@goast/typescript 0.0.4 → 0.2.0
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/assets/{service → client}/angular/request-builder.ts +6 -2
- package/assets/client/fetch/{url-builder.ts → fetch-client.utils.ts} +15 -0
- package/assets/stubs/easy-network-stub/easy-network-stub.utils.ts +235 -0
- package/cjs/lib/ast/_index.js +108 -0
- package/cjs/lib/ast/common.js +2 -0
- package/cjs/lib/ast/index.js +5 -0
- package/cjs/lib/ast/node.js +10 -0
- package/cjs/lib/ast/nodes/argument.js +20 -0
- package/cjs/lib/ast/nodes/array-type.js +27 -0
- package/cjs/lib/ast/nodes/arrow-function.js +51 -0
- package/cjs/lib/ast/nodes/call.js +26 -0
- package/cjs/lib/ast/nodes/class.js +70 -0
- package/cjs/lib/ast/nodes/constructor-parameter.js +46 -0
- package/cjs/lib/ast/nodes/constructor.js +42 -0
- package/cjs/lib/ast/nodes/decorator.js +38 -0
- package/cjs/lib/ast/nodes/doc-tag.js +64 -0
- package/cjs/lib/ast/nodes/doc.js +57 -0
- package/cjs/lib/ast/nodes/enum-value.js +35 -0
- package/cjs/lib/ast/nodes/enum.js +46 -0
- package/cjs/lib/ast/nodes/export.js +27 -0
- package/cjs/lib/ast/nodes/function-type.js +35 -0
- package/cjs/lib/ast/nodes/function.js +60 -0
- package/cjs/lib/ast/nodes/generic-parameter.js +40 -0
- package/cjs/lib/ast/nodes/indexer.js +32 -0
- package/cjs/lib/ast/nodes/interface.js +60 -0
- package/cjs/lib/ast/nodes/intersection-type.js +44 -0
- package/cjs/lib/ast/nodes/lookup-type.js +30 -0
- package/cjs/lib/ast/nodes/method.js +82 -0
- package/cjs/lib/ast/nodes/object-type.js +24 -0
- package/cjs/lib/ast/nodes/object.js +24 -0
- package/cjs/lib/ast/nodes/parameter.js +45 -0
- package/cjs/lib/ast/nodes/property-accessor.js +128 -0
- package/cjs/lib/ast/nodes/property.js +119 -0
- package/cjs/lib/ast/nodes/reference.js +63 -0
- package/cjs/lib/ast/nodes/string.js +30 -0
- package/cjs/lib/ast/nodes/tuple.js +28 -0
- package/cjs/lib/ast/nodes/type-alias.js +36 -0
- package/cjs/lib/ast/nodes/typeof.js +23 -0
- package/cjs/lib/ast/nodes/types.js +2 -0
- package/cjs/lib/ast/nodes/union-type.js +44 -0
- package/cjs/lib/ast/nodes/variable.js +38 -0
- package/cjs/lib/ast/references/angular.js +12 -0
- package/cjs/lib/ast/references/easy-network-stub.js +8 -0
- package/cjs/lib/ast/references/index.js +7 -0
- package/cjs/lib/ast/references/rxjs.js +9 -0
- package/cjs/lib/ast/references/typescript.js +33 -0
- package/cjs/lib/ast/utils/get-type-script-builder-options.js +19 -0
- package/cjs/lib/ast/utils/to-ts-node.js +24 -0
- package/cjs/lib/ast/utils/write-ts-generic-parameters.js +11 -0
- package/cjs/lib/ast/utils/write-ts-members.js +18 -0
- package/cjs/lib/ast/utils/write-ts-nodes.js +24 -0
- package/cjs/lib/ast/utils/write-ts-parameters.js +14 -0
- package/cjs/lib/config.js +5 -3
- package/cjs/lib/file-builder.js +45 -202
- package/cjs/lib/generators/file-generator.js +2 -18
- package/cjs/lib/generators/index.js +1 -0
- package/cjs/lib/generators/models/model-generator.js +144 -205
- package/cjs/lib/generators/models/models-generator.js +12 -26
- package/cjs/lib/generators/models/models.js +1 -1
- package/cjs/lib/generators/services/angular-services/angular-service-generator.js +183 -306
- package/cjs/lib/generators/services/angular-services/angular-services-generator.js +168 -76
- package/cjs/lib/generators/services/angular-services/models.js +10 -1
- package/cjs/lib/generators/services/angular-services/refs.js +24 -0
- package/cjs/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +169 -0
- package/cjs/lib/generators/services/easy-network-stub/easy-network-stubs-generator.js +73 -0
- package/cjs/lib/generators/services/easy-network-stub/index.js +6 -0
- package/cjs/lib/generators/services/easy-network-stub/models.js +10 -0
- package/cjs/lib/generators/services/easy-network-stub/refs.js +21 -0
- package/cjs/lib/generators/services/fetch-clients/fetch-client-generator.js +126 -180
- package/cjs/lib/generators/services/fetch-clients/fetch-clients-generator.js +5 -1
- package/cjs/lib/generators/services/fetch-clients/refs.js +17 -0
- package/cjs/lib/import-collection.js +18 -19
- package/esm/lib/ast/_index.js +37 -0
- package/esm/lib/ast/common.js +1 -0
- package/esm/lib/ast/index.js +2 -0
- package/esm/lib/ast/node.js +6 -0
- package/esm/lib/ast/nodes/argument.js +16 -0
- package/esm/lib/ast/nodes/array-type.js +23 -0
- package/esm/lib/ast/nodes/arrow-function.js +47 -0
- package/esm/lib/ast/nodes/call.js +22 -0
- package/esm/lib/ast/nodes/class.js +66 -0
- package/esm/lib/ast/nodes/constructor-parameter.js +42 -0
- package/esm/lib/ast/nodes/constructor.js +38 -0
- package/esm/lib/ast/nodes/decorator.js +34 -0
- package/esm/lib/ast/nodes/doc-tag.js +60 -0
- package/esm/lib/ast/nodes/doc.js +53 -0
- package/esm/lib/ast/nodes/enum-value.js +31 -0
- package/esm/lib/ast/nodes/enum.js +42 -0
- package/esm/lib/ast/nodes/export.js +22 -0
- package/esm/lib/ast/nodes/function-type.js +31 -0
- package/esm/lib/ast/nodes/function.js +56 -0
- package/esm/lib/ast/nodes/generic-parameter.js +36 -0
- package/esm/lib/ast/nodes/indexer.js +28 -0
- package/esm/lib/ast/nodes/interface.js +56 -0
- package/esm/lib/ast/nodes/intersection-type.js +40 -0
- package/esm/lib/ast/nodes/lookup-type.js +26 -0
- package/esm/lib/ast/nodes/method.js +77 -0
- package/esm/lib/ast/nodes/object-type.js +20 -0
- package/esm/lib/ast/nodes/object.js +20 -0
- package/esm/lib/ast/nodes/parameter.js +41 -0
- package/esm/lib/ast/nodes/property-accessor.js +121 -0
- package/esm/lib/ast/nodes/property.js +113 -0
- package/esm/lib/ast/nodes/reference.js +59 -0
- package/esm/lib/ast/nodes/string.js +26 -0
- package/esm/lib/ast/nodes/tuple.js +24 -0
- package/esm/lib/ast/nodes/type-alias.js +32 -0
- package/esm/lib/ast/nodes/typeof.js +18 -0
- package/esm/lib/ast/nodes/types.js +1 -0
- package/esm/lib/ast/nodes/union-type.js +40 -0
- package/esm/lib/ast/nodes/variable.js +34 -0
- package/esm/lib/ast/references/angular.js +9 -0
- package/esm/lib/ast/references/easy-network-stub.js +5 -0
- package/esm/lib/ast/references/index.js +5 -0
- package/esm/lib/ast/references/rxjs.js +6 -0
- package/esm/lib/ast/references/typescript.js +30 -0
- package/esm/lib/ast/utils/get-type-script-builder-options.js +15 -0
- package/esm/lib/ast/utils/to-ts-node.js +20 -0
- package/esm/lib/ast/utils/write-ts-generic-parameters.js +7 -0
- package/esm/lib/ast/utils/write-ts-members.js +14 -0
- package/esm/lib/ast/utils/write-ts-nodes.js +19 -0
- package/esm/lib/ast/utils/write-ts-parameters.js +10 -0
- package/esm/lib/config.js +5 -3
- package/esm/lib/file-builder.js +44 -202
- package/esm/lib/generators/file-generator.js +2 -18
- package/esm/lib/generators/index.js +1 -0
- package/esm/lib/generators/models/model-generator.js +149 -210
- package/esm/lib/generators/models/models-generator.js +15 -29
- package/esm/lib/generators/models/models.js +1 -1
- package/esm/lib/generators/services/angular-services/angular-service-generator.js +186 -309
- package/esm/lib/generators/services/angular-services/angular-services-generator.js +170 -78
- package/esm/lib/generators/services/angular-services/models.js +10 -1
- package/esm/lib/generators/services/angular-services/refs.js +20 -0
- package/esm/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +165 -0
- package/esm/lib/generators/services/easy-network-stub/easy-network-stubs-generator.js +69 -0
- package/esm/lib/generators/services/easy-network-stub/index.js +3 -0
- package/esm/lib/generators/services/easy-network-stub/models.js +7 -0
- package/esm/lib/generators/services/easy-network-stub/refs.js +17 -0
- package/esm/lib/generators/services/fetch-clients/fetch-client-generator.js +128 -182
- package/esm/lib/generators/services/fetch-clients/fetch-clients-generator.js +5 -1
- package/esm/lib/generators/services/fetch-clients/refs.js +13 -0
- package/esm/lib/import-collection.js +17 -18
- package/package.json +6 -6
- package/types/lib/ast/_index.d.ts +38 -0
- package/types/lib/ast/common.d.ts +1 -0
- package/types/lib/ast/index.d.ts +1 -0
- package/types/lib/ast/node.d.ts +4 -0
- package/types/lib/ast/nodes/argument.d.ts +17 -0
- package/types/lib/ast/nodes/array-type.d.ts +19 -0
- package/types/lib/ast/nodes/arrow-function.d.ts +29 -0
- package/types/lib/ast/nodes/call.d.ts +20 -0
- package/types/lib/ast/nodes/class.d.ts +41 -0
- package/types/lib/ast/nodes/constructor-parameter.d.ts +19 -0
- package/types/lib/ast/nodes/constructor.d.ts +25 -0
- package/types/lib/ast/nodes/decorator.d.ts +22 -0
- package/types/lib/ast/nodes/doc-tag.d.ts +73 -0
- package/types/lib/ast/nodes/doc.d.ts +28 -0
- package/types/lib/ast/nodes/enum-value.d.ts +21 -0
- package/types/lib/ast/nodes/enum.d.ts +26 -0
- package/types/lib/ast/nodes/export.d.ts +19 -0
- package/types/lib/ast/nodes/function-type.d.ts +23 -0
- package/types/lib/ast/nodes/function.d.ts +35 -0
- package/types/lib/ast/nodes/generic-parameter.d.ts +25 -0
- package/types/lib/ast/nodes/indexer.d.ts +23 -0
- package/types/lib/ast/nodes/interface.d.ts +36 -0
- package/types/lib/ast/nodes/intersection-type.d.ts +17 -0
- package/types/lib/ast/nodes/lookup-type.d.ts +19 -0
- package/types/lib/ast/nodes/method.d.ts +45 -0
- package/types/lib/ast/nodes/object-type.d.ts +20 -0
- package/types/lib/ast/nodes/object.d.ts +19 -0
- package/types/lib/ast/nodes/parameter.d.ts +28 -0
- package/types/lib/ast/nodes/property-accessor.d.ts +53 -0
- package/types/lib/ast/nodes/property.d.ts +84 -0
- package/types/lib/ast/nodes/reference.d.ts +46 -0
- package/types/lib/ast/nodes/string.d.ts +18 -0
- package/types/lib/ast/nodes/tuple.d.ts +17 -0
- package/types/lib/ast/nodes/type-alias.d.ts +27 -0
- package/types/lib/ast/nodes/typeof.d.ts +18 -0
- package/types/lib/ast/nodes/types.d.ts +18 -0
- package/types/lib/ast/nodes/union-type.d.ts +17 -0
- package/types/lib/ast/nodes/variable.d.ts +28 -0
- package/types/lib/ast/references/angular.d.ts +37 -0
- package/types/lib/ast/references/easy-network-stub.d.ts +26 -0
- package/types/lib/ast/references/index.d.ts +3 -0
- package/types/lib/ast/references/rxjs.d.ts +30 -0
- package/types/lib/ast/references/typescript.d.ts +133 -0
- package/types/lib/ast/utils/get-type-script-builder-options.d.ts +3 -0
- package/types/lib/ast/utils/to-ts-node.d.ts +8 -0
- package/types/lib/ast/utils/write-ts-generic-parameters.d.ts +3 -0
- package/types/lib/ast/utils/write-ts-members.d.ts +5 -0
- package/types/lib/ast/utils/write-ts-nodes.d.ts +6 -0
- package/types/lib/ast/utils/write-ts-parameters.d.ts +3 -0
- package/types/lib/common-results.d.ts +4 -0
- package/types/lib/config.d.ts +5 -2
- package/types/lib/file-builder.d.ts +21 -98
- package/types/lib/generators/file-generator.d.ts +3 -7
- package/types/lib/generators/index.d.ts +1 -0
- package/types/lib/generators/models/model-generator.d.ts +18 -23
- package/types/lib/generators/models/models-generator.d.ts +4 -5
- package/types/lib/generators/models/models.d.ts +4 -4
- package/types/lib/generators/services/angular-services/angular-service-generator.d.ts +15 -35
- package/types/lib/generators/services/angular-services/angular-services-generator.d.ts +12 -10
- package/types/lib/generators/services/angular-services/models.d.ts +67 -22
- package/types/lib/generators/services/angular-services/refs.d.ts +34 -0
- package/types/lib/generators/services/easy-network-stub/easy-network-stub-generator.d.ts +32 -0
- package/types/lib/generators/services/easy-network-stub/easy-network-stubs-generator.d.ts +25 -0
- package/types/lib/generators/services/easy-network-stub/index.d.ts +3 -0
- package/types/lib/generators/services/easy-network-stub/models.d.ts +51 -0
- package/types/lib/generators/services/easy-network-stub/refs.d.ts +49 -0
- package/types/lib/generators/services/fetch-clients/fetch-client-generator.d.ts +11 -22
- package/types/lib/generators/services/fetch-clients/models.d.ts +4 -1
- package/types/lib/generators/services/fetch-clients/refs.d.ts +23 -0
- package/types/lib/import-collection.d.ts +13 -5
- package/assets/client/fetch/types.ts +0 -9
- package/assets/service/angular/api-configuration.ts +0 -18
- package/assets/service/angular/base-service.ts +0 -29
- package/assets/service/angular/response-handlers.ts +0 -127
- package/assets/service/angular/strict-http-response.ts +0 -8
|
@@ -3,6 +3,10 @@ export type TypeScriptComponentOutput = {
|
|
|
3
3
|
filePath?: string;
|
|
4
4
|
imports: TypeScriptImport[];
|
|
5
5
|
};
|
|
6
|
+
export type TypeScriptExportOutput = {
|
|
7
|
+
component: string;
|
|
8
|
+
filePath: string;
|
|
9
|
+
};
|
|
6
10
|
export type TypeScriptImportKind = 'module' | 'file';
|
|
7
11
|
export type TypeScriptImport = {
|
|
8
12
|
kind: TypeScriptImportKind;
|
package/types/lib/config.d.ts
CHANGED
|
@@ -2,11 +2,14 @@ import { DefaultGenerationProviderConfig, OpenApiGeneratorConfig, StringCasing,
|
|
|
2
2
|
import { ImportModuleTransformer } from './utils';
|
|
3
3
|
export type TypeScriptGeneratorConfig = OpenApiGeneratorConfig & {
|
|
4
4
|
importModuleTransformer: ImportModuleTransformer;
|
|
5
|
+
fileNameCasing: StringCasing | StringCasingWithOptions;
|
|
5
6
|
typeNameCasing: StringCasing | StringCasingWithOptions;
|
|
6
|
-
|
|
7
|
+
functionNameCasing: StringCasing | StringCasingWithOptions;
|
|
7
8
|
propertyNameCasing: StringCasing | StringCasingWithOptions;
|
|
8
9
|
enumValueNameCasing: StringCasing | StringCasingWithOptions;
|
|
9
|
-
|
|
10
|
+
constantNameCasing: StringCasing | StringCasingWithOptions;
|
|
11
|
+
paramNameCasing: StringCasing | StringCasingWithOptions;
|
|
12
|
+
genericParamNameCasing: StringCasing | StringCasingWithOptions;
|
|
10
13
|
preferUnknown: boolean;
|
|
11
14
|
useSingleQuotes: boolean;
|
|
12
15
|
};
|
|
@@ -1,110 +1,33 @@
|
|
|
1
|
-
import { Nullable, SourceBuilder
|
|
1
|
+
import { AppendParam, AppendValue, Nullable, SourceBuilder } from '@goast/core';
|
|
2
|
+
import { TsNode } from './ast/node';
|
|
2
3
|
import { TypeScriptGeneratorConfig } from './config';
|
|
3
4
|
import { TypeScriptModelGeneratorOutput } from './generators';
|
|
4
5
|
import { ImportExportCollection } from './import-collection';
|
|
5
|
-
export
|
|
6
|
+
export type TypeScriptAppends<TAdditionalAppends> = TsNode<TypeScriptFileBuilder> | TAdditionalAppends;
|
|
7
|
+
export type TypeScriptAppendParam<TBuilder extends TypeScriptFileBuilder, TAdditionalAppends> = AppendParam<TBuilder, TypeScriptAppends<TAdditionalAppends>>;
|
|
8
|
+
export declare function isTypeScriptAppendValue<TBuilder extends TypeScriptFileBuilder = TypeScriptFileBuilder>(value: unknown): value is AppendValue<TBuilder>;
|
|
9
|
+
export declare class TypeScriptFileBuilder<TAdditionalAppends = never> extends SourceBuilder<TypeScriptAppends<TAdditionalAppends>> {
|
|
6
10
|
readonly filePath: string | undefined;
|
|
7
11
|
readonly imports: ImportExportCollection;
|
|
8
12
|
get options(): TypeScriptGeneratorConfig;
|
|
9
|
-
constructor(filePath
|
|
13
|
+
constructor(filePath?: string, options?: TypeScriptGeneratorConfig);
|
|
10
14
|
addImport(name: string, moduleNameOrfilePath: string): this;
|
|
11
15
|
addExport(name: string, filePath: string): this;
|
|
12
16
|
clear(): void;
|
|
13
17
|
toString(addPadding?: boolean): string;
|
|
14
|
-
|
|
15
|
-
appendParameter(parameter: Nullable<TextOrBuilderFn<this>> | TypeScriptParameterOptions): this | undefined;
|
|
16
|
-
appendParameters(...parameters: (Nullable<TextOrBuilderFn<this>> | TypeScriptParameterOptions)[]): this;
|
|
17
|
-
appendObjectLiteral(...properties: Nullable<TextOrBuilderFn<this>>[]): this;
|
|
18
|
-
appendArrayLiteral(...items: Nullable<TextOrBuilderFn<this>>[]): this;
|
|
19
|
-
appendCodeBlock(...content: Nullable<TextOrBuilderFn<this>>[]): this;
|
|
20
|
-
appendComment(style: '/***/' | '/**/' | '//', comment: Nullable<TextOrBuilderFn<this>>): this;
|
|
21
|
-
appendDocumentation(documentation: Nullable<TextOrBuilderFn<this>>): this;
|
|
18
|
+
protected appendSingle(value: TypeScriptAppendParam<this, TAdditionalAppends>): void;
|
|
22
19
|
appendModelUsage(type: TypeScriptModelGeneratorOutput): this;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
writeToFile(filePath?: string): void;
|
|
21
|
+
static generate(options: {
|
|
22
|
+
filePath: string;
|
|
23
|
+
logName?: Nullable<string>;
|
|
24
|
+
options?: TypeScriptGeneratorConfig;
|
|
25
|
+
generator: (builder: TypeScriptFileBuilder) => void;
|
|
26
|
+
}): void;
|
|
27
|
+
static tryGenerate({ filePath, generator, options, logName, }: {
|
|
28
|
+
filePath: Nullable<string>;
|
|
29
|
+
logName?: Nullable<string>;
|
|
30
|
+
options?: TypeScriptGeneratorConfig;
|
|
31
|
+
generator: (builder: TypeScriptFileBuilder) => void;
|
|
32
|
+
}): void;
|
|
32
33
|
}
|
|
33
|
-
export type TypeScriptTypeDeclarationOptions = {
|
|
34
|
-
documentation?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
35
|
-
omitExport?: boolean;
|
|
36
|
-
name: string;
|
|
37
|
-
type: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
38
|
-
};
|
|
39
|
-
export type TypeScriptExternalTypeOptions = {
|
|
40
|
-
name: string;
|
|
41
|
-
module: string;
|
|
42
|
-
};
|
|
43
|
-
export type TypeScriptAnnotationOptions = {
|
|
44
|
-
name: string;
|
|
45
|
-
module?: string;
|
|
46
|
-
args?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>[];
|
|
47
|
-
};
|
|
48
|
-
export type TypeScriptClassOptions = {
|
|
49
|
-
documentation?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
50
|
-
annotations?: TypeScriptAnnotationOptions[];
|
|
51
|
-
omitExport?: boolean;
|
|
52
|
-
isAbstract?: boolean;
|
|
53
|
-
name: string;
|
|
54
|
-
genericArguments?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>[];
|
|
55
|
-
extends?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
56
|
-
implements?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>[];
|
|
57
|
-
body?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
58
|
-
};
|
|
59
|
-
export type TypeScriptConstructorOptions = {
|
|
60
|
-
documentation?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
61
|
-
annotations?: TypeScriptAnnotationOptions[];
|
|
62
|
-
parameters?: (Nullable<TextOrBuilderFn<TypeScriptFileBuilder>> | TypeScriptParameterOptions)[];
|
|
63
|
-
body?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
64
|
-
};
|
|
65
|
-
export type TypeScriptParameterOptions = {
|
|
66
|
-
name: string;
|
|
67
|
-
isOptional?: boolean;
|
|
68
|
-
type?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>> | TypeScriptExternalTypeOptions;
|
|
69
|
-
genericArguments?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>[];
|
|
70
|
-
defaultValue?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
71
|
-
};
|
|
72
|
-
export type TypeScriptMethodOptions = {
|
|
73
|
-
documentation?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
74
|
-
annotations?: TypeScriptAnnotationOptions[];
|
|
75
|
-
accessibility?: 'public' | 'protected' | 'private';
|
|
76
|
-
isAbstract?: boolean;
|
|
77
|
-
isStatic?: boolean;
|
|
78
|
-
isAsync?: boolean;
|
|
79
|
-
name: string;
|
|
80
|
-
genericArguments?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>[];
|
|
81
|
-
parameters?: (Nullable<TextOrBuilderFn<TypeScriptFileBuilder>> | TypeScriptParameterOptions)[];
|
|
82
|
-
returnType?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
83
|
-
body?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
84
|
-
};
|
|
85
|
-
export type TypeScriptPropertyOptions = {
|
|
86
|
-
documentation?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
87
|
-
annotations?: TypeScriptAnnotationOptions[];
|
|
88
|
-
accessibility?: 'public' | 'protected' | 'private';
|
|
89
|
-
isAbstract?: boolean;
|
|
90
|
-
isStatic?: boolean;
|
|
91
|
-
isReadonly?: boolean;
|
|
92
|
-
isOptional?: boolean;
|
|
93
|
-
kind?: 'property' | 'getter' | 'setter' | 'getter-setter';
|
|
94
|
-
name: string;
|
|
95
|
-
type?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
96
|
-
initializer?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
97
|
-
getter?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
98
|
-
getterAnnotations?: TypeScriptAnnotationOptions[];
|
|
99
|
-
setter?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
100
|
-
setterAnnotations?: TypeScriptAnnotationOptions[];
|
|
101
|
-
};
|
|
102
|
-
export type TypeScriptFunctionOptions = {
|
|
103
|
-
kind?: 'function' | 'arrow-function';
|
|
104
|
-
isAsync?: boolean;
|
|
105
|
-
name?: string;
|
|
106
|
-
parameters: (Nullable<TextOrBuilderFn<TypeScriptFileBuilder>> | TypeScriptParameterOptions)[];
|
|
107
|
-
returnType?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
108
|
-
body?: Nullable<TextOrBuilderFn<TypeScriptFileBuilder>>;
|
|
109
|
-
singleLine?: boolean;
|
|
110
|
-
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { OpenApiGenerationProviderContext, OpenApiGeneratorInput } from '@goast/core';
|
|
1
|
+
import { OpenApiGenerationProviderContext, OpenApiGeneratorInput, SourceBuilder } from '@goast/core';
|
|
2
|
+
import { ts } from '../ast';
|
|
2
3
|
import { TypeScriptGeneratorConfig } from '../config';
|
|
3
4
|
export declare abstract class TypeScriptFileGenerator<TContext extends OpenApiGenerationProviderContext<OpenApiGeneratorInput, TypeScriptGeneratorConfig>, TOutput> {
|
|
4
5
|
abstract generate(context: TContext): TOutput;
|
|
5
|
-
protected getAnyType(context: TContext):
|
|
6
|
-
protected toTypeName(context: TContext, name: string): string;
|
|
7
|
-
protected toMethodName(context: TContext, name: string): string;
|
|
8
|
-
protected toPropertyName(context: TContext, name: string, keepCasing?: boolean): string;
|
|
9
|
-
protected toEnumValueName(context: TContext, name: string): string;
|
|
10
|
-
protected toStringLiteral(context: TContext, text: string): string;
|
|
6
|
+
protected getAnyType(context: TContext): ts.Reference<SourceBuilder>;
|
|
11
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ApiSchema,
|
|
1
|
+
import { ApiSchema, AppendValueGroup, ArrayLikeApiSchema, CombinedLikeApiSchema, Nullable, ObjectLikeApiSchema } from '@goast/core';
|
|
2
2
|
import { TypeScriptModelGeneratorContext, TypeScriptModelGeneratorOutput } from './models';
|
|
3
|
+
import { ts } from '../../ast';
|
|
3
4
|
import { TypeScriptFileBuilder } from '../../file-builder';
|
|
4
5
|
import { TypeScriptFileGenerator } from '../file-generator';
|
|
5
6
|
type Context = TypeScriptModelGeneratorContext;
|
|
@@ -10,31 +11,25 @@ export interface TypeScriptModelGenerator<TOutput extends Output = Output> {
|
|
|
10
11
|
}
|
|
11
12
|
export declare class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator<Context, Output> implements TypeScriptModelGenerator {
|
|
12
13
|
generate(ctx: Context): Output;
|
|
13
|
-
protected
|
|
14
|
-
protected
|
|
15
|
-
protected
|
|
16
|
-
protected
|
|
17
|
-
protected
|
|
18
|
-
protected
|
|
19
|
-
protected
|
|
20
|
-
protected
|
|
21
|
-
protected
|
|
22
|
-
protected
|
|
23
|
-
protected
|
|
24
|
-
protected
|
|
25
|
-
protected generateCombinedType(ctx: Context, builder: Builder, schema: CombinedLikeApiSchema): void;
|
|
26
|
-
protected generateOneOfType(ctx: Context, builder: Builder, schema: ApiSchema<'oneOf'>): void;
|
|
27
|
-
protected generateMultiType(ctx: Context, builder: Builder, schema: ApiSchema<'multi-type'>): void;
|
|
28
|
-
protected generateObjectType(ctx: Context, builder: Builder, schema: ObjectLikeApiSchema): void;
|
|
29
|
-
protected generateObjectTypeProperties(ctx: Context, builder: Builder, schema: ObjectLikeApiSchema): void;
|
|
30
|
-
protected generateObjectTypeAdditionalProperties(ctx: Context, builder: Builder, schema: ObjectLikeApiSchema): void;
|
|
31
|
-
protected generateEnumType(ctx: Context, builder: Builder, schema: ApiSchema): void;
|
|
32
|
-
protected generateTypeDocumentation(ctx: Context, builder: Builder): void;
|
|
33
|
-
protected generatePropertyDocumentation(ctx: Context, builder: Builder, property: ApiSchemaProperty): void;
|
|
34
|
-
protected generateDocumentation(ctx: Context, builder: Builder, schema: ApiSchema): void;
|
|
14
|
+
protected getFileContent(ctx: Context): AppendValueGroup<Builder>;
|
|
15
|
+
protected getEnum(ctx: Context): ts.Enum<import("@goast/core").SourceBuilder<never>, never>;
|
|
16
|
+
protected getInterface(ctx: Context, schema: ObjectLikeApiSchema): ts.Interface<Builder, never>;
|
|
17
|
+
protected getTypeAlias(ctx: Context, schema: ApiSchema): ts.TypeAlias<Builder>;
|
|
18
|
+
protected getIndexer(ctx: Context, schema: ObjectLikeApiSchema): ts.Indexer<Builder, never> | null;
|
|
19
|
+
protected getProperties(ctx: Context, schema: ObjectLikeApiSchema): (import("../../ast/nodes/property").TsAccessorProperty<Builder, ""> | import("../../ast/nodes/property").TsSimpleProperty<Builder, "">)[];
|
|
20
|
+
protected getType(ctx: Context, schema: Nullable<ApiSchema>, skipSchemas?: boolean): ts.Type<Builder> | null;
|
|
21
|
+
protected getArrayType(ctx: Context, schema: ArrayLikeApiSchema): ts.Type<Builder>;
|
|
22
|
+
protected getObjectType(ctx: Context, schema: ObjectLikeApiSchema): ts.Type<Builder>;
|
|
23
|
+
protected getCombinedType(ctx: Context, schema: CombinedLikeApiSchema): ts.Type<Builder>;
|
|
24
|
+
protected getOneOfType(ctx: Context, schema: ApiSchema<'oneOf'>): ts.Type<Builder>;
|
|
25
|
+
protected getMultiType(ctx: Context, schema: ApiSchema<'multi-type'>): ts.Type<Builder>;
|
|
35
26
|
protected shouldGenerateTypeDeclaration(ctx: Context, schema: ApiSchema): boolean;
|
|
36
27
|
protected resolveInterfaceSchema(ctx: Context): ApiSchema<'object'> | undefined;
|
|
37
28
|
protected getDeclarationTypeName(ctx: Context, schema: ApiSchema): string;
|
|
29
|
+
protected getDiscriminatorGenericParamName(ctx: Context, schema: ApiSchema): string;
|
|
30
|
+
protected getInheritedSchemas(ctx: Context, schema: ApiSchema): (ApiSchema<import("@goast/core").ApiSchemaKind> & {
|
|
31
|
+
discriminator: import("@goast/core").ApiSchemaDiscriminator;
|
|
32
|
+
})[];
|
|
38
33
|
protected getFilePath(ctx: Context, schema: ApiSchema): string;
|
|
39
34
|
}
|
|
40
35
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiSchema, OpenApiGeneratorContext, OpenApiSchemasGenerationProviderBase, Factory } from '@goast/core';
|
|
1
|
+
import { ApiSchema, OpenApiGeneratorContext, OpenApiSchemasGenerationProviderBase, Factory, AppendValueGroup } from '@goast/core';
|
|
2
2
|
import { TypeScriptModelGenerator } from './model-generator';
|
|
3
3
|
import { TypeScriptModelGeneratorOutput, TypeScriptModelsGeneratorConfig, TypeScriptModelsGeneratorContext, TypeScriptModelsGeneratorInput, TypeScriptModelsGeneratorOutput } from './models';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../file-builder';
|
|
@@ -15,9 +15,8 @@ export declare class TypeScriptModelsGenerator extends OpenApiSchemasGenerationP
|
|
|
15
15
|
onGenerate(ctx: Context): Output;
|
|
16
16
|
protected generateSchema(ctx: Context, schema: ApiSchema): SchemaOutput;
|
|
17
17
|
protected addSchemaResult(ctx: Context, schema: ApiSchema, result: SchemaOutput): void;
|
|
18
|
-
protected generateIndexFile(ctx: Context): string |
|
|
19
|
-
protected getIndexFilePath(ctx: Context): string;
|
|
20
|
-
protected
|
|
21
|
-
protected generateIndexFileContent(ctx: Context, builder: TypeScriptFileBuilder): void;
|
|
18
|
+
protected generateIndexFile(ctx: Context): string | null;
|
|
19
|
+
protected getIndexFilePath(ctx: Context): string | null;
|
|
20
|
+
protected getIndexFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
22
21
|
}
|
|
23
22
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { ApiSchema, DefaultGenerationProviderConfig, OpenApiSchemasGenerationProviderContext, Nullable
|
|
1
|
+
import { ApiSchema, DefaultGenerationProviderConfig, OpenApiSchemasGenerationProviderContext, Nullable } from '@goast/core';
|
|
2
2
|
import { TypeScriptComponentOutput } from '../../common-results';
|
|
3
3
|
import { TypeScriptGeneratorConfig } from '../../config';
|
|
4
4
|
export type TypeScriptModelGeneratorConfig = TypeScriptGeneratorConfig & {
|
|
5
|
-
fileNameCasing: StringCasing | StringCasingWithOptions;
|
|
6
|
-
typeNameCasing: StringCasing | StringCasingWithOptions;
|
|
7
5
|
enumGeneration: 'union' | 'prefer-enum';
|
|
8
6
|
immutableTypes: boolean;
|
|
9
7
|
inlineUnnamedSchemas: boolean;
|
|
@@ -20,7 +18,9 @@ export type TypeScriptModelsGeneratorOutput = {
|
|
|
20
18
|
models: {
|
|
21
19
|
[schemaId: string]: TypeScriptModelGeneratorOutput;
|
|
22
20
|
};
|
|
23
|
-
|
|
21
|
+
indexFiles: {
|
|
22
|
+
models: Nullable<string>;
|
|
23
|
+
};
|
|
24
24
|
};
|
|
25
25
|
export type TypeScriptModelGeneratorOutput = TypeScriptComponentOutput;
|
|
26
26
|
export type TypeScriptModelsGeneratorContext = OpenApiSchemasGenerationProviderContext<TypeScriptModelsGeneratorInput, TypeScriptModelsGeneratorOutput, TypeScriptModelsGeneratorConfig, TypeScriptModelGeneratorOutput>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { ApiEndpoint,
|
|
1
|
+
import { ApiEndpoint, ApiSchema, AppendValueGroup } from '@goast/core';
|
|
2
2
|
import { TypeScriptAngularServiceGeneratorContext, TypeScriptAngularServiceGeneratorOutput } from './models';
|
|
3
|
-
import {
|
|
3
|
+
import { ts } from '../../../ast';
|
|
4
|
+
import { TypeScriptExportOutput } from '../../../common-results';
|
|
5
|
+
import { TypeScriptFileBuilder } from '../../../file-builder';
|
|
4
6
|
import { TypeScriptFileGenerator } from '../../file-generator';
|
|
5
7
|
type Context = TypeScriptAngularServiceGeneratorContext;
|
|
6
8
|
type Output = TypeScriptAngularServiceGeneratorOutput;
|
|
@@ -9,45 +11,23 @@ export interface TypeScriptAngularServiceGenerator<TOutput extends Output = Outp
|
|
|
9
11
|
generate(ctx: Context): TOutput;
|
|
10
12
|
}
|
|
11
13
|
export declare class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGenerator<Context, Output> implements TypeScriptAngularServiceGenerator {
|
|
12
|
-
protected readonly httpClientType: TypeScriptExternalTypeOptions;
|
|
13
|
-
protected readonly httpContextType: TypeScriptExternalTypeOptions;
|
|
14
|
-
protected readonly httpResponseType: TypeScriptExternalTypeOptions;
|
|
15
|
-
protected readonly observableType: TypeScriptExternalTypeOptions;
|
|
16
|
-
protected readonly rxjsFilterType: TypeScriptExternalTypeOptions;
|
|
17
|
-
protected readonly rxjsMapType: TypeScriptExternalTypeOptions;
|
|
18
|
-
protected getApiConfigurationType(ctx: Context): TypeScriptExternalTypeOptions;
|
|
19
|
-
protected getBaseServiceType(ctx: Context): TypeScriptExternalTypeOptions;
|
|
20
|
-
protected getStrictHttpResponseType(ctx: Context): TypeScriptExternalTypeOptions;
|
|
21
|
-
protected getRequestBuilderType(ctx: Context): TypeScriptExternalTypeOptions;
|
|
22
14
|
generate(ctx: Context): Output;
|
|
23
|
-
protected
|
|
24
|
-
protected
|
|
25
|
-
protected
|
|
26
|
-
protected
|
|
27
|
-
protected
|
|
28
|
-
protected
|
|
29
|
-
protected
|
|
30
|
-
protected generateEndpointPathProperty(ctx: Context, builder: Builder, endpoint: ApiEndpoint): void;
|
|
31
|
-
protected generateEndpointResponseMethod(ctx: Context, builder: Builder, endpoint: ApiEndpoint): void;
|
|
32
|
-
protected generateEndpointResponseMethodContent(ctx: Context, builder: Builder, endpoint: ApiEndpoint): void;
|
|
33
|
-
protected generateEndpointMethod(ctx: Context, builder: Builder, endpoint: ApiEndpoint): void;
|
|
34
|
-
protected generateEndpointMethodContent(ctx: Context, builder: Builder, endpoint: ApiEndpoint): void;
|
|
35
|
-
protected getClassOptions(ctx: Context): TypeScriptClassOptions;
|
|
36
|
-
protected getConstructorOptions(ctx: Context): TypeScriptConstructorOptions;
|
|
37
|
-
protected getEndpointPathPropertyOptions(ctx: Context, endpoint: ApiEndpoint): TypeScriptPropertyOptions;
|
|
38
|
-
protected getEndpointMethodParams(ctx: Context, endpoint: ApiEndpoint): (TextOrBuilderFn<Builder> | TypeScriptParameterOptions)[];
|
|
39
|
-
protected generateEndpointSuccessResponseSchema(ctx: Context, builder: Builder, endpoint: ApiEndpoint): void;
|
|
40
|
-
protected getEndpointResponseMethodOptions(ctx: Context, endpoint: ApiEndpoint): TypeScriptMethodOptions;
|
|
41
|
-
protected getEndpointMethodOptions(ctx: Context, endpoint: ApiEndpoint): TypeScriptMethodOptions;
|
|
15
|
+
protected generateResponseModels(ctx: Context): Record<string, TypeScriptExportOutput>;
|
|
16
|
+
protected getResponseModelFileContent(ctx: Context, endpoint: ApiEndpoint): AppendValueGroup<Builder>;
|
|
17
|
+
protected getEndpointStatusCodes(ctx: Context, endpoint: ApiEndpoint): Record<number, ts.Type<Builder>>;
|
|
18
|
+
protected getServiceFileContent(ctx: Context): AppendValueGroup<Builder>;
|
|
19
|
+
protected getEndpointParamsType(ctx: Context, endpoint: ApiEndpoint): ts.TypeAlias<Builder>;
|
|
20
|
+
protected getClass(ctx: Context): ts.Class<Builder>;
|
|
21
|
+
protected getEndpointMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
42
22
|
protected getEndpointSuccessResponse(ctx: Context, endpoint: ApiEndpoint): import("@goast/core").ApiResponse | undefined;
|
|
43
23
|
protected getServiceClassName(ctx: Context): string;
|
|
44
|
-
protected
|
|
24
|
+
protected getResponseModelName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
45
25
|
protected getEndpointParamsTypeName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
46
26
|
protected getEndpointPathPropertyName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
47
27
|
protected getEndpointMethodName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
48
|
-
protected getEndpointResponseMethodName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
49
28
|
protected getServiceFilePath(ctx: Context): string;
|
|
50
|
-
protected
|
|
51
|
-
protected
|
|
29
|
+
protected getResponseModelFilePath(ctx: Context): string;
|
|
30
|
+
protected hasEndpointParams(ctx: Context, endpoint: ApiEndpoint): boolean;
|
|
31
|
+
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, fallback?: ts.Type<Builder>): ts.Type<Builder>;
|
|
52
32
|
}
|
|
53
33
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiService, Factory, OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
|
|
1
|
+
import { ApiService, AppendValueGroup, Factory, OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
|
|
2
2
|
import { TypeScriptAngularServiceGenerator } from './angular-service-generator';
|
|
3
3
|
import { TypeScriptAngularServicesGeneratorInput, TypeScriptAngularServicesGeneratorOutput, TypeScriptAngularServicesGeneratorConfig, TypeScriptAngularServiceGeneratorOutput, TypeScriptAngularServicesGeneratorContext } from './models';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder';
|
|
@@ -15,15 +15,17 @@ export declare class TypeScriptAngularServicesGenerator extends OpenApiServicesG
|
|
|
15
15
|
onGenerate(ctx: Context): Output;
|
|
16
16
|
protected generateService(ctx: Context, service: ApiService): ServiceOutput;
|
|
17
17
|
protected addServiceResult(ctx: Context, service: ApiService, result: ServiceOutput): void;
|
|
18
|
-
protected
|
|
19
|
-
protected
|
|
20
|
-
protected
|
|
21
|
-
protected
|
|
22
|
-
protected
|
|
23
|
-
protected getResponseModelsIndexFilePath(ctx: Context): string;
|
|
24
|
-
protected shouldGenerateResponseModelsIndexFile(ctx: Context): boolean;
|
|
25
|
-
protected generateResponseModelsIndexFileContent(ctx: Context, builder: TypeScriptFileBuilder): void;
|
|
26
|
-
protected copyUtilsFiles(ctx: Context): void;
|
|
18
|
+
protected generateUtilsFiles(ctx: Context): void;
|
|
19
|
+
protected getApiConfigurationFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
20
|
+
protected getApiBaseServiceFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
21
|
+
protected getHttpStatusCodeFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
22
|
+
protected getProvideFnFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
27
23
|
protected getRootUrl(ctx: Context): string;
|
|
24
|
+
protected generateIndexFiles(ctx: Context): Output['indexFiles'];
|
|
25
|
+
protected getServicesIndexFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
26
|
+
protected getResponseModelsIndexFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
27
|
+
protected getServicesIndexFilePath(ctx: Context): string | null;
|
|
28
|
+
protected getResponseModelsIndexFilePath(ctx: Context): string | null;
|
|
29
|
+
private copyFile;
|
|
28
30
|
}
|
|
29
31
|
export {};
|
|
@@ -1,41 +1,86 @@
|
|
|
1
|
-
import { ApiEndpoint, ApiService, DefaultGenerationProviderConfig, Nullable, OpenApiServicesGenerationProviderContext,
|
|
2
|
-
import {
|
|
1
|
+
import { ApiEndpoint, ApiSchema, ApiService, DefaultGenerationProviderConfig, Nullable, OpenApiServicesGenerationProviderContext, StringCasing, StringCasingWithOptions } from '@goast/core';
|
|
2
|
+
import { getReferenceFactories } from './refs';
|
|
3
|
+
import { ts } from '../../../ast';
|
|
4
|
+
import { TypeScriptExportOutput } from '../../../common-results';
|
|
3
5
|
import { TypeScriptGeneratorConfig } from '../../../config';
|
|
4
|
-
import {
|
|
6
|
+
import { TypeScriptFileBuilder } from '../../../file-builder';
|
|
7
|
+
import { TypeScriptModelGeneratorOutput } from '../../models';
|
|
5
8
|
export type TypeScriptAngularServicesGeneratorConfig = TypeScriptGeneratorConfig & {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
responseModelFileNameCasing: StringCasing | StringCasingWithOptions;
|
|
10
|
+
/**
|
|
11
|
+
* How the services should be provided in the Angular application.
|
|
12
|
+
* - `root` - provides all the services using `Injectable({ providedIn: 'root' })`
|
|
13
|
+
* - `provide-fn` - generates a function `provideApiClients` that provides the services
|
|
14
|
+
* - `module` - generates an angular module `ApiClientModule` that provides the services
|
|
15
|
+
* @default 'root'
|
|
16
|
+
*/
|
|
17
|
+
provideKind: 'root' | 'provide-fn';
|
|
18
|
+
/**
|
|
19
|
+
* The domain name of the API. Used as a prefix for exported components (e.g. `ApiConfiguration`).
|
|
20
|
+
*/
|
|
21
|
+
domainName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to use strict response types for the services.
|
|
24
|
+
* If enabled only the status codes are included that are defined in the OpenAPI specification or the `defaultStatusCodeResponseTypes` option.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
strictResponseTypes: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The default response types for status codes that are not defined in the OpenAPI specification.
|
|
30
|
+
* @example
|
|
31
|
+
* {
|
|
32
|
+
* 400: schemas =>
|
|
33
|
+
* schemas.find(s => s.name === 'BadRequestResponse')
|
|
34
|
+
* ?? throwExp('BadRequestResponse not found'),
|
|
35
|
+
* 404: 'never',
|
|
36
|
+
* 500: ts.refs.any(),
|
|
37
|
+
* }
|
|
38
|
+
* @default
|
|
39
|
+
* {
|
|
40
|
+
* 401: ts.refs.never(),
|
|
41
|
+
* 403: ts.refs.never(),
|
|
42
|
+
* 500: ts.refs.never(),
|
|
43
|
+
* }
|
|
44
|
+
*/
|
|
45
|
+
defaultStatusCodeResponseTypes: Record<number, Exclude<ts.Type<TypeScriptFileBuilder>, Function> | ((schemas: readonly ApiSchema[]) => ApiSchema)>;
|
|
46
|
+
/**
|
|
47
|
+
* The possible status codes that any API endpoint can return.
|
|
48
|
+
* This is only used when `strictResponseTypes` is set to `false`;
|
|
49
|
+
* @default
|
|
50
|
+
* [100, 101, 102, 103, 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, 300, 301, 302, 303, 304, 305, 306, 307, 308, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511]
|
|
51
|
+
*/
|
|
52
|
+
possibleStatusCodes: number[];
|
|
11
53
|
rootUrl?: string | RegExp | ((rootUrl: string) => string);
|
|
12
54
|
pathModifier?: RegExp | ((path: string, endpoint: ApiEndpoint) => string);
|
|
13
55
|
servicesDirPath: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
indexFilePath: Nullable<string>;
|
|
56
|
+
servicesIndexFilePath: Nullable<string>;
|
|
57
|
+
responseModelsDirPath: string;
|
|
17
58
|
responseModelsIndexFilePath: Nullable<string>;
|
|
59
|
+
utilsDirPath: string;
|
|
18
60
|
};
|
|
19
61
|
export declare const defaultTypeScriptAngularServicesGeneratorConfig: DefaultGenerationProviderConfig<TypeScriptAngularServicesGeneratorConfig>;
|
|
20
|
-
export type TypeScriptAngularServicesGeneratorInput =
|
|
62
|
+
export type TypeScriptAngularServicesGeneratorInput = {
|
|
63
|
+
models: {
|
|
64
|
+
[schemaId: string]: TypeScriptModelGeneratorOutput;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
21
67
|
export type TypeScriptAngularServicesGeneratorOutput = {
|
|
22
68
|
services: {
|
|
23
69
|
[serviceId: string]: TypeScriptAngularServiceGeneratorOutput;
|
|
24
70
|
};
|
|
25
|
-
|
|
26
|
-
|
|
71
|
+
indexFiles: {
|
|
72
|
+
services: Nullable<string>;
|
|
73
|
+
responseModels: Nullable<string>;
|
|
74
|
+
};
|
|
27
75
|
};
|
|
28
|
-
export type
|
|
29
|
-
export type TypeScriptAngularServiceGeneratorOutput = RequiredProperties<TypeScriptComponentOutput, 'filePath'> & {
|
|
76
|
+
export type TypeScriptAngularServiceGeneratorOutput = TypeScriptExportOutput & {
|
|
30
77
|
responseModels: {
|
|
31
|
-
[operationId: string]:
|
|
32
|
-
statusCodes: {
|
|
33
|
-
[statusCode: string]: TypeScriptComponentOutput;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
78
|
+
[operationId: string]: TypeScriptExportOutput;
|
|
36
79
|
};
|
|
37
80
|
};
|
|
38
|
-
export type TypeScriptAngularServicesGeneratorContext = OpenApiServicesGenerationProviderContext<TypeScriptAngularServicesGeneratorInput, TypeScriptAngularServicesGeneratorOutput, TypeScriptAngularServicesGeneratorConfig, TypeScriptAngularServiceGeneratorOutput
|
|
81
|
+
export type TypeScriptAngularServicesGeneratorContext = OpenApiServicesGenerationProviderContext<TypeScriptAngularServicesGeneratorInput, TypeScriptAngularServicesGeneratorOutput, TypeScriptAngularServicesGeneratorConfig, TypeScriptAngularServiceGeneratorOutput> & {
|
|
82
|
+
refs: ReturnType<typeof getReferenceFactories>;
|
|
83
|
+
};
|
|
39
84
|
export type TypeScriptAngularServiceGeneratorContext = TypeScriptAngularServicesGeneratorContext & {
|
|
40
85
|
readonly service: ApiService;
|
|
41
86
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ts } from '../../../ast';
|
|
2
|
+
import type { TypeScriptAngularServicesGeneratorConfig } from './models';
|
|
3
|
+
export declare function getReferenceFactories(options: TypeScriptAngularServicesGeneratorConfig): {
|
|
4
|
+
requestBuilder: (<TBuilder extends import("@goast/core").SourceBuilder<never>>() => ts.Reference<TBuilder, never>) & {
|
|
5
|
+
refName: string;
|
|
6
|
+
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
7
|
+
} & {
|
|
8
|
+
moduleNameOrfilePath: string;
|
|
9
|
+
};
|
|
10
|
+
apiConfiguration: (<TBuilder extends import("@goast/core").SourceBuilder<never>>() => ts.Reference<TBuilder, never>) & {
|
|
11
|
+
refName: string;
|
|
12
|
+
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
13
|
+
} & {
|
|
14
|
+
moduleNameOrfilePath: string;
|
|
15
|
+
};
|
|
16
|
+
apiBaseService: (<TBuilder extends import("@goast/core").SourceBuilder<never>>() => ts.Reference<TBuilder, never>) & {
|
|
17
|
+
refName: string;
|
|
18
|
+
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
19
|
+
} & {
|
|
20
|
+
moduleNameOrfilePath: string;
|
|
21
|
+
};
|
|
22
|
+
httpStatusCode: (<TBuilder extends import("@goast/core").SourceBuilder<never>>() => ts.Reference<TBuilder, never>) & {
|
|
23
|
+
refName: string;
|
|
24
|
+
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
25
|
+
} & {
|
|
26
|
+
moduleNameOrfilePath: string;
|
|
27
|
+
};
|
|
28
|
+
provide: (<TBuilder extends import("@goast/core").SourceBuilder<never>>() => ts.Reference<TBuilder, never>) & {
|
|
29
|
+
refName: string;
|
|
30
|
+
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
31
|
+
} & {
|
|
32
|
+
moduleNameOrfilePath: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ApiEndpoint, ApiSchema, AppendValueGroup } from '@goast/core';
|
|
2
|
+
import { TypeScriptEasyNetworkStubGeneratorContext, TypeScriptEasyNetworkStubGeneratorOutput } from './models';
|
|
3
|
+
import { ts } from '../../../ast';
|
|
4
|
+
import { TypeScriptFileBuilder } from '../../../file-builder';
|
|
5
|
+
import { TypeScriptFileGenerator } from '../../file-generator';
|
|
6
|
+
type Context = TypeScriptEasyNetworkStubGeneratorContext;
|
|
7
|
+
type Output = TypeScriptEasyNetworkStubGeneratorOutput;
|
|
8
|
+
type Builder = TypeScriptFileBuilder;
|
|
9
|
+
export interface TypeScriptEasyNetworkStubGenerator<TOutput extends Output = Output> {
|
|
10
|
+
generate(ctx: Context): TOutput;
|
|
11
|
+
}
|
|
12
|
+
export declare class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGenerator<Context, Output> implements TypeScriptEasyNetworkStubGenerator {
|
|
13
|
+
generate(ctx: Context): Output;
|
|
14
|
+
protected getStubFileContent(ctx: Context): AppendValueGroup<Builder>;
|
|
15
|
+
protected getResponderVariable(ctx: Context, endpoint: ApiEndpoint): ts.Variable<Builder>;
|
|
16
|
+
protected getStubClass(ctx: Context): ts.Class<Builder>;
|
|
17
|
+
protected getEndpointRequestsType(ctx: Context, endpoint: ApiEndpoint, options?: {
|
|
18
|
+
readonly?: boolean;
|
|
19
|
+
}): ts.Type<Builder>;
|
|
20
|
+
protected getEndpointStubMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
21
|
+
protected getStubFilePath(ctx: Context): string;
|
|
22
|
+
protected getResponderVariableName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
23
|
+
protected getStubClassName(ctx: Context): string;
|
|
24
|
+
protected getEndpointPathPropertyName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
25
|
+
protected getEndpointRequestsFieldName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
26
|
+
protected getEndpointRequestsPropertyName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
27
|
+
protected getEndpointStubMethodName(ctx: Context, endpoint: ApiEndpoint): string;
|
|
28
|
+
protected getStubRoute(ctx: Context, endpoint: ApiEndpoint): string;
|
|
29
|
+
protected getEndpointStatusCodes(ctx: Context, endpoint: ApiEndpoint): Record<number, ts.Type<Builder>>;
|
|
30
|
+
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, fallback?: ts.Type<Builder>): ts.Type<Builder>;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApiService, AppendValueGroup, Factory, OpenApiGeneratorContext, OpenApiServicesGenerationProviderBase } from '@goast/core';
|
|
2
|
+
import { TypeScriptEasyNetworkStubGenerator } from './easy-network-stub-generator';
|
|
3
|
+
import { TypeScriptEasyNetworkStubsGeneratorInput, TypeScriptEasyNetworkStubsGeneratorOutput, TypeScriptEasyNetworkStubsGeneratorConfig, TypeScriptEasyNetworkStubGeneratorOutput, TypeScriptEasyNetworkStubsGeneratorContext } from './models';
|
|
4
|
+
import { TypeScriptExportOutput } from '../../../common-results';
|
|
5
|
+
import { TypeScriptFileBuilder } from '../../../file-builder';
|
|
6
|
+
type Input = TypeScriptEasyNetworkStubsGeneratorInput;
|
|
7
|
+
type Output = TypeScriptEasyNetworkStubsGeneratorOutput;
|
|
8
|
+
type Config = TypeScriptEasyNetworkStubsGeneratorConfig;
|
|
9
|
+
type ServiceOutput = TypeScriptEasyNetworkStubGeneratorOutput;
|
|
10
|
+
type Context = TypeScriptEasyNetworkStubsGeneratorContext;
|
|
11
|
+
export declare class TypeScriptEasyNetworkStubsGenerator extends OpenApiServicesGenerationProviderBase<Input, Output, Config, ServiceOutput, Context> {
|
|
12
|
+
private readonly _generatorFactory;
|
|
13
|
+
constructor(generatorFactory?: Factory<TypeScriptEasyNetworkStubGenerator, []>);
|
|
14
|
+
protected initResult(): Output;
|
|
15
|
+
protected buildContext(context: OpenApiGeneratorContext<Input>, config?: Partial<Config> | undefined): Context;
|
|
16
|
+
onGenerate(ctx: Context): Output;
|
|
17
|
+
protected generateService(ctx: Context, service: ApiService): TypeScriptExportOutput;
|
|
18
|
+
protected addServiceResult(ctx: Context, service: ApiService, result: TypeScriptExportOutput): void;
|
|
19
|
+
protected generateUtilsFiles(ctx: Context): void;
|
|
20
|
+
protected generateIndexFiles(ctx: Context): Output['indexFiles'];
|
|
21
|
+
protected getStubsIndexFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
22
|
+
protected getStubsIndexFilePath(ctx: Context): string | null;
|
|
23
|
+
private copyFile;
|
|
24
|
+
}
|
|
25
|
+
export {};
|