@ogcio/building-blocks-sdk 0.0.19 → 0.0.21

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/README.md +33 -2
  2. package/dist/__tests__/client/clients/featureFlags/index.test.d.ts.map +1 -0
  3. package/dist/{client → __tests__/client}/clients/featureFlags/index.test.js +12 -8
  4. package/dist/__tests__/client/clients/featureFlags/index.test.js.map +1 -0
  5. package/dist/__tests__/client/utils/client-utils.test.d.ts +2 -0
  6. package/dist/__tests__/client/utils/client-utils.test.d.ts.map +1 -0
  7. package/dist/__tests__/client/utils/client-utils.test.js +115 -0
  8. package/dist/__tests__/client/utils/client-utils.test.js.map +1 -0
  9. package/dist/client/base-client.d.ts +1 -4
  10. package/dist/client/base-client.d.ts.map +1 -1
  11. package/dist/client/base-client.js +0 -27
  12. package/dist/client/base-client.js.map +1 -1
  13. package/dist/client/clients/featureFlags/index.d.ts.map +1 -1
  14. package/dist/client/clients/featureFlags/index.js +3 -2
  15. package/dist/client/clients/featureFlags/index.js.map +1 -1
  16. package/dist/client/clients/messaging/index.d.ts.map +1 -1
  17. package/dist/client/clients/messaging/index.js +30 -30
  18. package/dist/client/clients/messaging/index.js.map +1 -1
  19. package/dist/client/clients/payments/index.d.ts.map +1 -1
  20. package/dist/client/clients/payments/index.js +25 -24
  21. package/dist/client/clients/payments/index.js.map +1 -1
  22. package/dist/client/clients/profile/index.d.ts.map +1 -1
  23. package/dist/client/clients/profile/index.js +14 -13
  24. package/dist/client/clients/profile/index.js.map +1 -1
  25. package/dist/client/clients/scheduler/index.d.ts.map +1 -1
  26. package/dist/client/clients/scheduler/index.js +2 -1
  27. package/dist/client/clients/scheduler/index.js.map +1 -1
  28. package/dist/client/clients/upload/index.d.ts +11 -44
  29. package/dist/client/clients/upload/index.d.ts.map +1 -1
  30. package/dist/client/clients/upload/index.js +10 -9
  31. package/dist/client/clients/upload/index.js.map +1 -1
  32. package/dist/client/utils/client-utils.d.ts +3 -1
  33. package/dist/client/utils/client-utils.d.ts.map +1 -1
  34. package/dist/client/utils/client-utils.js +27 -0
  35. package/dist/client/utils/client-utils.js.map +1 -1
  36. package/package.json +2 -2
  37. package/src/{client → __tests__/client}/clients/featureFlags/index.test.ts +16 -9
  38. package/src/__tests__/client/utils/client-utils.test.ts +198 -0
  39. package/src/__tests__/client/utils/response-types.d.ts +59 -0
  40. package/src/client/base-client.ts +0 -33
  41. package/src/client/clients/featureFlags/index.ts +3 -2
  42. package/src/client/clients/messaging/index.ts +60 -58
  43. package/src/client/clients/payments/index.ts +49 -48
  44. package/src/client/clients/profile/index.ts +27 -26
  45. package/src/client/clients/scheduler/index.ts +3 -2
  46. package/src/client/clients/upload/index.ts +31 -17
  47. package/src/client/utils/client-utils.ts +34 -1
  48. package/dist/client/clients/featureFlags/index.test.d.ts.map +0 -1
  49. package/dist/client/clients/featureFlags/index.test.js.map +0 -1
  50. /package/dist/{client → __tests__/client}/clients/featureFlags/index.test.d.ts +0 -0
