@goast/typescript 0.5.1-k6.2 → 0.5.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.
Files changed (112) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +52 -52
  3. package/assets/client/angular/angular-service.utils.ts +82 -82
  4. package/assets/client/angular/request-builder.ts +377 -377
  5. package/assets/client/fetch/fetch-client.utils.ts +52 -52
  6. package/assets/client/k6/request-builder.js +419 -419
  7. package/assets/client/k6/request-builder.ts +341 -341
  8. package/assets/stubs/easy-network-stub/easy-network-stub.utils.ts +259 -259
  9. package/esm/src/generators/models/model-generator.d.ts +1 -1
  10. package/esm/src/generators/models/model-generator.d.ts.map +1 -1
  11. package/esm/src/generators/models/model-generator.js +2 -2
  12. package/esm/src/generators/models/models.d.ts +7 -0
  13. package/esm/src/generators/models/models.d.ts.map +1 -1
  14. package/esm/src/generators/models/models.js +2 -0
  15. package/esm/src/generators/services/angular-services/angular-service-generator.js +9 -9
  16. package/esm/src/generators/services/easy-network-stub/easy-network-stub-generator.js +9 -9
  17. package/esm/src/generators/services/fetch-clients/fetch-client-generator.js +2 -2
  18. package/esm/src/generators/services/k6-clients/k6-client-generator.js +11 -11
  19. package/package.json +1 -1
  20. package/script/src/generators/models/model-generator.d.ts +1 -1
  21. package/script/src/generators/models/model-generator.d.ts.map +1 -1
  22. package/script/src/generators/models/model-generator.js +2 -2
  23. package/script/src/generators/models/models.d.ts +7 -0
  24. package/script/src/generators/models/models.d.ts.map +1 -1
  25. package/script/src/generators/models/models.js +2 -0
  26. package/script/src/generators/services/angular-services/angular-service-generator.js +9 -9
  27. package/script/src/generators/services/easy-network-stub/easy-network-stub-generator.js +9 -9
  28. package/script/src/generators/services/fetch-clients/fetch-client-generator.js +2 -2
  29. package/script/src/generators/services/k6-clients/k6-client-generator.js +11 -11
  30. package/src/mod.ts +7 -0
  31. package/src/src/assets.ts +9 -0
  32. package/src/src/ast/_index.ts +54 -0
  33. package/src/src/ast/common.ts +1 -0
  34. package/src/src/ast/index.ts +1 -0
  35. package/src/src/ast/node.ts +10 -0
  36. package/src/src/ast/nodes/argument.ts +40 -0
  37. package/src/src/ast/nodes/array-type.ts +49 -0
  38. package/src/src/ast/nodes/arrow-function.ts +91 -0
  39. package/src/src/ast/nodes/call.ts +55 -0
  40. package/src/src/ast/nodes/class.ts +133 -0
  41. package/src/src/ast/nodes/constructor-parameter.ts +70 -0
  42. package/src/src/ast/nodes/constructor.ts +77 -0
  43. package/src/src/ast/nodes/decorator.ts +76 -0
  44. package/src/src/ast/nodes/doc-tag.ts +291 -0
  45. package/src/src/ast/nodes/doc.ts +102 -0
  46. package/src/src/ast/nodes/enum-value.ts +72 -0
  47. package/src/src/ast/nodes/enum.ts +77 -0
  48. package/src/src/ast/nodes/export.ts +54 -0
  49. package/src/src/ast/nodes/function-type.ts +60 -0
  50. package/src/src/ast/nodes/function.ts +107 -0
  51. package/src/src/ast/nodes/generic-parameter.ts +71 -0
  52. package/src/src/ast/nodes/indexer.ts +60 -0
  53. package/src/src/ast/nodes/interface.ts +117 -0
  54. package/src/src/ast/nodes/intersection-type.ts +67 -0
  55. package/src/src/ast/nodes/lookup-type.ts +53 -0
  56. package/src/src/ast/nodes/method.ts +138 -0
  57. package/src/src/ast/nodes/object-type.ts +52 -0
  58. package/src/src/ast/nodes/object.ts +48 -0
  59. package/src/src/ast/nodes/parameter.ts +85 -0
  60. package/src/src/ast/nodes/property-accessor.ts +173 -0
  61. package/src/src/ast/nodes/property.ts +192 -0
  62. package/src/src/ast/nodes/reference.ts +194 -0
  63. package/src/src/ast/nodes/string.ts +49 -0
  64. package/src/src/ast/nodes/tuple.ts +53 -0
  65. package/src/src/ast/nodes/type-alias.ts +75 -0
  66. package/src/src/ast/nodes/typeof.ts +42 -0
  67. package/src/src/ast/nodes/types.ts +40 -0
  68. package/src/src/ast/nodes/union-type.ts +62 -0
  69. package/src/src/ast/nodes/variable.ts +73 -0
  70. package/src/src/ast/references/angular.ts +24 -0
  71. package/src/src/ast/references/easy-network-stub.ts +21 -0
  72. package/src/src/ast/references/index.ts +5 -0
  73. package/src/src/ast/references/k6.ts +8 -0
  74. package/src/src/ast/references/rxjs.ts +7 -0
  75. package/src/src/ast/references/typescript.ts +35 -0
  76. package/src/src/ast/utils/get-type-script-builder-options.ts +19 -0
  77. package/src/src/ast/utils/to-ts-node.ts +27 -0
  78. package/src/src/ast/utils/write-ts-generic-parameters.ts +25 -0
  79. package/src/src/ast/utils/write-ts-members.ts +28 -0
  80. package/src/src/ast/utils/write-ts-nodes.ts +35 -0
  81. package/src/src/ast/utils/write-ts-parameters.ts +25 -0
  82. package/src/src/common-results.ts +26 -0
  83. package/src/src/config.ts +89 -0
  84. package/src/src/file-builder.ts +136 -0
  85. package/src/src/generators/file-generator.ts +15 -0
  86. package/src/src/generators/index.ts +6 -0
  87. package/src/src/generators/models/index.ts +3 -0
  88. package/src/src/generators/models/model-generator.ts +469 -0
  89. package/src/src/generators/models/models-generator.ts +108 -0
  90. package/src/src/generators/models/models.ts +121 -0
  91. package/src/src/generators/services/angular-services/angular-service-generator.ts +406 -0
  92. package/src/src/generators/services/angular-services/angular-services-generator.ts +295 -0
  93. package/src/src/generators/services/angular-services/index.ts +3 -0
  94. package/src/src/generators/services/angular-services/models.ts +277 -0
  95. package/src/src/generators/services/angular-services/refs.ts +54 -0
  96. package/src/src/generators/services/easy-network-stub/easy-network-stub-generator.ts +242 -0
  97. package/src/src/generators/services/easy-network-stub/easy-network-stubs-generator.ts +211 -0
  98. package/src/src/generators/services/easy-network-stub/index.ts +3 -0
  99. package/src/src/generators/services/easy-network-stub/models.ts +124 -0
  100. package/src/src/generators/services/easy-network-stub/refs.ts +45 -0
  101. package/src/src/generators/services/fetch-clients/fetch-client-generator.ts +267 -0
  102. package/src/src/generators/services/fetch-clients/fetch-clients-generator.ts +163 -0
  103. package/src/src/generators/services/fetch-clients/index.ts +3 -0
  104. package/src/src/generators/services/fetch-clients/models.ts +130 -0
  105. package/src/src/generators/services/fetch-clients/refs.ts +21 -0
  106. package/src/src/generators/services/k6-clients/index.ts +3 -0
  107. package/src/src/generators/services/k6-clients/k6-client-generator.ts +465 -0
  108. package/src/src/generators/services/k6-clients/k6-clients-generator.ts +171 -0
  109. package/src/src/generators/services/k6-clients/models.ts +247 -0
  110. package/src/src/generators/services/k6-clients/refs.ts +16 -0
  111. package/src/src/import-collection.ts +236 -0
  112. package/src/src/utils.ts +72 -0
