import { DateTime } from 'luxon'; import Roles from 'the-api-roles'; import { Routings } from 'the-api-routings'; import { TheAPI } from './TheApi'; import type { Knex } from 'knex'; import type { IncomingHttpHeaders } from 'http'; import type { Hono } from 'hono'; import type { CrudBuilderOptionsType } from 'the-api-routings'; import type { MethodType, RoutingsInputType, TheApiOptionsType } from './types'; type BodyType = string | number | boolean | HttpPostBodyType; export type HttpPostBodyType = { [key: string]: BodyType | BodyType[]; }; export type TestClientUserType = { id: number; userId?: number; roles?: string[]; token?: string; }; export type TestClientUsersType = Record; export type TestClientTokensType = Record; export type TestClientRolesConfigType = Record; export type TestClientOptionsType = { migrationDirs?: string[]; crudParams?: CrudBuilderOptionsType[]; roles?: Roles | TestClientRolesConfigType; routings?: RoutingsInputType; newRoutings?: (router: Routings) => void; beforeInit?: (theAPI: TheAPI) => void | Promise; theApiOptions?: Omit; }; export type TestClientResultType = { client: TestClient; theAPI: TheAPI; DateTime: typeof DateTime; tokens: TestClientTokensType; users: TestClientUsersType; db: Knex; }; export declare class TestClient { private readonly app; private readonly headers?; private readonly vars; readonly db: Knex; readonly tokens: TestClientTokensType; readonly users: TestClientUsersType; /** * Конструктор принимает всё необходимое — объект сразу готов к работе, * никакого отложенного init(). */ constructor(app: Hono, db: Knex, headers?: IncomingHttpHeaders); deleteTables(): Promise; truncateTables(tables: string[] | string): Promise; request(method: MethodType, requestPath: string, body?: HttpPostBodyType, token?: string): Promise; get(p: string, token?: string): Promise; post(p: string, json: HttpPostBodyType, token?: string): Promise; postForm(p: string, form: HttpPostBodyType, token?: string): Promise; postFormRequest(p: string, obj: Record, token?: string): Promise; private appendFormValue; patch(p: string, json: HttpPostBodyType, token?: string): Promise; delete(p: string, token?: string): Promise; generateGWT(params: Record, expiresIn?: string): string; storeValue(key: string, value: unknown): void; getValue(key: string): unknown; readFile(relativePath: string, type?: string): Promise; } export declare function createRoutings(options?: { migrationDirs?: string[]; }): Routings; /** * Главная точка входа для тестов. * * - Создаёт свежий TheAPI + TestClient на каждый вызов (без singleton) * - Автоматически вызывает theAPI.init() * - Автоматически регистрирует afterAll для очистки */ export declare function testClient(options?: TestClientOptionsType): Promise; export {}; //# sourceMappingURL=testClient.d.ts.map