@goast/typescript 0.7.6 → 0.8.0-beta.2
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.
- package/esm/src/generators/models/model-generator.d.ts +22 -0
- package/esm/src/generators/models/model-generator.d.ts.map +1 -1
- package/esm/src/generators/models/model-generator.js +37 -5
- package/esm/src/generators/services/angular-services/angular-services-generator.js +2 -2
- package/esm/src/generators/services/k6-clients/k6-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/k6-clients/k6-client-generator.js +12 -2
- package/esm/src/import-collection.d.ts.map +1 -1
- package/esm/src/import-collection.js +2 -2
- package/package.json +2 -2
- package/script/src/generators/models/model-generator.d.ts +22 -0
- package/script/src/generators/models/model-generator.d.ts.map +1 -1
- package/script/src/generators/models/model-generator.js +37 -5
- package/script/src/generators/services/angular-services/angular-services-generator.js +2 -2
- package/script/src/generators/services/k6-clients/k6-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/k6-clients/k6-client-generator.js +12 -2
- package/script/src/import-collection.d.ts.map +1 -1
- package/script/src/import-collection.js +1 -1
- package/src/mod.ts +0 -7
- package/src/src/assets.ts +0 -9
- package/src/src/ast/_index.ts +0 -54
- package/src/src/ast/common.ts +0 -1
- package/src/src/ast/index.ts +0 -1
- package/src/src/ast/node.ts +0 -10
- package/src/src/ast/nodes/argument.ts +0 -40
- package/src/src/ast/nodes/array-type.ts +0 -49
- package/src/src/ast/nodes/arrow-function.ts +0 -91
- package/src/src/ast/nodes/call.ts +0 -55
- package/src/src/ast/nodes/class.ts +0 -133
- package/src/src/ast/nodes/constructor-parameter.ts +0 -70
- package/src/src/ast/nodes/constructor.ts +0 -77
- package/src/src/ast/nodes/decorator.ts +0 -76
- package/src/src/ast/nodes/doc-tag.ts +0 -291
- package/src/src/ast/nodes/doc.ts +0 -102
- package/src/src/ast/nodes/enum-value.ts +0 -72
- package/src/src/ast/nodes/enum.ts +0 -77
- package/src/src/ast/nodes/export.ts +0 -54
- package/src/src/ast/nodes/function-type.ts +0 -60
- package/src/src/ast/nodes/function.ts +0 -107
- package/src/src/ast/nodes/generic-parameter.ts +0 -71
- package/src/src/ast/nodes/indexer.ts +0 -60
- package/src/src/ast/nodes/interface.ts +0 -117
- package/src/src/ast/nodes/intersection-type.ts +0 -67
- package/src/src/ast/nodes/lookup-type.ts +0 -53
- package/src/src/ast/nodes/method.ts +0 -138
- package/src/src/ast/nodes/object-type.ts +0 -52
- package/src/src/ast/nodes/object.ts +0 -48
- package/src/src/ast/nodes/parameter.ts +0 -85
- package/src/src/ast/nodes/property-accessor.ts +0 -173
- package/src/src/ast/nodes/property.ts +0 -192
- package/src/src/ast/nodes/reference.ts +0 -194
- package/src/src/ast/nodes/string.ts +0 -49
- package/src/src/ast/nodes/tuple.ts +0 -53
- package/src/src/ast/nodes/type-alias.ts +0 -75
- package/src/src/ast/nodes/typeof.ts +0 -42
- package/src/src/ast/nodes/types.ts +0 -40
- package/src/src/ast/nodes/union-type.ts +0 -62
- package/src/src/ast/nodes/variable.ts +0 -73
- package/src/src/ast/references/angular.ts +0 -24
- package/src/src/ast/references/easy-network-stub.ts +0 -21
- package/src/src/ast/references/index.ts +0 -5
- package/src/src/ast/references/k6.ts +0 -8
- package/src/src/ast/references/rxjs.ts +0 -7
- package/src/src/ast/references/typescript.ts +0 -35
- package/src/src/ast/utils/get-type-script-builder-options.ts +0 -19
- package/src/src/ast/utils/to-ts-node.ts +0 -27
- package/src/src/ast/utils/write-ts-generic-parameters.ts +0 -25
- package/src/src/ast/utils/write-ts-members.ts +0 -28
- package/src/src/ast/utils/write-ts-nodes.ts +0 -35
- package/src/src/ast/utils/write-ts-parameters.ts +0 -25
- package/src/src/common-results.ts +0 -26
- package/src/src/config.ts +0 -96
- package/src/src/file-builder.ts +0 -137
- package/src/src/generators/file-generator.ts +0 -15
- package/src/src/generators/index.ts +0 -6
- package/src/src/generators/models/index.ts +0 -3
- package/src/src/generators/models/model-generator.ts +0 -493
- package/src/src/generators/models/models-generator.ts +0 -108
- package/src/src/generators/models/models.ts +0 -121
- package/src/src/generators/services/angular-services/angular-service-generator.ts +0 -431
- package/src/src/generators/services/angular-services/angular-services-generator.ts +0 -295
- package/src/src/generators/services/angular-services/index.ts +0 -3
- package/src/src/generators/services/angular-services/models.ts +0 -277
- package/src/src/generators/services/angular-services/refs.ts +0 -54
- package/src/src/generators/services/easy-network-stub/easy-network-stub-generator.ts +0 -250
- package/src/src/generators/services/easy-network-stub/easy-network-stubs-generator.ts +0 -211
- package/src/src/generators/services/easy-network-stub/index.ts +0 -3
- package/src/src/generators/services/easy-network-stub/models.ts +0 -124
- package/src/src/generators/services/easy-network-stub/refs.ts +0 -47
- package/src/src/generators/services/fetch-clients/fetch-client-generator.ts +0 -305
- package/src/src/generators/services/fetch-clients/fetch-clients-generator.ts +0 -163
- package/src/src/generators/services/fetch-clients/index.ts +0 -3
- package/src/src/generators/services/fetch-clients/models.ts +0 -130
- package/src/src/generators/services/fetch-clients/refs.ts +0 -21
- package/src/src/generators/services/k6-clients/index.ts +0 -3
- package/src/src/generators/services/k6-clients/k6-client-generator.ts +0 -505
- package/src/src/generators/services/k6-clients/k6-clients-generator.ts +0 -171
- package/src/src/generators/services/k6-clients/models.ts +0 -247
- package/src/src/generators/services/k6-clients/refs.ts +0 -16
- package/src/src/import-collection.ts +0 -236
- package/src/src/utils.ts +0 -79
|
@@ -20,6 +20,28 @@ export declare class DefaultTypeScriptModelGenerator extends TypeScriptFileGener
|
|
|
20
20
|
protected getEnumValuesVariable(ctx: Context, schema: ApiSchema): ts.Variable<Builder>;
|
|
21
21
|
protected getIndexer(ctx: Context, schema: ObjectLikeApiSchema): ts.Indexer<Builder> | null;
|
|
22
22
|
protected getProperties(ctx: Context, schema: ObjectLikeApiSchema): ts.Property<Builder>[];
|
|
23
|
+
/**
|
|
24
|
+
* The type of a schema used as a *member* of an enclosing type - a composition branch, an array element, an
|
|
25
|
+
* `additionalProperties` value - with the schema's own nullability applied.
|
|
26
|
+
*
|
|
27
|
+
* `getType` renders a schema's type without its `null` on purpose: the two contexts that render a schema's type
|
|
28
|
+
* as a whole declare nullability themselves. A property has it added by `getProperties`, and a top-level type
|
|
29
|
+
* alias deliberately does not hoist it, because that would change what every declared type means for consumers.
|
|
30
|
+
* A member position has neither - nothing downstream can add the `null` back - so unless it is admitted here the
|
|
31
|
+
* emitted type cannot represent a value the spec explicitly permits.
|
|
32
|
+
*/
|
|
33
|
+
protected getMemberType(ctx: Context, schema: Nullable<ApiSchema>, options?: {
|
|
34
|
+
skipSchemas?: boolean;
|
|
35
|
+
useBaseType?: boolean;
|
|
36
|
+
}): ts.Type<Builder> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a schema needs a `null` added to the type `getType` renders for it. A schema that only ever renders as
|
|
39
|
+
* `null` (the null type itself) already admits it, and adding a second one would emit `(null) | (null)`.
|
|
40
|
+
*
|
|
41
|
+
* Nullability is read through the reference chain the same way `getType` reads the type, so a `$ref` to a
|
|
42
|
+
* declared nullable schema - whose own declaration does not hoist the `null` - still admits null where it is used.
|
|
43
|
+
*/
|
|
44
|
+
protected isNullableMember(schema: ApiSchema): boolean;
|
|
23
45
|
protected getType(ctx: Context, schema: Nullable<ApiSchema>, options?: {
|
|
24
46
|
skipSchemas?: boolean;
|
|
25
47
|
useBaseType?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAI1B,KAAK,YAAY,EAEjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,6BAA6B,EAAE,M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AO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAI3E,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAIlE,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,kBAAkB,CAAC;IAM7F,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;CAO/D"}
|
|
@@ -158,7 +158,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
158
158
|
getIndexer(ctx, schema) {
|
|
159
159
|
var _a;
|
|
160
160
|
return schema.additionalProperties
|
|
161
|
-
? ts.indexer(ts.refs.string(), (_a = (schema.additionalProperties === true ? null : this.
|
|
161
|
+
? ts.indexer(ts.refs.string(), (_a = (schema.additionalProperties === true ? null : this.getMemberType(ctx, schema.additionalProperties))) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), { readonly: ctx.config.immutableTypes })
|
|
162
162
|
: null;
|
|
163
163
|
}
|
|
164
164
|
getProperties(ctx, schema) {
|
|
@@ -174,6 +174,33 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* The type of a schema used as a *member* of an enclosing type - a composition branch, an array element, an
|
|
179
|
+
* `additionalProperties` value - with the schema's own nullability applied.
|
|
180
|
+
*
|
|
181
|
+
* `getType` renders a schema's type without its `null` on purpose: the two contexts that render a schema's type
|
|
182
|
+
* as a whole declare nullability themselves. A property has it added by `getProperties`, and a top-level type
|
|
183
|
+
* alias deliberately does not hoist it, because that would change what every declared type means for consumers.
|
|
184
|
+
* A member position has neither - nothing downstream can add the `null` back - so unless it is admitted here the
|
|
185
|
+
* emitted type cannot represent a value the spec explicitly permits.
|
|
186
|
+
*/
|
|
187
|
+
getMemberType(ctx, schema, options) {
|
|
188
|
+
const type = this.getType(ctx, schema, options);
|
|
189
|
+
return type !== null && schema && this.isNullableMember(schema) ? ts.unionType([type, 'null']) : type;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Whether a schema needs a `null` added to the type `getType` renders for it. A schema that only ever renders as
|
|
193
|
+
* `null` (the null type itself) already admits it, and adding a second one would emit `(null) | (null)`.
|
|
194
|
+
*
|
|
195
|
+
* Nullability is read through the reference chain the same way `getType` reads the type, so a `$ref` to a
|
|
196
|
+
* declared nullable schema - whose own declaration does not hoist the `null` - still admits null where it is used.
|
|
197
|
+
*/
|
|
198
|
+
isNullableMember(schema) {
|
|
199
|
+
const resolved = getSchemaReference(schema, DEFAULT_IGNORED_SCHEMA_PROPERTIES);
|
|
200
|
+
if (resolved.kind === 'null')
|
|
201
|
+
return false;
|
|
202
|
+
return schema.nullable === true || resolved.nullable === true;
|
|
203
|
+
}
|
|
177
204
|
getType(ctx, schema, options) {
|
|
178
205
|
if (!schema)
|
|
179
206
|
return this.getAnyType(ctx);
|
|
@@ -228,7 +255,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
228
255
|
}
|
|
229
256
|
getArrayType(ctx, schema) {
|
|
230
257
|
var _a;
|
|
231
|
-
return ts.arrayType((_a = this.
|
|
258
|
+
return ts.arrayType((_a = this.getMemberType(ctx, schema.items)) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), {
|
|
232
259
|
readonly: ctx.config.immutableTypes,
|
|
233
260
|
});
|
|
234
261
|
}
|
|
@@ -276,16 +303,21 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
276
303
|
return this.getAnyType(ctx);
|
|
277
304
|
}
|
|
278
305
|
const useBaseType = schema.id === ctx.schema.id;
|
|
306
|
+
// allOf branches must all hold at once, i.e. an intersection. anyOf branches only require at least one to hold,
|
|
307
|
+
// i.e. a union - TypeScript unions already admit values matching several branches, so no Partial<> wrapper is
|
|
308
|
+
// needed to express that overlap. A schema with both intersects the allOf branches with the anyOf union.
|
|
279
309
|
return ts.intersectionType([
|
|
280
|
-
...schema.allOf.map((x) => this.
|
|
281
|
-
|
|
310
|
+
...schema.allOf.map((x) => this.getMemberType(ctx, x, { useBaseType })),
|
|
311
|
+
schema.anyOf.length > 0
|
|
312
|
+
? ts.unionType(schema.anyOf.map((x) => this.getMemberType(ctx, x, { useBaseType })))
|
|
313
|
+
: null,
|
|
282
314
|
]);
|
|
283
315
|
}
|
|
284
316
|
getOneOfType(ctx, schema) {
|
|
285
317
|
if (schema.oneOf.length === 0) {
|
|
286
318
|
return this.getAnyType(ctx);
|
|
287
319
|
}
|
|
288
|
-
return ts.unionType(schema.oneOf.map((x) => this.
|
|
320
|
+
return ts.unionType(schema.oneOf.map((x) => this.getMemberType(ctx, x)));
|
|
289
321
|
}
|
|
290
322
|
getMultiType(ctx, schema) {
|
|
291
323
|
if (schema.type.length === 0) {
|
|
@@ -163,8 +163,8 @@ export class TypeScriptAngularServicesGenerator extends OpenApiServicesGeneratio
|
|
|
163
163
|
], '\n');
|
|
164
164
|
}
|
|
165
165
|
getRootUrl(ctx) {
|
|
166
|
-
var _a, _b, _c, _d, _e, _f;
|
|
167
|
-
return modifyString((
|
|
166
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
167
|
+
return modifyString((_j = (_h = (_g = (_f = (_e = ((_b = (_a = ctx.data.services[0]) === null || _a === void 0 ? void 0 : _a.$src) !== null && _b !== void 0 ? _b : (_d = (_c = ctx.data.services[0]) === null || _c === void 0 ? void 0 : _c.endpoints[0]) === null || _d === void 0 ? void 0 : _d.$src)) === null || _e === void 0 ? void 0 : _e.document) === null || _f === void 0 ? void 0 : _f.servers) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.url) !== null && _j !== void 0 ? _j : '/', ctx.config.rootUrl);
|
|
168
168
|
}
|
|
169
169
|
// #endregion
|
|
170
170
|
// #region Index
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACnD;AAED,qBAAa,kCAAmC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAC7F,YAAW,2BAA2B;IACtB,QAAQ,CAAC,GAAG,EAAE,kCAAkC,GAAG,YAAY,CAAC,iCAAiC,CAAC;IA4BlH,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAetF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAqErG,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;IAuBjH,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAqBvE,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,2BAA2B,C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
type: schema
|
|
155
155
|
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
156
156
|
: this.getAnyType(ctx),
|
|
157
|
-
description:
|
|
157
|
+
description: parameter.description
|
|
158
|
+
? (parameter.deprecated ? 'Deprecated: ' : '') + parameter.description
|
|
159
|
+
: parameter.deprecated
|
|
160
|
+
? 'Deprecated'
|
|
161
|
+
: undefined,
|
|
158
162
|
required: parameter.required,
|
|
159
163
|
};
|
|
160
164
|
});
|
|
@@ -243,7 +247,13 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
243
247
|
}),
|
|
244
248
|
parameters: [
|
|
245
249
|
ts.constructorParameter('rootUrl', { type: isJs ? undefined : rootUrlType }),
|
|
246
|
-
|
|
250
|
+
// `optional` renders a TypeScript `?`, which is a syntax error in a `.js` file. JavaScript
|
|
251
|
+
// parameters are optional anyway, and the JSDoc `@param [defaultK6ParamsFactory]` above
|
|
252
|
+
// already records it.
|
|
253
|
+
ts.constructorParameter('defaultK6ParamsFactory', {
|
|
254
|
+
type: isJs ? undefined : paramType,
|
|
255
|
+
optional: isJs ? undefined : true,
|
|
256
|
+
}),
|
|
247
257
|
],
|
|
248
258
|
body: s `this.rootUrl = rootUrl;
|
|
249
259
|
this._defaultK6ParamsFactory = defaultK6ParamsFactory;`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-collection.d.ts","sourceRoot":"","sources":["../../src/src/import-collection.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"import-collection.d.ts","sourceRoot":"","sources":["../../src/src/import-collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtF,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAA+B,KAAK,uBAAu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AAS,CAAC,mBAAmB,CAC3B,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,QAAQ,GAAG,QAAQ,GAAG,aAAa,GAAG,aAAa,GAAG,YAAY,EAC3E,IAAI,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAC3D,OAAO,EAAE;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE;IA2BvC,SAAS,CAAC,cAAc,CACtB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,EAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,uBAAuB,EAAE,uBAAuB,GAC/C,CAAC,SAAS,CAAC,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE;IASxD,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB;IAKjE,SAAS,CAAC,iBAAiB,CACzB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,uBAAuB,EAAE,uBAAuB,GAC/C,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAUjC,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAW5E,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,oBAAoB,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAQ7E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extname } from 'node:path';
|
|
2
|
-
import { StringBuilder } from '@goast/core';
|
|
2
|
+
import { compareString, StringBuilder } from '@goast/core';
|
|
3
3
|
import { defaultTypeScriptGeneratorConfig } from './config.js';
|
|
4
4
|
import { getModulePathRelativeToFile } from './utils.js';
|
|
5
5
|
export const defaultImportExportCollectionOptions = {
|
|
@@ -170,7 +170,7 @@ export class ImportExportCollection {
|
|
|
170
170
|
}
|
|
171
171
|
sortAndResolve(data, filePath, importModuleTransformer) {
|
|
172
172
|
return Array.from(data.entries())
|
|
173
|
-
.sort(([
|
|
173
|
+
.sort(([a], [b]) => compareString(a, b))
|
|
174
174
|
.map(([fromModule, names]) => [...this.resolveModulePath(fromModule, filePath, importModuleTransformer), Array.from(names).sort()]);
|
|
175
175
|
}
|
|
176
176
|
getImportKind(fromModule) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goast/typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-beta.2",
|
|
4
4
|
"description": "Provides gOAst generators for generating TypeScript code from OpenAPI specifications.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marc Schmidt (MaSch0212)",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"tslib": "^2.6.2",
|
|
27
27
|
"fs-extra": "^11.3.3",
|
|
28
|
-
"@goast/core": "0.
|
|
28
|
+
"@goast/core": "0.6.0-beta.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.9.0",
|
|
@@ -20,6 +20,28 @@ export declare class DefaultTypeScriptModelGenerator extends TypeScriptFileGener
|
|
|
20
20
|
protected getEnumValuesVariable(ctx: Context, schema: ApiSchema): ts.Variable<Builder>;
|
|
21
21
|
protected getIndexer(ctx: Context, schema: ObjectLikeApiSchema): ts.Indexer<Builder> | null;
|
|
22
22
|
protected getProperties(ctx: Context, schema: ObjectLikeApiSchema): ts.Property<Builder>[];
|
|
23
|
+
/**
|
|
24
|
+
* The type of a schema used as a *member* of an enclosing type - a composition branch, an array element, an
|
|
25
|
+
* `additionalProperties` value - with the schema's own nullability applied.
|
|
26
|
+
*
|
|
27
|
+
* `getType` renders a schema's type without its `null` on purpose: the two contexts that render a schema's type
|
|
28
|
+
* as a whole declare nullability themselves. A property has it added by `getProperties`, and a top-level type
|
|
29
|
+
* alias deliberately does not hoist it, because that would change what every declared type means for consumers.
|
|
30
|
+
* A member position has neither - nothing downstream can add the `null` back - so unless it is admitted here the
|
|
31
|
+
* emitted type cannot represent a value the spec explicitly permits.
|
|
32
|
+
*/
|
|
33
|
+
protected getMemberType(ctx: Context, schema: Nullable<ApiSchema>, options?: {
|
|
34
|
+
skipSchemas?: boolean;
|
|
35
|
+
useBaseType?: boolean;
|
|
36
|
+
}): ts.Type<Builder> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a schema needs a `null` added to the type `getType` renders for it. A schema that only ever renders as
|
|
39
|
+
* `null` (the null type itself) already admits it, and adding a second one would emit `(null) | (null)`.
|
|
40
|
+
*
|
|
41
|
+
* Nullability is read through the reference chain the same way `getType` reads the type, so a `$ref` to a
|
|
42
|
+
* declared nullable schema - whose own declaration does not hoist the `null` - still admits null where it is used.
|
|
43
|
+
*/
|
|
44
|
+
protected isNullableMember(schema: ApiSchema): boolean;
|
|
23
45
|
protected getType(ctx: Context, schema: Nullable<ApiSchema>, options?: {
|
|
24
46
|
skipSchemas?: boolean;
|
|
25
47
|
useBaseType?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAI1B,KAAK,YAAY,EAEjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;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AG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAIlE,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,kBAAkB,CAAC;IAM7F,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;CAO/D"}
|
|
@@ -161,7 +161,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
161
161
|
getIndexer(ctx, schema) {
|
|
162
162
|
var _a;
|
|
163
163
|
return schema.additionalProperties
|
|
164
|
-
? index_js_1.ts.indexer(index_js_1.ts.refs.string(), (_a = (schema.additionalProperties === true ? null : this.
|
|
164
|
+
? index_js_1.ts.indexer(index_js_1.ts.refs.string(), (_a = (schema.additionalProperties === true ? null : this.getMemberType(ctx, schema.additionalProperties))) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), { readonly: ctx.config.immutableTypes })
|
|
165
165
|
: null;
|
|
166
166
|
}
|
|
167
167
|
getProperties(ctx, schema) {
|
|
@@ -177,6 +177,33 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* The type of a schema used as a *member* of an enclosing type - a composition branch, an array element, an
|
|
182
|
+
* `additionalProperties` value - with the schema's own nullability applied.
|
|
183
|
+
*
|
|
184
|
+
* `getType` renders a schema's type without its `null` on purpose: the two contexts that render a schema's type
|
|
185
|
+
* as a whole declare nullability themselves. A property has it added by `getProperties`, and a top-level type
|
|
186
|
+
* alias deliberately does not hoist it, because that would change what every declared type means for consumers.
|
|
187
|
+
* A member position has neither - nothing downstream can add the `null` back - so unless it is admitted here the
|
|
188
|
+
* emitted type cannot represent a value the spec explicitly permits.
|
|
189
|
+
*/
|
|
190
|
+
getMemberType(ctx, schema, options) {
|
|
191
|
+
const type = this.getType(ctx, schema, options);
|
|
192
|
+
return type !== null && schema && this.isNullableMember(schema) ? index_js_1.ts.unionType([type, 'null']) : type;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Whether a schema needs a `null` added to the type `getType` renders for it. A schema that only ever renders as
|
|
196
|
+
* `null` (the null type itself) already admits it, and adding a second one would emit `(null) | (null)`.
|
|
197
|
+
*
|
|
198
|
+
* Nullability is read through the reference chain the same way `getType` reads the type, so a `$ref` to a
|
|
199
|
+
* declared nullable schema - whose own declaration does not hoist the `null` - still admits null where it is used.
|
|
200
|
+
*/
|
|
201
|
+
isNullableMember(schema) {
|
|
202
|
+
const resolved = (0, core_1.getSchemaReference)(schema, core_1.DEFAULT_IGNORED_SCHEMA_PROPERTIES);
|
|
203
|
+
if (resolved.kind === 'null')
|
|
204
|
+
return false;
|
|
205
|
+
return schema.nullable === true || resolved.nullable === true;
|
|
206
|
+
}
|
|
180
207
|
getType(ctx, schema, options) {
|
|
181
208
|
if (!schema)
|
|
182
209
|
return this.getAnyType(ctx);
|
|
@@ -231,7 +258,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
231
258
|
}
|
|
232
259
|
getArrayType(ctx, schema) {
|
|
233
260
|
var _a;
|
|
234
|
-
return index_js_1.ts.arrayType((_a = this.
|
|
261
|
+
return index_js_1.ts.arrayType((_a = this.getMemberType(ctx, schema.items)) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), {
|
|
235
262
|
readonly: ctx.config.immutableTypes,
|
|
236
263
|
});
|
|
237
264
|
}
|
|
@@ -279,16 +306,21 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
279
306
|
return this.getAnyType(ctx);
|
|
280
307
|
}
|
|
281
308
|
const useBaseType = schema.id === ctx.schema.id;
|
|
309
|
+
// allOf branches must all hold at once, i.e. an intersection. anyOf branches only require at least one to hold,
|
|
310
|
+
// i.e. a union - TypeScript unions already admit values matching several branches, so no Partial<> wrapper is
|
|
311
|
+
// needed to express that overlap. A schema with both intersects the allOf branches with the anyOf union.
|
|
282
312
|
return index_js_1.ts.intersectionType([
|
|
283
|
-
...schema.allOf.map((x) => this.
|
|
284
|
-
|
|
313
|
+
...schema.allOf.map((x) => this.getMemberType(ctx, x, { useBaseType })),
|
|
314
|
+
schema.anyOf.length > 0
|
|
315
|
+
? index_js_1.ts.unionType(schema.anyOf.map((x) => this.getMemberType(ctx, x, { useBaseType })))
|
|
316
|
+
: null,
|
|
285
317
|
]);
|
|
286
318
|
}
|
|
287
319
|
getOneOfType(ctx, schema) {
|
|
288
320
|
if (schema.oneOf.length === 0) {
|
|
289
321
|
return this.getAnyType(ctx);
|
|
290
322
|
}
|
|
291
|
-
return index_js_1.ts.unionType(schema.oneOf.map((x) => this.
|
|
323
|
+
return index_js_1.ts.unionType(schema.oneOf.map((x) => this.getMemberType(ctx, x)));
|
|
292
324
|
}
|
|
293
325
|
getMultiType(ctx, schema) {
|
|
294
326
|
if (schema.type.length === 0) {
|
|
@@ -167,8 +167,8 @@ class TypeScriptAngularServicesGenerator extends core_1.OpenApiServicesGeneratio
|
|
|
167
167
|
], '\n');
|
|
168
168
|
}
|
|
169
169
|
getRootUrl(ctx) {
|
|
170
|
-
var _a, _b, _c, _d, _e, _f;
|
|
171
|
-
return (0, utils_js_1.modifyString)((
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
171
|
+
return (0, utils_js_1.modifyString)((_j = (_h = (_g = (_f = (_e = ((_b = (_a = ctx.data.services[0]) === null || _a === void 0 ? void 0 : _a.$src) !== null && _b !== void 0 ? _b : (_d = (_c = ctx.data.services[0]) === null || _c === void 0 ? void 0 : _c.endpoints[0]) === null || _d === void 0 ? void 0 : _d.$src)) === null || _e === void 0 ? void 0 : _e.document) === null || _f === void 0 ? void 0 : _f.servers) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.url) !== null && _j !== void 0 ? _j : '/', ctx.config.rootUrl);
|
|
172
172
|
}
|
|
173
173
|
// #endregion
|
|
174
174
|
// #region Index
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACnD;AAED,qBAAa,kCAAmC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAC7F,YAAW,2BAA2B;IACtB,QAAQ,CAAC,GAAG,EAAE,kCAAkC,GAAG,YAAY,CAAC,iCAAiC,CAAC;IA4BlH,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAetF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAqErG,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;IAuBjH,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAqBvE,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;A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157,11 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
157
157
|
type: schema
|
|
158
158
|
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
159
159
|
: this.getAnyType(ctx),
|
|
160
|
-
description:
|
|
160
|
+
description: parameter.description
|
|
161
|
+
? (parameter.deprecated ? 'Deprecated: ' : '') + parameter.description
|
|
162
|
+
: parameter.deprecated
|
|
163
|
+
? 'Deprecated'
|
|
164
|
+
: undefined,
|
|
161
165
|
required: parameter.required,
|
|
162
166
|
};
|
|
163
167
|
});
|
|
@@ -246,7 +250,13 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
246
250
|
}),
|
|
247
251
|
parameters: [
|
|
248
252
|
index_js_1.ts.constructorParameter('rootUrl', { type: isJs ? undefined : rootUrlType }),
|
|
249
|
-
|
|
253
|
+
// `optional` renders a TypeScript `?`, which is a syntax error in a `.js` file. JavaScript
|
|
254
|
+
// parameters are optional anyway, and the JSDoc `@param [defaultK6ParamsFactory]` above
|
|
255
|
+
// already records it.
|
|
256
|
+
index_js_1.ts.constructorParameter('defaultK6ParamsFactory', {
|
|
257
|
+
type: isJs ? undefined : paramType,
|
|
258
|
+
optional: isJs ? undefined : true,
|
|
259
|
+
}),
|
|
250
260
|
],
|
|
251
261
|
body: (0, core_1.builderTemplate) `this.rootUrl = rootUrl;
|
|
252
262
|
this._defaultK6ParamsFactory = defaultK6ParamsFactory;`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-collection.d.ts","sourceRoot":"","sources":["../../src/src/import-collection.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"import-collection.d.ts","sourceRoot":"","sources":["../../src/src/import-collection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtF,OAAO,KAAK,EACV,oBAAoB,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ort(([a], [b]) => (0, core_1.compareString)(a, b))
|
|
177
177
|
.map(([fromModule, names]) => [...this.resolveModulePath(fromModule, filePath, importModuleTransformer), Array.from(names).sort()]);
|
|
178
178
|
}
|
|
179
179
|
getImportKind(fromModule) {
|
package/src/mod.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './src/ast/index.js';
|
|
2
|
-
export * from './src/common-results.js';
|
|
3
|
-
export * from './src/config.js';
|
|
4
|
-
export * from './src/file-builder.js';
|
|
5
|
-
export * from './src/generators/index.js';
|
|
6
|
-
export * from './src/import-collection.js';
|
|
7
|
-
export * from './src/utils.js';
|
package/src/src/assets.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AssetManager } from '@goast/core';
|
|
2
|
-
import { pathToFileURL, URL } from 'node:url';
|
|
3
|
-
|
|
4
|
-
declare const __filename: string | undefined;
|
|
5
|
-
const scriptUrl = typeof __filename === 'undefined' ? import.meta.url : pathToFileURL(__filename);
|
|
6
|
-
|
|
7
|
-
const manager = new AssetManager(new URL('../assets/', scriptUrl));
|
|
8
|
-
export const getAssetFileContent = manager.getAssetFileContent.bind(manager);
|
|
9
|
-
export const copyAssetFile = manager.copyAssetFile.bind(manager);
|
package/src/src/ast/_index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export { type TsAccessModifier as AccessModifier } from './common.js';
|
|
2
|
-
export { TsNode as Node } from './node.js';
|
|
3
|
-
export { TsArgument as Argument, tsArgument as argument } from './nodes/argument.js';
|
|
4
|
-
export { TsArrayType as ArrayType, tsArrayType as arrayType } from './nodes/array-type.js';
|
|
5
|
-
export { TsArrowFunction as ArrowFunction, tsArrowFunction as arrowFunction } from './nodes/arrow-function.js';
|
|
6
|
-
export { TsCall as Call, tsCall as call } from './nodes/call.js';
|
|
7
|
-
export { TsClass as Class, tsClass as class } from './nodes/class.js';
|
|
8
|
-
export {
|
|
9
|
-
TsConstructorParameter as ConstructorParameter,
|
|
10
|
-
tsConstructorParameter as constructorParameter,
|
|
11
|
-
} from './nodes/constructor-parameter.js';
|
|
12
|
-
export { TsConstructor as Constructor, tsConstructor as constructor } from './nodes/constructor.js';
|
|
13
|
-
export { TsDecorator as Decorator, tsDecorator as decorator } from './nodes/decorator.js';
|
|
14
|
-
export { TsDocTag as DocTag, tsDocTag as docTag } from './nodes/doc-tag.js';
|
|
15
|
-
export { TsDoc as Doc, tsDoc as doc } from './nodes/doc.js';
|
|
16
|
-
export { TsEnumValue as EnumValue, tsEnumValue as enumValue } from './nodes/enum-value.js';
|
|
17
|
-
export { TsEnum as Enum, tsEnum as enum } from './nodes/enum.js';
|
|
18
|
-
export { TsExport as Export, tsExport as export } from './nodes/export.js';
|
|
19
|
-
export { TsFunctionType as FunctionType, tsFunctionType as functionType } from './nodes/function-type.js';
|
|
20
|
-
export { TsFunction as Function, tsFunction as function } from './nodes/function.js';
|
|
21
|
-
export {
|
|
22
|
-
TsGenericParameter as GenericParameter,
|
|
23
|
-
tsGenericParameter as genericParameter,
|
|
24
|
-
} from './nodes/generic-parameter.js';
|
|
25
|
-
export { TsIndexer as Indexer, tsIndexer as indexer } from './nodes/indexer.js';
|
|
26
|
-
export { TsInterface as Interface, tsInterface as interface } from './nodes/interface.js';
|
|
27
|
-
export {
|
|
28
|
-
TsIntersectionType as IntersectionType,
|
|
29
|
-
tsIntersectionType as intersectionType,
|
|
30
|
-
} from './nodes/intersection-type.js';
|
|
31
|
-
export { TsLookupType as LookupType, tsLookupType as lookupType } from './nodes/lookup-type.js';
|
|
32
|
-
export { TsMethod as Method, tsMethod as method } from './nodes/method.js';
|
|
33
|
-
export { TsObjectType as ObjectType, tsObjectType as objectType } from './nodes/object-type.js';
|
|
34
|
-
export { TsObject as Object, tsObject as object } from './nodes/object.js';
|
|
35
|
-
export { TsParameter as Parameter, tsParameter as parameter } from './nodes/parameter.js';
|
|
36
|
-
export { TsProperty as Property, tsProperty as property } from './nodes/property.js';
|
|
37
|
-
export {
|
|
38
|
-
type TsGenericModuleReferenceFactory as GenericModuleReferenceFactory,
|
|
39
|
-
type TsGenericReferenceFactory as GenericReferenceFactory,
|
|
40
|
-
type TsModuleReferenceFactory as ModuleReferenceFactory,
|
|
41
|
-
TsReference as Reference,
|
|
42
|
-
tsReference as reference,
|
|
43
|
-
type TsReferenceFactory as ReferenceFactory,
|
|
44
|
-
} from './nodes/reference.js';
|
|
45
|
-
export { TsString as String, tsString as string } from './nodes/string.js';
|
|
46
|
-
export { TsTuple as Tuple, tsTuple as tuple } from './nodes/tuple.js';
|
|
47
|
-
export { TsTypeAlias as TypeAlias, tsTypeAlias as typeAlias } from './nodes/type-alias.js';
|
|
48
|
-
export { TsTypeof as Typeof, tsTypeof as typeof } from './nodes/typeof.js';
|
|
49
|
-
export { type TsType as Type, type TsValue as Value } from './nodes/types.js';
|
|
50
|
-
export { TsUnionType as UnionType, tsUnionType as unionType } from './nodes/union-type.js';
|
|
51
|
-
export { TsVariable as Variable, tsVariable as variable } from './nodes/variable.js';
|
|
52
|
-
export * as refs from './references/index.js';
|
|
53
|
-
export { getTypeScriptBuilderOptions as getBuilderOptions } from './utils/get-type-script-builder-options.js';
|
|
54
|
-
export { toTsNode as toNode } from './utils/to-ts-node.js';
|
package/src/src/ast/common.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type TsAccessModifier = 'public' | 'protected' | 'private';
|
package/src/src/ast/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as ts from './_index.js';
|
package/src/src/ast/node.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AstNode, type AstNodeOptions, type SourceBuilder } from '@goast/core';
|
|
2
|
-
|
|
3
|
-
export abstract class TsNode<TBuilder extends SourceBuilder, TInjects extends string = never> extends AstNode<
|
|
4
|
-
TBuilder,
|
|
5
|
-
TInjects
|
|
6
|
-
> {
|
|
7
|
-
constructor(options: AstNodeOptions<typeof AstNode<TBuilder, TInjects>>) {
|
|
8
|
-
super(options);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { AstNodeOptions, Prettify, SourceBuilder } from '@goast/core';
|
|
2
|
-
|
|
3
|
-
import { TsNode } from '../node.js';
|
|
4
|
-
import { writeTsNode } from '../utils/write-ts-nodes.js';
|
|
5
|
-
import { writeTsParameters } from '../utils/write-ts-parameters.js';
|
|
6
|
-
import type { TsValue } from './types.js';
|
|
7
|
-
|
|
8
|
-
type Injects = never;
|
|
9
|
-
|
|
10
|
-
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
11
|
-
typeof TsNode<TBuilder, TInjects | Injects>,
|
|
12
|
-
{
|
|
13
|
-
value: TsValue<TBuilder>;
|
|
14
|
-
}
|
|
15
|
-
>;
|
|
16
|
-
|
|
17
|
-
export class TsArgument<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<
|
|
18
|
-
TBuilder,
|
|
19
|
-
TInjects | Injects
|
|
20
|
-
> {
|
|
21
|
-
public value: TsValue<TBuilder>;
|
|
22
|
-
|
|
23
|
-
constructor(options: Options<TBuilder, TInjects>) {
|
|
24
|
-
super(options);
|
|
25
|
-
this.value = options.value;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
protected override onWrite(builder: TBuilder): void {
|
|
29
|
-
writeTsNode(builder, this.value);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const createArgument = <TBuilder extends SourceBuilder>(
|
|
34
|
-
value: Options<TBuilder>['value'],
|
|
35
|
-
options?: Prettify<Omit<Options<TBuilder>, 'value'>>,
|
|
36
|
-
): TsArgument<TBuilder> => new TsArgument<TBuilder>({ ...options, value });
|
|
37
|
-
|
|
38
|
-
export const tsArgument: typeof createArgument & { write: typeof writeTsParameters } = Object.assign(createArgument, {
|
|
39
|
-
write: writeTsParameters,
|
|
40
|
-
});
|