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.
Files changed (367) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +51 -2
  3. package/cordis.patch.yml +4 -0
  4. package/lib/client.js +381 -0
  5. package/lib/index.js +267 -0
  6. package/package.json +67 -3
  7. package/skill/SKILL.md +48 -0
  8. package/skill/tools/node_modules/.package-lock.json +163 -0
  9. package/skill/tools/node_modules/pg/LICENSE +21 -0
  10. package/skill/tools/node_modules/pg/README.md +96 -0
  11. package/skill/tools/node_modules/pg/esm/index.mjs +20 -0
  12. package/skill/tools/node_modules/pg/lib/client.js +846 -0
  13. package/skill/tools/node_modules/pg/lib/connection-parameters.js +184 -0
  14. package/skill/tools/node_modules/pg/lib/connection.js +250 -0
  15. package/skill/tools/node_modules/pg/lib/crypto/cert-signatures.js +122 -0
  16. package/skill/tools/node_modules/pg/lib/crypto/sasl.js +262 -0
  17. package/skill/tools/node_modules/pg/lib/crypto/utils.js +89 -0
  18. package/skill/tools/node_modules/pg/lib/defaults.js +94 -0
  19. package/skill/tools/node_modules/pg/lib/index.js +73 -0
  20. package/skill/tools/node_modules/pg/lib/native/client.js +428 -0
  21. package/skill/tools/node_modules/pg/lib/native/index.js +2 -0
  22. package/skill/tools/node_modules/pg/lib/native/query.js +167 -0
  23. package/skill/tools/node_modules/pg/lib/query.js +263 -0
  24. package/skill/tools/node_modules/pg/lib/result.js +109 -0
  25. package/skill/tools/node_modules/pg/lib/stream.js +83 -0
  26. package/skill/tools/node_modules/pg/lib/type-overrides.js +35 -0
  27. package/skill/tools/node_modules/pg/lib/utils.js +225 -0
  28. package/skill/tools/node_modules/pg/package.json +76 -0
  29. package/skill/tools/node_modules/pg-cloudflare/LICENSE +21 -0
  30. package/skill/tools/node_modules/pg-cloudflare/README.md +112 -0
  31. package/skill/tools/node_modules/pg-cloudflare/dist/empty.d.ts +2 -0
  32. package/skill/tools/node_modules/pg-cloudflare/dist/empty.js +6 -0
  33. package/skill/tools/node_modules/pg-cloudflare/dist/empty.js.map +1 -0
  34. package/skill/tools/node_modules/pg-cloudflare/dist/index.d.ts +29 -0
  35. package/skill/tools/node_modules/pg-cloudflare/dist/index.js +171 -0
  36. package/skill/tools/node_modules/pg-cloudflare/dist/index.js.map +1 -0
  37. package/skill/tools/node_modules/pg-cloudflare/esm/index.mjs +3 -0
  38. package/skill/tools/node_modules/pg-cloudflare/package.json +39 -0
  39. package/skill/tools/node_modules/pg-cloudflare/src/empty.ts +3 -0
  40. package/skill/tools/node_modules/pg-cloudflare/src/index.ts +187 -0
  41. package/skill/tools/node_modules/pg-cloudflare/src/types.d.ts +25 -0
  42. package/skill/tools/node_modules/pg-connection-string/LICENSE +21 -0
  43. package/skill/tools/node_modules/pg-connection-string/README.md +105 -0
  44. package/skill/tools/node_modules/pg-connection-string/esm/index.mjs +8 -0
  45. package/skill/tools/node_modules/pg-connection-string/index.d.ts +37 -0
  46. package/skill/tools/node_modules/pg-connection-string/index.js +237 -0
  47. package/skill/tools/node_modules/pg-connection-string/package.json +51 -0
  48. package/skill/tools/node_modules/pg-int8/LICENSE +13 -0
  49. package/skill/tools/node_modules/pg-int8/README.md +16 -0
  50. package/skill/tools/node_modules/pg-int8/index.js +100 -0
  51. package/skill/tools/node_modules/pg-int8/package.json +24 -0
  52. package/skill/tools/node_modules/pg-pool/LICENSE +21 -0
  53. package/skill/tools/node_modules/pg-pool/README.md +357 -0
  54. package/skill/tools/node_modules/pg-pool/esm/index.mjs +5 -0
  55. package/skill/tools/node_modules/pg-pool/index.js +517 -0
  56. package/skill/tools/node_modules/pg-pool/package.json +51 -0
  57. package/skill/tools/node_modules/pg-protocol/LICENSE +21 -0
  58. package/skill/tools/node_modules/pg-protocol/README.md +3 -0
  59. package/skill/tools/node_modules/pg-protocol/dist/b.d.ts +1 -0
  60. package/skill/tools/node_modules/pg-protocol/dist/b.js +23 -0
  61. package/skill/tools/node_modules/pg-protocol/dist/b.js.map +1 -0
  62. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.d.ts +14 -0
  63. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js +55 -0
  64. package/skill/tools/node_modules/pg-protocol/dist/buffer-reader.js.map +1 -0
  65. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.d.ts +21 -0
  66. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js +113 -0
  67. package/skill/tools/node_modules/pg-protocol/dist/buffer-writer.js.map +1 -0
  68. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.d.ts +1 -0
  69. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js +538 -0
  70. package/skill/tools/node_modules/pg-protocol/dist/inbound-parser.test.js.map +1 -0
  71. package/skill/tools/node_modules/pg-protocol/dist/index.d.ts +5 -0
  72. package/skill/tools/node_modules/pg-protocol/dist/index.js +15 -0
  73. package/skill/tools/node_modules/pg-protocol/dist/index.js.map +1 -0
  74. package/skill/tools/node_modules/pg-protocol/dist/messages.d.ts +161 -0
  75. package/skill/tools/node_modules/pg-protocol/dist/messages.js +160 -0
  76. package/skill/tools/node_modules/pg-protocol/dist/messages.js.map +1 -0
  77. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.d.ts +1 -0
  78. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js +325 -0
  79. package/skill/tools/node_modules/pg-protocol/dist/outbound-serializer.test.js.map +1 -0
  80. package/skill/tools/node_modules/pg-protocol/dist/parser.d.ts +22 -0
  81. package/skill/tools/node_modules/pg-protocol/dist/parser.js +325 -0
  82. package/skill/tools/node_modules/pg-protocol/dist/parser.js.map +1 -0
  83. package/skill/tools/node_modules/pg-protocol/dist/serializer.d.ts +42 -0
  84. package/skill/tools/node_modules/pg-protocol/dist/serializer.js +198 -0
  85. package/skill/tools/node_modules/pg-protocol/dist/serializer.js.map +1 -0
  86. package/skill/tools/node_modules/pg-protocol/esm/index.js +11 -0
  87. package/skill/tools/node_modules/pg-protocol/package.json +44 -0
  88. package/skill/tools/node_modules/pg-protocol/src/b.ts +25 -0
  89. package/skill/tools/node_modules/pg-protocol/src/buffer-reader.ts +58 -0
  90. package/skill/tools/node_modules/pg-protocol/src/buffer-writer.ts +120 -0
  91. package/skill/tools/node_modules/pg-protocol/src/inbound-parser.test.ts +585 -0
  92. package/skill/tools/node_modules/pg-protocol/src/index.ts +11 -0
  93. package/skill/tools/node_modules/pg-protocol/src/messages.ts +262 -0
  94. package/skill/tools/node_modules/pg-protocol/src/outbound-serializer.test.ts +356 -0
  95. package/skill/tools/node_modules/pg-protocol/src/parser.ts +414 -0
  96. package/skill/tools/node_modules/pg-protocol/src/serializer.ts +286 -0
  97. package/skill/tools/node_modules/pg-protocol/src/testing/buffer-list.ts +67 -0
  98. package/skill/tools/node_modules/pg-protocol/src/testing/test-buffers.ts +166 -0
  99. package/skill/tools/node_modules/pg-types/.travis.yml +7 -0
  100. package/skill/tools/node_modules/pg-types/Makefile +14 -0
  101. package/skill/tools/node_modules/pg-types/README.md +75 -0
  102. package/skill/tools/node_modules/pg-types/index.d.ts +137 -0
  103. package/skill/tools/node_modules/pg-types/index.js +47 -0
  104. package/skill/tools/node_modules/pg-types/index.test-d.ts +21 -0
  105. package/skill/tools/node_modules/pg-types/lib/arrayParser.js +11 -0
  106. package/skill/tools/node_modules/pg-types/lib/binaryParsers.js +257 -0
  107. package/skill/tools/node_modules/pg-types/lib/builtins.js +73 -0
  108. package/skill/tools/node_modules/pg-types/lib/textParsers.js +215 -0
  109. package/skill/tools/node_modules/pg-types/package.json +42 -0
  110. package/skill/tools/node_modules/pg-types/test/index.js +24 -0
  111. package/skill/tools/node_modules/pg-types/test/types.js +597 -0
  112. package/skill/tools/node_modules/pgpass/README.md +74 -0
  113. package/skill/tools/node_modules/pgpass/lib/helper.js +233 -0
  114. package/skill/tools/node_modules/pgpass/lib/index.js +23 -0
  115. package/skill/tools/node_modules/pgpass/package.json +41 -0
  116. package/skill/tools/node_modules/postgres-array/index.d.ts +4 -0
  117. package/skill/tools/node_modules/postgres-array/index.js +97 -0
  118. package/skill/tools/node_modules/postgres-array/license +21 -0
  119. package/skill/tools/node_modules/postgres-array/package.json +35 -0
  120. package/skill/tools/node_modules/postgres-array/readme.md +43 -0
  121. package/skill/tools/node_modules/postgres-bytea/index.js +33 -0
  122. package/skill/tools/node_modules/postgres-bytea/license +21 -0
  123. package/skill/tools/node_modules/postgres-bytea/package.json +34 -0
  124. package/skill/tools/node_modules/postgres-bytea/readme.md +34 -0
  125. package/skill/tools/node_modules/postgres-date/index.js +116 -0
  126. package/skill/tools/node_modules/postgres-date/license +21 -0
  127. package/skill/tools/node_modules/postgres-date/package.json +33 -0
  128. package/skill/tools/node_modules/postgres-date/readme.md +49 -0
  129. package/skill/tools/node_modules/postgres-interval/index.d.ts +20 -0
  130. package/skill/tools/node_modules/postgres-interval/index.js +125 -0
  131. package/skill/tools/node_modules/postgres-interval/license +21 -0
  132. package/skill/tools/node_modules/postgres-interval/package.json +36 -0
  133. package/skill/tools/node_modules/postgres-interval/readme.md +48 -0
  134. package/skill/tools/node_modules/split2/LICENSE +13 -0
  135. package/skill/tools/node_modules/split2/README.md +85 -0
  136. package/skill/tools/node_modules/split2/bench.js +27 -0
  137. package/skill/tools/node_modules/split2/index.js +141 -0
  138. package/skill/tools/node_modules/split2/package.json +39 -0
  139. package/skill/tools/node_modules/split2/test.js +409 -0
  140. package/skill/tools/node_modules/undici/LICENSE +21 -0
  141. package/skill/tools/node_modules/undici/README.md +828 -0
  142. package/skill/tools/node_modules/undici/docs/docs/api/Agent.md +291 -0
  143. package/skill/tools/node_modules/undici/docs/docs/api/BalancedPool.md +297 -0
  144. package/skill/tools/node_modules/undici/docs/docs/api/CacheStorage.md +188 -0
  145. package/skill/tools/node_modules/undici/docs/docs/api/CacheStore.md +375 -0
  146. package/skill/tools/node_modules/undici/docs/docs/api/Client.md +538 -0
  147. package/skill/tools/node_modules/undici/docs/docs/api/ClientStats.md +93 -0
  148. package/skill/tools/node_modules/undici/docs/docs/api/Connector.md +198 -0
  149. package/skill/tools/node_modules/undici/docs/docs/api/ContentType.md +97 -0
  150. package/skill/tools/node_modules/undici/docs/docs/api/Cookies.md +179 -0
  151. package/skill/tools/node_modules/undici/docs/docs/api/Debug.md +78 -0
  152. package/skill/tools/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +518 -0
  153. package/skill/tools/node_modules/undici/docs/docs/api/Dispatcher.md +842 -0
  154. package/skill/tools/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +171 -0
  155. package/skill/tools/node_modules/undici/docs/docs/api/Errors.md +624 -0
  156. package/skill/tools/node_modules/undici/docs/docs/api/EventSource.md +358 -0
  157. package/skill/tools/node_modules/undici/docs/docs/api/Fetch.md +721 -0
  158. package/skill/tools/node_modules/undici/docs/docs/api/GlobalInstallation.md +121 -0
  159. package/skill/tools/node_modules/undici/docs/docs/api/H2CClient.md +386 -0
  160. package/skill/tools/node_modules/undici/docs/docs/api/Interceptors.md +439 -0
  161. package/skill/tools/node_modules/undici/docs/docs/api/MockAgent.md +622 -0
  162. package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistory.md +371 -0
  163. package/skill/tools/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +206 -0
  164. package/skill/tools/node_modules/undici/docs/docs/api/MockClient.md +199 -0
  165. package/skill/tools/node_modules/undici/docs/docs/api/MockErrors.md +63 -0
  166. package/skill/tools/node_modules/undici/docs/docs/api/MockPool.md +618 -0
  167. package/skill/tools/node_modules/undici/docs/docs/api/Pool.md +278 -0
  168. package/skill/tools/node_modules/undici/docs/docs/api/PoolStats.md +141 -0
  169. package/skill/tools/node_modules/undici/docs/docs/api/ProxyAgent.md +248 -0
  170. package/skill/tools/node_modules/undici/docs/docs/api/RedirectHandler.md +279 -0
  171. package/skill/tools/node_modules/undici/docs/docs/api/RetryAgent.md +136 -0
  172. package/skill/tools/node_modules/undici/docs/docs/api/RetryHandler.md +200 -0
  173. package/skill/tools/node_modules/undici/docs/docs/api/RoundRobinPool.md +239 -0
  174. package/skill/tools/node_modules/undici/docs/docs/api/SnapshotAgent.md +361 -0
  175. package/skill/tools/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +256 -0
  176. package/skill/tools/node_modules/undici/docs/docs/api/Util.md +82 -0
  177. package/skill/tools/node_modules/undici/docs/docs/api/WebSocket.md +536 -0
  178. package/skill/tools/node_modules/undici/docs/docs/api/api-lifecycle.md +159 -0
  179. package/skill/tools/node_modules/undici/docs/docs/best-practices/client-certificate.md +66 -0
  180. package/skill/tools/node_modules/undici/docs/docs/best-practices/crawling.md +60 -0
  181. package/skill/tools/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +233 -0
  182. package/skill/tools/node_modules/undici/docs/docs/best-practices/mocking-request.md +192 -0
  183. package/skill/tools/node_modules/undici/docs/docs/best-practices/proxy.md +129 -0
  184. package/skill/tools/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +226 -0
  185. package/skill/tools/node_modules/undici/docs/docs/best-practices/writing-tests.md +65 -0
  186. package/skill/tools/node_modules/undici/docs/docs/getting-started.md +281 -0
  187. package/skill/tools/node_modules/undici/docs/docs/index.md +793 -0
  188. package/skill/tools/node_modules/undici/docs/docs/site.json +125 -0
  189. package/skill/tools/node_modules/undici/docs/docs/type-map.json +79 -0
  190. package/skill/tools/node_modules/undici/index-fetch.js +65 -0
  191. package/skill/tools/node_modules/undici/index.d.ts +3 -0
  192. package/skill/tools/node_modules/undici/index.js +236 -0
  193. package/skill/tools/node_modules/undici/lib/api/abort-signal.js +59 -0
  194. package/skill/tools/node_modules/undici/lib/api/api-connect.js +112 -0
  195. package/skill/tools/node_modules/undici/lib/api/api-pipeline.js +265 -0
  196. package/skill/tools/node_modules/undici/lib/api/api-request.js +244 -0
  197. package/skill/tools/node_modules/undici/lib/api/api-stream.js +270 -0
  198. package/skill/tools/node_modules/undici/lib/api/api-upgrade.js +121 -0
  199. package/skill/tools/node_modules/undici/lib/api/index.js +7 -0
  200. package/skill/tools/node_modules/undici/lib/api/readable.js +615 -0
  201. package/skill/tools/node_modules/undici/lib/cache/memory-cache-store.js +314 -0
  202. package/skill/tools/node_modules/undici/lib/cache/sqlite-cache-store.js +593 -0
  203. package/skill/tools/node_modules/undici/lib/core/connect.js +198 -0
  204. package/skill/tools/node_modules/undici/lib/core/constants.js +131 -0
  205. package/skill/tools/node_modules/undici/lib/core/diagnostics.js +227 -0
  206. package/skill/tools/node_modules/undici/lib/core/errors.js +534 -0
  207. package/skill/tools/node_modules/undici/lib/core/request.js +582 -0
  208. package/skill/tools/node_modules/undici/lib/core/socks5-client.js +422 -0
  209. package/skill/tools/node_modules/undici/lib/core/socks5-utils.js +212 -0
  210. package/skill/tools/node_modules/undici/lib/core/symbols.js +81 -0
  211. package/skill/tools/node_modules/undici/lib/core/tree.js +160 -0
  212. package/skill/tools/node_modules/undici/lib/core/util.js +1035 -0
  213. package/skill/tools/node_modules/undici/lib/dispatcher/agent.js +181 -0
  214. package/skill/tools/node_modules/undici/lib/dispatcher/balanced-pool.js +217 -0
  215. package/skill/tools/node_modules/undici/lib/dispatcher/client-h1.js +1846 -0
  216. package/skill/tools/node_modules/undici/lib/dispatcher/client-h2.js +1989 -0
  217. package/skill/tools/node_modules/undici/lib/dispatcher/client.js +749 -0
  218. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher-base.js +198 -0
  219. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher.js +58 -0
  220. package/skill/tools/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +127 -0
  221. package/skill/tools/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +190 -0
  222. package/skill/tools/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  223. package/skill/tools/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
  224. package/skill/tools/node_modules/undici/lib/dispatcher/parser-h1.js +1065 -0
  225. package/skill/tools/node_modules/undici/lib/dispatcher/pool-base.js +347 -0
  226. package/skill/tools/node_modules/undici/lib/dispatcher/pool.js +229 -0
  227. package/skill/tools/node_modules/undici/lib/dispatcher/proxy-agent.js +418 -0
  228. package/skill/tools/node_modules/undici/lib/dispatcher/retry-agent.js +48 -0
  229. package/skill/tools/node_modules/undici/lib/dispatcher/round-robin-pool.js +169 -0
  230. package/skill/tools/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +350 -0
  231. package/skill/tools/node_modules/undici/lib/encoding/index.js +33 -0
  232. package/skill/tools/node_modules/undici/lib/global.js +82 -0
  233. package/skill/tools/node_modules/undici/lib/handler/cache-handler.js +1222 -0
  234. package/skill/tools/node_modules/undici/lib/handler/cache-revalidation-handler.js +134 -0
  235. package/skill/tools/node_modules/undici/lib/handler/decorator-handler.js +76 -0
  236. package/skill/tools/node_modules/undici/lib/handler/deduplication-handler.js +540 -0
  237. package/skill/tools/node_modules/undici/lib/handler/redirect-handler.js +284 -0
  238. package/skill/tools/node_modules/undici/lib/handler/retry-handler.js +686 -0
  239. package/skill/tools/node_modules/undici/lib/interceptor/cache.js +771 -0
  240. package/skill/tools/node_modules/undici/lib/interceptor/decompress.js +574 -0
  241. package/skill/tools/node_modules/undici/lib/interceptor/deduplicate.js +118 -0
  242. package/skill/tools/node_modules/undici/lib/interceptor/dns.js +593 -0
  243. package/skill/tools/node_modules/undici/lib/interceptor/dump.js +99 -0
  244. package/skill/tools/node_modules/undici/lib/interceptor/redirect.js +21 -0
  245. package/skill/tools/node_modules/undici/lib/interceptor/response-error.js +139 -0
  246. package/skill/tools/node_modules/undici/lib/interceptor/retry.js +19 -0
  247. package/skill/tools/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
  248. package/skill/tools/node_modules/undici/lib/llhttp/constants.js +531 -0
  249. package/skill/tools/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  250. package/skill/tools/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  251. package/skill/tools/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
  252. package/skill/tools/node_modules/undici/lib/llhttp/utils.js +12 -0
  253. package/skill/tools/node_modules/undici/lib/milo/LICENSE.md +7 -0
  254. package/skill/tools/node_modules/undici/lib/milo/no-simd.js +1002 -0
  255. package/skill/tools/node_modules/undici/lib/milo/simd.js +1002 -0
  256. package/skill/tools/node_modules/undici/lib/mock/mock-agent.js +255 -0
  257. package/skill/tools/node_modules/undici/lib/mock/mock-call-history.js +248 -0
  258. package/skill/tools/node_modules/undici/lib/mock/mock-client.js +68 -0
  259. package/skill/tools/node_modules/undici/lib/mock/mock-errors.js +29 -0
  260. package/skill/tools/node_modules/undici/lib/mock/mock-interceptor.js +227 -0
  261. package/skill/tools/node_modules/undici/lib/mock/mock-pool.js +68 -0
  262. package/skill/tools/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  263. package/skill/tools/node_modules/undici/lib/mock/mock-utils.js +730 -0
  264. package/skill/tools/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  265. package/skill/tools/node_modules/undici/lib/mock/snapshot-agent.js +371 -0
  266. package/skill/tools/node_modules/undici/lib/mock/snapshot-recorder.js +624 -0
  267. package/skill/tools/node_modules/undici/lib/mock/snapshot-utils.js +159 -0
  268. package/skill/tools/node_modules/undici/lib/util/cache.js +764 -0
  269. package/skill/tools/node_modules/undici/lib/util/date.js +670 -0
  270. package/skill/tools/node_modules/undici/lib/util/runtime-features.js +93 -0
  271. package/skill/tools/node_modules/undici/lib/util/stats.js +32 -0
  272. package/skill/tools/node_modules/undici/lib/util/timers.js +425 -0
  273. package/skill/tools/node_modules/undici/lib/web/cache/cache.js +871 -0
  274. package/skill/tools/node_modules/undici/lib/web/cache/cachestorage.js +158 -0
  275. package/skill/tools/node_modules/undici/lib/web/cache/util.js +45 -0
  276. package/skill/tools/node_modules/undici/lib/web/cookies/constants.js +12 -0
  277. package/skill/tools/node_modules/undici/lib/web/cookies/index.js +211 -0
  278. package/skill/tools/node_modules/undici/lib/web/cookies/parse.js +318 -0
  279. package/skill/tools/node_modules/undici/lib/web/cookies/util.js +371 -0
  280. package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource-stream.js +575 -0
  281. package/skill/tools/node_modules/undici/lib/web/eventsource/eventsource.js +547 -0
  282. package/skill/tools/node_modules/undici/lib/web/eventsource/util.js +60 -0
  283. package/skill/tools/node_modules/undici/lib/web/fetch/LICENSE +21 -0
  284. package/skill/tools/node_modules/undici/lib/web/fetch/body.js +583 -0
  285. package/skill/tools/node_modules/undici/lib/web/fetch/constants.js +131 -0
  286. package/skill/tools/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  287. package/skill/tools/node_modules/undici/lib/web/fetch/formdata-parser.js +594 -0
  288. package/skill/tools/node_modules/undici/lib/web/fetch/formdata.js +272 -0
  289. package/skill/tools/node_modules/undici/lib/web/fetch/global.js +40 -0
  290. package/skill/tools/node_modules/undici/lib/web/fetch/headers.js +722 -0
  291. package/skill/tools/node_modules/undici/lib/web/fetch/index.js +2451 -0
  292. package/skill/tools/node_modules/undici/lib/web/fetch/request.js +1117 -0
  293. package/skill/tools/node_modules/undici/lib/web/fetch/response.js +638 -0
  294. package/skill/tools/node_modules/undici/lib/web/fetch/util.js +1530 -0
  295. package/skill/tools/node_modules/undici/lib/web/infra/index.js +244 -0
  296. package/skill/tools/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
  297. package/skill/tools/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
  298. package/skill/tools/node_modules/undici/lib/web/webidl/index.js +992 -0
  299. package/skill/tools/node_modules/undici/lib/web/websocket/connection.js +350 -0
  300. package/skill/tools/node_modules/undici/lib/web/websocket/constants.js +126 -0
  301. package/skill/tools/node_modules/undici/lib/web/websocket/events.js +348 -0
  302. package/skill/tools/node_modules/undici/lib/web/websocket/frame.js +127 -0
  303. package/skill/tools/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
  304. package/skill/tools/node_modules/undici/lib/web/websocket/receiver.js +530 -0
  305. package/skill/tools/node_modules/undici/lib/web/websocket/sender.js +109 -0
  306. package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketerror.js +107 -0
  307. package/skill/tools/node_modules/undici/lib/web/websocket/stream/websocketstream.js +511 -0
  308. package/skill/tools/node_modules/undici/lib/web/websocket/util.js +347 -0
  309. package/skill/tools/node_modules/undici/lib/web/websocket/websocket.js +783 -0
  310. package/skill/tools/node_modules/undici/package.json +154 -0
  311. package/skill/tools/node_modules/undici/scripts/strip-comments.js +10 -0
  312. package/skill/tools/node_modules/undici/types/README.md +6 -0
  313. package/skill/tools/node_modules/undici/types/agent.d.ts +30 -0
  314. package/skill/tools/node_modules/undici/types/api.d.ts +43 -0
  315. package/skill/tools/node_modules/undici/types/balanced-pool.d.ts +30 -0
  316. package/skill/tools/node_modules/undici/types/cache-interceptor.d.ts +189 -0
  317. package/skill/tools/node_modules/undici/types/cache.d.ts +36 -0
  318. package/skill/tools/node_modules/undici/types/client-stats.d.ts +15 -0
  319. package/skill/tools/node_modules/undici/types/client.d.ts +190 -0
  320. package/skill/tools/node_modules/undici/types/connector.d.ts +37 -0
  321. package/skill/tools/node_modules/undici/types/content-type.d.ts +21 -0
  322. package/skill/tools/node_modules/undici/types/cookies.d.ts +30 -0
  323. package/skill/tools/node_modules/undici/types/diagnostics-channel.d.ts +75 -0
  324. package/skill/tools/node_modules/undici/types/dispatcher.d.ts +253 -0
  325. package/skill/tools/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
  326. package/skill/tools/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
  327. package/skill/tools/node_modules/undici/types/errors.d.ts +202 -0
  328. package/skill/tools/node_modules/undici/types/eventsource.d.ts +66 -0
  329. package/skill/tools/node_modules/undici/types/fetch.d.ts +235 -0
  330. package/skill/tools/node_modules/undici/types/formdata.d.ts +108 -0
  331. package/skill/tools/node_modules/undici/types/global-dispatcher.d.ts +9 -0
  332. package/skill/tools/node_modules/undici/types/global-origin.d.ts +7 -0
  333. package/skill/tools/node_modules/undici/types/h2c-client.d.ts +73 -0
  334. package/skill/tools/node_modules/undici/types/handlers.d.ts +16 -0
  335. package/skill/tools/node_modules/undici/types/header.d.ts +165 -0
  336. package/skill/tools/node_modules/undici/types/index.d.ts +93 -0
  337. package/skill/tools/node_modules/undici/types/interceptors.d.ts +87 -0
  338. package/skill/tools/node_modules/undici/types/mock-agent.d.ts +69 -0
  339. package/skill/tools/node_modules/undici/types/mock-call-history.d.ts +111 -0
  340. package/skill/tools/node_modules/undici/types/mock-client.d.ts +27 -0
  341. package/skill/tools/node_modules/undici/types/mock-errors.d.ts +12 -0
  342. package/skill/tools/node_modules/undici/types/mock-interceptor.d.ts +98 -0
  343. package/skill/tools/node_modules/undici/types/mock-pool.d.ts +27 -0
  344. package/skill/tools/node_modules/undici/types/patch.d.ts +29 -0
  345. package/skill/tools/node_modules/undici/types/pool-stats.d.ts +19 -0
  346. package/skill/tools/node_modules/undici/types/pool.d.ts +39 -0
  347. package/skill/tools/node_modules/undici/types/proxy-agent.d.ts +36 -0
  348. package/skill/tools/node_modules/undici/types/readable.d.ts +68 -0
  349. package/skill/tools/node_modules/undici/types/retry-agent.d.ts +8 -0
  350. package/skill/tools/node_modules/undici/types/retry-handler.d.ts +125 -0
  351. package/skill/tools/node_modules/undici/types/round-robin-pool.d.ts +39 -0
  352. package/skill/tools/node_modules/undici/types/snapshot-agent.d.ts +113 -0
  353. package/skill/tools/node_modules/undici/types/socks5-proxy-agent.d.ts +27 -0
  354. package/skill/tools/node_modules/undici/types/util.d.ts +18 -0
  355. package/skill/tools/node_modules/undici/types/utility.d.ts +7 -0
  356. package/skill/tools/node_modules/undici/types/webidl.d.ts +352 -0
  357. package/skill/tools/node_modules/undici/types/websocket.d.ts +188 -0
  358. package/skill/tools/node_modules/xtend/.jshintrc +30 -0
  359. package/skill/tools/node_modules/xtend/LICENSE +20 -0
  360. package/skill/tools/node_modules/xtend/README.md +32 -0
  361. package/skill/tools/node_modules/xtend/immutable.js +19 -0
  362. package/skill/tools/node_modules/xtend/mutable.js +17 -0
  363. package/skill/tools/node_modules/xtend/package.json +55 -0
  364. package/skill/tools/node_modules/xtend/test.js +103 -0
  365. package/skill/tools/package-lock.json +172 -0
  366. package/skill/tools/package.json +9 -0
  367. package/skill/tools/transfer_core.js +414 -0
