@goast/typescript 0.3.8-beta1 → 0.3.8

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,260 +1,260 @@
1
- import { EasyNetworkStub } from 'easy-network-stub';
2
-
3
- import type { HttpMethod, RouteResponseCallback, ErrorResponse } 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]
78
- ? (statusCode: S) => ErrorResponse<T[S]>
79
- : (statusCode: S, content: T[S]) => ErrorResponse<T[S]>
80
- : never;
81
- type _StubResponder<T extends Record<number, unknown>> = _UnionToIntersection<__StubResponder<T, keyof T>>;
82
- const untypedResponder = (statusCode: number, content?: unknown) => ({ statusCode, content });
83
-
84
- /**
85
- * Gets the responder function typed to a specific set of status codes.
86
- * @returns The responder function.
87
- */
88
- export function getStubResponder<T extends Record<number, unknown>>(): _StubResponder<T> {
89
- return untypedResponder as _StubResponder<T>;
90
- }
91
-
92
- /**
93
- * Wrapper for `EasyNetworkStub` that adds additional functionality.
94
- */
95
- export class EasyNetworkStubWrapper {
96
- private _requests: StubRequestItem[] = [];
97
-
98
- /**
99
- * The options for the wrapper.
100
- */
101
- public readonly options: Readonly<EasyNetworkStubWrapperOptions>;
102
-
103
- /**
104
- * The requests that have been intercepted by the wrapper.
105
- */
106
- public get requests(): ReadonlyArray<StubRequestItem> {
107
- return this._requests;
108
- }
109
-
110
- constructor(
111
- public readonly wrappedStub: EasyNetworkStub,
112
- options?: Partial<EasyNetworkStubWrapperOptions>,
113
- ) {
114
- this.options = {
115
- delay: options?.delay ?? 0,
116
- logRequests: options?.logRequests ?? false,
117
- logResponses: options?.logResponses ?? false,
118
- rememberRequests: options?.rememberRequests ?? false,
119
- responseCallback: options?.responseCallback,
120
- logUrlPrefix: options?.logUrlPrefix ?? '/api/',
121
- };
122
- }
123
-
124
- /**
125
- * Add a single api stub to your intercepted routes.
126
- * @param method The http method that should be stubbed
127
- * @param route The route that should be stubbed. Supports parameters in the form of {name:type}.
128
- * @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.
129
- */
130
- public stub<Route extends string>(
131
- method: HttpMethod,
132
- route: Route,
133
- response: RouteResponseCallback<Route, unknown>,
134
- ): void {
135
- this.wrappedStub.stub<Route>(method, route, async (request) => {
136
- if (this.options.delay > 0) await sleep(this.options.delay);
137
- return await this.runRequest(method, route, response, request);
138
- });
139
- }
140
-
141
- /**
142
- * The stub2 method provides a way to set the type of the body that is sent.
143
- * Due to restrictions in TypeScript (https://github.com/microsoft/TypeScript/issues/10571, https://github.com/Microsoft/TypeScript/pull/26349),
144
- * We have to hacke a bit here. Calling stub2<T>() will return the stub method with a body of type T.
145
- *
146
- * Usage:
147
- * ```
148
- * .stub2<MyRequest>()('GET', '/api/test', ({ body }) => {
149
- * // body is of type MyRequest
150
- * });
151
- * ```
152
- * @returns The stub method with a body of type T.
153
- */
154
- public stub2<T>(): <Route extends string>(
155
- method: HttpMethod,
156
- route: Route,
157
- response: RouteResponseCallback<Route, T>,
158
- ) => void {
159
- return <Route extends string>(method: HttpMethod, route: Route, response: RouteResponseCallback<Route, T>) => {
160
- this.wrappedStub.stub2<T>()<Route>(method, route, async (request) => {
161
- if (this.options.delay > 0) await sleep(this.options.delay);
162
- return await this.runRequest(method, route, response, request);
163
- });
164
- };
165
- }
166
-
167
- /**
168
- * Reset the stubs and requests.
169
- */
170
- public reset(): void {
171
- this._requests = [];
172
- this.wrappedStub['_config'].stubs = [];
173
- }
174
-
175
- private async runRequest<Route extends string, T>(
176
- method: HttpMethod,
177
- route: Route,
178
- response: RouteResponseCallback<Route, T>,
179
- request: StubRequestInfo<Route, T>,
180
- ): Promise<unknown> {
181
- if (this.options.rememberRequests) {
182
- this._requests.push({ method, route, request });
183
- }
184
- this.log('request', method, route, request, '#7FFFFF');
185
- try {
186
- const r = await response(request);
187
- this.options.responseCallback?.(r);
188
- this.log('response', method, route, r, '#7FFF8E');
189
- return r;
190
- } catch (error: unknown) {
191
- this.options.responseCallback?.(error);
192
- if (isHttpResponse(error) && error.statusCode >= 200 && error.statusCode < 300) {
193
- this.log('response', method, route, error.content, '#7FFF8E');
194
- throw error;
195
- } else {
196
- const isError = isHttpResponse(error) && error.statusCode >= 400 && error.statusCode < 600;
197
- this.log('response', method, route, error, isError ? '#FF7F7F' : '7F7F7F');
198
- throw error;
199
- }
200
- }
201
- }
202
-
203
- private log(type: 'request' | 'response', method: HttpMethod, route: string, data: unknown, color: string) {
204
- if (type === 'request' && !this.options.logRequests) return;
205
- if (type === 'response' && !this.options.logResponses) return;
206
- const typeDisplay = type === 'request' ? ' [req]' : '[resp]';
207
- const strippedRoute = route.match(/[^?]*(?=\?)?/)?.[0];
208
- console.log(`%c${typeDisplay} ${method}: ${this.options.logUrlPrefix}${strippedRoute}`, `color:${color};`, data);
209
- }
210
- }
211
-
212
- /**
213
- * Base class for generated easy network stubs.
214
- */
215
- export class EasyNetworkStubBase {
216
- protected readonly stubWrapper: EasyNetworkStubWrapper;
217
- protected readonly ownsStubWrapper: boolean;
218
-
219
- constructor(stub: EasyNetworkStub | EasyNetworkStubWrapper, options?: EasyNetworkStubWrapperOptions) {
220
- this.stubWrapper = stub instanceof EasyNetworkStubWrapper ? stub : new EasyNetworkStubWrapper(stub, options);
221
- this.ownsStubWrapper = !(stub instanceof EasyNetworkStubWrapper);
222
- }
223
-
224
- public reset() {
225
- if (this.ownsStubWrapper) {
226
- this.stubWrapper.reset();
227
- }
228
- }
229
- }
230
-
231
- export type EasyNetworkStubGroup<Group, GroupContainer> = Group & {
232
- (stubActions: (stubs: Group) => void): GroupContainer;
233
- };
234
-
235
- // eslint-disable-next-line @typescript-eslint/ban-types
236
- declare interface GroupType<T> extends Function {
237
- new (stubWrapper: EasyNetworkStubWrapper): T;
238
- }
239
-
240
- export function createEasyNetworkStubGroup<GroupContainer, Group>(
241
- container: GroupContainer,
242
- stubWrapper: EasyNetworkStubWrapper,
243
- groupType: GroupType<Group>,
244
- ): EasyNetworkStubGroup<Group, GroupContainer> {
245
- const group = new groupType(stubWrapper);
246
- const groupFn = (stubActions: (stubs: Group) => void) => {
247
- stubActions(group);
248
- return container;
249
- };
250
- Object.setPrototypeOf(groupFn, groupType.prototype);
251
- return Object.assign(groupFn, group);
252
- }
253
-
254
- function sleep(ms: number): Promise<void> {
255
- return new Promise((resolve) => setTimeout(resolve, ms));
256
- }
257
-
258
- function isHttpResponse(value: unknown): value is ErrorResponse<unknown> {
259
- return typeof value === 'object' && value !== null && 'statusCode' in value;
260
- }
1
+ import { EasyNetworkStub } from 'easy-network-stub';
2
+
3
+ import type { HttpMethod, RouteResponseCallback, ErrorResponse } 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]
78
+ ? (statusCode: S) => ErrorResponse<T[S]>
79
+ : (statusCode: S, content: T[S]) => ErrorResponse<T[S]>
80
+ : never;
81
+ type _StubResponder<T extends Record<number, unknown>> = _UnionToIntersection<__StubResponder<T, keyof T>>;
82
+ const untypedResponder = (statusCode: number, content?: unknown) => ({ statusCode, content });
83
+
84
+ /**
85
+ * Gets the responder function typed to a specific set of status codes.
86
+ * @returns The responder function.
87
+ */
88
+ export function getStubResponder<T extends Record<number, unknown>>(): _StubResponder<T> {
89
+ return untypedResponder as _StubResponder<T>;
90
+ }
91
+
92
+ /**
93
+ * Wrapper for `EasyNetworkStub` that adds additional functionality.
94
+ */
95
+ export class EasyNetworkStubWrapper {
96
+ private _requests: StubRequestItem[] = [];
97
+
98
+ /**
99
+ * The options for the wrapper.
100
+ */
101
+ public readonly options: Readonly<EasyNetworkStubWrapperOptions>;
102
+
103
+ /**
104
+ * The requests that have been intercepted by the wrapper.
105
+ */
106
+ public get requests(): ReadonlyArray<StubRequestItem> {
107
+ return this._requests;
108
+ }
109
+
110
+ constructor(
111
+ public readonly wrappedStub: EasyNetworkStub,
112
+ options?: Partial<EasyNetworkStubWrapperOptions>,
113
+ ) {
114
+ this.options = {
115
+ delay: options?.delay ?? 0,
116
+ logRequests: options?.logRequests ?? false,
117
+ logResponses: options?.logResponses ?? false,
118
+ rememberRequests: options?.rememberRequests ?? false,
119
+ responseCallback: options?.responseCallback,
120
+ logUrlPrefix: options?.logUrlPrefix ?? '/api/',
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Add a single api stub to your intercepted routes.
126
+ * @param method The http method that should be stubbed
127
+ * @param route The route that should be stubbed. Supports parameters in the form of {name:type}.
128
+ * @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.
129
+ */
130
+ public stub<Route extends string>(
131
+ method: HttpMethod,
132
+ route: Route,
133
+ response: RouteResponseCallback<Route, unknown>,
134
+ ): void {
135
+ this.wrappedStub.stub<Route>(method, route, async (request) => {
136
+ if (this.options.delay > 0) await sleep(this.options.delay);
137
+ return await this.runRequest(method, route, response, request);
138
+ });
139
+ }
140
+
141
+ /**
142
+ * The stub2 method provides a way to set the type of the body that is sent.
143
+ * Due to restrictions in TypeScript (https://github.com/microsoft/TypeScript/issues/10571, https://github.com/Microsoft/TypeScript/pull/26349),
144
+ * We have to hacke a bit here. Calling stub2<T>() will return the stub method with a body of type T.
145
+ *
146
+ * Usage:
147
+ * ```
148
+ * .stub2<MyRequest>()('GET', '/api/test', ({ body }) => {
149
+ * // body is of type MyRequest
150
+ * });
151
+ * ```
152
+ * @returns The stub method with a body of type T.
153
+ */
154
+ public stub2<T>(): <Route extends string>(
155
+ method: HttpMethod,
156
+ route: Route,
157
+ response: RouteResponseCallback<Route, T>,
158
+ ) => void {
159
+ return <Route extends string>(method: HttpMethod, route: Route, response: RouteResponseCallback<Route, T>) => {
160
+ this.wrappedStub.stub2<T>()<Route>(method, route, async (request) => {
161
+ if (this.options.delay > 0) await sleep(this.options.delay);
162
+ return await this.runRequest(method, route, response, request);
163
+ });
164
+ };
165
+ }
166
+
167
+ /**
168
+ * Reset the stubs and requests.
169
+ */
170
+ public reset(): void {
171
+ this._requests = [];
172
+ this.wrappedStub['_config'].stubs = [];
173
+ }
174
+
175
+ private async runRequest<Route extends string, T>(
176
+ method: HttpMethod,
177
+ route: Route,
178
+ response: RouteResponseCallback<Route, T>,
179
+ request: StubRequestInfo<Route, T>,
180
+ ): Promise<unknown> {
181
+ if (this.options.rememberRequests) {
182
+ this._requests.push({ method, route, request });
183
+ }
184
+ this.log('request', method, route, request, '#7FFFFF');
185
+ try {
186
+ const r = await response(request);
187
+ this.options.responseCallback?.(r);
188
+ this.log('response', method, route, r, '#7FFF8E');
189
+ return r;
190
+ } catch (error: unknown) {
191
+ this.options.responseCallback?.(error);
192
+ if (isHttpResponse(error) && error.statusCode >= 200 && error.statusCode < 300) {
193
+ this.log('response', method, route, error.content, '#7FFF8E');
194
+ throw error;
195
+ } else {
196
+ const isError = isHttpResponse(error) && error.statusCode >= 400 && error.statusCode < 600;
197
+ this.log('response', method, route, error, isError ? '#FF7F7F' : '7F7F7F');
198
+ throw error;
199
+ }
200
+ }
201
+ }
202
+
203
+ private log(type: 'request' | 'response', method: HttpMethod, route: string, data: unknown, color: string) {
204
+ if (type === 'request' && !this.options.logRequests) return;
205
+ if (type === 'response' && !this.options.logResponses) return;
206
+ const typeDisplay = type === 'request' ? ' [req]' : '[resp]';
207
+ const strippedRoute = route.match(/[^?]*(?=\?)?/)?.[0];
208
+ console.log(`%c${typeDisplay} ${method}: ${this.options.logUrlPrefix}${strippedRoute}`, `color:${color};`, data);
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Base class for generated easy network stubs.
214
+ */
215
+ export class EasyNetworkStubBase {
216
+ protected readonly stubWrapper: EasyNetworkStubWrapper;
217
+ protected readonly ownsStubWrapper: boolean;
218
+
219
+ constructor(stub: EasyNetworkStub | EasyNetworkStubWrapper, options?: EasyNetworkStubWrapperOptions) {
220
+ this.stubWrapper = stub instanceof EasyNetworkStubWrapper ? stub : new EasyNetworkStubWrapper(stub, options);
221
+ this.ownsStubWrapper = !(stub instanceof EasyNetworkStubWrapper);
222
+ }
223
+
224
+ public reset() {
225
+ if (this.ownsStubWrapper) {
226
+ this.stubWrapper.reset();
227
+ }
228
+ }
229
+ }
230
+
231
+ export type EasyNetworkStubGroup<Group, GroupContainer> = Group & {
232
+ (stubActions: (stubs: Group) => void): GroupContainer;
233
+ };
234
+
235
+ // eslint-disable-next-line @typescript-eslint/ban-types
236
+ declare interface GroupType<T> extends Function {
237
+ new (stubWrapper: EasyNetworkStubWrapper): T;
238
+ }
239
+
240
+ export function createEasyNetworkStubGroup<GroupContainer, Group>(
241
+ container: GroupContainer,
242
+ stubWrapper: EasyNetworkStubWrapper,
243
+ groupType: GroupType<Group>,
244
+ ): EasyNetworkStubGroup<Group, GroupContainer> {
245
+ const group = new groupType(stubWrapper);
246
+ const groupFn = (stubActions: (stubs: Group) => void) => {
247
+ stubActions(group);
248
+ return container;
249
+ };
250
+ Object.setPrototypeOf(groupFn, groupType.prototype);
251
+ return Object.assign(groupFn, group);
252
+ }
253
+
254
+ function sleep(ms: number): Promise<void> {
255
+ return new Promise((resolve) => setTimeout(resolve, ms));
256
+ }
257
+
258
+ function isHttpResponse(value: unknown): value is ErrorResponse<unknown> {
259
+ return typeof value === 'object' && value !== null && 'statusCode' in value;
260
+ }
@@ -231,13 +231,13 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_1.TypeScri
231
231
  }
232
232
  : null,
233
233
  '',
234
- (0, core_1.builderTemplate) `return ${ctx.refs.waitForResponse([responseModelType])}(${core_1.builderTemplate.indent `
235
- this.http.request(rb.build({${core_1.builderTemplate.indent `
236
- responseType: ${ast_1.ts.string(responseType)},
237
- accept: ${ast_1.ts.string(accept)},
238
- context,`}
239
- })),
240
- {${core_1.builderTemplate.indent `
234
+ (0, core_1.builderTemplate) `return ${ctx.refs.waitForResponse([responseModelType])}(${core_1.builderTemplate.indent `
235
+ this.http.request(rb.build({${core_1.builderTemplate.indent `
236
+ responseType: ${ast_1.ts.string(responseType)},
237
+ accept: ${ast_1.ts.string(accept)},
238
+ context,`}
239
+ })),
240
+ {${core_1.builderTemplate.indent `
241
241
  errorResponseTypes: ${ast_1.ts.object({
242
242
  members: [
243
243
  ...Object.entries(this.getEndpointStatusCodes(ctx, endpoint))
@@ -246,8 +246,8 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_1.TypeScri
246
246
  return ast_1.ts.property(key, { value: ast_1.ts.string(value.parser) });
247
247
  }),
248
248
  ],
249
- })}`}
250
- }`}
249
+ })}`}
250
+ }`}
251
251
  )`,
252
252
  ], '\n'),
253
253
  });
@@ -97,15 +97,15 @@ class DefaultTypeScriptEasyNetworkStubGenerator extends file_generator_1.TypeScr
97
97
  ],
98
98
  returnType: 'this',
99
99
  body: (0, core_1.appendValueGroup)([
100
- (0, core_1.builderTemplate) `this.stubWrapper.stub2<${requestType}>()(${core_1.builderTemplate.indent `
101
- ${ast_1.ts.string(endpoint.method.toUpperCase())},
102
- ${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
103
- async (request) => {${core_1.builderTemplate.indent `
104
- if (this.stubWrapper.options.rememberRequests) {${core_1.builderTemplate.indent `
105
- this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
106
- }
107
- throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
108
- }`}
100
+ (0, core_1.builderTemplate) `this.stubWrapper.stub2<${requestType}>()(${core_1.builderTemplate.indent `
101
+ ${ast_1.ts.string(endpoint.method.toUpperCase())},
102
+ ${this.getStubClassName(ctx)}.${this.getEndpointPathPropertyName(ctx, endpoint)},
103
+ async (request) => {${core_1.builderTemplate.indent `
104
+ if (this.stubWrapper.options.rememberRequests) {${core_1.builderTemplate.indent `
105
+ this.${this.getEndpointRequestsFieldName(ctx, endpoint)}.push(request);`}
106
+ }
107
+ throw await response(${this.getResponderVariableName(ctx, endpoint)}, request);`}
108
+ }`}
109
109
  );`,
110
110
  'return this;',
111
111
  ], '\n'),
@@ -136,7 +136,7 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_1.TypeScriptF
136
136
  const method = this.getInterfaceEndpointMethod(ctx, endpoint);
137
137
  method.accessModifier = 'public';
138
138
  method.body = (0, core_1.appendValueGroup)([
139
- (0, core_1.builderTemplate) `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${core_1.builderTemplate.indent `
139
+ (0, core_1.builderTemplate) `const url = new ${ctx.refs.urlBuilder()}(this.options.baseUrl)${core_1.builderTemplate.indent `
140
140
  .withPath(${ast_1.ts.string(endpoint.path)})${(b) => b.forEach(endpoint.parameters, (b, p) => {
141
141
  switch (p.target) {
142
142
  case 'path':
@@ -146,7 +146,7 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_1.TypeScriptF
146
146
  b.append((0, core_1.builderTemplate) `\n.withQueryParam(${ast_1.ts.string(p.name)}, params.${(0, core_1.toCasing)(p.name, ctx.config.paramNameCasing)})`);
147
147
  break;
148
148
  }
149
- })}
149
+ })}
150
150
  .build();`}`,
