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,428 @@
|
|
|
1
|
+
const nodeUtils = require('util')
|
|
2
|
+
// eslint-disable-next-line
|
|
3
|
+
var Native
|
|
4
|
+
// eslint-disable-next-line no-useless-catch
|
|
5
|
+
try {
|
|
6
|
+
// Wrap this `require()` in a try-catch to avoid upstream bundlers from complaining that this might not be available since it is an optional import
|
|
7
|
+
Native = require('pg-native')
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw e
|
|
10
|
+
}
|
|
11
|
+
const TypeOverrides = require('../type-overrides')
|
|
12
|
+
const EventEmitter = require('events').EventEmitter
|
|
13
|
+
const util = require('util')
|
|
14
|
+
const ConnectionParameters = require('../connection-parameters')
|
|
15
|
+
|
|
16
|
+
const NativeQuery = require('./query')
|
|
17
|
+
|
|
18
|
+
const queryQueueLengthDeprecationNotice = nodeUtils.deprecate(
|
|
19
|
+
() => {},
|
|
20
|
+
'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.'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const Client = (module.exports = function (config) {
|
|
24
|
+
EventEmitter.call(this)
|
|
25
|
+
config = config || {}
|
|
26
|
+
|
|
27
|
+
this._Promise = config.Promise || global.Promise
|
|
28
|
+
this._types = new TypeOverrides(config.types)
|
|
29
|
+
|
|
30
|
+
this.native = new Native({
|
|
31
|
+
types: this._types,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
this._queryQueue = []
|
|
35
|
+
this._ending = false
|
|
36
|
+
this._connecting = false
|
|
37
|
+
this._connected = false
|
|
38
|
+
this._queryable = true
|
|
39
|
+
this.pipeline = Boolean(config.pipeline)
|
|
40
|
+
this._pipelineInFlight = false
|
|
41
|
+
|
|
42
|
+
// keep these on the object for legacy reasons
|
|
43
|
+
// for the time being. TODO: deprecate all this jazz
|
|
44
|
+
const cp = (this.connectionParameters = new ConnectionParameters(config))
|
|
45
|
+
if (config.nativeConnectionString) cp.nativeConnectionString = config.nativeConnectionString
|
|
46
|
+
this.user = cp.user
|
|
47
|
+
|
|
48
|
+
// "hiding" the password so it doesn't show up in stack traces
|
|
49
|
+
// or if the client is console.logged
|
|
50
|
+
Object.defineProperty(this, 'password', {
|
|
51
|
+
configurable: true,
|
|
52
|
+
enumerable: false,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: cp.password,
|
|
55
|
+
})
|
|
56
|
+
this.database = cp.database
|
|
57
|
+
this.host = cp.host
|
|
58
|
+
this.port = cp.port
|
|
59
|
+
|
|
60
|
+
// a hash to hold named queries
|
|
61
|
+
this.namedQueries = {}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
Client.Query = NativeQuery
|
|
65
|
+
|
|
66
|
+
util.inherits(Client, EventEmitter)
|
|
67
|
+
|
|
68
|
+
Client.prototype._errorAllQueries = function (err) {
|
|
69
|
+
const enqueueError = (query) => {
|
|
70
|
+
process.nextTick(() => {
|
|
71
|
+
query.native = this.native
|
|
72
|
+
query.handleError(err)
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (this._hasActiveQuery()) {
|
|
77
|
+
enqueueError(this._activeQuery)
|
|
78
|
+
this._activeQuery = null
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this._queryQueue.forEach(enqueueError)
|
|
82
|
+
this._queryQueue.length = 0
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// connect to the backend
|
|
86
|
+
// pass an optional callback to be called once connected
|
|
87
|
+
// or with an error if there was a connection error
|
|
88
|
+
Client.prototype._connect = function (cb) {
|
|
89
|
+
const self = this
|
|
90
|
+
|
|
91
|
+
if (this._connecting) {
|
|
92
|
+
process.nextTick(() => cb(new Error('Client has already been connected. You cannot reuse a client.')))
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this._connecting = true
|
|
97
|
+
|
|
98
|
+
this.connectionParameters.getLibpqConnectionString(function (err, conString) {
|
|
99
|
+
if (self.connectionParameters.nativeConnectionString) conString = self.connectionParameters.nativeConnectionString
|
|
100
|
+
if (err) return cb(err)
|
|
101
|
+
self.native.connect(conString, function (err) {
|
|
102
|
+
if (err) {
|
|
103
|
+
self.native.end()
|
|
104
|
+
return cb(err)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// set internal states to connected
|
|
108
|
+
self._connected = true
|
|
109
|
+
|
|
110
|
+
// handle connection errors from the native layer
|
|
111
|
+
self.native.on('error', function (err) {
|
|
112
|
+
self._queryable = false
|
|
113
|
+
self._errorAllQueries(err)
|
|
114
|
+
self.emit('error', err)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
self.native.on('notification', function (msg) {
|
|
118
|
+
self.emit('notification', {
|
|
119
|
+
channel: msg.relname,
|
|
120
|
+
payload: msg.extra,
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// signal we are connected now
|
|
125
|
+
self.emit('connect')
|
|
126
|
+
self._pulseQueryQueue(true)
|
|
127
|
+
|
|
128
|
+
cb(null, this)
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Client.prototype.connect = function (callback) {
|
|
134
|
+
if (callback) {
|
|
135
|
+
this._connect(callback)
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return new this._Promise((resolve, reject) => {
|
|
140
|
+
this._connect((error) => {
|
|
141
|
+
if (error) {
|
|
142
|
+
reject(error)
|
|
143
|
+
} else {
|
|
144
|
+
resolve(this)
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// send a query to the server
|
|
151
|
+
// this method is highly overloaded to take
|
|
152
|
+
// 1) string query, optional array of parameters, optional function callback
|
|
153
|
+
// 2) object query with {
|
|
154
|
+
// string query
|
|
155
|
+
// optional array values,
|
|
156
|
+
// optional function callback instead of as a separate parameter
|
|
157
|
+
// optional string name to name & cache the query plan
|
|
158
|
+
// optional string rowMode = 'array' for an array of results
|
|
159
|
+
// }
|
|
160
|
+
Client.prototype.query = function (config, values, callback) {
|
|
161
|
+
let query
|
|
162
|
+
let result
|
|
163
|
+
let readTimeout
|
|
164
|
+
let readTimeoutTimer
|
|
165
|
+
let queryCallback
|
|
166
|
+
|
|
167
|
+
if (config === null || config === undefined) {
|
|
168
|
+
throw new TypeError('Client was passed a null or undefined query')
|
|
169
|
+
} else if (typeof config.submit === 'function') {
|
|
170
|
+
readTimeout = config.query_timeout || this.connectionParameters.query_timeout
|
|
171
|
+
result = query = config
|
|
172
|
+
// accept query(new Query(...), (err, res) => { }) style
|
|
173
|
+
if (typeof values === 'function') {
|
|
174
|
+
config.callback = values
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
readTimeout = config.query_timeout || this.connectionParameters.query_timeout
|
|
178
|
+
query = new NativeQuery(config, values, callback)
|
|
179
|
+
if (!query.callback) {
|
|
180
|
+
let resolveOut, rejectOut
|
|
181
|
+
result = new this._Promise((resolve, reject) => {
|
|
182
|
+
resolveOut = resolve
|
|
183
|
+
rejectOut = reject
|
|
184
|
+
}).catch((err) => {
|
|
185
|
+
Error.captureStackTrace(err)
|
|
186
|
+
throw err
|
|
187
|
+
})
|
|
188
|
+
query.callback = (err, res) => (err ? rejectOut(err) : resolveOut(res))
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (readTimeout) {
|
|
193
|
+
queryCallback = query.callback || (() => {})
|
|
194
|
+
|
|
195
|
+
readTimeoutTimer = setTimeout(() => {
|
|
196
|
+
const error = new Error('Query read timeout')
|
|
197
|
+
|
|
198
|
+
process.nextTick(() => {
|
|
199
|
+
query.handleError(error, this.connection)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
queryCallback(error)
|
|
203
|
+
|
|
204
|
+
// we already returned an error,
|
|
205
|
+
// just do nothing if query completes
|
|
206
|
+
query.callback = () => {}
|
|
207
|
+
|
|
208
|
+
// Remove from queue
|
|
209
|
+
const index = this._queryQueue.indexOf(query)
|
|
210
|
+
if (index > -1) {
|
|
211
|
+
this._queryQueue.splice(index, 1)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this._pulseQueryQueue()
|
|
215
|
+
}, readTimeout)
|
|
216
|
+
|
|
217
|
+
query.callback = (err, res) => {
|
|
218
|
+
clearTimeout(readTimeoutTimer)
|
|
219
|
+
queryCallback(err, res)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (!this._queryable) {
|
|
224
|
+
query.native = this.native
|
|
225
|
+
process.nextTick(() => {
|
|
226
|
+
query.handleError(new Error('Client has encountered a connection error and is not queryable'))
|
|
227
|
+
})
|
|
228
|
+
return result
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (this._ending) {
|
|
232
|
+
query.native = this.native
|
|
233
|
+
process.nextTick(() => {
|
|
234
|
+
query.handleError(new Error('Client was closed and is not queryable'))
|
|
235
|
+
})
|
|
236
|
+
return result
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if (this._queryQueue.length > 0 && !this.pipeline) {
|
|
240
|
+
queryQueueLengthDeprecationNotice()
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this._queryQueue.push(query)
|
|
244
|
+
this._pulseQueryQueue()
|
|
245
|
+
return result
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// disconnect from the backend server
|
|
249
|
+
Client.prototype.end = function (cb) {
|
|
250
|
+
const self = this
|
|
251
|
+
|
|
252
|
+
this._ending = true
|
|
253
|
+
|
|
254
|
+
if (this._connecting && !this._connected) {
|
|
255
|
+
this.once('connect', () => {
|
|
256
|
+
this.end(() => {})
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
let result
|
|
260
|
+
if (!cb) {
|
|
261
|
+
result = new this._Promise(function (resolve, reject) {
|
|
262
|
+
cb = (err) => (err ? reject(err) : resolve())
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const doEnd = function () {
|
|
267
|
+
self.native.end(function () {
|
|
268
|
+
self._connected = false
|
|
269
|
+
|
|
270
|
+
self._errorAllQueries(new Error('Connection terminated'))
|
|
271
|
+
|
|
272
|
+
process.nextTick(() => {
|
|
273
|
+
self.emit('end')
|
|
274
|
+
if (cb) cb()
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// If pipeline has in-flight or queued queries, wait for them to drain before closing
|
|
280
|
+
if (this.pipeline && (this._pipelineInFlight || this._queryQueue.length > 0)) {
|
|
281
|
+
this.once('drain', doEnd)
|
|
282
|
+
} else {
|
|
283
|
+
doEnd()
|
|
284
|
+
}
|
|
285
|
+
return result
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
Client.prototype._hasActiveQuery = function () {
|
|
289
|
+
return this._activeQuery && this._activeQuery.state !== 'error' && this._activeQuery.state !== 'end'
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
Client.prototype._pulseQueryQueue = function (initialConnection) {
|
|
293
|
+
if (!this._connected) {
|
|
294
|
+
return
|
|
295
|
+
}
|
|
296
|
+
if (this.pipeline && !initialConnection) {
|
|
297
|
+
return this._pulsePipelinedQueryQueue()
|
|
298
|
+
}
|
|
299
|
+
if (this._hasActiveQuery()) {
|
|
300
|
+
return
|
|
301
|
+
}
|
|
302
|
+
const query = this._queryQueue.shift()
|
|
303
|
+
if (!query) {
|
|
304
|
+
if (!initialConnection) {
|
|
305
|
+
this.emit('drain')
|
|
306
|
+
}
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
this._activeQuery = query
|
|
310
|
+
query.submit(this)
|
|
311
|
+
const self = this
|
|
312
|
+
query.once('_done', function () {
|
|
313
|
+
self._pulseQueryQueue()
|
|
314
|
+
})
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
Client.prototype._pulsePipelinedQueryQueue = function () {
|
|
318
|
+
if (!this._connected || this._pipelineInFlight) {
|
|
319
|
+
return
|
|
320
|
+
}
|
|
321
|
+
if (this._queryQueue.length === 0) {
|
|
322
|
+
if (this.hasExecuted) {
|
|
323
|
+
this.emit('drain')
|
|
324
|
+
}
|
|
325
|
+
return
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
this._pipelineInFlight = true
|
|
329
|
+
const self = this
|
|
330
|
+
const queries = []
|
|
331
|
+
const nativeQueries = []
|
|
332
|
+
const utils = require('../utils')
|
|
333
|
+
|
|
334
|
+
while (this._queryQueue.length > 0) {
|
|
335
|
+
const query = this._queryQueue.shift()
|
|
336
|
+
this.hasExecuted = true
|
|
337
|
+
nativeQueries.push(query)
|
|
338
|
+
|
|
339
|
+
const values = query.values ? query.values.map(utils.prepareValue) : null
|
|
340
|
+
const pipelineEntry = { text: query.text, name: query.name, arrayMode: query._arrayMode }
|
|
341
|
+
if (values) {
|
|
342
|
+
pipelineEntry.values = values
|
|
343
|
+
}
|
|
344
|
+
if (query.name && this.namedQueries[query.name]) {
|
|
345
|
+
pipelineEntry._alreadyPrepared = true
|
|
346
|
+
}
|
|
347
|
+
queries.push(pipelineEntry)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
this.native.pipeline(queries, function (err, results) {
|
|
351
|
+
self._pipelineInFlight = false
|
|
352
|
+
|
|
353
|
+
if (err) {
|
|
354
|
+
// Total pipeline failure. Per-query errors arrive on results[i].err, so reaching here means
|
|
355
|
+
// the connection itself is gone: mark it unusable and say so, the way the JS client and the
|
|
356
|
+
// non-pipelined native path both do. Without this the client looks healthy after losing its
|
|
357
|
+
// backend, a Pool never discards it, and everything routed to it fails one query at a time
|
|
358
|
+
// for the life of the process.
|
|
359
|
+
self._connected = false
|
|
360
|
+
self._queryable = false
|
|
361
|
+
for (let i = 0; i < nativeQueries.length; i++) {
|
|
362
|
+
const q = nativeQueries[i]
|
|
363
|
+
q.native = self.native
|
|
364
|
+
q.handleError(err)
|
|
365
|
+
}
|
|
366
|
+
self._errorAllQueries(err)
|
|
367
|
+
self.emit('error', err)
|
|
368
|
+
self.emit('end')
|
|
369
|
+
return
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// Deliver results to each query
|
|
373
|
+
for (let i = 0; i < nativeQueries.length; i++) {
|
|
374
|
+
const q = nativeQueries[i]
|
|
375
|
+
const r = results[i]
|
|
376
|
+
q.native = self.native
|
|
377
|
+
|
|
378
|
+
if (r.err) {
|
|
379
|
+
q.handleError(r.err)
|
|
380
|
+
} else {
|
|
381
|
+
// Track named queries on success
|
|
382
|
+
if (q.name) {
|
|
383
|
+
self.namedQueries[q.name] = q.text
|
|
384
|
+
}
|
|
385
|
+
q.state = 'end'
|
|
386
|
+
q.emit('end', r.result)
|
|
387
|
+
if (q.callback) {
|
|
388
|
+
q.callback(null, r.result)
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
setImmediate(function () {
|
|
393
|
+
q.emit('_done')
|
|
394
|
+
})
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Process any queries that arrived while we were reading
|
|
398
|
+
self._pulsePipelinedQueryQueue()
|
|
399
|
+
})
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// attempt to cancel an in-progress query
|
|
403
|
+
Client.prototype.cancel = function (query) {
|
|
404
|
+
if (this._activeQuery === query) {
|
|
405
|
+
this.native.cancel(function () {})
|
|
406
|
+
} else if (this._queryQueue.indexOf(query) !== -1) {
|
|
407
|
+
this._queryQueue.splice(this._queryQueue.indexOf(query), 1)
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
Client.prototype.ref = function () {}
|
|
412
|
+
Client.prototype.unref = function () {}
|
|
413
|
+
|
|
414
|
+
Client.prototype.setTypeParser = function (oid, format, parseFn) {
|
|
415
|
+
return this._types.setTypeParser(oid, format, parseFn)
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
Client.prototype.getTypeParser = function (oid, format) {
|
|
419
|
+
return this._types.getTypeParser(oid, format)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
Client.prototype.isConnected = function () {
|
|
423
|
+
return this._connected
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
Client.prototype.getTransactionStatus = function () {
|
|
427
|
+
return this.native.getTransactionStatus()
|
|
428
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const EventEmitter = require('events').EventEmitter
|
|
4
|
+
const util = require('util')
|
|
5
|
+
const utils = require('../utils')
|
|
6
|
+
|
|
7
|
+
const NativeQuery = (module.exports = function (config, values, callback) {
|
|
8
|
+
EventEmitter.call(this)
|
|
9
|
+
config = utils.normalizeQueryConfig(config, values, callback)
|
|
10
|
+
this.text = config.text
|
|
11
|
+
this.values = config.values
|
|
12
|
+
this.name = config.name
|
|
13
|
+
this.queryMode = config.queryMode
|
|
14
|
+
this.callback = config.callback
|
|
15
|
+
this.state = 'new'
|
|
16
|
+
this._arrayMode = config.rowMode === 'array'
|
|
17
|
+
|
|
18
|
+
// if the 'row' event is listened for
|
|
19
|
+
// then emit them as they come in
|
|
20
|
+
// without setting singleRowMode to true
|
|
21
|
+
// this has almost no meaning because libpq
|
|
22
|
+
// reads all rows into memory before returning any
|
|
23
|
+
this._emitRowEvents = false
|
|
24
|
+
this.on(
|
|
25
|
+
'newListener',
|
|
26
|
+
function (event) {
|
|
27
|
+
if (event === 'row') this._emitRowEvents = true
|
|
28
|
+
}.bind(this)
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
util.inherits(NativeQuery, EventEmitter)
|
|
33
|
+
|
|
34
|
+
const errorFieldMap = {
|
|
35
|
+
sqlState: 'code',
|
|
36
|
+
statementPosition: 'position',
|
|
37
|
+
messagePrimary: 'message',
|
|
38
|
+
messageDetail: 'detail',
|
|
39
|
+
messageHint: 'hint',
|
|
40
|
+
context: 'where',
|
|
41
|
+
schemaName: 'schema',
|
|
42
|
+
tableName: 'table',
|
|
43
|
+
columnName: 'column',
|
|
44
|
+
dataTypeName: 'dataType',
|
|
45
|
+
constraintName: 'constraint',
|
|
46
|
+
sourceFile: 'file',
|
|
47
|
+
sourceLine: 'line',
|
|
48
|
+
sourceFunction: 'routine',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
NativeQuery.prototype.handleError = function (err) {
|
|
52
|
+
// copy pq error fields into the error object
|
|
53
|
+
const fields = this.native && this.native.pq.resultErrorFields()
|
|
54
|
+
if (fields) {
|
|
55
|
+
for (const key in fields) {
|
|
56
|
+
const normalizedFieldName = errorFieldMap[key] || key
|
|
57
|
+
err[normalizedFieldName] = fields[key]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (this.callback) {
|
|
61
|
+
this.callback(err)
|
|
62
|
+
} else {
|
|
63
|
+
this.emit('error', err)
|
|
64
|
+
}
|
|
65
|
+
this.state = 'error'
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
NativeQuery.prototype.then = function (onSuccess, onFailure) {
|
|
69
|
+
return this._getPromise().then(onSuccess, onFailure)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
NativeQuery.prototype.catch = function (callback) {
|
|
73
|
+
return this._getPromise().catch(callback)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
NativeQuery.prototype._getPromise = function () {
|
|
77
|
+
if (this._promise) return this._promise
|
|
78
|
+
this._promise = new Promise(
|
|
79
|
+
function (resolve, reject) {
|
|
80
|
+
this._once('end', resolve)
|
|
81
|
+
this._once('error', reject)
|
|
82
|
+
}.bind(this)
|
|
83
|
+
)
|
|
84
|
+
return this._promise
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
NativeQuery.prototype.submit = function (client) {
|
|
88
|
+
this.state = 'running'
|
|
89
|
+
const self = this
|
|
90
|
+
this.native = client.native
|
|
91
|
+
client.native.arrayMode = this._arrayMode
|
|
92
|
+
|
|
93
|
+
let after = function (err, rows, results) {
|
|
94
|
+
client.native.arrayMode = false
|
|
95
|
+
setImmediate(function () {
|
|
96
|
+
self.emit('_done')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// handle possible query error
|
|
100
|
+
if (err) {
|
|
101
|
+
return self.handleError(err)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// emit row events for each row in the result
|
|
105
|
+
if (self._emitRowEvents) {
|
|
106
|
+
if (results.length > 1) {
|
|
107
|
+
rows.forEach((rowOfRows, i) => {
|
|
108
|
+
rowOfRows.forEach((row) => {
|
|
109
|
+
self.emit('row', row, results[i])
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
} else {
|
|
113
|
+
rows.forEach(function (row) {
|
|
114
|
+
self.emit('row', row, results)
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// handle successful result
|
|
120
|
+
self.state = 'end'
|
|
121
|
+
self.emit('end', results)
|
|
122
|
+
if (self.callback) {
|
|
123
|
+
self.callback(null, results)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (process.domain) {
|
|
128
|
+
after = process.domain.bind(after)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// named query
|
|
132
|
+
if (this.name) {
|
|
133
|
+
if (this.name.length > 63) {
|
|
134
|
+
console.error('Warning! Postgres only supports 63 characters for query names.')
|
|
135
|
+
console.error('You supplied %s (%s)', this.name, this.name.length)
|
|
136
|
+
console.error('This can cause conflicts and silent errors executing queries')
|
|
137
|
+
}
|
|
138
|
+
const values = (this.values || []).map(utils.prepareValue)
|
|
139
|
+
|
|
140
|
+
// check if the client has already executed this named query
|
|
141
|
+
// if so...just execute it again - skip the planning phase
|
|
142
|
+
if (client.namedQueries[this.name] !== undefined) {
|
|
143
|
+
if (this.text && client.namedQueries[this.name] !== this.text) {
|
|
144
|
+
const err = new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`)
|
|
145
|
+
return after(err)
|
|
146
|
+
}
|
|
147
|
+
return client.native.execute(this.name, values, after)
|
|
148
|
+
}
|
|
149
|
+
// plan the named query the first time, then execute it
|
|
150
|
+
return client.native.prepare(this.name, this.text, values.length, function (err) {
|
|
151
|
+
if (err) return after(err)
|
|
152
|
+
client.namedQueries[self.name] = self.text
|
|
153
|
+
return self.native.execute(self.name, values, after)
|
|
154
|
+
})
|
|
155
|
+
} else if (this.values) {
|
|
156
|
+
if (!Array.isArray(this.values)) {
|
|
157
|
+
const err = new Error('Query values must be an array')
|
|
158
|
+
return after(err)
|
|
159
|
+
}
|
|
160
|
+
const vals = this.values.map(utils.prepareValue)
|
|
161
|
+
client.native.query(this.text, vals, after)
|
|
162
|
+
} else if (this.queryMode === 'extended') {
|
|
163
|
+
client.native.query(this.text, [], after)
|
|
164
|
+
} else {
|
|
165
|
+
client.native.query(this.text, after)
|
|
166
|
+
}
|
|
167
|
+
}
|