@azure-tools/rlc-common 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.rush/temp/package-deps_build.json +11 -11
  2. package/CHANGELOG.md +12 -0
  3. package/dist/buildClient.js +7 -2
  4. package/dist/buildClient.js.map +1 -1
  5. package/dist/buildObjectTypes.js +4 -3
  6. package/dist/buildObjectTypes.js.map +1 -1
  7. package/dist/buildPollingHelper.js +8 -8
  8. package/dist/buildPollingHelper.js.map +1 -1
  9. package/dist/helpers/importsUtil.js +6 -1
  10. package/dist/helpers/importsUtil.js.map +1 -1
  11. package/dist/interfaces.js.map +1 -1
  12. package/dist/metadata/buildESLintConfig.js +7 -1
  13. package/dist/metadata/buildESLintConfig.js.map +1 -1
  14. package/dist/metadata/packageJson/azurePackageCommon.js +2 -2
  15. package/dist/metadata/packageJson/azurePackageCommon.js.map +1 -1
  16. package/dist/package.json +1 -1
  17. package/dist/static/pollingContent.js +145 -37
  18. package/dist/static/pollingContent.js.map +1 -1
  19. package/dist/transformSampleGroups.js +2 -2
  20. package/dist/transformSampleGroups.js.map +1 -1
  21. package/dist-esm/buildClient.js +7 -2
  22. package/dist-esm/buildClient.js.map +1 -1
  23. package/dist-esm/buildObjectTypes.js +5 -2
  24. package/dist-esm/buildObjectTypes.js.map +1 -1
  25. package/dist-esm/buildPollingHelper.js +8 -8
  26. package/dist-esm/buildPollingHelper.js.map +1 -1
  27. package/dist-esm/helpers/importsUtil.js +6 -1
  28. package/dist-esm/helpers/importsUtil.js.map +1 -1
  29. package/dist-esm/interfaces.js.map +1 -1
  30. package/dist-esm/metadata/buildESLintConfig.js +6 -0
  31. package/dist-esm/metadata/buildESLintConfig.js.map +1 -1
  32. package/dist-esm/metadata/packageJson/azurePackageCommon.js +3 -3
  33. package/dist-esm/metadata/packageJson/azurePackageCommon.js.map +1 -1
  34. package/dist-esm/package.json +1 -1
  35. package/dist-esm/static/pollingContent.js +145 -37
  36. package/dist-esm/static/pollingContent.js.map +1 -1
  37. package/dist-esm/transformSampleGroups.js +2 -2
  38. package/dist-esm/transformSampleGroups.js.map +1 -1
  39. package/package.json +1 -1
  40. package/src/buildClient.ts +7 -2
  41. package/src/buildObjectTypes.ts +9 -5
  42. package/src/buildPollingHelper.ts +10 -9
  43. package/src/helpers/importsUtil.ts +6 -1
  44. package/src/interfaces.ts +2 -1
  45. package/src/metadata/buildESLintConfig.ts +7 -1
  46. package/src/metadata/packageJson/azurePackageCommon.ts +3 -3
  47. package/src/static/pollingContent.ts +145 -37
  48. package/src/transformSampleGroups.ts +2 -2
  49. package/types/interfaces.d.ts +2 -1
  50. package/types/static/pollingContent.d.ts +1 -1
@@ -3,23 +3,14 @@
3
3
 
