mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-06-03 00:19:01 +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.
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import type { ApiFetcher } from './fetch-utils';
|
|
import { paths } from './schema';
|
|
import { OpForPath, OpQueryParams, OpRequestBody, OpResponseBody } from './utils';
|
|
|
|
export const SETTINGS_ROUTES = {
|
|
GET_SAVE: '/api/settings',
|
|
} as const satisfies Record<string, keyof paths>;
|
|
|
|
export type SettingsResponse = OpResponseBody<OpForPath<typeof SETTINGS_ROUTES.GET_SAVE, 'get'>>;
|
|
export type SaveSettingsBody = OpRequestBody<OpForPath<typeof SETTINGS_ROUTES.GET_SAVE, 'put'>>;
|
|
export type GetSettingsQuery = OpQueryParams<OpForPath<typeof SETTINGS_ROUTES.GET_SAVE, 'get'>>;
|
|
|
|
export async function fetchSettings(
|
|
fetcher: ApiFetcher,
|
|
query?: GetSettingsQuery
|
|
): Promise<SettingsResponse> {
|
|
const get = fetcher.path(SETTINGS_ROUTES.GET_SAVE).method('get').create();
|
|
const { data } = await (get as (params?: GetSettingsQuery) => Promise<{ data: SettingsResponse }>)(
|
|
query ?? {}
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export async function saveSettings(
|
|
fetcher: ApiFetcher,
|
|
values: SaveSettingsBody
|
|
): Promise<void> {
|
|
const put = fetcher.path(SETTINGS_ROUTES.GET_SAVE).method('put').create();
|
|
await put(values);
|
|
}
|