@@ -0,0 +1,198 @@
1
+ import assert from "node:assert";
2
+ import { describe, test } from "node:test";
3
+ import {
4
+ type PaginationParams,
5
+ formatError,
6
+ formatResponse,
7
+ preparePaginationParams,
8
+ toStringOrUndefined,
9
+ } from "./../../../client/utils/client-utils.js";
10
+ import type {
11
+ ApiError,
12
+ TestNestedResponseObject,
13
+ TestResponseObject,
14
+ TypedErrorResponse,
15
+ TypedSuccessResponse,
16
+ } from "./response-types.js";
17
+ describe("toStringOrUndefined", () => {
18
+ test("should convert numbers and booleans to strings", () => {
19
+ assert.strictEqual(
20
+ toStringOrUndefined(42),
21
+ "42",
22
+ "Expected number to be converted to string",
23
+ );
24
+ assert.strictEqual(
25
+ toStringOrUndefined(true),
26
+ "true",
27
+ "Expected boolean true to be converted to string",
28
+ );
29
+ assert.strictEqual(
30
+ toStringOrUndefined(false),
31
+ "false",
32
+ "Expected boolean false to be converted to string",
33
+ );
34
+ });
35
+
36
+ test("should return undefined if input is undefined", () => {
37
+ assert.strictEqual(
38
+ toStringOrUndefined(undefined),
39
+ undefined,
40
+ "Expected undefined input to return undefined",
41
+ );
42
+ });
43
+
44
+ test("should convert offset and limit to strings if provided", () => {
45
+ const params: PaginationParams = { offset: 10, limit: 20 };
46
+ const result = preparePaginationParams(params);
47
+ assert.deepStrictEqual(
48
+ result,
49
+ { offset: "10", limit: "20" },
50
+ "Expected offset and limit to be converted to strings",
51
+ );
52
+ });
53
+
54
+ test("should handle string inputs for offset and limit", () => {
55
+ const params: PaginationParams = { offset: "5", limit: "15" };
56
+ const result = preparePaginationParams(params);
57
+ assert.deepStrictEqual(
58
+ result,
59
+ { offset: "5", limit: "15" },
60
+ "Expected offset and limit to remain strings if already provided as strings",
61
+ );
62
+ });
63
+
64
+ test("should return an empty object if no pagination parameters are provided", () => {
65
+ const result = preparePaginationParams();
66
+ assert.deepStrictEqual(
67
+ result,
68
+ {},
69
+ "Expected empty object if no pagination parameters are provided",
70
+ );
71
+ });
72
+ });
73
+
74
+ describe("preparePaginationParams", () => {
75
+ test("should handle missing offset and limit individually", () => {
76
+ const offsetOnly: PaginationParams = { offset: 30 };
77
+ const limitOnly: PaginationParams = { limit: 50 };
78
+
79
+ const resultOffsetOnly = preparePaginationParams(offsetOnly);
80
+ assert.deepStrictEqual(
81
+ resultOffsetOnly,
82
+ { offset: "30" },
83
+ "Expected only offset to be set when limit is not provided",
84
+ );
85
+
86
+ const resultLimitOnly = preparePaginationParams(limitOnly);
87
+ assert.deepStrictEqual(
88
+ resultLimitOnly,
89
+ { limit: "50" },
90
+ "Expected only limit to be set when offset is not provided",
91
+ );
92
+ });
93
+ });
94
+
95
+ describe("formatResponse", () => {
96
+ test("should handle response with plain data", () => {
97
+ // Create a properly typed success response
98
+ const mockResponse: TypedSuccessResponse<{ value: string }> = {
99
+ data: { value: "test" },
100
+ response: new Response(),
101
+ };
102
+
103
+ const result = formatResponse<
104
+ TestResponseObject["get"],
105
+ Record<string, unknown>
106
+ >(mockResponse);
107
+
108
+ assert.deepStrictEqual(result, {
109
+ data: { value: "test" },
110
+ metadata: undefined,
111
+ error: undefined,
112
+ });
113
+ });
114
+
115
+ test("should handle response with nested data property", () => {
116
+ // Create a properly typed nested success response
117
+ const mockResponse: TypedSuccessResponse<{
118
+ data: {
119
+ nested: {
120
+ value: string;
121
+ };
122
+ };
123
+ }> = {
124
+ data: {
125
+ data: {
126
+ nested: {
127
+ value: "test",
128
+ },
129
+ },
130
+ },
131
+ response: new Response(),
132
+ };
133
+
134
+ const result = formatResponse<
135
+ TestNestedResponseObject["get"],
136
+ Record<string, unknown>
137
+ >(mockResponse);
138
+
139
+ assert.deepStrictEqual(result, {
140
+ data: {
141
+ nested: {
142
+ value: "test",
143
+ },
144
+ },
145
+ metadata: undefined,
146
+ error: undefined,
147
+ });
148
+ });
149
+
150
+ test("should format typed error correctly", () => {
151
+ const mockError: ApiError = {
152
+ message: "Test error",
153
+ code: "500",
154
+ };
155
+
156
+ const errorResponse: TypedErrorResponse<ApiError> = {
157
+ error: mockError,
158
+ response: new Response(),
159
+ };
160
+
161
+ const result = formatResponse<
162
+ TestResponseObject["get"],
163
+ Record<string, unknown>
164
+ >(errorResponse);
165
+
166
+ assert.deepStrictEqual(result, {
167
+ data: undefined,
168
+ metadata: undefined,
169
+ error: mockError,
170
+ });
171
+ });
172
+ });
173
+
174
+ describe("formatError", () => {
175
+ test("should format error correctly", () => {
176
+ const error = new Error("Test error");
177
+ const result = formatError(error);
178
+ assert.deepStrictEqual(result, {
179
+ error: error,
180
+ });
181
+ });
182
+
183
+ test("should handle non-error objects", () => {
184
+ const errorObj = { code: 500, message: "Server error" };
185
+ const result = formatError(errorObj);
186
+ assert.deepStrictEqual(result, {
187
+ error: errorObj,
188
+ });
189
+ });
190
+
191
+ test("should handle primitive error values", () => {
192
+ const errorMessage = "Something went wrong";
193
+ const result = formatError(errorMessage);
194
+ assert.deepStrictEqual(result, {
195
+ error: errorMessage,
196
+ });
197
+ });
198
+ });
@@ -0,0 +1,59 @@
1
+ export type TestResponseObject = {
2
+ get: {
3
+ responses: {
4
+ 200: {
5
+ content: {
6
+ "application/json": {
7
+ value: string;
8
+ };
9
+ };
10
+ };
11
+ "4XX": {
12
+ headers: {
13
+ [name: string]: unknown;
14
+ };
15
+ content: {
16
+ "application/json": {
17
+ code: string;
18
+ message: string;
19
+ };
20
+ };
21
+ };
22
+ };
23
+ };
24
+ };
25
+
26
+ export type TestNestedResponseObject = {
27
+ get: {
28
+ responses: {
29
+ 200: {
30
+ content: {
31
+ "application/json": {
32
+ data: {
33
+ nested: {
34
+ value: string;
35
+ };
36
+ };
37
+ };
38
+ };
39
+ };
40
+ };
41
+ };
42
+ };
43
+
44
+ export type TypedSuccessResponse<T> = {
45
+ data: T;
46
+ error?: never;
47
+ response: Response;
48
+ };
49
+
50
+ export type TypedErrorResponse<T> = {
51
+ data?: never;
52
+ error: T;
53
+ response: Response;
54
+ };
55
+
56
+ export type ApiError = {
57
+ message: string;
58
+ code: string;
59
+ };
@@ -64,37 +64,4 @@ export abstract class BaseClient<T extends {}> {
64
64
  public isInitialized() {
65
65
  return this.initialized;
66
66
  }
67
-
68
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
69
- protected formatResponse<G extends Record<string | number, any>, O>(
70
- response: FetchResponse<G, O, "application/json">,
71
- ): DataResponseValue<G, O> {
72
- let outputData = undefined;
73
- let outputMetadata = undefined;
74
- if (!response) {
75
- return {} as DataResponseValue<G, O>;
76
- }
77
- if (response.data) {
78
- const dataEntries = Object.entries(response.data);
79
- // by docs the body should contain a "data"
80
- // properties with the response values
81
- const containsData = dataEntries.find((x) => x[0] === "data");
82
- const containsMetadata = dataEntries.find((x) => x[0] === "metadata");
83
-
84
- if (containsMetadata) {
85
- outputMetadata = containsMetadata[1];
86
- }
87
- outputData = containsData ? containsData[1] : response.data;
88
- }
89
-
90
- return {
91
- data: outputData,
92
- metadata: outputMetadata,
93
- error: response.error,
94
- } as unknown as DataResponseValue<G, O>;
95
- }
96
-
97
- protected formatError<G, O>(reason: unknown): DataResponseValue<G, O> {
98
- return { error: reason } as unknown as DataResponseValue<G, O>;
99
- }
100
67
  }
