@goast/typescript 0.6.2 → 0.6.3-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.
- package/LICENSE +21 -21
- package/assets/stubs/easy-network-stub/easy-network-stub.utils.ts +2 -6
- package/package.json +2 -2
- 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 -89
- 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 -481
- 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 -414
- 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 -45
- package/src/src/generators/services/fetch-clients/fetch-client-generator.ts +0 -285
- 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 -474
- 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 -72
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Marc Schmidt
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Marc Schmidt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { EasyNetworkStub } from 'easy-network-stub';
|
|
2
|
-
|
|
3
|
-
import type { ErrorResponse, HttpMethod, RouteResponseCallback } from 'easy-network-stub';
|
|
1
|
+
import type { EasyNetworkStub, ErrorResponse, HttpMethod, RouteResponseCallback } from 'easy-network-stub';
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Options for the `EasyNetworkStubWrapper`.
|
|
@@ -221,9 +219,7 @@ export class EasyNetworkStubBase {
|
|
|
221
219
|
}
|
|
222
220
|
|
|
223
221
|
public reset() {
|
|
224
|
-
|
|
225
|
-
this.stubWrapper.reset();
|
|
226
|
-
}
|
|
222
|
+
this.stubWrapper.reset();
|
|
227
223
|
}
|
|
228
224
|
}
|
|
229
225
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goast/typescript",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3-beta.1",
|
|
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.5.0"
|
|
28
|
+
"@goast/core": "0.5.0-beta.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.9.0",
|
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
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
|
-
|
|
3
|
-
import { TsNode } from '../node.js';
|
|
4
|
-
import { writeTsNode, writeTsNodes } from '../utils/write-ts-nodes.js';
|
|
5
|
-
import type { TsType } from './types.js';
|
|
6
|
-
|
|
7
|
-
type Injects = 'type';
|
|
8
|
-
|
|
9
|
-
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
10
|
-
typeof TsNode<TBuilder, TInjects | Injects>,
|
|
11
|
-
{
|
|
12
|
-
readonly?: Nullable<boolean>;
|
|
13
|
-
type: TsType<TBuilder>;
|
|
14
|
-
}
|
|
15
|
-
>;
|
|
16
|
-
|
|
17
|
-
export class TsArrayType<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<
|
|
18
|
-
TBuilder,
|
|
19
|
-
TInjects | Injects
|
|
20
|
-
> {
|
|
21
|
-
public readonly: boolean;
|
|
22
|
-
public type: TsType<TBuilder>;
|
|
23
|
-
|
|
24
|
-
constructor(options: Options<TBuilder, TInjects>) {
|
|
25
|
-
super(options);
|
|
26
|
-
this.readonly = options.readonly ?? false;
|
|
27
|
-
this.type = options.type;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
protected override onWrite(builder: TBuilder): void {
|
|
31
|
-
if (this.readonly) builder.append('readonly ');
|
|
32
|
-
|
|
33
|
-
builder
|
|
34
|
-
.append(this.inject.beforeType)
|
|
35
|
-
.parenthesize('()', (b) => writeTsNode(b, this.type))
|
|
36
|
-
.append(this.inject.afterType);
|
|
37
|
-
|
|
38
|
-
builder.append('[]');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const createArrayType = <TBuilder extends SourceBuilder>(
|
|
43
|
-
type: Options<TBuilder>['type'],
|
|
44
|
-
options?: Prettify<Omit<Options<TBuilder>, 'type'>>,
|
|
45
|
-
): TsArrayType<TBuilder> => new TsArrayType<TBuilder>({ ...options, type });
|
|
46
|
-
|
|
47
|
-
export const tsArrayType: typeof createArrayType & { write: typeof writeTsNodes } = Object.assign(createArrayType, {
|
|
48
|
-
write: writeTsNodes,
|
|
49
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AppendValue,
|
|
3
|
-
type AstNodeOptions,
|
|
4
|
-
type BasicAppendValue,
|
|
5
|
-
notNullish,
|
|
6
|
-
type Nullable,
|
|
7
|
-
type SourceBuilder,
|
|
8
|
-
} from '@goast/core';
|
|
9
|
-
|
|
10
|
-
import { TsNode } from '../node.js';
|
|
11
|
-
import { writeTsNode, writeTsNodes } from '../utils/write-ts-nodes.js';
|
|
12
|
-
import { type TsGenericParameter, tsGenericParameter } from './generic-parameter.js';
|
|
13
|
-
import { type TsParameter, tsParameter } from './parameter.js';
|
|
14
|
-
import type { TsType } from './types.js';
|
|
15
|
-
|
|
16
|
-
type Injects = 'generics' | 'params' | 'returnType' | 'body';
|
|
17
|
-
|
|
18
|
-
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
19
|
-
typeof TsNode<TBuilder, TInjects | Injects>,
|
|
20
|
-
{
|
|
21
|
-
async?: Nullable<boolean>;
|
|
22
|
-
generics?: Nullable<Nullable<TsGenericParameter<TBuilder> | BasicAppendValue<TBuilder>>[]>;
|
|
23
|
-
parameters?: Nullable<Nullable<TsParameter<TBuilder> | BasicAppendValue<TBuilder>>[]>;
|
|
24
|
-
returnType?: Nullable<TsType<TBuilder>>;
|
|
25
|
-
singleExpression?: Nullable<boolean>;
|
|
26
|
-
body?: Nullable<AppendValue<TBuilder>>;
|
|
27
|
-
}
|
|
28
|
-
>;
|
|
29
|
-
|
|
30
|
-
export class TsArrowFunction<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<
|
|
31
|
-
TBuilder,
|
|
32
|
-
TInjects | Injects
|
|
33
|
-
> {
|
|
34
|
-
public async: boolean;
|
|
35
|
-
public generics: (TsGenericParameter<TBuilder> | BasicAppendValue<TBuilder>)[];
|
|
36
|
-
public parameters: (TsParameter<TBuilder> | BasicAppendValue<TBuilder>)[];
|
|
37
|
-
public returnType: TsType<TBuilder> | null;
|
|
38
|
-
public singleExpression: boolean;
|
|
39
|
-
public body: AppendValue<TBuilder> | null;
|
|
40
|
-
|
|
41
|
-
constructor(options: Options<TBuilder, TInjects>) {
|
|
42
|
-
super(options);
|
|
43
|
-
this.async = options.async ?? false;
|
|
44
|
-
this.generics = options.generics?.filter(notNullish) ?? [];
|
|
45
|
-
this.parameters = options.parameters?.filter(notNullish) ?? [];
|
|
46
|
-
this.returnType = options.returnType ?? null;
|
|
47
|
-
this.singleExpression = options.singleExpression ?? false;
|
|
48
|
-
this.body = options.body ?? null;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected override onWrite(builder: TBuilder): void {
|
|
52
|
-
if (this.async) {
|
|
53
|
-
builder.append('async ');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
builder.append(this.inject.beforeGenerics);
|
|
57
|
-
tsGenericParameter.write(builder, this.generics);
|
|
58
|
-
builder.append(this.inject.afterGenerics);
|
|
59
|
-
|
|
60
|
-
builder.append(this.inject.beforeParams);
|
|
61
|
-
tsParameter.write(builder, this.parameters);
|
|
62
|
-
builder.append(this.inject.afterParams);
|
|
63
|
-
|
|
64
|
-
if (this.returnType) {
|
|
65
|
-
builder.append(': ');
|
|
66
|
-
builder.append(this.inject.beforeReturnType);
|
|
67
|
-
writeTsNode(builder, this.returnType);
|
|
68
|
-
builder.append(this.inject.afterReturnType);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
builder.append(' => ');
|
|
72
|
-
|
|
73
|
-
builder.append(this.inject.beforeBody);
|
|
74
|
-
if (this.singleExpression && this.body) {
|
|
75
|
-
builder.append(this.body);
|
|
76
|
-
} else {
|
|
77
|
-
builder.parenthesize('{}', this.body, { multiline: !!this.body });
|
|
78
|
-
}
|
|
79
|
-
builder.append(this.inject.afterBody);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const createArrowFunction = <TBuilder extends SourceBuilder>(options?: Options<TBuilder>): TsArrowFunction<TBuilder> =>
|
|
84
|
-
new TsArrowFunction<TBuilder>(options ?? {});
|
|
85
|
-
|
|
86
|
-
export const tsArrowFunction: typeof createArrowFunction & { write: typeof writeTsNodes } = Object.assign(
|
|
87
|
-
createArrowFunction,
|
|
88
|
-
{
|
|
89
|
-
write: writeTsNodes,
|
|
90
|
-
},
|
|
91
|
-
);
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ArrayItem,
|
|
3
|
-
type AstNodeOptions,
|
|
4
|
-
notNullish,
|
|
5
|
-
type Nullable,
|
|
6
|
-
type Prettify,
|
|
7
|
-
type SourceBuilder,
|
|
8
|
-
} from '@goast/core';
|
|
9
|
-
|
|
10
|
-
import { TsNode } from '../node.js';
|
|
11
|
-
import { writeTsNodes } from '../utils/write-ts-nodes.js';
|
|
12
|
-
import { type TsArgument, tsArgument } from './argument.js';
|
|
13
|
-
import type { TsType, TsValue } from './types.js';
|
|
14
|
-
|
|
15
|
-
type Injects = never;
|
|
16
|
-
|
|
17
|
-
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
18
|
-
typeof TsNode<TBuilder, TInjects | Injects>,
|
|
19
|
-
{
|
|
20
|
-
path: Nullable<TsType<TBuilder> | TsValue<TBuilder>>[];
|
|
21
|
-
arguments?: Nullable<Nullable<TsArgument<TBuilder> | TsValue<TBuilder>>[]>;
|
|
22
|
-
}
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
export class TsCall<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<
|
|
26
|
-
TBuilder,
|
|
27
|
-
TInjects | Injects
|
|
28
|
-
> {
|
|
29
|
-
public path: (TsType<TBuilder> | TsValue<TBuilder>)[];
|
|
30
|
-
public arguments: (TsArgument<TBuilder> | TsValue<TBuilder>)[] | null;
|
|
31
|
-
|
|
32
|
-
constructor(options: Options<TBuilder, TInjects>) {
|
|
33
|
-
super(options);
|
|
34
|
-
this.path = options.path.filter(notNullish);
|
|
35
|
-
this.arguments = options.arguments?.filter(notNullish) ?? null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
protected override onWrite(builder: TBuilder): void {
|
|
39
|
-
writeTsNodes(builder, this.path, { separator: '.' });
|
|
40
|
-
|
|
41
|
-
if (this.arguments) {
|
|
42
|
-
tsArgument.write(builder, this.arguments);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const createCall = <TBuilder extends SourceBuilder>(
|
|
48
|
-
path: Options<TBuilder>['path'] | ArrayItem<Options<TBuilder>['path']>,
|
|
49
|
-
args?: Options<TBuilder>['arguments'],
|
|
50
|
-
options?: Prettify<Omit<Options<TBuilder>, 'path' | 'arguments'>>,
|
|
51
|
-
): TsCall<TBuilder> => new TsCall<TBuilder>({ ...options, path: Array.isArray(path) ? path : [path], arguments: args });
|
|
52
|
-
|
|
53
|
-
export const tsCall: typeof createCall & { write: typeof writeTsNodes } = Object.assign(createCall, {
|
|
54
|
-
write: writeTsNodes,
|
|
55
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type AstNodeOptions,
|
|
3
|
-
type BasicAppendValue,
|
|
4
|
-
notNullish,
|
|
5
|
-
type Nullable,
|
|
6
|
-
type Prettify,
|
|
7
|
-
type SourceBuilder,
|
|
8
|
-
} from '@goast/core';
|
|
9
|
-
|
|
10
|
-
import { TsNode } from '../node.js';
|
|
11
|
-
import { writeTsMembers } from '../utils/write-ts-members.js';
|
|
12
|
-
import { writeTsNode, writeTsNodes } from '../utils/write-ts-nodes.js';
|
|
13
|
-
import type { TsConstructor } from './constructor.js';
|
|
14
|
-
import { type TsDecorator, tsDecorator } from './decorator.js';
|
|
15
|
-
import { type TsDoc, tsDoc } from './doc.js';
|
|
16
|
-
import { type TsGenericParameter, tsGenericParameter } from './generic-parameter.js';
|
|
17
|
-
import type { TsIndexer } from './indexer.js';
|
|
18
|
-
import type { TsMethod } from './method.js';
|
|
19
|
-
import type { TsProperty } from './property.js';
|
|
20
|
-
import type { TsReference } from './reference.js';
|
|
21
|
-
|
|
22
|
-
type Injects = 'doc' | 'decorators' | 'modifiers' | 'name' | 'generics' | 'extends' | 'implements' | 'body' | 'members';
|
|
23
|
-
|
|
24
|
-
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
25
|
-
typeof TsNode<TBuilder, TInjects | Injects>,
|
|
26
|
-
{
|
|
27
|
-
doc?: Nullable<TsDoc<TBuilder>>;
|
|
28
|
-
decorators?: Nullable<Nullable<TsDecorator<TBuilder>>[]>;
|
|
29
|
-
export?: Nullable<boolean>;
|
|
30
|
-
abstract?: Nullable<boolean>;
|
|
31
|
-
name: string;
|
|
32
|
-
generics?: Nullable<Nullable<TsGenericParameter<TBuilder> | BasicAppendValue<TBuilder>>[]>;
|
|
33
|
-
extends?: Nullable<TsReference<TBuilder> | BasicAppendValue<TBuilder>>;
|
|
34
|
-
implements?: Nullable<Nullable<TsReference<TBuilder> | BasicAppendValue<TBuilder>>[]>;
|
|
35
|
-
members?: Nullable<Nullable<Member<TBuilder>>[]>;
|
|
36
|
-
}
|
|
37
|
-
>;
|
|
38
|
-
|
|
39
|
-
type Member<TBuilder extends SourceBuilder> =
|
|
40
|
-
| TsProperty<TBuilder>
|
|
41
|
-
| TsMethod<TBuilder>
|
|
42
|
-
| TsIndexer<TBuilder>
|
|
43
|
-
| TsConstructor<TBuilder>
|
|
44
|
-
| BasicAppendValue<TBuilder>;
|
|
45
|
-
|
|
46
|
-
export class TsClass<TBuilder extends SourceBuilder, TInjects extends string = never> extends TsNode<
|
|
47
|
-
TBuilder,
|
|
48
|
-
TInjects | Injects
|
|
49
|
-
> {
|
|
50
|
-
public doc: TsDoc<TBuilder> | null;
|
|
51
|
-
public decorators: TsDecorator<TBuilder>[];
|
|
52
|
-
public export: boolean;
|
|
53
|
-
public abstract: boolean;
|
|
54
|
-
public name: string;
|
|
55
|
-
public generics: (TsGenericParameter<TBuilder> | BasicAppendValue<TBuilder>)[];
|
|
56
|
-
public extends: TsReference<TBuilder> | BasicAppendValue<TBuilder> | null;
|
|
57
|
-
public implements: (TsReference<TBuilder> | BasicAppendValue<TBuilder>)[];
|
|
58
|
-
public members: Member<TBuilder>[];
|
|
59
|
-
|
|
60
|
-
constructor(options: Options<TBuilder, TInjects>) {
|
|
61
|
-
super(options);
|
|
62
|
-
this.doc = options.doc ?? null;
|
|
63
|
-
this.decorators = options.decorators?.filter(notNullish) ?? [];
|
|
64
|
-
this.export = options.export ?? false;
|
|
65
|
-
this.abstract = options.abstract ?? false;
|
|
66
|
-
this.name = options.name;
|
|
67
|
-
this.generics = options.generics?.filter(notNullish) ?? [];
|
|
68
|
-
this.extends = options.extends ?? null;
|
|
69
|
-
this.implements = options.implements?.filter(notNullish) ?? [];
|
|
70
|
-
this.members = options.members?.filter(notNullish) ?? [];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
protected override onWrite(builder: TBuilder): void {
|
|
74
|
-
builder.append(this.inject.beforeDoc);
|
|
75
|
-
tsDoc.write(builder, tsDoc.get(this.doc, { generics: this.generics }));
|
|
76
|
-
builder.append(this.inject.afterDoc);
|
|
77
|
-
|
|
78
|
-
builder.append(this.inject.beforeDecorators);
|
|
79
|
-
tsDecorator.write(builder, this.decorators, { multiline: true });
|
|
80
|
-
builder.append(this.inject.afterDecorators);
|
|
81
|
-
|
|
82
|
-
builder.append(this.inject.beforeModifiers);
|
|
83
|
-
if (this.export) builder.append('export ');
|
|
84
|
-
if (this.abstract) builder.append('abstract ');
|
|
85
|
-
builder.append(this.inject.afterModifiers);
|
|
86
|
-
|
|
87
|
-
builder.append('class ');
|
|
88
|
-
builder.append(this.inject.beforeName, this.name, this.inject.afterName);
|
|
89
|
-
|
|
90
|
-
builder.append(this.inject.beforeGenerics);
|
|
91
|
-
tsGenericParameter.write(builder, this.generics);
|
|
92
|
-
builder.append(this.inject.afterGenerics);
|
|
93
|
-
|
|
94
|
-
if (this.extends) {
|
|
95
|
-
builder.append(' extends ');
|
|
96
|
-
builder.append(this.inject.beforeExtends);
|
|
97
|
-
writeTsNode(builder, this.extends);
|
|
98
|
-
builder.append(this.inject.afterExtends);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (this.implements.length > 0) {
|
|
102
|
-
builder.append(' implements ');
|
|
103
|
-
builder.append(this.inject.beforeImplements);
|
|
104
|
-
writeTsNodes(builder, this.implements, { separator: ', ' });
|
|
105
|
-
builder.append(this.inject.afterImplements);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
builder.append(' ');
|
|
109
|
-
|
|
110
|
-
builder.append(this.inject.beforeBody);
|
|
111
|
-
builder.parenthesize(
|
|
112
|
-
'{}',
|
|
113
|
-
(b) => {
|
|
114
|
-
b.append(this.inject.beforeMembers);
|
|
115
|
-
writeTsMembers(b, this.members);
|
|
116
|
-
b.append(this.inject.afterMembers);
|
|
117
|
-
},
|
|
118
|
-
{ multiline: this.members.length > 0 },
|
|
119
|
-
);
|
|
120
|
-
builder.append(this.inject.afterBody);
|
|
121
|
-
|
|
122
|
-
builder.appendLine();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const createClass = <TBuilder extends SourceBuilder>(
|
|
127
|
-
name: Options<TBuilder>['name'],
|
|
128
|
-
options?: Prettify<Omit<Options<TBuilder>, 'name'>>,
|
|
129
|
-
): TsClass<TBuilder> => new TsClass<TBuilder>({ ...options, name });
|
|
130
|
-
|
|
131
|
-
export const tsClass: typeof createClass & { write: typeof writeTsNodes } = Object.assign(createClass, {
|
|
132
|
-
write: writeTsNodes,
|
|
133
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { AstNodeOptions, Nullable, Prettify, SourceBuilder } from '@goast/core';
|
|
2
|
-
|
|
3
|
-
import type { TsAccessModifier } from '../common.js';
|
|
4
|
-
import { writeTsNode } from '../utils/write-ts-nodes.js';
|
|
5
|
-
import { writeTsParameters } from '../utils/write-ts-parameters.js';
|
|
6
|
-
import { tsDecorator } from './decorator.js';
|
|
7
|
-
import { TsParameter } from './parameter.js';
|
|
8
|
-
|
|
9
|
-
type Injects = 'modifiers';
|
|
10
|
-
|
|
11
|
-
type Options<TBuilder extends SourceBuilder, TInjects extends string = never> = AstNodeOptions<
|
|
12
|
-
typeof TsParameter<TBuilder, TInjects | Injects>,
|
|
13
|
-
{
|
|
14
|
-
accessModifier?: Nullable<TsAccessModifier>;
|
|
15
|
-
readonly?: Nullable<boolean>;
|
|
16
|
-
}
|
|
17
|
-
>;
|
|
18
|
-
|
|
19
|
-
export class TsConstructorParameter<TBuilder extends SourceBuilder, TInjects extends string = never>
|
|
20
|
-
extends TsParameter<
|
|
21
|
-
TBuilder,
|
|
22
|
-
TInjects | Injects
|
|
23
|
-
> {
|
|
24
|
-
public accessModifier: TsAccessModifier | null;
|
|
25
|
-
public readonly: boolean;
|
|
26
|
-
|
|
27
|
-
constructor(options: Options<TBuilder, TInjects>) {
|
|
28
|
-
super(options);
|
|
29
|
-
this.accessModifier = options.accessModifier ?? null;
|
|
30
|
-
this.readonly = options.readonly ?? false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
protected override onWrite(builder: TBuilder): void {
|
|
34
|
-
builder.append(this.inject.beforeDecorators);
|
|
35
|
-
tsDecorator.write(builder, this.decorators);
|
|
36
|
-
builder.append(this.inject.afterDecorators);
|
|
37
|
-
|
|
38
|
-
builder.append(this.inject.beforeModifiers);
|
|
39
|
-
if (this.accessModifier) builder.append(this.accessModifier, ' ');
|
|
40
|
-
if (this.readonly) builder.append('readonly ');
|
|
41
|
-
builder.append(this.inject.afterModifiers);
|
|
42
|
-
|
|
43
|
-
builder.append(this.inject.beforeName, this.name, this.inject.afterName);
|
|
44
|
-
if (this.optional) builder.append('?');
|
|
45
|
-
|
|
46
|
-
if (this.type) {
|
|
47
|
-
builder.append(': ');
|
|
48
|
-
builder.append(this.inject.beforeType);
|
|
49
|
-
writeTsNode(builder, this.type);
|
|
50
|
-
builder.append(this.inject.afterType);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (this.default) {
|
|
54
|
-
builder.append(' = ');
|
|
55
|
-
builder.append(this.inject.beforeDefault);
|
|
56
|
-
writeTsNode(builder, this.default);
|
|
57
|
-
builder.append(this.inject.afterDefault);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const createConstructorParameter = <TBuilder extends SourceBuilder>(
|
|
63
|
-
name: Options<TBuilder>['name'],
|
|
64
|
-
options?: Prettify<Omit<Options<TBuilder>, 'name'>>,
|
|
65
|
-
): TsConstructorParameter<TBuilder> => new TsConstructorParameter<TBuilder>({ ...options, name });
|
|
66
|
-
|
|
67
|
-
export const tsConstructorParameter: typeof createConstructorParameter & { write: typeof writeTsParameters } = Object
|
|
68
|
-
.assign(createConstructorParameter, {
|
|
69
|
-
write: writeTsParameters,
|
|
70
|
-
});
|