ts-openapi-codegen 2.0.0-beta.7 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -0
- package/README.rus.md +104 -0
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +4 -0
- package/dist/core/__tests__/WriteClient.test.js +3 -0
- package/dist/core/types/base/Templates.model.d.ts +3 -0
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.js +3 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +9 -3
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +5 -3
- package/dist/templatesCompiled/client/core/ApiError.js +1 -1
- package/dist/templatesCompiled/client/core/CancelablePromise.d.ts +1 -0
- package/dist/templatesCompiled/client/core/CancelablePromise.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/CancelablePromise.js +9 -2
- package/dist/templatesCompiled/client/core/HttpStatusCode.d.ts +1 -0
- package/dist/templatesCompiled/client/core/HttpStatusCode.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/HttpStatusCode.js +9 -2
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/{createExecutorAdapter.js → executor/createExecutorAdapter.js} +3 -3
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts +8 -0
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +18 -0
- package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.d.ts +8 -0
- package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.js +18 -0
- package/dist/templatesCompiled/client/core/{request-executor.d.ts → interceptors/interceptors.d.ts} +2 -1
- package/dist/templatesCompiled/client/core/interceptors/interceptors.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/interceptors/interceptors.js +18 -0
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.d.ts +8 -0
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +18 -0
- package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportClient.js +14 -10
- package/dist/templatesCompiled/client/exportService.js +1 -1
- package/dist/templatesCompiled/client/indexCore.js +2 -2
- package/dist/templatesCompiled/client/indexFull.js +2 -2
- package/package.json +1 -1
- package/dist/templatesCompiled/client/core/createExecutorAdapter.d.ts.map +0 -1
- package/dist/templatesCompiled/client/core/request-executor.d.ts.map +0 -1
- package/dist/templatesCompiled/client/core/request-executor.js +0 -11
- /package/dist/templatesCompiled/client/core/{createExecutorAdapter.d.ts → executor/createExecutorAdapter.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -526,6 +526,110 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
|
|
|
526
526
|
}
|
|
527
527
|
```
|
|
528
528
|
|
|
529
|
+
### RequestExecutor
|
|
530
|
+
|
|
531
|
+
Starting from version **2.0.0** the generated services use the `RequestExecutor` interface
|
|
532
|
+
instead of direct calls to the `request` core function.
|
|
533
|
+
|
|
534
|
+
The `RequestExecutor` is a single HTTP logic integration point responsible for executing requests
|
|
535
|
+
and extending client behavior. It allows you to:
|
|
536
|
+
- use any transport (fetch/axios/xhr/custom);
|
|
537
|
+
- Centrally handle requests, responses, and errors;
|
|
538
|
+
- expand the client's behavior without changing the generated services.
|
|
539
|
+
|
|
540
|
+
#### Interceptors
|
|
541
|
+
|
|
542
|
+
`RequestExecutor` supports **interceptors**, which allow you to implement additional
|
|
543
|
+
logic at different stages of the request lifecycle.:
|
|
544
|
+
|
|
545
|
+
- `onRequest` — modification of the request before sending (headers, auth, logging);
|
|
546
|
+
- `onResponse` — processing successful responses;
|
|
547
|
+
- `onError` — centralized error handling.
|
|
548
|
+
|
|
549
|
+
Interceptors are applied at the executor level and are automatically used by all
|
|
550
|
+
generated services.
|
|
551
|
+
|
|
552
|
+
```ts
|
|
553
|
+
import { createClient } from './generated';
|
|
554
|
+
|
|
555
|
+
const client = createClient({
|
|
556
|
+
interceptors: {
|
|
557
|
+
onRequest: [
|
|
558
|
+
(config) => ({
|
|
559
|
+
...config,
|
|
560
|
+
headers: {
|
|
561
|
+
...config.headers,
|
|
562
|
+
Authorization: 'Bearer token',
|
|
563
|
+
},
|
|
564
|
+
}),
|
|
565
|
+
],
|
|
566
|
+
onError: [
|
|
567
|
+
(error) => {
|
|
568
|
+
console.error(error);
|
|
569
|
+
throw error;
|
|
570
|
+
},
|
|
571
|
+
],
|
|
572
|
+
},
|
|
573
|
+
});
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
#### Custom implementation of RequestExecutor with interceptors
|
|
577
|
+
|
|
578
|
+
A custom `RequestExecutor` can be used together with interceptors.
|
|
579
|
+
In this case, the executor is responsible only for the transport and execution of the request,
|
|
580
|
+
while the interceptors are responsible for the extensible business logic (authorization, logging, error handling).
|
|
581
|
+
|
|
582
|
+
```ts
|
|
583
|
+
import type { RequestExecutor, RequestConfig } from './generated/core/executor/requestExecutor';
|
|
584
|
+
import { withInterceptors } from './generated/core/interceptors/withInterceptors';
|
|
585
|
+
import { SimpleService } from './generated/services/SimpleService';
|
|
586
|
+
|
|
587
|
+
interface MyCustomOptions {
|
|
588
|
+
timeout?: number;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const baseExecutor: RequestExecutor<MyCustomOptions> = {
|
|
592
|
+
async request<T>(config: RequestConfig, options?: MyCustomOptions): Promise<T> {
|
|
593
|
+
const response = await fetch(config.url, {
|
|
594
|
+
method: config.method,
|
|
595
|
+
headers: config.headers,
|
|
596
|
+
body: config.body ? JSON.stringify(config.body) : undefined,
|
|
597
|
+
signal: options?.timeout
|
|
598
|
+
? AbortSignal.timeout(options.timeout)
|
|
599
|
+
: undefined,
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
if (!response.ok) {
|
|
603
|
+
throw new Error(`Request failed: ${response.status}`);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
return response.json();
|
|
607
|
+
},
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
// Wrapping the executor interceptors
|
|
611
|
+
const executor = withInterceptors(baseExecutor, {
|
|
612
|
+
onRequest: [
|
|
613
|
+
(config) => ({
|
|
614
|
+
...config,
|
|
615
|
+
headers: {
|
|
616
|
+
...config.headers,
|
|
617
|
+
Authorization: 'Bearer token',
|
|
618
|
+
},
|
|
619
|
+
}),
|
|
620
|
+
],
|
|
621
|
+
onError: [
|
|
622
|
+
(error) => {
|
|
623
|
+
console.error(error);
|
|
624
|
+
throw error;
|
|
625
|
+
},
|
|
626
|
+
],
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
const service = new SimpleService(executor);
|
|
630
|
+
await service.getCallWithoutParametersAndResponse({ timeout: 5000 });
|
|
631
|
+
```
|
|
632
|
+
|
|
529
633
|
### Sorting strategy for function arguments `--sortByRequired`
|
|
530
634
|
By default, the OpenAPI generator sorts the parameters of service functions according to a simplified scheme. If you need a more strict sorting option, then you need to use the `--sortByRequired` flag. The simplified sorting option is similar to the one used in version 0.2.3 of the OpenAPI generator. This flag allows you to upgrade to a new version of the generator if you are "stuck" on version 0.2.3.
|
|
531
635
|
|
package/README.rus.md
CHANGED
|
@@ -526,6 +526,110 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
|
|
|
526
526
|
}
|
|
527
527
|
```
|
|
528
528
|
|
|
529
|
+
### RequestExecutor
|
|
530
|
+
|
|
531
|
+
Начиная с версии **2.0.0**, сгенерированные сервисы используют интерфейс `RequestExecutor`
|
|
532
|
+
вместо прямых вызовов core-функции `request`.
|
|
533
|
+
|
|
534
|
+
`RequestExecutor` — это единая точка интеграции HTTP-логики, отвечающая за выполнение запросов
|
|
535
|
+
и расширение поведения клиента. Он позволяет:
|
|
536
|
+
- использовать любой транспорт (fetch / axios / xhr / custom);
|
|
537
|
+
- централизованно обрабатывать запросы, ответы и ошибки;
|
|
538
|
+
- расширять поведение клиента без изменения сгенерированных сервисов.
|
|
539
|
+
|
|
540
|
+
#### Interceptors
|
|
541
|
+
|
|
542
|
+
`RequestExecutor` поддерживает **interceptors**, которые позволяют внедрять дополнительную
|
|
543
|
+
логику на разных этапах жизненного цикла запроса:
|
|
544
|
+
|
|
545
|
+
- `onRequest` — модификация запроса перед отправкой (headers, auth, логирование);
|
|
546
|
+
- `onResponse` — обработка успешных ответов;
|
|
547
|
+
- `onError` — централизованная обработка ошибок.
|
|
548
|
+
|
|
549
|
+
Interceptors применяются на уровне executor’а и автоматически используются всеми
|
|
550
|
+
сгенерированными сервисами.
|
|
551
|
+
|
|
552
|
+
```ts
|
|
553
|
+
import { createClient } from './generated';
|
|
554
|
+
|
|
555
|
+
const client = createClient({
|
|
556
|
+
interceptors: {
|
|
557
|
+
onRequest: [
|
|
558
|
+
(config) => ({
|
|
559
|
+
...config,
|
|
560
|
+
headers: {
|
|
561
|
+
...config.headers,
|
|
562
|
+
Authorization: 'Bearer token',
|
|
563
|
+
},
|
|
564
|
+
}),
|
|
565
|
+
],
|
|
566
|
+
onError: [
|
|
567
|
+
(error) => {
|
|
568
|
+
console.error(error);
|
|
569
|
+
throw error;
|
|
570
|
+
},
|
|
571
|
+
],
|
|
572
|
+
},
|
|
573
|
+
});
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
#### Пользовательская реализация RequestExecutor с interceptors
|
|
577
|
+
|
|
578
|
+
Пользовательский `RequestExecutor` может быть использован вместе с interceptors.
|
|
579
|
+
В этом случае executor отвечает только за транспорт и выполнение запроса,
|
|
580
|
+
а interceptors — за расширяемую бизнес-логику (авторизация, логирование, обработка ошибок).
|
|
581
|
+
|
|
582
|
+
```ts
|
|
583
|
+
import type { RequestExecutor, RequestConfig } from './generated/core/executor/requestExecutor';
|
|
584
|
+
import { withInterceptors } from './generated/core/interceptors/withInterceptors';
|
|
585
|
+
import { SimpleService } from './generated/services/SimpleService';
|
|
586
|
+
|
|
587
|
+
interface MyCustomOptions {
|
|
588
|
+
timeout?: number;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
const baseExecutor: RequestExecutor<MyCustomOptions> = {
|
|
592
|
+
async request<T>(config: RequestConfig, options?: MyCustomOptions): Promise<T> {
|
|
593
|
+
const response = await fetch(config.url, {
|
|
594
|
+
method: config.method,
|
|
595
|
+
headers: config.headers,
|
|
596
|
+
body: config.body ? JSON.stringify(config.body) : undefined,
|
|
597
|
+
signal: options?.timeout
|
|
598
|
+
? AbortSignal.timeout(options.timeout)
|
|
599
|
+
: undefined,
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
if (!response.ok) {
|
|
603
|
+
throw new Error(`Request failed: ${response.status}`);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
return response.json();
|
|
607
|
+
},
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
// Оборачиваем executor interceptors
|
|
611
|
+
const executor = withInterceptors(baseExecutor, {
|
|
612
|
+
onRequest: [
|
|
613
|
+
(config) => ({
|
|
614
|
+
...config,
|
|
615
|
+
headers: {
|
|
616
|
+
...config.headers,
|
|
617
|
+
Authorization: 'Bearer token',
|
|
618
|
+
},
|
|
619
|
+
}),
|
|
620
|
+
],
|
|
621
|
+
onError: [
|
|
622
|
+
(error) => {
|
|
623
|
+
console.error(error);
|
|
624
|
+
throw error;
|
|
625
|
+
},
|
|
626
|
+
],
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
const service = new SimpleService(executor);
|
|
630
|
+
await service.getCallWithoutParametersAndResponse({ timeout: 5000 });
|
|
631
|
+
```
|
|
632
|
+
|
|
529
633
|
### Стратегия сортировки аргументов функций `--sortByRequired`
|
|
530
634
|
По умолчанию генератор OpenAPI сортирует параметры сервисных функций согласно упрощенной схеме. Если вам нужна более строгая опция сортировки, используйте флаг `--sortByRequired`. Упрощенная опция сортировки похожа на ту, что использовалась в версии 0.2.3 генератора OpenAPI. Этот флаг позволяет обновиться до новой версии генератора, если вы "застряли" на версии 0.2.3.
|
|
531
635
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,KAAK,iBAAiB,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF,KAAK,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,sBAAsB,GAAG,qBAAqB,CAAC,CAAC;AAEnJ;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAuD;IACrE,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAU3B;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,KAAK,iBAAiB,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACzC,CAAC;AAEF,KAAK,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,sBAAsB,GAAG,qBAAqB,CAAC,CAAC;AAEnJ;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAuD;IACrE,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,CAAC,EAAE,MAAM;IAU3B;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA0G5D;;;OAGG;IACH,6BAA6B,CAAC,MAAM,EAAE,yBAAyB;IAUzD,eAAe;IAKf,sBAAsB;IAK5B,IAAW,MAAM,WAEhB;IAED,OAAO,CAAC,yBAAyB;IAyCjC,OAAO,CAAC,mBAAmB;YA4Db,gBAAgB;YAUhB,uBAAuB;IAMrC,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAId,eAAe,yBAAmB;IAClC,oBAAoB,8BAAwB;IAC5C,oBAAoB,8BAAwB;IAC5C,iBAAiB,2BAAqB;IACtC,sBAAsB,gCAA0B;IAChD,kBAAkB,4BAAsB;IACxC,uBAAuB,iCAA2B;IAClD,mBAAmB,6BAAuB;IAC1C,wBAAwB,kCAA4B;IACpD,sBAAsB,gCAA0B;IAChD,mBAAmB,6BAAuB;CACpD"}
|
package/dist/core/WriteClient.js
CHANGED
|
@@ -41,7 +41,11 @@ class WriteClient {
|
|
|
41
41
|
async writeClient(options) {
|
|
42
42
|
const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles = false, request, useCancelableRequest = false, useSeparatedIndexes = false, validationLibrary = ValidationLibrary_enum_1.ValidationLibrary.NONE, } = options;
|
|
43
43
|
if (!excludeCoreServiceFiles) {
|
|
44
|
+
const executorPath = (0, pathHelpers_1.resolveHelper)(outputPaths.outputCore, 'executor');
|
|
45
|
+
const interceptorsPath = (0, pathHelpers_1.resolveHelper)(outputPaths.outputCore, 'interceptors');
|
|
44
46
|
await fileSystemHelpers_1.fileSystemHelpers.mkdir(outputPaths.outputCore);
|
|
47
|
+
await fileSystemHelpers_1.fileSystemHelpers.mkdir(executorPath);
|
|
48
|
+
await fileSystemHelpers_1.fileSystemHelpers.mkdir(interceptorsPath);
|
|
45
49
|
await this.writeClientCore({ client, templates, outputCorePath: outputPaths.outputCore, httpClient, request, useCancelableRequest });
|
|
46
50
|
await this.writeClientCoreIndex({
|
|
47
51
|
templates,
|
|
@@ -55,6 +55,9 @@ const WriteClient_1 = require("../WriteClient");
|
|
|
55
55
|
httpStatusCode: () => 'httpStatusCode',
|
|
56
56
|
createExecutorAdapter: () => 'createExecutorAdapter',
|
|
57
57
|
requestExecutor: () => 'requestExecutor',
|
|
58
|
+
apiErrorInterceptor: () => 'apiErrorInterceptor',
|
|
59
|
+
interceptors: () => 'interceptors',
|
|
60
|
+
withInterceptors: () => 'withInterceptors'
|
|
58
61
|
},
|
|
59
62
|
};
|
|
60
63
|
const outputPaths = (0, getOutputPaths_1.getOutputPaths)({ output: './dist' });
|
|
@@ -24,6 +24,9 @@ export interface Templates {
|
|
|
24
24
|
httpStatusCode: Handlebars.TemplateDelegate;
|
|
25
25
|
requestExecutor: Handlebars.TemplateDelegate;
|
|
26
26
|
createExecutorAdapter: Handlebars.TemplateDelegate;
|
|
27
|
+
interceptors: Handlebars.TemplateDelegate;
|
|
28
|
+
apiErrorInterceptor: Handlebars.TemplateDelegate;
|
|
29
|
+
withInterceptors: Handlebars.TemplateDelegate;
|
|
27
30
|
};
|
|
28
31
|
}
|
|
29
32
|
//# sourceMappingURL=Templates.model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Templates.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/Templates.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAC;IACF,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAChD,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC5C,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC7C,qBAAqB,EAAE,UAAU,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Templates.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/Templates.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,oBAAoB,CAAC;AAEjD,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE;QACL,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAClC,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACzC,CAAC;IACF,OAAO,EAAE;QACL,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACpC,KAAK,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnC,MAAM,EAAE,UAAU,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAChD,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACxC,CAAC;IACF,IAAI,EAAE;QACF,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,QAAQ,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACtC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,SAAS,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACvC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACrC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC/C,cAAc,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC5C,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC7C,qBAAqB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACnD,YAAY,EAAE,UAAU,CAAC,gBAAgB,CAAC;QAC1C,mBAAmB,EAAE,UAAU,CAAC,gBAAgB,CAAC;QACjD,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAC;KACjD,CAAC;CACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__mocks__/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,eAAO,MAAM,SAAS,EAAE,SA6BvB,CAAC"}
|
|
@@ -26,5 +26,8 @@ exports.templates = {
|
|
|
26
26
|
httpStatusCode: () => 'httpStatusCode',
|
|
27
27
|
createExecutorAdapter: () => 'createExecutorAdapter',
|
|
28
28
|
requestExecutor: () => 'requestExecutor',
|
|
29
|
+
apiErrorInterceptor: () => 'apiErrorInterceptor',
|
|
30
|
+
interceptors: () => 'interceptors',
|
|
31
|
+
withInterceptors: () => 'withInterceptors',
|
|
29
32
|
},
|
|
30
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AA6FA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AA2C1E,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAAG,SAAS,CAyK1K"}
|
|
@@ -77,8 +77,11 @@ const sendRequest_3 = __importDefault(require("../../templatesCompiled/client/co
|
|
|
77
77
|
const OpenAPI_1 = __importDefault(require("../../templatesCompiled/client/core/OpenAPI"));
|
|
78
78
|
const CancelablePromise_1 = __importDefault(require("../../templatesCompiled/client/core/CancelablePromise"));
|
|
79
79
|
const request_4 = __importDefault(require("../../templatesCompiled/client/core/request"));
|
|
80
|
-
const
|
|
81
|
-
const createExecutorAdapter_1 = __importDefault(require("../../templatesCompiled/client/core/createExecutorAdapter"));
|
|
80
|
+
const requestExecutor_1 = __importDefault(require("../../templatesCompiled/client/core/executor/requestExecutor"));
|
|
81
|
+
const createExecutorAdapter_1 = __importDefault(require("../../templatesCompiled/client/core/executor/createExecutorAdapter"));
|
|
82
|
+
const interceptors_1 = __importDefault(require("../../templatesCompiled/client/core/interceptors/interceptors"));
|
|
83
|
+
const apiErrorInterceptor_1 = __importDefault(require("../../templatesCompiled/client/core/interceptors/apiErrorInterceptor"));
|
|
84
|
+
const withInterceptors_1 = __importDefault(require("../../templatesCompiled/client/core/interceptors/withInterceptors"));
|
|
82
85
|
const getHeaders_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getHeaders"));
|
|
83
86
|
const getRequestBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getRequestBody"));
|
|
84
87
|
const getResponseBody_4 = __importDefault(require("../../templatesCompiled/client/core/xhr/getResponseBody"));
|
|
@@ -193,8 +196,11 @@ function registerHandlebarTemplates(root) {
|
|
|
193
196
|
request: Handlebars.template(request_4.default),
|
|
194
197
|
cancelablePromise: Handlebars.template(CancelablePromise_1.default),
|
|
195
198
|
httpStatusCode: Handlebars.template(HttpStatusCode_1.default),
|
|
196
|
-
requestExecutor: Handlebars.template(
|
|
199
|
+
requestExecutor: Handlebars.template(requestExecutor_1.default),
|
|
197
200
|
createExecutorAdapter: Handlebars.template(createExecutorAdapter_1.default),
|
|
201
|
+
interceptors: Handlebars.template(interceptors_1.default),
|
|
202
|
+
apiErrorInterceptor: Handlebars.template(apiErrorInterceptor_1.default),
|
|
203
|
+
withInterceptors: Handlebars.template(withInterceptors_1.default),
|
|
198
204
|
},
|
|
199
205
|
};
|
|
200
206
|
// Partials for the generations of the models, services, etc.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;GAOG;AACH,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"writeClientCore.d.ts","sourceRoot":"","sources":["../../../src/core/utils/writeClientCore.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;;;;;GAOG;AACH,UAAU,gBAAgB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCjG"}
|
|
@@ -32,9 +32,11 @@ async function writeClientCore(options) {
|
|
|
32
32
|
}
|
|
33
33
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'HttpStatusCode.ts'), templates.core.httpStatusCode({}));
|
|
34
34
|
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'request.ts'), templates.core.request(context));
|
|
35
|
-
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, '
|
|
36
|
-
|
|
37
|
-
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, '
|
|
35
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'executor/requestExecutor.ts'), templates.core.requestExecutor({}));
|
|
36
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'executor/createExecutorAdapter.ts'), templates.core.createExecutorAdapter({ useCustomRequest: hasCustomRequest }));
|
|
37
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'interceptors/interceptors.ts'), templates.core.interceptors({}));
|
|
38
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'interceptors/apiErrorInterceptor.ts'), templates.core.apiErrorInterceptor({}));
|
|
39
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile((0, pathHelpers_1.resolveHelper)(outputCorePath, 'interceptors/withInterceptors.ts'), templates.core.withInterceptors({}));
|
|
38
40
|
if (hasCustomRequest) {
|
|
39
41
|
const requestFile = (0, pathHelpers_1.resolveHelper)(process.cwd(), request);
|
|
40
42
|
const requestFileExists = await fileSystemHelpers_1.fileSystemHelpers.exists(requestFile);
|
|
@@ -14,5 +14,5 @@ exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, de
|
|
|
14
14
|
return undefined;
|
|
15
15
|
};
|
|
16
16
|
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
-
+ "\
|
|
17
|
+
+ "\nexport class ApiError<TBody = unknown> extends Error {\n readonly status: number;\n readonly body?: TBody;\n readonly headers?: Record<string, string>;\n readonly request: RequestConfig;\n\n constructor(params: { status: number; message: string; body?: TBody; headers?: Record<string, string>; request: RequestConfig }) {\n super(params.message);\n this.name = 'ApiError';\n this.status = params.status;\n this.body = params.body;\n this.headers = params.headers;\n this.request = params.request;\n }\n}\n";
|
|
18
18
|
}, "usePartial": true, "useData": true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CancelablePromise.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/CancelablePromise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CancelablePromise.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/CancelablePromise.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}
|
|
@@ -7,5 +7,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
/* eslint: disable */
|
|
8
8
|
// @ts-nocheck
|
|
9
9
|
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
12
|
+
return parent[propertyName];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
+
+ "\nexport interface ICancelProps {\n readonly isResolved: boolean;\n readonly isRejected: boolean;\n readonly isCancelled: boolean;\n\n (cancelHandler: () => void): void;\n}\n\nexport class CancelablePromise<T> implements Promise<T> {\n readonly [Symbol.toStringTag]!: string;\n\n private _isResolved: boolean;\n private _isRejected: boolean;\n private _isCancelled: boolean;\n private readonly _cancelHandlers: (() => void)[];\n private readonly _promise: Promise<T>;\n private _resolve?: (value: T | PromiseLike<T>) => void;\n private _reject?: (reason?: any) => void;\n\n constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: ICancelProps) => void) {\n this._isResolved = false;\n this._isRejected = false;\n this._isCancelled = false;\n this._cancelHandlers = [];\n this._promise = new Promise<T>((resolve, reject) => {\n this._resolve = resolve;\n this._reject = reject;\n\n const onResolve = (value: T | PromiseLike<T>): void => {\n if (this._isResolved || this._isRejected || this._isCancelled) {\n return;\n }\n this._isResolved = true;\n this._resolve?.(value);\n };\n\n const onReject = (reason?: any): void => {\n if (this._isResolved || this._isRejected || this._isCancelled) {\n return;\n }\n this._isRejected = true;\n this._reject?.(reason);\n };\n\n const onCancel = (cancelHandler: () => void): void => {\n if (this._isResolved || this._isRejected || this._isCancelled) {\n return;\n }\n this._cancelHandlers.push(cancelHandler);\n };\n\n Object.defineProperty(onCancel, 'isResolved', {\n get: (): boolean => this._isResolved,\n });\n\n Object.defineProperty(onCancel, 'isRejected', {\n get: (): boolean => this._isRejected,\n });\n\n Object.defineProperty(onCancel, 'isCancelled', {\n get: (): boolean => this._isCancelled,\n });\n\n return executor(onResolve, onReject, onCancel as ICancelProps);\n });\n }\n\n public then<TResult1 = T, TResult2 = never>(\n onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,\n onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null\n ): Promise<TResult1 | TResult2> {\n return this._promise.then(onFulfilled, onRejected);\n }\n\n public catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult> {\n return this._promise.catch(onRejected);\n }\n\n public finally(onFinally?: (() => void) | null): Promise<T> {\n return this._promise.finally(onFinally);\n }\n\n public cancel(): void {\n if (this._isResolved || this._isRejected || this._isCancelled) {\n return;\n }\n this._isCancelled = true;\n if (this._cancelHandlers.length) {\n try {\n for (const cancelHandler of this._cancelHandlers) {\n cancelHandler();\n }\n } catch (error) {\n console.warn('Cancellation threw an error', error);\n return;\n }\n }\n this._cancelHandlers.length = 0;\n this._reject?.(new Error('CancelError: Request aborted'));\n }\n}";
|
|
18
|
+
}, "usePartial": true, "useData": true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpStatusCode.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/HttpStatusCode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpStatusCode.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/HttpStatusCode.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}
|
|
@@ -7,5 +7,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
/* eslint: disable */
|
|
8
8
|
// @ts-nocheck
|
|
9
9
|
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
12
|
+
return parent[propertyName];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
+
+ "\nexport enum EHTTP_STATUS_CODES {\n BAD_REQUEST = 400,\n UNAUTHORIZED = 401,\n FORBIDDEN = 403,\n NOT_FOUND = 404,\n INTERNAL_SERVER_ERROR = 500,\n BAD_GATEWAY = 502,\n SERVICE_UNAVAILABLE = 503,\n}\n\nexport enum EHTTP_STATUS_NAME {\n BAD_REQUEST = 'Bad Request',\n UNAUTHORIZED = 'Unauthorized',\n FORBIDDEN = 'Forbidden',\n NOT_FOUND = 'Not Found',\n INTERNAL_SERVER_ERROR = 'Internal Server Error',\n BAD_GATEWAY = 'Bad Gateway',\n SERVICE_UNAVAILABLE = 'Service Unavailable',\n}\n\n";
|
|
18
|
+
}, "usePartial": true, "useData": true };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createExecutorAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/core/executor/createExecutorAdapter.ts"],"names":[],"mappings":";;;;;;;;;;AAMA,wBAwBmC"}
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
/* eslint: disable */
|
|
8
8
|
// @ts-nocheck
|
|
9
9
|
exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
10
|
-
return "import type { ApiRequestOptions } from '
|
|
10
|
+
return "import type { ApiRequestOptions } from '../ApiRequestOptions';\nimport type { TOpenAPIConfig } from '../OpenAPI';\nimport { OpenAPI } from '../OpenAPI';\n";
|
|
11
11
|
}, "3": function (container, depth0, helpers, partials, data) {
|
|
12
12
|
return " openApiConfig: TOpenAPIConfig = OpenAPI,\n mapOptions?: (options: TRequestOptions | undefined) => Partial<ApiRequestOptions>,\n";
|
|
13
13
|
}, "5": function (container, depth0, helpers, partials, data) {
|
|
@@ -22,9 +22,9 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
22
22
|
return undefined;
|
|
23
23
|
};
|
|
24
24
|
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
25
|
-
+ "\nimport type { RequestExecutor, RequestConfig } from './
|
|
25
|
+
+ "\nimport type { RequestExecutor, RequestConfig } from './requestExecutor';\n"
|
|
26
26
|
+ ((stack1 = lookupProperty(helpers, "unless").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCustomRequest"), { "name": "unless", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 8, "column": 11 } } })) != null ? stack1 : "")
|
|
27
|
-
+ "import { request as __request } from '
|
|
27
|
+
+ "import { request as __request } from '../request';\n\nexport function createExecutorAdapter<TRequestOptions extends Record<string, any>>(\n"
|
|
28
28
|
+ ((stack1 = lookupProperty(helpers, "unless").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCustomRequest"), { "name": "unless", "hash": {}, "fn": container.program(3, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 15, "column": 11 } } })) != null ? stack1 : "")
|
|
29
29
|
+ "): RequestExecutor<TRequestOptions> {\n return {\n"
|
|
30
30
|
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCustomRequest"), { "name": "if", "hash": {}, "fn": container.program(5, data, 0), "inverse": container.program(7, data, 0), "data": data, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 39, "column": 15 } } })) != null ? stack1 : "")
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
compiler: (string | number)[];
|
|
3
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
4
|
+
usePartial: boolean;
|
|
5
|
+
useData: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=requestExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestExecutor.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/core/executor/requestExecutor.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// This is an automatically generated file for the hbs template.
|
|
4
|
+
// You don't need to change it, run npm run build:hbs to update it.
|
|
5
|
+
/* istanbul ignore file */
|
|
6
|
+
/* tslint: disable */
|
|
7
|
+
/* eslint: disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
+
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
12
|
+
return parent[propertyName];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
+
+ "\nexport interface RequestConfig {\n method: string;\n path: string;\n\n headers?: Record<string, string>;\n query?: Record<string, any>;\n body?: unknown;\n\n requestMediaType?: string;\n cookies?: Record<string, string>;\n}\n\nexport interface RequestExecutor<TOptions = unknown> {\n request<TResponse>(\n config: RequestConfig,\n options?: TOptions\n ): Promise<TResponse>;\n}";
|
|
18
|
+
}, "usePartial": true, "useData": true };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
compiler: (string | number)[];
|
|
3
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
4
|
+
usePartial: boolean;
|
|
5
|
+
useData: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=apiErrorInterceptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiErrorInterceptor.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/core/interceptors/apiErrorInterceptor.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// This is an automatically generated file for the hbs template.
|
|
4
|
+
// You don't need to change it, run npm run build:hbs to update it.
|
|
5
|
+
/* istanbul ignore file */
|
|
6
|
+
/* tslint: disable */
|
|
7
|
+
/* eslint: disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
+
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
12
|
+
return parent[propertyName];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
+
+ "\nimport { ErrorInterceptor } from './interceptors';\nimport { ApiError } from '../ApiError';\n\ninterface ExecutorError {\n status: number;\n body?: unknown;\n headers?: Record<string, string>;\n}\n\nexport const apiErrorInterceptor: ErrorInterceptor = (error, request) => {\n if (typeof error === 'object' && error && 'status' in error) {\n const e = error as ExecutorError;\n\n throw new ApiError({\n status: e.status,\n message: `Request failed with status ${e.status}`,\n body: e.body,\n headers: e.headers,\n request,\n });\n }\n\n throw error;\n};";
|
|
18
|
+
}, "usePartial": true, "useData": true };
|
package/dist/templatesCompiled/client/core/{request-executor.d.ts → interceptors/interceptors.d.ts}
RENAMED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
compiler: (string | number)[];
|
|
3
3
|
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
4
|
+
usePartial: boolean;
|
|
4
5
|
useData: boolean;
|
|
5
6
|
};
|
|
6
7
|
export default _default;
|
|
7
|
-
//# sourceMappingURL=
|
|
8
|
+
//# sourceMappingURL=interceptors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interceptors.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/core/interceptors/interceptors.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// This is an automatically generated file for the hbs template.
|
|
4
|
+
// You don't need to change it, run npm run build:hbs to update it.
|
|
5
|
+
/* istanbul ignore file */
|
|
6
|
+
/* tslint: disable */
|
|
7
|
+
/* eslint: disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
+
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
12
|
+
return parent[propertyName];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
+
+ "\nimport { RequestConfig } from '../executor/requestExecutor';\n\nexport type RequestInterceptor =\n (config: RequestConfig) => RequestConfig | Promise<RequestConfig>;\n\nexport type ResponseInterceptor<T = unknown> =\n (response: T, context: RequestConfig) => T | Promise<T>;\n\nexport type ErrorInterceptor =\n (error: unknown, context: RequestConfig) => unknown | Promise<unknown>;";
|
|
18
|
+
}, "usePartial": true, "useData": true };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
compiler: (string | number)[];
|
|
3
|
+
main: (container: any, depth0: any, helpers: any, partials: any, data: any) => string;
|
|
4
|
+
usePartial: boolean;
|
|
5
|
+
useData: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=withInterceptors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withInterceptors.d.ts","sourceRoot":"","sources":["../../../../../src/templatesCompiled/client/core/interceptors/withInterceptors.ts"],"names":[],"mappings":";;;;;;AAMA,wBAUmC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// This is an automatically generated file for the hbs template.
|
|
4
|
+
// You don't need to change it, run npm run build:hbs to update it.
|
|
5
|
+
/* istanbul ignore file */
|
|
6
|
+
/* tslint: disable */
|
|
7
|
+
/* eslint: disable */
|
|
8
|
+
// @ts-nocheck
|
|
9
|
+
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
+
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
12
|
+
return parent[propertyName];
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
16
|
+
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
17
|
+
+ "\nimport { RequestInterceptor, ResponseInterceptor, ErrorInterceptor } from './interceptors';\nimport { RequestConfig, RequestExecutor } from '../executor/requestExecutor';\n\nexport function withInterceptors<TOptions extends Record<string, any> = Record<string, never>>(\n executor: RequestExecutor<TOptions>,\n interceptors: {\n onRequest?: RequestInterceptor[];\n onResponse?: ResponseInterceptor[];\n onError?: ErrorInterceptor[];\n }\n): RequestExecutor<TOptions> {\n return {\n async request<TResponse>(config: RequestConfig, options?: TOptions): Promise<TResponse> {\n let currentConfig = config;\n\n try {\n for (const i of interceptors.onRequest ?? []) {\n currentConfig = await i(currentConfig);\n }\n\n let response: Awaited<TResponse> = await executor.request<TResponse>(config, options);\n\n for (const interceptor of interceptors.onResponse ?? []) {\n response = (await interceptor(response, config)) as Awaited<TResponse>;\n }\n\n return response as TResponse;\n } catch (caught) {\n let error = caught;\n\n for (const interceptor of interceptors.onError ?? []) {\n error = await interceptor(error, config);\n }\n\n throw error;\n }\n },\n };\n}\n";
|
|
18
|
+
}, "usePartial": true, "useData": true };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportClient.d.ts","sourceRoot":"","sources":["../../../src/templatesCompiled/client/exportClient.ts"],"names":[],"mappings":";;;;;;;;AAMA,
|
|
1
|
+
{"version":3,"file":"exportClient.d.ts","sourceRoot":"","sources":["../../../src/templatesCompiled/client/exportClient.ts"],"names":[],"mappings":";;;;;;;;AAMA,wBA+CmC"}
|
|
@@ -9,9 +9,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
10
10
|
var stack1, alias1 = container.strict, alias2 = container.lambda;
|
|
11
11
|
return "import { "
|
|
12
|
-
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line":
|
|
12
|
+
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 11, "column": 11 }, "end": { "line": 11, "column": 15 } }), depth0)) != null ? stack1 : "")
|
|
13
13
|
+ " } from './services/"
|
|
14
|
-
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line":
|
|
14
|
+
+ ((stack1 = alias2(alias1(depth0, "name", { "start": { "line": 11, "column": 39 }, "end": { "line": 11, "column": 43 } }), depth0)) != null ? stack1 : "")
|
|
15
15
|
+ "';\n";
|
|
16
16
|
}, "3": function (container, depth0, helpers, partials, data) {
|
|
17
17
|
var stack1, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
@@ -21,9 +21,9 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
21
21
|
return undefined;
|
|
22
22
|
};
|
|
23
23
|
return " "
|
|
24
|
-
+ ((stack1 = lookupProperty(helpers, "camelCase").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "name"), { "name": "camelCase", "hash": {}, "data": data, "loc": { "start": { "line":
|
|
24
|
+
+ ((stack1 = lookupProperty(helpers, "camelCase").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(depth0, "name"), { "name": "camelCase", "hash": {}, "data": data, "loc": { "start": { "line": 42, "column": 4 }, "end": { "line": 42, "column": 22 } } })) != null ? stack1 : "")
|
|
25
25
|
+ ": new "
|
|
26
|
-
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line":
|
|
26
|
+
+ ((stack1 = container.lambda(container.strict(depth0, "name", { "start": { "line": 42, "column": 30 }, "end": { "line": 42, "column": 34 } }), depth0)) != null ? stack1 : "")
|
|
27
27
|
+ "(executor),\n";
|
|
28
28
|
}, "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
29
29
|
var stack1, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
@@ -37,13 +37,17 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
37
37
|
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "OpenAPI", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 3, "column": 25 }, "end": { "line": 3, "column": 66 } } })) != null ? stack1 : "")
|
|
38
38
|
+ "';\nimport type { TOpenAPIConfig } from '"
|
|
39
39
|
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "OpenAPI", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 4, "column": 37 }, "end": { "line": 4, "column": 78 } } })) != null ? stack1 : "")
|
|
40
|
-
+ "';\nimport type { RequestExecutor } from '"
|
|
41
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "request-executor", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 5, "column": 38 }, "end": { "line": 5, "column": 88 } } })) != null ? stack1 : "")
|
|
42
40
|
+ "';\nimport { createExecutorAdapter } from '"
|
|
43
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "createExecutorAdapter", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line":
|
|
41
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "./executor/createExecutorAdapter", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 5, "column": 39 }, "end": { "line": 5, "column": 105 } } })) != null ? stack1 : "")
|
|
42
|
+
+ "';\nimport { RequestInterceptor, ResponseInterceptor, ErrorInterceptor } from '"
|
|
43
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "./interceptors/interceptors", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 6, "column": 75 }, "end": { "line": 6, "column": 136 } } })) != null ? stack1 : "")
|
|
44
|
+
+ "';\nimport { withInterceptors } from '"
|
|
45
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "./interceptors/withInterceptors", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 7, "column": 34 }, "end": { "line": 7, "column": 99 } } })) != null ? stack1 : "")
|
|
46
|
+
+ "';\nimport { apiErrorInterceptor } from '"
|
|
47
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "./interceptors/apiErrorInterceptor", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 8, "column": 37 }, "end": { "line": 8, "column": 105 } } })) != null ? stack1 : "")
|
|
44
48
|
+ "';\n\n"
|
|
45
|
-
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "services"), { "name": "each", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
46
|
-
+ "\nexport interface ClientOptions<TExecutorOptions extends Record<string, any>> {\n openApi?: Partial<TOpenAPIConfig>;\n
|
|
47
|
-
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "services"), { "name": "each", "hash": {}, "fn": container.program(3, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
49
|
+
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "services"), { "name": "each", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 12, "column": 9 } } })) != null ? stack1 : "")
|
|
50
|
+
+ "\nexport interface ClientOptions<TExecutorOptions extends Record<string, any>> {\n openApi?: Partial<TOpenAPIConfig>;\n interceptors?: {\n onRequest?: RequestInterceptor[];\n onResponse?: ResponseInterceptor[];\n onError?: ErrorInterceptor[];\n }\n}\n\nexport function createClient<TExecutorOptions extends Record<string, any>>(\n options: ClientOptions<TExecutorOptions> = {},\n) {\n const openApiConfig: TOpenAPIConfig = {\n ...OpenAPI,\n ...options.openApi,\n };\n\n let executor = createExecutorAdapter<TExecutorOptions>(openApiConfig);\n if (options?.interceptors) {\n executor = withInterceptors(executor, {\n onError: [apiErrorInterceptor, ...(options.interceptors?.onError ?? [])],\n onRequest: options.interceptors?.onRequest,\n onResponse: options.interceptors?.onResponse,\n });\n }\n\n return {\n"
|
|
51
|
+
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "services"), { "name": "each", "hash": {}, "fn": container.program(3, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 41, "column": 4 }, "end": { "line": 43, "column": 13 } } })) != null ? stack1 : "")
|
|
48
52
|
+ " };\n}\n";
|
|
49
53
|
}, "usePartial": true, "useData": true };
|
|
@@ -180,7 +180,7 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
180
180
|
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(depth0, "imports"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 7, "column": 7 } } })) != null ? stack1 : "")
|
|
181
181
|
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCancelableRequest"), { "name": "if", "hash": {}, "fn": container.program(5, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 10, "column": 7 } } })) != null ? stack1 : "")
|
|
182
182
|
+ "import type { RequestExecutor, RequestConfig } from '"
|
|
183
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "
|
|
183
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, lookupProperty(lookupProperty(data, "root"), "outputCore"), "requestExecutor", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 11, "column": 53 }, "end": { "line": 11, "column": 102 } } })) != null ? stack1 : "")
|
|
184
184
|
+ "';\n\n"
|
|
185
185
|
+ ((stack1 = lookupProperty(helpers, "each").call(alias1, lookupProperty(depth0, "operations"), { "name": "each", "hash": {}, "fn": container.program(7, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 18, "column": 9 } } })) != null ? stack1 : "")
|
|
186
186
|
+ "\nexport type T"
|
|
@@ -16,7 +16,7 @@ exports.default = { "1": function (container, depth0, helpers, partials, data) {
|
|
|
16
16
|
return undefined;
|
|
17
17
|
};
|
|
18
18
|
return ((stack1 = container.invokePartial(lookupProperty(partials, "header"), depth0, { "name": "header", "data": data, "helpers": helpers, "partials": partials, "decorators": container.decorators })) != null ? stack1 : "")
|
|
19
|
-
+ "\nexport { ApiError } from './ApiError';\nexport { RequestConfig, RequestExecutor } from './
|
|
20
|
-
+ ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(lookupProperty(data, "root"), "useCancelableRequest"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line":
|
|
19
|
+
+ "\nexport { ApiError } from './ApiError';\nexport { RequestConfig, RequestExecutor } from './executor/requestExecutor';\nexport { createExecutorAdapter } from './executor/createExecutorAdapter';\nexport { RequestInterceptor, ResponseInterceptor, ErrorInterceptor } from './interceptors/interceptors';\nexport { apiErrorInterceptor } from './interceptors/apiErrorInterceptor';\nexport { withInterceptors } from './interceptors/withInterceptors';\n"
|
|
20
|
+
+ ((stack1 = lookupProperty(helpers, "if").call(depth0 != null ? depth0 : (container.nullContext || {}), lookupProperty(lookupProperty(data, "root"), "useCancelableRequest"), { "name": "if", "hash": {}, "fn": container.program(1, data, 0), "inverse": container.noop, "data": data, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 11, "column": 7 } } })) != null ? stack1 : "")
|
|
21
21
|
+ "export { OpenAPI } from './OpenAPI';\nexport type { TOpenAPIConfig } from './OpenAPI';\n";
|
|
22
22
|
}, "usePartial": true, "useData": true };
|
|
@@ -31,11 +31,11 @@ exports.default = { "1": function (container, depth0, helpers, partials, data, b
|
|
|
31
31
|
+ ", RequestExecutor"
|
|
32
32
|
+ ((stack1 = lookupProperty(helpers, "notEquals").call(alias1, lookupProperty(lookupProperty(depths[1], "core"), "length"), 1, { "name": "notEquals", "hash": {}, "fn": container.program(7, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 6, "column": 114 }, "end": { "line": 6, "column": 191 } } })) != null ? stack1 : "")
|
|
33
33
|
+ " } from './"
|
|
34
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, depth0, "
|
|
34
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, depth0, "./executor/requestExecutor", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 6, "column": 202 }, "end": { "line": 6, "column": 250 } } })) != null ? stack1 : "")
|
|
35
35
|
+ "';\nexport { createExecutorAdapter"
|
|
36
36
|
+ ((stack1 = lookupProperty(helpers, "notEquals").call(alias1, lookupProperty(lookupProperty(depths[1], "core"), "length"), 1, { "name": "notEquals", "hash": {}, "fn": container.program(9, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 7, "column": 30 }, "end": { "line": 7, "column": 113 } } })) != null ? stack1 : "")
|
|
37
37
|
+ " } from './"
|
|
38
|
-
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, depth0, "createExecutorAdapter", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 7, "column": 124 }, "end": { "line": 7, "column":
|
|
38
|
+
+ ((stack1 = lookupProperty(helpers, "joinPath").call(alias1, depth0, "./executor/createExecutorAdapter", { "name": "joinPath", "hash": {}, "data": data, "loc": { "start": { "line": 7, "column": 124 }, "end": { "line": 7, "column": 178 } } })) != null ? stack1 : "")
|
|
39
39
|
+ "';\n"
|
|
40
40
|
+ ((stack1 = lookupProperty(helpers, "if").call(alias1, lookupProperty(lookupProperty(data, "root"), "useCancelableRequest"), { "name": "if", "hash": {}, "fn": container.program(11, data, 0, blockParams, depths), "inverse": container.noop, "data": data, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 10, "column": 7 } } })) != null ? stack1 : "")
|
|
41
41
|
+ "export { OpenAPI"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-openapi-codegen",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.8",
|
|
4
4
|
"description": "Library that generates Typescript clients based on the OpenAPI specification. It bases on openapi-typescript-codegen",
|
|
5
5
|
"author": "Alexey Zverev",
|
|
6
6
|
"homepage": "https://github.com/ozonophore/openapi-codegen.git",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createExecutorAdapter.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/createExecutorAdapter.ts"],"names":[],"mappings":";;;;;;;;;;AAMA,wBAwBmC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request-executor.d.ts","sourceRoot":"","sources":["../../../../src/templatesCompiled/client/core/request-executor.ts"],"names":[],"mappings":";;;;;AAMA,wBAEiB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// This is an automatically generated file for the hbs template.
|
|
4
|
-
// You don't need to change it, run npm run build:hbs to update it.
|
|
5
|
-
/* istanbul ignore file */
|
|
6
|
-
/* tslint: disable */
|
|
7
|
-
/* eslint: disable */
|
|
8
|
-
// @ts-nocheck
|
|
9
|
-
exports.default = { "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
10
|
-
return "export interface RequestConfig {\n method: string;\n path: string;\n\n headers?: Record<string, string>;\n query?: Record<string, any>;\n body?: unknown;\n\n requestMediaType?: string;\n cookies?: Record<string, string>;\n}\n\nexport interface RequestExecutor<TOptions = unknown> {\n request<TResponse>(\n config: RequestConfig,\n options?: TOptions\n ): Promise<TResponse>;\n}";
|
|
11
|
-
}, "useData": true };
|
|
File without changes
|