maka-agent 0.2.0-dev.64.20260929 → 0.2.0-dev.67.20261002
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 +1 -1
- package/THIRD_PARTY_NOTICES.txt +3 -3
- package/dist/pi-tui-runner.js +26 -29
- package/dist/tui-copy-catalog.js +9 -9
- package/native/runtime-host-peer/prebuilds/darwin-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-arm64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/linux-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-peer/prebuilds/win32-x64/maka_runtime_host_peer.node +0 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@maka/core/dist/settings.js +2 -2
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +53 -150
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +8 -1
- package/node_modules/@maka/runtime/dist/conversation-copy.js +6 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +17 -0
- package/node_modules/@maka/runtime/dist/session-manager.js +25 -40
- package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +79 -13
- package/node_modules/@maka/runtime/dist/stream-graph-projection.js +64 -0
- package/node_modules/@maka/runtime/dist/stream-graph-read-model.js +138 -20
- package/node_modules/@maka/runtime/dist/tool-availability.js +10 -3
- package/node_modules/@maka/runtime-host/dist/candidate-entry.js +15 -0
- package/node_modules/@maka/runtime-host/dist/candidate-startup-failure.js +5 -0
- package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +1 -0
- package/node_modules/@maka/runtime-host/dist/client/startup-error.js +5 -0
- package/node_modules/@maka/runtime-host/dist/protocol/agent-graph.js +46 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +14 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +5 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +12 -0
- package/node_modules/@maka/runtime-host/dist/protocol/session-retirement.js +46 -10
- package/node_modules/@maka/runtime-host/dist/protocol/storage-usage.js +155 -0
- package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +23 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +5 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +27 -6
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +6 -0
- package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +112 -36
- package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +27 -1
- package/node_modules/@maka/runtime-host/dist/server/storage-usage-coordinator.js +67 -0
- package/node_modules/@maka/runtime-host/dist/server/workhub-inspection-tool.js +208 -0
- package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +3 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +0 -13
- package/node_modules/@maka/storage/dist/session-store.js +9 -6
- package/node_modules/@maka/storage/dist/sqlite-file-set.js +22 -0
- package/node_modules/@maka/storage/dist/sqlite-long-term-memory-store.js +1 -3
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +10 -260
- package/node_modules/@maka/storage/dist/sqlite-session-catalog-query.js +1 -0
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-schema.js +18 -6
- package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +28 -6
- package/node_modules/@maka/storage/dist/storage-footprint.js +239 -0
- package/node_modules/@maka/storage/dist/storage-writer-composition.js +10 -1
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +297 -5
- package/node_modules/axios/dist/axios.js +728 -170
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/browser/axios.cjs +871 -188
- package/node_modules/axios/dist/esm/axios.js +871 -188
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/node/axios.cjs +1037 -225
- package/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/axios/lib/adapters/http.js +140 -67
- package/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/axios/lib/core/Axios.js +43 -20
- package/node_modules/axios/lib/core/AxiosError.js +33 -2
- package/node_modules/axios/lib/core/AxiosHeaders.js +124 -1
- package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/axios/lib/core/buildFullPath.js +41 -15
- package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/axios/lib/core/mergeConfig.js +19 -4
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/core/setFormDataHeaders.js +27 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +12 -1
- package/node_modules/axios/lib/helpers/combineURLs.js +11 -3
- package/node_modules/axios/lib/helpers/composeSignals.js +12 -1
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +115 -54
- package/node_modules/axios/lib/helpers/formDataToJSON.js +11 -5
- package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +5 -3
- package/node_modules/axios/lib/helpers/progressEventReducer.js +4 -4
- package/node_modules/axios/lib/helpers/resolveConfig.js +5 -17
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +300 -5
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +17 -23
- package/node_modules/axios/lib/platform/node/classes/Buffer.js +11 -0
- package/node_modules/axios/lib/utils.js +151 -18
- package/node_modules/axios/package.json +21 -19
- package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
- package/node_modules/brace-expansion/dist/esm/index.js +68 -24
- package/node_modules/brace-expansion/package.json +2 -1
- package/node_modules/fast-uri/index.js +10 -6
- package/node_modules/fast-uri/package.json +1 -1
- package/package.json +1 -1
|
@@ -296,6 +296,128 @@
|
|
|
296
296
|
</p>
|
|
297
297
|
</td>
|
|
298
298
|
</tr>
|
|
299
|
+
<tr width="33.333333333333336%">
|
|
300
|
+
<td align="center" width="33.333333333333336%">
|
|
301
|
+
<a
|
|
302
|
+
href="https://www.jbo88b.com/vn/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
303
|
+
style="padding: 10px; display: inline-block"
|
|
304
|
+
target="_blank"
|
|
305
|
+
>
|
|
306
|
+
<img
|
|
307
|
+
width="71px"
|
|
308
|
+
height="70px"
|
|
309
|
+
src="https://images.opencollective.com/jbo-vietnam/3fc6159/avatar.png"
|
|
310
|
+
alt="JBO Vietnam"
|
|
311
|
+
/>
|
|
312
|
+
</a>
|
|
313
|
+
<p
|
|
314
|
+
align="center"
|
|
315
|
+
>
|
|
316
|
+
JBO Vietnam is a prominent online entertainment brand in Vietnam, offering sports betting, esports, online casino games, and a wide range of other exciting games.
|
|
317
|
+
</p>
|
|
318
|
+
<p align="center">
|
|
319
|
+
<a
|
|
320
|
+
href="https://www.jbo88b.com/vn/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
321
|
+
target="_blank"
|
|
322
|
+
><b>jbo88b.com</b></a
|
|
323
|
+
>
|
|
324
|
+
</p>
|
|
325
|
+
</td>
|
|
326
|
+
<td align="center" width="33.333333333333336%">
|
|
327
|
+
<a
|
|
328
|
+
href="https://www.jbo579.com/th/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
329
|
+
style="padding: 10px; display: inline-block"
|
|
330
|
+
target="_blank"
|
|
331
|
+
>
|
|
332
|
+
<img
|
|
333
|
+
width="71px"
|
|
334
|
+
height="70px"
|
|
335
|
+
src="https://images.opencollective.com/jbo-thailand/d17e84f/avatar.png"
|
|
336
|
+
alt="JBO Thailand"
|
|
337
|
+
/>
|
|
338
|
+
</a>
|
|
339
|
+
<p
|
|
340
|
+
align="center"
|
|
341
|
+
>
|
|
342
|
+
JBO Thailand is a prominent online entertainment brand in Thailand, offering sports betting, esports, online casino games, and a wide range of other exciting games.
|
|
343
|
+
</p>
|
|
344
|
+
<p align="center">
|
|
345
|
+
<a
|
|
346
|
+
href="https://www.jbo579.com/th/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
347
|
+
target="_blank"
|
|
348
|
+
><b>jbo88b.com</b></a
|
|
349
|
+
>
|
|
350
|
+
</p>
|
|
351
|
+
</td>
|
|
352
|
+
<td align="center" width="33.333333333333336%">
|
|
353
|
+
<a
|
|
354
|
+
href="https://kasyno.us.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
355
|
+
style="padding: 10px; display: inline-block"
|
|
356
|
+
target="_blank"
|
|
357
|
+
>
|
|
358
|
+
<img
|
|
359
|
+
width="71px"
|
|
360
|
+
height="70px"
|
|
361
|
+
src="https://images.opencollective.com/polskie-kasyno-online/c25e456/avatar.png"
|
|
362
|
+
alt="polskie kasyno online"
|
|
363
|
+
/>
|
|
364
|
+
</a>
|
|
365
|
+
<p
|
|
366
|
+
align="center"
|
|
367
|
+
>
|
|
368
|
+
Kasyno.us.com to niezależny portal o tematyce kasyno online Polska, który pomaga graczom znaleźć bezpieczne i sprawdzone kasyna internetowe.
|
|
369
|
+
</p>
|
|
370
|
+
<p align="center">
|
|
371
|
+
<a
|
|
372
|
+
href="https://kasyno.us.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
373
|
+
target="_blank"
|
|
374
|
+
><b>kasyno.us.com</b></a
|
|
375
|
+
>
|
|
376
|
+
</p>
|
|
377
|
+
</td>
|
|
378
|
+
</tr>
|
|
379
|
+
<tr width="33.333333333333336%">
|
|
380
|
+
<td align="center" width="33.333333333333336%">
|
|
381
|
+
<a
|
|
382
|
+
href="https://www.scrapingbee.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
383
|
+
style="padding: 10px; display: inline-block"
|
|
384
|
+
target="_blank"
|
|
385
|
+
>
|
|
386
|
+
<img
|
|
387
|
+
width="90px"
|
|
388
|
+
height="90px"
|
|
389
|
+
src="https://images.opencollective.com/scrapingbee/6d5dc95/logo.png"
|
|
390
|
+
alt="ScrapingBee"
|
|
391
|
+
/>
|
|
392
|
+
</a>
|
|
393
|
+
<p
|
|
394
|
+
align="center"
|
|
395
|
+
>
|
|
396
|
+
Scrape websites with a powerful web scraping API without managing proxies, browsers, or anti-bot defenses.
|
|
397
|
+
</p>
|
|
398
|
+
<p align="center">
|
|
399
|
+
<a
|
|
400
|
+
href="https://www.scrapingbee.com/?utm_source=axios_docs_website&utm_medium=website&utm_campaign=axios_open_collective_sponsorship"
|
|
401
|
+
target="_blank"
|
|
402
|
+
><b>scrapingbee.com</b></a
|
|
403
|
+
>
|
|
404
|
+
</p>
|
|
405
|
+
</td>
|
|
406
|
+
<td align="center" width="33.333333333333336%">
|
|
407
|
+
<a
|
|
408
|
+
href="https://opencollective.com/axios/contribute"
|
|
409
|
+
target="_blank"
|
|
410
|
+
>💜 Become a sponsor</a
|
|
411
|
+
>
|
|
412
|
+
</td>
|
|
413
|
+
<td align="center" width="33.333333333333336%">
|
|
414
|
+
<a
|
|
415
|
+
href="https://opencollective.com/axios/contribute"
|
|
416
|
+
target="_blank"
|
|
417
|
+
>💜 Become a sponsor</a
|
|
418
|
+
>
|
|
419
|
+
</td>
|
|
420
|
+
</tr>
|
|
299
421
|
</table>
|
|
300
422
|
|
|
301
423
|
<!--<div>marker</div>-->
|
|
@@ -587,6 +709,7 @@ axios({
|
|
|
587
709
|
|
|
588
710
|
```js
|
|
589
711
|
// GET request for remote image in node.js
|
|
712
|
+
import fs from 'fs';
|
|
590
713
|
const response = await axios({
|
|
591
714
|
method: 'get',
|
|
592
715
|
url: 'https://bit.ly/2mTM3nY',
|
|
@@ -699,6 +822,11 @@ These config options are available for requests. Only `url` is required. Request
|
|
|
699
822
|
// Axios prepends `baseURL` to `url` unless `url` is absolute and `allowAbsoluteUrls` is set to true.
|
|
700
823
|
// It can be convenient to set `baseURL` for an instance of axios to pass relative URLs
|
|
701
824
|
// to the methods of that instance.
|
|
825
|
+
// `baseURL` is not a security boundary. If `url` is attacker-controlled, validate it
|
|
826
|
+
// before passing it to axios. Relative URLs can contain `..` segments that resolve
|
|
827
|
+
// outside an intended path prefix after the final URL is parsed.
|
|
828
|
+
// HTTP(S) URLs must include `//` after the protocol. Values such as
|
|
829
|
+
// `https:example.com` and `https:/example.com` are rejected with ERR_INVALID_URL.
|
|
702
830
|
baseURL: 'https://some-domain.com/api/',
|
|
703
831
|
|
|
704
832
|
// `allowAbsoluteUrls` determines whether or not absolute URLs will override a configured `baseUrl`.
|
|
@@ -1307,6 +1435,40 @@ axios.interceptors.request.use(
|
|
|
1307
1435
|
);
|
|
1308
1436
|
```
|
|
1309
1437
|
|
|
1438
|
+
If a synchronous request interceptor throws, Axios calls that interceptor's paired rejection handler and stops running the remaining request interceptors. A rejection handler that returns normally, including one that returns `undefined` or a fulfilled Promise, treats the error as handled: Axios dispatches the request with the last valid config, and ignores the handler's return value. To block dispatch, omit the rejection handler or throw/return a rejected Promise from it. The final error then continues through response rejection interceptors.
|
|
1439
|
+
|
|
1440
|
+
Use a rejected Promise when validation must prevent the request:
|
|
1441
|
+
|
|
1442
|
+
```js
|
|
1443
|
+
axios.interceptors.request.use(
|
|
1444
|
+
function validate(config) {
|
|
1445
|
+
if (!config.headers.has('Authorization')) {
|
|
1446
|
+
throw new Error('Authorization is required');
|
|
1447
|
+
}
|
|
1448
|
+
return config;
|
|
1449
|
+
},
|
|
1450
|
+
function rejectInvalidRequest(error) {
|
|
1451
|
+
return Promise.reject(error);
|
|
1452
|
+
},
|
|
1453
|
+
{ synchronous: true }
|
|
1454
|
+
);
|
|
1455
|
+
```
|
|
1456
|
+
|
|
1457
|
+
A logging-only rejection handler can return normally to preserve the existing request-continuation behavior:
|
|
1458
|
+
|
|
1459
|
+
```js
|
|
1460
|
+
axios.interceptors.request.use(
|
|
1461
|
+
function prepare(config) {
|
|
1462
|
+
throw new Error('Optional preparation failed');
|
|
1463
|
+
},
|
|
1464
|
+
function logPreparationFailure(error) {
|
|
1465
|
+
console.warn(error);
|
|
1466
|
+
// Returning normally dispatches with the last valid config.
|
|
1467
|
+
},
|
|
1468
|
+
{ synchronous: true }
|
|
1469
|
+
);
|
|
1470
|
+
```
|
|
1471
|
+
|
|
1310
1472
|
If you want to execute a particular interceptor based on a runtime check,
|
|
1311
1473
|
you can add a `runWhen` function to the options object. The request interceptor will not run **if and only if** the return
|
|
1312
1474
|
of `runWhen` is `false`. Axios calls the function with the config
|
|
@@ -1374,7 +1536,7 @@ When a response is fulfilled and multiple response interceptors are registered:
|
|
|
1374
1536
|
- If a fulfillment interceptor throws, Axios skips the next fulfillment interceptor and calls the next rejection interceptor.
|
|
1375
1537
|
- After the error is caught, later fulfillment interceptors run again, just like in a promise chain.
|
|
1376
1538
|
|
|
1377
|
-
Read [the interceptor tests](./
|
|
1539
|
+
Read [the interceptor tests](./tests/browser/interceptors.browser.test.js) to see all this in code.
|
|
1378
1540
|
|
|
1379
1541
|
## Error types
|
|
1380
1542
|
|
|
@@ -1432,6 +1594,10 @@ axios.get('/user/12345').catch(function (error) {
|
|
|
1432
1594
|
});
|
|
1433
1595
|
```
|
|
1434
1596
|
|
|
1597
|
+
Axios rejects an `http:` or `https:` request `url` or `baseURL` that omits `//` after the protocol. For example, `https:example.com` and `https:/example.com` reject with `AxiosError` code `ERR_INVALID_URL` instead of being silently normalized. Pass a well-formed URL such as `https://example.com`.
|
|
1598
|
+
|
|
1599
|
+
The error identifies the malformed URL, for example `Invalid URL "https:example.com": missing "//" after protocol`. To keep logs useful without leaking secrets, Axios reports the control-character-normalized URL with credentials, query parameter values, and fragment contents redacted; the scheme, host, path, and query parameter names remain visible.
|
|
1600
|
+
|
|
1435
1601
|
Use `validateStatus` to override the default condition (`status >= 200 && status < 300`) and choose which HTTP status codes should reject.
|
|
1436
1602
|
|
|
1437
1603
|
```js
|
|
@@ -1867,6 +2033,24 @@ formData.append('users[1][surname]', 'Anderson');
|
|
|
1867
2033
|
formData.append('obj2{}', '[{"x":1}]');
|
|
1868
2034
|
```
|
|
1869
2035
|
|
|
2036
|
+
### Converting FormData to JSON
|
|
2037
|
+
|
|
2038
|
+
`axios.formToJSON()` converts `FormData` field names that use dot or bracket notation into nested objects and arrays. Only `.`, `[`, and `]` are structural separators. Other characters, including `-`, spaces, `+`, `*`, and `&`, remain part of the literal key.
|
|
2039
|
+
|
|
2040
|
+
```js
|
|
2041
|
+
const form = new FormData();
|
|
2042
|
+
form.append('user-name', 'johndoe');
|
|
2043
|
+
form.append('user.name', 'john');
|
|
2044
|
+
|
|
2045
|
+
console.log(axios.formToJSON(form));
|
|
2046
|
+
// {
|
|
2047
|
+
// 'user-name': 'johndoe',
|
|
2048
|
+
// user: { name: 'john' }
|
|
2049
|
+
// }
|
|
2050
|
+
```
|
|
2051
|
+
|
|
2052
|
+
`user[name]` also creates `{ user: { name: ... } }`, while `items[]` creates an array.
|
|
2053
|
+
|
|
1870
2054
|
Axios supports `postForm`, `putForm`, and `patchForm` as shortcuts for the matching HTTP methods with the `Content-Type` header preset to `multipart/form-data`.
|
|
1871
2055
|
|
|
1872
2056
|
## Posting files
|
|
@@ -1940,10 +2124,9 @@ submits this JSON object:
|
|
|
1940
2124
|
{
|
|
1941
2125
|
"foo": "1",
|
|
1942
2126
|
"deep": {
|
|
1943
|
-
"prop":
|
|
1944
|
-
"spaced": "3"
|
|
1945
|
-
}
|
|
2127
|
+
"prop": "2"
|
|
1946
2128
|
},
|
|
2129
|
+
"deep prop spaced": "3",
|
|
1947
2130
|
"baz": [
|
|
1948
2131
|
"4",
|
|
1949
2132
|
"5"
|
|
@@ -1954,6 +2137,8 @@ submits this JSON object:
|
|
|
1954
2137
|
}
|
|
1955
2138
|
```
|
|
1956
2139
|
|
|
2140
|
+
Only dot and bracket notation create nested paths when a form is converted to JSON. Spaces and other punctuation remain part of literal field names.
|
|
2141
|
+
|
|
1957
2142
|
Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported.
|
|
1958
2143
|
|
|
1959
2144
|
## Progress capturing
|
|
@@ -2182,8 +2367,9 @@ Returns `this`.
|
|
|
2182
2367
|
### AxiosHeaders#get(header)
|
|
2183
2368
|
|
|
2184
2369
|
```
|
|
2185
|
-
get(headerName: string,
|
|
2370
|
+
get(headerName: string, parser: typeof AxiosHeaders.parseParameters): AxiosHeaderParameters;
|
|
2186
2371
|
get(headerName: string, parser: RegExp): RegExpExecArray | null;
|
|
2372
|
+
get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue;
|
|
2187
2373
|
```
|
|
2188
2374
|
|
|
2189
2375
|
Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`,
|
|
@@ -2203,6 +2389,15 @@ console.log(headers.get('Content-Type', true)); // parse key-value pairs from a
|
|
|
2203
2389
|
// boundary: 'Asrf456BGe4h'
|
|
2204
2390
|
// }
|
|
2205
2391
|
|
|
2392
|
+
const quotedHeaders = new AxiosHeaders({
|
|
2393
|
+
'Content-Type': 'multipart/form-data; boundary="a,b"',
|
|
2394
|
+
});
|
|
2395
|
+
|
|
2396
|
+
console.log({
|
|
2397
|
+
...quotedHeaders.get('Content-Type', AxiosHeaders.parseParameters),
|
|
2398
|
+
});
|
|
2399
|
+
// { boundary: 'a,b' }
|
|
2400
|
+
|
|
2206
2401
|
console.log(
|
|
2207
2402
|
headers.get('Content-Type', (value, name, headers) => {
|
|
2208
2403
|
return String(value).replace(/a/g, 'ZZZ');
|
|
@@ -2214,6 +2409,10 @@ console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]);
|
|
|
2214
2409
|
// boundary=Asrf456BGe4h
|
|
2215
2410
|
```
|
|
2216
2411
|
|
|
2412
|
+
`AxiosHeaders.parseParameters` is the opt-in parser for normalized HTTP parameter values. It returns a null-prototype map, matches parameter names case-insensitively, removes quoted-string delimiters, decodes escaped quotes and backslashes, preserves commas and semicolons inside quoted values, and removes only HTTP optional whitespace around unquoted values. It omits the unsafe keys `__proto__`, `constructor`, and `prototype`.
|
|
2413
|
+
|
|
2414
|
+
Passing `true` remains the legacy tokenizer and keeps its existing output for backward compatibility.
|
|
2415
|
+
|
|
2217
2416
|
Returns the value of the header.
|
|
2218
2417
|
|
|
2219
2418
|
### AxiosHeaders#has(header, matcher?)
|
|
@@ -2498,6 +2697,99 @@ try {
|
|
|
2498
2697
|
}
|
|
2499
2698
|
```
|
|
2500
2699
|
|
|
2700
|
+
### Typing request data and query params
|
|
2701
|
+
|
|
2702
|
+
`AxiosRequestConfig<D = any, P = any>` uses `D` for the request body and `P` for query parameters. The params serializer receives the same `P`, and both types are preserved on the default response config:
|
|
2703
|
+
|
|
2704
|
+
```typescript
|
|
2705
|
+
import axios, {
|
|
2706
|
+
type AxiosPromise,
|
|
2707
|
+
type AxiosRequestConfig,
|
|
2708
|
+
type InternalAxiosRequestConfig,
|
|
2709
|
+
} from 'axios';
|
|
2710
|
+
|
|
2711
|
+
interface RequestBody {
|
|
2712
|
+
includeArchived: boolean;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
interface SearchParams {
|
|
2716
|
+
query: string;
|
|
2717
|
+
page?: number;
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2720
|
+
interface SearchResponse {
|
|
2721
|
+
results: string[];
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
const config: AxiosRequestConfig<RequestBody, SearchParams> = {
|
|
2725
|
+
data: { includeArchived: false },
|
|
2726
|
+
params: { query: 'axios', page: 1 },
|
|
2727
|
+
paramsSerializer: (params) => `${params.query}:${params.page ?? 1}`,
|
|
2728
|
+
};
|
|
2729
|
+
|
|
2730
|
+
const response = await axios.get('/search', config);
|
|
2731
|
+
response.config.data; // RequestBody | undefined
|
|
2732
|
+
response.config.params; // SearchParams | undefined
|
|
2733
|
+
|
|
2734
|
+
const invalidConfig: AxiosRequestConfig<RequestBody, SearchParams> = {
|
|
2735
|
+
// @ts-expect-error `query` must be a string
|
|
2736
|
+
params: { query: 123 },
|
|
2737
|
+
};
|
|
2738
|
+
|
|
2739
|
+
const adapter = (
|
|
2740
|
+
adapterConfig: InternalAxiosRequestConfig<RequestBody, SearchParams>
|
|
2741
|
+
): AxiosPromise<SearchResponse, RequestBody, SearchParams> =>
|
|
2742
|
+
Promise.resolve({
|
|
2743
|
+
data: { results: [] },
|
|
2744
|
+
status: 200,
|
|
2745
|
+
statusText: 'OK',
|
|
2746
|
+
headers: {},
|
|
2747
|
+
config: adapterConfig,
|
|
2748
|
+
});
|
|
2749
|
+
```
|
|
2750
|
+
|
|
2751
|
+
The request methods place `P` last—`<T, R, D, P>`—so the existing response data (`T`), custom response (`R`), and request data (`D`) positions do not change. Explicit custom response types still determine the resolved value. `RawAxiosRequestConfig`, `InternalAxiosRequestConfig`, defaults, `AxiosResponse`, `AxiosPromise<T, D, P>`, `AxiosError`, `CanceledError`, callable instances, adapters, and `mergeConfig()` also carry `P`. The default is `any` for backward compatibility.
|
|
2752
|
+
|
|
2753
|
+
Use all three public error generics when cancellation narrowing must retain the response, request body, and params types:
|
|
2754
|
+
|
|
2755
|
+
```typescript
|
|
2756
|
+
declare const error: unknown;
|
|
2757
|
+
|
|
2758
|
+
if (axios.isCancel<SearchResponse, RequestBody, SearchParams>(error)) {
|
|
2759
|
+
error.config?.data; // RequestBody | undefined
|
|
2760
|
+
error.config?.params; // SearchParams | undefined
|
|
2761
|
+
}
|
|
2762
|
+
```
|
|
2763
|
+
|
|
2764
|
+
### Symbol-keyed custom request config
|
|
2765
|
+
|
|
2766
|
+
Own enumerable symbol properties survive config merging, so module-augmented options can reach request interceptors and adapters:
|
|
2767
|
+
|
|
2768
|
+
```typescript
|
|
2769
|
+
import axios from 'axios';
|
|
2770
|
+
|
|
2771
|
+
export const someFlag: unique symbol = Symbol(
|
|
2772
|
+
'some flag used in request interceptor'
|
|
2773
|
+
);
|
|
2774
|
+
|
|
2775
|
+
declare module 'axios' {
|
|
2776
|
+
interface AxiosRequestConfig<D = any, P = any> {
|
|
2777
|
+
[someFlag]?: boolean;
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
axios.interceptors.request.use((config) => {
|
|
2782
|
+
if (config[someFlag]) {
|
|
2783
|
+
config.headers.set('X-Some-Flag', 'enabled');
|
|
2784
|
+
}
|
|
2785
|
+
return config;
|
|
2786
|
+
});
|
|
2787
|
+
|
|
2788
|
+
await axios.get('/users', { [someFlag]: true });
|
|
2789
|
+
```
|
|
2790
|
+
|
|
2791
|
+
Only own enumerable symbol properties are copied; inherited and non-enumerable symbol properties are not.
|
|
2792
|
+
|
|
2501
2793
|
Because axios publishes an ESM default export and a CJS `module.exports`, TypeScript has a few caveats.
|
|
2502
2794
|
The recommended setting is `"moduleResolution": "node16"`, which is implied by `"module": "node16"`. This requires TypeScript 4.7 or greater.
|
|
2503
2795
|
If you use ESM, your settings should be fine.
|