ts-openapi-codegen 2.0.0-beta.5 → 2.0.0-beta.7

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 (125) hide show
  1. package/README.md +0 -74
  2. package/README.rus.md +0 -73
  3. package/dist/cli/initOpenApiConfig/Types.d.ts +0 -5
  4. package/dist/cli/initOpenApiConfig/Types.d.ts.map +1 -1
  5. package/dist/core/Context.d.ts +22 -0
  6. package/dist/core/Context.d.ts.map +1 -1
  7. package/dist/core/Context.js +97 -0
  8. package/dist/core/WriteClient.d.ts +3 -1
  9. package/dist/core/WriteClient.d.ts.map +1 -1
  10. package/dist/core/WriteClient.js +8 -0
  11. package/dist/core/__tests__/WriteClient.test.js +2 -1
  12. package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
  13. package/dist/core/api/v2/parser/getModels.js +1 -2
  14. package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
  15. package/dist/core/api/v2/parser/getType.js +14 -8
  16. package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
  17. package/dist/core/api/v3/parser/getModels.js +1 -2
  18. package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
  19. package/dist/core/api/v3/parser/getType.js +14 -8
  20. package/dist/core/types/base/ClientArtifacts.model.d.ts +1 -1
  21. package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
  22. package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +1 -1
  23. package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -1
  24. package/dist/core/types/base/Templates.model.d.ts +29 -0
  25. package/dist/core/types/base/Templates.model.d.ts.map +1 -0
  26. package/dist/core/utils/__mocks__/templates.d.ts +1 -1
  27. package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
  28. package/dist/core/utils/__mocks__/templates.js +2 -1
  29. package/dist/core/utils/getOpenApiSpec.d.ts +0 -6
  30. package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
  31. package/dist/core/utils/getOpenApiSpec.js +13 -23
  32. package/dist/core/utils/precompileTemplates.js +1 -0
  33. package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
  34. package/dist/core/utils/registerHandlebarHelpers.js +11 -0
  35. package/dist/core/utils/registerHandlebarTemplates.d.ts +1 -27
  36. package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
  37. package/dist/core/utils/registerHandlebarTemplates.js +4 -2
  38. package/dist/core/utils/stripNamespace.js +1 -1
  39. package/dist/core/utils/writeClientCore.d.ts +1 -1
  40. package/dist/core/utils/writeClientCore.d.ts.map +1 -1
  41. package/dist/core/utils/writeClientCore.js +3 -2
  42. package/dist/core/utils/writeClientCoreIndex.d.ts +1 -1
  43. package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
  44. package/dist/core/utils/writeClientExecutor.d.ts +12 -0
  45. package/dist/core/utils/writeClientExecutor.d.ts.map +1 -0
  46. package/dist/core/utils/writeClientExecutor.js +18 -0
  47. package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
  48. package/dist/core/utils/writeClientFullIndex.js +1 -1
  49. package/dist/core/utils/writeClientModels.d.ts +1 -1
  50. package/dist/core/utils/writeClientModels.d.ts.map +1 -1
  51. package/dist/core/utils/writeClientModelsIndex.d.ts +1 -1
  52. package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
  53. package/dist/core/utils/writeClientSchemas.d.ts +1 -1
  54. package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
  55. package/dist/core/utils/writeClientSchemasIndex.d.ts +1 -1
  56. package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
  57. package/dist/core/utils/writeClientServices.d.ts +1 -1
  58. package/dist/core/utils/writeClientServices.d.ts.map +1 -1
  59. package/dist/core/utils/writeClientServicesIndex.d.ts +1 -1
  60. package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
  61. package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -1
  62. package/dist/core/utils/writeClientSimpleIndex.js +1 -1
  63. package/dist/templatesCompiled/client/core/createExecutorAdapter.d.ts +12 -0
  64. package/dist/templatesCompiled/client/core/createExecutorAdapter.d.ts.map +1 -0
  65. package/dist/templatesCompiled/client/core/createExecutorAdapter.js +32 -0
  66. package/dist/templatesCompiled/client/{core/legacy-request-adapter.d.ts → exportClient.d.ts} +3 -1
  67. package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -0
  68. package/dist/templatesCompiled/client/exportClient.js +49 -0
  69. package/dist/templatesCompiled/client/indexCore.js +2 -2
  70. package/dist/templatesCompiled/client/indexFull.d.ts +12 -9
  71. package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
  72. package/dist/templatesCompiled/client/indexFull.js +69 -46
  73. package/dist/templatesCompiled/client/indexSimple.d.ts.map +1 -1
  74. package/dist/templatesCompiled/client/indexSimple.js +2 -1
  75. package/dist/templatesCompiled/client/partials/serviceOption.d.ts +2 -1
  76. package/dist/templatesCompiled/client/partials/serviceOption.d.ts.map +1 -1
  77. package/dist/templatesCompiled/client/partials/serviceOption.js +36 -30
  78. package/package.json +1 -7
  79. package/dist/cli/initOpenApiConfig/Enums.d.ts +0 -5
  80. package/dist/cli/initOpenApiConfig/Enums.d.ts.map +0 -1
  81. package/dist/cli/initOpenApiConfig/Enums.js +0 -8
  82. package/dist/core/types/base/RefWithtype.model.d.ts +0 -11
  83. package/dist/core/types/base/RefWithtype.model.d.ts.map +0 -1
  84. package/dist/core/types/enums/TypeRef.enum.d.ts +0 -8
  85. package/dist/core/types/enums/TypeRef.enum.d.ts.map +0 -1
  86. package/dist/core/types/enums/TypeRef.enum.js +0 -11
  87. package/dist/core/utils/__tests__/getGatheringRefs.test.d.ts +0 -2
  88. package/dist/core/utils/__tests__/getGatheringRefs.test.d.ts.map +0 -1
  89. package/dist/core/utils/__tests__/getGatheringRefs.test.js +0 -26
  90. package/dist/core/utils/__tests__/getRefFromSchema.test.d.ts +0 -2
  91. package/dist/core/utils/__tests__/getRefFromSchema.test.d.ts.map +0 -1
  92. package/dist/core/utils/__tests__/getRefFromSchema.test.js +0 -167
  93. package/dist/core/utils/__tests__/refResolver.test.d.ts +0 -2
  94. package/dist/core/utils/__tests__/refResolver.test.d.ts.map +0 -1
  95. package/dist/core/utils/__tests__/refResolver.test.js +0 -55
  96. package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts +0 -2
  97. package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts.map +0 -1
  98. package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +0 -385
  99. package/dist/core/utils/findCommonParent.d.ts +0 -7
  100. package/dist/core/utils/findCommonParent.d.ts.map +0 -1
  101. package/dist/core/utils/findCommonParent.js +0 -20
  102. package/dist/core/utils/getGatheringRefs.d.ts +0 -4
  103. package/dist/core/utils/getGatheringRefs.d.ts.map +0 -1
  104. package/dist/core/utils/getGatheringRefs.js +0 -68
  105. package/dist/core/utils/getRefFromSchema.d.ts +0 -3
  106. package/dist/core/utils/getRefFromSchema.d.ts.map +0 -1
  107. package/dist/core/utils/getRefFromSchema.js +0 -9
  108. package/dist/core/utils/isBoolean.d.ts +0 -2
  109. package/dist/core/utils/isBoolean.d.ts.map +0 -1
  110. package/dist/core/utils/isBoolean.js +0 -12
  111. package/dist/core/utils/isFileName.d.ts +0 -7
  112. package/dist/core/utils/isFileName.d.ts.map +0 -1
  113. package/dist/core/utils/isFileName.js +0 -30
  114. package/dist/core/utils/mapPathToTargetDirSafe.d.ts +0 -10
  115. package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +0 -1
  116. package/dist/core/utils/mapPathToTargetDirSafe.js +0 -48
  117. package/dist/core/utils/normalizeAllRefs.d.ts +0 -6
  118. package/dist/core/utils/normalizeAllRefs.d.ts.map +0 -1
  119. package/dist/core/utils/normalizeAllRefs.js +0 -35
  120. package/dist/core/utils/resolveRefToImportPath.d.ts +0 -13
  121. package/dist/core/utils/resolveRefToImportPath.d.ts.map +0 -1
  122. package/dist/core/utils/resolveRefToImportPath.js +0 -111
  123. package/dist/templatesCompiled/client/core/legacy-request-adapter.d.ts.map +0 -1
  124. package/dist/templatesCompiled/client/core/legacy-request-adapter.js +0 -18
  125. /package/dist/core/types/base/{RefWithtype.model.js → Templates.model.js} +0 -0
