@goast/kotlin 0.4.18-beta5 → 0.4.18-springwebclient1

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 (98) hide show
  1. package/assets/client/spring-reactive-web-clients/ApiRequestFile.kt +33 -0
  2. package/esm/src/ast/nodes/call.d.ts.map +1 -1
  3. package/esm/src/ast/nodes/call.js +11 -1
  4. package/esm/src/ast/nodes/lambda-type.d.ts +2 -0
  5. package/esm/src/ast/nodes/lambda-type.d.ts.map +1 -1
  6. package/esm/src/ast/nodes/lambda-type.js +11 -4
  7. package/esm/src/ast/nodes/lambda.d.ts.map +1 -1
  8. package/esm/src/ast/nodes/lambda.js +10 -5
  9. package/esm/src/ast/references/index.d.ts +2 -0
  10. package/esm/src/ast/references/index.d.ts.map +1 -1
  11. package/esm/src/ast/references/index.js +2 -0
  12. package/esm/src/ast/references/java.d.ts +1 -0
  13. package/esm/src/ast/references/java.d.ts.map +1 -1
  14. package/esm/src/ast/references/java.js +1 -0
  15. package/esm/src/ast/references/kotlinx.d.ts +5 -0
  16. package/esm/src/ast/references/kotlinx.d.ts.map +1 -0
  17. package/esm/src/ast/references/kotlinx.js +6 -0
  18. package/esm/src/ast/references/spring-reactive.d.ts +9 -0
  19. package/esm/src/ast/references/spring-reactive.d.ts.map +1 -0
  20. package/esm/src/ast/references/spring-reactive.js +10 -0
  21. package/esm/src/ast/references/spring.d.ts +4 -0
  22. package/esm/src/ast/references/spring.d.ts.map +1 -1
  23. package/esm/src/ast/references/spring.js +6 -0
  24. package/esm/src/generators/index.d.ts +1 -0
  25. package/esm/src/generators/index.d.ts.map +1 -1
  26. package/esm/src/generators/index.js +1 -0
  27. package/esm/src/generators/services/okhttp3-clients/args.d.ts +4 -0
  28. package/esm/src/generators/services/okhttp3-clients/args.d.ts.map +1 -1
  29. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts +2 -2
  30. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  31. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +18 -20
  32. package/esm/src/generators/services/spring-reactive-web-clients/args.d.ts +99 -0
  33. package/esm/src/generators/services/spring-reactive-web-clients/args.d.ts.map +1 -0
  34. package/esm/src/generators/services/spring-reactive-web-clients/args.js +1 -0
  35. package/esm/src/generators/services/spring-reactive-web-clients/index.d.ts +5 -0
  36. package/esm/src/generators/services/spring-reactive-web-clients/index.d.ts.map +1 -0
  37. package/esm/src/generators/services/spring-reactive-web-clients/index.js +4 -0
  38. package/esm/src/generators/services/spring-reactive-web-clients/models.d.ts +34 -0
  39. package/esm/src/generators/services/spring-reactive-web-clients/models.d.ts.map +1 -0
  40. package/esm/src/generators/services/spring-reactive-web-clients/models.js +8 -0
  41. package/esm/src/generators/services/spring-reactive-web-clients/refs.d.ts +5 -0
  42. package/esm/src/generators/services/spring-reactive-web-clients/refs.d.ts.map +1 -0
  43. package/esm/src/generators/services/spring-reactive-web-clients/refs.js +8 -0
  44. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts +46 -0
  45. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -0
  46. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +383 -0
  47. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts +23 -0
  48. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts.map +1 -0
  49. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.js +79 -0
  50. package/package.json +2 -5
  51. package/script/src/ast/nodes/call.d.ts.map +1 -1
  52. package/script/src/ast/nodes/call.js +11 -1
  53. package/script/src/ast/nodes/lambda-type.d.ts +2 -0
  54. package/script/src/ast/nodes/lambda-type.d.ts.map +1 -1
  55. package/script/src/ast/nodes/lambda-type.js +11 -4
  56. package/script/src/ast/nodes/lambda.d.ts.map +1 -1
  57. package/script/src/ast/nodes/lambda.js +10 -5
  58. package/script/src/ast/references/index.d.ts +2 -0
  59. package/script/src/ast/references/index.d.ts.map +1 -1
  60. package/script/src/ast/references/index.js +3 -1
  61. package/script/src/ast/references/java.d.ts +1 -0
  62. package/script/src/ast/references/java.d.ts.map +1 -1
  63. package/script/src/ast/references/java.js +2 -1
  64. package/script/src/ast/references/kotlinx.d.ts +5 -0
  65. package/script/src/ast/references/kotlinx.d.ts.map +1 -0
  66. package/script/src/ast/references/kotlinx.js +9 -0
  67. package/script/src/ast/references/spring-reactive.d.ts +9 -0
  68. package/script/src/ast/references/spring-reactive.d.ts.map +1 -0
  69. package/script/src/ast/references/spring-reactive.js +13 -0
  70. package/script/src/ast/references/spring.d.ts +4 -0
  71. package/script/src/ast/references/spring.d.ts.map +1 -1
  72. package/script/src/ast/references/spring.js +7 -1
  73. package/script/src/generators/index.d.ts +1 -0
  74. package/script/src/generators/index.d.ts.map +1 -1
  75. package/script/src/generators/index.js +1 -0
  76. package/script/src/generators/services/okhttp3-clients/args.d.ts +4 -0
  77. package/script/src/generators/services/okhttp3-clients/args.d.ts.map +1 -1
  78. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts +2 -2
  79. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  80. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +18 -20
  81. package/script/src/generators/services/spring-reactive-web-clients/args.d.ts +99 -0
  82. package/script/src/generators/services/spring-reactive-web-clients/args.d.ts.map +1 -0
  83. package/script/src/generators/services/spring-reactive-web-clients/args.js +2 -0
  84. package/script/src/generators/services/spring-reactive-web-clients/index.d.ts +5 -0
  85. package/script/src/generators/services/spring-reactive-web-clients/index.d.ts.map +1 -0
  86. package/script/src/generators/services/spring-reactive-web-clients/index.js +8 -0
  87. package/script/src/generators/services/spring-reactive-web-clients/models.d.ts +34 -0
  88. package/script/src/generators/services/spring-reactive-web-clients/models.d.ts.map +1 -0
  89. package/script/src/generators/services/spring-reactive-web-clients/models.js +11 -0
  90. package/script/src/generators/services/spring-reactive-web-clients/refs.d.ts +5 -0
  91. package/script/src/generators/services/spring-reactive-web-clients/refs.d.ts.map +1 -0
  92. package/script/src/generators/services/spring-reactive-web-clients/refs.js +11 -0
  93. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts +46 -0
  94. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -0
  95. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +388 -0
  96. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts +23 -0
  97. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.d.ts.map +1 -0
  98. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.js +84 -0
