monitor-transfer-dsh 0.0.0-stage → 0.1.2
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/CHANGELOG.md +25 -0
- package/README.md +51 -2
- package/cordis.patch.yml +4 -0
- package/lib/client.js +381 -0
- package/lib/index.js +267 -0
- package/package.json +67 -3
- package/skill/SKILL.md +48 -0
- package/skill/tools/node_modules/.package-lock.json +163 -0
- package/skill/tools/node_modules/pg/LICENSE +21 -0
- package/skill/tools/node_modules/pg/README.md +96 -0
- package/skill/tools/node_modules/pg/esm/index.mjs +20 -0
- package/skill/tools/node_modules/pg/lib/client.js +846 -0
- package/skill/tools/node_modules/pg/lib/connection-parameters.js +184 -0
- package/skill/tools/node_modules/pg/lib/connection.js +250 -0
- package/skill/tools/node_modules/pg/lib/crypto/cert-signatures.js +122 -0
- package/skill/tools/node_modules/pg/lib/crypto/sasl.js +262 -0
- package/skill/tools/node_modules/pg/lib/crypto/utils.js +89 -0
- package/skill/tools/node_modules/pg/lib/defaults.js +94 -0
- package/skill/tools/node_modules/pg/lib/index.js +73 -0
- package/skill/tools/node_modules/pg/lib/native/client.js +428 -0
- package/skill/tools/node_modules/pg/lib/native/index.js +2 -0
- package/skill/tools/node_modules/pg/lib/native/query.js +167 -0
- package/skill/tools/node_modules/pg/lib/query.js +263 -0
- package/skill/tools/node_modules/pg/lib/result.js +109 -0
- package/skill/tools/node_modules/pg/lib/stream.js +83 -0
- package/skill/tools/node_modules/pg/lib/type-overrides.js +35 -0
- package/skill/tools/node_modules/pg/lib/utils.js +225 -0
- package/skill/tools/node_modules/pg/package.json +76 -0
- package/skill/tools/node_modules/pg-cloudflare/LICENSE +21 -0
- package/skill/tools/node_modules/pg-cloudflare/README.md +112 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/empty.d.ts +2 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/empty.js +6 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/empty.js.map +1 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/index.d.ts +29 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/index.js +171 -0
- package/skill/tools/node_modules/pg-cloudflare/dist/index.js.map +1 -0
- package/skill/tools/node_modules/pg-cloudflare/esm/index.mjs +3 -0
- package/skill/tools/node_modules/pg-cloudflare/package.json +39 -0
- package/skill/tools/node_modules/pg-cloudflare/src/empty.ts +3 -0
- package/skill/tools/node_modules/pg-cloudflare/src/index.ts +187 -0
- package/skill/tools/node_modules/pg-cloudflare/src/types.d.ts +25 -0
- package/skill/tools/node_modules/pg-connection-string/LICENSE +21 -0
- package/skill/tools/node_modules/pg-connection-string/README.md +105 -0
- package/skill/tools/node_modules/pg-connection-string/esm/index.mjs +8 -0
- package/skill/tools/node_modules/pg-connection-string/index.d.ts +37 -0
- package/skill/tools/node_modules/pg-connection-string/index.js +237 -0
- package/skill/tools/node_modules/pg-connection-string/package.json +51 -0
- package/skill/tools/node_modules/pg-int8/LICENSE +13 -0
- package/skill/tools/node_modules/pg-int8/README.md +16 -0
- package/skill/tools/node_modules/pg-int8/index.js +100 -0
- package/skill/tools/node_modules/pg-int8/package.json +24 -0
- package/skill/tools/node_modules/pg-pool/LICENSE +21 -0
- package/skill/tools/node_modules/pg-pool/README.md +357 -0
- package/skill/tools/node_modules/pg-pool/esm/index.mjs +5 -0
- package/skill/tools/node_modules/pg-pool/index.js +517 -0
- package/skill/tools/node_modules/pg-pool/package.json +51 -0
- package/skill/tools/node_modules/pg-protocol/LICENSE +21 -0
- package/skill/tools/node_modules/pg-protocol/README.md +3 -0
- package/skill/tools/node_modules/pg-protocol/dist/b.d.ts +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/b.js +23 -0
- package/skill/tools/node_modules/pg-protocol/dist/b.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.d.ts +14 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js +55 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.d.ts +21 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js +113 -0
- package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.d.ts +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js +538 -0
- package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/index.d.ts +5 -0
- package/skill/tools/node_modules/pg-protocol/dist/index.js +15 -0
- package/skill/tools/node_modules/pg-protocol/dist/index.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/messages.d.ts +161 -0
- package/skill/tools/node_modules/pg-protocol/dist/messages.js +160 -0
- package/skill/tools/node_modules/pg-protocol/dist/messages.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.d.ts +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js +325 -0
- package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/parser.d.ts +22 -0
- package/skill/tools/node_modules/pg-protocol/dist/parser.js +325 -0
- package/skill/tools/node_modules/pg-protocol/dist/parser.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/dist/serializer.d.ts +42 -0
- package/skill/tools/node_modules/pg-protocol/dist/serializer.js +198 -0
- package/skill/tools/node_modules/pg-protocol/dist/serializer.js.map +1 -0
- package/skill/tools/node_modules/pg-protocol/esm/index.js +11 -0
- package/skill/tools/node_modules/pg-protocol/package.json +44 -0
- package/skill/tools/node_modules/pg-protocol/src/b.ts +25 -0
- package/skill/tools/node_modules/pg-protocol/src/buffer-reader.ts +58 -0
- package/skill/tools/node_modules/pg-protocol/src/buffer-writer.ts +120 -0
- package/skill/tools/node_modules/pg-protocol/src/inbound-parser.test.ts +585 -0
- package/skill/tools/node_modules/pg-protocol/src/index.ts +11 -0
- package/skill/tools/node_modules/pg-protocol/src/messages.ts +262 -0
- package/skill/tools/node_modules/pg-protocol/src/outbound-serializer.test.ts +356 -0
- package/skill/tools/node_modules/pg-protocol/src/parser.ts +414 -0
- package/skill/tools/node_modules/pg-protocol/src/serializer.ts +286 -0
- package/skill/tools/node_modules/pg-protocol/src/testing/buffer-list.ts +67 -0
- package/skill/tools/node_modules/pg-protocol/src/testing/test-buffers.ts +166 -0
- package/skill/tools/node_modules/pg-types/.travis.yml +7 -0
- package/skill/tools/node_modules/pg-types/Makefile +14 -0
- package/skill/tools/node_modules/pg-types/README.md +75 -0
- package/skill/tools/node_modules/pg-types/index.d.ts +137 -0
- package/skill/tools/node_modules/pg-types/index.js +47 -0
- package/skill/tools/node_modules/pg-types/index.test-d.ts +21 -0
- package/skill/tools/node_modules/pg-types/lib/arrayParser.js +11 -0
- package/skill/tools/node_modules/pg-types/lib/binaryParsers.js +257 -0
- package/skill/tools/node_modules/pg-types/lib/builtins.js +73 -0
- package/skill/tools/node_modules/pg-types/lib/textParsers.js +215 -0
- package/skill/tools/node_modules/pg-types/package.json +42 -0
- package/skill/tools/node_modules/pg-types/test/index.js +24 -0
- package/skill/tools/node_modules/pg-types/test/types.js +597 -0
- package/skill/tools/node_modules/pgpass/README.md +74 -0
- package/skill/tools/node_modules/pgpass/lib/helper.js +233 -0
- package/skill/tools/node_modules/pgpass/lib/index.js +23 -0
- package/skill/tools/node_modules/pgpass/package.json +41 -0
- package/skill/tools/node_modules/postgres-array/index.d.ts +4 -0
- package/skill/tools/node_modules/postgres-array/index.js +97 -0
- package/skill/tools/node_modules/postgres-array/license +21 -0
- package/skill/tools/node_modules/postgres-array/package.json +35 -0
- package/skill/tools/node_modules/postgres-array/readme.md +43 -0
- package/skill/tools/node_modules/postgres-bytea/index.js +33 -0
- package/skill/tools/node_modules/postgres-bytea/license +21 -0
- package/skill/tools/node_modules/postgres-bytea/package.json +34 -0
- package/skill/tools/node_modules/postgres-bytea/readme.md +34 -0
- package/skill/tools/node_modules/postgres-date/index.js +116 -0
- package/skill/tools/node_modules/postgres-date/license +21 -0
- package/skill/tools/node_modules/postgres-date/package.json +33 -0
- package/skill/tools/node_modules/postgres-date/readme.md +49 -0
- package/skill/tools/node_modules/postgres-interval/index.d.ts +20 -0
- package/skill/tools/node_modules/postgres-interval/index.js +125 -0
- package/skill/tools/node_modules/postgres-interval/license +21 -0
- package/skill/tools/node_modules/postgres-interval/package.json +36 -0
- package/skill/tools/node_modules/postgres-interval/readme.md +48 -0
- package/skill/tools/node_modules/split2/LICENSE +13 -0
- package/skill/tools/node_modules/split2/README.md +85 -0
- package/skill/tools/node_modules/split2/bench.js +27 -0
- package/skill/tools/node_modules/split2/index.js +141 -0
- package/skill/tools/node_modules/split2/package.json +39 -0
- package/skill/tools/node_modules/split2/test.js +409 -0
- package/skill/tools/node_modules/undici/LICENSE +21 -0
- package/skill/tools/node_modules/undici/README.md +828 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Agent.md +291 -0
- package/skill/tools/node_modules/undici/docs/docs/api/BalancedPool.md +297 -0
- package/skill/tools/node_modules/undici/docs/docs/api/CacheStorage.md +188 -0
- package/skill/tools/node_modules/undici/docs/docs/api/CacheStore.md +375 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Client.md +538 -0
- package/skill/tools/node_modules/undici/docs/docs/api/ClientStats.md +93 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Connector.md +198 -0
- package/skill/tools/node_modules/undici/docs/docs/api/ContentType.md +97 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Cookies.md +179 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Debug.md +78 -0
- package/skill/tools/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +518 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Dispatcher.md +842 -0
- package/skill/tools/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +171 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Errors.md +624 -0
- package/skill/tools/node_modules/undici/docs/docs/api/EventSource.md +358 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Fetch.md +721 -0
- package/skill/tools/node_modules/undici/docs/docs/api/GlobalInstallation.md +121 -0
- package/skill/tools/node_modules/undici/docs/docs/api/H2CClient.md +386 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Interceptors.md +439 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockAgent.md +622 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistory.md +371 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +206 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockClient.md +199 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockErrors.md +63 -0
- package/skill/tools/node_modules/undici/docs/docs/api/MockPool.md +618 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Pool.md +278 -0
- package/skill/tools/node_modules/undici/docs/docs/api/PoolStats.md +141 -0
- package/skill/tools/node_modules/undici/docs/docs/api/ProxyAgent.md +248 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RedirectHandler.md +279 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RetryAgent.md +136 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RetryHandler.md +200 -0
- package/skill/tools/node_modules/undici/docs/docs/api/RoundRobinPool.md +239 -0
- package/skill/tools/node_modules/undici/docs/docs/api/SnapshotAgent.md +361 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +256 -0
- package/skill/tools/node_modules/undici/docs/docs/api/Util.md +82 -0
- package/skill/tools/node_modules/undici/docs/docs/api/WebSocket.md +536 -0
- package/skill/tools/node_modules/undici/docs/docs/api/api-lifecycle.md +159 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/client-certificate.md +66 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/crawling.md +60 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +233 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/mocking-request.md +192 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/proxy.md +129 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +226 -0
- package/skill/tools/node_modules/undici/docs/docs/best-practices/writing-tests.md +65 -0
- package/skill/tools/node_modules/undici/docs/docs/getting-started.md +281 -0
- package/skill/tools/node_modules/undici/docs/docs/index.md +793 -0
- package/skill/tools/node_modules/undici/docs/docs/site.json +125 -0
- package/skill/tools/node_modules/undici/docs/docs/type-map.json +79 -0
- package/skill/tools/node_modules/undici/index-fetch.js +65 -0
- package/skill/tools/node_modules/undici/index.d.ts +3 -0
- package/skill/tools/node_modules/undici/index.js +236 -0
- package/skill/tools/node_modules/undici/lib/api/abort-signal.js +59 -0
- package/skill/tools/node_modules/undici/lib/api/api-connect.js +112 -0
- package/skill/tools/node_modules/undici/lib/api/api-pipeline.js +265 -0
- package/skill/tools/node_modules/undici/lib/api/api-request.js +244 -0
- package/skill/tools/node_modules/undici/lib/api/api-stream.js +270 -0
- package/skill/tools/node_modules/undici/lib/api/api-upgrade.js +121 -0
- package/skill/tools/node_modules/undici/lib/api/index.js +7 -0
- package/skill/tools/node_modules/undici/lib/api/readable.js +615 -0
- package/skill/tools/node_modules/undici/lib/cache/memory-cache-store.js +314 -0
- package/skill/tools/node_modules/undici/lib/cache/sqlite-cache-store.js +593 -0
- package/skill/tools/node_modules/undici/lib/core/connect.js +198 -0
- package/skill/tools/node_modules/undici/lib/core/constants.js +131 -0
- package/skill/tools/node_modules/undici/lib/core/diagnostics.js +227 -0
- package/skill/tools/node_modules/undici/lib/core/errors.js +534 -0
- package/skill/tools/node_modules/undici/lib/core/request.js +582 -0
- package/skill/tools/node_modules/undici/lib/core/socks5-client.js +422 -0
- package/skill/tools/node_modules/undici/lib/core/socks5-utils.js +212 -0
- package/skill/tools/node_modules/undici/lib/core/symbols.js +81 -0
- package/skill/tools/node_modules/undici/lib/core/tree.js +160 -0
- package/skill/tools/node_modules/undici/lib/core/util.js +1035 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/agent.js +181 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/balanced-pool.js +217 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/client-h1.js +1846 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/client-h2.js +1989 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/client.js +749 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher-base.js +198 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher.js +58 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +127 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +190 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/parser-h1.js +1065 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/pool-base.js +347 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/pool.js +229 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/proxy-agent.js +418 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/retry-agent.js +48 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/round-robin-pool.js +169 -0
- package/skill/tools/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +350 -0
- package/skill/tools/node_modules/undici/lib/encoding/index.js +33 -0
- package/skill/tools/node_modules/undici/lib/global.js +82 -0
- package/skill/tools/node_modules/undici/lib/handler/cache-handler.js +1222 -0
- package/skill/tools/node_modules/undici/lib/handler/cache-revalidation-handler.js +134 -0
- package/skill/tools/node_modules/undici/lib/handler/decorator-handler.js +76 -0
- package/skill/tools/node_modules/undici/lib/handler/deduplication-handler.js +540 -0
- package/skill/tools/node_modules/undici/lib/handler/redirect-handler.js +284 -0
- package/skill/tools/node_modules/undici/lib/handler/retry-handler.js +686 -0
- package/skill/tools/node_modules/undici/lib/interceptor/cache.js +771 -0
- package/skill/tools/node_modules/undici/lib/interceptor/decompress.js +574 -0
- package/skill/tools/node_modules/undici/lib/interceptor/deduplicate.js +118 -0
- package/skill/tools/node_modules/undici/lib/interceptor/dns.js +593 -0
- package/skill/tools/node_modules/undici/lib/interceptor/dump.js +99 -0
- package/skill/tools/node_modules/undici/lib/interceptor/redirect.js +21 -0
- package/skill/tools/node_modules/undici/lib/interceptor/response-error.js +139 -0
- package/skill/tools/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/skill/tools/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
- package/skill/tools/node_modules/undici/lib/llhttp/constants.js +531 -0
- package/skill/tools/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
- package/skill/tools/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/skill/tools/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
- package/skill/tools/node_modules/undici/lib/llhttp/utils.js +12 -0
- package/skill/tools/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/skill/tools/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/skill/tools/node_modules/undici/lib/milo/simd.js +1002 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-agent.js +255 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-call-history.js +248 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-client.js +68 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-errors.js +29 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-interceptor.js +227 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-pool.js +68 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-symbols.js +32 -0
- package/skill/tools/node_modules/undici/lib/mock/mock-utils.js +730 -0
- package/skill/tools/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/skill/tools/node_modules/undici/lib/mock/snapshot-agent.js +371 -0
- package/skill/tools/node_modules/undici/lib/mock/snapshot-recorder.js +624 -0
- package/skill/tools/node_modules/undici/lib/mock/snapshot-utils.js +159 -0
- package/skill/tools/node_modules/undici/lib/util/cache.js +764 -0
- package/skill/tools/node_modules/undici/lib/util/date.js +670 -0
- package/skill/tools/node_modules/undici/lib/util/runtime-features.js +93 -0
- package/skill/tools/node_modules/undici/lib/util/stats.js +32 -0
- package/skill/tools/node_modules/undici/lib/util/timers.js +425 -0
- package/skill/tools/node_modules/undici/lib/web/cache/cache.js +871 -0
- package/skill/tools/node_modules/undici/lib/web/cache/cachestorage.js +158 -0
- package/skill/tools/node_modules/undici/lib/web/cache/util.js +45 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/index.js +211 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/parse.js +318 -0
- package/skill/tools/node_modules/undici/lib/web/cookies/util.js +371 -0
- package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource-stream.js +575 -0
- package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource.js +547 -0
- package/skill/tools/node_modules/undici/lib/web/eventsource/util.js +60 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/LICENSE +21 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/body.js +583 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/constants.js +131 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/data-url.js +596 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/formdata-parser.js +594 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/formdata.js +272 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/headers.js +722 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/index.js +2451 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/request.js +1117 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/response.js +638 -0
- package/skill/tools/node_modules/undici/lib/web/fetch/util.js +1530 -0
- package/skill/tools/node_modules/undici/lib/web/infra/index.js +244 -0
- package/skill/tools/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
- package/skill/tools/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
- package/skill/tools/node_modules/undici/lib/web/webidl/index.js +992 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/connection.js +350 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/constants.js +126 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/events.js +348 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/frame.js +127 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/receiver.js +530 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/sender.js +109 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketerror.js +107 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketstream.js +511 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/util.js +347 -0
- package/skill/tools/node_modules/undici/lib/web/websocket/websocket.js +783 -0
- package/skill/tools/node_modules/undici/package.json +154 -0
- package/skill/tools/node_modules/undici/scripts/strip-comments.js +10 -0
- package/skill/tools/node_modules/undici/types/README.md +6 -0
- package/skill/tools/node_modules/undici/types/agent.d.ts +30 -0
- package/skill/tools/node_modules/undici/types/api.d.ts +43 -0
- package/skill/tools/node_modules/undici/types/balanced-pool.d.ts +30 -0
- package/skill/tools/node_modules/undici/types/cache-interceptor.d.ts +189 -0
- package/skill/tools/node_modules/undici/types/cache.d.ts +36 -0
- package/skill/tools/node_modules/undici/types/client-stats.d.ts +15 -0
- package/skill/tools/node_modules/undici/types/client.d.ts +190 -0
- package/skill/tools/node_modules/undici/types/connector.d.ts +37 -0
- package/skill/tools/node_modules/undici/types/content-type.d.ts +21 -0
- package/skill/tools/node_modules/undici/types/cookies.d.ts +30 -0
- package/skill/tools/node_modules/undici/types/diagnostics-channel.d.ts +75 -0
- package/skill/tools/node_modules/undici/types/dispatcher.d.ts +253 -0
- package/skill/tools/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
- package/skill/tools/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
- package/skill/tools/node_modules/undici/types/errors.d.ts +202 -0
- package/skill/tools/node_modules/undici/types/eventsource.d.ts +66 -0
- package/skill/tools/node_modules/undici/types/fetch.d.ts +235 -0
- package/skill/tools/node_modules/undici/types/formdata.d.ts +108 -0
- package/skill/tools/node_modules/undici/types/global-dispatcher.d.ts +9 -0
- package/skill/tools/node_modules/undici/types/global-origin.d.ts +7 -0
- package/skill/tools/node_modules/undici/types/h2c-client.d.ts +73 -0
- package/skill/tools/node_modules/undici/types/handlers.d.ts +16 -0
- package/skill/tools/node_modules/undici/types/header.d.ts +165 -0
- package/skill/tools/node_modules/undici/types/index.d.ts +93 -0
- package/skill/tools/node_modules/undici/types/interceptors.d.ts +87 -0
- package/skill/tools/node_modules/undici/types/mock-agent.d.ts +69 -0
- package/skill/tools/node_modules/undici/types/mock-call-history.d.ts +111 -0
- package/skill/tools/node_modules/undici/types/mock-client.d.ts +27 -0
- package/skill/tools/node_modules/undici/types/mock-errors.d.ts +12 -0
- package/skill/tools/node_modules/undici/types/mock-interceptor.d.ts +98 -0
- package/skill/tools/node_modules/undici/types/mock-pool.d.ts +27 -0
- package/skill/tools/node_modules/undici/types/patch.d.ts +29 -0
- package/skill/tools/node_modules/undici/types/pool-stats.d.ts +19 -0
- package/skill/tools/node_modules/undici/types/pool.d.ts +39 -0
- package/skill/tools/node_modules/undici/types/proxy-agent.d.ts +36 -0
- package/skill/tools/node_modules/undici/types/readable.d.ts +68 -0
- package/skill/tools/node_modules/undici/types/retry-agent.d.ts +8 -0
- package/skill/tools/node_modules/undici/types/retry-handler.d.ts +125 -0
- package/skill/tools/node_modules/undici/types/round-robin-pool.d.ts +39 -0
- package/skill/tools/node_modules/undici/types/snapshot-agent.d.ts +113 -0
- package/skill/tools/node_modules/undici/types/socks5-proxy-agent.d.ts +27 -0
- package/skill/tools/node_modules/undici/types/util.d.ts +18 -0
- package/skill/tools/node_modules/undici/types/utility.d.ts +7 -0
- package/skill/tools/node_modules/undici/types/webidl.d.ts +352 -0
- package/skill/tools/node_modules/undici/types/websocket.d.ts +188 -0
- package/skill/tools/node_modules/xtend/.jshintrc +30 -0
- package/skill/tools/node_modules/xtend/LICENSE +20 -0
- package/skill/tools/node_modules/xtend/README.md +32 -0
- package/skill/tools/node_modules/xtend/immutable.js +19 -0
- package/skill/tools/node_modules/xtend/mutable.js +17 -0
- package/skill/tools/node_modules/xtend/package.json +55 -0
- package/skill/tools/node_modules/xtend/test.js +103 -0
- package/skill/tools/package-lock.json +172 -0
- package/skill/tools/package.json +9 -0
- package/skill/tools/transfer_core.js +414 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { kClients } = require('../core/symbols')
|
|
4
|
+
const Agent = require('../dispatcher/agent')
|
|
5
|
+
const {
|
|
6
|
+
kAgent,
|
|
7
|
+
kMockAgentSet,
|
|
8
|
+
kMockAgentGet,
|
|
9
|
+
kDispatches,
|
|
10
|
+
kIsMockActive,
|
|
11
|
+
kNetConnect,
|
|
12
|
+
kGetNetConnect,
|
|
13
|
+
kOptions,
|
|
14
|
+
kFactory,
|
|
15
|
+
kMockAgentRegisterCallHistory,
|
|
16
|
+
kMockAgentIsCallHistoryEnabled,
|
|
17
|
+
kMockAgentAddCallHistoryLog,
|
|
18
|
+
kMockAgentMockCallHistoryInstance,
|
|
19
|
+
kMockAgentAcceptsNonStandardSearchParameters,
|
|
20
|
+
kMockCallHistoryAddLog,
|
|
21
|
+
kIgnoreTrailingSlash
|
|
22
|
+
} = require('./mock-symbols')
|
|
23
|
+
const MockClient = require('./mock-client')
|
|
24
|
+
const MockPool = require('./mock-pool')
|
|
25
|
+
const { matchValue, normalizeSearchParams, buildAndValidateMockOptions, normalizeOrigin } = require('./mock-utils')
|
|
26
|
+
const { InvalidArgumentError, UndiciError } = require('../core/errors')
|
|
27
|
+
const Dispatcher = require('../dispatcher/dispatcher')
|
|
28
|
+
const PendingInterceptorsFormatter = require('./pending-interceptors-formatter')
|
|
29
|
+
const { MockCallHistory } = require('./mock-call-history')
|
|
30
|
+
|
|
31
|
+
class MockAgent extends Dispatcher {
|
|
32
|
+
constructor (opts = {}) {
|
|
33
|
+
super(opts)
|
|
34
|
+
|
|
35
|
+
const mockOptions = buildAndValidateMockOptions(opts)
|
|
36
|
+
|
|
37
|
+
this[kNetConnect] = true
|
|
38
|
+
this[kIsMockActive] = true
|
|
39
|
+
this[kMockAgentIsCallHistoryEnabled] = mockOptions.enableCallHistory ?? false
|
|
40
|
+
this[kMockAgentAcceptsNonStandardSearchParameters] = mockOptions.acceptNonStandardSearchParameters ?? false
|
|
41
|
+
this[kIgnoreTrailingSlash] = mockOptions.ignoreTrailingSlash ?? false
|
|
42
|
+
|
|
43
|
+
// Instantiate Agent and encapsulate
|
|
44
|
+
if (opts?.agent && typeof opts.agent.dispatch !== 'function') {
|
|
45
|
+
throw new InvalidArgumentError('Argument opts.agent must implement Agent')
|
|
46
|
+
}
|
|
47
|
+
const agent = opts?.agent ? opts.agent : new Agent(opts)
|
|
48
|
+
this[kAgent] = agent
|
|
49
|
+
|
|
50
|
+
this[kClients] = agent[kClients]
|
|
51
|
+
this[kOptions] = mockOptions
|
|
52
|
+
|
|
53
|
+
if (this[kMockAgentIsCallHistoryEnabled]) {
|
|
54
|
+
this[kMockAgentRegisterCallHistory]()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// WebSocket and EventSource read their receive limits from the dispatcher
|
|
59
|
+
// they are given, so report the settings of the agent that makes real
|
|
60
|
+
// connections.
|
|
61
|
+
get webSocketOptions () {
|
|
62
|
+
return this[kAgent].webSocketOptions
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get eventSourceOptions () {
|
|
66
|
+
return this[kAgent].eventSourceOptions
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get (origin) {
|
|
70
|
+
// Normalize origin to handle URL objects and case-insensitive hostnames
|
|
71
|
+
const normalizedOrigin = normalizeOrigin(origin)
|
|
72
|
+
const originKey = this[kIgnoreTrailingSlash] ? normalizedOrigin.replace(/\/$/, '') : normalizedOrigin
|
|
73
|
+
|
|
74
|
+
let dispatcher = this[kMockAgentGet](originKey)
|
|
75
|
+
|
|
76
|
+
if (!dispatcher) {
|
|
77
|
+
dispatcher = this[kFactory](originKey)
|
|
78
|
+
this[kMockAgentSet](originKey, dispatcher)
|
|
79
|
+
}
|
|
80
|
+
return dispatcher
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
dispatch (opts, handler) {
|
|
84
|
+
opts.origin = normalizeOrigin(opts.origin)
|
|
85
|
+
|
|
86
|
+
// Call MockAgent.get to perform additional setup before dispatching as normal
|
|
87
|
+
const mockDispatcher = this.get(opts.origin)
|
|
88
|
+
|
|
89
|
+
this[kMockAgentAddCallHistoryLog](opts)
|
|
90
|
+
|
|
91
|
+
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters]
|
|
92
|
+
|
|
93
|
+
const dispatchOpts = { ...opts }
|
|
94
|
+
|
|
95
|
+
// Agent keeps HTTP/1.1-only dispatchers under a separate key. Legacy
|
|
96
|
+
// global dispatcher consumers use that path, so mirror the mock dispatches
|
|
97
|
+
// before delegating to the internal Agent.
|
|
98
|
+
if (dispatchOpts.allowH2 === false) {
|
|
99
|
+
const http1OnlyKey = `${dispatchOpts.origin}#http1-only`
|
|
100
|
+
if (!this[kClients].has(http1OnlyKey)) {
|
|
101
|
+
const http1OnlyDispatcher = this[kFactory](dispatchOpts.origin)
|
|
102
|
+
http1OnlyDispatcher[kDispatches] = mockDispatcher[kDispatches]
|
|
103
|
+
this[kMockAgentSet](http1OnlyKey, http1OnlyDispatcher)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
108
|
+
const [path, searchParams] = dispatchOpts.path.split('?')
|
|
109
|
+
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters)
|
|
110
|
+
dispatchOpts.path = `${path}?${normalizedSearchParams}`
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return this[kAgent].dispatch(dispatchOpts, handler)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async close () {
|
|
117
|
+
this.clearCallHistory()
|
|
118
|
+
await this[kAgent].close()
|
|
119
|
+
this[kClients].clear()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
deactivate () {
|
|
123
|
+
this[kIsMockActive] = false
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
activate () {
|
|
127
|
+
this[kIsMockActive] = true
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
enableNetConnect (matcher) {
|
|
131
|
+
if (typeof matcher === 'string' || typeof matcher === 'function' || matcher instanceof RegExp) {
|
|
132
|
+
if (Array.isArray(this[kNetConnect])) {
|
|
133
|
+
this[kNetConnect].push(matcher)
|
|
134
|
+
} else {
|
|
135
|
+
this[kNetConnect] = [matcher]
|
|
136
|
+
}
|
|
137
|
+
} else if (typeof matcher === 'undefined') {
|
|
138
|
+
this[kNetConnect] = true
|
|
139
|
+
} else {
|
|
140
|
+
throw new InvalidArgumentError('Unsupported matcher. Must be one of String|Function|RegExp.')
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
disableNetConnect () {
|
|
145
|
+
this[kNetConnect] = false
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
enableCallHistory () {
|
|
149
|
+
this[kMockAgentIsCallHistoryEnabled] = true
|
|
150
|
+
|
|
151
|
+
return this
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
disableCallHistory () {
|
|
155
|
+
this[kMockAgentIsCallHistoryEnabled] = false
|
|
156
|
+
|
|
157
|
+
return this
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
getCallHistory () {
|
|
161
|
+
return this[kMockAgentMockCallHistoryInstance]
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
clearCallHistory () {
|
|
165
|
+
if (this[kMockAgentMockCallHistoryInstance] !== undefined) {
|
|
166
|
+
this[kMockAgentMockCallHistoryInstance].clear()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// This is required to bypass issues caused by using global symbols - see:
|
|
171
|
+
// https://github.com/nodejs/undici/issues/1447
|
|
172
|
+
get isMockActive () {
|
|
173
|
+
return this[kIsMockActive]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
[kMockAgentRegisterCallHistory] () {
|
|
177
|
+
if (this[kMockAgentMockCallHistoryInstance] === undefined) {
|
|
178
|
+
this[kMockAgentMockCallHistoryInstance] = new MockCallHistory()
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
[kMockAgentAddCallHistoryLog] (opts) {
|
|
183
|
+
if (this[kMockAgentIsCallHistoryEnabled]) {
|
|
184
|
+
// additional setup when enableCallHistory class method is used after mockAgent instantiation
|
|
185
|
+
this[kMockAgentRegisterCallHistory]()
|
|
186
|
+
|
|
187
|
+
// add call history log on every call (intercepted or not)
|
|
188
|
+
this[kMockAgentMockCallHistoryInstance][kMockCallHistoryAddLog](opts)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
[kMockAgentSet] (origin, dispatcher) {
|
|
193
|
+
this[kClients].set(origin, dispatcher)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[kFactory] (origin) {
|
|
197
|
+
const mockOptions = Object.assign({ agent: this }, this[kOptions])
|
|
198
|
+
return this[kOptions] && this[kOptions].connections === 1
|
|
199
|
+
? new MockClient(origin, mockOptions)
|
|
200
|
+
: new MockPool(origin, mockOptions)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
[kMockAgentGet] (origin) {
|
|
204
|
+
// First check if we can immediately find it
|
|
205
|
+
const dispatcher = this[kClients].get(origin)
|
|
206
|
+
if (dispatcher) {
|
|
207
|
+
return dispatcher
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// If the origin is not a string create a dummy parent pool and return to user
|
|
211
|
+
if (typeof origin !== 'string') {
|
|
212
|
+
const dispatcher = this[kFactory]('http://localhost:9999')
|
|
213
|
+
this[kMockAgentSet](origin, dispatcher)
|
|
214
|
+
return dispatcher
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// If we match, create a pool and assign the same dispatches
|
|
218
|
+
for (const [keyMatcher, nonExplicitDispatcher] of Array.from(this[kClients])) {
|
|
219
|
+
if (nonExplicitDispatcher && typeof keyMatcher !== 'string' && matchValue(keyMatcher, origin)) {
|
|
220
|
+
const dispatcher = this[kFactory](origin)
|
|
221
|
+
this[kMockAgentSet](origin, dispatcher)
|
|
222
|
+
dispatcher[kDispatches] = nonExplicitDispatcher[kDispatches]
|
|
223
|
+
return dispatcher
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
[kGetNetConnect] () {
|
|
229
|
+
return this[kNetConnect]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
pendingInterceptors () {
|
|
233
|
+
const mockAgentClients = this[kClients]
|
|
234
|
+
|
|
235
|
+
return Array.from(mockAgentClients.entries())
|
|
236
|
+
.flatMap(([origin, dispatcher]) => dispatcher[kDispatches].map(dispatch => ({ ...dispatch, origin })))
|
|
237
|
+
.filter(({ pending }) => pending)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
assertNoPendingInterceptors ({ pendingInterceptorsFormatter = new PendingInterceptorsFormatter() } = {}) {
|
|
241
|
+
const pending = this.pendingInterceptors()
|
|
242
|
+
|
|
243
|
+
if (pending.length === 0) {
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
throw new UndiciError(
|
|
248
|
+
pending.length === 1
|
|
249
|
+
? `1 interceptor is pending:\n\n${pendingInterceptorsFormatter.format(pending)}`.trim()
|
|
250
|
+
: `${pending.length} interceptors are pending:\n\n${pendingInterceptorsFormatter.format(pending)}`.trim()
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
module.exports = MockAgent
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { kMockCallHistoryAddLog } = require('./mock-symbols')
|
|
4
|
+
const { InvalidArgumentError } = require('../core/errors')
|
|
5
|
+
|
|
6
|
+
function handleFilterCallsWithOptions (criteria, options, handler, store, allLogs) {
|
|
7
|
+
switch (options.operator) {
|
|
8
|
+
case 'OR':
|
|
9
|
+
store.push(...handler(criteria, allLogs))
|
|
10
|
+
|
|
11
|
+
return store
|
|
12
|
+
case 'AND':
|
|
13
|
+
return handler(criteria, store)
|
|
14
|
+
default:
|
|
15
|
+
// guard -- should never happens because buildAndValidateFilterCallsOptions is called before
|
|
16
|
+
throw new InvalidArgumentError('options.operator must to be a case insensitive string equal to \'OR\' or \'AND\'')
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function buildAndValidateFilterCallsOptions (options = {}) {
|
|
21
|
+
const finalOptions = {}
|
|
22
|
+
|
|
23
|
+
if ('operator' in options) {
|
|
24
|
+
if (typeof options.operator !== 'string' || (options.operator.toUpperCase() !== 'OR' && options.operator.toUpperCase() !== 'AND')) {
|
|
25
|
+
throw new InvalidArgumentError('options.operator must to be a case insensitive string equal to \'OR\' or \'AND\'')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...finalOptions,
|
|
30
|
+
operator: options.operator.toUpperCase()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return finalOptions
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function makeFilterCalls (parameterName) {
|
|
38
|
+
return (parameterValue, logs = this.logs) => {
|
|
39
|
+
if (typeof parameterValue === 'string' || parameterValue == null) {
|
|
40
|
+
return logs.filter((log) => {
|
|
41
|
+
return log[parameterName] === parameterValue
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
if (parameterValue instanceof RegExp) {
|
|
45
|
+
return logs.filter((log) => {
|
|
46
|
+
return parameterValue.test(log[parameterName])
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function computeUrlWithMaybeSearchParameters (requestInit) {
|
|
54
|
+
// path can contains query url parameters
|
|
55
|
+
// or query can contains query url parameters
|
|
56
|
+
try {
|
|
57
|
+
const url = new URL(requestInit.path, requestInit.origin)
|
|
58
|
+
|
|
59
|
+
// requestInit.path contains query url parameters
|
|
60
|
+
// requestInit.query is then undefined
|
|
61
|
+
if (url.search.length !== 0) {
|
|
62
|
+
return url
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// requestInit.query can be populated here
|
|
66
|
+
url.search = new URLSearchParams(requestInit.query).toString()
|
|
67
|
+
|
|
68
|
+
return url
|
|
69
|
+
} catch (error) {
|
|
70
|
+
throw new InvalidArgumentError('An error occurred when computing MockCallHistoryLog.url', { cause: error })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
class MockCallHistoryLog {
|
|
75
|
+
constructor (requestInit = {}) {
|
|
76
|
+
this.body = requestInit.body
|
|
77
|
+
this.headers = requestInit.headers
|
|
78
|
+
this.method = requestInit.method
|
|
79
|
+
|
|
80
|
+
const url = computeUrlWithMaybeSearchParameters(requestInit)
|
|
81
|
+
|
|
82
|
+
this.fullUrl = url.toString()
|
|
83
|
+
this.origin = url.origin
|
|
84
|
+
this.path = url.pathname
|
|
85
|
+
this.searchParams = Object.fromEntries(url.searchParams)
|
|
86
|
+
this.protocol = url.protocol
|
|
87
|
+
this.host = url.host
|
|
88
|
+
this.port = url.port
|
|
89
|
+
this.hash = url.hash
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
toMap () {
|
|
93
|
+
return new Map([
|
|
94
|
+
['protocol', this.protocol],
|
|
95
|
+
['host', this.host],
|
|
96
|
+
['port', this.port],
|
|
97
|
+
['origin', this.origin],
|
|
98
|
+
['path', this.path],
|
|
99
|
+
['hash', this.hash],
|
|
100
|
+
['searchParams', this.searchParams],
|
|
101
|
+
['fullUrl', this.fullUrl],
|
|
102
|
+
['method', this.method],
|
|
103
|
+
['body', this.body],
|
|
104
|
+
['headers', this.headers]]
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
toString () {
|
|
109
|
+
const options = { betweenKeyValueSeparator: '->', betweenPairSeparator: '|' }
|
|
110
|
+
let result = ''
|
|
111
|
+
|
|
112
|
+
this.toMap().forEach((value, key) => {
|
|
113
|
+
if (typeof value === 'string' || value === undefined || value === null) {
|
|
114
|
+
result = `${result}${key}${options.betweenKeyValueSeparator}${value}${options.betweenPairSeparator}`
|
|
115
|
+
}
|
|
116
|
+
if ((typeof value === 'object' && value !== null) || Array.isArray(value)) {
|
|
117
|
+
result = `${result}${key}${options.betweenKeyValueSeparator}${JSON.stringify(value)}${options.betweenPairSeparator}`
|
|
118
|
+
}
|
|
119
|
+
// maybe miss something for non Record / Array headers and searchParams here
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
// delete last betweenPairSeparator
|
|
123
|
+
return result.slice(0, -1)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
class MockCallHistory {
|
|
128
|
+
logs = []
|
|
129
|
+
|
|
130
|
+
calls () {
|
|
131
|
+
return this.logs
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
firstCall () {
|
|
135
|
+
return this.logs.at(0)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
lastCall () {
|
|
139
|
+
return this.logs.at(-1)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
nthCall (number) {
|
|
143
|
+
if (typeof number !== 'number') {
|
|
144
|
+
throw new InvalidArgumentError('nthCall must be called with a number')
|
|
145
|
+
}
|
|
146
|
+
if (!Number.isInteger(number)) {
|
|
147
|
+
throw new InvalidArgumentError('nthCall must be called with an integer')
|
|
148
|
+
}
|
|
149
|
+
if (Math.sign(number) !== 1) {
|
|
150
|
+
throw new InvalidArgumentError('nthCall must be called with a positive value. use firstCall or lastCall instead')
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// non zero based index. this is more human readable
|
|
154
|
+
return this.logs.at(number - 1)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
filterCalls (criteria, options) {
|
|
158
|
+
// perf
|
|
159
|
+
if (this.logs.length === 0) {
|
|
160
|
+
return this.logs
|
|
161
|
+
}
|
|
162
|
+
if (typeof criteria === 'function') {
|
|
163
|
+
return this.logs.filter(criteria)
|
|
164
|
+
}
|
|
165
|
+
if (criteria instanceof RegExp) {
|
|
166
|
+
return this.logs.filter((log) => {
|
|
167
|
+
return criteria.test(log.toString())
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
if (typeof criteria === 'object' && criteria !== null) {
|
|
171
|
+
// no criteria - returning all logs
|
|
172
|
+
if (Object.keys(criteria).length === 0) {
|
|
173
|
+
return this.logs
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const finalOptions = { operator: 'OR', ...buildAndValidateFilterCallsOptions(options) }
|
|
177
|
+
|
|
178
|
+
let maybeDuplicatedLogsFiltered = finalOptions.operator === 'AND' ? this.logs : []
|
|
179
|
+
if ('protocol' in criteria) {
|
|
180
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered, this.logs)
|
|
181
|
+
}
|
|
182
|
+
if ('host' in criteria) {
|
|
183
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered, this.logs)
|
|
184
|
+
}
|
|
185
|
+
if ('port' in criteria) {
|
|
186
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered, this.logs)
|
|
187
|
+
}
|
|
188
|
+
if ('origin' in criteria) {
|
|
189
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered, this.logs)
|
|
190
|
+
}
|
|
191
|
+
if ('path' in criteria) {
|
|
192
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered, this.logs)
|
|
193
|
+
}
|
|
194
|
+
if ('hash' in criteria) {
|
|
195
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered, this.logs)
|
|
196
|
+
}
|
|
197
|
+
if ('fullUrl' in criteria) {
|
|
198
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered, this.logs)
|
|
199
|
+
}
|
|
200
|
+
if ('method' in criteria) {
|
|
201
|
+
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered, this.logs)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const uniqLogsFiltered = [...new Set(maybeDuplicatedLogsFiltered)]
|
|
205
|
+
|
|
206
|
+
return uniqLogsFiltered
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
throw new InvalidArgumentError('criteria parameter should be one of function, regexp, or object')
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
filterCallsByProtocol = makeFilterCalls.call(this, 'protocol')
|
|
213
|
+
|
|
214
|
+
filterCallsByHost = makeFilterCalls.call(this, 'host')
|
|
215
|
+
|
|
216
|
+
filterCallsByPort = makeFilterCalls.call(this, 'port')
|
|
217
|
+
|
|
218
|
+
filterCallsByOrigin = makeFilterCalls.call(this, 'origin')
|
|
219
|
+
|
|
220
|
+
filterCallsByPath = makeFilterCalls.call(this, 'path')
|
|
221
|
+
|
|
222
|
+
filterCallsByHash = makeFilterCalls.call(this, 'hash')
|
|
223
|
+
|
|
224
|
+
filterCallsByFullUrl = makeFilterCalls.call(this, 'fullUrl')
|
|
225
|
+
|
|
226
|
+
filterCallsByMethod = makeFilterCalls.call(this, 'method')
|
|
227
|
+
|
|
228
|
+
clear () {
|
|
229
|
+
this.logs = []
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
[kMockCallHistoryAddLog] (requestInit) {
|
|
233
|
+
const log = new MockCallHistoryLog(requestInit)
|
|
234
|
+
|
|
235
|
+
this.logs.push(log)
|
|
236
|
+
|
|
237
|
+
return log
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
* [Symbol.iterator] () {
|
|
241
|
+
for (const log of this.calls()) {
|
|
242
|
+
yield log
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
module.exports.MockCallHistory = MockCallHistory
|
|
248
|
+
module.exports.MockCallHistoryLog = MockCallHistoryLog
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { promisify } = require('node:util')
|
|
4
|
+
const Client = require('../dispatcher/client')
|
|
5
|
+
const { buildMockDispatch } = require('./mock-utils')
|
|
6
|
+
const {
|
|
7
|
+
kDispatches,
|
|
8
|
+
kMockAgent,
|
|
9
|
+
kClose,
|
|
10
|
+
kOriginalClose,
|
|
11
|
+
kOrigin,
|
|
12
|
+
kOriginalDispatch,
|
|
13
|
+
kConnected,
|
|
14
|
+
kIgnoreTrailingSlash
|
|
15
|
+
} = require('./mock-symbols')
|
|
16
|
+
const { MockInterceptor } = require('./mock-interceptor')
|
|
17
|
+
const Symbols = require('../core/symbols')
|
|
18
|
+
const { InvalidArgumentError } = require('../core/errors')
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* MockClient provides an API that extends the Client to influence the mockDispatches.
|
|
22
|
+
*/
|
|
23
|
+
class MockClient extends Client {
|
|
24
|
+
constructor (origin, opts) {
|
|
25
|
+
if (!opts || !opts.agent || typeof opts.agent.dispatch !== 'function') {
|
|
26
|
+
throw new InvalidArgumentError('Argument opts.agent must implement Agent')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
super(origin, opts)
|
|
30
|
+
|
|
31
|
+
this[kMockAgent] = opts.agent
|
|
32
|
+
this[kOrigin] = origin
|
|
33
|
+
this[kIgnoreTrailingSlash] = opts.ignoreTrailingSlash ?? false
|
|
34
|
+
this[kDispatches] = []
|
|
35
|
+
this[kConnected] = 1
|
|
36
|
+
this[kOriginalDispatch] = this.dispatch
|
|
37
|
+
this[kOriginalClose] = this.close.bind(this)
|
|
38
|
+
|
|
39
|
+
this.dispatch = buildMockDispatch.call(this)
|
|
40
|
+
this.close = this[kClose]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get [Symbols.kConnected] () {
|
|
44
|
+
return this[kConnected]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Sets up the base interceptor for mocking replies from undici.
|
|
49
|
+
*/
|
|
50
|
+
intercept (opts) {
|
|
51
|
+
return new MockInterceptor(
|
|
52
|
+
opts && { ignoreTrailingSlash: this[kIgnoreTrailingSlash], ...opts },
|
|
53
|
+
this[kDispatches]
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
cleanMocks () {
|
|
58
|
+
this[kDispatches] = []
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async [kClose] () {
|
|
62
|
+
await promisify(this[kOriginalClose])()
|
|
63
|
+
this[kConnected] = 0
|
|
64
|
+
this[kMockAgent][Symbols.kClients].delete(this[kOrigin])
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = MockClient
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { UndiciError } = require('../core/errors')
|
|
4
|
+
|
|
5
|
+
const kMockNotMatchedError = Symbol.for('undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The request does not match any registered mock dispatches.
|
|
9
|
+
*/
|
|
10
|
+
class MockNotMatchedError extends UndiciError {
|
|
11
|
+
constructor (message) {
|
|
12
|
+
super(message)
|
|
13
|
+
this.name = 'MockNotMatchedError'
|
|
14
|
+
this.message = message || 'The request does not match any registered mock dispatches'
|
|
15
|
+
this.code = 'UND_MOCK_ERR_MOCK_NOT_MATCHED'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static [Symbol.hasInstance] (instance) {
|
|
19
|
+
return instance && instance[kMockNotMatchedError] === true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get [kMockNotMatchedError] () {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
MockNotMatchedError
|
|
29
|
+
}
|