@@ -1,259 +1,259 @@
1
- import type { EasyNetworkStub } from 'easy-network-stub';
2
-
3
- import type { ErrorResponse, HttpMethod, RouteResponseCallback } from 'easy-network-stub';
4
-
5
- /**
6
- * Options for the `EasyNetworkStubWrapper`.
7
- */
8
- export type EasyNetworkStubWrapperOptions = {
9
- /**
10
- * Delay in milliseconds before responding.
11
- * @default 0
12
- */
13
- delay: number;
14
- /**
15
- * Whether to log requests to the console.
16
- * @default false
17
- */
18
- logRequests: boolean;
19
- /**
20
- * Whether to log responses to the console.
21
- * @default false
22
- */
23
- logResponses: boolean;
24
- /**
25
- * Whether to remember requests. Remebered requests can be accessed via the `requests` property.
26
- * @default false
27
- */
28
- rememberRequests: boolean;
29
- /**
30
- * Function to call when a response is sent.
31
- * @param response The response that was sent.
32
- * @default undefined
33
- */
34
- responseCallback?: (response: unknown) => void;
35
- /**
36
- * A prefix to add to the URL in log messages.
37
- * @default /api/
38
- */
39
- logUrlPrefix: string;
40
- };
41
-
42
- /**
43
- * Represents a request intercepted by the `EasyNetworkStubWrapper`.
44
- */
45
- export type StubRequestItem = {
46
- /**
47
- * The HTTP method of the request.
48
- */
49
- method: HttpMethod;
50
- /**
51
- * The route of the request.
52
- */
53
- route: string;
54
- /**
55
- * The request information provided by `easy-network-stub`.
56
- */
57
- request: StubRequestInfo;
58
- };
59
-
60
- /**
61
- * Represents the request information provided by `easy-network-stub`.
62
- */
63
- export type StubRequestInfo<TRoute extends string = string, TBody = unknown> = Parameters<
64
- RouteResponseCallback<TRoute, TBody>
65
- >[0];
66
-
67
- /**
68
- * A strict version of `RouteResponseCallback` that allows for a responder to be passed as the first argument.
69
- */
70
- export type StrictRouteResponseCallback<T, P extends string, R> = (
71
- respondWith: R,
72
- ...args: Parameters<RouteResponseCallback<P, T>>
73
- ) => ErrorResponse<any> | Promise<ErrorResponse<any>>;
74
-
75
- type _UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
76
- type __StubResponder<T extends Record<number, unknown>, S> = S extends number
77
- ? [T[S]] extends [never] ? (statusCode: S) => ErrorResponse<T[S]>
78
- : (statusCode: S, content: T[S]) => ErrorResponse<T[S]>
79
- : never;
80
- type _StubResponder<T extends Record<number, unknown>> = _UnionToIntersection<__StubResponder<T, keyof T>>;
81
- const untypedResponder = (statusCode: number, content?: unknown) => ({ statusCode, content });
82
-
83
- /**
84
- * Gets the responder function typed to a specific set of status codes.
85
- * @returns The responder function.
86
- */
87
- export function getStubResponder<T extends Record<number, unknown>>(): _StubResponder<T> {
88
- return untypedResponder as _StubResponder<T>;
89
- }
90
-
91
- /**
92
- * Wrapper for `EasyNetworkStub` that adds additional functionality.
93
- */
94
- export class EasyNetworkStubWrapper {
95
- private _requests: StubRequestItem[] = [];
96
-
97
- /**
98
- * The options for the wrapper.
99
- */
100
- public readonly options: Readonly<EasyNetworkStubWrapperOptions>;
101
-
102
- /**
103
- * The requests that have been intercepted by the wrapper.
104
- */
105
- public get requests(): ReadonlyArray<StubRequestItem> {
106
- return this._requests;
107
- }
108
-
109
- constructor(
110
- public readonly wrappedStub: EasyNetworkStub,
111
- options?: Partial<EasyNetworkStubWrapperOptions>,
112
- ) {
113
- this.options = {
114
- delay: options?.delay ?? 0,
115
- logRequests: options?.logRequests ?? false,
116
- logResponses: options?.logResponses ?? false,
117
- rememberRequests: options?.rememberRequests ?? false,
118
- responseCallback: options?.responseCallback,
119
- logUrlPrefix: options?.logUrlPrefix ?? '/api/',
120
- };
121
- }
122
-
123
- /**
124
- * Add a single api stub to your intercepted routes.
125
- * @param method The http method that should be stubbed
126
- * @param route The route that should be stubbed. Supports parameters in the form of {name:type}.
127
- * @param response The callback in which you can process the request and reply with the stub. When a Promise is returned, the stub response will be delayed until it is resolved.
128
- */
129
- public stub<Route extends string>(
130
- method: HttpMethod,
131
- route: Route,
132
- response: RouteResponseCallback<Route, unknown>,
133
- ): void {
134
- this.wrappedStub.stub<Route>(method, route, async (request) => {
135
- if (this.options.delay > 0) await sleep(this.options.delay);
136
- return await this.runRequest(method, route, response, request);
137
- });
138
- }
139
-
140
- /**
141
- * The stub2 method provides a way to set the type of the body that is sent.
142
- * Due to restrictions in TypeScript (https://github.com/microsoft/TypeScript/issues/10571, https://github.com/Microsoft/TypeScript/pull/26349),
143
- * We have to hacke a bit here. Calling stub2<T>() will return the stub method with a body of type T.
144
- *
145
- * Usage:
146
- * ```
147
- * .stub2<MyRequest>()('GET', '/api/test', ({ body }) => {
148
- * // body is of type MyRequest
149
- * });
150
- * ```
151
- * @returns The stub method with a body of type T.
152
- */
153
- public stub2<T>(): <Route extends string>(
154
- method: HttpMethod,
155
- route: Route,
156
- response: RouteResponseCallback<Route, T>,
157
- ) => void {
158
- return <Route extends string>(method: HttpMethod, route: Route, response: RouteResponseCallback<Route, T>) => {
159
- this.wrappedStub.stub2<T>()<Route>(method, route, async (request) => {
160
- if (this.options.delay > 0) await sleep(this.options.delay);
161
- return await this.runRequest(method, route, response, request);
162
- });
163
- };
164
- }
165
-
166
- /**
167
- * Reset the stubs and requests.
168
- */
169
- public reset(): void {
170
- this._requests = [];
171
- this.wrappedStub['_config'].stubs = [];
172
- }
173
-
174
- private async runRequest<Route extends string, T>(
175
- method: HttpMethod,
176
- route: Route,
177
- response: RouteResponseCallback<Route, T>,
178
- request: StubRequestInfo<Route, T>,
179
- ): Promise<unknown> {
180
- if (this.options.rememberRequests) {
181
- this._requests.push({ method, route, request });
182
- }
183
- this.log('request', method, route, request, '#7FFFFF');
184
- try {
185
- const r = await response(request);
186
- this.options.responseCallback?.(r);
187
- this.log('response', method, route, r, '#7FFF8E');
188
- return r;
189
- } catch (error: unknown) {
190
- this.options.responseCallback?.(error);
191
- if (isHttpResponse(error) && error.statusCode >= 200 && error.statusCode < 300) {
192
- this.log('response', method, route, error.content, '#7FFF8E');
193
- throw error;
194
- } else {
195
- const isError = isHttpResponse(error) && error.statusCode >= 400 && error.statusCode < 600;
196
- this.log('response', method, route, error, isError ? '#FF7F7F' : '7F7F7F');
197
- throw error;
198
- }
199
- }
200
- }
201
-
202
- private log(type: 'request' | 'response', method: HttpMethod, route: string, data: unknown, color: string) {
203
- if (type === 'request' && !this.options.logRequests) return;
204
- if (type === 'response' && !this.options.logResponses) return;
205
- const typeDisplay = type === 'request' ? ' [req]' : '[resp]';
206
- const strippedRoute = route.match(/[^?]*(?=\?)?/)?.[0];
207
- console.log(`%c${typeDisplay} ${method}: ${this.options.logUrlPrefix}${strippedRoute}`, `color:${color};`, data);
208
- }
209
- }
210
-
211
- /**
212
- * Base class for generated easy network stubs.
213
- */
214
- export class EasyNetworkStubBase {
215
- protected readonly stubWrapper: EasyNetworkStubWrapper;
216
- protected readonly ownsStubWrapper: boolean;
217
-
218
- constructor(stub: EasyNetworkStub | EasyNetworkStubWrapper, options?: EasyNetworkStubWrapperOptions) {
219
- this.stubWrapper = stub instanceof EasyNetworkStubWrapper ? stub : new EasyNetworkStubWrapper(stub, options);
220
- this.ownsStubWrapper = !(stub instanceof EasyNetworkStubWrapper);
221
- }
222
-
223
- public reset() {
224
- if (this.ownsStubWrapper) {
225
- this.stubWrapper.reset();
226
- }
227
- }
228
- }
229
-
230
- export type EasyNetworkStubGroup<Group, GroupContainer> = Group & {
231
- (stubActions: (stubs: Group) => void): GroupContainer;
232
- };
233
-
234
- // eslint-disable-next-line @typescript-eslint/ban-types
235
- declare interface GroupType<T> extends Function {
236
- new (stubWrapper: EasyNetworkStubWrapper): T;
237
- }
238
-
239
- export function createEasyNetworkStubGroup<GroupContainer, Group>(
240
- container: GroupContainer,
241
- stubWrapper: EasyNetworkStubWrapper,
242
- groupType: GroupType<Group>,
243
- ): EasyNetworkStubGroup<Group, GroupContainer> {
244
- const group = new groupType(stubWrapper);
245
- const groupFn = (stubActions: (stubs: Group) => void) => {
246
- stubActions(group);
247
- return container;
248
- };
249
- Object.setPrototypeOf(groupFn, groupType.prototype);
250
- return Object.assign(groupFn, group);
251
- }
252
-
253
- function sleep(ms: number): Promise<void> {
254
- return new Promise((resolve) => setTimeout(resolve, ms));
255
- }
256
-
257
- function isHttpResponse(value: unknown): value is ErrorResponse<unknown> {
258
- return typeof value === 'object' && value !== null && 'statusCode' in value;
259
- }
1
+ import type { EasyNetworkStub } from 'easy-network-stub';
2
+
3
+ import type { ErrorResponse, HttpMethod, RouteResponseCallback } from 'easy-network-stub';
4
+
5
+ /**
6
+ * Options for the `EasyNetworkStubWrapper`.
7
+ */
8
+ export type EasyNetworkStubWrapperOptions = {
9
+ /**
10
+ * Delay in milliseconds before responding.
11
+ * @default 0
12
+ */
13
+ delay: number;
14
+ /**
15
+ * Whether to log requests to the console.
16
+ * @default false
17
+ */
18
+ logRequests: boolean;
19
+ /**
20
+ * Whether to log responses to the console.
21
+ * @default false
22
+ */
23
+ logResponses: boolean;
24
+ /**
25
+ * Whether to remember requests. Remebered requests can be accessed via the `requests` property.
26
+ * @default false
27
+ */
28
+ rememberRequests: boolean;
29
+ /**
30
+ * Function to call when a response is sent.
31
+ * @param response The response that was sent.
32
+ * @default undefined
33
+ */
34
+ responseCallback?: (response: unknown) => void;
35
+ /**
36
+ * A prefix to add to the URL in log messages.
37
+ * @default /api/
38
+ */
39
+ logUrlPrefix: string;
40
+ };
41
+
42
+ /**
43
+ * Represents a request intercepted by the `EasyNetworkStubWrapper`.
44
+ */
45
+ export type StubRequestItem = {
46
+ /**
47
+ * The HTTP method of the request.
48
+ */
49
+ method: HttpMethod;
50
+ /**
51
+ * The route of the request.
52
+ */
53
+ route: string;
54
+ /**
55
+ * The request information provided by `easy-network-stub`.
56
+ */
57
+ request: StubRequestInfo;
58
+ };
59
+
60
+ /**
61
+ * Represents the request information provided by `easy-network-stub`.
62
+ */
63
+ export type StubRequestInfo<TRoute extends string = string, TBody = unknown> = Parameters<
64
+ RouteResponseCallback<TRoute, TBody>
65
+ >[0];
66
+
67
+ /**
68
+ * A strict version of `RouteResponseCallback` that allows for a responder to be passed as the first argument.
69
+ */
70
+ export type StrictRouteResponseCallback<T, P extends string, R> = (
71
+ respondWith: R,
72
+ ...args: Parameters<RouteResponseCallback<P, T>>
73
+ ) => ErrorResponse<any> | Promise<ErrorResponse<any>>;
74
+
75
+ type _UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
76
+ type __StubResponder<T extends Record<number, unknown>, S> = S extends number
77
+ ? [T[S]] extends [never] ? (statusCode: S) => ErrorResponse<T[S]>
78
+ : (statusCode: S, content: T[S]) => ErrorResponse<T[S]>
79
+ : never;
80
+ type _StubResponder<T extends Record<number, unknown>> = _UnionToIntersection<__StubResponder<T, keyof T>>;
81
+ const untypedResponder = (statusCode: number, content?: unknown) => ({ statusCode, content });
82
+
83
+ /**
84
+ * Gets the responder function typed to a specific set of status codes.
85
+ * @returns The responder function.
86
+ */
87
+ export function getStubResponder<T extends Record<number, unknown>>(): _StubResponder<T> {
88
+ return untypedResponder as _StubResponder<T>;
89
+ }
90
+
91
+ /**
92
+ * Wrapper for `EasyNetworkStub` that adds additional functionality.
93
+ */
94
+ export class EasyNetworkStubWrapper {
95
+ private _requests: StubRequestItem[] = [];
96
+
97
+ /**
98
+ * The options for the wrapper.
99
+ */
100
+ public readonly options: Readonly<EasyNetworkStubWrapperOptions>;
101
+
102
+ /**
103
+ * The requests that have been intercepted by the wrapper.
104
+ */
105
+ public get requests(): ReadonlyArray<StubRequestItem> {
106
+ return this._requests;
107
+ }
108
+
109
+ constructor(
110
+ public readonly wrappedStub: EasyNetworkStub,
111
+ options?: Partial<EasyNetworkStubWrapperOptions>,
112
+ ) {
113
+ this.options = {
114
+ delay: options?.delay ?? 0,
115
+ logRequests: options?.logRequests ?? false,
116
+ logResponses: options?.logResponses ?? false,
117
+ rememberRequests: options?.rememberRequests ?? false,
118
+ responseCallback: options?.responseCallback,
119
+ logUrlPrefix: options?.logUrlPrefix ?? '/api/',
120
+ };
121
+ }
122
+
123
+ /**
124
+ * Add a single api stub to your intercepted routes.
125
+ * @param method The http method that should be stubbed
126
+ * @param route The route that should be stubbed. Supports parameters in the form of {name:type}.
127
+ * @param response The callback in which you can process the request and reply with the stub. When a Promise is returned, the stub response will be delayed until it is resolved.
128
+ */
129
+ public stub<Route extends string>(
130
+ method: HttpMethod,
131
+ route: Route,
132
+ response: RouteResponseCallback<Route, unknown>,
133
+ ): void {
134
+ this.wrappedStub.stub<Route>(method, route, async (request) => {
135
+ if (this.options.delay > 0) await sleep(this.options.delay);
136
+ return await this.runRequest(method, route, response, request);
137
+ });
138
+ }
139
+
140
+ /**
141
+ * The stub2 method provides a way to set the type of the body that is sent.
142
+ * Due to restrictions in TypeScript (https://github.com/microsoft/TypeScript/issues/10571, https://github.com/Microsoft/TypeScript/pull/26349),
143
+ * We have to hacke a bit here. Calling stub2<T>() will return the stub method with a body of type T.
144
+ *
145
+ * Usage:
146
+ * ```
147
+ * .stub2<MyRequest>()('GET', '/api/test', ({ body }) => {
148
+ * // body is of type MyRequest
149
+ * });
150
+ * ```
151
+ * @returns The stub method with a body of type T.
152
+ */
153
+ public stub2<T>(): <Route extends string>(
154
+ method: HttpMethod,
155
+ route: Route,
156
+ response: RouteResponseCallback<Route, T>,
157
+ ) => void {
158
+ return <Route extends string>(method: HttpMethod, route: Route, response: RouteResponseCallback<Route, T>) => {
159
+ this.wrappedStub.stub2<T>()<Route>(method, route, async (request) => {
160
+ if (this.options.delay > 0) await sleep(this.options.delay);
161
+ return await this.runRequest(method, route, response, request);
162
+ });
163
+ };
164
+ }
165
+
166
+ /**
167
+ * Reset the stubs and requests.
168
+ */
169
+ public reset(): void {
170
+ this._requests = [];
171
+ this.wrappedStub['_config'].stubs = [];
172
+ }
173
+
174
+ private async runRequest<Route extends string, T>(
175
+ method: HttpMethod,
176
+ route: Route,
177
+ response: RouteResponseCallback<Route, T>,
178
+ request: StubRequestInfo<Route, T>,
179
+ ): Promise<unknown> {
180
+ if (this.options.rememberRequests) {
181
+ this._requests.push({ method, route, request });
182
+ }
183
+ this.log('request', method, route, request, '#7FFFFF');
184
+ try {
185
+ const r = await response(request);
186
+ this.options.responseCallback?.(r);
187
+ this.log('response', method, route, r, '#7FFF8E');
188
+ return r;
189
+ } catch (error: unknown) {
190
+ this.options.responseCallback?.(error);
191
+ if (isHttpResponse(error) && error.statusCode >= 200 && error.statusCode < 300) {
192
+ this.log('response', method, route, error.content, '#7FFF8E');
193
+ throw error;
194
+ } else {
195
+ const isError = isHttpResponse(error) && error.statusCode >= 400 && error.statusCode < 600;
196
+ this.log('response', method, route, error, isError ? '#FF7F7F' : '7F7F7F');
197
+ throw error;
198
+ }
199
+ }
200
+ }
201
+
202
+ private log(type: 'request' | 'response', method: HttpMethod, route: string, data: unknown, color: string) {
203
+ if (type === 'request' && !this.options.logRequests) return;
204
+ if (type === 'response' && !this.options.logResponses) return;
205
+ const typeDisplay = type === 'request' ? ' [req]' : '[resp]';
206
+ const strippedRoute = route.match(/[^?]*(?=\?)?/)?.[0];
207
+ console.log(`%c${typeDisplay} ${method}: ${this.options.logUrlPrefix}${strippedRoute}`, `color:${color};`, data);
208
+ }
209
+ }
210
+
211
+ /**
212
+ * Base class for generated easy network stubs.
213
+ */
214
+ export class EasyNetworkStubBase {
215
+ protected readonly stubWrapper: EasyNetworkStubWrapper;
216
+ protected readonly ownsStubWrapper: boolean;
217
+
218
+ constructor(stub: EasyNetworkStub | EasyNetworkStubWrapper, options?: EasyNetworkStubWrapperOptions) {
219
+ this.stubWrapper = stub instanceof EasyNetworkStubWrapper ? stub : new EasyNetworkStubWrapper(stub, options);
220
+ this.ownsStubWrapper = !(stub instanceof EasyNetworkStubWrapper);
221
+ }
222
+
223
+ public reset() {
224
+ if (this.ownsStubWrapper) {
225
+ this.stubWrapper.reset();
226
+ }
227
+ }
228
+ }
229
+
230
+ export type EasyNetworkStubGroup<Group, GroupContainer> = Group & {
231
+ (stubActions: (stubs: Group) => void): GroupContainer;
232
+ };
233
+
234
+ // eslint-disable-next-line @typescript-eslint/ban-types
235
+ declare interface GroupType<T> extends Function {
236
+ new (stubWrapper: EasyNetworkStubWrapper): T;
237
+ }
238
+
239
+ export function createEasyNetworkStubGroup<GroupContainer, Group>(
240
+ container: GroupContainer,
241
+ stubWrapper: EasyNetworkStubWrapper,
242
+ groupType: GroupType<Group>,
243
+ ): EasyNetworkStubGroup<Group, GroupContainer> {
244
+ const group = new groupType(stubWrapper);
245
+ const groupFn = (stubActions: (stubs: Group) => void) => {
246
+ stubActions(group);
247
+ return container;
248
+ };
249
+ Object.setPrototypeOf(groupFn, groupType.prototype);
250
+ return Object.assign(groupFn, group);
251
+ }
252
+
253
+ function sleep(ms: number): Promise<void> {
254
+ return new Promise((resolve) => setTimeout(resolve, ms));
255
+ }
256
+
257
+ function isHttpResponse(value: unknown): value is ErrorResponse<unknown> {
258
+ return typeof value === 'object' && value !== null && 'statusCode' in value;
259
+ }
@@ -24,7 +24,7 @@ export declare class DefaultTypeScriptModelGenerator extends TypeScriptFileGener
24
24
  skipSchemas?: boolean;
