ts-openapi-codegen 2.0.0-beta.6 → 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.
Files changed (109) hide show
  1. package/README.md +78 -48
  2. package/README.rus.md +78 -47
  3. package/dist/cli/initOpenApiConfig/Types.d.ts +0 -5
  4. package/dist/cli/initOpenApiConfig/Types.d.ts.map +1 -1
  5. package/dist/common/utils/fileSystemHelpers.d.ts +0 -2
  6. package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -1
  7. package/dist/common/utils/fileSystemHelpers.js +0 -9
  8. package/dist/core/Context.d.ts +22 -0
  9. package/dist/core/Context.d.ts.map +1 -1
  10. package/dist/core/Context.js +97 -0
  11. package/dist/core/WriteClient.d.ts.map +1 -1
  12. package/dist/core/WriteClient.js +4 -0
  13. package/dist/core/__tests__/WriteClient.test.js +3 -0
  14. package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
  15. package/dist/core/api/v2/parser/getModels.js +1 -2
  16. package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
  17. package/dist/core/api/v2/parser/getType.js +14 -8
  18. package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
  19. package/dist/core/api/v3/parser/getModels.js +1 -2
  20. package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
  21. package/dist/core/api/v3/parser/getType.js +14 -8
  22. package/dist/core/types/base/Templates.model.d.ts +3 -0
  23. package/dist/core/types/base/Templates.model.d.ts.map +1 -1
  24. package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
  25. package/dist/core/utils/__mocks__/templates.js +3 -0
  26. package/dist/core/utils/getOpenApiSpec.d.ts +0 -6
  27. package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
  28. package/dist/core/utils/getOpenApiSpec.js +13 -23
  29. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  30. package/dist/core/utils/registerHandlebarTemplates.js +9 -3
  31. package/dist/core/utils/stripNamespace.js +1 -1
  32. package/dist/core/utils/writeClientCore.d.ts.map +1 -1
  33. package/dist/core/utils/writeClientCore.js +5 -3
  34. package/dist/templatesCompiled/client/core/ApiError.js +1 -1
  35. package/dist/templatesCompiled/client/core/CancelablePromise.d.ts +1 -0
  36. package/dist/templatesCompiled/client/core/CancelablePromise.d.ts.map +1 -1
  37. package/dist/templatesCompiled/client/core/CancelablePromise.js +9 -2
  38. package/dist/templatesCompiled/client/core/HttpStatusCode.d.ts +1 -0
  39. package/dist/templatesCompiled/client/core/HttpStatusCode.d.ts.map +1 -1
  40. package/dist/templatesCompiled/client/core/HttpStatusCode.js +9 -2
  41. package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -0
  42. package/dist/templatesCompiled/client/core/{createExecutorAdapter.js → executor/createExecutorAdapter.js} +3 -3
  43. package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts +8 -0
  44. package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts.map +1 -0
  45. package/dist/templatesCompiled/client/core/executor/requestExecutor.js +18 -0
  46. package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.d.ts +8 -0
  47. package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.d.ts.map +1 -0
  48. package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.js +18 -0
  49. package/dist/templatesCompiled/client/core/{request-executor.d.ts → interceptors/interceptors.d.ts} +2 -1
  50. package/dist/templatesCompiled/client/core/interceptors/interceptors.d.ts.map +1 -0
  51. package/dist/templatesCompiled/client/core/interceptors/interceptors.js +18 -0
  52. package/dist/templatesCompiled/client/core/interceptors/withInterceptors.d.ts +8 -0
  53. package/dist/templatesCompiled/client/core/interceptors/withInterceptors.d.ts.map +1 -0
  54. package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +18 -0
  55. package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
  56. package/dist/templatesCompiled/client/exportClient.js +14 -10
  57. package/dist/templatesCompiled/client/exportService.js +1 -1
  58. package/dist/templatesCompiled/client/indexCore.js +2 -2
  59. package/dist/templatesCompiled/client/indexFull.js +2 -2
  60. package/package.json +1 -7
  61. package/dist/cli/initOpenApiConfig/Enums.d.ts +0 -5
  62. package/dist/cli/initOpenApiConfig/Enums.d.ts.map +0 -1
  63. package/dist/cli/initOpenApiConfig/Enums.js +0 -8
  64. package/dist/core/types/base/RefWithtype.model.d.ts +0 -11
  65. package/dist/core/types/base/RefWithtype.model.d.ts.map +0 -1
  66. package/dist/core/types/base/RefWithtype.model.js +0 -2
  67. package/dist/core/types/enums/TypeRef.enum.d.ts +0 -8
  68. package/dist/core/types/enums/TypeRef.enum.d.ts.map +0 -1
  69. package/dist/core/types/enums/TypeRef.enum.js +0 -11
  70. package/dist/core/utils/__tests__/getGatheringRefs.test.d.ts +0 -2
  71. package/dist/core/utils/__tests__/getGatheringRefs.test.d.ts.map +0 -1
  72. package/dist/core/utils/__tests__/getGatheringRefs.test.js +0 -26
  73. package/dist/core/utils/__tests__/getRefFromSchema.test.d.ts +0 -2
  74. package/dist/core/utils/__tests__/getRefFromSchema.test.d.ts.map +0 -1
  75. package/dist/core/utils/__tests__/getRefFromSchema.test.js +0 -167
  76. package/dist/core/utils/__tests__/refResolver.test.d.ts +0 -2
  77. package/dist/core/utils/__tests__/refResolver.test.d.ts.map +0 -1
  78. package/dist/core/utils/__tests__/refResolver.test.js +0 -55
  79. package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts +0 -2
  80. package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts.map +0 -1
  81. package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +0 -449
  82. package/dist/core/utils/findCommonParent.d.ts +0 -7
  83. package/dist/core/utils/findCommonParent.d.ts.map +0 -1
  84. package/dist/core/utils/findCommonParent.js +0 -20
  85. package/dist/core/utils/getGatheringRefs.d.ts +0 -4
  86. package/dist/core/utils/getGatheringRefs.d.ts.map +0 -1
  87. package/dist/core/utils/getGatheringRefs.js +0 -68
  88. package/dist/core/utils/getRefFromSchema.d.ts +0 -3
  89. package/dist/core/utils/getRefFromSchema.d.ts.map +0 -1
  90. package/dist/core/utils/getRefFromSchema.js +0 -9
  91. package/dist/core/utils/isBoolean.d.ts +0 -2
  92. package/dist/core/utils/isBoolean.d.ts.map +0 -1
  93. package/dist/core/utils/isBoolean.js +0 -12
  94. package/dist/core/utils/isFileName.d.ts +0 -7
  95. package/dist/core/utils/isFileName.d.ts.map +0 -1
  96. package/dist/core/utils/isFileName.js +0 -30
  97. package/dist/core/utils/mapPathToTargetDirSafe.d.ts +0 -10
  98. package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +0 -1
  99. package/dist/core/utils/mapPathToTargetDirSafe.js +0 -48
  100. package/dist/core/utils/normalizeAllRefs.d.ts +0 -6
  101. package/dist/core/utils/normalizeAllRefs.d.ts.map +0 -1
  102. package/dist/core/utils/normalizeAllRefs.js +0 -35
  103. package/dist/core/utils/resolveRefToImportPath.d.ts +0 -13
  104. package/dist/core/utils/resolveRefToImportPath.d.ts.map +0 -1
  105. package/dist/core/utils/resolveRefToImportPath.js +0 -106
  106. package/dist/templatesCompiled/client/core/createExecutorAdapter.d.ts.map +0 -1
  107. package/dist/templatesCompiled/client/core/request-executor.d.ts.map +0 -1
  108. package/dist/templatesCompiled/client/core/request-executor.js +0 -11
  109. /package/dist/templatesCompiled/client/core/{createExecutorAdapter.d.ts → executor/createExecutorAdapter.d.ts} +0 -0
