@goast/kotlin 0.5.9 → 0.5.11-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 (124) hide show
  1. package/LICENSE +21 -21
  2. package/assets/client/okhttp3/ApiAbstractions.kt +30 -30
  3. package/assets/client/okhttp3/ApiClient.kt +252 -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/ast/references/jackson.d.ts +8 -5
  12. package/esm/src/ast/references/jackson.d.ts.map +1 -1
  13. package/esm/src/ast/references/jackson.js +14 -6
  14. package/esm/src/ast/references/spring-reactive.d.ts +1 -0
  15. package/esm/src/ast/references/spring-reactive.d.ts.map +1 -1
  16. package/esm/src/ast/references/spring-reactive.js +1 -0
  17. package/esm/src/config.d.ts +10 -0
  18. package/esm/src/config.d.ts.map +1 -1
  19. package/esm/src/config.js +1 -0
  20. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  21. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +36 -32
  22. package/esm/src/generators/services/okhttp3-clients/okhttp3-clients-generator.d.ts.map +1 -1
  23. package/esm/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +22 -6
  24. package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  25. package/esm/src/generators/services/spring-controllers/spring-controller-generator.js +23 -13
  26. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -1
  27. package/esm/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +6 -6
  28. package/package.json +1 -1
  29. package/script/src/ast/references/jackson.d.ts +8 -5
  30. package/script/src/ast/references/jackson.d.ts.map +1 -1
  31. package/script/src/ast/references/jackson.js +20 -7
  32. package/script/src/ast/references/spring-reactive.d.ts +1 -0
  33. package/script/src/ast/references/spring-reactive.d.ts.map +1 -1
  34. package/script/src/ast/references/spring-reactive.js +2 -1
  35. package/script/src/config.d.ts +10 -0
  36. package/script/src/config.d.ts.map +1 -1
  37. package/script/src/config.js +1 -0
  38. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.d.ts.map +1 -1
  39. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +36 -32
  40. package/script/src/generators/services/okhttp3-clients/okhttp3-clients-generator.d.ts.map +1 -1
  41. package/script/src/generators/services/okhttp3-clients/okhttp3-clients-generator.js +22 -6
  42. package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  43. package/script/src/generators/services/spring-controllers/spring-controller-generator.js +23 -13
  44. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.d.ts.map +1 -1
  45. package/script/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.js +6 -6
  46. package/src/mod.ts +0 -8
  47. package/src/src/assets.ts +0 -9
  48. package/src/src/ast/_index.ts +0 -66
  49. package/src/src/ast/common.ts +0 -1
  50. package/src/src/ast/index.ts +0 -1
  51. package/src/src/ast/node.ts +0 -10
  52. package/src/src/ast/nodes/annotation.ts +0 -79
  53. package/src/src/ast/nodes/argument.ts +0 -62
  54. package/src/src/ast/nodes/call.ts +0 -75
  55. package/src/src/ast/nodes/class.ts +0 -178
  56. package/src/src/ast/nodes/collection-literal.ts +0 -49
  57. package/src/src/ast/nodes/constructor.ts +0 -126
  58. package/src/src/ast/nodes/doc-tag.ts +0 -138
  59. package/src/src/ast/nodes/doc.ts +0 -111
  60. package/src/src/ast/nodes/enum-value.ts +0 -100
  61. package/src/src/ast/nodes/enum.ts +0 -163
  62. package/src/src/ast/nodes/function.ts +0 -178
  63. package/src/src/ast/nodes/generic-parameter.ts +0 -54
  64. package/src/src/ast/nodes/init-block.ts +0 -38
  65. package/src/src/ast/nodes/interface.ts +0 -133
  66. package/src/src/ast/nodes/lambda-type.ts +0 -73
  67. package/src/src/ast/nodes/lambda.ts +0 -74
  68. package/src/src/ast/nodes/object.ts +0 -102
  69. package/src/src/ast/nodes/parameter.ts +0 -118
  70. package/src/src/ast/nodes/property.ts +0 -225
  71. package/src/src/ast/nodes/reference.ts +0 -178
  72. package/src/src/ast/nodes/string.ts +0 -114
  73. package/src/src/ast/nodes/types.ts +0 -23
  74. package/src/src/ast/references/index.ts +0 -10
  75. package/src/src/ast/references/jackson.ts +0 -44
  76. package/src/src/ast/references/jakarta.ts +0 -14
  77. package/src/src/ast/references/java.ts +0 -27
  78. package/src/src/ast/references/kotlin.ts +0 -41
  79. package/src/src/ast/references/kotlinx.ts +0 -14
  80. package/src/src/ast/references/okhttp3.ts +0 -5
  81. package/src/src/ast/references/reactor.ts +0 -5
  82. package/src/src/ast/references/spring-reactive.ts +0 -33
  83. package/src/src/ast/references/spring.ts +0 -86
  84. package/src/src/ast/references/swagger.ts +0 -23
  85. package/src/src/ast/utils/get-kotlin-builder-options.ts +0 -19
  86. package/src/src/ast/utils/to-kt-node.ts +0 -31
  87. package/src/src/ast/utils/write-kt-annotations.ts +0 -15
  88. package/src/src/ast/utils/write-kt-arguments.ts +0 -45
  89. package/src/src/ast/utils/write-kt-enum-values.ts +0 -27
  90. package/src/src/ast/utils/write-kt-generic-parameters.ts +0 -12
  91. package/src/src/ast/utils/write-kt-members.ts +0 -25
  92. package/src/src/ast/utils/write-kt-node.ts +0 -37
  93. package/src/src/ast/utils/write-kt-parameters.ts +0 -25
  94. package/src/src/common-results.ts +0 -4
  95. package/src/src/config.ts +0 -48
  96. package/src/src/file-builder.ts +0 -112
  97. package/src/src/generators/file-generator.ts +0 -29
  98. package/src/src/generators/index.ts +0 -5
  99. package/src/src/generators/models/args.ts +0 -136
  100. package/src/src/generators/models/index.ts +0 -4
  101. package/src/src/generators/models/model-generator.ts +0 -725
  102. package/src/src/generators/models/models-generator.ts +0 -65
  103. package/src/src/generators/models/models.ts +0 -95
  104. package/src/src/generators/services/okhttp3-clients/args.ts +0 -90
  105. package/src/src/generators/services/okhttp3-clients/index.ts +0 -4
  106. package/src/src/generators/services/okhttp3-clients/models.ts +0 -73
  107. package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +0 -609
  108. package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +0 -169
  109. package/src/src/generators/services/okhttp3-clients/refs.ts +0 -59
  110. package/src/src/generators/services/spring-controllers/args.ts +0 -95
  111. package/src/src/generators/services/spring-controllers/index.ts +0 -4
  112. package/src/src/generators/services/spring-controllers/models.ts +0 -76
  113. package/src/src/generators/services/spring-controllers/refs.ts +0 -17
  114. package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +0 -1099
  115. package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +0 -140
  116. package/src/src/generators/services/spring-reactive-web-clients/args.ts +0 -103
  117. package/src/src/generators/services/spring-reactive-web-clients/index.ts +0 -4
  118. package/src/src/generators/services/spring-reactive-web-clients/models.ts +0 -62
  119. package/src/src/generators/services/spring-reactive-web-clients/refs.ts +0 -11
  120. package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-client-generator.ts +0 -583
  121. package/src/src/generators/services/spring-reactive-web-clients/spring-reactive-web-clients-generator.ts +0 -125
  122. package/src/src/import-collection.ts +0 -98
  123. package/src/src/types.ts +0 -3
  124. package/src/src/utils.ts +0 -47
