@goast/kotlin 0.2.5 → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jvmStatic = exports.mutableMapOf = exports.mapOf = exports.mutableListOf = exports.listOf = exports.mutableMap = exports.map = exports.mutableList = exports.list = exports.throws = exports.lazyFun = exports.boolean = exports.double = exports.float = exports.long = exports.int = exports.string = exports.unit = exports.nothing = exports.any = void 0;
3
+ exports.jvmStatic = exports.mutableMapOf = exports.mapOf = exports.mutableListOf = exports.listOf = exports.mutableMap = exports.map = exports.mutableList = exports.list = exports.deprecated = exports.throws = exports.lazyFun = exports.boolean = exports.double = exports.float = exports.long = exports.int = exports.string = exports.unit = exports.nothing = exports.any = void 0;
4
4
  const reference_1 = require("../nodes/reference");
5
5
  // kotlin
6
6
  exports.any = reference_1.ktReference.factory('Any', 'kotlin');
@@ -14,6 +14,7 @@ exports.double = reference_1.ktReference.factory('Double', 'kotlin');
14
14
  exports.boolean = reference_1.ktReference.factory('Boolean', 'kotlin');
15
15
  exports.lazyFun = reference_1.ktReference.genericFactory('lazy', 'kotlin');
16
16
  exports.throws = reference_1.ktReference.factory('Throws', 'kotlin');
17
+ exports.deprecated = reference_1.ktReference.factory('Deprecated', 'kotlin');
17
18
  // kotlin.collections
18
19
  exports.list = reference_1.ktReference.genericFactory('List', 'kotlin.collections');
19
20
  exports.mutableList = reference_1.ktReference.genericFactory('MutableList', 'kotlin.collections');
@@ -65,6 +65,7 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
65
65
  const parameters = this.getClassProperties(ctx, { schema });
66
66
  return ast_1.kt.class(this.getDeclarationTypeName(ctx, { schema }), {
67
67
  doc: ast_1.kt.doc((_a = schema.description) === null || _a === void 0 ? void 0 : _a.trim()),
68
+ annotations: [schema.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null],
68
69
  classKind: parameters.length === 0 ? null : 'data',
69
70
  implements: inheritedSchemas.map((schema) => this.getType(ctx, { schema })),
70
71
  primaryConstructor: ast_1.kt.constructor(parameters.map((property) => this.getClassParameter(ctx, Object.assign(Object.assign({}, args), { inheritedSchemas, parameters, property })))),
@@ -87,6 +88,7 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
87
88
  annotations: [
88
89
  this.getJacksonJsonTypeInfoAnnotation(ctx, { schema }),
89
90
  this.getJacksonJsonSubTypesAnnotation(ctx, { schema }),
91
+ schema.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null,
90
92
  ].filter(core_1.notNullish),
91
93
  members: this.sortProperties(ctx, { schema, properties: schema.properties.values() }).map((property) => this.getInterfaceProperty(ctx, { schema, property })),
92
94
  });
@@ -99,6 +101,7 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
99
101
  arguments: [ast_1.kt.argument(ast_1.kt.string(String(x)))],
