@zowe/db2-for-zowe-cli 6.1.17 → 6.1.19
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 +12 -10
- package/lib/Db2PluginLifeCycle.d.ts +11 -9
- package/lib/Db2PluginLifeCycle.js +18 -13
- package/lib/Db2PluginLifeCycle.js.map +1 -1
- package/node_modules/adm-zip/adm-zip.js +32 -6
- package/node_modules/adm-zip/headers/entryHeader.js +13 -1
- package/node_modules/adm-zip/methods/inflater.js +33 -3
- package/node_modules/adm-zip/package.json +2 -2
- package/node_modules/adm-zip/util/errors.js +3 -0
- package/node_modules/adm-zip/util/utils.js +102 -14
- package/node_modules/adm-zip/zipEntry.js +43 -18
- package/node_modules/adm-zip/zipFile.js +10 -0
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +236 -73
- package/node_modules/axios/dist/axios.js +1308 -357
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +1443 -403
- package/node_modules/axios/dist/esm/axios.js +1443 -403
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +1483 -348
- package/node_modules/axios/index.d.cts +24 -1
- package/node_modules/axios/index.d.ts +22 -1
- package/node_modules/axios/lib/adapters/fetch.js +136 -30
- package/node_modules/axios/lib/adapters/http.js +277 -74
- package/node_modules/axios/lib/adapters/xhr.js +172 -16
- package/node_modules/axios/lib/core/Axios.js +87 -27
- package/node_modules/axios/lib/core/AxiosError.js +59 -0
- package/node_modules/axios/lib/core/AxiosHeaders.js +17 -4
- package/node_modules/axios/lib/core/InterceptorManager.js +118 -8
- package/node_modules/axios/lib/core/assertParamsAcyclic.js +49 -0
- package/node_modules/axios/lib/core/buildFullPath.js +1 -13
- package/node_modules/axios/lib/core/createMultipartBody.js +37 -0
- package/node_modules/axios/lib/core/dispatchRequest.js +28 -2
- package/node_modules/axios/lib/core/mergeConfig.js +183 -120
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/defaults/transitional.js +1 -0
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/AxiosTransformStream.js +11 -2
- package/node_modules/axios/lib/helpers/Http2Sessions.js +4 -1
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
- package/node_modules/axios/lib/helpers/composeSignals.js +6 -3
- package/node_modules/axios/lib/helpers/cookies.js +30 -6
- package/node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js +34 -7
- package/node_modules/axios/lib/helpers/formDataToBlob.js +113 -0
- package/node_modules/axios/lib/helpers/formDataToJSON.js +25 -1
- package/node_modules/axios/lib/helpers/fromDataURI.js +11 -4
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +4 -9
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/parseHeaders.js +2 -1
- package/node_modules/axios/lib/helpers/parseProtocol.js +1 -1
- package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
- package/node_modules/axios/lib/helpers/resolveConfig.js +20 -5
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +197 -6
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +14 -21
- package/node_modules/axios/lib/utils.js +192 -20
- package/node_modules/axios/package.json +1 -2
- package/node_modules/follow-redirects/README.md +27 -1
- package/node_modules/follow-redirects/index.js +11 -6
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/fs-extra/README.md +0 -1
- package/node_modules/fs-extra/lib/empty/index.js +4 -2
- package/node_modules/fs-extra/lib/util/stat.js +12 -2
- package/node_modules/fs-extra/package.json +1 -1
- package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
- package/node_modules/ibm_db/LICENSE +23 -23
- package/node_modules/ibm_db/README.md +735 -735
- package/node_modules/ibm_db/binding.gyp +99 -98
- package/node_modules/ibm_db/installer/driverInstall.js +984 -958
- package/node_modules/ibm_db/installer/ifx.sh +38 -38
- package/node_modules/ibm_db/installer/setenv.sh +23 -23
- package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
- package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
- package/node_modules/ibm_db/lib/climacros.js +431 -431
- package/node_modules/ibm_db/lib/odbc.js +4293 -3487
- package/node_modules/ibm_db/lib/simple-queue.js +41 -41
- package/node_modules/ibm_db/package.json +70 -70
- package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
- package/node_modules/ibm_db/src/odbc.h +477 -473
- package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
- package/node_modules/ibm_db/src/odbc_connection.h +228 -215
- package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
- package/node_modules/ibm_db/src/odbc_result.h +152 -152
- package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
- package/node_modules/ibm_db/src/odbc_statement.h +257 -135
- package/node_modules/ibm_db/src/strptime.c +389 -389
- package/node_modules/ibm_db/src/strptime.h +46 -46
- package/node_modules/ibm_db/test/README +23 -23
- package/node_modules/ibm_db/test/bench-insert.js +62 -62
- package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
- package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
- package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
- package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
- package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
- package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
- package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
- package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
- package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
- package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
- package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
- package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
- package/node_modules/ibm_db/test/bench-query.js +40 -40
- package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
- package/node_modules/ibm_db/test/bench-querySync.js +29 -29
- package/node_modules/ibm_db/test/common.d.ts +10 -10
- package/node_modules/ibm_db/test/common.js +127 -127
- package/node_modules/ibm_db/test/config.json +7 -7
- package/node_modules/ibm_db/test/config.zos.json +4 -4
- package/node_modules/ibm_db/test/data/sample1.txt +9 -9
- package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
- package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
- package/node_modules/ibm_db/test/odbc-bench.c +123 -123
- package/node_modules/ibm_db/test/perfTest.js +53 -53
- package/node_modules/ibm_db/test/quick-example.sh +30 -30
- package/node_modules/ibm_db/test/quick-example.ts +80 -80
- package/node_modules/ibm_db/test/run-bench.js +96 -96
- package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
- package/node_modules/ibm_db/test/run-tests.js +132 -138
- package/node_modules/ibm_db/test/sql-cli.js +28 -28
- package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
- package/node_modules/ibm_db/test/test-array-insert.js +178 -178
- package/node_modules/ibm_db/test/test-async-await.js +105 -105
- package/node_modules/ibm_db/test/test-attributes.js +34 -34
- package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
- package/node_modules/ibm_db/test/test-basic-test.js +138 -138
- package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
- package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
- package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
- package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
- package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
- package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
- package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
- package/node_modules/ibm_db/test/test-call-async.js +64 -64
- package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
- package/node_modules/ibm_db/test/test-cancel.js +703 -0
- package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
- package/node_modules/ibm_db/test/test-connection.js +306 -0
- package/node_modules/ibm_db/test/test-date.js +32 -32
- package/node_modules/ibm_db/test/test-dbclob.js +93 -93
- package/node_modules/ibm_db/test/test-decimals.js +135 -135
- package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
- package/node_modules/ibm_db/test/test-executeFile.js +167 -167
- package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
- package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
- package/node_modules/ibm_db/test/test-fetchN.js +130 -130
- package/node_modules/ibm_db/test/test-getinfo.js +197 -197
- package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
- package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
- package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
- package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
- package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
- package/node_modules/ibm_db/test/test-issue-54.js +39 -39
- package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
- package/node_modules/ibm_db/test/test-issue211.js +80 -80
- package/node_modules/ibm_db/test/test-issue253.js +39 -39
- package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
- package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
- package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
- package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
- package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
- package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
- package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
- package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
- package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
- package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
- package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
- package/node_modules/ibm_db/test/test-procedures.js +243 -0
- package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
- package/node_modules/ibm_db/test/test-query-operations.js +405 -0
- package/node_modules/ibm_db/test/test-quick-example.js +25 -25
- package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
- package/node_modules/ibm_db/test/test-sp-array.js +54 -54
- package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
- package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
- package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
- package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
- package/node_modules/ibm_db/test/test-transactions.js +261 -0
- package/node_modules/ibm_db/test/test-typescript.js +48 -48
- package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
- package/node_modules/ibm_db/test/testWebApp.js +56 -56
- package/node_modules/ibm_db/test/trace +51 -51
- package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
- package/node_modules/ibm_db/test/webapp.html +17 -17
- package/node_modules/ibm_db/test/webapp.js +79 -79
- package/node_modules/ibm_db/typescript/README.md +28 -28
- package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
- package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/string_decoder/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/which-typed-array/CHANGELOG.md +14 -0
- package/node_modules/which-typed-array/README.md +0 -2
- package/node_modules/which-typed-array/index.d.ts +288 -11
- package/node_modules/which-typed-array/index.js +6 -7
- package/node_modules/which-typed-array/package.json +12 -11
- package/package.json +10 -11
- package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
- package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
- package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
- package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
- package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
- package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
- package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
- package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
- package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
- package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
- package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
- package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
- package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
- package/node_modules/ibm_db/test/test-closed.js +0 -14
- package/node_modules/ibm_db/test/test-connection-object.js +0 -16
- package/node_modules/ibm_db/test/test-describe-column.js +0 -92
- package/node_modules/ibm_db/test/test-describe-database.js +0 -18
- package/node_modules/ibm_db/test/test-describe-table.js +0 -31
- package/node_modules/ibm_db/test/test-domains-open.js +0 -19
- package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
- package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
- package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
- package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
- package/node_modules/ibm_db/test/test-open-close.js +0 -29
- package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
- package/node_modules/ibm_db/test/test-openSync.js +0 -31
- package/node_modules/ibm_db/test/test-pool-close.js +0 -120
- package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
- package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
- package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
- package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
- package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
- package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
- package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
- package/node_modules/ibm_db/test/test-query-insert.js +0 -38
- package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
- package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
- package/node_modules/ibm_db/test/test-query-select.js +0 -64
- package/node_modules/ibm_db/test/test-queryResult.js +0 -35
- package/node_modules/ibm_db/test/test-queryStream.js +0 -43
- package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
- package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
- package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
- package/node_modules/ibm_db/test/test-statement-close.js +0 -118
- package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
- package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
- package/node_modules/which-typed-array/eslint.config.mjs +0 -12
- package/node_modules/which-typed-array/test/index.js +0 -105
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/LICENSE +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/README.md +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/chownr.js +0 -0
- /package/node_modules/{tar-fs/node_modules/chownr → chownr}/package.json +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/.travis.yml +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/LICENSE +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/README.md +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/lib/string_decoder.js +0 -0
- /package/node_modules/{tar-stream/node_modules/string_decoder → string_decoder}/package.json +0 -0
|
@@ -2,9 +2,67 @@
|
|
|
2
2
|
|
|
3
3
|
import utils from '../utils.js';
|
|
4
4
|
|
|
5
|
+
const $internals = Symbol('internals');
|
|
6
|
+
|
|
7
|
+
// `handlers` is public and may be replaced with a nullish value by user code;
|
|
8
|
+
// `clear()` has always tolerated that. Treat it as an empty stack rather than
|
|
9
|
+
// dereferencing it.
|
|
10
|
+
function countHandlers(handlers) {
|
|
11
|
+
return handlers ? handlers.length : 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function trimHandlers(handlers) {
|
|
15
|
+
if (!handlers) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
while (handlers.length && handlers[handlers.length - 1] === null) {
|
|
20
|
+
handlers.pop();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Preserve the array-key coercion used before IDs were stored in a Map, without
|
|
25
|
+
// treating null, empty strings, or noncanonical numeric strings as ID zero.
|
|
26
|
+
function normalizeHandlerId(id) {
|
|
27
|
+
if (typeof id === 'string' && id !== '' && String(Number(id)) === id) {
|
|
28
|
+
return Number(id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return id;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function syncHandlerEntries(manager, internals) {
|
|
35
|
+
const handlers = manager.handlers;
|
|
36
|
+
const length = countHandlers(handlers);
|
|
37
|
+
|
|
38
|
+
if (handlers !== internals.handlersRef) {
|
|
39
|
+
internals.handlersRef = handlers;
|
|
40
|
+
internals.handlerEntries.clear();
|
|
41
|
+
} else if (length !== internals.handlersLength) {
|
|
42
|
+
if (!length) {
|
|
43
|
+
internals.handlerEntries.clear();
|
|
44
|
+
} else {
|
|
45
|
+
internals.handlerEntries.forEach(function removeStaleEntry(entry, id) {
|
|
46
|
+
if (handlers[entry.index] !== entry.handler) {
|
|
47
|
+
internals.handlerEntries.delete(id);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
internals.handlersLength = length;
|
|
54
|
+
}
|
|
55
|
+
|
|
5
56
|
class InterceptorManager {
|
|
6
57
|
constructor() {
|
|
7
58
|
this.handlers = [];
|
|
59
|
+
this[$internals] = {
|
|
60
|
+
handlersRef: this.handlers,
|
|
61
|
+
handlersLength: this.handlers.length,
|
|
62
|
+
handlerEntries: new Map(),
|
|
63
|
+
iterationDepth: 0,
|
|
64
|
+
nextId: 0,
|
|
65
|
+
};
|
|
8
66
|
}
|
|
9
67
|
|
|
10
68
|
/**
|
|
@@ -17,13 +75,30 @@ class InterceptorManager {
|
|
|
17
75
|
* @return {Number} An ID used to remove interceptor later
|
|
18
76
|
*/
|
|
19
77
|
use(fulfilled, rejected, options) {
|
|
20
|
-
|
|
78
|
+
const handler = {
|
|
21
79
|
fulfilled,
|
|
22
80
|
rejected,
|
|
23
81
|
synchronous: options ? options.synchronous : false,
|
|
24
82
|
runWhen: options ? options.runWhen : null,
|
|
83
|
+
};
|
|
84
|
+
const internals = this[$internals];
|
|
85
|
+
|
|
86
|
+
if (this.handlers == null) {
|
|
87
|
+
this.handlers = [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
syncHandlerEntries(this, internals);
|
|
91
|
+
|
|
92
|
+
const id = internals.nextId++;
|
|
93
|
+
|
|
94
|
+
this.handlers.push(handler);
|
|
95
|
+
internals.handlerEntries.set(id, {
|
|
96
|
+
handler,
|
|
97
|
+
index: this.handlers.length - 1,
|
|
25
98
|
});
|
|
26
|
-
|
|
99
|
+
internals.handlersLength = this.handlers.length;
|
|
100
|
+
|
|
101
|
+
return id;
|
|
27
102
|
}
|
|
28
103
|
|
|
29
104
|
/**
|
|
@@ -34,8 +109,28 @@ class InterceptorManager {
|
|
|
34
109
|
* @returns {void}
|
|
35
110
|
*/
|
|
36
111
|
eject(id) {
|
|
37
|
-
|
|
38
|
-
|
|
112
|
+
const internals = this[$internals];
|
|
113
|
+
|
|
114
|
+
syncHandlerEntries(this, internals);
|
|
115
|
+
|
|
116
|
+
const handlerId = normalizeHandlerId(id);
|
|
117
|
+
const entry = internals.handlerEntries.get(handlerId);
|
|
118
|
+
|
|
119
|
+
if (entry) {
|
|
120
|
+
internals.handlerEntries.delete(handlerId);
|
|
121
|
+
|
|
122
|
+
// Ignore IDs invalidated by clear or direct replacement of handlers.
|
|
123
|
+
if (this.handlers[entry.index] !== entry.handler) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
this.handlers[entry.index] = null;
|
|
128
|
+
|
|
129
|
+
// Do not reuse an index while forEach is walking its length snapshot.
|
|
130
|
+
if (!internals.iterationDepth) {
|
|
131
|
+
trimHandlers(this.handlers);
|
|
132
|
+
internals.handlersLength = this.handlers.length;
|
|
133
|
+
}
|
|
39
134
|
}
|
|
40
135
|
}
|
|
41
136
|
|
|
@@ -47,6 +142,7 @@ class InterceptorManager {
|
|
|
47
142
|
clear() {
|
|
48
143
|
if (this.handlers) {
|
|
49
144
|
this.handlers = [];
|
|
145
|
+
syncHandlerEntries(this, this[$internals]);
|
|
50
146
|
}
|
|
51
147
|
}
|
|
52
148
|
|
|
@@ -61,11 +157,25 @@ class InterceptorManager {
|
|
|
61
157
|
* @returns {void}
|
|
62
158
|
*/
|
|
63
159
|
forEach(fn) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
160
|
+
const internals = this[$internals];
|
|
161
|
+
|
|
162
|
+
syncHandlerEntries(this, internals);
|
|
163
|
+
|
|
164
|
+
internals.iterationDepth++;
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
utils.forEach(this.handlers, function forEachHandler(h) {
|
|
168
|
+
if (h !== null) {
|
|
169
|
+
fn(h);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
} finally {
|
|
173
|
+
if (!--internals.iterationDepth) {
|
|
174
|
+
syncHandlerEntries(this, internals);
|
|
175
|
+
trimHandlers(this.handlers);
|
|
176
|
+
internals.handlersLength = countHandlers(this.handlers);
|
|
67
177
|
}
|
|
68
|
-
}
|
|
178
|
+
}
|
|
69
179
|
}
|
|
70
180
|
}
|
|
71
181
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import utils from '../utils.js';
|
|
4
|
+
import AxiosError from './AxiosError.js';
|
|
5
|
+
|
|
6
|
+
export default function assertParamsAcyclic(params) {
|
|
7
|
+
const pending = [{ value: params }];
|
|
8
|
+
const active = new WeakSet();
|
|
9
|
+
const visited = new WeakSet();
|
|
10
|
+
|
|
11
|
+
while (pending.length) {
|
|
12
|
+
const { value, done } = pending.pop();
|
|
13
|
+
if (!utils.isPlainObject(value) && !utils.isArray(value)) continue;
|
|
14
|
+
if (done) {
|
|
15
|
+
active.delete(value);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (active.has(value)) {
|
|
19
|
+
throw new AxiosError(
|
|
20
|
+
'Circular reference detected in params',
|
|
21
|
+
AxiosError.ERR_BAD_OPTION_VALUE
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (visited.has(value)) continue;
|
|
25
|
+
visited.add(value);
|
|
26
|
+
active.add(value);
|
|
27
|
+
pending.push({ value, done: true });
|
|
28
|
+
|
|
29
|
+
const keys = Object.keys(value);
|
|
30
|
+
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
31
|
+
Object.getOwnPropertySymbols(value).forEach((key) => {
|
|
32
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
33
|
+
if (descriptor && descriptor.enumerable) keys.push(key);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Shallow array elements retain fields filtered during plain-object merges.
|
|
37
|
+
// Inspect reserved data properties without evaluating their accessors.
|
|
38
|
+
keys.forEach((key) => {
|
|
39
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
40
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
41
|
+
if (descriptor && utils.hasOwnProp(descriptor, 'value')) {
|
|
42
|
+
pending.push({ value: descriptor.value });
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
pending.push({ value: value[key] });
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -3,21 +3,9 @@
|
|
|
3
3
|
import AxiosError, { REDACTED } from './AxiosError.js';
|
|
4
4
|
import isAbsoluteURL from '../helpers/isAbsoluteURL.js';
|
|
5
5
|
import combineURLs from '../helpers/combineURLs.js';
|
|
6
|
+
import normalizeURLForProtocolCheck from '../helpers/normalizeURLForProtocolCheck.js';
|
|
6
7
|
|
|
7
8
|
const malformedHttpProtocol = /^https?:(?!\/\/)/i;
|
|
8
|
-
const httpProtocolControlCharacters = /[\t\n\r]/g;
|
|
9
|
-
|
|
10
|
-
function stripLeadingC0ControlOrSpace(url) {
|
|
11
|
-
let i = 0;
|
|
12
|
-
while (i < url.length && url.charCodeAt(i) <= 0x20) {
|
|
13
|
-
i++;
|
|
14
|
-
}
|
|
15
|
-
return url.slice(i);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function normalizeURLForProtocolCheck(url) {
|
|
19
|
-
return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, '');
|
|
20
|
-
}
|
|
21
9
|
|
|
22
10
|
// Redact the parts of a URL that can carry secrets before it is embedded in an
|
|
23
11
|
// error message. AxiosError.toJSON() serializes `message` verbatim and errors
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import utils from '../utils.js';
|
|
2
|
+
import platform from '../platform/index.js';
|
|
3
|
+
import AxiosError from './AxiosError.js';
|
|
4
|
+
import formDataToBlob, { FormDataError } from '../helpers/formDataToBlob.js';
|
|
5
|
+
|
|
6
|
+
export default function createMultipartBody(form, Blob, limit, limitError, boundary) {
|
|
7
|
+
// Report missing Blob support before trying to select a random source.
|
|
8
|
+
if (!utils.isFunction(Blob)) {
|
|
9
|
+
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (boundary === undefined) {
|
|
13
|
+
if (utils.isFunction(platform.generateString)) {
|
|
14
|
+
boundary = 'axios-' + platform.generateString(36, '0123456789abcdef');
|
|
15
|
+
} else {
|
|
16
|
+
const crypto = utils.global.crypto;
|
|
17
|
+
if (!crypto || !utils.isFunction(crypto.getRandomValues)) {
|
|
18
|
+
throw new AxiosError('Random byte generation is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
19
|
+
}
|
|
20
|
+
const random = new Uint8Array(18);
|
|
21
|
+
crypto.getRandomValues(random);
|
|
22
|
+
boundary =
|
|
23
|
+
'axios-' + Array.from(random, (value) => ('0' + value.toString(16)).slice(-2)).join('');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
return formDataToBlob(form, Blob, limit, limitError, boundary);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error instanceof FormDataError) {
|
|
31
|
+
const code =
|
|
32
|
+
error.reason === 'boundary' ? AxiosError.ERR_BAD_OPTION_VALUE : AxiosError.ERR_BAD_REQUEST;
|
|
33
|
+
throw new AxiosError(error.message, code);
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -6,6 +6,7 @@ import defaults from '../defaults/index.js';
|
|
|
6
6
|
import CanceledError from '../cancel/CanceledError.js';
|
|
7
7
|
import AxiosHeaders from '../core/AxiosHeaders.js';
|
|
8
8
|
import adapters from '../adapters/adapters.js';
|
|
9
|
+
import utils from '../utils.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Throws a `CanceledError` if cancellation has been requested.
|
|
@@ -24,6 +25,21 @@ function throwIfCancellationRequested(config) {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Milliseconds elapsed since `start`, floored at zero.
|
|
30
|
+
*
|
|
31
|
+
* Wall-clock, to match the rest of the codebase (speedometer, throttle,
|
|
32
|
+
* AxiosTransformStream). A backwards clock adjustment mid-request would
|
|
33
|
+
* otherwise produce a negative duration, so the result is clamped.
|
|
34
|
+
*
|
|
35
|
+
* @param {number} start Timestamp from `Date.now()`
|
|
36
|
+
*
|
|
37
|
+
* @returns {number} Non-negative elapsed milliseconds
|
|
38
|
+
*/
|
|
39
|
+
function elapsedSince(start) {
|
|
40
|
+
return Math.max(0, Date.now() - start);
|
|
41
|
+
}
|
|
42
|
+
|
|
27
43
|
/**
|
|
28
44
|
* Dispatch a request to the server using the configured adapter.
|
|
29
45
|
*
|
|
@@ -31,10 +47,15 @@ function throwIfCancellationRequested(config) {
|
|
|
31
47
|
*
|
|
32
48
|
* @returns {Promise} The Promise to be fulfilled
|
|
33
49
|
*/
|
|
34
|
-
export default function dispatchRequest(
|
|
50
|
+
export default function dispatchRequest(_config) {
|
|
51
|
+
// Interceptors may replace the merged config with an ordinary object. Flatten
|
|
52
|
+
// it at the dispatch boundary so shared prototype members cannot become
|
|
53
|
+
// request behavior, while preserving intentional template/class members.
|
|
54
|
+
const config = utils.toSafeFlatObject(_config);
|
|
55
|
+
|
|
35
56
|
throwIfCancellationRequested(config);
|
|
36
57
|
|
|
37
|
-
config.headers = AxiosHeaders.from(config
|
|
58
|
+
config.headers = AxiosHeaders.from(utils.getSafeProp(config, 'headers'));
|
|
38
59
|
|
|
39
60
|
// Transform request data
|
|
40
61
|
config.data = transformData.call(config, config.transformRequest);
|
|
@@ -45,10 +66,14 @@ export default function dispatchRequest(config) {
|
|
|
45
66
|
|
|
46
67
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
|
|
47
68
|
|
|
69
|
+
const start = Date.now();
|
|
70
|
+
|
|
48
71
|
return adapter(config).then(
|
|
49
72
|
function onAdapterResolution(response) {
|
|
50
73
|
throwIfCancellationRequested(config);
|
|
51
74
|
|
|
75
|
+
response.duration = elapsedSince(start);
|
|
76
|
+
|
|
52
77
|
// Expose the current response on config so that transformResponse can
|
|
53
78
|
// attach it to any AxiosError it throws (e.g. on JSON parse failure).
|
|
54
79
|
// We clean it up afterwards to avoid polluting the config object.
|
|
@@ -69,6 +94,7 @@ export default function dispatchRequest(config) {
|
|
|
69
94
|
|
|
70
95
|
// Transform response data
|
|
71
96
|
if (reason && reason.response) {
|
|
97
|
+
reason.response.duration = elapsedSince(start);
|
|
72
98
|
config.response = reason.response;
|
|
73
99
|
try {
|
|
74
100
|
reason.response.data = transformData.call(
|
|
@@ -2,20 +2,191 @@
|
|
|
2
2
|
|
|
3
3
|
import utils from '../utils.js';
|
|
4
4
|
import AxiosHeaders from './AxiosHeaders.js';
|
|
5
|
+
import assertParamsAcyclic from './assertParamsAcyclic.js';
|
|
5
6
|
|
|
6
7
|
const headersToObject = (thing) => (thing instanceof AxiosHeaders ? { ...thing } : thing);
|
|
7
8
|
|
|
8
9
|
const ownEnumerableKeys = (thing) => {
|
|
9
10
|
if (Object.getOwnPropertySymbols && Object.getOwnPropertyDescriptor) {
|
|
10
11
|
return Object.keys(thing).concat(
|
|
11
|
-
Object.getOwnPropertySymbols(thing).filter(
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Object.getOwnPropertySymbols(thing).filter((symbol) => {
|
|
13
|
+
const descriptor = Object.getOwnPropertyDescriptor(thing, symbol);
|
|
14
|
+
return descriptor && descriptor.enumerable;
|
|
15
|
+
})
|
|
14
16
|
);
|
|
15
17
|
}
|
|
16
18
|
return Object.keys(thing);
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
// Copy params without recursive merges so the serializer remains responsible
|
|
22
|
+
// for its depth policy. Only visit defaults that contribute to the result.
|
|
23
|
+
function mergeParams(a, b) {
|
|
24
|
+
const pending = [];
|
|
25
|
+
const copies = new WeakMap();
|
|
26
|
+
const empty = {};
|
|
27
|
+
|
|
28
|
+
function copy(target, source) {
|
|
29
|
+
if (!utils.isPlainObject(source)) {
|
|
30
|
+
return utils.isArray(source) ? source.slice() : source;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const base = utils.isPlainObject(target) ? target : empty;
|
|
34
|
+
let bases = copies.get(source);
|
|
35
|
+
if (!bases) {
|
|
36
|
+
bases = new WeakMap();
|
|
37
|
+
copies.set(source, bases);
|
|
38
|
+
}
|
|
39
|
+
if (bases.has(base)) return bases.get(base);
|
|
40
|
+
|
|
41
|
+
const result = {};
|
|
42
|
+
bases.set(base, result);
|
|
43
|
+
pending.push({ base, source, result });
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const result = utils.isUndefined(b) ? copy(undefined, a) : copy(a, b);
|
|
48
|
+
while (pending.length) {
|
|
49
|
+
const { base, source, result: target } = pending.pop();
|
|
50
|
+
const baseKeys = new Set(ownEnumerableKeys(base));
|
|
51
|
+
const sourceKeys = new Set(ownEnumerableKeys(source));
|
|
52
|
+
const keys = new Set([...baseKeys, ...sourceKeys]);
|
|
53
|
+
|
|
54
|
+
keys.forEach((key) => {
|
|
55
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') return;
|
|
56
|
+
const hasSource = sourceKeys.has(key);
|
|
57
|
+
const value = hasSource ? source[key] : undefined;
|
|
58
|
+
const previous =
|
|
59
|
+
(!hasSource || utils.isPlainObject(value)) && baseKeys.has(key) ? base[key] : undefined;
|
|
60
|
+
target[key] = hasSource ? copy(previous, value) : copy(undefined, previous);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
assertParamsAcyclic(result);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getMergedValue(target, source, prop, caseless) {
|
|
69
|
+
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
70
|
+
return utils.merge.call({ caseless }, target, source);
|
|
71
|
+
} else if (utils.isPlainObject(source)) {
|
|
72
|
+
return utils.merge({}, source);
|
|
73
|
+
} else if (utils.isArray(source)) {
|
|
74
|
+
return source.slice();
|
|
75
|
+
}
|
|
76
|
+
return source;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function mergeDeepProperties(a, b, prop, caseless) {
|
|
80
|
+
if (!utils.isUndefined(b)) {
|
|
81
|
+
return getMergedValue(a, b, prop, caseless);
|
|
82
|
+
} else if (!utils.isUndefined(a)) {
|
|
83
|
+
return getMergedValue(undefined, a, prop, caseless);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// eslint-disable-next-line consistent-return
|
|
88
|
+
function valueFromConfig2(a, b) {
|
|
89
|
+
if (!utils.isUndefined(b)) {
|
|
90
|
+
return getMergedValue(undefined, b);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// eslint-disable-next-line consistent-return
|
|
95
|
+
function defaultToConfig2(a, b) {
|
|
96
|
+
if (!utils.isUndefined(b)) {
|
|
97
|
+
return getMergedValue(undefined, b);
|
|
98
|
+
} else if (!utils.isUndefined(a)) {
|
|
99
|
+
return getMergedValue(undefined, a);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getMergedTransitionalOption(config1, config2, prop) {
|
|
104
|
+
const transitional2 = utils.hasOwnProp(config2, 'transitional')
|
|
105
|
+
? config2.transitional
|
|
106
|
+
: undefined;
|
|
107
|
+
|
|
108
|
+
if (!utils.isUndefined(transitional2)) {
|
|
109
|
+
if (utils.isPlainObject(transitional2)) {
|
|
110
|
+
if (utils.hasOwnProp(transitional2, prop)) {
|
|
111
|
+
return transitional2[prop];
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const transitional1 = utils.hasOwnProp(config1, 'transitional')
|
|
119
|
+
? config1.transitional
|
|
120
|
+
: undefined;
|
|
121
|
+
|
|
122
|
+
if (utils.isPlainObject(transitional1) && utils.hasOwnProp(transitional1, prop)) {
|
|
123
|
+
return transitional1[prop];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// eslint-disable-next-line consistent-return
|
|
130
|
+
function mergeDirectKeys(a, b, prop, config1, config2) {
|
|
131
|
+
if (utils.hasOwnProp(config2, prop)) {
|
|
132
|
+
return getMergedValue(a, b);
|
|
133
|
+
} else if (utils.hasOwnProp(config1, prop)) {
|
|
134
|
+
return getMergedValue(undefined, a);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function mergeHeaders(a, b, prop) {
|
|
139
|
+
return mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Null-proto, frozen descriptor so a polluted Object.prototype.get cannot turn
|
|
143
|
+
// this data descriptor into an accessor descriptor on the way in.
|
|
144
|
+
// defineProperty only reads it, so one shared instance serves every call.
|
|
145
|
+
const hasOwnPropertyDescriptor = Object.freeze({
|
|
146
|
+
__proto__: null,
|
|
147
|
+
value: Object.prototype.hasOwnProperty,
|
|
148
|
+
enumerable: false,
|
|
149
|
+
writable: true,
|
|
150
|
+
configurable: true,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// The strategy table and the strategies above are stateless, so they are
|
|
154
|
+
// built once at module load instead of on every call: mergeConfig runs at
|
|
155
|
+
// most twice per request (once from a method alias, once from `_request`).
|
|
156
|
+
const mergeMap = {
|
|
157
|
+
url: valueFromConfig2,
|
|
158
|
+
method: valueFromConfig2,
|
|
159
|
+
data: valueFromConfig2,
|
|
160
|
+
baseURL: defaultToConfig2,
|
|
161
|
+
transformRequest: defaultToConfig2,
|
|
162
|
+
transformResponse: defaultToConfig2,
|
|
163
|
+
params: mergeParams,
|
|
164
|
+
paramsSerializer: defaultToConfig2,
|
|
165
|
+
timeout: defaultToConfig2,
|
|
166
|
+
timeoutErrorMessage: defaultToConfig2,
|
|
167
|
+
withCredentials: defaultToConfig2,
|
|
168
|
+
withXSRFToken: defaultToConfig2,
|
|
169
|
+
adapter: defaultToConfig2,
|
|
170
|
+
responseType: defaultToConfig2,
|
|
171
|
+
xsrfCookieName: defaultToConfig2,
|
|
172
|
+
xsrfHeaderName: defaultToConfig2,
|
|
173
|
+
onUploadProgress: defaultToConfig2,
|
|
174
|
+
onDownloadProgress: defaultToConfig2,
|
|
175
|
+
decompress: defaultToConfig2,
|
|
176
|
+
maxContentLength: defaultToConfig2,
|
|
177
|
+
maxBodyLength: defaultToConfig2,
|
|
178
|
+
beforeRedirect: defaultToConfig2,
|
|
179
|
+
transport: defaultToConfig2,
|
|
180
|
+
httpAgent: defaultToConfig2,
|
|
181
|
+
httpsAgent: defaultToConfig2,
|
|
182
|
+
cancelToken: defaultToConfig2,
|
|
183
|
+
socketPath: defaultToConfig2,
|
|
184
|
+
allowedSocketPaths: defaultToConfig2,
|
|
185
|
+
responseEncoding: defaultToConfig2,
|
|
186
|
+
validateStatus: mergeDirectKeys,
|
|
187
|
+
headers: mergeHeaders,
|
|
188
|
+
};
|
|
189
|
+
|
|
19
190
|
/**
|
|
20
191
|
* Config-specific merge-function which creates a new config-object
|
|
21
192
|
* by merging two configuration objects together.
|
|
@@ -35,133 +206,25 @@ export default function mergeConfig(config1, config2) {
|
|
|
35
206
|
// `hasOwnProperty` is restored as a non-enumerable own slot to preserve
|
|
36
207
|
// ergonomics for user code that relies on it.
|
|
37
208
|
const config = Object.create(null);
|
|
38
|
-
Object.defineProperty(config, 'hasOwnProperty',
|
|
39
|
-
// Null-proto descriptor so a polluted Object.prototype.get cannot turn
|
|
40
|
-
// this data descriptor into an accessor descriptor on the way in.
|
|
41
|
-
__proto__: null,
|
|
42
|
-
value: Object.prototype.hasOwnProperty,
|
|
43
|
-
enumerable: false,
|
|
44
|
-
writable: true,
|
|
45
|
-
configurable: true,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
function getMergedValue(target, source, prop, caseless) {
|
|
49
|
-
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
50
|
-
return utils.merge.call({ caseless }, target, source);
|
|
51
|
-
} else if (utils.isPlainObject(source)) {
|
|
52
|
-
return utils.merge({}, source);
|
|
53
|
-
} else if (utils.isArray(source)) {
|
|
54
|
-
return source.slice();
|
|
55
|
-
}
|
|
56
|
-
return source;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function mergeDeepProperties(a, b, prop, caseless) {
|
|
60
|
-
if (!utils.isUndefined(b)) {
|
|
61
|
-
return getMergedValue(a, b, prop, caseless);
|
|
62
|
-
} else if (!utils.isUndefined(a)) {
|
|
63
|
-
return getMergedValue(undefined, a, prop, caseless);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
209
|
+
Object.defineProperty(config, 'hasOwnProperty', hasOwnPropertyDescriptor);
|
|
66
210
|
|
|
67
|
-
|
|
68
|
-
function valueFromConfig2(a, b) {
|
|
69
|
-
if (!utils.isUndefined(b)) {
|
|
70
|
-
return getMergedValue(undefined, b);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
211
|
+
const keys = ownEnumerableKeys({ ...config1, ...config2 });
|
|
73
212
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
return getMergedValue(undefined, b);
|
|
78
|
-
} else if (!utils.isUndefined(a)) {
|
|
79
|
-
return getMergedValue(undefined, a);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function getMergedTransitionalOption(prop) {
|
|
84
|
-
const transitional2 = utils.hasOwnProp(config2, 'transitional')
|
|
85
|
-
? config2.transitional
|
|
86
|
-
: undefined;
|
|
87
|
-
|
|
88
|
-
if (!utils.isUndefined(transitional2)) {
|
|
89
|
-
if (utils.isPlainObject(transitional2)) {
|
|
90
|
-
if (utils.hasOwnProp(transitional2, prop)) {
|
|
91
|
-
return transitional2[prop];
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const transitional1 = utils.hasOwnProp(config1, 'transitional')
|
|
99
|
-
? config1.transitional
|
|
100
|
-
: undefined;
|
|
101
|
-
|
|
102
|
-
if (utils.isPlainObject(transitional1) && utils.hasOwnProp(transitional1, prop)) {
|
|
103
|
-
return transitional1[prop];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return undefined;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// eslint-disable-next-line consistent-return
|
|
110
|
-
function mergeDirectKeys(a, b, prop) {
|
|
111
|
-
if (utils.hasOwnProp(config2, prop)) {
|
|
112
|
-
return getMergedValue(a, b);
|
|
113
|
-
} else if (utils.hasOwnProp(config1, prop)) {
|
|
114
|
-
return getMergedValue(undefined, a);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const mergeMap = {
|
|
119
|
-
url: valueFromConfig2,
|
|
120
|
-
method: valueFromConfig2,
|
|
121
|
-
data: valueFromConfig2,
|
|
122
|
-
baseURL: defaultToConfig2,
|
|
123
|
-
transformRequest: defaultToConfig2,
|
|
124
|
-
transformResponse: defaultToConfig2,
|
|
125
|
-
paramsSerializer: defaultToConfig2,
|
|
126
|
-
timeout: defaultToConfig2,
|
|
127
|
-
timeoutMessage: defaultToConfig2,
|
|
128
|
-
withCredentials: defaultToConfig2,
|
|
129
|
-
withXSRFToken: defaultToConfig2,
|
|
130
|
-
adapter: defaultToConfig2,
|
|
131
|
-
responseType: defaultToConfig2,
|
|
132
|
-
xsrfCookieName: defaultToConfig2,
|
|
133
|
-
xsrfHeaderName: defaultToConfig2,
|
|
134
|
-
onUploadProgress: defaultToConfig2,
|
|
135
|
-
onDownloadProgress: defaultToConfig2,
|
|
136
|
-
decompress: defaultToConfig2,
|
|
137
|
-
maxContentLength: defaultToConfig2,
|
|
138
|
-
maxBodyLength: defaultToConfig2,
|
|
139
|
-
beforeRedirect: defaultToConfig2,
|
|
140
|
-
transport: defaultToConfig2,
|
|
141
|
-
httpAgent: defaultToConfig2,
|
|
142
|
-
httpsAgent: defaultToConfig2,
|
|
143
|
-
cancelToken: defaultToConfig2,
|
|
144
|
-
socketPath: defaultToConfig2,
|
|
145
|
-
allowedSocketPaths: defaultToConfig2,
|
|
146
|
-
responseEncoding: defaultToConfig2,
|
|
147
|
-
validateStatus: mergeDirectKeys,
|
|
148
|
-
headers: (a, b, prop) =>
|
|
149
|
-
mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true),
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
utils.forEach(ownEnumerableKeys({ ...config1, ...config2 }), function computeConfigValue(prop) {
|
|
153
|
-
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
|
|
213
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
214
|
+
const prop = keys[i];
|
|
215
|
+
if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') continue;
|
|
154
216
|
const merge = utils.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
|
|
155
217
|
const a = utils.hasOwnProp(config1, prop) ? config1[prop] : undefined;
|
|
156
218
|
const b = utils.hasOwnProp(config2, prop) ? config2[prop] : undefined;
|
|
157
|
-
const configValue =
|
|
219
|
+
const configValue =
|
|
220
|
+
merge === mergeDirectKeys ? merge(a, b, prop, config1, config2) : merge(a, b, prop);
|
|
158
221
|
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
159
|
-
}
|
|
222
|
+
}
|
|
160
223
|
|
|
161
224
|
if (
|
|
162
225
|
utils.hasOwnProp(config2, 'validateStatus') &&
|
|
163
226
|
utils.isUndefined(config2.validateStatus) &&
|
|
164
|
-
getMergedTransitionalOption('validateStatusUndefinedResolves') === false
|
|
227
|
+
getMergedTransitionalOption(config1, config2, 'validateStatusUndefinedResolves') === false
|
|
165
228
|
) {
|
|
166
229
|
if (utils.hasOwnProp(config1, 'validateStatus')) {
|
|
167
230
|
config.validateStatus = getMergedValue(undefined, config1.validateStatus);
|