package/README.md CHANGED
@@ -526,80 +526,6 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
526
526
  }
527
527
  ```
528
528
 
529
- ### Custom Request Executor
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.
532
-
533
- **Using a custom RequestExecutor:**
534
-
535
- You can create your own `RequestExecutor` implementation:
536
-
537
- ```ts
538
- import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
539
- import { SimpleService } from './generated/services/SimpleService';
540
-
541
- // Define your custom options type (optional)
542
- interface MyCustomOptions {
543
- timeout?: number;
544
- retries?: number;
545
- }
546
-
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
551
- const response = await fetch(config.url, {
552
- method: config.method,
553
- headers: config.headers,
554
- body: config.body ? JSON.stringify(config.body) : undefined,
555
- signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
556
- });
557
-
558
- if (!response.ok) {
559
- throw new Error(`Request failed: ${response.statusText}`);
560
- }
561
-
562
- return response.json();
563
- },
564
- };
565
-
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
- };
593
- });
594
-
595
- // Use with services
596
- const simpleService = new SimpleService(executor);
597
- await simpleService.getCallWithoutParametersAndResponse();
598
- ```
599
-
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
529
  ### Sorting strategy for function arguments `--sortByRequired`
604
530
  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
531
 
package/README.rus.md CHANGED
@@ -526,79 +526,6 @@ export function request<T>(config: TOpenAPIConfig, options: ApiRequestOptions):
526
526
  }
527
527
  ```
