From 4116094a0402fa3a8bbcf3939110a8c8bf77eec4 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:21:13 +0000 Subject: [PATCH 1/3] [fern-generated] Update SDK Generated by Fern CLI Version: unknown Generators: - fernapi/fern-typescript-sdk: 3.107.1 --- .shiprc | 6 - AUTH_MIGRATION_GUIDE.md | 14 - auth-migration/authentication-flows.md | 234 ---- auth-migration/index.md | 732 ---------- auth-migration/server-side-sessions.md | 163 --- auth-migration/troubleshooting.md | 32 - package.json | 11 - reference.md | 489 ++----- scripts/rename-to-esm-files.js | 65 + src/management/BaseClient.ts | 20 + src/management/api/requests/requests.ts | 42 +- .../api/resources/actions/client/Client.ts | 42 +- .../resources/executions/client/Client.ts | 4 +- .../resources/modules/client/Client.ts | 53 +- .../resources/versions/client/Client.ts | 23 +- .../resources/triggers/client/Client.ts | 2 + .../resources/bindings/client/Client.ts | 22 +- .../resources/versions/client/Client.ts | 26 +- .../api/resources/agents/client/Client.ts | 21 +- .../anomaly/resources/blocks/client/Client.ts | 8 +- .../attackProtection/client/Client.ts | 6 - .../resources/botDetection/client/Client.ts | 7 +- .../client/Client.ts | 7 +- .../bruteForceProtection/client/Client.ts | 7 +- .../resources/captcha/client/Client.ts | 7 +- .../captchaPolicies/client/Client.ts | 455 ------ .../resources/captchaPolicies/client/index.ts | 1 - .../resources/captchaPolicies/exports.ts | 4 - .../resources/captchaPolicies/index.ts | 1 - .../attackProtection/resources/index.ts | 1 - .../phoneProviderProtection/client/Client.ts | 7 +- .../suspiciousIpThrottling/client/Client.ts | 7 +- .../api/resources/branding/client/Client.ts | 7 +- .../resources/providers/client/Client.ts | 27 +- .../resources/templates/client/Client.ts | 33 +- .../resources/templates/client/Client.ts | 9 +- .../resources/themes/client/Client.ts | 21 +- .../resources/clientGrants/client/Client.ts | 23 +- .../resources/organizations/client/Client.ts | 4 +- .../resources/clientProfiles/client/Client.ts | 21 +- .../api/resources/clients/client/Client.ts | 46 +- .../resources/connections/client/Client.ts | 4 +- .../resources/credentials/client/Client.ts | 25 +- .../connectionProfiles/client/Client.ts | 27 +- .../resources/connections/client/Client.ts | 25 +- .../resources/clients/client/Client.ts | 11 +- .../directoryProvisioning/client/Client.ts | 49 +- .../synchronizations/client/Client.ts | 4 +- .../resources/keys/client/Client.ts | 17 +- .../scimConfiguration/client/Client.ts | 27 +- .../resources/tokens/client/Client.ts | 15 +- .../resources/users/client/Client.ts | 4 +- .../resources/customDomains/client/Client.ts | 35 +- .../deviceCredentials/client/Client.ts | 22 +- .../resources/emailTemplates/client/Client.ts | 21 +- .../resources/provider/client/Client.ts | 13 +- .../resources/eventStreams/client/Client.ts | 27 +- .../resources/deliveries/client/Client.ts | 8 +- .../resources/redeliveries/client/Client.ts | 11 +- .../api/resources/events/client/Client.ts | 37 + .../resources/experiments/client/Client.ts | 34 +- .../resources/featureFlags/client/Client.ts | 21 +- .../resources/variations/client/Client.ts | 25 +- .../resources/segments/client/Client.ts | 21 +- .../api/resources/flows/client/Client.ts | 32 +- .../resources/executions/client/Client.ts | 12 +- .../resources/connections/client/Client.ts | 32 +- .../api/resources/forms/client/Client.ts | 32 +- .../api/resources/groups/client/Client.ts | 10 +- .../groups/resources/members/client/Client.ts | 4 +- .../groups/resources/roles/client/Client.ts | 17 +- .../api/resources/guardian/client/Client.ts | 7 +- .../resources/enrollments/client/Client.ts | 13 +- .../resources/factors/client/Client.ts | 11 +- .../duo/resources/settings/client/Client.ts | 11 +- .../factors/resources/email/client/Client.ts | 7 +- .../factors/resources/phone/client/Client.ts | 31 +- .../pushNotification/client/Client.ts | 43 +- .../factors/resources/sms/client/Client.ts | 19 +- .../resources/policies/client/Client.ts | 7 +- .../api/resources/hooks/client/Client.ts | 32 +- .../hooks/resources/secrets/client/Client.ts | 23 +- .../api/resources/jobs/client/Client.ts | 4 +- .../jobs/resources/errors/client/Client.ts | 4 +- .../resources/usersExports/client/Client.ts | 5 +- .../resources/usersImports/client/Client.ts | 2 + .../verificationEmail/client/Client.ts | 5 +- .../resources/customSigning/client/Client.ts | 9 +- .../resources/encryption/client/Client.ts | 38 +- .../resources/networkAcls/client/Client.ts | 15 +- .../keys/resources/signing/client/Client.ts | 12 +- .../api/resources/logStreams/client/Client.ts | 21 +- .../api/resources/logs/client/Client.ts | 17 +- .../resources/networkAcls/client/Client.ts | 38 +- .../resources/organizations/client/Client.ts | 27 +- .../resources/clientGrants/client/Client.ts | 26 +- .../resources/clients/client/Client.ts | 27 +- .../resources/connections/client/Client.ts | 36 +- .../discoveryDomains/client/Client.ts | 29 +- .../enabledConnections/client/Client.ts | 36 +- .../resources/groups/client/Client.ts | 4 +- .../groups/resources/roles/client/Client.ts | 17 +- .../resources/invitations/client/Client.ts | 30 +- .../resources/members/client/Client.ts | 17 +- .../resources/effectiveRoles/client/Client.ts | 4 +- .../sources/resources/groups/client/Client.ts | 4 +- .../members/resources/roles/client/Client.ts | 28 +- .../roles/resources/groups/client/Client.ts | 4 +- .../roles/resources/members/client/Client.ts | 4 +- .../api/resources/prompts/client/Client.ts | 7 +- .../resources/customText/client/Client.ts | 11 +- .../resources/partials/client/Client.ts | 11 +- .../resources/rendering/client/Client.ts | 28 +- .../rateLimitPolicies/client/Client.ts | 21 +- .../resources/refreshTokens/client/Client.ts | 21 +- .../resourceServers/client/Client.ts | 34 +- .../resources/settings/client/Client.ts | 7 +- .../resources/newDevice/client/Client.ts | 7 +- .../api/resources/roles/client/Client.ts | 32 +- .../roles/resources/groups/client/Client.ts | 17 +- .../resources/permissions/client/Client.ts | 28 +- .../roles/resources/users/client/Client.ts | 11 +- .../api/resources/rules/client/Client.ts | 32 +- .../resources/rulesConfigs/client/Client.ts | 13 +- .../selfServiceProfiles/client/Client.ts | 32 +- .../resources/customText/client/Client.ts | 11 +- .../resources/ssoTicket/client/Client.ts | 11 +- .../api/resources/sessions/client/Client.ts | 19 +- .../api/resources/stats/client/Client.ts | 4 + .../supplementalSignals/client/Client.ts | 7 +- .../resources/settings/client/Client.ts | 7 +- .../api/resources/tickets/client/Client.ts | 9 +- .../tokenExchangeProfiles/client/Client.ts | 21 +- .../userAttributeProfiles/client/Client.ts | 27 +- .../api/resources/userBlocks/client/Client.ts | 12 +- .../api/resources/userGrants/client/Client.ts | 19 +- .../api/resources/users/client/Client.ts | 44 +- .../authenticationMethods/client/Client.ts | 46 +- .../resources/authenticators/client/Client.ts | 4 +- .../connectedAccounts/client/Client.ts | 4 +- .../effectivePermissions/client/Client.ts | 4 +- .../sources/resources/roles/client/Client.ts | 4 +- .../resources/effectiveRoles/client/Client.ts | 4 +- .../sources/resources/groups/client/Client.ts | 4 +- .../resources/enrollments/client/Client.ts | 4 +- .../users/resources/groups/client/Client.ts | 4 +- .../resources/identities/client/Client.ts | 11 +- .../users/resources/logs/client/Client.ts | 15 +- .../resources/multifactor/client/Client.ts | 8 +- .../resources/organizations/client/Client.ts | 15 +- .../resources/permissions/client/Client.ts | 28 +- .../resources/refreshToken/client/Client.ts | 8 +- .../riskAssessments/client/Client.ts | 7 +- .../users/resources/roles/client/Client.ts | 28 +- .../users/resources/sessions/client/Client.ts | 8 +- .../resources/templates/client/Client.ts | 21 +- src/management/api/types/types.ts | 287 ++-- src/management/core/fetcher/Fetcher.ts | 151 +- src/management/core/fetcher/Headers.ts | 8 +- .../core/fetcher/getErrorResponseBody.ts | 29 +- .../core/fetcher/getResponseBody.ts | 56 +- .../core/fetcher/makePassthroughRequest.ts | 79 +- src/management/core/fetcher/makeRequest.ts | 57 +- src/management/core/fetcher/redactUrl.ts | 102 ++ .../core/fetcher/requestWithRetries.ts | 25 +- src/management/core/fetcher/signals.ts | 2 +- src/management/core/file/file.ts | 5 + .../core/form-data-utils/FormDataWrapper.ts | 5 + src/management/core/requestBody.ts | 26 + src/management/core/runtime/index.ts | 2 +- src/management/core/runtime/runtime.ts | 97 ++ src/management/core/stream/Stream.ts | 406 +++++- src/management/core/stream/index.ts | 1 + src/management/core/url/encodePathParam.ts | 13 +- src/management/core/url/qs.ts | 4 +- .../core/utils/setObjectProperty.ts | 25 +- src/management/errors/ManagementError.ts | 18 + .../errors/ManagementTimeoutError.ts | 12 +- src/management/tests/mock-server/withJson.ts | 45 +- .../tests/unit/fetcher/Fetcher.test.ts | 195 +++ .../unit/fetcher/createRequestUrl.test.ts | 2 +- .../unit/fetcher/getResponseBody.test.ts | 14 +- .../fetcher/makePassthroughRequest.test.ts | 144 ++ .../tests/unit/fetcher/makeRequest.test.ts | 64 +- .../unit/fetcher/requestWithRetries.test.ts | 41 + src/management/tests/unit/file/file.test.ts | 14 + .../encodeAsFormParameter.test.ts | 2 - .../tests/unit/stream/Stream.test.ts | 1221 +++++++++++++++-- .../tests/unit/url/encodePathParam.test.ts | 46 + src/management/tests/unit/url/qs.test.ts | 4 +- .../unit/utils/setObjectProperty.test.ts | 36 + src/management/tests/wire/actions.test.ts | 32 +- .../tests/wire/actions/modules.test.ts | 42 +- .../wire/actions/modules/versions.test.ts | 10 +- .../wire/actions/triggers/bindings.test.ts | 8 +- .../tests/wire/actions/versions.test.ts | 8 +- .../attackProtection/captchaPolicies.test.ts | 728 ---------- src/management/tests/wire/clients.test.ts | 32 +- .../tests/wire/deviceCredentials.test.ts | 8 +- .../wire/experimentation/experiments.test.ts | 16 + src/management/tests/wire/flows.test.ts | 32 +- .../wire/flows/vault/connections.test.ts | 8 +- src/management/tests/wire/forms.test.ts | 32 +- src/management/tests/wire/hooks.test.ts | 40 +- .../tests/wire/keys/encryption.test.ts | 32 +- src/management/tests/wire/logs.test.ts | 32 +- src/management/tests/wire/networkAcls.test.ts | 32 +- .../wire/organizations/clientGrants.test.ts | 8 +- .../wire/organizations/connections.test.ts | 8 +- .../organizations/enabledConnections.test.ts | 10 +- .../wire/organizations/invitations.test.ts | 10 +- .../wire/organizations/members/roles.test.ts | 10 +- .../tests/wire/prompts/rendering.test.ts | 40 +- .../tests/wire/resourceServers.test.ts | 32 +- src/management/tests/wire/roles.test.ts | 32 +- .../tests/wire/roles/permissions.test.ts | 10 +- src/management/tests/wire/rules.test.ts | 40 +- .../tests/wire/selfServiceProfiles.test.ts | 8 +- src/management/tests/wire/userGrants.test.ts | 24 +- src/management/tests/wire/users.test.ts | 40 +- .../wire/users/authenticationMethods.test.ts | 10 +- src/management/tests/wire/users/logs.test.ts | 32 +- .../tests/wire/users/organizations.test.ts | 10 +- .../tests/wire/users/permissions.test.ts | 10 +- src/management/tests/wire/users/roles.test.ts | 40 +- v6_MIGRATION_GUIDE.md | 158 --- v7_MIGRATION_GUIDE.md | 146 -- yarn.lock | 102 +- 228 files changed, 4953 insertions(+), 4886 deletions(-) delete mode 100644 .shiprc delete mode 100644 AUTH_MIGRATION_GUIDE.md delete mode 100644 auth-migration/authentication-flows.md delete mode 100644 auth-migration/index.md delete mode 100644 auth-migration/server-side-sessions.md delete mode 100644 auth-migration/troubleshooting.md delete mode 100644 src/management/api/resources/attackProtection/resources/captchaPolicies/client/Client.ts delete mode 100644 src/management/api/resources/attackProtection/resources/captchaPolicies/client/index.ts delete mode 100644 src/management/api/resources/attackProtection/resources/captchaPolicies/exports.ts delete mode 100644 src/management/api/resources/attackProtection/resources/captchaPolicies/index.ts create mode 100644 src/management/core/fetcher/redactUrl.ts create mode 100644 src/management/core/requestBody.ts create mode 100644 src/management/tests/unit/url/encodePathParam.test.ts delete mode 100644 src/management/tests/wire/attackProtection/captchaPolicies.test.ts delete mode 100644 v6_MIGRATION_GUIDE.md delete mode 100644 v7_MIGRATION_GUIDE.md diff --git a/.shiprc b/.shiprc deleted file mode 100644 index d1791e98e5..0000000000 --- a/.shiprc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "files": { - ".version": [], - "src/management/version.ts": [] - } -} diff --git a/AUTH_MIGRATION_GUIDE.md b/AUTH_MIGRATION_GUIDE.md deleted file mode 100644 index 64626f8067..0000000000 --- a/AUTH_MIGRATION_GUIDE.md +++ /dev/null @@ -1,14 +0,0 @@ -# Authentication Migration Guide - -This guide lives in the [`auth-migration/`](./auth-migration/) directory. - -**→ Start here: [`auth-migration/index.md`](./auth-migration/index.md)**: migrate your authentication code off the `auth0` package to [`@auth0/auth0-auth-js`](https://github.com/auth0/auth0-auth-js) (stateless token grants) or [`@auth0/auth0-server-js`](https://github.com/auth0/auth0-auth-js/tree/main/packages/auth0-server-js) (server-managed sessions). - -The directory contains: - -- [`auth-migration/index.md`](./auth-migration/index.md): the main guide covering OIDC token grants and the four cross-cutting breaking changes. -- [`auth-migration/authentication-flows.md`](./auth-migration/authentication-flows.md): database, passwordless, backchannel (CIBA), token exchange, and `UserInfoClient`. -- [`auth-migration/server-side-sessions.md`](./auth-migration/server-side-sessions.md): the `@auth0/auth0-server-js` session layer. -- [`auth-migration/troubleshooting.md`](./auth-migration/troubleshooting.md): FAQ and gotchas. - -> **Migrating with an AI agent?** Point it at the Auth0 migration skill: the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`. diff --git a/auth-migration/authentication-flows.md b/auth-migration/authentication-flows.md deleted file mode 100644 index 6f7bace2a1..0000000000 --- a/auth-migration/authentication-flows.md +++ /dev/null @@ -1,234 +0,0 @@ -# Migrating the other authentication flows - -This is the incremental part of the [Authentication Migration Guide](./index.md). Start with the guide's [OIDC token grants](./index.md#oidc-token-grants) and cross-cutting breaking changes before you touch anything here. Everything below builds on those changes, so apply them to every rewrite on this page too. - -> **Migrating with an AI agent?** Point it at the Auth0 migration skill (the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`). - -Migrate one flow at a time. Only the flows your app actually uses need attention; skip the rest. - -- [Database connections](#database-connections) -- [Passwordless](#passwordless) -- [Backchannel authentication (CIBA)](#backchannel-authentication-ciba) -- [Token exchange (RFC 8693)](#token-exchange-rfc-8693) -- [UserInfoClient](#userinfoclient) -- [Quick lookup table](#quick-lookup-table) - -Unless a row routes explicitly to `@auth0/auth0-server-js`, the replacement lives on the `@auth0/auth0-auth-js` `AuthClient` (or a sub-client: `authClient.database`, `authClient.passwordless`, `authClient.mfa`, `authClient.passkey`). - -## Database connections - -Database connection operations move to the `authClient.database` sub-client. Names and required parameters stay the same; only casing and return shape change. - -### `database.signUp` → `authClient.database.signUp` - -```ts -// before -const resp = await auth0.database.signUp({ - email, - password, - connection: "Username-Password-Authentication", - given_name: "Ada", - family_name: "Lovelace", - user_metadata: { plan: "free" }, -}); -const userId = resp.data.id; -// after -const result = await authClient.database.signUp({ - email, - password, - connection: "Username-Password-Authentication", - givenName: "Ada", - familyName: "Lovelace", - userMetadata: { plan: "free" }, -}); -const userId = result.id; -``` - -> ID normalization is preserved: node-auth0 mapped the server's `_id | user_id | id` onto a single `id`. The new SDK does the same, so `result.id` is always present. Do not add your own `_id` fallback. - -### `database.changePassword` → `authClient.database.changePassword` - -node-auth0 returned a `TextApiResponse` (read via `.data`); the new SDK returns the plain `string` directly. - -```ts -// before -const resp = await auth0.database.changePassword({ email, connection: "Username-Password-Authentication" }); -const message = resp.data; // plain-text confirmation -// after -const message = await authClient.database.changePassword({ email, connection: "Username-Password-Authentication" }); -``` - -> `changePassword` requires `connection` plus at least one of `email` or `username`: either identifier is accepted, not `email` alone. - -## Passwordless - -node-auth0 lumped "start" (send the code or link) and "login" (redeem the code) onto one sub-client. The new SDK splits them: starting stays on `authClient.passwordless`; redeeming a code becomes a top-level grant method on `AuthClient`. - -### `passwordless.sendEmail` → `authClient.passwordless.sendEmail` - -```ts -// before -await auth0.passwordless.sendEmail({ email, send: "code" }); -// after -await authClient.passwordless.sendEmail({ email, send: "code" }); -``` - -> Default changed: node-auth0 defaulted `send` to `'link'` (magic link). The new SDK defaults `send` to `'code'` (one-time password). If you relied on the implicit default to send magic links, set `send: 'link'` explicitly. - -### `passwordless.sendSMS` → `authClient.passwordless.sendSms` - -Note the casing change: `sendSMS` → `sendSms`, and `phone_number` → `phoneNumber`. - -```ts -// before -await auth0.passwordless.sendSMS({ phone_number: "+15551234567" }); -// after -await authClient.passwordless.sendSms({ phoneNumber: "+15551234567" }); -``` - -### `passwordless.loginWithEmail` → `getTokenByPasswordlessEmail` - -Redeeming the one-time password is now a grant method on `AuthClient`, not on the passwordless sub-client. - -```ts -// before -const resp = await auth0.passwordless.loginWithEmail({ email, code, audience, scope }); -const token = resp.data.access_token; -// after -const tokens = await authClient.getTokenByPasswordlessEmail({ email, code, audience, scope }); -const token = tokens.accessToken; -``` - -### `passwordless.loginWithSMS` → `getTokenByPasswordlessSms` - -```ts -// before -const resp = await auth0.passwordless.loginWithSMS({ phone_number, code }); -// after -const tokens = await authClient.getTokenByPasswordlessSms({ phoneNumber, code }); -``` - -> Session apps: `@auth0/auth0-server-js` exposes `startPasswordless` / `completePasswordless` / `completePasswordlessMagicLink`, which both send the code and establish a session. Use those instead of the two-step auth-js flow when the SDK owns the session. See [Migrating session apps](./server-side-sessions.md). - -## Backchannel authentication (CIBA) - -CIBA is Client-Initiated Backchannel Authentication. - -### `backchannel.authorize` → `initiateBackchannelAuthentication` - -```ts -// before -const resp = await auth0.backchannel.authorize({ - binding_message: "ABC123", - scope: "openid", - userId: "auth0|123", -}); -const authReqId = resp.auth_req_id; -// after -const { authReqId, expiresIn, interval } = await authClient.initiateBackchannelAuthentication({ - bindingMessage: "ABC123", - loginHint: { sub: "auth0|123" }, // login_hint is an object with `sub`, not a bare string - authorizationParams: { scope: "openid" }, // scope goes here, NOT as a top-level key -}); -``` - -### `backchannel.backchannelGrant` → `backchannelAuthenticationGrant` - -```ts -// before -const resp = await auth0.backchannel.backchannelGrant({ auth_req_id: authReqId }); -// after -const tokens = await authClient.backchannelAuthenticationGrant({ authReqId }); -``` - -> One-shot convenience: `authClient.backchannelAuthentication({ ... })` initiates and polls to completion, returning a `TokenResponse`. Use it if your code did the initiate-then-poll loop by hand. -> -> Session apps: for CIBA that also establishes a session, see [Migrating session apps](./server-side-sessions.md). - -## Token exchange (RFC 8693) - -```ts -// before -const resp = await auth0.tokenExchange.exchangeToken({ - subject_token_type: "urn:example:custom", - subject_token: token, - audience: "https://api.example.com", - scope: "read", -}); -// after -const tokens = await authClient.exchangeToken({ - subjectTokenType: "urn:example:custom", - subjectToken: token, - audience: "https://api.example.com", - scope: "read", -}); -``` - -> `exchangeToken` is overloaded: a custom-exchange profile shape (`subjectTokenType` + `subjectToken` + `audience`) and a Token Vault shape (`connection` present). Presence of `connection` routes to the vault path. The custom-exchange profile is the RFC 8693 replacement for `tokenExchange.exchangeToken`. -> -> Session apps: `@auth0/auth0-server-js` exposes `loginWithCustomTokenExchange` (exchange, then establish a session) and `customTokenExchange` (exchange, then return tokens with no session). - -## UserInfoClient - -The standalone `UserInfoClient` from node-auth0 does not exist in the new SDK. Choose the replacement based on what the app needs: - -| Your intent | Replacement | -| --- | --- | -| Wanted user profile claims right after login | Read `TokenResponse.claims` from the grant result; the SDK already decodes the ID token. No extra `/userinfo` round-trip needed. **Preferred.** | -| Wanted a live `/userinfo` response for an arbitrary access token | `await authClient.getUserInfo({ accessToken })`, a direct method on `AuthClient`. | -| Wanted the profile in a server-rendered app with a session | `await serverClient.getUser()` returns the stored user claims from the session. | - -**Before (node-auth0):** - -```ts -import { UserInfoClient } from "auth0"; -const userInfo = new UserInfoClient({ domain }); -const resp = await userInfo.getUserInfo(accessToken); -const profile = resp.data; // { sub, name, email, ... } -``` - -**After (preferred): use the claims you already have:** - -```ts -const tokens = await authClient.getTokenByCode(callbackUrl, {}); -const profile = tokens.claims; // { sub, name, email, ... } decoded from the id_token -``` - -**After (direct method):** for when you only have an access token: - -```ts -// Takes an options object: { accessToken, expectedSubject? } -const profile = await authClient.getUserInfo({ accessToken }); -``` - -> Prefer reading `claims` over any `/userinfo` call: it avoids a network round-trip and the claims are already validated by the SDK. - -## Quick lookup table - -The complete node-auth0 → new SDK map, including the OIDC methods covered in the main guide. - -| node-auth0 | new SDK equivalent | Layer | -| --- | --- | --- | -| `oauth.authorizationCodeGrant` | `authClient.getTokenByCode(url, opts)` | auth-js | -| `oauth.authorizationCodeGrantWithPKCE` | `authClient.getTokenByCode(url, { codeVerifier })` | auth-js | -| `oauth.refreshTokenGrant` | `authClient.getTokenByRefreshToken({ refreshToken })` | auth-js | -| `oauth.passwordGrant` | `authClient.getTokenByPassword({ ... })` | auth-js | -| `oauth.clientCredentialsGrant` | `authClient.getTokenByClientCredentials({ audience })` | auth-js | -| `oauth.revokeRefreshToken` | `authClient.revokeToken({ token })` / `serverClient.revokeRefreshToken()` | auth-js / server-js | -| `oauth.tokenForConnection` | `authClient.exchangeToken({ connection, ... })` | auth-js | -| `oauth.pushedAuthorization` | `authClient.buildAuthorizationUrl({ pushedAuthorizationRequests: true })` | auth-js | -| `database.signUp` | `authClient.database.signUp({ ... })` | auth-js | -| `database.changePassword` | `authClient.database.changePassword({ ... })` | auth-js | -| `passwordless.sendEmail` | `authClient.passwordless.sendEmail({ ... })` | auth-js | -| `passwordless.sendSMS` | `authClient.passwordless.sendSms({ phoneNumber })` | auth-js | -| `passwordless.loginWithEmail` | `authClient.getTokenByPasswordlessEmail({ ... })` | auth-js | -| `passwordless.loginWithSMS` | `authClient.getTokenByPasswordlessSms({ ... })` | auth-js | -| `backchannel.authorize` | `authClient.initiateBackchannelAuthentication({ ... })` | auth-js | -| `backchannel.backchannelGrant` | `authClient.backchannelAuthenticationGrant({ authReqId })` | auth-js | -| `tokenExchange.exchangeToken` | `authClient.exchangeToken({ subjectTokenType, subjectToken, audience })` | auth-js | -| `UserInfoClient.getUserInfo` | `TokenResponse.claims` (preferred) / `authClient.getUserInfo({ accessToken })` / `serverClient.getUser()` | auth-js / server-js | -| (no equivalent): build `/authorize` URL | `authClient.buildAuthorizationUrl({ ... })` | auth-js | -| (no equivalent): build `/v2/logout` URL | `authClient.buildLogoutUrl({ returnTo })` | auth-js | -| `ManagementClient.*` | **not migrated, stays on `auth0`** | n/a | - -When you finish a flow, return to the [verification checklist](./index.md#verification-checklist) and confirm the four cross-cutting changes for every call site you touched. diff --git a/auth-migration/index.md b/auth-migration/index.md deleted file mode 100644 index 85a11c45c7..0000000000 --- a/auth-migration/index.md +++ /dev/null @@ -1,732 +0,0 @@ -# Authentication Migration Guide - -A guide to migrating your authentication code off the `auth0` package (node-auth0) to the modern Auth0 server SDKs: [`@auth0/auth0-auth-js`](https://github.com/auth0/auth0-auth-js) for stateless token grants, and [`@auth0/auth0-server-js`](https://github.com/auth0/auth0-auth-js/tree/main/packages/auth0-server-js) for server-managed sessions. - -> **Migrating with an AI agent?** Point it at the Auth0 migration skill first. The skill lives in [`auth0/agent-skills`](https://github.com/auth0/agent-skills) as the `auth0` skill (migration intent: `migrate-node-auth0`). It encodes the target-SDK routing, the four cross-cutting breaking changes, the method-by-method mapping, and a build-until-green verify loop. - -## Contents - -- [How to use this guide](#how-to-use-this-guide) -- [Overview](#overview) - - [Who this is for](#who-this-is-for) - - [Scope](#scope) -- [Choosing your target SDK](#choosing-your-target-sdk) -- [Prerequisites](#prerequisites) -- [Installation and constructor mapping](#installation-and-constructor-mapping) -- [OIDC token grants](#oidc-token-grants) - - [Optional: migrate only OIDC while staying on v6](#optional-migrate-only-oidc-while-staying-on-v6) -- [Cross-cutting breaking changes](#cross-cutting-breaking-changes) - - [1. Return shape](#1-return-shape) - - [2. Casing](#2-casing) - - [3. Token expiry](#3-token-expiry) - - [4. Error model](#4-error-model) -- [Verification checklist](#verification-checklist) -- [Continue the migration](#continue-the-migration) - - [Other authentication flows](#other-authentication-flows) - - [Server-side sessions](#server-side-sessions) - - [Troubleshooting](#troubleshooting) - -## How to use this guide - -This is a reference, not a linear read. You do not have to work through it top to bottom; migrate only the flows your app actually uses, in whatever order suits you. Most apps finish after the [OIDC token grants](#oidc-token-grants) section. - -The work falls into three phases: - -| Phase | What you do | Where | -| --- | --- | --- | -| **Before**: orient and set up | Pick your target SDK, check prerequisites, install the package, map constructor options. | [Choosing your target SDK](#choosing-your-target-sdk), [Prerequisites](#prerequisites), [Installation and constructor mapping](#installation-and-constructor-mapping) | -| **During**: rewrite call sites | Rewrite the OIDC token grants (in this file), then the other flows and the session layer as needed. Apply the four cross-cutting breaking changes to every call site. | [OIDC token grants](#oidc-token-grants), [Cross-cutting breaking changes](#cross-cutting-breaking-changes), [`authentication-flows.md`](./authentication-flows.md), [`server-side-sessions.md`](./server-side-sessions.md) | -| **After**: verify | Run the build-until-green checklist; confirm no residue and that `ManagementClient` code is untouched. | [Verification checklist](#verification-checklist) | - -Suggested order: start with the OIDC grants and cross-cutting changes (the whole job for most apps), then the [other flows](./authentication-flows.md) you actually use, then [session apps](./server-side-sessions.md) if you want the SDK to own sessions. Stuck? See [`troubleshooting.md`](./troubleshooting.md). - -## Overview - -node-auth0's `AuthenticationClient` is a stateless HTTP client. Every method is a single call to an Auth0 Authentication API endpoint that returns a response object. It has no notion of a logged-in user, no session, no cookie, no token store, and no automatic refresh. Anything stateful in a node-auth0 app (persisting tokens, deciding when to refresh, tracking the login across requests) was written by you *around* node-auth0. - -The modern stack splits those two concerns into two packages: - -- `@auth0/auth0-auth-js` is the stateless token layer. It is the direct successor to `AuthenticationClient`: the same "one method equals one API call equals one result" model, with modern ergonomics (camelCase, typed errors, direct return values, per-request options). -- `@auth0/auth0-server-js` is a stateful session layer built on top of auth0-auth-js. It owns the login redirect flow, a pluggable state/transaction store, cookie handling, automatic token refresh, and logout. It is the successor to the *session code you hand-rolled*, not to `AuthenticationClient` itself. - -### Who this is for - -You are running a Node.js backend that imports the `auth0` package and calls `AuthenticationClient` (or `UserInfoClient`) to perform token grants, database signup, passwordless, CIBA, token exchange, or userinfo lookups. You want to move that code to the current first-party server SDKs. This is a surgical rewrite of the authentication layer: routes, controllers, business logic, data access, and framework wiring stay as they are. You touch the smallest possible surface: the files that import and call node-auth0's Authentication API. - -### Scope - -In scope: - -- `AuthenticationClient` and its sub-clients: `.oauth`, `.database`, `.passwordless`, `.backchannel`, `.tokenExchange` -- `UserInfoClient` -- The auth error types (`AuthApiError`) and token-validation types (`IDTokenValidateOptions`, `IdTokenValidatorError`) - -Out of scope, do not touch: - -- `ManagementClient` (Management API v2). It is not being migrated and stays on the `auth0` package. -- Application routes, view/controller logic, database code, and any non-auth use of the `auth0` package. - -> If a file uses `ManagementClient`, leave that code alone. Only rewrite the `AuthenticationClient` / `UserInfoClient` parts. - -## Choosing your target SDK - -The routing question is: do you want to keep owning your session, or hand that responsibility to the SDK? - -### Decision table - -| If your code… | Migrate to | Why | -| --- | --- | --- | -| Only performs token grants / DB signup / passwordless / userinfo and manages its own session (or is a machine-to-machine service backend) | `@auth0/auth0-auth-js` | Direct, near 1:1 replacement for `AuthenticationClient`. Same stateless model. | -| Wants the SDK to own the login redirect flow, session storage, cookies, token refresh, and logout (a server-rendered web app) | `@auth0/auth0-server-js` | Adds a session layer node-auth0 never had. This is a rewrite of the session handling, not a method-for-method port. | - -**Default recommendation:** start with `@auth0/auth0-auth-js` for a faithful parity migration. Choose `@auth0/auth0-server-js` only when you currently hand-roll session/cookie/refresh logic around node-auth0 and would benefit from the SDK owning it. - -### Signals - -Signals that point to auth0-auth-js: - -- Predominant use is `clientCredentialsGrant` (machine-to-machine). There is no user, so there is no session to own. -- The app already has a session framework it is happy with and only calls node-auth0 for token grants. -- The app is an API, worker, or CLI, not a browser-facing web server. -- You want the smallest, most mechanical, lowest-risk migration. - -Signals that point to auth0-server-js: - -- The app performs a browser redirect login and reads `req.session.user` (or equivalent) on later requests. -- You wrote refresh-on-expiry logic, a token cache, or logout-with-revocation by hand. -- You use `express-openid-connect` today and want a first-party, framework-agnostic replacement. -- You are on a server framework (Express, Fastify, Hono, Next.js) and want the SDK to manage cookies. - -### Mixing both - -A single app can use both: auth0-server-js for the user-facing login/session, and auth0-auth-js directly for a separate machine-to-machine `clientCredentialsGrant` to call another API. `ServerClient` even exposes the underlying `AuthClient` via `serverClient.authClient` for occasional low-level needs. Do not force everything onto one package. - -## Prerequisites - -### Node.js version - -Both target SDKs need Node.js 20 LTS or newer. Verify the project's runtime before installing. - -### SDK versions - -- `@auth0/auth0-auth-js` >= `1.13.0` -- `@auth0/auth0-server-js` >= `1.13.0` - -Both are published on npm; install the current `latest`. `1.13.0` is the floor for the full API surface used in this guide (`getUserInfo`, per-request `RequestOptions`, and `fullResponse`). - -## Installation and constructor mapping - -Add the target package: - -```bash -# auth-js target (stateless token grants) -npm install @auth0/auth0-auth-js - -# server-js target (server-managed sessions), pulls in auth0-auth-js transitively -npm install @auth0/auth0-server-js -``` - -Keep the `auth0` package installed if the app still uses `ManagementClient`. - -### Imports - -```ts -// before -import { AuthenticationClient, UserInfoClient, AuthApiError } from "auth0"; - -// after: auth-js target -import { AuthClient, TokenByCodeError, isMfaRequiredError } from "@auth0/auth0-auth-js"; - -// after: server-js target -import { ServerClient } from "@auth0/auth0-server-js"; -``` - -> Keep the `auth0` import if the file also uses `ManagementClient`. It is correct for a file to import both `auth0` (for `ManagementClient`) and `@auth0/auth0-auth-js` (for authentication). Only remove the `auth0` import from files where it was used *solely* for `AuthenticationClient` / `UserInfoClient`. - -### AuthClient options - -The constructor options mostly carry over with camelCase names. A few are renamed or dropped. - -**Before (node-auth0):** - -```ts -new AuthenticationClient({ - domain: "tenant.us.auth0.com", - clientId: "...", - clientSecret: "...", // OR clientAssertionSigningKey - clientAssertionSigningKey: "...", - clientAssertionSigningAlg: "RS256", - idTokenSigningAlg: "RS256", // for manual id_token validation - clockTolerance: 60, // seconds, for validation - useMTLS: false, - telemetry: true, - headers: { "X-Custom": "..." }, // sent on every request - timeoutDuration: 10000, // ms - retry: { - /* ... */ - }, - agent: undiciDispatcher, - fetch: customFetch, - middleware: [ - /* ... */ - ], -}); -``` - -**After (auth0-auth-js):** - -```ts -import { AuthClient } from "@auth0/auth0-auth-js"; - -new AuthClient({ - domain: "tenant.us.auth0.com", // same (no scheme) - clientId: "...", // same - clientSecret: "...", // same - clientAssertionSigningKey: "...", // same (string | CryptoKey) - clientAssertionSigningAlg: "RS256", // same - authorizationParams: { - // NEW: default scope/audience/redirect_uri for URL builders - scope: "openid profile email", - audience: "https://api.example.com", - redirect_uri: "https://app.example.com/callback", - }, - useMtls: false, // RENAMED from useMTLS (lowercase tls) - customFetch: fetch, // RENAMED from fetch - telemetry: { - /* ... */ - }, // structured TelemetryConfig - discoveryCache: { ttl, maxEntries }, // NEW: OIDC discovery / JWKS cache -}); -``` - -Option-by-option: - -| node-auth0 | auth0-auth-js | Notes | -| --- | --- | --- | -| `domain` | `domain` | Unchanged. No `https://` scheme. | -| `clientId` | `clientId` | Unchanged. | -| `clientSecret` | `clientSecret` | Unchanged. | -| `clientAssertionSigningKey` | `clientAssertionSigningKey` | Unchanged. Now also accepts a `CryptoKey`. | -| `clientAssertionSigningAlg` | `clientAssertionSigningAlg` | Unchanged. | -| `useMTLS` | `useMtls` | Renamed (casing). | -| `fetch` | `customFetch` | Renamed. | -| `telemetry: boolean` | `telemetry: TelemetryConfig` | Now a structured object. | -| `headers` (global) | per-request `RequestOptions.headers` | Moved to per-request options; set per call site rather than globally. | -| `timeoutDuration` | per-request `RequestOptions.signal` | Use an `AbortSignal.timeout(ms)` on the call. | -| `retry` | configure via `customFetch` | Wrap your fetch with retry if needed. | -| `agent` | configure via `customFetch` | Set the dispatcher inside your custom fetch. | -| `middleware` | `customFetch` | Compose behavior in the fetch wrapper. | -| `idTokenSigningAlg` | (internal) | ID-token validation is internal; read `TokenResponse.claims`. | -| `clockTolerance` | (internal) | Handled internally during validation. | - -### ServerClient options - -`ServerClient` wraps an `AuthClient` and adds the session machinery. It shares the auth options and adds required stores. This constructor and the stores it needs are covered in [`server-side-sessions.md`](./server-side-sessions.md); reach for it only when you route to server-js. - -### Global config to per-request options - -node-auth0's global constructor options for `headers`, `timeoutDuration`, `agent`, `retry`, and `middleware` have no direct constructor equivalents in auth0-auth-js. Instead, the new SDK's methods accept a trailing `RequestOptions` parameter: - -```ts -import type { RequestOptions } from "@auth0/auth0-server-js"; // or '@auth0/auth0-auth-js' - -const tokens = await authClient.getTokenByClientCredentials( - { audience: "https://api.example.com" }, - { - headers: { "X-Custom": "value" }, - signal: AbortSignal.timeout(5000), // timeout in ms - } satisfies RequestOptions, -); -``` - -`@auth0/auth0-server-js` re-exports `RequestOptions`, `ApiResponse`, and `FullResponseOption` from `@auth0/auth0-auth-js`, so you can import any of them from either package. - -Arity rule: MFA methods (`authClient.mfa.*`) take `requestOptions` as the 2nd argument; store-first methods (session-owning methods on `serverClient`) take it as the 3rd argument after the store context; cache hits ignore it entirely. - -Common patterns: - -- Global headers: apply via `RequestOptions.headers` on each call that needs it, or wrap `customFetch` once to inject it everywhere. -- Timeout: replace `timeoutDuration: 10000` with `signal: AbortSignal.timeout(10000)` on the call. -- Agent (Node.js dispatcher): wrap `customFetch` to inject the agent into the underlying HTTP transport. -- Retry / middleware: compose behavior in a `customFetch` wrapper passed either at construction or per request. - -## OIDC token grants - -This is the core of the migration and, for most apps, the whole of it. These are the `AuthenticationClient.oauth.*` grants that drive OpenID Connect login and machine-to-machine token acquisition. All of them move onto the `AuthClient` instance directly (not a sub-client). - -Before you touch any method, internalize the four [cross-cutting breaking changes](#cross-cutting-breaking-changes); they apply to *every* rewrite here and on the incremental pages. - -Naming conventions used throughout: - -| node-auth0 | new SDKs | -| --- | --- | -| Params and response fields use the snake_case wire shape: `client_id`, `refresh_token`, `access_token`, `expires_in`, `phone_number` | camelCase: `clientId`, `refreshToken`, `accessToken`, `expiresAt`, `phoneNumber` | -| Methods take a `bodyParameters` object (+ optional `initOverrides`) | Methods take a single `options` object (+ optional trailing `RequestOptions` for per-request `signal`, `headers`, `customFetch`) | -| Every method returns a `JSONApiResponse` / `VoidApiResponse` / `TextApiResponse` wrapper | Methods return the domain object directly (`TokenResponse`, `SignUpResult`, `string`, `void`) | - -### `oauth.authorizationCodeGrant` → `getTokenByCode` - -The single most important semantic change in the whole migration. In node-auth0 you pass the raw authorization `code` (and `redirect_uri`) that you extracted from the callback query string yourself. In auth0-auth-js you pass the entire callback `URL`; the SDK extracts `code` and enforces PKCE, and `redirect_uri` comes from the `AuthClient` config / `authorizationParams`. The stateless `AuthClient` does **not** validate OAuth `state` — that is your responsibility (or use `@auth0/auth0-server-js` `completeInteractiveLogin`, which owns a transaction store and validates `state` for you). - -**Before (node-auth0):** - -```ts -import { AuthenticationClient } from "auth0"; - -const auth0 = new AuthenticationClient({ domain, clientId, clientSecret }); - -// You parsed `code` out of the callback URL yourself. -const resp = await auth0.oauth.authorizationCodeGrant({ - code, - redirect_uri: "https://app.example.com/callback", -}); -const accessToken = resp.data.access_token; -const expiresIn = resp.data.expires_in; // relative seconds -const reqId = resp.headers.get("x-request-id"); // metadata on success -``` - -**After (auth0-auth-js):** - -```ts -import { AuthClient } from "@auth0/auth0-auth-js"; - -const authClient = new AuthClient({ domain, clientId, clientSecret }); - -// `url` is a URL object for the full incoming request URL, -// e.g. new URL(req.url, `https://${req.headers.host}`) -const tokens = await authClient.getTokenByCode(url, { - // options; e.g. codeVerifier (PKCE) or organization -}); -const accessToken = tokens.accessToken; -const expiresAt = tokens.expiresAt; // absolute Unix seconds -``` - -> If your code manually parses `req.query.code`, that parsing is now the SDK's job. Delete it and hand the SDK the full URL. The SDK reads `code` from the URL and validates the PKCE verifier; it does **not** validate OAuth `state`. **Keep your existing `state` check** (compare the `state` query parameter against what you stored before the redirect) — or migrate to `@auth0/auth0-server-js` `completeInteractiveLogin`, which handles `state` validation automatically. (`getTokenByCode` options are `codeVerifier` and `organization`.) If the node-auth0 code read `resp.headers.get(...)` on success, see [Reading HTTP response metadata](#reading-http-response-metadata-fullresponse). Error-path metadata remains accessible on the typed error. - -> **Warning:** Do not delete your `state`/CSRF check when migrating to `AuthClient.getTokenByCode`. The stateless client does not validate `state`. Removing the check silently disables CSRF protection on the authorization-code flow. - -### `oauth.authorizationCodeGrantWithPKCE` → `getTokenByCode` (with verifier) - -PKCE (Proof Key for Code Exchange) is folded into the same method; supply the code verifier via options. Typically the verifier was produced earlier by `buildAuthorizationUrl` (below), which returns a `codeVerifier` for you to persist. - -```ts -// before -const resp = await auth0.oauth.authorizationCodeGrantWithPKCE({ - code, - code_verifier: verifier, - redirect_uri: "https://app.example.com/callback", -}); - -// after -const tokens = await authClient.getTokenByCode(url, { - codeVerifier: verifier, -}); -``` - -> If you build the authorization URL yourself today, prefer switching to `authClient.buildAuthorizationUrl()` (below) so the SDK generates and returns the `codeVerifier`, then persist it and pass it back to `getTokenByCode`. - -### `oauth.refreshTokenGrant` → `getTokenByRefreshToken` - -```ts -// before -const resp = await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); -// after -const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); -``` - -### `oauth.passwordGrant` → `getTokenByPassword` - -```ts -// before -const resp = await auth0.oauth.passwordGrant({ - username, - password, - realm: "Username-Password-Authentication", - audience, - scope, -}); -// after -const tokens = await authClient.getTokenByPassword({ - username, - password, - realm: "Username-Password-Authentication", - audience, - scope, -}); -``` - -### `oauth.clientCredentialsGrant` → `getTokenByClientCredentials` - -The canonical machine-to-machine grant. This is the most common reason to stay on auth0-auth-js rather than adopt server-js: there is no user session involved. - -```ts -// before -const resp = await auth0.oauth.clientCredentialsGrant({ audience: "https://api.example.com" }); -const token = resp.data.access_token; -// after -const tokens = await authClient.getTokenByClientCredentials({ audience: "https://api.example.com" }); -const token = tokens.accessToken; -``` - -### `oauth.revokeRefreshToken` → `revokeToken` - -Renamed, and simplified return (was `VoidApiResponse`, now `void`). - -```ts -// before -await auth0.oauth.revokeRefreshToken({ token: rt }); -// after -await authClient.revokeToken({ token: rt }); -``` - -> **Session apps:** if you are migrating to server-js and this revoke was part of logout, use `serverClient.revokeRefreshToken()` instead of the low-level `revokeToken`. By default it reads the refresh token from the session; you can also pass an explicit `{ token }` in its options. - -### Build the authorization and logout URLs - -node-auth0 left `/authorize` URL construction to the caller (or to `express-openid-connect`). The new SDK gives you `buildAuthorizationUrl()` and `buildLogoutUrl()`. When migrating a redirect login, replace hand-built `/authorize` and `/v2/logout` URLs with these: - -```ts -const { authorizationUrl, codeVerifier } = await authClient.buildAuthorizationUrl({ - authorizationParams: { redirect_uri, scope: "openid profile email", audience }, -}); -// ... later, on logout: -const logoutUrl = await authClient.buildLogoutUrl({ returnTo: "https://app.example.com" }); -``` - -> Pushed Authorization Requests (PAR): there is no standalone PAR method. Pass `pushedAuthorizationRequests: true` to `buildAuthorizationUrl`: the SDK performs the PAR POST and returns an authorization URL that references the resulting `request_uri`. Requires the tenant to expose a `pushed_authorization_request_endpoint`; the SDK throws if PAR is requested but unsupported. This replaces node-auth0's `oauth.pushedAuthorization`. - -Once the OIDC grants are rewritten and the [cross-cutting breaking changes](#cross-cutting-breaking-changes) are applied, run the [verification checklist](#verification-checklist). If your app also uses database, passwordless, CIBA, token exchange, or `UserInfoClient`, continue with [`authentication-flows.md`](./authentication-flows.md). If you want the SDK to own sessions, see [`server-side-sessions.md`](./server-side-sessions.md). - -### Optional: migrate only OIDC while staying on v6 - -You do not have to migrate everything at once, and you do not have to wait for v7. node-auth0 v6 still ships `AuthenticationClient` alongside `ManagementClient`, so you can move your OIDC login and token grant code off `AuthenticationClient` to `@auth0/auth0-auth-js` now, incrementally, while the rest of the app keeps using `auth0` v6 unchanged. - -A common and fully supported end state: - -- OIDC / token grant code: migrated to `@auth0/auth0-auth-js` (the grants covered in this section). -- Other auth flows you have not gotten to yet: still on `AuthenticationClient` from `auth0` v6. -- Management API: still on `ManagementClient` from `auth0` (never migrates). - -The OIDC grants above are a complete, shippable step on their own; finishing them is a valid stopping point even if you migrate nothing else. Move on to [`authentication-flows.md`](./authentication-flows.md) and [`server-side-sessions.md`](./server-side-sessions.md) later, at your own pace. When you eventually upgrade to v7 (which removes the Authentication API from the main entrypoint; see the [v7 Migration Guide](../v7_MIGRATION_GUIDE.md)), the OIDC work is already done. - -## Cross-cutting breaking changes - -Every call-site rewrite in this guide and on the incremental pages is subject to four changes that cut across all methods. They cause the overwhelming majority of migration defects, and three of the four are *silent*: the code compiles and often runs, but produces wrong behavior at runtime. Apply each one deliberately. - -1. [Return shape: `JSONApiResponse` → domain object](#1-return-shape) -2. [Casing: snake_case wire shape → camelCase](#2-casing) -3. [Token expiry: `expires_in` (relative) → `expiresAt` (absolute)](#3-token-expiry), most dangerous -4. [Error model: `AuthApiError` → typed per-operation errors](#4-error-model) - -### 1. Return shape - -node-auth0 wraps most Authentication API results in a response envelope: - -- `JSONApiResponse`: has `.data` (the payload), `.status` (number), `.statusText`, `.headers` (a `Headers` object). -- `VoidApiResponse`: same envelope, `.data` is `undefined` (used by `sendEmail`, `revokeRefreshToken`, …). -- `TextApiResponse`: `.data` is a `string` (used by `database.changePassword`). - -Exception: `backchannel.authorize`, `backchannel.backchannelGrant`, and `tokenExchange.exchangeToken` return domain objects directly (no `.data` wrapper) in node-auth0. - -The new SDKs drop the envelope and return the domain object directly: - -- Token grants return a `TokenResponse` instance. -- `database.signUp` returns a `SignUpResult` object. -- `database.changePassword` returns a `string`. -- `sendEmail` / `sendSms` / `revokeToken` return `void`. - -HTTP metadata (status code, response headers such as `x-request-id`, `retry-after`, rate-limit headers) is available through the typed error objects on failure paths. On success paths, metadata is available via the opt-in `fullResponse` envelope (see [Reading HTTP response metadata](#reading-http-response-metadata-fullresponse)). It is no longer on the bare success value by default. - -The rewrite: delete `.data` indirection on every success path: - -```ts -// before -const resp = await auth0.oauth.clientCredentialsGrant({ audience }); -const token = resp.data.access_token; -const status = resp.status; - -// after -const tokens = await authClient.getTokenByClientCredentials({ audience }); -const token = tokens.accessToken; -``` - -```ts -// before: changePassword returned TextApiResponse -const resp = await auth0.database.changePassword({ email, connection }); -console.log(resp.data); - -// after: returns the string directly -const message = await authClient.database.changePassword({ email, connection }); -console.log(message); -``` - -> `changePassword` requires `connection` plus at least one of `email` or `username`: either identifier is accepted, not `email` alone. - -#### Reading HTTP response metadata (fullResponse) - -When your node-auth0 code reads HTTP response metadata (status, headers) on a success path, migrate to the opt-in envelope rather than dropping the read. This is most common when you track rate limits, log request IDs, or check retry-after headers for dashboard telemetry. - -```ts -// before (node-auth0): metadata on the success envelope -const resp = await auth0.oauth.clientCredentialsGrant({ audience }); -const remaining = resp.headers.get("x-ratelimit-remaining"); -const token = resp.data.access_token; - -// after: opt in to the envelope, read the native Response -const { data, response } = await authClient.getTokenByClientCredentials({ audience, fullResponse: true }); -const remaining = response.headers.get("x-ratelimit-remaining"); -const token = data.accessToken; -``` - -The same opt-in covers the non-token Authentication API methods that node-auth0 wrapped in a `JSONApiResponse` / `TextApiResponse` / `VoidApiResponse`: - -| Method | Bare return | `fullResponse: true` return | -| --- | --- | --- | -| `database.signUp` | `SignUpResult` | `ApiResponse` | -| `database.changePassword` | `string` | `ApiResponse` | -| `passwordless.sendEmail` | `void` | `ApiResponse` (`data` is `undefined`) | -| `passwordless.sendSms` | `void` | `ApiResponse` (`data` is `undefined`) | - -```ts -// before (node-auth0): read the request id off the signup envelope -const resp = await auth0.database.signUp({ email, password, connection }); -const reqId = resp.headers.get("x-request-id"); - -// after: opt in to the envelope -const { data, response } = await authClient.database.signUp({ email, password, connection, fullResponse: true }); -const reqId = response.headers.get("x-request-id"); - -// void-returning methods expose the Response with an undefined `data` -const { response: sendResp } = await authClient.passwordless.sendEmail({ email, fullResponse: true }); -const rateLimit = sendResp.headers.get("x-ratelimit-remaining"); -``` - -Caveats: - -- Pass `fullResponse: true` as a literal, not a variable. Using spread (`{ ...opts, fullResponse: true }`) widens `true` to `boolean`, causing TypeScript overload resolution to fall back to the bare return type. Fix: pass `{ ...opts, fullResponse: true as const }` or include `fullResponse` as an inline literal in the options object. -- Performance: `@auth0/auth0-auth-js` does not cache tokens: every `AuthClient` grant method performs a live token-endpoint round-trip regardless of `fullResponse`, so the flag adds no extra network cost at this layer. (Token caching and reuse live in `@auth0/auth0-server-js`'s session store, not in the auth-js `AuthClient`.) The only in-memory cache in auth-js is for OIDC discovery / JWKS metadata, which is unrelated to `fullResponse`. -- Reserved headers: a caller `Authorization` header is ignored and the telemetry `Auth0-Client` header always wins; `RequestOptions.headers` cannot override them. -- Per-request `customFetch` replaces the base transport for that call but does not inherit mutual TLS (mTLS). If you rely on mTLS, the supplied fetch must itself be mTLS-capable. - -Default to the bare return type. Reach for `fullResponse` only where you actually consumed response metadata on success: rate-limit dashboards, request-id logging for support investigations, or retry-after handling. `MissingCapturedResponseError` is an internal-bug sentinel; you do not normally catch it. - -Gotchas: - -- **Void methods.** Code that did `const r = await auth0.passwordless.sendEmail(...)` and then checked `r.status === 200` must drop that check: by default the method returns `void` and throws on failure. Rely on the thrown error instead (see [Error model](#4-error-model)). -- **Header reads.** Any code reading `resp.headers.get('x-ratelimit-remaining')` on a success path needs the opt-in `fullResponse` envelope. Error paths still surface metadata on the typed error. Search your code for `.headers` on response values. -- **Do not hand-roll a compatibility shim.** Resist reintroducing a custom `{ data, status }` shape to minimize downstream diff. Let the domain object flow through; the SDK's opt-in `fullResponse` envelope is the sanctioned channel when you genuinely need the HTTP Response. - -### 2. Casing - -node-auth0's public API exposes the snake_case wire shape verbatim, on both inputs and outputs. The new SDKs use camelCase for the public API and only translate to snake_case at the HTTP boundary internally. - -Input parameters, field map: - -| node-auth0 (snake_case) | new SDK (camelCase) | -| --- | --- | -| `client_id` | `clientId` | -| `client_secret` | `clientSecret` | -| `refresh_token` | `refreshToken` | -| `redirect_uri` | (via `authorizationParams.redirect_uri` on config / builder) | -| `code_verifier` | `codeVerifier` | -| `phone_number` | `phoneNumber` | -| `auth_req_id` | `authReqId` | -| `binding_message` | `bindingMessage` | -| `subject_token` / `subject_token_type` | `subjectToken` / `subjectTokenType` | -| `given_name` / `family_name` | `givenName` / `familyName` | -| `user_metadata` | `userMetadata` | -| `login_hint` | `loginHint` | - -Output fields, `TokenResponse` field map: - -| node-auth0 `TokenSet` (snake_case) | new SDK `TokenResponse` (camelCase) | -| --- | --- | -| `access_token` | `accessToken` | -| `refresh_token` | `refreshToken` | -| `id_token` | `idToken` | -| `token_type` | `tokenType` | -| `expires_in` (relative) | `expiresAt` (absolute, see [Token expiry](#3-token-expiry)) | -| `scope` | `scope` | -| (none): had to decode id_token yourself | `claims` (already-decoded ID token claims) | -| `authorization_details` | `authorizationDetails` | - -Rename fields on both the arguments you pass in and the fields you read out: - -```ts -// before -const resp = await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); -const newRt = resp.data.refresh_token; -const idToken = resp.data.id_token; - -// after -const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); -const newRt = tokens.refreshToken; -const idToken = tokens.idToken; -``` - -> **Gotcha: keys that look renamed but are your data.** `user_metadata` → `userMetadata` is a rename of the *SDK's* parameter. The object *inside* it (e.g. `{ plan: 'free' }`) is passed through untouched. Do not rename your own metadata keys. The same applies to `authorization_details`. - -### 3. Token expiry - -**This is the highest-risk change in the migration. It is silent, it compiles, and it corrupts session lifetimes.** - -- node-auth0 `TokenSet.expires_in` = the token's lifetime in seconds relative to now (e.g. `86400` for a 24-hour token). This is the raw OAuth `expires_in` from the wire. -- new SDK `TokenResponse.expiresAt` = an absolute Unix timestamp in seconds (e.g. `1786000000`) computed by the SDK as roughly `now + expires_in`. - -Existing node-auth0 code almost always converts the relative value to an absolute deadline itself: - -```ts -// before: very common node-auth0 pattern -const resp = await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); -const expiresAtMs = Date.now() + resp.data.expires_in * 1000; // stored deadline -``` - -If you mechanically rename `expires_in` → `expiresAt` and leave the arithmetic, you get: - -```ts -// WRONG: double-counts "now" -const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); -const expiresAtMs = Date.now() + tokens.expiresAt * 1000; // ~ now + (now + lifetime) → far future -``` - -The stored deadline lands decades in the future, so the token is treated as valid long after it has actually expired. The app does not refresh it, so production 401s follow. - -The rewrite: `expiresAt` is *already* the deadline. Do not add `Date.now()`: - -```ts -// after: correct -const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); -const expiresAtMs = tokens.expiresAt * 1000; // absolute; convert s → ms only if you store ms -``` - -If downstream code genuinely needs the *relative* remaining lifetime (e.g. to set a cookie `Max-Age`), compute it from the absolute value: - -```ts -const secondsRemaining = tokens.expiresAt - Math.floor(Date.now() / 1000); -``` - -To find every instance, grep your code for these patterns and inspect each by hand: - -- `expires_in` -- `Date.now() +` near a token result -- `+ expires` / `* 1000` near a token result -- any stored field named `expiresAt`, `expires_at`, `expiry`, `tokenExpiry` fed from a grant - -Every one of these is a candidate for the double-count bug. - -> **Session apps get this for free.** If you migrate to server-js, the SDK owns expiry math inside `getAccessToken`. Delete your `Date.now() + expires_in * 1000` bookkeeping entirely. - -### 4. Error model - -node-auth0 throws a single error type for Authentication API failures: - -```ts -class AuthApiError extends Error { - name: "AuthApiError"; - error: string; // OAuth error code, e.g. 'invalid_grant' - error_description: string; - statusCode: number; - body: string; - headers: Headers; -} -``` - -The new SDKs throw typed, operation-specific error classes: `TokenByCodeError`, `TokenByRefreshTokenError`, `TokenByClientCredentialsError`, `TokenByPasswordError`, `TokenExchangeError`, `TokenRevocationError`, `PasswordlessStartError`, `PasswordlessChallengeError`, `PasswordlessDbGetTokenError`, `MfaEnrollmentError`, and so on. Each carries a structured `.cause` (the underlying OAuth2 error) rather than flat `error` / `error_description` strings. - -The rewrite: generic catch: - -```ts -// before -try { - await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); -} catch (e) { - if (e instanceof AuthApiError && e.error === "invalid_grant") { - // refresh token revoked/expired - } -} - -// after -import { TokenByRefreshTokenError } from "@auth0/auth0-auth-js"; -try { - await authClient.getTokenByRefreshToken({ refreshToken: rt }); -} catch (e) { - if (e instanceof TokenByRefreshTokenError && e.cause?.error === "invalid_grant") { - // refresh token revoked/expired - } -} -``` - -Import the specific error class for the operation you are calling. If you had one broad `catch (e instanceof AuthApiError)` around several different operations, either widen to catch each operation's error type or check the shared base behavior. Prefer the specific type per call site, since it documents which operation can fail. - -#### MFA detection: use the type guard, not the string - -Multi-factor authentication (MFA). A very common node-auth0 pattern is detecting `mfa_required` by string comparison to route the user into an MFA challenge: - -```ts -// before -try { - await auth0.oauth.passwordGrant({ username, password }); -} catch (e) { - if (e instanceof AuthApiError && e.error === "mfa_required") { - // start MFA flow using e (mfa_token is in the body) - } -} -``` - -The new SDK provides `isMfaRequiredError()`, a type guard that narrows the error and gives typed access to the MFA context (including the `mfa_token`). Use it instead of matching the string: - -```ts -// after -import { isMfaRequiredError } from "@auth0/auth0-auth-js"; -try { - await authClient.getTokenByPassword({ username, password }); -} catch (e) { - if (isMfaRequiredError(e)) { - // e is narrowed; drive the MFA challenge via authClient.mfa.* - } -} -``` - -> After detecting `mfa_required`, the MFA enroll/challenge/verify flow that node-auth0 handled ad hoc now lives on `authClient.mfa.*` (`listAuthenticators`, `enrollAuthenticator`, `challengeAuthenticator`, `verify`, and `deleteAuthenticator`). In server-js, `serverClient.mfa.verify()` also persists the resulting tokens to the session. - -#### ID-token validation types - -node-auth0 exposed `IDTokenValidateOptions` and `IdTokenValidatorError` for callers doing manual ID-token validation. The new SDK validates ID tokens internally during grants and exposes the decoded, validated result as `TokenResponse.claims`. Replace manual validation: - -- Options like `organization`, `nonce`, `maxAge` are passed to the grant call (e.g. `getTokenByCode`), and the SDK validates them and throws a typed error on mismatch, so you no longer construct a validator or catch `IdTokenValidatorError` yourself. -- Read the validated claims from `TokenResponse.claims` instead of decoding the `id_token` string. - -## Verification checklist - -The migration is not complete until every check passes in a single pass. For every node-auth0 auth call you rewrote (here or on the incremental pages), confirm all four cross-cutting changes: - -- [ ] **Return shape**: removed `.data` / `.status` / `.headers` access on the success path. -- [ ] **Casing**: renamed every snake_case field on input args and output reads to camelCase. -- [ ] **Expiry**: any code using the old `expires_in` now uses `expiresAt` as an *absolute* timestamp; no `Date.now() +` was left in front of it. -- [ ] **Errors**: `AuthApiError` catches replaced with the specific typed error (`.cause.error`); `mfa_required` string checks replaced with `isMfaRequiredError()`. - -Then run the project gates and repeat the whole loop if any step fails: - -- [ ] Grep for residue: unmigrated `from 'auth0'` auth imports, `.data.` reads on auth responses, and relative `expires_in` arithmetic. -- [ ] `tsc --noEmit`: catches structural mismatches and type errors. -- [ ] `npm test` (or the project's test command): confirms behavior is preserved. -- [ ] Run the linter if the project has one configured. -- [ ] Confirm files that use `ManagementClient` still import and call it from `auth0`; that code must be untouched. - -Do not declare the migration complete until the loop converges: all steps pass in a single iteration. - -## Continue the migration - -Once the OIDC grants and the four cross-cutting changes are in, migrate the rest at your own pace. Each area lives in its own page. - -### Other authentication flows - -Database signup, passwordless, backchannel (CIBA), token exchange, and `UserInfoClient` lookups: see [`authentication-flows.md`](./authentication-flows.md). - -### Server-side sessions - -Routing to `@auth0/auth0-server-js`, where the SDK owns the login redirect flow, session storage, cookies, token refresh, and logout: see [`server-side-sessions.md`](./server-side-sessions.md). - -### Troubleshooting - -Common questions and failure modes (tokens valid for decades, missing `resp.data`, magic-link default flip, `getUserInfo`, `mfa_required` detection, global config): see [`troubleshooting.md`](./troubleshooting.md). diff --git a/auth-migration/server-side-sessions.md b/auth-migration/server-side-sessions.md deleted file mode 100644 index d040e2986b..0000000000 --- a/auth-migration/server-side-sessions.md +++ /dev/null @@ -1,163 +0,0 @@ -# Migrating session apps to `@auth0/auth0-server-js` - -This page is part of the [Authentication Migration Guide](./index.md). Read it only when you are routing to **`@auth0/auth0-server-js`**: when you want the SDK to own the login redirect flow, session storage, cookies, token refresh, and logout, instead of hand-rolling that around node-auth0. If you only need stateless token grants, stay on the main guide and [`authentication-flows.md`](./authentication-flows.md); you do not need this page. - -> **Migrating with an AI agent?** Point it at the Auth0 migration skill (the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`). It walks the session lifecycle step by step. - -**This is a rewrite of the session handling, not a method-for-method port.** node-auth0 had no session concept, so there is nothing to translate line-for-line. Instead you *replace* your existing session code (your `express-session` wiring, your token cache, your refresh-on-expiry logic, your logout handler) with the ServerClient lifecycle. You still touch only the auth/session code; routes, views, and business logic stay put. - -- [Mental model](#mental-model) -- [Store setup](#store-setup) -- [The redirect-login lifecycle](#the-redirect-login-lifecycle) -- [Logins without a browser redirect](#logins-without-a-browser-redirect) -- [Backchannel logout](#backchannel-logout) - -## Mental model - -A ServerClient login has three durable pieces: - -1. **Transaction store**: short-lived. Holds the in-flight login: the OAuth `state` and the PKCE (Proof Key for Code Exchange) `code_verifier` between the moment you redirect the user to Auth0 and the moment they come back to your callback. Created at `startInteractiveLogin`, consumed at `completeInteractiveLogin`. -2. **State store**: long-lived. Holds the established session: the user claims plus the access / refresh / ID tokens and their absolute expiry. Read on every subsequent request via `getUser`, `getSession`, `getAccessToken`. -3. **Cookies**: how the two stores key themselves to the browser. With a *stateless* store the session data lives encrypted in the cookie itself; with a *stateful* store the cookie holds only an identifier and the data lives in your backend (Redis, database, and so on). - -node-auth0 exposed none of this; you built equivalents by hand. You are swapping your implementation for the SDK's. - -## Store setup - -`@auth0/auth0-server-js` ships store base classes and cookie-backed implementations: - -- `CookieTransactionStore`: transaction store backed entirely by a cookie. Good default. -- `StatelessStateStore`: session lives encrypted in the cookie. No server-side storage; good for serverless or horizontally-scaled deployments with small sessions. -- `StatefulStateStore`: session lives server-side; the cookie holds an id. Use for large sessions or when you need server-side revocation. -- `AbstractTransactionStore` / `AbstractStateStore`: extend these to back a store with your own storage (Redis, Postgres, and so on). These are the exported base-class names. - -All stores accept a `CookieHandler` so they can integrate with any framework's cookie API. The `storeOptions` generic (`TStoreOptions`) is how you thread per-request context (like the framework `req` / `res`) into store reads and writes; every ServerClient method takes an optional trailing `storeOptions` argument for exactly this. - -```ts -import { ServerClient, CookieTransactionStore, StatelessStateStore } from "@auth0/auth0-server-js"; - -const serverClient = new ServerClient({ - domain: process.env.AUTH0_DOMAIN!, - clientId: process.env.AUTH0_CLIENT_ID!, - clientSecret: process.env.AUTH0_CLIENT_SECRET!, - authorizationParams: { - redirect_uri: "https://app.example.com/callback", - scope: "openid profile email offline_access", // offline_access ⇒ refresh token - audience: "https://api.example.com", - }, - transactionStore: new CookieTransactionStore( - { secret: process.env.SESSION_SECRET! }, - cookieHandler, // CookieHandler implementation - ), - stateStore: new StatelessStateStore( - { secret: process.env.SESSION_SECRET! }, - cookieHandler, // CookieHandler implementation - ), -}); -``` - -## The redirect-login lifecycle - -### 1. Start login: replace the hand-built `/authorize` redirect - -Whatever you did to send the user to Auth0 (a hand-constructed `/authorize` URL, or `express-openid-connect`'s `/login`) becomes: - -```ts -// GET /login -app.get("/login", async (req, res) => { - const authorizationUrl = await serverClient.startInteractiveLogin( - { - authorizationParams: { - /* optional per-login overrides */ - }, - appState: { returnTo: req.query.returnTo || "/" }, // seed appState for round-trip - }, - { req, res }, // storeOptions: lets the transaction store write its cookie - ); - res.redirect(authorizationUrl.href); -}); -``` - -`startInteractiveLogin` generates `state` and PKCE, writes them to the transaction store, and returns the fully-formed authorization URL. - -### 2. Complete login: replace the manual code exchange - -The callback handler that used to call `oauth.authorizationCodeGrant` (or `authorizationCodeGrantWithPKCE`) and then stuff tokens into the session becomes a single call: - -```ts -// GET /callback -app.get("/callback", async (req, res) => { - const callbackUrl = new URL(req.url, `https://${req.headers.host}`); - const { appState } = await serverClient.completeInteractiveLogin(callbackUrl, { req, res }); - // Session is now established in the state store. Tokens are NOT your concern anymore. - res.redirect(appState?.returnTo ?? "/"); -}); -``` - -`completeInteractiveLogin` validates `state`, exchanges the code, validates the ID token, writes the session (user + tokens + absolute expiry) to the state store, and clears the transaction. - -### 3. Read the user or session on later requests - -Replace `req.session.user` reads: - -```ts -const user = await serverClient.getUser({ req, res }); // user claims, or undefined -const session = await serverClient.getSession({ req, res }); // full session data, or undefined -``` - -`getUser` / `getSession` return `undefined` when there is no session or it has expired (the store deletes expired sessions on read), so use that as your "not logged in" signal. - -### 4. Get an access token to call an API: refresh is automatic - -Replace your manual "is the token expired? if so refresh" block: - -```ts -const { accessToken } = await serverClient.getAccessToken({ req, res }); -// If the stored access token is expired and a refresh token exists, -// the SDK refreshes and persists the new tokens transparently. -``` - -This is where the `expires_in` → `expiresAt` hazard disappears entirely: the SDK owns expiry math. For a downstream federated connection token (Token Vault), use `serverClient.getAccessTokenForConnection({ connection }, { req, res })`. - -### 5. Logout: replace manual revoke, session clear, and `/v2/logout` redirect - -```ts -// GET /logout -app.get("/logout", async (req, res) => { - const logoutUrl = await serverClient.logout({ returnTo: "https://app.example.com" }, { req, res }); - res.redirect(logoutUrl.href); -}); -``` - -`logout` clears the session from the state store and returns the Auth0 `/v2/logout` URL. If you also revoked the refresh token on logout (via `oauth.revokeRefreshToken`), call `serverClient.revokeRefreshToken({ req, res })` before redirecting; by default it reads the refresh token from the session, so you do not handle the raw token yourself (it also accepts an explicit `{ token }` if you need to revoke a specific one). - -## Logins without a browser redirect - -Some logins do not use a browser redirect: the password grant, passwordless, CIBA, and custom token exchange. If you used node-auth0 for one of these *and* want a server-js session out of it, use the ServerClient methods that both authenticate and write the session, rather than the low-level auth-js grants: - -| Flow | ServerClient method | -| --- | --- | -| Backchannel / CIBA | `loginBackchannel({ ... }, storeOptions)` | -| Passwordless (send) | `startPasswordless({ connection, email \| phoneNumber, ... }, storeOptions)` | -| Passwordless (verify code → session) | `completePasswordless({ connection, email \| phoneNumber, verificationCode }, storeOptions)` | -| Passwordless magic link (callback → session) | `completePasswordlessMagicLink(url, storeOptions)` | -| Custom token exchange → session | `loginWithCustomTokenExchange({ ... }, storeOptions)` | -| MFA verify → session | `serverClient.mfa.verify({ ... }, storeOptions)` | - -Each of these performs the underlying grant *and* persists the resulting tokens to the state store, so the user is logged in afterward, exactly the behavior you previously wrote by hand after a node-auth0 grant. - -## Backchannel logout - -If you implemented an Auth0 back-channel logout endpoint by hand (validating the logout token, then clearing your session store), replace it with: - -```ts -// POST /backchannel-logout -app.post("/backchannel-logout", async (req, res) => { - await serverClient.handleBackchannelLogout(req.body.logout_token, { req, res }); - res.sendStatus(204); -}); -``` - -It validates the logout token and clears the corresponding session. - -When the session layer is wired, return to the [verification checklist](./index.md#verification-checklist) in the main guide. diff --git a/auth-migration/troubleshooting.md b/auth-migration/troubleshooting.md deleted file mode 100644 index 334a37a698..0000000000 --- a/auth-migration/troubleshooting.md +++ /dev/null @@ -1,32 +0,0 @@ -# Troubleshooting: FAQ and gotchas - -Common questions and failure modes when migrating off the `auth0` package's Authentication API. This page is part of the [Authentication Migration Guide](./index.md); it assumes the terms defined there. - -> **Migrating with an AI agent?** Point it at the Auth0 migration skill (the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`). - -### Do I have to migrate everything at once? -No. The OIDC / token-grant work is a complete, shippable step on its own. You can stay on `auth0` v6 and migrate only OIDC, leaving other auth flows on `AuthenticationClient` for now. See [Optional: migrate only OIDC while staying on v6](./index.md#optional-migrate-only-oidc-while-staying-on-v6). - -### Do I have to migrate the Management API too? -No. `ManagementClient` is out of scope and stays on the `auth0` package. A file importing both `auth0` (for management) and `@auth0/auth0-auth-js` (for authentication) is correct. - -### auth0-auth-js or auth0-server-js: which do I pick? -Default to auth0-auth-js for a low-risk parity migration. Pick auth0-server-js only when you want the SDK to own the login redirect flow, session storage, cookies, refresh, and logout. See [Choosing your target SDK](./index.md#choosing-your-target-sdk). - -### My tokens suddenly look valid for decades. What happened? -You almost certainly left `Date.now() +` in front of `expiresAt`. `expiresAt` is already an absolute Unix timestamp, not a relative lifetime. See [Token expiry](./index.md#3-token-expiry). - -### Where did `resp.data` go? -The new SDKs return the domain object directly. Read `tokens.accessToken`, not `resp.data.access_token`. If you truly need HTTP response metadata on a success path, opt into `fullResponse`. - -### My magic-link passwordless flow stopped sending links. -The `send` default changed from `'link'` (node-auth0) to `'code'` (new SDK). Set `send: 'link'` explicitly if you want magic links. See [Passwordless](./authentication-flows.md#passwordless). - -### Where is `getUserInfo`? -Prefer `TokenResponse.claims`; they are already decoded and validated, with no extra round-trip. For an arbitrary access token, use `authClient.getUserInfo({ accessToken })`. In a session app, use `serverClient.getUser()`. See [UserInfoClient](./authentication-flows.md#userinfoclient). - -### Can I still set a global `headers` / `timeout` / `agent` on the client? -Not on the constructor. Move them to the per-call `RequestOptions` argument (`headers`, `signal: AbortSignal.timeout(ms)`) or wrap `customFetch`. - -### How do I detect `mfa_required` now? -Use the `isMfaRequiredError()` type guard, not a string comparison. It narrows the error and exposes the `mfa_token`. Drive the challenge via `authClient.mfa.*`. See [Error model](./index.md#4-error-model). diff --git a/package.json b/package.json index c456e8ca17..e9d0ebdf6a 100644 --- a/package.json +++ b/package.json @@ -606,17 +606,6 @@ }, "default": "./dist/cjs/management/api/resources/attackProtection/resources/captcha/exports.js" }, - "./attackProtection/captchaPolicies": { - "import": { - "types": "./dist/esm/management/api/resources/attackProtection/resources/captchaPolicies/exports.d.mts", - "default": "./dist/esm/management/api/resources/attackProtection/resources/captchaPolicies/exports.mjs" - }, - "require": { - "types": "./dist/cjs/management/api/resources/attackProtection/resources/captchaPolicies/exports.d.ts", - "default": "./dist/cjs/management/api/resources/attackProtection/resources/captchaPolicies/exports.js" - }, - "default": "./dist/cjs/management/api/resources/attackProtection/resources/captchaPolicies/exports.js" - }, "./attackProtection/phoneProviderProtection": { "import": { "types": "./dist/esm/management/api/resources/attackProtection/resources/phoneProviderProtection/exports.d.mts", diff --git a/reference.md b/reference.md index 8ee6cfcd15..466e9bb8fb 100644 --- a/reference.md +++ b/reference.md @@ -52,7 +52,7 @@ let page = await client.actions.list({ installed: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -550,7 +550,7 @@ let page = await client.agents.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -1027,7 +1027,7 @@ let page = await client.clientGrants.list({ default_for: "third_party_clients", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -1184,7 +1184,7 @@ let page = await client.clientGrants.search({ sort: "audience", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -1465,7 +1465,7 @@ let page = await client.clientProfiles.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -1854,7 +1854,7 @@ let page = await client.clients.list({ q: "q", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -2176,7 +2176,7 @@ let page = await client.clients.search({ sort: "name", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -2564,7 +2564,7 @@ let page = await client.connectionProfiles.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -3053,7 +3053,7 @@ let page = await client.connections.list({ include_fields: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -4118,7 +4118,7 @@ let page = await client.deviceCredentials.list({ type: "public_key", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -4593,7 +4593,7 @@ let page = await client.eventStreams.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -5008,7 +5008,7 @@ let page = await client.flows.list({ synchronous: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -5292,7 +5292,7 @@ let page = await client.forms.list({ hydrate: ["flow_count"], }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -5595,7 +5595,7 @@ let page = await client.userGrants.list({ audience: "audience", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -5820,7 +5820,7 @@ let page = await client.groups.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -6162,7 +6162,7 @@ let page = await client.hooks.list({ triggerId: "credentials-exchange", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -7445,7 +7445,7 @@ let page = await client.logs.list({ search: "search", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -7593,7 +7593,7 @@ let page = await client.networkAcls.list({ include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -8043,7 +8043,7 @@ let page = await client.organizations.list({ include_client_association_for: "include_client_association_for", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -8272,7 +8272,7 @@ let page = await client.organizations.search({ sort: "name", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -8665,7 +8665,7 @@ let page = await client.rateLimitPolicies.list({ from: "from", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -8967,7 +8967,7 @@ let page = await client.refreshTokens.list({ include_fields: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -9316,7 +9316,7 @@ let page = await client.resourceServers.list({ include_fields: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -9475,7 +9475,7 @@ let page = await client.resourceServers.search({ sort: "identifier", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -9775,7 +9775,7 @@ let page = await client.roles.list({ owner_id: "owner_id", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -10130,7 +10130,7 @@ let page = await client.rules.list({ include_fields: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -10686,7 +10686,7 @@ let page = await client.selfServiceProfiles.list({ include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -11679,7 +11679,7 @@ let page = await client.tokenExchangeProfiles.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -12035,7 +12035,7 @@ let page = await client.userAttributeProfiles.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -12810,7 +12810,7 @@ let page = await client.users.list({ primary_order: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -13463,7 +13463,7 @@ let page = await client.actions.versions.list("actionId", { per_page: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -13769,7 +13769,7 @@ let page = await client.actions.modules.list({ per_page: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -14113,7 +14113,7 @@ let page = await client.actions.modules.listActions("id", { per_page: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -14334,7 +14334,7 @@ let page = await client.actions.modules.versions.list("id", { per_page: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -14559,7 +14559,7 @@ let page = await client.actions.triggers.bindings.list("post-login", { per_page: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -15285,328 +15285,6 @@ await client.attackProtection.captcha.update(); -## AttackProtection CaptchaPolicies - -
client.attackProtection.captchaPolicies.list() -> Management.ListAttackProtectionCaptchaPoliciesResponseContent -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve all CAPTCHA attack protection policies for the tenant, sorted by priority ascending. - -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.attackProtection.captchaPolicies.list(); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `CaptchaPoliciesClient.RequestOptions` - -
-
-
-
- -
-
-
- -
client.attackProtection.captchaPolicies.create({ ...params }) -> Management.AttackProtectionCaptchaPolicy -
-
- -#### 📝 Description - -
-
- -
-
- -Create a new CAPTCHA attack protection policy for the tenant. The maximum number of policies per tenant is determined by the tenant's subscription. - -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.attackProtection.captchaPolicies.create({ - name: "name", - priority: 1, - match: {}, - action: {}, -}); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**request:** `Management.CreateAttackProtectionCaptchaPolicyRequestContent` - -
-
- -
-
- -**requestOptions:** `CaptchaPoliciesClient.RequestOptions` - -
-
-
-
- -
-
-
- -
client.attackProtection.captchaPolicies.get(id) -> Management.AttackProtectionCaptchaPolicy -
-
- -#### 📝 Description - -
-
- -
-
- -Retrieve a single CAPTCHA attack protection policy for the tenant by ID. - -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.attackProtection.captchaPolicies.get("id"); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**id:** `string` — ID of the CAPTCHA attack protection policy. - -
-
- -
-
- -**requestOptions:** `CaptchaPoliciesClient.RequestOptions` - -
-
-
-
- -
-
-
- -
client.attackProtection.captchaPolicies.delete(id) -> void -
-
- -#### 📝 Description - -
-
- -
-
- -Delete a CAPTCHA attack protection policy for the tenant. - -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.attackProtection.captchaPolicies.delete("id"); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**id:** `string` — ID of the CAPTCHA attack protection policy. - -
-
- -
-
- -**requestOptions:** `CaptchaPoliciesClient.RequestOptions` - -
-
-
-
- -
-
-
- -
client.attackProtection.captchaPolicies.update(id, { ...params }) -> Management.AttackProtectionCaptchaPolicy -
-
- -#### 📝 Description - -
-
- -
-
- -Partially update a CAPTCHA attack protection policy. Only the provided fields are modified. A provided match or action replaces the stored value in full rather than merging with it; within action, a provider secret or API key that is omitted from a provided provider block keeps its stored value. - -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.attackProtection.captchaPolicies.update("id"); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**id:** `string` — ID of the CAPTCHA attack protection policy. - -
-
- -
-
- -**request:** `Management.UpdateAttackProtectionCaptchaPolicyRequestContent` - -
-
- -
-
- -**requestOptions:** `CaptchaPoliciesClient.RequestOptions` - -
-
-
-
- -
-
-
- ## AttackProtection PhoneProviderProtection
client.attackProtection.phoneProviderProtection.get() -> Management.GetPhoneProviderProtectionResponseContent @@ -17267,7 +16945,7 @@ let page = await client.clientGrants.organizations.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -17784,7 +17462,7 @@ let page = await client.clients.connections.get("id", { include_fields: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -17875,7 +17553,7 @@ let page = await client.connections.directoryProvisioning.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -18289,7 +17967,7 @@ let page = await client.connections.directoryProvisioning.listSynchronizedGroups q: "q", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -18611,7 +18289,7 @@ let page = await client.connections.scimConfiguration.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -19030,7 +18708,7 @@ let page = await client.connections.clients.get("id", { from: "from", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -20028,7 +19706,7 @@ let page = await client.eventStreams.deliveries.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -20295,7 +19973,7 @@ let page = await client.experimentation.experiments.list({ feature_flag_id: "feature_flag_id", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -20366,6 +20044,7 @@ await client.experimentation.experiments.create({ name: "name", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); ``` @@ -20782,7 +20461,7 @@ let page = await client.experimentation.featureFlags.list({ status: "draft", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -21130,7 +20809,7 @@ let page = await client.experimentation.segments.list({ type: "auth0", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -21825,7 +21504,7 @@ let page = await client.flows.executions.list("flow_id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -22025,7 +21704,7 @@ let page = await client.flows.vault.connections.list({ include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -22320,7 +21999,7 @@ let page = await client.groups.members.get("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -22411,7 +22090,7 @@ let page = await client.groups.roles.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -22900,7 +22579,7 @@ await client.guardian.factors.set("push-notification", {
-**name:** `Management.GuardianFactorNameEnum` — Factor name. Can be `sms`, `push-notification`, `email`, `duo` `otp` `webauthn-roaming`, `webauthn-platform`, or `recovery-code`. +**name:** `Management.GuardianFactorNameEnum` — Factor name. Can be `sms`, `push-notification`, `email`, `duo`, `otp`, `webauthn-roaming`, `webauthn-platform`, `recovery-code`, or `passkey`.
@@ -25824,7 +25503,7 @@ let page = await client.keys.encryption.list({ include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -26770,7 +26449,7 @@ let page = await client.organizations.clientGrants.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -26980,7 +26659,7 @@ let page = await client.organizations.clients.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -27361,7 +27040,7 @@ let page = await client.organizations.connections.list("id", { is_enabled: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -27687,7 +27366,7 @@ let page = await client.organizations.discoveryDomains.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -28147,7 +27826,7 @@ let page = await client.organizations.enabledConnections.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -28544,7 +28223,7 @@ let page = await client.organizations.invitations.list("id", { sort: "sort", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -28858,7 +28537,7 @@ let page = await client.organizations.members.list("id", { include_fields: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -29082,7 +28761,7 @@ let page = await client.organizations.groups.list("organization_id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -29173,7 +28852,7 @@ let page = await client.organizations.groups.roles.list("organization_id", "grou take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -29434,7 +29113,7 @@ let page = await client.organizations.members.effectiveRoles.list("id", "user_id take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -29539,7 +29218,7 @@ let page = await client.organizations.members.roles.list("id", "user_id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -29806,7 +29485,7 @@ let page = await client.organizations.members.effectiveRoles.sources.groups.list role_id: "role_id", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -29914,7 +29593,7 @@ let page = await client.organizations.roles.members.list("id", "role_id", { include_fields: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -30013,7 +29692,7 @@ let page = await client.organizations.roles.groups.list("organization_id", "role take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -30124,7 +29803,7 @@ let page = await client.prompts.rendering.list({ rendering_mode: "advanced", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -30963,7 +30642,7 @@ let page = await client.roles.groups.get("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -31202,7 +30881,7 @@ let page = await client.roles.permissions.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -31469,7 +31148,7 @@ let page = await client.roles.users.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -32083,7 +31762,7 @@ let page = await client.users.authenticationMethods.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -32658,7 +32337,7 @@ let page = await client.users.connectedAccounts.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -32751,7 +32430,7 @@ let page = await client.users.effectivePermissions.list("id", { resource_server_identifier: "resource_server_identifier", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -32842,7 +32521,7 @@ let page = await client.users.effectiveRoles.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -33004,7 +32683,7 @@ let page = await client.users.groups.get("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -33286,7 +32965,7 @@ let page = await client.users.logs.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -33531,7 +33210,7 @@ let page = await client.users.organizations.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -33626,7 +33305,7 @@ let page = await client.users.permissions.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -33955,7 +33634,7 @@ let page = await client.users.roles.list("id", { include_totals: true, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -34198,7 +33877,7 @@ let page = await client.users.refreshToken.list("user_id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -34354,7 +34033,7 @@ let page = await client.users.sessions.list("user_id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -34512,7 +34191,7 @@ let page = await client.users.effectivePermissions.sources.roles.list("id", { permission_name: "permission_name", }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -34605,7 +34284,7 @@ let page = await client.users.effectiveRoles.sources.groups.list("id", { take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response @@ -34696,7 +34375,7 @@ let page = await client.verifiableCredentials.verification.templates.list({ take: 1, }); while (page.hasNextPage()) { - page = page.getNextPage(); + page = await page.getNextPage(); } // You can also access the underlying response diff --git a/scripts/rename-to-esm-files.js b/scripts/rename-to-esm-files.js index dc1df1cbba..2425ed4564 100644 --- a/scripts/rename-to-esm-files.js +++ b/scripts/rename-to-esm-files.js @@ -1,6 +1,7 @@ #!/usr/bin/env node const fs = require("fs").promises; +const fsSync = require("fs"); const path = require("path"); const extensionMap = { @@ -44,8 +45,32 @@ async function updateFiles(files) { console.log(`Updated imports in ${updatedFiles.length} files.`); } +const KNOWN_EXTENSIONS = new Set([".js", ".mjs", ".cjs", ".jsx", ".json", ".ts", ".mts", ".cts", ".tsx", ".node"]); + +function hasFileExtension(importPath) { + const basename = path.basename(importPath); + const dotIndex = basename.lastIndexOf("."); + if (dotIndex <= 0) { + return false; + } + return KNOWN_EXTENSIONS.has(basename.slice(dotIndex).toLowerCase()); +} + +function resolveExtensionlessImport(dir, importPath) { + const resolvedPath = path.resolve(dir, importPath); + if (fsSync.existsSync(resolvedPath + ".js")) { + return importPath + ".mjs"; + } + const indexPath = path.join(resolvedPath, "index.js"); + if (fsSync.existsSync(indexPath)) { + return importPath + "/index.mjs"; + } + return null; +} + async function updateFileContents(file) { const content = await fs.readFile(file, "utf8"); + const dir = path.dirname(file); let newContent = content; // Update each extension type defined in the map @@ -62,6 +87,46 @@ async function updateFileContents(file) { newContent = newContent.replace(dynamicRegex, `$1("$2${newExt}")`); } + // Handle extensionless relative imports (e.g. from "./oauth" or from "../utils"). + // These violate the ESM spec and break Node's ESM loader and Turbopack. + const staticExtensionless = /(import|export)(.+from\s+['"])(\.\.?\/[^'"]+?)(['"])/g; + const staticReplacements = []; + let match; + while ((match = staticExtensionless.exec(newContent)) !== null) { + const importPath = match[3]; + if (hasFileExtension(importPath)) continue; + const resolved = resolveExtensionlessImport(dir, importPath); + if (resolved != null) { + staticReplacements.push({ + start: match.index, + end: match.index + match[0].length, + replacement: `${match[1]}${match[2]}${resolved}${match[4]}`, + }); + } + } + for (const { start, end, replacement } of staticReplacements.reverse()) { + newContent = newContent.slice(0, start) + replacement + newContent.slice(end); + } + + // Handle extensionless dynamic imports + const dynamicExtensionless = /(yield\s+import|await\s+import|import)\s*\(\s*['"](\.\.?\/[^'"]+?)['"]\s*\)/g; + const dynamicReplacements = []; + while ((match = dynamicExtensionless.exec(newContent)) !== null) { + const importPath = match[2]; + if (hasFileExtension(importPath)) continue; + const resolved = resolveExtensionlessImport(dir, importPath); + if (resolved != null) { + dynamicReplacements.push({ + start: match.index, + end: match.index + match[0].length, + replacement: `${match[1]}("${resolved}")`, + }); + } + } + for (const { start, end, replacement } of dynamicReplacements.reverse()) { + newContent = newContent.slice(0, start) + replacement + newContent.slice(end); + } + if (content !== newContent) { await fs.writeFile(file, newContent, "utf8"); return true; diff --git a/src/management/BaseClient.ts b/src/management/BaseClient.ts index 0bed906654..63b941f61f 100644 --- a/src/management/BaseClient.ts +++ b/src/management/BaseClient.ts @@ -15,6 +15,8 @@ export type BaseClientOptions = { environment?: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; + /** Defaults to "{TENANT}.auth0.com". */ + tenantDomain?: string; /** Additional headers to include in requests. */ headers?: Record | null | undefined>; /** The default maximum time to wait for a response in seconds. */ @@ -26,6 +28,8 @@ export type BaseClientOptions = { fetcher?: core.FetchFunction; /** Configure logging for the client. */ logging?: core.logging.LogConfig | core.logging.Logger; + /** Default options for SSE stream reconnection behavior. Has no effect on non-resumable endpoints. */ + stream?: { reconnectionEnabled?: boolean; maxReconnectionAttempts?: number }; /** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */ auth?: AuthOption; } & BearerAuthProvider.AuthOptions; @@ -39,8 +43,12 @@ export interface BaseRequestOptions { abortSignal?: AbortSignal; /** Additional query string parameters to include in the request. */ queryParams?: Record; + /** A dictionary containing additional parameters to spread into the request's body. */ + additionalBodyParameters?: Record; /** Additional headers to include in the request. */ headers?: Record | null | undefined>; + /** Options for SSE stream reconnection behavior. Has no effect on non-resumable endpoints. */ + stream?: { reconnectionEnabled?: boolean; maxReconnectionAttempts?: number }; } export type NormalizedClientOptions = T & { @@ -56,8 +64,20 @@ export type NormalizedClientOptionsWithAuth( options: T, ): NormalizedClientOptions { + let baseUrl = options?.baseUrl; + if (options?.tenantDomain != null) { + const _tenantDomain = options?.tenantDomain ?? "{TENANT}.auth0.com"; + if (baseUrl == null) { + const _environmentUrls = new Map([ + [environments.ManagementEnvironment.Default, `https://${_tenantDomain}/api/v2`], + ]); + baseUrl = _environmentUrls.get(options?.environment) ?? `https://${_tenantDomain}/api/v2`; + } + } + return { ...options, + baseUrl, logging: core.logging.createLogger(options?.logging), } as NormalizedClientOptions; } diff --git a/src/management/api/requests/requests.ts b/src/management/api/requests/requests.ts index b27fae3bd4..cea5fa740b 100644 --- a/src/management/api/requests/requests.ts +++ b/src/management/api/requests/requests.ts @@ -2512,41 +2512,6 @@ export interface UpdateAttackProtectionCaptchaRequestContent { simple_captcha?: Management.AttackProtectionCaptchaSimpleCaptchaResponseContent; } -/** - * @example - * { - * name: "name", - * priority: 1, - * match: {}, - * action: {} - * } - */ -export interface CreateAttackProtectionCaptchaPolicyRequestContent { - /** Human-readable policy name. */ - name: string; - /** Description of the attack protection policy. */ - description?: string; - /** Conflict resolution order. Lower number takes higher precedence. Must be unique per tenant. */ - priority: number; - match: Management.AttackProtectionCaptchaPolicyMatch; - action: Management.AttackProtectionCaptchaPolicyActionInput; -} - -/** - * @example - * {} - */ -export interface UpdateAttackProtectionCaptchaPolicyRequestContent { - /** Human-readable policy name. */ - name?: string; - /** Description of the policy's purpose. */ - description?: string; - /** Conflict resolution order. Lower number takes higher precedence. Must be unique per tenant. */ - priority?: number; - match?: Management.AttackProtectionCaptchaPolicyMatch; - action?: Management.AttackProtectionCaptchaPolicyActionInput; -} - /** * @example * { @@ -3164,7 +3129,8 @@ export interface ListExperimentsRequestParameters { * { * name: "name", * feature_flag_id: "feature_flag_id", - * authentication_flow: "authentication" + * authentication_flow: "authentication", + * allocation_strategy: "percentage" * } */ export interface CreateExperimentRequestContent { @@ -3178,7 +3144,7 @@ export interface CreateExperimentRequestContent { /** Applies only to Auth0-managed flags. Controls where non-overridden config keys resolve from: 'tenant' inherits the tenant's live config so the experiment overlays only its changes, 'flag' uses the flag's frozen defaults for a complete config. Optional; defaults to 'tenant' when omitted. Rejected for customer-defined flags. */ default_config?: Management.DefaultConfigEnum; /** The traffic allocation strategy for this experiment */ - allocation_strategy?: Management.AllocationStrategyEnum; + allocation_strategy: Management.AllocationStrategyEnum; /** Traffic allocations mapping variations to weights or segments */ allocations?: Management.AllocationRequestItem[]; /** Ramp experiment levels configuration. A strictly-increasing sequence of exposure percentages, each an integer in [0, 100]. */ @@ -3340,7 +3306,7 @@ export interface UpdateVariationRequestContent { name?: string; /** A description of what this variation controls */ description?: string | null; - overrides?: Management.UpdateVariationOverridesMap; + overrides?: (Management.UpdateVariationOverridesMap | undefined) | null; } /** diff --git a/src/management/api/resources/actions/client/Client.ts b/src/management/api/resources/actions/client/Client.ts index 12fb561227..154ef6e5aa 100644 --- a/src/management/api/resources/actions/client/Client.ts +++ b/src/management/api/resources/actions/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -56,6 +57,8 @@ export class ActionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.list({ @@ -156,8 +159,15 @@ export class ActionsClient { (request?.per_page == null || (response?.actions ?? []).length >= request?.per_page), getItems: (response) => response?.actions ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -172,6 +182,8 @@ export class ActionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.create({ @@ -210,7 +222,7 @@ export class ActionsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -257,6 +269,8 @@ export class ActionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.get("id") @@ -283,7 +297,7 @@ export class ActionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(id)}`, + `actions/actions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -334,6 +348,8 @@ export class ActionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.delete("id", { @@ -368,7 +384,7 @@ export class ActionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(id)}`, + `actions/actions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -423,6 +439,8 @@ export class ActionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.update("id") @@ -451,14 +469,14 @@ export class ActionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(id)}`, + `actions/actions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -506,6 +524,8 @@ export class ActionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.deploy("id") @@ -532,7 +552,7 @@ export class ActionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(id)}/deploy`, + `actions/actions/${core.url.encodePathParam(id, errors.ManagementError)}/deploy`, ), method: "POST", headers: _headers, @@ -583,6 +603,8 @@ export class ActionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.test("id", { @@ -615,14 +637,14 @@ export class ActionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(id)}/test`, + `actions/actions/${core.url.encodePathParam(id, errors.ManagementError)}/test`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/actions/resources/executions/client/Client.ts b/src/management/api/resources/actions/resources/executions/client/Client.ts index 0faecd7524..d1ecf9fac3 100644 --- a/src/management/api/resources/actions/resources/executions/client/Client.ts +++ b/src/management/api/resources/actions/resources/executions/client/Client.ts @@ -33,6 +33,8 @@ export class ExecutionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.executions.get("id") @@ -59,7 +61,7 @@ export class ExecutionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/executions/${core.url.encodePathParam(id)}`, + `actions/executions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/actions/resources/modules/client/Client.ts b/src/management/api/resources/actions/resources/modules/client/Client.ts index 9b1ce11f25..20895d689f 100644 --- a/src/management/api/resources/actions/resources/modules/client/Client.ts +++ b/src/management/api/resources/actions/resources/modules/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -38,6 +39,8 @@ export class ModulesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.list({ @@ -130,8 +133,15 @@ export class ModulesClient { (request?.per_page == null || (response?.modules ?? []).length >= request?.per_page), getItems: (response) => response?.modules ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -147,6 +157,8 @@ export class ModulesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.create({ @@ -183,7 +195,7 @@ export class ModulesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -232,6 +244,8 @@ export class ModulesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.get("id") @@ -258,7 +272,7 @@ export class ModulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -312,6 +326,8 @@ export class ModulesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.PreconditionFailedError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.delete("id") @@ -335,7 +351,7 @@ export class ModulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -392,6 +408,8 @@ export class ModulesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.update("id") @@ -420,14 +438,14 @@ export class ModulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -479,6 +497,8 @@ export class ModulesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.listActions("id", { @@ -511,7 +531,7 @@ export class ModulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}/actions`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}/actions`, ), method: "GET", headers: _headers, @@ -579,8 +599,15 @@ export class ModulesClient { (request?.per_page == null || (response?.actions ?? []).length >= request?.per_page), getItems: (response) => response?.actions ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -598,6 +625,8 @@ export class ModulesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.rollback("id", { @@ -628,14 +657,14 @@ export class ModulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}/rollback`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}/rollback`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/actions/resources/modules/resources/versions/client/Client.ts b/src/management/api/resources/actions/resources/modules/resources/versions/client/Client.ts index 135bd5e67a..8962a29c0b 100644 --- a/src/management/api/resources/actions/resources/modules/resources/versions/client/Client.ts +++ b/src/management/api/resources/actions/resources/modules/resources/versions/client/Client.ts @@ -37,6 +37,8 @@ export class VersionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.versions.list("id", { @@ -69,7 +71,7 @@ export class VersionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}/versions`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}/versions`, ), method: "GET", headers: _headers, @@ -137,8 +139,15 @@ export class VersionsClient { (request?.per_page == null || (response?.versions ?? []).length >= request?.per_page), getItems: (response) => response?.versions ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -155,6 +164,8 @@ export class VersionsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.PreconditionFailedError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.versions.create("id") @@ -181,7 +192,7 @@ export class VersionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}/versions`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}/versions`, ), method: "POST", headers: _headers, @@ -245,6 +256,8 @@ export class VersionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.modules.versions.get("id", "versionId") @@ -273,7 +286,7 @@ export class VersionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/modules/${core.url.encodePathParam(id)}/versions/${core.url.encodePathParam(versionId)}`, + `actions/modules/${core.url.encodePathParam(id, errors.ManagementError)}/versions/${core.url.encodePathParam(versionId, errors.ManagementError)}`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/actions/resources/triggers/client/Client.ts b/src/management/api/resources/actions/resources/triggers/client/Client.ts index d782fd7085..05376641f1 100644 --- a/src/management/api/resources/actions/resources/triggers/client/Client.ts +++ b/src/management/api/resources/actions/resources/triggers/client/Client.ts @@ -37,6 +37,8 @@ export class TriggersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.triggers.list() diff --git a/src/management/api/resources/actions/resources/triggers/resources/bindings/client/Client.ts b/src/management/api/resources/actions/resources/triggers/resources/bindings/client/Client.ts index 2a26fe190c..e7757c425a 100644 --- a/src/management/api/resources/actions/resources/triggers/resources/bindings/client/Client.ts +++ b/src/management/api/resources/actions/resources/triggers/resources/bindings/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -36,6 +37,8 @@ export class BindingsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.triggers.bindings.list("post-login", { @@ -68,7 +71,7 @@ export class BindingsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/triggers/${core.url.encodePathParam(triggerId)}/bindings`, + `actions/triggers/${core.url.encodePathParam(triggerId, errors.ManagementError)}/bindings`, ), method: "GET", headers: _headers, @@ -134,8 +137,15 @@ export class BindingsClient { (request?.per_page == null || (response?.bindings ?? []).length >= request?.per_page), getItems: (response) => response?.bindings ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -151,6 +161,8 @@ export class BindingsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.triggers.bindings.updateMany("post-login") @@ -179,14 +191,14 @@ export class BindingsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/triggers/${core.url.encodePathParam(triggerId)}/bindings`, + `actions/triggers/${core.url.encodePathParam(triggerId, errors.ManagementError)}/bindings`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/actions/resources/versions/client/Client.ts b/src/management/api/resources/actions/resources/versions/client/Client.ts index 8f7b71497a..f47b344468 100644 --- a/src/management/api/resources/actions/resources/versions/client/Client.ts +++ b/src/management/api/resources/actions/resources/versions/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class VersionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.versions.list("actionId", { @@ -65,7 +68,7 @@ export class VersionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(actionId)}/versions`, + `actions/actions/${core.url.encodePathParam(actionId, errors.ManagementError)}/versions`, ), method: "GET", headers: _headers, @@ -131,8 +134,15 @@ export class VersionsClient { (request?.per_page == null || (response?.versions ?? []).length >= request?.per_page), getItems: (response) => response?.versions ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -149,6 +159,8 @@ export class VersionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.versions.get("actionId", "id") @@ -177,7 +189,7 @@ export class VersionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(actionId)}/versions/${core.url.encodePathParam(id)}`, + `actions/actions/${core.url.encodePathParam(actionId, errors.ManagementError)}/versions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -236,6 +248,8 @@ export class VersionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.actions.versions.deploy("actionId", "id") @@ -266,14 +280,14 @@ export class VersionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `actions/actions/${core.url.encodePathParam(actionId)}/versions/${core.url.encodePathParam(id)}/deploy`, + `actions/actions/${core.url.encodePathParam(actionId, errors.ManagementError)}/versions/${core.url.encodePathParam(id, errors.ManagementError)}/deploy`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/agents/client/Client.ts b/src/management/api/resources/agents/client/Client.ts index ceb76a840f..b29c34531d 100644 --- a/src/management/api/resources/agents/client/Client.ts +++ b/src/management/api/resources/agents/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class AgentsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.agents.list({ @@ -138,6 +141,8 @@ export class AgentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.agents.create({ @@ -173,7 +178,7 @@ export class AgentsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -218,6 +223,8 @@ export class AgentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.agents.read("id") @@ -244,7 +251,7 @@ export class AgentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `agents/${core.url.encodePathParam(id)}`, + `agents/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -291,6 +298,8 @@ export class AgentsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.agents.delete("id") @@ -314,7 +323,7 @@ export class AgentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `agents/${core.url.encodePathParam(id)}`, + `agents/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -363,6 +372,8 @@ export class AgentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.agents.update("id") @@ -391,14 +402,14 @@ export class AgentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `agents/${core.url.encodePathParam(id)}`, + `agents/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/anomaly/resources/blocks/client/Client.ts b/src/management/api/resources/anomaly/resources/blocks/client/Client.ts index 694b73b679..3adad1aa1a 100644 --- a/src/management/api/resources/anomaly/resources/blocks/client/Client.ts +++ b/src/management/api/resources/anomaly/resources/blocks/client/Client.ts @@ -33,6 +33,8 @@ export class BlocksClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.anomaly.blocks.checkIp("id") @@ -59,7 +61,7 @@ export class BlocksClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `anomaly/blocks/ips/${core.url.encodePathParam(id)}`, + `anomaly/blocks/ips/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -108,6 +110,8 @@ export class BlocksClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.anomaly.blocks.unblockIp("id") @@ -134,7 +138,7 @@ export class BlocksClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `anomaly/blocks/ips/${core.url.encodePathParam(id)}`, + `anomaly/blocks/ips/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/attackProtection/client/Client.ts b/src/management/api/resources/attackProtection/client/Client.ts index 1835f6bca7..7458d7f1b9 100644 --- a/src/management/api/resources/attackProtection/client/Client.ts +++ b/src/management/api/resources/attackProtection/client/Client.ts @@ -8,7 +8,6 @@ import { BotDetectionClient } from "../resources/botDetection/client/Client.js"; import { BreachedPasswordDetectionClient } from "../resources/breachedPasswordDetection/client/Client.js"; import { BruteForceProtectionClient } from "../resources/bruteForceProtection/client/Client.js"; import { CaptchaClient } from "../resources/captcha/client/Client.js"; -import { CaptchaPoliciesClient } from "../resources/captchaPolicies/client/Client.js"; import { PhoneProviderProtectionClient } from "../resources/phoneProviderProtection/client/Client.js"; import { SuspiciousIpThrottlingClient } from "../resources/suspiciousIpThrottling/client/Client.js"; @@ -22,7 +21,6 @@ export class AttackProtectionClient { protected _breachedPasswordDetection: BreachedPasswordDetectionClient | undefined; protected _bruteForceProtection: BruteForceProtectionClient | undefined; protected _captcha: CaptchaClient | undefined; - protected _captchaPolicies: CaptchaPoliciesClient | undefined; protected _phoneProviderProtection: PhoneProviderProtectionClient | undefined; protected _suspiciousIpThrottling: SuspiciousIpThrottlingClient | undefined; @@ -46,10 +44,6 @@ export class AttackProtectionClient { return (this._captcha ??= new CaptchaClient(this._options)); } - public get captchaPolicies(): CaptchaPoliciesClient { - return (this._captchaPolicies ??= new CaptchaPoliciesClient(this._options)); - } - public get phoneProviderProtection(): PhoneProviderProtectionClient { return (this._phoneProviderProtection ??= new PhoneProviderProtectionClient(this._options)); } diff --git a/src/management/api/resources/attackProtection/resources/botDetection/client/Client.ts b/src/management/api/resources/attackProtection/resources/botDetection/client/Client.ts index 406ed0c264..d22ab26575 100644 --- a/src/management/api/resources/attackProtection/resources/botDetection/client/Client.ts +++ b/src/management/api/resources/attackProtection/resources/botDetection/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class BotDetectionClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.botDetection.get() @@ -111,6 +114,8 @@ export class BotDetectionClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.botDetection.update() @@ -144,7 +149,7 @@ export class BotDetectionClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/attackProtection/resources/breachedPasswordDetection/client/Client.ts b/src/management/api/resources/attackProtection/resources/breachedPasswordDetection/client/Client.ts index 69691eccce..321cd30a49 100644 --- a/src/management/api/resources/attackProtection/resources/breachedPasswordDetection/client/Client.ts +++ b/src/management/api/resources/attackProtection/resources/breachedPasswordDetection/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -30,6 +31,8 @@ export class BreachedPasswordDetectionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.breachedPasswordDetection.get() @@ -107,6 +110,8 @@ export class BreachedPasswordDetectionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.breachedPasswordDetection.update() @@ -140,7 +145,7 @@ export class BreachedPasswordDetectionClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/attackProtection/resources/bruteForceProtection/client/Client.ts b/src/management/api/resources/attackProtection/resources/bruteForceProtection/client/Client.ts index ef5d3977f5..24779f1bfb 100644 --- a/src/management/api/resources/attackProtection/resources/bruteForceProtection/client/Client.ts +++ b/src/management/api/resources/attackProtection/resources/bruteForceProtection/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -30,6 +31,8 @@ export class BruteForceProtectionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.bruteForceProtection.get() @@ -107,6 +110,8 @@ export class BruteForceProtectionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.bruteForceProtection.update() @@ -140,7 +145,7 @@ export class BruteForceProtectionClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/attackProtection/resources/captcha/client/Client.ts b/src/management/api/resources/attackProtection/resources/captcha/client/Client.ts index e883ca4058..098e8e7470 100644 --- a/src/management/api/resources/attackProtection/resources/captcha/client/Client.ts +++ b/src/management/api/resources/attackProtection/resources/captcha/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class CaptchaClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.captcha.get() @@ -105,6 +108,8 @@ export class CaptchaClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.captcha.update() @@ -138,7 +143,7 @@ export class CaptchaClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/attackProtection/resources/captchaPolicies/client/Client.ts b/src/management/api/resources/attackProtection/resources/captchaPolicies/client/Client.ts deleted file mode 100644 index 736eaf399b..0000000000 --- a/src/management/api/resources/attackProtection/resources/captchaPolicies/client/Client.ts +++ /dev/null @@ -1,455 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; -import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; -import * as core from "../../../../../../core/index.js"; -import { mergeHeaders } from "../../../../../../core/headers.js"; -import * as environments from "../../../../../../environments.js"; -import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; -import * as errors from "../../../../../../errors/index.js"; -import * as Management from "../../../../../index.js"; - -export declare namespace CaptchaPoliciesClient { - export type Options = BaseClientOptions; - - export interface RequestOptions extends BaseRequestOptions {} -} - -export class CaptchaPoliciesClient { - protected readonly _options: NormalizedClientOptionsWithAuth; - - constructor(options: CaptchaPoliciesClient.Options) { - this._options = normalizeClientOptionsWithAuth(options); - } - - /** - * Retrieve all CAPTCHA attack protection policies for the tenant, sorted by priority ascending. - * - * @param {CaptchaPoliciesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Management.BadRequestError} - * @throws {@link Management.UnauthorizedError} - * @throws {@link Management.ForbiddenError} - * @throws {@link Management.NotFoundError} - * @throws {@link Management.TooManyRequestsError} - * - * @example - * await client.attackProtection.captchaPolicies.list() - */ - public list( - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); - } - - private async __list( - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - let _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.ManagementEnvironment.Default, - "attack-protection/captcha/policies", - ), - method: "GET", - headers: _headers, - queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Management.ListAttackProtectionCaptchaPoliciesResponseContent, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Management.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Management.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); - case 403: - throw new Management.ForbiddenError(_response.error.body as unknown, _response.rawResponse); - case 404: - throw new Management.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 429: - throw new Management.TooManyRequestsError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.ManagementError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/attack-protection/captcha/policies", - ); - } - - /** - * Create a new CAPTCHA attack protection policy for the tenant. The maximum number of policies per tenant is determined by the tenant's subscription. - * - * @param {Management.CreateAttackProtectionCaptchaPolicyRequestContent} request - * @param {CaptchaPoliciesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Management.BadRequestError} - * @throws {@link Management.UnauthorizedError} - * @throws {@link Management.ForbiddenError} - * @throws {@link Management.NotFoundError} - * @throws {@link Management.ConflictError} - * @throws {@link Management.TooManyRequestsError} - * - * @example - * await client.attackProtection.captchaPolicies.create({ - * name: "name", - * priority: 1, - * match: {}, - * action: {} - * }) - */ - public create( - request: Management.CreateAttackProtectionCaptchaPolicyRequestContent, - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); - } - - private async __create( - request: Management.CreateAttackProtectionCaptchaPolicyRequestContent, - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - let _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.ManagementEnvironment.Default, - "attack-protection/captcha/policies", - ), - method: "POST", - headers: _headers, - contentType: "application/json", - queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Management.AttackProtectionCaptchaPolicy, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Management.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Management.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); - case 403: - throw new Management.ForbiddenError(_response.error.body as unknown, _response.rawResponse); - case 404: - throw new Management.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 409: - throw new Management.ConflictError(_response.error.body as unknown, _response.rawResponse); - case 429: - throw new Management.TooManyRequestsError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.ManagementError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "POST", - "/attack-protection/captcha/policies", - ); - } - - /** - * Retrieve a single CAPTCHA attack protection policy for the tenant by ID. - * - * @param {string} id - ID of the CAPTCHA attack protection policy. - * @param {CaptchaPoliciesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Management.BadRequestError} - * @throws {@link Management.UnauthorizedError} - * @throws {@link Management.ForbiddenError} - * @throws {@link Management.NotFoundError} - * @throws {@link Management.TooManyRequestsError} - * - * @example - * await client.attackProtection.captchaPolicies.get("id") - */ - public get( - id: string, - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__get(id, requestOptions)); - } - - private async __get( - id: string, - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - let _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.ManagementEnvironment.Default, - `attack-protection/captcha/policies/${core.url.encodePathParam(id)}`, - ), - method: "GET", - headers: _headers, - queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Management.AttackProtectionCaptchaPolicy, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Management.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Management.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); - case 403: - throw new Management.ForbiddenError(_response.error.body as unknown, _response.rawResponse); - case 404: - throw new Management.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 429: - throw new Management.TooManyRequestsError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.ManagementError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "GET", - "/attack-protection/captcha/policies/{id}", - ); - } - - /** - * Delete a CAPTCHA attack protection policy for the tenant. - * - * @param {string} id - ID of the CAPTCHA attack protection policy. - * @param {CaptchaPoliciesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Management.BadRequestError} - * @throws {@link Management.UnauthorizedError} - * @throws {@link Management.ForbiddenError} - * @throws {@link Management.NotFoundError} - * @throws {@link Management.TooManyRequestsError} - * - * @example - * await client.attackProtection.captchaPolicies.delete("id") - */ - public delete(id: string, requestOptions?: CaptchaPoliciesClient.RequestOptions): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__delete(id, requestOptions)); - } - - private async __delete( - id: string, - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - let _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.ManagementEnvironment.Default, - `attack-protection/captcha/policies/${core.url.encodePathParam(id)}`, - ), - method: "DELETE", - headers: _headers, - queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { data: undefined, rawResponse: _response.rawResponse }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Management.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Management.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); - case 403: - throw new Management.ForbiddenError(_response.error.body as unknown, _response.rawResponse); - case 404: - throw new Management.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 429: - throw new Management.TooManyRequestsError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.ManagementError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "DELETE", - "/attack-protection/captcha/policies/{id}", - ); - } - - /** - * Partially update a CAPTCHA attack protection policy. Only the provided fields are modified. A provided match or action replaces the stored value in full rather than merging with it; within action, a provider secret or API key that is omitted from a provided provider block keeps its stored value. - * - * @param {string} id - ID of the CAPTCHA attack protection policy. - * @param {Management.UpdateAttackProtectionCaptchaPolicyRequestContent} request - * @param {CaptchaPoliciesClient.RequestOptions} requestOptions - Request-specific configuration. - * - * @throws {@link Management.BadRequestError} - * @throws {@link Management.UnauthorizedError} - * @throws {@link Management.ForbiddenError} - * @throws {@link Management.NotFoundError} - * @throws {@link Management.ConflictError} - * @throws {@link Management.TooManyRequestsError} - * - * @example - * await client.attackProtection.captchaPolicies.update("id") - */ - public update( - id: string, - request: Management.UpdateAttackProtectionCaptchaPolicyRequestContent = {}, - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): core.HttpResponsePromise { - return core.HttpResponsePromise.fromPromise(this.__update(id, request, requestOptions)); - } - - private async __update( - id: string, - request: Management.UpdateAttackProtectionCaptchaPolicyRequestContent = {}, - requestOptions?: CaptchaPoliciesClient.RequestOptions, - ): Promise> { - const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); - let _headers: core.Fetcher.Args["headers"] = mergeHeaders( - _authRequest.headers, - this._options?.headers, - requestOptions?.headers, - ); - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: core.url.join( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.ManagementEnvironment.Default, - `attack-protection/captcha/policies/${core.url.encodePathParam(id)}`, - ), - method: "PATCH", - headers: _headers, - contentType: "application/json", - queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), - requestType: "json", - body: request, - timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, - maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, - abortSignal: requestOptions?.abortSignal, - fetchFn: this._options?.fetch, - logging: this._options.logging, - }); - if (_response.ok) { - return { - data: _response.body as Management.AttackProtectionCaptchaPolicy, - rawResponse: _response.rawResponse, - }; - } - - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 400: - throw new Management.BadRequestError(_response.error.body as unknown, _response.rawResponse); - case 401: - throw new Management.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); - case 403: - throw new Management.ForbiddenError(_response.error.body as unknown, _response.rawResponse); - case 404: - throw new Management.NotFoundError(_response.error.body as unknown, _response.rawResponse); - case 409: - throw new Management.ConflictError(_response.error.body as unknown, _response.rawResponse); - case 429: - throw new Management.TooManyRequestsError(_response.error.body as unknown, _response.rawResponse); - default: - throw new errors.ManagementError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - rawResponse: _response.rawResponse, - }); - } - } - - return handleNonStatusCodeError( - _response.error, - _response.rawResponse, - "PATCH", - "/attack-protection/captcha/policies/{id}", - ); - } -} diff --git a/src/management/api/resources/attackProtection/resources/captchaPolicies/client/index.ts b/src/management/api/resources/attackProtection/resources/captchaPolicies/client/index.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/src/management/api/resources/attackProtection/resources/captchaPolicies/client/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/src/management/api/resources/attackProtection/resources/captchaPolicies/exports.ts b/src/management/api/resources/attackProtection/resources/captchaPolicies/exports.ts deleted file mode 100644 index 30f5ea983b..0000000000 --- a/src/management/api/resources/attackProtection/resources/captchaPolicies/exports.ts +++ /dev/null @@ -1,4 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export { CaptchaPoliciesClient } from "./client/Client.js"; -export * from "./client/index.js"; diff --git a/src/management/api/resources/attackProtection/resources/captchaPolicies/index.ts b/src/management/api/resources/attackProtection/resources/captchaPolicies/index.ts deleted file mode 100644 index 914b8c3c72..0000000000 --- a/src/management/api/resources/attackProtection/resources/captchaPolicies/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./client/index.js"; diff --git a/src/management/api/resources/attackProtection/resources/index.ts b/src/management/api/resources/attackProtection/resources/index.ts index dc44c1dd38..0e56ff80f4 100644 --- a/src/management/api/resources/attackProtection/resources/index.ts +++ b/src/management/api/resources/attackProtection/resources/index.ts @@ -2,6 +2,5 @@ export * as botDetection from "./botDetection/index.js"; export * as breachedPasswordDetection from "./breachedPasswordDetection/index.js"; export * as bruteForceProtection from "./bruteForceProtection/index.js"; export * as captcha from "./captcha/index.js"; -export * as captchaPolicies from "./captchaPolicies/index.js"; export * as phoneProviderProtection from "./phoneProviderProtection/index.js"; export * as suspiciousIpThrottling from "./suspiciousIpThrottling/index.js"; diff --git a/src/management/api/resources/attackProtection/resources/phoneProviderProtection/client/Client.ts b/src/management/api/resources/attackProtection/resources/phoneProviderProtection/client/Client.ts index be6dd8541f..65734e4837 100644 --- a/src/management/api/resources/attackProtection/resources/phoneProviderProtection/client/Client.ts +++ b/src/management/api/resources/attackProtection/resources/phoneProviderProtection/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class PhoneProviderProtectionClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.phoneProviderProtection.get() @@ -109,6 +112,8 @@ export class PhoneProviderProtectionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.phoneProviderProtection.patch({ @@ -144,7 +149,7 @@ export class PhoneProviderProtectionClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/attackProtection/resources/suspiciousIpThrottling/client/Client.ts b/src/management/api/resources/attackProtection/resources/suspiciousIpThrottling/client/Client.ts index e63797cc0c..52583751af 100644 --- a/src/management/api/resources/attackProtection/resources/suspiciousIpThrottling/client/Client.ts +++ b/src/management/api/resources/attackProtection/resources/suspiciousIpThrottling/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -30,6 +31,8 @@ export class SuspiciousIpThrottlingClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.suspiciousIpThrottling.get() @@ -107,6 +110,8 @@ export class SuspiciousIpThrottlingClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.attackProtection.suspiciousIpThrottling.update() @@ -140,7 +145,7 @@ export class SuspiciousIpThrottlingClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/branding/client/Client.ts b/src/management/api/resources/branding/client/Client.ts index cf87110923..04d52da2b7 100644 --- a/src/management/api/resources/branding/client/Client.ts +++ b/src/management/api/resources/branding/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -48,6 +49,8 @@ export class BrandingClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.get() @@ -120,6 +123,8 @@ export class BrandingClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.update() @@ -153,7 +158,7 @@ export class BrandingClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/branding/resources/phone/resources/providers/client/Client.ts b/src/management/api/resources/branding/resources/phone/resources/providers/client/Client.ts index df9ec802ad..dfbb1ce7c3 100644 --- a/src/management/api/resources/branding/resources/phone/resources/providers/client/Client.ts +++ b/src/management/api/resources/branding/resources/phone/resources/providers/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -35,6 +36,8 @@ export class ProvidersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.providers.list({ @@ -123,6 +126,8 @@ export class ProvidersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.providers.create({ @@ -161,7 +166,7 @@ export class ProvidersClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -210,6 +215,8 @@ export class ProvidersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.providers.get("id") @@ -236,7 +243,7 @@ export class ProvidersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/providers/${core.url.encodePathParam(id)}`, + `branding/phone/providers/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -293,6 +300,8 @@ export class ProvidersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.providers.delete("id") @@ -316,7 +325,7 @@ export class ProvidersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/providers/${core.url.encodePathParam(id)}`, + `branding/phone/providers/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -372,6 +381,8 @@ export class ProvidersClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.providers.update("id") @@ -400,14 +411,14 @@ export class ProvidersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/providers/${core.url.encodePathParam(id)}`, + `branding/phone/providers/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -463,6 +474,8 @@ export class ProvidersClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.providers.test("id", { @@ -493,14 +506,14 @@ export class ProvidersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/providers/${core.url.encodePathParam(id)}/try`, + `branding/phone/providers/${core.url.encodePathParam(id, errors.ManagementError)}/try`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/branding/resources/phone/resources/templates/client/Client.ts b/src/management/api/resources/branding/resources/phone/resources/templates/client/Client.ts index 0202ca1b39..a7b64a7748 100644 --- a/src/management/api/resources/branding/resources/phone/resources/templates/client/Client.ts +++ b/src/management/api/resources/branding/resources/phone/resources/templates/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class TemplatesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.templates.list({ @@ -118,6 +121,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.templates.create() @@ -151,7 +156,7 @@ export class TemplatesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -198,6 +203,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.templates.get("id") @@ -224,7 +231,7 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/templates/${core.url.encodePathParam(id)}`, + `branding/phone/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -280,6 +287,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.templates.delete("id") @@ -303,7 +312,7 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/templates/${core.url.encodePathParam(id)}`, + `branding/phone/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -357,6 +366,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.templates.update("id") @@ -385,14 +396,14 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/templates/${core.url.encodePathParam(id)}`, + `branding/phone/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -444,6 +455,8 @@ export class TemplatesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.templates.reset("id", { @@ -474,14 +487,14 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/templates/${core.url.encodePathParam(id)}/reset`, + `branding/phone/templates/${core.url.encodePathParam(id, errors.ManagementError)}/reset`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -532,6 +545,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.phone.templates.test("id", { @@ -562,14 +577,14 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/phone/templates/${core.url.encodePathParam(id)}/try`, + `branding/phone/templates/${core.url.encodePathParam(id, errors.ManagementError)}/try`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/branding/resources/templates/client/Client.ts b/src/management/api/resources/branding/resources/templates/client/Client.ts index 7e58c0bd08..456e4ea106 100644 --- a/src/management/api/resources/branding/resources/templates/client/Client.ts +++ b/src/management/api/resources/branding/resources/templates/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -30,6 +31,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.templates.getUniversalLogin() @@ -136,6 +139,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.templates.updateUniversalLogin("string") @@ -169,7 +174,7 @@ export class TemplatesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -218,6 +223,8 @@ export class TemplatesClient { * @throws {@link Management.PaymentRequiredError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.templates.deleteUniversalLogin() diff --git a/src/management/api/resources/branding/resources/themes/client/Client.ts b/src/management/api/resources/branding/resources/themes/client/Client.ts index 3689bb96a9..7952347460 100644 --- a/src/management/api/resources/branding/resources/themes/client/Client.ts +++ b/src/management/api/resources/branding/resources/themes/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class ThemesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.themes.create({ @@ -137,7 +140,7 @@ export class ThemesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -184,6 +187,8 @@ export class ThemesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.themes.getDefault() @@ -258,6 +263,8 @@ export class ThemesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.themes.get("themeId") @@ -284,7 +291,7 @@ export class ThemesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/themes/${core.url.encodePathParam(themeId)}`, + `branding/themes/${core.url.encodePathParam(themeId, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -334,6 +341,8 @@ export class ThemesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.themes.delete("themeId") @@ -357,7 +366,7 @@ export class ThemesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/themes/${core.url.encodePathParam(themeId)}`, + `branding/themes/${core.url.encodePathParam(themeId, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -406,6 +415,8 @@ export class ThemesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.branding.themes.update("themeId", { @@ -505,14 +516,14 @@ export class ThemesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `branding/themes/${core.url.encodePathParam(themeId)}`, + `branding/themes/${core.url.encodePathParam(themeId, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/clientGrants/client/Client.ts b/src/management/api/resources/clientGrants/client/Client.ts index 68e0881a31..f7e2804a9f 100644 --- a/src/management/api/resources/clientGrants/client/Client.ts +++ b/src/management/api/resources/clientGrants/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -37,6 +38,8 @@ export class ClientGrantsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientGrants.list({ @@ -162,6 +165,8 @@ export class ClientGrantsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientGrants.create({ @@ -197,7 +202,7 @@ export class ClientGrantsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -251,6 +256,8 @@ export class ClientGrantsClient { * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} * @throws {@link Management.GatewayTimeoutError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientGrants.search({ @@ -379,6 +386,8 @@ export class ClientGrantsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientGrants.get("id") @@ -405,7 +414,7 @@ export class ClientGrantsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `client-grants/${core.url.encodePathParam(id)}`, + `client-grants/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -455,6 +464,8 @@ export class ClientGrantsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientGrants.delete("id") @@ -478,7 +489,7 @@ export class ClientGrantsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `client-grants/${core.url.encodePathParam(id)}`, + `client-grants/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -527,6 +538,8 @@ export class ClientGrantsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientGrants.update("id") @@ -555,14 +568,14 @@ export class ClientGrantsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `client-grants/${core.url.encodePathParam(id)}`, + `client-grants/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/clientGrants/resources/organizations/client/Client.ts b/src/management/api/resources/clientGrants/resources/organizations/client/Client.ts index 1257bedeef..8688faf85b 100644 --- a/src/management/api/resources/clientGrants/resources/organizations/client/Client.ts +++ b/src/management/api/resources/clientGrants/resources/organizations/client/Client.ts @@ -32,6 +32,8 @@ export class OrganizationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientGrants.organizations.list("id", { @@ -66,7 +68,7 @@ export class OrganizationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `client-grants/${core.url.encodePathParam(id)}/organizations`, + `client-grants/${core.url.encodePathParam(id, errors.ManagementError)}/organizations`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/clientProfiles/client/Client.ts b/src/management/api/resources/clientProfiles/client/Client.ts index 321b5e53d7..bfcf2a0452 100644 --- a/src/management/api/resources/clientProfiles/client/Client.ts +++ b/src/management/api/resources/clientProfiles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class ClientProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientProfiles.list({ @@ -138,6 +141,8 @@ export class ClientProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientProfiles.create({ @@ -178,7 +183,7 @@ export class ClientProfilesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -224,6 +229,8 @@ export class ClientProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientProfiles.get("id") @@ -250,7 +257,7 @@ export class ClientProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `client-profiles/${core.url.encodePathParam(id)}`, + `client-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -299,6 +306,8 @@ export class ClientProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientProfiles.delete("id") @@ -325,7 +334,7 @@ export class ClientProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `client-profiles/${core.url.encodePathParam(id)}`, + `client-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -374,6 +383,8 @@ export class ClientProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clientProfiles.update("id") @@ -402,14 +413,14 @@ export class ClientProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `client-profiles/${core.url.encodePathParam(id)}`, + `client-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/clients/client/Client.ts b/src/management/api/resources/clients/client/Client.ts index eb5d47542d..a833b70eed 100644 --- a/src/management/api/resources/clients/client/Client.ts +++ b/src/management/api/resources/clients/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -68,6 +69,8 @@ export class ClientsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.list({ @@ -187,8 +190,15 @@ export class ClientsClient { (request?.per_page == null || (response?.clients ?? []).length >= request?.per_page), getItems: (response) => response?.clients ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -218,6 +228,8 @@ export class ClientsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.create({ @@ -253,7 +265,7 @@ export class ClientsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -308,6 +320,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.previewCimdMetadata({ @@ -343,7 +357,7 @@ export class ClientsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -403,6 +417,8 @@ export class ClientsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.registerCimdClient({ @@ -438,7 +454,7 @@ export class ClientsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -502,6 +518,8 @@ export class ClientsClient { * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} * @throws {@link Management.GatewayTimeoutError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.search({ @@ -654,6 +672,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.get("id", { @@ -690,7 +710,7 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(id)}`, + `clients/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -743,6 +763,8 @@ export class ClientsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.delete("id") @@ -766,7 +788,7 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(id)}`, + `clients/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -823,6 +845,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.update("id") @@ -851,14 +875,14 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(id)}`, + `clients/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -911,6 +935,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.rotateSecret("id") @@ -937,7 +963,7 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(id)}/rotate-secret`, + `clients/${core.url.encodePathParam(id, errors.ManagementError)}/rotate-secret`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/clients/resources/connections/client/Client.ts b/src/management/api/resources/clients/resources/connections/client/Client.ts index 818f4cbfe6..dcd0e32811 100644 --- a/src/management/api/resources/clients/resources/connections/client/Client.ts +++ b/src/management/api/resources/clients/resources/connections/client/Client.ts @@ -37,6 +37,8 @@ export class ConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.connections.get("id", { @@ -79,7 +81,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(id)}/connections`, + `clients/${core.url.encodePathParam(id, errors.ManagementError)}/connections`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/clients/resources/credentials/client/Client.ts b/src/management/api/resources/clients/resources/credentials/client/Client.ts index 8ab6a8dc03..cd4780383c 100644 --- a/src/management/api/resources/clients/resources/credentials/client/Client.ts +++ b/src/management/api/resources/clients/resources/credentials/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class CredentialsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.credentials.list("client_id") @@ -60,7 +63,7 @@ export class CredentialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(client_id)}/credentials`, + `clients/${core.url.encodePathParam(client_id, errors.ManagementError)}/credentials`, ), method: "GET", headers: _headers, @@ -170,6 +173,8 @@ export class CredentialsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.credentials.create("client_id", { @@ -200,14 +205,14 @@ export class CredentialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(client_id)}/credentials`, + `clients/${core.url.encodePathParam(client_id, errors.ManagementError)}/credentials`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -263,6 +268,8 @@ export class CredentialsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.credentials.get("client_id", "credential_id") @@ -291,7 +298,7 @@ export class CredentialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(client_id)}/credentials/${core.url.encodePathParam(credential_id)}`, + `clients/${core.url.encodePathParam(client_id, errors.ManagementError)}/credentials/${core.url.encodePathParam(credential_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -347,6 +354,8 @@ export class CredentialsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.credentials.delete("client_id", "credential_id") @@ -375,7 +384,7 @@ export class CredentialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(client_id)}/credentials/${core.url.encodePathParam(credential_id)}`, + `clients/${core.url.encodePathParam(client_id, errors.ManagementError)}/credentials/${core.url.encodePathParam(credential_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -430,6 +439,8 @@ export class CredentialsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.clients.credentials.update("client_id", "credential_id") @@ -460,14 +471,14 @@ export class CredentialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `clients/${core.url.encodePathParam(client_id)}/credentials/${core.url.encodePathParam(credential_id)}`, + `clients/${core.url.encodePathParam(client_id, errors.ManagementError)}/credentials/${core.url.encodePathParam(credential_id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/connectionProfiles/client/Client.ts b/src/management/api/resources/connectionProfiles/client/Client.ts index 7be21f26d8..ece83878e5 100644 --- a/src/management/api/resources/connectionProfiles/client/Client.ts +++ b/src/management/api/resources/connectionProfiles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class ConnectionProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connectionProfiles.list({ @@ -138,6 +141,8 @@ export class ConnectionProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connectionProfiles.create({ @@ -173,7 +178,7 @@ export class ConnectionProfilesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -219,6 +224,8 @@ export class ConnectionProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connectionProfiles.listTemplates() @@ -296,6 +303,8 @@ export class ConnectionProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connectionProfiles.getTemplate("id") @@ -322,7 +331,7 @@ export class ConnectionProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connection-profiles/templates/${core.url.encodePathParam(id)}`, + `connection-profiles/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -377,6 +386,8 @@ export class ConnectionProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connectionProfiles.get("id") @@ -403,7 +414,7 @@ export class ConnectionProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connection-profiles/${core.url.encodePathParam(id)}`, + `connection-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -452,6 +463,8 @@ export class ConnectionProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connectionProfiles.delete("id") @@ -478,7 +491,7 @@ export class ConnectionProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connection-profiles/${core.url.encodePathParam(id)}`, + `connection-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -525,6 +538,8 @@ export class ConnectionProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connectionProfiles.update("id") @@ -553,14 +568,14 @@ export class ConnectionProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connection-profiles/${core.url.encodePathParam(id)}`, + `connection-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/connections/client/Client.ts b/src/management/api/resources/connections/client/Client.ts index ced9b77347..010e92dbe9 100644 --- a/src/management/api/resources/connections/client/Client.ts +++ b/src/management/api/resources/connections/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -78,6 +79,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.list({ @@ -212,6 +215,8 @@ export class ConnectionsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.UnprocessableEntityError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.create({ @@ -248,7 +253,7 @@ export class ConnectionsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -303,6 +308,8 @@ export class ConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.get("id", { @@ -339,7 +346,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -397,6 +404,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.delete("id") @@ -420,7 +429,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -473,6 +482,8 @@ export class ConnectionsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.UnprocessableEntityError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.update("id") @@ -501,14 +512,14 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -564,6 +575,8 @@ export class ConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.checkStatus("id") @@ -587,7 +600,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/status`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/status`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/connections/resources/clients/client/Client.ts b/src/management/api/resources/connections/resources/clients/client/Client.ts index 322dce0a5b..2469664adf 100644 --- a/src/management/api/resources/connections/resources/clients/client/Client.ts +++ b/src/management/api/resources/connections/resources/clients/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -36,6 +37,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.clients.get("id", { @@ -68,7 +71,7 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/clients`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/clients`, ), method: "GET", headers: _headers, @@ -151,6 +154,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.clients.update("id", [{ @@ -182,14 +187,14 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/clients`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/clients`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/connections/resources/directoryProvisioning/client/Client.ts b/src/management/api/resources/connections/resources/directoryProvisioning/client/Client.ts index e59da3f42c..4b2dfe85d3 100644 --- a/src/management/api/resources/connections/resources/directoryProvisioning/client/Client.ts +++ b/src/management/api/resources/connections/resources/directoryProvisioning/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -38,6 +39,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.list({ @@ -149,6 +152,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.get("id") @@ -175,7 +180,7 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning`, ), method: "GET", headers: _headers, @@ -235,6 +240,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.create("id") @@ -263,14 +270,14 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -326,6 +333,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.delete("id") @@ -352,7 +361,7 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning`, ), method: "DELETE", headers: _headers, @@ -408,6 +417,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.update("id") @@ -436,14 +447,14 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -497,6 +508,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.getDefaultMapping("id") @@ -523,7 +536,7 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning/default-mapping`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning/default-mapping`, ), method: "GET", headers: _headers, @@ -582,6 +595,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.listSynchronizedGroups("id", { @@ -616,7 +631,7 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning/synchronized-groups`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning/synchronized-groups`, ), method: "GET", headers: _headers, @@ -699,6 +714,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.addSynchronizedGroupSelections("id", { @@ -731,14 +748,14 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning/synchronized-groups`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning/synchronized-groups`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -791,6 +808,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.set("id", { @@ -823,14 +842,14 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning/synchronized-groups`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning/synchronized-groups`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -884,6 +903,8 @@ export class DirectoryProvisioningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.deleteSynchronizedGroupSelections("id", { @@ -918,14 +939,14 @@ export class DirectoryProvisioningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning/synchronized-groups`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning/synchronized-groups`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/client/Client.ts b/src/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/client/Client.ts index 687b5dd7a4..1c24d1a460 100644 --- a/src/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/client/Client.ts +++ b/src/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/client/Client.ts @@ -37,6 +37,8 @@ export class SynchronizationsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.directoryProvisioning.synchronizations.create("id") @@ -63,7 +65,7 @@ export class SynchronizationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/directory-provisioning/synchronizations`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/directory-provisioning/synchronizations`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/connections/resources/keys/client/Client.ts b/src/management/api/resources/connections/resources/keys/client/Client.ts index 5d30a42953..dd098919c0 100644 --- a/src/management/api/resources/connections/resources/keys/client/Client.ts +++ b/src/management/api/resources/connections/resources/keys/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class KeysClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.keys.get("id") @@ -59,7 +62,7 @@ export class KeysClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/keys`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/keys`, ), method: "GET", headers: _headers, @@ -111,6 +114,8 @@ export class KeysClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.keys.create("id") @@ -139,14 +144,14 @@ export class KeysClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/keys`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/keys`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -198,6 +203,8 @@ export class KeysClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.keys.rotate("id") @@ -226,14 +233,14 @@ export class KeysClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/keys/rotate`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/keys/rotate`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/connections/resources/scimConfiguration/client/Client.ts b/src/management/api/resources/connections/resources/scimConfiguration/client/Client.ts index 2f60065b2d..25bdfb41d7 100644 --- a/src/management/api/resources/connections/resources/scimConfiguration/client/Client.ts +++ b/src/management/api/resources/connections/resources/scimConfiguration/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -38,6 +39,8 @@ export class ScimConfigurationClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.list({ @@ -146,6 +149,8 @@ export class ScimConfigurationClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.get("id") @@ -172,7 +177,7 @@ export class ScimConfigurationClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration`, ), method: "GET", headers: _headers, @@ -223,6 +228,8 @@ export class ScimConfigurationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.create("id") @@ -251,14 +258,14 @@ export class ScimConfigurationClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -305,6 +312,8 @@ export class ScimConfigurationClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.delete("id") @@ -328,7 +337,7 @@ export class ScimConfigurationClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration`, ), method: "DELETE", headers: _headers, @@ -375,6 +384,8 @@ export class ScimConfigurationClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.update("id", { @@ -406,14 +417,14 @@ export class ScimConfigurationClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -458,6 +469,8 @@ export class ScimConfigurationClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.getDefaultMapping("id") @@ -484,7 +497,7 @@ export class ScimConfigurationClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration/default-mapping`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration/default-mapping`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/connections/resources/scimConfiguration/resources/tokens/client/Client.ts b/src/management/api/resources/connections/resources/scimConfiguration/resources/tokens/client/Client.ts index 33f1032b0b..839032d4bd 100644 --- a/src/management/api/resources/connections/resources/scimConfiguration/resources/tokens/client/Client.ts +++ b/src/management/api/resources/connections/resources/scimConfiguration/resources/tokens/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class TokensClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.tokens.get("id") @@ -59,7 +62,7 @@ export class TokensClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration/tokens`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration/tokens`, ), method: "GET", headers: _headers, @@ -110,6 +113,8 @@ export class TokensClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.tokens.create("id") @@ -138,14 +143,14 @@ export class TokensClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration/tokens`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration/tokens`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -193,6 +198,8 @@ export class TokensClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.scimConfiguration.tokens.delete("id", "tokenId") @@ -221,7 +228,7 @@ export class TokensClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/scim-configuration/tokens/${core.url.encodePathParam(tokenId)}`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/scim-configuration/tokens/${core.url.encodePathParam(tokenId, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/connections/resources/users/client/Client.ts b/src/management/api/resources/connections/resources/users/client/Client.ts index 7a9968b387..c138e2f9ac 100644 --- a/src/management/api/resources/connections/resources/users/client/Client.ts +++ b/src/management/api/resources/connections/resources/users/client/Client.ts @@ -34,6 +34,8 @@ export class UsersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.connections.users.deleteByEmail("id", { @@ -68,7 +70,7 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `connections/${core.url.encodePathParam(id)}/users`, + `connections/${core.url.encodePathParam(id, errors.ManagementError)}/users`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/customDomains/client/Client.ts b/src/management/api/resources/customDomains/client/Client.ts index 8269fb93d9..1ae3833791 100644 --- a/src/management/api/resources/customDomains/client/Client.ts +++ b/src/management/api/resources/customDomains/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class CustomDomainsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.list({ @@ -134,6 +137,8 @@ export class CustomDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.create({ @@ -170,7 +175,7 @@ export class CustomDomainsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -216,6 +221,8 @@ export class CustomDomainsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.getDefault() @@ -286,6 +293,8 @@ export class CustomDomainsClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.setDefault({ @@ -321,7 +330,7 @@ export class CustomDomainsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -364,6 +373,8 @@ export class CustomDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.get("id") @@ -390,7 +401,7 @@ export class CustomDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `custom-domains/${core.url.encodePathParam(id)}`, + `custom-domains/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -443,6 +454,8 @@ export class CustomDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.delete("id") @@ -466,7 +479,7 @@ export class CustomDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `custom-domains/${core.url.encodePathParam(id)}`, + `custom-domains/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -547,6 +560,8 @@ export class CustomDomainsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.update("id") @@ -575,14 +590,14 @@ export class CustomDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `custom-domains/${core.url.encodePathParam(id)}`, + `custom-domains/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -629,6 +644,8 @@ export class CustomDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.test("id") @@ -655,7 +672,7 @@ export class CustomDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `custom-domains/${core.url.encodePathParam(id)}/test`, + `custom-domains/${core.url.encodePathParam(id, errors.ManagementError)}/test`, ), method: "POST", headers: _headers, @@ -715,6 +732,8 @@ export class CustomDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.customDomains.verify("id") @@ -741,7 +760,7 @@ export class CustomDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `custom-domains/${core.url.encodePathParam(id)}/verify`, + `custom-domains/${core.url.encodePathParam(id, errors.ManagementError)}/verify`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/deviceCredentials/client/Client.ts b/src/management/api/resources/deviceCredentials/client/Client.ts index 0659d1f674..d47bf79e77 100644 --- a/src/management/api/resources/deviceCredentials/client/Client.ts +++ b/src/management/api/resources/deviceCredentials/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class DeviceCredentialsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.deviceCredentials.list({ @@ -148,8 +151,15 @@ export class DeviceCredentialsClient { (request?.per_page == null || (response?.device_credentials ?? []).length >= request?.per_page), getItems: (response) => response?.device_credentials ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -167,6 +177,8 @@ export class DeviceCredentialsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.deviceCredentials.createPublicKey({ @@ -205,7 +217,7 @@ export class DeviceCredentialsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -253,6 +265,8 @@ export class DeviceCredentialsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.deviceCredentials.delete("id") @@ -276,7 +290,7 @@ export class DeviceCredentialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `device-credentials/${core.url.encodePathParam(id)}`, + `device-credentials/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/emailTemplates/client/Client.ts b/src/management/api/resources/emailTemplates/client/Client.ts index d2c3df0aec..dec09f2d8c 100644 --- a/src/management/api/resources/emailTemplates/client/Client.ts +++ b/src/management/api/resources/emailTemplates/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class EmailTemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emailTemplates.create({ @@ -68,7 +71,7 @@ export class EmailTemplatesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -116,6 +119,8 @@ export class EmailTemplatesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emailTemplates.get("verify_email") @@ -142,7 +147,7 @@ export class EmailTemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `email-templates/${core.url.encodePathParam(templateName)}`, + `email-templates/${core.url.encodePathParam(templateName, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -199,6 +204,8 @@ export class EmailTemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emailTemplates.set("verify_email", { @@ -229,14 +236,14 @@ export class EmailTemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `email-templates/${core.url.encodePathParam(templateName)}`, + `email-templates/${core.url.encodePathParam(templateName, errors.ManagementError)}`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -291,6 +298,8 @@ export class EmailTemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emailTemplates.update("verify_email") @@ -319,14 +328,14 @@ export class EmailTemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `email-templates/${core.url.encodePathParam(templateName)}`, + `email-templates/${core.url.encodePathParam(templateName, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/emails/resources/provider/client/Client.ts b/src/management/api/resources/emails/resources/provider/client/Client.ts index f4371b9b1d..bbf711d861 100644 --- a/src/management/api/resources/emails/resources/provider/client/Client.ts +++ b/src/management/api/resources/emails/resources/provider/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class ProviderClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emails.provider.get({ @@ -148,6 +151,8 @@ export class ProviderClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emails.provider.create({ @@ -186,7 +191,7 @@ export class ProviderClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -234,6 +239,8 @@ export class ProviderClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emails.provider.delete() @@ -330,6 +337,8 @@ export class ProviderClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.emails.provider.update() @@ -363,7 +372,7 @@ export class ProviderClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/eventStreams/client/Client.ts b/src/management/api/resources/eventStreams/client/Client.ts index 5d6c605b00..b574af4cee 100644 --- a/src/management/api/resources/eventStreams/client/Client.ts +++ b/src/management/api/resources/eventStreams/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -42,6 +43,8 @@ export class EventStreamsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.list({ @@ -146,6 +149,8 @@ export class EventStreamsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.create({ @@ -190,7 +195,7 @@ export class EventStreamsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -236,6 +241,8 @@ export class EventStreamsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.get("id") @@ -262,7 +269,7 @@ export class EventStreamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -310,6 +317,8 @@ export class EventStreamsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.delete("id") @@ -333,7 +342,7 @@ export class EventStreamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -379,6 +388,8 @@ export class EventStreamsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.update("id") @@ -407,14 +418,14 @@ export class EventStreamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -458,6 +469,8 @@ export class EventStreamsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.test("id", { @@ -488,14 +501,14 @@ export class EventStreamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}/test`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}/test`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/eventStreams/resources/deliveries/client/Client.ts b/src/management/api/resources/eventStreams/resources/deliveries/client/Client.ts index c54b1ce122..49da86042c 100644 --- a/src/management/api/resources/eventStreams/resources/deliveries/client/Client.ts +++ b/src/management/api/resources/eventStreams/resources/deliveries/client/Client.ts @@ -32,6 +32,8 @@ export class DeliveriesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.deliveries.list("id", { @@ -79,7 +81,7 @@ export class DeliveriesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}/deliveries`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}/deliveries`, ), method: "GET", headers: _headers, @@ -159,6 +161,8 @@ export class DeliveriesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.deliveries.getHistory("id", "event_id") @@ -187,7 +191,7 @@ export class DeliveriesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}/deliveries/${core.url.encodePathParam(event_id)}`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}/deliveries/${core.url.encodePathParam(event_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/eventStreams/resources/redeliveries/client/Client.ts b/src/management/api/resources/eventStreams/resources/redeliveries/client/Client.ts index e5de1739f7..e7c8d6a05a 100644 --- a/src/management/api/resources/eventStreams/resources/redeliveries/client/Client.ts +++ b/src/management/api/resources/eventStreams/resources/redeliveries/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class RedeliveriesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.redeliveries.create("id") @@ -60,14 +63,14 @@ export class RedeliveriesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}/redeliver`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}/redeliver`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -120,6 +123,8 @@ export class RedeliveriesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.eventStreams.redeliveries.createById("id", "event_id") @@ -148,7 +153,7 @@ export class RedeliveriesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `event-streams/${core.url.encodePathParam(id)}/redeliver/${core.url.encodePathParam(event_id)}`, + `event-streams/${core.url.encodePathParam(id, errors.ManagementError)}/redeliver/${core.url.encodePathParam(event_id, errors.ManagementError)}`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/events/client/Client.ts b/src/management/api/resources/events/client/Client.ts index abedca801d..879c07f978 100644 --- a/src/management/api/resources/events/client/Client.ts +++ b/src/management/api/resources/events/client/Client.ts @@ -73,6 +73,36 @@ export class EventsClient { fetchFn: this._options?.fetch, logging: this._options.logging, }); + const _reconnect = async (lastEventId: string) => { + const _reconnectResponse = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.ManagementEnvironment.Default, + "events", + ), + method: "GET", + headers: { ..._headers, "Last-Event-ID": lastEventId }, + queryString: core.url + .queryBuilder() + .addMany(_queryParams) + .mergeAdditional(requestOptions?.queryParams) + .build(), + responseType: "sse", + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (!_reconnectResponse.ok) { + throw new Error("SSE stream reconnection failed"); + } + if (_reconnectResponse.body == null) { + throw new Error("SSE stream reconnection failed: empty response body"); + } + return _reconnectResponse.body; + }; if (_response.ok) { return { data: new core.Stream({ @@ -82,7 +112,14 @@ export class EventsClient { eventShape: { type: "sse", eventDiscriminator: "type", + resumable: true, }, + reconnectionEnabled: + requestOptions?.stream?.reconnectionEnabled ?? this._options?.stream?.reconnectionEnabled, + maxReconnectionAttempts: + requestOptions?.stream?.maxReconnectionAttempts ?? + this._options?.stream?.maxReconnectionAttempts, + reconnect: _reconnect, }), rawResponse: _response.rawResponse, }; diff --git a/src/management/api/resources/experimentation/resources/experiments/client/Client.ts b/src/management/api/resources/experimentation/resources/experiments/client/Client.ts index 9943efb06e..5e8758567c 100644 --- a/src/management/api/resources/experimentation/resources/experiments/client/Client.ts +++ b/src/management/api/resources/experimentation/resources/experiments/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class ExperimentsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.experiments.list({ @@ -157,12 +160,15 @@ export class ExperimentsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.UnprocessableEntityError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.experiments.create({ * name: "name", * feature_flag_id: "feature_flag_id", - * authentication_flow: "authentication" + * authentication_flow: "authentication", + * allocation_strategy: "percentage" * }) */ public create( @@ -194,7 +200,7 @@ export class ExperimentsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -249,6 +255,8 @@ export class ExperimentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.experiments.get("id") @@ -275,7 +283,7 @@ export class ExperimentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/experiments/${core.url.encodePathParam(id)}`, + `experimentation/experiments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -329,6 +337,8 @@ export class ExperimentsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.experiments.delete("id") @@ -352,7 +362,7 @@ export class ExperimentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/experiments/${core.url.encodePathParam(id)}`, + `experimentation/experiments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -406,6 +416,8 @@ export class ExperimentsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.UnprocessableEntityError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.experiments.update("id") @@ -434,14 +446,14 @@ export class ExperimentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/experiments/${core.url.encodePathParam(id)}`, + `experimentation/experiments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -504,6 +516,8 @@ export class ExperimentsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.experiments.advanceRamp("id", { @@ -534,14 +548,14 @@ export class ExperimentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/experiments/${core.url.encodePathParam(id)}/advance-ramp`, + `experimentation/experiments/${core.url.encodePathParam(id, errors.ManagementError)}/advance-ramp`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -596,6 +610,8 @@ export class ExperimentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.experiments.validate("id") @@ -622,7 +638,7 @@ export class ExperimentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/experiments/${core.url.encodePathParam(id)}/validate`, + `experimentation/experiments/${core.url.encodePathParam(id, errors.ManagementError)}/validate`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/experimentation/resources/featureFlags/client/Client.ts b/src/management/api/resources/experimentation/resources/featureFlags/client/Client.ts index 3acb54393d..da8e718e98 100644 --- a/src/management/api/resources/experimentation/resources/featureFlags/client/Client.ts +++ b/src/management/api/resources/experimentation/resources/featureFlags/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -38,6 +39,8 @@ export class FeatureFlagsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.list({ @@ -153,6 +156,8 @@ export class FeatureFlagsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.create({ @@ -189,7 +194,7 @@ export class FeatureFlagsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -242,6 +247,8 @@ export class FeatureFlagsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.get("id") @@ -268,7 +275,7 @@ export class FeatureFlagsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -322,6 +329,8 @@ export class FeatureFlagsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.delete("id") @@ -345,7 +354,7 @@ export class FeatureFlagsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -398,6 +407,8 @@ export class FeatureFlagsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.update("id") @@ -426,14 +437,14 @@ export class FeatureFlagsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/experimentation/resources/featureFlags/resources/variations/client/Client.ts b/src/management/api/resources/experimentation/resources/featureFlags/resources/variations/client/Client.ts index 24b81dab86..e1a6432730 100644 --- a/src/management/api/resources/experimentation/resources/featureFlags/resources/variations/client/Client.ts +++ b/src/management/api/resources/experimentation/resources/featureFlags/resources/variations/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -36,6 +37,8 @@ export class VariationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.variations.list("id") @@ -62,7 +65,7 @@ export class VariationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}/variations`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}/variations`, ), method: "GET", headers: _headers, @@ -122,6 +125,8 @@ export class VariationsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.variations.create("id", { @@ -155,14 +160,14 @@ export class VariationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}/variations`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}/variations`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -218,6 +223,8 @@ export class VariationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.variations.get("id", "vid") @@ -246,7 +253,7 @@ export class VariationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}/variations/${core.url.encodePathParam(vid)}`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}/variations/${core.url.encodePathParam(vid, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -302,6 +309,8 @@ export class VariationsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.variations.delete("id", "vid") @@ -330,7 +339,7 @@ export class VariationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}/variations/${core.url.encodePathParam(vid)}`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}/variations/${core.url.encodePathParam(vid, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -386,6 +395,8 @@ export class VariationsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.featureFlags.variations.update("id", "vid") @@ -416,14 +427,14 @@ export class VariationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/feature-flags/${core.url.encodePathParam(id)}/variations/${core.url.encodePathParam(vid)}`, + `experimentation/feature-flags/${core.url.encodePathParam(id, errors.ManagementError)}/variations/${core.url.encodePathParam(vid, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/experimentation/resources/segments/client/Client.ts b/src/management/api/resources/experimentation/resources/segments/client/Client.ts index 2d7154adf8..1ed064ecc6 100644 --- a/src/management/api/resources/experimentation/resources/segments/client/Client.ts +++ b/src/management/api/resources/experimentation/resources/segments/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class SegmentsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.segments.list({ @@ -146,6 +149,8 @@ export class SegmentsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.UnprocessableEntityError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.segments.create({ @@ -182,7 +187,7 @@ export class SegmentsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -235,6 +240,8 @@ export class SegmentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.segments.get("id") @@ -261,7 +268,7 @@ export class SegmentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/segments/${core.url.encodePathParam(id)}`, + `experimentation/segments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -312,6 +319,8 @@ export class SegmentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.segments.delete("id") @@ -335,7 +344,7 @@ export class SegmentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/segments/${core.url.encodePathParam(id)}`, + `experimentation/segments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -389,6 +398,8 @@ export class SegmentsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.UnprocessableEntityError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.experimentation.segments.update("id") @@ -417,14 +428,14 @@ export class SegmentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `experimentation/segments/${core.url.encodePathParam(id)}`, + `experimentation/segments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/flows/client/Client.ts b/src/management/api/resources/flows/client/Client.ts index 3d9eeb9af5..db27b3eaf8 100644 --- a/src/management/api/resources/flows/client/Client.ts +++ b/src/management/api/resources/flows/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -42,6 +43,8 @@ export class FlowsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.list({ @@ -150,8 +153,15 @@ export class FlowsClient { (request?.per_page == null || (response?.flows ?? []).length >= request?.per_page), getItems: (response) => response?.flows ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -164,6 +174,8 @@ export class FlowsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.create({ @@ -199,7 +211,7 @@ export class FlowsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -242,6 +254,8 @@ export class FlowsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.get("id", { @@ -276,7 +290,7 @@ export class FlowsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/${core.url.encodePathParam(id)}`, + `flows/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -329,6 +343,8 @@ export class FlowsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.delete("id") @@ -352,7 +368,7 @@ export class FlowsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/${core.url.encodePathParam(id)}`, + `flows/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -403,6 +419,8 @@ export class FlowsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.update("id") @@ -431,14 +449,14 @@ export class FlowsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/${core.url.encodePathParam(id)}`, + `flows/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/flows/resources/executions/client/Client.ts b/src/management/api/resources/flows/resources/executions/client/Client.ts index 3b16441ee0..bc0c71845d 100644 --- a/src/management/api/resources/flows/resources/executions/client/Client.ts +++ b/src/management/api/resources/flows/resources/executions/client/Client.ts @@ -32,6 +32,8 @@ export class ExecutionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.executions.list("flow_id", { @@ -66,7 +68,7 @@ export class ExecutionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/${core.url.encodePathParam(flow_id)}/executions`, + `flows/${core.url.encodePathParam(flow_id, errors.ManagementError)}/executions`, ), method: "GET", headers: _headers, @@ -148,6 +150,8 @@ export class ExecutionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.executions.get("flow_id", "execution_id", { @@ -184,7 +188,7 @@ export class ExecutionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/${core.url.encodePathParam(flow_id)}/executions/${core.url.encodePathParam(execution_id)}`, + `flows/${core.url.encodePathParam(flow_id, errors.ManagementError)}/executions/${core.url.encodePathParam(execution_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -244,6 +248,8 @@ export class ExecutionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.executions.delete("flow_id", "execution_id") @@ -272,7 +278,7 @@ export class ExecutionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/${core.url.encodePathParam(flow_id)}/executions/${core.url.encodePathParam(execution_id)}`, + `flows/${core.url.encodePathParam(flow_id, errors.ManagementError)}/executions/${core.url.encodePathParam(execution_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/flows/resources/vault/resources/connections/client/Client.ts b/src/management/api/resources/flows/resources/vault/resources/connections/client/Client.ts index f25b39ead0..cffa17f95a 100644 --- a/src/management/api/resources/flows/resources/vault/resources/connections/client/Client.ts +++ b/src/management/api/resources/flows/resources/vault/resources/connections/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.vault.connections.list({ @@ -140,8 +143,15 @@ export class ConnectionsClient { (request?.per_page == null || (response?.connections ?? []).length >= request?.per_page), getItems: (response) => response?.connections ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -154,6 +164,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.vault.connections.create({ @@ -195,7 +207,7 @@ export class ConnectionsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -240,6 +252,8 @@ export class ConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.vault.connections.get("id") @@ -266,7 +280,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/vault/connections/${core.url.encodePathParam(id)}`, + `flows/vault/connections/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -316,6 +330,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.vault.connections.delete("id") @@ -339,7 +355,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/vault/connections/${core.url.encodePathParam(id)}`, + `flows/vault/connections/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -391,6 +407,8 @@ export class ConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.flows.vault.connections.update("id") @@ -419,14 +437,14 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `flows/vault/connections/${core.url.encodePathParam(id)}`, + `flows/vault/connections/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/forms/client/Client.ts b/src/management/api/resources/forms/client/Client.ts index e86becc100..d0eff9984e 100644 --- a/src/management/api/resources/forms/client/Client.ts +++ b/src/management/api/resources/forms/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -30,6 +31,8 @@ export class FormsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.forms.list({ @@ -130,8 +133,15 @@ export class FormsClient { (request?.per_page == null || (response?.forms ?? []).length >= request?.per_page), getItems: (response) => response?.forms ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -144,6 +154,8 @@ export class FormsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.forms.create({ @@ -179,7 +191,7 @@ export class FormsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -222,6 +234,8 @@ export class FormsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.forms.get("id", { @@ -256,7 +270,7 @@ export class FormsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `forms/${core.url.encodePathParam(id)}`, + `forms/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -307,6 +321,8 @@ export class FormsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.forms.delete("id") @@ -330,7 +346,7 @@ export class FormsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `forms/${core.url.encodePathParam(id)}`, + `forms/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -377,6 +393,8 @@ export class FormsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.forms.update("id") @@ -405,14 +423,14 @@ export class FormsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `forms/${core.url.encodePathParam(id)}`, + `forms/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/groups/client/Client.ts b/src/management/api/resources/groups/client/Client.ts index 48718f824c..f12d5e02c0 100644 --- a/src/management/api/resources/groups/client/Client.ts +++ b/src/management/api/resources/groups/client/Client.ts @@ -44,6 +44,8 @@ export class GroupsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.groups.list({ @@ -174,6 +176,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.groups.get("id") @@ -200,7 +204,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `groups/${core.url.encodePathParam(id)}`, + `groups/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -249,6 +253,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.groups.delete("id") @@ -272,7 +278,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `groups/${core.url.encodePathParam(id)}`, + `groups/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/groups/resources/members/client/Client.ts b/src/management/api/resources/groups/resources/members/client/Client.ts index 82352ea56b..2569f7ee23 100644 --- a/src/management/api/resources/groups/resources/members/client/Client.ts +++ b/src/management/api/resources/groups/resources/members/client/Client.ts @@ -34,6 +34,8 @@ export class MembersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.groups.members.get("id", { @@ -70,7 +72,7 @@ export class MembersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `groups/${core.url.encodePathParam(id)}/members`, + `groups/${core.url.encodePathParam(id, errors.ManagementError)}/members`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/groups/resources/roles/client/Client.ts b/src/management/api/resources/groups/resources/roles/client/Client.ts index c40a7e8239..a2c8c642bc 100644 --- a/src/management/api/resources/groups/resources/roles/client/Client.ts +++ b/src/management/api/resources/groups/resources/roles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.groups.roles.list("id", { @@ -66,7 +69,7 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `groups/${core.url.encodePathParam(id)}/roles`, + `groups/${core.url.encodePathParam(id, errors.ManagementError)}/roles`, ), method: "GET", headers: _headers, @@ -144,6 +147,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.groups.roles.create("id", { @@ -174,14 +179,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `groups/${core.url.encodePathParam(id)}/roles`, + `groups/${core.url.encodePathParam(id, errors.ManagementError)}/roles`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -228,6 +233,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.groups.roles.delete("id", { @@ -258,14 +265,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `groups/${core.url.encodePathParam(id)}/roles`, + `groups/${core.url.encodePathParam(id, errors.ManagementError)}/roles`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/client/Client.ts b/src/management/api/resources/guardian/client/Client.ts index 7ea7239e51..f3f46e33a9 100644 --- a/src/management/api/resources/guardian/client/Client.ts +++ b/src/management/api/resources/guardian/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -48,6 +49,8 @@ export class GuardianClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.get() @@ -120,6 +123,8 @@ export class GuardianClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.set({ @@ -158,7 +163,7 @@ export class GuardianClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/resources/enrollments/client/Client.ts b/src/management/api/resources/guardian/resources/enrollments/client/Client.ts index 76dd00256d..bc819eb755 100644 --- a/src/management/api/resources/guardian/resources/enrollments/client/Client.ts +++ b/src/management/api/resources/guardian/resources/enrollments/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class EnrollmentsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.enrollments.createTicket({ @@ -67,7 +70,7 @@ export class EnrollmentsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -112,6 +115,8 @@ export class EnrollmentsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.enrollments.get("id") @@ -138,7 +143,7 @@ export class EnrollmentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `guardian/enrollments/${core.url.encodePathParam(id)}`, + `guardian/enrollments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -185,6 +190,8 @@ export class EnrollmentsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.enrollments.delete("id") @@ -208,7 +215,7 @@ export class EnrollmentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `guardian/enrollments/${core.url.encodePathParam(id)}`, + `guardian/enrollments/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/guardian/resources/factors/client/Client.ts b/src/management/api/resources/guardian/resources/factors/client/Client.ts index 554747045c..f2e35330d8 100644 --- a/src/management/api/resources/guardian/resources/factors/client/Client.ts +++ b/src/management/api/resources/guardian/resources/factors/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -60,6 +61,8 @@ export class FactorsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.list() @@ -120,13 +123,15 @@ export class FactorsClient { /** * Update the status (i.e., enabled or disabled) of a specific multi-factor authentication factor. * - * @param {Management.GuardianFactorNameEnum} name - Factor name. Can be `sms`, `push-notification`, `email`, `duo` `otp` `webauthn-roaming`, `webauthn-platform`, or `recovery-code`. + * @param {Management.GuardianFactorNameEnum} name - Factor name. Can be `sms`, `push-notification`, `email`, `duo`, `otp`, `webauthn-roaming`, `webauthn-platform`, `recovery-code`, or `passkey`. * @param {Management.SetGuardianFactorRequestContent} request * @param {FactorsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.set("push-notification", { @@ -157,14 +162,14 @@ export class FactorsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `guardian/factors/${core.url.encodePathParam(name)}`, + `guardian/factors/${core.url.encodePathParam(name, errors.ManagementError)}`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/client/Client.ts b/src/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/client/Client.ts index 38b9c1b1bb..11f3c7603a 100644 --- a/src/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/client/Client.ts +++ b/src/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class SettingsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.duo.settings.get() @@ -109,6 +112,8 @@ export class SettingsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.duo.settings.set() @@ -142,7 +147,7 @@ export class SettingsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -188,6 +193,8 @@ export class SettingsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.duo.settings.update() @@ -221,7 +228,7 @@ export class SettingsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/resources/factors/resources/email/client/Client.ts b/src/management/api/resources/guardian/resources/factors/resources/email/client/Client.ts index 0c0d0bf74d..2546a50486 100644 --- a/src/management/api/resources/guardian/resources/factors/resources/email/client/Client.ts +++ b/src/management/api/resources/guardian/resources/factors/resources/email/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class EmailClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.email.get() @@ -110,6 +113,8 @@ export class EmailClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.email.set({ @@ -146,7 +151,7 @@ export class EmailClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/resources/factors/resources/phone/client/Client.ts b/src/management/api/resources/guardian/resources/factors/resources/phone/client/Client.ts index ae3b0267ee..763957b461 100644 --- a/src/management/api/resources/guardian/resources/factors/resources/phone/client/Client.ts +++ b/src/management/api/resources/guardian/resources/factors/resources/phone/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class PhoneClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.getMessageTypes() @@ -110,6 +113,8 @@ export class PhoneClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.setMessageTypes({ @@ -145,7 +150,7 @@ export class PhoneClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -194,6 +199,8 @@ export class PhoneClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.getTwilioProvider() @@ -270,6 +277,8 @@ export class PhoneClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.setTwilioProvider() @@ -303,7 +312,7 @@ export class PhoneClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -350,6 +359,8 @@ export class PhoneClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.getSelectedProvider() @@ -424,6 +435,8 @@ export class PhoneClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.setProvider({ @@ -459,7 +472,7 @@ export class PhoneClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -506,6 +519,8 @@ export class PhoneClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.get() @@ -583,6 +598,8 @@ export class PhoneClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.set({ @@ -619,7 +636,7 @@ export class PhoneClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -668,6 +685,8 @@ export class PhoneClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.getTemplates() @@ -744,6 +763,8 @@ export class PhoneClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.phone.setTemplates({ @@ -780,7 +801,7 @@ export class PhoneClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/resources/factors/resources/pushNotification/client/Client.ts b/src/management/api/resources/guardian/resources/factors/resources/pushNotification/client/Client.ts index 7bad087b68..aa180c658a 100644 --- a/src/management/api/resources/guardian/resources/factors/resources/pushNotification/client/Client.ts +++ b/src/management/api/resources/guardian/resources/factors/resources/pushNotification/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.getApnsProvider() @@ -109,6 +112,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.setApnsProvider() @@ -142,7 +147,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -190,6 +195,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.updateApnsProvider() @@ -223,7 +230,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -271,6 +278,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.setFcmProvider() @@ -304,7 +313,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -352,6 +361,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.updateFcmProvider() @@ -385,7 +396,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -433,6 +444,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.setFcmv1Provider() @@ -466,7 +479,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -514,6 +527,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.updateFcmv1Provider() @@ -547,7 +562,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -594,6 +609,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.getSnsProvider() @@ -670,6 +687,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.setSnsProvider() @@ -703,7 +722,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -751,6 +770,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.updateSnsProvider() @@ -784,7 +805,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -831,6 +852,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.getSelectedProvider() @@ -907,6 +930,8 @@ export class PushNotificationClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.pushNotification.setProvider({ @@ -942,7 +967,7 @@ export class PushNotificationClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/resources/factors/resources/sms/client/Client.ts b/src/management/api/resources/guardian/resources/factors/resources/sms/client/Client.ts index 2c0ad7292e..57db28d572 100644 --- a/src/management/api/resources/guardian/resources/factors/resources/sms/client/Client.ts +++ b/src/management/api/resources/guardian/resources/factors/resources/sms/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -35,6 +36,8 @@ export class SmsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.sms.getTwilioProvider() @@ -113,6 +116,8 @@ export class SmsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.sms.setTwilioProvider() @@ -146,7 +151,7 @@ export class SmsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -195,6 +200,8 @@ export class SmsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.sms.getSelectedProvider() @@ -273,6 +280,8 @@ export class SmsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.sms.setProvider({ @@ -308,7 +317,7 @@ export class SmsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -357,6 +366,8 @@ export class SmsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.sms.getTemplates() @@ -435,6 +446,8 @@ export class SmsClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.factors.sms.setTemplates({ @@ -471,7 +484,7 @@ export class SmsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/guardian/resources/policies/client/Client.ts b/src/management/api/resources/guardian/resources/policies/client/Client.ts index e58e7c5e2b..a285eb3523 100644 --- a/src/management/api/resources/guardian/resources/policies/client/Client.ts +++ b/src/management/api/resources/guardian/resources/policies/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -37,6 +38,8 @@ export class PoliciesClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.policies.list() @@ -115,6 +118,8 @@ export class PoliciesClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.guardian.policies.set(["all-applications"]) @@ -148,7 +153,7 @@ export class PoliciesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/hooks/client/Client.ts b/src/management/api/resources/hooks/client/Client.ts index a900ec62ac..7c6c7b7cf8 100644 --- a/src/management/api/resources/hooks/client/Client.ts +++ b/src/management/api/resources/hooks/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -39,6 +40,8 @@ export class HooksClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.list({ @@ -148,8 +151,15 @@ export class HooksClient { (request?.per_page == null || (response?.hooks ?? []).length >= request?.per_page), getItems: (response) => response?.hooks ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -165,6 +175,8 @@ export class HooksClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.create({ @@ -202,7 +214,7 @@ export class HooksClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -249,6 +261,8 @@ export class HooksClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.get("id", { @@ -283,7 +297,7 @@ export class HooksClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `hooks/${core.url.encodePathParam(id)}`, + `hooks/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -336,6 +350,8 @@ export class HooksClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.delete("id") @@ -359,7 +375,7 @@ export class HooksClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `hooks/${core.url.encodePathParam(id)}`, + `hooks/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -409,6 +425,8 @@ export class HooksClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.update("id") @@ -437,14 +455,14 @@ export class HooksClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `hooks/${core.url.encodePathParam(id)}`, + `hooks/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/hooks/resources/secrets/client/Client.ts b/src/management/api/resources/hooks/resources/secrets/client/Client.ts index da0085e7c6..86f722eadd 100644 --- a/src/management/api/resources/hooks/resources/secrets/client/Client.ts +++ b/src/management/api/resources/hooks/resources/secrets/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class SecretsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.secrets.get("id") @@ -59,7 +62,7 @@ export class SecretsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `hooks/${core.url.encodePathParam(id)}/secrets`, + `hooks/${core.url.encodePathParam(id, errors.ManagementError)}/secrets`, ), method: "GET", headers: _headers, @@ -113,6 +116,8 @@ export class SecretsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.secrets.create("id", { @@ -143,14 +148,14 @@ export class SecretsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `hooks/${core.url.encodePathParam(id)}/secrets`, + `hooks/${core.url.encodePathParam(id, errors.ManagementError)}/secrets`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -196,6 +201,8 @@ export class SecretsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.secrets.delete("id", ["string"]) @@ -224,14 +231,14 @@ export class SecretsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `hooks/${core.url.encodePathParam(id)}/secrets`, + `hooks/${core.url.encodePathParam(id, errors.ManagementError)}/secrets`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -277,6 +284,8 @@ export class SecretsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.hooks.secrets.update("id", { @@ -307,14 +316,14 @@ export class SecretsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `hooks/${core.url.encodePathParam(id)}/secrets`, + `hooks/${core.url.encodePathParam(id, errors.ManagementError)}/secrets`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/jobs/client/Client.ts b/src/management/api/resources/jobs/client/Client.ts index 7377274f9f..447ed8db6a 100644 --- a/src/management/api/resources/jobs/client/Client.ts +++ b/src/management/api/resources/jobs/client/Client.ts @@ -57,6 +57,8 @@ export class JobsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.jobs.get("id") @@ -83,7 +85,7 @@ export class JobsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `jobs/${core.url.encodePathParam(id)}`, + `jobs/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/jobs/resources/errors/client/Client.ts b/src/management/api/resources/jobs/resources/errors/client/Client.ts index d43710450b..389fd36012 100644 --- a/src/management/api/resources/jobs/resources/errors/client/Client.ts +++ b/src/management/api/resources/jobs/resources/errors/client/Client.ts @@ -33,6 +33,8 @@ export class ErrorsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.jobs.errors.get("id") @@ -59,7 +61,7 @@ export class ErrorsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `jobs/${core.url.encodePathParam(id)}/errors`, + `jobs/${core.url.encodePathParam(id, errors.ManagementError)}/errors`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/jobs/resources/usersExports/client/Client.ts b/src/management/api/resources/jobs/resources/usersExports/client/Client.ts index 27d1846250..28cdc00f89 100644 --- a/src/management/api/resources/jobs/resources/usersExports/client/Client.ts +++ b/src/management/api/resources/jobs/resources/usersExports/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class UsersExportsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.jobs.usersExports.create() @@ -65,7 +68,7 @@ export class UsersExportsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/jobs/resources/usersImports/client/Client.ts b/src/management/api/resources/jobs/resources/usersImports/client/Client.ts index da19e8c4ac..e2ea2901ba 100644 --- a/src/management/api/resources/jobs/resources/usersImports/client/Client.ts +++ b/src/management/api/resources/jobs/resources/usersImports/client/Client.ts @@ -35,6 +35,8 @@ export class UsersImportsClient { * @throws {@link Management.ContentTooLargeError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * import { createReadStream } from "fs"; diff --git a/src/management/api/resources/jobs/resources/verificationEmail/client/Client.ts b/src/management/api/resources/jobs/resources/verificationEmail/client/Client.ts index c6393010ca..f755d2eafd 100644 --- a/src/management/api/resources/jobs/resources/verificationEmail/client/Client.ts +++ b/src/management/api/resources/jobs/resources/verificationEmail/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class VerificationEmailClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.jobs.verificationEmail.create({ @@ -69,7 +72,7 @@ export class VerificationEmailClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/keys/resources/customSigning/client/Client.ts b/src/management/api/resources/keys/resources/customSigning/client/Client.ts index 01d2cbce50..625a8c725d 100644 --- a/src/management/api/resources/keys/resources/customSigning/client/Client.ts +++ b/src/management/api/resources/keys/resources/customSigning/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class CustomSigningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.customSigning.get() @@ -105,6 +108,8 @@ export class CustomSigningClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.customSigning.set({ @@ -142,7 +147,7 @@ export class CustomSigningClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -186,6 +191,8 @@ export class CustomSigningClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.customSigning.delete() diff --git a/src/management/api/resources/keys/resources/encryption/client/Client.ts b/src/management/api/resources/keys/resources/encryption/client/Client.ts index e51debbe95..9a4b0280db 100644 --- a/src/management/api/resources/keys/resources/encryption/client/Client.ts +++ b/src/management/api/resources/keys/resources/encryption/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class EncryptionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.encryption.list({ @@ -126,8 +129,15 @@ export class EncryptionClient { (request?.per_page == null || (response?.keys ?? []).length >= request?.per_page), getItems: (response) => response?.keys ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -143,6 +153,8 @@ export class EncryptionClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.encryption.create({ @@ -178,7 +190,7 @@ export class EncryptionClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -224,6 +236,8 @@ export class EncryptionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.encryption.rekey() @@ -290,6 +304,8 @@ export class EncryptionClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.encryption.get("kid") @@ -316,7 +332,7 @@ export class EncryptionClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/encryption/${core.url.encodePathParam(kid)}`, + `keys/encryption/${core.url.encodePathParam(kid, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -370,6 +386,8 @@ export class EncryptionClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.encryption.import("kid", { @@ -400,14 +418,14 @@ export class EncryptionClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/encryption/${core.url.encodePathParam(kid)}`, + `keys/encryption/${core.url.encodePathParam(kid, errors.ManagementError)}`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -455,6 +473,8 @@ export class EncryptionClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.encryption.delete("kid") @@ -478,7 +498,7 @@ export class EncryptionClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/encryption/${core.url.encodePathParam(kid)}`, + `keys/encryption/${core.url.encodePathParam(kid, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -526,6 +546,8 @@ export class EncryptionClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.encryption.createPublicWrappingKey("kid") @@ -552,7 +574,7 @@ export class EncryptionClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/encryption/${core.url.encodePathParam(kid)}/wrapping-key`, + `keys/encryption/${core.url.encodePathParam(kid, errors.ManagementError)}/wrapping-key`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/keys/resources/networkAcls/client/Client.ts b/src/management/api/resources/keys/resources/networkAcls/client/Client.ts index 22c107a133..bd9e0ef0e6 100644 --- a/src/management/api/resources/keys/resources/networkAcls/client/Client.ts +++ b/src/management/api/resources/keys/resources/networkAcls/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.networkAcls.list() @@ -109,6 +112,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.networkAcls.create({ @@ -146,7 +151,7 @@ export class NetworkAclsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -195,6 +200,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.networkAcls.get("id") @@ -221,7 +228,7 @@ export class NetworkAclsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/network-acls/${core.url.encodePathParam(id)}`, + `keys/network-acls/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -271,6 +278,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.networkAcls.delete("id") @@ -294,7 +303,7 @@ export class NetworkAclsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/network-acls/${core.url.encodePathParam(id)}`, + `keys/network-acls/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/keys/resources/signing/client/Client.ts b/src/management/api/resources/keys/resources/signing/client/Client.ts index 6b55abee95..19354d1e9a 100644 --- a/src/management/api/resources/keys/resources/signing/client/Client.ts +++ b/src/management/api/resources/keys/resources/signing/client/Client.ts @@ -31,6 +31,8 @@ export class SigningClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.signing.list() @@ -98,6 +100,8 @@ export class SigningClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.signing.rotate() @@ -171,6 +175,8 @@ export class SigningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.signing.get("kid") @@ -197,7 +203,7 @@ export class SigningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/signing/${core.url.encodePathParam(kid)}`, + `keys/signing/${core.url.encodePathParam(kid, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -249,6 +255,8 @@ export class SigningClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.keys.signing.revoke("kid") @@ -275,7 +283,7 @@ export class SigningClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `keys/signing/${core.url.encodePathParam(kid)}/revoke`, + `keys/signing/${core.url.encodePathParam(kid, errors.ManagementError)}/revoke`, ), method: "PUT", headers: _headers, diff --git a/src/management/api/resources/logStreams/client/Client.ts b/src/management/api/resources/logStreams/client/Client.ts index 3af529d2d1..aca69bed04 100644 --- a/src/management/api/resources/logStreams/client/Client.ts +++ b/src/management/api/resources/logStreams/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -101,6 +102,8 @@ export class LogStreamsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.logStreams.list() @@ -369,6 +372,8 @@ export class LogStreamsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.logStreams.create({ @@ -407,7 +412,7 @@ export class LogStreamsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -606,6 +611,8 @@ export class LogStreamsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.logStreams.get("id") @@ -632,7 +639,7 @@ export class LogStreamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `log-streams/${core.url.encodePathParam(id)}`, + `log-streams/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -683,6 +690,8 @@ export class LogStreamsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.logStreams.delete("id") @@ -706,7 +715,7 @@ export class LogStreamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `log-streams/${core.url.encodePathParam(id)}`, + `log-streams/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -829,6 +838,8 @@ export class LogStreamsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.logStreams.update("id") @@ -857,14 +868,14 @@ export class LogStreamsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `log-streams/${core.url.encodePathParam(id)}`, + `log-streams/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/logs/client/Client.ts b/src/management/api/resources/logs/client/Client.ts index a24f45dec5..2f469a887a 100644 --- a/src/management/api/resources/logs/client/Client.ts +++ b/src/management/api/resources/logs/client/Client.ts @@ -57,6 +57,8 @@ export class LogsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.logs.list({ @@ -167,8 +169,15 @@ export class LogsClient { (request?.per_page == null || (response?.logs ?? []).length >= request?.per_page), getItems: (response) => response?.logs ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -184,6 +193,8 @@ export class LogsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.logs.get("id") @@ -210,7 +221,7 @@ export class LogsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `logs/${core.url.encodePathParam(id)}`, + `logs/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/networkAcls/client/Client.ts b/src/management/api/resources/networkAcls/client/Client.ts index 7621c0e984..7fa1207d80 100644 --- a/src/management/api/resources/networkAcls/client/Client.ts +++ b/src/management/api/resources/networkAcls/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.networkAcls.list({ @@ -128,8 +131,15 @@ export class NetworkAclsClient { (request?.per_page == null || (response?.network_acls ?? []).length >= request?.per_page), getItems: (response) => response?.network_acls ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -146,6 +156,8 @@ export class NetworkAclsClient { * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.networkAcls.create({ @@ -186,7 +198,7 @@ export class NetworkAclsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -233,6 +245,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.networkAcls.get("id") @@ -259,7 +273,7 @@ export class NetworkAclsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `network-acls/${core.url.encodePathParam(id)}`, + `network-acls/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -311,6 +325,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.networkAcls.set("id", { @@ -346,14 +362,14 @@ export class NetworkAclsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `network-acls/${core.url.encodePathParam(id)}`, + `network-acls/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -402,6 +418,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.networkAcls.delete("id") @@ -425,7 +443,7 @@ export class NetworkAclsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `network-acls/${core.url.encodePathParam(id)}`, + `network-acls/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -476,6 +494,8 @@ export class NetworkAclsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.networkAcls.update("id") @@ -504,14 +524,14 @@ export class NetworkAclsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `network-acls/${core.url.encodePathParam(id)}`, + `network-acls/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/client/Client.ts b/src/management/api/resources/organizations/client/Client.ts index e775ddbfad..d50585f285 100644 --- a/src/management/api/resources/organizations/client/Client.ts +++ b/src/management/api/resources/organizations/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -102,6 +103,8 @@ export class OrganizationsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.list({ @@ -220,6 +223,8 @@ export class OrganizationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.create({ @@ -255,7 +260,7 @@ export class OrganizationsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -304,6 +309,8 @@ export class OrganizationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.getByName("name") @@ -330,7 +337,7 @@ export class OrganizationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/name/${core.url.encodePathParam(name)}`, + `organizations/name/${core.url.encodePathParam(name, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -397,6 +404,8 @@ export class OrganizationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.GatewayTimeoutError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.search({ @@ -514,6 +523,8 @@ export class OrganizationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.get("id") @@ -540,7 +551,7 @@ export class OrganizationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -595,6 +606,8 @@ export class OrganizationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.delete("id") @@ -618,7 +631,7 @@ export class OrganizationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -668,6 +681,8 @@ export class OrganizationsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.update("id") @@ -696,14 +711,14 @@ export class OrganizationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/clientGrants/client/Client.ts b/src/management/api/resources/organizations/resources/clientGrants/client/Client.ts index fc3ed11883..a94c402a8a 100644 --- a/src/management/api/resources/organizations/resources/clientGrants/client/Client.ts +++ b/src/management/api/resources/organizations/resources/clientGrants/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class ClientGrantsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clientGrants.list("id", { @@ -83,7 +86,7 @@ export class ClientGrantsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/client-grants`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/client-grants`, ), method: "GET", headers: _headers, @@ -152,8 +155,15 @@ export class ClientGrantsClient { (request?.per_page == null || (response?.client_grants ?? []).length >= request?.per_page), getItems: (response) => response?.client_grants ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -169,6 +179,8 @@ export class ClientGrantsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clientGrants.create("id", { @@ -199,14 +211,14 @@ export class ClientGrantsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/client-grants`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/client-grants`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -261,6 +273,8 @@ export class ClientGrantsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clientGrants.delete("id", "grant_id") @@ -289,7 +303,7 @@ export class ClientGrantsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/client-grants/${core.url.encodePathParam(grant_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/client-grants/${core.url.encodePathParam(grant_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/organizations/resources/clients/client/Client.ts b/src/management/api/resources/organizations/resources/clients/client/Client.ts index 252680e564..4397edc40e 100644 --- a/src/management/api/resources/organizations/resources/clients/client/Client.ts +++ b/src/management/api/resources/organizations/resources/clients/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -39,6 +40,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clients.list("id", { @@ -71,7 +74,7 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/clients`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/clients`, ), method: "GET", headers: _headers, @@ -155,6 +158,8 @@ export class ClientsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clients.create("id", { @@ -188,14 +193,14 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/clients`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/clients`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -247,6 +252,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clients.delete("id", { @@ -277,14 +284,14 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/clients`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/clients`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -336,6 +343,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clients.get("id", "client_id") @@ -364,7 +373,7 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/clients/${core.url.encodePathParam(client_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/clients/${core.url.encodePathParam(client_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -424,6 +433,8 @@ export class ClientsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.clients.update("id", "client_id") @@ -454,14 +465,14 @@ export class ClientsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/clients/${core.url.encodePathParam(client_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/clients/${core.url.encodePathParam(client_id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/connections/client/Client.ts b/src/management/api/resources/organizations/resources/connections/client/Client.ts index b612b88839..9d53c7ccf8 100644 --- a/src/management/api/resources/organizations/resources/connections/client/Client.ts +++ b/src/management/api/resources/organizations/resources/connections/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.connections.list("id", { @@ -79,7 +82,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/connections`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/connections`, ), method: "GET", headers: _headers, @@ -148,8 +151,15 @@ export class ConnectionsClient { (request?.per_page == null || (response?.connections ?? []).length >= request?.per_page), getItems: (response) => response?.connections ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -165,6 +175,8 @@ export class ConnectionsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.connections.create("id", { @@ -195,14 +207,14 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/connections`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/connections`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -256,6 +268,8 @@ export class ConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.connections.get("id", "connection_id") @@ -284,7 +298,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/connections/${core.url.encodePathParam(connection_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/connections/${core.url.encodePathParam(connection_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -337,6 +351,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.connections.delete("id", "connection_id") @@ -365,7 +381,7 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/connections/${core.url.encodePathParam(connection_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/connections/${core.url.encodePathParam(connection_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -415,6 +431,8 @@ export class ConnectionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.connections.update("id", "connection_id") @@ -445,14 +463,14 @@ export class ConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/connections/${core.url.encodePathParam(connection_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/connections/${core.url.encodePathParam(connection_id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/discoveryDomains/client/Client.ts b/src/management/api/resources/organizations/resources/discoveryDomains/client/Client.ts index 0e55a76498..97834844db 100644 --- a/src/management/api/resources/organizations/resources/discoveryDomains/client/Client.ts +++ b/src/management/api/resources/organizations/resources/discoveryDomains/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -35,6 +36,8 @@ export class DiscoveryDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.discoveryDomains.list("id", { @@ -69,7 +72,7 @@ export class DiscoveryDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/discovery-domains`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/discovery-domains`, ), method: "GET", headers: _headers, @@ -156,6 +159,8 @@ export class DiscoveryDomainsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.discoveryDomains.create("id", { @@ -186,14 +191,14 @@ export class DiscoveryDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/discovery-domains`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/discovery-domains`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -251,6 +256,8 @@ export class DiscoveryDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.discoveryDomains.getByName("id", "discovery_domain") @@ -279,7 +286,7 @@ export class DiscoveryDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/discovery-domains/name/${core.url.encodePathParam(discovery_domain)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/discovery-domains/name/${core.url.encodePathParam(discovery_domain, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -339,6 +346,8 @@ export class DiscoveryDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.discoveryDomains.get("id", "discovery_domain_id") @@ -367,7 +376,7 @@ export class DiscoveryDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/discovery-domains/${core.url.encodePathParam(discovery_domain_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/discovery-domains/${core.url.encodePathParam(discovery_domain_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -425,6 +434,8 @@ export class DiscoveryDomainsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.discoveryDomains.delete("id", "discovery_domain_id") @@ -453,7 +464,7 @@ export class DiscoveryDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/discovery-domains/${core.url.encodePathParam(discovery_domain_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/discovery-domains/${core.url.encodePathParam(discovery_domain_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -505,6 +516,8 @@ export class DiscoveryDomainsClient { * * @throws {@link Management.BadRequestError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.discoveryDomains.update("id", "discovery_domain_id") @@ -535,14 +548,14 @@ export class DiscoveryDomainsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/discovery-domains/${core.url.encodePathParam(discovery_domain_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/discovery-domains/${core.url.encodePathParam(discovery_domain_id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/enabledConnections/client/Client.ts b/src/management/api/resources/organizations/resources/enabledConnections/client/Client.ts index 6c6ebd3d19..ec516174de 100644 --- a/src/management/api/resources/organizations/resources/enabledConnections/client/Client.ts +++ b/src/management/api/resources/organizations/resources/enabledConnections/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class EnabledConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.enabledConnections.list("id", { @@ -73,7 +76,7 @@ export class EnabledConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/enabled_connections`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/enabled_connections`, ), method: "GET", headers: _headers, @@ -144,8 +147,15 @@ export class EnabledConnectionsClient { (request?.per_page == null || (response?.enabled_connections ?? []).length >= request?.per_page), getItems: (response) => response?.enabled_connections ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -165,6 +175,8 @@ export class EnabledConnectionsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.enabledConnections.add("id", { @@ -195,14 +207,14 @@ export class EnabledConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/enabled_connections`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/enabled_connections`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -258,6 +270,8 @@ export class EnabledConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.enabledConnections.get("id", "connectionId") @@ -286,7 +300,7 @@ export class EnabledConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/enabled_connections/${core.url.encodePathParam(connectionId)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/enabled_connections/${core.url.encodePathParam(connectionId, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -345,6 +359,8 @@ export class EnabledConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.enabledConnections.delete("id", "connectionId") @@ -373,7 +389,7 @@ export class EnabledConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/enabled_connections/${core.url.encodePathParam(connectionId)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/enabled_connections/${core.url.encodePathParam(connectionId, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -430,6 +446,8 @@ export class EnabledConnectionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.enabledConnections.update("id", "connectionId") @@ -460,14 +478,14 @@ export class EnabledConnectionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/enabled_connections/${core.url.encodePathParam(connectionId)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/enabled_connections/${core.url.encodePathParam(connectionId, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/groups/client/Client.ts b/src/management/api/resources/organizations/resources/groups/client/Client.ts index 0b7f754ac3..34139ceece 100644 --- a/src/management/api/resources/organizations/resources/groups/client/Client.ts +++ b/src/management/api/resources/organizations/resources/groups/client/Client.ts @@ -40,6 +40,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.groups.list("organization_id", { @@ -72,7 +74,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(organization_id)}/groups`, + `organizations/${core.url.encodePathParam(organization_id, errors.ManagementError)}/groups`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/organizations/resources/groups/resources/roles/client/Client.ts b/src/management/api/resources/organizations/resources/groups/resources/roles/client/Client.ts index 4624724e33..a6b9b30862 100644 --- a/src/management/api/resources/organizations/resources/groups/resources/roles/client/Client.ts +++ b/src/management/api/resources/organizations/resources/groups/resources/roles/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -38,6 +39,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.groups.roles.list("organization_id", "group_id", { @@ -71,7 +74,7 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(organization_id)}/groups/${core.url.encodePathParam(group_id)}/roles`, + `organizations/${core.url.encodePathParam(organization_id, errors.ManagementError)}/groups/${core.url.encodePathParam(group_id, errors.ManagementError)}/roles`, ), method: "GET", headers: _headers, @@ -156,6 +159,8 @@ export class RolesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.groups.roles.create("organization_id", "group_id", { @@ -188,14 +193,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(organization_id)}/groups/${core.url.encodePathParam(group_id)}/roles`, + `organizations/${core.url.encodePathParam(organization_id, errors.ManagementError)}/groups/${core.url.encodePathParam(group_id, errors.ManagementError)}/roles`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -250,6 +255,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.groups.roles.delete("organization_id", "group_id", { @@ -282,14 +289,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(organization_id)}/groups/${core.url.encodePathParam(group_id)}/roles`, + `organizations/${core.url.encodePathParam(organization_id, errors.ManagementError)}/groups/${core.url.encodePathParam(group_id, errors.ManagementError)}/roles`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/invitations/client/Client.ts b/src/management/api/resources/organizations/resources/invitations/client/Client.ts index 195805bd2a..9cdb8872ec 100644 --- a/src/management/api/resources/organizations/resources/invitations/client/Client.ts +++ b/src/management/api/resources/organizations/resources/invitations/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class InvitationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.invitations.list("id", { @@ -86,7 +89,7 @@ export class InvitationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/invitations`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/invitations`, ), method: "GET", headers: _headers, @@ -157,8 +160,15 @@ export class InvitationsClient { (request?.per_page == null || (response?.invitations ?? []).length >= request?.per_page), getItems: (response) => response?.invitations ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -175,6 +185,8 @@ export class InvitationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.invitations.create("id", { @@ -211,14 +223,14 @@ export class InvitationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/invitations`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/invitations`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -272,6 +284,8 @@ export class InvitationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.invitations.get("id", "invitation_id", { @@ -310,7 +324,7 @@ export class InvitationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/invitations/${core.url.encodePathParam(invitation_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/invitations/${core.url.encodePathParam(invitation_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -370,6 +384,8 @@ export class InvitationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.invitations.delete("id", "invitation_id") @@ -398,7 +414,7 @@ export class InvitationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/invitations/${core.url.encodePathParam(invitation_id)}`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/invitations/${core.url.encodePathParam(invitation_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/organizations/resources/members/client/Client.ts b/src/management/api/resources/organizations/resources/members/client/Client.ts index ae79ab5de8..30f94bc761 100644 --- a/src/management/api/resources/organizations/resources/members/client/Client.ts +++ b/src/management/api/resources/organizations/resources/members/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -61,6 +62,8 @@ export class MembersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.list("id", { @@ -105,7 +108,7 @@ export class MembersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members`, ), method: "GET", headers: _headers, @@ -191,6 +194,8 @@ export class MembersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.create("id", { @@ -221,14 +226,14 @@ export class MembersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -270,6 +275,8 @@ export class MembersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.delete("id", { @@ -300,14 +307,14 @@ export class MembersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/client/Client.ts b/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/client/Client.ts index 0ed27ab156..c5fff8b015 100644 --- a/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/client/Client.ts +++ b/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/client/Client.ts @@ -44,6 +44,8 @@ export class EffectiveRolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.effectiveRoles.list("id", "user_id", { @@ -82,7 +84,7 @@ export class EffectiveRolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members/${core.url.encodePathParam(user_id)}/effective-roles`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members/${core.url.encodePathParam(user_id, errors.ManagementError)}/effective-roles`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts b/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts index 54c305d457..2b23604d20 100644 --- a/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts +++ b/src/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts @@ -38,6 +38,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.effectiveRoles.sources.groups.list("id", "user_id", { @@ -73,7 +75,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members/${core.url.encodePathParam(user_id)}/effective-roles/sources/groups`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members/${core.url.encodePathParam(user_id, errors.ManagementError)}/effective-roles/sources/groups`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/organizations/resources/members/resources/roles/client/Client.ts b/src/management/api/resources/organizations/resources/members/resources/roles/client/Client.ts index 6549c77542..7d179fc3a6 100644 --- a/src/management/api/resources/organizations/resources/members/resources/roles/client/Client.ts +++ b/src/management/api/resources/organizations/resources/members/resources/roles/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -42,6 +43,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.roles.list("id", "user_id", { @@ -77,7 +80,7 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members/${core.url.encodePathParam(user_id)}/roles`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members/${core.url.encodePathParam(user_id, errors.ManagementError)}/roles`, ), method: "GET", headers: _headers, @@ -145,8 +148,15 @@ export class RolesClient { (request?.per_page == null || (response?.roles ?? []).length >= request?.per_page), getItems: (response) => response?.roles ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -166,6 +176,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.roles.assign("id", "user_id", { @@ -198,14 +210,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members/${core.url.encodePathParam(user_id)}/roles`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members/${core.url.encodePathParam(user_id, errors.ManagementError)}/roles`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -259,6 +271,8 @@ export class RolesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.members.roles.delete("id", "user_id", { @@ -291,14 +305,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/members/${core.url.encodePathParam(user_id)}/roles`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/members/${core.url.encodePathParam(user_id, errors.ManagementError)}/roles`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/organizations/resources/roles/resources/groups/client/Client.ts b/src/management/api/resources/organizations/resources/roles/resources/groups/client/Client.ts index 816db48a11..947e60faca 100644 --- a/src/management/api/resources/organizations/resources/roles/resources/groups/client/Client.ts +++ b/src/management/api/resources/organizations/resources/roles/resources/groups/client/Client.ts @@ -38,6 +38,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.roles.groups.list("organization_id", "role_id", { @@ -71,7 +73,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(organization_id)}/roles/${core.url.encodePathParam(role_id)}/groups`, + `organizations/${core.url.encodePathParam(organization_id, errors.ManagementError)}/roles/${core.url.encodePathParam(role_id, errors.ManagementError)}/groups`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/organizations/resources/roles/resources/members/client/Client.ts b/src/management/api/resources/organizations/resources/roles/resources/members/client/Client.ts index af23ba8a52..5924d549f5 100644 --- a/src/management/api/resources/organizations/resources/roles/resources/members/client/Client.ts +++ b/src/management/api/resources/organizations/resources/roles/resources/members/client/Client.ts @@ -43,6 +43,8 @@ export class MembersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.organizations.roles.members.list("id", "role_id", { @@ -80,7 +82,7 @@ export class MembersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `organizations/${core.url.encodePathParam(id)}/roles/${core.url.encodePathParam(role_id)}/members`, + `organizations/${core.url.encodePathParam(id, errors.ManagementError)}/roles/${core.url.encodePathParam(role_id, errors.ManagementError)}/members`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/prompts/client/Client.ts b/src/management/api/resources/prompts/client/Client.ts index eaffa40fec..67e0df25a0 100644 --- a/src/management/api/resources/prompts/client/Client.ts +++ b/src/management/api/resources/prompts/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -48,6 +49,8 @@ export class PromptsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.getSettings() @@ -120,6 +123,8 @@ export class PromptsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.updateSettings() @@ -153,7 +158,7 @@ export class PromptsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/prompts/resources/customText/client/Client.ts b/src/management/api/resources/prompts/resources/customText/client/Client.ts index b41d19f32c..c3fce619cb 100644 --- a/src/management/api/resources/prompts/resources/customText/client/Client.ts +++ b/src/management/api/resources/prompts/resources/customText/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class CustomTextClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.customText.get("login", "am") @@ -62,7 +65,7 @@ export class CustomTextClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `prompts/${core.url.encodePathParam(prompt)}/custom-text/${core.url.encodePathParam(language)}`, + `prompts/${core.url.encodePathParam(prompt, errors.ManagementError)}/custom-text/${core.url.encodePathParam(language, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -121,6 +124,8 @@ export class CustomTextClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.customText.set("login", "am", { @@ -153,14 +158,14 @@ export class CustomTextClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `prompts/${core.url.encodePathParam(prompt)}/custom-text/${core.url.encodePathParam(language)}`, + `prompts/${core.url.encodePathParam(prompt, errors.ManagementError)}/custom-text/${core.url.encodePathParam(language, errors.ManagementError)}`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/prompts/resources/partials/client/Client.ts b/src/management/api/resources/prompts/resources/partials/client/Client.ts index 4e8e2bcf5a..f53c36e32d 100644 --- a/src/management/api/resources/prompts/resources/partials/client/Client.ts +++ b/src/management/api/resources/prompts/resources/partials/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class PartialsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.partials.get("login") @@ -59,7 +62,7 @@ export class PartialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `prompts/${core.url.encodePathParam(prompt)}/partials`, + `prompts/${core.url.encodePathParam(prompt, errors.ManagementError)}/partials`, ), method: "GET", headers: _headers, @@ -112,6 +115,8 @@ export class PartialsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.partials.set("login", { @@ -142,14 +147,14 @@ export class PartialsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `prompts/${core.url.encodePathParam(prompt)}/partials`, + `prompts/${core.url.encodePathParam(prompt, errors.ManagementError)}/partials`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/prompts/resources/rendering/client/Client.ts b/src/management/api/resources/prompts/resources/rendering/client/Client.ts index 756a6dabf5..5a58ca6af7 100644 --- a/src/management/api/resources/prompts/resources/rendering/client/Client.ts +++ b/src/management/api/resources/prompts/resources/rendering/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class RenderingClient { * @throws {@link Management.PaymentRequiredError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.rendering.list({ @@ -154,8 +157,15 @@ export class RenderingClient { (request?.per_page == null || (response?.configs ?? []).length >= request?.per_page), getItems: (response) => response?.configs ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -171,6 +181,8 @@ export class RenderingClient { * @throws {@link Management.PaymentRequiredError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.rendering.bulkUpdate({ @@ -209,7 +221,7 @@ export class RenderingClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -260,6 +272,8 @@ export class RenderingClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.rendering.get("login", "login") @@ -288,7 +302,7 @@ export class RenderingClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `prompts/${core.url.encodePathParam(prompt)}/screen/${core.url.encodePathParam(screen)}/rendering`, + `prompts/${core.url.encodePathParam(prompt, errors.ManagementError)}/screen/${core.url.encodePathParam(screen, errors.ManagementError)}/rendering`, ), method: "GET", headers: _headers, @@ -347,6 +361,8 @@ export class RenderingClient { * @throws {@link Management.PaymentRequiredError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.prompts.rendering.update("login", "login") @@ -377,14 +393,14 @@ export class RenderingClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `prompts/${core.url.encodePathParam(prompt)}/screen/${core.url.encodePathParam(screen)}/rendering`, + `prompts/${core.url.encodePathParam(prompt, errors.ManagementError)}/screen/${core.url.encodePathParam(screen, errors.ManagementError)}/rendering`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/rateLimitPolicies/client/Client.ts b/src/management/api/resources/rateLimitPolicies/client/Client.ts index dc0aa7ca54..950d561848 100644 --- a/src/management/api/resources/rateLimitPolicies/client/Client.ts +++ b/src/management/api/resources/rateLimitPolicies/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -30,6 +31,8 @@ export class RateLimitPoliciesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rateLimitPolicies.list({ @@ -140,6 +143,8 @@ export class RateLimitPoliciesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rateLimitPolicies.create({ @@ -180,7 +185,7 @@ export class RateLimitPoliciesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -226,6 +231,8 @@ export class RateLimitPoliciesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rateLimitPolicies.get("id") @@ -252,7 +259,7 @@ export class RateLimitPoliciesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rate-limit-policies/${core.url.encodePathParam(id)}`, + `rate-limit-policies/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -300,6 +307,8 @@ export class RateLimitPoliciesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rateLimitPolicies.delete("id") @@ -323,7 +332,7 @@ export class RateLimitPoliciesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rate-limit-policies/${core.url.encodePathParam(id)}`, + `rate-limit-policies/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -370,6 +379,8 @@ export class RateLimitPoliciesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rateLimitPolicies.update("id", { @@ -402,14 +413,14 @@ export class RateLimitPoliciesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rate-limit-policies/${core.url.encodePathParam(id)}`, + `rate-limit-policies/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/refreshTokens/client/Client.ts b/src/management/api/resources/refreshTokens/client/Client.ts index 144d0e00b9..cc39d3f677 100644 --- a/src/management/api/resources/refreshTokens/client/Client.ts +++ b/src/management/api/resources/refreshTokens/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class RefreshTokensClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.refreshTokens.list({ @@ -158,6 +161,8 @@ export class RefreshTokensClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.refreshTokens.revoke() @@ -191,7 +196,7 @@ export class RefreshTokensClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -235,6 +240,8 @@ export class RefreshTokensClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.refreshTokens.get("id") @@ -261,7 +268,7 @@ export class RefreshTokensClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `refresh-tokens/${core.url.encodePathParam(id)}`, + `refresh-tokens/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -313,6 +320,8 @@ export class RefreshTokensClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.refreshTokens.delete("id") @@ -336,7 +345,7 @@ export class RefreshTokensClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `refresh-tokens/${core.url.encodePathParam(id)}`, + `refresh-tokens/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -385,6 +394,8 @@ export class RefreshTokensClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.refreshTokens.update("id") @@ -413,14 +424,14 @@ export class RefreshTokensClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `refresh-tokens/${core.url.encodePathParam(id)}`, + `refresh-tokens/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/resourceServers/client/Client.ts b/src/management/api/resources/resourceServers/client/Client.ts index 957f54cb73..efd3fca2a0 100644 --- a/src/management/api/resources/resourceServers/client/Client.ts +++ b/src/management/api/resources/resourceServers/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class ResourceServersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.resourceServers.list({ @@ -136,8 +139,15 @@ export class ResourceServersClient { (request?.per_page == null || (response?.resource_servers ?? []).length >= request?.per_page), getItems: (response) => response?.resource_servers ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -153,6 +163,8 @@ export class ResourceServersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.resourceServers.create({ @@ -188,7 +200,7 @@ export class ResourceServersClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -242,6 +254,8 @@ export class ResourceServersClient { * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} * @throws {@link Management.GatewayTimeoutError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.resourceServers.search({ @@ -376,6 +390,8 @@ export class ResourceServersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.resourceServers.get("id", { @@ -410,7 +426,7 @@ export class ResourceServersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `resource-servers/${core.url.encodePathParam(id)}`, + `resource-servers/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -466,6 +482,8 @@ export class ResourceServersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.resourceServers.delete("id") @@ -489,7 +507,7 @@ export class ResourceServersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `resource-servers/${core.url.encodePathParam(id)}`, + `resource-servers/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -538,6 +556,8 @@ export class ResourceServersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.resourceServers.update("id") @@ -566,14 +586,14 @@ export class ResourceServersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `resource-servers/${core.url.encodePathParam(id)}`, + `resource-servers/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/riskAssessments/resources/settings/client/Client.ts b/src/management/api/resources/riskAssessments/resources/settings/client/Client.ts index 970bc1dcd3..acb2f2dce3 100644 --- a/src/management/api/resources/riskAssessments/resources/settings/client/Client.ts +++ b/src/management/api/resources/riskAssessments/resources/settings/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -37,6 +38,8 @@ export class SettingsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.riskAssessments.settings.get() @@ -112,6 +115,8 @@ export class SettingsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.riskAssessments.settings.update({ @@ -147,7 +152,7 @@ export class SettingsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/riskAssessments/resources/settings/resources/newDevice/client/Client.ts b/src/management/api/resources/riskAssessments/resources/settings/resources/newDevice/client/Client.ts index bda2e74462..6b090c3a92 100644 --- a/src/management/api/resources/riskAssessments/resources/settings/resources/newDevice/client/Client.ts +++ b/src/management/api/resources/riskAssessments/resources/settings/resources/newDevice/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class NewDeviceClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.riskAssessments.settings.newDevice.get() @@ -114,6 +117,8 @@ export class NewDeviceClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.riskAssessments.settings.newDevice.update({ @@ -149,7 +154,7 @@ export class NewDeviceClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/roles/client/Client.ts b/src/management/api/resources/roles/client/Client.ts index a2689bc82b..deda1f2f26 100644 --- a/src/management/api/resources/roles/client/Client.ts +++ b/src/management/api/resources/roles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -52,6 +53,8 @@ export class RolesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.list({ @@ -159,8 +162,15 @@ export class RolesClient { (request?.per_page == null || (response?.roles ?? []).length >= request?.per_page), getItems: (response) => response?.roles ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -178,6 +188,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.create({ @@ -213,7 +225,7 @@ export class RolesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -259,6 +271,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.get("id") @@ -285,7 +299,7 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -335,6 +349,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.delete("id") @@ -358,7 +374,7 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -408,6 +424,8 @@ export class RolesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.update("id") @@ -436,14 +454,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/roles/resources/groups/client/Client.ts b/src/management/api/resources/roles/resources/groups/client/Client.ts index ceb3dc0903..9073fd667a 100644 --- a/src/management/api/resources/roles/resources/groups/client/Client.ts +++ b/src/management/api/resources/roles/resources/groups/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.groups.get("id", { @@ -66,7 +69,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/groups`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/groups`, ), method: "GET", headers: _headers, @@ -144,6 +147,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.groups.create("id", { @@ -174,14 +179,14 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/groups`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/groups`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -228,6 +233,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.groups.delete("id", { @@ -258,14 +265,14 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/groups`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/groups`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/roles/resources/permissions/client/Client.ts b/src/management/api/resources/roles/resources/permissions/client/Client.ts index 231e5f7097..751a705cd9 100644 --- a/src/management/api/resources/roles/resources/permissions/client/Client.ts +++ b/src/management/api/resources/roles/resources/permissions/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class PermissionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.permissions.list("id", { @@ -70,7 +73,7 @@ export class PermissionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/permissions`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/permissions`, ), method: "GET", headers: _headers, @@ -141,8 +144,15 @@ export class PermissionsClient { (request?.per_page == null || (response?.permissions ?? []).length >= request?.per_page), getItems: (response) => response?.permissions ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -159,6 +169,8 @@ export class PermissionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.permissions.add("id", { @@ -192,14 +204,14 @@ export class PermissionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/permissions`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/permissions`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -245,6 +257,8 @@ export class PermissionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.permissions.delete("id", { @@ -278,14 +292,14 @@ export class PermissionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/permissions`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/permissions`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/roles/resources/users/client/Client.ts b/src/management/api/resources/roles/resources/users/client/Client.ts index 2e6f11f06a..df305bc81a 100644 --- a/src/management/api/resources/roles/resources/users/client/Client.ts +++ b/src/management/api/resources/roles/resources/users/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -52,6 +53,8 @@ export class UsersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.users.list("id", { @@ -86,7 +89,7 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/users`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/users`, ), method: "GET", headers: _headers, @@ -166,6 +169,8 @@ export class UsersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.roles.users.assign("id", { @@ -196,14 +201,14 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `roles/${core.url.encodePathParam(id)}/users`, + `roles/${core.url.encodePathParam(id, errors.ManagementError)}/users`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/rules/client/Client.ts b/src/management/api/resources/rules/client/Client.ts index 65170293ac..1190fff306 100644 --- a/src/management/api/resources/rules/client/Client.ts +++ b/src/management/api/resources/rules/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class RulesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rules.list({ @@ -142,8 +145,15 @@ export class RulesClient { (request?.per_page == null || (response?.rules ?? []).length >= request?.per_page), getItems: (response) => response?.rules ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -161,6 +171,8 @@ export class RulesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rules.create({ @@ -197,7 +209,7 @@ export class RulesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -244,6 +256,8 @@ export class RulesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rules.get("id", { @@ -280,7 +294,7 @@ export class RulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rules/${core.url.encodePathParam(id)}`, + `rules/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -333,6 +347,8 @@ export class RulesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rules.delete("id") @@ -356,7 +372,7 @@ export class RulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rules/${core.url.encodePathParam(id)}`, + `rules/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -406,6 +422,8 @@ export class RulesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rules.update("id") @@ -434,14 +452,14 @@ export class RulesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rules/${core.url.encodePathParam(id)}`, + `rules/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/rulesConfigs/client/Client.ts b/src/management/api/resources/rulesConfigs/client/Client.ts index 1a9cea7809..9b0e62162d 100644 --- a/src/management/api/resources/rulesConfigs/client/Client.ts +++ b/src/management/api/resources/rulesConfigs/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class RulesConfigsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rulesConfigs.list() @@ -101,6 +104,8 @@ export class RulesConfigsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rulesConfigs.set("key", { @@ -131,14 +136,14 @@ export class RulesConfigsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rules-configs/${core.url.encodePathParam(key)}`, + `rules-configs/${core.url.encodePathParam(key, errors.ManagementError)}`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -181,6 +186,8 @@ export class RulesConfigsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.rulesConfigs.delete("key") @@ -204,7 +211,7 @@ export class RulesConfigsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `rules-configs/${core.url.encodePathParam(key)}`, + `rules-configs/${core.url.encodePathParam(key, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/selfServiceProfiles/client/Client.ts b/src/management/api/resources/selfServiceProfiles/client/Client.ts index 8a106681e2..d11e3c70a7 100644 --- a/src/management/api/resources/selfServiceProfiles/client/Client.ts +++ b/src/management/api/resources/selfServiceProfiles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -44,6 +45,8 @@ export class SelfServiceProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.list({ @@ -144,8 +147,15 @@ export class SelfServiceProfilesClient { (request?.per_page == null || (response?.self_service_profiles ?? []).length >= request?.per_page), getItems: (response) => response?.self_service_profiles ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }, ); @@ -163,6 +173,8 @@ export class SelfServiceProfilesClient { * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.create({ @@ -198,7 +210,7 @@ export class SelfServiceProfilesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -250,6 +262,8 @@ export class SelfServiceProfilesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.get("id") @@ -276,7 +290,7 @@ export class SelfServiceProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `self-service-profiles/${core.url.encodePathParam(id)}`, + `self-service-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -331,6 +345,8 @@ export class SelfServiceProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.delete("id") @@ -357,7 +373,7 @@ export class SelfServiceProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `self-service-profiles/${core.url.encodePathParam(id)}`, + `self-service-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -414,6 +430,8 @@ export class SelfServiceProfilesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.InternalServerError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.update("id") @@ -442,14 +460,14 @@ export class SelfServiceProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `self-service-profiles/${core.url.encodePathParam(id)}`, + `self-service-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/selfServiceProfiles/resources/customText/client/Client.ts b/src/management/api/resources/selfServiceProfiles/resources/customText/client/Client.ts index be6fd5685d..f20793b17f 100644 --- a/src/management/api/resources/selfServiceProfiles/resources/customText/client/Client.ts +++ b/src/management/api/resources/selfServiceProfiles/resources/customText/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class CustomTextClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.customText.list("id", "en", "get-started") @@ -64,7 +67,7 @@ export class CustomTextClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `self-service-profiles/${core.url.encodePathParam(id)}/custom-text/${core.url.encodePathParam(language)}/${core.url.encodePathParam(page)}`, + `self-service-profiles/${core.url.encodePathParam(id, errors.ManagementError)}/custom-text/${core.url.encodePathParam(language, errors.ManagementError)}/${core.url.encodePathParam(page, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -122,6 +125,8 @@ export class CustomTextClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.customText.set("id", "en", "get-started", { @@ -156,14 +161,14 @@ export class CustomTextClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `self-service-profiles/${core.url.encodePathParam(id)}/custom-text/${core.url.encodePathParam(language)}/${core.url.encodePathParam(page)}`, + `self-service-profiles/${core.url.encodePathParam(id, errors.ManagementError)}/custom-text/${core.url.encodePathParam(language, errors.ManagementError)}/${core.url.encodePathParam(page, errors.ManagementError)}`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/selfServiceProfiles/resources/ssoTicket/client/Client.ts b/src/management/api/resources/selfServiceProfiles/resources/ssoTicket/client/Client.ts index b30df795b4..c2ff487231 100644 --- a/src/management/api/resources/selfServiceProfiles/resources/ssoTicket/client/Client.ts +++ b/src/management/api/resources/selfServiceProfiles/resources/ssoTicket/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class SsoTicketClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.ssoTicket.create("id") @@ -62,14 +65,14 @@ export class SsoTicketClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `self-service-profiles/${core.url.encodePathParam(id)}/sso-ticket`, + `self-service-profiles/${core.url.encodePathParam(id, errors.ManagementError)}/sso-ticket`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -123,6 +126,8 @@ export class SsoTicketClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.selfServiceProfiles.ssoTicket.revoke("profileId", "id") @@ -151,7 +156,7 @@ export class SsoTicketClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `self-service-profiles/${core.url.encodePathParam(profileId)}/sso-ticket/${core.url.encodePathParam(id)}/revoke`, + `self-service-profiles/${core.url.encodePathParam(profileId, errors.ManagementError)}/sso-ticket/${core.url.encodePathParam(id, errors.ManagementError)}/revoke`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/sessions/client/Client.ts b/src/management/api/resources/sessions/client/Client.ts index fd947eaccb..f9401b938b 100644 --- a/src/management/api/resources/sessions/client/Client.ts +++ b/src/management/api/resources/sessions/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class SessionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.sessions.get("id") @@ -58,7 +61,7 @@ export class SessionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `sessions/${core.url.encodePathParam(id)}`, + `sessions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -105,6 +108,8 @@ export class SessionsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.sessions.delete("id") @@ -128,7 +133,7 @@ export class SessionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `sessions/${core.url.encodePathParam(id)}`, + `sessions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -177,6 +182,8 @@ export class SessionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.sessions.update("id") @@ -205,14 +212,14 @@ export class SessionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `sessions/${core.url.encodePathParam(id)}`, + `sessions/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -261,6 +268,8 @@ export class SessionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.sessions.revoke("id") @@ -284,7 +293,7 @@ export class SessionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `sessions/${core.url.encodePathParam(id)}/revoke`, + `sessions/${core.url.encodePathParam(id, errors.ManagementError)}/revoke`, ), method: "POST", headers: _headers, diff --git a/src/management/api/resources/stats/client/Client.ts b/src/management/api/resources/stats/client/Client.ts index d7f750bc6d..fd56438dc0 100644 --- a/src/management/api/resources/stats/client/Client.ts +++ b/src/management/api/resources/stats/client/Client.ts @@ -30,6 +30,8 @@ export class StatsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.stats.getActiveUsersCount() @@ -102,6 +104,8 @@ export class StatsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.stats.getDaily({ diff --git a/src/management/api/resources/supplementalSignals/client/Client.ts b/src/management/api/resources/supplementalSignals/client/Client.ts index 2742b5fad0..f64cb86bcf 100644 --- a/src/management/api/resources/supplementalSignals/client/Client.ts +++ b/src/management/api/resources/supplementalSignals/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -31,6 +32,8 @@ export class SupplementalSignalsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.supplementalSignals.get() @@ -105,6 +108,8 @@ export class SupplementalSignalsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.supplementalSignals.patch({ @@ -140,7 +145,7 @@ export class SupplementalSignalsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/tenants/resources/settings/client/Client.ts b/src/management/api/resources/tenants/resources/settings/client/Client.ts index 0fa166f21d..057e9b43ab 100644 --- a/src/management/api/resources/tenants/resources/settings/client/Client.ts +++ b/src/management/api/resources/tenants/resources/settings/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class SettingsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tenants.settings.get({ @@ -120,6 +123,8 @@ export class SettingsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tenants.settings.update() @@ -153,7 +158,7 @@ export class SettingsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/tickets/client/Client.ts b/src/management/api/resources/tickets/client/Client.ts index c1cf9939a5..d5c7885235 100644 --- a/src/management/api/resources/tickets/client/Client.ts +++ b/src/management/api/resources/tickets/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class TicketsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tickets.verifyEmail({ @@ -68,7 +71,7 @@ export class TicketsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -119,6 +122,8 @@ export class TicketsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tickets.changePassword() @@ -152,7 +157,7 @@ export class TicketsClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/tokenExchangeProfiles/client/Client.ts b/src/management/api/resources/tokenExchangeProfiles/client/Client.ts index bd317f519d..bb3c90d140 100644 --- a/src/management/api/resources/tokenExchangeProfiles/client/Client.ts +++ b/src/management/api/resources/tokenExchangeProfiles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -41,6 +42,8 @@ export class TokenExchangeProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tokenExchangeProfiles.list({ @@ -159,6 +162,8 @@ export class TokenExchangeProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tokenExchangeProfiles.create({ @@ -197,7 +202,7 @@ export class TokenExchangeProfilesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -248,6 +253,8 @@ export class TokenExchangeProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tokenExchangeProfiles.get("id") @@ -274,7 +281,7 @@ export class TokenExchangeProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `token-exchange-profiles/${core.url.encodePathParam(id)}`, + `token-exchange-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -327,6 +334,8 @@ export class TokenExchangeProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tokenExchangeProfiles.delete("id") @@ -353,7 +362,7 @@ export class TokenExchangeProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `token-exchange-profiles/${core.url.encodePathParam(id)}`, + `token-exchange-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -408,6 +417,8 @@ export class TokenExchangeProfilesClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.tokenExchangeProfiles.update("id") @@ -436,14 +447,14 @@ export class TokenExchangeProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `token-exchange-profiles/${core.url.encodePathParam(id)}`, + `token-exchange-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/userAttributeProfiles/client/Client.ts b/src/management/api/resources/userAttributeProfiles/client/Client.ts index 089945cbd8..8773d22209 100644 --- a/src/management/api/resources/userAttributeProfiles/client/Client.ts +++ b/src/management/api/resources/userAttributeProfiles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -32,6 +33,8 @@ export class UserAttributeProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userAttributeProfiles.list({ @@ -148,6 +151,8 @@ export class UserAttributeProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userAttributeProfiles.create({ @@ -191,7 +196,7 @@ export class UserAttributeProfilesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -237,6 +242,8 @@ export class UserAttributeProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userAttributeProfiles.listTemplates() @@ -314,6 +321,8 @@ export class UserAttributeProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userAttributeProfiles.getTemplate("id") @@ -340,7 +349,7 @@ export class UserAttributeProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `user-attribute-profiles/templates/${core.url.encodePathParam(id)}`, + `user-attribute-profiles/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -395,6 +404,8 @@ export class UserAttributeProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userAttributeProfiles.get("id") @@ -421,7 +432,7 @@ export class UserAttributeProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `user-attribute-profiles/${core.url.encodePathParam(id)}`, + `user-attribute-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -470,6 +481,8 @@ export class UserAttributeProfilesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userAttributeProfiles.delete("id") @@ -496,7 +509,7 @@ export class UserAttributeProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `user-attribute-profiles/${core.url.encodePathParam(id)}`, + `user-attribute-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -548,6 +561,8 @@ export class UserAttributeProfilesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userAttributeProfiles.update("id") @@ -576,14 +591,14 @@ export class UserAttributeProfilesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `user-attribute-profiles/${core.url.encodePathParam(id)}`, + `user-attribute-profiles/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/userBlocks/client/Client.ts b/src/management/api/resources/userBlocks/client/Client.ts index 98d062f9f1..e62fe81ce1 100644 --- a/src/management/api/resources/userBlocks/client/Client.ts +++ b/src/management/api/resources/userBlocks/client/Client.ts @@ -32,6 +32,8 @@ export class UserBlocksClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userBlocks.listByIdentifier({ @@ -122,6 +124,8 @@ export class UserBlocksClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userBlocks.deleteByIdentifier({ @@ -207,6 +211,8 @@ export class UserBlocksClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userBlocks.list("id", { @@ -241,7 +247,7 @@ export class UserBlocksClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `user-blocks/${core.url.encodePathParam(id)}`, + `user-blocks/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -300,6 +306,8 @@ export class UserBlocksClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userBlocks.delete("id") @@ -323,7 +331,7 @@ export class UserBlocksClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `user-blocks/${core.url.encodePathParam(id)}`, + `user-blocks/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/userGrants/client/Client.ts b/src/management/api/resources/userGrants/client/Client.ts index 16b496b665..8f295cc760 100644 --- a/src/management/api/resources/userGrants/client/Client.ts +++ b/src/management/api/resources/userGrants/client/Client.ts @@ -31,6 +31,8 @@ export class UserGrantsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userGrants.list({ @@ -133,8 +135,15 @@ export class UserGrantsClient { (request?.per_page == null || (response?.grants ?? []).length >= request?.per_page), getItems: (response) => response?.grants ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -148,6 +157,8 @@ export class UserGrantsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userGrants.deleteByUserId({ @@ -228,6 +239,8 @@ export class UserGrantsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.userGrants.delete("id") @@ -251,7 +264,7 @@ export class UserGrantsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `grants/${core.url.encodePathParam(id)}`, + `grants/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/users/client/Client.ts b/src/management/api/resources/users/client/Client.ts index 32f324b385..562c993100 100644 --- a/src/management/api/resources/users/client/Client.ts +++ b/src/management/api/resources/users/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClie import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"; import * as core from "../../../../core/index.js"; import { mergeHeaders } from "../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js"; import * as environments from "../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../errors/index.js"; @@ -144,6 +145,8 @@ export class UsersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} * @throws {@link Management.ServiceUnavailableError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.list({ @@ -268,8 +271,15 @@ export class UsersClient { (request?.per_page == null || (response?.users ?? []).length >= request?.per_page), getItems: (response) => response?.users ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -287,6 +297,8 @@ export class UsersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.create({ @@ -322,7 +334,7 @@ export class UsersClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -371,6 +383,8 @@ export class UsersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.listUsersByEmail({ @@ -460,6 +474,8 @@ export class UsersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.get("id", { @@ -496,7 +512,7 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -549,6 +565,8 @@ export class UsersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.delete("id") @@ -572,7 +590,7 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -711,6 +729,8 @@ export class UsersClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.update("id") @@ -739,14 +759,14 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -791,6 +811,8 @@ export class UsersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.regenerateRecoveryCode("id") @@ -817,7 +839,7 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/recovery-code-regeneration`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/recovery-code-regeneration`, ), method: "POST", headers: _headers, @@ -873,6 +895,8 @@ export class UsersClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.revokeAccess("id") @@ -901,14 +925,14 @@ export class UsersClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/revoke-access`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/revoke-access`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/users/resources/authenticationMethods/client/Client.ts b/src/management/api/resources/users/resources/authenticationMethods/client/Client.ts index bd965af81a..b6aad0232b 100644 --- a/src/management/api/resources/users/resources/authenticationMethods/client/Client.ts +++ b/src/management/api/resources/users/resources/authenticationMethods/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -34,6 +35,8 @@ export class AuthenticationMethodsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticationMethods.list("id", { @@ -75,7 +78,7 @@ export class AuthenticationMethodsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authentication-methods`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authentication-methods`, ), method: "GET", headers: _headers, @@ -146,8 +149,15 @@ export class AuthenticationMethodsClient { (request?.per_page == null || (response?.authenticators ?? []).length >= request?.per_page), getItems: (response) => response?.authenticators ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -165,6 +175,8 @@ export class AuthenticationMethodsClient { * @throws {@link Management.NotFoundError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticationMethods.create("id", { @@ -195,14 +207,14 @@ export class AuthenticationMethodsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authentication-methods`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authentication-methods`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -261,6 +273,8 @@ export class AuthenticationMethodsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticationMethods.set("id", [{ @@ -291,14 +305,14 @@ export class AuthenticationMethodsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authentication-methods`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authentication-methods`, ), method: "PUT", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -351,6 +365,8 @@ export class AuthenticationMethodsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticationMethods.deleteAll("id") @@ -377,7 +393,7 @@ export class AuthenticationMethodsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authentication-methods`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authentication-methods`, ), method: "DELETE", headers: _headers, @@ -429,6 +445,8 @@ export class AuthenticationMethodsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticationMethods.get("id", "authentication_method_id") @@ -457,7 +475,7 @@ export class AuthenticationMethodsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authentication-methods/${core.url.encodePathParam(authentication_method_id)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authentication-methods/${core.url.encodePathParam(authentication_method_id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -516,6 +534,8 @@ export class AuthenticationMethodsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticationMethods.delete("id", "authentication_method_id") @@ -544,7 +564,7 @@ export class AuthenticationMethodsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authentication-methods/${core.url.encodePathParam(authentication_method_id)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authentication-methods/${core.url.encodePathParam(authentication_method_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -601,6 +621,8 @@ export class AuthenticationMethodsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticationMethods.update("id", "authentication_method_id") @@ -633,14 +655,14 @@ export class AuthenticationMethodsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authentication-methods/${core.url.encodePathParam(authentication_method_id)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authentication-methods/${core.url.encodePathParam(authentication_method_id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/users/resources/authenticators/client/Client.ts b/src/management/api/resources/users/resources/authenticators/client/Client.ts index 7985543f8e..29023f4cc3 100644 --- a/src/management/api/resources/users/resources/authenticators/client/Client.ts +++ b/src/management/api/resources/users/resources/authenticators/client/Client.ts @@ -32,6 +32,8 @@ export class AuthenticatorsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.authenticators.deleteAll("id") @@ -55,7 +57,7 @@ export class AuthenticatorsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/authenticators`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/authenticators`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/users/resources/connectedAccounts/client/Client.ts b/src/management/api/resources/users/resources/connectedAccounts/client/Client.ts index 02f7944d8d..487abac785 100644 --- a/src/management/api/resources/users/resources/connectedAccounts/client/Client.ts +++ b/src/management/api/resources/users/resources/connectedAccounts/client/Client.ts @@ -34,6 +34,8 @@ export class ConnectedAccountsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.connectedAccounts.list("id", { @@ -66,7 +68,7 @@ export class ConnectedAccountsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/connected-accounts`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/connected-accounts`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/users/resources/effectivePermissions/client/Client.ts b/src/management/api/resources/users/resources/effectivePermissions/client/Client.ts index c459e8a3f2..05b072d6fe 100644 --- a/src/management/api/resources/users/resources/effectivePermissions/client/Client.ts +++ b/src/management/api/resources/users/resources/effectivePermissions/client/Client.ts @@ -40,6 +40,8 @@ export class EffectivePermissionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.effectivePermissions.list("id", { @@ -79,7 +81,7 @@ export class EffectivePermissionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/effective-permissions`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/effective-permissions`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/client/Client.ts b/src/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/client/Client.ts index 00fbe424e4..40177dbc01 100644 --- a/src/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/client/Client.ts +++ b/src/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/client/Client.ts @@ -37,6 +37,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.effectivePermissions.sources.roles.list("id", { @@ -83,7 +85,7 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/effective-permissions/sources/effective-roles`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/effective-permissions/sources/effective-roles`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/users/resources/effectiveRoles/client/Client.ts b/src/management/api/resources/users/resources/effectiveRoles/client/Client.ts index 79c75dda25..5de7c5ec06 100644 --- a/src/management/api/resources/users/resources/effectiveRoles/client/Client.ts +++ b/src/management/api/resources/users/resources/effectiveRoles/client/Client.ts @@ -40,6 +40,8 @@ export class EffectiveRolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.effectiveRoles.list("id", { @@ -72,7 +74,7 @@ export class EffectiveRolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/effective-roles`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/effective-roles`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts b/src/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts index 4a1ac22bd0..03d21bd9c3 100644 --- a/src/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts +++ b/src/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/client/Client.ts @@ -37,6 +37,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.effectiveRoles.sources.groups.list("id", { @@ -71,7 +73,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/effective-roles/sources/groups`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/effective-roles/sources/groups`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/users/resources/enrollments/client/Client.ts b/src/management/api/resources/users/resources/enrollments/client/Client.ts index 75e4238edf..443df362b0 100644 --- a/src/management/api/resources/users/resources/enrollments/client/Client.ts +++ b/src/management/api/resources/users/resources/enrollments/client/Client.ts @@ -33,6 +33,8 @@ export class EnrollmentsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.enrollments.get("id") @@ -59,7 +61,7 @@ export class EnrollmentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/enrollments`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/enrollments`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/users/resources/groups/client/Client.ts b/src/management/api/resources/users/resources/groups/client/Client.ts index 8ee5cef021..d5bbaaa44f 100644 --- a/src/management/api/resources/users/resources/groups/client/Client.ts +++ b/src/management/api/resources/users/resources/groups/client/Client.ts @@ -34,6 +34,8 @@ export class GroupsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.groups.get("id", { @@ -78,7 +80,7 @@ export class GroupsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/groups`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/groups`, ), method: "GET", headers: _headers, diff --git a/src/management/api/resources/users/resources/identities/client/Client.ts b/src/management/api/resources/users/resources/identities/client/Client.ts index d48a64f674..2a4c6f8c3a 100644 --- a/src/management/api/resources/users/resources/identities/client/Client.ts +++ b/src/management/api/resources/users/resources/identities/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -62,6 +63,8 @@ export class IdentitiesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.identities.link("id") @@ -90,14 +93,14 @@ export class IdentitiesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/identities`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/identities`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -146,6 +149,8 @@ export class IdentitiesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.identities.delete("id", "ad", "user_id") @@ -176,7 +181,7 @@ export class IdentitiesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/identities/${core.url.encodePathParam(provider)}/${core.url.encodePathParam(user_id)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/identities/${core.url.encodePathParam(provider, errors.ManagementError)}/${core.url.encodePathParam(user_id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/users/resources/logs/client/Client.ts b/src/management/api/resources/users/resources/logs/client/Client.ts index 87466c15d9..47627dbc2b 100644 --- a/src/management/api/resources/users/resources/logs/client/Client.ts +++ b/src/management/api/resources/users/resources/logs/client/Client.ts @@ -39,6 +39,8 @@ export class LogsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.logs.list("id", { @@ -75,7 +77,7 @@ export class LogsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/logs`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/logs`, ), method: "GET", headers: _headers, @@ -136,8 +138,15 @@ export class LogsClient { (request?.per_page == null || (response?.logs ?? []).length >= request?.per_page), getItems: (response) => response?.logs ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } diff --git a/src/management/api/resources/users/resources/multifactor/client/Client.ts b/src/management/api/resources/users/resources/multifactor/client/Client.ts index 2f6268ad2b..e1e12a3f24 100644 --- a/src/management/api/resources/users/resources/multifactor/client/Client.ts +++ b/src/management/api/resources/users/resources/multifactor/client/Client.ts @@ -31,6 +31,8 @@ export class MultifactorClient { * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.multifactor.invalidateRememberBrowser("id") @@ -57,7 +59,7 @@ export class MultifactorClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/multifactor/actions/invalidate-remember-browser`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/multifactor/actions/invalidate-remember-browser`, ), method: "POST", headers: _headers, @@ -109,6 +111,8 @@ export class MultifactorClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.multifactor.deleteProvider("id", "duo") @@ -137,7 +141,7 @@ export class MultifactorClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/multifactor/${core.url.encodePathParam(provider)}`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/multifactor/${core.url.encodePathParam(provider, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/users/resources/organizations/client/Client.ts b/src/management/api/resources/users/resources/organizations/client/Client.ts index 9f95559aa8..7ca7b8cbf0 100644 --- a/src/management/api/resources/users/resources/organizations/client/Client.ts +++ b/src/management/api/resources/users/resources/organizations/client/Client.ts @@ -50,6 +50,8 @@ export class OrganizationsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.organizations.list("id", { @@ -84,7 +86,7 @@ export class OrganizationsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/organizations`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/organizations`, ), method: "GET", headers: _headers, @@ -152,8 +154,15 @@ export class OrganizationsClient { (request?.per_page == null || (response?.organizations ?? []).length >= request?.per_page), getItems: (response) => response?.organizations ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } diff --git a/src/management/api/resources/users/resources/permissions/client/Client.ts b/src/management/api/resources/users/resources/permissions/client/Client.ts index 85bc783fb9..327bbcdb9e 100644 --- a/src/management/api/resources/users/resources/permissions/client/Client.ts +++ b/src/management/api/resources/users/resources/permissions/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -36,6 +37,8 @@ export class PermissionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.permissions.list("id", { @@ -72,7 +75,7 @@ export class PermissionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/permissions`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/permissions`, ), method: "GET", headers: _headers, @@ -143,8 +146,15 @@ export class PermissionsClient { (request?.per_page == null || (response?.permissions ?? []).length >= request?.per_page), getItems: (response) => response?.permissions ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -161,6 +171,8 @@ export class PermissionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.permissions.create("id", { @@ -194,14 +206,14 @@ export class PermissionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/permissions`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/permissions`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -248,6 +260,8 @@ export class PermissionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.permissions.delete("id", { @@ -281,14 +295,14 @@ export class PermissionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/permissions`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/permissions`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/users/resources/refreshToken/client/Client.ts b/src/management/api/resources/users/resources/refreshToken/client/Client.ts index 79395e949c..e5166ceaef 100644 --- a/src/management/api/resources/users/resources/refreshToken/client/Client.ts +++ b/src/management/api/resources/users/resources/refreshToken/client/Client.ts @@ -33,6 +33,8 @@ export class RefreshTokenClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.refreshToken.list("user_id", { @@ -69,7 +71,7 @@ export class RefreshTokenClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(user_id)}/refresh-tokens`, + `users/${core.url.encodePathParam(user_id, errors.ManagementError)}/refresh-tokens`, ), method: "GET", headers: _headers, @@ -149,6 +151,8 @@ export class RefreshTokenClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.refreshToken.delete("user_id") @@ -172,7 +176,7 @@ export class RefreshTokenClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(user_id)}/refresh-tokens`, + `users/${core.url.encodePathParam(user_id, errors.ManagementError)}/refresh-tokens`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/users/resources/riskAssessments/client/Client.ts b/src/management/api/resources/users/resources/riskAssessments/client/Client.ts index c6f9dfe1de..f89968880d 100644 --- a/src/management/api/resources/users/resources/riskAssessments/client/Client.ts +++ b/src/management/api/resources/users/resources/riskAssessments/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -33,6 +34,8 @@ export class RiskAssessmentsClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.riskAssessments.clear("id", { @@ -64,14 +67,14 @@ export class RiskAssessmentsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/risk-assessments/clear`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/risk-assessments/clear`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/users/resources/roles/client/Client.ts b/src/management/api/resources/users/resources/roles/client/Client.ts index 321415b2aa..7dce42090e 100644 --- a/src/management/api/resources/users/resources/roles/client/Client.ts +++ b/src/management/api/resources/users/resources/roles/client/Client.ts @@ -4,6 +4,7 @@ import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../Ba import { normalizeClientOptionsWithAuth, type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js"; import * as core from "../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../core/requestBody.js"; import * as environments from "../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../errors/index.js"; @@ -38,6 +39,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.roles.list("id", { @@ -72,7 +75,7 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/roles`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/roles`, ), method: "GET", headers: _headers, @@ -135,8 +138,15 @@ export class RolesClient { (request?.per_page == null || (response?.roles ?? []).length >= request?.per_page), getItems: (response) => response?.roles ?? [], loadPage: (_response) => { - _offset += 1; - return list(core.setObjectProperty(request, "page", _offset)); + const _nextOffset = _offset + 1; + return core.HttpResponsePromise.fromPromise( + list(core.setObjectProperty(request, "page", _nextOffset)) + .withRawResponse() + .then((_pageResponse) => { + _offset = _nextOffset; + return _pageResponse; + }), + ); }, }); } @@ -155,6 +165,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.roles.assign("id", { @@ -185,14 +197,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/roles`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/roles`, ), method: "POST", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -240,6 +252,8 @@ export class RolesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.roles.delete("id", { @@ -270,14 +284,14 @@ export class RolesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(id)}/roles`, + `users/${core.url.encodePathParam(id, errors.ManagementError)}/roles`, ), method: "DELETE", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/resources/users/resources/sessions/client/Client.ts b/src/management/api/resources/users/resources/sessions/client/Client.ts index 78ed641d68..eea3fc040a 100644 --- a/src/management/api/resources/users/resources/sessions/client/Client.ts +++ b/src/management/api/resources/users/resources/sessions/client/Client.ts @@ -33,6 +33,8 @@ export class SessionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.sessions.list("user_id", { @@ -67,7 +69,7 @@ export class SessionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(user_id)}/sessions`, + `users/${core.url.encodePathParam(user_id, errors.ManagementError)}/sessions`, ), method: "GET", headers: _headers, @@ -144,6 +146,8 @@ export class SessionsClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.users.sessions.delete("user_id") @@ -167,7 +171,7 @@ export class SessionsClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `users/${core.url.encodePathParam(user_id)}/sessions`, + `users/${core.url.encodePathParam(user_id, errors.ManagementError)}/sessions`, ), method: "DELETE", headers: _headers, diff --git a/src/management/api/resources/verifiableCredentials/resources/verification/resources/templates/client/Client.ts b/src/management/api/resources/verifiableCredentials/resources/verification/resources/templates/client/Client.ts index ad5a594444..d8cb9a69a9 100644 --- a/src/management/api/resources/verifiableCredentials/resources/verification/resources/templates/client/Client.ts +++ b/src/management/api/resources/verifiableCredentials/resources/verification/resources/templates/client/Client.ts @@ -7,6 +7,7 @@ import { } from "../../../../../../../../BaseClient.js"; import * as core from "../../../../../../../../core/index.js"; import { mergeHeaders } from "../../../../../../../../core/headers.js"; +import { mergeAdditionalBodyParameters } from "../../../../../../../../core/requestBody.js"; import * as environments from "../../../../../../../../environments.js"; import { handleNonStatusCodeError } from "../../../../../../../../errors/handleNonStatusCodeError.js"; import * as errors from "../../../../../../../../errors/index.js"; @@ -35,6 +36,8 @@ export class TemplatesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.verifiableCredentials.verification.templates.list({ @@ -154,6 +157,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.verifiableCredentials.verification.templates.create({ @@ -197,7 +202,7 @@ export class TemplatesClient { contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, @@ -251,6 +256,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.verifiableCredentials.verification.templates.get("id") @@ -277,7 +284,7 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `verifiable-credentials/verification/templates/${core.url.encodePathParam(id)}`, + `verifiable-credentials/verification/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "GET", headers: _headers, @@ -334,6 +341,8 @@ export class TemplatesClient { * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.verifiableCredentials.verification.templates.delete("id") @@ -357,7 +366,7 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `verifiable-credentials/verification/templates/${core.url.encodePathParam(id)}`, + `verifiable-credentials/verification/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "DELETE", headers: _headers, @@ -411,6 +420,8 @@ export class TemplatesClient { * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} + * @throws {@link errors.ManagementError} + * @throws {@link errors.ManagementTimeoutError} * * @example * await client.verifiableCredentials.verification.templates.update("id") @@ -439,14 +450,14 @@ export class TemplatesClient { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.ManagementEnvironment.Default, - `verifiable-credentials/verification/templates/${core.url.encodePathParam(id)}`, + `verifiable-credentials/verification/templates/${core.url.encodePathParam(id, errors.ManagementError)}`, ), method: "PATCH", headers: _headers, contentType: "application/json", queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), requestType: "json", - body: request, + body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters), timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/management/api/types/types.ts b/src/management/api/types/types.ts index 28fbb2ee3d..9d82c4d1d4 100644 --- a/src/management/api/types/types.ts +++ b/src/management/api/types/types.ts @@ -1528,64 +1528,6 @@ export interface AttackProtectionCaptchaHcaptchaResponseContent { [key: string]: any; } -/** - * An attack protection policy override for CAPTCHA. - */ -export interface AttackProtectionCaptchaPolicy { - /** System-generated identifier for the policy. */ - id: string; - /** Human-readable policy name. */ - name: string; - /** Description of the policy's purpose. */ - description?: string | undefined; - /** Conflict resolution order. Lower number takes higher precedence. */ - priority: number; - match: Management.AttackProtectionCaptchaPolicyMatch; - action: Management.AttackProtectionCaptchaPolicyAction; - /** ISO 8601 timestamp when the policy was created. */ - created_at: string; - /** ISO 8601 timestamp when the policy was last updated. */ - updated_at: string; -} - -/** - * CAPTCHA configuration override stored for this policy. - */ -export interface AttackProtectionCaptchaPolicyAction { - active_provider_id?: Management.CaptchaActiveProviderEnum | undefined; - simple_captcha?: Management.CaptchaPolicyActionSimpleCaptcha | undefined; - auth_challenge?: Management.CaptchaPolicyActionAuthChallenge | undefined; - recaptcha_v2?: Management.CaptchaPolicyActionRecaptchaV2 | undefined; - recaptcha_enterprise?: Management.CaptchaPolicyActionRecaptchaEnterprise | undefined; - hcaptcha?: Management.CaptchaPolicyActionHcaptcha | undefined; - friendly_captcha?: Management.CaptchaPolicyActionFriendlyCaptcha | undefined; - arkose?: Management.CaptchaPolicyActionArkose | undefined; -} - -/** - * CAPTCHA configuration override for this policy. - */ -export interface AttackProtectionCaptchaPolicyActionInput { - active_provider_id?: Management.CaptchaActiveProviderEnum | undefined; - simple_captcha?: Management.CaptchaPolicyActionSimpleCaptcha | undefined; - auth_challenge?: Management.CaptchaPolicyActionAuthChallenge | undefined; - recaptcha_v2?: Management.CaptchaPolicyActionRecaptchaV2Input | undefined; - recaptcha_enterprise?: Management.CaptchaPolicyActionRecaptchaEnterpriseInput | undefined; - hcaptcha?: Management.CaptchaPolicyActionHcaptchaInput | undefined; - friendly_captcha?: Management.CaptchaPolicyActionFriendlyCaptchaInput | undefined; - arkose?: Management.CaptchaPolicyActionArkoseInput | undefined; -} - -/** - * Traffic matching criteria for the policy. Exactly one of auth0_managed or geo_country_codes must be specified. - */ -export interface AttackProtectionCaptchaPolicyMatch { - /** Match by Auth0-managed traffic identifiers. */ - auth0_managed?: string[] | undefined; - /** Match by ISO 3166-1 alpha-2 country codes. */ - geo_country_codes?: string[] | undefined; -} - /** The id of the active provider for the CAPTCHA. */ export const AttackProtectionCaptchaProviderId = { Arkose: "arkose", @@ -2189,137 +2131,6 @@ export interface BulkUpdateAculResponseContent { [key: string]: any; } -/** The CAPTCHA provider type. */ -export const CaptchaActiveProviderEnum = { - SimpleCaptcha: "simple_captcha", - AuthChallenge: "auth_challenge", - RecaptchaV2: "recaptcha_v2", - RecaptchaEnterprise: "recaptcha_enterprise", - Hcaptcha: "hcaptcha", - FriendlyCaptcha: "friendly_captcha", - Arkose: "arkose", -} as const; -export type CaptchaActiveProviderEnum = (typeof CaptchaActiveProviderEnum)[keyof typeof CaptchaActiveProviderEnum]; - -/** - * Arkose Labs provider configuration. - */ -export interface CaptchaPolicyActionArkose { - /** The Arkose Labs site key. */ - site_key?: string | undefined; - /** The Arkose Labs client subdomain. */ - client_subdomain?: string | undefined; - /** The Arkose Labs verify subdomain. */ - verify_subdomain?: string | undefined; - /** Whether to allow access when Arkose Labs is unavailable. */ - fail_open?: boolean | undefined; -} - -/** - * Arkose Labs provider configuration. - */ -export interface CaptchaPolicyActionArkoseInput { - /** The Arkose Labs site key. */ - site_key?: string | undefined; - /** The Arkose Labs private key. Encrypted at rest. */ - secret?: string | undefined; - /** The Arkose Labs client subdomain. */ - client_subdomain?: string | undefined; - /** The Arkose Labs verify subdomain. */ - verify_subdomain?: string | undefined; - /** Whether to allow access when Arkose Labs is unavailable. */ - fail_open?: boolean | undefined; -} - -/** - * Auth Challenge CAPTCHA provider configuration. - */ -export interface CaptchaPolicyActionAuthChallenge { - /** Whether to allow access when the challenge provider is unavailable. */ - fail_open?: boolean | undefined; -} - -/** - * Friendly Captcha provider configuration. - */ -export interface CaptchaPolicyActionFriendlyCaptcha { - /** The Friendly Captcha site key. */ - site_key?: string | undefined; -} - -/** - * Friendly Captcha provider configuration. - */ -export interface CaptchaPolicyActionFriendlyCaptchaInput { - /** The Friendly Captcha site key. */ - site_key?: string | undefined; - /** The Friendly Captcha secret key. Encrypted at rest. */ - secret?: string | undefined; -} - -/** - * hCaptcha provider configuration. - */ -export interface CaptchaPolicyActionHcaptcha { - /** The hCaptcha site key. */ - site_key?: string | undefined; -} - -/** - * hCaptcha provider configuration. - */ -export interface CaptchaPolicyActionHcaptchaInput { - /** The hCaptcha site key. */ - site_key?: string | undefined; - /** The hCaptcha secret key. Encrypted at rest. */ - secret?: string | undefined; -} - -/** - * reCAPTCHA Enterprise provider configuration. - */ -export interface CaptchaPolicyActionRecaptchaEnterprise { - /** The reCAPTCHA Enterprise site key. */ - site_key?: string | undefined; - /** The Google Cloud project ID. */ - project_id?: string | undefined; -} - -/** - * reCAPTCHA Enterprise provider configuration. - */ -export interface CaptchaPolicyActionRecaptchaEnterpriseInput { - /** The reCAPTCHA Enterprise site key. */ - site_key?: string | undefined; - /** The Google Cloud project ID. */ - project_id?: string | undefined; - /** The reCAPTCHA Enterprise API key. Encrypted at rest. */ - api_key?: string | undefined; -} - -/** - * reCAPTCHA v2 provider configuration. - */ -export interface CaptchaPolicyActionRecaptchaV2 { - /** The reCAPTCHA v2 site key. */ - site_key?: string | undefined; -} - -/** - * reCAPTCHA v2 provider configuration. - */ -export interface CaptchaPolicyActionRecaptchaV2Input { - /** The reCAPTCHA v2 site key. */ - site_key?: string | undefined; - /** The reCAPTCHA v2 secret key. Encrypted at rest. */ - secret?: string | undefined; -} - -/** - * Simple CAPTCHA provider configuration. - */ -export interface CaptchaPolicyActionSimpleCaptcha {} - export interface CertificateSubjectDnCredential { credential_type: Management.CertificateSubjectDnCredentialTypeEnum; /** Friendly name for a credential. */ @@ -7032,7 +6843,7 @@ export interface ConnectionPropertiesOptions { /** Enable this if you have a legacy user store and you want to gradually migrate those users to the Auth0 user store */ import_mode?: boolean | undefined; /** Stores encrypted string only configurations for connections */ - configuration?: (Record | null) | undefined; + configuration?: (Record | null) | undefined; customScripts?: Management.ConnectionCustomScripts | undefined; authentication_methods?: (Management.ConnectionAuthenticationMethods | null) | undefined; passkey_options?: (Management.ConnectionPasskeyOptions | null) | undefined; @@ -8623,7 +8434,7 @@ export type ConnectionUpstreamAliasEnum = * Options for adding parameters in the request to the upstream IdP */ export type ConnectionUpstreamParams = - | (Record | null) + | (Record | null) | undefined; /** @@ -8721,7 +8532,7 @@ export type ConnectionsDiscoveryUrl = (string | null) | undefined; /** * Metadata associated with the connection in the form of an object with string values (max 255 chars). Maximum of 10 metadata properties allowed. */ -export type ConnectionsMetadata = Record; +export type ConnectionsMetadata = Record; /** * Additional OIDC metadata to include in the discovery document. Only applicable when strategy=oidc, okta, or samlp. @@ -10180,6 +9991,7 @@ export interface CreateExperimentResponseContent { authentication_flow: string; allocation_strategy: Management.AllocationStrategyEnum; status: Management.ExperimentStatusEnum; + /** Whether the experiment is valid and ready to activate, as of its last update. It can lag changes made later to related entities. Call POST /experiments/{id}/validate for the current result. */ is_valid: boolean; default_config?: Management.DefaultConfigEnum | undefined; feature_flag_snapshot?: (Record | null) | undefined; @@ -11907,7 +11719,7 @@ export type DomainCertificateStatusEnum = /** * Domain metadata associated with the custom domain, in the form of an object with string values (max 255 chars). Maximum of 10 domain metadata properties allowed. */ -export type DomainMetadata = Record; +export type DomainMetadata = Record; /** * Domain verification settings. @@ -22272,6 +22084,7 @@ export interface EventStreamCloudEventContext { connection?: Management.EventStreamCloudEventContextConnection | undefined; request?: Management.EventStreamCloudEventContextRequest | undefined; tenant: Management.EventStreamCloudEventContextTenant; + transaction?: Management.EventStreamCloudEventContextTransaction | undefined; } /** @@ -22351,6 +22164,71 @@ export interface EventStreamCloudEventContextTenant { id: string; } +/** + * An auth transaction. + */ +export interface EventStreamCloudEventContextTransaction { + /** acr_values in the request. */ + acr_values: string[]; + /** The locale used for this transaction. */ + locale: string; + /** Hint about the login identifier the user might use in this transaction. */ + login_hint?: string | undefined; + /** Instructions indicating whether the user may be prompted for re-authentication and consent. */ + prompt?: string[] | undefined; + protocol?: Management.EventStreamCloudEventContextTransactionProtocolEnum | undefined; + /** The URL to which the client will be redirected when the transaction completes. */ + redirect_uri?: string | undefined; + /** The scopes requested. */ + requested_scopes: string[]; + response_mode?: Management.EventStreamCloudEventContextTransactionResponseModeEnum | undefined; + /** The kind of credential issued by this transaction. */ + response_type?: Management.EventStreamCloudEventContextTransactionResponseTypeItemEnum[] | undefined; + /** The OAuth state parameter for this transaction. */ + state?: string | undefined; + /** The ui_locales requested for this transaction. */ + ui_locales: string[]; +} + +/** The protocol used for this transaction. */ +export const EventStreamCloudEventContextTransactionProtocolEnum = { + OidcBasicProfile: "oidc-basic-profile", + OidcImplicitProfile: "oidc-implicit-profile", + Oauth2DeviceCode: "oauth2-device-code", + Oauth2ResourceOwner: "oauth2-resource-owner", + Oauth2ResourceOwnerJwtBearer: "oauth2-resource-owner-jwt-bearer", + Oauth2Password: "oauth2-password", + Oauth2Webauthn: "oauth2-webauthn", + Oauth2AccessToken: "oauth2-access-token", + Oauth2RefreshToken: "oauth2-refresh-token", + Oauth2TokenExchange: "oauth2-token-exchange", + OidcHybridProfile: "oidc-hybrid-profile", + Samlp: "samlp", + Wsfed: "wsfed", + WstrustUsernamemixed: "wstrust-usernamemixed", +} as const; +export type EventStreamCloudEventContextTransactionProtocolEnum = + (typeof EventStreamCloudEventContextTransactionProtocolEnum)[keyof typeof EventStreamCloudEventContextTransactionProtocolEnum]; + +/** This transaction's method for returning parameters from the Authorization Endpoint. */ +export const EventStreamCloudEventContextTransactionResponseModeEnum = { + Query: "query", + Fragment: "fragment", + FormPost: "form_post", + WebMessage: "web_message", +} as const; +export type EventStreamCloudEventContextTransactionResponseModeEnum = + (typeof EventStreamCloudEventContextTransactionResponseModeEnum)[keyof typeof EventStreamCloudEventContextTransactionResponseModeEnum]; + +/** OAuth/OIDC response types. */ +export const EventStreamCloudEventContextTransactionResponseTypeItemEnum = { + Code: "code", + Token: "token", + IdToken: "id_token", +} as const; +export type EventStreamCloudEventContextTransactionResponseTypeItemEnum = + (typeof EventStreamCloudEventContextTransactionResponseTypeItemEnum)[keyof typeof EventStreamCloudEventContextTransactionResponseTypeItemEnum]; + /** * Event contents. */ @@ -28992,6 +28870,7 @@ export interface ExperimentListItem { authentication_flow: string; allocation_strategy: Management.AllocationStrategyEnum; status: Management.ExperimentStatusEnum; + /** Whether the experiment is valid and ready to activate, as of its last update. It can lag changes made later to related entities. Call POST /experiments/{id}/validate for the current result. */ is_valid: boolean; default_config?: Management.DefaultConfigEnum | undefined; feature_flag_snapshot?: (Record | null) | undefined; @@ -29533,7 +29412,7 @@ export type FlowActionAuth0SendRequestParamsPayloadObject = Record; export namespace FlowActionAuth0SendRequestParamsQueryParams { @@ -30039,7 +29918,7 @@ export type FlowActionHttpSendRequestParamsPayloadObject = Record; export namespace FlowActionHttpSendRequestParamsQueryParams { @@ -33298,6 +33177,7 @@ export interface GetExperimentResponseContent { authentication_flow: string; allocation_strategy: Management.AllocationStrategyEnum; status: Management.ExperimentStatusEnum; + /** Whether the experiment is valid and ready to activate, as of its last update. It can lag changes made later to related entities. Call POST /experiments/{id}/validate for the current result. */ is_valid: boolean; default_config?: Management.DefaultConfigEnum | undefined; feature_flag_snapshot?: (Record | null) | undefined; @@ -34456,7 +34336,7 @@ export interface GuardianFactor { settings?: Management.GuardianFactorSettings | undefined; } -/** Factor name. Can be `sms`, `push-notification`, `email`, `duo` `otp` `webauthn-roaming`, `webauthn-platform`, or `recovery-code`. */ +/** Factor name. Can be `sms`, `push-notification`, `email`, `duo`, `otp`, `webauthn-roaming`, `webauthn-platform`, `recovery-code`, or `passkey`. */ export const GuardianFactorNameEnum = { PushNotification: "push-notification", Sms: "sms", @@ -34466,6 +34346,7 @@ export const GuardianFactorNameEnum = { WebauthnRoaming: "webauthn-roaming", WebauthnPlatform: "webauthn-platform", RecoveryCode: "recovery-code", + Passkey: "passkey", } as const; export type GuardianFactorNameEnum = (typeof GuardianFactorNameEnum)[keyof typeof GuardianFactorNameEnum]; @@ -34857,11 +34738,6 @@ export interface ListAgentsResponseContent { next?: string | undefined; } -/** - * List of CAPTCHA attack protection policies for the tenant, sorted by priority ascending. - */ -export type ListAttackProtectionCaptchaPoliciesResponseContent = Management.AttackProtectionCaptchaPolicy[]; - export interface ListBrandingPhoneProvidersResponseContent { providers?: Management.PhoneProviderSchemaMasked[] | undefined; } @@ -36462,7 +36338,7 @@ export interface OrganizationMemberRole { /** * Metadata associated with the organization, in the form of an object with string values (max 255 chars). Maximum of 25 metadata properties allowed. */ -export type OrganizationMetadata = Record; +export type OrganizationMetadata = Record; /** Field name to sort results by in ascending order only. Defaults to insertion order (oldest first) if not provided. */ export const OrganizationSortFieldEnum = { @@ -39627,7 +39503,7 @@ export interface UpdateConnectionOptions { /** Enable this if you have a legacy user store and you want to gradually migrate those users to the Auth0 user store */ import_mode?: boolean | undefined; /** Stores encrypted string only configurations for connections */ - configuration?: (Record | null) | undefined; + configuration?: (Record | null) | undefined; customScripts?: Management.ConnectionCustomScripts | undefined; authentication_methods?: (Management.ConnectionAuthenticationMethods | null) | undefined; passkey_options?: (Management.ConnectionPasskeyOptions | null) | undefined; @@ -40260,6 +40136,7 @@ export interface UpdateExperimentResponseContent { authentication_flow: string; allocation_strategy: Management.AllocationStrategyEnum; status: Management.ExperimentStatusEnum; + /** Whether the experiment is valid and ready to activate, as of its last update. It can lag changes made later to related entities. Call POST /experiments/{id}/validate for the current result. */ is_valid: boolean; default_config?: Management.DefaultConfigEnum | undefined; feature_flag_snapshot?: (Record | null) | undefined; @@ -40903,9 +40780,9 @@ export interface UpdateUserResponseContent { } /** - * Configuration overrides for this variation; keys must exist in the parent flag parameters. Empty {} is the baseline (control) variation that overrides nothing. + * Top-level keys merge into the stored overrides. Set a key to `null` to remove it. Set `overrides` to `null` or `{}` to clear all. Keys must exist in the parent flag parameters. */ -export type UpdateVariationOverridesMap = Record; +export type UpdateVariationOverridesMap = (Record | null) | undefined; export interface UpdateVariationResponseContent { id: string; diff --git a/src/management/core/fetcher/Fetcher.ts b/src/management/core/fetcher/Fetcher.ts index 943ec1bfe9..b8456abedb 100644 --- a/src/management/core/fetcher/Fetcher.ts +++ b/src/management/core/fetcher/Fetcher.ts @@ -7,11 +7,13 @@ import { EndpointSupplier } from "./EndpointSupplier.js"; import { getErrorResponseBody } from "./getErrorResponseBody.js"; import { getFetchFn } from "./getFetchFn.js"; import { getRequestBody } from "./getRequestBody.js"; -import { getResponseBody } from "./getResponseBody.js"; +import { getResponseBody, isResponseBodyError } from "./getResponseBody.js"; import { Headers } from "./Headers.js"; -import { makeRequest } from "./makeRequest.js"; +import { clearResponseTimeout, makeRequest } from "./makeRequest.js"; import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js"; +import { redactUrl, SENSITIVE_QUERY_PARAMS } from "./redactUrl.js"; import { requestWithRetries } from "./requestWithRetries.js"; +import { TIMEOUT } from "./signals.js"; export type FetchFunction = (args: Fetcher.Args) => Promise>; @@ -103,27 +105,6 @@ function redactHeaders(headers: Headers | Record): Record | undefined, ): Record | undefined { @@ -137,88 +118,6 @@ function redactQueryParameters( return redacted; } -function redactUrl(url: string): string { - const protocolIndex = url.indexOf("://"); - if (protocolIndex === -1) return url; - - const afterProtocol = protocolIndex + 3; - - // Find the first delimiter that marks the end of the authority section - const pathStart = url.indexOf("/", afterProtocol); - let queryStart = url.indexOf("?", afterProtocol); - let fragmentStart = url.indexOf("#", afterProtocol); - - const firstDelimiter = Math.min( - pathStart === -1 ? url.length : pathStart, - queryStart === -1 ? url.length : queryStart, - fragmentStart === -1 ? url.length : fragmentStart, - ); - - // Find the LAST @ before the delimiter (handles multiple @ in credentials) - let atIndex = -1; - for (let i = afterProtocol; i < firstDelimiter; i++) { - if (url[i] === "@") { - atIndex = i; - } - } - - if (atIndex !== -1) { - url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`; - } - - // Recalculate queryStart since url might have changed - queryStart = url.indexOf("?"); - if (queryStart === -1) return url; - - fragmentStart = url.indexOf("#", queryStart); - const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length; - const queryString = url.slice(queryStart + 1, queryEnd); - - if (queryString.length === 0) return url; - - // FAST PATH: Quick check if any sensitive keywords present - // Using indexOf is faster than regex for simple substring matching - const lower = queryString.toLowerCase(); - const hasSensitive = - lower.includes("token") || - lower.includes("key") || - lower.includes("password") || - lower.includes("passwd") || - lower.includes("secret") || - lower.includes("session") || - lower.includes("auth"); - - if (!hasSensitive) { - return url; - } - - // SLOW PATH: Parse and redact - const redactedParams: string[] = []; - const params = queryString.split("&"); - - for (const param of params) { - const equalIndex = param.indexOf("="); - if (equalIndex === -1) { - redactedParams.push(param); - continue; - } - - const key = param.slice(0, equalIndex); - let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()); - - if (!shouldRedact && key.includes("%")) { - try { - const decodedKey = decodeURIComponent(key); - shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase()); - } catch {} - } - - redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param); - } - - return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd); -} - async function getHeaders(args: Fetcher.Args): Promise { const newHeaders: Headers = new Headers(); @@ -254,6 +153,11 @@ async function getHeaders(args: Fetcher.Args): Promise { return newHeaders; } +function isJsonContentType(contentType: string | null): boolean { + const mediaType = contentType?.split(";")[0]?.trim().toLowerCase() ?? ""; + return mediaType === "application/json" || mediaType === "text/json" || mediaType.endsWith("+json"); +} + export async function fetcherImpl(args: Fetcher.Args): Promise> { let url = args.url; if (args.queryString != null && args.queryString.length > 0) { @@ -280,10 +184,18 @@ export async function fetcherImpl(args: Fetcher.Args): Promise - makeRequest( + async () => { + // A retry means the previous attempt is over; stop its timer now rather than at the end. + for (const previousResponse of attemptResponses) { + clearResponseTimeout(previousResponse); + } + const attemptResponse = await makeRequest( fetchFn, url, args.method, @@ -294,8 +206,13 @@ export async function fetcherImpl(args: Fetcher.Args): Promise= 200 && response.status < 400) { @@ -309,6 +226,18 @@ export async function fetcherImpl(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise { + *entries(): IterableIterator<[string, string]> { for (const [key, values] of this.headers.entries()) { yield [key, values.join(", ")]; } } - *keys(): HeadersIterator { + *keys(): IterableIterator { yield* this.headers.keys(); } - *values(): HeadersIterator { + *values(): IterableIterator { for (const values of this.headers.values()) { yield values.join(", "); } } - [Symbol.iterator](): HeadersIterator<[string, string]> { + [Symbol.iterator](): IterableIterator<[string, string]> { return this.entries(); } }; diff --git a/src/management/core/fetcher/getErrorResponseBody.ts b/src/management/core/fetcher/getErrorResponseBody.ts index 7cf4e623c2..a8bcfd9178 100644 --- a/src/management/core/fetcher/getErrorResponseBody.ts +++ b/src/management/core/fetcher/getErrorResponseBody.ts @@ -1,10 +1,26 @@ import { fromJson } from "../json.js"; -import { getResponseBody } from "./getResponseBody.js"; +import { getResponseBody, isResponseBodyError } from "./getResponseBody.js"; + +/** Parses a JSON error body, falling back to the raw text so the status and body are never lost. */ +function parseJsonErrorBody(text: string): unknown { + if (text.length === 0) { + return undefined; + } + try { + return fromJson(text); + } catch { + return text; + } +} export async function getErrorResponseBody(response: Response): Promise { let contentType = response.headers.get("Content-Type")?.toLowerCase(); if (contentType == null || contentType.length === 0) { - return getResponseBody(response); + const body = await getResponseBody(response); + if (isResponseBodyError(body)) { + return body.error.reason === "non-json" ? body.error.rawBody : undefined; + } + return body; } if (contentType.indexOf(";") !== -1) { @@ -16,14 +32,11 @@ export async function getErrorResponseBody(response: Response): Promise case "application/ld+json": case "application/problem+json": case "application/vnd.api+json": - case "text/json": { - const text = await response.text(); - return text.length > 0 ? fromJson(text) : undefined; - } + case "text/json": + return parseJsonErrorBody(await response.text()); default: if (contentType.startsWith("application/vnd.") && contentType.endsWith("+json")) { - const text = await response.text(); - return text.length > 0 ? fromJson(text) : undefined; + return parseJsonErrorBody(await response.text()); } // Fallback to plain text if content type is not recognized diff --git a/src/management/core/fetcher/getResponseBody.ts b/src/management/core/fetcher/getResponseBody.ts index 2e831e4956..e0b736335a 100644 --- a/src/management/core/fetcher/getResponseBody.ts +++ b/src/management/core/fetcher/getResponseBody.ts @@ -11,6 +11,27 @@ function retainResponse(target: object, response: Response): void { }); } +export type ResponseBodyError = { + ok: false; + error: { reason: "non-json"; statusCode: number; rawBody: string } | { reason: "body-is-null"; statusCode: number }; +}; + +const responseBodyErrors = new WeakSet(); + +function responseBodyError(error: ResponseBodyError["error"]): ResponseBodyError { + const record: ResponseBodyError = { ok: false, error }; + responseBodyErrors.add(record); + return record; +} + +/** + * Returns true when `value` is a failure record created by `getResponseBody` (for example malformed JSON), + * as opposed to a parsed JSON body that happens to have the same shape. + */ +export function isResponseBodyError(value: unknown): value is ResponseBodyError { + return typeof value === "object" && value != null && responseBodyErrors.has(value); +} + export async function getResponseBody(response: Response, responseType?: string): Promise { switch (responseType) { case "binary-response": @@ -21,25 +42,19 @@ export async function getResponseBody(response: Response, responseType?: string) return await response.arrayBuffer(); case "sse": if (response.body == null) { - return { - ok: false, - error: { - reason: "body-is-null", - statusCode: response.status, - }, - }; + return responseBodyError({ + reason: "body-is-null", + statusCode: response.status, + }); } retainResponse(response.body, response); return response.body; case "streaming": if (response.body == null) { - return { - ok: false, - error: { - reason: "body-is-null", - statusCode: response.status, - }, - }; + return responseBodyError({ + reason: "body-is-null", + statusCode: response.status, + }); } retainResponse(response.body, response); @@ -56,14 +71,11 @@ export async function getResponseBody(response: Response, responseType?: string) const responseBody = fromJson(text); return responseBody; } catch (_err) { - return { - ok: false, - error: { - reason: "non-json", - statusCode: response.status, - rawBody: text, - }, - }; + return responseBodyError({ + reason: "non-json", + statusCode: response.status, + rawBody: text, + }); } } return undefined; diff --git a/src/management/core/fetcher/makePassthroughRequest.ts b/src/management/core/fetcher/makePassthroughRequest.ts index f5ba761400..2c518a350a 100644 --- a/src/management/core/fetcher/makePassthroughRequest.ts +++ b/src/management/core/fetcher/makePassthroughRequest.ts @@ -3,7 +3,9 @@ import { join } from "../url/join.js"; import { EndpointSupplier } from "./EndpointSupplier.js"; import { getFetchFn } from "./getFetchFn.js"; import { makeRequest } from "./makeRequest.js"; +import { redactUrl } from "./redactUrl.js"; import { requestWithRetries } from "./requestWithRetries.js"; +import { TIMEOUT } from "./signals.js"; import { Supplier } from "./Supplier.js"; export declare namespace PassthroughRequest { @@ -114,8 +116,10 @@ export async function makePassthroughRequest( } } - // Apply auth headers - if (clientOptions.getAuthHeaders != null) { + // Apply auth headers, but only when the resolved URL targets the configured base URL. + // This prevents the SDK's credentials from leaking to an unrelated host when a caller + // passes an absolute cross-origin URL into the passthrough fetch escape hatch. + if (clientOptions.getAuthHeaders != null && targetsBaseUrl(fullUrl, baseUrl)) { const authHeaders = await clientOptions.getAuthHeaders(); for (const [key, value] of Object.entries(authHeaders)) { mergedHeaders[key.toLowerCase()] = value; @@ -155,35 +159,70 @@ export async function makePassthroughRequest( if (logger.isDebug()) { logger.debug("Making passthrough HTTP request", { method, - url: fullUrl, + url: redactUrl(fullUrl), hasBody: body != null, }); } - const response = await requestWithRetries( - async () => - makeRequest( - fetchFn, - fullUrl, - method, - mergedHeaders, - body ?? undefined, - timeoutMs, - abortSignal, - effectiveInit?.credentials === "include", - undefined, // duplex - false, // disableCache - ), - maxRetries, - ); + let response: Response; + try { + response = await requestWithRetries( + async () => + makeRequest( + fetchFn, + fullUrl, + method, + mergedHeaders, + body ?? undefined, + timeoutMs, + abortSignal, + effectiveInit?.credentials === "include", + undefined, // duplex + false, // disableCache + ), + maxRetries, + abortSignal, + ); + } catch (error) { + // Match `fetch`: a timeout rejects with an Error named "TimeoutError", not the bare abort reason. + if (error === TIMEOUT) { + throw createTimeoutError(); + } + throw error; + } if (logger.isDebug()) { logger.debug("Passthrough HTTP request completed", { method, - url: fullUrl, + url: redactUrl(fullUrl), statusCode: response.status, }); } return response; } + +function createTimeoutError(): Error { + const error = new Error("The request timed out."); + error.name = "TimeoutError"; + return error; +} + +/** + * Returns true when the resolved request URL points at the same origin as the + * configured base URL. Relative paths are always joined onto the base URL, so + * they resolve to the base origin and return true. Absolute URLs only match when + * their origin equals the base origin. When there is no base URL to compare + * against, or either value is not a parseable absolute URL, this returns false so + * auth headers are not attached. + */ +function targetsBaseUrl(fullUrl: string, baseUrl: string | undefined): boolean { + if (baseUrl == null) { + return false; + } + try { + return new URL(fullUrl).origin === new URL(baseUrl).origin; + } catch { + return false; + } +} diff --git a/src/management/core/fetcher/makeRequest.ts b/src/management/core/fetcher/makeRequest.ts index 360a86df40..62ff9fcc7e 100644 --- a/src/management/core/fetcher/makeRequest.ts +++ b/src/management/core/fetcher/makeRequest.ts @@ -1,4 +1,4 @@ -import { anySignal, getTimeoutSignal } from "./signals.js"; +import { anySignal, getTimeoutSignal, TIMEOUT } from "./signals.js"; /** * Cached result of checking whether the current runtime supports @@ -26,6 +26,20 @@ export function resetCacheNoStoreSupported(): void { _cacheNoStoreSupported = undefined; } +const responseTimeouts = new WeakMap>(); + +/** + * Clears the timeout that `makeRequest` kept running (with `keepTimeoutUntilBodyRead`) so that it also + * covered reading the response body. + */ +export function clearResponseTimeout(response: Response): void { + const timeoutId = responseTimeouts.get(response); + if (timeoutId != null) { + clearTimeout(timeoutId); + responseTimeouts.delete(response); + } +} + export const makeRequest = async ( fetchFn: (url: string, init: RequestInit) => Promise, url: string, @@ -37,13 +51,16 @@ export const makeRequest = async ( withCredentials?: boolean, duplex?: "half", disableCache?: boolean, + keepTimeoutUntilBodyRead?: boolean, ): Promise => { const signals: AbortSignal[] = []; let timeoutAbortId: ReturnType | undefined; + let timeoutSignal: AbortSignal | undefined; if (timeoutMs != null) { const { signal, abortId } = getTimeoutSignal(timeoutMs); timeoutAbortId = abortId; + timeoutSignal = signal; signals.push(signal); } @@ -51,19 +68,35 @@ export const makeRequest = async ( signals.push(abortSignal); } const newSignals = anySignal(signals); - const response = await fetchFn(url, { - method: method, - headers, - body: requestBody, - signal: newSignals, - credentials: withCredentials ? "include" : undefined, - // @ts-ignore - duplex, - ...(disableCache && isCacheNoStoreSupported() ? { cache: "no-store" as RequestCache } : {}), - }); + let response: Response; + try { + response = await fetchFn(url, { + method: method, + headers, + body: requestBody, + signal: newSignals, + credentials: withCredentials ? "include" : undefined, + // @ts-ignore + duplex, + ...(disableCache && isCacheNoStoreSupported() ? { cache: "no-store" as RequestCache } : {}), + }); + } catch (error) { + if (timeoutAbortId != null) { + clearTimeout(timeoutAbortId); + } + // Some runtimes (e.g. Node 18) reject with their own error instead of the abort reason. + if (timeoutSignal?.aborted && !abortSignal?.aborted) { + throw TIMEOUT; + } + throw error; + } if (timeoutAbortId != null) { - clearTimeout(timeoutAbortId); + if (keepTimeoutUntilBodyRead) { + responseTimeouts.set(response, timeoutAbortId); + } else { + clearTimeout(timeoutAbortId); + } } return response; diff --git a/src/management/core/fetcher/redactUrl.ts b/src/management/core/fetcher/redactUrl.ts new file mode 100644 index 0000000000..3c2e897a61 --- /dev/null +++ b/src/management/core/fetcher/redactUrl.ts @@ -0,0 +1,102 @@ +export const SENSITIVE_QUERY_PARAMS: Set = new Set([ + "api_key", + "api-key", + "apikey", + "token", + "access_token", + "access-token", + "auth_token", + "auth-token", + "password", + "passwd", + "secret", + "api_secret", + "api-secret", + "apisecret", + "key", + "session", + "session_id", + "session-id", +]); + +export function redactUrl(url: string): string { + const protocolIndex = url.indexOf("://"); + if (protocolIndex === -1) return url; + + const afterProtocol = protocolIndex + 3; + + // Find the first delimiter that marks the end of the authority section + const pathStart = url.indexOf("/", afterProtocol); + let queryStart = url.indexOf("?", afterProtocol); + let fragmentStart = url.indexOf("#", afterProtocol); + + const firstDelimiter = Math.min( + pathStart === -1 ? url.length : pathStart, + queryStart === -1 ? url.length : queryStart, + fragmentStart === -1 ? url.length : fragmentStart, + ); + + // Find the LAST @ before the delimiter (handles multiple @ in credentials) + let atIndex = -1; + for (let i = afterProtocol; i < firstDelimiter; i++) { + if (url[i] === "@") { + atIndex = i; + } + } + + if (atIndex !== -1) { + url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`; + } + + // Recalculate queryStart since url might have changed + queryStart = url.indexOf("?"); + if (queryStart === -1) return url; + + fragmentStart = url.indexOf("#", queryStart); + const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length; + const queryString = url.slice(queryStart + 1, queryEnd); + + if (queryString.length === 0) return url; + + // FAST PATH: Quick check if any sensitive keywords present + // Using indexOf is faster than regex for simple substring matching + const lower = queryString.toLowerCase(); + const hasSensitive = + lower.includes("token") || + lower.includes("key") || + lower.includes("password") || + lower.includes("passwd") || + lower.includes("secret") || + lower.includes("session") || + lower.includes("auth"); + + if (!hasSensitive) { + return url; + } + + // SLOW PATH: Parse and redact + const redactedParams: string[] = []; + const params = queryString.split("&"); + + for (const param of params) { + const equalIndex = param.indexOf("="); + if (equalIndex === -1) { + redactedParams.push(param); + continue; + } + + const key = param.slice(0, equalIndex); + let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()); + + if (!shouldRedact && key.includes("%")) { + try { + const decodedKey = decodeURIComponent(key); + shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase()); + } catch {} + } + + redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param); + } + + return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd); +} diff --git a/src/management/core/fetcher/requestWithRetries.ts b/src/management/core/fetcher/requestWithRetries.ts index 5e66b9330e..eb7c273e28 100644 --- a/src/management/core/fetcher/requestWithRetries.ts +++ b/src/management/core/fetcher/requestWithRetries.ts @@ -48,9 +48,32 @@ function getRetryDelayFromHeaders(response: Response, retryAttempt: number): num return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * 2 ** retryAttempt, MAX_RETRY_DELAY)); } +/** + * Waits `ms` milliseconds, or rejects as soon as `abortSignal` aborts. The timer and + * the abort listener are always removed, so a cancelled wait never keeps the process alive. + */ +function sleep(ms: number, abortSignal: AbortSignal | undefined): Promise { + return new Promise((resolve, reject) => { + if (abortSignal?.aborted) { + reject(abortSignal.reason); + return; + } + const onAbort = () => { + clearTimeout(timeoutId); + reject(abortSignal?.reason); + }; + const timeoutId = setTimeout(() => { + abortSignal?.removeEventListener("abort", onAbort); + resolve(); + }, ms); + abortSignal?.addEventListener("abort", onAbort, { once: true }); + }); +} + export async function requestWithRetries( requestFn: () => Promise, maxRetries: number = DEFAULT_MAX_RETRIES, + abortSignal?: AbortSignal, ): Promise { let response: Response = await requestFn(); @@ -58,7 +81,7 @@ export async function requestWithRetries( if (isRetryableStatusCode(response.status)) { const delay = getRetryDelayFromHeaders(response, i); - await new Promise((resolve) => setTimeout(resolve, delay)); + await sleep(delay, abortSignal); response = await requestFn(); } else { break; diff --git a/src/management/core/fetcher/signals.ts b/src/management/core/fetcher/signals.ts index ba74c4d02b..925527b695 100644 --- a/src/management/core/fetcher/signals.ts +++ b/src/management/core/fetcher/signals.ts @@ -1,4 +1,4 @@ -const TIMEOUT = "timeout"; +export const TIMEOUT = "timeout"; export function getTimeoutSignal(timeoutMs: number): { signal: AbortSignal; abortId: ReturnType } { const controller = new AbortController(); diff --git a/src/management/core/file/file.ts b/src/management/core/file/file.ts index 0bacc48410..e2b7b2d57d 100644 --- a/src/management/core/file/file.ts +++ b/src/management/core/file/file.ts @@ -37,6 +37,11 @@ async function getFileWithMetadata( file: Uploadable, { noSniffFileSize }: { noSniffFileSize?: boolean } = {}, ): Promise { + if (file == null) { + throw new Error( + `Expected file to be a Blob, Buffer, ReadableStream, or an object with a "path" or "data" property, but received ${file === null ? "null" : "undefined"}.`, + ); + } if (isFileLike(file)) { return getFileWithMetadata( { diff --git a/src/management/core/form-data-utils/FormDataWrapper.ts b/src/management/core/form-data-utils/FormDataWrapper.ts index c4ae3f480d..6f26023014 100644 --- a/src/management/core/form-data-utils/FormDataWrapper.ts +++ b/src/management/core/form-data-utils/FormDataWrapper.ts @@ -24,6 +24,11 @@ export class FormDataWrapper { } public async appendFile(key: string, value: Uploadable): Promise { + if (value == null) { + throw new Error( + `File upload for "${key}" received ${value === null ? "null" : "undefined"}. The generated code should not call appendFile with null/undefined — check that optional file fields are guarded before this call.`, + ); + } const { data, filename, contentType } = await toMultipartDataPart(value); const blob = await convertToBlob(data, contentType); if (filename) { diff --git a/src/management/core/requestBody.ts b/src/management/core/requestBody.ts new file mode 100644 index 0000000000..d58ef590cf --- /dev/null +++ b/src/management/core/requestBody.ts @@ -0,0 +1,26 @@ +/** + * Spreads caller-supplied `additionalBodyParameters` (from `requestOptions.additionalBodyParameters`) + * on top of the request body. Caller-supplied properties win over the endpoint body. When no + * additional body parameters are provided, the original body is returned unchanged so serialization + * is unaffected. + * + * The merge only applies to plain-object (JSON object) bodies. When the body is `null`/`undefined` + * the additional parameters become the body; when the body is an array or a primitive JSON value it + * is returned unchanged, since object properties cannot be spread into it. This mirrors the Python + * SDK, which only merges additional body parameters into mapping bodies. + */ +export function mergeAdditionalBodyParameters( + body: unknown, + additionalBodyParameters: Record | undefined, +): unknown { + if (additionalBodyParameters == null) { + return body; + } + if (body == null) { + return { ...additionalBodyParameters }; + } + if (typeof body === "object" && !Array.isArray(body)) { + return { ...body, ...additionalBodyParameters }; + } + return body; +} diff --git a/src/management/core/runtime/index.ts b/src/management/core/runtime/index.ts index cfab23f9a8..8dd66f3fbe 100644 --- a/src/management/core/runtime/index.ts +++ b/src/management/core/runtime/index.ts @@ -1 +1 @@ -export { RUNTIME } from "./runtime.js"; +export { RUNTIME, getUserAgent } from "./runtime.js"; diff --git a/src/management/core/runtime/runtime.ts b/src/management/core/runtime/runtime.ts index e6e66b2a7b..d367ce6b90 100644 --- a/src/management/core/runtime/runtime.ts +++ b/src/management/core/runtime/runtime.ts @@ -2,6 +2,10 @@ interface DenoGlobal { version: { deno: string; }; + build?: { + os?: string; + arch?: string; + }; } interface BunGlobal { @@ -24,6 +28,18 @@ export interface Runtime { type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd" | "edge-runtime"; version?: string; parsedVersion?: number; + /** + * The operating system the SDK is running on, when it can be determined + * (e.g. "linux", "darwin", "win32" on server runtimes). Undefined in + * environments where the OS is not observable (e.g. browsers). + */ + os?: string; + /** + * The CPU architecture the SDK is running on, when it can be determined + * (e.g. "x64", "arm64" on server runtimes). Undefined in environments where + * the architecture is not observable (e.g. browsers). + */ + arch?: string; } function evaluateRuntime(): Runtime { @@ -85,6 +101,8 @@ function evaluateRuntime(): Runtime { return { type: "deno", version: Deno.version.deno, + os: Deno.build?.os, + arch: Deno.build?.arch, }; } @@ -96,6 +114,8 @@ function evaluateRuntime(): Runtime { return { type: "bun", version: Bun.version, + os: typeof process !== "undefined" ? process.platform : undefined, + arch: typeof process !== "undefined" ? process.arch : undefined, }; } @@ -125,6 +145,8 @@ function evaluateRuntime(): Runtime { type: "node", version: _process.versions.node, parsedVersion: Number(_process.versions.node.split(".")[0]), + os: _process.platform, + arch: _process.arch, }; } @@ -132,3 +154,78 @@ function evaluateRuntime(): Runtime { type: "unknown", }; } + +/** + * Display names for the language runtimes whose version is meaningful to encode + * in a User-Agent. Environments where a version string is not useful (e.g. + * browsers, where `version` is the full navigator UA) are intentionally mapped + * to `undefined` so they are omitted from the User-Agent. + */ +const RUNTIME_DISPLAY_NAMES: Record = { + node: "Node", + deno: "Deno", + bun: "Bun", + browser: undefined, + "web-worker": undefined, + "react-native": undefined, + workerd: undefined, + "edge-runtime": undefined, + unknown: undefined, +}; + +/** + * CPU architecture aliases that all refer to 64-bit x86. They are normalized to + * the single canonical token `x86_64` so the User-Agent architecture label is + * consistent regardless of which runtime reports it (Node reports `x64`, others + * report `amd64` or `x86_64`). + */ +const X86_64_ARCH_ALIASES = new Set(["x64", "amd64", "x86_64"]); + +/** + * Normalizes a CPU architecture token, collapsing the 64-bit x86 aliases + * (`x64`, `amd64`, `x86_64`) to `x86_64`. Other architectures are returned + * unchanged. + */ +function normalizeArch(arch: string | undefined): string | undefined { + if (arch == null) { + return arch; + } + return X86_64_ARCH_ALIASES.has(arch.toLowerCase()) ? "x86_64" : arch; +} + +/** + * Percent-encodes the `@` and `/` characters in an npm package name so the + * User-Agent product token stays within the RFC 7230 token grammar. The + * original scoped package name can be recovered by URL-decoding (e.g. + * `@dummy/sdk` becomes `%40dummy%2Fsdk`). + */ +function encodeProductName(sdkName: string): string { + return sdkName.replace(/@/g, "%40").replace(/\//g, "%2F"); +} + +/** + * Builds a structured User-Agent string of the form + * `{sdkName}/{sdkVersion} ({os}; {arch}) {runtime}/{runtimeVersion}` + * where the platform group and runtime segment are omitted gracefully when the + * underlying values cannot be determined (e.g. in a browser). + */ +export function getUserAgent(sdkName: string, sdkVersion: string): string { + let userAgent = `${encodeProductName(sdkName)}/${sdkVersion}`; + + const platform = [RUNTIME.os, normalizeArch(RUNTIME.arch)].filter( + (part): part is string => part != null && part.length > 0, + ); + if (platform.length > 0) { + userAgent += ` (${platform.join("; ")})`; + } + + const runtimeName = RUNTIME_DISPLAY_NAMES[RUNTIME.type]; + if (runtimeName != null) { + userAgent += ` ${runtimeName}`; + if (RUNTIME.version != null && RUNTIME.version.length > 0) { + userAgent += `/${RUNTIME.version}`; + } + } + + return userAgent; +} diff --git a/src/management/core/stream/Stream.ts b/src/management/core/stream/Stream.ts index 8ccdecf989..89d0594d5a 100644 --- a/src/management/core/stream/Stream.ts +++ b/src/management/core/stream/Stream.ts @@ -17,6 +17,24 @@ export declare namespace Stream { * An abort signal to stop the stream. */ signal?: AbortSignal; + /** + * Whether transparent mid-stream reconnection is enabled on resumable + * SSE endpoints. Defaults to true. Has no effect on non-resumable endpoints. + */ + reconnectionEnabled?: boolean; + /** + * Maximum number of consecutive failed reconnect attempts on resumable SSE + * endpoints before giving up. The counter resets to zero each time a + * reconnected stream successfully yields at least one event (i.e. makes + * progress). Has no effect on non-resumable endpoints. + */ + maxReconnectionAttempts?: number; + /** + * A function that re-issues the HTTP request with the Last-Event-ID header + * and returns the new response body stream. Required for reconnection to work. + */ + + reconnect?: (lastEventId: string) => Promise; } interface JsonEvent { @@ -28,11 +46,27 @@ export declare namespace Stream { type: "sse"; streamTerminator?: string; eventDiscriminator?: string; + /** Event names whose union variant wraps the `data:` payload as `{ , data }`. */ + envelopeEvents?: string[]; + resumable?: boolean; } } +export interface ServerSentEvent { + data: T; + id?: string; + retry?: number; + event?: string; +} + const DATA_PREFIX = "data:"; const EVENT_PREFIX = "event:"; +const ID_PREFIX = "id:"; +const RETRY_PREFIX = "retry:"; + +const DEFAULT_MAX_RECONNECTION_ATTEMPTS = 5; +const DEFAULT_RECONNECT_DELAY_MS = 1_000; +const MAX_RECONNECT_DELAY_MS = 30_000; export class Stream implements AsyncIterable { private stream: ReadableStream; @@ -46,10 +80,27 @@ export class Stream implements AsyncIterable { private messageTerminator: string; private streamTerminator: string | undefined; private eventDiscriminator: string | undefined; + private envelopeEvents: Set | undefined; + private resumable: boolean; + private reconnectionEnabled: boolean; + private maxReconnectionAttempts: number; + + private reconnect: ((lastEventId: string) => Promise) | undefined; + private controller: AbortController = new AbortController(); private decoder: TextDecoder | undefined; + private externalSignal: AbortSignal | undefined; + private onExternalAbort: (() => void) | undefined; - constructor({ stream, parse, eventShape, signal }: Stream.Args & { parse: (val: unknown) => Promise }) { + constructor({ + stream, + parse, + eventShape, + signal, + reconnectionEnabled, + maxReconnectionAttempts, + reconnect, + }: Stream.Args & { parse: (val: unknown) => Promise }) { this.stream = stream; this.parse = parse; if (eventShape.type === "sse") { @@ -57,10 +108,20 @@ export class Stream implements AsyncIterable { this.messageTerminator = "\n"; this.streamTerminator = eventShape.streamTerminator; this.eventDiscriminator = eventShape.eventDiscriminator; + this.envelopeEvents = eventShape.envelopeEvents != null ? new Set(eventShape.envelopeEvents) : undefined; + this.resumable = eventShape.resumable ?? false; } else { this.messageTerminator = eventShape.messageTerminator; + this.resumable = false; + } + this.reconnectionEnabled = reconnectionEnabled ?? true; + this.maxReconnectionAttempts = maxReconnectionAttempts ?? DEFAULT_MAX_RECONNECTION_ATTEMPTS; + this.reconnect = reconnect; + if (signal != null) { + this.externalSignal = signal; + this.onExternalAbort = () => this.controller.abort(); + signal.addEventListener("abort", this.onExternalAbort, { once: true }); } - signal?.addEventListener("abort", () => this.controller.abort()); // Initialize shared TextDecoder if (typeof TextDecoder !== "undefined") { @@ -68,7 +129,7 @@ export class Stream implements AsyncIterable { } } - private async *iterMessages(): AsyncGenerator { + private async *iterMessages(): AsyncGenerator, void> { if (this.eventDiscriminator != null) { yield* this.iterSseEvents(); } else { @@ -76,81 +137,215 @@ export class Stream implements AsyncIterable { } } - private async *iterDataMessages(): AsyncGenerator { - const stream = readableStreamAsyncIterable(this.stream); - let buf = ""; - let prefixSeen = false; - for await (const chunk of stream) { - buf += this.decodeChunk(chunk); + private async *iterDataMessages(): AsyncGenerator, void> { + let reconnectAttempts = 0; + let currentStream = this.stream; + let lastId: string | undefined; + // The id of the most recently *dispatched* event. Per the WHATWG + // EventSource spec, the "last event ID" is only committed when an event + // is dispatched, not when the `id:` line is parsed. Reconnecting with a + // parsed-but-undispatched id would skip an event that was never yielded + // (e.g. if the connection drops after `id:` but before the event's + // terminating blank line), so reconnection uses lastDispatchedId. + let lastDispatchedId: string | undefined; + let lastRetry: number | undefined; - let terminatorIndex: number; - while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) { - let line = buf.slice(0, terminatorIndex); - buf = buf.slice(terminatorIndex + this.messageTerminator.length); + while (true) { + const stream = readableStreamAsyncIterable(currentStream); + let buf = ""; + let dataValue: string | undefined; - if (!line.trim()) { - continue; - } + for await (const chunk of stream) { + buf += this.decodeChunk(chunk); + + let terminatorIndex: number; + while ((terminatorIndex = buf.indexOf(this.messageTerminator)) >= 0) { + const line = buf.slice(0, terminatorIndex); + buf = buf.slice(terminatorIndex + this.messageTerminator.length); - if (!prefixSeen && this.prefix != null) { - const prefixIndex = line.indexOf(this.prefix); - if (prefixIndex === -1) { + if (!line.trim()) { + if (this.prefix != null && dataValue != null) { + if (this.streamTerminator != null && dataValue.includes(this.streamTerminator)) { + return; + } + const data = await this.parse(fromJson(dataValue)); + yield { data, id: lastId, retry: lastRetry, event: undefined }; + lastDispatchedId = lastId; + reconnectAttempts = 0; + dataValue = undefined; + } + continue; + } + + if (line.startsWith(ID_PREFIX)) { + const idValue = line.slice(ID_PREFIX.length).trim(); + if (!idValue.includes("\0")) { + lastId = idValue; + } continue; } - prefixSeen = true; - line = line.slice(prefixIndex + this.prefix.length); + if (line.startsWith(RETRY_PREFIX)) { + const retryValue = line.slice(RETRY_PREFIX.length).trim(); + const parsed = parseInt(retryValue, 10); + if (!Number.isNaN(parsed) && String(parsed) === retryValue) { + lastRetry = parsed; + } + continue; + } + + if (this.prefix != null) { + const prefixIndex = line.indexOf(this.prefix); + if (prefixIndex === -1) { + continue; + } + const val = line.slice(prefixIndex + this.prefix.length).trim(); + dataValue = dataValue != null ? `${dataValue}\n${val}` : val; + } else { + if (this.streamTerminator != null && line.includes(this.streamTerminator)) { + return; + } + const data = await this.parse(fromJson(line)); + yield { data, id: lastId, retry: lastRetry, event: undefined }; + lastDispatchedId = lastId; + reconnectAttempts = 0; + } } + } - if (this.streamTerminator != null && line.includes(this.streamTerminator)) { + if (this.prefix != null && dataValue != null) { + if (this.streamTerminator != null && dataValue.includes(this.streamTerminator)) { return; } - const message = await this.parse(fromJson(line)); - yield message; - prefixSeen = false; + const data = await this.parse(fromJson(dataValue)); + yield { data, id: lastId, retry: lastRetry, event: undefined }; + lastDispatchedId = lastId; + reconnectAttempts = 0; + } + + if (!this.shouldReconnect(lastDispatchedId, reconnectAttempts)) { + return; + } + + reconnectAttempts++; + await this.delayReconnect(lastRetry); + if (this.controller.signal.aborted) { + return; + } + // Re-check after async delay; needed for TypeScript narrowing. + const reconnectFn = this.reconnect; + if (reconnectFn == null || lastDispatchedId == null) { + return; + } + try { + const reconnected = await reconnectFn(lastDispatchedId); + if (reconnected == null) { + currentStream = this.createEmptyStream(); + continue; + } + currentStream = reconnected; + } catch { + // Failed reconnect (e.g. HTTP error); assign an empty stream + // so the next iteration is a safe no-op before shouldReconnect. + currentStream = this.createEmptyStream(); + continue; } } } - private async *iterSseEvents(): AsyncGenerator { - const stream = readableStreamAsyncIterable(this.stream); - let buf = ""; - let eventType: string | undefined; - let dataValue: string | undefined; + private async *iterSseEvents(): AsyncGenerator, void> { + let reconnectAttempts = 0; + let currentStream = this.stream; + let lastId: string | undefined; + // See iterDataMessages: reconnection uses the last *dispatched* id (per + // the EventSource spec), not the last *parsed* id, to avoid skipping an + // event that was never yielded when a drop lands mid-event. + let lastDispatchedId: string | undefined; + let lastRetry: number | undefined; - for await (const chunk of stream) { - buf += this.decodeChunk(chunk); + while (true) { + const stream = readableStreamAsyncIterable(currentStream); + let buf = ""; + let eventType: string | undefined; + let dataValue: string | undefined; - let terminatorIndex: number; - while ((terminatorIndex = buf.indexOf("\n")) >= 0) { - const line = buf.slice(0, terminatorIndex).replace(/\r$/, ""); - buf = buf.slice(terminatorIndex + 1); + for await (const chunk of stream) { + buf += this.decodeChunk(chunk); - if (!line.trim()) { - if (dataValue != null) { - const message = await this.dispatchSseEvent(dataValue, eventType); - if (message == null) { - return; + let terminatorIndex: number; + while ((terminatorIndex = buf.indexOf("\n")) >= 0) { + const line = buf.slice(0, terminatorIndex).replace(/\r$/, ""); + buf = buf.slice(terminatorIndex + 1); + + if (!line.trim()) { + if (dataValue != null) { + const data = await this.dispatchSseEvent(dataValue, eventType); + if (data == null) { + return; + } + yield { data, id: lastId, retry: lastRetry, event: eventType }; + lastDispatchedId = lastId; + reconnectAttempts = 0; + } + eventType = undefined; + dataValue = undefined; + continue; + } + + if (line.startsWith(EVENT_PREFIX)) { + eventType = line.slice(EVENT_PREFIX.length).trim(); + } else if (line.startsWith(DATA_PREFIX)) { + const val = line.slice(DATA_PREFIX.length).trim(); + dataValue = dataValue != null ? `${dataValue}\n${val}` : val; + } else if (line.startsWith(ID_PREFIX)) { + const idValue = line.slice(ID_PREFIX.length).trim(); + if (!idValue.includes("\0")) { + lastId = idValue; + } + } else if (line.startsWith(RETRY_PREFIX)) { + const retryValue = line.slice(RETRY_PREFIX.length).trim(); + const parsed = parseInt(retryValue, 10); + if (!Number.isNaN(parsed) && String(parsed) === retryValue) { + lastRetry = parsed; } - yield message; } - eventType = undefined; - dataValue = undefined; - continue; } + } - if (line.startsWith(EVENT_PREFIX)) { - eventType = line.slice(EVENT_PREFIX.length).trim(); - } else if (line.startsWith(DATA_PREFIX)) { - const val = line.slice(DATA_PREFIX.length).trim(); - dataValue = dataValue != null ? `${dataValue}\n${val}` : val; + if (dataValue != null) { + const data = await this.dispatchSseEvent(dataValue, eventType); + if (data != null) { + yield { data, id: lastId, retry: lastRetry, event: eventType }; + lastDispatchedId = lastId; + reconnectAttempts = 0; } } - } - if (dataValue != null) { - const message = await this.dispatchSseEvent(dataValue, eventType); - if (message != null) { - yield message; + if (!this.shouldReconnect(lastDispatchedId, reconnectAttempts)) { + return; + } + + reconnectAttempts++; + await this.delayReconnect(lastRetry); + if (this.controller.signal.aborted) { + return; + } + // Re-check after async delay; needed for TypeScript narrowing. + const reconnectFn = this.reconnect; + if (reconnectFn == null || lastDispatchedId == null) { + return; + } + try { + const reconnected = await reconnectFn(lastDispatchedId); + if (reconnected == null) { + currentStream = this.createEmptyStream(); + continue; + } + currentStream = reconnected; + } catch { + // Failed reconnect (e.g. HTTP error); assign an empty stream + // so the next iteration is a safe no-op before shouldReconnect. + currentStream = this.createEmptyStream(); + continue; } } } @@ -165,10 +360,103 @@ export class Stream implements AsyncIterable { return this.parse(this.injectDiscriminator(fromJson(dataValue), eventType)); } + /** + * Determines whether a reconnection attempt should be made. + */ + private shouldReconnect(lastId: string | undefined, reconnectAttempts: number): boolean { + if (!this.resumable) { + return false; + } + if (this.streamTerminator == null) { + // Without a terminator the client cannot distinguish a completed + // stream from a dropped connection, so reconnection is disabled. + return false; + } + // NOTE: When a terminator IS configured but the server never sends it + // (e.g. it drops the connection after emitting events every time), + // maxReconnectionAttempts is a per-consecutive-failure cap — each + // yielded event resets the counter. This matches EventSource semantics + // but means such a server can cause unbounded reconnections. Callers + // concerned about this should impose a wall-clock budget externally. + if (!this.reconnectionEnabled) { + return false; + } + if (this.reconnect == null) { + return false; + } + if (lastId == null || lastId === "") { + return false; + } + if (reconnectAttempts >= this.maxReconnectionAttempts) { + return false; + } + if (this.controller.signal.aborted) { + return false; + } + return true; + } + + /** + * Delays before reconnecting, using a server-sent retry directive if provided + * (clamped to MAX_RECONNECT_DELAY_MS), otherwise falling back to + * DEFAULT_RECONNECT_DELAY_MS. The delay is abortable: if the stream's abort + * signal fires during the wait, the promise resolves immediately. + */ + private async delayReconnect(lastRetry: number | undefined): Promise { + const base = lastRetry != null && lastRetry > 0 ? lastRetry : DEFAULT_RECONNECT_DELAY_MS; + const delay = Math.min(base, MAX_RECONNECT_DELAY_MS); + const signal = this.controller.signal; + if (signal.aborted) { + return; + } + await new Promise((resolve) => { + const timer = setTimeout(() => { + signal.removeEventListener("abort", onAbort); + resolve(); + }, delay); + const onAbort = (): void => { + clearTimeout(timer); + resolve(); + }; + signal.addEventListener("abort", onAbort, { once: true }); + }); + } + + private createEmptyStream(): ReadableStream { + return new ReadableStream({ + start(controller) { + controller.close(); + }, + }); + } + + private removeAbortListener(): void { + if (this.externalSignal != null && this.onExternalAbort != null) { + this.externalSignal.removeEventListener("abort", this.onExternalAbort); + this.onExternalAbort = undefined; + } + } + + public withMetadata(): AsyncIterable> { + const self = this; + return { + async *[Symbol.asyncIterator]() { + try { + yield* self.iterMessages(); + } finally { + self.removeAbortListener(); + } + }, + }; + } + private injectDiscriminator(parsed: unknown, eventType: string | undefined): unknown { if (this.eventDiscriminator == null || eventType == null) { return parsed; } + if (this.envelopeEvents?.has(eventType)) { + return { [this.eventDiscriminator]: eventType, data: parsed }; + } if (parsed == null || typeof parsed !== "object" || Array.isArray(parsed)) { return parsed; } @@ -180,8 +468,12 @@ export class Stream implements AsyncIterable { } async *[Symbol.asyncIterator](): AsyncIterator { - for await (const message of this.iterMessages()) { - yield message; + try { + for await (const event of this.iterMessages()) { + yield event.data; + } + } finally { + this.removeAbortListener(); } } diff --git a/src/management/core/stream/index.ts b/src/management/core/stream/index.ts index 4e28b34b43..5a14b638d6 100644 --- a/src/management/core/stream/index.ts +++ b/src/management/core/stream/index.ts @@ -1 +1,2 @@ export { Stream } from "./Stream.js"; +export type { ServerSentEvent } from "./Stream.js"; diff --git a/src/management/core/url/encodePathParam.ts b/src/management/core/url/encodePathParam.ts index 19b9012442..052f1dfc81 100644 --- a/src/management/core/url/encodePathParam.ts +++ b/src/management/core/url/encodePathParam.ts @@ -1,4 +1,7 @@ -export function encodePathParam(param: unknown): string { +export function encodePathParam( + param: unknown, + InvalidPathParameterError?: new (args: { message: string }) => Error, +): string { if (param === null) { return "null"; } @@ -14,5 +17,11 @@ export function encodePathParam(param: unknown): string { param = String(param); break; } - return encodeURIComponent(param as string | number | boolean); + const encoded = encodeURIComponent(param as string | number | boolean); + // "." and ".." are dot segments: URL resolution would remove them and send the request to a different path. + if (encoded === "." || encoded === "..") { + const message = `Invalid path parameter "${encoded}": "." and ".." are not allowed because they change the request path.`; + throw InvalidPathParameterError != null ? new InvalidPathParameterError({ message }) : new Error(message); + } + return encoded; } diff --git a/src/management/core/url/qs.ts b/src/management/core/url/qs.ts index f8b455652a..aebb95a38b 100644 --- a/src/management/core/url/qs.ts +++ b/src/management/core/url/qs.ts @@ -27,7 +27,7 @@ function stringifyObject(obj: Record, prefix = "", options: Req for (const [key, value] of Object.entries(obj)) { const fullKey = prefix ? `${prefix}[${key}]` : key; - if (value === undefined) { + if (value == null) { continue; } @@ -47,7 +47,7 @@ function stringifyObject(obj: Record, prefix = "", options: Req } else { for (let i = 0; i < value.length; i++) { const item = value[i]; - if (item === undefined) { + if (item == null) { continue; } if (typeof item === "object" && !Array.isArray(item) && item !== null) { diff --git a/src/management/core/utils/setObjectProperty.ts b/src/management/core/utils/setObjectProperty.ts index 5528af2486..9daac39e84 100644 --- a/src/management/core/utils/setObjectProperty.ts +++ b/src/management/core/utils/setObjectProperty.ts @@ -1,12 +1,13 @@ /** - * Sets the value at path of object. If a portion of path doesn’t exist it’s created. This is - * inspired by Lodash's set function, but is simplified to accommodate our use case. - * For more details, see https://lodash.com/docs/4.17.15#set. + * Returns a copy of object with the value at path set. If a portion of path doesn’t exist it’s created. + * Each object along path is shallow-copied, so the original object (and any nested objects it + * shares with the copy) is never modified. This is inspired by Lodash's set function, but is + * simplified to accommodate our use case. For more details, see https://lodash.com/docs/4.17.15#set. * - * @param object The object to modify. + * @param object The object to copy. * @param path The path of the property to set. * @param value The value to set. - * @return Returns object. + * @return Returns the updated copy of object. */ export function setObjectProperty(object: T, path: string, value: any): T { if (object == null) { @@ -19,15 +20,19 @@ export function setObjectProperty(object: T, path: string, val return object; } - let current: Record = object; + const result: Record = { ...object }; + let current: Record = result; for (let i = 0; i < keys.length - 1; i++) { const key = keys[i]; if (key == null) { // Unreachable. continue; } - if (!current[key] || typeof current[key] !== "object") { - current[key] = {}; + const next = current[key]; + if (Array.isArray(next)) { + current[key] = [...next]; + } else { + current[key] = next != null && typeof next === "object" ? { ...next } : {}; } current = current[key] as Record; } @@ -35,9 +40,9 @@ export function setObjectProperty(object: T, path: string, val const lastKey = keys[keys.length - 1]; if (lastKey == null) { // Unreachable. - return object; + return result as T; } current[lastKey] = value; - return object; + return result as T; } diff --git a/src/management/errors/ManagementError.ts b/src/management/errors/ManagementError.ts index b2ff163d8a..fd0210ccf8 100644 --- a/src/management/errors/ManagementError.ts +++ b/src/management/errors/ManagementError.ts @@ -36,6 +36,24 @@ export class ManagementError extends Error { this.cause = cause; } } + + public get requestId(): string | undefined { + const headers = this.rawResponse?.headers; + if (headers == null) { + return undefined; + } + const requestId = headers.get("X-Request-Id"); + if (requestId != null) { + return requestId; + } + let fallback: string | undefined; + headers.forEach((value, name) => { + if (fallback === undefined && /request[-_]?id$/i.test(name)) { + fallback = value; + } + }); + return fallback; + } } function buildMessage({ diff --git a/src/management/errors/ManagementTimeoutError.ts b/src/management/errors/ManagementTimeoutError.ts index 3f24fc1489..51b6fa29e7 100644 --- a/src/management/errors/ManagementTimeoutError.ts +++ b/src/management/errors/ManagementTimeoutError.ts @@ -1,18 +1,18 @@ // This file was auto-generated by Fern from our API Definition. -export class ManagementTimeoutError extends Error { - public readonly cause?: unknown; +import * as errors from "./index.js"; +export class ManagementTimeoutError extends errors.ManagementError { constructor(message: string, opts?: { cause?: unknown }) { - super(message); + super({ + message: message, + cause: opts?.cause, + }); Object.setPrototypeOf(this, new.target.prototype); if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } this.name = "ManagementTimeoutError"; - if (opts?.cause != null) { - this.cause = opts.cause; - } } } diff --git a/src/management/tests/mock-server/withJson.ts b/src/management/tests/mock-server/withJson.ts index 9047b87e94..3c42a30914 100644 --- a/src/management/tests/mock-server/withJson.ts +++ b/src/management/tests/mock-server/withJson.ts @@ -42,7 +42,9 @@ export function withJson( } const mismatches = findMismatches(actualBody, expectedBody); - const filteredMismatches = Object.keys(mismatches).filter((key) => !ignoredFields.includes(key)); + const filteredMismatches = Object.entries(mismatches).filter( + ([key, mismatch]) => !isIgnoredMismatch(key, mismatch, ignoredFields), + ); if (filteredMismatches.length > 0) { console.error("JSON body mismatch:", toJson(mismatches, undefined, 2)); return passthrough(); @@ -52,6 +54,47 @@ export function withJson( }; } +/** + * A mismatch is ignored when its path is listed in ignoredFields, or when it is an object + * that is absent from the expected body and every leaf inside it is listed in ignoredFields. + * The latter happens when an ignored field is nested (e.g. "options.offset") and the client + * creates the parent object to hold the next page value. + */ +function isIgnoredMismatch( + key: string, + mismatch: { actual: unknown; expected: unknown }, + ignoredFields: string[], +): boolean { + if (ignoredFields.includes(key)) { + return true; + } + if (mismatch.expected !== undefined || !isPlainObject(mismatch.actual)) { + return false; + } + const leafPaths = collectLeafPaths(mismatch.actual, key); + return leafPaths.length > 0 && leafPaths.every((path) => ignoredFields.includes(path)); +} + +function isPlainObject(value: unknown): value is Record { + return typeof value === "object" && value !== null && !Array.isArray(value); +} + +function collectLeafPaths(value: Record, prefix: string): string[] { + const paths: string[] = []; + for (const [key, child] of Object.entries(value)) { + if (child === undefined) { + continue; + } + const path = `${prefix}.${key}`; + if (isPlainObject(child)) { + paths.push(...collectLeafPaths(child, path)); + } else { + paths.push(path); + } + } + return paths; +} + function findMismatches(actual: any, expected: any): Record { const mismatches: Record = {}; diff --git a/src/management/tests/unit/fetcher/Fetcher.test.ts b/src/management/tests/unit/fetcher/Fetcher.test.ts index b3a901657c..3400f22547 100644 --- a/src/management/tests/unit/fetcher/Fetcher.test.ts +++ b/src/management/tests/unit/fetcher/Fetcher.test.ts @@ -259,4 +259,199 @@ describe("Test fetcherImpl", () => { expect(body.bodyUsed).toBe(true); } }); + + it("should return a non-json error instead of a body when a successful response has malformed JSON", async () => { + global.fetch = jest.fn().mockResolvedValue( + new Response('{"broken":', { + status: 200, + headers: { "Content-Type": "application/json", "X-Request-Id": "req-200" }, + }), + ); + + const result = await fetcherImpl({ url: "https://example.com/items", method: "GET", maxRetries: 0 }); + + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toEqual({ reason: "non-json", statusCode: 200, rawBody: '{"broken":' }); + expect(result.rawResponse.status).toBe(200); + expect(result.rawResponse.headers.get("X-Request-Id")).toBe("req-200"); + } + }); + + it("should still resolve when a successful response has a plain-text body", async () => { + global.fetch = jest + .fn() + .mockResolvedValue(new Response("OK", { status: 200, headers: { "Content-Type": "text/plain" } })); + + const result = await fetcherImpl({ url: "https://example.com/items", method: "DELETE", maxRetries: 0 }); + + expect(result.ok).toBe(true); + }); + + it("should keep the status and raw body when a JSON error response is malformed", async () => { + global.fetch = jest.fn().mockResolvedValue( + new Response("Bad Gateway", { + status: 502, + headers: { "Content-Type": "application/json", "X-Request-Id": "req-502" }, + }), + ); + + const result = await fetcherImpl({ url: "https://example.com/items", method: "GET", maxRetries: 0 }); + + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toEqual({ reason: "status-code", statusCode: 502, body: "Bad Gateway" }); + expect(result.rawResponse.headers.get("X-Request-Id")).toBe("req-502"); + } + }); + + it("should return the raw text for a malformed error body without a content type", async () => { + global.fetch = jest + .fn() + .mockResolvedValue(new Response(new TextEncoder().encode('{"broken":'), { status: 500 })); + + const result = await fetcherImpl({ url: "https://example.com/items", method: "GET", maxRetries: 0 }); + + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error).toEqual({ reason: "status-code", statusCode: 500, body: '{"broken":' }); + } + }); + + it("should still parse valid JSON error bodies and keep plain-text error bodies", async () => { + const fetchMock = jest.fn(); + fetchMock + .mockResolvedValueOnce( + new Response(JSON.stringify({ error_code: "INVALID" }), { + status: 400, + headers: { "Content-Type": "application/json" }, + }), + ) + .mockResolvedValueOnce(new Response("Service Unavailable", { status: 503 })); + global.fetch = fetchMock; + + const json = await fetcherImpl({ url: "https://example.com/items", method: "GET", maxRetries: 0 }); + const text = await fetcherImpl({ url: "https://example.com/items", method: "GET", maxRetries: 0 }); + + expect(json.ok || json.error).toEqual({ + reason: "status-code", + statusCode: 400, + body: { error_code: "INVALID" }, + }); + expect(text.ok || text.error).toEqual({ reason: "status-code", statusCode: 503, body: "Service Unavailable" }); + }); + + it("should time out while reading a slow JSON body", async () => { + global.fetch = jest.fn().mockImplementation(async (_url: string, init: RequestInit) => { + const body = new ReadableStream({ + start(controller) { + controller.enqueue(new TextEncoder().encode('{"data":')); + init.signal?.addEventListener("abort", () => controller.error(init.signal?.reason)); + }, + }); + return new Response(body, { status: 200, headers: { "Content-Type": "application/json" } }); + }); + + const result = await fetcherImpl({ + url: "https://example.com/slow", + method: "GET", + maxRetries: 0, + timeoutMs: 20, + }); + + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error.reason).toBe("timeout"); + } + }); + + it("should report a timeout when fetch rejects with the timeout reason", async () => { + global.fetch = jest.fn().mockImplementation( + (_url: string, init: RequestInit) => + new Promise((_resolve, reject) => { + init.signal?.addEventListener("abort", () => reject(init.signal?.reason)); + }), + ); + + const result = await fetcherImpl({ + url: "https://example.com/slow", + method: "GET", + maxRetries: 0, + timeoutMs: 20, + }); + + expect(result.ok).toBe(false); + if (!result.ok) { + expect(result.error.reason).toBe("timeout"); + } + }); + + it("should not leave timers running after a request succeeds or fails", async () => { + jest.useFakeTimers(); + try { + global.fetch = jest + .fn() + .mockResolvedValueOnce( + new Response(JSON.stringify({ data: "test" }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }), + ) + .mockRejectedValueOnce(new TypeError("fetch failed")); + + const success = await fetcherImpl({ + url: "https://example.com", + method: "GET", + maxRetries: 0, + timeoutMs: 1000, + }); + expect(success.ok).toBe(true); + expect(jest.getTimerCount()).toBe(0); + + const failure = await fetcherImpl({ + url: "https://example.com", + method: "GET", + maxRetries: 0, + timeoutMs: 1000, + }); + expect(failure.ok).toBe(false); + expect(jest.getTimerCount()).toBe(0); + } finally { + jest.useRealTimers(); + } + }); + + it("should clear the previous attempt's timeout before a retry is sent", async () => { + jest.useFakeTimers(); + try { + const timersSeenByAttempt: number[] = []; + let attempt = 0; + global.fetch = jest.fn().mockImplementation(async () => { + timersSeenByAttempt.push(jest.getTimerCount()); + attempt += 1; + return attempt === 1 + ? new Response("busy", { status: 503, headers: { "Retry-After": "1" } }) + : new Response(JSON.stringify({ data: "test" }), { + status: 200, + headers: { "Content-Type": "application/json" }, + }); + }); + + const promise = fetcherImpl({ + url: "https://example.com", + method: "GET", + maxRetries: 1, + timeoutMs: 60_000, + }); + await jest.advanceTimersByTimeAsync(2_000); + const result = await promise; + + expect(result.ok).toBe(true); + // The retry only sees its own timeout timer, not the first attempt's. + expect(timersSeenByAttempt).toEqual([1, 1]); + expect(jest.getTimerCount()).toBe(0); + } finally { + jest.useRealTimers(); + } + }); }); diff --git a/src/management/tests/unit/fetcher/createRequestUrl.test.ts b/src/management/tests/unit/fetcher/createRequestUrl.test.ts index f6c2b25367..4535811da3 100644 --- a/src/management/tests/unit/fetcher/createRequestUrl.test.ts +++ b/src/management/tests/unit/fetcher/createRequestUrl.test.ts @@ -77,7 +77,7 @@ describe("Test createRequestUrl", () => { undefinedValue: undefined, emptyString: "", }, - expected: "https://api.example.com?valid=value&nullValue=&emptyString=", + expected: "https://api.example.com?valid=value&emptyString=", }, { description: "should handle deeply nested objects", diff --git a/src/management/tests/unit/fetcher/getResponseBody.test.ts b/src/management/tests/unit/fetcher/getResponseBody.test.ts index 9bfc206e53..722c858997 100644 --- a/src/management/tests/unit/fetcher/getResponseBody.test.ts +++ b/src/management/tests/unit/fetcher/getResponseBody.test.ts @@ -1,4 +1,4 @@ -import { getResponseBody } from "../../../core/fetcher/getResponseBody"; +import { getResponseBody, isResponseBodyError } from "../../../core/fetcher/getResponseBody"; import { RUNTIME } from "../../../core/runtime"; @@ -120,4 +120,16 @@ describe("Test getResponseBody", () => { const descriptor = Object.getOwnPropertyDescriptor(result, "__fern_response_ref"); expect(descriptor?.enumerable).toBe(false); }); + + it("should mark malformed JSON as a response body error", async () => { + const result = await getResponseBody(new Response("invalid json")); + expect(isResponseBodyError(result)).toBe(true); + }); + + it("should not treat a JSON body shaped like a failure record as a response body error", async () => { + const lookalike = { ok: false, error: { reason: "non-json", statusCode: 200, rawBody: "x" } }; + const result = await getResponseBody(new Response(JSON.stringify(lookalike))); + expect(result).toEqual(lookalike); + expect(isResponseBodyError(result)).toBe(false); + }); }); diff --git a/src/management/tests/unit/fetcher/makePassthroughRequest.test.ts b/src/management/tests/unit/fetcher/makePassthroughRequest.test.ts index 48278ac2a5..e00d9561a0 100644 --- a/src/management/tests/unit/fetcher/makePassthroughRequest.test.ts +++ b/src/management/tests/unit/fetcher/makePassthroughRequest.test.ts @@ -88,6 +88,7 @@ describe("makePassthroughRequest", () => { headers: { "X-Custom": "from-init", Authorization: "from-init" }, }, { + baseUrl: "https://api.example.com", headers: { "X-Custom": "from-sdk", "X-SDK-Only": "sdk-value", @@ -167,6 +168,7 @@ describe("makePassthroughRequest", () => { describe("auth headers", () => { it("should include auth headers when getAuthHeaders is provided", async () => { await makePassthroughRequest("https://api.example.com", undefined, { + baseUrl: "https://api.example.com", getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), fetch: mockFetch, }); @@ -187,6 +189,7 @@ describe("makePassthroughRequest", () => { "https://api.example.com", { headers: { Authorization: "Bearer override" } }, { + baseUrl: "https://api.example.com", getAuthHeaders: async () => ({ Authorization: "Bearer sdk-auth" }), fetch: mockFetch, }, @@ -196,6 +199,82 @@ describe("makePassthroughRequest", () => { }); }); + describe("auth header origin scoping", () => { + it("should attach auth headers to relative paths resolved against baseUrl", async () => { + await makePassthroughRequest("/v1/users", undefined, { + baseUrl: "https://api.example.com", + getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), + fetch: mockFetch, + }); + const [, calledOptions] = mockFetch.mock.calls[0]; + expect(calledOptions.headers["authorization"]).toBe("Bearer my-token"); + }); + + it("should attach auth headers to same-origin absolute URLs", async () => { + await makePassthroughRequest("https://api.example.com/v1/users", undefined, { + baseUrl: "https://api.example.com", + getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), + fetch: mockFetch, + }); + const [, calledOptions] = mockFetch.mock.calls[0]; + expect(calledOptions.headers["authorization"]).toBe("Bearer my-token"); + }); + + it("should attach auth headers when the absolute URL matches the environment origin", async () => { + await makePassthroughRequest("https://env.example.com/v1/users", undefined, { + environment: "https://env.example.com", + getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), + fetch: mockFetch, + }); + const [, calledOptions] = mockFetch.mock.calls[0]; + expect(calledOptions.headers["authorization"]).toBe("Bearer my-token"); + }); + + it("should NOT attach auth headers to a cross-origin absolute URL", async () => { + await makePassthroughRequest("https://evil.example.com/steal", undefined, { + baseUrl: "https://api.example.com", + getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), + fetch: mockFetch, + }); + const [, calledOptions] = mockFetch.mock.calls[0]; + expect(calledOptions.headers["authorization"]).toBeUndefined(); + }); + + it("should NOT attach auth headers to a cross-origin URL differing only by port", async () => { + await makePassthroughRequest("https://api.example.com:9999/steal", undefined, { + baseUrl: "https://api.example.com", + getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), + fetch: mockFetch, + }); + const [, calledOptions] = mockFetch.mock.calls[0]; + expect(calledOptions.headers["authorization"]).toBeUndefined(); + }); + + it("should NOT attach auth headers when no baseUrl or environment is configured", async () => { + await makePassthroughRequest("https://api.example.com/v1/users", undefined, { + getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), + fetch: mockFetch, + }); + const [, calledOptions] = mockFetch.mock.calls[0]; + expect(calledOptions.headers["authorization"]).toBeUndefined(); + }); + + it("should still allow explicit init headers on cross-origin requests", async () => { + await makePassthroughRequest( + "https://evil.example.com/steal", + { headers: { "X-Custom": "keep-me" } }, + { + baseUrl: "https://api.example.com", + getAuthHeaders: async () => ({ Authorization: "Bearer my-token" }), + fetch: mockFetch, + }, + ); + const [, calledOptions] = mockFetch.mock.calls[0]; + expect(calledOptions.headers["authorization"]).toBeUndefined(); + expect(calledOptions.headers["x-custom"]).toBe("keep-me"); + }); + }); + describe("method and body", () => { it("should default to GET when no method specified", async () => { await makePassthroughRequest("https://api.example.com", undefined, { @@ -262,6 +341,44 @@ describe("makePassthroughRequest", () => { jest.restoreAllMocks(); }); + + it("should reject with an Error named TimeoutError when the request times out", async () => { + mockFetch.mockImplementation( + (_url: string, init: RequestInit) => + new Promise((_resolve, reject) => { + init.signal?.addEventListener("abort", () => reject(init.signal?.reason)); + }), + ); + + const error = await makePassthroughRequest("https://api.example.com", undefined, { + timeoutInSeconds: 0.01, + maxRetries: 0, + fetch: mockFetch, + }).catch((e: unknown) => e); + + expect(error).toBeInstanceOf(Error); + expect((error as Error).name).toBe("TimeoutError"); + }); + + it("should keep the caller's abort reason when the caller aborts", async () => { + mockFetch.mockImplementation( + (_url: string, init: RequestInit) => + new Promise((_resolve, reject) => { + init.signal?.addEventListener("abort", () => reject(init.signal?.reason)); + }), + ); + const controller = new AbortController(); + + const promise = makePassthroughRequest( + "https://api.example.com", + undefined, + { timeoutInSeconds: 10, maxRetries: 0, fetch: mockFetch }, + { abortSignal: controller.signal }, + ).catch((e: unknown) => e); + controller.abort("cancelled"); + + expect(await promise).toBe("cancelled"); + }); }); describe("abort signal", () => { @@ -394,4 +511,31 @@ describe("makePassthroughRequest", () => { expect(calledOptions.headers["x-dynamic"]).toBe("dynamic-value"); }); }); + + describe("debug logging", () => { + it("should redact credentials in the logged request URL", async () => { + const mockLogger = { + debug: jest.fn(), + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), + }; + await makePassthroughRequest("https://user:password@api.example.com/v1/users?token=secret", undefined, { + fetch: mockFetch, + logging: { + level: "debug", + logger: mockLogger, + silent: false, + }, + }); + + const loggedUrls = mockLogger.debug.mock.calls.map(([, meta]) => (meta as { url: string }).url); + expect(loggedUrls.length).toBeGreaterThan(0); + for (const loggedUrl of loggedUrls) { + expect(loggedUrl).toBe("https://[REDACTED]@api.example.com/v1/users?token=[REDACTED]"); + expect(loggedUrl).not.toContain("password"); + expect(loggedUrl).not.toContain("secret"); + } + }); + }); }); diff --git a/src/management/tests/unit/fetcher/makeRequest.test.ts b/src/management/tests/unit/fetcher/makeRequest.test.ts index 64a13b9d41..aec1c44e40 100644 --- a/src/management/tests/unit/fetcher/makeRequest.test.ts +++ b/src/management/tests/unit/fetcher/makeRequest.test.ts @@ -1,4 +1,9 @@ -import { makeRequest, isCacheNoStoreSupported, resetCacheNoStoreSupported } from "../../../core/fetcher/makeRequest"; +import { + clearResponseTimeout, + makeRequest, + isCacheNoStoreSupported, + resetCacheNoStoreSupported, +} from "../../../core/fetcher/makeRequest"; describe("Test makeRequest", () => { const mockPostUrl = "https://httpbin.org/post"; @@ -150,4 +155,61 @@ describe("Test makeRequest", () => { resetCacheNoStoreSupported(); } }); + + it("should clear the timeout once headers arrive by default", async () => { + jest.useFakeTimers(); + try { + await makeRequest(mockFetch, mockGetUrl, "GET", mockHeaders, undefined, 1000); + expect(jest.getTimerCount()).toBe(0); + } finally { + jest.useRealTimers(); + } + }); + + it("should keep the timeout running until clearResponseTimeout when keepTimeoutUntilBodyRead is set", async () => { + jest.useFakeTimers(); + try { + const response = await makeRequest( + mockFetch, + mockGetUrl, + "GET", + mockHeaders, + undefined, + 1000, + undefined, + undefined, + undefined, + undefined, + true, + ); + expect(jest.getTimerCount()).toBe(1); + clearResponseTimeout(response); + expect(jest.getTimerCount()).toBe(0); + } finally { + jest.useRealTimers(); + } + }); + + it("should clear the timeout when fetch rejects", async () => { + jest.useFakeTimers(); + try { + mockFetch.mockRejectedValue(new TypeError("fetch failed")); + await expect(makeRequest(mockFetch, mockGetUrl, "GET", mockHeaders, undefined, 1000)).rejects.toThrow( + "fetch failed", + ); + expect(jest.getTimerCount()).toBe(0); + } finally { + jest.useRealTimers(); + } + }); + + it("should reject with the timeout reason when the runtime rejects with its own error after the timeout fires", async () => { + mockFetch.mockImplementation( + (_url: string, init: RequestInit) => + new Promise((_resolve, reject) => { + init.signal?.addEventListener("abort", () => reject(new TypeError("invalid_argument"))); + }), + ); + await expect(makeRequest(mockFetch, mockGetUrl, "GET", mockHeaders, undefined, 10)).rejects.toBe("timeout"); + }); }); diff --git a/src/management/tests/unit/fetcher/requestWithRetries.test.ts b/src/management/tests/unit/fetcher/requestWithRetries.test.ts index 78bf9a4673..d545db8e9c 100644 --- a/src/management/tests/unit/fetcher/requestWithRetries.test.ts +++ b/src/management/tests/unit/fetcher/requestWithRetries.test.ts @@ -263,4 +263,45 @@ describe("requestWithRetries", () => { expect(setTimeoutSpy).toHaveBeenCalledWith(expect.any(Function), 60000); expect(response.status).toBe(200); }); + + it("should stop waiting and not retry when aborted during the backoff", async () => { + jest.restoreAllMocks(); + const controller = new AbortController(); + mockFetch.mockImplementation(async () => new Response("", { status: 429, headers: { "Retry-After": "1" } })); + + const responsePromise = requestWithRetries(() => mockFetch(), 2, controller.signal); + const assertion = expect(responsePromise).rejects.toBe("cancelled"); + await jest.advanceTimersByTimeAsync(30); + controller.abort("cancelled"); + await assertion; + + expect(mockFetch).toHaveBeenCalledTimes(1); + expect(jest.getTimerCount()).toBe(0); + }); + + it("should not wait when the signal is already aborted", async () => { + jest.restoreAllMocks(); + const controller = new AbortController(); + controller.abort("cancelled"); + mockFetch.mockImplementation(async () => new Response("", { status: 503 })); + + await expect(requestWithRetries(() => mockFetch(), 2, controller.signal)).rejects.toBe("cancelled"); + expect(mockFetch).toHaveBeenCalledTimes(1); + expect(jest.getTimerCount()).toBe(0); + }); + + it("should still retry normally when a signal is passed but never aborted", async () => { + jest.restoreAllMocks(); + const controller = new AbortController(); + mockFetch + .mockImplementationOnce(async () => new Response("", { status: 503 })) + .mockImplementationOnce(async () => new Response("", { status: 200 })); + + const responsePromise = requestWithRetries(() => mockFetch(), 2, controller.signal); + await jest.runAllTimersAsync(); + const response = await responsePromise; + + expect(response.status).toBe(200); + expect(mockFetch).toHaveBeenCalledTimes(2); + }); }); diff --git a/src/management/tests/unit/file/file.test.ts b/src/management/tests/unit/file/file.test.ts index f9e0f20e32..5a57e2d05d 100644 --- a/src/management/tests/unit/file/file.test.ts +++ b/src/management/tests/unit/file/file.test.ts @@ -430,6 +430,20 @@ describe("toBinaryUploadRequest", () => { }); }); + describe("null and undefined input", () => { + it("should throw Error for undefined in binary upload", async () => { + await expect(toBinaryUploadRequest(undefined as unknown as Uploadable)).rejects.toThrow(Error); + await expect(toBinaryUploadRequest(undefined as unknown as Uploadable)).rejects.toThrow( + /but received undefined/, + ); + }); + + it("should throw Error for null in binary upload", async () => { + await expect(toBinaryUploadRequest(null as unknown as Uploadable)).rejects.toThrow(Error); + await expect(toBinaryUploadRequest(null as unknown as Uploadable)).rejects.toThrow(/but received null/); + }); + }); + describe("Edge cases", () => { it("should handle empty headers when no metadata is available", async () => { const buffer = Buffer.from(""); diff --git a/src/management/tests/unit/form-data-utils/encodeAsFormParameter.test.ts b/src/management/tests/unit/form-data-utils/encodeAsFormParameter.test.ts index b5448f081e..133bcbd09c 100644 --- a/src/management/tests/unit/form-data-utils/encodeAsFormParameter.test.ts +++ b/src/management/tests/unit/form-data-utils/encodeAsFormParameter.test.ts @@ -63,7 +63,6 @@ describe("encodeAsFormParameter", () => { const obj = { items: ["a", null, "c", undefined, "e"] }; expect(encodeAsFormParameter(obj)).toEqual({ "items[0]": "a", - "items[1]": "", "items[2]": "c", "items[4]": "e", }); @@ -247,7 +246,6 @@ describe("encodeAsFormParameter", () => { const obj = { name: "John", age: null, email: undefined, active: true }; expect(encodeAsFormParameter(obj)).toEqual({ name: "John", - age: "", active: "true", }); }); diff --git a/src/management/tests/unit/stream/Stream.test.ts b/src/management/tests/unit/stream/Stream.test.ts index 9158aeeeb9..670b6f192c 100644 --- a/src/management/tests/unit/stream/Stream.test.ts +++ b/src/management/tests/unit/stream/Stream.test.ts @@ -1,4 +1,4 @@ -import { Stream } from "../../../core/stream/Stream"; +import { Stream, ServerSentEvent } from "../../../core/stream/Stream"; describe("Stream", () => { describe("JSON streaming", () => { @@ -101,7 +101,9 @@ describe("Stream", () => { }); it("should parse multiple SSE events", async () => { - const mockStream = createReadableStream(['data: {"value": 1}\ndata: {"value": 2}\ndata: {"value": 3}\n']); + const mockStream = createReadableStream([ + 'data: {"value": 1}\n\ndata: {"value": 2}\n\ndata: {"value": 3}\n', + ]); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, @@ -117,7 +119,7 @@ describe("Stream", () => { }); it("should stop at stream terminator", async () => { - const mockStream = createReadableStream(['data: {"value": 1}\ndata: [DONE]\ndata: {"value": 2}\n']); + const mockStream = createReadableStream(['data: {"value": 1}\n\ndata: [DONE]\n\ndata: {"value": 2}\n']); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, @@ -134,7 +136,7 @@ describe("Stream", () => { it("should skip lines without data prefix", async () => { const mockStream = createReadableStream([ - 'event: message\ndata: {"value": 1}\nid: 123\ndata: {"value": 2}\n', + 'event: message\ndata: {"value": 1}\nid: 123\n\ndata: {"value": 2}\n', ]); const stream = new Stream({ stream: mockStream, @@ -149,6 +151,77 @@ describe("Stream", () => { expect(messages).toEqual([{ value: 1 }, { value: 2 }]); }); + + it("should capture id when it appears after data line", async () => { + const mockStream = createReadableStream([ + 'data: {"type":"model.message","thread_id":"main"}\nid: 2\n\ndata: {"content":"Hi","type":"model.message.delta"}\nid: 3\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([ + { type: "model.message", thread_id: "main" }, + { content: "Hi", type: "model.message.delta" }, + ]); + }); + + it("should handle multiline data with id after last data line", async () => { + const mockStream = createReadableStream(['data: {"delta":\ndata: "hello"}\nid: 42\n\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ delta: "hello" }]); + }); + + it("should handle id after data without trailing blank line", async () => { + const mockStream = createReadableStream(['data: {"value": 1}\nid: last-event\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + }); + + it("should handle stream terminator with id after data", async () => { + const mockStream = createReadableStream([ + 'data: {"value": 1}\nid: 1\n\ndata: [DONE]\nid: 2\n\ndata: {"value": 3}\nid: 3\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + }); }); describe("SSE event-level discrimination (inject discriminator)", () => { @@ -194,6 +267,27 @@ describe("Stream", () => { ]); }); + it("should wrap data in an envelope for envelope events", async () => { + const mockStream = createReadableStream([ + 'event: entity\ndata: {"id": "1"}\n\nevent: error\ndata: {"code": 3, "message": "bad input"}\n\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse", eventDiscriminator: "event", envelopeEvents: ["entity"] }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([ + { event: "entity", data: { id: "1" } }, + { event: "error", code: 3, message: "bad input" }, + ]); + }); + it("should not inject if data already contains discriminator key", async () => { const mockStream = createReadableStream([ 'event: completion\ndata: {"type": "existing", "content": "hello"}\n\n', @@ -366,174 +460,1105 @@ describe("Stream", () => { }); }); - describe("encoding and decoding", () => { - it("should decode UTF-8 text using TextDecoder", async () => { - const encoder = new TextEncoder(); - const mockStream = createReadableStream([encoder.encode('{"text": "café"}\n')]); + describe("withMetadata()", () => { + it("should yield ServerSentEvent with per-event id and retry", async () => { + const mockStream = createReadableStream([ + 'id: evt-1\nretry: 5000\ndata: {"value": 1}\n\nid: evt-2\ndata: {"value": 2}\n', + ]); const stream = new Stream({ stream: mockStream, - parse: async (val: unknown) => val as { text: string }, - eventShape: { type: "json", messageTerminator: "\n" }, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, }); - const messages: unknown[] = []; - for await (const message of stream) { - messages.push(message); + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); } - expect(messages).toEqual([{ text: "café" }]); + expect(events).toEqual([ + { data: { value: 1 }, id: "evt-1", retry: 5000, event: undefined }, + { data: { value: 2 }, id: "evt-2", retry: 5000, event: undefined }, + ]); }); - it("should decode emoji correctly", async () => { - const encoder = new TextEncoder(); - const mockStream = createReadableStream([encoder.encode('{"emoji": "🎉"}\n')]); + it("should persist id across events per SSE spec", async () => { + const mockStream = createReadableStream(['id: evt-1\ndata: {"value": 1}\n\ndata: {"value": 2}\n']); const stream = new Stream({ stream: mockStream, - parse: async (val: unknown) => val as { emoji: string }, - eventShape: { type: "json", messageTerminator: "\n" }, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, }); - const messages: unknown[] = []; - for await (const message of stream) { - messages.push(message); + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); } - expect(messages).toEqual([{ emoji: "🎉" }]); + expect(events).toEqual([ + { data: { value: 1 }, id: "evt-1", retry: undefined, event: undefined }, + { data: { value: 2 }, id: "evt-1", retry: undefined, event: undefined }, + ]); }); - it("should handle binary data chunks", async () => { - const encoder = new TextEncoder(); - const mockStream = createReadableStream([encoder.encode('{"val'), encoder.encode('ue": 1}\n')]); + it("should ignore id field containing null character", async () => { + const mockStream = createReadableStream([ + 'id: valid\ndata: {"value": 1}\n\nid: bad\0id\ndata: {"value": 2}\n', + ]); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, - eventShape: { type: "json", messageTerminator: "\n" }, + eventShape: { type: "sse" }, }); - const messages: unknown[] = []; - for await (const message of stream) { - messages.push(message); + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); } - expect(messages).toEqual([{ value: 1 }]); + expect(events[0]?.id).toBe("valid"); + expect(events[1]?.id).toBe("valid"); }); - it("should handle multi-byte UTF-8 characters split across chunk boundaries", async () => { - // Test string with Japanese (3 bytes), Russian (2 bytes), German (2 bytes), and Chinese (3 bytes) - const testString = '{"text": "こんにちは Привет Größe 你好"}\n'; - const fullBytes = new TextEncoder().encode(testString); + it("should ignore retry field with non-integer value", async () => { + const mockStream = createReadableStream(['retry: abc\ndata: {"value": 1}\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); - // Split the bytes in the middle of multi-byte characters - // Japanese "こ" starts at byte 11, is 3 bytes (E3 81 93) - // Split after first byte of "こ" to test mid-character splitting - const splitPoint = 12; // This splits "こ" in the middle - const chunk1 = fullBytes.slice(0, splitPoint); - const chunk2 = fullBytes.slice(splitPoint); + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } - const mockStream = createReadableStream([chunk1, chunk2]); + expect(events[0]?.retry).toBeUndefined(); + }); + + it("should include event type and metadata with discriminator", async () => { + const mockStream = createReadableStream([ + 'event: completion\nid: msg-001\nretry: 3000\ndata: {"content": "hello"}\n\nevent: completion\nid: msg-002\ndata: {"content": "world"}\n\n', + ]); const stream = new Stream({ stream: mockStream, - parse: async (val: unknown) => val as { text: string }, - eventShape: { type: "json", messageTerminator: "\n" }, + parse: async (val: unknown) => val, + eventShape: { type: "sse", eventDiscriminator: "type" }, }); - const messages: unknown[] = []; - for await (const message of stream) { - messages.push(message); + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); } - expect(messages).toEqual([{ text: "こんにちは Привет Größe 你好" }]); + expect(events).toEqual([ + { data: { type: "completion", content: "hello" }, id: "msg-001", retry: 3000, event: "completion" }, + { data: { type: "completion", content: "world" }, id: "msg-002", retry: 3000, event: "completion" }, + ]); }); - }); - describe("abort signal", () => { - it("should handle abort signal", async () => { - const controller = new AbortController(); - const mockStream = createReadableStream(['{"value": 1}\n{"value": 2}\n{"value": 3}\n']); + it("should persist id across discriminated events per SSE spec", async () => { + const mockStream = createReadableStream([ + 'event: completion\nid: msg-001\ndata: {"content": "first"}\n\nevent: completion\ndata: {"content": "second"}\n\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse", eventDiscriminator: "type" }, + }); + + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events[0]?.id).toBe("msg-001"); + expect(events[1]?.id).toBe("msg-001"); + }); + + it("should yield undefined metadata for JSON streams", async () => { + const mockStream = createReadableStream(['{"value": 1}\n']); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, eventShape: { type: "json", messageTerminator: "\n" }, - signal: controller.signal, }); - const messages: unknown[] = []; - let count = 0; - for await (const message of stream) { - messages.push(message); - count++; - if (count === 2) { - controller.abort(); - break; - } + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); } - expect(messages.length).toBe(2); + expect(events).toEqual([{ data: { value: 1 }, id: undefined, retry: undefined, event: undefined }]); }); - }); - describe("async iteration", () => { - it("should support async iterator protocol", async () => { - const mockStream = createReadableStream(['{"value": 1}\n{"value": 2}\n']); + it("should stop at stream terminator via withMetadata (non-discriminator)", async () => { + const mockStream = createReadableStream([ + 'id: evt-1\ndata: {"value": 1}\n\ndata: [DONE]\n\ndata: {"value": 2}\n', + ]); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, - eventShape: { type: "json", messageTerminator: "\n" }, + eventShape: { type: "sse", streamTerminator: "[DONE]" }, }); - const iterator = stream[Symbol.asyncIterator](); - const first = await iterator.next(); - expect(first.done).toBe(false); - expect(first.value).toEqual({ value: 1 }); + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } - const second = await iterator.next(); - expect(second.done).toBe(false); - expect(second.value).toEqual({ value: 2 }); + expect(events).toEqual([{ data: { value: 1 }, id: "evt-1", retry: undefined, event: undefined }]); + }); - const third = await iterator.next(); - expect(third.done).toBe(true); + it("should stop at stream terminator via withMetadata (discriminator)", async () => { + const mockStream = createReadableStream([ + 'event: completion\nid: msg-001\ndata: {"content": "hi"}\n\nevent: done\ndata: [DONE]\n\nevent: completion\ndata: {"content": "bye"}\n\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse", eventDiscriminator: "type", streamTerminator: "[DONE]" }, + }); + + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([ + { data: { type: "completion", content: "hi" }, id: "msg-001", retry: undefined, event: "completion" }, + ]); }); - }); - describe("edge cases", () => { - it("should handle empty stream", async () => { - const mockStream = createReadableStream([]); + it("should reject retry with decimal value", async () => { + const mockStream = createReadableStream(['retry: 3.5\ndata: {"value": 1}\n']); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, - eventShape: { type: "json", messageTerminator: "\n" }, + eventShape: { type: "sse" }, }); - const messages: unknown[] = []; - for await (const message of stream) { - messages.push(message); + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); } - expect(messages).toEqual([]); + expect(events[0]?.retry).toBeUndefined(); }); - it("should handle stream with only whitespace", async () => { - const mockStream = createReadableStream([" \n\n\t\n "]); + it("should accept retry value of zero", async () => { + const mockStream = createReadableStream(['retry: 0\ndata: {"value": 1}\n']); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, - eventShape: { type: "json", messageTerminator: "\n" }, + eventShape: { type: "sse" }, }); - const messages: unknown[] = []; - for await (const message of stream) { - messages.push(message); + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); } - expect(messages).toEqual([]); + expect(events[0]?.retry).toBe(0); }); - it("should handle incomplete message at end of stream", async () => { - const mockStream = createReadableStream(['{"value": 1}\n{"incomplete']); + it("should set empty string id when id field has no value", async () => { + const mockStream = createReadableStream(['id:\ndata: {"value": 1}\n']); const stream = new Stream({ stream: mockStream, parse: async (val: unknown) => val as { value: number }, - eventShape: { type: "json", messageTerminator: "\n" }, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events[0]?.id).toBe(""); + }); + + it("should yield undefined event field for non-discriminator SSE even with event lines", async () => { + const mockStream = createReadableStream(['event: completion\nid: evt-1\ndata: {"value": 1}\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events[0]?.event).toBeUndefined(); + expect(events[0]?.id).toBe("evt-1"); + expect(events[0]?.data).toEqual({ value: 1 }); + }); + + it("should preserve metadata across chunked data", async () => { + const mockStream = createReadableStream(["id: ev", "t-1\nretry: 30", '00\ndata: {"val', 'ue": 1}\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([{ data: { value: 1 }, id: "evt-1", retry: 3000, event: undefined }]); + }); + + it("should update id between events in discriminator path", async () => { + const mockStream = createReadableStream([ + 'event: msg\nid: first\ndata: {"n": 1}\n\nevent: msg\nid: second\ndata: {"n": 2}\n\nevent: msg\ndata: {"n": 3}\n\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse", eventDiscriminator: "type" }, + }); + + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events[0]?.id).toBe("first"); + expect(events[1]?.id).toBe("second"); + expect(events[2]?.id).toBe("second"); + }); + + it("should attach metadata on last event without trailing blank line", async () => { + const mockStream = createReadableStream([ + 'event: completion\nid: last-1\nretry: 1000\ndata: {"content": "hi"}\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse", eventDiscriminator: "type" }, + }); + + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([ + { data: { type: "completion", content: "hi" }, id: "last-1", retry: 1000, event: "completion" }, + ]); + }); + + it("should capture id after data line (customer scenario)", async () => { + const mockStream = createReadableStream([ + 'data: {"type":"model.message","thread_id":"main","created_at":"2026-06-26T06:58:53.649Z","id":"01kw1bjtjg1702sn5tf5esqwbm"}\nid: 2\n\ndata: {"content":"Hi","type":"model.message.delta","id":"01kw1bjtjg1702sn5tf5esqwbm","thread_id":"main","created_at":"2026-06-26T06:58:59.691Z"}\nid: 3\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([ + { + data: { + type: "model.message", + thread_id: "main", + created_at: "2026-06-26T06:58:53.649Z", + id: "01kw1bjtjg1702sn5tf5esqwbm", + }, + id: "2", + retry: undefined, + event: undefined, + }, + { + data: { + content: "Hi", + type: "model.message.delta", + id: "01kw1bjtjg1702sn5tf5esqwbm", + thread_id: "main", + created_at: "2026-06-26T06:58:59.691Z", + }, + id: "3", + retry: undefined, + event: undefined, + }, + ]); + }); + + it("should capture retry after data line", async () => { + const mockStream = createReadableStream([ + 'data: {"value": 1}\nretry: 5000\n\ndata: {"value": 2}\nretry: 3000\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([ + { data: { value: 1 }, id: undefined, retry: 5000, event: undefined }, + { data: { value: 2 }, id: undefined, retry: 3000, event: undefined }, + ]); + }); + + it("should capture both id and retry after data line", async () => { + const mockStream = createReadableStream([ + 'data: {"value": 1}\nid: evt-1\nretry: 2000\n\ndata: {"value": 2}\nid: evt-2\nretry: 4000\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([ + { data: { value: 1 }, id: "evt-1", retry: 2000, event: undefined }, + { data: { value: 2 }, id: "evt-2", retry: 4000, event: undefined }, + ]); + }); + + it("should handle chunked boundary splitting data and id lines", async () => { + const mockStream = createReadableStream(['data: {"value": 1}\n', "id: chunked-", "id\n\n"]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent<{ value: number }>[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([{ data: { value: 1 }, id: "chunked-id", retry: undefined, event: undefined }]); + }); + + it("should handle multiline data followed by id", async () => { + const mockStream = createReadableStream(['data: {"delta":\ndata: "hello"}\nid: multi-42\n\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events).toEqual([{ data: { delta: "hello" }, id: "multi-42", retry: undefined, event: undefined }]); + }); + + it("should handle mixed id ordering across events", async () => { + const mockStream = createReadableStream([ + 'id: before-data\ndata: {"n": 1}\n\ndata: {"n": 2}\nid: after-data\n\ndata: {"n": 3}\n', + ]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val, + eventShape: { type: "sse" }, + }); + + const events: ServerSentEvent[] = []; + for await (const event of stream.withMetadata()) { + events.push(event); + } + + expect(events[0]?.id).toBe("before-data"); + expect(events[1]?.id).toBe("after-data"); + expect(events[2]?.id).toBe("after-data"); + }); + + it("should not affect default iteration which still yields T", async () => { + const mockStream = createReadableStream(['id: evt-1\nretry: 3000\ndata: {"value": 1}\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + }); + }); + + describe("encoding and decoding", () => { + it("should decode UTF-8 text using TextDecoder", async () => { + const encoder = new TextEncoder(); + const mockStream = createReadableStream([encoder.encode('{"text": "café"}\n')]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { text: string }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ text: "café" }]); + }); + + it("should decode emoji correctly", async () => { + const encoder = new TextEncoder(); + const mockStream = createReadableStream([encoder.encode('{"emoji": "🎉"}\n')]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { emoji: string }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ emoji: "🎉" }]); + }); + + it("should handle binary data chunks", async () => { + const encoder = new TextEncoder(); + const mockStream = createReadableStream([encoder.encode('{"val'), encoder.encode('ue": 1}\n')]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + }); + + it("should handle multi-byte UTF-8 characters split across chunk boundaries", async () => { + // Test string with Japanese (3 bytes), Russian (2 bytes), German (2 bytes), and Chinese (3 bytes) + const testString = '{"text": "こんにちは Привет Größe 你好"}\n'; + const fullBytes = new TextEncoder().encode(testString); + + // Split the bytes in the middle of multi-byte characters + // Japanese "こ" starts at byte 11, is 3 bytes (E3 81 93) + // Split after first byte of "こ" to test mid-character splitting + const splitPoint = 12; // This splits "こ" in the middle + const chunk1 = fullBytes.slice(0, splitPoint); + const chunk2 = fullBytes.slice(splitPoint); + + const mockStream = createReadableStream([chunk1, chunk2]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { text: string }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ text: "こんにちは Привет Größe 你好" }]); + }); + }); + + describe("abort signal", () => { + it("should handle abort signal", async () => { + const controller = new AbortController(); + const mockStream = createReadableStream(['{"value": 1}\n{"value": 2}\n{"value": 3}\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "json", messageTerminator: "\n" }, + signal: controller.signal, + }); + + const messages: unknown[] = []; + let count = 0; + for await (const message of stream) { + messages.push(message); + count++; + if (count === 2) { + controller.abort(); + break; + } + } + + expect(messages.length).toBe(2); + }); + }); + + describe("async iteration", () => { + it("should support async iterator protocol", async () => { + const mockStream = createReadableStream(['{"value": 1}\n{"value": 2}\n']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const iterator = stream[Symbol.asyncIterator](); + const first = await iterator.next(); + expect(first.done).toBe(false); + expect(first.value).toEqual({ value: 1 }); + + const second = await iterator.next(); + expect(second.done).toBe(false); + expect(second.value).toEqual({ value: 2 }); + + const third = await iterator.next(); + expect(third.done).toBe(true); + }); + }); + + describe("edge cases", () => { + it("should handle empty stream", async () => { + const mockStream = createReadableStream([]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([]); + }); + + it("should handle stream with only whitespace", async () => { + const mockStream = createReadableStream([" \n\n\t\n "]); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([]); + }); + + it("should handle incomplete message at end of stream", async () => { + const mockStream = createReadableStream(['{"value": 1}\n{"incomplete']); + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "json", messageTerminator: "\n" }, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + }); + }); + + describe("SSE stream reconnection", () => { + it("should reconnect on premature EOF when resumable", async () => { + const firstStream = createReadableStream([ + 'id: 1\ndata: {"value": 1}\n\n', + 'id: 2\ndata: {"value": 2}\n\n', + ]); + const secondStream = createReadableStream(['id: 3\ndata: {"value": 3}\n\n', "data: [DONE]\n\n"]); + + let reconnectCallCount = 0; + let lastReceivedEventId: string | undefined; + const reconnect = async (lastEventId: string) => { + reconnectCallCount++; + lastReceivedEventId = lastEventId; + return secondStream; + }; + + const stream = new Stream({ + stream: firstStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }, { value: 2 }, { value: 3 }]); + expect(reconnectCallCount).toBe(1); + expect(lastReceivedEventId).toBe("2"); + }); + + it("should reconnect using the last dispatched id, not a parsed-but-undispatched id", async () => { + // evt-1 is fully dispatched; evt-2's id: line is parsed but the + // stream ends before evt-2's data + blank line, so evt-2 is never + // yielded. Reconnection must resume from evt-1 (the last dispatched + // id), otherwise evt-2 would be silently skipped. + const firstStream = createReadableStream(['id: evt-1\ndata: {"value": 1}\n\n', "id: evt-2\n"]); + const secondStream = createReadableStream(['id: evt-2\ndata: {"value": 2}\n\n', "data: [DONE]\n\n"]); + + let reconnectCallCount = 0; + let lastReceivedEventId: string | undefined; + const reconnect = async (lastEventId: string) => { + reconnectCallCount++; + lastReceivedEventId = lastEventId; + return secondStream; + }; + + const stream = new Stream({ + stream: firstStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }, { value: 2 }]); + expect(reconnectCallCount).toBe(1); + expect(lastReceivedEventId).toBe("evt-1"); + }); + + it("should not reconnect when reconnectionEnabled is false", async () => { + const mockStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n']); + + let reconnectCallCount = 0; + const reconnect = async (_lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(["data: [DONE]\n\n"]); + }; + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: false, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + expect(reconnectCallCount).toBe(0); + }); + + it("should not reconnect when not resumable", async () => { + const mockStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n']); + + let reconnectCallCount = 0; + const reconnect = async (_lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(["data: [DONE]\n\n"]); + }; + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: false }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + expect(reconnectCallCount).toBe(0); + }); + + it("should respect maxReconnectionAttempts", async () => { + let reconnectCallCount = 0; + const reconnect = async (_lastEventId: string) => { + reconnectCallCount++; + // Return a stream that immediately ends without data (server down) + return createReadableStream([]); + }; + + const firstStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n']); + + const stream = new Stream({ + stream: firstStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 3, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + // First stream yields 1, then reconnection attempts get empty streams + expect(messages).toEqual([{ value: 1 }]); + expect(reconnectCallCount).toBe(3); + }); + + it("should not reconnect when stream ends with terminator", async () => { + const mockStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n', "data: [DONE]\n\n"]); + + let reconnectCallCount = 0; + const reconnect = async (_lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(["data: [DONE]\n\n"]); + }; + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + expect(reconnectCallCount).toBe(0); + }); + + it("should not reconnect without a reconnect function", async () => { + const mockStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n']); + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + }); + + it("should not reconnect without a lastId", async () => { + const mockStream = createReadableStream(['data: {"value": 1}\n\n']); + + let reconnectCallCount = 0; + const reconnect = async (_lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(["data: [DONE]\n\n"]); + }; + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }]); + expect(reconnectCallCount).toBe(0); + }); + }); + + describe("SSE stream reconnection - abort during delay", () => { + it("should stop promptly when aborted during reconnect delay", async () => { + const firstStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n']); + + let reconnectCallCount = 0; + const reconnect = async (lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(["data: [DONE]\n\n"]); + }; + + const abortController = new AbortController(); + const stream = new Stream({ + stream: firstStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + signal: abortController.signal, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + const startTime = Date.now(); + + // Abort after a short delay (while the stream is in its reconnect delay) + setTimeout(() => abortController.abort(), 50); + + for await (const message of stream) { + messages.push(message); + } + + const elapsed = Date.now() - startTime; + // Should have stopped well before the default 1000ms reconnect delay completes. + // Use a generous upper bound to avoid flakiness on slow CI runners. + expect(elapsed).toBeLessThan(800); + expect(messages).toEqual([{ value: 1 }]); + // reconnect should NOT have been called since we aborted during the delay + expect(reconnectCallCount).toBe(0); + }); + }); + + describe("SSE stream reconnection - backoff with progress", () => { + it("should apply default backoff even when server sends no retry directive", async () => { + // Server yields 1 event then drops on each connection (no retry: field) + const streams = [ + createReadableStream(['id: 1\ndata: {"value": 1}\n\n']), + createReadableStream(['id: 2\ndata: {"value": 2}\n\n']), + createReadableStream(['id: 3\ndata: {"value": 3}\n\ndata: [DONE]\n\n']), + ]; + + let reconnectCallCount = 0; + const reconnect = async (lastEventId: string) => { + reconnectCallCount++; + const s = streams[reconnectCallCount]; + if (s == null) { + throw new Error(`unexpected reconnect call ${reconnectCallCount}`); + } + return s; + }; + + const startTime = Date.now(); + const first = streams[0]; + if (first == null) { + throw new Error("missing first stream"); + } + const stream = new Stream({ + stream: first, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }, { value: 2 }, { value: 3 }]); + expect(reconnectCallCount).toBe(2); + // Total elapsed time should be at least 2 * DEFAULT_RECONNECT_DELAY_MS (~1000ms each). + // Use a slightly relaxed lower bound to tolerate timer jitter on slow CI. + const totalElapsed = Date.now() - startTime; + expect(totalElapsed).toBeGreaterThanOrEqual(1500); + }); + + it("should respect maxReconnectionAttempts even when each reconnect yields data", async () => { + // Server yields 1 event per connection, then drops (no terminator, no retry). + // reconnectAttempts resets on progress, so the cap is per-consecutive-failed-reconnects. + // With data yielded each time, reconnects reset and should keep going until terminator. + const streams = [ + createReadableStream(['id: 1\ndata: {"value": 1}\n\n']), + createReadableStream(['id: 2\ndata: {"value": 2}\n\n']), + createReadableStream(['id: 3\ndata: {"value": 3}\n\ndata: [DONE]\n\n']), + ]; + + let reconnectCallCount = 0; + const reconnect = async (lastEventId: string) => { + reconnectCallCount++; + const s = streams[reconnectCallCount]; + if (s == null) { + throw new Error(`unexpected reconnect call ${reconnectCallCount}`); + } + return s; + }; + + const first = streams[0]; + if (first == null) { + throw new Error("missing first stream"); + } + const stream = new Stream({ + stream: first, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 1, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + // Even with maxReconnectionAttempts=1, since each reconnect yields data + // the counter resets; all 3 events are received. + expect(messages).toEqual([{ value: 1 }, { value: 2 }, { value: 3 }]); + expect(reconnectCallCount).toBe(2); + }); + }); + + describe("SSE stream reconnection - terminator stops without extra reconnect", () => { + it("should stop immediately on terminator with zero reconnect calls", async () => { + let reconnectCallCount = 0; + const reconnect = async (lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(["data: [DONE]\n\n"]); + }; + + const mockStream = createReadableStream([ + 'id: 1\ndata: {"value": 1}\n\n', + 'id: 2\ndata: {"value": 2}\n\n', + "data: [DONE]\n\n", + ]); + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + expect(messages).toEqual([{ value: 1 }, { value: 2 }]); + expect(reconnectCallCount).toBe(0); + }); + + it("should stop immediately on terminator mid-stream without extra reconnect", async () => { + let reconnectCallCount = 0; + const reconnect = async (lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(['id: 99\ndata: {"value": 99}\n\ndata: [DONE]\n\n']); + }; + + // Terminator arrives in the middle of a stream that still has more data buffered + const mockStream = createReadableStream([ + 'id: 1\ndata: {"value": 1}\n\n', + 'id: 2\ndata: {"value": 2}\n\n', + "id: 3\ndata: [DONE]\n\n", + 'id: 4\ndata: {"value": 4}\n\n', + ]); + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + // Should stop at [DONE] and not yield event 4 or attempt reconnection + expect(messages).toEqual([{ value: 1 }, { value: 2 }]); + expect(reconnectCallCount).toBe(0); + }); + }); + + describe("SSE stream reconnection - no terminator prevents reconnect", () => { + it("should not attempt reconnection when no streamTerminator is configured", async () => { + let reconnectCallCount = 0; + const reconnect = async (_lastEventId: string) => { + reconnectCallCount++; + return createReadableStream(['id: 2\ndata: {"value": 2}\n\n']); + }; + + const mockStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n']); + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 5, + reconnect, + }); + + const messages: unknown[] = []; + for await (const message of stream) { + messages.push(message); + } + + // Without a streamTerminator, shouldReconnect returns false + // to avoid a reconnect storm. + expect(messages).toEqual([{ value: 1 }]); + expect(reconnectCallCount).toBe(0); + }); + }); + + describe("SSE stream reconnection - null reconnect body", () => { + it("should treat null reconnect body as a failed attempt", async () => { + let reconnectCallCount = 0; + const reconnect = async (_lastEventId: string) => { + reconnectCallCount++; + // @ts-expect-error Intentionally returning null to test null-body handling + return null; + }; + + const mockStream = createReadableStream(['id: 1\ndata: {"value": 1}\n\n']); + + const stream = new Stream({ + stream: mockStream, + parse: async (val: unknown) => val as { value: number }, + eventShape: { type: "sse", streamTerminator: "[DONE]", resumable: true }, + reconnectionEnabled: true, + maxReconnectionAttempts: 2, + reconnect, }); const messages: unknown[] = []; @@ -542,6 +1567,8 @@ describe("Stream", () => { } expect(messages).toEqual([{ value: 1 }]); + // Both reconnect attempts returned null, exhausting maxReconnectionAttempts + expect(reconnectCallCount).toBe(2); }); }); }); diff --git a/src/management/tests/unit/url/encodePathParam.test.ts b/src/management/tests/unit/url/encodePathParam.test.ts new file mode 100644 index 0000000000..6f72ccc561 --- /dev/null +++ b/src/management/tests/unit/url/encodePathParam.test.ts @@ -0,0 +1,46 @@ +import { encodePathParam, join } from "../../../core/url/index"; + +class InvalidPathParameterError extends Error { + constructor({ message }: { message: string }) { + super(message); + this.name = "InvalidPathParameterError"; + } +} + +describe("encodePathParam", () => { + it.each([ + ["usr_123", "usr_123"], + ["a/b", "a%2Fb"], + ["a b", "a%20b"], + ["a?b#c", "a%3Fb%23c"], + ["...", "..."], + [".a", ".a"], + ["a..b", "a..b"], + ["%2E%2E", "%252E%252E"], + ["", ""], + [42, "42"], + [true, "true"], + [null, "null"], + [undefined, "undefined"], + ])("encodes %j as %j", (input, expected) => { + expect(encodePathParam(input)).toBe(expected); + }); + + it.each([".", ".."])("rejects the dot segment %j", (input) => { + expect(() => encodePathParam(input)).toThrow(`Invalid path parameter "${input}"`); + }); + + it("throws the provided error class", () => { + expect(() => encodePathParam("..", InvalidPathParameterError)).toThrow(InvalidPathParameterError); + }); + + it("does not throw the provided error class for valid values", () => { + expect(encodePathParam("usr_123", InvalidPathParameterError)).toBe("usr_123"); + }); + + it("keeps encoded values in the path when joined with a base URL", () => { + expect(join("https://api.example.com/api/v2", `/users/${encodePathParam("...")}/roles`)).toBe( + "https://api.example.com/api/v2/users/.../roles", + ); + }); +}); diff --git a/src/management/tests/unit/url/qs.test.ts b/src/management/tests/unit/url/qs.test.ts index 3af9e83b4c..39cc0cb3b8 100644 --- a/src/management/tests/unit/url/qs.test.ts +++ b/src/management/tests/unit/url/qs.test.ts @@ -189,12 +189,12 @@ describe("Test qs toQueryString", () => { { description: "should handle arrays with null/undefined values", input: { items: ["a", null, "c", undefined, "e"] }, - expected: "items%5B0%5D=a&items%5B1%5D=&items%5B2%5D=c&items%5B4%5D=e", + expected: "items%5B0%5D=a&items%5B2%5D=c&items%5B4%5D=e", }, { description: "should handle objects with null/undefined values", input: { name: "John", age: null, email: undefined, active: true }, - expected: "name=John&age=&active=true", + expected: "name=John&active=true", }, ]; diff --git a/src/management/tests/unit/utils/setObjectProperty.test.ts b/src/management/tests/unit/utils/setObjectProperty.test.ts index c3b86d8686..393a68f71d 100644 --- a/src/management/tests/unit/utils/setObjectProperty.test.ts +++ b/src/management/tests/unit/utils/setObjectProperty.test.ts @@ -74,3 +74,39 @@ describe("Test setObjectProperty", () => { expect(result).toEqual(wantObject); }); }); + +describe("setObjectProperty does not modify its input", () => { + test("top-level property", () => { + const original = { cursor: "a", limit: 10 }; + const result = setObjectProperty(original, "cursor", "b"); + expect(result).toEqual({ cursor: "b", limit: 10 }); + expect(original).toEqual({ cursor: "a", limit: 10 }); + }); + + test("nested property", () => { + const options = { offset: 0, count: 2 }; + const original = { id: "x", options }; + const result = setObjectProperty(original, "options.offset", 2); + expect(result).toEqual({ id: "x", options: { offset: 2, count: 2 } }); + expect(original).toEqual({ id: "x", options: { offset: 0, count: 2 } }); + expect(original.options).toBe(options); + expect(result.options).not.toBe(options); + }); + + test("missing nested object", () => { + const original: { id: string; options?: { offset?: number } } = { id: "x" }; + const result = setObjectProperty(original, "options.offset", 2); + expect(result).toEqual({ id: "x", options: { offset: 2 } }); + expect(original).toEqual({ id: "x" }); + }); + + test("array along the path stays an array", () => { + const items = [{ name: "a" }]; + const original = { items }; + const result = setObjectProperty(original, "items.0", { name: "b" }); + expect(Array.isArray(result.items)).toBe(true); + expect(result.items).toEqual([{ name: "b" }]); + expect(original.items).toBe(items); + expect(items).toEqual([{ name: "a" }]); + }); +}); diff --git a/src/management/tests/wire/actions.test.ts b/src/management/tests/wire/actions.test.ts index 1a94ac6f57..59b6b9b226 100644 --- a/src/management/tests/wire/actions.test.ts +++ b/src/management/tests/wire/actions.test.ts @@ -64,13 +64,7 @@ describe("ActionsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/actions") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/actions").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.list(); @@ -83,13 +77,7 @@ describe("ActionsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/actions") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/actions").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.list(); @@ -102,13 +90,7 @@ describe("ActionsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/actions") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/actions").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.list(); @@ -121,13 +103,7 @@ describe("ActionsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/actions") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/actions").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.list(); diff --git a/src/management/tests/wire/actions/modules.test.ts b/src/management/tests/wire/actions/modules.test.ts index 05c7d15902..6da3f45c83 100644 --- a/src/management/tests/wire/actions/modules.test.ts +++ b/src/management/tests/wire/actions/modules.test.ts @@ -55,13 +55,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/modules") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/modules").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.modules.list(); @@ -74,13 +68,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/modules") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/modules").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.modules.list(); @@ -93,13 +81,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/modules") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/modules").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.modules.list(); @@ -112,13 +94,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/actions/modules") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/actions/modules").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.actions.modules.list(); @@ -741,7 +717,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/actions") .respondWith() .statusCode(400) @@ -760,7 +736,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/actions") .respondWith() .statusCode(401) @@ -779,7 +755,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/actions") .respondWith() .statusCode(403) @@ -798,7 +774,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/actions") .respondWith() .statusCode(404) @@ -817,7 +793,7 @@ describe("ModulesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/actions") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/actions/modules/versions.test.ts b/src/management/tests/wire/actions/modules/versions.test.ts index 823ee581b8..92b2df5878 100644 --- a/src/management/tests/wire/actions/modules/versions.test.ts +++ b/src/management/tests/wire/actions/modules/versions.test.ts @@ -53,7 +53,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/versions") .respondWith() .statusCode(400) @@ -72,7 +72,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/versions") .respondWith() .statusCode(401) @@ -91,7 +91,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/versions") .respondWith() .statusCode(403) @@ -110,7 +110,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/versions") .respondWith() .statusCode(404) @@ -129,7 +129,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/modules/id/versions") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/actions/triggers/bindings.test.ts b/src/management/tests/wire/actions/triggers/bindings.test.ts index 3b99960f53..9d2dcf1782 100644 --- a/src/management/tests/wire/actions/triggers/bindings.test.ts +++ b/src/management/tests/wire/actions/triggers/bindings.test.ts @@ -51,7 +51,7 @@ describe("BindingsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/triggers/post-login/bindings") .respondWith() .statusCode(400) @@ -70,7 +70,7 @@ describe("BindingsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/triggers/post-login/bindings") .respondWith() .statusCode(401) @@ -89,7 +89,7 @@ describe("BindingsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/triggers/post-login/bindings") .respondWith() .statusCode(403) @@ -108,7 +108,7 @@ describe("BindingsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/triggers/post-login/bindings") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/actions/versions.test.ts b/src/management/tests/wire/actions/versions.test.ts index 6d8f51b4dd..5dbb8e42b0 100644 --- a/src/management/tests/wire/actions/versions.test.ts +++ b/src/management/tests/wire/actions/versions.test.ts @@ -61,7 +61,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/actions/actionId/versions") .respondWith() .statusCode(400) @@ -80,7 +80,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/actions/actionId/versions") .respondWith() .statusCode(401) @@ -99,7 +99,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/actions/actionId/versions") .respondWith() .statusCode(403) @@ -118,7 +118,7 @@ describe("VersionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/actions/actions/actionId/versions") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/attackProtection/captchaPolicies.test.ts b/src/management/tests/wire/attackProtection/captchaPolicies.test.ts deleted file mode 100644 index 015372d694..0000000000 --- a/src/management/tests/wire/attackProtection/captchaPolicies.test.ts +++ /dev/null @@ -1,728 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import * as Management from "../../../api/index"; -import { ManagementClient } from "../../../Client"; -import { mockServerPool } from "../../mock-server/MockServerPool"; - -describe("CaptchaPoliciesClient", () => { - test("list (1)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = [ - { - id: "id", - name: "name", - description: "description", - priority: 1, - match: { auth0_managed: ["auth0_managed"], geo_country_codes: ["geo_country_codes"] }, - action: { active_provider_id: "simple_captcha" }, - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - }, - ]; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.attackProtection.captchaPolicies.list(); - expect(response).toEqual(rawResponseBody); - }); - - test("list (2)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.list(); - }).rejects.toThrow(Management.BadRequestError); - }); - - test("list (3)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.list(); - }).rejects.toThrow(Management.UnauthorizedError); - }); - - test("list (4)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.list(); - }).rejects.toThrow(Management.ForbiddenError); - }); - - test("list (5)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.list(); - }).rejects.toThrow(Management.NotFoundError); - }); - - test("list (6)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.list(); - }).rejects.toThrow(Management.TooManyRequestsError); - }); - - test("create (1)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = { name: "name", priority: 1, match: {}, action: {} }; - const rawResponseBody = { - id: "id", - name: "name", - description: "description", - priority: 1, - match: { auth0_managed: ["auth0_managed"], geo_country_codes: ["geo_country_codes"] }, - action: { - active_provider_id: "simple_captcha", - auth_challenge: { fail_open: true }, - recaptcha_v2: { site_key: "site_key" }, - recaptcha_enterprise: { site_key: "site_key", project_id: "project_id" }, - hcaptcha: { site_key: "site_key" }, - friendly_captcha: { site_key: "site_key" }, - arkose: { - site_key: "site_key", - client_subdomain: "client_subdomain", - verify_subdomain: "verify_subdomain", - fail_open: true, - }, - }, - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - }; - - server - .mockEndpoint() - .post("/attack-protection/captcha/policies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.attackProtection.captchaPolicies.create({ - name: "name", - priority: 1, - match: {}, - action: {}, - }); - expect(response).toEqual(rawResponseBody); - }); - - test("create (2)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = { name: "x", priority: 1, match: {}, action: {} }; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .post("/attack-protection/captcha/policies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.create({ - name: "x", - priority: 1, - match: {}, - action: {}, - }); - }).rejects.toThrow(Management.BadRequestError); - }); - - test("create (3)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = { name: "x", priority: 1, match: {}, action: {} }; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .post("/attack-protection/captcha/policies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.create({ - name: "x", - priority: 1, - match: {}, - action: {}, - }); - }).rejects.toThrow(Management.UnauthorizedError); - }); - - test("create (4)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = { name: "x", priority: 1, match: {}, action: {} }; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .post("/attack-protection/captcha/policies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.create({ - name: "x", - priority: 1, - match: {}, - action: {}, - }); - }).rejects.toThrow(Management.ForbiddenError); - }); - - test("create (5)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = { name: "x", priority: 1, match: {}, action: {} }; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .post("/attack-protection/captcha/policies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.create({ - name: "x", - priority: 1, - match: {}, - action: {}, - }); - }).rejects.toThrow(Management.NotFoundError); - }); - - test("create (6)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = { name: "x", priority: 1, match: {}, action: {} }; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .post("/attack-protection/captcha/policies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(409) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.create({ - name: "x", - priority: 1, - match: {}, - action: {}, - }); - }).rejects.toThrow(Management.ConflictError); - }); - - test("create (7)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = { name: "x", priority: 1, match: {}, action: {} }; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .post("/attack-protection/captcha/policies") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.create({ - name: "x", - priority: 1, - match: {}, - action: {}, - }); - }).rejects.toThrow(Management.TooManyRequestsError); - }); - - test("get (1)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { - id: "id", - name: "name", - description: "description", - priority: 1, - match: { auth0_managed: ["auth0_managed"], geo_country_codes: ["geo_country_codes"] }, - action: { - active_provider_id: "simple_captcha", - auth_challenge: { fail_open: true }, - recaptcha_v2: { site_key: "site_key" }, - recaptcha_enterprise: { site_key: "site_key", project_id: "project_id" }, - hcaptcha: { site_key: "site_key" }, - friendly_captcha: { site_key: "site_key" }, - arkose: { - site_key: "site_key", - client_subdomain: "client_subdomain", - verify_subdomain: "verify_subdomain", - fail_open: true, - }, - }, - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.attackProtection.captchaPolicies.get("id"); - expect(response).toEqual(rawResponseBody); - }); - - test("get (2)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.get("id"); - }).rejects.toThrow(Management.BadRequestError); - }); - - test("get (3)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.get("id"); - }).rejects.toThrow(Management.UnauthorizedError); - }); - - test("get (4)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.get("id"); - }).rejects.toThrow(Management.ForbiddenError); - }); - - test("get (5)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.get("id"); - }).rejects.toThrow(Management.NotFoundError); - }); - - test("get (6)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .get("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.get("id"); - }).rejects.toThrow(Management.TooManyRequestsError); - }); - - test("delete (1)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - server.mockEndpoint().delete("/attack-protection/captcha/policies/id").respondWith().statusCode(200).build(); - - const response = await client.attackProtection.captchaPolicies.delete("id"); - expect(response).toEqual(undefined); - }); - - test("delete (2)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .delete("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.delete("id"); - }).rejects.toThrow(Management.BadRequestError); - }); - - test("delete (3)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .delete("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.delete("id"); - }).rejects.toThrow(Management.UnauthorizedError); - }); - - test("delete (4)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .delete("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.delete("id"); - }).rejects.toThrow(Management.ForbiddenError); - }); - - test("delete (5)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .delete("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.delete("id"); - }).rejects.toThrow(Management.NotFoundError); - }); - - test("delete (6)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .delete("/attack-protection/captcha/policies/id") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.delete("id"); - }).rejects.toThrow(Management.TooManyRequestsError); - }); - - test("update (1)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = {}; - const rawResponseBody = { - id: "id", - name: "name", - description: "description", - priority: 1, - match: { auth0_managed: ["auth0_managed"], geo_country_codes: ["geo_country_codes"] }, - action: { - active_provider_id: "simple_captcha", - auth_challenge: { fail_open: true }, - recaptcha_v2: { site_key: "site_key" }, - recaptcha_enterprise: { site_key: "site_key", project_id: "project_id" }, - hcaptcha: { site_key: "site_key" }, - friendly_captcha: { site_key: "site_key" }, - arkose: { - site_key: "site_key", - client_subdomain: "client_subdomain", - verify_subdomain: "verify_subdomain", - fail_open: true, - }, - }, - created_at: "2024-01-15T09:30:00Z", - updated_at: "2024-01-15T09:30:00Z", - }; - - server - .mockEndpoint() - .patch("/attack-protection/captcha/policies/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(200) - .jsonBody(rawResponseBody) - .build(); - - const response = await client.attackProtection.captchaPolicies.update("id"); - expect(response).toEqual(rawResponseBody); - }); - - test("update (2)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .patch("/attack-protection/captcha/policies/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.update("id"); - }).rejects.toThrow(Management.BadRequestError); - }); - - test("update (3)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .patch("/attack-protection/captcha/policies/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.update("id"); - }).rejects.toThrow(Management.UnauthorizedError); - }); - - test("update (4)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .patch("/attack-protection/captcha/policies/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.update("id"); - }).rejects.toThrow(Management.ForbiddenError); - }); - - test("update (5)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .patch("/attack-protection/captcha/policies/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.update("id"); - }).rejects.toThrow(Management.NotFoundError); - }); - - test("update (6)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .patch("/attack-protection/captcha/policies/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(409) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.update("id"); - }).rejects.toThrow(Management.ConflictError); - }); - - test("update (7)", async () => { - const server = mockServerPool.createServer(); - const client = new ManagementClient({ maxRetries: 0, token: "test", environment: server.baseUrl }); - const rawRequestBody = {}; - const rawResponseBody = { key: "value" }; - - server - .mockEndpoint() - .patch("/attack-protection/captcha/policies/id") - .jsonBody(rawRequestBody) - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); - - await expect(async () => { - return await client.attackProtection.captchaPolicies.update("id"); - }).rejects.toThrow(Management.TooManyRequestsError); - }); -}); diff --git a/src/management/tests/wire/clients.test.ts b/src/management/tests/wire/clients.test.ts index 4200ce0d67..1e61e35a83 100644 --- a/src/management/tests/wire/clients.test.ts +++ b/src/management/tests/wire/clients.test.ts @@ -122,13 +122,7 @@ describe("ClientsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/clients") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/clients").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.clients.list(); @@ -141,13 +135,7 @@ describe("ClientsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/clients") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/clients").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.clients.list(); @@ -160,13 +148,7 @@ describe("ClientsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/clients") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/clients").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.clients.list(); @@ -179,13 +161,7 @@ describe("ClientsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/clients") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/clients").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.clients.list(); diff --git a/src/management/tests/wire/deviceCredentials.test.ts b/src/management/tests/wire/deviceCredentials.test.ts index 4aa62fd9c2..a06cb82e90 100644 --- a/src/management/tests/wire/deviceCredentials.test.ts +++ b/src/management/tests/wire/deviceCredentials.test.ts @@ -58,7 +58,7 @@ describe("DeviceCredentialsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/device-credentials") .respondWith() .statusCode(400) @@ -77,7 +77,7 @@ describe("DeviceCredentialsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/device-credentials") .respondWith() .statusCode(401) @@ -96,7 +96,7 @@ describe("DeviceCredentialsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/device-credentials") .respondWith() .statusCode(403) @@ -115,7 +115,7 @@ describe("DeviceCredentialsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/device-credentials") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/experimentation/experiments.test.ts b/src/management/tests/wire/experimentation/experiments.test.ts index 926cf8dcd0..9a1ba68b61 100644 --- a/src/management/tests/wire/experimentation/experiments.test.ts +++ b/src/management/tests/wire/experimentation/experiments.test.ts @@ -142,6 +142,7 @@ describe("ExperimentsClient", () => { name: "name", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { id: "id", @@ -191,6 +192,7 @@ describe("ExperimentsClient", () => { name: "name", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); expect(response).toEqual(rawResponseBody); }); @@ -202,6 +204,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { key: "value" }; @@ -219,6 +222,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); }).rejects.toThrow(Management.BadRequestError); }); @@ -230,6 +234,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { key: "value" }; @@ -247,6 +252,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); }).rejects.toThrow(Management.UnauthorizedError); }); @@ -258,6 +264,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { key: "value" }; @@ -275,6 +282,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); }).rejects.toThrow(Management.ForbiddenError); }); @@ -286,6 +294,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { key: "value" }; @@ -303,6 +312,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); }).rejects.toThrow(Management.NotFoundError); }); @@ -314,6 +324,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { key: "value" }; @@ -331,6 +342,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); }).rejects.toThrow(Management.ConflictError); }); @@ -342,6 +354,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { key: "value" }; @@ -359,6 +372,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); }).rejects.toThrow(Management.UnprocessableEntityError); }); @@ -370,6 +384,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }; const rawResponseBody = { key: "value" }; @@ -387,6 +402,7 @@ describe("ExperimentsClient", () => { name: "foo", feature_flag_id: "feature_flag_id", authentication_flow: "authentication", + allocation_strategy: "percentage", }); }).rejects.toThrow(Management.TooManyRequestsError); }); diff --git a/src/management/tests/wire/flows.test.ts b/src/management/tests/wire/flows.test.ts index 91282476d6..2551baa197 100644 --- a/src/management/tests/wire/flows.test.ts +++ b/src/management/tests/wire/flows.test.ts @@ -53,13 +53,7 @@ describe("FlowsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/flows") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/flows").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.flows.list(); @@ -72,13 +66,7 @@ describe("FlowsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/flows") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/flows").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.flows.list(); @@ -91,13 +79,7 @@ describe("FlowsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/flows") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/flows").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.flows.list(); @@ -110,13 +92,7 @@ describe("FlowsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/flows") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/flows").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.flows.list(); diff --git a/src/management/tests/wire/flows/vault/connections.test.ts b/src/management/tests/wire/flows/vault/connections.test.ts index d7775c2397..d7663b8b5b 100644 --- a/src/management/tests/wire/flows/vault/connections.test.ts +++ b/src/management/tests/wire/flows/vault/connections.test.ts @@ -56,7 +56,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/flows/vault/connections") .respondWith() .statusCode(400) @@ -75,7 +75,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/flows/vault/connections") .respondWith() .statusCode(401) @@ -94,7 +94,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/flows/vault/connections") .respondWith() .statusCode(403) @@ -113,7 +113,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/flows/vault/connections") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/forms.test.ts b/src/management/tests/wire/forms.test.ts index f454dfeee4..144c8399b6 100644 --- a/src/management/tests/wire/forms.test.ts +++ b/src/management/tests/wire/forms.test.ts @@ -53,13 +53,7 @@ describe("FormsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/forms") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/forms").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.forms.list(); @@ -72,13 +66,7 @@ describe("FormsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/forms") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/forms").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.forms.list(); @@ -91,13 +79,7 @@ describe("FormsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/forms") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/forms").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.forms.list(); @@ -110,13 +92,7 @@ describe("FormsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/forms") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/forms").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.forms.list(); diff --git a/src/management/tests/wire/hooks.test.ts b/src/management/tests/wire/hooks.test.ts index 464b71c32c..0f87f8c1cd 100644 --- a/src/management/tests/wire/hooks.test.ts +++ b/src/management/tests/wire/hooks.test.ts @@ -55,13 +55,7 @@ describe("HooksClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/hooks") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/hooks").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.hooks.list(); @@ -74,13 +68,7 @@ describe("HooksClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/hooks") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/hooks").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.hooks.list(); @@ -93,13 +81,7 @@ describe("HooksClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/hooks") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/hooks").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.hooks.list(); @@ -112,13 +94,7 @@ describe("HooksClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/hooks") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/hooks").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.hooks.list(); @@ -131,13 +107,7 @@ describe("HooksClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/hooks") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/hooks").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.hooks.list(); diff --git a/src/management/tests/wire/keys/encryption.test.ts b/src/management/tests/wire/keys/encryption.test.ts index 8bf0ba3414..e54065ff01 100644 --- a/src/management/tests/wire/keys/encryption.test.ts +++ b/src/management/tests/wire/keys/encryption.test.ts @@ -53,13 +53,7 @@ describe("EncryptionClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/keys/encryption") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/keys/encryption").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.keys.encryption.list(); @@ -72,13 +66,7 @@ describe("EncryptionClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/keys/encryption") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/keys/encryption").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.keys.encryption.list(); @@ -91,13 +79,7 @@ describe("EncryptionClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/keys/encryption") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/keys/encryption").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.keys.encryption.list(); @@ -110,13 +92,7 @@ describe("EncryptionClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/keys/encryption") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/keys/encryption").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.keys.encryption.list(); diff --git a/src/management/tests/wire/logs.test.ts b/src/management/tests/wire/logs.test.ts index d350a80884..ace84c0a17 100644 --- a/src/management/tests/wire/logs.test.ts +++ b/src/management/tests/wire/logs.test.ts @@ -70,13 +70,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/logs") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/logs").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.logs.list(); @@ -89,13 +83,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/logs") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/logs").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.logs.list(); @@ -108,13 +96,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/logs") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/logs").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.logs.list(); @@ -127,13 +109,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/logs") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/logs").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.logs.list(); diff --git a/src/management/tests/wire/networkAcls.test.ts b/src/management/tests/wire/networkAcls.test.ts index 21efd35c6d..18ee910c3e 100644 --- a/src/management/tests/wire/networkAcls.test.ts +++ b/src/management/tests/wire/networkAcls.test.ts @@ -53,13 +53,7 @@ describe("NetworkAclsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/network-acls") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/network-acls").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.networkAcls.list(); @@ -72,13 +66,7 @@ describe("NetworkAclsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/network-acls") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/network-acls").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.networkAcls.list(); @@ -91,13 +79,7 @@ describe("NetworkAclsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/network-acls") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/network-acls").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.networkAcls.list(); @@ -110,13 +92,7 @@ describe("NetworkAclsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/network-acls") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/network-acls").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.networkAcls.list(); diff --git a/src/management/tests/wire/organizations/clientGrants.test.ts b/src/management/tests/wire/organizations/clientGrants.test.ts index 817d35d49b..273e2477ed 100644 --- a/src/management/tests/wire/organizations/clientGrants.test.ts +++ b/src/management/tests/wire/organizations/clientGrants.test.ts @@ -56,7 +56,7 @@ describe("ClientGrantsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/client-grants") .respondWith() .statusCode(400) @@ -75,7 +75,7 @@ describe("ClientGrantsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/client-grants") .respondWith() .statusCode(401) @@ -94,7 +94,7 @@ describe("ClientGrantsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/client-grants") .respondWith() .statusCode(403) @@ -113,7 +113,7 @@ describe("ClientGrantsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/client-grants") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/organizations/connections.test.ts b/src/management/tests/wire/organizations/connections.test.ts index ea28010d3d..b333622ca7 100644 --- a/src/management/tests/wire/organizations/connections.test.ts +++ b/src/management/tests/wire/organizations/connections.test.ts @@ -56,7 +56,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/connections") .respondWith() .statusCode(400) @@ -75,7 +75,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/connections") .respondWith() .statusCode(401) @@ -94,7 +94,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/connections") .respondWith() .statusCode(403) @@ -113,7 +113,7 @@ describe("ConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/connections") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/organizations/enabledConnections.test.ts b/src/management/tests/wire/organizations/enabledConnections.test.ts index 675056690b..cae718b187 100644 --- a/src/management/tests/wire/organizations/enabledConnections.test.ts +++ b/src/management/tests/wire/organizations/enabledConnections.test.ts @@ -51,7 +51,7 @@ describe("EnabledConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/enabled_connections") .respondWith() .statusCode(400) @@ -70,7 +70,7 @@ describe("EnabledConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/enabled_connections") .respondWith() .statusCode(401) @@ -89,7 +89,7 @@ describe("EnabledConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/enabled_connections") .respondWith() .statusCode(403) @@ -108,7 +108,7 @@ describe("EnabledConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/enabled_connections") .respondWith() .statusCode(404) @@ -127,7 +127,7 @@ describe("EnabledConnectionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/enabled_connections") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/organizations/invitations.test.ts b/src/management/tests/wire/organizations/invitations.test.ts index 14a4c6169e..53727ac156 100644 --- a/src/management/tests/wire/organizations/invitations.test.ts +++ b/src/management/tests/wire/organizations/invitations.test.ts @@ -62,7 +62,7 @@ describe("InvitationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/invitations") .respondWith() .statusCode(400) @@ -81,7 +81,7 @@ describe("InvitationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/invitations") .respondWith() .statusCode(401) @@ -100,7 +100,7 @@ describe("InvitationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/invitations") .respondWith() .statusCode(403) @@ -119,7 +119,7 @@ describe("InvitationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/invitations") .respondWith() .statusCode(404) @@ -138,7 +138,7 @@ describe("InvitationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/invitations") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/organizations/members/roles.test.ts b/src/management/tests/wire/organizations/members/roles.test.ts index 1ba486d88a..68ebd5092c 100644 --- a/src/management/tests/wire/organizations/members/roles.test.ts +++ b/src/management/tests/wire/organizations/members/roles.test.ts @@ -44,7 +44,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/members/user_id/roles") .respondWith() .statusCode(400) @@ -63,7 +63,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/members/user_id/roles") .respondWith() .statusCode(401) @@ -82,7 +82,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/members/user_id/roles") .respondWith() .statusCode(403) @@ -101,7 +101,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/members/user_id/roles") .respondWith() .statusCode(404) @@ -120,7 +120,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/organizations/id/members/user_id/roles") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/prompts/rendering.test.ts b/src/management/tests/wire/prompts/rendering.test.ts index cf696f6e68..cb8bdeb738 100644 --- a/src/management/tests/wire/prompts/rendering.test.ts +++ b/src/management/tests/wire/prompts/rendering.test.ts @@ -59,13 +59,7 @@ describe("RenderingClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/prompts/rendering") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/prompts/rendering").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.prompts.rendering.list(); @@ -78,13 +72,7 @@ describe("RenderingClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/prompts/rendering") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/prompts/rendering").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.prompts.rendering.list(); @@ -97,13 +85,7 @@ describe("RenderingClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/prompts/rendering") - .respondWith() - .statusCode(402) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/prompts/rendering").respondWith().statusCode(402).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.prompts.rendering.list(); @@ -116,13 +98,7 @@ describe("RenderingClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/prompts/rendering") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/prompts/rendering").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.prompts.rendering.list(); @@ -135,13 +111,7 @@ describe("RenderingClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/prompts/rendering") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/prompts/rendering").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.prompts.rendering.list(); diff --git a/src/management/tests/wire/resourceServers.test.ts b/src/management/tests/wire/resourceServers.test.ts index 0d95c70b66..ae93ec2113 100644 --- a/src/management/tests/wire/resourceServers.test.ts +++ b/src/management/tests/wire/resourceServers.test.ts @@ -73,13 +73,7 @@ describe("ResourceServersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/resource-servers") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/resource-servers").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.resourceServers.list(); @@ -92,13 +86,7 @@ describe("ResourceServersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/resource-servers") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/resource-servers").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.resourceServers.list(); @@ -111,13 +99,7 @@ describe("ResourceServersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/resource-servers") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/resource-servers").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.resourceServers.list(); @@ -130,13 +112,7 @@ describe("ResourceServersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/resource-servers") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/resource-servers").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.resourceServers.list(); diff --git a/src/management/tests/wire/roles.test.ts b/src/management/tests/wire/roles.test.ts index fd527d2ef6..d6fbe22db1 100644 --- a/src/management/tests/wire/roles.test.ts +++ b/src/management/tests/wire/roles.test.ts @@ -46,13 +46,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/roles") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/roles").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.roles.list(); @@ -65,13 +59,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/roles") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/roles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.roles.list(); @@ -84,13 +72,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/roles") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/roles").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.roles.list(); @@ -103,13 +85,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/roles") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/roles").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.roles.list(); diff --git a/src/management/tests/wire/roles/permissions.test.ts b/src/management/tests/wire/roles/permissions.test.ts index b322bfcd5f..ade31603b9 100644 --- a/src/management/tests/wire/roles/permissions.test.ts +++ b/src/management/tests/wire/roles/permissions.test.ts @@ -51,7 +51,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/roles/id/permissions") .respondWith() .statusCode(400) @@ -70,7 +70,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/roles/id/permissions") .respondWith() .statusCode(401) @@ -89,7 +89,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/roles/id/permissions") .respondWith() .statusCode(403) @@ -108,7 +108,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/roles/id/permissions") .respondWith() .statusCode(404) @@ -127,7 +127,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/roles/id/permissions") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/rules.test.ts b/src/management/tests/wire/rules.test.ts index 9f5566b5ce..6166109da6 100644 --- a/src/management/tests/wire/rules.test.ts +++ b/src/management/tests/wire/rules.test.ts @@ -46,13 +46,7 @@ describe("RulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/rules") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/rules").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.rules.list(); @@ -65,13 +59,7 @@ describe("RulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/rules") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/rules").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.rules.list(); @@ -84,13 +72,7 @@ describe("RulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/rules") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/rules").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.rules.list(); @@ -103,13 +85,7 @@ describe("RulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/rules") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/rules").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.rules.list(); @@ -122,13 +98,7 @@ describe("RulesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/rules") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/rules").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.rules.list(); diff --git a/src/management/tests/wire/selfServiceProfiles.test.ts b/src/management/tests/wire/selfServiceProfiles.test.ts index a710702b6c..5f874fa2aa 100644 --- a/src/management/tests/wire/selfServiceProfiles.test.ts +++ b/src/management/tests/wire/selfServiceProfiles.test.ts @@ -55,7 +55,7 @@ describe("SelfServiceProfilesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/self-service-profiles") .respondWith() .statusCode(401) @@ -74,7 +74,7 @@ describe("SelfServiceProfilesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/self-service-profiles") .respondWith() .statusCode(403) @@ -93,7 +93,7 @@ describe("SelfServiceProfilesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/self-service-profiles") .respondWith() .statusCode(429) @@ -112,7 +112,7 @@ describe("SelfServiceProfilesClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/self-service-profiles") .respondWith() .statusCode(500) diff --git a/src/management/tests/wire/userGrants.test.ts b/src/management/tests/wire/userGrants.test.ts index 379dc4cf80..977beb7d52 100644 --- a/src/management/tests/wire/userGrants.test.ts +++ b/src/management/tests/wire/userGrants.test.ts @@ -55,13 +55,7 @@ describe("UserGrantsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/grants") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/grants").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.userGrants.list(); @@ -74,13 +68,7 @@ describe("UserGrantsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/grants") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/grants").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.userGrants.list(); @@ -93,13 +81,7 @@ describe("UserGrantsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/grants") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/grants").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.userGrants.list(); diff --git a/src/management/tests/wire/users.test.ts b/src/management/tests/wire/users.test.ts index 0fb5757e74..9e8329342c 100644 --- a/src/management/tests/wire/users.test.ts +++ b/src/management/tests/wire/users.test.ts @@ -77,13 +77,7 @@ describe("UsersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.list(); @@ -96,13 +90,7 @@ describe("UsersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.list(); @@ -115,13 +103,7 @@ describe("UsersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.list(); @@ -134,13 +116,7 @@ describe("UsersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.list(); @@ -153,13 +129,7 @@ describe("UsersClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users") - .respondWith() - .statusCode(503) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users").respondWith().statusCode(503).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.list(); diff --git a/src/management/tests/wire/users/authenticationMethods.test.ts b/src/management/tests/wire/users/authenticationMethods.test.ts index 3729858d18..49ea0d005a 100644 --- a/src/management/tests/wire/users/authenticationMethods.test.ts +++ b/src/management/tests/wire/users/authenticationMethods.test.ts @@ -69,7 +69,7 @@ describe("AuthenticationMethodsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/authentication-methods") .respondWith() .statusCode(400) @@ -88,7 +88,7 @@ describe("AuthenticationMethodsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/authentication-methods") .respondWith() .statusCode(401) @@ -107,7 +107,7 @@ describe("AuthenticationMethodsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/authentication-methods") .respondWith() .statusCode(403) @@ -126,7 +126,7 @@ describe("AuthenticationMethodsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/authentication-methods") .respondWith() .statusCode(404) @@ -145,7 +145,7 @@ describe("AuthenticationMethodsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/authentication-methods") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/users/logs.test.ts b/src/management/tests/wire/users/logs.test.ts index 16429d276a..0249bf680d 100644 --- a/src/management/tests/wire/users/logs.test.ts +++ b/src/management/tests/wire/users/logs.test.ts @@ -67,13 +67,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/logs") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/logs").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.logs.list("id"); @@ -86,13 +80,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/logs") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/logs").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.logs.list("id"); @@ -105,13 +93,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/logs") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/logs").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.logs.list("id"); @@ -124,13 +106,7 @@ describe("LogsClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/logs") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/logs").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.logs.list("id"); diff --git a/src/management/tests/wire/users/organizations.test.ts b/src/management/tests/wire/users/organizations.test.ts index 0ff7e6bab0..f9dc82fa64 100644 --- a/src/management/tests/wire/users/organizations.test.ts +++ b/src/management/tests/wire/users/organizations.test.ts @@ -53,7 +53,7 @@ describe("OrganizationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/organizations") .respondWith() .statusCode(400) @@ -72,7 +72,7 @@ describe("OrganizationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/organizations") .respondWith() .statusCode(401) @@ -91,7 +91,7 @@ describe("OrganizationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/organizations") .respondWith() .statusCode(403) @@ -110,7 +110,7 @@ describe("OrganizationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/organizations") .respondWith() .statusCode(404) @@ -129,7 +129,7 @@ describe("OrganizationsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/organizations") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/users/permissions.test.ts b/src/management/tests/wire/users/permissions.test.ts index 72bce56eb4..ab37f1ffca 100644 --- a/src/management/tests/wire/users/permissions.test.ts +++ b/src/management/tests/wire/users/permissions.test.ts @@ -51,7 +51,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/permissions") .respondWith() .statusCode(400) @@ -70,7 +70,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/permissions") .respondWith() .statusCode(401) @@ -89,7 +89,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/permissions") .respondWith() .statusCode(403) @@ -108,7 +108,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/permissions") .respondWith() .statusCode(404) @@ -127,7 +127,7 @@ describe("PermissionsClient", () => { const rawResponseBody = { key: "value" }; server - .mockEndpoint({ once: false }) + .mockEndpoint() .get("/users/id/permissions") .respondWith() .statusCode(429) diff --git a/src/management/tests/wire/users/roles.test.ts b/src/management/tests/wire/users/roles.test.ts index 2752aa89aa..d3792bd863 100644 --- a/src/management/tests/wire/users/roles.test.ts +++ b/src/management/tests/wire/users/roles.test.ts @@ -43,13 +43,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/roles") - .respondWith() - .statusCode(400) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/roles").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.roles.list("id"); @@ -62,13 +56,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/roles") - .respondWith() - .statusCode(401) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/roles").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.roles.list("id"); @@ -81,13 +69,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/roles") - .respondWith() - .statusCode(403) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/roles").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.roles.list("id"); @@ -100,13 +82,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/roles") - .respondWith() - .statusCode(404) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/roles").respondWith().statusCode(404).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.roles.list("id"); @@ -119,13 +95,7 @@ describe("RolesClient", () => { const rawResponseBody = { key: "value" }; - server - .mockEndpoint({ once: false }) - .get("/users/id/roles") - .respondWith() - .statusCode(429) - .jsonBody(rawResponseBody) - .build(); + server.mockEndpoint().get("/users/id/roles").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); await expect(async () => { return await client.users.roles.list("id"); diff --git a/v6_MIGRATION_GUIDE.md b/v6_MIGRATION_GUIDE.md deleted file mode 100644 index d1eb6bd699..0000000000 --- a/v6_MIGRATION_GUIDE.md +++ /dev/null @@ -1,158 +0,0 @@ -# V6 Migration Guide - -A guide to migrating the Auth0 Node.js SDK from `5.x` to `6.x`. - -- [Overall changes](#overall-changes) -- [Breaking changes](#breaking-changes) - - [ConnectionAttributeIdentifier replaced with identifier-specific types](#connectionattributeidentifier-replaced-with-identifier-specific-types) - - [PhoneProviderProtectionBackoffStrategyEnum value change](#phoneproviderprotectionbackoffstrategyenum-value-change) - - [users.federatedConnectionsTokensets removed](#usersfederatedconnectionstokensets-removed) - - [federated_connections_access_tokens removed from connection options](#federated_connections_access_tokens-removed-from-connection-options) - -## Overall changes - -V6 addresses type correctness for database connection attribute identifiers, aligns the phone provider backoff strategy enum with the updated API, and removes the federated connections tokensets user sub-client. There are no changes to the Authentication API — any code written for the Authentication API in `5.x` will continue to work in `6.x`. - -## Breaking changes - -### ConnectionAttributeIdentifier replaced with identifier-specific types - -In v5, all three attribute identifiers (email, phone number, and username) shared a single `ConnectionAttributeIdentifier` type for their `identifier` field. This was incorrect — each identifier type supports different values for `default_method`. - -In v6, `ConnectionAttributeIdentifier` has been removed and replaced with three separate types: - -| Attribute | Old type | New type | `default_method` values | -| -------------- | ------------------------------- | ----------------------------- | ----------------------------- | -| `email` | `ConnectionAttributeIdentifier` | `EmailAttributeIdentifier` | `"password"` \| `"email_otp"` | -| `phone_number` | `ConnectionAttributeIdentifier` | `PhoneAttributeIdentifier` | `"password"` \| `"phone_otp"` | -| `username` | `ConnectionAttributeIdentifier` | `UsernameAttributeIdentifier` | _(no `default_method`)_ | - -**Before (v5):** - -```ts -import { Management } from "auth0"; - -const identifier: Management.ConnectionAttributeIdentifier = { - active: true, - default_method: "email_otp", -}; -``` - -**After (v6):** - -```ts -import { Management } from "auth0"; - -// For email attribute -const emailIdentifier: Management.EmailAttributeIdentifier = { - active: true, - default_method: "email_otp", -}; - -// For phone_number attribute -const phoneIdentifier: Management.PhoneAttributeIdentifier = { - active: true, - default_method: "phone_otp", -}; - -// For username attribute (no default_method) -const usernameIdentifier: Management.UsernameAttributeIdentifier = { - active: true, -}; -``` - -If you were using `ConnectionAttributeIdentifier` as a type annotation in your own code, update it to the appropriate identifier-specific type based on which attribute it applies to. - ---- - -### PhoneProviderProtectionBackoffStrategyEnum value change - -The `PhoneProviderProtectionBackoffStrategyEnum` enum has been updated to reflect a change in the Auth0 API. The `None` variant has been renamed to `Default`, and its string value has changed from `"none"` to `"default"`. - -**Before (v5):** - -```ts -import { Management } from "auth0"; - -const strategy = Management.PhoneProviderProtectionBackoffStrategyEnum.None; // "none" -``` - -**After (v6):** - -```ts -import { Management } from "auth0"; - -const strategy = Management.PhoneProviderProtectionBackoffStrategyEnum.Default; // "default" -``` - -If you were passing this value directly as a string `"none"`, update it to `"default"` to match the updated API. - ---- - -### users.federatedConnectionsTokensets removed - -The `client.users.federatedConnectionsTokensets` sub-client has been removed. This includes the `list()` and `delete()` methods. - -**Before (v5):** - -```ts -// List active federated connection tokensets for a user -const tokensets = await client.users.federatedConnectionsTokensets.list("user_id"); - -// Delete a tokenset -await client.users.federatedConnectionsTokensets.delete("user_id", "tokenset_id"); -``` - -**After (v6):** - -These methods are no longer available. Remove any calls to `client.users.federatedConnectionsTokensets` from your code. - ---- - -### federated_connections_access_tokens removed from connection options - -The `federated_connections_access_tokens` field has been removed from all connection option types, including create and update. This affects OIDC, Azure AD, Google Apps, and other connection strategies. Remove it from any create or update payloads. - -**Before (v5):** - -```ts -// On create -await client.connections.create({ - strategy: "oidc", - name: "my-connection", - options: { - federated_connections_access_tokens: { ... }, - // other options - }, -}); - -// On update -await client.connections.update("connection_id", { - options: { - federated_connections_access_tokens: { ... }, - // other options - }, -}); -``` - -**After (v6):** - -```ts -// On create -await client.connections.create({ - strategy: "oidc", - name: "my-connection", - options: { - // remove federated_connections_access_tokens - // other options - }, -}); - -// On update -await client.connections.update("connection_id", { - options: { - // remove federated_connections_access_tokens - // other options - }, -}); -``` diff --git a/v7_MIGRATION_GUIDE.md b/v7_MIGRATION_GUIDE.md deleted file mode 100644 index 95d366b1e8..0000000000 --- a/v7_MIGRATION_GUIDE.md +++ /dev/null @@ -1,146 +0,0 @@ -# V7 Migration Guide - -A guide to migrating the Auth0 Node.js SDK from `6.x` to `7.x`. - -> **Migrating with an AI agent?** Point it at the Auth0 migration skill first. The skill lives in [`auth0/agent-skills`](https://github.com/auth0/agent-skills) as the `auth0` skill (migration intent: `migrate-node-auth0`). It encodes the authentication-layer rewrite rules and a verify loop. - -- [Overall changes](#overall-changes) -- [Breaking changes](#breaking-changes) - - [Authentication API removed from the main entrypoint](#authentication-api-removed-from-the-main-entrypoint) - - [Removed exports](#removed-exports) - - [ManagementClient mTLS requires an explicit `fetch`](#managementclient-mtls-requires-an-explicit-fetch) - - [mTLS works with both client secret and client assertion](#mtls-works-with-both-client-secret-and-client-assertion) - - [`domain` must be a bare hostname](#domain-must-be-a-bare-hostname) - - [Token acquisition failures throw `ManagementError`](#token-acquisition-failures-throw-managementerror) - - [`uuid` dependency removed](#uuid-dependency-removed) -- [Migrating authentication code](#migrating-authentication-code) -- [Staying on the legacy entrypoint](#staying-on-the-legacy-entrypoint) - -## Overall changes - -V7 makes `node-auth0` a **Management-API-only SDK**. The Authentication API layer (`AuthenticationClient`, its sub-clients, and `UserInfoClient`) has been removed from the main entrypoint. `ManagementClient` continues to work exactly as before; it now acquires its internal token directly via the client credentials grant rather than through the removed authentication layer. - -If your code only uses `ManagementClient`, the upgrade is small: address the Management-side breaking changes below (mTLS, domain validation, error type) and you are done. If your code uses `AuthenticationClient` or `UserInfoClient`, that code must move to a dedicated package; see [Migrating authentication code](#migrating-authentication-code). - -## Breaking changes - -### Authentication API removed from the main entrypoint - -`AuthenticationClient` and `UserInfoClient` are no longer exported from the `auth0` main entrypoint. The stateless authentication layer now lives in [`@auth0/auth0-auth-js`](https://github.com/auth0/auth0-auth-js), and the server-managed session layer lives in [`@auth0/auth0-server-js`](https://github.com/auth0/auth0-auth-js/tree/main/packages/auth0-server-js). - -**Before (v6):** - -```ts -import { AuthenticationClient, UserInfoClient } from "auth0"; - -const auth = new AuthenticationClient({ domain, clientId, clientSecret }); -const tokens = await auth.oauth.clientCredentialsGrant({ audience }); -``` - -**After (v7):** - -```ts -import { AuthClient } from "@auth0/auth0-auth-js"; - -const auth = new AuthClient({ domain, clientId, clientSecret }); -const tokens = await auth.getTokenByClientCredentials({ audience }); -``` - -The complete method-by-method mapping, the four cross-cutting behavior changes (return shape, casing, token expiry, error model), and the session-app wiring are documented in the dedicated [Authentication Migration Guide](https://github.com/auth0/node-auth0/tree/master/auth-migration). This guide does not repeat that detail. - -If you need the old clients unchanged as a stopgap, they still ship from the [legacy entrypoint](#staying-on-the-legacy-entrypoint). - -### Removed exports - -The following symbols were exported from the main entrypoint in v6 and are removed in v7. Each moves to `@auth0/auth0-auth-js`, or remains available from the `auth0/legacy` entrypoint at its v4.x shape. - -| Removed export (v6) | Replacement in v7 | -| ---------------------------- | ------------------------------------------------------------------------------------- | -| `AuthenticationClient` | `AuthClient` from `@auth0/auth0-auth-js` | -| `UserInfoClient` | `AuthClient.getUserInfo()` from `@auth0/auth0-auth-js`, or read `TokenResponse.claims` | -| `AuthApiError` | Per-operation typed errors from `@auth0/auth0-auth-js` (`TokenByCodeError`, `TokenByRefreshTokenError`, …); use their `.cause` | -| `AuthenticationClientOptions`| `AuthClientOptions` from `@auth0/auth0-auth-js` | -| `IDTokenValidateOptions` | Validation is internal to the grant call; pass `organization` / `nonce` / `maxAge` to the grant and read `TokenResponse.claims` | -| `IdTokenValidatorError` | Thrown internally by the grant as a typed error on claim mismatch | -| `TokenSet` | `TokenResponse` from `@auth0/auth0-auth-js` (camelCase fields; `expiresAt` is absolute) | -| `SUBJECT_TOKEN_TYPES` | Pass the token-type URN string directly to `exchangeToken` in `@auth0/auth0-auth-js` | -| `UserInfoResponse` | Return type of `AuthClient.getUserInfo()` in `@auth0/auth0-auth-js` | -| `UserInfoError` | Typed error from `AuthClient.getUserInfo()` in `@auth0/auth0-auth-js` | -| `ResponseError` | Management API calls throw `ManagementError` | -| `FetchError` | Management API calls throw `ManagementError` | -| `JSONApiResponse` | Responses return the data directly (no wrapper) | - -`ManagementClient`, the `Management` namespace, and `ManagementError` are unchanged and still exported. - -### ManagementClient mTLS requires an explicit `fetch` - -A `ManagementClient` constructed with `useMTLS: true` must now supply an explicit `fetch` option carrying the client certificate. The client throws at construction if `useMTLS` is set without a `fetch`. Previously a missing fetch surfaced as silent `401`s at request time; failing at construction makes the misconfiguration obvious. - -The token endpoint automatically uses the `mtls.{domain}` host when `useMTLS` is enabled. - -```ts -// v7: throws at construction if `fetch` is omitted -const mgmt = new ManagementClient({ - domain, - clientId, - clientSecret, - useMTLS: true, - fetch: mtlsCapableFetch, // now required -}); -``` - -### mTLS works with both client secret and client assertion - -`useMTLS` works with both `clientSecret` and `clientAssertionSigningKey`. mTLS (RFC 8705) is a transport-layer concern: the TLS client certificate yields a certificate-bound token regardless of which client authentication method is used. An explicit `fetch` option is always required when `useMTLS` is set. - -### `domain` must be a bare hostname - -`domain` must be a bare host such as `tenant.us.auth0.com`. A value containing a scheme, slashes, or a query string now throws at construction instead of producing malformed request URLs later. - -```ts -// throws in v7 -new ManagementClient({ domain: "https://tenant.us.auth0.com/", ... }); -// correct -new ManagementClient({ domain: "tenant.us.auth0.com", ... }); -``` - -### Token acquisition failures throw `ManagementError` - -When the internal client-credentials token request fails, the client now throws a `ManagementError` (previously a plain `Error`). The error carries `statusCode` and a parsed `body` with the OAuth error details. A request that exceeds the 10-second timeout throws `ManagementError` with status `408`. - -```ts -import { ManagementError } from "auth0"; - -try { - await mgmt.users.getAll(); -} catch (e) { - if (e instanceof ManagementError) { - console.error(e.statusCode, e.body); - } -} -``` - -### `uuid` dependency removed - -The `uuid` package is no longer a dependency. If your project imported `uuid` transitively through `auth0`, add it to your own `dependencies`. - -## Migrating authentication code - -If your app calls `AuthenticationClient` or `UserInfoClient`, follow the dedicated [Authentication Migration Guide](https://github.com/auth0/node-auth0/tree/master/auth-migration). Start with [`auth-migration/index.md`](https://github.com/auth0/node-auth0/blob/master/auth-migration/index.md) for the OIDC token grants section; the incremental flow, session, and troubleshooting pages live in the same [`auth-migration/`](https://github.com/auth0/node-auth0/tree/master/auth-migration) directory. It covers: - -- Choosing between `@auth0/auth0-auth-js` (stateless token grants) and `@auth0/auth0-server-js` (server-managed sessions). -- The complete method-by-method API mapping for `.oauth`, `.database`, `.passwordless`, `.backchannel`, `.tokenExchange`, and `UserInfoClient`. -- The four cross-cutting behavior changes: return shape (envelope dropped), casing (snake_case → camelCase), token expiry (`expires_in` relative → `expiresAt` absolute, a silent high-risk change), and the typed error model with `isMfaRequiredError()`. -- Wiring the `auth0-server-js` session lifecycle when you want the SDK to own login, cookies, refresh, and logout. - -The Management API is explicitly out of scope in that guide: a file that keeps using `ManagementClient` from `auth0` while importing `@auth0/auth0-auth-js` for authentication is correct and expected. - -## Staying on the legacy entrypoint - -If you cannot migrate the authentication code immediately, the `auth0/legacy` entrypoint still ships `AuthenticationClient` and `UserInfoClient` at their v4.x configuration format and method signatures. This is a stopgap, not a destination; the legacy shapes differ from the current API and will not receive new features. - -```ts -import { AuthenticationClient } from "auth0/legacy"; -``` - -Plan the move to `@auth0/auth0-auth-js` / `@auth0/auth0-server-js` rather than treating the legacy entrypoint as permanent. diff --git a/yarn.lock b/yarn.lock index 76a3eebcab..91c7ee2157 100644 --- a/yarn.lock +++ b/yarn.lock @@ -284,6 +284,11 @@ dependencies: statuses "^2.0.1" +"@dual-bundle/import-meta-resolve@^4.2.1": + version "4.2.1" + resolved "https://registry.yarnpkg.com/@dual-bundle/import-meta-resolve/-/import-meta-resolve-4.2.1.tgz#cd0b25b3808cd9e684cd6cd549bbf8e1dcf05ee7" + integrity sha512-id+7YRUgoUX6CgV0DtuhirQWodeeA7Lf4i2x71JS/vtA5pRb/hIGWlw+G6MeXvsM+MXrz0VAydTGElX1rAfgPg== + "@eslint-community/eslint-utils@^4.8.0", "@eslint-community/eslint-utils@^4.9.1": version "4.10.1" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz#8911bd72b2c3640a543609e0400b8c4d2e7e7cb6" @@ -1385,9 +1390,9 @@ balanced-match@^4.0.2: integrity sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA== baseline-browser-mapping@^2.11.26: - version "2.11.28" - resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.11.28.tgz#784efec0fa3965c28a0bbb755f40604ace1c9db0" - integrity sha512-br0LOmjJqr6Rt4AEkadbcNf67Zpo7EPwKsWbjnRrJIa1QYFHQBqM4C7F2WTbV8ahTEcg1Eo+Y0aWjjORInYFyA== + version "2.11.29" + resolved "https://registry.yarnpkg.com/baseline-browser-mapping/-/baseline-browser-mapping-2.11.29.tgz#dbed0ed2c17943aa4427863c91300865d9d8ca23" + integrity sha512-YeesxhUmR4h5y5V8KF8iBCqJb8YFrBJ++XBTeGcWIaQOYXGN19JM0FoiOjAhwuDoln8owMgXcWBmgHtYSkky2w== brace-expansion@^1.1.7: version "1.1.21" @@ -1465,9 +1470,9 @@ camelcase@^6.2.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001813: - version "1.0.30001815" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001815.tgz#7cf8faa82c998b06873a113e9d3d9544f2022ac0" - integrity sha512-uDybUEyfgbyJJ93J1vikTylBX31AkdVYeVPeffMQpf8XN7hSfr0oZOn4VFOIMNvtU5+rHvC5Udg2TgtJKHm23Q== + version "1.0.30001816" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001816.tgz#80567cffb179fd8a1702816bc80de8efc9784021" + integrity sha512-+8Yx7BXCoqk6IF8yTicjfUR6D/ldJzdlsodlEOiOSPmhK844WIgk67/zIQaGAOxNkZyyvBlrRFnLvqKIoqbAFw== chalk@^4.0.0, chalk@^4.1.0: version "4.1.2" @@ -1692,9 +1697,9 @@ dunder-proto@^1.0.1: gopd "^1.2.0" electron-to-chromium@^1.5.439: - version "1.5.453" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.453.tgz#6b0c7e9e659a6f537c185973319859f6514d5e9b" - integrity sha512-9r/nz9akllr3SZsHUhfK10ktUH6j0Dbo3cKdh91khw0FvR6HhXGnATmOq5X8ena2aq4GXLQ1koh3nvKaQJaNmQ== + version "1.5.458" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.458.tgz#fdc608c8ee26eeb4fa20b3447378c6c83a806a76" + integrity sha512-/hIH2gRSmxrf4/X4Nw/t/Wc8PVS22l8/3HnWjWTWsTOM5dsnMUPZF/+u+yr3LqweNuTBJE1rq6qAQzKkZVwMfA== emittery@^0.13.1: version "0.13.1" @@ -1711,7 +1716,7 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== -enhanced-resolve@^5.25.0: +enhanced-resolve@^5.26.0: version "5.26.0" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.26.0.tgz#9dfb47d050ed6c87f2c6d43b4d7e30f8c0a91ed7" integrity sha512-9vhedylFonb2YGogzUKX6+Ja72gOJbN1QHAqdrvqLwhdl/QWbKopzoUC9EbQNVsAns/bx/4uyqalrQAoy1IByw== @@ -1805,12 +1810,12 @@ eslint-config-prettier@^10.1.8: integrity sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w== eslint-plugin-prettier@^5.5.3: - version "5.5.6" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.6.tgz#363ebe4d769bce157ccdd8129ce3efd91dc62564" - integrity sha512-ifetmTcxWfz+4qRW3pH/ujdTq2jQIj59AxJMIN26K5avYgU8dxycUETQonWiW+wPrYXA0j3Try0l1CnwVQtDqQ== + version "5.5.7" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.7.tgz#ebef3acc2d664333b1356b717780198abc635398" + integrity sha512-WjHyn3GrFd+ZR0rzsLiM4zJZ35PZMOE0SUIxzGmnWNG0126yNfJKJzObmmkYDwHJfGlkz3PSlzyG9ez/LJntwg== dependencies: prettier-linter-helpers "^1.0.1" - synckit "^0.11.13" + synckit "^0.12.3" eslint-scope@^8.4.0: version "8.4.0" @@ -2148,7 +2153,7 @@ graphql@^16.8.1: resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.14.2.tgz#83faf25869e3df727cc855161db5da85b0e5b2c0" integrity sha512-Chq1s4CY7jmh8gO2qvLIJyfCDIN+EHLFW/9iShnp1z8FjBQMoodWP1kDC36VAMXXIvAjj4ARa7ntfAV2BrjsbA== -handlebars@^4.7.9: +handlebars@^4.7.10: version "4.7.10" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.10.tgz#12419ea1b41391b3ffcf003f2164dcbce090c417" integrity sha512-P5VJMVM7qgBn6vjXMw8WG9uVI+ncf2pi72j4de4yz5ZULLj2RGqLYaKOYGsgyrViQ0tePOVlN1tDCCXXtFqXKg== @@ -3009,9 +3014,9 @@ makeerror@1.0.12: tmpl "1.0.5" markdown-it@^14.3.0: - version "14.3.2" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.3.2.tgz#eb41b5855120836603c33c1be4c92f58001f8a26" - integrity sha512-sHHjZ5fJKlgrG4qns2YwVcdNep35h5fERrfkD2YNsb9UFk0UIHarbiTaHKVMlPuWAoiilyK8Fv/jAm11slsY7Q== + version "14.3.3" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-14.3.3.tgz#15e6e145d20b1499a7b323bb14e21062690132d8" + integrity sha512-L//tDAkjTjJCU6pBUSBTgs3Kg4InVaZuUZog/b6V12UKhcDQ7S78877ibbCanRExwPuYP1CZD7Gd2dxSy1GXRg== dependencies: argparse "^2.0.1" entities "^4.5.0" @@ -3089,7 +3094,7 @@ minimist@^1.2.8: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== -minimizer-webpack-plugin@^5.7.0: +minimizer-webpack-plugin@^5.13.0: version "5.13.0" resolved "https://registry.yarnpkg.com/minimizer-webpack-plugin/-/minimizer-webpack-plugin-5.13.0.tgz#3624cd9556b0645aceed66f5e7466586d0635ebe" integrity sha512-OO1NF2zHj6sf4CNv2AsUWYcS8WEwkVKQDXxxKzlOxx1Xl+WlqYtVC+oNlGNwGkLAOnpj277BSHypWwRtd9w4JQ== @@ -3164,9 +3169,9 @@ node-int64@^0.4.0: integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== node-releases@^2.0.57: - version "2.0.58" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.58.tgz#bc58566945248a28a1d4ba2a7deeee0a71a73fad" - integrity sha512-BdiKAgbfRlvfMq/XzO/AF9NPmaA8a+YpLAyAFTVFBj3gARrAIfWvNq7Q7NE4se3KgFu0KkrvQMxTS0XVnsGzHg== + version "2.0.59" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.59.tgz#172a7e253e3cca1ae00e8015a82b54e7fcc68fd3" + integrity sha512-5qr2okC4ItAI0hG5SaV0HoYMpnM/Y6+Oqr7AmPYy/2uEoGvS+GbSKLeRxSS1uAdu59yz0ouzcuXievSgg///WA== normalize-path@^3.0.0: version "3.0.0" @@ -3710,11 +3715,12 @@ symbol-tree@^3.2.4: resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" integrity sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw== -synckit@^0.11.13: - version "0.11.13" - resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.11.13.tgz#062a5ea57d81befc35892f8254de5c567e97c80a" - integrity sha512-eNRKgb3z66Yp3D2CixVujOUvXLFUTij/zVnV8KRyvFdQwpz7I5DS8UfRkTeLzb64u+dkzDSdelE24izu+zSSUg== +synckit@^0.12.3: + version "0.12.3" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.12.3.tgz#6e30a3441d095ed04c311077350ce205465512d6" + integrity sha512-U+/AXT6LWsxnj2vz9HeUuPWBNgdWxjyIEjEPdbJARC9txmgPzo2VEdqnFo4hHaNyMPtycyVJrSaQYeQv/PoyyA== dependencies: + "@dual-bundle/import-meta-resolve" "^4.2.1" "@pkgr/core" "^0.3.6" tapable@^2.3.0, tapable@^2.3.3: @@ -3808,13 +3814,13 @@ ts-api-utils@^2.5.0: integrity sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA== ts-jest@^29.3.4: - version "29.4.14" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.4.14.tgz#cb36c043df0fada861c8b604a5d514f953126180" - integrity sha512-+943G6wCX5E3VpzTQhBGBFntCmdT+QAkTvUlp03edTONFBvqskuXPhpyX16xdUotO4P5HQKyppldSWjocoltLQ== + version "29.4.15" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.4.15.tgz#238f2d495066a33ca973a54a36a5ef228262a9ad" + integrity sha512-s2qmEUYFRqbjz1wv0EmccNPVOb45HOFpFuhzQJLKShYVisuTbCFPIIAIV2EuK5rIxb4BejLDbH7dnBZfYjybUQ== dependencies: bs-logger "^0.2.6" fast-json-stable-stringify "^2.1.0" - handlebars "^4.7.9" + handlebars "^4.7.10" json5 "^2.2.3" lodash.memoize "^4.1.2" make-error "^1.3.6" @@ -3885,9 +3891,9 @@ uglify-js@^3.1.4: integrity sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ== undici-types@^6.15.0: - version "6.29.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.29.0.tgz#0d27a99a7d6ebdb87ffa891f6f7096804556516e" - integrity sha512-yzE4aF6qGj7fE8lu8fE8LonY07kmMXs20QR1bG3JGJ+jXrVTLtgUBieEr74AQRChYyqHrhJm9IktT337qOQhng== + version "6.29.1" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.29.1.tgz#4076643b12c49e26caabceea9a72f6d4b37d1864" + integrity sha512-8ewZRMhr1pEZVOUITV/cBrtH8iz6juS76jNqam5zXA1LQuTjM5CcidoAEIp8u+3OJc7EWKfMhW7CBD2xJJVh4A== undici-types@~6.21.0: version "6.21.0" @@ -3900,9 +3906,9 @@ undici-types@~8.9.0: integrity sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg== undici@^7.12.0: - version "7.30.0" - resolved "https://registry.yarnpkg.com/undici/-/undici-7.30.0.tgz#64a947266eb7e21dbeac8b99f8720feef308bbe0" - integrity sha512-dkrQXeHSaoamnItlYbmzG0wFYrM0ZwDxCIg0A7aKjTyyhh9svRzCNFEzV+Vm05/yehjCzjDZ31KXfGEjYSztDQ== + version "7.30.1" + resolved "https://registry.yarnpkg.com/undici/-/undici-7.30.1.tgz#360b3de104b94abc52729aa1a4a07e027aa71f73" + integrity sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg== universalify@^0.2.0: version "0.2.0" @@ -3960,10 +3966,10 @@ walker@^1.0.8: dependencies: makeerror "1.0.12" -watchpack@^2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.5.2.tgz#e12e82d84674266fc1c6dbfe38891b92ff0522ec" - integrity sha512-6i/00NBjP4yGPs+caKSyRfpTF/8Torsu0MOW3mMzIbhgISFder8i7xbqgHlLMwJrdiN8ndBV3UA1/AfzPSr+jg== +watchpack@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.6.1.tgz#fda5ef91ab74cdba7e9105e0bd2b03268b6818aa" + integrity sha512-8mk/LnXpQAiM2xKZhTkxikwly5GhL2Z+DWiLTkMa/E1Nfv9zURhHgiFyWvM4BWqW+LjIgL2AIS7JntEUx6v3vQ== dependencies: graceful-fs "^4.1.2" @@ -3972,15 +3978,15 @@ webidl-conversions@^7.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a" integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== -webpack-sources@^3.5.1: +webpack-sources@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.6.0.tgz#b2e4a4f1aef1a0d60f3011eb47736c5bf7f1ed7f" integrity sha512-EIMmPVvNI0CYXyRPp34F2Qk7W37/BZVZIofS6LAUnrNjCVahS+hO4mxwFJDjQjODTGZDtVzLYoN2+1dYkhk9qA== webpack@^5.105.4: - version "5.111.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.111.1.tgz#7c12cd014fbb9bfd8509a6cfc6f1c79f4e06cade" - integrity sha512-cNypaz0RP+S4cvQVi1M/3bRUkvNP0xZpL0TjFx+c6jg64VbxD+2weWDgY9UnjRI6dhZgtaj8DU76GGFcJ79xPQ== + version "5.112.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.112.0.tgz#e8710dcc0329ef076bd3b5c3bd6cf78e971c009a" + integrity sha512-NIBpsRuCll036haDDt/CfcTDfsWNR9Z782nMRMI9D377BsGcYzZDTNU5TyzhCJzPIcihAxMBaMAhq2WSaDrH8Q== dependencies: "@types/estree" "^1.0.8" "@types/json-schema" "^7.0.15" @@ -3989,16 +3995,16 @@ webpack@^5.105.4: "@webassemblyjs/wasm-parser" "^1.14.1" browserslist "^4.28.1" chrome-trace-event "^1.0.2" - enhanced-resolve "^5.25.0" + enhanced-resolve "^5.26.0" es-module-lexer "^2.1.0" events "^3.2.0" graceful-fs "^4.2.11" mime-db "^1.54.0" - minimizer-webpack-plugin "^5.7.0" + minimizer-webpack-plugin "^5.13.0" schema-utils "^4.5.0" tapable "^2.3.0" - watchpack "^2.5.2" - webpack-sources "^3.5.1" + watchpack "^2.6.1" + webpack-sources "^3.6.0" whatwg-encoding@^2.0.0: version "2.0.0" From ef4ae50a4c503f2898a530d4f7f901974cc1e5d8 Mon Sep 17 00:00:00 2001 From: "fern-api[bot]" <115122769+fern-api[bot]@users.noreply.github.com> Date: Fri, 16 Oct 2026 15:21:14 +0000 Subject: [PATCH 2/3] [fern-replay] Applied customizations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patches applied (5): - patch-066ff9e0: docs: add v6 migration guide for breaking changes in v6.0.0 (#1368) - patch-d8faf7a2: docs: update v6 migration guide with federatedConnectionsTokensets and federated_connections_access_tokens breaking changes (#1370) - patch-0f7baa6f: fix: auto-stamp SDK_VERSION from package.json during build (#1382) - patch-b942f5d6: docs: add Authentication API migration guide (auth0-auth-js / auth0-server-js) (#1395) - patch-842d2f51: docs: add v7 migration guide (v6 → v7) (#1396) Patches with unresolved conflicts (11): - patch-490e5634: feat(management): add sub-package exports and management auth helper (#1373) - patch-74170bb0: Release v6.1.0 (#1381) - patch-4fcb39a4: Release v6.2.0 (#1389) - patch-f9d64134: Release v6.3.0 (#1393) - patch-4d450aa4: Release v6.4.0 (#1401) - patch-d4614ec0: Release v7.0.0 (#1402) - patch-e1e90b89: Release v7.1.0 (#1405) - patch-567042f4: Release v7.2.0 (#1409) - patch-de9f20d2: Release v7.3.0 (#1415) - patch-7750e996: Release v7.4.0 (#1424) - patch-f9566e21: Release v7.5.0 (#1427) Run `fern-replay resolve` to apply these customizations. --- .fern/replay.lock | 1918 +++++++++++++++++++++++- .shiprc | 6 + AUTH_MIGRATION_GUIDE.md | 14 + auth-migration/authentication-flows.md | 234 +++ auth-migration/index.md | 732 +++++++++ auth-migration/server-side-sessions.md | 163 ++ auth-migration/troubleshooting.md | 32 + v6_MIGRATION_GUIDE.md | 158 ++ v7_MIGRATION_GUIDE.md | 146 ++ 9 files changed, 3397 insertions(+), 6 deletions(-) create mode 100644 .shiprc create mode 100644 AUTH_MIGRATION_GUIDE.md create mode 100644 auth-migration/authentication-flows.md create mode 100644 auth-migration/index.md create mode 100644 auth-migration/server-side-sessions.md create mode 100644 auth-migration/troubleshooting.md create mode 100644 v6_MIGRATION_GUIDE.md create mode 100644 v7_MIGRATION_GUIDE.md diff --git a/.fern/replay.lock b/.fern/replay.lock index 2b4eb4a78f..111a822fa1 100644 --- a/.fern/replay.lock +++ b/.fern/replay.lock @@ -66,14 +66,20 @@ generations: cli_version: unknown generator_versions: fernapi/fern-typescript-sdk: 3.72.5 -current_generation: 7144e91fbd0e642fd5ba5b5fb5de21e4e4db3ab2 + - commit_sha: 4f367ef3d7e2a5746f847006bc4e646c8b5b27cf + tree_hash: 991d0ccbf9e0c1d1ac227d03319e5a054efcc82f + timestamp: 2026-10-16T15:20:50.607Z + cli_version: unknown + generator_versions: + fernapi/fern-typescript-sdk: 3.107.1 +current_generation: 4f367ef3d7e2a5746f847006bc4e646c8b5b27cf patches: - id: patch-066ff9e0 content_hash: sha256:5b87ec9a63fc57aba4840d0d335d472c621e838fc1d61515b30660df39d0dbc2 original_commit: 066ff9e02c45f4abf46791a3f070c762f7ecd924 original_message: "docs: add v6 migration guide for breaking changes in v6.0.0 (#1368)" original_author: Ankita Tripathi <51994119+ankita10119@users.noreply.github.com> - base_generation: 7144e91fbd0e642fd5ba5b5fb5de21e4e4db3ab2 + base_generation: 4f367ef3d7e2a5746f847006bc4e646c8b5b27cf files: - v6_MIGRATION_GUIDE.md patch_content: | @@ -407,7 +413,7 @@ patches: original_commit: d8faf7a21efbed3bd75a0f36ff0d190bb9dd986b original_message: "docs: update v6 migration guide with federatedConnectionsTokensets and federated_connections_access_tokens breaking changes (#1370)" original_author: Ankita Tripathi <51994119+ankita10119@users.noreply.github.com> - base_generation: 7144e91fbd0e642fd5ba5b5fb5de21e4e4db3ab2 + base_generation: 4f367ef3d7e2a5746f847006bc4e646c8b5b27cf files: - v6_MIGRATION_GUIDE.md patch_content: | @@ -8249,7 +8255,7 @@ patches: original_commit: 0f7baa6fa58a2944cd9e39abbfd8caf7be8d7e8c original_message: "fix: auto-stamp SDK_VERSION from package.json during build (#1382)" original_author: Ankita Tripathi <51994119+ankita10119@users.noreply.github.com> - base_generation: 7144e91fbd0e642fd5ba5b5fb5de21e4e4db3ab2 + base_generation: 4f367ef3d7e2a5746f847006bc4e646c8b5b27cf files: - .shiprc patch_content: | @@ -13726,7 +13732,7 @@ patches: original_commit: b942f5d6b1b5f3e565f3315f12421c58ae005bec original_message: "docs: add Authentication API migration guide (auth0-auth-js / auth0-server-js) (#1395)" original_author: tusharpandey13 - base_generation: 7144e91fbd0e642fd5ba5b5fb5de21e4e4db3ab2 + base_generation: 4f367ef3d7e2a5746f847006bc4e646c8b5b27cf files: - AUTH_MIGRATION_GUIDE.md - auth-migration/authentication-flows.md @@ -16126,7 +16132,7 @@ patches: original_commit: 842d2f5189493b78e420c17c968c80bc239e143a original_message: "docs: add v7 migration guide (v6 → v7) (#1396)" original_author: tusharpandey13 - base_generation: 7144e91fbd0e642fd5ba5b5fb5de21e4e4db3ab2 + base_generation: 4f367ef3d7e2a5746f847006bc4e646c8b5b27cf files: - v7_MIGRATION_GUIDE.md patch_content: | @@ -25732,3 +25738,1903 @@ patches: src/management/version.ts: | export const SDK_VERSION = "7.4.0"; status: unresolved + - id: patch-f9566e21 + content_hash: sha256:3359546288f8178f80696587c90c4064dbf9a318de4ed55374d77fbdd645a82d + original_commit: f9566e218363f1a46bdfd62fdd947f08272e7537 + original_message: Release v7.5.0 (#1427) + original_author: Ankita Tripathi <51994119+ankita10119@users.noreply.github.com> + base_generation: 0b3c8a4f22d3c758112a0aca732d20beba54c601 + files: + - package.json + - src/management/version.ts + patch_content: | + diff --git a/package.json b/package.json + index acea6f27f2..c456e8ca17 100644 + --- a/package.json + +++ b/package.json + @@ -1,6 +1,6 @@ + { + "name": "auth0", + - "version": "7.4.0", + + "version": "7.5.0", + "private": false, + "repository": { + "type": "git", + diff --git a/src/management/version.ts b/src/management/version.ts + index ccd206f972..6a5cc9fe4a 100644 + --- a/src/management/version.ts + +++ b/src/management/version.ts + @@ -1 +1 @@ + -export const SDK_VERSION = "7.4.0"; + +export const SDK_VERSION = "7.5.0"; + theirs_snapshot: + package.json: | + { + "name": "auth0", + "version": "7.5.0", + "private": false, + "repository": { + "type": "git", + "url": "git+https://github.com/auth0/node-auth0.git" + }, + "license": "MIT", + "type": "commonjs", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.mjs", + "types": "./dist/cjs/index.d.ts", + "exports": { + ".": { + "import": { + "types": "./dist/esm/index.d.mts", + "default": "./dist/esm/index.mjs" + }, + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "default": "./dist/cjs/index.js" + }, + "./actions": { + "import": { + "types": "./dist/esm/management/api/resources/actions/exports.d.mts", + "default": "./dist/esm/management/api/resources/actions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/actions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/actions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/actions/exports.js" + }, + "./agents": { + "import": { + "types": "./dist/esm/management/api/resources/agents/exports.d.mts", + "default": "./dist/esm/management/api/resources/agents/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/agents/exports.d.ts", + "default": "./dist/cjs/management/api/resources/agents/exports.js" + }, + "default": "./dist/cjs/management/api/resources/agents/exports.js" + }, + "./branding": { + "import": { + "types": "./dist/esm/management/api/resources/branding/exports.d.mts", + "default": "./dist/esm/management/api/resources/branding/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/branding/exports.d.ts", + "default": "./dist/cjs/management/api/resources/branding/exports.js" + }, + "default": "./dist/cjs/management/api/resources/branding/exports.js" + }, + "./clientGrants": { + "import": { + "types": "./dist/esm/management/api/resources/clientGrants/exports.d.mts", + "default": "./dist/esm/management/api/resources/clientGrants/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/clientGrants/exports.d.ts", + "default": "./dist/cjs/management/api/resources/clientGrants/exports.js" + }, + "default": "./dist/cjs/management/api/resources/clientGrants/exports.js" + }, + "./clientProfiles": { + "import": { + "types": "./dist/esm/management/api/resources/clientProfiles/exports.d.mts", + "default": "./dist/esm/management/api/resources/clientProfiles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/clientProfiles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/clientProfiles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/clientProfiles/exports.js" + }, + "./clients": { + "import": { + "types": "./dist/esm/management/api/resources/clients/exports.d.mts", + "default": "./dist/esm/management/api/resources/clients/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/clients/exports.d.ts", + "default": "./dist/cjs/management/api/resources/clients/exports.js" + }, + "default": "./dist/cjs/management/api/resources/clients/exports.js" + }, + "./connectionProfiles": { + "import": { + "types": "./dist/esm/management/api/resources/connectionProfiles/exports.d.mts", + "default": "./dist/esm/management/api/resources/connectionProfiles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connectionProfiles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connectionProfiles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connectionProfiles/exports.js" + }, + "./connections": { + "import": { + "types": "./dist/esm/management/api/resources/connections/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/exports.js" + }, + "./customDomains": { + "import": { + "types": "./dist/esm/management/api/resources/customDomains/exports.d.mts", + "default": "./dist/esm/management/api/resources/customDomains/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/customDomains/exports.d.ts", + "default": "./dist/cjs/management/api/resources/customDomains/exports.js" + }, + "default": "./dist/cjs/management/api/resources/customDomains/exports.js" + }, + "./deviceCredentials": { + "import": { + "types": "./dist/esm/management/api/resources/deviceCredentials/exports.d.mts", + "default": "./dist/esm/management/api/resources/deviceCredentials/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/deviceCredentials/exports.d.ts", + "default": "./dist/cjs/management/api/resources/deviceCredentials/exports.js" + }, + "default": "./dist/cjs/management/api/resources/deviceCredentials/exports.js" + }, + "./emailTemplates": { + "import": { + "types": "./dist/esm/management/api/resources/emailTemplates/exports.d.mts", + "default": "./dist/esm/management/api/resources/emailTemplates/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/emailTemplates/exports.d.ts", + "default": "./dist/cjs/management/api/resources/emailTemplates/exports.js" + }, + "default": "./dist/cjs/management/api/resources/emailTemplates/exports.js" + }, + "./eventStreams": { + "import": { + "types": "./dist/esm/management/api/resources/eventStreams/exports.d.mts", + "default": "./dist/esm/management/api/resources/eventStreams/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/eventStreams/exports.d.ts", + "default": "./dist/cjs/management/api/resources/eventStreams/exports.js" + }, + "default": "./dist/cjs/management/api/resources/eventStreams/exports.js" + }, + "./events": { + "import": { + "types": "./dist/esm/management/api/resources/events/exports.d.mts", + "default": "./dist/esm/management/api/resources/events/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/events/exports.d.ts", + "default": "./dist/cjs/management/api/resources/events/exports.js" + }, + "default": "./dist/cjs/management/api/resources/events/exports.js" + }, + "./flows": { + "import": { + "types": "./dist/esm/management/api/resources/flows/exports.d.mts", + "default": "./dist/esm/management/api/resources/flows/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/flows/exports.d.ts", + "default": "./dist/cjs/management/api/resources/flows/exports.js" + }, + "default": "./dist/cjs/management/api/resources/flows/exports.js" + }, + "./forms": { + "import": { + "types": "./dist/esm/management/api/resources/forms/exports.d.mts", + "default": "./dist/esm/management/api/resources/forms/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/forms/exports.d.ts", + "default": "./dist/cjs/management/api/resources/forms/exports.js" + }, + "default": "./dist/cjs/management/api/resources/forms/exports.js" + }, + "./userGrants": { + "import": { + "types": "./dist/esm/management/api/resources/userGrants/exports.d.mts", + "default": "./dist/esm/management/api/resources/userGrants/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/userGrants/exports.d.ts", + "default": "./dist/cjs/management/api/resources/userGrants/exports.js" + }, + "default": "./dist/cjs/management/api/resources/userGrants/exports.js" + }, + "./groups": { + "import": { + "types": "./dist/esm/management/api/resources/groups/exports.d.mts", + "default": "./dist/esm/management/api/resources/groups/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/groups/exports.d.ts", + "default": "./dist/cjs/management/api/resources/groups/exports.js" + }, + "default": "./dist/cjs/management/api/resources/groups/exports.js" + }, + "./guardian": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/exports.js" + }, + "./hooks": { + "import": { + "types": "./dist/esm/management/api/resources/hooks/exports.d.mts", + "default": "./dist/esm/management/api/resources/hooks/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/hooks/exports.d.ts", + "default": "./dist/cjs/management/api/resources/hooks/exports.js" + }, + "default": "./dist/cjs/management/api/resources/hooks/exports.js" + }, + "./jobs": { + "import": { + "types": "./dist/esm/management/api/resources/jobs/exports.d.mts", + "default": "./dist/esm/management/api/resources/jobs/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/jobs/exports.d.ts", + "default": "./dist/cjs/management/api/resources/jobs/exports.js" + }, + "default": "./dist/cjs/management/api/resources/jobs/exports.js" + }, + "./logStreams": { + "import": { + "types": "./dist/esm/management/api/resources/logStreams/exports.d.mts", + "default": "./dist/esm/management/api/resources/logStreams/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/logStreams/exports.d.ts", + "default": "./dist/cjs/management/api/resources/logStreams/exports.js" + }, + "default": "./dist/cjs/management/api/resources/logStreams/exports.js" + }, + "./logs": { + "import": { + "types": "./dist/esm/management/api/resources/logs/exports.d.mts", + "default": "./dist/esm/management/api/resources/logs/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/logs/exports.d.ts", + "default": "./dist/cjs/management/api/resources/logs/exports.js" + }, + "default": "./dist/cjs/management/api/resources/logs/exports.js" + }, + "./networkAcls": { + "import": { + "types": "./dist/esm/management/api/resources/networkAcls/exports.d.mts", + "default": "./dist/esm/management/api/resources/networkAcls/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/networkAcls/exports.d.ts", + "default": "./dist/cjs/management/api/resources/networkAcls/exports.js" + }, + "default": "./dist/cjs/management/api/resources/networkAcls/exports.js" + }, + "./organizations": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/exports.js" + }, + "./prompts": { + "import": { + "types": "./dist/esm/management/api/resources/prompts/exports.d.mts", + "default": "./dist/esm/management/api/resources/prompts/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/prompts/exports.d.ts", + "default": "./dist/cjs/management/api/resources/prompts/exports.js" + }, + "default": "./dist/cjs/management/api/resources/prompts/exports.js" + }, + "./rateLimitPolicies": { + "import": { + "types": "./dist/esm/management/api/resources/rateLimitPolicies/exports.d.mts", + "default": "./dist/esm/management/api/resources/rateLimitPolicies/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/rateLimitPolicies/exports.d.ts", + "default": "./dist/cjs/management/api/resources/rateLimitPolicies/exports.js" + }, + "default": "./dist/cjs/management/api/resources/rateLimitPolicies/exports.js" + }, + "./refreshTokens": { + "import": { + "types": "./dist/esm/management/api/resources/refreshTokens/exports.d.mts", + "default": "./dist/esm/management/api/resources/refreshTokens/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/refreshTokens/exports.d.ts", + "default": "./dist/cjs/management/api/resources/refreshTokens/exports.js" + }, + "default": "./dist/cjs/management/api/resources/refreshTokens/exports.js" + }, + "./resourceServers": { + "import": { + "types": "./dist/esm/management/api/resources/resourceServers/exports.d.mts", + "default": "./dist/esm/management/api/resources/resourceServers/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/resourceServers/exports.d.ts", + "default": "./dist/cjs/management/api/resources/resourceServers/exports.js" + }, + "default": "./dist/cjs/management/api/resources/resourceServers/exports.js" + }, + "./roles": { + "import": { + "types": "./dist/esm/management/api/resources/roles/exports.d.mts", + "default": "./dist/esm/management/api/resources/roles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/roles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/roles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/roles/exports.js" + }, + "./rules": { + "import": { + "types": "./dist/esm/management/api/resources/rules/exports.d.mts", + "default": "./dist/esm/management/api/resources/rules/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/rules/exports.d.ts", + "default": "./dist/cjs/management/api/resources/rules/exports.js" + }, + "default": "./dist/cjs/management/api/resources/rules/exports.js" + }, + "./rulesConfigs": { + "import": { + "types": "./dist/esm/management/api/resources/rulesConfigs/exports.d.mts", + "default": "./dist/esm/management/api/resources/rulesConfigs/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/rulesConfigs/exports.d.ts", + "default": "./dist/cjs/management/api/resources/rulesConfigs/exports.js" + }, + "default": "./dist/cjs/management/api/resources/rulesConfigs/exports.js" + }, + "./selfServiceProfiles": { + "import": { + "types": "./dist/esm/management/api/resources/selfServiceProfiles/exports.d.mts", + "default": "./dist/esm/management/api/resources/selfServiceProfiles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/selfServiceProfiles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/selfServiceProfiles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/selfServiceProfiles/exports.js" + }, + "./sessions": { + "import": { + "types": "./dist/esm/management/api/resources/sessions/exports.d.mts", + "default": "./dist/esm/management/api/resources/sessions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/sessions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/sessions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/sessions/exports.js" + }, + "./stats": { + "import": { + "types": "./dist/esm/management/api/resources/stats/exports.d.mts", + "default": "./dist/esm/management/api/resources/stats/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/stats/exports.d.ts", + "default": "./dist/cjs/management/api/resources/stats/exports.js" + }, + "default": "./dist/cjs/management/api/resources/stats/exports.js" + }, + "./supplementalSignals": { + "import": { + "types": "./dist/esm/management/api/resources/supplementalSignals/exports.d.mts", + "default": "./dist/esm/management/api/resources/supplementalSignals/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/supplementalSignals/exports.d.ts", + "default": "./dist/cjs/management/api/resources/supplementalSignals/exports.js" + }, + "default": "./dist/cjs/management/api/resources/supplementalSignals/exports.js" + }, + "./tickets": { + "import": { + "types": "./dist/esm/management/api/resources/tickets/exports.d.mts", + "default": "./dist/esm/management/api/resources/tickets/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/tickets/exports.d.ts", + "default": "./dist/cjs/management/api/resources/tickets/exports.js" + }, + "default": "./dist/cjs/management/api/resources/tickets/exports.js" + }, + "./tokenExchangeProfiles": { + "import": { + "types": "./dist/esm/management/api/resources/tokenExchangeProfiles/exports.d.mts", + "default": "./dist/esm/management/api/resources/tokenExchangeProfiles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/tokenExchangeProfiles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/tokenExchangeProfiles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/tokenExchangeProfiles/exports.js" + }, + "./userAttributeProfiles": { + "import": { + "types": "./dist/esm/management/api/resources/userAttributeProfiles/exports.d.mts", + "default": "./dist/esm/management/api/resources/userAttributeProfiles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/userAttributeProfiles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/userAttributeProfiles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/userAttributeProfiles/exports.js" + }, + "./userBlocks": { + "import": { + "types": "./dist/esm/management/api/resources/userBlocks/exports.d.mts", + "default": "./dist/esm/management/api/resources/userBlocks/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/userBlocks/exports.d.ts", + "default": "./dist/cjs/management/api/resources/userBlocks/exports.js" + }, + "default": "./dist/cjs/management/api/resources/userBlocks/exports.js" + }, + "./users": { + "import": { + "types": "./dist/esm/management/api/resources/users/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/exports.js" + }, + "./actions/versions": { + "import": { + "types": "./dist/esm/management/api/resources/actions/resources/versions/exports.d.mts", + "default": "./dist/esm/management/api/resources/actions/resources/versions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/actions/resources/versions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/actions/resources/versions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/actions/resources/versions/exports.js" + }, + "./actions/executions": { + "import": { + "types": "./dist/esm/management/api/resources/actions/resources/executions/exports.d.mts", + "default": "./dist/esm/management/api/resources/actions/resources/executions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/actions/resources/executions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/actions/resources/executions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/actions/resources/executions/exports.js" + }, + "./actions/modules": { + "import": { + "types": "./dist/esm/management/api/resources/actions/resources/modules/exports.d.mts", + "default": "./dist/esm/management/api/resources/actions/resources/modules/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/actions/resources/modules/exports.d.ts", + "default": "./dist/cjs/management/api/resources/actions/resources/modules/exports.js" + }, + "default": "./dist/cjs/management/api/resources/actions/resources/modules/exports.js" + }, + "./actions/triggers": { + "import": { + "types": "./dist/esm/management/api/resources/actions/resources/triggers/exports.d.mts", + "default": "./dist/esm/management/api/resources/actions/resources/triggers/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/actions/resources/triggers/exports.d.ts", + "default": "./dist/cjs/management/api/resources/actions/resources/triggers/exports.js" + }, + "default": "./dist/cjs/management/api/resources/actions/resources/triggers/exports.js" + }, + "./actions/modules/versions": { + "import": { + "types": "./dist/esm/management/api/resources/actions/resources/modules/resources/versions/exports.d.mts", + "default": "./dist/esm/management/api/resources/actions/resources/modules/resources/versions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/actions/resources/modules/resources/versions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/actions/resources/modules/resources/versions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/actions/resources/modules/resources/versions/exports.js" + }, + "./actions/triggers/bindings": { + "import": { + "types": "./dist/esm/management/api/resources/actions/resources/triggers/resources/bindings/exports.d.mts", + "default": "./dist/esm/management/api/resources/actions/resources/triggers/resources/bindings/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/actions/resources/triggers/resources/bindings/exports.d.ts", + "default": "./dist/cjs/management/api/resources/actions/resources/triggers/resources/bindings/exports.js" + }, + "default": "./dist/cjs/management/api/resources/actions/resources/triggers/resources/bindings/exports.js" + }, + "./anomaly": { + "import": { + "types": "./dist/esm/management/api/resources/anomaly/exports.d.mts", + "default": "./dist/esm/management/api/resources/anomaly/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/anomaly/exports.d.ts", + "default": "./dist/cjs/management/api/resources/anomaly/exports.js" + }, + "default": "./dist/cjs/management/api/resources/anomaly/exports.js" + }, + "./anomaly/blocks": { + "import": { + "types": "./dist/esm/management/api/resources/anomaly/resources/blocks/exports.d.mts", + "default": "./dist/esm/management/api/resources/anomaly/resources/blocks/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/anomaly/resources/blocks/exports.d.ts", + "default": "./dist/cjs/management/api/resources/anomaly/resources/blocks/exports.js" + }, + "default": "./dist/cjs/management/api/resources/anomaly/resources/blocks/exports.js" + }, + "./attackProtection": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/exports.js" + }, + "./attackProtection/botDetection": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/resources/botDetection/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/resources/botDetection/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/resources/botDetection/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/resources/botDetection/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/resources/botDetection/exports.js" + }, + "./attackProtection/breachedPasswordDetection": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/resources/breachedPasswordDetection/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/resources/breachedPasswordDetection/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/resources/breachedPasswordDetection/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/resources/breachedPasswordDetection/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/resources/breachedPasswordDetection/exports.js" + }, + "./attackProtection/bruteForceProtection": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/resources/bruteForceProtection/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/resources/bruteForceProtection/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/resources/bruteForceProtection/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/resources/bruteForceProtection/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/resources/bruteForceProtection/exports.js" + }, + "./attackProtection/captcha": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/resources/captcha/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/resources/captcha/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/resources/captcha/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/resources/captcha/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/resources/captcha/exports.js" + }, + "./attackProtection/captchaPolicies": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/resources/captchaPolicies/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/resources/captchaPolicies/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/resources/captchaPolicies/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/resources/captchaPolicies/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/resources/captchaPolicies/exports.js" + }, + "./attackProtection/phoneProviderProtection": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/resources/phoneProviderProtection/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/resources/phoneProviderProtection/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/resources/phoneProviderProtection/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/resources/phoneProviderProtection/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/resources/phoneProviderProtection/exports.js" + }, + "./attackProtection/suspiciousIpThrottling": { + "import": { + "types": "./dist/esm/management/api/resources/attackProtection/resources/suspiciousIpThrottling/exports.d.mts", + "default": "./dist/esm/management/api/resources/attackProtection/resources/suspiciousIpThrottling/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/attackProtection/resources/suspiciousIpThrottling/exports.d.ts", + "default": "./dist/cjs/management/api/resources/attackProtection/resources/suspiciousIpThrottling/exports.js" + }, + "default": "./dist/cjs/management/api/resources/attackProtection/resources/suspiciousIpThrottling/exports.js" + }, + "./branding/templates": { + "import": { + "types": "./dist/esm/management/api/resources/branding/resources/templates/exports.d.mts", + "default": "./dist/esm/management/api/resources/branding/resources/templates/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/branding/resources/templates/exports.d.ts", + "default": "./dist/cjs/management/api/resources/branding/resources/templates/exports.js" + }, + "default": "./dist/cjs/management/api/resources/branding/resources/templates/exports.js" + }, + "./branding/themes": { + "import": { + "types": "./dist/esm/management/api/resources/branding/resources/themes/exports.d.mts", + "default": "./dist/esm/management/api/resources/branding/resources/themes/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/branding/resources/themes/exports.d.ts", + "default": "./dist/cjs/management/api/resources/branding/resources/themes/exports.js" + }, + "default": "./dist/cjs/management/api/resources/branding/resources/themes/exports.js" + }, + "./branding/phone": { + "import": { + "types": "./dist/esm/management/api/resources/branding/resources/phone/exports.d.mts", + "default": "./dist/esm/management/api/resources/branding/resources/phone/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/branding/resources/phone/exports.d.ts", + "default": "./dist/cjs/management/api/resources/branding/resources/phone/exports.js" + }, + "default": "./dist/cjs/management/api/resources/branding/resources/phone/exports.js" + }, + "./branding/phone/providers": { + "import": { + "types": "./dist/esm/management/api/resources/branding/resources/phone/resources/providers/exports.d.mts", + "default": "./dist/esm/management/api/resources/branding/resources/phone/resources/providers/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/branding/resources/phone/resources/providers/exports.d.ts", + "default": "./dist/cjs/management/api/resources/branding/resources/phone/resources/providers/exports.js" + }, + "default": "./dist/cjs/management/api/resources/branding/resources/phone/resources/providers/exports.js" + }, + "./branding/phone/templates": { + "import": { + "types": "./dist/esm/management/api/resources/branding/resources/phone/resources/templates/exports.d.mts", + "default": "./dist/esm/management/api/resources/branding/resources/phone/resources/templates/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/branding/resources/phone/resources/templates/exports.d.ts", + "default": "./dist/cjs/management/api/resources/branding/resources/phone/resources/templates/exports.js" + }, + "default": "./dist/cjs/management/api/resources/branding/resources/phone/resources/templates/exports.js" + }, + "./clientGrants/organizations": { + "import": { + "types": "./dist/esm/management/api/resources/clientGrants/resources/organizations/exports.d.mts", + "default": "./dist/esm/management/api/resources/clientGrants/resources/organizations/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/clientGrants/resources/organizations/exports.d.ts", + "default": "./dist/cjs/management/api/resources/clientGrants/resources/organizations/exports.js" + }, + "default": "./dist/cjs/management/api/resources/clientGrants/resources/organizations/exports.js" + }, + "./clients/credentials": { + "import": { + "types": "./dist/esm/management/api/resources/clients/resources/credentials/exports.d.mts", + "default": "./dist/esm/management/api/resources/clients/resources/credentials/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/clients/resources/credentials/exports.d.ts", + "default": "./dist/cjs/management/api/resources/clients/resources/credentials/exports.js" + }, + "default": "./dist/cjs/management/api/resources/clients/resources/credentials/exports.js" + }, + "./clients/connections": { + "import": { + "types": "./dist/esm/management/api/resources/clients/resources/connections/exports.d.mts", + "default": "./dist/esm/management/api/resources/clients/resources/connections/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/clients/resources/connections/exports.d.ts", + "default": "./dist/cjs/management/api/resources/clients/resources/connections/exports.js" + }, + "default": "./dist/cjs/management/api/resources/clients/resources/connections/exports.js" + }, + "./connections/directoryProvisioning": { + "import": { + "types": "./dist/esm/management/api/resources/connections/resources/directoryProvisioning/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/resources/directoryProvisioning/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/resources/directoryProvisioning/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/resources/directoryProvisioning/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/resources/directoryProvisioning/exports.js" + }, + "./connections/scimConfiguration": { + "import": { + "types": "./dist/esm/management/api/resources/connections/resources/scimConfiguration/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/resources/scimConfiguration/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/resources/scimConfiguration/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/resources/scimConfiguration/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/resources/scimConfiguration/exports.js" + }, + "./connections/clients": { + "import": { + "types": "./dist/esm/management/api/resources/connections/resources/clients/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/resources/clients/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/resources/clients/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/resources/clients/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/resources/clients/exports.js" + }, + "./connections/keys": { + "import": { + "types": "./dist/esm/management/api/resources/connections/resources/keys/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/resources/keys/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/resources/keys/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/resources/keys/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/resources/keys/exports.js" + }, + "./connections/users": { + "import": { + "types": "./dist/esm/management/api/resources/connections/resources/users/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/resources/users/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/resources/users/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/resources/users/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/resources/users/exports.js" + }, + "./connections/directoryProvisioning/synchronizations": { + "import": { + "types": "./dist/esm/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/resources/directoryProvisioning/resources/synchronizations/exports.js" + }, + "./connections/scimConfiguration/tokens": { + "import": { + "types": "./dist/esm/management/api/resources/connections/resources/scimConfiguration/resources/tokens/exports.d.mts", + "default": "./dist/esm/management/api/resources/connections/resources/scimConfiguration/resources/tokens/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/connections/resources/scimConfiguration/resources/tokens/exports.d.ts", + "default": "./dist/cjs/management/api/resources/connections/resources/scimConfiguration/resources/tokens/exports.js" + }, + "default": "./dist/cjs/management/api/resources/connections/resources/scimConfiguration/resources/tokens/exports.js" + }, + "./emails": { + "import": { + "types": "./dist/esm/management/api/resources/emails/exports.d.mts", + "default": "./dist/esm/management/api/resources/emails/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/emails/exports.d.ts", + "default": "./dist/cjs/management/api/resources/emails/exports.js" + }, + "default": "./dist/cjs/management/api/resources/emails/exports.js" + }, + "./emails/provider": { + "import": { + "types": "./dist/esm/management/api/resources/emails/resources/provider/exports.d.mts", + "default": "./dist/esm/management/api/resources/emails/resources/provider/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/emails/resources/provider/exports.d.ts", + "default": "./dist/cjs/management/api/resources/emails/resources/provider/exports.js" + }, + "default": "./dist/cjs/management/api/resources/emails/resources/provider/exports.js" + }, + "./eventStreams/deliveries": { + "import": { + "types": "./dist/esm/management/api/resources/eventStreams/resources/deliveries/exports.d.mts", + "default": "./dist/esm/management/api/resources/eventStreams/resources/deliveries/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/eventStreams/resources/deliveries/exports.d.ts", + "default": "./dist/cjs/management/api/resources/eventStreams/resources/deliveries/exports.js" + }, + "default": "./dist/cjs/management/api/resources/eventStreams/resources/deliveries/exports.js" + }, + "./eventStreams/redeliveries": { + "import": { + "types": "./dist/esm/management/api/resources/eventStreams/resources/redeliveries/exports.d.mts", + "default": "./dist/esm/management/api/resources/eventStreams/resources/redeliveries/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/eventStreams/resources/redeliveries/exports.d.ts", + "default": "./dist/cjs/management/api/resources/eventStreams/resources/redeliveries/exports.js" + }, + "default": "./dist/cjs/management/api/resources/eventStreams/resources/redeliveries/exports.js" + }, + "./experimentation": { + "import": { + "types": "./dist/esm/management/api/resources/experimentation/exports.d.mts", + "default": "./dist/esm/management/api/resources/experimentation/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/experimentation/exports.d.ts", + "default": "./dist/cjs/management/api/resources/experimentation/exports.js" + }, + "default": "./dist/cjs/management/api/resources/experimentation/exports.js" + }, + "./experimentation/experiments": { + "import": { + "types": "./dist/esm/management/api/resources/experimentation/resources/experiments/exports.d.mts", + "default": "./dist/esm/management/api/resources/experimentation/resources/experiments/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/experimentation/resources/experiments/exports.d.ts", + "default": "./dist/cjs/management/api/resources/experimentation/resources/experiments/exports.js" + }, + "default": "./dist/cjs/management/api/resources/experimentation/resources/experiments/exports.js" + }, + "./experimentation/featureFlags": { + "import": { + "types": "./dist/esm/management/api/resources/experimentation/resources/featureFlags/exports.d.mts", + "default": "./dist/esm/management/api/resources/experimentation/resources/featureFlags/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/experimentation/resources/featureFlags/exports.d.ts", + "default": "./dist/cjs/management/api/resources/experimentation/resources/featureFlags/exports.js" + }, + "default": "./dist/cjs/management/api/resources/experimentation/resources/featureFlags/exports.js" + }, + "./experimentation/segments": { + "import": { + "types": "./dist/esm/management/api/resources/experimentation/resources/segments/exports.d.mts", + "default": "./dist/esm/management/api/resources/experimentation/resources/segments/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/experimentation/resources/segments/exports.d.ts", + "default": "./dist/cjs/management/api/resources/experimentation/resources/segments/exports.js" + }, + "default": "./dist/cjs/management/api/resources/experimentation/resources/segments/exports.js" + }, + "./experimentation/featureFlags/variations": { + "import": { + "types": "./dist/esm/management/api/resources/experimentation/resources/featureFlags/resources/variations/exports.d.mts", + "default": "./dist/esm/management/api/resources/experimentation/resources/featureFlags/resources/variations/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/experimentation/resources/featureFlags/resources/variations/exports.d.ts", + "default": "./dist/cjs/management/api/resources/experimentation/resources/featureFlags/resources/variations/exports.js" + }, + "default": "./dist/cjs/management/api/resources/experimentation/resources/featureFlags/resources/variations/exports.js" + }, + "./flows/executions": { + "import": { + "types": "./dist/esm/management/api/resources/flows/resources/executions/exports.d.mts", + "default": "./dist/esm/management/api/resources/flows/resources/executions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/flows/resources/executions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/flows/resources/executions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/flows/resources/executions/exports.js" + }, + "./flows/vault": { + "import": { + "types": "./dist/esm/management/api/resources/flows/resources/vault/exports.d.mts", + "default": "./dist/esm/management/api/resources/flows/resources/vault/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/flows/resources/vault/exports.d.ts", + "default": "./dist/cjs/management/api/resources/flows/resources/vault/exports.js" + }, + "default": "./dist/cjs/management/api/resources/flows/resources/vault/exports.js" + }, + "./flows/vault/connections": { + "import": { + "types": "./dist/esm/management/api/resources/flows/resources/vault/resources/connections/exports.d.mts", + "default": "./dist/esm/management/api/resources/flows/resources/vault/resources/connections/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/flows/resources/vault/resources/connections/exports.d.ts", + "default": "./dist/cjs/management/api/resources/flows/resources/vault/resources/connections/exports.js" + }, + "default": "./dist/cjs/management/api/resources/flows/resources/vault/resources/connections/exports.js" + }, + "./groups/members": { + "import": { + "types": "./dist/esm/management/api/resources/groups/resources/members/exports.d.mts", + "default": "./dist/esm/management/api/resources/groups/resources/members/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/groups/resources/members/exports.d.ts", + "default": "./dist/cjs/management/api/resources/groups/resources/members/exports.js" + }, + "default": "./dist/cjs/management/api/resources/groups/resources/members/exports.js" + }, + "./groups/roles": { + "import": { + "types": "./dist/esm/management/api/resources/groups/resources/roles/exports.d.mts", + "default": "./dist/esm/management/api/resources/groups/resources/roles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/groups/resources/roles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/groups/resources/roles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/groups/resources/roles/exports.js" + }, + "./guardian/enrollments": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/enrollments/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/enrollments/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/enrollments/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/enrollments/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/enrollments/exports.js" + }, + "./guardian/factors": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/factors/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/factors/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/factors/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/exports.js" + }, + "./guardian/policies": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/policies/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/policies/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/policies/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/policies/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/policies/exports.js" + }, + "./guardian/factors/email": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/factors/resources/email/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/email/exports.js" + }, + "./guardian/factors/phone": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/phone/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/factors/resources/phone/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/phone/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/phone/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/phone/exports.js" + }, + "./guardian/factors/pushNotification": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/pushNotification/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/factors/resources/pushNotification/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/pushNotification/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/pushNotification/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/pushNotification/exports.js" + }, + "./guardian/factors/sms": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/sms/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/factors/resources/sms/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/sms/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/sms/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/sms/exports.js" + }, + "./guardian/factors/duo": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/duo/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/factors/resources/duo/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/duo/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/duo/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/duo/exports.js" + }, + "./guardian/factors/duo/settings": { + "import": { + "types": "./dist/esm/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/exports.d.mts", + "default": "./dist/esm/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/exports.d.ts", + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/exports.js" + }, + "default": "./dist/cjs/management/api/resources/guardian/resources/factors/resources/duo/resources/settings/exports.js" + }, + "./hooks/secrets": { + "import": { + "types": "./dist/esm/management/api/resources/hooks/resources/secrets/exports.d.mts", + "default": "./dist/esm/management/api/resources/hooks/resources/secrets/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/hooks/resources/secrets/exports.d.ts", + "default": "./dist/cjs/management/api/resources/hooks/resources/secrets/exports.js" + }, + "default": "./dist/cjs/management/api/resources/hooks/resources/secrets/exports.js" + }, + "./jobs/usersExports": { + "import": { + "types": "./dist/esm/management/api/resources/jobs/resources/usersExports/exports.d.mts", + "default": "./dist/esm/management/api/resources/jobs/resources/usersExports/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/jobs/resources/usersExports/exports.d.ts", + "default": "./dist/cjs/management/api/resources/jobs/resources/usersExports/exports.js" + }, + "default": "./dist/cjs/management/api/resources/jobs/resources/usersExports/exports.js" + }, + "./jobs/usersImports": { + "import": { + "types": "./dist/esm/management/api/resources/jobs/resources/usersImports/exports.d.mts", + "default": "./dist/esm/management/api/resources/jobs/resources/usersImports/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/jobs/resources/usersImports/exports.d.ts", + "default": "./dist/cjs/management/api/resources/jobs/resources/usersImports/exports.js" + }, + "default": "./dist/cjs/management/api/resources/jobs/resources/usersImports/exports.js" + }, + "./jobs/verificationEmail": { + "import": { + "types": "./dist/esm/management/api/resources/jobs/resources/verificationEmail/exports.d.mts", + "default": "./dist/esm/management/api/resources/jobs/resources/verificationEmail/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/jobs/resources/verificationEmail/exports.d.ts", + "default": "./dist/cjs/management/api/resources/jobs/resources/verificationEmail/exports.js" + }, + "default": "./dist/cjs/management/api/resources/jobs/resources/verificationEmail/exports.js" + }, + "./jobs/errors": { + "import": { + "types": "./dist/esm/management/api/resources/jobs/resources/errors/exports.d.mts", + "default": "./dist/esm/management/api/resources/jobs/resources/errors/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/jobs/resources/errors/exports.d.ts", + "default": "./dist/cjs/management/api/resources/jobs/resources/errors/exports.js" + }, + "default": "./dist/cjs/management/api/resources/jobs/resources/errors/exports.js" + }, + "./keys": { + "import": { + "types": "./dist/esm/management/api/resources/keys/exports.d.mts", + "default": "./dist/esm/management/api/resources/keys/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/keys/exports.d.ts", + "default": "./dist/cjs/management/api/resources/keys/exports.js" + }, + "default": "./dist/cjs/management/api/resources/keys/exports.js" + }, + "./keys/customSigning": { + "import": { + "types": "./dist/esm/management/api/resources/keys/resources/customSigning/exports.d.mts", + "default": "./dist/esm/management/api/resources/keys/resources/customSigning/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/keys/resources/customSigning/exports.d.ts", + "default": "./dist/cjs/management/api/resources/keys/resources/customSigning/exports.js" + }, + "default": "./dist/cjs/management/api/resources/keys/resources/customSigning/exports.js" + }, + "./keys/encryption": { + "import": { + "types": "./dist/esm/management/api/resources/keys/resources/encryption/exports.d.mts", + "default": "./dist/esm/management/api/resources/keys/resources/encryption/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/keys/resources/encryption/exports.d.ts", + "default": "./dist/cjs/management/api/resources/keys/resources/encryption/exports.js" + }, + "default": "./dist/cjs/management/api/resources/keys/resources/encryption/exports.js" + }, + "./keys/networkAcls": { + "import": { + "types": "./dist/esm/management/api/resources/keys/resources/networkAcls/exports.d.mts", + "default": "./dist/esm/management/api/resources/keys/resources/networkAcls/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/keys/resources/networkAcls/exports.d.ts", + "default": "./dist/cjs/management/api/resources/keys/resources/networkAcls/exports.js" + }, + "default": "./dist/cjs/management/api/resources/keys/resources/networkAcls/exports.js" + }, + "./keys/signing": { + "import": { + "types": "./dist/esm/management/api/resources/keys/resources/signing/exports.d.mts", + "default": "./dist/esm/management/api/resources/keys/resources/signing/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/keys/resources/signing/exports.d.ts", + "default": "./dist/cjs/management/api/resources/keys/resources/signing/exports.js" + }, + "default": "./dist/cjs/management/api/resources/keys/resources/signing/exports.js" + }, + "./organizations/clientGrants": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/clientGrants/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/clientGrants/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/clientGrants/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/clientGrants/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/clientGrants/exports.js" + }, + "./organizations/clients": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/clients/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/clients/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/clients/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/clients/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/clients/exports.js" + }, + "./organizations/connections": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/connections/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/connections/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/connections/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/connections/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/connections/exports.js" + }, + "./organizations/discoveryDomains": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/discoveryDomains/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/discoveryDomains/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/discoveryDomains/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/discoveryDomains/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/discoveryDomains/exports.js" + }, + "./organizations/enabledConnections": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/enabledConnections/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/enabledConnections/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/enabledConnections/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/enabledConnections/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/enabledConnections/exports.js" + }, + "./organizations/invitations": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/invitations/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/invitations/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/invitations/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/invitations/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/invitations/exports.js" + }, + "./organizations/members": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/members/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/members/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/members/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/members/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/members/exports.js" + }, + "./organizations/groups": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/groups/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/groups/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/groups/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/groups/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/groups/exports.js" + }, + "./organizations/groups/roles": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/groups/resources/roles/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/groups/resources/roles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/groups/resources/roles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/groups/resources/roles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/groups/resources/roles/exports.js" + }, + "./organizations/members/effectiveRoles": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/members/resources/effectiveRoles/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/members/resources/effectiveRoles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/exports.js" + }, + "./organizations/members/roles": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/members/resources/roles/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/members/resources/roles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/members/resources/roles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/roles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/roles/exports.js" + }, + "./organizations/members/effectiveRoles/sources": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/exports.js" + }, + "./organizations/members/effectiveRoles/sources/groups": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/members/resources/effectiveRoles/resources/sources/resources/groups/exports.js" + }, + "./organizations/roles": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/roles/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/roles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/roles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/roles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/roles/exports.js" + }, + "./organizations/roles/members": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/roles/resources/members/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/roles/resources/members/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/roles/resources/members/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/roles/resources/members/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/roles/resources/members/exports.js" + }, + "./organizations/roles/groups": { + "import": { + "types": "./dist/esm/management/api/resources/organizations/resources/roles/resources/groups/exports.d.mts", + "default": "./dist/esm/management/api/resources/organizations/resources/roles/resources/groups/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/organizations/resources/roles/resources/groups/exports.d.ts", + "default": "./dist/cjs/management/api/resources/organizations/resources/roles/resources/groups/exports.js" + }, + "default": "./dist/cjs/management/api/resources/organizations/resources/roles/resources/groups/exports.js" + }, + "./prompts/rendering": { + "import": { + "types": "./dist/esm/management/api/resources/prompts/resources/rendering/exports.d.mts", + "default": "./dist/esm/management/api/resources/prompts/resources/rendering/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/prompts/resources/rendering/exports.d.ts", + "default": "./dist/cjs/management/api/resources/prompts/resources/rendering/exports.js" + }, + "default": "./dist/cjs/management/api/resources/prompts/resources/rendering/exports.js" + }, + "./prompts/customText": { + "import": { + "types": "./dist/esm/management/api/resources/prompts/resources/customText/exports.d.mts", + "default": "./dist/esm/management/api/resources/prompts/resources/customText/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/prompts/resources/customText/exports.d.ts", + "default": "./dist/cjs/management/api/resources/prompts/resources/customText/exports.js" + }, + "default": "./dist/cjs/management/api/resources/prompts/resources/customText/exports.js" + }, + "./prompts/partials": { + "import": { + "types": "./dist/esm/management/api/resources/prompts/resources/partials/exports.d.mts", + "default": "./dist/esm/management/api/resources/prompts/resources/partials/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/prompts/resources/partials/exports.d.ts", + "default": "./dist/cjs/management/api/resources/prompts/resources/partials/exports.js" + }, + "default": "./dist/cjs/management/api/resources/prompts/resources/partials/exports.js" + }, + "./riskAssessments": { + "import": { + "types": "./dist/esm/management/api/resources/riskAssessments/exports.d.mts", + "default": "./dist/esm/management/api/resources/riskAssessments/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/riskAssessments/exports.d.ts", + "default": "./dist/cjs/management/api/resources/riskAssessments/exports.js" + }, + "default": "./dist/cjs/management/api/resources/riskAssessments/exports.js" + }, + "./riskAssessments/settings": { + "import": { + "types": "./dist/esm/management/api/resources/riskAssessments/resources/settings/exports.d.mts", + "default": "./dist/esm/management/api/resources/riskAssessments/resources/settings/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/riskAssessments/resources/settings/exports.d.ts", + "default": "./dist/cjs/management/api/resources/riskAssessments/resources/settings/exports.js" + }, + "default": "./dist/cjs/management/api/resources/riskAssessments/resources/settings/exports.js" + }, + "./riskAssessments/settings/newDevice": { + "import": { + "types": "./dist/esm/management/api/resources/riskAssessments/resources/settings/resources/newDevice/exports.d.mts", + "default": "./dist/esm/management/api/resources/riskAssessments/resources/settings/resources/newDevice/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/riskAssessments/resources/settings/resources/newDevice/exports.d.ts", + "default": "./dist/cjs/management/api/resources/riskAssessments/resources/settings/resources/newDevice/exports.js" + }, + "default": "./dist/cjs/management/api/resources/riskAssessments/resources/settings/resources/newDevice/exports.js" + }, + "./roles/groups": { + "import": { + "types": "./dist/esm/management/api/resources/roles/resources/groups/exports.d.mts", + "default": "./dist/esm/management/api/resources/roles/resources/groups/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/roles/resources/groups/exports.d.ts", + "default": "./dist/cjs/management/api/resources/roles/resources/groups/exports.js" + }, + "default": "./dist/cjs/management/api/resources/roles/resources/groups/exports.js" + }, + "./roles/permissions": { + "import": { + "types": "./dist/esm/management/api/resources/roles/resources/permissions/exports.d.mts", + "default": "./dist/esm/management/api/resources/roles/resources/permissions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/roles/resources/permissions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/roles/resources/permissions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/roles/resources/permissions/exports.js" + }, + "./roles/users": { + "import": { + "types": "./dist/esm/management/api/resources/roles/resources/users/exports.d.mts", + "default": "./dist/esm/management/api/resources/roles/resources/users/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/roles/resources/users/exports.d.ts", + "default": "./dist/cjs/management/api/resources/roles/resources/users/exports.js" + }, + "default": "./dist/cjs/management/api/resources/roles/resources/users/exports.js" + }, + "./selfServiceProfiles/customText": { + "import": { + "types": "./dist/esm/management/api/resources/selfServiceProfiles/resources/customText/exports.d.mts", + "default": "./dist/esm/management/api/resources/selfServiceProfiles/resources/customText/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/selfServiceProfiles/resources/customText/exports.d.ts", + "default": "./dist/cjs/management/api/resources/selfServiceProfiles/resources/customText/exports.js" + }, + "default": "./dist/cjs/management/api/resources/selfServiceProfiles/resources/customText/exports.js" + }, + "./selfServiceProfiles/ssoTicket": { + "import": { + "types": "./dist/esm/management/api/resources/selfServiceProfiles/resources/ssoTicket/exports.d.mts", + "default": "./dist/esm/management/api/resources/selfServiceProfiles/resources/ssoTicket/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/selfServiceProfiles/resources/ssoTicket/exports.d.ts", + "default": "./dist/cjs/management/api/resources/selfServiceProfiles/resources/ssoTicket/exports.js" + }, + "default": "./dist/cjs/management/api/resources/selfServiceProfiles/resources/ssoTicket/exports.js" + }, + "./tenants": { + "import": { + "types": "./dist/esm/management/api/resources/tenants/exports.d.mts", + "default": "./dist/esm/management/api/resources/tenants/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/tenants/exports.d.ts", + "default": "./dist/cjs/management/api/resources/tenants/exports.js" + }, + "default": "./dist/cjs/management/api/resources/tenants/exports.js" + }, + "./tenants/settings": { + "import": { + "types": "./dist/esm/management/api/resources/tenants/resources/settings/exports.d.mts", + "default": "./dist/esm/management/api/resources/tenants/resources/settings/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/tenants/resources/settings/exports.d.ts", + "default": "./dist/cjs/management/api/resources/tenants/resources/settings/exports.js" + }, + "default": "./dist/cjs/management/api/resources/tenants/resources/settings/exports.js" + }, + "./users/authenticationMethods": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/authenticationMethods/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/authenticationMethods/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/authenticationMethods/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/authenticationMethods/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/authenticationMethods/exports.js" + }, + "./users/authenticators": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/authenticators/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/authenticators/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/authenticators/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/authenticators/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/authenticators/exports.js" + }, + "./users/connectedAccounts": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/connectedAccounts/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/connectedAccounts/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/connectedAccounts/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/connectedAccounts/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/connectedAccounts/exports.js" + }, + "./users/effectivePermissions": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/effectivePermissions/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/effectivePermissions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/exports.js" + }, + "./users/effectiveRoles": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/effectiveRoles/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/effectiveRoles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/exports.js" + }, + "./users/enrollments": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/enrollments/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/enrollments/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/enrollments/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/enrollments/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/enrollments/exports.js" + }, + "./users/groups": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/groups/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/groups/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/groups/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/groups/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/groups/exports.js" + }, + "./users/identities": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/identities/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/identities/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/identities/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/identities/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/identities/exports.js" + }, + "./users/logs": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/logs/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/logs/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/logs/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/logs/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/logs/exports.js" + }, + "./users/multifactor": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/multifactor/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/multifactor/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/multifactor/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/multifactor/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/multifactor/exports.js" + }, + "./users/organizations": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/organizations/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/organizations/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/organizations/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/organizations/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/organizations/exports.js" + }, + "./users/permissions": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/permissions/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/permissions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/permissions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/permissions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/permissions/exports.js" + }, + "./users/riskAssessments": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/riskAssessments/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/riskAssessments/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/riskAssessments/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/riskAssessments/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/riskAssessments/exports.js" + }, + "./users/roles": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/roles/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/roles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/roles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/roles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/roles/exports.js" + }, + "./users/refreshToken": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/refreshToken/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/refreshToken/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/refreshToken/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/refreshToken/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/refreshToken/exports.js" + }, + "./users/sessions": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/sessions/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/sessions/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/sessions/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/sessions/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/sessions/exports.js" + }, + "./users/effectivePermissions/sources": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/effectivePermissions/resources/sources/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/effectivePermissions/resources/sources/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/resources/sources/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/resources/sources/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/resources/sources/exports.js" + }, + "./users/effectivePermissions/sources/roles": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/effectivePermissions/resources/sources/resources/roles/exports.js" + }, + "./users/effectiveRoles/sources": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/effectiveRoles/resources/sources/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/effectiveRoles/resources/sources/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/resources/sources/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/resources/sources/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/resources/sources/exports.js" + }, + "./users/effectiveRoles/sources/groups": { + "import": { + "types": "./dist/esm/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/exports.d.mts", + "default": "./dist/esm/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/exports.d.ts", + "default": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/exports.js" + }, + "default": "./dist/cjs/management/api/resources/users/resources/effectiveRoles/resources/sources/resources/groups/exports.js" + }, + "./verifiableCredentials": { + "import": { + "types": "./dist/esm/management/api/resources/verifiableCredentials/exports.d.mts", + "default": "./dist/esm/management/api/resources/verifiableCredentials/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/verifiableCredentials/exports.d.ts", + "default": "./dist/cjs/management/api/resources/verifiableCredentials/exports.js" + }, + "default": "./dist/cjs/management/api/resources/verifiableCredentials/exports.js" + }, + "./verifiableCredentials/verification": { + "import": { + "types": "./dist/esm/management/api/resources/verifiableCredentials/resources/verification/exports.d.mts", + "default": "./dist/esm/management/api/resources/verifiableCredentials/resources/verification/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/verifiableCredentials/resources/verification/exports.d.ts", + "default": "./dist/cjs/management/api/resources/verifiableCredentials/resources/verification/exports.js" + }, + "default": "./dist/cjs/management/api/resources/verifiableCredentials/resources/verification/exports.js" + }, + "./verifiableCredentials/verification/templates": { + "import": { + "types": "./dist/esm/management/api/resources/verifiableCredentials/resources/verification/resources/templates/exports.d.mts", + "default": "./dist/esm/management/api/resources/verifiableCredentials/resources/verification/resources/templates/exports.mjs" + }, + "require": { + "types": "./dist/cjs/management/api/resources/verifiableCredentials/resources/verification/resources/templates/exports.d.ts", + "default": "./dist/cjs/management/api/resources/verifiableCredentials/resources/verification/resources/templates/exports.js" + }, + "default": "./dist/cjs/management/api/resources/verifiableCredentials/resources/verification/resources/templates/exports.js" + }, + "./package.json": "./package.json", + "./legacy": { + "types": "./legacy/exports/index.d.ts", + "import": { + "types": "./legacy/exports/index.d.mts", + "default": "./legacy/exports/index.mjs" + }, + "require": { + "types": "./legacy/exports/index.d.ts", + "default": "./legacy/exports/index.js" + } + }, + "./management": { + "import": { + "types": "./dist/esm/management/index.d.mts", + "default": "./dist/esm/management/index.mjs" + }, + "require": { + "types": "./dist/cjs/management/index.d.ts", + "default": "./dist/cjs/management/index.js" + }, + "default": "./dist/cjs/management/index.js" + } + }, + "files": [ + "legacy", + "package.json", + "dist", + "reference.md", + "README.md", + "LICENSE" + ], + "scripts": { + "format": "prettier . --write --ignore-unknown", + "format:check": "prettier . --check --ignore-unknown", + "lint": "eslint . --ext .js,.ts,.tsx", + "lint:fix": "eslint . --ext .js,.ts,.tsx --fix", + "check": "yarn format:check", + "check:fix": "yarn format", + "build": "yarn build:cjs && yarn build:esm", + "build:cjs": "tsc --project ./tsconfig.cjs.json", + "build:esm": "tsc --project ./tsconfig.esm.json && node scripts/rename-to-esm-files.js dist/esm", + "test": "jest --config jest.config.mjs", + "test:unit": "jest --selectProjects unit", + "test:wire": "jest --selectProjects wire", + "prepare": "husky", + "lint:check": "eslint . --ext .js,.ts,.tsx", + "lint:package": "publint --pack npm", + "test:coverage": "jest --config jest.config.mjs --coverage", + "test:coverage:unit": "jest --selectProjects unit --coverage", + "test:coverage:browser": "jest --selectProjects browser --coverage", + "test:coverage:wire": "jest --selectProjects wire --coverage", + "docs": "typedoc", + "docs:clean": "rm -rf docs", + "docs:build": "yarn docs:clean && yarn docs", + "precommit": "lint-staged", + "validate": "yarn lint:check && yarn format --check && yarn build && yarn test && yarn lint:package" + }, + "dependencies": { + "uuid": "^11.1.1", + "jose": "^5.0.0", + "auth0-legacy": "npm:auth0@^4.37.1" + }, + "devDependencies": { + "webpack": "^5.105.4", + "ts-loader": "^9.5.4", + "jest": "^29.7.0", + "@jest/globals": "^29.7.0", + "@types/jest": "^29.5.14", + "ts-jest": "^29.3.4", + "jest-environment-jsdom": "^29.7.0", + "msw": "2.11.2", + "@types/node": "^20.0.0", + "typescript": "~5.9.3", + "prettier": "3.8.1", + "typedoc": "^0.28.7", + "typedoc-plugin-missing-exports": "^4.0.0", + "nock": "^14.0.6", + "undici": "^7.12.0", + "@eslint/js": "^9.32.0", + "@typescript-eslint/eslint-plugin": "^8.38.0", + "@typescript-eslint/parser": "^8.38.0", + "eslint": "^9.32.0", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-prettier": "^5.5.3", + "husky": "^9.1.7", + "lint-staged": "^16.1.4", + "publint": "^0.3.12" + }, + "browser": { + "fs": false, + "os": false, + "path": false, + "stream": false, + "crypto": false + }, + "packageManager": "yarn@1.22.22", + "engines": { + "node": "^20.19.0 || ^22.12.0 || ^24.0.0 || ^26.0.0" + }, + "sideEffects": false, + "bugs": { + "url": "https://github.com/auth0/node-auth0/issues" + }, + "homepage": "https://github.com/auth0/node-auth0", + "keywords": [ + "auth0", + "authentication", + "login", + "auth", + "jwt", + "management api", + "json web token" + ], + "description": "Auth0 Node.js SDK for the Management API v2.", + "lint-staged": { + "*.{js,ts,tsx}": [ + "eslint --fix", + "prettier --write" + ], + "*.{json,md,yml,yaml}": [ + "prettier --write" + ] + } + } + src/management/version.ts: | + export const SDK_VERSION = "7.5.0"; + status: unresolved diff --git a/.shiprc b/.shiprc new file mode 100644 index 0000000000..d1791e98e5 --- /dev/null +++ b/.shiprc @@ -0,0 +1,6 @@ +{ + "files": { + ".version": [], + "src/management/version.ts": [] + } +} diff --git a/AUTH_MIGRATION_GUIDE.md b/AUTH_MIGRATION_GUIDE.md new file mode 100644 index 0000000000..64626f8067 --- /dev/null +++ b/AUTH_MIGRATION_GUIDE.md @@ -0,0 +1,14 @@ +# Authentication Migration Guide + +This guide lives in the [`auth-migration/`](./auth-migration/) directory. + +**→ Start here: [`auth-migration/index.md`](./auth-migration/index.md)**: migrate your authentication code off the `auth0` package to [`@auth0/auth0-auth-js`](https://github.com/auth0/auth0-auth-js) (stateless token grants) or [`@auth0/auth0-server-js`](https://github.com/auth0/auth0-auth-js/tree/main/packages/auth0-server-js) (server-managed sessions). + +The directory contains: + +- [`auth-migration/index.md`](./auth-migration/index.md): the main guide covering OIDC token grants and the four cross-cutting breaking changes. +- [`auth-migration/authentication-flows.md`](./auth-migration/authentication-flows.md): database, passwordless, backchannel (CIBA), token exchange, and `UserInfoClient`. +- [`auth-migration/server-side-sessions.md`](./auth-migration/server-side-sessions.md): the `@auth0/auth0-server-js` session layer. +- [`auth-migration/troubleshooting.md`](./auth-migration/troubleshooting.md): FAQ and gotchas. + +> **Migrating with an AI agent?** Point it at the Auth0 migration skill: the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`. diff --git a/auth-migration/authentication-flows.md b/auth-migration/authentication-flows.md new file mode 100644 index 0000000000..6f7bace2a1 --- /dev/null +++ b/auth-migration/authentication-flows.md @@ -0,0 +1,234 @@ +# Migrating the other authentication flows + +This is the incremental part of the [Authentication Migration Guide](./index.md). Start with the guide's [OIDC token grants](./index.md#oidc-token-grants) and cross-cutting breaking changes before you touch anything here. Everything below builds on those changes, so apply them to every rewrite on this page too. + +> **Migrating with an AI agent?** Point it at the Auth0 migration skill (the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`). + +Migrate one flow at a time. Only the flows your app actually uses need attention; skip the rest. + +- [Database connections](#database-connections) +- [Passwordless](#passwordless) +- [Backchannel authentication (CIBA)](#backchannel-authentication-ciba) +- [Token exchange (RFC 8693)](#token-exchange-rfc-8693) +- [UserInfoClient](#userinfoclient) +- [Quick lookup table](#quick-lookup-table) + +Unless a row routes explicitly to `@auth0/auth0-server-js`, the replacement lives on the `@auth0/auth0-auth-js` `AuthClient` (or a sub-client: `authClient.database`, `authClient.passwordless`, `authClient.mfa`, `authClient.passkey`). + +## Database connections + +Database connection operations move to the `authClient.database` sub-client. Names and required parameters stay the same; only casing and return shape change. + +### `database.signUp` → `authClient.database.signUp` + +```ts +// before +const resp = await auth0.database.signUp({ + email, + password, + connection: "Username-Password-Authentication", + given_name: "Ada", + family_name: "Lovelace", + user_metadata: { plan: "free" }, +}); +const userId = resp.data.id; +// after +const result = await authClient.database.signUp({ + email, + password, + connection: "Username-Password-Authentication", + givenName: "Ada", + familyName: "Lovelace", + userMetadata: { plan: "free" }, +}); +const userId = result.id; +``` + +> ID normalization is preserved: node-auth0 mapped the server's `_id | user_id | id` onto a single `id`. The new SDK does the same, so `result.id` is always present. Do not add your own `_id` fallback. + +### `database.changePassword` → `authClient.database.changePassword` + +node-auth0 returned a `TextApiResponse` (read via `.data`); the new SDK returns the plain `string` directly. + +```ts +// before +const resp = await auth0.database.changePassword({ email, connection: "Username-Password-Authentication" }); +const message = resp.data; // plain-text confirmation +// after +const message = await authClient.database.changePassword({ email, connection: "Username-Password-Authentication" }); +``` + +> `changePassword` requires `connection` plus at least one of `email` or `username`: either identifier is accepted, not `email` alone. + +## Passwordless + +node-auth0 lumped "start" (send the code or link) and "login" (redeem the code) onto one sub-client. The new SDK splits them: starting stays on `authClient.passwordless`; redeeming a code becomes a top-level grant method on `AuthClient`. + +### `passwordless.sendEmail` → `authClient.passwordless.sendEmail` + +```ts +// before +await auth0.passwordless.sendEmail({ email, send: "code" }); +// after +await authClient.passwordless.sendEmail({ email, send: "code" }); +``` + +> Default changed: node-auth0 defaulted `send` to `'link'` (magic link). The new SDK defaults `send` to `'code'` (one-time password). If you relied on the implicit default to send magic links, set `send: 'link'` explicitly. + +### `passwordless.sendSMS` → `authClient.passwordless.sendSms` + +Note the casing change: `sendSMS` → `sendSms`, and `phone_number` → `phoneNumber`. + +```ts +// before +await auth0.passwordless.sendSMS({ phone_number: "+15551234567" }); +// after +await authClient.passwordless.sendSms({ phoneNumber: "+15551234567" }); +``` + +### `passwordless.loginWithEmail` → `getTokenByPasswordlessEmail` + +Redeeming the one-time password is now a grant method on `AuthClient`, not on the passwordless sub-client. + +```ts +// before +const resp = await auth0.passwordless.loginWithEmail({ email, code, audience, scope }); +const token = resp.data.access_token; +// after +const tokens = await authClient.getTokenByPasswordlessEmail({ email, code, audience, scope }); +const token = tokens.accessToken; +``` + +### `passwordless.loginWithSMS` → `getTokenByPasswordlessSms` + +```ts +// before +const resp = await auth0.passwordless.loginWithSMS({ phone_number, code }); +// after +const tokens = await authClient.getTokenByPasswordlessSms({ phoneNumber, code }); +``` + +> Session apps: `@auth0/auth0-server-js` exposes `startPasswordless` / `completePasswordless` / `completePasswordlessMagicLink`, which both send the code and establish a session. Use those instead of the two-step auth-js flow when the SDK owns the session. See [Migrating session apps](./server-side-sessions.md). + +## Backchannel authentication (CIBA) + +CIBA is Client-Initiated Backchannel Authentication. + +### `backchannel.authorize` → `initiateBackchannelAuthentication` + +```ts +// before +const resp = await auth0.backchannel.authorize({ + binding_message: "ABC123", + scope: "openid", + userId: "auth0|123", +}); +const authReqId = resp.auth_req_id; +// after +const { authReqId, expiresIn, interval } = await authClient.initiateBackchannelAuthentication({ + bindingMessage: "ABC123", + loginHint: { sub: "auth0|123" }, // login_hint is an object with `sub`, not a bare string + authorizationParams: { scope: "openid" }, // scope goes here, NOT as a top-level key +}); +``` + +### `backchannel.backchannelGrant` → `backchannelAuthenticationGrant` + +```ts +// before +const resp = await auth0.backchannel.backchannelGrant({ auth_req_id: authReqId }); +// after +const tokens = await authClient.backchannelAuthenticationGrant({ authReqId }); +``` + +> One-shot convenience: `authClient.backchannelAuthentication({ ... })` initiates and polls to completion, returning a `TokenResponse`. Use it if your code did the initiate-then-poll loop by hand. +> +> Session apps: for CIBA that also establishes a session, see [Migrating session apps](./server-side-sessions.md). + +## Token exchange (RFC 8693) + +```ts +// before +const resp = await auth0.tokenExchange.exchangeToken({ + subject_token_type: "urn:example:custom", + subject_token: token, + audience: "https://api.example.com", + scope: "read", +}); +// after +const tokens = await authClient.exchangeToken({ + subjectTokenType: "urn:example:custom", + subjectToken: token, + audience: "https://api.example.com", + scope: "read", +}); +``` + +> `exchangeToken` is overloaded: a custom-exchange profile shape (`subjectTokenType` + `subjectToken` + `audience`) and a Token Vault shape (`connection` present). Presence of `connection` routes to the vault path. The custom-exchange profile is the RFC 8693 replacement for `tokenExchange.exchangeToken`. +> +> Session apps: `@auth0/auth0-server-js` exposes `loginWithCustomTokenExchange` (exchange, then establish a session) and `customTokenExchange` (exchange, then return tokens with no session). + +## UserInfoClient + +The standalone `UserInfoClient` from node-auth0 does not exist in the new SDK. Choose the replacement based on what the app needs: + +| Your intent | Replacement | +| --- | --- | +| Wanted user profile claims right after login | Read `TokenResponse.claims` from the grant result; the SDK already decodes the ID token. No extra `/userinfo` round-trip needed. **Preferred.** | +| Wanted a live `/userinfo` response for an arbitrary access token | `await authClient.getUserInfo({ accessToken })`, a direct method on `AuthClient`. | +| Wanted the profile in a server-rendered app with a session | `await serverClient.getUser()` returns the stored user claims from the session. | + +**Before (node-auth0):** + +```ts +import { UserInfoClient } from "auth0"; +const userInfo = new UserInfoClient({ domain }); +const resp = await userInfo.getUserInfo(accessToken); +const profile = resp.data; // { sub, name, email, ... } +``` + +**After (preferred): use the claims you already have:** + +```ts +const tokens = await authClient.getTokenByCode(callbackUrl, {}); +const profile = tokens.claims; // { sub, name, email, ... } decoded from the id_token +``` + +**After (direct method):** for when you only have an access token: + +```ts +// Takes an options object: { accessToken, expectedSubject? } +const profile = await authClient.getUserInfo({ accessToken }); +``` + +> Prefer reading `claims` over any `/userinfo` call: it avoids a network round-trip and the claims are already validated by the SDK. + +## Quick lookup table + +The complete node-auth0 → new SDK map, including the OIDC methods covered in the main guide. + +| node-auth0 | new SDK equivalent | Layer | +| --- | --- | --- | +| `oauth.authorizationCodeGrant` | `authClient.getTokenByCode(url, opts)` | auth-js | +| `oauth.authorizationCodeGrantWithPKCE` | `authClient.getTokenByCode(url, { codeVerifier })` | auth-js | +| `oauth.refreshTokenGrant` | `authClient.getTokenByRefreshToken({ refreshToken })` | auth-js | +| `oauth.passwordGrant` | `authClient.getTokenByPassword({ ... })` | auth-js | +| `oauth.clientCredentialsGrant` | `authClient.getTokenByClientCredentials({ audience })` | auth-js | +| `oauth.revokeRefreshToken` | `authClient.revokeToken({ token })` / `serverClient.revokeRefreshToken()` | auth-js / server-js | +| `oauth.tokenForConnection` | `authClient.exchangeToken({ connection, ... })` | auth-js | +| `oauth.pushedAuthorization` | `authClient.buildAuthorizationUrl({ pushedAuthorizationRequests: true })` | auth-js | +| `database.signUp` | `authClient.database.signUp({ ... })` | auth-js | +| `database.changePassword` | `authClient.database.changePassword({ ... })` | auth-js | +| `passwordless.sendEmail` | `authClient.passwordless.sendEmail({ ... })` | auth-js | +| `passwordless.sendSMS` | `authClient.passwordless.sendSms({ phoneNumber })` | auth-js | +| `passwordless.loginWithEmail` | `authClient.getTokenByPasswordlessEmail({ ... })` | auth-js | +| `passwordless.loginWithSMS` | `authClient.getTokenByPasswordlessSms({ ... })` | auth-js | +| `backchannel.authorize` | `authClient.initiateBackchannelAuthentication({ ... })` | auth-js | +| `backchannel.backchannelGrant` | `authClient.backchannelAuthenticationGrant({ authReqId })` | auth-js | +| `tokenExchange.exchangeToken` | `authClient.exchangeToken({ subjectTokenType, subjectToken, audience })` | auth-js | +| `UserInfoClient.getUserInfo` | `TokenResponse.claims` (preferred) / `authClient.getUserInfo({ accessToken })` / `serverClient.getUser()` | auth-js / server-js | +| (no equivalent): build `/authorize` URL | `authClient.buildAuthorizationUrl({ ... })` | auth-js | +| (no equivalent): build `/v2/logout` URL | `authClient.buildLogoutUrl({ returnTo })` | auth-js | +| `ManagementClient.*` | **not migrated, stays on `auth0`** | n/a | + +When you finish a flow, return to the [verification checklist](./index.md#verification-checklist) and confirm the four cross-cutting changes for every call site you touched. diff --git a/auth-migration/index.md b/auth-migration/index.md new file mode 100644 index 0000000000..85a11c45c7 --- /dev/null +++ b/auth-migration/index.md @@ -0,0 +1,732 @@ +# Authentication Migration Guide + +A guide to migrating your authentication code off the `auth0` package (node-auth0) to the modern Auth0 server SDKs: [`@auth0/auth0-auth-js`](https://github.com/auth0/auth0-auth-js) for stateless token grants, and [`@auth0/auth0-server-js`](https://github.com/auth0/auth0-auth-js/tree/main/packages/auth0-server-js) for server-managed sessions. + +> **Migrating with an AI agent?** Point it at the Auth0 migration skill first. The skill lives in [`auth0/agent-skills`](https://github.com/auth0/agent-skills) as the `auth0` skill (migration intent: `migrate-node-auth0`). It encodes the target-SDK routing, the four cross-cutting breaking changes, the method-by-method mapping, and a build-until-green verify loop. + +## Contents + +- [How to use this guide](#how-to-use-this-guide) +- [Overview](#overview) + - [Who this is for](#who-this-is-for) + - [Scope](#scope) +- [Choosing your target SDK](#choosing-your-target-sdk) +- [Prerequisites](#prerequisites) +- [Installation and constructor mapping](#installation-and-constructor-mapping) +- [OIDC token grants](#oidc-token-grants) + - [Optional: migrate only OIDC while staying on v6](#optional-migrate-only-oidc-while-staying-on-v6) +- [Cross-cutting breaking changes](#cross-cutting-breaking-changes) + - [1. Return shape](#1-return-shape) + - [2. Casing](#2-casing) + - [3. Token expiry](#3-token-expiry) + - [4. Error model](#4-error-model) +- [Verification checklist](#verification-checklist) +- [Continue the migration](#continue-the-migration) + - [Other authentication flows](#other-authentication-flows) + - [Server-side sessions](#server-side-sessions) + - [Troubleshooting](#troubleshooting) + +## How to use this guide + +This is a reference, not a linear read. You do not have to work through it top to bottom; migrate only the flows your app actually uses, in whatever order suits you. Most apps finish after the [OIDC token grants](#oidc-token-grants) section. + +The work falls into three phases: + +| Phase | What you do | Where | +| --- | --- | --- | +| **Before**: orient and set up | Pick your target SDK, check prerequisites, install the package, map constructor options. | [Choosing your target SDK](#choosing-your-target-sdk), [Prerequisites](#prerequisites), [Installation and constructor mapping](#installation-and-constructor-mapping) | +| **During**: rewrite call sites | Rewrite the OIDC token grants (in this file), then the other flows and the session layer as needed. Apply the four cross-cutting breaking changes to every call site. | [OIDC token grants](#oidc-token-grants), [Cross-cutting breaking changes](#cross-cutting-breaking-changes), [`authentication-flows.md`](./authentication-flows.md), [`server-side-sessions.md`](./server-side-sessions.md) | +| **After**: verify | Run the build-until-green checklist; confirm no residue and that `ManagementClient` code is untouched. | [Verification checklist](#verification-checklist) | + +Suggested order: start with the OIDC grants and cross-cutting changes (the whole job for most apps), then the [other flows](./authentication-flows.md) you actually use, then [session apps](./server-side-sessions.md) if you want the SDK to own sessions. Stuck? See [`troubleshooting.md`](./troubleshooting.md). + +## Overview + +node-auth0's `AuthenticationClient` is a stateless HTTP client. Every method is a single call to an Auth0 Authentication API endpoint that returns a response object. It has no notion of a logged-in user, no session, no cookie, no token store, and no automatic refresh. Anything stateful in a node-auth0 app (persisting tokens, deciding when to refresh, tracking the login across requests) was written by you *around* node-auth0. + +The modern stack splits those two concerns into two packages: + +- `@auth0/auth0-auth-js` is the stateless token layer. It is the direct successor to `AuthenticationClient`: the same "one method equals one API call equals one result" model, with modern ergonomics (camelCase, typed errors, direct return values, per-request options). +- `@auth0/auth0-server-js` is a stateful session layer built on top of auth0-auth-js. It owns the login redirect flow, a pluggable state/transaction store, cookie handling, automatic token refresh, and logout. It is the successor to the *session code you hand-rolled*, not to `AuthenticationClient` itself. + +### Who this is for + +You are running a Node.js backend that imports the `auth0` package and calls `AuthenticationClient` (or `UserInfoClient`) to perform token grants, database signup, passwordless, CIBA, token exchange, or userinfo lookups. You want to move that code to the current first-party server SDKs. This is a surgical rewrite of the authentication layer: routes, controllers, business logic, data access, and framework wiring stay as they are. You touch the smallest possible surface: the files that import and call node-auth0's Authentication API. + +### Scope + +In scope: + +- `AuthenticationClient` and its sub-clients: `.oauth`, `.database`, `.passwordless`, `.backchannel`, `.tokenExchange` +- `UserInfoClient` +- The auth error types (`AuthApiError`) and token-validation types (`IDTokenValidateOptions`, `IdTokenValidatorError`) + +Out of scope, do not touch: + +- `ManagementClient` (Management API v2). It is not being migrated and stays on the `auth0` package. +- Application routes, view/controller logic, database code, and any non-auth use of the `auth0` package. + +> If a file uses `ManagementClient`, leave that code alone. Only rewrite the `AuthenticationClient` / `UserInfoClient` parts. + +## Choosing your target SDK + +The routing question is: do you want to keep owning your session, or hand that responsibility to the SDK? + +### Decision table + +| If your code… | Migrate to | Why | +| --- | --- | --- | +| Only performs token grants / DB signup / passwordless / userinfo and manages its own session (or is a machine-to-machine service backend) | `@auth0/auth0-auth-js` | Direct, near 1:1 replacement for `AuthenticationClient`. Same stateless model. | +| Wants the SDK to own the login redirect flow, session storage, cookies, token refresh, and logout (a server-rendered web app) | `@auth0/auth0-server-js` | Adds a session layer node-auth0 never had. This is a rewrite of the session handling, not a method-for-method port. | + +**Default recommendation:** start with `@auth0/auth0-auth-js` for a faithful parity migration. Choose `@auth0/auth0-server-js` only when you currently hand-roll session/cookie/refresh logic around node-auth0 and would benefit from the SDK owning it. + +### Signals + +Signals that point to auth0-auth-js: + +- Predominant use is `clientCredentialsGrant` (machine-to-machine). There is no user, so there is no session to own. +- The app already has a session framework it is happy with and only calls node-auth0 for token grants. +- The app is an API, worker, or CLI, not a browser-facing web server. +- You want the smallest, most mechanical, lowest-risk migration. + +Signals that point to auth0-server-js: + +- The app performs a browser redirect login and reads `req.session.user` (or equivalent) on later requests. +- You wrote refresh-on-expiry logic, a token cache, or logout-with-revocation by hand. +- You use `express-openid-connect` today and want a first-party, framework-agnostic replacement. +- You are on a server framework (Express, Fastify, Hono, Next.js) and want the SDK to manage cookies. + +### Mixing both + +A single app can use both: auth0-server-js for the user-facing login/session, and auth0-auth-js directly for a separate machine-to-machine `clientCredentialsGrant` to call another API. `ServerClient` even exposes the underlying `AuthClient` via `serverClient.authClient` for occasional low-level needs. Do not force everything onto one package. + +## Prerequisites + +### Node.js version + +Both target SDKs need Node.js 20 LTS or newer. Verify the project's runtime before installing. + +### SDK versions + +- `@auth0/auth0-auth-js` >= `1.13.0` +- `@auth0/auth0-server-js` >= `1.13.0` + +Both are published on npm; install the current `latest`. `1.13.0` is the floor for the full API surface used in this guide (`getUserInfo`, per-request `RequestOptions`, and `fullResponse`). + +## Installation and constructor mapping + +Add the target package: + +```bash +# auth-js target (stateless token grants) +npm install @auth0/auth0-auth-js + +# server-js target (server-managed sessions), pulls in auth0-auth-js transitively +npm install @auth0/auth0-server-js +``` + +Keep the `auth0` package installed if the app still uses `ManagementClient`. + +### Imports + +```ts +// before +import { AuthenticationClient, UserInfoClient, AuthApiError } from "auth0"; + +// after: auth-js target +import { AuthClient, TokenByCodeError, isMfaRequiredError } from "@auth0/auth0-auth-js"; + +// after: server-js target +import { ServerClient } from "@auth0/auth0-server-js"; +``` + +> Keep the `auth0` import if the file also uses `ManagementClient`. It is correct for a file to import both `auth0` (for `ManagementClient`) and `@auth0/auth0-auth-js` (for authentication). Only remove the `auth0` import from files where it was used *solely* for `AuthenticationClient` / `UserInfoClient`. + +### AuthClient options + +The constructor options mostly carry over with camelCase names. A few are renamed or dropped. + +**Before (node-auth0):** + +```ts +new AuthenticationClient({ + domain: "tenant.us.auth0.com", + clientId: "...", + clientSecret: "...", // OR clientAssertionSigningKey + clientAssertionSigningKey: "...", + clientAssertionSigningAlg: "RS256", + idTokenSigningAlg: "RS256", // for manual id_token validation + clockTolerance: 60, // seconds, for validation + useMTLS: false, + telemetry: true, + headers: { "X-Custom": "..." }, // sent on every request + timeoutDuration: 10000, // ms + retry: { + /* ... */ + }, + agent: undiciDispatcher, + fetch: customFetch, + middleware: [ + /* ... */ + ], +}); +``` + +**After (auth0-auth-js):** + +```ts +import { AuthClient } from "@auth0/auth0-auth-js"; + +new AuthClient({ + domain: "tenant.us.auth0.com", // same (no scheme) + clientId: "...", // same + clientSecret: "...", // same + clientAssertionSigningKey: "...", // same (string | CryptoKey) + clientAssertionSigningAlg: "RS256", // same + authorizationParams: { + // NEW: default scope/audience/redirect_uri for URL builders + scope: "openid profile email", + audience: "https://api.example.com", + redirect_uri: "https://app.example.com/callback", + }, + useMtls: false, // RENAMED from useMTLS (lowercase tls) + customFetch: fetch, // RENAMED from fetch + telemetry: { + /* ... */ + }, // structured TelemetryConfig + discoveryCache: { ttl, maxEntries }, // NEW: OIDC discovery / JWKS cache +}); +``` + +Option-by-option: + +| node-auth0 | auth0-auth-js | Notes | +| --- | --- | --- | +| `domain` | `domain` | Unchanged. No `https://` scheme. | +| `clientId` | `clientId` | Unchanged. | +| `clientSecret` | `clientSecret` | Unchanged. | +| `clientAssertionSigningKey` | `clientAssertionSigningKey` | Unchanged. Now also accepts a `CryptoKey`. | +| `clientAssertionSigningAlg` | `clientAssertionSigningAlg` | Unchanged. | +| `useMTLS` | `useMtls` | Renamed (casing). | +| `fetch` | `customFetch` | Renamed. | +| `telemetry: boolean` | `telemetry: TelemetryConfig` | Now a structured object. | +| `headers` (global) | per-request `RequestOptions.headers` | Moved to per-request options; set per call site rather than globally. | +| `timeoutDuration` | per-request `RequestOptions.signal` | Use an `AbortSignal.timeout(ms)` on the call. | +| `retry` | configure via `customFetch` | Wrap your fetch with retry if needed. | +| `agent` | configure via `customFetch` | Set the dispatcher inside your custom fetch. | +| `middleware` | `customFetch` | Compose behavior in the fetch wrapper. | +| `idTokenSigningAlg` | (internal) | ID-token validation is internal; read `TokenResponse.claims`. | +| `clockTolerance` | (internal) | Handled internally during validation. | + +### ServerClient options + +`ServerClient` wraps an `AuthClient` and adds the session machinery. It shares the auth options and adds required stores. This constructor and the stores it needs are covered in [`server-side-sessions.md`](./server-side-sessions.md); reach for it only when you route to server-js. + +### Global config to per-request options + +node-auth0's global constructor options for `headers`, `timeoutDuration`, `agent`, `retry`, and `middleware` have no direct constructor equivalents in auth0-auth-js. Instead, the new SDK's methods accept a trailing `RequestOptions` parameter: + +```ts +import type { RequestOptions } from "@auth0/auth0-server-js"; // or '@auth0/auth0-auth-js' + +const tokens = await authClient.getTokenByClientCredentials( + { audience: "https://api.example.com" }, + { + headers: { "X-Custom": "value" }, + signal: AbortSignal.timeout(5000), // timeout in ms + } satisfies RequestOptions, +); +``` + +`@auth0/auth0-server-js` re-exports `RequestOptions`, `ApiResponse`, and `FullResponseOption` from `@auth0/auth0-auth-js`, so you can import any of them from either package. + +Arity rule: MFA methods (`authClient.mfa.*`) take `requestOptions` as the 2nd argument; store-first methods (session-owning methods on `serverClient`) take it as the 3rd argument after the store context; cache hits ignore it entirely. + +Common patterns: + +- Global headers: apply via `RequestOptions.headers` on each call that needs it, or wrap `customFetch` once to inject it everywhere. +- Timeout: replace `timeoutDuration: 10000` with `signal: AbortSignal.timeout(10000)` on the call. +- Agent (Node.js dispatcher): wrap `customFetch` to inject the agent into the underlying HTTP transport. +- Retry / middleware: compose behavior in a `customFetch` wrapper passed either at construction or per request. + +## OIDC token grants + +This is the core of the migration and, for most apps, the whole of it. These are the `AuthenticationClient.oauth.*` grants that drive OpenID Connect login and machine-to-machine token acquisition. All of them move onto the `AuthClient` instance directly (not a sub-client). + +Before you touch any method, internalize the four [cross-cutting breaking changes](#cross-cutting-breaking-changes); they apply to *every* rewrite here and on the incremental pages. + +Naming conventions used throughout: + +| node-auth0 | new SDKs | +| --- | --- | +| Params and response fields use the snake_case wire shape: `client_id`, `refresh_token`, `access_token`, `expires_in`, `phone_number` | camelCase: `clientId`, `refreshToken`, `accessToken`, `expiresAt`, `phoneNumber` | +| Methods take a `bodyParameters` object (+ optional `initOverrides`) | Methods take a single `options` object (+ optional trailing `RequestOptions` for per-request `signal`, `headers`, `customFetch`) | +| Every method returns a `JSONApiResponse` / `VoidApiResponse` / `TextApiResponse` wrapper | Methods return the domain object directly (`TokenResponse`, `SignUpResult`, `string`, `void`) | + +### `oauth.authorizationCodeGrant` → `getTokenByCode` + +The single most important semantic change in the whole migration. In node-auth0 you pass the raw authorization `code` (and `redirect_uri`) that you extracted from the callback query string yourself. In auth0-auth-js you pass the entire callback `URL`; the SDK extracts `code` and enforces PKCE, and `redirect_uri` comes from the `AuthClient` config / `authorizationParams`. The stateless `AuthClient` does **not** validate OAuth `state` — that is your responsibility (or use `@auth0/auth0-server-js` `completeInteractiveLogin`, which owns a transaction store and validates `state` for you). + +**Before (node-auth0):** + +```ts +import { AuthenticationClient } from "auth0"; + +const auth0 = new AuthenticationClient({ domain, clientId, clientSecret }); + +// You parsed `code` out of the callback URL yourself. +const resp = await auth0.oauth.authorizationCodeGrant({ + code, + redirect_uri: "https://app.example.com/callback", +}); +const accessToken = resp.data.access_token; +const expiresIn = resp.data.expires_in; // relative seconds +const reqId = resp.headers.get("x-request-id"); // metadata on success +``` + +**After (auth0-auth-js):** + +```ts +import { AuthClient } from "@auth0/auth0-auth-js"; + +const authClient = new AuthClient({ domain, clientId, clientSecret }); + +// `url` is a URL object for the full incoming request URL, +// e.g. new URL(req.url, `https://${req.headers.host}`) +const tokens = await authClient.getTokenByCode(url, { + // options; e.g. codeVerifier (PKCE) or organization +}); +const accessToken = tokens.accessToken; +const expiresAt = tokens.expiresAt; // absolute Unix seconds +``` + +> If your code manually parses `req.query.code`, that parsing is now the SDK's job. Delete it and hand the SDK the full URL. The SDK reads `code` from the URL and validates the PKCE verifier; it does **not** validate OAuth `state`. **Keep your existing `state` check** (compare the `state` query parameter against what you stored before the redirect) — or migrate to `@auth0/auth0-server-js` `completeInteractiveLogin`, which handles `state` validation automatically. (`getTokenByCode` options are `codeVerifier` and `organization`.) If the node-auth0 code read `resp.headers.get(...)` on success, see [Reading HTTP response metadata](#reading-http-response-metadata-fullresponse). Error-path metadata remains accessible on the typed error. + +> **Warning:** Do not delete your `state`/CSRF check when migrating to `AuthClient.getTokenByCode`. The stateless client does not validate `state`. Removing the check silently disables CSRF protection on the authorization-code flow. + +### `oauth.authorizationCodeGrantWithPKCE` → `getTokenByCode` (with verifier) + +PKCE (Proof Key for Code Exchange) is folded into the same method; supply the code verifier via options. Typically the verifier was produced earlier by `buildAuthorizationUrl` (below), which returns a `codeVerifier` for you to persist. + +```ts +// before +const resp = await auth0.oauth.authorizationCodeGrantWithPKCE({ + code, + code_verifier: verifier, + redirect_uri: "https://app.example.com/callback", +}); + +// after +const tokens = await authClient.getTokenByCode(url, { + codeVerifier: verifier, +}); +``` + +> If you build the authorization URL yourself today, prefer switching to `authClient.buildAuthorizationUrl()` (below) so the SDK generates and returns the `codeVerifier`, then persist it and pass it back to `getTokenByCode`. + +### `oauth.refreshTokenGrant` → `getTokenByRefreshToken` + +```ts +// before +const resp = await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); +// after +const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); +``` + +### `oauth.passwordGrant` → `getTokenByPassword` + +```ts +// before +const resp = await auth0.oauth.passwordGrant({ + username, + password, + realm: "Username-Password-Authentication", + audience, + scope, +}); +// after +const tokens = await authClient.getTokenByPassword({ + username, + password, + realm: "Username-Password-Authentication", + audience, + scope, +}); +``` + +### `oauth.clientCredentialsGrant` → `getTokenByClientCredentials` + +The canonical machine-to-machine grant. This is the most common reason to stay on auth0-auth-js rather than adopt server-js: there is no user session involved. + +```ts +// before +const resp = await auth0.oauth.clientCredentialsGrant({ audience: "https://api.example.com" }); +const token = resp.data.access_token; +// after +const tokens = await authClient.getTokenByClientCredentials({ audience: "https://api.example.com" }); +const token = tokens.accessToken; +``` + +### `oauth.revokeRefreshToken` → `revokeToken` + +Renamed, and simplified return (was `VoidApiResponse`, now `void`). + +```ts +// before +await auth0.oauth.revokeRefreshToken({ token: rt }); +// after +await authClient.revokeToken({ token: rt }); +``` + +> **Session apps:** if you are migrating to server-js and this revoke was part of logout, use `serverClient.revokeRefreshToken()` instead of the low-level `revokeToken`. By default it reads the refresh token from the session; you can also pass an explicit `{ token }` in its options. + +### Build the authorization and logout URLs + +node-auth0 left `/authorize` URL construction to the caller (or to `express-openid-connect`). The new SDK gives you `buildAuthorizationUrl()` and `buildLogoutUrl()`. When migrating a redirect login, replace hand-built `/authorize` and `/v2/logout` URLs with these: + +```ts +const { authorizationUrl, codeVerifier } = await authClient.buildAuthorizationUrl({ + authorizationParams: { redirect_uri, scope: "openid profile email", audience }, +}); +// ... later, on logout: +const logoutUrl = await authClient.buildLogoutUrl({ returnTo: "https://app.example.com" }); +``` + +> Pushed Authorization Requests (PAR): there is no standalone PAR method. Pass `pushedAuthorizationRequests: true` to `buildAuthorizationUrl`: the SDK performs the PAR POST and returns an authorization URL that references the resulting `request_uri`. Requires the tenant to expose a `pushed_authorization_request_endpoint`; the SDK throws if PAR is requested but unsupported. This replaces node-auth0's `oauth.pushedAuthorization`. + +Once the OIDC grants are rewritten and the [cross-cutting breaking changes](#cross-cutting-breaking-changes) are applied, run the [verification checklist](#verification-checklist). If your app also uses database, passwordless, CIBA, token exchange, or `UserInfoClient`, continue with [`authentication-flows.md`](./authentication-flows.md). If you want the SDK to own sessions, see [`server-side-sessions.md`](./server-side-sessions.md). + +### Optional: migrate only OIDC while staying on v6 + +You do not have to migrate everything at once, and you do not have to wait for v7. node-auth0 v6 still ships `AuthenticationClient` alongside `ManagementClient`, so you can move your OIDC login and token grant code off `AuthenticationClient` to `@auth0/auth0-auth-js` now, incrementally, while the rest of the app keeps using `auth0` v6 unchanged. + +A common and fully supported end state: + +- OIDC / token grant code: migrated to `@auth0/auth0-auth-js` (the grants covered in this section). +- Other auth flows you have not gotten to yet: still on `AuthenticationClient` from `auth0` v6. +- Management API: still on `ManagementClient` from `auth0` (never migrates). + +The OIDC grants above are a complete, shippable step on their own; finishing them is a valid stopping point even if you migrate nothing else. Move on to [`authentication-flows.md`](./authentication-flows.md) and [`server-side-sessions.md`](./server-side-sessions.md) later, at your own pace. When you eventually upgrade to v7 (which removes the Authentication API from the main entrypoint; see the [v7 Migration Guide](../v7_MIGRATION_GUIDE.md)), the OIDC work is already done. + +## Cross-cutting breaking changes + +Every call-site rewrite in this guide and on the incremental pages is subject to four changes that cut across all methods. They cause the overwhelming majority of migration defects, and three of the four are *silent*: the code compiles and often runs, but produces wrong behavior at runtime. Apply each one deliberately. + +1. [Return shape: `JSONApiResponse` → domain object](#1-return-shape) +2. [Casing: snake_case wire shape → camelCase](#2-casing) +3. [Token expiry: `expires_in` (relative) → `expiresAt` (absolute)](#3-token-expiry), most dangerous +4. [Error model: `AuthApiError` → typed per-operation errors](#4-error-model) + +### 1. Return shape + +node-auth0 wraps most Authentication API results in a response envelope: + +- `JSONApiResponse`: has `.data` (the payload), `.status` (number), `.statusText`, `.headers` (a `Headers` object). +- `VoidApiResponse`: same envelope, `.data` is `undefined` (used by `sendEmail`, `revokeRefreshToken`, …). +- `TextApiResponse`: `.data` is a `string` (used by `database.changePassword`). + +Exception: `backchannel.authorize`, `backchannel.backchannelGrant`, and `tokenExchange.exchangeToken` return domain objects directly (no `.data` wrapper) in node-auth0. + +The new SDKs drop the envelope and return the domain object directly: + +- Token grants return a `TokenResponse` instance. +- `database.signUp` returns a `SignUpResult` object. +- `database.changePassword` returns a `string`. +- `sendEmail` / `sendSms` / `revokeToken` return `void`. + +HTTP metadata (status code, response headers such as `x-request-id`, `retry-after`, rate-limit headers) is available through the typed error objects on failure paths. On success paths, metadata is available via the opt-in `fullResponse` envelope (see [Reading HTTP response metadata](#reading-http-response-metadata-fullresponse)). It is no longer on the bare success value by default. + +The rewrite: delete `.data` indirection on every success path: + +```ts +// before +const resp = await auth0.oauth.clientCredentialsGrant({ audience }); +const token = resp.data.access_token; +const status = resp.status; + +// after +const tokens = await authClient.getTokenByClientCredentials({ audience }); +const token = tokens.accessToken; +``` + +```ts +// before: changePassword returned TextApiResponse +const resp = await auth0.database.changePassword({ email, connection }); +console.log(resp.data); + +// after: returns the string directly +const message = await authClient.database.changePassword({ email, connection }); +console.log(message); +``` + +> `changePassword` requires `connection` plus at least one of `email` or `username`: either identifier is accepted, not `email` alone. + +#### Reading HTTP response metadata (fullResponse) + +When your node-auth0 code reads HTTP response metadata (status, headers) on a success path, migrate to the opt-in envelope rather than dropping the read. This is most common when you track rate limits, log request IDs, or check retry-after headers for dashboard telemetry. + +```ts +// before (node-auth0): metadata on the success envelope +const resp = await auth0.oauth.clientCredentialsGrant({ audience }); +const remaining = resp.headers.get("x-ratelimit-remaining"); +const token = resp.data.access_token; + +// after: opt in to the envelope, read the native Response +const { data, response } = await authClient.getTokenByClientCredentials({ audience, fullResponse: true }); +const remaining = response.headers.get("x-ratelimit-remaining"); +const token = data.accessToken; +``` + +The same opt-in covers the non-token Authentication API methods that node-auth0 wrapped in a `JSONApiResponse` / `TextApiResponse` / `VoidApiResponse`: + +| Method | Bare return | `fullResponse: true` return | +| --- | --- | --- | +| `database.signUp` | `SignUpResult` | `ApiResponse` | +| `database.changePassword` | `string` | `ApiResponse` | +| `passwordless.sendEmail` | `void` | `ApiResponse` (`data` is `undefined`) | +| `passwordless.sendSms` | `void` | `ApiResponse` (`data` is `undefined`) | + +```ts +// before (node-auth0): read the request id off the signup envelope +const resp = await auth0.database.signUp({ email, password, connection }); +const reqId = resp.headers.get("x-request-id"); + +// after: opt in to the envelope +const { data, response } = await authClient.database.signUp({ email, password, connection, fullResponse: true }); +const reqId = response.headers.get("x-request-id"); + +// void-returning methods expose the Response with an undefined `data` +const { response: sendResp } = await authClient.passwordless.sendEmail({ email, fullResponse: true }); +const rateLimit = sendResp.headers.get("x-ratelimit-remaining"); +``` + +Caveats: + +- Pass `fullResponse: true` as a literal, not a variable. Using spread (`{ ...opts, fullResponse: true }`) widens `true` to `boolean`, causing TypeScript overload resolution to fall back to the bare return type. Fix: pass `{ ...opts, fullResponse: true as const }` or include `fullResponse` as an inline literal in the options object. +- Performance: `@auth0/auth0-auth-js` does not cache tokens: every `AuthClient` grant method performs a live token-endpoint round-trip regardless of `fullResponse`, so the flag adds no extra network cost at this layer. (Token caching and reuse live in `@auth0/auth0-server-js`'s session store, not in the auth-js `AuthClient`.) The only in-memory cache in auth-js is for OIDC discovery / JWKS metadata, which is unrelated to `fullResponse`. +- Reserved headers: a caller `Authorization` header is ignored and the telemetry `Auth0-Client` header always wins; `RequestOptions.headers` cannot override them. +- Per-request `customFetch` replaces the base transport for that call but does not inherit mutual TLS (mTLS). If you rely on mTLS, the supplied fetch must itself be mTLS-capable. + +Default to the bare return type. Reach for `fullResponse` only where you actually consumed response metadata on success: rate-limit dashboards, request-id logging for support investigations, or retry-after handling. `MissingCapturedResponseError` is an internal-bug sentinel; you do not normally catch it. + +Gotchas: + +- **Void methods.** Code that did `const r = await auth0.passwordless.sendEmail(...)` and then checked `r.status === 200` must drop that check: by default the method returns `void` and throws on failure. Rely on the thrown error instead (see [Error model](#4-error-model)). +- **Header reads.** Any code reading `resp.headers.get('x-ratelimit-remaining')` on a success path needs the opt-in `fullResponse` envelope. Error paths still surface metadata on the typed error. Search your code for `.headers` on response values. +- **Do not hand-roll a compatibility shim.** Resist reintroducing a custom `{ data, status }` shape to minimize downstream diff. Let the domain object flow through; the SDK's opt-in `fullResponse` envelope is the sanctioned channel when you genuinely need the HTTP Response. + +### 2. Casing + +node-auth0's public API exposes the snake_case wire shape verbatim, on both inputs and outputs. The new SDKs use camelCase for the public API and only translate to snake_case at the HTTP boundary internally. + +Input parameters, field map: + +| node-auth0 (snake_case) | new SDK (camelCase) | +| --- | --- | +| `client_id` | `clientId` | +| `client_secret` | `clientSecret` | +| `refresh_token` | `refreshToken` | +| `redirect_uri` | (via `authorizationParams.redirect_uri` on config / builder) | +| `code_verifier` | `codeVerifier` | +| `phone_number` | `phoneNumber` | +| `auth_req_id` | `authReqId` | +| `binding_message` | `bindingMessage` | +| `subject_token` / `subject_token_type` | `subjectToken` / `subjectTokenType` | +| `given_name` / `family_name` | `givenName` / `familyName` | +| `user_metadata` | `userMetadata` | +| `login_hint` | `loginHint` | + +Output fields, `TokenResponse` field map: + +| node-auth0 `TokenSet` (snake_case) | new SDK `TokenResponse` (camelCase) | +| --- | --- | +| `access_token` | `accessToken` | +| `refresh_token` | `refreshToken` | +| `id_token` | `idToken` | +| `token_type` | `tokenType` | +| `expires_in` (relative) | `expiresAt` (absolute, see [Token expiry](#3-token-expiry)) | +| `scope` | `scope` | +| (none): had to decode id_token yourself | `claims` (already-decoded ID token claims) | +| `authorization_details` | `authorizationDetails` | + +Rename fields on both the arguments you pass in and the fields you read out: + +```ts +// before +const resp = await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); +const newRt = resp.data.refresh_token; +const idToken = resp.data.id_token; + +// after +const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); +const newRt = tokens.refreshToken; +const idToken = tokens.idToken; +``` + +> **Gotcha: keys that look renamed but are your data.** `user_metadata` → `userMetadata` is a rename of the *SDK's* parameter. The object *inside* it (e.g. `{ plan: 'free' }`) is passed through untouched. Do not rename your own metadata keys. The same applies to `authorization_details`. + +### 3. Token expiry + +**This is the highest-risk change in the migration. It is silent, it compiles, and it corrupts session lifetimes.** + +- node-auth0 `TokenSet.expires_in` = the token's lifetime in seconds relative to now (e.g. `86400` for a 24-hour token). This is the raw OAuth `expires_in` from the wire. +- new SDK `TokenResponse.expiresAt` = an absolute Unix timestamp in seconds (e.g. `1786000000`) computed by the SDK as roughly `now + expires_in`. + +Existing node-auth0 code almost always converts the relative value to an absolute deadline itself: + +```ts +// before: very common node-auth0 pattern +const resp = await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); +const expiresAtMs = Date.now() + resp.data.expires_in * 1000; // stored deadline +``` + +If you mechanically rename `expires_in` → `expiresAt` and leave the arithmetic, you get: + +```ts +// WRONG: double-counts "now" +const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); +const expiresAtMs = Date.now() + tokens.expiresAt * 1000; // ~ now + (now + lifetime) → far future +``` + +The stored deadline lands decades in the future, so the token is treated as valid long after it has actually expired. The app does not refresh it, so production 401s follow. + +The rewrite: `expiresAt` is *already* the deadline. Do not add `Date.now()`: + +```ts +// after: correct +const tokens = await authClient.getTokenByRefreshToken({ refreshToken: rt }); +const expiresAtMs = tokens.expiresAt * 1000; // absolute; convert s → ms only if you store ms +``` + +If downstream code genuinely needs the *relative* remaining lifetime (e.g. to set a cookie `Max-Age`), compute it from the absolute value: + +```ts +const secondsRemaining = tokens.expiresAt - Math.floor(Date.now() / 1000); +``` + +To find every instance, grep your code for these patterns and inspect each by hand: + +- `expires_in` +- `Date.now() +` near a token result +- `+ expires` / `* 1000` near a token result +- any stored field named `expiresAt`, `expires_at`, `expiry`, `tokenExpiry` fed from a grant + +Every one of these is a candidate for the double-count bug. + +> **Session apps get this for free.** If you migrate to server-js, the SDK owns expiry math inside `getAccessToken`. Delete your `Date.now() + expires_in * 1000` bookkeeping entirely. + +### 4. Error model + +node-auth0 throws a single error type for Authentication API failures: + +```ts +class AuthApiError extends Error { + name: "AuthApiError"; + error: string; // OAuth error code, e.g. 'invalid_grant' + error_description: string; + statusCode: number; + body: string; + headers: Headers; +} +``` + +The new SDKs throw typed, operation-specific error classes: `TokenByCodeError`, `TokenByRefreshTokenError`, `TokenByClientCredentialsError`, `TokenByPasswordError`, `TokenExchangeError`, `TokenRevocationError`, `PasswordlessStartError`, `PasswordlessChallengeError`, `PasswordlessDbGetTokenError`, `MfaEnrollmentError`, and so on. Each carries a structured `.cause` (the underlying OAuth2 error) rather than flat `error` / `error_description` strings. + +The rewrite: generic catch: + +```ts +// before +try { + await auth0.oauth.refreshTokenGrant({ refresh_token: rt }); +} catch (e) { + if (e instanceof AuthApiError && e.error === "invalid_grant") { + // refresh token revoked/expired + } +} + +// after +import { TokenByRefreshTokenError } from "@auth0/auth0-auth-js"; +try { + await authClient.getTokenByRefreshToken({ refreshToken: rt }); +} catch (e) { + if (e instanceof TokenByRefreshTokenError && e.cause?.error === "invalid_grant") { + // refresh token revoked/expired + } +} +``` + +Import the specific error class for the operation you are calling. If you had one broad `catch (e instanceof AuthApiError)` around several different operations, either widen to catch each operation's error type or check the shared base behavior. Prefer the specific type per call site, since it documents which operation can fail. + +#### MFA detection: use the type guard, not the string + +Multi-factor authentication (MFA). A very common node-auth0 pattern is detecting `mfa_required` by string comparison to route the user into an MFA challenge: + +```ts +// before +try { + await auth0.oauth.passwordGrant({ username, password }); +} catch (e) { + if (e instanceof AuthApiError && e.error === "mfa_required") { + // start MFA flow using e (mfa_token is in the body) + } +} +``` + +The new SDK provides `isMfaRequiredError()`, a type guard that narrows the error and gives typed access to the MFA context (including the `mfa_token`). Use it instead of matching the string: + +```ts +// after +import { isMfaRequiredError } from "@auth0/auth0-auth-js"; +try { + await authClient.getTokenByPassword({ username, password }); +} catch (e) { + if (isMfaRequiredError(e)) { + // e is narrowed; drive the MFA challenge via authClient.mfa.* + } +} +``` + +> After detecting `mfa_required`, the MFA enroll/challenge/verify flow that node-auth0 handled ad hoc now lives on `authClient.mfa.*` (`listAuthenticators`, `enrollAuthenticator`, `challengeAuthenticator`, `verify`, and `deleteAuthenticator`). In server-js, `serverClient.mfa.verify()` also persists the resulting tokens to the session. + +#### ID-token validation types + +node-auth0 exposed `IDTokenValidateOptions` and `IdTokenValidatorError` for callers doing manual ID-token validation. The new SDK validates ID tokens internally during grants and exposes the decoded, validated result as `TokenResponse.claims`. Replace manual validation: + +- Options like `organization`, `nonce`, `maxAge` are passed to the grant call (e.g. `getTokenByCode`), and the SDK validates them and throws a typed error on mismatch, so you no longer construct a validator or catch `IdTokenValidatorError` yourself. +- Read the validated claims from `TokenResponse.claims` instead of decoding the `id_token` string. + +## Verification checklist + +The migration is not complete until every check passes in a single pass. For every node-auth0 auth call you rewrote (here or on the incremental pages), confirm all four cross-cutting changes: + +- [ ] **Return shape**: removed `.data` / `.status` / `.headers` access on the success path. +- [ ] **Casing**: renamed every snake_case field on input args and output reads to camelCase. +- [ ] **Expiry**: any code using the old `expires_in` now uses `expiresAt` as an *absolute* timestamp; no `Date.now() +` was left in front of it. +- [ ] **Errors**: `AuthApiError` catches replaced with the specific typed error (`.cause.error`); `mfa_required` string checks replaced with `isMfaRequiredError()`. + +Then run the project gates and repeat the whole loop if any step fails: + +- [ ] Grep for residue: unmigrated `from 'auth0'` auth imports, `.data.` reads on auth responses, and relative `expires_in` arithmetic. +- [ ] `tsc --noEmit`: catches structural mismatches and type errors. +- [ ] `npm test` (or the project's test command): confirms behavior is preserved. +- [ ] Run the linter if the project has one configured. +- [ ] Confirm files that use `ManagementClient` still import and call it from `auth0`; that code must be untouched. + +Do not declare the migration complete until the loop converges: all steps pass in a single iteration. + +## Continue the migration + +Once the OIDC grants and the four cross-cutting changes are in, migrate the rest at your own pace. Each area lives in its own page. + +### Other authentication flows + +Database signup, passwordless, backchannel (CIBA), token exchange, and `UserInfoClient` lookups: see [`authentication-flows.md`](./authentication-flows.md). + +### Server-side sessions + +Routing to `@auth0/auth0-server-js`, where the SDK owns the login redirect flow, session storage, cookies, token refresh, and logout: see [`server-side-sessions.md`](./server-side-sessions.md). + +### Troubleshooting + +Common questions and failure modes (tokens valid for decades, missing `resp.data`, magic-link default flip, `getUserInfo`, `mfa_required` detection, global config): see [`troubleshooting.md`](./troubleshooting.md). diff --git a/auth-migration/server-side-sessions.md b/auth-migration/server-side-sessions.md new file mode 100644 index 0000000000..d040e2986b --- /dev/null +++ b/auth-migration/server-side-sessions.md @@ -0,0 +1,163 @@ +# Migrating session apps to `@auth0/auth0-server-js` + +This page is part of the [Authentication Migration Guide](./index.md). Read it only when you are routing to **`@auth0/auth0-server-js`**: when you want the SDK to own the login redirect flow, session storage, cookies, token refresh, and logout, instead of hand-rolling that around node-auth0. If you only need stateless token grants, stay on the main guide and [`authentication-flows.md`](./authentication-flows.md); you do not need this page. + +> **Migrating with an AI agent?** Point it at the Auth0 migration skill (the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`). It walks the session lifecycle step by step. + +**This is a rewrite of the session handling, not a method-for-method port.** node-auth0 had no session concept, so there is nothing to translate line-for-line. Instead you *replace* your existing session code (your `express-session` wiring, your token cache, your refresh-on-expiry logic, your logout handler) with the ServerClient lifecycle. You still touch only the auth/session code; routes, views, and business logic stay put. + +- [Mental model](#mental-model) +- [Store setup](#store-setup) +- [The redirect-login lifecycle](#the-redirect-login-lifecycle) +- [Logins without a browser redirect](#logins-without-a-browser-redirect) +- [Backchannel logout](#backchannel-logout) + +## Mental model + +A ServerClient login has three durable pieces: + +1. **Transaction store**: short-lived. Holds the in-flight login: the OAuth `state` and the PKCE (Proof Key for Code Exchange) `code_verifier` between the moment you redirect the user to Auth0 and the moment they come back to your callback. Created at `startInteractiveLogin`, consumed at `completeInteractiveLogin`. +2. **State store**: long-lived. Holds the established session: the user claims plus the access / refresh / ID tokens and their absolute expiry. Read on every subsequent request via `getUser`, `getSession`, `getAccessToken`. +3. **Cookies**: how the two stores key themselves to the browser. With a *stateless* store the session data lives encrypted in the cookie itself; with a *stateful* store the cookie holds only an identifier and the data lives in your backend (Redis, database, and so on). + +node-auth0 exposed none of this; you built equivalents by hand. You are swapping your implementation for the SDK's. + +## Store setup + +`@auth0/auth0-server-js` ships store base classes and cookie-backed implementations: + +- `CookieTransactionStore`: transaction store backed entirely by a cookie. Good default. +- `StatelessStateStore`: session lives encrypted in the cookie. No server-side storage; good for serverless or horizontally-scaled deployments with small sessions. +- `StatefulStateStore`: session lives server-side; the cookie holds an id. Use for large sessions or when you need server-side revocation. +- `AbstractTransactionStore` / `AbstractStateStore`: extend these to back a store with your own storage (Redis, Postgres, and so on). These are the exported base-class names. + +All stores accept a `CookieHandler` so they can integrate with any framework's cookie API. The `storeOptions` generic (`TStoreOptions`) is how you thread per-request context (like the framework `req` / `res`) into store reads and writes; every ServerClient method takes an optional trailing `storeOptions` argument for exactly this. + +```ts +import { ServerClient, CookieTransactionStore, StatelessStateStore } from "@auth0/auth0-server-js"; + +const serverClient = new ServerClient({ + domain: process.env.AUTH0_DOMAIN!, + clientId: process.env.AUTH0_CLIENT_ID!, + clientSecret: process.env.AUTH0_CLIENT_SECRET!, + authorizationParams: { + redirect_uri: "https://app.example.com/callback", + scope: "openid profile email offline_access", // offline_access ⇒ refresh token + audience: "https://api.example.com", + }, + transactionStore: new CookieTransactionStore( + { secret: process.env.SESSION_SECRET! }, + cookieHandler, // CookieHandler implementation + ), + stateStore: new StatelessStateStore( + { secret: process.env.SESSION_SECRET! }, + cookieHandler, // CookieHandler implementation + ), +}); +``` + +## The redirect-login lifecycle + +### 1. Start login: replace the hand-built `/authorize` redirect + +Whatever you did to send the user to Auth0 (a hand-constructed `/authorize` URL, or `express-openid-connect`'s `/login`) becomes: + +```ts +// GET /login +app.get("/login", async (req, res) => { + const authorizationUrl = await serverClient.startInteractiveLogin( + { + authorizationParams: { + /* optional per-login overrides */ + }, + appState: { returnTo: req.query.returnTo || "/" }, // seed appState for round-trip + }, + { req, res }, // storeOptions: lets the transaction store write its cookie + ); + res.redirect(authorizationUrl.href); +}); +``` + +`startInteractiveLogin` generates `state` and PKCE, writes them to the transaction store, and returns the fully-formed authorization URL. + +### 2. Complete login: replace the manual code exchange + +The callback handler that used to call `oauth.authorizationCodeGrant` (or `authorizationCodeGrantWithPKCE`) and then stuff tokens into the session becomes a single call: + +```ts +// GET /callback +app.get("/callback", async (req, res) => { + const callbackUrl = new URL(req.url, `https://${req.headers.host}`); + const { appState } = await serverClient.completeInteractiveLogin(callbackUrl, { req, res }); + // Session is now established in the state store. Tokens are NOT your concern anymore. + res.redirect(appState?.returnTo ?? "/"); +}); +``` + +`completeInteractiveLogin` validates `state`, exchanges the code, validates the ID token, writes the session (user + tokens + absolute expiry) to the state store, and clears the transaction. + +### 3. Read the user or session on later requests + +Replace `req.session.user` reads: + +```ts +const user = await serverClient.getUser({ req, res }); // user claims, or undefined +const session = await serverClient.getSession({ req, res }); // full session data, or undefined +``` + +`getUser` / `getSession` return `undefined` when there is no session or it has expired (the store deletes expired sessions on read), so use that as your "not logged in" signal. + +### 4. Get an access token to call an API: refresh is automatic + +Replace your manual "is the token expired? if so refresh" block: + +```ts +const { accessToken } = await serverClient.getAccessToken({ req, res }); +// If the stored access token is expired and a refresh token exists, +// the SDK refreshes and persists the new tokens transparently. +``` + +This is where the `expires_in` → `expiresAt` hazard disappears entirely: the SDK owns expiry math. For a downstream federated connection token (Token Vault), use `serverClient.getAccessTokenForConnection({ connection }, { req, res })`. + +### 5. Logout: replace manual revoke, session clear, and `/v2/logout` redirect + +```ts +// GET /logout +app.get("/logout", async (req, res) => { + const logoutUrl = await serverClient.logout({ returnTo: "https://app.example.com" }, { req, res }); + res.redirect(logoutUrl.href); +}); +``` + +`logout` clears the session from the state store and returns the Auth0 `/v2/logout` URL. If you also revoked the refresh token on logout (via `oauth.revokeRefreshToken`), call `serverClient.revokeRefreshToken({ req, res })` before redirecting; by default it reads the refresh token from the session, so you do not handle the raw token yourself (it also accepts an explicit `{ token }` if you need to revoke a specific one). + +## Logins without a browser redirect + +Some logins do not use a browser redirect: the password grant, passwordless, CIBA, and custom token exchange. If you used node-auth0 for one of these *and* want a server-js session out of it, use the ServerClient methods that both authenticate and write the session, rather than the low-level auth-js grants: + +| Flow | ServerClient method | +| --- | --- | +| Backchannel / CIBA | `loginBackchannel({ ... }, storeOptions)` | +| Passwordless (send) | `startPasswordless({ connection, email \| phoneNumber, ... }, storeOptions)` | +| Passwordless (verify code → session) | `completePasswordless({ connection, email \| phoneNumber, verificationCode }, storeOptions)` | +| Passwordless magic link (callback → session) | `completePasswordlessMagicLink(url, storeOptions)` | +| Custom token exchange → session | `loginWithCustomTokenExchange({ ... }, storeOptions)` | +| MFA verify → session | `serverClient.mfa.verify({ ... }, storeOptions)` | + +Each of these performs the underlying grant *and* persists the resulting tokens to the state store, so the user is logged in afterward, exactly the behavior you previously wrote by hand after a node-auth0 grant. + +## Backchannel logout + +If you implemented an Auth0 back-channel logout endpoint by hand (validating the logout token, then clearing your session store), replace it with: + +```ts +// POST /backchannel-logout +app.post("/backchannel-logout", async (req, res) => { + await serverClient.handleBackchannelLogout(req.body.logout_token, { req, res }); + res.sendStatus(204); +}); +``` + +It validates the logout token and clears the corresponding session. + +When the session layer is wired, return to the [verification checklist](./index.md#verification-checklist) in the main guide. diff --git a/auth-migration/troubleshooting.md b/auth-migration/troubleshooting.md new file mode 100644 index 0000000000..334a37a698 --- /dev/null +++ b/auth-migration/troubleshooting.md @@ -0,0 +1,32 @@ +# Troubleshooting: FAQ and gotchas + +Common questions and failure modes when migrating off the `auth0` package's Authentication API. This page is part of the [Authentication Migration Guide](./index.md); it assumes the terms defined there. + +> **Migrating with an AI agent?** Point it at the Auth0 migration skill (the `auth0` skill in [`auth0/agent-skills`](https://github.com/auth0/agent-skills), migration intent `migrate-node-auth0`). + +### Do I have to migrate everything at once? +No. The OIDC / token-grant work is a complete, shippable step on its own. You can stay on `auth0` v6 and migrate only OIDC, leaving other auth flows on `AuthenticationClient` for now. See [Optional: migrate only OIDC while staying on v6](./index.md#optional-migrate-only-oidc-while-staying-on-v6). + +### Do I have to migrate the Management API too? +No. `ManagementClient` is out of scope and stays on the `auth0` package. A file importing both `auth0` (for management) and `@auth0/auth0-auth-js` (for authentication) is correct. + +### auth0-auth-js or auth0-server-js: which do I pick? +Default to auth0-auth-js for a low-risk parity migration. Pick auth0-server-js only when you want the SDK to own the login redirect flow, session storage, cookies, refresh, and logout. See [Choosing your target SDK](./index.md#choosing-your-target-sdk). + +### My tokens suddenly look valid for decades. What happened? +You almost certainly left `Date.now() +` in front of `expiresAt`. `expiresAt` is already an absolute Unix timestamp, not a relative lifetime. See [Token expiry](./index.md#3-token-expiry). + +### Where did `resp.data` go? +The new SDKs return the domain object directly. Read `tokens.accessToken`, not `resp.data.access_token`. If you truly need HTTP response metadata on a success path, opt into `fullResponse`. + +### My magic-link passwordless flow stopped sending links. +The `send` default changed from `'link'` (node-auth0) to `'code'` (new SDK). Set `send: 'link'` explicitly if you want magic links. See [Passwordless](./authentication-flows.md#passwordless). + +### Where is `getUserInfo`? +Prefer `TokenResponse.claims`; they are already decoded and validated, with no extra round-trip. For an arbitrary access token, use `authClient.getUserInfo({ accessToken })`. In a session app, use `serverClient.getUser()`. See [UserInfoClient](./authentication-flows.md#userinfoclient). + +### Can I still set a global `headers` / `timeout` / `agent` on the client? +Not on the constructor. Move them to the per-call `RequestOptions` argument (`headers`, `signal: AbortSignal.timeout(ms)`) or wrap `customFetch`. + +### How do I detect `mfa_required` now? +Use the `isMfaRequiredError()` type guard, not a string comparison. It narrows the error and exposes the `mfa_token`. Drive the challenge via `authClient.mfa.*`. See [Error model](./index.md#4-error-model). diff --git a/v6_MIGRATION_GUIDE.md b/v6_MIGRATION_GUIDE.md new file mode 100644 index 0000000000..d1eb6bd699 --- /dev/null +++ b/v6_MIGRATION_GUIDE.md @@ -0,0 +1,158 @@ +# V6 Migration Guide + +A guide to migrating the Auth0 Node.js SDK from `5.x` to `6.x`. + +- [Overall changes](#overall-changes) +- [Breaking changes](#breaking-changes) + - [ConnectionAttributeIdentifier replaced with identifier-specific types](#connectionattributeidentifier-replaced-with-identifier-specific-types) + - [PhoneProviderProtectionBackoffStrategyEnum value change](#phoneproviderprotectionbackoffstrategyenum-value-change) + - [users.federatedConnectionsTokensets removed](#usersfederatedconnectionstokensets-removed) + - [federated_connections_access_tokens removed from connection options](#federated_connections_access_tokens-removed-from-connection-options) + +## Overall changes + +V6 addresses type correctness for database connection attribute identifiers, aligns the phone provider backoff strategy enum with the updated API, and removes the federated connections tokensets user sub-client. There are no changes to the Authentication API — any code written for the Authentication API in `5.x` will continue to work in `6.x`. + +## Breaking changes + +### ConnectionAttributeIdentifier replaced with identifier-specific types + +In v5, all three attribute identifiers (email, phone number, and username) shared a single `ConnectionAttributeIdentifier` type for their `identifier` field. This was incorrect — each identifier type supports different values for `default_method`. + +In v6, `ConnectionAttributeIdentifier` has been removed and replaced with three separate types: + +| Attribute | Old type | New type | `default_method` values | +| -------------- | ------------------------------- | ----------------------------- | ----------------------------- | +| `email` | `ConnectionAttributeIdentifier` | `EmailAttributeIdentifier` | `"password"` \| `"email_otp"` | +| `phone_number` | `ConnectionAttributeIdentifier` | `PhoneAttributeIdentifier` | `"password"` \| `"phone_otp"` | +| `username` | `ConnectionAttributeIdentifier` | `UsernameAttributeIdentifier` | _(no `default_method`)_ | + +**Before (v5):** + +```ts +import { Management } from "auth0"; + +const identifier: Management.ConnectionAttributeIdentifier = { + active: true, + default_method: "email_otp", +}; +``` + +**After (v6):** + +```ts +import { Management } from "auth0"; + +// For email attribute +const emailIdentifier: Management.EmailAttributeIdentifier = { + active: true, + default_method: "email_otp", +}; + +// For phone_number attribute +const phoneIdentifier: Management.PhoneAttributeIdentifier = { + active: true, + default_method: "phone_otp", +}; + +// For username attribute (no default_method) +const usernameIdentifier: Management.UsernameAttributeIdentifier = { + active: true, +}; +``` + +If you were using `ConnectionAttributeIdentifier` as a type annotation in your own code, update it to the appropriate identifier-specific type based on which attribute it applies to. + +--- + +### PhoneProviderProtectionBackoffStrategyEnum value change + +The `PhoneProviderProtectionBackoffStrategyEnum` enum has been updated to reflect a change in the Auth0 API. The `None` variant has been renamed to `Default`, and its string value has changed from `"none"` to `"default"`. + +**Before (v5):** + +```ts +import { Management } from "auth0"; + +const strategy = Management.PhoneProviderProtectionBackoffStrategyEnum.None; // "none" +``` + +**After (v6):** + +```ts +import { Management } from "auth0"; + +const strategy = Management.PhoneProviderProtectionBackoffStrategyEnum.Default; // "default" +``` + +If you were passing this value directly as a string `"none"`, update it to `"default"` to match the updated API. + +--- + +### users.federatedConnectionsTokensets removed + +The `client.users.federatedConnectionsTokensets` sub-client has been removed. This includes the `list()` and `delete()` methods. + +**Before (v5):** + +```ts +// List active federated connection tokensets for a user +const tokensets = await client.users.federatedConnectionsTokensets.list("user_id"); + +// Delete a tokenset +await client.users.federatedConnectionsTokensets.delete("user_id", "tokenset_id"); +``` + +**After (v6):** + +These methods are no longer available. Remove any calls to `client.users.federatedConnectionsTokensets` from your code. + +--- + +### federated_connections_access_tokens removed from connection options + +The `federated_connections_access_tokens` field has been removed from all connection option types, including create and update. This affects OIDC, Azure AD, Google Apps, and other connection strategies. Remove it from any create or update payloads. + +**Before (v5):** + +```ts +// On create +await client.connections.create({ + strategy: "oidc", + name: "my-connection", + options: { + federated_connections_access_tokens: { ... }, + // other options + }, +}); + +// On update +await client.connections.update("connection_id", { + options: { + federated_connections_access_tokens: { ... }, + // other options + }, +}); +``` + +**After (v6):** + +```ts +// On create +await client.connections.create({ + strategy: "oidc", + name: "my-connection", + options: { + // remove federated_connections_access_tokens + // other options + }, +}); + +// On update +await client.connections.update("connection_id", { + options: { + // remove federated_connections_access_tokens + // other options + }, +}); +``` diff --git a/v7_MIGRATION_GUIDE.md b/v7_MIGRATION_GUIDE.md new file mode 100644 index 0000000000..95d366b1e8 --- /dev/null +++ b/v7_MIGRATION_GUIDE.md @@ -0,0 +1,146 @@ +# V7 Migration Guide + +A guide to migrating the Auth0 Node.js SDK from `6.x` to `7.x`. + +> **Migrating with an AI agent?** Point it at the Auth0 migration skill first. The skill lives in [`auth0/agent-skills`](https://github.com/auth0/agent-skills) as the `auth0` skill (migration intent: `migrate-node-auth0`). It encodes the authentication-layer rewrite rules and a verify loop. + +- [Overall changes](#overall-changes) +- [Breaking changes](#breaking-changes) + - [Authentication API removed from the main entrypoint](#authentication-api-removed-from-the-main-entrypoint) + - [Removed exports](#removed-exports) + - [ManagementClient mTLS requires an explicit `fetch`](#managementclient-mtls-requires-an-explicit-fetch) + - [mTLS works with both client secret and client assertion](#mtls-works-with-both-client-secret-and-client-assertion) + - [`domain` must be a bare hostname](#domain-must-be-a-bare-hostname) + - [Token acquisition failures throw `ManagementError`](#token-acquisition-failures-throw-managementerror) + - [`uuid` dependency removed](#uuid-dependency-removed) +- [Migrating authentication code](#migrating-authentication-code) +- [Staying on the legacy entrypoint](#staying-on-the-legacy-entrypoint) + +## Overall changes + +V7 makes `node-auth0` a **Management-API-only SDK**. The Authentication API layer (`AuthenticationClient`, its sub-clients, and `UserInfoClient`) has been removed from the main entrypoint. `ManagementClient` continues to work exactly as before; it now acquires its internal token directly via the client credentials grant rather than through the removed authentication layer. + +If your code only uses `ManagementClient`, the upgrade is small: address the Management-side breaking changes below (mTLS, domain validation, error type) and you are done. If your code uses `AuthenticationClient` or `UserInfoClient`, that code must move to a dedicated package; see [Migrating authentication code](#migrating-authentication-code). + +## Breaking changes + +### Authentication API removed from the main entrypoint + +`AuthenticationClient` and `UserInfoClient` are no longer exported from the `auth0` main entrypoint. The stateless authentication layer now lives in [`@auth0/auth0-auth-js`](https://github.com/auth0/auth0-auth-js), and the server-managed session layer lives in [`@auth0/auth0-server-js`](https://github.com/auth0/auth0-auth-js/tree/main/packages/auth0-server-js). + +**Before (v6):** + +```ts +import { AuthenticationClient, UserInfoClient } from "auth0"; + +const auth = new AuthenticationClient({ domain, clientId, clientSecret }); +const tokens = await auth.oauth.clientCredentialsGrant({ audience }); +``` + +**After (v7):** + +```ts +import { AuthClient } from "@auth0/auth0-auth-js"; + +const auth = new AuthClient({ domain, clientId, clientSecret }); +const tokens = await auth.getTokenByClientCredentials({ audience }); +``` + +The complete method-by-method mapping, the four cross-cutting behavior changes (return shape, casing, token expiry, error model), and the session-app wiring are documented in the dedicated [Authentication Migration Guide](https://github.com/auth0/node-auth0/tree/master/auth-migration). This guide does not repeat that detail. + +If you need the old clients unchanged as a stopgap, they still ship from the [legacy entrypoint](#staying-on-the-legacy-entrypoint). + +### Removed exports + +The following symbols were exported from the main entrypoint in v6 and are removed in v7. Each moves to `@auth0/auth0-auth-js`, or remains available from the `auth0/legacy` entrypoint at its v4.x shape. + +| Removed export (v6) | Replacement in v7 | +| ---------------------------- | ------------------------------------------------------------------------------------- | +| `AuthenticationClient` | `AuthClient` from `@auth0/auth0-auth-js` | +| `UserInfoClient` | `AuthClient.getUserInfo()` from `@auth0/auth0-auth-js`, or read `TokenResponse.claims` | +| `AuthApiError` | Per-operation typed errors from `@auth0/auth0-auth-js` (`TokenByCodeError`, `TokenByRefreshTokenError`, …); use their `.cause` | +| `AuthenticationClientOptions`| `AuthClientOptions` from `@auth0/auth0-auth-js` | +| `IDTokenValidateOptions` | Validation is internal to the grant call; pass `organization` / `nonce` / `maxAge` to the grant and read `TokenResponse.claims` | +| `IdTokenValidatorError` | Thrown internally by the grant as a typed error on claim mismatch | +| `TokenSet` | `TokenResponse` from `@auth0/auth0-auth-js` (camelCase fields; `expiresAt` is absolute) | +| `SUBJECT_TOKEN_TYPES` | Pass the token-type URN string directly to `exchangeToken` in `@auth0/auth0-auth-js` | +| `UserInfoResponse` | Return type of `AuthClient.getUserInfo()` in `@auth0/auth0-auth-js` | +| `UserInfoError` | Typed error from `AuthClient.getUserInfo()` in `@auth0/auth0-auth-js` | +| `ResponseError` | Management API calls throw `ManagementError` | +| `FetchError` | Management API calls throw `ManagementError` | +| `JSONApiResponse` | Responses return the data directly (no wrapper) | + +`ManagementClient`, the `Management` namespace, and `ManagementError` are unchanged and still exported. + +### ManagementClient mTLS requires an explicit `fetch` + +A `ManagementClient` constructed with `useMTLS: true` must now supply an explicit `fetch` option carrying the client certificate. The client throws at construction if `useMTLS` is set without a `fetch`. Previously a missing fetch surfaced as silent `401`s at request time; failing at construction makes the misconfiguration obvious. + +The token endpoint automatically uses the `mtls.{domain}` host when `useMTLS` is enabled. + +```ts +// v7: throws at construction if `fetch` is omitted +const mgmt = new ManagementClient({ + domain, + clientId, + clientSecret, + useMTLS: true, + fetch: mtlsCapableFetch, // now required +}); +``` + +### mTLS works with both client secret and client assertion + +`useMTLS` works with both `clientSecret` and `clientAssertionSigningKey`. mTLS (RFC 8705) is a transport-layer concern: the TLS client certificate yields a certificate-bound token regardless of which client authentication method is used. An explicit `fetch` option is always required when `useMTLS` is set. + +### `domain` must be a bare hostname + +`domain` must be a bare host such as `tenant.us.auth0.com`. A value containing a scheme, slashes, or a query string now throws at construction instead of producing malformed request URLs later. + +```ts +// throws in v7 +new ManagementClient({ domain: "https://tenant.us.auth0.com/", ... }); +// correct +new ManagementClient({ domain: "tenant.us.auth0.com", ... }); +``` + +### Token acquisition failures throw `ManagementError` + +When the internal client-credentials token request fails, the client now throws a `ManagementError` (previously a plain `Error`). The error carries `statusCode` and a parsed `body` with the OAuth error details. A request that exceeds the 10-second timeout throws `ManagementError` with status `408`. + +```ts +import { ManagementError } from "auth0"; + +try { + await mgmt.users.getAll(); +} catch (e) { + if (e instanceof ManagementError) { + console.error(e.statusCode, e.body); + } +} +``` + +### `uuid` dependency removed + +The `uuid` package is no longer a dependency. If your project imported `uuid` transitively through `auth0`, add it to your own `dependencies`. + +## Migrating authentication code + +If your app calls `AuthenticationClient` or `UserInfoClient`, follow the dedicated [Authentication Migration Guide](https://github.com/auth0/node-auth0/tree/master/auth-migration). Start with [`auth-migration/index.md`](https://github.com/auth0/node-auth0/blob/master/auth-migration/index.md) for the OIDC token grants section; the incremental flow, session, and troubleshooting pages live in the same [`auth-migration/`](https://github.com/auth0/node-auth0/tree/master/auth-migration) directory. It covers: + +- Choosing between `@auth0/auth0-auth-js` (stateless token grants) and `@auth0/auth0-server-js` (server-managed sessions). +- The complete method-by-method API mapping for `.oauth`, `.database`, `.passwordless`, `.backchannel`, `.tokenExchange`, and `UserInfoClient`. +- The four cross-cutting behavior changes: return shape (envelope dropped), casing (snake_case → camelCase), token expiry (`expires_in` relative → `expiresAt` absolute, a silent high-risk change), and the typed error model with `isMfaRequiredError()`. +- Wiring the `auth0-server-js` session lifecycle when you want the SDK to own login, cookies, refresh, and logout. + +The Management API is explicitly out of scope in that guide: a file that keeps using `ManagementClient` from `auth0` while importing `@auth0/auth0-auth-js` for authentication is correct and expected. + +## Staying on the legacy entrypoint + +If you cannot migrate the authentication code immediately, the `auth0/legacy` entrypoint still ships `AuthenticationClient` and `UserInfoClient` at their v4.x configuration format and method signatures. This is a stopgap, not a destination; the legacy shapes differ from the current API and will not receive new features. + +```ts +import { AuthenticationClient } from "auth0/legacy"; +``` + +Plan the move to `@auth0/auth0-auth-js` / `@auth0/auth0-server-js` rather than treating the legacy entrypoint as permanent. From 6ed371c59ec2c2aba41076c7b2df648dc5208bd4 Mon Sep 17 00:00:00 2001 From: "ankitatripathi.mp@gmail.com" Date: Mon, 19 Oct 2026 13:42:57 +0530 Subject: [PATCH 3/3] test: fix misplaced ts-expect-error in Stream reconnect test --- src/management/tests/unit/stream/Stream.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/management/tests/unit/stream/Stream.test.ts b/src/management/tests/unit/stream/Stream.test.ts index 670b6f192c..be92ae5906 100644 --- a/src/management/tests/unit/stream/Stream.test.ts +++ b/src/management/tests/unit/stream/Stream.test.ts @@ -1544,7 +1544,7 @@ describe("Stream", () => { describe("SSE stream reconnection - null reconnect body", () => { it("should treat null reconnect body as a failed attempt", async () => { let reconnectCallCount = 0; - const reconnect = async (_lastEventId: string) => { + const reconnect = async (_lastEventId: string): Promise => { reconnectCallCount++; // @ts-expect-error Intentionally returning null to test null-body handling return null;