25
25
  useBaseType?: boolean;
26
26
  }): ts.Type<Builder> | null;
27
- protected getStringType(_ctx: Context, schema: StringLikeApiSchema): ts.Type<Builder>;
27
+ protected getStringType(ctx: Context, schema: StringLikeApiSchema): ts.Type<Builder>;
28
28
  protected getArrayType(ctx: Context, schema: ArrayLikeApiSchema): ts.Type<Builder>;
29
29
  protected getObjectType(ctx: Context, schema: ObjectLikeApiSchema): ts.Type<Builder>;
30
30
  protected getDiscriminatorType(ctx: Context, schema: ApiSchema): ts.Type<Builder>;
@@ -1 +1 @@
1
- {"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"m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
222
- getStringType(_ctx, schema) {
222
+ getStringType(ctx, schema) {
223
223
  if (schema.format === 'binary') {
224
- return ts.refs.blob();
224
+ return ctx.config.binarySchemaType();
225
225
  }
226
226
  return 'string';
227
227
  }
@@ -1,6 +1,8 @@
1
1
  import type { ApiSchema, DefaultGenerationProviderConfig, ExtendedStringCasing, Nullable, OpenApiSchemasGenerationProviderContext } from '@goast/core';
2
+ import { ts } from '../../ast/index.js';
2
3
  import type { TypeScriptComponentOutput } from '../../common-results.js';
3
4
  import { type TypeScriptGeneratorConfig } from '../../config.js';
5
+ import type { TypeScriptFileBuilder } from '../../file-builder.js';
4
6
  export type TypeScriptModelGeneratorConfig = TypeScriptGeneratorConfig & {
5
7
  /**
6
8
  * Determines how to generate enums.
@@ -41,6 +43,11 @@ export type TypeScriptModelGeneratorConfig = TypeScriptGeneratorConfig & {
41
43
  * @default `_<SchemaName>Base`
42
44
  */
43
45
  discriminatorBaseTypeCasing: ExtendedStringCasing;
46
+ /**
47
+ * The type to use for binary schemas.
48
+ * @default `ts.refs.blob`
49
+ */
50
+ binarySchemaType: () => ts.Type<TypeScriptFileBuilder>;
44
51
  };
45
52
  export type TypeScriptModelsGeneratorConfig = TypeScriptModelGeneratorConfig & {
46
53
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,+BAA+B,EAC/B,oBAAoB,EACpB,QAAQ,EACR,uCAAuC,EACxC,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAoC,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAEnG,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,GAAG;IACvE;;;;;OAKG;IACH,cAAc,EAAE,OAAO,GAAG,aAAa,CAAC;IAExC;;;OAGG;IACH,cAAc,EAAE,OAAO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YACV,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;SAC1B,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,CAAC;AAEvE,MAAM,MAAM,gCAAgC,GAAG,uCAAuC,CACpF,8BAA8B,EAC9B,+BAA+B,EAC/B,+BAA+B,EAC/B,8BAA8B,CAC/B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,gCAAgC,GAAG;IAC/E,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { ts } from '../../ast/index.js';
1
2
  import { defaultTypeScriptGeneratorConfig } from '../../config.js';
2
3
  export const defaultTypeScriptModelGeneratorConfig = {
3
4
  ...defaultTypeScriptGeneratorConfig,
@@ -8,6 +9,7 @@ export const defaultTypeScriptModelGeneratorConfig = {
8
9
  modelFileNameCasing: undefined,
9
10
  typeDeclaration: 'type',
10
11
  discriminatorBaseTypeCasing: { casing: 'pascal', prefix: '_', suffix: 'Base' },
12
+ binarySchemaType: ts.refs.blob,
11
13
  };
12
14
  export const defaultTypeScriptModelsGeneratorConfig = {
13
15
  ...defaultTypeScriptModelGeneratorConfig,
@@ -229,13 +229,13 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
229
229
  ], '\n'), { multiline: true })
230
230
  : null,
231
231
  '',
232
- s `return ${ctx.refs.waitForResponse([responseModelType])}(${s.indent `
233
- this.http.request(rb.build({${s.indent `
234
- responseType: ${ts.string(responseType)},
235
- accept: ${ts.string(accept)},
236
- context,`}
237
- })),
238
- {${s.indent `
232
+ s `return ${ctx.refs.waitForResponse([responseModelType])}(${s.indent `
233
+ this.http.request(rb.build({${s.indent `
234
+ responseType: ${ts.string(responseType)},
235
+ accept: ${ts.string(accept)},
236
+ context,`}
237
+ })),
238
+ {${s.indent `
239
239
  errorResponseTypes: ${ts.object({
240
240
  members: [
241
241
  ...Object.entries(this.getEndpointStatusCodes(ctx, endpoint))
@@ -244,8 +244,8 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
244
244
  return ts.property(key, { value: ts.string(value.parser) });
245
245
  }),
246
246
  ],
247
- })}`}
248
- }`}
247
+ })}`}
248
+ }`}
249
249
  )`,
250
250
  ], '\n'),
251
251
  });