4
4
  export const pollingContent = `
5
5
  import { Client, HttpResponse } from "@azure-rest/core-client";
6
- {{#if useLegacyLro}}
7
- import {
8
- LongRunningOperation,
9
- LroEngine,
10
- LroEngineOptions,
11
- LroResponse,
12
- PollerLike,
13
- PollOperationState
14
- } from "@azure/core-lro";
15
- {{else}}
6
+ import { AbortSignalLike } from "@azure/abort-controller";
16
7
  import {
8
+ CancelOnProgress,
17
9
  CreateHttpPollerOptions,
18
10
  LongRunningOperation,
19
- LroResponse,
11
+ OperationResponse,
20
12
  OperationState,
21
- SimplePollerLike,
22
- createHttpPoller
13
+ createHttpPoller,
23
14
  } from "@azure/core-lro";
24
15
  {{#if clientOverload}}
25
16
  import {
@@ -28,7 +19,76 @@ import {
28
19
  {{/each}}
29
20
  } from "./responses{{#if isEsm}}.js{{/if}}";
30
21
  {{/if}}
31
- {{/if}}
22
+
23
+ /**
24
+ * A simple poller that can be used to poll a long running operation.
25
+ */
26
+ export interface SimplePollerLike<
27
+ TState extends OperationState<TResult>,
28
+ TResult
29
+ > {
30
+ /**
31
+ * Returns true if the poller has finished polling.
32
+ */
33
+ isDone(): boolean;
34
+ /**
35
+ * Returns true if the poller is stopped.
36
+ */
37
+ isStopped(): boolean;
38
+ /**
39
+ * Returns the state of the operation.
40
+ */
41
+ getOperationState(): TState;
42
+ /**
43
+ * Returns the result value of the operation,
44
+ * regardless of the state of the poller.
45
+ * It can return undefined or an incomplete form of the final TResult value
46
+ * depending on the implementation.
47
+ */
48
+ getResult(): TResult | undefined;
49
+ /**
50
+ * Returns a promise that will resolve once a single polling request finishes.
51
+ * It does this by calling the update method of the Poller's operation.
52
+ */
53
+ poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;
54
+ /**
55
+ * Returns a promise that will resolve once the underlying operation is completed.
56
+ */
57
+ pollUntilDone(pollOptions?: {
58
+ abortSignal?: AbortSignalLike;
59
+ }): Promise<TResult>;
60
+ /**
61
+ * Invokes the provided callback after each polling is completed,
62
+ * sending the current state of the poller's operation.
63
+ *
64
+ * It returns a method that can be used to stop receiving updates on the given callback function.
65
+ */
66
+ onProgress(callback: (state: TState) => void): CancelOnProgress;
67
+
68
+ /**
69
+ * Returns a promise that could be used for serialized version of the poller's operation
70
+ * by invoking the operation's serialize method.
71
+ */
72
+ serialize(): Promise<string>;
73
+
74
+ /**
75
+ * Wait the poller to be submitted.
76
+ */
77
+ submitted(): Promise<void>;
78
+
79
+ /**
80
+ * Returns a string representation of the poller's operation. Similar to serialize but returns a string.
81
+ * @deprecated Use serialize() instead.
82
+ */
83
+ toString(): string;
84
+
85
+ /**
86
+ * Stops the poller from continuing to poll. Please note this will only stop the client-side polling
87
+ * @deprecated Use abortSignal to stop polling instead.
88
+ */
89
+ stopPolling(): void;
90
+ }
91
+
32
92
  /**
33
93
  * Helper function that builds a Poller object to help polling a long running operation.
34
94
  * @param client - Client to use for sending the request to get additional pages.
@@ -42,38 +102,52 @@ export async function getLongRunningPoller<
42
102
  TResult extends {{ this.finalResponses }}
43
103
  >(
44
104
  client: Client,
45
- initialResponse: {{ this.initalResponses }},
105
+ initialResponse: {{ this.initialResponses }},
46
106
  options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>
47
107
  ): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;
48
108
  {{/each}}
49
109
  {{/if}}
50
- export {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TResult extends HttpResponse>(
51
- client: Client,
52
- initialResponse: TResult,
53
- {{#if useLegacyLro}}
54
- options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}
55
- ): PollerLike<PollOperationState<TResult>, TResult> {
56
- {{else}}
110
+ export async function getLongRunningPoller<TResult extends HttpResponse>(
111
+ client: Client,
112
+ initialResponse: TResult,
57
113
  options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}
58
- ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {
59
- {{/if}}
60
- const poller: LongRunningOperation<TResult> = {
61
- requestMethod: initialResponse.request.method,
62
- requestPath: initialResponse.request.url,
114
+ ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {
115
+ const abortController = new AbortController();
116
+ const poller: LongRunningOperation<TResult> = {
63
117
  sendInitialRequest: async () => {
64
118
  // In the case of Rest Clients we are building the LRO poller object from a response that's the reason
65
119
  // we are not triggering the initial request here, just extracting the information from the
66
120
  // response we were provided.
67
121
  return getLroResponse(initialResponse);
68
122
  },
69
- sendPollRequest: async path => {
123
+ sendPollRequest: async (
124
+ path,
125
+ options?: { abortSignal?: AbortSignalLike }
126
+ ) => {
70
127
  // This is the callback that is going to be called to poll the service
71
128
  // to get the latest status. We use the client provided and the polling path
72
129
  // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
73
130
  // depending on the lro pattern that the service implements. If non is provided we default to the initial path.
74
- const response = await client
75
- .pathUnchecked(path ?? initialResponse.request.url)
76
- .get();
131
+ function abortListener(): void {
132
+ abortController.abort();
133
+ }
134
+ const inputAbortSignal = options?.abortSignal;
135
+ const abortSignal = abortController.signal;
136
+ if (inputAbortSignal?.aborted) {
137
+ abortController.abort();
138
+ } else if (!abortSignal.aborted) {
139
+ inputAbortSignal?.addEventListener("abort", abortListener, {
140
+ once: true
141
+ });
142
+ }
143
+ let response;
144
+ try {
145
+ response = await client
146
+ .pathUnchecked(path ?? initialResponse.request.url)
147
+ .get({ abortSignal });
148
+ } finally {
149
+ inputAbortSignal?.removeEventListener("abort", abortListener);
150
+ }
77
151
  const lroResponse = getLroResponse(response as TResult);
78
152
  lroResponse.rawResponse.headers["x-ms-original-url"] =
79
153
  initialResponse.request.url;
@@ -81,12 +155,46 @@ export {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TR
81
155
  }
82
156
  };
83
157
 
84
- {{#if useLegacyLro}}
85
- return new LroEngine(poller, options);
86
- {{else}}
87
158
  options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;
88
- return createHttpPoller(poller, options);
89
- {{/if}}
159
+ const httpPoller = createHttpPoller(poller, options);
160
+ const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {
161
+ isDone() {
162
+ return httpPoller.isDone;
163
+ },
164
+ isStopped() {
165
+ return httpPoller.isStopped;
166
+ },
167
+ getOperationState() {
168
+ if (!httpPoller.operationState) {
169
+ throw new Error(
170
+ "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState()."
171
+ );
172
+ }
173
+ return httpPoller.operationState;
174
+ },
175
+ getResult() {
176
+ return httpPoller.result;
177
+ },
178
+ toString() {
179
+ if (!httpPoller.operationState) {
180
+ throw new Error(
181
+ "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState()."
182
+ );
183
+ }
184
+ return JSON.stringify({
185
+ state: httpPoller.operationState
186
+ });
187
+ },
188
+ stopPolling() {
189
+ abortController.abort();
190
+ },
191
+ onProgress: httpPoller.onProgress,
192
+ poll: httpPoller.poll,
193
+ pollUntilDone: httpPoller.pollUntilDone,
194
+ serialize: httpPoller.serialize,
195
+ submitted: httpPoller.submitted
196
+ };
197
+ return simplePoller;
90
198
  }
91
199
 
92
200
  /**
@@ -96,7 +204,7 @@ export {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TR
96
204
  */
97
205
  function getLroResponse<TResult extends HttpResponse>(
98
206
  response: TResult
99
- ): LroResponse<TResult> {
207
+ ): OperationResponse<TResult> {
100
208
  if (Number.isNaN(response.status)) {
101
209
  throw new TypeError(
102
210
  \`Status code of the response is not a number. Value: \${response.status}\`
@@ -85,7 +85,7 @@ export function transformSampleGroups(model: RLCModel, allowMockValue = true) {
85
85
  methodParamNames: "",
86
86
  method,
87
87
  isLRO: detail.operationHelperDetail?.lroDetails?.isLongRunning ?? false,
88
- isPaging: detail.operationHelperDetail?.isPageable ?? false,
88
+ isPaging: detail.operationHelperDetail?.isPaging ?? false,
89
89
  useLegacyLro: false
90
90
  };
91
91
  // client-level, path-level and method-level parameter preparation
@@ -126,7 +126,7 @@ function enrichLROAndPagingInSample(
126
126
  ) {
127
127
  const isLRO =
128
128
  operation.operationHelperDetail?.lroDetails?.isLongRunning ?? false,
129
- isPaging = operation.operationHelperDetail?.isPageable ?? false;
129
+ isPaging = operation.operationHelperDetail?.isPaging ?? false;
130
130
  if (isPaging) {
131
131
  if (isLRO) {
132
132
  // TODO: report warning this is not supported
@@ -132,7 +132,7 @@ export type PathParameter = {
132
132
  };
133
133
  export interface OperationHelperDetail {
134
134
  lroDetails?: OperationLroDetail;
135
- isPageable?: boolean;
135
+ isPaging?: boolean;
136
136
  }
137
137
  export declare const OPERATION_LRO_HIGH_PRIORITY = 0, OPERATION_LRO_LOW_PRIORITY = 1;
138
138
  export interface OperationLroDetail {
@@ -193,6 +193,7 @@ export interface RLCOptions {
193
193
  flavor?: PackageFlavor;
194
194
  enableModelNamespace?: boolean;
195
195
  hierarchyClient?: boolean;
196
+ compatibilityMode?: boolean;
196
197
  }
197
198
  export interface ServiceInfo {
198
199
  title?: string;
@@ -1 +1 @@
1
- export declare const pollingContent = "\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\n{{#if useLegacyLro}}\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState\n} from \"@azure/core-lro\";\n{{else}}\nimport {\n CreateHttpPollerOptions,\n LongRunningOperation,\n LroResponse,\n OperationState,\n SimplePollerLike,\n createHttpPoller\n} from \"@azure/core-lro\";\n{{#if clientOverload}}\nimport {\n {{#each importedResponses}}\n {{this}},\n {{/each}}\n} from \"./responses{{#if isEsm}}.js{{/if}}\";\n{{/if}}\n{{/if}}\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\n{{#if clientOverload}}\n{{#each overloadMap}}\nexport async function getLongRunningPoller<\n TResult extends {{ this.finalResponses }}\n>(\n client: Client,\n initialResponse: {{ this.initalResponses }},\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\n{{/each}}\n{{/if}}\nexport {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n {{#if useLegacyLro}}\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n ): PollerLike<PollOperationState<TResult>, TResult> {\n {{else}}\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}\n ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n {{/if}} \n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async path => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n }\n };\n\n {{#if useLegacyLro}}\n return new LroEngine(poller, options);\n {{else}}\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n return createHttpPoller(poller, options);\n {{/if}}\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult\n): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`\n );\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body\n }\n };\n}\n";
1
+ export declare const pollingContent = "\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport {\n CancelOnProgress,\n CreateHttpPollerOptions,\n LongRunningOperation,\n OperationResponse,\n OperationState,\n createHttpPoller,\n} from \"@azure/core-lro\";\n{{#if clientOverload}}\nimport {\n {{#each importedResponses}}\n {{this}},\n {{/each}}\n} from \"./responses{{#if isEsm}}.js{{/if}}\";\n{{/if}}\n\n/**\n * A simple poller that can be used to poll a long running operation.\n */\nexport interface SimplePollerLike<\n TState extends OperationState<TResult>,\n TResult\n> {\n /**\n * Returns true if the poller has finished polling.\n */\n isDone(): boolean;\n /**\n * Returns true if the poller is stopped.\n */\n isStopped(): boolean;\n /**\n * Returns the state of the operation.\n */\n getOperationState(): TState;\n /**\n * Returns the result value of the operation,\n * regardless of the state of the poller.\n * It can return undefined or an incomplete form of the final TResult value\n * depending on the implementation.\n */\n getResult(): TResult | undefined;\n /**\n * Returns a promise that will resolve once a single polling request finishes.\n * It does this by calling the update method of the Poller's operation.\n */\n poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;\n /**\n * Returns a promise that will resolve once the underlying operation is completed.\n */\n pollUntilDone(pollOptions?: {\n abortSignal?: AbortSignalLike;\n }): Promise<TResult>;\n /**\n * Invokes the provided callback after each polling is completed,\n * sending the current state of the poller's operation.\n *\n * It returns a method that can be used to stop receiving updates on the given callback function.\n */\n onProgress(callback: (state: TState) => void): CancelOnProgress;\n\n /**\n * Returns a promise that could be used for serialized version of the poller's operation\n * by invoking the operation's serialize method.\n */\n serialize(): Promise<string>;\n\n /**\n * Wait the poller to be submitted.\n */\n submitted(): Promise<void>;\n\n /**\n * Returns a string representation of the poller's operation. Similar to serialize but returns a string.\n * @deprecated Use serialize() instead.\n */\n toString(): string;\n\n /**\n * Stops the poller from continuing to poll. Please note this will only stop the client-side polling\n * @deprecated Use abortSignal to stop polling instead.\n */\n stopPolling(): void;\n}\n\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\n{{#if clientOverload}}\n{{#each overloadMap}}\nexport async function getLongRunningPoller<\n TResult extends {{ this.finalResponses }}\n>(\n client: Client,\n initialResponse: {{ this.initialResponses }},\n options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>\n): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;\n{{/each}}\n{{/if}}\nexport async function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}\n ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> { \n const abortController = new AbortController();\n const poller: LongRunningOperation<TResult> = {\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async (\n path,\n options?: { abortSignal?: AbortSignalLike }\n ) => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n function abortListener(): void {\n abortController.abort();\n }\n const inputAbortSignal = options?.abortSignal;\n const abortSignal = abortController.signal;\n if (inputAbortSignal?.aborted) {\n abortController.abort();\n } else if (!abortSignal.aborted) {\n inputAbortSignal?.addEventListener(\"abort\", abortListener, {\n once: true\n });\n }\n let response;\n try {\n response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get({ abortSignal });\n } finally {\n inputAbortSignal?.removeEventListener(\"abort\", abortListener);\n }\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n }\n };\n\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n const httpPoller = createHttpPoller(poller, options);\n const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {\n isDone() {\n return httpPoller.isDone;\n },\n isStopped() {\n return httpPoller.isStopped;\n },\n getOperationState() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\"\n );\n }\n return httpPoller.operationState;\n },\n getResult() {\n return httpPoller.result;\n },\n toString() {\n if (!httpPoller.operationState) {\n throw new Error(\n \"Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState().\"\n );\n }\n return JSON.stringify({\n state: httpPoller.operationState\n });\n },\n stopPolling() {\n abortController.abort();\n },\n onProgress: httpPoller.onProgress,\n poll: httpPoller.poll,\n pollUntilDone: httpPoller.pollUntilDone,\n serialize: httpPoller.serialize,\n submitted: httpPoller.submitted\n };\n return simplePoller;\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult\n): OperationResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`\n );\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body\n }\n };\n}\n";