@goast/kotlin 0.5.0 → 0.5.1-beta.1

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 (94) hide show
  1. package/LICENSE +21 -21
  2. package/assets/client/okhttp3/ApiAbstractions.kt +30 -30
  3. package/assets/client/okhttp3/ApiClient.kt +253 -253
  4. package/assets/client/okhttp3/ApiResponse.kt +43 -43
  5. package/assets/client/okhttp3/Errors.kt +21 -21
  6. package/assets/client/okhttp3/PartConfig.kt +11 -11
  7. package/assets/client/okhttp3/RequestConfig.kt +18 -18
  8. package/assets/client/okhttp3/RequestMethod.kt +8 -8
  9. package/assets/client/okhttp3/ResponseExtensions.kt +24 -24
  10. package/assets/client/spring-reactive-web-clients/ApiRequestFile.kt +33 -33
  11. package/esm/src/generators/models/model-generator.d.ts.map +1 -1
  12. package/esm/src/generators/models/model-generator.js +10 -5
  13. package/package.json +2 -2
  14. package/script/src/generators/models/model-generator.d.ts.map +1 -1
  15. package/script/src/generators/models/model-generator.js +10 -5
  16. package/src/mod.ts +0 -8
  17. package/src/src/assets.ts +0 -9
  18. package/src/src/ast/_index.ts +0 -66
  19. package/src/src/ast/common.ts +0 -1
  20. package/src/src/ast/index.ts +0 -1
  21. package/src/src/ast/node.ts +0 -10
  22. package/src/src/ast/nodes/annotation.ts +0 -79
  23. package/src/src/ast/nodes/argument.ts +0 -62
  24. package/src/src/ast/nodes/call.ts +0 -75
  25. package/src/src/ast/nodes/class.ts +0 -178
  26. package/src/src/ast/nodes/collection-literal.ts +0 -49
  27. package/src/src/ast/nodes/constructor.ts +0 -126
  28. package/src/src/ast/nodes/doc-tag.ts +0 -138
  29. package/src/src/ast/nodes/doc.ts +0 -111
  30. package/src/src/ast/nodes/enum-value.ts +0 -100
  31. package/src/src/ast/nodes/enum.ts +0 -163
  32. package/src/src/ast/nodes/function.ts +0 -178
  33. package/src/src/ast/nodes/generic-parameter.ts +0 -54
  34. package/src/src/ast/nodes/init-block.ts +0 -38
  35. package/src/src/ast/nodes/interface.ts +0 -133
  36. package/src/src/ast/nodes/lambda-type.ts +0 -73
  37. package/src/src/ast/nodes/lambda.ts +0 -74
  38. package/src/src/ast/nodes/object.ts +0 -102
  39. package/src/src/ast/nodes/parameter.ts +0 -118
  40. package/src/src/ast/nodes/property.ts +0 -225
  41. package/src/src/ast/nodes/reference.ts +0 -178
  42. package/src/src/ast/nodes/string.ts +0 -114
  43. package/src/src/ast/nodes/types.ts +0 -23
  44. package/src/src/ast/references/index.ts +0 -10
  45. package/src/src/ast/references/jackson.ts +0 -44
  46. package/src/src/ast/references/jakarta.ts +0 -14
  47. package/src/src/ast/references/java.ts +0 -20
  48. package/src/src/ast/references/kotlin.ts +0 -41
  49. package/src/src/ast/references/kotlinx.ts +0 -14
  50. package/src/src/ast/references/okhttp3.ts +0 -5
  51. package/src/src/ast/references/reactor.ts +0 -5
  52. package/src/src/ast/references/spring-reactive.ts +0 -33
  53. package/src/src/ast/references/spring.ts +0 -86
  54. package/src/src/ast/references/swagger.ts +0 -23
  55. package/src/src/ast/utils/get-kotlin-builder-options.ts +0 -19
  56. package/src/src/ast/utils/to-kt-node.ts +0 -31
  57. package/src/src/ast/utils/write-kt-annotations.ts +0 -15
  58. package/src/src/ast/utils/write-kt-arguments.ts +0 -45
  59. package/src/src/ast/utils/write-kt-enum-values.ts +0 -27
  60. package/src/src/ast/utils/write-kt-generic-parameters.ts +0 -12
  61. package/src/src/ast/utils/write-kt-members.ts +0 -25
  62. package/src/src/ast/utils/write-kt-node.ts +0 -37
  63. package/src/src/ast/utils/write-kt-parameters.ts +0 -25
  64. package/src/src/common-results.ts +0 -4
  65. package/src/src/config.ts +0 -41
  66. package/src/src/file-builder.ts +0 -112
  67. package/src/src/generators/file-generator.ts +0 -29
  68. package/src/src/generators/index.ts +0 -5
  69. package/src/src/generators/models/args.ts +0 -132
  70. package/src/src/generators/models/index.ts +0 -4
  71. package/src/src/generators/models/model-generator.ts +0 -695
  72. package/src/src/generators/models/models-generator.ts +0 -65
  73. package/src/src/generators/models/models.ts +0 -95
  74. package/src/src/generators/services/okhttp3-clients/args.ts +0 -88
  75. package/src/src/generators/services/okhttp3-clients/index.ts +0 -4
  76. package/src/src/generators/services/okhttp3-clients/models.ts +0 -73
  77. package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +0 -597
  78. package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +0 -169
  79. package/src/src/generators/services/okhttp3-clients/refs.ts +0 -59
  80. package/src/src/generators/services/spring-controllers/args.ts +0 -93
  81. package/src/src/generators/services/spring-controllers/index.ts +0 -4
  82. package/src/src/generators/services/spring-controllers/models.ts +0 -76
  83. package/src/src/generators/services/spring-controllers/refs.ts +0 -17
  84. package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +0 -1084
  85. package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +0 -140
  86. package/src/src/generators/services/spring-reactive-web-clients/args.ts +0 -101
  87. package/src/src/generators/services/spring-reactive-web-clients/index.ts +0 -4
  88. package/src/src/generators/services/spring-reactive-web-clients/models.ts +0 -62
  89. package/src/src/generators/services/spring-reactive-web-clients/refs.ts +0 -11
  90. package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts +0 -571
  91. package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts +0 -125
  92. package/src/src/import-collection.ts +0 -98
  93. package/src/src/types.ts +0 -3
  94. package/src/src/utils.ts +0 -39