@@ -2,6 +2,7 @@ import type createClient from "openapi-fetch";
2
2
  import type { BaseApiClientParams } from "../../../types/index.js";
3
3
  import { FEATURE_FLAGS } from "../../../types/index.js";
4
4
  import { BaseClient } from "../../base-client.js";
5
+ import { formatError, formatResponse } from "../../utils/client-utils.js";
5
6
  import { DEFAULT_PROJECT_ID } from "./const.js";
6
7
  import type { components, paths } from "./schema.js";
7
8
 
@@ -69,14 +70,14 @@ export class FeatureFlags extends BaseClient<paths> {
69
70
  .then(
70
71
  (response) => {
71
72
  // @ts-expect-error: TODO: fix me
72
- const { data, metadata, error } = this.formatResponse(response);
73
+ const { data, metadata, error } = formatResponse(response);
73
74
  return {
74
75
  data: data?.features as components["schemas"]["projectFeatureSchema"][],
75
76
  metadata,
76
77
  error,
77
78
  };
78
79
  },
79
- (reason) => this.formatError(reason),
80
+ (reason) => formatError(reason),
80
81
  );
81
82
  }
82
83
  }
@@ -4,6 +4,8 @@ import { MESSAGING } from "../../../types/index.js";
4
4
  import { BaseClient } from "../../base-client.js";