528
528
 
529
- ### Пользовательский Request Executor
530
-
531
- Начиная с версии 2.0.0, сгенерированные сервисы используют интерфейс `RequestExecutor` вместо прямых вызовов core-функции `request`. Это позволяет вам предоставить свою собственную реализацию запросов или адаптировать существующие.
532
-
533
- **Использование пользовательского RequestExecutor:**
534
-
535
- Вы можете создать свою собственную реализацию `RequestExecutor`:
536
-
537
- ```ts
538
- import type { RequestExecutor, RequestConfig } from './generated/core/request-executor';
539
- import { SimpleService } from './generated/services/SimpleService';
540
-
541
- // Определите свой тип опций (опционально)
542
- interface MyCustomOptions {
543
- timeout?: number;
544
- retries?: number;
545
- }
546
-
547
- // Создайте пользовательский executor
548
- const customExecutor: RequestExecutor<MyCustomOptions> = {
549
- async request<TResponse>(config: RequestConfig, options?: MyCustomOptions): Promise<TResponse> {
550
- // Ваша пользовательская логика запросов здесь
551
- const response = await fetch(config.url, {
552
- method: config.method,
553
- headers: config.headers,
554
- body: config.body ? JSON.stringify(config.body) : undefined,
555
- signal: options?.timeout ? AbortSignal.timeout(options.timeout) : undefined,
556
- });
557
-
558
- if (!response.ok) {
559
- throw new Error(`Request failed: ${response.statusText}`);
560
- }
561
-
562
- return response.json();
563
- },
564
- };
565
-
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
- };
593
- });
594
-
595
- // Используйте со сервисами
596
- const simpleService = new SimpleService(executor);
597
- await simpleService.getCallWithoutParametersAndResponse();
598
- ```
599
-
600
- **Примечание:** Опция --request по-прежнему работает для кастомизации core-функции request. Сгенерированный legacy-request-adapter автоматически будет использовать вашу пользовательскую реализацию request при создании адаптера.
601
-
602
529
  ### Стратегия сортировки аргументов функций `--sortByRequired`
