mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-06-02 16:09:00 +00:00
- Added new authentication routes for user sign-in, sign-up, and password reset functionalities. - Updated account management routes to include bulk delete and validation for accounts. - Refactored type definitions to utilize utility functions for better type safety and clarity. - Introduced new methods for handling user authentication and account operations in the SDK.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { ApiFetcher } from './fetch-utils';
|
|
import { paths } from './schema';
|
|
import { OpForPath, OpRequestBody, OpResponseBody } from './utils';
|
|
|
|
export const API_KEYS_ROUTES = {
|
|
LIST: '/api/api-keys',
|
|
GENERATE: '/api/api-keys/generate',
|
|
REVOKE: '/api/api-keys/{id}/revoke',
|
|
} as const satisfies Record<string, keyof paths>;
|
|
|
|
export type ApiKeysList = OpResponseBody<OpForPath<typeof API_KEYS_ROUTES.LIST, 'get'>>;
|
|
export type GenerateApiKeyBody = OpRequestBody<OpForPath<typeof API_KEYS_ROUTES.GENERATE, 'post'>>;
|
|
|
|
export async function fetchApiKeys(fetcher: ApiFetcher): Promise<ApiKeysList> {
|
|
const get = fetcher.path(API_KEYS_ROUTES.LIST).method('get').create();
|
|
const { data } = await get({});
|
|
return data;
|
|
}
|
|
|
|
export async function generateApiKey(
|
|
fetcher: ApiFetcher,
|
|
body: GenerateApiKeyBody
|
|
): Promise<void> {
|
|
const post = fetcher.path(API_KEYS_ROUTES.GENERATE).method('post').create();
|
|
await post(body);
|
|
}
|
|
|
|
export async function revokeApiKey(fetcher: ApiFetcher, id: number): Promise<void> {
|
|
const put = fetcher.path(API_KEYS_ROUTES.REVOKE).method('put').create();
|
|
await put({ id });
|
|
}
|