5
5
  import {
6
6
  type PaginationParams,
7
+ formatError,
8
+ formatResponse,
7
9
  preparePaginationParams,
8
10
  toStringOrUndefined,
9
11
  } from "../../utils/client-utils.js";
@@ -39,8 +41,8 @@ export class Messaging extends BaseClient<paths> {
39
41
  },
40
42
  })
41
43
  .then(
42
- (response) => this.formatResponse(response),
43
- (reason) => this.formatError(reason),
44
+ (response) => formatResponse(response),
45
+ (reason) => formatError(reason),
44
46
  );
45
47
  }
46
48
 
@@ -58,8 +60,8 @@ export class Messaging extends BaseClient<paths> {
58
60
  },
59
61
  })
60
62
  .then(
61
- (response) => this.formatResponse(response),
62
- (reason) => this.formatError(reason),
63
+ (response) => formatResponse(response),
64
+ (reason) => formatError(reason),
63
65
  );
64
66
  }
65
67
 
@@ -71,8 +73,8 @@ export class Messaging extends BaseClient<paths> {
71
73
  params: { path: { messageId } },
72
74
  })
73
75
  .then(
74
- (response) => this.formatResponse(response),
75
- (reason) => this.formatError(reason),
76
+ (response) => formatResponse(response),
77
+ (reason) => formatError(reason),
76
78
  );
77
79
  }
78
80
 
@@ -84,8 +86,8 @@ export class Messaging extends BaseClient<paths> {
84
86
  body,
85
87
  })
86
88
  .then(
87
- (response) => this.formatResponse(response),
88
- (reason) => this.formatError(reason),
89
+ (response) => formatResponse(response),
90
+ (reason) => formatError(reason),
89
91
  );
90
92
  }
91
93
 
@@ -99,8 +101,8 @@ export class Messaging extends BaseClient<paths> {
99
101
  },
100
102
  })
101
103
  .then(
102
- (response) => this.formatResponse(response),
103
- (reason) => this.formatError(reason),
104
+ (response) => formatResponse(response),
105
+ (reason) => formatError(reason),
104
106
  );
105
107
  }
106
108
 
@@ -116,8 +118,8 @@ export class Messaging extends BaseClient<paths> {
116
118
  },
117
119
  })
118
120
  .then(
119
- (response) => this.formatResponse(response),
120
- (reason) => this.formatError(reason),
121
+ (response) => formatResponse(response),
122
+ (reason) => formatError(reason),
121
123
  );
122
124
  }
123
125
 
@@ -194,8 +196,8 @@ export class Messaging extends BaseClient<paths> {
194
196
  body: paths["/api/v1/templates/"]["post"]["requestBody"]["content"]["application/json"],
195
197
  ) {
196
198
  return this.client.POST("/api/v1/templates/", { body }).then(
197
- (response) => this.formatResponse(response),
198
- (reason) => this.formatError(reason),
199
+ (response) => formatResponse(response),
200
+ (reason) => formatError(reason),
199
201
  );
200
202
  }