603
530
  По умолчанию генератор OpenAPI сортирует параметры сервисных функций согласно упрощенной схеме. Если вам нужна более строгая опция сортировки, используйте флаг `--sortByRequired`. Упрощенная опция сортировки похожа на ту, что использовалась в версии 0.2.3 генератора OpenAPI. Этот флаг позволяет обновиться до новой версии генератора, если вы "застряли" на версии 0.2.3.
604
531
 
@@ -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"}
@@ -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,C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AC,QAAQ,CAAU;IAC1B,OAAO,CAAC,YAAY,CAA6B;gBAErC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,aAAa;IAmB7D,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;IAKhC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAO/C,GAAG,CAAC,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,11 +1,12 @@
1
1
  import { Logger } from '../common/Logger';
2
2
  import { OutputPaths } from './types/base/OutputPaths.model';
3
+ import { Templates } from './types/base/Templates.model';
3
4
  import { HttpClient } from './types/enums/HttpClient.enum';
4
5
  import { ValidationLibrary } from './types/enums/ValidationLibrary.enum';
5
6
  import type { Client } from './types/shared/Client.model';
6
- import { Templates } from './utils/registerHandlebarTemplates';
7
7
  import { writeClientCore } from './utils/writeClientCore';
8
8
  import { writeClientCoreIndex } from './utils/writeClientCoreIndex';
9
+ import { writeClientExecutor } from './utils/writeClientExecutor';
9
10
  import { writeClientFullIndex } from './utils/writeClientFullIndex';
10
11
  import { writeClientModels } from './utils/writeClientModels';
11
12
  import { writeClientModelsIndex } from './utils/writeClientModelsIndex';
@@ -80,6 +81,7 @@ export declare class WriteClient {
80
81
  writeClientServices: typeof writeClientServices;
81
82
  writeClientServicesIndex: typeof writeClientServicesIndex;
82
83
  writeClientSimpleIndex: typeof writeClientSimpleIndex;
84
+ writeClientExecutor: typeof writeClientExecutor;
83
85
  }
84
86
  export {};
85
87
  //# sourceMappingURL=WriteClient.d.ts.map
@@ -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,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,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AW;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"}
@@ -11,6 +11,7 @@ const sortModelByName_1 = require("./utils/sortModelByName");
11
11
  const unique_1 = require("./utils/unique");
12
12
  const writeClientCore_1 = require("./utils/writeClientCore");
13
13
  const writeClientCoreIndex_1 = require("./utils/writeClientCoreIndex");
14
+ const writeClientExecutor_1 = require("./utils/writeClientExecutor");
14
15
  const writeClientFullIndex_1 = require("./utils/writeClientFullIndex");
15
16
  const writeClientModels_1 = require("./utils/writeClientModels");
16
17
  const writeClientModelsIndex_1 = require("./utils/writeClientModelsIndex");
@@ -69,6 +70,12 @@ class WriteClient {
69
70
  outputServices,
70
71
  useSeparatedIndexes,
71
72
  });
73
+ await this.writeClientExecutor({
74
+ outputPath: outputPaths.output,
75
+ outputCorePath: (0, pathHelpers_1.relativeHelper)(outputPaths.output, outputCore),
76
+ services: client.services,
77
+ templates,
78
+ });
72
79
  }