100
102
  }))) !== null && _b !== void 0 ? _b : [], {
101
103
  doc: ast_1.kt.doc((_c = schema.description) === null || _c === void 0 ? void 0 : _c.trim()),
104
+ annotations: [schema.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null],
102
105
  primaryConstructor: ast_1.kt.constructor([
103
106
  ast_1.kt.parameter.class((0, core_1.toCasing)('value', ctx.config.propertyNameCasing), ast_1.kt.refs.string(), {
104
107
  property: 'readonly',
@@ -201,6 +204,7 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
201
204
  this.getSwaggerSchemaAnnotation(ctx, { schema, property }),
202
205
  this.getJacksonJsonPropertyAnnotation(ctx, { schema, property }),
203
206
  (0, core_1.modify)(this.getJacksonJsonIncludeAnnotation(ctx, { schema, property }), (x) => (x.target = 'get')),
207
+ property.schema.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null,
204
208
  ].filter(core_1.notNullish),
205
209
  override: inheritedSchemas.some((schema) => this.hasProperty(ctx, { schema, propertyName: property.name })),
206
210
  property: 'readonly',
@@ -217,6 +221,7 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
217
221
  annotations: (0, core_1.modifyEach)([
218
222
  this.getJacksonJsonPropertyAnnotation(ctx, { schema, property }),
219
223
  this.getJacksonJsonIncludeAnnotation(ctx, { schema, property }),
224
+ property.schema.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null,
220
225
  ].filter(core_1.notNullish), (x) => (x.target = 'get')),
221
226
  type: this.getType(ctx, {
222
227
  schema: property.schema,
@@ -321,6 +326,9 @@ class DefaultKotlinModelGenerator extends file_generator_1.KotlinFileGenerator {
321
326
  property.schema.description !== undefined
322
327
  ? ast_1.kt.argument.named('description', ast_1.kt.string(property.schema.description))
323
328
  : null,
329
+ property.schema.deprecated !== undefined
330
+ ? ast_1.kt.argument.named('deprecated', ast_1.kt.toNode(property.schema.deprecated))
331
+ : null,
324
332
  ])
325
333
  : null;
326
334
  }
@@ -27,6 +27,11 @@ class DefaultKotlinOkHttp3Generator extends file_generator_1.KotlinFileGenerator
27
27
  }
28
28
  getClientClass(ctx, args) {
29
29
  return ast_1.kt.class(this.getApiClientName(ctx, {}), {
30
+ annotations: [
31
+ ctx.service.endpoints.length === 0 || ctx.service.endpoints.some((x) => !x.deprecated)
32
+ ? null
33
+ : ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]),
34
+ ],
30
35
  extends: ctx.refs.apiClient(),
31
36
  primaryConstructor: ast_1.kt.constructor([
32
37
  ast_1.kt.parameter('basePath', ast_1.kt.refs.string(), { default: 'defaultBasePath' }),
@@ -81,6 +86,7 @@ class DefaultKotlinOkHttp3Generator extends file_generator_1.KotlinFileGenerator
81
86
  ctx.refs.clientException({ classReference: true }),
82
87
  ctx.refs.serverException({ classReference: true }),
83
88
  ]),
89
+ endpoint.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null,
84
90
  ],
85
91
  parameters: parameters.map((p) => {
86
92
  var _a;
@@ -138,6 +144,7 @@ class DefaultKotlinOkHttp3Generator extends file_generator_1.KotlinFileGenerator
138
144
  ast_1.kt.refs.java.illegalStateException({ classReference: true }),
139
145
  ast_1.kt.refs.java.ioException({ classReference: true }),
140
146
  ]),
147
+ endpoint.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null,
141
148
  ],
142
149
  parameters: parameters.map((p) => {
143
150
  var _a;
@@ -175,6 +182,7 @@ class DefaultKotlinOkHttp3Generator extends file_generator_1.KotlinFileGenerator
175
182
  return ast_1.kt.function((0, core_1.toCasing)(args.endpoint.name, ctx.config.functionNameCasing) + 'RequestConfig', {
176
183
  accessModifier: 'private',
177
184
  doc: ast_1.kt.doc(`To obtain the request config of the operation ${operationName}`),
185
+ annotations: [endpoint.deprecated ? ast_1.kt.annotation(ast_1.kt.refs.deprecated(), [ast_1.kt.argument(ast_1.kt.string(''))]) : null],
178
186
  parameters: parameters.map((p) => {
179
187
  var _a;
180
188
  return ast_1.kt.parameter((0, core_1.toCasing)(p.name, ctx.config.parameterNameCasing), this.getTypeUsage(ctx, { schema: p.schema, nullable: !p.required }), {
@@ -86,9 +86,10 @@ class DefaultKotlinSpringControllerGenerator extends file_generator_1.KotlinFile
86
86
  var _a, _b;
87
87
  return ast_1.kt.call(ast_1.kt.refs.swagger.apiResponse(), [
88
88
  ast_1.kt.argument.named('responseCode', ast_1.kt.string((_a = response.statusCode) === null || _a === void 0 ? void 0 : _a.toString())),
89
- endpoint.description ? ast_1.kt.argument.named('description', ast_1.kt.string((_b = response.description) === null || _b === void 0 ? void 0 : _b.trim())) : null,
89
+ response.description ? ast_1.kt.argument.named('description', ast_1.kt.string((_b = response.description) === null || _b === void 0 ? void 0 : _b.trim())) : null,
90
90
  ]);
91
91
  }))),
92
+ endpoint.deprecated !== undefined ? ast_1.kt.argument.named('deprecated', ast_1.kt.toNode(endpoint.deprecated)) : null,
92
93
  ]);
93
94
  const requestMapping = ast_1.kt.annotation(ast_1.kt.refs.spring.requestMapping(), [
94
95
  ast_1.kt.argument.named('method', ast_1.kt.collectionLiteral([ast_1.kt.call([ast_1.kt.refs.spring.requestMethod(), endpoint.method.toUpperCase()])])),
@@ -11,6 +11,7 @@ export const double = ktReference.factory('Double', 'kotlin');
11
11
  export const boolean = ktReference.factory('Boolean', 'kotlin');
12
12
  export const lazyFun = ktReference.genericFactory('lazy', 'kotlin');
13
13
  export const throws = ktReference.factory('Throws', 'kotlin');
14
+ export const deprecated = ktReference.factory('Deprecated', 'kotlin');
14
15
  // kotlin.collections
15
16
  export const list = ktReference.genericFactory('List', 'kotlin.collections');
16
17
  export const mutableList = ktReference.genericFactory('MutableList', 'kotlin.collections');
@@ -62,6 +62,7 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
62
62
  const parameters = this.getClassProperties(ctx, { schema });
63
63
  return kt.class(this.getDeclarationTypeName(ctx, { schema }), {
64
64
  doc: kt.doc((_a = schema.description) === null || _a === void 0 ? void 0 : _a.trim()),
65
+ annotations: [schema.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null],
65
66
  classKind: parameters.length === 0 ? null : 'data',
66
67
  implements: inheritedSchemas.map((schema) => this.getType(ctx, { schema })),
67
68
  primaryConstructor: kt.constructor(parameters.map((property) => this.getClassParameter(ctx, Object.assign(Object.assign({}, args), { inheritedSchemas, parameters, property })))),
@@ -84,6 +85,7 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
84
85
  annotations: [
85
86
  this.getJacksonJsonTypeInfoAnnotation(ctx, { schema }),
86
87
  this.getJacksonJsonSubTypesAnnotation(ctx, { schema }),
88
+ schema.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null,
87
89
  ].filter(notNullish),
88
90
  members: this.sortProperties(ctx, { schema, properties: schema.properties.values() }).map((property) => this.getInterfaceProperty(ctx, { schema, property })),
89
91
  });
@@ -96,6 +98,7 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
96
98
  arguments: [kt.argument(kt.string(String(x)))],
97
99
  }))) !== null && _b !== void 0 ? _b : [], {
98
100
  doc: kt.doc((_c = schema.description) === null || _c === void 0 ? void 0 : _c.trim()),
101
+ annotations: [schema.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null],
99
102
  primaryConstructor: kt.constructor([
100
103
  kt.parameter.class(toCasing('value', ctx.config.propertyNameCasing), kt.refs.string(), {
101
104
  property: 'readonly',
@@ -198,6 +201,7 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
198
201
  this.getSwaggerSchemaAnnotation(ctx, { schema, property }),
199
202
  this.getJacksonJsonPropertyAnnotation(ctx, { schema, property }),
200
203
  modify(this.getJacksonJsonIncludeAnnotation(ctx, { schema, property }), (x) => (x.target = 'get')),
204
+ property.schema.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null,
201
205
  ].filter(notNullish),
202
206
  override: inheritedSchemas.some((schema) => this.hasProperty(ctx, { schema, propertyName: property.name })),
203
207
  property: 'readonly',
@@ -214,6 +218,7 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
214
218
  annotations: modifyEach([
215
219
  this.getJacksonJsonPropertyAnnotation(ctx, { schema, property }),
216
220
  this.getJacksonJsonIncludeAnnotation(ctx, { schema, property }),
221
+ property.schema.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null,
217
222
  ].filter(notNullish), (x) => (x.target = 'get')),
218
223
  type: this.getType(ctx, {
219
224
  schema: property.schema,
@@ -318,6 +323,9 @@ export class DefaultKotlinModelGenerator extends KotlinFileGenerator {
318
323
  property.schema.description !== undefined
319
324
  ? kt.argument.named('description', kt.string(property.schema.description))
320
325
  : null,
326
+ property.schema.deprecated !== undefined
327
+ ? kt.argument.named('deprecated', kt.toNode(property.schema.deprecated))
328
+ : null,
321
329
  ])
322
330
  : null;
323
331
  }
@@ -24,6 +24,11 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
24
24
  }
25
25
  getClientClass(ctx, args) {
26
26
  return kt.class(this.getApiClientName(ctx, {}), {
27
+ annotations: [
28
+ ctx.service.endpoints.length === 0 || ctx.service.endpoints.some((x) => !x.deprecated)
29
+ ? null
30
+ : kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]),
31
+ ],
27
32
  extends: ctx.refs.apiClient(),
28
33
  primaryConstructor: kt.constructor([
29
34
  kt.parameter('basePath', kt.refs.string(), { default: 'defaultBasePath' }),
@@ -78,6 +83,7 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
78
83
  ctx.refs.clientException({ classReference: true }),
79
84
  ctx.refs.serverException({ classReference: true }),
80
85
  ]),
86
+ endpoint.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null,
81
87
  ],
82
88
  parameters: parameters.map((p) => {
83
89
  var _a;
@@ -135,6 +141,7 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
135
141
  kt.refs.java.illegalStateException({ classReference: true }),
136
142
  kt.refs.java.ioException({ classReference: true }),
137
143
  ]),
144
+ endpoint.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null,
138
145
  ],
139
146
  parameters: parameters.map((p) => {
140
147
  var _a;
@@ -172,6 +179,7 @@ export class DefaultKotlinOkHttp3Generator extends KotlinFileGenerator {
172
179
  return kt.function(toCasing(args.endpoint.name, ctx.config.functionNameCasing) + 'RequestConfig', {
173
180
  accessModifier: 'private',
174
181
  doc: kt.doc(`To obtain the request config of the operation ${operationName}`),
182
+ annotations: [endpoint.deprecated ? kt.annotation(kt.refs.deprecated(), [kt.argument(kt.string(''))]) : null],
175
183
  parameters: parameters.map((p) => {
176
184
  var _a;
177
185
  return kt.parameter(toCasing(p.name, ctx.config.parameterNameCasing), this.getTypeUsage(ctx, { schema: p.schema, nullable: !p.required }), {
@@ -83,9 +83,10 @@ export class DefaultKotlinSpringControllerGenerator extends KotlinFileGenerator
83
83
  var _a, _b;
84
84
  return kt.call(kt.refs.swagger.apiResponse(), [
85
85
  kt.argument.named('responseCode', kt.string((_a = response.statusCode) === null || _a === void 0 ? void 0 : _a.toString())),
86
- endpoint.description ? kt.argument.named('description', kt.string((_b = response.description) === null || _b === void 0 ? void 0 : _b.trim())) : null,
86
+ response.description ? kt.argument.named('description', kt.string((_b = response.description) === null || _b === void 0 ? void 0 : _b.trim())) : null,
87
87
  ]);
88
88
  }))),
89
+ endpoint.deprecated !== undefined ? kt.argument.named('deprecated', kt.toNode(endpoint.deprecated)) : null,
89
90
  ]);
90
91
  const requestMapping = kt.annotation(kt.refs.spring.requestMapping(), [
91
92
  kt.argument.named('method', kt.collectionLiteral([kt.call([kt.refs.spring.requestMethod(), endpoint.method.toUpperCase()])])),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/kotlin",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "repository": "https://github.com/MaSch0212/goast.git",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",
@@ -124,6 +124,17 @@ export declare const throws: (<TBuilder extends import("@goast/core").SourceBuil
124
124
  packageName: import("@goast/core").Nullable<string>;
125
125
  matches: (value: unknown) => value is import("../nodes/reference").KtReference<never, never>;
126
126
  };
127
+ export declare const deprecated: (<TBuilder extends import("@goast/core").SourceBuilder<never>>(options?: {
128
+ nullable?: import("@goast/core").Nullable<boolean>;
129
+ inject?: import("@goast/core").AstNodeInject<TBuilder, ""> | undefined;
130
+ generics?: import("@goast/core").Nullable<import("@goast/core").Nullable<import("../_index").Type<TBuilder>>[]>;
131
+ classReference?: import("@goast/core").Nullable<boolean>;
132
+ subReference?: import("@goast/core").Nullable<import("../nodes/reference").KtReference<TBuilder, never> | import("../_index").Call<TBuilder, never>>;
133
+ } | undefined) => import("../nodes/reference").KtReference<TBuilder, never>) & {
134
+ refName: string;
135
+ packageName: import("@goast/core").Nullable<string>;
136
+ matches: (value: unknown) => value is import("../nodes/reference").KtReference<never, never>;
137
+ };
127
138
  export declare const list: (<TBuilder extends import("@goast/core").SourceBuilder<never>>(generics: [import("../_index").Type<TBuilder>], options?: {
128
139
  nullable?: import("@goast/core").Nullable<boolean>;
129
140
  inject?: import("@goast/core").AstNodeInject<TBuilder, ""> | undefined;