feat: переработать кастомизацию HttpClient

- добавлен плоский ApiConfig с lifecycle hooks
- добавлены ApiError, retry context, timeout и кастомные parser/serializer
- обновлены примеры, документация и тесты под новый API
This commit is contained in:
2026-06-30 23:52:06 +03:00
parent fe5d3ae091
commit 6662224a9a
9 changed files with 719 additions and 217 deletions

View File

@@ -251,7 +251,7 @@ describe('Generator', () => {
expect(content).toContain('guest');
}, 30000);
test('должен обработать Bearer authentication', async () => {
test('должен генерировать hooks для авторизации', async () => {
const outputPath = join(tempDir, 'output');
const config: GeneratorConfig = {
inputPath: FIXTURES.WITH_AUTH,
@@ -265,8 +265,11 @@ describe('Generator', () => {
const generatedFile = join(outputPath, 'http-client.ts');
const content = await readTextFile(generatedFile);
// Проверяем наличие методов для работы с токеном
expect(content).toContain('setSecurityData');
// Проверяем наличие hooks для добавления авторизации
expect(content).toContain('onRequest?: RequestInterceptor');
expect(content).toContain('secure?: boolean');
expect(content).not.toContain('baseApiParams');
expect(content).not.toContain('setSecurityData');
}, 30000);
test('должен использовать baseUrl из servers', async () => {