201
203
 
@@ -209,8 +211,8 @@ export class Messaging extends BaseClient<paths> {
209
211
  body,
210
212
  })
211
213
  .then(
212
- (response) => this.formatResponse(response),
213
- (reason) => this.formatError(reason),
214
+ (response) => formatResponse(response),
215
+ (reason) => formatError(reason),
214
216
  );
215
217
  }
216
218
 
@@ -222,8 +224,8 @@ export class Messaging extends BaseClient<paths> {
222
224
  params: { path: { templateId } },
223
225
  })
224
226
  .then(
225
- (response) => this.formatResponse(response),
226
- (reason) => this.formatError(reason),
227
+ (response) => formatResponse(response),
228
+ (reason) => formatError(reason),
227
229
  );
228
230
  }
229
231
 
@@ -292,8 +294,8 @@ export class Messaging extends BaseClient<paths> {
292
294
  },
293
295
  })
294
296
  .then(
295
- (response) => this.formatResponse(response),
296
- (reason) => this.formatError(reason),
297
+ (response) => formatResponse(response),
298
+ (reason) => formatError(reason),
297
299
  );
298
300
  }
299
301
 
@@ -318,8 +320,8 @@ export class Messaging extends BaseClient<paths> {
318
320
  },
319
321
  })
320
322
  .then(
321
- (response) => this.formatResponse(response),
322
- (reason) => this.formatError(reason),
323
+ (response) => formatResponse(response),
324
+ (reason) => formatError(reason),
323
325
  );
324
326
  }
325
327
 
@@ -329,8 +331,8 @@ export class Messaging extends BaseClient<paths> {
329
331
  params: { path: { providerId } },
330
332
  })
331
333
  .then(
332
- (response) => this.formatResponse(response),
333
- (reason) => this.formatError(reason),
334
+ (response) => formatResponse(response),
335
+ (reason) => formatError(reason),
334
336
  );
335
337
  }
336
338
 
@@ -403,8 +405,8 @@ export class Messaging extends BaseClient<paths> {
403
405
  },
404
406
  })
405
407
  .then(
406
- (response) => this.formatResponse(response),
407
- (reason) => this.formatError(reason),
408
+ (response) => formatResponse(response),
409
+ (reason) => formatError(reason),
408
410
  );
409
411
  }
410
412
 
@@ -427,8 +429,8 @@ export class Messaging extends BaseClient<paths> {
427
429
  },
428
430
  })
429
431
  .then(
430
- (response) => this.formatResponse(response),
431
- (reason) => this.formatError(reason),
432
+ (response) => formatResponse(response),
433
+ (reason) => formatError(reason),
432
434
  );
433
435
  }
434
436
 
@@ -438,8 +440,8 @@ export class Messaging extends BaseClient<paths> {
438
440
  params: { path: { providerId } },
439
441
  })
440
442
  .then(
441
- (response) => this.formatResponse(response),
442
- (reason) => this.formatError(reason),
443
+ (response) => formatResponse(response),
444
+ (reason) => formatError(reason),
443
445
  );
444
446
  }
445
447
 
@@ -467,8 +469,8 @@ export class Messaging extends BaseClient<paths> {
467
469
  body: toImport.records,
468
470
  })
469
471
  .then(
470
- (response) => this.formatResponse(response),
471
- (reason) => this.formatError(reason),
472
+ (response) => formatResponse(response),
473
+ (reason) => formatError(reason),
472
474
  );
473
475
  }
474
476
 
@@ -478,8 +480,8 @@ export class Messaging extends BaseClient<paths> {
478
480
  parseAs: "blob",
479
481
  })
480
482
  .then(
481
- (response) => this.formatResponse(response),
482
- (reason) => this.formatError(reason),
483
+ (response) => formatResponse(response),
484
+ (reason) => formatError(reason),
483
485
  );
484
486
  }
485
487
 
@@ -496,8 +498,8 @@ export class Messaging extends BaseClient<paths> {
496
498
  },
497
499
  })
498
500
  .then(
499
- (response) => this.formatResponse(response),
500
- (reason) => this.formatError(reason),
501
+ (response) => formatResponse(response),
502
+ (reason) => formatError(reason),
501
503
  );
502
504
  }
