@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,98 +0,0 @@
1
- import { type SourceBuilderOptions, StringBuilder } from '@goast/core';
2
-
3
- import type { KotlinImport } from './common-results.js';
4
- import { defaultKotlinGeneratorConfig } from './config.js';
5
-
6
- export type ImportCollectionOptions = {
7
- globalImports: string[];
8
- };
9
-
10
- export const defaultImportCollectionOptions: ImportCollectionOptions = {
11
- globalImports: defaultKotlinGeneratorConfig.globalImports,
12
- };
13
-
14
- export class ImportCollection {
15
- private readonly _imports: Map<string, Set<string>> = new Map();
16
- private readonly _options: ImportCollectionOptions;
17
-
18
- constructor(options: Partial<ImportCollectionOptions> = {}) {
19
- this._options = { ...defaultImportCollectionOptions, ...options };
20
- }
21
-
22
- public get hasImports(): boolean {
23
- return this._imports.size > 0;
24
- }
25
-
26
- public get imports(): KotlinImport[] {
27
- return Array.from(this._imports.entries())
28
- .map(([fromPackage, importNames]) =>
29
- Array.from(importNames).map((importName) => ({
30
- packageName: fromPackage,
31
- typeName: importName,
32
- }))
33
- )
34
- .flat();
35
- }
36
-
37
- public addImport(importName: string, fromModule: string): void;
38
- public addImport(importObj: KotlinImport): void;
39
- public addImport(importOrImportName: KotlinImport | string, fromModule?: string): void {
40
- const importName = typeof importOrImportName === 'string' ? importOrImportName : importOrImportName.typeName;
41
- fromModule = typeof importOrImportName === 'string' ? fromModule : importOrImportName.packageName;
42
-
43
- if (!fromModule) {
44
- return;
45
- }
46
-
47
- const existingImport = this._imports.get(fromModule);
48
- if (existingImport) {
49
- existingImport.add(importName);
50
- } else {
51
- this._imports.set(fromModule!, new Set([importName]));
52
- }
53
- }
54
-
55
- public addImports(imports: KotlinImport[]): void {
56
- for (const importObj of imports) {
57
- this.addImport(importObj);
58
- }
59
- }
60
-
61
- public clear(): void {
62
- this._imports.clear();
63
- }
64
-
65
- public toString(options?: Partial<SourceBuilderOptions>): string {
66
- const builder = new StringBuilder(options);
67
- this.writeTo(builder);
68
- return builder.toString();
69
- }
70
-
71
- public writeTo(builder: StringBuilder) {
72
- if (this._imports.size > 0) {
73
- const globalPackages = this._options.globalImports
74
- .filter((g) => g.endsWith('.*'))
75
- .map((g) => g.substring(0, g.length - 2));
76
- const globalImports = this._options.globalImports.filter((g) => !g.endsWith('.*'));
77
-
78
- Array.from(this._imports.entries())
79
- .filter(([packageName]) => !globalPackages.includes(packageName))
80
- .flatMap(([packageName, importNames]) => Array.from(importNames).map((importName) => [packageName, importName]))
81
- .map(([packageName, importName]) => `${packageName}.${importName}`)
82
- .filter((importPath) => !globalImports.includes(importPath))
83
- .sort((a, b) => {
84
- if (isCoreImport(a) && !isCoreImport(b)) {
85
- return 1;
86
- } else if (!isCoreImport(a) && isCoreImport(b)) {
87
- return -1;
88
- }
89
- return a.localeCompare(b);
90
- })
91
- .forEach((importPath) => builder.appendLine(`import ${importPath}`));
92
- }
93
- }
94
- }
95
-
96
- function isCoreImport(importPath: string): boolean {
97
- return importPath.startsWith('kotlin.') || importPath.startsWith('java.') || importPath.startsWith('javax.');
98
- }
package/src/src/types.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { ApiParameter } from '@goast/core';
2
-
3
- export type ApiParameterWithMultipartInfo = ApiParameter & { multipart?: { name: string; isFile: boolean } };
package/src/src/utils.ts DELETED
@@ -1,39 +0,0 @@
1
- import type { Nullable } from '@goast/core';
2
-
3
- export function toKotlinStringLiteral(value: Nullable<string>): string {
4
- if (!value) {
5
- return '""';
6
- }
7
-
8
- const escaped = value
9
- .replace(/(["\\$])/g, '\\$1')
10
- .replace(/\n/g, '\\n')
11
- .replace(/\r/g, '\\r')
12
- .replace(/\t/g, '\\t');
13
- return `"${escaped}"`;
14
- }
15
-
16
- export function toKotlinPropertyName(value: string): string {
17
- if (value.match(/^[a-zA-Z_$][a-zA-Z_$0-9]*$/)) {
18
- return value;
19
- }
20
- return `\`${value}\``;
21
- }
22
-
23
- export function modifyString<TArgs extends unknown[]>(
24
- value: string,
25
- modifier: string | RegExp | ((value: string, ...args: TArgs) => string) | undefined,
26
- ...args: TArgs
27
- ): string {
28
- if (typeof modifier === 'string') {
29
- return modifier;
30
- }
31
- if (modifier instanceof RegExp) {
32
- const match = value.match(modifier);
33
- return match?.[0] ?? value;
34
- }
35
- if (typeof modifier === 'function') {
36
- return modifier(value, ...args);
37
- }
38
- return value;
39
- }