@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.
- package/README.md +33 -2
- package/dist/__tests__/client/clients/featureFlags/index.test.d.ts.map +1 -0
- package/dist/{client → __tests__/client}/clients/featureFlags/index.test.js +12 -8
- package/dist/__tests__/client/clients/featureFlags/index.test.js.map +1 -0
- package/dist/__tests__/client/utils/client-utils.test.d.ts +2 -0
- package/dist/__tests__/client/utils/client-utils.test.d.ts.map +1 -0
- package/dist/__tests__/client/utils/client-utils.test.js +115 -0
- package/dist/__tests__/client/utils/client-utils.test.js.map +1 -0
- package/dist/client/base-client.d.ts +1 -4
- package/dist/client/base-client.d.ts.map +1 -1
- package/dist/client/base-client.js +0 -27
- package/dist/client/base-client.js.map +1 -1
- package/dist/client/clients/featureFlags/index.d.ts.map +1 -1
- package/dist/client/clients/featureFlags/index.js +3 -2
- package/dist/client/clients/featureFlags/index.js.map +1 -1
- package/dist/client/clients/messaging/index.d.ts.map +1 -1
- package/dist/client/clients/messaging/index.js +30 -30
- package/dist/client/clients/messaging/index.js.map +1 -1
- package/dist/client/clients/payments/index.d.ts.map +1 -1
- package/dist/client/clients/payments/index.js +25 -24
- package/dist/client/clients/payments/index.js.map +1 -1
- package/dist/client/clients/profile/index.d.ts.map +1 -1
- package/dist/client/clients/profile/index.js +14 -13
- package/dist/client/clients/profile/index.js.map +1 -1
- package/dist/client/clients/scheduler/index.d.ts.map +1 -1
- package/dist/client/clients/scheduler/index.js +2 -1
- package/dist/client/clients/scheduler/index.js.map +1 -1
- package/dist/client/clients/upload/index.d.ts +11 -44
- package/dist/client/clients/upload/index.d.ts.map +1 -1
- package/dist/client/clients/upload/index.js +10 -9
- package/dist/client/clients/upload/index.js.map +1 -1
- package/dist/client/utils/client-utils.d.ts +3 -1
- package/dist/client/utils/client-utils.d.ts.map +1 -1
- package/dist/client/utils/client-utils.js +27 -0
- package/dist/client/utils/client-utils.js.map +1 -1
- package/package.json +2 -2
- package/src/{client → __tests__/client}/clients/featureFlags/index.test.ts +16 -9
- package/src/__tests__/client/utils/client-utils.test.ts +198 -0
- package/src/__tests__/client/utils/response-types.d.ts +59 -0
- package/src/client/base-client.ts +0 -33
- package/src/client/clients/featureFlags/index.ts +3 -2
- package/src/client/clients/messaging/index.ts +60 -58
- package/src/client/clients/payments/index.ts +49 -48
- package/src/client/clients/profile/index.ts +27 -26
- package/src/client/clients/scheduler/index.ts +3 -2
- package/src/client/clients/upload/index.ts +31 -17
- package/src/client/utils/client-utils.ts +34 -1
- package/dist/client/clients/featureFlags/index.test.d.ts.map +0 -1
- package/dist/client/clients/featureFlags/index.test.js.map +0 -1
- /package/dist/{client → __tests__/client}/clients/featureFlags/index.test.d.ts +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type createClient from "openapi-fetch";
|
|
2
2
|
import { PAYMENTS } from "../../../types/index.js";
|
|
3
3
|
import { BaseClient } from "../../base-client.js";
|
|
4
|
+
import { formatError, formatResponse } from "../../utils/client-utils.js";
|
|
4
5
|
import type { paths } from "./schema.js";
|
|
5
6
|
|
|
6
7
|
export class Payments extends BaseClient<paths> {
|
|
@@ -12,8 +13,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
12
13
|
*/
|
|
13
14
|
async getProviders() {
|
|
14
15
|
return this.client.GET("/api/v1/providers/").then(
|
|
15
|
-
(response) =>
|
|
16
|
-
(reason) =>
|
|
16
|
+
(response) => formatResponse(response),
|
|
17
|
+
(reason) => formatError(reason),
|
|
17
18
|
);
|
|
18
19
|
}
|
|
19
20
|
|
|
@@ -29,8 +30,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
29
30
|
},
|
|
30
31
|
})
|
|
31
32
|
.then(
|
|
32
|
-
(response) =>
|
|
33
|
-
(reason) =>
|
|
33
|
+
(response) => formatResponse(response),
|
|
34
|
+
(reason) => formatError(reason),
|
|
34
35
|
);
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -42,8 +43,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
42
43
|
body: data,
|
|
43
44
|
})
|
|
44
45
|
.then(
|
|
45
|
-
(response) =>
|
|
46
|
-
(reason) =>
|
|
46
|
+
(response) => formatResponse(response),
|
|
47
|
+
(reason) => formatError(reason),
|
|
47
48
|
);
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -61,8 +62,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
61
62
|
body: data,
|
|
62
63
|
})
|
|
63
64
|
.then(
|
|
64
|
-
(response) =>
|
|
65
|
-
(reason) =>
|
|
65
|
+
(response) => formatResponse(response),
|
|
66
|
+
(reason) => formatError(reason),
|
|
66
67
|
);
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -80,8 +81,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
80
81
|
},
|
|
81
82
|
})
|
|
82
83
|
.then(
|
|
83
|
-
(response) =>
|
|
84
|
-
(reason) =>
|
|
84
|
+
(response) => formatResponse(response),
|
|
85
|
+
(reason) => formatError(reason),
|
|
85
86
|
);
|
|
86
87
|
}
|
|
87
88
|
|
|
@@ -97,8 +98,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
97
98
|
},
|
|
98
99
|
})
|
|
99
100
|
.then(
|
|
100
|
-
(response) =>
|
|
101
|
-
(reason) =>
|
|
101
|
+
(response) => formatResponse(response),
|
|
102
|
+
(reason) => formatError(reason),
|
|
102
103
|
);
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -116,8 +117,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
116
117
|
},
|
|
117
118
|
})
|
|
118
119
|
.then(
|
|
119
|
-
(response) =>
|
|
120
|
-
(reason) =>
|
|
120
|
+
(response) => formatResponse(response),
|
|
121
|
+
(reason) => formatError(reason),
|
|
121
122
|
);
|
|
122
123
|
}
|
|
123
124
|
|
|
@@ -129,8 +130,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
129
130
|
body: data,
|
|
130
131
|
})
|
|
131
132
|
.then(
|
|
132
|
-
(response) =>
|
|
133
|
-
(reason) =>
|
|
133
|
+
(response) => formatResponse(response),
|
|
134
|
+
(reason) => formatError(reason),
|
|
134
135
|
);
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -146,8 +147,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
146
147
|
},
|
|
147
148
|
})
|
|
148
149
|
.then(
|
|
149
|
-
(response) =>
|
|
150
|
-
(reason) =>
|
|
150
|
+
(response) => formatResponse(response),
|
|
151
|
+
(reason) => formatError(reason),
|
|
151
152
|
);
|
|
152
153
|
}
|
|
153
154
|
|
|
@@ -159,8 +160,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
159
160
|
body: data,
|
|
160
161
|
})
|
|
161
162
|
.then(
|
|
162
|
-
(response) =>
|
|
163
|
-
(reason) =>
|
|
163
|
+
(response) => formatResponse(response),
|
|
164
|
+
(reason) => formatError(reason),
|
|
164
165
|
);
|
|
165
166
|
}
|
|
166
167
|
|
|
@@ -176,8 +177,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
176
177
|
},
|
|
177
178
|
})
|
|
178
179
|
.then(
|
|
179
|
-
(response) =>
|
|
180
|
-
(reason) =>
|
|
180
|
+
(response) => formatResponse(response),
|
|
181
|
+
(reason) => formatError(reason),
|
|
181
182
|
);
|
|
182
183
|
}
|
|
183
184
|
|
|
@@ -195,8 +196,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
195
196
|
},
|
|
196
197
|
})
|
|
197
198
|
.then(
|
|
198
|
-
(response) =>
|
|
199
|
-
(reason) =>
|
|
199
|
+
(response) => formatResponse(response),
|
|
200
|
+
(reason) => formatError(reason),
|
|
200
201
|
);
|
|
201
202
|
}
|
|
202
203
|
|
|
@@ -210,8 +211,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
210
211
|
},
|
|
211
212
|
})
|
|
212
213
|
.then(
|
|
213
|
-
(response) =>
|
|
214
|
-
(reason) =>
|
|
214
|
+
(response) => formatResponse(response),
|
|
215
|
+
(reason) => formatError(reason),
|
|
215
216
|
);
|
|
216
217
|
}
|
|
217
218
|
|
|
@@ -229,8 +230,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
229
230
|
body: data,
|
|
230
231
|
})
|
|
231
232
|
.then(
|
|
232
|
-
(response) =>
|
|
233
|
-
(reason) =>
|
|
233
|
+
(response) => formatResponse(response),
|
|
234
|
+
(reason) => formatError(reason),
|
|
234
235
|
);
|
|
235
236
|
}
|
|
236
237
|
|
|
@@ -242,15 +243,15 @@ export class Payments extends BaseClient<paths> {
|
|
|
242
243
|
body: data,
|
|
243
244
|
})
|
|
244
245
|
.then(
|
|
245
|
-
(response) =>
|
|
246
|
-
(reason) =>
|
|
246
|
+
(response) => formatResponse(response),
|
|
247
|
+
(reason) => formatError(reason),
|
|
247
248
|
);
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
async generatePaymentIntentId() {
|
|
251
252
|
return this.client.GET("/api/v1/transactions/generatePaymentIntentId").then(
|
|
252
|
-
(response) =>
|
|
253
|
-
(reason) =>
|
|
253
|
+
(response) => formatResponse(response),
|
|
254
|
+
(reason) => formatError(reason),
|
|
254
255
|
);
|
|
255
256
|
}
|
|
256
257
|
|
|
@@ -264,8 +265,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
264
265
|
},
|
|
265
266
|
})
|
|
266
267
|
.then(
|
|
267
|
-
(response) =>
|
|
268
|
-
(reason) =>
|
|
268
|
+
(response) => formatResponse(response),
|
|
269
|
+
(reason) => formatError(reason),
|
|
269
270
|
);
|
|
270
271
|
}
|
|
271
272
|
/**
|
|
@@ -282,8 +283,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
282
283
|
},
|
|
283
284
|
})
|
|
284
285
|
.then(
|
|
285
|
-
(response) =>
|
|
286
|
-
(reason) =>
|
|
286
|
+
(response) => formatResponse(response),
|
|
287
|
+
(reason) => formatError(reason),
|
|
287
288
|
);
|
|
288
289
|
}
|
|
289
290
|
|
|
@@ -297,8 +298,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
297
298
|
},
|
|
298
299
|
})
|
|
299
300
|
.then(
|
|
300
|
-
(response) =>
|
|
301
|
-
(reason) =>
|
|
301
|
+
(response) => formatResponse(response),
|
|
302
|
+
(reason) => formatError(reason),
|
|
302
303
|
);
|
|
303
304
|
}
|
|
304
305
|
|
|
@@ -316,8 +317,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
316
317
|
},
|
|
317
318
|
})
|
|
318
319
|
.then(
|
|
319
|
-
(response) =>
|
|
320
|
-
(reason) =>
|
|
320
|
+
(response) => formatResponse(response),
|
|
321
|
+
(reason) => formatError(reason),
|
|
321
322
|
);
|
|
322
323
|
}
|
|
323
324
|
|
|
@@ -333,15 +334,15 @@ export class Payments extends BaseClient<paths> {
|
|
|
333
334
|
},
|
|
334
335
|
})
|
|
335
336
|
.then(
|
|
336
|
-
(response) =>
|
|
337
|
-
(reason) =>
|
|
337
|
+
(response) => formatResponse(response),
|
|
338
|
+
(reason) => formatError(reason),
|
|
338
339
|
);
|
|
339
340
|
}
|
|
340
341
|
|
|
341
342
|
async getAuditLogEventTypes() {
|
|
342
343
|
return this.client.GET("/api/v1/auditLogs/event-types").then(
|
|
343
|
-
(response) =>
|
|
344
|
-
(reason) =>
|
|
344
|
+
(response) => formatResponse(response),
|
|
345
|
+
(reason) => formatError(reason),
|
|
345
346
|
);
|
|
346
347
|
}
|
|
347
348
|
|
|
@@ -357,8 +358,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
357
358
|
},
|
|
358
359
|
})
|
|
359
360
|
.then(
|
|
360
|
-
(response) =>
|
|
361
|
-
(reason) =>
|
|
361
|
+
(response) => formatResponse(response),
|
|
362
|
+
(reason) => formatError(reason),
|
|
362
363
|
);
|
|
363
364
|
}
|
|
364
365
|
|
|
@@ -370,8 +371,8 @@ export class Payments extends BaseClient<paths> {
|
|
|
370
371
|
body: data,
|
|
371
372
|
})
|
|
372
373
|
.then(
|
|
373
|
-
(response) =>
|
|
374
|
-
(reason) =>
|
|
374
|
+
(response) => formatResponse(response),
|
|
375
|
+
(reason) => formatError(reason),
|
|
375
376
|
);
|
|
376
377
|
}
|
|
377
378
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type createClient from "openapi-fetch";
|
|
2
2
|
import { PROFILE } from "../../../types/index.js";
|
|
3
3
|
import { BaseClient } from "../../base-client.js";
|
|
4
|
+
import { formatError, formatResponse } from "../../utils/client-utils.js";
|
|
4
5
|
import type { paths } from "./schema.js";
|
|
5
6
|
|
|
6
7
|
export class Profile extends BaseClient<paths> {
|
|
@@ -9,8 +10,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
9
10
|
|
|
10
11
|
async getAddresses() {
|
|
11
12
|
return this.client.GET("/api/v1/addresses/").then(
|
|
12
|
-
(response) =>
|
|
13
|
-
(reason) =>
|
|
13
|
+
(response) => formatResponse(response),
|
|
14
|
+
(reason) => formatError(reason),
|
|
14
15
|
);
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -20,8 +21,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
20
21
|
params: { path: { addressId } },
|
|
21
22
|
})
|
|
22
23
|
.then(
|
|
23
|
-
(response) =>
|
|
24
|
-
(reason) =>
|
|
24
|
+
(response) => formatResponse(response),
|
|
25
|
+
(reason) => formatError(reason),
|
|
25
26
|
);
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -33,8 +34,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
33
34
|
body: data,
|
|
34
35
|
})
|
|
35
36
|
.then(
|
|
36
|
-
(response) =>
|
|
37
|
-
(reason) =>
|
|
37
|
+
(response) => formatResponse(response),
|
|
38
|
+
(reason) => formatError(reason),
|
|
38
39
|
);
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -53,8 +54,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
53
54
|
body: data,
|
|
54
55
|
})
|
|
55
56
|
.then(
|
|
56
|
-
(response) =>
|
|
57
|
-
(reason) =>
|
|
57
|
+
(response) => formatResponse(response),
|
|
58
|
+
(reason) => formatError(reason),
|
|
58
59
|
);
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -68,8 +69,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
68
69
|
body: data,
|
|
69
70
|
})
|
|
70
71
|
.then(
|
|
71
|
-
(response) =>
|
|
72
|
-
(reason) =>
|
|
72
|
+
(response) => formatResponse(response),
|
|
73
|
+
(reason) => formatError(reason),
|
|
73
74
|
);
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -79,15 +80,15 @@ export class Profile extends BaseClient<paths> {
|
|
|
79
80
|
params: { path: { addressId } },
|
|
80
81
|
})
|
|
81
82
|
.then(
|
|
82
|
-
(response) =>
|
|
83
|
-
(reason) =>
|
|
83
|
+
(response) => formatResponse(response),
|
|
84
|
+
(reason) => formatError(reason),
|
|
84
85
|
);
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
async getEntitlements() {
|
|
88
89
|
return this.client.GET("/api/v1/entitlements/").then(
|
|
89
|
-
(response) =>
|
|
90
|
-
(reason) =>
|
|
90
|
+
(response) => formatResponse(response),
|
|
91
|
+
(reason) => formatError(reason),
|
|
91
92
|
);
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -97,8 +98,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
97
98
|
params: { path: { userId } },
|
|
98
99
|
})
|
|
99
100
|
.then(
|
|
100
|
-
(response) =>
|
|
101
|
-
(reason) =>
|
|
101
|
+
(response) => formatResponse(response),
|
|
102
|
+
(reason) => formatError(reason),
|
|
102
103
|
);
|
|
103
104
|
}
|
|
104
105
|
|
|
@@ -110,8 +111,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
110
111
|
body: data,
|
|
111
112
|
})
|
|
112
113
|
.then(
|
|
113
|
-
(response) =>
|
|
114
|
-
(reason) =>
|
|
114
|
+
(response) => formatResponse(response),
|
|
115
|
+
(reason) => formatError(reason),
|
|
115
116
|
);
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -125,8 +126,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
125
126
|
body: data,
|
|
126
127
|
})
|
|
127
128
|
.then(
|
|
128
|
-
(response) =>
|
|
129
|
-
(reason) =>
|
|
129
|
+
(response) => formatResponse(response),
|
|
130
|
+
(reason) => formatError(reason),
|
|
130
131
|
);
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -145,8 +146,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
145
146
|
body: data,
|
|
146
147
|
})
|
|
147
148
|
.then(
|
|
148
|
-
(response) =>
|
|
149
|
-
(reason) =>
|
|
149
|
+
(response) => formatResponse(response),
|
|
150
|
+
(reason) => formatError(reason),
|
|
150
151
|
);
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -160,8 +161,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
160
161
|
},
|
|
161
162
|
})
|
|
162
163
|
.then(
|
|
163
|
-
(response) =>
|
|
164
|
-
(reason) =>
|
|
164
|
+
(response) => formatResponse(response),
|
|
165
|
+
(reason) => formatError(reason),
|
|
165
166
|
);
|
|
166
167
|
}
|
|
167
168
|
|
|
@@ -173,8 +174,8 @@ export class Profile extends BaseClient<paths> {
|
|
|
173
174
|
body: { ids },
|
|
174
175
|
})
|
|
175
176
|
.then(
|
|
176
|
-
(response) =>
|
|
177
|
-
(reason) =>
|
|
177
|
+
(response) => formatResponse(response),
|
|
178
|
+
(reason) => formatError(reason),
|
|
178
179
|
);
|
|
179
180
|
}
|
|
180
181
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type createClient from "openapi-fetch";
|
|
2
2
|
import { SCHEDULER } from "../../../types/index.js";
|
|
3
3
|
import { BaseClient } from "../../base-client.js";
|
|
4
|
+
import { formatError, formatResponse } from "../../utils/client-utils.js";
|
|
4
5
|
import type { paths } from "./schema.js";
|
|
5
6
|
|
|
6
7
|
export class Scheduler extends BaseClient<paths> {
|
|
@@ -19,8 +20,8 @@ export class Scheduler extends BaseClient<paths> {
|
|
|
19
20
|
body: tasks,
|
|
20
21
|
})
|
|
21
22
|
.then(
|
|
22
|
-
(response) =>
|
|
23
|
-
(reason) =>
|
|
23
|
+
(response) => formatResponse(response),
|
|
24
|
+
(reason) => formatError(reason),
|
|
24
25
|
);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type createClient from "openapi-fetch";
|
|
2
2
|
import { UPLOAD } from "../../../types/index.js";
|
|
3
3
|
import { BaseClient } from "../../base-client.js";
|
|
4
|
+
import { formatError, formatResponse } from "../../utils/client-utils.js";
|
|
4
5
|
import type { paths } from "./schema.js";
|
|
5
6
|
|
|
6
7
|
export class Upload extends BaseClient<paths> {
|
|
@@ -24,8 +25,8 @@ export class Upload extends BaseClient<paths> {
|
|
|
24
25
|
},
|
|
25
26
|
})
|
|
26
27
|
.then(
|
|
27
|
-
(response) =>
|
|
28
|
-
(reason) =>
|
|
28
|
+
(response) => formatResponse(response),
|
|
29
|
+
(reason) => formatError(reason),
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -62,8 +63,8 @@ export class Upload extends BaseClient<paths> {
|
|
|
62
63
|
params: { query: { userId } },
|
|
63
64
|
})
|
|
64
65
|
.then(
|
|
65
|
-
(response) =>
|
|
66
|
-
(reason) =>
|
|
66
|
+
(response) => formatResponse(response),
|
|
67
|
+
(reason) => formatError(reason),
|
|
67
68
|
);
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -73,8 +74,8 @@ export class Upload extends BaseClient<paths> {
|
|
|
73
74
|
params: { path: { id } },
|
|
74
75
|
})
|
|
75
76
|
.then(
|
|
76
|
-
(response) =>
|
|
77
|
-
(reason) =>
|
|
77
|
+
(response) => formatResponse(response),
|
|
78
|
+
(reason) => formatError(reason),
|
|
78
79
|
);
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -84,8 +85,8 @@ export class Upload extends BaseClient<paths> {
|
|
|
84
85
|
body: { fileId: id },
|
|
85
86
|
})
|
|
86
87
|
.then(
|
|
87
|
-
(response) =>
|
|
88
|
-
(reason) =>
|
|
88
|
+
(response) => formatResponse(response),
|
|
89
|
+
(reason) => formatError(reason),
|
|
89
90
|
);
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -99,8 +100,8 @@ export class Upload extends BaseClient<paths> {
|
|
|
99
100
|
},
|
|
100
101
|
})
|
|
101
102
|
.then(
|
|
102
|
-
(response) =>
|
|
103
|
-
(reason) =>
|
|
103
|
+
(response) => formatResponse(response),
|
|
104
|
+
(reason) => formatError(reason),
|
|
104
105
|
);
|
|
105
106
|
}
|
|
106
107
|
|
|
@@ -110,8 +111,8 @@ export class Upload extends BaseClient<paths> {
|
|
|
110
111
|
body: { fileId, userId },
|
|
111
112
|
})
|
|
112
113
|
.then(
|
|
113
|
-
(response) =>
|
|
114
|
-
(reason) =>
|
|
114
|
+
(response) => formatResponse(response),
|
|
115
|
+
(reason) => formatError(reason),
|
|
115
116
|
);
|
|
116
117
|
}
|
|
117
118
|
|
|
@@ -121,13 +122,26 @@ export class Upload extends BaseClient<paths> {
|
|
|
121
122
|
body: { fileId, userId },
|
|
122
123
|
})
|
|
123
124
|
.then(
|
|
124
|
-
(response) =>
|
|
125
|
-
(reason) =>
|
|
125
|
+
(response) => formatResponse(response),
|
|
126
|
+
(reason) => formatError(reason),
|
|
126
127
|
);
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
async uploadFile(
|
|
130
|
-
|
|
130
|
+
async uploadFile(
|
|
131
|
+
file: File,
|
|
132
|
+
expirationDate?: string,
|
|
133
|
+
): Promise<{
|
|
134
|
+
error?: {
|
|
135
|
+
code: string;
|
|
136
|
+
detail: string;
|
|
137
|
+
requestId: string;
|
|
138
|
+
name: string;
|
|
139
|
+
validation?: unknown;
|
|
140
|
+
validationContext?: string;
|
|
141
|
+
};
|
|
142
|
+
data?: { uploadId?: string };
|
|
143
|
+
}> {
|
|
144
|
+
const { error, data } = await this.client.POST("/api/v1/files/", {
|
|
131
145
|
body: {
|
|
132
146
|
file,
|
|
133
147
|
expirationDate,
|
|
@@ -144,6 +158,6 @@ export class Upload extends BaseClient<paths> {
|
|
|
144
158
|
},
|
|
145
159
|
});
|
|
146
160
|
|
|
147
|
-
return { error };
|
|
161
|
+
return { error, data: { uploadId: data?.data.id } };
|
|
148
162
|
}
|
|
149
163
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParseAsResponse } from "openapi-fetch";
|
|
1
|
+
import type { FetchResponse, ParseAsResponse } from "openapi-fetch";
|
|
2
2
|
import type {
|
|
3
3
|
ErrorStatus,
|
|
4
4
|
FilterKeys,
|
|
@@ -48,3 +48,36 @@ export function preparePaginationParams(paginationParams?: PaginationParams): {
|
|
|
48
48
|
|
|
49
49
|
return output;
|
|
50
50
|
}
|
|
51
|
+
|
|
52
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
53
|
+
export function formatResponse<G extends Record<string | number, any>, O>(
|
|
54
|
+
response: FetchResponse<G, O, "application/json">,
|
|
55
|
+
): DataResponseValue<G, O> {
|
|
56
|
+
let outputData = undefined;
|
|
57
|
+
let outputMetadata = undefined;
|
|
58
|
+
if (!response) {
|
|
59
|
+
return {} as DataResponseValue<G, O>;
|
|
60
|
+
}
|
|
61
|
+
if (response.data) {
|
|
62
|
+
const dataEntries = Object.entries(response.data);
|
|
63
|
+
// by docs the body should contain a "data"
|
|
64
|
+
// properties with the response values
|
|
65
|
+
const containsData = dataEntries.find((x) => x[0] === "data");
|
|
66
|
+
const containsMetadata = dataEntries.find((x) => x[0] === "metadata");
|
|
67
|
+
|
|
68
|
+
if (containsMetadata) {
|
|
69
|
+
outputMetadata = containsMetadata[1];
|
|
70
|
+
}
|
|
71
|
+
outputData = containsData ? containsData[1] : response.data;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
data: outputData,
|
|
76
|
+
metadata: outputMetadata,
|
|
77
|
+
error: response.error,
|
|
78
|
+
} as unknown as DataResponseValue<G, O>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function formatError<G, O>(reason: unknown): DataResponseValue<G, O> {
|
|
82
|
+
return { error: reason } as unknown as DataResponseValue<G, O>;
|
|
83
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../../src/client/clients/featureFlags/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../../../src/client/clients/featureFlags/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,IAAI,SAAS,GAAG,IAAI,CAAC;AAErB,MAAM,EAAE,CAAC,UAAU,CAAC,gBAAgB,EAAE;IACpC,UAAU,EAAE,EAAE,CAAC,IAAI,EAAE;IACrB,oBAAoB,EAAE,EAAE,CAAC,IAAI,EAAE;CAChC,CAAC,CAAC;AAEH,IAAI,aAAa,GAAG,EAAE,CAAC;AAEvB,MAAM,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE,CACxB,CAAC;IACC,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,GAAG;IACX,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,aAAa;IAC/B,OAAO,EAAE,IAAI,OAAO,EAAE;CACvB,CAAa,CAAC;AAEjB,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACjC,MAAM,OAAO,GAAG,iBAAiB,CAAC;IAClC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC;IACtC,IAAI,YAA0B,CAAC;IAE/B,CAAC,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;QACtB,YAAY,GAAG,IAAI,YAAY,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,CAAC,CAAC,IAAI,CAAC,4CAA4C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC/D,SAAS,GAAG,KAAK,CAAC;QAClB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAC7D,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,CAAC,CAAC,IAAI,CAAC,uCAAuC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC1D,SAAS,GAAG,IAAI,CAAC;QACjB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAC7D,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,CAAC,CAAC,IAAI,CACJ,iEAAiE,EACjE,KAAK,IAAI,EAAE;QACT,aAAa,GAAG,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAC;QACpD,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QACb,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE;YACb,IAAI,EAAE,EAAE;YACR,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
File without changes
|