package/README.md CHANGED
@@ -526,80 +526,110 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
526
526
  }
527
527
  ```
528
528
 
529
- ### Custom Request Executor
529
+ ### RequestExecutor
530
530
 
531
- Starting from version 2.0.0-beta.1, generated services use the `RequestExecutor` interface instead of calling the core `request` function directly. This allows you to provide your own request implementation or adapt existing ones.
531
+ Starting from version **2.0.0** the generated services use the `RequestExecutor` interface
532
+ instead of direct calls to the `request` core function.
532
533
 
533
- **Using a custom RequestExecutor:**
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.
534
539
 
535
- You can create your own `RequestExecutor` implementation:
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).
536
581
 
537
582
  ```ts
538
- import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
583
+ import type { RequestExecutor, RequestConfig } from './generated/core/executor/requestExecutor';
584
+ import { withInterceptors } from './generated/core/interceptors/withInterceptors';
539
585
  import { SimpleService } from './generated/services/SimpleService';
540
586
 
541
- // Define your custom options type (optional)
542
587
  interface MyCustomOptions {
543
588
  timeout?: number;
544
- retries?: number;
545
589
  }
546
590
 
547
- // Create a custom executor
548
- const customExecutor: RequestExecutor<MyCustomOptions> = {
549
- async request<TResponse>(config: RequestConfig, options?: MyCustomOptions): Promise<TResponse> {
550
- // Your custom request logic here
591
+ const baseExecutor: RequestExecutor<MyCustomOptions> = {
592
+ async request<T>(config: RequestConfig, options?: MyCustomOptions): Promise<T> {
551
593
  const response = await fetch(config.url, {
552
594
  method: config.method,
553
595
  headers: config.headers,
554
596
  body: config.body ? JSON.stringify(config.body) : undefined,
555
- signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
597
+ signal: options?.timeout
598
+ ? AbortSignal.timeout(options.timeout)
599
+ : undefined,
556
600
  });
557
-
601
+
558
602
  if (!response.ok) {
559
- throw new Error(`Request failed: ${response.statusText}`);
603
+ throw new Error(`Request failed: ${response.status}`);
560
604
  }
561
-
605
+
562
606
  return response.json();
563
607
  },
564
608
  };
565
609
 
566
- // Use it with generated services
567
- const simpleService = new SimpleService<MyCustomOptions>(customExecutor);
568
- await simpleService.getCallWithoutParametersAndResponse({ timeout: 5000, retries: 3 });
569
- ```
570
-
571
- **Using legacy request adapter:**
572
-
573
- If you have an existing custom `request` file (specified via `--request` option), you can use the `createLegacyExecutor` helper to adapt it to the new `RequestExecutor` interface:
574
-
575
- ```ts
576
- import { createLegacyExecutor } from './generated/core/legacy-request-adapter';
577
- import { OpenAPI } from './generated/core/OpenAPI';
578
- import { SimpleService } from './generated/services/SimpleService';
579
-
580
- // The legacy adapter wraps your existing request function
581
- const executor = createLegacyExecutor(OpenAPI);
582
-
583
- // Optionally, you can map custom options to ApiRequestOptions
584
- interface XHROptions {
585
- timeout?: number;
586
- }
587
-
588
- const executorWithOptions = createLegacyExecutor<XHROptions>(OpenAPI, (options) => {
589
- // Map your custom options to ApiRequestOptions if needed
590
- return {
591
- // Add any ApiRequestOptions fields based on options
592
- };
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
+ ],
593
627
  });
594
628
 
595
- // Use with services
596
- const simpleService = new SimpleService(executor);
597
- await simpleService.getCallWithoutParametersAndResponse();
629
+ const service = new SimpleService(executor);
630
+ await service.getCallWithoutParametersAndResponse({ timeout: 5000 });
598
631
  ```
599
632
 
600
- **Note:** The `--request` option still works for customizing the core `request` function. The generated
601
- `legacy-request-adapter` will automatically use your custom request implementation when creating the adapter.
602
-
603
633
  ### Sorting strategy for function arguments `--sortByRequired`
604
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.
605
635
 
package/README.rus.md CHANGED
@@ -526,79 +526,110 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
526
526
  }
527
527
  ```
528
528
 
529
- ### Пользовательский Request Executor
529
+ ### RequestExecutor
530
530
 
531
- Начиная с версии 2.0.0, сгенерированные сервисы используют интерфейс `RequestExecutor` вместо прямых вызовов core-функции `request`. Это позволяет вам предоставить свою собственную реализацию запросов или адаптировать существующие.
531
+ Начиная с версии **2.0.0**, сгенерированные сервисы используют интерфейс `RequestExecutor`
532
+ вместо прямых вызовов core-функции `request`.
532
533
 
533
- **Использование пользовательского RequestExecutor:**
534
+ `RequestExecutor` это единая точка интеграции HTTP-логики, отвечающая за выполнение запросов
535
+ и расширение поведения клиента. Он позволяет:
536
+ - использовать любой транспорт (fetch / axios / xhr / custom);
537
+ - централизованно обрабатывать запросы, ответы и ошибки;
538
+ - расширять поведение клиента без изменения сгенерированных сервисов.
534
539
 
535
- Вы можете создать свою собственную реализацию `RequestExecutor`:
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 — за расширяемую бизнес-логику (авторизация, логирование, обработка ошибок).
536
581
 
537
582
  ```ts
538
- import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
583
+ import type { RequestExecutor, RequestConfig } from './generated/core/executor/requestExecutor';
584
+ import { withInterceptors } from './generated/core/interceptors/withInterceptors';
539
585
  import { SimpleService } from './generated/services/SimpleService';
540
586
 
541
- // Определите свой тип опций (опционально)
542
587
  interface MyCustomOptions {
543
588
  timeout?: number;
544
- retries?: number;
545
589
  }
546
590
 
547
- // Создайте пользовательский executor
548
- const customExecutor: RequestExecutor<MyCustomOptions> = {
549
- async request<TResponse>(config: RequestConfig, options?: MyCustomOptions): Promise<TResponse> {
550
- // Ваша пользовательская логика запросов здесь
591
+ const baseExecutor: RequestExecutor<MyCustomOptions> = {
592
+ async request<T>(config: RequestConfig, options?: MyCustomOptions): Promise<T> {
551
593
  const response = await fetch(config.url, {
552
594
  method: config.method,
553
595
  headers: config.headers,
554
596
  body: config.body ? JSON.stringify(config.body) : undefined,
555
- signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
597
+ signal: options?.timeout
598
+ ? AbortSignal.timeout(options.timeout)
599
+ : undefined,
556
600
  });
557
-
601
+
558
602
  if (!response.ok) {
559
- throw new Error(`Request failed: ${response.statusText}`);
603
+ throw new Error(`Request failed: ${response.status}`);
560
604
  }
561
-
605
+
562
606
  return response.json();
563
607
  },
564
608
  };
565
609
 
566
- // Используйте его со сгенерированными сервисами
567
- const simpleService = new SimpleService<MyCustomOptions>(customExecutor);
568
- await simpleService.getCallWithoutParametersAndResponse({ timeout: 5000, retries: 3 });
569
- ```
570
-
571
- **Использование legacy request adapter:**
572
-
573
- Если у вас есть существующий пользовательский файл `request` (указанный через опцию `--request`), вы можете использовать хелпер `createLegacyExecutor` для адаптации его к новому интерфейсу `RequestExecutor`:
574
-
575
- ```ts
576
- import { createLegacyExecutor } from './generated/core/legacy-request-adapter';
577
- import { OpenAPI } from './generated/core/OpenAPI';
578
- import { SimpleService } from './generated/services/SimpleService';
579
-
580
- // Legacy адаптер оборачивает вашу существующую функцию request
581
- const executor = createLegacyExecutor(OpenAPI);
582
-
583
- // Опционально, вы можете мапить пользовательские опции в ApiRequestOptions
584
- interface XHROptions {
585
- timeout?: number;
586
- }
587
-
588
- const executorWithOptions = createLegacyExecutor<XHROptions>(OpenAPI, (options) => {
589
- // Мапьте ваши пользовательские опции в ApiRequestOptions при необходимости
590
- return {
591
- // Добавьте любые поля ApiRequestOptions на основе options
592
- };
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
+ ],
593
627
  });
594
628
 
595
- // Используйте со сервисами
596
- const simpleService = new SimpleService(executor);
597
- await simpleService.getCallWithoutParametersAndResponse();
629
+ const service = new SimpleService(executor);
630
+ await service.getCallWithoutParametersAndResponse({ timeout: 5000 });
598
631
  ```
599
632
 
600
- **Примечание:** Опция --request по-прежнему работает для кастомизации core-функции request. Сгенерированный legacy-request-adapter автоматически будет использовать вашу пользовательскую реализацию request при создании адаптера.
601
-
602
633
  ### Стратегия сортировки аргументов функций `--sortByRequired`
603
634
  По умолчанию генератор OpenAPI сортирует параметры сервисных функций согласно упрощенной схеме. Если вам нужна более строгая опция сортировки, используйте флаг `--sortByRequired`. Упрощенная опция сортировки похожа на ту, что использовалась в версии 0.2.3 генератора OpenAPI. Этот флаг позволяет обновиться до новой версии генератора, если вы "застряли" на версии 0.2.3.
604
635
 
@@ -1,8 +1,3 @@
1
- import { EOptionType } from "./Enums";
2
- export type TInitOpenApiConfigParams = {
3
- type: EOptionType;
4
- openapiConfig?: string;
5
- };
6
1
  export type CLITemplates = {
7
2
  config: Handlebars.TemplateDelegate;
8
3
  request: Handlebars.TemplateDelegate;
@@ -1 +1 @@
1
- {"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/cli/initOpenApiConfig/Types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,MAAM,wBAAwB,GAAG;IACnC,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;IACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;IACrC,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;CAChD,CAAC"}
1
+ {"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../../src/cli/initOpenApiConfig/Types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACvB,MAAM,EAAE,UAAU,CAAC,gBAAgB,CAAC;IACpC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC;IACrC,eAAe,EAAE,UAAU,CAAC,gBAAgB,CAAC;CAChD,CAAC"}
@@ -1,7 +1,6 @@
1
1
  import { copyFile as __copyFile, exists as __exists, readdir as __readdir, readFile as __readFile, writeFile as __writeFile } from 'fs';
2
2
  declare function isDirectory(path: string): boolean;
3
3
  declare function isPathToFile(path: string): boolean;
4
- declare function isSameFilePath(a: string, b: string): boolean;
5
4
  declare const fileSystemHelpers: {
6
5
  readFile: typeof __readFile.__promisify__;
7
6
  writeFile: typeof __writeFile.__promisify__;
@@ -13,7 +12,6 @@ declare const fileSystemHelpers: {
13
12
  isDirectory: typeof isDirectory;
14
13
  isPathToFile: typeof isPathToFile;
15
14
  readdir: typeof __readdir.__promisify__;
16
- isSameFilePath: typeof isSameFilePath;
17
15
  };
18
16
  export { fileSystemHelpers };
19
17
  //# sourceMappingURL=fileSystemHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileSystemHelpers.d.ts","sourceRoot":"","sources":["../../../src/common/utils/fileSystemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,IAAI,UAAU,EAEtB,MAAM,IAAI,QAAQ,EAElB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EAMtB,SAAS,IAAI,WAAW,EAC3B,MAAM,IAAI,CAAC;AA0DZ,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1C;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3C;AAED,iBAAS,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAMrD;AAED,QAAA,MAAM,iBAAiB;;;;;;kBA7DI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAgBtB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;;;;CAyDhD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"fileSystemHelpers.d.ts","sourceRoot":"","sources":["../../../src/common/utils/fileSystemHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,IAAI,UAAU,EAEtB,MAAM,IAAI,QAAQ,EAElB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EAKtB,SAAS,IAAI,WAAW,EAC3B,MAAM,IAAI,CAAC;AA0DZ,iBAAS,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1C;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM3C;AAED,QAAA,MAAM,iBAAiB;;;;;;kBArDI,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;kBAgBtB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC;;;;CAgDhD,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -73,14 +73,6 @@ function isPathToFile(path) {
73
73
  return false;
74
74
  }
75
75
  }
76
- function isSameFilePath(a, b) {
77
- try {
78
- return (0, fs_1.realpathSync)(a) === (0, fs_1.realpathSync)(b);
79
- }
80
- catch {
81
- return false;
82
- }
83
- }
84
76
  const fileSystemHelpers = {
85
77
  readFile,
86
78
  writeFile,
@@ -92,6 +84,5 @@ const fileSystemHelpers = {
92
84
  isDirectory,
93
85
  isPathToFile,
94
86
  readdir,
95
- isSameFilePath,
96
87
  };
97
88
  exports.fileSystemHelpers = fileSystemHelpers;
@@ -14,6 +14,15 @@ type RefsLike = {
14
14
  paths: (...args: any[]) => string[];
15
15
  exists: (...args: any[]) => boolean;
16
16
  };
17
+ interface VirtualFile {
18
+ /** Абсолютный путь исходного файла (БЕЗ fragment) */
19
+ sourceFile: string;
20
+ /** Абсолютный путь output-файла (.ts) */
21
+ outputFile: string;
22
+ /** Все fragment'ы, которые встречались у этого файла */
23
+ fragments: Set<string>;
24
+ }
25
+ type VirtualFileMap = Map<string, VirtualFile>;
17
26
  /**
18
27
  * A Context wich can share a data between methods
19
28
  */
@@ -23,6 +32,8 @@ export declare class Context {
23
32
  private _output;
24
33
  prefix: PrefixArtifacts;
25
34
  private _sortByRequired;
35
+ private specRoot;
36
+ private virtualFiles;
26
37
  constructor({ input, output, prefix, sortByRequired }: TContextProps);
27
38
  addRefs(refs: RefsLike): Context;
28
39
  values(...types: string[]): Record<string, any>;
@@ -33,6 +44,17 @@ export declare class Context {
33
44
  get output(): OutputPaths;
34
45
  get sortByRequired(): boolean;
35
46
  get root(): $Root | undefined;
47
+ private canonicalizeRef;
48
+ private mapSourceToOutput;
49
+ private registerRef;
50
+ private walkSchema;
51
+ initializeVirtualFileMap(rootSchema: unknown, entryFile: string): void;
52
+ getVirtualFiles(): VirtualFileMap;
53
+ getAllCanonicalRefs(): string[];
54
+ resolveCanonicalRef(canonicalRef: string): {
55
+ outputFile: string;
56
+ fragment?: string;
57
+ } | undefined;
36
58
  }
37
59
  export {};
38
60
  //# sourceMappingURL=Context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/core/Context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGhF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIhD,KAAK,aAAa,GAAG;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,QAAQ,GAAG;IACZ,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChD,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;IAC7E,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EA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AAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,GAAG,eAAe;IAOtE,KAAK,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAOnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO7B,QAAQ,IAAI,MAAM;IAOzB,IAAW,MAAM,gBAKhB;IAED,IAAW,cAAc,YAExB;IAED,IAAW,IAAI,IAAI,KAAK,GAAG,SAAS,CAEnC;IAED,OAAO,CAAC,eAAe;IAqBvB,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,WAAW;IAmBnB,OAAO,CAAC,UAAU;IAiBX,wBAAwB,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM;IAiB/D,eAAe,IAAI,cAAc;IAIjC,mBAAmB,IAAI,MAAM,EAAE;IAgB/B,mBAAmB,CAAC,YAAY,EAAE,MAAM,GACzC;QACI,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACrB,GACD,SAAS;CAYlB"}
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Context = void 0;
4
+ const path_1 = require("path");
4
5
  const pathHelpers_1 = require("../common/utils/pathHelpers");
5
6
  const getFileName_1 = require("./utils/getFileName");
6
7
  const isString_1 = require("./utils/isString");
8
+ const parseRef_1 = require("./utils/parseRef");
7
9
  /**
8
10
  * A Context wich can share a data between methods
9
11
  */
@@ -17,6 +19,8 @@ class Context {
17
19
  type: 'T',
18
20
  };
19
21
  _sortByRequired = false;
22
+ specRoot;
23
+ virtualFiles = new Map();
20
24
  constructor({ input, output, prefix, sortByRequired }) {
21
25
  this._output = output;
22
26
  this._refs = {};
@@ -80,5 +84,98 @@ class Context {
80
84
  get root() {
81
85
  return this._root;
82
86
  }
87
+ canonicalizeRef(ref, parentSourceFile) {
88
+ const parsed = (0, parseRef_1.parseRef)(ref);
89
+ // LOCAL_FRAGMENT → тот же файл
90
+ if (parsed.type === parseRef_1.RefType.LOCAL_FRAGMENT) {
91
+ return {
92
+ sourceFile: (0, pathHelpers_1.normalizeHelper)(parentSourceFile),
93
+ fragment: parsed.fragment,
94
+ };
95
+ }
96
+ // Внешний ref
97
+ const parentDir = (0, pathHelpers_1.dirNameHelper)(parentSourceFile);
98
+ const absSource = (0, pathHelpers_1.resolveHelper)(parentDir, parsed.filePath);
99
+ return {
100
+ sourceFile: (0, pathHelpers_1.normalizeHelper)(absSource),
101
+ fragment: parsed.fragment,
102
+ };
103
+ }
104
+ mapSourceToOutput(sourceFile) {
105
+ const relative = (0, pathHelpers_1.relativeHelper)(this.specRoot, sourceFile);
106
+ const dir = (0, pathHelpers_1.dirNameHelper)(relative);
107
+ const baseName = (0, path_1.basename)(relative).replace(/\.(yaml|yml|json)$/i, '.ts');
108
+ return (0, pathHelpers_1.resolveHelper)(this.output.outputModels, dir, baseName);
109
+ }
110
+ registerRef(ref, parentSourceFile) {
111
+ const { sourceFile, fragment } = this.canonicalizeRef(ref, parentSourceFile);
112
+ let entry = this.virtualFiles.get(sourceFile);
113
+ if (!entry) {
114
+ entry = {
115
+ sourceFile,
116
+ outputFile: this.mapSourceToOutput(sourceFile),
117
+ fragments: new Set(),
118
+ };
119
+ this.virtualFiles.set(sourceFile, entry);
120
+ }
121
+ if (fragment) {
122
+ entry.fragments.add(fragment);
123
+ }
124
+ }
125
+ walkSchema(obj, parentSourceFile) {
126
+ if (!obj || typeof obj !== 'object')
127
+ return;
128
+ if (typeof obj.$ref === 'string') {
129
+ this.registerRef(obj.$ref, parentSourceFile);
130
+ }
131
+ if (Array.isArray(obj)) {
132
+ obj.forEach(item => this.walkSchema(item, parentSourceFile));
133
+ return;
134
+ }
135
+ for (const value of Object.values(obj)) {
136
+ this.walkSchema(value, parentSourceFile);
137
+ }
138
+ }
139
+ initializeVirtualFileMap(rootSchema, entryFile) {
140
+ this.specRoot = (0, pathHelpers_1.normalizeHelper)((0, pathHelpers_1.dirNameHelper)(entryFile));
141
+ const normalizedEntry = (0, pathHelpers_1.normalizeHelper)(entryFile);
142
+ // Гарантируем, что entry файл тоже есть в карте
143
+ if (!this.virtualFiles.has(normalizedEntry)) {
144
+ this.virtualFiles.set(normalizedEntry, {
145
+ sourceFile: normalizedEntry,
146
+ outputFile: this.mapSourceToOutput(normalizedEntry),
147
+ fragments: new Set(),
148
+ });
149
+ }
150
+ this.walkSchema(rootSchema, normalizedEntry);
151
+ }
152
+ getVirtualFiles() {
153
+ return this.virtualFiles;
154
+ }
155
+ getAllCanonicalRefs() {
156
+ const result = [];
157
+ for (const file of this.virtualFiles.values()) {
158
+ if (file.fragments.size > 0) {
159
+ for (const fragment of file.fragments) {
160
+ result.push(`${file.sourceFile}${fragment}`);
161
+ }
162
+ }
163
+ else {
164
+ result.push(file.sourceFile);
165
+ }
166
+ }
167
+ return result;
168
+ }
169
+ resolveCanonicalRef(canonicalRef) {
170
+ const parsed = (0, parseRef_1.parseRef)(canonicalRef);
171
+ const sourceFile = (0, pathHelpers_1.normalizeHelper)(parsed.filePath ?? '');
172
+ const file = this.virtualFiles.get(sourceFile);
173
+ if (!file)
174
+ return undefined;
175
+ return {
176
+ outputFile: file.outputFile,
177
+ fragment: parsed.fragment,
178
+ };
179
+ }
83
180
  }
84
181
  exports.Context = Context;
@@ -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,CAA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,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"}
@@ -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' });
@@ -1 +1 @@
1
- {"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAM/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,CAsBjE"}
1
+ {"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAK/D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEtD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,EAAE,CAsBjE"}
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getModels = getModels;
4
4
  const getModelNameWithPrefix_1 = require("../../../utils/getModelNameWithPrefix");
5
- const getRefFromSchema_1 = require("../../../utils/getRefFromSchema");
6
5
  const modelHelpers_1 = require("../../../utils/modelHelpers");
7
6
  const sortModelsByName_1 = require("../../../utils/sortModelsByName");
8
7
  const unique_1 = require("../../../utils/unique");
9
8
  function getModels(openApi) {
10
9
  let models = [];
11
- const listOfModelsRef = (0, getRefFromSchema_1.getRefFromSchema)(this.context, openApi);
10
+ const listOfModelsRef = this.context.getAllCanonicalRefs();
12
11
  if (listOfModelsRef) {
13
12
  for (const modelRef of listOfModelsRef) {
14
13
  const definition = this.context.get(modelRef);
@@ -1 +1 @@
1
- {"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getType.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAoC5E"}
1
+ {"version":3,"file":"getType.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v2/parser/getType.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAK7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CA4C5E"}