151
151
  (0, core_1.builderTemplate) `const response = (this.options.fetch ?? fetch)(url, ${ast_1.ts.object({
152
152
  members: [
@@ -189,7 +189,7 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_1.TypeScriptFile
189
189
  ],
190
190
  }),
191
191
  parameters: [ast_1.ts.constructorParameter('rootUrl'), ast_1.ts.constructorParameter('defaultK6ParamsFactory')],
192
- body: (0, core_1.builderTemplate) `this.rootUrl = rootUrl;
192
+ body: (0, core_1.builderTemplate) `this.rootUrl = rootUrl;
193
193
  this._defaultK6ParamsFactory = defaultK6ParamsFactory;`,
194
194
  }),
195
195
  ...ctx.service.endpoints.map((e) => this.getEndpointMethod(ctx, e)),
@@ -248,11 +248,11 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_1.TypeScriptFile
248
248
  }
249
249
  : null,
250
250
  '',
251
- (0, core_1.builderTemplate) `return /** @type {${returnType}} */ (${core_1.builderTemplate.indent `
252
- ${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${core_1.builderTemplate.indent `
253
- accept: ${ast_1.ts.string(accept)},
254
- params: this.getK6Params(k6Params),`}
255
- })`}
251
+ (0, core_1.builderTemplate) `return /** @type {${returnType}} */ (${core_1.builderTemplate.indent `
252
+ ${ctx.config.async ? 'await rb.buildAsync' : 'rb.build'}({${core_1.builderTemplate.indent `
253
+ accept: ${ast_1.ts.string(accept)},
254
+ params: this.getK6Params(k6Params),`}
255
+ })`}
256
256
  );`,
257
257
  ], '\n'),
258
258
  });
@@ -228,13 +228,13 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
228
228
  }
229
229
  : null,
230
230
  '',
231
- s `return ${ctx.refs.waitForResponse([responseModelType])}(${s.indent `
232
- this.http.request(rb.build({${s.indent `
233
- responseType: ${ts.string(responseType)},
234
- accept: ${ts.string(accept)},
235
- context,`}
236
- })),
237
- {${s.indent `
231
+ s `return ${ctx.refs.waitForResponse([responseModelType])}(${s.indent `
232
+ this.http.request(rb.build({${s.indent `
233
+ responseType: ${ts.string(responseType)},
234
+ accept: ${ts.string(accept)},
235
+ context,`}
236
+ })),
237
+ {${s.indent `
238
238
  errorResponseTypes: ${ts.object({
239
239
  members: [
240
240
  ...Object.entries(this.getEndpointStatusCodes(ctx, endpoint))
@@ -243,8 +243,8 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
243
243
  return ts.property(key, { value: ts.string(value.parser) });
244
244
  }),
245
245
  ],
246
- })}`}
247
- }`}
246
+ })}`}
247
+ }`}
248
248
  )`,
249
249
  ], '\n'),
250
250
  });