@@ -0,0 +1,263 @@
1
+ 'use strict'
2
+
3
+ const { EventEmitter } = require('events')
4
+
5
+ const Result = require('./result')
6
+ const utils = require('./utils')
7
+
8
+ class Query extends EventEmitter {
9
+ constructor(config, values, callback) {
10
+ super()
11
+
12
+ config = utils.normalizeQueryConfig(config, values, callback)
13
+
14
+ this.text = config.text
15
+ this.values = config.values
16
+ this.rows = config.rows
17
+ this.types = config.types
18
+ this.name = config.name
19
+ this.queryMode = config.queryMode
20
+ this.binary = config.binary
21
+ // use unique portal name each time
22
+ this.portal = config.portal || ''
23
+ this.callback = config.callback
24
+ this._rowMode = config.rowMode
25
+ if (process.domain && config.callback) {
26
+ this.callback = process.domain.bind(config.callback)
27
+ }
28
+ this._result = new Result(this._rowMode, this.types)
29
+
30
+ // potential for multiple results
31
+ this._results = this._result
32
+ this._canceledDueToError = false
33
+ }
34
+
35
+ requiresPreparation() {
36
+ if (this.queryMode === 'extended') {
37
+ return true
38
+ }
39
+
40
+ // named queries must always be prepared
41
+ if (this.name) {
42
+ return true
43
+ }
44
+ // always prepare if there are max number of rows expected per
45
+ // portal execution
46
+ if (this.rows) {
47
+ return true
48
+ }
49
+ // don't prepare empty text queries
50
+ if (!this.text) {
51
+ return false
52
+ }
53
+ // prepare if there are values
54
+ if (!this.values) {
55
+ return false
56
+ }
57
+ return this.values.length > 0
58
+ }
59
+
60
+ _checkForMultirow() {
61
+ // if we already have a result with a command property
62
+ // then we've already executed one query in a multi-statement simple query
63
+ // turn our results into an array of results
64
+ if (this._result.command) {
65
+ if (!Array.isArray(this._results)) {
66
+ this._results = [this._result]
67
+ }
68
+ this._result = new Result(this._rowMode, this._result._types)
69
+ this._results.push(this._result)
70
+ }
71
+ }
72
+
73
+ // associates row metadata from the supplied
74
+ // message with this query object
75
+ // metadata used when parsing row results
76
+ handleRowDescription(msg) {
77
+ this._checkForMultirow()
78
+ this._result.addFields(msg.fields)
79
+ this._accumulateRows = this.callback || !this.listeners('row').length
80
+ }
81
+
82
+ handleDataRow(msg) {
83
+ let row
84
+
85
+ if (this._canceledDueToError) {
86
+ return
87
+ }
88
+
89
+ try {
90
+ row = this._result.parseRow(msg.fields)
91
+ } catch (err) {
92
+ this._canceledDueToError = err
93
+ return
94
+ }
95
+
96
+ this.emit('row', row, this._result)
97
+ if (this._accumulateRows) {
98
+ this._result.addRow(row)
99
+ }
100
+ }
101
+
102
+ handleCommandComplete(msg, connection) {
103
+ this._checkForMultirow()
104
+ this._result.addCommandComplete(msg)
105
+ // need to sync after each command complete of a prepared statement
106
+ // if we were using a row count which results in multiple calls to _getRows
107
+ if (this.rows) {
108
+ connection.sync()
109
+ }
110
+ }
111
+
112
+ // if a named prepared statement is created with empty query text
113
+ // the backend will send an emptyQuery message but *not* a command complete message
114
+ // since we pipeline sync immediately after execute we don't need to do anything here
115
+ // unless we have rows specified, in which case we did not pipeline the initial sync call
116
+ handleEmptyQuery(connection) {
117
+ if (this.rows) {
118
+ connection.sync()
119
+ }
120
+ }
121
+
122
+ handleError(err, connection) {
123
+ // need to sync after error during a prepared statement
124
+ if (this._canceledDueToError) {
125
+ err = this._canceledDueToError
126
+ this._canceledDueToError = false
127
+ }
128
+ // if callback supplied do not emit error event as uncaught error
129
+ // events will bubble up to node process
130
+ if (this.callback) {
131
+ return this.callback(err)
132
+ }
133
+ this.emit('error', err)
134
+ }
135
+
136
+ handleReadyForQuery(con) {
137
+ if (this._canceledDueToError) {
138
+ return this.handleError(this._canceledDueToError, con)
139
+ }
140
+ if (this.callback) {
141
+ try {
142
+ this.callback(null, this._results)
143
+ } catch (err) {
144
+ process.nextTick(() => {
145
+ throw err
146
+ })
147
+ }
148
+ }
149
+ this.emit('end', this._results)
150
+ }
151
+
152
+ submit(connection) {
153
+ if (typeof this.text !== 'string' && typeof this.name !== 'string') {
154
+ return new Error('A query must have either text or a name. Supplying neither is unsupported.')
155
+ }
156
+ const previous = connection.parsedStatements[this.name] || connection.submittedNamedStatements[this.name]
157
+ if (this.text && previous && this.text !== previous) {
158
+ return new Error(`Prepared statements must be unique - '${this.name}' was used for a different statement`)
159
+ }
160
+ if (this.values && !Array.isArray(this.values)) {
161
+ return new Error('Query values must be an array')
162
+ }
163
+ if (this.requiresPreparation()) {
164
+ // If we're using the extended query protocol we fire off several separate commands
165
+ // to the backend. On some versions of node & some operating system versions
166
+ // the network stack writes each message separately instead of buffering them together
167
+ // causing the client & network to send more slowly. Corking & uncorking the stream
168
+ // allows node to buffer up the messages internally before sending them all off at once.
169
+ // note: we're checking for existence of cork/uncork because some versions of streams
170
+ // might not have this (cloudflare?)
171
+ connection.stream.cork && connection.stream.cork()
172
+ try {
173
+ this.prepare(connection)
174
+ } finally {
175
+ // while unlikely for this.prepare to throw, if it does & we don't uncork this stream
176
+ // this client becomes unresponsive, so put in finally block "just in case"
177
+ connection.stream.uncork && connection.stream.uncork()
178
+ }
179
+ } else {
180
+ connection.query(this.text)
181
+ }
182
+ return null
183
+ }
184
+
185
+ hasBeenParsed(connection) {
186
+ return (
187
+ this.name &&
188
+ (connection.parsedStatements[this.name] !== undefined ||
189
+ connection.submittedNamedStatements[this.name] !== undefined)
190
+ )
191
+ }
192
+
193
+ handlePortalSuspended(connection) {
194
+ this._getRows(connection, this.rows)
195
+ }
196
+
197
+ _getRows(connection, rows) {
198
+ connection.execute({
199
+ portal: this.portal,
200
+ rows: rows,
201
+ })
202
+ // if we're not reading pages of rows send the sync command
203
+ // to indicate the pipeline is finished
204
+ if (!rows) {
205
+ connection.sync()
206
+ } else {
207
+ // otherwise flush the call out to read more rows
208
+ connection.flush()
209
+ }
210
+ }
211
+
212
+ // http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
213
+ prepare(connection) {
214
+ // TODO refactor this poor encapsulation
215
+ if (!this.hasBeenParsed(connection)) {
216
+ connection.parse({
217
+ text: this.text,
218
+ name: this.name,
219
+ types: this.types,
220
+ })
221
+ if (this.name) {
222
+ connection.submittedNamedStatements[this.name] = this.text
223
+ }
224
+ }
225
+
226
+ // because we're mapping user supplied values to
227
+ // postgres wire protocol compatible values it could
228
+ // throw an exception, so try/catch this section
229
+ try {
230
+ connection.bind({
231
+ portal: this.portal,
232
+ statement: this.name,
233
+ values: this.values,
234
+ binary: this.binary,
235
+ valueMapper: utils.prepareValue,
236
+ })
237
+ } catch (err) {
238
+ // we should close parse to avoid leaking connections
239
+ connection.close({ type: 'S', name: this.name })
240
+ connection.sync()
241
+
242
+ this.handleError(err, connection)
243
+ return
244
+ }
245
+
246
+ connection.describe({
247
+ type: 'P',
248
+ name: this.portal || '',
249
+ })
250
+
251
+ this._getRows(connection, this.rows)
252
+ }
253
+
254
+ handleCopyInResponse(connection) {
255
+ connection.sendCopyFail('No source stream defined')
256
+ }
257
+
258
+ handleCopyData(msg, connection) {
259
+ // noop
260
+ }
261
+ }
262
+
263
+ module.exports = Query
@@ -0,0 +1,109 @@
1
+ 'use strict'
2
+
3
+ const types = require('pg-types')
4
+
5
+ const matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/
6
+
7
+ // result object returned from query
8
+ // in the 'end' event and also
9
+ // passed as second argument to provided callback
10
+ class Result {
11
+ constructor(rowMode, types) {
12
+ this.command = null
13
+ this.rowCount = null
14
+ this.oid = null
15
+ this.rows = []
16
+ this.fields = []
17
+ this._parsers = undefined
18
+ this._types = types
19
+ this.RowCtor = null
20
+ this.rowAsArray = rowMode === 'array'
21
+ if (this.rowAsArray) {
22
+ this.parseRow = this._parseRowAsArray
23
+ }
24
+ this._prebuiltEmptyResultObject = null
25
+ }
26
+
27
+ // adds a command complete message
28
+ addCommandComplete(msg) {
29
+ let match
30
+ if (msg.text) {
31
+ // pure javascript
32
+ match = matchRegexp.exec(msg.text)
33
+ } else {
34
+ // native bindings
35
+ match = matchRegexp.exec(msg.command)
36
+ }
37
+ if (match) {
38
+ this.command = match[1]
39
+ if (match[3]) {
40
+ // COMMAND OID ROWS
41
+ this.oid = parseInt(match[2], 10)
42
+ this.rowCount = parseInt(match[3], 10)
43
+ } else if (match[2]) {
44
+ // COMMAND ROWS
45
+ this.rowCount = parseInt(match[2], 10)
46
+ }
47
+ }
48
+ }
49
+
50
+ _parseRowAsArray(rowData) {
51
+ const row = new Array(rowData.length)
52
+ for (let i = 0, len = rowData.length; i < len; i++) {
53
+ const rawValue = rowData[i]
54
+ if (rawValue !== null) {
55
+ row[i] = this._parsers[i](rawValue)
56
+ } else {
57
+ row[i] = null
58
+ }
59
+ }
60
+ return row
61
+ }
62
+
63
+ parseRow(rowData) {
64
+ const row = { ...this._prebuiltEmptyResultObject }
65
+ for (let i = 0, len = rowData.length; i < len; i++) {
66
+ const rawValue = rowData[i]
67
+ const field = this.fields[i].name
68
+ if (rawValue !== null) {
69
+ const v = this.fields[i].format === 'binary' ? Buffer.from(rawValue) : rawValue
70
+ row[field] = this._parsers[i](v)
71
+ } else {
72
+ row[field] = null
73
+ }
74
+ }
75
+ return row
76
+ }
77
+
78
+ addRow(row) {
79
+ this.rows.push(row)
80
+ }
81
+
82
+ addFields(fieldDescriptions) {
83
+ // clears field definitions
84
+ // multiple query statements in 1 action can result in multiple sets
85
+ // of rowDescriptions...eg: 'select NOW(); select 1::int;'
86
+ // you need to reset the fields
87
+ this.fields = fieldDescriptions
88
+ if (this.fields.length) {
89
+ this._parsers = new Array(fieldDescriptions.length)
90
+ }
91
+
92
+ const row = Object.create(null)
93
+
94
+ for (let i = 0; i < fieldDescriptions.length; i++) {
95
+ const desc = fieldDescriptions[i]
96
+ row[desc.name] = null
97
+
98
+ if (this._types) {
99
+ this._parsers[i] = this._types.getTypeParser(desc.dataTypeID, desc.format || 'text')
100
+ } else {
101
+ this._parsers[i] = types.getTypeParser(desc.dataTypeID, desc.format || 'text')
102
+ }
103
+ }
104
+
105
+ this._prebuiltEmptyResultObject = { ...row }
106
+ }
107
+ }
108
+
109
+ module.exports = Result
@@ -0,0 +1,83 @@
1
+ const { getStream, getSecureStream } = getStreamFuncs()
2
+
3
+ module.exports = {
4
+ /**
5
+ * Get a socket stream compatible with the current runtime environment.
6
+ * @returns {Duplex}
7
+ */
8
+ getStream,
9
+ /**
10
+ * Get a TLS secured socket, compatible with the current environment,
11
+ * using the socket and other settings given in `options`.
12
+ * @returns {Duplex}
13
+ */
14
+ getSecureStream,
15
+ }
16
+
17
+ /**
18
+ * The stream functions that work in Node.js
19
+ */
20
+ function getNodejsStreamFuncs() {
21
+ function getStream(ssl) {
22
+ const net = require('net')
23
+ return new net.Socket()
24
+ }
25
+
26
+ function getSecureStream(options) {
27
+ const tls = require('tls')
28
+ return tls.connect(options)
29
+ }
30
+ return {
31
+ getStream,
32
+ getSecureStream,
33
+ }
34
+ }
35
+
36
+ /**
37
+ * The stream functions that work in Cloudflare Workers
38
+ */
39
+ function getCloudflareStreamFuncs() {
40
+ function getStream(ssl) {
41
+ const { CloudflareSocket } = require('pg-cloudflare')
42
+ return new CloudflareSocket(ssl)
43
+ }
44
+
45
+ function getSecureStream(options) {
46
+ options.socket.startTls(options)
47
+ return options.socket
48
+ }
49
+ return {
50
+ getStream,
51
+ getSecureStream,
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Are we running in a Cloudflare Worker?
57
+ *
58
+ * @returns true if the code is currently running inside a Cloudflare Worker.
59
+ */
60
+ function isCloudflareRuntime() {
61
+ // Since 2022-03-21 the `global_navigator` compatibility flag is on for Cloudflare Workers
62
+ // which means that `navigator.userAgent` will be defined.
63
+ // eslint-disable-next-line no-undef
64
+ if (typeof navigator === 'object' && navigator !== null && typeof navigator.userAgent === 'string') {
65
+ // eslint-disable-next-line no-undef
66
+ return navigator.userAgent === 'Cloudflare-Workers'
67
+ }
68
+ // In case `navigator` or `navigator.userAgent` is not defined then try a more sneaky approach
69
+ if (typeof Response === 'function') {
70
+ const resp = new Response(null, { cf: { thing: true } })
71
+ if (typeof resp.cf === 'object' && resp.cf !== null && resp.cf.thing) {
72
+ return true
73
+ }
74
+ }
75
+ return false
76
+ }
77
+
78
+ function getStreamFuncs() {
79
+ if (isCloudflareRuntime()) {
80
+ return getCloudflareStreamFuncs()
81
+ }
82
+ return getNodejsStreamFuncs()
83
+ }
@@ -0,0 +1,35 @@
1
+ 'use strict'
2
+
3
+ const types = require('pg-types')
4
+
5
+ function TypeOverrides(userTypes) {
6
+ this._types = userTypes || types
7
+ this.text = {}
8
+ this.binary = {}
9
+ }
10
+
11
+ TypeOverrides.prototype.getOverrides = function (format) {
12
+ switch (format) {
13
+ case 'text':
14
+ return this.text
15
+ case 'binary':
16
+ return this.binary
17
+ default:
18
+ return {}
19
+ }
20
+ }
21
+
22
+ TypeOverrides.prototype.setTypeParser = function (oid, format, parseFn) {
23
+ if (typeof format === 'function') {
24
+ parseFn = format
25
+ format = 'text'
26
+ }
27
+ this.getOverrides(format)[oid] = parseFn
28
+ }
29
+
30
+ TypeOverrides.prototype.getTypeParser = function (oid, format) {
31
+ format = format || 'text'
32
+ return this.getOverrides(format)[oid] || this._types.getTypeParser(oid, format)
33
+ }
34
+
35
+ module.exports = TypeOverrides
@@ -0,0 +1,225 @@
1
+ 'use strict'
2
+
3
+ const defaults = require('./defaults')
4
+ const nodeUtils = require('util')
5
+
6
+ const { isDate } = require('util/types')
7
+
8
+ const invalidDateDeprecationNotice = nodeUtils.deprecate(
9
+ () => {},
10
+ 'Sending an invalid date to Postgres is deprecated and will throw an error in the next major version of pg. Ensure any Date object passed as a query parameter is valid.',
11
+ 'PG_INVALID_DATE'
12
+ )
13
+
14
+ function escapeElement(elementRepresentation) {
15
+ const escaped = elementRepresentation.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
16
+
17
+ return '"' + escaped + '"'
18
+ }
19
+
20
+ // convert a JS array to a postgres array literal
21
+ // uses comma separator so won't work for types like box that use
22
+ // a different array separator.
23
+ function arrayString(val) {
24
+ let result = '{'
25
+ for (let i = 0; i < val.length; i++) {
26
+ if (i > 0) {
27
+ result += ','
28
+ }
29
+ let item = val[i]
30
+ if (item == null) {
31
+ result += 'NULL'
32
+ } else if (Array.isArray(item)) {
33
+ result += arrayString(item)
34
+ } else if (ArrayBuffer.isView(item)) {
35
+ if (!(item instanceof Buffer)) {
36
+ item = Buffer.from(item.buffer, item.byteOffset, item.byteLength)
37
+ }
38
+ result += '\\\\x' + item.toString('hex')
39
+ } else {
40
+ result += escapeElement(prepareValue(item))
41
+ }
42
+ }
43
+ result += '}'
44
+ return result
45
+ }
46
+
47
+ // converts values from javascript types
48
+ // to their 'raw' counterparts for use as a postgres parameter
49
+ // note: you can override this function to provide your own conversion mechanism
50
+ // for complex types, etc...
51
+ const prepareValue = function (val, seen) {
52
+ // null and undefined are both null for postgres
53
+ if (val == null) {
54
+ return null
55
+ }
56
+ if (typeof val === 'object') {
57
+ if (val instanceof Buffer) {
58
+ return val
59
+ }
60
+ if (ArrayBuffer.isView(val)) {
61
+ return Buffer.from(val.buffer, val.byteOffset, val.byteLength)
62
+ }
63
+ if (isDate(val)) {
64
+ if (isNaN(val.getTime())) {
65
+ invalidDateDeprecationNotice()
66
+ }
67
+ if (defaults.parseInputDatesAsUTC) {
68
+ return dateToStringUTC(val)
69
+ } else {
70
+ return dateToString(val)
71
+ }
72
+ }
73
+ if (Array.isArray(val)) {
74
+ return arrayString(val)
75
+ }
76
+
77
+ return prepareObject(val, seen)
78
+ }
79
+ return val.toString()
80
+ }
81
+
82
+ function prepareObject(val, seen) {
83
+ if (val && typeof val.toPostgres === 'function') {
84
+ seen = seen || []
85
+ if (seen.indexOf(val) !== -1) {
86
+ throw new Error('circular reference detected while preparing "' + val + '" for query')
87
+ }
88
+ seen.push(val)
89
+
90
+ return prepareValue(val.toPostgres(prepareValue), seen)
91
+ }
92
+ return JSON.stringify(val)
93
+ }
94
+
95
+ function dateToString(date) {
96
+ let offset = -date.getTimezoneOffset()
97
+
98
+ let year = date.getFullYear()
99
+ const isBCYear = year < 1
100
+ if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
101
+
102
+ let ret =
103
+ String(year).padStart(4, '0') +
104
+ '-' +
105
+ String(date.getMonth() + 1).padStart(2, '0') +
106
+ '-' +
107
+ String(date.getDate()).padStart(2, '0') +
108
+ 'T' +
109
+ String(date.getHours()).padStart(2, '0') +
110
+ ':' +
111
+ String(date.getMinutes()).padStart(2, '0') +
112
+ ':' +
113
+ String(date.getSeconds()).padStart(2, '0') +
114
+ '.' +
115
+ String(date.getMilliseconds()).padStart(3, '0')
116
+
117
+ if (offset < 0) {
118
+ ret += '-'
119
+ offset *= -1
120
+ } else {
121
+ ret += '+'
122
+ }
123
+
124
+ ret += String(Math.floor(offset / 60)).padStart(2, '0') + ':' + String(offset % 60).padStart(2, '0')
125
+ if (isBCYear) ret += ' BC'
126
+ return ret
127
+ }
128
+
129
+ function dateToStringUTC(date) {
130
+ let year = date.getUTCFullYear()
131
+ const isBCYear = year < 1
132
+ if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
133
+
134
+ let ret =
135
+ String(year).padStart(4, '0') +
136
+ '-' +
137
+ String(date.getUTCMonth() + 1).padStart(2, '0') +
138
+ '-' +
139
+ String(date.getUTCDate()).padStart(2, '0') +
140
+ 'T' +
141
+ String(date.getUTCHours()).padStart(2, '0') +
142
+ ':' +
143
+ String(date.getUTCMinutes()).padStart(2, '0') +
144
+ ':' +
145
+ String(date.getUTCSeconds()).padStart(2, '0') +
146
+ '.' +
147
+ String(date.getUTCMilliseconds()).padStart(3, '0')
148
+
149
+ ret += '+00:00'
150
+ if (isBCYear) ret += ' BC'
151
+ return ret
152
+ }
153
+
154
+ function normalizeQueryConfig(config, values, callback) {
155
+ // can take in strings or config objects
156
+ // Copy config so normalization does not mutate the caller's object.
157
+ config = typeof config === 'string' ? { text: config } : cloneQueryConfig(config)
158
+ if (values) {
159
+ if (typeof values === 'function') {
160
+ config.callback = values
161
+ } else {
162
+ config.values = values
163
+ }
164
+ }
165
+ if (callback) {
166
+ config.callback = callback
167
+ }
168
+ return config
169
+ }
170
+
171
+ function cloneQueryConfig(config) {
172
+ if (config == null) {
173
+ return config
174
+ }
175
+ return Object.defineProperties(Object.create(Object.getPrototypeOf(config)), Object.getOwnPropertyDescriptors(config))
176
+ }
177
+
178
+ // Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
179
+ const escapeIdentifier = function (str) {
180
+ return '"' + str.replace(/"/g, '""') + '"'
181
+ }
182
+
183
+ const escapeLiteral = function (str) {
184
+ let hasBackslash = false
185
+ let escaped = "'"
186
+
187
+ if (str == null) {
188
+ return "''"
189
+ }
190
+
191
+ if (typeof str !== 'string') {
192
+ return "''"
193
+ }
194
+
195
+ for (let i = 0; i < str.length; i++) {
196
+ const c = str[i]
197
+ if (c === "'") {
198
+ escaped += c + c
199
+ } else if (c === '\\') {
200
+ escaped += c + c
201
+ hasBackslash = true
202
+ } else {
203
+ escaped += c
204
+ }
205
+ }
206
+
207
+ escaped += "'"
208
+
209
+ if (hasBackslash === true) {
210
+ escaped = ' E' + escaped
211
+ }
212
+
213
+ return escaped
214
+ }
215
+
216
+ module.exports = {
217
+ prepareValue: function prepareValueWrapper(value) {
218
+ // this ensures that extra arguments do not get passed into prepareValue
219
+ // by accident, eg: from calling values.map(utils.prepareValue)
220
+ return prepareValue(value)
221
+ },
222
+ normalizeQueryConfig,
223
+ escapeIdentifier,
224
+ escapeLiteral,
225
+ }