- Implemented OAuth endpoints (providers list, authorization, callback, linked accounts management). - Added UI translations for OAuth workflows (auth process messages, linked accounts management). - Extended TypeScript types and React hooks to support OAuth features. - Updated app configuration with OAuth-specific settings and provider details. - Introduced skeleton implementations for authorization and token endpoints in provider mode. - Included unit test and integration hooks for OAuth capabilities.
1169 lines
38 KiB
TypeScript
1169 lines
38 KiB
TypeScript
// This file is auto-generated by @hey-api/openapi-ts
|
|
/* eslint-disable */
|
|
|
|
import { type Client, type Options as Options2, type TDataShape, urlSearchParamsBodySerializer } from './client';
|
|
import { client } from './client.gen';
|
|
import type { AdminActivateUserData, AdminActivateUserErrors, AdminActivateUserResponses, AdminAddOrganizationMemberData, AdminAddOrganizationMemberErrors, AdminAddOrganizationMemberResponses, AdminBulkUserActionData, AdminBulkUserActionErrors, AdminBulkUserActionResponses, AdminCreateOrganizationData, AdminCreateOrganizationErrors, AdminCreateOrganizationResponses, AdminCreateUserData, AdminCreateUserErrors, AdminCreateUserResponses, AdminDeactivateUserData, AdminDeactivateUserErrors, AdminDeactivateUserResponses, AdminDeleteOrganizationData, AdminDeleteOrganizationErrors, AdminDeleteOrganizationResponses, AdminDeleteUserData, AdminDeleteUserErrors, AdminDeleteUserResponses, AdminGetOrganizationData, AdminGetOrganizationErrors, AdminGetOrganizationResponses, AdminGetStatsData, AdminGetStatsResponses, AdminGetUserData, AdminGetUserErrors, AdminGetUserResponses, AdminListOrganizationMembersData, AdminListOrganizationMembersErrors, AdminListOrganizationMembersResponses, AdminListOrganizationsData, AdminListOrganizationsErrors, AdminListOrganizationsResponses, AdminListSessionsData, AdminListSessionsErrors, AdminListSessionsResponses, AdminListUsersData, AdminListUsersErrors, AdminListUsersResponses, AdminRemoveOrganizationMemberData, AdminRemoveOrganizationMemberErrors, AdminRemoveOrganizationMemberResponses, AdminUpdateOrganizationData, AdminUpdateOrganizationErrors, AdminUpdateOrganizationResponses, AdminUpdateUserData, AdminUpdateUserErrors, AdminUpdateUserResponses, ChangeCurrentUserPasswordData, ChangeCurrentUserPasswordErrors, ChangeCurrentUserPasswordResponses, CleanupExpiredSessionsData, CleanupExpiredSessionsResponses, ConfirmPasswordResetData, ConfirmPasswordResetErrors, ConfirmPasswordResetResponses, DeleteUserData, DeleteUserErrors, DeleteUserResponses, GetCurrentUserProfileData, GetCurrentUserProfileResponses, GetMyOrganizationsData, GetMyOrganizationsErrors, GetMyOrganizationsResponses, GetOauthAuthorizationUrlData, GetOauthAuthorizationUrlErrors, GetOauthAuthorizationUrlResponses, GetOauthServerMetadataData, GetOauthServerMetadataResponses, GetOrganizationData, GetOrganizationErrors, GetOrganizationMembersData, GetOrganizationMembersErrors, GetOrganizationMembersResponses, GetOrganizationResponses, GetUserByIdData, GetUserByIdErrors, GetUserByIdResponses, HandleOauthCallbackData, HandleOauthCallbackErrors, HandleOauthCallbackResponses, HealthCheckData, HealthCheckResponses, ListMySessionsData, ListMySessionsResponses, ListOauthAccountsData, ListOauthAccountsResponses, ListOauthProvidersData, ListOauthProvidersResponses, ListUsersData, ListUsersErrors, ListUsersResponses, LoginData, LoginErrors, LoginOauthData, LoginOauthErrors, LoginOauthResponses, LoginResponses, LogoutAllData, LogoutAllResponses, LogoutData, LogoutErrors, LogoutResponses, OauthProviderAuthorizeData, OauthProviderAuthorizeErrors, OauthProviderAuthorizeResponses, OauthProviderRevokeData, OauthProviderRevokeErrors, OauthProviderRevokeResponses, OauthProviderTokenData, OauthProviderTokenErrors, OauthProviderTokenResponses, RefreshTokenData, RefreshTokenErrors, RefreshTokenResponses, RegisterData, RegisterErrors, RegisterOauthClientData, RegisterOauthClientErrors, RegisterOauthClientResponses, RegisterResponses, RequestPasswordResetData, RequestPasswordResetErrors, RequestPasswordResetResponses, RevokeSessionData, RevokeSessionErrors, RevokeSessionResponses, RootGetData, RootGetResponses, StartOauthLinkData, StartOauthLinkErrors, StartOauthLinkResponses, UnlinkOauthAccountData, UnlinkOauthAccountErrors, UnlinkOauthAccountResponses, UpdateCurrentUserData, UpdateCurrentUserErrors, UpdateCurrentUserResponses, UpdateOrganizationData, UpdateOrganizationErrors, UpdateOrganizationResponses, UpdateUserData, UpdateUserErrors, UpdateUserResponses } from './types.gen';
|
|
|
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
|
|
/**
|
|
* You can provide a client instance returned by `createClient()` instead of
|
|
* individual options. This might be also useful if you want to implement a
|
|
* custom client.
|
|
*/
|
|
client?: Client;
|
|
/**
|
|
* You can pass arbitrary values through the `meta` object. This can be
|
|
* used to access values that aren't defined as part of the SDK function.
|
|
*/
|
|
meta?: Record<string, unknown>;
|
|
};
|
|
|
|
/**
|
|
* Root
|
|
*/
|
|
export const rootGet = <ThrowOnError extends boolean = false>(options?: Options<RootGetData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<RootGetResponses, unknown, ThrowOnError>({
|
|
responseType: 'text',
|
|
url: '/',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Health Check
|
|
*
|
|
* Check the health status of the API and its dependencies
|
|
*/
|
|
export const healthCheck = <ThrowOnError extends boolean = false>(options?: Options<HealthCheckData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<HealthCheckResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/health',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Register User
|
|
*
|
|
* Register a new user.
|
|
*
|
|
* Returns:
|
|
* The created user information.
|
|
*/
|
|
export const register = <ThrowOnError extends boolean = false>(options: Options<RegisterData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<RegisterResponses, RegisterErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/auth/register',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Login
|
|
*
|
|
* Login with username and password.
|
|
*
|
|
* Creates a new session for this device.
|
|
*
|
|
* Returns:
|
|
* Access and refresh tokens.
|
|
*/
|
|
export const login = <ThrowOnError extends boolean = false>(options: Options<LoginData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<LoginResponses, LoginErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/auth/login',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Login Oauth
|
|
*
|
|
* OAuth2-compatible login endpoint, used by the OpenAPI UI.
|
|
*
|
|
* Creates a new session for this device.
|
|
*
|
|
* Returns:
|
|
* Access and refresh tokens.
|
|
*/
|
|
export const loginOauth = <ThrowOnError extends boolean = false>(options: Options<LoginOauthData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<LoginOauthResponses, LoginOauthErrors, ThrowOnError>({
|
|
...urlSearchParamsBodySerializer,
|
|
responseType: 'json',
|
|
url: '/api/v1/auth/login/oauth',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Refresh Token
|
|
*
|
|
* Refresh access token using a refresh token.
|
|
*
|
|
* Validates that the session is still active before issuing new tokens.
|
|
*
|
|
* Returns:
|
|
* New access and refresh tokens.
|
|
*/
|
|
export const refreshToken = <ThrowOnError extends boolean = false>(options: Options<RefreshTokenData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<RefreshTokenResponses, RefreshTokenErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/auth/refresh',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Request Password Reset
|
|
*
|
|
* Request a password reset link.
|
|
*
|
|
* An email will be sent with a reset link if the email exists.
|
|
* Always returns success to prevent email enumeration.
|
|
*
|
|
* **Rate Limit**: 3 requests/minute
|
|
*/
|
|
export const requestPasswordReset = <ThrowOnError extends boolean = false>(options: Options<RequestPasswordResetData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<RequestPasswordResetResponses, RequestPasswordResetErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/auth/password-reset/request',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Confirm Password Reset
|
|
*
|
|
* Reset password using a token from email.
|
|
*
|
|
* **Rate Limit**: 5 requests/minute
|
|
*/
|
|
export const confirmPasswordReset = <ThrowOnError extends boolean = false>(options: Options<ConfirmPasswordResetData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<ConfirmPasswordResetResponses, ConfirmPasswordResetErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/auth/password-reset/confirm',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Logout from Current Device
|
|
*
|
|
* Logout from the current device only.
|
|
*
|
|
* Other devices will remain logged in.
|
|
*
|
|
* Requires the refresh token to identify which session to terminate.
|
|
*
|
|
* **Rate Limit**: 10 requests/minute
|
|
*/
|
|
export const logout = <ThrowOnError extends boolean = false>(options: Options<LogoutData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<LogoutResponses, LogoutErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/auth/logout',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Logout from All Devices
|
|
*
|
|
* Logout from ALL devices.
|
|
*
|
|
* This will terminate all active sessions for the current user.
|
|
* You will need to log in again on all devices.
|
|
*
|
|
* **Rate Limit**: 5 requests/minute
|
|
*/
|
|
export const logoutAll = <ThrowOnError extends boolean = false>(options?: Options<LogoutAllData, ThrowOnError>) => {
|
|
return (options?.client ?? client).post<LogoutAllResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/auth/logout-all',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List OAuth Providers
|
|
*
|
|
* Get list of enabled OAuth providers for the login/register UI.
|
|
*
|
|
* Returns:
|
|
* List of enabled providers with display info.
|
|
*/
|
|
export const listOauthProviders = <ThrowOnError extends boolean = false>(options?: Options<ListOauthProvidersData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<ListOauthProvidersResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/providers',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get OAuth Authorization URL
|
|
*
|
|
* Get the authorization URL to redirect the user to the OAuth provider.
|
|
*
|
|
* The frontend should redirect the user to the returned URL.
|
|
* After authentication, the provider will redirect back to the callback URL.
|
|
*
|
|
* **Rate Limit**: 10 requests/minute
|
|
*/
|
|
export const getOauthAuthorizationUrl = <ThrowOnError extends boolean = false>(options: Options<GetOauthAuthorizationUrlData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<GetOauthAuthorizationUrlResponses, GetOauthAuthorizationUrlErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/authorize/{provider}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* OAuth Callback
|
|
*
|
|
* Handle OAuth callback from provider.
|
|
*
|
|
* The frontend should call this endpoint with the code and state
|
|
* parameters received from the OAuth provider redirect.
|
|
*
|
|
* Returns:
|
|
* JWT tokens for the authenticated user.
|
|
*
|
|
* **Rate Limit**: 10 requests/minute
|
|
*/
|
|
export const handleOauthCallback = <ThrowOnError extends boolean = false>(options: Options<HandleOauthCallbackData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<HandleOauthCallbackResponses, HandleOauthCallbackErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/callback/{provider}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List Linked OAuth Accounts
|
|
*
|
|
* Get list of OAuth accounts linked to the current user.
|
|
*
|
|
* Requires authentication.
|
|
*/
|
|
export const listOauthAccounts = <ThrowOnError extends boolean = false>(options?: Options<ListOauthAccountsData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<ListOauthAccountsResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/oauth/accounts',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Unlink OAuth Account
|
|
*
|
|
* Unlink an OAuth provider from the current user.
|
|
*
|
|
* The user must have either a password set or another OAuth provider
|
|
* linked to ensure they can still log in.
|
|
*
|
|
* **Rate Limit**: 5 requests/minute
|
|
*/
|
|
export const unlinkOauthAccount = <ThrowOnError extends boolean = false>(options: Options<UnlinkOauthAccountData, ThrowOnError>) => {
|
|
return (options.client ?? client).delete<UnlinkOauthAccountResponses, UnlinkOauthAccountErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/oauth/accounts/{provider}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Start Account Linking
|
|
*
|
|
* Start the OAuth flow to link a new provider to the current user.
|
|
*
|
|
* This is a convenience endpoint that redirects to /authorize/{provider}
|
|
* with the current user context.
|
|
*
|
|
* **Rate Limit**: 10 requests/minute
|
|
*/
|
|
export const startOauthLink = <ThrowOnError extends boolean = false>(options: Options<StartOauthLinkData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<StartOauthLinkResponses, StartOauthLinkErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/oauth/link/{provider}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* OAuth Server Metadata
|
|
*
|
|
* OAuth 2.0 Authorization Server Metadata (RFC 8414).
|
|
*
|
|
* Returns server metadata including supported endpoints, scopes,
|
|
* and capabilities for MCP clients.
|
|
*/
|
|
export const getOauthServerMetadata = <ThrowOnError extends boolean = false>(options?: Options<GetOauthServerMetadataData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<GetOauthServerMetadataResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/.well-known/oauth-authorization-server',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Authorization Endpoint (Skeleton)
|
|
*
|
|
* OAuth 2.0 Authorization Endpoint.
|
|
*
|
|
* **NOTE**: This is a skeleton implementation. In a full implementation,
|
|
* this would:
|
|
* 1. Validate client_id and redirect_uri
|
|
* 2. Display consent screen to user
|
|
* 3. Generate authorization code
|
|
* 4. Redirect back to client with code
|
|
*
|
|
* Currently returns a 501 Not Implemented response.
|
|
*/
|
|
export const oauthProviderAuthorize = <ThrowOnError extends boolean = false>(options: Options<OauthProviderAuthorizeData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<OauthProviderAuthorizeResponses, OauthProviderAuthorizeErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/provider/authorize',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Token Endpoint (Skeleton)
|
|
*
|
|
* OAuth 2.0 Token Endpoint.
|
|
*
|
|
* **NOTE**: This is a skeleton implementation. In a full implementation,
|
|
* this would exchange authorization codes for access tokens.
|
|
*
|
|
* Currently returns a 501 Not Implemented response.
|
|
*/
|
|
export const oauthProviderToken = <ThrowOnError extends boolean = false>(options: Options<OauthProviderTokenData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<OauthProviderTokenResponses, OauthProviderTokenErrors, ThrowOnError>({
|
|
...urlSearchParamsBodySerializer,
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/provider/token',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Token Revocation Endpoint (Skeleton)
|
|
*
|
|
* OAuth 2.0 Token Revocation Endpoint (RFC 7009).
|
|
*
|
|
* **NOTE**: This is a skeleton implementation.
|
|
*
|
|
* Currently returns a 501 Not Implemented response.
|
|
*/
|
|
export const oauthProviderRevoke = <ThrowOnError extends boolean = false>(options: Options<OauthProviderRevokeData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<OauthProviderRevokeResponses, OauthProviderRevokeErrors, ThrowOnError>({
|
|
...urlSearchParamsBodySerializer,
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/provider/revoke',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Register OAuth Client (Admin)
|
|
*
|
|
* Register a new OAuth client (admin only).
|
|
*
|
|
* This endpoint allows creating MCP clients that can authenticate
|
|
* against this API.
|
|
*
|
|
* **NOTE**: This is a minimal implementation.
|
|
*/
|
|
export const registerOauthClient = <ThrowOnError extends boolean = false>(options: Options<RegisterOauthClientData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<RegisterOauthClientResponses, RegisterOauthClientErrors, ThrowOnError>({
|
|
...urlSearchParamsBodySerializer,
|
|
responseType: 'json',
|
|
url: '/api/v1/oauth/provider/clients',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List Users
|
|
*
|
|
* List all users with pagination, filtering, and sorting (admin only).
|
|
*
|
|
* **Authentication**: Required (Bearer token)
|
|
* **Authorization**: Superuser only
|
|
*
|
|
* **Filtering**: is_active, is_superuser
|
|
* **Sorting**: Any user field (email, first_name, last_name, created_at, etc.)
|
|
*
|
|
* **Rate Limit**: 60 requests/minute
|
|
*/
|
|
export const listUsers = <ThrowOnError extends boolean = false>(options?: Options<ListUsersData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<ListUsersResponses, ListUsersErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/users',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get Current User
|
|
*
|
|
* Get the current authenticated user's profile.
|
|
*
|
|
* **Authentication**: Required (Bearer token)
|
|
*
|
|
* **Rate Limit**: 60 requests/minute
|
|
*/
|
|
export const getCurrentUserProfile = <ThrowOnError extends boolean = false>(options?: Options<GetCurrentUserProfileData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<GetCurrentUserProfileResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/users/me',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Update Current User
|
|
*
|
|
* Update the current authenticated user's profile.
|
|
*
|
|
* Users can update their own profile information (except is_superuser).
|
|
*
|
|
* **Authentication**: Required (Bearer token)
|
|
*
|
|
* **Rate Limit**: 30 requests/minute
|
|
*/
|
|
export const updateCurrentUser = <ThrowOnError extends boolean = false>(options: Options<UpdateCurrentUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).patch<UpdateCurrentUserResponses, UpdateCurrentUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/users/me',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Delete User
|
|
*
|
|
* Delete a specific user by their ID.
|
|
*
|
|
* **Authentication**: Required (Bearer token)
|
|
* **Authorization**: Superuser only
|
|
*
|
|
* **Rate Limit**: 10 requests/minute
|
|
*
|
|
* **Note**: This performs a hard delete. Consider implementing soft deletes for production.
|
|
*/
|
|
export const deleteUser = <ThrowOnError extends boolean = false>(options: Options<DeleteUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).delete<DeleteUserResponses, DeleteUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/users/{user_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get User by ID
|
|
*
|
|
* Get a specific user by their ID.
|
|
*
|
|
* **Authentication**: Required (Bearer token)
|
|
* **Authorization**:
|
|
* - Regular users: Can only access their own profile
|
|
* - Superusers: Can access any profile
|
|
*
|
|
* **Rate Limit**: 60 requests/minute
|
|
*/
|
|
export const getUserById = <ThrowOnError extends boolean = false>(options: Options<GetUserByIdData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<GetUserByIdResponses, GetUserByIdErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/users/{user_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Update User
|
|
*
|
|
* Update a specific user by their ID.
|
|
*
|
|
* **Authentication**: Required (Bearer token)
|
|
* **Authorization**:
|
|
* - Regular users: Can only update their own profile (except is_superuser)
|
|
* - Superusers: Can update any profile
|
|
*
|
|
* **Rate Limit**: 30 requests/minute
|
|
*/
|
|
export const updateUser = <ThrowOnError extends boolean = false>(options: Options<UpdateUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).patch<UpdateUserResponses, UpdateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/users/{user_id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Change Current User Password
|
|
*
|
|
* Change the current authenticated user's password.
|
|
*
|
|
* Requires the current password for verification.
|
|
*
|
|
* **Authentication**: Required (Bearer token)
|
|
*
|
|
* **Rate Limit**: 5 requests/minute
|
|
*/
|
|
export const changeCurrentUserPassword = <ThrowOnError extends boolean = false>(options: Options<ChangeCurrentUserPasswordData, ThrowOnError>) => {
|
|
return (options.client ?? client).patch<ChangeCurrentUserPasswordResponses, ChangeCurrentUserPasswordErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/users/me/password',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* List My Active Sessions
|
|
*
|
|
* Get a list of all active sessions for the current user.
|
|
*
|
|
* This shows where you're currently logged in.
|
|
*
|
|
* **Rate Limit**: 30 requests/minute
|
|
*/
|
|
export const listMySessions = <ThrowOnError extends boolean = false>(options?: Options<ListMySessionsData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<ListMySessionsResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/sessions/me',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Revoke Specific Session
|
|
*
|
|
* Revoke a specific session by ID.
|
|
*
|
|
* This logs you out from that particular device.
|
|
* You can only revoke your own sessions.
|
|
*
|
|
* **Rate Limit**: 10 requests/minute
|
|
*/
|
|
export const revokeSession = <ThrowOnError extends boolean = false>(options: Options<RevokeSessionData, ThrowOnError>) => {
|
|
return (options.client ?? client).delete<RevokeSessionResponses, RevokeSessionErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/sessions/{session_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Cleanup Expired Sessions
|
|
*
|
|
* Remove expired sessions for the current user.
|
|
*
|
|
* This is a cleanup operation to remove old session records.
|
|
*
|
|
* **Rate Limit**: 5 requests/minute
|
|
*/
|
|
export const cleanupExpiredSessions = <ThrowOnError extends boolean = false>(options?: Options<CleanupExpiredSessionsData, ThrowOnError>) => {
|
|
return (options?.client ?? client).delete<CleanupExpiredSessionsResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/sessions/me/expired',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Get Dashboard Stats
|
|
*
|
|
* Get aggregated statistics for the admin dashboard (admin only)
|
|
*/
|
|
export const adminGetStats = <ThrowOnError extends boolean = false>(options?: Options<AdminGetStatsData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<AdminGetStatsResponses, unknown, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/stats',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: List All Users
|
|
*
|
|
* Get paginated list of all users with filtering and search (admin only)
|
|
*/
|
|
export const adminListUsers = <ThrowOnError extends boolean = false>(options?: Options<AdminListUsersData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<AdminListUsersResponses, AdminListUsersErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Create User
|
|
*
|
|
* Create a new user (admin only)
|
|
*/
|
|
export const adminCreateUser = <ThrowOnError extends boolean = false>(options: Options<AdminCreateUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<AdminCreateUserResponses, AdminCreateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Delete User
|
|
*
|
|
* Soft delete a user (admin only)
|
|
*/
|
|
export const adminDeleteUser = <ThrowOnError extends boolean = false>(options: Options<AdminDeleteUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).delete<AdminDeleteUserResponses, AdminDeleteUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users/{user_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Get User Details
|
|
*
|
|
* Get detailed user information (admin only)
|
|
*/
|
|
export const adminGetUser = <ThrowOnError extends boolean = false>(options: Options<AdminGetUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<AdminGetUserResponses, AdminGetUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users/{user_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Update User
|
|
*
|
|
* Update user information (admin only)
|
|
*/
|
|
export const adminUpdateUser = <ThrowOnError extends boolean = false>(options: Options<AdminUpdateUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).put<AdminUpdateUserResponses, AdminUpdateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users/{user_id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Activate User
|
|
*
|
|
* Activate a user account (admin only)
|
|
*/
|
|
export const adminActivateUser = <ThrowOnError extends boolean = false>(options: Options<AdminActivateUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<AdminActivateUserResponses, AdminActivateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users/{user_id}/activate',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Deactivate User
|
|
*
|
|
* Deactivate a user account (admin only)
|
|
*/
|
|
export const adminDeactivateUser = <ThrowOnError extends boolean = false>(options: Options<AdminDeactivateUserData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<AdminDeactivateUserResponses, AdminDeactivateUserErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users/{user_id}/deactivate',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Bulk User Action
|
|
*
|
|
* Perform bulk actions on multiple users (admin only)
|
|
*/
|
|
export const adminBulkUserAction = <ThrowOnError extends boolean = false>(options: Options<AdminBulkUserActionData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<AdminBulkUserActionResponses, AdminBulkUserActionErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/users/bulk-action',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: List Organizations
|
|
*
|
|
* Get paginated list of all organizations (admin only)
|
|
*/
|
|
export const adminListOrganizations = <ThrowOnError extends boolean = false>(options?: Options<AdminListOrganizationsData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<AdminListOrganizationsResponses, AdminListOrganizationsErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Create Organization
|
|
*
|
|
* Create a new organization (admin only)
|
|
*/
|
|
export const adminCreateOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminCreateOrganizationData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<AdminCreateOrganizationResponses, AdminCreateOrganizationErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Delete Organization
|
|
*
|
|
* Delete an organization (admin only)
|
|
*/
|
|
export const adminDeleteOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminDeleteOrganizationData, ThrowOnError>) => {
|
|
return (options.client ?? client).delete<AdminDeleteOrganizationResponses, AdminDeleteOrganizationErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations/{org_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Get Organization Details
|
|
*
|
|
* Get detailed organization information (admin only)
|
|
*/
|
|
export const adminGetOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminGetOrganizationData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<AdminGetOrganizationResponses, AdminGetOrganizationErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations/{org_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Update Organization
|
|
*
|
|
* Update organization information (admin only)
|
|
*/
|
|
export const adminUpdateOrganization = <ThrowOnError extends boolean = false>(options: Options<AdminUpdateOrganizationData, ThrowOnError>) => {
|
|
return (options.client ?? client).put<AdminUpdateOrganizationResponses, AdminUpdateOrganizationErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations/{org_id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: List Organization Members
|
|
*
|
|
* Get all members of an organization (admin only)
|
|
*/
|
|
export const adminListOrganizationMembers = <ThrowOnError extends boolean = false>(options: Options<AdminListOrganizationMembersData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<AdminListOrganizationMembersResponses, AdminListOrganizationMembersErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations/{org_id}/members',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Add Member to Organization
|
|
*
|
|
* Add a user to an organization (admin only)
|
|
*/
|
|
export const adminAddOrganizationMember = <ThrowOnError extends boolean = false>(options: Options<AdminAddOrganizationMemberData, ThrowOnError>) => {
|
|
return (options.client ?? client).post<AdminAddOrganizationMemberResponses, AdminAddOrganizationMemberErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations/{org_id}/members',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: Remove Member from Organization
|
|
*
|
|
* Remove a user from an organization (admin only)
|
|
*/
|
|
export const adminRemoveOrganizationMember = <ThrowOnError extends boolean = false>(options: Options<AdminRemoveOrganizationMemberData, ThrowOnError>) => {
|
|
return (options.client ?? client).delete<AdminRemoveOrganizationMemberResponses, AdminRemoveOrganizationMemberErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/organizations/{org_id}/members/{user_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Admin: List All Sessions
|
|
*
|
|
* List all sessions across all users (admin only).
|
|
*
|
|
* Returns paginated list of sessions with user information.
|
|
* Useful for admin dashboard statistics and session monitoring.
|
|
*/
|
|
export const adminListSessions = <ThrowOnError extends boolean = false>(options?: Options<AdminListSessionsData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<AdminListSessionsResponses, AdminListSessionsErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/admin/sessions',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get My Organizations
|
|
*
|
|
* Get all organizations the current user belongs to
|
|
*/
|
|
export const getMyOrganizations = <ThrowOnError extends boolean = false>(options?: Options<GetMyOrganizationsData, ThrowOnError>) => {
|
|
return (options?.client ?? client).get<GetMyOrganizationsResponses, GetMyOrganizationsErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/organizations/me',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get Organization Details
|
|
*
|
|
* Get details of an organization the user belongs to
|
|
*/
|
|
export const getOrganization = <ThrowOnError extends boolean = false>(options: Options<GetOrganizationData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<GetOrganizationResponses, GetOrganizationErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/organizations/{organization_id}',
|
|
...options
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Update Organization
|
|
*
|
|
* Update organization details (admin/owner only)
|
|
*/
|
|
export const updateOrganization = <ThrowOnError extends boolean = false>(options: Options<UpdateOrganizationData, ThrowOnError>) => {
|
|
return (options.client ?? client).put<UpdateOrganizationResponses, UpdateOrganizationErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/organizations/{organization_id}',
|
|
...options,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...options.headers
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Get Organization Members
|
|
*
|
|
* Get all members of an organization (members can view)
|
|
*/
|
|
export const getOrganizationMembers = <ThrowOnError extends boolean = false>(options: Options<GetOrganizationMembersData, ThrowOnError>) => {
|
|
return (options.client ?? client).get<GetOrganizationMembersResponses, GetOrganizationMembersErrors, ThrowOnError>({
|
|
responseType: 'json',
|
|
security: [
|
|
{
|
|
scheme: 'bearer',
|
|
type: 'http'
|
|
}
|
|
],
|
|
url: '/api/v1/organizations/{organization_id}/members',
|
|
...options
|
|
});
|
|
};
|