73
80
  /**
74
81
  * TODO: Нужно собирать импорты из всех вложенных моделей (link, properties в composition и т.д.) и передавать их в шаблон.
@@ -287,5 +294,6 @@ class WriteClient {
287
294
  writeClientServices = writeClientServices_1.writeClientServices;
288
295
  writeClientServicesIndex = writeClientServicesIndex_1.writeClientServicesIndex;
289
296
  writeClientSimpleIndex = writeClientSimpleIndex_1.writeClientSimpleIndex;
297
+ writeClientExecutor = writeClientExecutor_1.writeClientExecutor;
290
298
  }
291
299
  exports.WriteClient = WriteClient;
@@ -40,6 +40,7 @@ const WriteClient_1 = require("../WriteClient");
40
40
  services: () => 'servicesIndex',
41
41
  },
42
42
  exports: {
43
+ client: () => 'client',
43
44
  model: () => 'model',
44
45
  schema: () => 'schema',
45
46
  service: () => 'service',
@@ -52,7 +53,7 @@ const WriteClient_1 = require("../WriteClient");
52
53
  request: () => 'request',
53
54
  cancelablePromise: () => 'cancelablePromise',
54
55
  httpStatusCode: () => 'httpStatusCode',
55
- legacyRequestAdapter: () => 'legacyRequestAdapter',
56
+ createExecutorAdapter: () => 'createExecutorAdapter',
56
57
  requestExecutor: () => 'requestExecutor',
57
58
  },
58
59
  };
@@ -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"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getType = getType;
4
+ const pathHelpers_1 = require("../../../../common/utils/pathHelpers");
4
5
  const getMappedType_1 = require("../../../utils/getMappedType");
5
6
  const getTypeName_1 = require("../../../utils/getTypeName");
6
7
  const normalizeString_1 = require("../../../utils/normalizeString");
7
- const resolveRefToImportPath_1 = require("../../../utils/resolveRefToImportPath");
8
8
  const stripNamespace_1 = require("../../../utils/stripNamespace");
9
9
  /**
10
10
  * Parse any string value into a type object.
@@ -30,13 +30,19 @@ function getType(value, parentRef) {
30
30
  }
31
31
  }
32
32
  else if (valueClean) {
33
- // Safely calculate the path that the specification file will have in outputModels folder
34
- const valuePath = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
35
- mainSpecPath: this.context.root?.path || '',
36
- parentFilePath: parentRef,
37
- refValuePath: normalizedValue,
38
- outputModelsPath: this.context.output?.outputModels,
39
- });
33
+ /**
34
+ * canonicalValue может быть пустой строкой.
35
+ * В этом случае надо брать непосредственно normalizedValue - это относительный путь или фрагмент.
36
+ * Предполагаем, что в таком случае расчитывать нет нужды. Это путь от папки outputModels
37
+ */
38
+ const canonicalValue = this.context.resolveCanonicalRef(normalizedValue);
39
+ let valuePath = valueClean;
40
+ if (canonicalValue) {
41
+ const refValuePath = canonicalValue?.fragment ? `${canonicalValue.outputFile}${canonicalValue.fragment}` : canonicalValue?.outputFile || '';
42
+ const cleanedRefValuePath = (0, stripNamespace_1.stripNamespace)(refValuePath);
43
+ valuePath = (0, pathHelpers_1.relativeHelper)(this.context.output?.outputModels, cleanedRefValuePath);
44
+ }
45
+ valuePath = !valuePath.startsWith('./') && !valuePath.startsWith('../') ? `./${valuePath}` : valuePath;
40
46
  const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), parentRef);
41
47
  const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
42
48
  result.path = valuePath;