@@ -0,0 +1,34 @@
1
+ import type { ApiEndpoint, ApiService, DefaultGenerationProviderConfig, OpenApiServicesGenerationProviderContext } from '@goast/core';
2
+ import type { KotlinImport } from '../../../common-results.js';
3
+ import { type KotlinGeneratorConfig } from '../../../config.js';
4
+ import type { KotlinModelsGeneratorOutput } from '../../models/index.js';
5
+ import { getReferenceFactories } from './refs.js';
6
+ export type KotlinSpringReactiveWebClientsGeneratorConfig = KotlinGeneratorConfig & {
7
+ packageName: string;
8
+ packageSuffix: string | ((service?: ApiService) => string);
9
+ infrastructurePackageName: string | {
10
+ mode: 'append-package-name' | 'append-full-package-name' | 'replace';
11
+ value: string;
12
+ };
13
+ basePath?: string | RegExp | ((basePath: string, service: ApiService) => string);
14
+ pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
15
+ serializerJsonInclude: 'always' | 'non-null' | 'non-absent' | 'non-default' | 'non-empty' | 'use-defaults';
16
+ };
17
+ export declare const defaultKotlinSpringReactiveWebClientsGeneratorConfig: DefaultGenerationProviderConfig<KotlinSpringReactiveWebClientsGeneratorConfig>;
18
+ export type KotlinSpringReactiveWebClientsGeneratorInput = KotlinModelsGeneratorOutput;
19
+ export type KotlinSpringReactiveWebClientsGeneratorOutput = {
20
+ kotlin: {
21
+ clients: {
22
+ [serviceId: string]: KotlinSpringReactiveWebClientGeneratorOutput;
23
+ };
24
+ };
25
+ };
26
+ export type KotlinSpringReactiveWebClientGeneratorOutput = KotlinImport;
27
+ export type KotlinSpringReactiveWebClientsGeneratorContext = OpenApiServicesGenerationProviderContext<KotlinSpringReactiveWebClientsGeneratorInput, KotlinSpringReactiveWebClientsGeneratorOutput, KotlinSpringReactiveWebClientsGeneratorConfig, KotlinSpringReactiveWebClientGeneratorOutput> & {
28
+ infrastructurePackageName: string;
29
+ refs: ReturnType<typeof getReferenceFactories>;
30
+ };
31
+ export type KotlinSpringReactiveWebClientGeneratorContext = KotlinSpringReactiveWebClientsGeneratorContext & {
32
+ service: ApiService;
33
+ };
34
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,+BAA+B,EAC/B,wCAAwC,EACzC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,MAAM,6CAA6C,GAAG,qBAAqB,GAAG;IAClF,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC;IAC3D,yBAAyB,EACrB,MAAM,GACN;QAAE,IAAI,EAAE,qBAAqB,GAAG,0BAA0B,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAE5F,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,KAAK,MAAM,CAAC,CAAC;IACjF,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,KAAK,MAAM,CAAC,CAAC;IAC1E,qBAAqB,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,WAAW,GAAG,cAAc,CAAC;CAC5G,CAAC;AAEF,eAAO,MAAM,oDAAoD,EAAE,+BAA+B,CAChG,6CAA6C,CAQ9C,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG,2BAA2B,CAAC;AAEvF,MAAM,MAAM,6CAA6C,GAAG;IAC1D,MAAM,EAAE;QACN,OAAO,EAAE;YACP,CAAC,SAAS,EAAE,MAAM,GAAG,4CAA4C,CAAC;SACnE,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,4CAA4C,GAAG,YAAY,CAAC;AAExE,MAAM,MAAM,8CAA8C,GACtD,wCAAwC,CACxC,4CAA4C,EAC5C,6CAA6C,EAC7C,6CAA6C,EAC7C,4CAA4C,CAC7C,GACC;IACA,yBAAyB,EAAE,MAAM,CAAC;IAClC,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC;CAChD,CAAC;AAEJ,MAAM,MAAM,6CAA6C,GAAG,8CAA8C,GAAG;IAC3G,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultKotlinSpringReactiveWebClientsGeneratorConfig = void 0;
4
+ const config_js_1 = require("../../../config.js");
5
+ exports.defaultKotlinSpringReactiveWebClientsGeneratorConfig = {
6
+ ...config_js_1.defaultKotlinGeneratorConfig,
7
+ packageName: 'com.openapi.generated',
8
+ packageSuffix: '.api.client',
9
+ infrastructurePackageName: { mode: 'append-full-package-name', value: '.infrastructure' },
10
+ serializerJsonInclude: 'non-absent',
11
+ };
@@ -0,0 +1,5 @@
1
+ import { kt } from '../../../ast/index.js';
2
+ export declare function getReferenceFactories(infrastructurePackageName: string): {
3
+ apiRequestFile: kt.ReferenceFactory;
4
+ };
5
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAG3C,wBAAgB,qBAAqB,CAAC,yBAAyB,EAAE,MAAM,GAAG;IACxE,cAAc,EAAE,EAAE,CAAC,gBAAgB,CAAC;CACrC,CAKA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReferenceFactories = getReferenceFactories;
4
+ const index_js_1 = require("../../../ast/index.js");
5
+ // See packages/kotlin/assets/client/spring-reactive-web-clients for reference
6
+ function getReferenceFactories(infrastructurePackageName) {
7
+ return {
8
+ // ApiRequestFile.kt
9
+ apiRequestFile: index_js_1.kt.reference.factory('ApiRequestFile', infrastructurePackageName),
10
+ };
11
+ }
@@ -0,0 +1,46 @@
1
+ import { type ApiSchema, type AppendValueGroup, type MaybePromise, SourceBuilder } from '@goast/core';
2
+ import { kt } from '../../../ast/index.js';
3
+ import { KotlinFileBuilder } from '../../../file-builder.js';
4
+ import type { ApiParameterWithMultipartInfo } from '../../../types.js';
5
+ import { KotlinFileGenerator } from '../../file-generator.js';
6
+ import type { DefaultKotlinSpringReactiveWebClientGeneratorArgs as Args } from './index.js';
7
+ import type { KotlinSpringReactiveWebClientGeneratorContext, KotlinSpringReactiveWebClientGeneratorOutput } from './models.js';
8
+ type Context = KotlinSpringReactiveWebClientGeneratorContext;
9
+ type Output = KotlinSpringReactiveWebClientGeneratorOutput;
10
+ type Builder = KotlinFileBuilder;
11
+ export interface KotlinSpringReactiveWebClientGenerator<TOutput extends Output = Output> {
12
+ generate(ctx: Context): MaybePromise<TOutput>;
13
+ }
14
+ export declare class DefaultKotlinSpringReactiveWebClientGenerator extends KotlinFileGenerator<Context, Output> implements KotlinSpringReactiveWebClientGenerator {
15
+ generate(ctx: Context): MaybePromise<Output>;
16
+ protected getClientFileContent(ctx: Context, args: Args.GetClientFileContent): AppendValueGroup<Builder>;
17
+ protected getRequestsObject(ctx: Context, args: Args.GetRequestsObject): kt.Object<Builder>;
18
+ protected getEndpointMembers(ctx: Context, args: Args.GetEndpointMembers): kt.ObjectMember<Builder>[];
19
+ protected getEndpointFunctionName(ctx: Context, args: Args.GetEndpointFunctionName): string;
20
+ protected getEndpointFunction(ctx: Context, args: Args.GetEndpointFunction): kt.Function<Builder>;
21
+ protected getEndpointFunctionBody(ctx: Context, args: Args.GetEndpointFunctionBody): AppendValueGroup<Builder>;
22
+ protected getEndpointFunctionWithHandler(ctx: Context, args: Args.GetEndpointFunctionWithHandler): kt.Function<Builder>;
23
+ protected getEndpointFunctionWithHandlerBody(ctx: Context, args: Args.GetEndpointFunctionWithHandlerBody): AppendValueGroup<Builder>;
24
+ protected getEndpointRequestFunctionName(ctx: Context, args: Args.GetEndpointRequestFunctionName): string;
25
+ protected getEndpointRequestFunction(ctx: Context, args: Args.GetEndpointRequestFunction): kt.Function<Builder>;
26
+ protected getEndpointRequestFunctionBody(ctx: Context, args: Args.GetEndpointRequestFunctionBody): AppendValueGroup<Builder>;
27
+ protected getEndpointUriFunctionName(ctx: Context, args: Args.GetEndpointUriFunctionName): string;
28
+ protected getEndpointUriFunction(ctx: Context, args: Args.GetEndpointUriFunction): kt.Function<Builder>;
29
+ protected getEndpointUriFunctionBody(ctx: Context, args: Args.GetEndpointUriFunctionBody): AppendValueGroup<Builder>;
30
+ protected getParameterToString(ctx: Context, args: Args.GetParameterToString): kt.Value<Builder>;
31
+ protected getParameterType(ctx: Context, args: Args.GetParameterType): kt.Type<Builder>;
32
+ protected getParameterDefaultValue(ctx: Context, args: Args.GetParameterDefaultValue): kt.Value<Builder> | null;
33
+ protected getTypeUsage(ctx: Context, args: Args.GetTypeUsage<Builder>): kt.Type<Builder>;
34
+ protected getPackageName(ctx: Context, args: Args.GetPackageName): string;
35
+ protected getResponseSchema(_ctx: Context, args: Args.GetResponseSchema): ApiSchema | undefined;
36
+ protected getSchemaType(ctx: Context, args: Args.GetSchemaType): kt.Reference<SourceBuilder> | undefined;
37
+ protected getAllParameters(ctx: Context, args: Args.GetAllParameters): ApiParameterWithMultipartInfo[];
38
+ protected getRequestBodyParamName(ctx: Context, args: Args.GetRequestBodyParamName): string;
39
+ protected getBasePath(ctx: Context, _args: Args.GetBasePath): string;
40
+ protected getEndpointPath(ctx: Context, args: Args.GetEndpointPath): string;
41
+ protected getFilePath(ctx: Context, args: Args.GetFilePath): string;
42
+ protected getRequestsObjectName(ctx: Context, args: Args.GetRequestsObjectName): string;
43
+ private createApiParameter;
44
+ }
45
+ export {};
46
+ //# sourceMappingURL=spring-reactive-web-client-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-reactive-web-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,gBAAgB,EAIrB,KAAK,YAAY,EAEjB,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;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,MAAM;IAMnE,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,qBAAqB;IAI9E,OAAO,CAAC,kBAAkB;CAgB3B"}
@@ -0,0 +1,388 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultKotlinSpringReactiveWebClientGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_path_1 = require("node:path");
6
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
7
+ const core_1 = require("@goast/core");
8
+ const index_js_1 = require("../../../ast/index.js");
9
+ const file_builder_js_1 = require("../../../file-builder.js");
10
+ const utils_js_1 = require("../../../utils.js");
11
+ const file_generator_js_1 = require("../../file-generator.js");
12
+ class DefaultKotlinSpringReactiveWebClientGenerator extends file_generator_js_1.KotlinFileGenerator {
13
+ generate(ctx) {
14
+ const typeName = this.getRequestsObjectName(ctx, {});
15
+ const packageName = this.getPackageName(ctx, {});
16
+ const filePath = this.getFilePath(ctx, { packageName });
17
+ fs_extra_1.default.ensureDirSync((0, node_path_1.dirname)(filePath));
18
+ console.log(`Generating client for service ${ctx.service.name} to ${filePath}...`);
19
+ const builder = new file_builder_js_1.KotlinFileBuilder(packageName, ctx.config);
20
+ builder.append(this.getClientFileContent(ctx, {}));
21
+ fs_extra_1.default.writeFileSync(filePath, builder.toString());
22
+ return { typeName, packageName };
23
+ }
24
+ // deno-lint-ignore no-unused-vars
25
+ getClientFileContent(ctx, args) {
26
+ return (0, core_1.appendValueGroup)([this.getRequestsObject(ctx, {})], '\n\n');
27
+ }
28
+ // deno-lint-ignore no-unused-vars
29
+ getRequestsObject(ctx, args) {
30
+ return index_js_1.kt.object({
31
+ name: this.getRequestsObjectName(ctx, {}),
32
+ members: ctx.service.endpoints.flatMap((endpoint) => this.getEndpointMembers(ctx, { endpoint, parameters: this.getAllParameters(ctx, { endpoint }) })),
33
+ });
34
+ }
35
+ getEndpointMembers(ctx, args) {
36
+ const { endpoint, parameters } = args;
37
+ const responseSchema = this.getResponseSchema(ctx, { endpoint });
38
+ return [
39
+ this.getEndpointFunction(ctx, { endpoint, parameters, responseSchema }),
40
+ this.getEndpointFunctionWithHandler(ctx, { endpoint, parameters, responseSchema }),
41
+ this.getEndpointUriFunction(ctx, { endpoint, parameters }),
42
+ this.getEndpointRequestFunction(ctx, { endpoint, parameters, responseSchema }),
43
+ ];
44
+ }
45
+ getEndpointFunctionName(ctx, args) {
46
+ const { endpoint } = args;
47
+ return (0, core_1.toCasing)(endpoint.name, ctx.config.functionNameCasing);
48
+ }
49
+ getEndpointFunction(ctx, args) {
50
+ const { endpoint, parameters, responseSchema } = args;
51
+ const functionName = this.getEndpointFunctionName(ctx, { endpoint });
52
+ return index_js_1.kt.function(functionName, {
53
+ doc: index_js_1.kt.doc(endpoint.description),
54
+ suspend: true,
55
+ receiverType: index_js_1.kt.refs.springReactive.webClient(),
56
+ parameters: parameters.map((parameter) => index_js_1.kt.parameter((0, core_1.toCasing)(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
57
+ returnType: this.getTypeUsage(ctx, { schema: responseSchema, fallback: index_js_1.kt.refs.unit() }),
58
+ body: this.getEndpointFunctionBody(ctx, { endpoint, parameters, responseSchema }),
59
+ });
60
+ }
61
+ getEndpointFunctionBody(ctx, args) {
62
+ const { endpoint, parameters, responseSchema } = args;
63
+ const result = (0, core_1.appendValueGroup)([], '\n');
64
+ const requestFunctionName = this.getEndpointRequestFunctionName(ctx, { endpoint });
65
+ const parameterNames = parameters.map((p) => (0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing));
66
+ const call = index_js_1.kt.call([
67
+ 'this',
68
+ index_js_1.kt.call(requestFunctionName, parameterNames),
69
+ index_js_1.kt.call('retrieve', []),
70
+ responseSchema
71
+ ? index_js_1.kt.call(index_js_1.kt.refs.springReactive.awaitBody([
72
+ this.getTypeUsage(ctx, { schema: responseSchema, fallback: index_js_1.kt.refs.unit() }),
73
+ ]), [])
74
+ : index_js_1.kt.call(index_js_1.kt.refs.springReactive.awaitBodilessEntity(), []),
75
+ ]);
76
+ if (responseSchema) {
77
+ result.values.push((0, core_1.builderTemplate) `return ${call}`);
78
+ }
79
+ else {
80
+ result.values.push(call);
81
+ }
82
+ return result;
83
+ }
84
+ getEndpointFunctionWithHandler(ctx, args) {
85
+ const { endpoint, parameters, responseSchema } = args;
86
+ const functionName = this.getEndpointFunctionName(ctx, { endpoint });
87
+ return index_js_1.kt.function(functionName, {
88
+ doc: index_js_1.kt.doc(endpoint.description),
89
+ suspend: true,
90
+ generics: [index_js_1.kt.genericParameter('T')],
91
+ receiverType: index_js_1.kt.refs.springReactive.webClient(),
92
+ parameters: [
93
+ ...parameters.map((parameter) => index_js_1.kt.parameter((0, core_1.toCasing)(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
94
+ index_js_1.kt.parameter('responseHandler', index_js_1.kt.lambdaType([index_js_1.kt.refs.springReactive.clientResponse()], 'T', { suspend: true })),
95
+ ],
96
+ returnType: 'T',
97
+ body: this.getEndpointFunctionWithHandlerBody(ctx, { endpoint, parameters, responseSchema }),
98
+ });
99
+ }
100
+ getEndpointFunctionWithHandlerBody(ctx, args) {
101
+ const { endpoint, parameters } = args;
102
+ const result = (0, core_1.appendValueGroup)([], '\n');
103
+ const requestFunctionName = this.getEndpointRequestFunctionName(ctx, { endpoint });
104
+ const parameterNames = parameters.map((p) => (0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing));
105
+ result.values.push((0, core_1.builderTemplate) `return ${index_js_1.kt.call([
106
+ index_js_1.kt.call(['this', requestFunctionName], parameterNames),
107
+ index_js_1.kt.call(['exchangeToMono'], [
108
+ index_js_1.kt.lambda([], index_js_1.kt.call(index_js_1.kt.refs.kotlinx.mono.infer(), [index_js_1.kt.lambda([], 'responseHandler(it)', { singleline: true })]), { singleline: true }),
109
+ ]),
110
+ index_js_1.kt.call([index_js_1.kt.refs.kotlinx.awaitFirstOrNull.infer()], []),
111
+ ])} as T`);
112
+ return result;
113
+ }
114
+ getEndpointRequestFunctionName(ctx, args) {
115
+ const { endpoint } = args;
116
+ return (0, core_1.toCasing)(`${this.getEndpointFunctionName(ctx, { endpoint })}_request`, ctx.config.functionNameCasing);
117
+ }
118
+ getEndpointRequestFunction(ctx, args) {
119
+ const { endpoint, parameters, responseSchema } = args;
120
+ const functionName = this.getEndpointRequestFunctionName(ctx, { endpoint });
121
+ return index_js_1.kt.function(functionName, {
122
+ doc: index_js_1.kt.doc(endpoint.description),
123
+ receiverType: index_js_1.kt.refs.springReactive.webClient(),
124
+ parameters: parameters.map((parameter) => index_js_1.kt.parameter((0, core_1.toCasing)(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
125
+ returnType: index_js_1.kt.refs.springReactive.requestHeadersSpec(['*']),
126
+ body: this.getEndpointRequestFunctionBody(ctx, { endpoint, parameters, responseSchema }),
127
+ });
128
+ }
129
+ getEndpointRequestFunctionBody(ctx, args) {
130
+ var _a, _b;
131
+ const { endpoint, parameters, responseSchema } = args;
132
+ const result = (0, core_1.appendValueGroup)([], '\n');
133
+ const callChain = [];
134
+ callChain.push((0, core_1.builderTemplate) `return this.method(${index_js_1.kt.refs.spring.httpMethod()}.${endpoint.method.toUpperCase()})`, index_js_1.kt.call('uri', [index_js_1.kt.call([this.getEndpointUriFunctionName(ctx, { endpoint })], parameters.filter((p) => p.target === 'path' || p.target === 'query').map((p) => (0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing)))]));
135
+ if (responseSchema) {
136
+ callChain.push((0, core_1.builderTemplate) `accept(${index_js_1.kt.refs.spring.mediaType()}.APPLICATION_JSON)`);
137
+ }
138
+ if (((_a = endpoint.requestBody) === null || _a === void 0 ? void 0 : _a.content[0]) !== undefined) {
139
+ callChain.push((0, core_1.builderTemplate) `contentType(${index_js_1.kt.refs.spring.mediaType()}.parseMediaType(${index_js_1.kt.string(endpoint.requestBody.content[0].type)}))`);
140
+ }
141
+ if ((_b = endpoint.requestBody) === null || _b === void 0 ? void 0 : _b.content[0]) {
142
+ if (endpoint.requestBody.content[0].type === 'multipart/form-data') {
143
+ callChain.push(index_js_1.kt.call('body', [
144
+ index_js_1.kt.call([index_js_1.kt.refs.springReactive.bodyInserters(), 'fromMultipartData'], [
145
+ index_js_1.kt.call([
146
+ index_js_1.kt.call(index_js_1.kt.refs.spring.multipartBodyBuilder(), []),
147
+ index_js_1.kt.call('apply', [
148
+ index_js_1.kt.lambda([], (0, core_1.appendValueGroup)(parameters.filter((x) => x.multipart).map((p) => {
149
+ var _a, _b, _c;
150
+ const parameterName = (0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing);
151
+ if ((_a = p.multipart) === null || _a === void 0 ? void 0 : _a.isFile) {
152
+ return index_js_1.kt.call([
153
+ p.required && !((_b = p.schema) === null || _b === void 0 ? void 0 : _b.nullable) ? parameterName : `${parameterName}?`,
154
+ 'addToBuilder',
155
+ ], ['this']);
156
+ }
157
+ else {
158
+ const call = index_js_1.kt.call([
159
+ index_js_1.kt.call('part', [index_js_1.kt.string(p.multipart.name), parameterName]),
160
+ index_js_1.kt.call('contentType', [
161
+ index_js_1.kt.call([
162
+ index_js_1.kt.refs.spring.mediaType(),
163
+ 'APPLICATION_JSON',
164
+ ]),
165
+ ]),
166
+ ]);
167
+ return p.required && !((_c = p.schema) === null || _c === void 0 ? void 0 : _c.nullable) ? call : index_js_1.kt.call([`${parameterName}?`, 'also'], [
168
+ index_js_1.kt.lambda([parameterName], call, { singleline: true }),
169
+ ]);
170
+ }
171
+ }), '\n')),
172
+ ]),
173
+ 'build',
174
+ ], []),
175
+ ]),
176
+ ]));
177
+ }
178
+ else {
179
+ const bodySchema = endpoint.requestBody.content[0].schema;
180
+ const parameterName = this.getRequestBodyParamName(ctx, { endpoint });
181
+ const call = index_js_1.kt.call('bodyValue', [
182
+ (0, core_1.toCasing)(parameterName, ctx.config.parameterNameCasing),
183
+ ]);
184
+ callChain.push(endpoint.requestBody.required && !(bodySchema === null || bodySchema === void 0 ? void 0 : bodySchema.nullable) ? call : index_js_1.kt.call('apply', [
185
+ index_js_1.kt.lambda([], index_js_1.kt.call([`${parameterName}?`, 'also'], [index_js_1.kt.lambda([parameterName], call, { singleline: true })]), { singleline: true }),
186
+ ]));
187
+ }
188
+ }
189
+ if (parameters.some((x) => x.target === 'header')) {
190
+ callChain.push(index_js_1.kt.call('headers', [
191
+ index_js_1.kt.lambda(['headers'], (0, core_1.appendValueGroup)(parameters.filter((x) => x.target === 'header').map((p) => {
192
+ var _a;
193
+ const parameterName = (0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing);
194
+ const toString = this.getParameterToString(ctx, { endpoint, parameter: p });
195
+ return p.required && !((_a = p.schema) === null || _a === void 0 ? void 0 : _a.nullable)
196
+ ? index_js_1.kt.call(['headers', 'add'], [index_js_1.kt.string(p.name), parameterName + toString])
197
+ : index_js_1.kt.call([`${parameterName}?`, 'also'], [
198
+ index_js_1.kt.lambda([], index_js_1.kt.call(['headers', 'add'], [index_js_1.kt.string(p.name), 'it' + toString]), {
199
+ singleline: true,
200
+ }),
201
+ ]);
202
+ }), '\n')),
203
+ ]));
204
+ }
205
+ result.values.push(index_js_1.kt.call(callChain));
206
+ return result;
207
+ }
208
+ getEndpointUriFunctionName(ctx, args) {
209
+ const { endpoint } = args;
210
+ return (0, core_1.toCasing)(`${this.getEndpointFunctionName(ctx, { endpoint })}_uri`, ctx.config.functionNameCasing);
211
+ }
212
+ getEndpointUriFunction(ctx, args) {
213
+ const { endpoint, parameters } = args;
214
+ const functionName = this.getEndpointUriFunctionName(ctx, { endpoint });
215
+ return index_js_1.kt.function(functionName, {
216
+ parameters: parameters.filter((p) => p.target === 'path' || p.target === 'query').map((parameter) => index_js_1.kt.parameter((0, core_1.toCasing)(parameter.name, ctx.config.parameterNameCasing), this.getParameterType(ctx, { endpoint, parameter }), { default: this.getParameterDefaultValue(ctx, { endpoint, parameter }) })),
217
+ returnType: index_js_1.kt.refs.string(),
218
+ body: this.getEndpointUriFunctionBody(ctx, { endpoint, parameters }),
219
+ });
220
+ }
221
+ getEndpointUriFunctionBody(ctx, args) {
222
+ const { endpoint } = args;
223
+ const result = (0, core_1.appendValueGroup)([], '\n');
224
+ const callChain = [];
225
+ callChain.push((0, core_1.builderTemplate) `${index_js_1.kt.refs.spring.uriComponentsBuilder()}.fromPath(${index_js_1.kt.string(this.getEndpointPath(ctx, { endpoint }))})`);
226
+ if (endpoint.parameters.some((x) => x.target === 'query')) {
227
+ callChain.push(index_js_1.kt.call('apply', [index_js_1.kt.lambda([], (0, core_1.appendValueGroup)(endpoint.parameters.filter((x) => x.target === 'query').map((p) => {
228
+ var _a;
229
+ const parameterName = (0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing);
230
+ const toString = this.getParameterToString(ctx, { endpoint, parameter: p });
231
+ return p.required && !((_a = p.schema) === null || _a === void 0 ? void 0 : _a.nullable)
232
+ ? index_js_1.kt.call('queryParam', [index_js_1.kt.string(p.name), parameterName + toString])
233
+ : index_js_1.kt.call([`${parameterName}?`, 'also'], [
234
+ index_js_1.kt.lambda([], index_js_1.kt.call('queryParam', [index_js_1.kt.string(p.name), 'it' + toString]), { singleline: true }),
235
+ ]);
236
+ }), '\n'))]));
237
+ }
238
+ if (endpoint.parameters.some((x) => x.target === 'path')) {
239
+ callChain.push(index_js_1.kt.call('buildAndExpand', [
240
+ index_js_1.kt.call([index_js_1.kt.refs.mapOf.infer()], endpoint.parameters.filter((p) => p.target === 'path').map((p) => (0, core_1.builderTemplate) `${index_js_1.kt.string(p.name)} to ${(0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing)}${this.getParameterToString(ctx, { endpoint, parameter: p })}`)),
241
+ ]));
242
+ }
243
+ else {
244
+ callChain.push(index_js_1.kt.call('build', []));
245
+ }
246
+ callChain.push('toUriString');
247
+ result.values.push((0, core_1.builderTemplate) `return ${index_js_1.kt.call(callChain, [])}`);
248
+ return result;
249
+ }
250
+ getParameterToString(ctx, args) {
251
+ var _a, _b, _c;
252
+ const { parameter } = args;
253
+ if (((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'array') {
254
+ return '.joinToString()';
255
+ }
256
+ else if (((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.kind) === 'string' && ((_c = parameter.schema.enum) === null || _c === void 0 ? void 0 : _c.length) &&
257
+ this.getSchemaType(ctx, { schema: parameter.schema })) {
258
+ return '.value';
259
+ }
260
+ else {
261
+ return '.toString()';
262
+ }
263
+ }
264
+ getParameterType(ctx, args) {
265
+ var _a;
266
+ const { parameter } = args;
267
+ if ((_a = parameter.multipart) === null || _a === void 0 ? void 0 : _a.isFile) {
268
+ return ctx.refs.apiRequestFile();
269
+ }
270
+ return this.getTypeUsage(ctx, {
271
+ schema: parameter.schema,
272
+ nullable: !parameter.required,
273
+ });
274
+ }
275
+ getParameterDefaultValue(ctx, args) {
276
+ var _a, _b;
277
+ const { parameter } = args;
278
+ return !parameter.required
279
+ ? ((_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.kind) === 'string' && parameter.schema.enum && parameter.schema.default
280
+ ? (0, core_1.builderTemplate) `${this.getTypeUsage(ctx, { schema: parameter.schema, nullable: false })}.${(0, core_1.toCasing)(String(parameter.schema.default), ctx.config.enumValueNameCasing)}`
281
+ : index_js_1.kt.toNode((_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.default)
282
+ : null;
283
+ }
284
+ getTypeUsage(ctx, args) {
285
+ const { schema, nullable, fallback } = args;
286
+ const type = this.getSchemaType(ctx, { schema });
287
+ return type
288
+ ? (0, core_1.createOverwriteProxy)(type, { nullable: nullable !== null && nullable !== void 0 ? nullable : type.nullable })
289
+ : (fallback !== null && fallback !== void 0 ? fallback : index_js_1.kt.refs.any({ nullable }));
290
+ }
291
+ // deno-lint-ignore no-unused-vars
292
+ getPackageName(ctx, args) {
293
+ const packageSuffix = typeof ctx.config.packageSuffix === 'string'
294
+ ? ctx.config.packageSuffix
295
+ : ctx.config.packageSuffix(ctx.service);
296
+ return ctx.config.packageName + packageSuffix;
297
+ }
298
+ getResponseSchema(_ctx, args) {
299
+ var _a, _b;
300
+ const { endpoint } = args;
301
+ return (_b = (_a = endpoint.responses.find((x) => !x.statusCode || (x.statusCode >= 200 && x.statusCode < 300))) === null || _a === void 0 ? void 0 : _a.contentOptions[0]) === null || _b === void 0 ? void 0 : _b.schema;
302
+ }
303
+ getSchemaType(ctx, args) {
304
+ const { schema } = args;
305
+ return schema && ctx.input.kotlin.models[schema.id].type;
306
+ }
307
+ getAllParameters(ctx, args) {
308
+ var _a, _b;
309
+ const { endpoint } = args;
310
+ const parameters = endpoint.parameters.filter((parameter) => parameter.target === 'query' || parameter.target === 'path' || parameter.target === 'header');
311
+ if (endpoint.requestBody) {
312
+ const content = endpoint.requestBody.content[0];
313
+ let schema = content.schema;
314
+ if (content.type === 'multipart/form-data') {
315
+ if (schema && schema.kind === 'object') {
316
+ schema = (_a = (0, core_1.resolveAnyOfAndAllOf)(schema, true)) !== null && _a !== void 0 ? _a : schema;
317
+ const properties = (_b = schema.properties) !== null && _b !== void 0 ? _b : {};
318
+ for (const [name, property] of properties.entries()) {
319
+ parameters.push(Object.assign(this.createApiParameter({
320
+ id: `multipart-${name}`,
321
+ name,
322
+ target: 'body',
323
+ schema: property.schema,
324
+ required: schema.required.has(name),
325
+ description: property.schema.description,
326
+ }), {
327
+ multipart: {
328
+ name,
329
+ isFile: property.schema.kind === 'string' && property.schema.format === 'binary',
330
+ },
331
+ }));
332
+ }
333
+ }
334
+ }
335
+ else {
336
+ parameters.push(this.createApiParameter({
337
+ id: 'body',
338
+ name: this.getRequestBodyParamName(ctx, { endpoint }),
339
+ target: 'body',
340
+ schema,
341
+ required: endpoint.requestBody.required,
342
+ description: endpoint.requestBody.description,
343
+ }));
344
+ }
345
+ }
346
+ return parameters.sort((a, b) => (a.required === b.required ? 0 : a.required ? -1 : 1));
347
+ }
348
+ getRequestBodyParamName(ctx, args) {
349
+ var _a;
350
+ const { endpoint } = args;
351
+ const schema = (_a = endpoint.requestBody) === null || _a === void 0 ? void 0 : _a.content[0].schema;
352
+ const schemaInfo = this.getSchemaType(ctx, { schema });
353
+ return (0, core_1.toCasing)(schemaInfo && schemaInfo.name !== 'Any' ? core_1.SourceBuilder.build((b) => index_js_1.kt.reference.write(b, schemaInfo)) : 'body', ctx.config.parameterNameCasing);
354
+ }
355
+ getBasePath(ctx, _args) {
356
+ var _a, _b, _c, _d, _e, _f;
357
+ return (0, utils_js_1.modifyString)((_f = (_e = (_d = (_c = ((_a = ctx.service.$src) !== null && _a !== void 0 ? _a : (_b = ctx.service.endpoints[0]) === null || _b === void 0 ? void 0 : _b.$src)) === null || _c === void 0 ? void 0 : _c.document.servers) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : '/', ctx.config.basePath, ctx.service);
358
+ }
359
+ getEndpointPath(ctx, args) {
360
+ const { endpoint } = args;
361
+ return (0, utils_js_1.modifyString)(endpoint.path.replace(/^\/*/, ''), ctx.config.pathModifier, endpoint);
362
+ }
363
+ getFilePath(ctx, args) {
364
+ const { packageName } = args;
365
+ return `${ctx.config.outputDir}/${packageName.replace(/\./g, '/')}/${this.getRequestsObjectName(ctx, {})}.kt`;
366
+ }
367
+ // deno-lint-ignore no-unused-vars
368
+ getRequestsObjectName(ctx, args) {
369
+ return (0, core_1.toCasing)(`${ctx.service.name}_Requests`, ctx.config.typeNameCasing);
370
+ }
371
+ createApiParameter(data) {
372
+ return {
373
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
374
+ $src: undefined,
375
+ $ref: undefined,
376
+ schema: undefined,
377
+ required: false,
378
+ description: undefined,
379
+ allowEmptyValue: undefined,
380
+ allowReserved: undefined,
381
+ deprecated: false,
382
+ explode: undefined,
383
+ style: undefined,
384
+ ...data,
385
+ };
386
+ }
387
+ }
388
+ exports.DefaultKotlinSpringReactiveWebClientGenerator = DefaultKotlinSpringReactiveWebClientGenerator;
@@ -0,0 +1,23 @@
1
+ import { type ApiService, Factory, type MaybePromise, type OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
2
+ import type { KotlinServicesGeneratorInput } from '../spring-controllers/index.js';
3
+ import { type KotlinSpringReactiveWebClientGeneratorOutput, type KotlinSpringReactiveWebClientsGeneratorConfig, type KotlinSpringReactiveWebClientsGeneratorContext, type KotlinSpringReactiveWebClientsGeneratorInput, type KotlinSpringReactiveWebClientsGeneratorOutput } from './models.js';
4
+ import { type KotlinSpringReactiveWebClientGenerator } from './spring-reactive-web-client-generator.js';
5
+ type Input = KotlinSpringReactiveWebClientsGeneratorInput;
6
+ type Output = KotlinSpringReactiveWebClientsGeneratorOutput;
7
+ type Config = KotlinSpringReactiveWebClientsGeneratorConfig;
8
+ type ServiceOutput = KotlinSpringReactiveWebClientGeneratorOutput;
9
+ type Context = KotlinSpringReactiveWebClientsGeneratorContext;
10
+ export declare class KotlinSpringReactiveWebClientsGenerator extends OpenApiServicesGenerationProviderBase<Input, Output, Config, ServiceOutput, Context> {
11
+ private readonly _serviceGeneratorFactory;
12
+ constructor(serviceGeneratorFactory?: Factory<KotlinSpringReactiveWebClientGenerator, []>);
13
+ protected generateAdditionalFiles(ctx: Context): Promise<void>;
14
+ protected initResult(): Output;
15
+ protected generateService(ctx: Context, service: ApiService): MaybePromise<ServiceOutput>;
16
+ protected addServiceResult(ctx: Context, service: ApiService, result: ServiceOutput): void;
17
+ protected buildContext(context: OpenApiGeneratorContext<KotlinServicesGeneratorInput>, config?: Partial<Config> | undefined): Context;
18
+ protected getInfrastructurePackageName(config: Config): string;
19
+ protected getPackageName(config: Config): string;
20
+ private copyInfrastructureFiles;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=spring-reactive-web-clients-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-reactive-web-clients-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,UAAU,EACf,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,qCAAqC,EACtC,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAEL,KAAK,4CAA4C,EACjD,KAAK,6CAA6C,EAClD,KAAK,8CAA8C,EACnD,KAAK,4CAA4C,EACjD,KAAK,6CAA6C,EACnD,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,sCAAsC,EAC5C,MAAM,2CAA2C,CAAC;AAEnD,KAAK,KAAK,GAAG,4CAA4C,CAAC;AAC1D,KAAK,MAAM,GAAG,6CAA6C,CAAC;AAC5D,KAAK,MAAM,GAAG,6CAA6C,CAAC;AAC5D,KAAK,aAAa,GAAG,4CAA4C,CAAC;AAClE,KAAK,OAAO,GAAG,8CAA8C,CAAC;AAE9D,qBAAa,uCAAwC,SAAQ,qCAAqC,CAChG,KAAK,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,OAAO,CACR;IACC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAsD;gBAEnF,uBAAuB,CAAC,EAAE,OAAO,CAAC,sCAAsC,EAAE,EAAE,CAAC;cAMhE,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7E,SAAS,CAAC,UAAU,IAAI,MAAM;IAQ9B,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,GAAG,YAAY,CAAC,aAAa,CAAC;IAQzF,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI;IAI1F,SAAS,CAAC,YAAY,CACpB,OAAO,EAAE,uBAAuB,CAAC,4BAA4B,CAAC,EAC9D,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,GACnC,OAAO;IAcV,SAAS,CAAC,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAc9D,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;YAKlC,uBAAuB;CAiBtC"}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KotlinSpringReactiveWebClientsGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const node_path_1 = require("node:path");
6
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
7
+ const core_1 = require("@goast/core");
8
+ const assets_js_1 = require("../../../assets.js");
9
+ const models_js_1 = require("./models.js");
10
+ const refs_js_1 = require("./refs.js");
11
+ const spring_reactive_web_client_generator_js_1 = require("./spring-reactive-web-client-generator.js");
12
+ class KotlinSpringReactiveWebClientsGenerator extends core_1.OpenApiServicesGenerationProviderBase {
13
+ constructor(serviceGeneratorFactory) {
14
+ super();
15
+ Object.defineProperty(this, "_serviceGeneratorFactory", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: void 0
20
+ });
21
+ this._serviceGeneratorFactory = serviceGeneratorFactory !== null && serviceGeneratorFactory !== void 0 ? serviceGeneratorFactory : core_1.Factory.fromValue(new spring_reactive_web_client_generator_js_1.DefaultKotlinSpringReactiveWebClientGenerator());
22
+ }
23
+ async generateAdditionalFiles(ctx) {
24
+ await this.copyInfrastructureFiles(ctx);
25
+ }
26
+ initResult() {
27
+ return {
28
+ kotlin: {
29
+ clients: {},
30
+ },
31
+ };
32
+ }
33
+ generateService(ctx, service) {
34
+ const serviceGenerator = this._serviceGeneratorFactory.create();
35
+ return serviceGenerator.generate({
36
+ ...ctx,
37
+ service,
38
+ });
39
+ }
40
+ addServiceResult(ctx, service, result) {
41
+ ctx.output.kotlin.clients[service.id] = result;
42
+ }
43
+ buildContext(context, config) {
44
+ context.data.services = context.data.services.filter((x) => x.name !== 'exclude-from-generation');
45
+ const providerContext = this.getProviderContext(context, config, models_js_1.defaultKotlinSpringReactiveWebClientsGeneratorConfig);
46
+ const infrastructurePackageName = this.getInfrastructurePackageName(providerContext.config);
47
+ return Object.assign(providerContext, {
48
+ infrastructurePackageName,
49
+ refs: (0, refs_js_1.getReferenceFactories)(infrastructurePackageName),
50
+ });
51
+ }
52
+ getInfrastructurePackageName(config) {
53
+ if (typeof config.infrastructurePackageName === 'string') {
54
+ return config.infrastructurePackageName;
55
+ }
56
+ if (config.infrastructurePackageName.mode === 'append-package-name') {
57
+ return config.packageName + config.infrastructurePackageName.value;
58
+ }
59
+ if (config.infrastructurePackageName.mode === 'append-full-package-name') {
60
+ return this.getPackageName(config) + config.infrastructurePackageName.value;
61
+ }
62
+ return config.infrastructurePackageName.value;
63
+ }
64
+ getPackageName(config) {
65
+ const packageSuffix = typeof config.packageSuffix === 'string' ? config.packageSuffix : config.packageSuffix();
66
+ return config.packageName + packageSuffix;
67
+ }
68
+ async copyInfrastructureFiles(ctx) {
69
+ const targetDir = (0, node_path_1.resolve)(ctx.config.outputDir, ctx.infrastructurePackageName.replace(/\./g, '/'));
70
+ await fs_extra_1.default.ensureDir(targetDir);
71
+ const files = [
72
+ 'ApiRequestFile.kt',
73
+ ];
74
+ for (const file of files) {
75
+ const sourcePath = `client/spring-reactive-web-clients/${file}`;
76
+ const targetPath = (0, node_path_1.resolve)(targetDir, file);
77
+ console.log(`Copying asset file "${sourcePath}" to "${targetPath}"`);
78
+ const fileContent = (await (0, assets_js_1.getAssetFileContent)(sourcePath))
79
+ .replace(/@PACKAGE_NAME@/g, ctx.infrastructurePackageName);
80
+ fs_extra_1.default.writeFileSync(targetPath, fileContent);
81
+ }
82
+ }
83
+ }
84
+ exports.KotlinSpringReactiveWebClientsGenerator = KotlinSpringReactiveWebClientsGenerator;