Files
bigcapital/shared/sdk-ts/src/transactions-locking.ts
Ahmed Bouhuolia ac8dcfed67 feat(sdk): enhance authentication and account management API endpoints
- 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.
2026-03-05 01:07:14 +02:00

62 lines
2.1 KiB
TypeScript

import type { ApiFetcher } from './fetch-utils';
import { paths } from './schema';
import { OpForPath, OpResponseBody } from './utils';
export const TRANSACTIONS_LOCKING_ROUTES = {
LOCK: '/api/transactions-locking/lock',
CANCEL_LOCK: '/api/transactions-locking/cancel-lock',
UNLOCK_PARTIAL: '/api/transactions-locking/unlock-partial',
CANCEL_UNLOCK_PARTIAL: '/api/transactions-locking/cancel-unlock-partial',
LIST: '/api/transactions-locking',
BY_MODULE: '/api/transactions-locking/{module}',
} as const satisfies Record<string, keyof paths>;
export type TransactionsLockingListResponse = OpResponseBody<OpForPath<typeof TRANSACTIONS_LOCKING_ROUTES.LIST, 'get'>>;
export async function fetchTransactionsLocking(fetcher: ApiFetcher): Promise<TransactionsLockingListResponse> {
const get = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.LIST).method('get').create();
const { data } = await get({});
return data;
}
export async function fetchTransactionsLockingByModule(
fetcher: ApiFetcher,
module: string
): Promise<unknown> {
const get = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.BY_MODULE).method('get').create();
const { data } = await get({ module });
return data;
}
export async function lockTransactions(
fetcher: ApiFetcher,
values: Record<string, unknown>
): Promise<void> {
const put = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.LOCK).method('put').create();
await put(values as never);
}
export async function cancelLockTransactions(
fetcher: ApiFetcher,
values: Record<string, unknown>
): Promise<void> {
const put = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.CANCEL_LOCK).method('put').create();
await put(values as never);
}
export async function unlockPartialTransactions(
fetcher: ApiFetcher,
values: Record<string, unknown>
): Promise<void> {
const put = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.UNLOCK_PARTIAL).method('put').create();
await put(values as never);
}
export async function cancelUnlockPartialTransactions(
fetcher: ApiFetcher,
values: Record<string, unknown>
): Promise<void> {
const put = fetcher.path(TRANSACTIONS_LOCKING_ROUTES.CANCEL_UNLOCK_PARTIAL).method('put').create();
await put(values as never);
}