@goast/typescript 0.2.20 → 0.3.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/README.md +41 -11
- package/assets/client/angular/angular-service.utils.ts +80 -80
- package/assets/client/angular/request-builder.ts +372 -372
- package/assets/client/fetch/fetch-client.utils.ts +52 -52
- package/assets/stubs/easy-network-stub/easy-network-stub.utils.ts +258 -258
- package/cjs/index.js +1 -0
- package/cjs/lib/ast/nodes/argument.js +1 -1
- package/cjs/lib/ast/nodes/array-type.js +1 -1
- package/cjs/lib/ast/nodes/call.js +1 -1
- package/cjs/lib/ast/nodes/class.js +1 -1
- package/cjs/lib/ast/nodes/constructor-parameter.js +1 -1
- package/cjs/lib/ast/nodes/decorator.js +1 -1
- package/cjs/lib/ast/nodes/enum-value.js +1 -1
- package/cjs/lib/ast/nodes/enum.js +1 -1
- package/cjs/lib/ast/nodes/export.js +1 -1
- package/cjs/lib/ast/nodes/function.js +1 -1
- package/cjs/lib/ast/nodes/generic-parameter.js +1 -1
- package/cjs/lib/ast/nodes/indexer.js +1 -1
- package/cjs/lib/ast/nodes/interface.js +1 -1
- package/cjs/lib/ast/nodes/intersection-type.js +1 -1
- package/cjs/lib/ast/nodes/lookup-type.js +1 -1
- package/cjs/lib/ast/nodes/method.js +1 -1
- package/cjs/lib/ast/nodes/parameter.js +1 -1
- package/cjs/lib/ast/nodes/property.js +2 -2
- package/cjs/lib/ast/nodes/reference.js +1 -1
- package/cjs/lib/ast/nodes/string.js +1 -1
- package/cjs/lib/ast/nodes/tuple.js +1 -1
- package/cjs/lib/ast/nodes/type-alias.js +1 -1
- package/cjs/lib/ast/nodes/typeof.js +1 -1
- package/cjs/lib/ast/nodes/union-type.js +1 -1
- package/cjs/lib/ast/nodes/variable.js +1 -1
- package/cjs/lib/ast/utils/get-type-script-builder-options.js +2 -3
- package/cjs/lib/ast/utils/to-ts-node.js +1 -2
- package/cjs/lib/ast/utils/write-ts-generic-parameters.js +1 -2
- package/cjs/lib/ast/utils/write-ts-members.js +1 -2
- package/cjs/lib/ast/utils/write-ts-nodes.js +2 -3
- package/cjs/lib/ast/utils/write-ts-parameters.js +1 -2
- package/cjs/lib/file-builder.js +2 -2
- package/cjs/lib/generators/models/model-generator.js +2 -1
- package/cjs/lib/generators/models/models-generator.js +12 -7
- package/cjs/lib/generators/models/models.js +13 -2
- package/cjs/lib/generators/services/angular-services/angular-service-generator.js +17 -15
- package/cjs/lib/generators/services/angular-services/angular-services-generator.js +17 -12
- package/cjs/lib/generators/services/angular-services/models.js +19 -3
- package/cjs/lib/generators/services/angular-services/refs.js +2 -3
- package/cjs/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +13 -12
- package/cjs/lib/generators/services/easy-network-stub/easy-network-stubs-generator.js +16 -11
- package/cjs/lib/generators/services/easy-network-stub/models.js +10 -2
- package/cjs/lib/generators/services/easy-network-stub/refs.js +2 -3
- package/cjs/lib/generators/services/fetch-clients/fetch-client-generator.js +16 -13
- package/cjs/lib/generators/services/fetch-clients/fetch-clients-generator.js +48 -13
- package/cjs/lib/generators/services/fetch-clients/models.js +13 -1
- package/cjs/lib/generators/services/fetch-clients/refs.js +2 -3
- package/cjs/lib/import-collection.js +1 -1
- package/cjs/lib/utils.js +5 -6
- package/esm/index.js +1 -0
- package/esm/lib/ast/nodes/argument.js +1 -1
- package/esm/lib/ast/nodes/array-type.js +1 -1
- package/esm/lib/ast/nodes/call.js +1 -1
- package/esm/lib/ast/nodes/class.js +1 -1
- package/esm/lib/ast/nodes/constructor-parameter.js +1 -1
- package/esm/lib/ast/nodes/decorator.js +1 -1
- package/esm/lib/ast/nodes/enum-value.js +1 -1
- package/esm/lib/ast/nodes/enum.js +1 -1
- package/esm/lib/ast/nodes/export.js +1 -1
- package/esm/lib/ast/nodes/function.js +1 -1
- package/esm/lib/ast/nodes/generic-parameter.js +1 -1
- package/esm/lib/ast/nodes/indexer.js +1 -1
- package/esm/lib/ast/nodes/interface.js +1 -1
- package/esm/lib/ast/nodes/intersection-type.js +1 -1
- package/esm/lib/ast/nodes/lookup-type.js +1 -1
- package/esm/lib/ast/nodes/method.js +1 -1
- package/esm/lib/ast/nodes/parameter.js +1 -1
- package/esm/lib/ast/nodes/property.js +2 -2
- package/esm/lib/ast/nodes/reference.js +1 -1
- package/esm/lib/ast/nodes/string.js +1 -1
- package/esm/lib/ast/nodes/tuple.js +1 -1
- package/esm/lib/ast/nodes/type-alias.js +1 -1
- package/esm/lib/ast/nodes/typeof.js +1 -1
- package/esm/lib/ast/nodes/union-type.js +1 -1
- package/esm/lib/ast/nodes/variable.js +1 -1
- package/esm/lib/ast/utils/get-type-script-builder-options.js +1 -1
- package/esm/lib/generators/models/model-generator.js +2 -1
- package/esm/lib/generators/models/models-generator.js +12 -7
- package/esm/lib/generators/models/models.js +13 -2
- package/esm/lib/generators/services/angular-services/angular-service-generator.js +17 -15
- package/esm/lib/generators/services/angular-services/angular-services-generator.js +17 -12
- package/esm/lib/generators/services/angular-services/models.js +19 -3
- package/esm/lib/generators/services/angular-services/refs.js +1 -1
- package/esm/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +13 -12
- package/esm/lib/generators/services/easy-network-stub/easy-network-stubs-generator.js +16 -11
- package/esm/lib/generators/services/easy-network-stub/models.js +10 -2
- package/esm/lib/generators/services/easy-network-stub/refs.js +1 -1
- package/esm/lib/generators/services/fetch-clients/fetch-client-generator.js +16 -13
- package/esm/lib/generators/services/fetch-clients/fetch-clients-generator.js +46 -11
- package/esm/lib/generators/services/fetch-clients/models.js +13 -1
- package/esm/lib/generators/services/fetch-clients/refs.js +1 -1
- package/esm/lib/import-collection.js +1 -1
- package/package.json +22 -6
- package/types/index.d.ts +1 -0
- package/types/lib/ast/nodes/argument.d.ts +1 -1
- package/types/lib/ast/nodes/array-type.d.ts +1 -1
- package/types/lib/ast/nodes/arrow-function.d.ts +1 -1
- package/types/lib/ast/nodes/call.d.ts +1 -1
- package/types/lib/ast/nodes/class.d.ts +1 -1
- package/types/lib/ast/nodes/constructor-parameter.d.ts +1 -1
- package/types/lib/ast/nodes/constructor.d.ts +1 -1
- package/types/lib/ast/nodes/decorator.d.ts +2 -2
- package/types/lib/ast/nodes/doc.d.ts +1 -1
- package/types/lib/ast/nodes/enum-value.d.ts +2 -2
- package/types/lib/ast/nodes/enum.d.ts +1 -1
- package/types/lib/ast/nodes/export.d.ts +2 -2
- package/types/lib/ast/nodes/function-type.d.ts +1 -1
- package/types/lib/ast/nodes/function.d.ts +1 -1
- package/types/lib/ast/nodes/generic-parameter.d.ts +1 -1
- package/types/lib/ast/nodes/indexer.d.ts +1 -1
- package/types/lib/ast/nodes/interface.d.ts +1 -1
- package/types/lib/ast/nodes/intersection-type.d.ts +1 -1
- package/types/lib/ast/nodes/lookup-type.d.ts +1 -1
- package/types/lib/ast/nodes/method.d.ts +2 -2
- package/types/lib/ast/nodes/object-type.d.ts +1 -1
- package/types/lib/ast/nodes/object.d.ts +1 -1
- package/types/lib/ast/nodes/parameter.d.ts +1 -1
- package/types/lib/ast/nodes/property-accessor.d.ts +2 -2
- package/types/lib/ast/nodes/property.d.ts +15 -15
- package/types/lib/ast/nodes/reference.d.ts +4 -4
- package/types/lib/ast/nodes/string.d.ts +1 -1
- package/types/lib/ast/nodes/tuple.d.ts +1 -1
- package/types/lib/ast/nodes/type-alias.d.ts +1 -1
- package/types/lib/ast/nodes/typeof.d.ts +2 -2
- package/types/lib/ast/nodes/union-type.d.ts +1 -1
- package/types/lib/ast/nodes/variable.d.ts +1 -1
- package/types/lib/ast/references/angular.d.ts +8 -8
- package/types/lib/ast/references/easy-network-stub.d.ts +6 -6
- package/types/lib/ast/references/rxjs.d.ts +5 -5
- package/types/lib/ast/references/typescript.d.ts +46 -46
- package/types/lib/config.d.ts +53 -9
- package/types/lib/generators/models/model-generator.d.ts +1 -1
- package/types/lib/generators/models/models.d.ts +43 -8
- package/types/lib/generators/services/angular-services/angular-services-generator.d.ts +1 -1
- package/types/lib/generators/services/angular-services/models.d.ts +61 -20
- package/types/lib/generators/services/angular-services/refs.d.ts +9 -9
- package/types/lib/generators/services/easy-network-stub/easy-network-stubs-generator.d.ts +1 -1
- package/types/lib/generators/services/easy-network-stub/models.d.ts +35 -13
- package/types/lib/generators/services/easy-network-stub/refs.d.ts +14 -14
- package/types/lib/generators/services/fetch-clients/fetch-clients-generator.d.ts +4 -1
- package/types/lib/generators/services/fetch-clients/models.d.ts +63 -18
- package/types/lib/generators/services/fetch-clients/refs.d.ts +4 -4
- package/types/lib/utils.d.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiEndpoint, ApiSchema, ApiService, DefaultGenerationProviderConfig, Nullable, OpenApiServicesGenerationProviderContext
|
|
1
|
+
import { ApiEndpoint, ApiSchema, ApiService, DefaultGenerationProviderConfig, ExtendedStringCasing, Nullable, OpenApiServicesGenerationProviderContext } from '@goast/core';
|
|
2
2
|
import { getReferenceFactories } from './refs';
|
|
3
3
|
import { ts } from '../../../ast';
|
|
4
4
|
import { TypeScriptExportOutput } from '../../../common-results';
|
|
@@ -6,19 +6,18 @@ import { TypeScriptGeneratorConfig } from '../../../config';
|
|
|
6
6
|
import { TypeScriptFileBuilder } from '../../../file-builder';
|
|
7
7
|
import { TypeScriptModelGeneratorOutput } from '../../models';
|
|
8
8
|
export type TypeScriptAngularServicesGeneratorConfig = TypeScriptGeneratorConfig & {
|
|
9
|
-
responseModelFileNameCasing: StringCasing | StringCasingWithOptions;
|
|
10
9
|
/**
|
|
11
10
|
* How the services should be provided in the Angular application.
|
|
12
11
|
* - `root` - provides all the services using `Injectable({ providedIn: 'root' })`
|
|
13
12
|
* - `provide-fn` - generates a function `provideApiClients` that provides the services
|
|
14
|
-
* - `module` - generates an angular module `ApiClientModule` that provides the services
|
|
15
13
|
* @default 'root'
|
|
16
14
|
*/
|
|
17
15
|
provideKind: 'root' | 'provide-fn';
|
|
18
16
|
/**
|
|
19
17
|
* The domain name of the API. Used as a prefix for exported components (e.g. `ApiConfiguration`).
|
|
18
|
+
* @default undefined
|
|
20
19
|
*/
|
|
21
|
-
domainName
|
|
20
|
+
domainName: Nullable<string>;
|
|
22
21
|
/**
|
|
23
22
|
* Whether to use strict response types for the services.
|
|
24
23
|
* If enabled only the status codes are included that are defined in the OpenAPI specification or the `defaultStatusCodeResponseTypes` option.
|
|
@@ -54,32 +53,74 @@ export type TypeScriptAngularServicesGeneratorConfig = TypeScriptGeneratorConfig
|
|
|
54
53
|
} | null>;
|
|
55
54
|
/**
|
|
56
55
|
* The possible status codes that any API endpoint can return.
|
|
57
|
-
* This is only used when `strictResponseTypes` is set to `false
|
|
56
|
+
* This is only used when `strictResponseTypes` is set to `false`.
|
|
58
57
|
* @default
|
|
59
58
|
* [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]
|
|
60
59
|
*/
|
|
61
60
|
possibleStatusCodes: number[];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Explicitly set the root URL of the API. If `undefined`, the root URL is taken from the first `server` in the OpenAPI specification.
|
|
63
|
+
* @default undefined
|
|
64
|
+
*/
|
|
65
|
+
rootUrl: Nullable<string | RegExp | ((rootUrl: string) => string)>;
|
|
66
|
+
/**
|
|
67
|
+
* Modifier that is applied to the path of each endpoint.
|
|
68
|
+
* @default undefined
|
|
69
|
+
*/
|
|
70
|
+
pathModifier: Nullable<RegExp | ((path: string, endpoint: ApiEndpoint) => string)>;
|
|
71
|
+
/**
|
|
72
|
+
* The directory where the services should be saved. The path is relative to the output directory.
|
|
73
|
+
* @default 'services'
|
|
74
|
+
*/
|
|
75
|
+
servicesDir: string;
|
|
76
|
+
/**
|
|
77
|
+
* The casing of the file names for the services. If nullish, the `fileNameCasing` is used.
|
|
78
|
+
* @default { casing: 'kebab', suffix: '.service' }
|
|
79
|
+
*/
|
|
80
|
+
serviceFileNameCasing: Nullable<ExtendedStringCasing>;
|
|
81
|
+
/**
|
|
82
|
+
* The path to the index file where all services should be exported. The path is relative to the output directory. If nullish, no index file will be generated.
|
|
83
|
+
* @default 'services.ts'
|
|
84
|
+
*/
|
|
85
|
+
servicesIndexFile: Nullable<string>;
|
|
86
|
+
/**
|
|
87
|
+
* The directory where the response models should be saved. The path is relative to the output directory.
|
|
88
|
+
* @default 'models/responses'
|
|
89
|
+
*/
|
|
90
|
+
responseModelsDir: string;
|
|
91
|
+
/**
|
|
92
|
+
* The casing of the file names for the response models. If nullish, the `fileNameCasing` is used.
|
|
93
|
+
* @default { casing: 'kebab', suffix: '-responses.model' }
|
|
94
|
+
*/
|
|
95
|
+
responseModelFileNameCasing: Nullable<ExtendedStringCasing>;
|
|
96
|
+
/**
|
|
97
|
+
* The path to the index file where all response models should be exported. The path is relative to the output directory. If nullish, no index file will be generated.
|
|
98
|
+
* @default 'responses.ts'
|
|
99
|
+
*/
|
|
100
|
+
responseModelsIndexFile: Nullable<string>;
|
|
101
|
+
/**
|
|
102
|
+
* The directory where the utilies should be saved. The path is relative to the output directory.
|
|
103
|
+
* @default 'utils'
|
|
104
|
+
*/
|
|
105
|
+
utilsDir: string;
|
|
69
106
|
};
|
|
70
107
|
export declare const defaultTypeScriptAngularServicesGeneratorConfig: DefaultGenerationProviderConfig<TypeScriptAngularServicesGeneratorConfig>;
|
|
71
108
|
export type TypeScriptAngularServicesGeneratorInput = {
|
|
72
|
-
|
|
73
|
-
|
|
109
|
+
typescript: {
|
|
110
|
+
models: {
|
|
111
|
+
[schemaId: string]: TypeScriptModelGeneratorOutput;
|
|
112
|
+
};
|
|
74
113
|
};
|
|
75
114
|
};
|
|
76
115
|
export type TypeScriptAngularServicesGeneratorOutput = {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
116
|
+
typescript: {
|
|
117
|
+
services: {
|
|
118
|
+
[serviceId: string]: TypeScriptAngularServiceGeneratorOutput;
|
|
119
|
+
};
|
|
120
|
+
indexFiles: {
|
|
121
|
+
services: Nullable<string>;
|
|
122
|
+
responseModels: Nullable<string>;
|
|
123
|
+
};
|
|
83
124
|
};
|
|
84
125
|
};
|
|
85
126
|
export type TypeScriptAngularServiceGeneratorOutput = TypeScriptExportOutput & {
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { ts } from '../../../ast';
|
|
2
2
|
import type { TypeScriptAngularServicesGeneratorConfig } from './models';
|
|
3
3
|
export declare function getReferenceFactories(options: TypeScriptAngularServicesGeneratorConfig): {
|
|
4
|
-
abortablePromise: (<TBuilder extends import("@goast/core").SourceBuilder
|
|
4
|
+
abortablePromise: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
5
5
|
refName: string;
|
|
6
6
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
7
|
-
infer: <
|
|
7
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
8
8
|
} & {
|
|
9
9
|
moduleNameOrfilePath: string;
|
|
10
10
|
};
|
|
11
|
-
waitForResponse: (<TBuilder extends import("@goast/core").SourceBuilder
|
|
11
|
+
waitForResponse: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
12
12
|
refName: string;
|
|
13
13
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
14
|
-
infer: <
|
|
14
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
15
15
|
} & {
|
|
16
16
|
moduleNameOrfilePath: string;
|
|
17
17
|
};
|
|
18
|
-
requestBuilder: (<
|
|
18
|
+
requestBuilder: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
19
19
|
refName: string;
|
|
20
20
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
21
21
|
} & {
|
|
22
22
|
moduleNameOrfilePath: string;
|
|
23
23
|
};
|
|
24
|
-
apiConfiguration: (<
|
|
24
|
+
apiConfiguration: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
25
25
|
refName: string;
|
|
26
26
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
27
27
|
} & {
|
|
28
28
|
moduleNameOrfilePath: string;
|
|
29
29
|
};
|
|
30
|
-
apiBaseService: (<
|
|
30
|
+
apiBaseService: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
31
31
|
refName: string;
|
|
32
32
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
33
33
|
} & {
|
|
34
34
|
moduleNameOrfilePath: string;
|
|
35
35
|
};
|
|
36
|
-
httpStatusCode: (<
|
|
36
|
+
httpStatusCode: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
37
37
|
refName: string;
|
|
38
38
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
39
39
|
} & {
|
|
40
40
|
moduleNameOrfilePath: string;
|
|
41
41
|
};
|
|
42
|
-
provide: (<
|
|
42
|
+
provide: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
43
43
|
refName: string;
|
|
44
44
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
45
45
|
} & {
|
|
@@ -18,7 +18,7 @@ export declare class TypeScriptEasyNetworkStubsGenerator extends OpenApiServices
|
|
|
18
18
|
protected generateService(ctx: Context, service: ApiService): TypeScriptExportOutput;
|
|
19
19
|
protected addServiceResult(ctx: Context, service: ApiService, result: TypeScriptExportOutput): void;
|
|
20
20
|
protected generateUtilsFiles(ctx: Context): void;
|
|
21
|
-
protected generateIndexFiles(ctx: Context): Output['indexFiles'];
|
|
21
|
+
protected generateIndexFiles(ctx: Context): Output['typescript']['indexFiles'];
|
|
22
22
|
protected getStubsIndexFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
23
23
|
protected getStubsClass(ctx: Context): ts.Class<TypeScriptFileBuilder>;
|
|
24
24
|
protected getStubsIndexFilePath(ctx: Context): string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiSchema, ApiService, DefaultGenerationProviderConfig, Nullable, OpenApiServicesGenerationProviderContext } from '@goast/core';
|
|
1
|
+
import { ApiSchema, ApiService, DefaultGenerationProviderConfig, ExtendedStringCasing, Nullable, OpenApiServicesGenerationProviderContext } from '@goast/core';
|
|
2
2
|
import { getReferenceFactories } from './refs';
|
|
3
3
|
import { ts } from '../../../ast';
|
|
4
4
|
import { TypeScriptExportOutput } from '../../../common-results';
|
|
@@ -7,9 +7,10 @@ import { TypeScriptFileBuilder } from '../../../file-builder';
|
|
|
7
7
|
import { TypeScriptModelGeneratorOutput } from '../../models';
|
|
8
8
|
export type TypeScriptEasyNetworkStubsGeneratorConfig = TypeScriptGeneratorConfig & {
|
|
9
9
|
/**
|
|
10
|
-
* The domain name of the API. Used as a prefix for exported components (e.g. `
|
|
10
|
+
* The domain name of the API. Used as a prefix for exported components (e.g. `ApiStubs`).
|
|
11
|
+
* @default undefined
|
|
11
12
|
*/
|
|
12
|
-
domainName
|
|
13
|
+
domainName: Nullable<string>;
|
|
13
14
|
/**
|
|
14
15
|
* The default response types for status codes that are not defined in the OpenAPI specification.
|
|
15
16
|
* @example
|
|
@@ -28,22 +29,43 @@ export type TypeScriptEasyNetworkStubsGeneratorConfig = TypeScriptGeneratorConfi
|
|
|
28
29
|
* }
|
|
29
30
|
*/
|
|
30
31
|
defaultStatusCodeResponseTypes: Record<number, Exclude<ts.Type<TypeScriptFileBuilder>, Function> | ((schemas: readonly ApiSchema[]) => ApiSchema)>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
/**
|
|
33
|
+
* The directory where the stubs should be saved. The path is relative to the output directory.
|
|
34
|
+
* @default 'stubs'
|
|
35
|
+
*/
|
|
36
|
+
stubsDir: string;
|
|
37
|
+
/**
|
|
38
|
+
* The casing of the stub file names. If nullish, the `fileNameCasing` is used.
|
|
39
|
+
* @default { casing: 'kebab', suffix: '.stubs' }
|
|
40
|
+
*/
|
|
41
|
+
stubFileNameCasing: Nullable<ExtendedStringCasing>;
|
|
42
|
+
/**
|
|
43
|
+
* The index file where all stubs should be exported. The path is relative to the output directory. If nullish, no index file will be generated.
|
|
44
|
+
* @default 'stubs.ts'
|
|
45
|
+
*/
|
|
46
|
+
stubsIndexFile: Nullable<string>;
|
|
47
|
+
/**
|
|
48
|
+
* The directory where the utilies should be saved. The path is relative to the output directory.
|
|
49
|
+
* @default 'utils'
|
|
50
|
+
*/
|
|
51
|
+
utilsDir: string;
|
|
34
52
|
};
|
|
35
53
|
export declare const defaultTypeScriptEasyNetworkStubsGeneratorConfig: DefaultGenerationProviderConfig<TypeScriptEasyNetworkStubsGeneratorConfig>;
|
|
36
54
|
export type TypeScriptEasyNetworkStubsGeneratorInput = {
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
typescript: {
|
|
56
|
+
models: {
|
|
57
|
+
[schemaId: string]: TypeScriptModelGeneratorOutput;
|
|
58
|
+
};
|
|
39
59
|
};
|
|
40
60
|
};
|
|
41
61
|
export type TypeScriptEasyNetworkStubsGeneratorOutput = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
typescript: {
|
|
63
|
+
stubs: {
|
|
64
|
+
[serviceId: string]: TypeScriptEasyNetworkStubGeneratorOutput;
|
|
65
|
+
};
|
|
66
|
+
indexFiles: {
|
|
67
|
+
stubs: Nullable<string>;
|
|
68
|
+
};
|
|
47
69
|
};
|
|
48
70
|
};
|
|
49
71
|
export type TypeScriptEasyNetworkStubGeneratorOutput = TypeScriptExportOutput;
|
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
import { TypeScriptEasyNetworkStubsGeneratorConfig } from './models';
|
|
2
2
|
import { ts } from '../../../ast';
|
|
3
3
|
export declare function getReferenceFactories(options: TypeScriptEasyNetworkStubsGeneratorConfig): {
|
|
4
|
-
easyNetworkStubWrapperOptions: (<TBuilder extends import("@goast/core").SourceBuilder
|
|
4
|
+
easyNetworkStubWrapperOptions: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
5
5
|
refName: string;
|
|
6
6
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
7
7
|
} & {
|
|
8
8
|
moduleNameOrfilePath: string;
|
|
9
9
|
};
|
|
10
|
-
stubRequestItem: (<TBuilder extends import("@goast/core").SourceBuilder
|
|
10
|
+
stubRequestItem: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
11
11
|
refName: string;
|
|
12
12
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
13
13
|
} & {
|
|
14
14
|
moduleNameOrfilePath: string;
|
|
15
15
|
};
|
|
16
|
-
stubRequestInfo: (<
|
|
16
|
+
stubRequestInfo: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>, ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
17
17
|
refName: string;
|
|
18
18
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
19
|
-
infer: <
|
|
19
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
20
20
|
} & {
|
|
21
21
|
moduleNameOrfilePath: string;
|
|
22
22
|
};
|
|
23
|
-
strictRouteResponseCallback: (<
|
|
23
|
+
strictRouteResponseCallback: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>, ts.Type<TBuilder>, ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
24
24
|
refName: string;
|
|
25
25
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
26
|
-
infer: <
|
|
26
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
27
27
|
} & {
|
|
28
28
|
moduleNameOrfilePath: string;
|
|
29
29
|
};
|
|
30
|
-
getStubResponder: (<
|
|
30
|
+
getStubResponder: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
31
31
|
refName: string;
|
|
32
32
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
33
|
-
infer: <
|
|
33
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
34
34
|
} & {
|
|
35
35
|
moduleNameOrfilePath: string;
|
|
36
36
|
};
|
|
37
|
-
easyNetworkStubWrapper: (<TBuilder extends import("@goast/core").SourceBuilder
|
|
37
|
+
easyNetworkStubWrapper: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
38
38
|
refName: string;
|
|
39
39
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
40
40
|
} & {
|
|
41
41
|
moduleNameOrfilePath: string;
|
|
42
42
|
};
|
|
43
|
-
easyNetworkStubBase: (<TBuilder extends import("@goast/core").SourceBuilder
|
|
43
|
+
easyNetworkStubBase: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
44
44
|
refName: string;
|
|
45
45
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
46
46
|
} & {
|
|
47
47
|
moduleNameOrfilePath: string;
|
|
48
48
|
};
|
|
49
|
-
easyNetworkStubGroup: (<
|
|
49
|
+
easyNetworkStubGroup: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>, ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
50
50
|
refName: string;
|
|
51
51
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
52
|
-
infer: <
|
|
52
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
53
53
|
} & {
|
|
54
54
|
moduleNameOrfilePath: string;
|
|
55
55
|
};
|
|
56
|
-
createEasyNetworkStubGroup: (<
|
|
56
|
+
createEasyNetworkStubGroup: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>, ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
57
57
|
refName: string;
|
|
58
58
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
59
|
-
infer: <
|
|
59
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
60
60
|
} & {
|
|
61
61
|
moduleNameOrfilePath: string;
|
|
62
62
|
};
|
|
@@ -7,7 +7,7 @@ type Output = TypeScriptFetchClientsGeneratorOutput;
|
|
|
7
7
|
type Config = TypeScriptFetchClientsGeneratorConfig;
|
|
8
8
|
type ServiceOutput = TypeScriptFetchClientGeneratorOutput;
|
|
9
9
|
type Context = TypeScriptFetchClientsGeneratorContext;
|
|
10
|
-
export declare class
|
|
10
|
+
export declare class TypeScriptFetchClientsGenerator extends OpenApiServicesGenerationProviderBase<Input, Output, Config, ServiceOutput, Context> {
|
|
11
11
|
private readonly _clientGeneratorFactory;
|
|
12
12
|
constructor(clientGeneratorFactory?: Factory<TypeScriptFetchClientGenerator, []>);
|
|
13
13
|
protected initResult(): Output;
|
|
@@ -16,8 +16,11 @@ export declare class TypeScriptClientsGenerator extends OpenApiServicesGeneratio
|
|
|
16
16
|
protected generateService(ctx: Context, service: ApiService): ServiceOutput;
|
|
17
17
|
protected addServiceResult(ctx: Context, service: ApiService, result: ServiceOutput): void;
|
|
18
18
|
protected generateIndexFile(ctx: Context): string | null;
|
|
19
|
+
protected generateInterfaceIndexFile(ctx: Context): string | null;
|
|
19
20
|
protected getIndexFilePath(ctx: Context): string | null;
|
|
21
|
+
protected getInterfaceIndexFilePath(ctx: Context): string | null;
|
|
20
22
|
protected getIndexFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
23
|
+
protected getInterfaceIndexFileContent(ctx: Context): AppendValueGroup<TypeScriptFileBuilder>;
|
|
21
24
|
private copyUtilsFiles;
|
|
22
25
|
}
|
|
23
26
|
export {};
|
|
@@ -1,34 +1,79 @@
|
|
|
1
|
-
import { ApiService, DefaultGenerationProviderConfig, OpenApiServicesGenerationProviderContext,
|
|
1
|
+
import { ApiService, DefaultGenerationProviderConfig, OpenApiServicesGenerationProviderContext, Nullable, ExtendedStringCasing } from '@goast/core';
|
|
2
2
|
import { getReferenceFactories } from './refs';
|
|
3
3
|
import { TypeScriptExportOutput } from '../../../common-results';
|
|
4
4
|
import { TypeScriptGeneratorConfig } from '../../../config';
|
|
5
5
|
import { TypeScriptModelsGeneratorOutput } from '../../models/models';
|
|
6
6
|
export type TypeScriptFetchClientsGeneratorConfig = TypeScriptGeneratorConfig & {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* The casing of the client file names. If nullish, the `fileNameCasing` is used.
|
|
9
|
+
* @default { casing: 'kebab', suffix: '-client' }
|
|
10
|
+
*/
|
|
11
|
+
clientFileNameCasing: Nullable<ExtendedStringCasing>;
|
|
12
|
+
/**
|
|
13
|
+
* The casing of the client interface file names. If nullish, the `fileNameCasing` is used.
|
|
14
|
+
* @default { casing: 'kebab', suffix: '-client' }
|
|
15
|
+
*/
|
|
16
|
+
clientInterfaceFileNameCasing: Nullable<ExtendedStringCasing>;
|
|
17
|
+
/**
|
|
18
|
+
* The casing of the client names. If nullish, the `typeNameCasing` is used.
|
|
19
|
+
* @default { casing: 'pascal', suffix: 'Client' }
|
|
20
|
+
*/
|
|
21
|
+
clientNameCasing: Nullable<ExtendedStringCasing>;
|
|
22
|
+
/**
|
|
23
|
+
* The casing of the client interface names. If nullish, the `typeNameCasing` is used.
|
|
24
|
+
* @default { prefix: 'I', casing: 'pascal', suffix: 'Client' }
|
|
25
|
+
*/
|
|
26
|
+
clientInterfaceNameCasing: Nullable<ExtendedStringCasing>;
|
|
27
|
+
/**
|
|
28
|
+
* Determines how the client files should be generated.
|
|
29
|
+
* - `interface` - generates only the interface
|
|
30
|
+
* - `class` - generates only the class
|
|
31
|
+
* - `class-and-interface` - generates both the class and the interface
|
|
32
|
+
* @default 'class'
|
|
33
|
+
*/
|
|
12
34
|
clientFileKind: 'interface' | 'class' | 'class-and-interface';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The directory where the client files should be saved. The path is relative to the output directory.
|
|
37
|
+
* @default 'clients'
|
|
38
|
+
*/
|
|
39
|
+
clientDir: string;
|
|
40
|
+
/**
|
|
41
|
+
* The directory where the client interface files should be saved. The path is relative to the output directory.
|
|
42
|
+
* @default 'clients/interfaces'
|
|
43
|
+
*/
|
|
44
|
+
clientInterfaceDir: Nullable<string>;
|
|
45
|
+
/**
|
|
46
|
+
* The index file where all clients should be exported. The path is relative to the output directory. If nullish, no index file will be generated.
|
|
47
|
+
* @default 'clients.ts'
|
|
48
|
+
*/
|
|
49
|
+
clientsIndexFile: Nullable<string>;
|
|
50
|
+
/**
|
|
51
|
+
* The index file where all client interfaces should be exported. The path is relative to the output directory. If nullish, no index file will be generated.
|
|
52
|
+
* @default 'clients.ts'
|
|
53
|
+
*/
|
|
54
|
+
clientInterfacesIndexFile: Nullable<string>;
|
|
55
|
+
/**
|
|
56
|
+
* The directory where the utilies should be saved. The path is relative to the output directory.
|
|
57
|
+
* @default 'utils'
|
|
58
|
+
*/
|
|
59
|
+
utilsDir: string;
|
|
18
60
|
};
|
|
19
61
|
export declare const defaultTypeScriptFetchClientsGeneratorConfig: DefaultGenerationProviderConfig<TypeScriptFetchClientsGeneratorConfig>;
|
|
20
62
|
export type TypeScriptFetchClientsGeneratorInput = TypeScriptModelsGeneratorOutput;
|
|
21
63
|
export type TypeScriptFetchClientsGeneratorOutput = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
64
|
+
typescript: {
|
|
65
|
+
clients: {
|
|
66
|
+
[serviceId: string]: TypeScriptFetchClientGeneratorOutput;
|
|
67
|
+
};
|
|
68
|
+
indexFiles: {
|
|
69
|
+
clients: Nullable<string>;
|
|
70
|
+
clientInterfaces: Nullable<string>;
|
|
71
|
+
};
|
|
27
72
|
};
|
|
28
73
|
};
|
|
29
74
|
export type TypeScriptFetchClientGeneratorOutput = {
|
|
30
|
-
|
|
31
|
-
|
|
75
|
+
client?: TypeScriptExportOutput;
|
|
76
|
+
clientInterface?: TypeScriptExportOutput;
|
|
32
77
|
};
|
|
33
78
|
export type TypeScriptFetchClientsGeneratorContext = OpenApiServicesGenerationProviderContext<TypeScriptFetchClientsGeneratorInput, TypeScriptFetchClientsGeneratorOutput, TypeScriptFetchClientsGeneratorConfig, TypeScriptFetchClientGeneratorOutput> & {
|
|
34
79
|
refs: ReturnType<typeof getReferenceFactories>;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { TypeScriptFetchClientsGeneratorConfig } from './models';
|
|
2
2
|
import { ts } from '../../../ast';
|
|
3
3
|
export declare function getReferenceFactories(options: TypeScriptFetchClientsGeneratorConfig): {
|
|
4
|
-
typedResponse: (<TBuilder extends import("@goast/core").SourceBuilder
|
|
4
|
+
typedResponse: (<TBuilder extends import("@goast/core").SourceBuilder>(generics: [ts.Type<TBuilder>]) => ts.Reference<TBuilder, never>) & {
|
|
5
5
|
refName: string;
|
|
6
6
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
7
|
-
infer: <
|
|
7
|
+
infer: <TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>;
|
|
8
8
|
} & {
|
|
9
9
|
moduleNameOrfilePath: string;
|
|
10
10
|
};
|
|
11
|
-
fetchClientOptions: (<
|
|
11
|
+
fetchClientOptions: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
12
12
|
refName: string;
|
|
13
13
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
14
14
|
} & {
|
|
15
15
|
moduleNameOrfilePath: string;
|
|
16
16
|
};
|
|
17
|
-
urlBuilder: (<
|
|
17
|
+
urlBuilder: (<TBuilder extends import("@goast/core").SourceBuilder>() => ts.Reference<TBuilder, never>) & {
|
|
18
18
|
refName: string;
|
|
19
19
|
moduleNameOrfilePath: import("@goast/core").Nullable<string>;
|
|
20
20
|
} & {
|
package/types/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Nullable } from '@goast/core';
|
|
1
2
|
export type ImportModuleTransformer = 'omit-extension' | 'js-extension' | ((module: string) => string);
|
|
2
3
|
export declare function toTypeScriptStringLiteral(value: string, useSingleQuotes: boolean): string;
|
|
3
4
|
export declare function toTypeScriptPropertyName(value: string, useSingleQuotes: boolean): string;
|
|
4
5
|
export declare function getModulePathRelativeToFile(from: string, to: string, transformer: ImportModuleTransformer): string;
|
|
5
6
|
export declare function getModulePathRelativeToDirectory(from: string, to: string, transformer: ImportModuleTransformer): string;
|
|
6
|
-
export declare function modifyString<TArgs extends any[]>(value: string, modifier: string | RegExp | ((value: string, ...args: TArgs) => string)
|
|
7
|
+
export declare function modifyString<TArgs extends any[]>(value: string, modifier: Nullable<string | RegExp | ((value: string, ...args: TArgs) => string)>, ...args: TArgs): string;
|