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,846 @@
|
|
|
1
|
+
const EventEmitter = require('events').EventEmitter
|
|
2
|
+
const utils = require('./utils')
|
|
3
|
+
const nodeUtils = require('util')
|
|
4
|
+
const sasl = require('./crypto/sasl')
|
|
5
|
+
const TypeOverrides = require('./type-overrides')
|
|
6
|
+
|
|
7
|
+
const ConnectionParameters = require('./connection-parameters')
|
|
8
|
+
const Query = require('./query')
|
|
9
|
+
const defaults = require('./defaults')
|
|
10
|
+
const Connection = require('./connection')
|
|
11
|
+
const crypto = require('./crypto/utils')
|
|
12
|
+
|
|
13
|
+
const activeQueryDeprecationNotice = nodeUtils.deprecate(
|
|
14
|
+
() => {},
|
|
15
|
+
'Client.activeQuery is deprecated and will be removed in pg@9.0'
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const queryQueueDeprecationNotice = nodeUtils.deprecate(
|
|
19
|
+
() => {},
|
|
20
|
+
'Client.queryQueue is deprecated and will be removed in pg@9.0.'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const pgPassDeprecationNotice = nodeUtils.deprecate(
|
|
24
|
+
() => {},
|
|
25
|
+
'pgpass support is deprecated and will be removed in pg@9.0. ' +
|
|
26
|
+
'You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code.'
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const byoPromiseDeprecationNotice = nodeUtils.deprecate(
|
|
30
|
+
() => {},
|
|
31
|
+
'Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0.'
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
|
|
35
|
+
() => {},
|
|
36
|
+
'Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead.'
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
function coerceNumberOrDefault(value, defaultValue) {
|
|
40
|
+
if (typeof value === 'number') {
|
|
41
|
+
return Number.isFinite(value) ? value : defaultValue
|
|
42
|
+
}
|
|
43
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
44
|
+
const n = Number(value)
|
|
45
|
+
return Number.isFinite(n) ? n : defaultValue
|
|
46
|
+
}
|
|
47
|
+
return defaultValue
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class Client extends EventEmitter {
|
|
51
|
+
constructor(config) {
|
|
52
|
+
super()
|
|
53
|
+
|
|
54
|
+
this.connectionParameters = new ConnectionParameters(config)
|
|
55
|
+
this.user = this.connectionParameters.user
|
|
56
|
+
this.database = this.connectionParameters.database
|
|
57
|
+
this.port = this.connectionParameters.port
|
|
58
|
+
this.host = this.connectionParameters.host
|
|
59
|
+
|
|
60
|
+
// "hiding" the password so it doesn't show up in stack traces
|
|
61
|
+
// or if the client is console.logged
|
|
62
|
+
Object.defineProperty(this, 'password', {
|
|
63
|
+
configurable: true,
|
|
64
|
+
enumerable: false,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: this.connectionParameters.password,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
this.replication = this.connectionParameters.replication
|
|
70
|
+
|
|
71
|
+
const c = config || {}
|
|
72
|
+
|
|
73
|
+
if (c.Promise) {
|
|
74
|
+
byoPromiseDeprecationNotice()
|
|
75
|
+
}
|
|
76
|
+
this._Promise = c.Promise || global.Promise
|
|
77
|
+
this._types = new TypeOverrides(c.types)
|
|
78
|
+
this._ending = false
|
|
79
|
+
this._ended = false
|
|
80
|
+
this._connecting = false
|
|
81
|
+
this._connected = false
|
|
82
|
+
this._connectionError = false
|
|
83
|
+
this._queryable = true
|
|
84
|
+
this._activeQuery = null
|
|
85
|
+
this._txStatus = null
|
|
86
|
+
|
|
87
|
+
this.enableChannelBinding = Boolean(c.enableChannelBinding) // set true to use SCRAM-SHA-256-PLUS when offered
|
|
88
|
+
this.scramMaxIterations = coerceNumberOrDefault(c.scramMaxIterations, sasl.DEFAULT_MAX_SCRAM_ITERATIONS)
|
|
89
|
+
this.connection =
|
|
90
|
+
c.connection ||
|
|
91
|
+
new Connection({
|
|
92
|
+
stream: c.stream,
|
|
93
|
+
ssl: this.connectionParameters.ssl,
|
|
94
|
+
sslNegotiation: this.connectionParameters.sslnegotiation,
|
|
95
|
+
keepAlive: c.keepAlive || false,
|
|
96
|
+
keepAliveInitialDelayMillis: c.keepAliveInitialDelayMillis || 0,
|
|
97
|
+
encoding: this.connectionParameters.client_encoding || 'utf8',
|
|
98
|
+
})
|
|
99
|
+
this._queryQueue = []
|
|
100
|
+
this._sentQueryQueue = []
|
|
101
|
+
this.pipeline = Boolean(c.pipeline)
|
|
102
|
+
this.binary = c.binary || defaults.binary
|
|
103
|
+
this.processID = null
|
|
104
|
+
this.secretKey = null
|
|
105
|
+
this.ssl = this.connectionParameters.ssl || false
|
|
106
|
+
this.sslNegotiation = this.connectionParameters.sslnegotiation || 'postgres'
|
|
107
|
+
// As with Password, make SSL->Key (the private key) non-enumerable.
|
|
108
|
+
// It won't show up in stack traces
|
|
109
|
+
// or if the client is console.logged
|
|
110
|
+
if (this.ssl && this.ssl.key) {
|
|
111
|
+
Object.defineProperty(this.ssl, 'key', {
|
|
112
|
+
enumerable: false,
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this._connectionTimeoutMillis = c.connectionTimeoutMillis || 0
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get activeQuery() {
|
|
120
|
+
activeQueryDeprecationNotice()
|
|
121
|
+
return this._activeQuery
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
set activeQuery(val) {
|
|
125
|
+
activeQueryDeprecationNotice()
|
|
126
|
+
this._activeQuery = val
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
_getActiveQuery() {
|
|
130
|
+
return this._activeQuery
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_errorAllQueries(err) {
|
|
134
|
+
const enqueueError = (query) => {
|
|
135
|
+
process.nextTick(() => {
|
|
136
|
+
query.handleError(err, this.connection)
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const activeQuery = this._getActiveQuery()
|
|
141
|
+
if (activeQuery) {
|
|
142
|
+
enqueueError(activeQuery)
|
|
143
|
+
this._activeQuery = null
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
this._sentQueryQueue.forEach(enqueueError)
|
|
147
|
+
this._sentQueryQueue.length = 0
|
|
148
|
+
|
|
149
|
+
this._queryQueue.forEach(enqueueError)
|
|
150
|
+
this._queryQueue.length = 0
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
_connect(callback) {
|
|
154
|
+
const self = this
|
|
155
|
+
const con = this.connection
|
|
156
|
+
this._connectionCallback = callback
|
|
157
|
+
|
|
158
|
+
if (this._connecting || this._connected) {
|
|
159
|
+
const err = new Error('Client has already been connected. You cannot reuse a client.')
|
|
160
|
+
process.nextTick(() => {
|
|
161
|
+
callback(err)
|
|
162
|
+
})
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
this._connecting = true
|
|
166
|
+
|
|
167
|
+
if (this._connectionTimeoutMillis > 0) {
|
|
168
|
+
this.connectionTimeoutHandle = setTimeout(() => {
|
|
169
|
+
con._ending = true
|
|
170
|
+
con.stream.destroy(new Error('timeout expired'))
|
|
171
|
+
}, this._connectionTimeoutMillis)
|
|
172
|
+
|
|
173
|
+
if (this.connectionTimeoutHandle.unref) {
|
|
174
|
+
this.connectionTimeoutHandle.unref()
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (this.host && this.host.indexOf('/') === 0) {
|
|
179
|
+
con.connect(this.host + '/.s.PGSQL.' + this.port)
|
|
180
|
+
} else {
|
|
181
|
+
con.connect(this.port, this.host)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// once connection is established send startup message
|
|
185
|
+
con.on('connect', function () {
|
|
186
|
+
if (self.ssl) {
|
|
187
|
+
// With direct SSL negotiation the connection upgrades to TLS without an
|
|
188
|
+
// SSLRequest packet, so the startup message is sent after 'sslconnect'.
|
|
189
|
+
if (self.sslNegotiation !== 'direct') {
|
|
190
|
+
con.requestSsl()
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
con.startup(self.getStartupConf())
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
con.on('sslconnect', function () {
|
|
198
|
+
con.startup(self.getStartupConf())
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
this._attachListeners(con)
|
|
202
|
+
|
|
203
|
+
con.once('end', () => {
|
|
204
|
+
const error = this._ending ? new Error('Connection terminated') : new Error('Connection terminated unexpectedly')
|
|
205
|
+
|
|
206
|
+
clearTimeout(this.connectionTimeoutHandle)
|
|
207
|
+
this._errorAllQueries(error)
|
|
208
|
+
this._ended = true
|
|
209
|
+
|
|
210
|
+
if (!this._ending) {
|
|
211
|
+
// if the connection is ended without us calling .end()
|
|
212
|
+
// on this client then we have an unexpected disconnection
|
|
213
|
+
// treat this as an error unless we've already emitted an error
|
|
214
|
+
// during connection.
|
|
215
|
+
if (this._connecting && !this._connectionError) {
|
|
216
|
+
if (this._connectionCallback) {
|
|
217
|
+
this._connectionCallback(error)
|
|
218
|
+
} else {
|
|
219
|
+
this._handleErrorEvent(error)
|
|
220
|
+
}
|
|
221
|
+
} else if (!this._connectionError) {
|
|
222
|
+
this._handleErrorEvent(error)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
process.nextTick(() => {
|
|
227
|
+
this.emit('end')
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
connect(callback) {
|
|
233
|
+
if (callback) {
|
|
234
|
+
this._connect(callback)
|
|
235
|
+
return
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return new this._Promise((resolve, reject) => {
|
|
239
|
+
this._connect((error) => {
|
|
240
|
+
if (error) {
|
|
241
|
+
reject(error)
|
|
242
|
+
} else {
|
|
243
|
+
resolve(this)
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
_attachListeners(con) {
|
|
250
|
+
// password request handling
|
|
251
|
+
con.on('authenticationCleartextPassword', this._handleAuthCleartextPassword.bind(this))
|
|
252
|
+
// password request handling
|
|
253
|
+
con.on('authenticationMD5Password', this._handleAuthMD5Password.bind(this))
|
|
254
|
+
// password request handling (SASL)
|
|
255
|
+
con.on('authenticationSASL', this._handleAuthSASL.bind(this))
|
|
256
|
+
con.on('authenticationSASLContinue', this._handleAuthSASLContinue.bind(this))
|
|
257
|
+
con.on('authenticationSASLFinal', this._handleAuthSASLFinal.bind(this))
|
|
258
|
+
con.on('backendKeyData', this._handleBackendKeyData.bind(this))
|
|
259
|
+
con.on('error', this._handleErrorEvent.bind(this))
|
|
260
|
+
con.on('errorMessage', this._handleErrorMessage.bind(this))
|
|
261
|
+
con.on('readyForQuery', this._handleReadyForQuery.bind(this))
|
|
262
|
+
con.on('notice', this._handleNotice.bind(this))
|
|
263
|
+
con.on('rowDescription', this._handleRowDescription.bind(this))
|
|
264
|
+
con.on('dataRow', this._handleDataRow.bind(this))
|
|
265
|
+
con.on('portalSuspended', this._handlePortalSuspended.bind(this))
|
|
266
|
+
con.on('emptyQuery', this._handleEmptyQuery.bind(this))
|
|
267
|
+
con.on('commandComplete', this._handleCommandComplete.bind(this))
|
|
268
|
+
con.on('parseComplete', this._handleParseComplete.bind(this))
|
|
269
|
+
con.on('copyInResponse', this._handleCopyInResponse.bind(this))
|
|
270
|
+
con.on('copyData', this._handleCopyData.bind(this))
|
|
271
|
+
con.on('notification', this._handleNotification.bind(this))
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
_getPassword(cb) {
|
|
275
|
+
const con = this.connection
|
|
276
|
+
if (typeof this.password === 'function') {
|
|
277
|
+
this._Promise
|
|
278
|
+
.resolve()
|
|
279
|
+
.then(() => this.password(this.connectionParameters))
|
|
280
|
+
.then((pass) => {
|
|
281
|
+
if (pass !== undefined) {
|
|
282
|
+
if (typeof pass !== 'string') {
|
|
283
|
+
con.emit('error', new TypeError('Password must be a string'))
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
this.connectionParameters.password = this.password = pass
|
|
287
|
+
} else {
|
|
288
|
+
this.connectionParameters.password = this.password = null
|
|
289
|
+
}
|
|
290
|
+
cb()
|
|
291
|
+
})
|
|
292
|
+
.catch((err) => {
|
|
293
|
+
con.emit('error', err)
|
|
294
|
+
})
|
|
295
|
+
} else if (this.password !== null) {
|
|
296
|
+
cb()
|
|
297
|
+
} else {
|
|
298
|
+
try {
|
|
299
|
+
const pgPass = require('pgpass')
|
|
300
|
+
pgPass(this.connectionParameters, (pass) => {
|
|
301
|
+
if (undefined !== pass) {
|
|
302
|
+
pgPassDeprecationNotice()
|
|
303
|
+
this.connectionParameters.password = this.password = pass
|
|
304
|
+
}
|
|
305
|
+
cb()
|
|
306
|
+
})
|
|
307
|
+
} catch (e) {
|
|
308
|
+
this.emit('error', e)
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
_handleAuthCleartextPassword(msg) {
|
|
314
|
+
this._getPassword(() => {
|
|
315
|
+
this.connection.password(this.password)
|
|
316
|
+
})
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
_handleAuthMD5Password(msg) {
|
|
320
|
+
this._getPassword(async () => {
|
|
321
|
+
try {
|
|
322
|
+
const hashedPassword = await crypto.postgresMd5PasswordHash(this.user, this.password, msg.salt)
|
|
323
|
+
this.connection.password(hashedPassword)
|
|
324
|
+
} catch (e) {
|
|
325
|
+
this.emit('error', e)
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
_handleAuthSASL(msg) {
|
|
331
|
+
this._getPassword(() => {
|
|
332
|
+
try {
|
|
333
|
+
this.saslSession = sasl.startSession(
|
|
334
|
+
msg.mechanisms,
|
|
335
|
+
this.enableChannelBinding && this.connection.stream,
|
|
336
|
+
this.scramMaxIterations
|
|
337
|
+
)
|
|
338
|
+
this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response)
|
|
339
|
+
} catch (err) {
|
|
340
|
+
this.connection.emit('error', err)
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async _handleAuthSASLContinue(msg) {
|
|
346
|
+
try {
|
|
347
|
+
await sasl.continueSession(
|
|
348
|
+
this.saslSession,
|
|
349
|
+
this.password,
|
|
350
|
+
msg.data,
|
|
351
|
+
this.enableChannelBinding && this.connection.stream
|
|
352
|
+
)
|
|
353
|
+
this.connection.sendSCRAMClientFinalMessage(this.saslSession.response)
|
|
354
|
+
} catch (err) {
|
|
355
|
+
this.connection.emit('error', err)
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
_handleAuthSASLFinal(msg) {
|
|
360
|
+
try {
|
|
361
|
+
sasl.finalizeSession(this.saslSession, msg.data)
|
|
362
|
+
this.saslSession = null
|
|
363
|
+
} catch (err) {
|
|
364
|
+
this.connection.emit('error', err)
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
_handleBackendKeyData(msg) {
|
|
369
|
+
this.processID = msg.processID
|
|
370
|
+
this.secretKey = msg.secretKey
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
_handleReadyForQuery(msg) {
|
|
374
|
+
if (this._connecting) {
|
|
375
|
+
this._connecting = false
|
|
376
|
+
this._connected = true
|
|
377
|
+
clearTimeout(this.connectionTimeoutHandle)
|
|
378
|
+
|
|
379
|
+
// process possible callback argument to Client#connect
|
|
380
|
+
if (this._connectionCallback) {
|
|
381
|
+
this._connectionCallback(null, this)
|
|
382
|
+
// remove callback for proper error handling
|
|
383
|
+
// after the connect event
|
|
384
|
+
this._connectionCallback = null
|
|
385
|
+
}
|
|
386
|
+
this.emit('connect')
|
|
387
|
+
}
|
|
388
|
+
const activeQuery = this._getActiveQuery()
|
|
389
|
+
this._activeQuery = null
|
|
390
|
+
this._txStatus = msg?.status ?? null
|
|
391
|
+
this.readyForQuery = true
|
|
392
|
+
if (activeQuery) {
|
|
393
|
+
activeQuery.handleReadyForQuery(this.connection)
|
|
394
|
+
}
|
|
395
|
+
this._pulseQueryQueue()
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// if we receive an error event or error message
|
|
399
|
+
// during the connection process we handle it here
|
|
400
|
+
_handleErrorWhileConnecting(err) {
|
|
401
|
+
if (this._connectionError) {
|
|
402
|
+
// TODO(bmc): this is swallowing errors - we shouldn't do this
|
|
403
|
+
return
|
|
404
|
+
}
|
|
405
|
+
this._connectionError = true
|
|
406
|
+
clearTimeout(this.connectionTimeoutHandle)
|
|
407
|
+
if (this._connectionCallback) {
|
|
408
|
+
return this._connectionCallback(err)
|
|
409
|
+
}
|
|
410
|
+
this.emit('error', err)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// if we're connected and we receive an error event from the connection
|
|
414
|
+
// this means the socket is dead - do a hard abort of all queries and emit
|
|
415
|
+
// the socket error on the client as well
|
|
416
|
+
_handleErrorEvent(err) {
|
|
417
|
+
if (this._connecting) {
|
|
418
|
+
return this._handleErrorWhileConnecting(err)
|
|
419
|
+
}
|
|
420
|
+
this._queryable = false
|
|
421
|
+
this._errorAllQueries(err)
|
|
422
|
+
this.emit('error', err)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// handle error messages from the postgres backend
|
|
426
|
+
_handleErrorMessage(msg) {
|
|
427
|
+
if (this._connecting) {
|
|
428
|
+
return this._handleErrorWhileConnecting(msg)
|
|
429
|
+
}
|
|
430
|
+
const activeQuery = this._getActiveQuery()
|
|
431
|
+
|
|
432
|
+
if (!activeQuery) {
|
|
433
|
+
this._handleErrorEvent(msg)
|
|
434
|
+
return
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
this._activeQuery = null
|
|
438
|
+
if (activeQuery.name) {
|
|
439
|
+
delete this.connection.submittedNamedStatements[activeQuery.name]
|
|
440
|
+
}
|
|
441
|
+
activeQuery.handleError(msg, this.connection)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
_handleRowDescription(msg) {
|
|
445
|
+
const activeQuery = this._getActiveQuery()
|
|
446
|
+
if (activeQuery == null) {
|
|
447
|
+
const error = new Error('Received unexpected rowDescription message from backend.')
|
|
448
|
+
this._handleErrorEvent(error)
|
|
449
|
+
return
|
|
450
|
+
}
|
|
451
|
+
// delegate rowDescription to active query
|
|
452
|
+
activeQuery.handleRowDescription(msg)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
_handleDataRow(msg) {
|
|
456
|
+
const activeQuery = this._getActiveQuery()
|
|
457
|
+
if (activeQuery == null) {
|
|
458
|
+
const error = new Error('Received unexpected dataRow message from backend.')
|
|
459
|
+
this._handleErrorEvent(error)
|
|
460
|
+
return
|
|
461
|
+
}
|
|
462
|
+
// delegate dataRow to active query
|
|
463
|
+
activeQuery.handleDataRow(msg)
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
_handlePortalSuspended(msg) {
|
|
467
|
+
const activeQuery = this._getActiveQuery()
|
|
468
|
+
if (activeQuery == null) {
|
|
469
|
+
const error = new Error('Received unexpected portalSuspended message from backend.')
|
|
470
|
+
this._handleErrorEvent(error)
|
|
471
|
+
return
|
|
472
|
+
}
|
|
473
|
+
// delegate portalSuspended to active query
|
|
474
|
+
activeQuery.handlePortalSuspended(this.connection)
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
_handleEmptyQuery(msg) {
|
|
478
|
+
const activeQuery = this._getActiveQuery()
|
|
479
|
+
if (activeQuery == null) {
|
|
480
|
+
const error = new Error('Received unexpected emptyQuery message from backend.')
|
|
481
|
+
this._handleErrorEvent(error)
|
|
482
|
+
return
|
|
483
|
+
}
|
|
484
|
+
// delegate emptyQuery to active query
|
|
485
|
+
activeQuery.handleEmptyQuery(this.connection)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
_handleCommandComplete(msg) {
|
|
489
|
+
const activeQuery = this._getActiveQuery()
|
|
490
|
+
if (activeQuery == null) {
|
|
491
|
+
const error = new Error('Received unexpected commandComplete message from backend.')
|
|
492
|
+
this._handleErrorEvent(error)
|
|
493
|
+
return
|
|
494
|
+
}
|
|
495
|
+
// delegate commandComplete to active query
|
|
496
|
+
activeQuery.handleCommandComplete(msg, this.connection)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
_handleParseComplete() {
|
|
500
|
+
const activeQuery = this._getActiveQuery()
|
|
501
|
+
if (activeQuery == null) {
|
|
502
|
+
const error = new Error('Received unexpected parseComplete message from backend.')
|
|
503
|
+
this._handleErrorEvent(error)
|
|
504
|
+
return
|
|
505
|
+
}
|
|
506
|
+
// if a prepared statement has a name and properly parses
|
|
507
|
+
// we track that its already been executed so we don't parse
|
|
508
|
+
// it again on the same client
|
|
509
|
+
if (activeQuery.name) {
|
|
510
|
+
this.connection.parsedStatements[activeQuery.name] = activeQuery.text
|
|
511
|
+
delete this.connection.submittedNamedStatements[activeQuery.name]
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
_handleCopyInResponse(msg) {
|
|
516
|
+
const activeQuery = this._getActiveQuery()
|
|
517
|
+
if (activeQuery == null) {
|
|
518
|
+
const error = new Error('Received unexpected copyInResponse message from backend.')
|
|
519
|
+
this._handleErrorEvent(error)
|
|
520
|
+
return
|
|
521
|
+
}
|
|
522
|
+
activeQuery.handleCopyInResponse(this.connection)
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
_handleCopyData(msg) {
|
|
526
|
+
const activeQuery = this._getActiveQuery()
|
|
527
|
+
if (activeQuery == null) {
|
|
528
|
+
const error = new Error('Received unexpected copyData message from backend.')
|
|
529
|
+
this._handleErrorEvent(error)
|
|
530
|
+
return
|
|
531
|
+
}
|
|
532
|
+
activeQuery.handleCopyData(msg, this.connection)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
_handleNotification(msg) {
|
|
536
|
+
this.emit('notification', msg)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
_handleNotice(msg) {
|
|
540
|
+
this.emit('notice', msg)
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
getStartupConf() {
|
|
544
|
+
const params = this.connectionParameters
|
|
545
|
+
|
|
546
|
+
const data = {
|
|
547
|
+
user: params.user,
|
|
548
|
+
database: params.database,
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const appName = params.application_name || params.fallback_application_name
|
|
552
|
+
if (appName) {
|
|
553
|
+
data.application_name = appName
|
|
554
|
+
}
|
|
555
|
+
if (params.replication) {
|
|
556
|
+
data.replication = '' + params.replication
|
|
557
|
+
}
|
|
558
|
+
if (params.statement_timeout) {
|
|
559
|
+
data.statement_timeout = String(parseInt(params.statement_timeout, 10))
|
|
560
|
+
}
|
|
561
|
+
if (params.lock_timeout) {
|
|
562
|
+
data.lock_timeout = String(parseInt(params.lock_timeout, 10))
|
|
563
|
+
}
|
|
564
|
+
if (params.idle_in_transaction_session_timeout) {
|
|
565
|
+
data.idle_in_transaction_session_timeout = String(parseInt(params.idle_in_transaction_session_timeout, 10))
|
|
566
|
+
}
|
|
567
|
+
if (params.options) {
|
|
568
|
+
data.options = params.options
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return data
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
cancel(client, query) {
|
|
575
|
+
if (client.activeQuery === query) {
|
|
576
|
+
const con = this.connection
|
|
577
|
+
|
|
578
|
+
if (this.host && this.host.indexOf('/') === 0) {
|
|
579
|
+
con.connect(this.host + '/.s.PGSQL.' + this.port)
|
|
580
|
+
} else {
|
|
581
|
+
con.connect(this.port, this.host)
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// once connection is established send cancel message
|
|
585
|
+
con.on('connect', function () {
|
|
586
|
+
con.cancel(client.processID, client.secretKey)
|
|
587
|
+
})
|
|
588
|
+
} else if (client._queryQueue.indexOf(query) !== -1) {
|
|
589
|
+
client._queryQueue.splice(client._queryQueue.indexOf(query), 1)
|
|
590
|
+
} else if (client._sentQueryQueue.indexOf(query) !== -1) {
|
|
591
|
+
// Query already sent on wire — can't remove it without corrupting the
|
|
592
|
+
// pipeline. No-op the callback so the result is silently discarded.
|
|
593
|
+
query.callback = () => {}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
setTypeParser(oid, format, parseFn) {
|
|
598
|
+
return this._types.setTypeParser(oid, format, parseFn)
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
getTypeParser(oid, format) {
|
|
602
|
+
return this._types.getTypeParser(oid, format)
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// escapeIdentifier and escapeLiteral moved to utility functions & exported
|
|
606
|
+
// on PG
|
|
607
|
+
// re-exported here for backwards compatibility
|
|
608
|
+
escapeIdentifier(str) {
|
|
609
|
+
return utils.escapeIdentifier(str)
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
escapeLiteral(str) {
|
|
613
|
+
return utils.escapeLiteral(str)
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
_pulseQueryQueue() {
|
|
617
|
+
if (this.pipeline) {
|
|
618
|
+
this._pulsePipelinedQueryQueue()
|
|
619
|
+
return
|
|
620
|
+
}
|
|
621
|
+
if (this.readyForQuery === true) {
|
|
622
|
+
this._activeQuery = this._queryQueue.shift()
|
|
623
|
+
const activeQuery = this._getActiveQuery()
|
|
624
|
+
if (activeQuery) {
|
|
625
|
+
this.readyForQuery = false
|
|
626
|
+
this.hasExecuted = true
|
|
627
|
+
|
|
628
|
+
const queryError = activeQuery.submit(this.connection)
|
|
629
|
+
if (queryError) {
|
|
630
|
+
process.nextTick(() => {
|
|
631
|
+
activeQuery.handleError(queryError, this.connection)
|
|
632
|
+
this.readyForQuery = true
|
|
633
|
+
this._pulseQueryQueue()
|
|
634
|
+
})
|
|
635
|
+
}
|
|
636
|
+
} else if (this.hasExecuted) {
|
|
637
|
+
this._activeQuery = null
|
|
638
|
+
this.emit('drain')
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
_pulsePipelinedQueryQueue() {
|
|
644
|
+
if (!this._connected || !this._queryable) {
|
|
645
|
+
return
|
|
646
|
+
}
|
|
647
|
+
while (this._queryQueue.length > 0) {
|
|
648
|
+
const query = this._queryQueue.shift()
|
|
649
|
+
this.hasExecuted = true
|
|
650
|
+
const queryError = query.submit(this.connection)
|
|
651
|
+
if (queryError) {
|
|
652
|
+
process.nextTick(() => {
|
|
653
|
+
query.handleError(queryError, this.connection)
|
|
654
|
+
})
|
|
655
|
+
continue
|
|
656
|
+
}
|
|
657
|
+
this._sentQueryQueue.push(query)
|
|
658
|
+
}
|
|
659
|
+
if (this.readyForQuery && !this._activeQuery && this._sentQueryQueue.length > 0) {
|
|
660
|
+
this._activeQuery = this._sentQueryQueue.shift()
|
|
661
|
+
this.readyForQuery = false
|
|
662
|
+
}
|
|
663
|
+
if (!this._activeQuery && this._sentQueryQueue.length === 0 && this._queryQueue.length === 0 && this.hasExecuted) {
|
|
664
|
+
this.emit('drain')
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
query(config, values, callback) {
|
|
669
|
+
// can take in strings, config object or query object
|
|
670
|
+
let query
|
|
671
|
+
let result
|
|
672
|
+
|
|
673
|
+
if (config == null) {
|
|
674
|
+
throw new TypeError('Client was passed a null or undefined query')
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
if (typeof config.submit === 'function') {
|
|
678
|
+
result = query = config
|
|
679
|
+
if (!query.callback) {
|
|
680
|
+
if (typeof values === 'function') {
|
|
681
|
+
query.callback = values
|
|
682
|
+
} else if (callback) {
|
|
683
|
+
query.callback = callback
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
} else {
|
|
687
|
+
query = new Query(config, values, callback)
|
|
688
|
+
if (!query.callback) {
|
|
689
|
+
result = new this._Promise((resolve, reject) => {
|
|
690
|
+
query.callback = (err, res) => (err ? reject(err) : resolve(res))
|
|
691
|
+
}).catch((err) => {
|
|
692
|
+
// replace the stack trace that leads to `TCP.onStreamRead` with one that leads back to the
|
|
693
|
+
// application that created the query
|
|
694
|
+
Error.captureStackTrace(err)
|
|
695
|
+
throw err
|
|
696
|
+
})
|
|
697
|
+
} else if (typeof query.callback !== 'function') {
|
|
698
|
+
throw new TypeError('callback is not a function')
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
const readTimeout = config.query_timeout || this.connectionParameters.query_timeout
|
|
703
|
+
if (readTimeout) {
|
|
704
|
+
const queryCallback = query.callback || (() => {})
|
|
705
|
+
|
|
706
|
+
const readTimeoutTimer = setTimeout(() => {
|
|
707
|
+
const error = new Error('Query read timeout')
|
|
708
|
+
|
|
709
|
+
process.nextTick(() => {
|
|
710
|
+
query.handleError(error, this.connection)
|
|
711
|
+
})
|
|
712
|
+
|
|
713
|
+
queryCallback(error)
|
|
714
|
+
|
|
715
|
+
// we already returned an error,
|
|
716
|
+
// just do nothing if query completes
|
|
717
|
+
query.callback = () => {}
|
|
718
|
+
|
|
719
|
+
// Remove from queue (only safe if not yet sent)
|
|
720
|
+
const index = this._queryQueue.indexOf(query)
|
|
721
|
+
if (index > -1) {
|
|
722
|
+
this._queryQueue.splice(index, 1)
|
|
723
|
+
} else if (this.pipeline) {
|
|
724
|
+
// Query already sent — the pipeline is blocked until it completes.
|
|
725
|
+
// Destroy the connection to unblock all remaining pipelined queries.
|
|
726
|
+
this.connection.stream.destroy()
|
|
727
|
+
return
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
this._pulseQueryQueue()
|
|
731
|
+
}, readTimeout)
|
|
732
|
+
|
|
733
|
+
query.callback = (err, res) => {
|
|
734
|
+
clearTimeout(readTimeoutTimer)
|
|
735
|
+
queryCallback(err, res)
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (this.binary && !query.binary) {
|
|
740
|
+
query.binary = true
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
if (query._result && !query._result._types) {
|
|
744
|
+
query._result._types = this._types
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
// A query that keeps a portal open across round trips cannot share a pipelined connection: the
|
|
748
|
+
// queries written behind it are answered out of its portal, so rows land on the wrong query and
|
|
749
|
+
// the reads that follow fail with 'portal does not exist'. Refuse it instead of corrupting.
|
|
750
|
+
if (this.pipeline) {
|
|
751
|
+
const portalQuery =
|
|
752
|
+
typeof config.submit === 'function' && !(query instanceof Query)
|
|
753
|
+
? 'Custom query classes such as pg-cursor and pg-query-stream are'
|
|
754
|
+
: query.rows
|
|
755
|
+
? 'The `rows` option is'
|
|
756
|
+
: null
|
|
757
|
+
if (portalQuery) {
|
|
758
|
+
process.nextTick(() => {
|
|
759
|
+
query.handleError(new Error(`${portalQuery} not supported in pipeline mode`), this.connection)
|
|
760
|
+
})
|
|
761
|
+
return result
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
if (!this._queryable) {
|
|
766
|
+
process.nextTick(() => {
|
|
767
|
+
query.handleError(new Error('Client has encountered a connection error and is not queryable'), this.connection)
|
|
768
|
+
})
|
|
769
|
+
return result
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
if (this._ending) {
|
|
773
|
+
process.nextTick(() => {
|
|
774
|
+
query.handleError(new Error('Client was closed and is not queryable'), this.connection)
|
|
775
|
+
})
|
|
776
|
+
return result
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
if (this._queryQueue.length > 0 && !this.pipeline) {
|
|
780
|
+
queryQueueLengthDeprecationNotice()
|
|
781
|
+
}
|
|
782
|
+
this._queryQueue.push(query)
|
|
783
|
+
this._pulseQueryQueue()
|
|
784
|
+
return result
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
ref() {
|
|
788
|
+
this.connection.ref()
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
unref() {
|
|
792
|
+
this.connection.unref()
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
getTransactionStatus() {
|
|
796
|
+
return this._txStatus
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
end(cb) {
|
|
800
|
+
this._ending = true
|
|
801
|
+
|
|
802
|
+
// if we have never connected, then end is a noop, callback immediately
|
|
803
|
+
if (!this.connection._connecting || this._ended) {
|
|
804
|
+
if (cb) {
|
|
805
|
+
cb()
|
|
806
|
+
return
|
|
807
|
+
} else {
|
|
808
|
+
return this._Promise.resolve()
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
if (!this._queryable) {
|
|
813
|
+
// socket is dead — force close
|
|
814
|
+
this.connection.stream.destroy()
|
|
815
|
+
} else if (
|
|
816
|
+
this.pipeline &&
|
|
817
|
+
(this._getActiveQuery() || this._sentQueryQueue.length > 0 || this._queryQueue.length > 0)
|
|
818
|
+
) {
|
|
819
|
+
// pipelined queries are already on the wire (or queued to send) and will
|
|
820
|
+
// complete normally; wait for drain then do a graceful goodbye
|
|
821
|
+
this.once('drain', () => this.connection.end())
|
|
822
|
+
} else if (this._getActiveQuery()) {
|
|
823
|
+
// non-pipeline: a hung query could block end forever — force disconnect
|
|
824
|
+
this.connection.stream.destroy()
|
|
825
|
+
} else {
|
|
826
|
+
this.connection.end()
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
if (cb) {
|
|
830
|
+
this.connection.once('end', cb)
|
|
831
|
+
} else {
|
|
832
|
+
return new this._Promise((resolve) => {
|
|
833
|
+
this.connection.once('end', resolve)
|
|
834
|
+
})
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
get queryQueue() {
|
|
838
|
+
queryQueueDeprecationNotice()
|
|
839
|
+
return this._queryQueue
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// expose a Query constructor
|
|
844
|
+
Client.Query = Query
|
|
845
|
+
|
|
846
|
+
module.exports = Client
|