@@ -1,112 +0,0 @@
1
- import { type AppendParam, type AppendValue, isAppendValue, SourceBuilder, writeGeneratedFile } from '@goast/core';
2
-
3
- import { KtNode } from './ast/node.js';
4
- import { defaultKotlinGeneratorConfig, type KotlinGeneratorConfig } from './config.js';
5
- import { ImportCollection } from './import-collection.js';
6
-
7
- type AnnotationArgumentValue<T extends SourceBuilder> = string | ((builder: T) => void);
8
- type AnnotationArgument<T extends SourceBuilder> =
9
- | AnnotationArgumentValue<T>
10
- | [key: string, value: AnnotationArgumentValue<T>]
11
- | [value: AnnotationArgumentValue<T>, condition: boolean]
12
- | [key: string, value: AnnotationArgumentValue<T>, condition: boolean];
13
-
14
- export type KotlinAppends<TAdditionalAppends> = KtNode<KotlinFileBuilder> | TAdditionalAppends;
15
- export type KotlinAppendParam<TBuilder extends KotlinFileBuilder, TAdditionalAppends> = AppendParam<
16
- TBuilder,
17
- KotlinAppends<TAdditionalAppends>
18
- >;
19
-
20
- export function isKotlinAppendValue<TBuilder extends KotlinFileBuilder>(
21
- value: unknown,
22
- ): value is AppendValue<TBuilder> {
23
- return isAppendValue(value) || value instanceof KtNode;
24
- }
25
-
26
- export class KotlinFileBuilder<TAdditionalAppends = never> extends SourceBuilder<KotlinAppends<TAdditionalAppends>> {
27
- public readonly packageName: string | undefined;
28
- public readonly imports: ImportCollection = new ImportCollection();
29
-
30
- public override get options(): KotlinGeneratorConfig {
31
- return super.options as KotlinGeneratorConfig;
32
- }
33
-
34
- constructor(packageName?: string, options?: KotlinGeneratorConfig) {
35
- super(options ?? defaultKotlinGeneratorConfig);
36
- this.packageName = packageName;
37
- }
38
-
39
- public addImport(name: string, packageName?: string): this {
40
- if (packageName !== undefined && packageName !== this.packageName) {
41
- this.imports.addImport(name, packageName);
42
- }
43
- return this;
44
- }
45
-
46
- public appendAnnotation(name: string, packageName?: string, args?: AnnotationArgument<this>[]): this {
47
- const allArgs: [key: string | undefined, value: AnnotationArgumentValue<this>][] = [];
48
- if (args) {
49
- for (const a of args) {
50
- if (!Array.isArray(a)) {
51
- allArgs.push([undefined, a]);
52
- } else if (a.length === 2 && a[1] === true) {
53
- allArgs.push([undefined, a[0]]);
54
- }
55
- }
56
- for (const a of args) {
57
- if (Array.isArray(a) && typeof a[1] !== 'boolean' && a[2] !== false) {
58
- allArgs.push(a.length === 2 ? a : [a[0], a[1]]);
59
- }
60
- }
61
- }
62
-
63
- this.append(`@${name}`).addImport(name, packageName);
64
-
65
- if (allArgs.length > 0) {
66
- const multiline = allArgs.some((x) => typeof x[1] !== 'string') ||
67
- allArgs.reduce((c, [key, value]) => c + (key ? key.length + 3 : 0) + (value?.length ?? 0), 0) > 80;
68
- this.parenthesize('()', (builder) =>
69
- builder
70
- .appendLineIf(multiline)
71
- .forEach(
72
- allArgs,
73
- (builder, [name, value]) =>
74
- builder
75
- .append(name ? `${name} = ` : '')
76
- .append((builder) => (typeof value === 'string' ? builder.append(value) : value(builder))),
77
- { separator: multiline ? ',\n' : ', ' },
78
- )
79
- .appendLineIf(multiline));
80
- }
81
-
82
- this.appendLine();
83
-
84
- return this;
85
- }
86
-
87
- public override clear(): void {
88
- super.clear();
89
- this.imports.clear();
90
- }
91
-
92
- public override toString(addPadding: boolean = true): string {
93
- return new SourceBuilder(this.options)
94
- .if(this.packageName !== undefined, (builder) => builder.appendLine(`package ${this.packageName}`).appendLine())
95
- .append((builder) => this.imports.writeTo(builder))
96
- .if(addPadding, (builder) => builder.ensurePreviousLineEmpty())
97
- .append(super.toString())
98
- .if(addPadding, (builder) => builder.ensureCurrentLineEmpty())
99
- .toString();
100
- }
101
-
102
- public writeToFile(filePath: string) {
103
- writeGeneratedFile(this.options, filePath, this.toString());
104
- }
105
-
106
- protected override appendSingle(value: KotlinAppendParam<this, TAdditionalAppends>): void {
107
- super.appendSingle(value);
108
- if (value instanceof KtNode) {
109
- value.write(this);
110
- }
111
- }
112
- }
@@ -1,29 +0,0 @@
1
- import {
2
- type MaybePromise,
3
- type Nullable,
4
- type OpenApiGenerationProviderContext,
5
- type OpenApiGeneratorInput,
6
- toCasing,
7
- } from '@goast/core';
8
-
9
- import type { KotlinGeneratorConfig } from '../config.js';
10
- import { toKotlinPropertyName, toKotlinStringLiteral } from '../utils.js';
11
-
12
- export abstract class KotlinFileGenerator<
13
- TContext extends OpenApiGenerationProviderContext<OpenApiGeneratorInput, KotlinGeneratorConfig>,
14
- TOutput,
15
- > {
16
- public abstract generate(context: TContext): MaybePromise<TOutput>;
17
-
18
- protected toPropertyName(context: TContext, name: string): string {
19
- return toKotlinPropertyName(toCasing(name, context.config.propertyNameCasing));
20
- }
21
-
22
- protected toEnumValueName(context: TContext, name: string): string {
23
- return toKotlinPropertyName(toCasing(name, context.config.enumValueNameCasing));
24
- }
25
-
26
- protected toStringLiteral(_context: TContext, text: Nullable<string>): string {
27
- return toKotlinStringLiteral(text);
28
- }
29
- }
@@ -1,5 +0,0 @@
1
- export * from './file-generator.js';
2
- export * from './models/index.js';
3
- export * from './services/okhttp3-clients/index.js';
4
- export * from './services/spring-controllers/index.js';
5
- export * from './services/spring-reactive-web-clients/index.js';
@@ -1,136 +0,0 @@
1
- import type { ApiSchema, ApiSchemaProperty } from '@goast/core';
2
-
3
- export type GetFileContent = object;
4
-
5
- export type GetSchemaDeclaration = {
6
- schema: ApiSchema;
7
- };
8
-
9
- export type GetClass = {
10
- schema: ApiSchema<'object'>;
11
- };
12
-
13
- export type GetInterface = {
14
- schema: ApiSchema<'object'>;
15
- };
16
-
17
- export type GetEnum = {
18
- schema: ApiSchema;
19
- };
20
-
21
- export type GetSchemaDocDescription = {
22
- schema: ApiSchema;
23
- };
24
-
25
- export type GetType = {
26
- schema: ApiSchema;
27
- nullable?: boolean;
28
- };
29
-
30
- export type GetGeneratedType = {
31
- schema: ApiSchema;
32
- nullable?: boolean;
33
- };
34
-
35
- export type GetAdditionalPropertiesType = {
36
- schema: ApiSchema<'object'>;
37
- };
38
-
39
- export type GetDefaultValue = {
40
- schema: ApiSchema;
41
- };
42
-
43
- export type GetClassParameter = {
44
- schema: ApiSchema<'object'>;
45
- inheritedSchemas: ApiSchema[];
46
- parameters: ApiSchemaProperty[];
47
- property: ApiSchemaProperty;
48
- };
49
-
50
- export type GetInterfaceProperty = {
51
- schema: ApiSchema<'object'>;
52
- property: ApiSchemaProperty;
53
- };
54
-
55
- export type GetAdditionalPropertiesProperty = {
56
- schema: ApiSchema<'object'>;
57
- };
58
-
59
- export type GetAdditionalPropertiesSetter = {
60
- schema: ApiSchema<'object'>;
61
- };
62
-
63
- export type GetAdditionalPropertiesGetter = {
64
- schema: ApiSchema<'object'>;
65
- };
66
-
67
- export type GetJacksonJsonTypeInfoAnnotation = {
68
- schema: ApiSchema;
69
- };
70
-
71
- export type GetJacksonJsonSubTypesAnnotation = {
72
- schema: ApiSchema;
73
- };
74
-
75
- export type GetJacksonJsonClassDescriptionAnnotation = {
76
- schema: ApiSchema;
77
- };
78
-
79
- export type GetJacksonJsonPropertyAnnotation = {
80
- schema: ApiSchema;
81
- property: ApiSchemaProperty;
82
- };
83
-
84
- export type GetJacksonJsonPropertyDescriptionAnnotation = {
85
- schema: ApiSchema;
86
- property: ApiSchemaProperty;
87
- };
88
-
89
- export type GetJacksonJsonIncludeAnnotation = {
90
- schema: ApiSchema;
91
- property: ApiSchemaProperty;
92
- };
93
-
94
- export type GetJakartaValidationAnnotations = {
95
- schema: ApiSchema;
96
- property: ApiSchemaProperty;
97
- };
98
-
99
- export type GetSwaggerSchemaAnnotation = {
100
- schema: ApiSchema;
101
- property: ApiSchemaProperty;
102
- };
103
-
104
- export type GetPackageName = {
105
- schema: ApiSchema;
106
- };
107
-
108
- export type ShouldGenerateTypeDeclaration = {
109
- schema: ApiSchema;
110
- };
111
-
112
- export type GetDeclarationTypeName = {
113
- schema: ApiSchema;
114
- };
115
-
116
- export type GetInheritedSchemas = {
117
- schema: ApiSchema;
118
- };
119
-
120
- export type GetClassProperties = {
121
- schema: ApiSchema<'object'>;
122
- };
123
-
124
- export type SortProperties = {
125
- schema: ApiSchema;
126
- properties: Iterable<ApiSchemaProperty>;
127
- };
128
-
129
- export type NormalizeSchema = {
130
- schema: ApiSchema;
131
- };
132
-
133
- export type HasProperty = {
134
- schema: ApiSchema;
135
- propertyName: string;
136
- };
@@ -1,4 +0,0 @@
1
- export * as DefaultKotlinModelGeneratorArgs from './args.js';
2
- export * from './model-generator.js';
3
- export * from './models-generator.js';
4
- export * from './models.js';