@goast/typescript 0.5.1-k6.3 → 0.5.2-k6.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.
@@ -1,5 +1,7 @@
1
1
  // @deno-types="npm:@types/k6/http"
2
2
  import http, { Params, Response } from 'k6/http';
3
+ // @ts-ignore
4
+ import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js';
3
5
 
4
6
  /**
5
7
  * Defines the options for appending a parameter
@@ -265,6 +267,13 @@ export class RequestBuilder {
265
267
  }
266
268
  }
267
269
  this._bodyContent = pairs.map((p) => `${encodeURIComponent(p[0])}=${encodeURIComponent(p[1])}`).join('&');
270
+ } else if (this._bodyContentType === 'multipart/form-data' && value !== null && typeof value === 'object') {
271
+ const fd = new FormData();
272
+ for (const key in value) {
273
+ fd.append(key, this.formDataValue(value[key]));
274
+ }
275
+ this._bodyContent = fd.body();
276
+ this._bodyContentType = 'multipart/form-data; boundary=' + fd.boundary;
268
277
  } else if (this._bodyContentType.indexOf('json') !== -1 && value !== null && typeof value === 'object') {
269
278
  this._bodyContent = JSON.stringify(value);
270
279
  } else {
@@ -277,10 +286,22 @@ export class RequestBuilder {
277
286
  if (value === null || value === undefined) {
278
287
  return null;
279
288
  }
280
- if (typeof value === 'object') {
281
- return JSON.stringify(value);
289
+ if (this.isFile(value)) {
290
+ return value;
282
291
  }
283
- return String(value);
292
+ return { data: JSON.stringify(value), content_type: 'application/json' };
293
+ }
294
+
295
+ private isFile(value: any): value is http.FileData {
296
+ return (
297
+ typeof value === 'object' &&
298
+ value !== null &&
299
+ 'data' in value &&
300
+ (typeof value.data === 'string' || value.data instanceof ArrayBuffer) &&
301
+ (!('filename' in value) || typeof value.filename === 'string') &&
302
+ (!('content_type' in value) || typeof value.content_type === 'string') &&
303
+ Object.keys(value).every((key) => key === 'data' || key === 'filename' || key === 'content_type')
304
+ );
284
305
  }
285
306
 
286
307
  /**
@@ -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
+ }
@@ -2,7 +2,7 @@ import type { ApiSchema, DefaultGenerationProviderConfig, ExtendedStringCasing,
2
2
  import { ts } from '../../ast/index.js';
3
3
  import type { TypeScriptComponentOutput } from '../../common-results.js';
4
4
  import { type TypeScriptGeneratorConfig } from '../../config.js';
5
- import { TypeScriptFileBuilder } from '../../file-builder.js';
5
+ import type { TypeScriptFileBuilder } from '../../file-builder.js';
6
6
  export type TypeScriptModelGeneratorConfig = TypeScriptGeneratorConfig & {
7
7
  /**
8
8
  * Determines how to generate enums.
@@ -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,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAoC,KAAK,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,MAAM,8BAA8B,GAAG,yBAAyB,GAAG;IACvE;;;;;OAKG;IAC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AE,CAAC;AAEhD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,UAAU,EAAE;QACV,MAAM,EAAE;YACN,CAAC,QAAQ,EAAE,MAAM,GAAG,8BAA8B,CAAC;SACpD,CAAC;QACF,UAAU,EAAE;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"}
@@ -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
  });
@@ -94,15 +94,15 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
94
94
  ],
95
95
  returnType: 'this',
96
96
  body: appendValueGroup([
97
- s `this.stubWrapper.stub2<${requestType}>()(${s.indent `
98
- ${ts.string(endpoint.method.toUpperCase())},
99
- ${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
100
- async (request) => {${s.indent `
101
- if (this.stubWrapper.options.rememberRequests) {${s.indent `
102
- this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
103
- }
104
- throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
105
- }`}
97
+ s `this.stubWrapper.stub2<${requestType}>()(${s.indent `
98
+ ${ts.string(endpoint.method.toUpperCase())},
99
+ ${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
100
+ async (request) => {${s.indent `
101
+ if (this.stubWrapper.options.rememberRequests) {${s.indent `
102
+ this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
103
+ }
104
+ throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
105
+ }`}
106
106
  );`,
107
107
  'return this;',
108
108
  ], '\n'),
@@ -131,7 +131,7 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
131
131
  const method = this.getInterfaceEndpointMethod(ctx, endpoint);
132
132
  method.accessModifier = 'public';
133
133
  method.body = appendValueGroup([
134
- s `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${s.indent `
134
+ s `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${s.indent `
135
135
  .withPath(${ts.string(endpoint.path)})${(b) => b.forEach(endpoint.parameters, (b, p) => {
136
136
  switch (p.target) {
137
137
  case 'path':
@@ -141,7 +141,7 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
141
141
  b.append(s `\n.withQueryParam(${ts.string(p.name)}, params.${toCasing(p.name, ctx.config.paramNameCasing)})`);
142
142
  break;
143
143
  }
144
- })}
144
+ })}
145
145
  .build();`}`,
146
146
  s `const response = (this.options.fetch ?? fetch)(url, ${ts.object({
147
147
  members: [