503
505
 
@@ -518,8 +520,8 @@ export class Messaging extends BaseClient<paths> {
518
520
  },
519
521
  })
520
522
  .then(
521
- (response) => this.formatResponse(response),
522
- (reason) => this.formatError(reason),
523
+ (response) => formatResponse(response),
524
+ (reason) => formatError(reason),
523
525
  );
524
526
  }
525
527
 
@@ -529,8 +531,8 @@ export class Messaging extends BaseClient<paths> {
529
531
  params: { query: { importId, activeOnly: String(activeOnly) } },
530
532
  })
531
533
  .then(
532
- (response) => this.formatResponse(response),
533
- (reason) => this.formatError(reason),
534
+ (response) => formatResponse(response),
535
+ (reason) => formatError(reason),
534
536
  );
535
537
  }
536
538
 
@@ -544,8 +546,8 @@ export class Messaging extends BaseClient<paths> {
544
546
  },
545
547
  })
546
548
  .then(
547
- (response) => this.formatResponse(response),
548
- (reason) => this.formatError(reason),
549
+ (response) => formatResponse(response),
550
+ (reason) => formatError(reason),
549
551
  );
550
552
  }
551
553
 
@@ -555,8 +557,8 @@ export class Messaging extends BaseClient<paths> {
555
557
  params: { path: { organisationSettingId } },
556
558
  })
557
559
  .then(
558
- (response) => this.formatResponse(response),
559
- (reason) => this.formatError(reason),
560
+ (response) => formatResponse(response),
561
+ (reason) => formatError(reason),
560
562
  );
561
563
  }
562
564
 
@@ -570,8 +572,8 @@ export class Messaging extends BaseClient<paths> {
570
572
  params: { path: { organisationSettingId } },
571
573
  })
572
574
  .then(
573
- (response) => this.formatResponse(response),
574
- (reason) => this.formatError(reason),
575
+ (response) => formatResponse(response),
576
+ (reason) => formatError(reason),
575
577
  );
576
578
  }
577
579
 
@@ -583,8 +585,8 @@ export class Messaging extends BaseClient<paths> {
583
585
  },
584
586
  })
585
587
  .then(
586
- (response) => this.formatResponse(response),
587
- (reason) => this.formatError(reason),
588
+ (response) => formatResponse(response),
589
+ (reason) => formatError(reason),
588
590
  );
589
591
  }
590
592
 
@@ -594,8 +596,8 @@ export class Messaging extends BaseClient<paths> {
594
596
  params: { path: { eventId } },
595
597
  })
596
598
  .then(
597
- (response) => this.formatResponse(response),
598
- (reason) => this.formatError(reason),
599
+ (response) => formatResponse(response),
600
+ (reason) => formatError(reason),
599
601
  );
600
602
  }
601
603
 
@@ -609,8 +611,8 @@ export class Messaging extends BaseClient<paths> {
609
611
  },
610
612
  })
611
613
  .then(
612
- (response) => this.formatResponse(response),
613
- (reason) => this.formatError(reason),
614
+ (response) => formatResponse(response),
615
+ (reason) => formatError(reason),
614
616
  );
615
617
  }
616
618
 
@@ -630,8 +632,8 @@ export class Messaging extends BaseClient<paths> {
630
632
  },
631
633
  })
632
634
  .then(
633
- (response) => this.formatResponse(response),
634
- (reason) => this.formatError(reason),
635
+ (response) => formatResponse(response),
636
+ (reason) => formatError(reason),
635
637
  );
636
638
  }
637
639
 
@@ -649,8 +651,8 @@ export class Messaging extends BaseClient<paths> {
649
651
  },
650
652
  })
651
653
  .then(
652
- (response) => this.formatResponse(response),
653
- (reason) => this.formatError(reason),
654
+ (response) => formatResponse(response),
655
+ (reason) => formatError(reason),
654
656
  );
655
657
  }
656
658
 
@@ -668,8 +670,8 @@ export class Messaging extends BaseClient<paths> {
668
670
  },
669
671
  })
670
672
  .then(
671
- (response) => this.formatResponse(response),
672
- (reason) => this.formatError(reason),
673
+ (response) => formatResponse(response),
674
+ (reason) => formatError(reason),
673
675
  );
674
676
  }
675
677