@@ -1 +1 @@
1
- {"version":3,"file":"getModels.d.ts","sourceRoot":"","sources":["../../../../../src/core/api/v3/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/v3/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/v3/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/v3/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,CA6C5E"}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getType = getType;
4
+ const pathHelpers_1 = require("../../../../common/utils/pathHelpers");
4
5
  const getMappedType_1 = require("../../../utils/getMappedType");
5
6
  const getTypeName_1 = require("../../../utils/getTypeName");
6
7
  const normalizeString_1 = require("../../../utils/normalizeString");
7
- const resolveRefToImportPath_1 = require("../../../utils/resolveRefToImportPath");
8
8
  const stripNamespace_1 = require("../../../utils/stripNamespace");
9
9
  /**
10
10
  * Parse any string value into a type object.
@@ -30,13 +30,19 @@ function getType(value, parentRef) {
30
30
  }
31
31
  }
32
32
  else if (valueClean) {
33
- // Safely calculate the path that the specification file will have in outputModels folder
34
- const valuePath = (0, resolveRefToImportPath_1.resolveRefToImportPath)({
35
- mainSpecPath: this.context.root?.path || '',
36
- parentFilePath: parentRef,
37
- refValuePath: normalizedValue,
38
- outputModelsPath: this.context.output?.outputModels,
39
- });
33
+ /**
34
+ * canonicalValue может быть пустой строкой.
35
+ * В этом случае надо брать непосредственно normalizedValue - это относительный путь или фрагмент.
36
+ * Предполагаем, что в таком случае расчитывать нет нужды. Это путь от папки outputModels
37
+ */
38
+ const canonicalValue = this.context.resolveCanonicalRef(normalizedValue);
39
+ let valuePath = valueClean;
40
+ if (canonicalValue) {
41
+ const refValuePath = canonicalValue?.fragment ? `${canonicalValue.outputFile}${canonicalValue.fragment}` : canonicalValue?.outputFile || '';
42
+ const cleanedRefValuePath = (0, stripNamespace_1.stripNamespace)(refValuePath);
43
+ valuePath = (0, pathHelpers_1.relativeHelper)(this.context.output?.outputModels, cleanedRefValuePath);
44
+ }
45
+ valuePath = !valuePath.startsWith('./') && !valuePath.startsWith('../') ? `./${valuePath}` : valuePath;
40
46
  const type = this.getTypeNameByRef((0, getTypeName_1.getTypeName)(valueClean), parentRef);
41
47
  const valueImportPath = !valuePath.startsWith('./') ? `./${valuePath}` : valuePath;
42
48
  result.path = valuePath;
@@ -1,4 +1,4 @@
1
- import { Templates } from "../../utils/registerHandlebarTemplates";
1
+ import { Templates } from "../../types/base/Templates.model";
2
2
  import { ExportedModel } from "./ExportedModel.model";
3
3
  import { ExportedService } from "./ExportedService.model";
4
4
  export type ClientArtifacts = {
@@ -1 +1 @@
1
- {"version":3,"file":"ClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/ClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAA"}
1
+ {"version":3,"file":"ClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/ClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,MAAM,MAAM,eAAe,GAAG;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC/B,CAAA"}
@@ -1,4 +1,4 @@
1
- import { Templates } from "../../utils/registerHandlebarTemplates";
1
+ import { Templates } from "../../types/base/Templates.model";
2
2
  export type SimpleClientArtifacts = {
3
3
  templates: Templates;
4
4
  outputPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/SimpleClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAEnE,MAAM,MAAM,qBAAqB,GAAG;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAA"}
1
+ {"version":3,"file":"SimpleClientArtifacts.model.d.ts","sourceRoot":"","sources":["../../../../src/core/types/base/SimpleClientArtifacts.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,MAAM,MAAM,qBAAqB,GAAG;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB,CAAA"}
@@ -0,0 +1,29 @@
1
+ import * as Handlebars from 'handlebars/runtime';
2
+ export interface Templates {
3
+ indexes: {
4
+ full: Handlebars.TemplateDelegate;
5
+ simple: Handlebars.TemplateDelegate;
6
+ core: Handlebars.TemplateDelegate;
7
+ models: Handlebars.TemplateDelegate;
8
+ schemas: Handlebars.TemplateDelegate;
9
+ services: Handlebars.TemplateDelegate;
10
+ };
11
+ exports: {
12
+ client: Handlebars.TemplateDelegate;
13
+ model: Handlebars.TemplateDelegate;
14
+ schema: Handlebars.TemplateDelegate | undefined;
15
+ service: Handlebars.TemplateDelegate;
16
+ };
17
+ core: {
18
+ settings: Handlebars.TemplateDelegate;
19
+ apiError: Handlebars.TemplateDelegate;
20
+ apiRequestOptions: Handlebars.TemplateDelegate;
21
+ apiResult: Handlebars.TemplateDelegate;
22
+ request: Handlebars.TemplateDelegate;
23
+ cancelablePromise: Handlebars.TemplateDelegate;
24
+ httpStatusCode: Handlebars.TemplateDelegate;
25
+ requestExecutor: Handlebars.TemplateDelegate;
26
+ createExecutorAdapter: Handlebars.TemplateDelegate;
27
+ };
28
+ }
29
+ //# sourceMappingURL=Templates.model.d.ts.map
@@ -0,0 +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;KACtD,CAAC;CACL"}
@@ -1,3 +1,3 @@
1
- import { Templates } from '../registerHandlebarTemplates';
1
+ import { Templates } from '../../types/base/Templates.model';
2
2
  export declare const templates: Templates;
3
3
  //# sourceMappingURL=templates.d.ts.map