@molecule/app-http 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +111 -24
- package/README.md +159 -133
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/provider.js +1 -1
- package/dist/provider.js.map +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
Apache License
|
|
2
3
|
Version 2.0, January 2004
|
|
3
4
|
http://www.apache.org/licenses/
|
|
@@ -34,21 +35,33 @@
|
|
|
34
35
|
|
|
35
36
|
"Work" shall mean the work of authorship, whether in Source or
|
|
36
37
|
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
38
40
|
|
|
39
41
|
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
42
|
form, that is based on (or derived from) the Work and for which the
|
|
41
43
|
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
-
represent, as a whole, an original work of authorship.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
49
62
|
|
|
50
63
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
51
|
-
on behalf of whom a Contribution has been received by
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
52
65
|
subsequently incorporated within the Work.
|
|
53
66
|
|
|
54
67
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
@@ -61,8 +74,18 @@
|
|
|
61
74
|
3. Grant of Patent License. Subject to the terms and conditions of
|
|
62
75
|
this License, each Contributor hereby grants to You a perpetual,
|
|
63
76
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
64
|
-
|
|
65
|
-
and otherwise transfer the Work
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
66
89
|
|
|
67
90
|
4. Redistribution. You may reproduce and distribute copies of the
|
|
68
91
|
Work or Derivative Works thereof in any medium, with or without
|
|
@@ -84,23 +107,87 @@
|
|
|
84
107
|
(d) If the Work includes a "NOTICE" text file as part of its
|
|
85
108
|
distribution, then any Derivative Works that You distribute must
|
|
86
109
|
include a readable copy of the attribution notices contained
|
|
87
|
-
within such NOTICE file
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
90
138
|
|
|
91
139
|
6. Trademarks. This License does not grant permission to use the trade
|
|
92
|
-
names, trademarks, service marks, or product names of the Licensor
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
93
143
|
|
|
94
144
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
95
|
-
agreed to in writing, Licensor provides the Work
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
104
191
|
|
|
105
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
106
193
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-10-16T00:35:00.541Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-http
|
|
@@ -49,29 +49,6 @@ npm install @molecule/app-http @molecule/app-bond @molecule/app-i18n @molecule/a
|
|
|
49
49
|
|
|
50
50
|
### Interfaces
|
|
51
51
|
|
|
52
|
-
#### `FullRequestConfig`
|
|
53
|
-
|
|
54
|
-
Full request configuration including method and URL.
|
|
55
|
-
|
|
56
|
-
```typescript
|
|
57
|
-
interface FullRequestConfig extends RequestConfig {
|
|
58
|
-
/**
|
|
59
|
-
* HTTP method.
|
|
60
|
-
*/
|
|
61
|
-
method: HttpMethod
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Request URL (can be relative or absolute).
|
|
65
|
-
*/
|
|
66
|
-
url: string
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Request body data.
|
|
70
|
-
*/
|
|
71
|
-
data?: unknown
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
52
|
#### `HttpClient`
|
|
76
53
|
|
|
77
54
|
HTTP client interface.
|
|
@@ -182,39 +159,13 @@ interface HttpClientConfig {
|
|
|
182
159
|
* Whether to include credentials by default.
|
|
183
160
|
*/
|
|
184
161
|
withCredentials?: boolean
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
#### `HttpResponse`
|
|
189
162
|
|
|
190
|
-
Parsed HTTP response with status code, headers, and typed body data.
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
interface HttpResponse<T = unknown> {
|
|
194
163
|
/**
|
|
195
|
-
*
|
|
164
|
+
* The scheme of the `Authorization` header the auth token is sent with:
|
|
165
|
+
* `Bearer` (default), or what your API expects, e.g. `Token` for an API that
|
|
166
|
+
* reads `Authorization: Token <jwt>`.
|
|
196
167
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* HTTP status code.
|
|
201
|
-
*/
|
|
202
|
-
status: number
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* HTTP status text.
|
|
206
|
-
*/
|
|
207
|
-
statusText: string
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Response headers.
|
|
211
|
-
*/
|
|
212
|
-
headers: Record<string, string>
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Original request config.
|
|
216
|
-
*/
|
|
217
|
-
config: FullRequestConfig
|
|
168
|
+
authScheme?: string
|
|
218
169
|
}
|
|
219
170
|
```
|
|
220
171
|
|
|
@@ -266,25 +217,64 @@ interface RequestConfig {
|
|
|
266
217
|
}
|
|
267
218
|
```
|
|
268
219
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
#### `ErrorInterceptor`
|
|
220
|
+
#### `FullRequestConfig`
|
|
272
221
|
|
|
273
|
-
|
|
274
|
-
Throwing from this interceptor propagates the error to the caller.
|
|
222
|
+
Full request configuration including method and URL.
|
|
275
223
|
|
|
276
224
|
```typescript
|
|
277
|
-
|
|
225
|
+
interface FullRequestConfig extends RequestConfig {
|
|
226
|
+
/**
|
|
227
|
+
* HTTP method.
|
|
228
|
+
*/
|
|
229
|
+
method: HttpMethod
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Request URL (can be relative or absolute).
|
|
233
|
+
*/
|
|
234
|
+
url: string
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Request body data.
|
|
238
|
+
*/
|
|
239
|
+
data?: unknown
|
|
240
|
+
}
|
|
278
241
|
```
|
|
279
242
|
|
|
280
|
-
#### `
|
|
243
|
+
#### `HttpResponse`
|
|
281
244
|
|
|
282
|
-
HTTP
|
|
245
|
+
Parsed HTTP response with status code, headers, and typed body data.
|
|
283
246
|
|
|
284
247
|
```typescript
|
|
285
|
-
|
|
248
|
+
interface HttpResponse<T = unknown> {
|
|
249
|
+
/**
|
|
250
|
+
* Response data.
|
|
251
|
+
*/
|
|
252
|
+
data: T
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* HTTP status code.
|
|
256
|
+
*/
|
|
257
|
+
status: number
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* HTTP status text.
|
|
261
|
+
*/
|
|
262
|
+
statusText: string
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Response headers.
|
|
266
|
+
*/
|
|
267
|
+
headers: Record<string, string>
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Original request config.
|
|
271
|
+
*/
|
|
272
|
+
config: FullRequestConfig
|
|
273
|
+
}
|
|
286
274
|
```
|
|
287
275
|
|
|
276
|
+
### Types
|
|
277
|
+
|
|
288
278
|
#### `RequestInterceptor`
|
|
289
279
|
|
|
290
280
|
Intercepts outgoing requests to modify headers, URL, or body
|
|
@@ -296,6 +286,8 @@ type RequestInterceptor = (
|
|
|
296
286
|
) => FullRequestConfig | Promise<FullRequestConfig>
|
|
297
287
|
```
|
|
298
288
|
|
|
289
|
+
- `config` — The full request configuration to transform.
|
|
290
|
+
|
|
299
291
|
#### `ResponseInterceptor`
|
|
300
292
|
|
|
301
293
|
Intercepts incoming responses to transform data, check status,
|
|
@@ -307,12 +299,44 @@ type ResponseInterceptor<T = unknown> = (
|
|
|
307
299
|
) => HttpResponse<T> | Promise<HttpResponse<T>>
|
|
308
300
|
```
|
|
309
301
|
|
|
302
|
+
#### `ErrorInterceptor`
|
|
303
|
+
|
|
304
|
+
Intercepts HTTP errors to transform, retry, or rethrow them.
|
|
305
|
+
Throwing from this interceptor propagates the error to the caller.
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
type ErrorInterceptor = (error: HttpError) => HttpError | Promise<HttpError> | never
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
#### `HttpMethod`
|
|
312
|
+
|
|
313
|
+
HTTP request method.
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'
|
|
317
|
+
```
|
|
318
|
+
|
|
310
319
|
### Classes
|
|
311
320
|
|
|
312
321
|
#### `HttpError`
|
|
313
322
|
|
|
314
323
|
HTTP error with response details.
|
|
315
324
|
|
|
325
|
+
```typescript
|
|
326
|
+
class HttpError extends Error {
|
|
327
|
+
constructor(
|
|
328
|
+
message: string,
|
|
329
|
+
public status: number,
|
|
330
|
+
public response?: HttpResponse,
|
|
331
|
+
public config?: FullRequestConfig,
|
|
332
|
+
public errorKey?: string,
|
|
333
|
+
) {
|
|
334
|
+
super(message)
|
|
335
|
+
this.name = 'HttpError'
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
316
340
|
### Functions
|
|
317
341
|
|
|
318
342
|
#### `createFetchClient(config)`
|
|
@@ -331,31 +355,71 @@ function createFetchClient(config?: HttpClientConfig): HttpClient
|
|
|
331
355
|
|
|
332
356
|
**Returns:** A fully configured `HttpClient` instance.
|
|
333
357
|
|
|
334
|
-
#### `
|
|
358
|
+
#### `unwrapList(res)`
|
|
335
359
|
|
|
336
|
-
|
|
360
|
+
Normalize an unknown response body into a typed array.
|
|
361
|
+
|
|
362
|
+
Accepts:
|
|
363
|
+
|
|
364
|
+
- a bare array → returned as-is (cast)
|
|
365
|
+
- `{ data: T[] }` envelope → the inner array
|
|
366
|
+
- `HttpResponse<T[]>` (i.e. `{ data: T[], status, ... }`) → the inner array
|
|
367
|
+
- `HttpResponse<{ data: T[] }>` (the response of an envelope-returning
|
|
368
|
+
endpoint as it arrives from `@molecule/app-http`'s `HttpClient`) → the
|
|
369
|
+
doubly-nested inner array
|
|
370
|
+
- `HttpResponse<{ data: T[], total, limit, offset }>` (a RICH pagination
|
|
371
|
+
envelope from a pre-built `@molecule/api-resource-*` list endpoint) → the
|
|
372
|
+
inner `data` array (the numeric `total`/`limit`/`offset` make the shape
|
|
373
|
+
unambiguous, so callers can pass the whole HttpResponse and still get the rows)
|
|
374
|
+
- anything else → `[]`
|
|
375
|
+
|
|
376
|
+
Callers commonly pass either the raw JSON body (e.g. from `fetch().then(r =>
|
|
377
|
+
r.json())`) or the `HttpResponse` returned by `useHttpClient().get(...)`.
|
|
378
|
+
Both shapes are handled here so pages don't have to remember to call
|
|
379
|
+
`unwrapList(res.data)` vs `unwrapList(res)`.
|
|
337
380
|
|
|
338
381
|
```typescript
|
|
339
|
-
function
|
|
382
|
+
function unwrapList(res: unknown): T[]
|
|
340
383
|
```
|
|
341
384
|
|
|
342
|
-
- `
|
|
343
|
-
- `config` — Optional request configuration.
|
|
385
|
+
- `res` — Raw response body OR an `HttpResponse` envelope from `@molecule/app-http`.
|
|
344
386
|
|
|
345
|
-
**Returns:**
|
|
387
|
+
**Returns:** A typed array `T[]`; never `null`/`undefined`.
|
|
346
388
|
|
|
347
|
-
#### `
|
|
389
|
+
#### `unwrapSingle(res)`
|
|
348
390
|
|
|
349
|
-
|
|
391
|
+
Normalize an unknown response body into a single typed resource.
|
|
392
|
+
|
|
393
|
+
Accepts:
|
|
394
|
+
|
|
395
|
+
- a non-empty plain object → returned as-is (cast)
|
|
396
|
+
- `{ data: T }` envelope → the inner value
|
|
397
|
+
- `{ data: null }`, `{ data: undefined }`, `{ data: [] }`, or
|
|
398
|
+
`{ data: {} }` (mock-server's no-match shape) → `null`
|
|
399
|
+
- an empty object `{}` → `null`
|
|
400
|
+
- arrays, primitives, `null`, `undefined` → `null`
|
|
401
|
+
|
|
402
|
+
The "envelope contains an array → null" branch handles the case
|
|
403
|
+
where the mock server returns `[]` for unmatched endpoints but the
|
|
404
|
+
caller expects a single resource.
|
|
350
405
|
|
|
351
406
|
```typescript
|
|
352
|
-
function
|
|
407
|
+
function unwrapSingle(res: unknown): T | null
|
|
353
408
|
```
|
|
354
409
|
|
|
355
|
-
- `
|
|
356
|
-
- `config` — Optional request configuration (headers, params, timeout).
|
|
410
|
+
- `res` — Raw response body (e.g. `HttpResponse.data` from `@molecule/app-http`).
|
|
357
411
|
|
|
358
|
-
**Returns:** The
|
|
412
|
+
**Returns:** The typed resource `T`, or `null` when the response shape indicates "no resource" (including the various empty envelopes above).
|
|
413
|
+
|
|
414
|
+
#### `setClient(client)`
|
|
415
|
+
|
|
416
|
+
Registers an HTTP client as the active singleton.
|
|
417
|
+
|
|
418
|
+
```typescript
|
|
419
|
+
function setClient(client: HttpClient): void
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
- `client` — The HTTP client implementation to bond.
|
|
359
423
|
|
|
360
424
|
#### `getClient()`
|
|
361
425
|
|
|
@@ -368,17 +432,16 @@ function getClient(): HttpClient
|
|
|
368
432
|
|
|
369
433
|
**Returns:** The active HTTP client instance.
|
|
370
434
|
|
|
371
|
-
#### `
|
|
435
|
+
#### `get(url, config)`
|
|
372
436
|
|
|
373
|
-
Makes a
|
|
437
|
+
Makes a GET request using the bonded HTTP client.
|
|
374
438
|
|
|
375
439
|
```typescript
|
|
376
|
-
function
|
|
440
|
+
function get(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
377
441
|
```
|
|
378
442
|
|
|
379
|
-
- `url` — The request URL.
|
|
380
|
-
- `
|
|
381
|
-
- `config` — Optional request configuration.
|
|
443
|
+
- `url` — The request URL (relative to baseURL if configured).
|
|
444
|
+
- `config` — Optional request configuration (headers, params, timeout).
|
|
382
445
|
|
|
383
446
|
**Returns:** The HTTP response with typed data.
|
|
384
447
|
|
|
@@ -410,71 +473,32 @@ function put(url: string, data?: unknown, config?: RequestConfig): Promise<HttpR
|
|
|
410
473
|
|
|
411
474
|
**Returns:** The HTTP response with typed data.
|
|
412
475
|
|
|
413
|
-
#### `
|
|
414
|
-
|
|
415
|
-
Registers an HTTP client as the active singleton.
|
|
416
|
-
|
|
417
|
-
```typescript
|
|
418
|
-
function setClient(client: HttpClient): void
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
- `client` — The HTTP client implementation to bond.
|
|
422
|
-
|
|
423
|
-
#### `unwrapList(res)`
|
|
424
|
-
|
|
425
|
-
Normalize an unknown response body into a typed array.
|
|
426
|
-
|
|
427
|
-
Accepts:
|
|
428
|
-
|
|
429
|
-
- a bare array → returned as-is (cast)
|
|
430
|
-
- `{ data: T[] }` envelope → the inner array
|
|
431
|
-
- `HttpResponse<T[]>` (i.e. `{ data: T[], status, ... }`) → the inner array
|
|
432
|
-
- `HttpResponse<{ data: T[] }>` (the response of an envelope-returning
|
|
433
|
-
endpoint as it arrives from `@molecule/app-http`'s `HttpClient`) → the
|
|
434
|
-
doubly-nested inner array
|
|
435
|
-
- `HttpResponse<{ data: T[], total, limit, offset }>` (a RICH pagination
|
|
436
|
-
envelope from a pre-built `@molecule/api-resource-*` list endpoint) → the
|
|
437
|
-
inner `data` array (the numeric `total`/`limit`/`offset` make the shape
|
|
438
|
-
unambiguous, so callers can pass the whole HttpResponse and still get the rows)
|
|
439
|
-
- anything else → `[]`
|
|
476
|
+
#### `patch(url, data, config)`
|
|
440
477
|
|
|
441
|
-
|
|
442
|
-
r.json())`) or the `HttpResponse` returned by `useHttpClient().get(...)`.
|
|
443
|
-
Both shapes are handled here so pages don't have to remember to call
|
|
444
|
-
`unwrapList(res.data)` vs `unwrapList(res)`.
|
|
478
|
+
Makes a PATCH request using the bonded HTTP client.
|
|
445
479
|
|
|
446
480
|
```typescript
|
|
447
|
-
function
|
|
481
|
+
function patch(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
448
482
|
```
|
|
449
483
|
|
|
450
|
-
- `
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
#### `unwrapSingle(res)`
|
|
455
|
-
|
|
456
|
-
Normalize an unknown response body into a single typed resource.
|
|
484
|
+
- `url` — The request URL.
|
|
485
|
+
- `data` — The request body (partial update).
|
|
486
|
+
- `config` — Optional request configuration.
|
|
457
487
|
|
|
458
|
-
|
|
488
|
+
**Returns:** The HTTP response with typed data.
|
|
459
489
|
|
|
460
|
-
|
|
461
|
-
- `{ data: T }` envelope → the inner value
|
|
462
|
-
- `{ data: null }`, `{ data: undefined }`, `{ data: [] }`, or
|
|
463
|
-
`{ data: {} }` (mock-server's no-match shape) → `null`
|
|
464
|
-
- an empty object `{}` → `null`
|
|
465
|
-
- arrays, primitives, `null`, `undefined` → `null`
|
|
490
|
+
#### `del(url, config)`
|
|
466
491
|
|
|
467
|
-
|
|
468
|
-
where the mock server returns `[]` for unmatched endpoints but the
|
|
469
|
-
caller expects a single resource.
|
|
492
|
+
Makes a DELETE request using the bonded HTTP client.
|
|
470
493
|
|
|
471
494
|
```typescript
|
|
472
|
-
function
|
|
495
|
+
function del(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
|
|
473
496
|
```
|
|
474
497
|
|
|
475
|
-
- `
|
|
498
|
+
- `url` — The request URL.
|
|
499
|
+
- `config` — Optional request configuration.
|
|
476
500
|
|
|
477
|
-
**Returns:** The
|
|
501
|
+
**Returns:** The HTTP response with typed data.
|
|
478
502
|
|
|
479
503
|
### Constants
|
|
480
504
|
|
|
@@ -530,6 +554,8 @@ Two mistakes that break in preview/production (seen in real imported apps):
|
|
|
530
554
|
Auth (the bearer token / session cookie) is attached by the client's interceptors — do not
|
|
531
555
|
read a token from `localStorage` or hand-attach it (the token is memory-only; see the user
|
|
532
556
|
resource).
|
|
557
|
+
An API that wants another scheme than `Bearer` (`Authorization: Token <jwt>`) sets
|
|
558
|
+
`authScheme: 'Token'` in the client config; do not hand-write a fetch wrapper for it.
|
|
533
559
|
|
|
534
560
|
## Translations
|
|
535
561
|
|
package/dist/client.d.ts
CHANGED
|
@@ -95,5 +95,11 @@ export interface HttpClientConfig {
|
|
|
95
95
|
* Whether to include credentials by default.
|
|
96
96
|
*/
|
|
97
97
|
withCredentials?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The scheme of the `Authorization` header the auth token is sent with:
|
|
100
|
+
* `Bearer` (default), or what your API expects, e.g. `Token` for an API that
|
|
101
|
+
* reads `Authorization: Token <jwt>`.
|
|
102
|
+
*/
|
|
103
|
+
authScheme?: string;
|
|
98
104
|
}
|
|
99
105
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAClG,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEhF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W,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEvC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
* Auth (the bearer token / session cookie) is attached by the client's interceptors — do not
|
|
42
42
|
* read a token from `localStorage` or hand-attach it (the token is memory-only; see the user
|
|
43
43
|
* resource).
|
|
44
|
+
* An API that wants another scheme than `Bearer` (`Authorization: Token <jwt>`) sets
|
|
45
|
+
* `authScheme: 'Token'` in the client config; do not hand-write a fetch wrapper for it.
|
|
44
46
|
*
|
|
45
47
|
* @module
|
|
46
48
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
* Auth (the bearer token / session cookie) is attached by the client's interceptors — do not
|
|
42
42
|
* read a token from `localStorage` or hand-attach it (the token is memory-only; see the user
|
|
43
43
|
* resource).
|
|
44
|
+
* An API that wants another scheme than `Bearer` (`Authorization: Token <jwt>`) sets
|
|
45
|
+
* `authScheme: 'Token'` in the client config; do not hand-write a fetch wrapper for it.
|
|
44
46
|
*
|
|
45
47
|
* @module
|
|
46
48
|
*/
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA"}
|
package/dist/provider.js
CHANGED
|
@@ -85,7 +85,7 @@ export const createFetchClient = (config = {}) => {
|
|
|
85
85
|
};
|
|
86
86
|
// Add auth token
|
|
87
87
|
if (authToken) {
|
|
88
|
-
headers['Authorization'] =
|
|
88
|
+
headers['Authorization'] = `${config.authScheme ?? 'Bearer'} ${authToken}`;
|
|
89
89
|
}
|
|
90
90
|
// Add content-type for JSON
|
|
91
91
|
if (finalConfig.data && !headers['Content-Type']) {
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAKhD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC;;;;;;;;;GASG;AACH,MAAM,C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@@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-http",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Client HTTP interface for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@molecule/app-bond": "1.0.2",
|
|
37
|
-
"@molecule/app-i18n": "1.0.
|
|
37
|
+
"@molecule/app-i18n": "1.0.3",
|
|
38
38
|
"@molecule/app-logger": "1.0.2",
|
|
39
39
|
"@types/node": "26.1.2",
|
|
40
40
|
"typescript": "6.0.3",
|