@@ -1,140 +0,0 @@
1
- import {
2
- type ApiService,
3
- type AppendValueGroup,
4
- appendValueGroup,
5
- Factory,
6
- type MaybePromise,
7
- type OpenApiGeneratorContext,
8
- OpenApiServicesGenerationProviderBase,
9
- } from '@goast/core';
10
-
11
- import { kt } from '../../../ast/index.js';
12
- import { KotlinFileBuilder } from '../../../file-builder.js';
13
- import {
14
- defaultKotlinServicesGeneratorConfig,
15
- type KotlinServiceGeneratorOutput,
16
- type KotlinServicesGeneratorConfig,
17
- type KotlinServicesGeneratorContext,
18
- type KotlinServicesGeneratorInput,
19
- type KotlinServicesGeneratorOutput,
20
- } from './models.js';
21
- import { getReferenceFactories } from './refs.js';
22
- import {
23
- DefaultKotlinSpringControllerGenerator,
24
- type KotlinSpringControllerGenerator,
25
- } from './spring-controller-generator.js';
26
-
27
- type Input = KotlinServicesGeneratorInput;
28
- type Output = KotlinServicesGeneratorOutput;
29
- type Config = KotlinServicesGeneratorConfig;
30
- type ServiceOutput = KotlinServiceGeneratorOutput;
31
- type Context = KotlinServicesGeneratorContext;
32
-
33
- export class KotlinSpringControllersGenerator extends OpenApiServicesGenerationProviderBase<
34
- Input,
35
- Output,
36
- Config,
37
- ServiceOutput,
38
- Context
39
- > {
40
- private readonly _serviceGeneratorFactory: Factory<
41
- KotlinSpringControllerGenerator,
42
- []
43
- >;
44
-
45
- constructor(
46
- serviceGeneratorFactory?: Factory<KotlinSpringControllerGenerator, []>,
47
- ) {
48
- super();
49
- this._serviceGeneratorFactory = serviceGeneratorFactory ??
50
- Factory.fromValue(new DefaultKotlinSpringControllerGenerator());
51
- }
52
-
53
- protected initResult(): Output {
54
- return {
55
- kotlin: {
56
- services: {},
57
- },
58
- };
59
- }
60
-
61
- protected generateService(
62
- ctx: Context,
63
- service: ApiService,
64
- ): MaybePromise<ServiceOutput> {
65
- const serviceGenerator = this._serviceGeneratorFactory.create();
66
- return serviceGenerator.generate({
67
- ...ctx,
68
- service,
69
- });
70
- }
71
-
72
- protected addServiceResult(
73
- ctx: Context,
74
- service: ApiService,
75
- result: ServiceOutput,
76
- ): void {
77
- ctx.output.kotlin.services[service.id] = result;
78
- }
79
-
80
- protected buildContext(
81
- context: OpenApiGeneratorContext<KotlinServicesGeneratorInput>,
82
- config?: Partial<Config> | undefined,
83
- ): Context {
84
- context.data.services = context.data.services.filter(
85
- (x) => x.name !== 'exclude-from-generation',
86
- );
87
- const providerContext = this.getProviderContext(
88
- context,
89
- config,
90
- defaultKotlinServicesGeneratorConfig,
91
- );
92
- return Object.assign(providerContext, {
93
- refs: getReferenceFactories(providerContext.config),
94
- });
95
- }
96
-
97
- protected override generateAdditionalFiles(
98
- ctx: KotlinServicesGeneratorContext,
99
- ): void {
100
- this.generateApiExceptionHandler(ctx);
101
- }
102
-
103
- protected generateApiExceptionHandler(ctx: Context): void {
104
- const packageName = ctx.refs.apiExceptionHandler.packageName ?? ctx.config.packageName;
105
- const dir = `${ctx.config.outputDir}/${packageName.replace(/\./g, '/')}`;
106
- const fileName = `${ctx.refs.apiExceptionHandler.refName}.kt`;
107
- console.log(`Generating Api Exception Handler to ${fileName}...`);
108
-
109
- const builder = new KotlinFileBuilder(packageName, ctx.config);
110
- builder.append(this.getApiExceptionHandlerInterface(ctx));
111
- builder.writeToFile(`${dir}/${fileName}`);
112
- }
113
-
114
- protected getApiExceptionHandlerFileContent(
115
- ctx: Context,
116
- ): AppendValueGroup<KotlinFileBuilder> {
117
- return appendValueGroup([this.getApiExceptionHandlerInterface(ctx)], '\n');
118
- }
119
-
120
- protected getApiExceptionHandlerInterface(
121
- ctx: Context,
122
- ): kt.Interface<KotlinFileBuilder> {
123
- return kt.interface(ctx.refs.apiExceptionHandler.refName, {
124
- members: [
125
- kt.function('handleApiException', {
126
- doc: kt.doc('Handler for API exceptions.', [
127
- kt.docTag('return', 'Response entity.'),
128
- ]),
129
- suspend: ctx.config.suspendingFunctions,
130
- parameters: [
131
- kt.parameter('exception', kt.refs.throwable(), {
132
- description: 'Exception that has been thrown by the API.',
133
- }),
134
- ],
135
- returnType: kt.refs.spring.responseEntity(['*']),
136
- }),
137
- ],
138
- });
139
- }
140
- }
@@ -1,101 +0,0 @@
1
- import type { ApiEndpoint, ApiParameter, ApiSchema, SourceBuilder } from '@goast/core';
2
- import type { kt } from '../../../ast/index.js';
3
- import type { ApiParameterWithMultipartInfo } from '../../../types.js';
4
-
5
- export type GetClientFileContent = object;
6
-
7
- export type GetRequestsObject = object;
8
-
9
- export type GetEndpointMembers = { endpoint: ApiEndpoint; parameters: ApiParameterWithMultipartInfo[] };
10
-
11
- export type GetEndpointFunctionName = { endpoint: ApiEndpoint };
12
-
13
- export type GetEndpointFunction = {
14
- endpoint: ApiEndpoint;
15
- parameters: ApiParameterWithMultipartInfo[];
16
- responseSchema: ApiSchema | undefined;
17
- };
18
-
19
- export type GetEndpointFunctionBody = {
20
- endpoint: ApiEndpoint;
21
- parameters: ApiParameterWithMultipartInfo[];
22
- responseSchema: ApiSchema | undefined;
23
- };
24
-
25
- export type GetEndpointRequestFunctionName = { endpoint: ApiEndpoint };
26
-
27
- export type GetEndpointRequestFunction = {
28
- endpoint: ApiEndpoint;
29
- parameters: ApiParameterWithMultipartInfo[];
30
- responseSchema: ApiSchema | undefined;
31
- };
32
-
33
- export type GetEndpointRequestFunctionBody = {
34
- endpoint: ApiEndpoint;
35
- parameters: ApiParameterWithMultipartInfo[];
36
- responseSchema: ApiSchema | undefined;
37
- };
38
-
39
- export type GetEndpointFunctionWithHandler = {
40
- endpoint: ApiEndpoint;
41
- parameters: ApiParameterWithMultipartInfo[];
42
- responseSchema: ApiSchema | undefined;
43
- };
44
-
45
- export type GetEndpointFunctionWithHandlerBody = {
46
- endpoint: ApiEndpoint;
47
- parameters: ApiParameterWithMultipartInfo[];
48
- responseSchema: ApiSchema | undefined;
49
- };
50
-
51
- export type GetEndpointUriFunctionName = { endpoint: ApiEndpoint };
52
-
53
- export type GetEndpointUriFunction = {
54
- endpoint: ApiEndpoint;
55
- parameters: ApiParameterWithMultipartInfo[];
56
- };
57
-
58
- export type GetEndpointUriFunctionBody = {
59
- endpoint: ApiEndpoint;
60
- parameters: ApiParameterWithMultipartInfo[];
61
- };
62
-
63
- export type GetParameterToString = {
64
- endpoint: ApiEndpoint;
65
- parameter: ApiParameterWithMultipartInfo;
66
- };
67
-
68
- export type GetAdditionalClientMembers = object;
69
-
70
- export type GetParameterType = { endpoint: ApiEndpoint; parameter: ApiParameterWithMultipartInfo };
71
-
72
- export type GetRequestBodyType = { endpoint: ApiEndpoint };
73
-
74
- export type GetParameterDefaultValue = {
75
- endpoint: ApiEndpoint;
76
- parameter: ApiParameter;
77
- };
78
-
79
- export type GetTypeUsage<TBuilder extends SourceBuilder> = {
80
- schema: ApiSchema | undefined;
81
- nullable?: boolean;
82
- fallback?: kt.Type<TBuilder>;
83
- };
84
-
85
- export type GetPackageName = object;
86
-
87
- export type GetResponseSchema = { endpoint: ApiEndpoint };
88
-
89
- export type GetSchemaType = { schema: ApiSchema | undefined };
90
-
91
- export type GetAllParameters = { endpoint: ApiEndpoint };
92
-
93
- export type GetRequestBodyParamName = { endpoint: ApiEndpoint };
94
-
95
- export type GetBasePath = object;
96
-
97
- export type GetEndpointPath = { endpoint: ApiEndpoint };
98
-
99
- export type GetFilePath = { packageName: string };
100
-
101
- export type GetRequestsObjectName = object;
@@ -1,4 +0,0 @@
1
- export * as DefaultKotlinSpringReactiveWebClientGeneratorArgs from './args.js';
2
- export * from './models.js';
3
- export * from './spring-reactive-web-client-generator.js';
4
- export * from './spring-reactive-web-clients-generator.js';
@@ -1,62 +0,0 @@
1
- import type {
2
- ApiEndpoint,
3
- ApiService,
4
- DefaultGenerationProviderConfig,
5
- OpenApiServicesGenerationProviderContext,
6
- } from '@goast/core';
7
-
8
- import type { KotlinImport } from '../../../common-results.js';
9
- import { defaultKotlinGeneratorConfig, type KotlinGeneratorConfig } from '../../../config.js';
10
- import type { KotlinModelsGeneratorOutput } from '../../models/index.js';
11
- import type { getReferenceFactories } from './refs.js';
12
-
13
- export type KotlinSpringReactiveWebClientsGeneratorConfig = KotlinGeneratorConfig & {
14
- packageName: string;
15
- packageSuffix: string | ((service?: ApiService) => string);
16
- infrastructurePackageName:
17
- | string
18
- | { mode: 'append-package-name' | 'append-full-package-name' | 'replace'; value: string };
19
-
20
- basePath?: string | RegExp | ((basePath: string, service: ApiService) => string);
21
- pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
22
- serializerJsonInclude: 'always' | 'non-null' | 'non-absent' | 'non-default' | 'non-empty' | 'use-defaults';
23
- };
24
-
25
- export const defaultKotlinSpringReactiveWebClientsGeneratorConfig: DefaultGenerationProviderConfig<
26
- KotlinSpringReactiveWebClientsGeneratorConfig
27
- > = {
28
- ...defaultKotlinGeneratorConfig,
29
-
30
- packageName: 'com.openapi.generated',
31
- packageSuffix: '.api.client',
32
- infrastructurePackageName: { mode: 'append-full-package-name', value: '.infrastructure' },
33
- serializerJsonInclude: 'non-absent',
34
- };
35
-
36
- export type KotlinSpringReactiveWebClientsGeneratorInput = KotlinModelsGeneratorOutput;
37
-
38
- export type KotlinSpringReactiveWebClientsGeneratorOutput = {
39
- kotlin: {
40
- clients: {
41
- [serviceId: string]: KotlinSpringReactiveWebClientGeneratorOutput;
42
- };
43
- };
44
- };
45
-
46
- export type KotlinSpringReactiveWebClientGeneratorOutput = KotlinImport;
47
-
48
- export type KotlinSpringReactiveWebClientsGeneratorContext =
49
- & OpenApiServicesGenerationProviderContext<
50
- KotlinSpringReactiveWebClientsGeneratorInput,
51
- KotlinSpringReactiveWebClientsGeneratorOutput,
52
- KotlinSpringReactiveWebClientsGeneratorConfig,
53
- KotlinSpringReactiveWebClientGeneratorOutput
54
- >
55
- & {
56
- infrastructurePackageName: string;
57
- refs: ReturnType<typeof getReferenceFactories>;
58
- };
59
-
60
- export type KotlinSpringReactiveWebClientGeneratorContext = KotlinSpringReactiveWebClientsGeneratorContext & {
61
- service: ApiService;
62
- };
@@ -1,11 +0,0 @@
1
- import { kt } from '../../../ast/index.js';
2
-
3
- // See packages/kotlin/assets/client/spring-reactive-web-clients for reference
4
- export function getReferenceFactories(infrastructurePackageName: string): {
5
- apiRequestFile: kt.ReferenceFactory;
6
- } {
7
- return {
8
- // ApiRequestFile.kt
9
- apiRequestFile: kt.reference.factory('ApiRequestFile', infrastructurePackageName),
10
- };
11
- }