@encore.dev/sdk 0.0.0 → 2.0.0-beta.10

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 (498) hide show
  1. package/LICENSE +362 -0
  2. package/README.md +245 -2
  3. package/app_meta.test.ts +154 -0
  4. package/app_meta.ts +226 -0
  5. package/config/config.test.ts +384 -0
  6. package/config/config.ts +236 -0
  7. package/config/mod.ts +15 -0
  8. package/config/secrets.ts +173 -0
  9. package/config/value.ts +239 -0
  10. package/cron/mod.test.ts +52 -0
  11. package/cron/mod.ts +62 -0
  12. package/dist/app_meta.d.ts +126 -0
  13. package/dist/app_meta.d.ts.map +1 -0
  14. package/dist/app_meta.js +67 -0
  15. package/dist/app_meta.js.map +1 -0
  16. package/dist/config/config.d.ts +135 -0
  17. package/dist/config/config.d.ts.map +1 -0
  18. package/dist/config/config.js +115 -0
  19. package/dist/config/config.js.map +1 -0
  20. package/dist/config/mod.d.ts +5 -0
  21. package/dist/config/mod.d.ts.map +1 -0
  22. package/dist/config/mod.js +3 -0
  23. package/dist/config/mod.js.map +1 -0
  24. package/dist/config/secrets.d.ts +124 -0
  25. package/dist/config/secrets.d.ts.map +1 -0
  26. package/dist/config/secrets.js +73 -0
  27. package/dist/config/secrets.js.map +1 -0
  28. package/dist/config/value.d.ts +54 -0
  29. package/dist/config/value.d.ts.map +1 -0
  30. package/dist/config/value.js +181 -0
  31. package/dist/config/value.js.map +1 -0
  32. package/dist/cron/mod.d.ts +57 -0
  33. package/dist/cron/mod.d.ts.map +1 -0
  34. package/dist/cron/mod.js +39 -0
  35. package/dist/cron/mod.js.map +1 -0
  36. package/dist/frontends/mod.d.ts +39 -0
  37. package/dist/frontends/mod.d.ts.map +1 -0
  38. package/dist/frontends/mod.js +47 -0
  39. package/dist/frontends/mod.js.map +1 -0
  40. package/dist/gateway/errors.d.ts +101 -0
  41. package/dist/gateway/errors.d.ts.map +1 -0
  42. package/dist/gateway/errors.js +146 -0
  43. package/dist/gateway/errors.js.map +1 -0
  44. package/dist/gateway/match.d.ts +127 -0
  45. package/dist/gateway/match.d.ts.map +1 -0
  46. package/dist/gateway/match.js +206 -0
  47. package/dist/gateway/match.js.map +1 -0
  48. package/dist/gateway/middleware.d.ts +108 -0
  49. package/dist/gateway/middleware.d.ts.map +1 -0
  50. package/dist/gateway/middleware.js +9 -0
  51. package/dist/gateway/middleware.js.map +1 -0
  52. package/dist/gateway/mod.d.ts +130 -0
  53. package/dist/gateway/mod.d.ts.map +1 -0
  54. package/dist/gateway/mod.js +188 -0
  55. package/dist/gateway/mod.js.map +1 -0
  56. package/dist/gateway/request.d.ts +304 -0
  57. package/dist/gateway/request.d.ts.map +1 -0
  58. package/dist/gateway/request.js +403 -0
  59. package/dist/gateway/request.js.map +1 -0
  60. package/dist/gateway/serve.d.ts +114 -0
  61. package/dist/gateway/serve.d.ts.map +1 -0
  62. package/dist/gateway/serve.js +510 -0
  63. package/dist/gateway/serve.js.map +1 -0
  64. package/dist/gateways/mod.d.ts +42 -0
  65. package/dist/gateways/mod.d.ts.map +1 -0
  66. package/dist/gateways/mod.js +55 -0
  67. package/dist/gateways/mod.js.map +1 -0
  68. package/dist/internal/clients/call.d.ts +171 -0
  69. package/dist/internal/clients/call.d.ts.map +1 -0
  70. package/dist/internal/clients/call.js +284 -0
  71. package/dist/internal/clients/call.js.map +1 -0
  72. package/dist/internal/clients/grpc.d.ts +108 -0
  73. package/dist/internal/clients/grpc.d.ts.map +1 -0
  74. package/dist/internal/clients/grpc.js +349 -0
  75. package/dist/internal/clients/grpc.js.map +1 -0
  76. package/dist/internal/clients/mod.d.ts +81 -0
  77. package/dist/internal/clients/mod.d.ts.map +1 -0
  78. package/dist/internal/clients/mod.js +237 -0
  79. package/dist/internal/clients/mod.js.map +1 -0
  80. package/dist/internal/fetch.d.ts +67 -0
  81. package/dist/internal/fetch.d.ts.map +1 -0
  82. package/dist/internal/fetch.js +264 -0
  83. package/dist/internal/fetch.js.map +1 -0
  84. package/dist/internal/otel/backend.d.ts +52 -0
  85. package/dist/internal/otel/backend.d.ts.map +1 -0
  86. package/dist/internal/otel/backend.js +2 -0
  87. package/dist/internal/otel/backend.js.map +1 -0
  88. package/dist/internal/otel/context.d.ts +11 -0
  89. package/dist/internal/otel/context.d.ts.map +1 -0
  90. package/dist/internal/otel/context.js +34 -0
  91. package/dist/internal/otel/context.js.map +1 -0
  92. package/dist/internal/otel/context_manager.d.ts +23 -0
  93. package/dist/internal/otel/context_manager.d.ts.map +1 -0
  94. package/dist/internal/otel/context_manager.js +120 -0
  95. package/dist/internal/otel/context_manager.js.map +1 -0
  96. package/dist/internal/otel/encode.d.ts +114 -0
  97. package/dist/internal/otel/encode.d.ts.map +1 -0
  98. package/dist/internal/otel/encode.js +290 -0
  99. package/dist/internal/otel/encode.js.map +1 -0
  100. package/dist/internal/otel/http.d.ts +11 -0
  101. package/dist/internal/otel/http.d.ts.map +1 -0
  102. package/dist/internal/otel/http.js +65 -0
  103. package/dist/internal/otel/http.js.map +1 -0
  104. package/dist/internal/otel/index.d.ts +9 -0
  105. package/dist/internal/otel/index.d.ts.map +1 -0
  106. package/dist/internal/otel/index.js +8 -0
  107. package/dist/internal/otel/index.js.map +1 -0
  108. package/dist/internal/otel/meter.d.ts +74 -0
  109. package/dist/internal/otel/meter.d.ts.map +1 -0
  110. package/dist/internal/otel/meter.js +265 -0
  111. package/dist/internal/otel/meter.js.map +1 -0
  112. package/dist/internal/otel/propagator.d.ts +15 -0
  113. package/dist/internal/otel/propagator.d.ts.map +1 -0
  114. package/dist/internal/otel/propagator.js +61 -0
  115. package/dist/internal/otel/propagator.js.map +1 -0
  116. package/dist/internal/otel/provider.d.ts +13 -0
  117. package/dist/internal/otel/provider.d.ts.map +1 -0
  118. package/dist/internal/otel/provider.js +22 -0
  119. package/dist/internal/otel/provider.js.map +1 -0
  120. package/dist/internal/otel/span.d.ts +75 -0
  121. package/dist/internal/otel/span.d.ts.map +1 -0
  122. package/dist/internal/otel/span.js +234 -0
  123. package/dist/internal/otel/span.js.map +1 -0
  124. package/dist/internal/otel/tracer.d.ts +16 -0
  125. package/dist/internal/otel/tracer.d.ts.map +1 -0
  126. package/dist/internal/otel/tracer.js +71 -0
  127. package/dist/internal/otel/tracer.js.map +1 -0
  128. package/dist/internal/reqfields.d.ts +170 -0
  129. package/dist/internal/reqfields.d.ts.map +1 -0
  130. package/dist/internal/reqfields.js +349 -0
  131. package/dist/internal/reqfields.js.map +1 -0
  132. package/dist/internal/runtime/meter.d.ts +12 -0
  133. package/dist/internal/runtime/meter.d.ts.map +1 -0
  134. package/dist/internal/runtime/meter.js +22 -0
  135. package/dist/internal/runtime/meter.js.map +1 -0
  136. package/dist/internal/runtime/mod.d.ts +18 -0
  137. package/dist/internal/runtime/mod.d.ts.map +1 -0
  138. package/dist/internal/runtime/mod.js +59 -0
  139. package/dist/internal/runtime/mod.js.map +1 -0
  140. package/dist/internal/runtime/napi/napi.cjs +308 -0
  141. package/dist/internal/runtime/napi/napi.d.cts +1251 -0
  142. package/dist/internal/runtime/shutdown.d.ts +91 -0
  143. package/dist/internal/runtime/shutdown.d.ts.map +1 -0
  144. package/dist/internal/runtime/shutdown.js +299 -0
  145. package/dist/internal/runtime/shutdown.js.map +1 -0
  146. package/dist/internal/testing/carry.d.ts +49 -0
  147. package/dist/internal/testing/carry.d.ts.map +1 -0
  148. package/dist/internal/testing/carry.js +77 -0
  149. package/dist/internal/testing/carry.js.map +1 -0
  150. package/dist/internal/testing/runner.d.ts +2 -0
  151. package/dist/internal/testing/runner.d.ts.map +1 -0
  152. package/dist/internal/testing/runner.js +10 -0
  153. package/dist/internal/testing/runner.js.map +1 -0
  154. package/dist/internal/testing/scope.d.ts +112 -0
  155. package/dist/internal/testing/scope.d.ts.map +1 -0
  156. package/dist/internal/testing/scope.js +346 -0
  157. package/dist/internal/testing/scope.js.map +1 -0
  158. package/dist/internal/testing/steps.d.ts +55 -0
  159. package/dist/internal/testing/steps.d.ts.map +1 -0
  160. package/dist/internal/testing/steps.js +295 -0
  161. package/dist/internal/testing/steps.js.map +1 -0
  162. package/dist/internal/testing/telemetry.d.ts +305 -0
  163. package/dist/internal/testing/telemetry.d.ts.map +1 -0
  164. package/dist/internal/testing/telemetry.js +188 -0
  165. package/dist/internal/testing/telemetry.js.map +1 -0
  166. package/dist/internal/utils/constraints.d.ts +10 -0
  167. package/dist/internal/utils/constraints.d.ts.map +1 -0
  168. package/dist/internal/utils/constraints.js +2 -0
  169. package/dist/internal/utils/constraints.js.map +1 -0
  170. package/dist/log/index.d.ts +40 -0
  171. package/dist/log/index.d.ts.map +1 -0
  172. package/dist/log/index.js +44 -0
  173. package/dist/log/index.js.map +1 -0
  174. package/dist/log/logger.d.ts +125 -0
  175. package/dist/log/logger.d.ts.map +1 -0
  176. package/dist/log/logger.js +203 -0
  177. package/dist/log/logger.js.map +1 -0
  178. package/dist/log/runtime.d.ts +21 -0
  179. package/dist/log/runtime.d.ts.map +1 -0
  180. package/dist/log/runtime.js +22 -0
  181. package/dist/log/runtime.js.map +1 -0
  182. package/dist/log/stderr.d.ts +10 -0
  183. package/dist/log/stderr.d.ts.map +1 -0
  184. package/dist/log/stderr.js +25 -0
  185. package/dist/log/stderr.js.map +1 -0
  186. package/dist/metrics/mod.d.ts +242 -0
  187. package/dist/metrics/mod.d.ts.map +1 -0
  188. package/dist/metrics/mod.js +353 -0
  189. package/dist/metrics/mod.js.map +1 -0
  190. package/dist/mod.d.ts +5 -0
  191. package/dist/mod.d.ts.map +1 -0
  192. package/dist/mod.js +3 -0
  193. package/dist/mod.js.map +1 -0
  194. package/dist/otel.d.ts +10 -0
  195. package/dist/otel.d.ts.map +1 -0
  196. package/dist/otel.js +13 -0
  197. package/dist/otel.js.map +1 -0
  198. package/dist/pubsub/encoding.d.ts +8 -0
  199. package/dist/pubsub/encoding.d.ts.map +1 -0
  200. package/dist/pubsub/encoding.js +18 -0
  201. package/dist/pubsub/encoding.js.map +1 -0
  202. package/dist/pubsub/mod.d.ts +7 -0
  203. package/dist/pubsub/mod.d.ts.map +1 -0
  204. package/dist/pubsub/mod.js +3 -0
  205. package/dist/pubsub/mod.js.map +1 -0
  206. package/dist/pubsub/refs.d.ts +20 -0
  207. package/dist/pubsub/refs.d.ts.map +1 -0
  208. package/dist/pubsub/refs.js +11 -0
  209. package/dist/pubsub/refs.js.map +1 -0
  210. package/dist/pubsub/subscription.d.ts +223 -0
  211. package/dist/pubsub/subscription.d.ts.map +1 -0
  212. package/dist/pubsub/subscription.js +121 -0
  213. package/dist/pubsub/subscription.js.map +1 -0
  214. package/dist/pubsub/topic.d.ts +218 -0
  215. package/dist/pubsub/topic.d.ts.map +1 -0
  216. package/dist/pubsub/topic.js +281 -0
  217. package/dist/pubsub/topic.js.map +1 -0
  218. package/dist/reqctx/mod.d.ts +174 -0
  219. package/dist/reqctx/mod.d.ts.map +1 -0
  220. package/dist/reqctx/mod.js +144 -0
  221. package/dist/reqctx/mod.js.map +1 -0
  222. package/dist/services/index.d.ts +171 -0
  223. package/dist/services/index.d.ts.map +1 -0
  224. package/dist/services/index.js +187 -0
  225. package/dist/services/index.js.map +1 -0
  226. package/dist/shutdown/mod.d.ts +60 -0
  227. package/dist/shutdown/mod.d.ts.map +1 -0
  228. package/dist/shutdown/mod.js +59 -0
  229. package/dist/shutdown/mod.js.map +1 -0
  230. package/dist/storage/clickhouse/database.d.ts +262 -0
  231. package/dist/storage/clickhouse/database.d.ts.map +1 -0
  232. package/dist/storage/clickhouse/database.js +362 -0
  233. package/dist/storage/clickhouse/database.js.map +1 -0
  234. package/dist/storage/clickhouse/errors.d.ts +67 -0
  235. package/dist/storage/clickhouse/errors.d.ts.map +1 -0
  236. package/dist/storage/clickhouse/errors.js +91 -0
  237. package/dist/storage/clickhouse/errors.js.map +1 -0
  238. package/dist/storage/clickhouse/mod.d.ts +31 -0
  239. package/dist/storage/clickhouse/mod.d.ts.map +1 -0
  240. package/dist/storage/clickhouse/mod.js +29 -0
  241. package/dist/storage/clickhouse/mod.js.map +1 -0
  242. package/dist/storage/objects/bucket.d.ts +522 -0
  243. package/dist/storage/objects/bucket.d.ts.map +1 -0
  244. package/dist/storage/objects/bucket.js +414 -0
  245. package/dist/storage/objects/bucket.js.map +1 -0
  246. package/dist/storage/objects/error.d.ts +24 -0
  247. package/dist/storage/objects/error.d.ts.map +1 -0
  248. package/dist/storage/objects/error.js +105 -0
  249. package/dist/storage/objects/error.js.map +1 -0
  250. package/dist/storage/objects/mod.d.ts +5 -0
  251. package/dist/storage/objects/mod.d.ts.map +1 -0
  252. package/dist/storage/objects/mod.js +3 -0
  253. package/dist/storage/objects/mod.js.map +1 -0
  254. package/dist/storage/objects/refs.d.ts +47 -0
  255. package/dist/storage/objects/refs.d.ts.map +1 -0
  256. package/dist/storage/objects/refs.js +26 -0
  257. package/dist/storage/objects/refs.js.map +1 -0
  258. package/dist/storage/postgres/database.d.ts +365 -0
  259. package/dist/storage/postgres/database.d.ts.map +1 -0
  260. package/dist/storage/postgres/database.js +480 -0
  261. package/dist/storage/postgres/database.js.map +1 -0
  262. package/dist/storage/postgres/errors.d.ts +120 -0
  263. package/dist/storage/postgres/errors.d.ts.map +1 -0
  264. package/dist/storage/postgres/errors.js +162 -0
  265. package/dist/storage/postgres/errors.js.map +1 -0
  266. package/dist/storage/postgres/interval.d.ts +44 -0
  267. package/dist/storage/postgres/interval.d.ts.map +1 -0
  268. package/dist/storage/postgres/interval.js +153 -0
  269. package/dist/storage/postgres/interval.js.map +1 -0
  270. package/dist/storage/postgres/mod.d.ts +5 -0
  271. package/dist/storage/postgres/mod.d.ts.map +1 -0
  272. package/dist/storage/postgres/mod.js +4 -0
  273. package/dist/storage/postgres/mod.js.map +1 -0
  274. package/dist/storage/redis/bitfield.d.ts +67 -0
  275. package/dist/storage/redis/bitfield.d.ts.map +1 -0
  276. package/dist/storage/redis/bitfield.js +114 -0
  277. package/dist/storage/redis/bitfield.js.map +1 -0
  278. package/dist/storage/redis/command.d.ts +45 -0
  279. package/dist/storage/redis/command.d.ts.map +1 -0
  280. package/dist/storage/redis/command.js +78 -0
  281. package/dist/storage/redis/command.js.map +1 -0
  282. package/dist/storage/redis/commands.d.ts +657 -0
  283. package/dist/storage/redis/commands.d.ts.map +1 -0
  284. package/dist/storage/redis/commands.js +759 -0
  285. package/dist/storage/redis/commands.js.map +1 -0
  286. package/dist/storage/redis/database.d.ts +336 -0
  287. package/dist/storage/redis/database.d.ts.map +1 -0
  288. package/dist/storage/redis/database.js +398 -0
  289. package/dist/storage/redis/database.js.map +1 -0
  290. package/dist/storage/redis/mod.d.ts +115 -0
  291. package/dist/storage/redis/mod.d.ts.map +1 -0
  292. package/dist/storage/redis/mod.js +109 -0
  293. package/dist/storage/redis/mod.js.map +1 -0
  294. package/dist/storage/redis/native.d.ts +16 -0
  295. package/dist/storage/redis/native.d.ts.map +1 -0
  296. package/dist/storage/redis/native.js +21 -0
  297. package/dist/storage/redis/native.js.map +1 -0
  298. package/dist/storage/redis/options.d.ts +90 -0
  299. package/dist/storage/redis/options.d.ts.map +1 -0
  300. package/dist/storage/redis/options.js +53 -0
  301. package/dist/storage/redis/options.js.map +1 -0
  302. package/dist/storage/redis/pubsub.d.ts +55 -0
  303. package/dist/storage/redis/pubsub.d.ts.map +1 -0
  304. package/dist/storage/redis/pubsub.js +88 -0
  305. package/dist/storage/redis/pubsub.js.map +1 -0
  306. package/dist/storage/redis/reply.d.ts +290 -0
  307. package/dist/storage/redis/reply.d.ts.map +1 -0
  308. package/dist/storage/redis/reply.js +611 -0
  309. package/dist/storage/redis/reply.js.map +1 -0
  310. package/dist/storage/redis/scan.d.ts +12 -0
  311. package/dist/storage/redis/scan.d.ts.map +1 -0
  312. package/dist/storage/redis/scan.js +76 -0
  313. package/dist/storage/redis/scan.js.map +1 -0
  314. package/dist/storage/redis/script.d.ts +92 -0
  315. package/dist/storage/redis/script.d.ts.map +1 -0
  316. package/dist/storage/redis/script.js +143 -0
  317. package/dist/storage/redis/script.js.map +1 -0
  318. package/dist/storage/redis/target.d.ts +49 -0
  319. package/dist/storage/redis/target.d.ts.map +1 -0
  320. package/dist/storage/redis/target.js +93 -0
  321. package/dist/storage/redis/target.js.map +1 -0
  322. package/dist/storage/redis/wire.d.ts +102 -0
  323. package/dist/storage/redis/wire.d.ts.map +1 -0
  324. package/dist/storage/redis/wire.js +309 -0
  325. package/dist/storage/redis/wire.js.map +1 -0
  326. package/dist/testing/bun.d.ts +8 -0
  327. package/dist/testing/bun.d.ts.map +1 -0
  328. package/dist/testing/bun.js +13 -0
  329. package/dist/testing/bun.js.map +1 -0
  330. package/dist/testing/jest.d.ts +8 -0
  331. package/dist/testing/jest.d.ts.map +1 -0
  332. package/dist/testing/jest.js +11 -0
  333. package/dist/testing/jest.js.map +1 -0
  334. package/dist/testing/mod.d.ts +183 -0
  335. package/dist/testing/mod.d.ts.map +1 -0
  336. package/dist/testing/mod.js +271 -0
  337. package/dist/testing/mod.js.map +1 -0
  338. package/dist/testing/node.d.ts +9 -0
  339. package/dist/testing/node.d.ts.map +1 -0
  340. package/dist/testing/node.js +12 -0
  341. package/dist/testing/node.js.map +1 -0
  342. package/dist/testing/playwright.d.ts +93 -0
  343. package/dist/testing/playwright.d.ts.map +1 -0
  344. package/dist/testing/playwright.js +164 -0
  345. package/dist/testing/playwright.js.map +1 -0
  346. package/dist/testing/puppeteer.d.ts +36 -0
  347. package/dist/testing/puppeteer.d.ts.map +1 -0
  348. package/dist/testing/puppeteer.js +70 -0
  349. package/dist/testing/puppeteer.js.map +1 -0
  350. package/dist/testing/system.d.ts +181 -0
  351. package/dist/testing/system.d.ts.map +1 -0
  352. package/dist/testing/system.js +255 -0
  353. package/dist/testing/system.js.map +1 -0
  354. package/dist/testing/vitest.d.ts +8 -0
  355. package/dist/testing/vitest.d.ts.map +1 -0
  356. package/dist/testing/vitest.js +13 -0
  357. package/dist/testing/vitest.js.map +1 -0
  358. package/dist/tracing/http.d.ts +11 -0
  359. package/dist/tracing/http.d.ts.map +1 -0
  360. package/dist/tracing/http.js +34 -0
  361. package/dist/tracing/http.js.map +1 -0
  362. package/dist/tracing/mod.d.ts +20 -0
  363. package/dist/tracing/mod.d.ts.map +1 -0
  364. package/dist/tracing/mod.js +47 -0
  365. package/dist/tracing/mod.js.map +1 -0
  366. package/dist/tracing/node.d.ts +10 -0
  367. package/dist/tracing/node.d.ts.map +1 -0
  368. package/dist/tracing/node.js +142 -0
  369. package/dist/tracing/node.js.map +1 -0
  370. package/dist/tsconfig.build.tsbuildinfo +1 -0
  371. package/dist/types/mod.d.ts +43 -0
  372. package/dist/types/mod.d.ts.map +1 -0
  373. package/dist/types/mod.js +65 -0
  374. package/dist/types/mod.js.map +1 -0
  375. package/frontends/mod.test.ts +51 -0
  376. package/frontends/mod.ts +50 -0
  377. package/gateway/errors.ts +172 -0
  378. package/gateway/gateway.e2e.test.ts +297 -0
  379. package/gateway/gateway.test.ts +891 -0
  380. package/gateway/match.ts +239 -0
  381. package/gateway/middleware.ts +134 -0
  382. package/gateway/mod.ts +211 -0
  383. package/gateway/request.ts +578 -0
  384. package/gateway/serve.ts +738 -0
  385. package/gateways/mod.ts +60 -0
  386. package/internal/clients/call.ts +418 -0
  387. package/internal/clients/grpc.test.ts +664 -0
  388. package/internal/clients/grpc.ts +485 -0
  389. package/internal/clients/mod.test.ts +481 -0
  390. package/internal/clients/mod.ts +337 -0
  391. package/internal/fetch.ts +305 -0
  392. package/internal/otel/backend.ts +60 -0
  393. package/internal/otel/context.test.ts +70 -0
  394. package/internal/otel/context.ts +48 -0
  395. package/internal/otel/context_manager.test.ts +154 -0
  396. package/internal/otel/context_manager.ts +141 -0
  397. package/internal/otel/encode.test.ts +266 -0
  398. package/internal/otel/encode.ts +408 -0
  399. package/internal/otel/http.ts +92 -0
  400. package/internal/otel/index.ts +14 -0
  401. package/internal/otel/meter.test.ts +231 -0
  402. package/internal/otel/meter.ts +332 -0
  403. package/internal/otel/propagator.test.ts +105 -0
  404. package/internal/otel/propagator.ts +68 -0
  405. package/internal/otel/provider.ts +26 -0
  406. package/internal/otel/span.ts +281 -0
  407. package/internal/otel/tracer.test.ts +380 -0
  408. package/internal/otel/tracer.ts +111 -0
  409. package/internal/reqfields.ts +423 -0
  410. package/internal/runtime/meter.ts +26 -0
  411. package/internal/runtime/mod.ts +81 -0
  412. package/internal/runtime/napi/napi.cjs +308 -0
  413. package/internal/runtime/napi/napi.d.cts +1251 -0
  414. package/internal/runtime/shutdown.test.ts +457 -0
  415. package/internal/runtime/shutdown.ts +350 -0
  416. package/internal/testing/carry.test.ts +242 -0
  417. package/internal/testing/carry.ts +101 -0
  418. package/internal/testing/runner.ts +10 -0
  419. package/internal/testing/scope.ts +384 -0
  420. package/internal/testing/steps.test.ts +152 -0
  421. package/internal/testing/steps.ts +342 -0
  422. package/internal/testing/telemetry.test.ts +210 -0
  423. package/internal/testing/telemetry.ts +466 -0
  424. package/internal/utils/constraints.ts +12 -0
  425. package/log/index.ts +107 -0
  426. package/log/logger.test.ts +194 -0
  427. package/log/logger.ts +308 -0
  428. package/log/runtime.test.ts +65 -0
  429. package/log/runtime.ts +40 -0
  430. package/log/stderr.test.ts +23 -0
  431. package/log/stderr.ts +24 -0
  432. package/metrics/export.test.ts +337 -0
  433. package/metrics/mod.test.ts +177 -0
  434. package/metrics/mod.ts +450 -0
  435. package/mod.ts +15 -0
  436. package/otel.test.ts +91 -0
  437. package/otel.ts +17 -0
  438. package/package.json +208 -5
  439. package/pubsub/encoding.ts +18 -0
  440. package/pubsub/mod.ts +26 -0
  441. package/pubsub/pubsub.test.ts +405 -0
  442. package/pubsub/refs.ts +38 -0
  443. package/pubsub/subscription.ts +359 -0
  444. package/pubsub/topic.test.ts +147 -0
  445. package/pubsub/topic.ts +431 -0
  446. package/reqctx/mod.ts +267 -0
  447. package/reqctx/reqctx.test.ts +216 -0
  448. package/scripts/postprocess-docs.test.ts +58 -0
  449. package/services/index.test.ts +370 -0
  450. package/services/index.ts +215 -0
  451. package/shutdown/mod.ts +78 -0
  452. package/storage/clickhouse/database.integration.test.ts +337 -0
  453. package/storage/clickhouse/database.test.ts +279 -0
  454. package/storage/clickhouse/database.ts +586 -0
  455. package/storage/clickhouse/errors.ts +130 -0
  456. package/storage/clickhouse/mod.ts +37 -0
  457. package/storage/objects/bucket.test.ts +573 -0
  458. package/storage/objects/bucket.ts +968 -0
  459. package/storage/objects/error.ts +121 -0
  460. package/storage/objects/mod.ts +50 -0
  461. package/storage/objects/refs.ts +117 -0
  462. package/storage/postgres/database.integration.test.ts +450 -0
  463. package/storage/postgres/database.test.ts +428 -0
  464. package/storage/postgres/database.ts +658 -0
  465. package/storage/postgres/errors.ts +186 -0
  466. package/storage/postgres/interval.test.ts +72 -0
  467. package/storage/postgres/interval.ts +170 -0
  468. package/storage/postgres/mod.ts +19 -0
  469. package/storage/redis/bitfield.ts +162 -0
  470. package/storage/redis/command.ts +84 -0
  471. package/storage/redis/commands.ts +1471 -0
  472. package/storage/redis/database.ts +520 -0
  473. package/storage/redis/mod.ts +171 -0
  474. package/storage/redis/native.ts +22 -0
  475. package/storage/redis/options.ts +119 -0
  476. package/storage/redis/pubsub.ts +92 -0
  477. package/storage/redis/redis.test.ts +866 -0
  478. package/storage/redis/reply.ts +780 -0
  479. package/storage/redis/runtime.test.ts +248 -0
  480. package/storage/redis/scan.ts +125 -0
  481. package/storage/redis/script.ts +162 -0
  482. package/storage/redis/target.ts +134 -0
  483. package/storage/redis/wire.ts +345 -0
  484. package/testing/bun.ts +13 -0
  485. package/testing/jest.ts +11 -0
  486. package/testing/mod.ts +393 -0
  487. package/testing/node.ts +12 -0
  488. package/testing/playwright.ts +247 -0
  489. package/testing/puppeteer.ts +101 -0
  490. package/testing/system.test.ts +108 -0
  491. package/testing/system.ts +373 -0
  492. package/testing/vitest.ts +13 -0
  493. package/tracing/http.ts +49 -0
  494. package/tracing/mod.ts +83 -0
  495. package/tracing/native.test.ts +272 -0
  496. package/tracing/node.ts +176 -0
  497. package/tracing/tracing.test.ts +953 -0
  498. package/types/mod.ts +92 -0
@@ -0,0 +1,162 @@
1
+ /**
2
+ * What kind of error a database reported, by its SQLSTATE: the cases an app
3
+ * most often handles. `other` is any other; the SQLSTATE says what.
4
+ *
5
+ * @example
6
+ * try {
7
+ * await db.exec`INSERT INTO users (email) VALUES (${email})`;
8
+ * } catch (err) {
9
+ * if (err instanceof DatabaseError && err.code === ErrorCode.UniqueViolation) {
10
+ * return {taken: true};
11
+ * }
12
+ * throw err;
13
+ * }
14
+ */
15
+ export const ErrorCode = {
16
+ /** None of the others; the SQLSTATE says what. */
17
+ Other: 'other',
18
+ /** A `NOT NULL` constraint would be violated (23502). */
19
+ NotNullViolation: 'not_null_violation',
20
+ /** A foreign key constraint would be violated (23503). */
21
+ ForeignKeyViolation: 'foreign_key_violation',
22
+ /** A unique constraint would be violated (23505). */
23
+ UniqueViolation: 'unique_violation',
24
+ /** A check constraint would be violated (23514). */
25
+ CheckViolation: 'check_violation',
26
+ /** An exclusion constraint would be violated (23P01). */
27
+ ExcludeViolation: 'exclude_violation',
28
+ /** A statement ran in a transaction an earlier statement failed (25P02). */
29
+ TransactionFailed: 'transaction_failed',
30
+ /** A deadlock was detected (40P01). */
31
+ DeadlockDetected: 'deadlock_detected',
32
+ /** The server refused a connection: it has as many as it allows (53300). */
33
+ TooManyConnections: 'too_many_connections',
34
+ /**
35
+ * A serializable or repeatable read transaction could not be serialized
36
+ * with a concurrent one (40001); retrying it may succeed.
37
+ */
38
+ SerializationFailure: 'serialization_failure',
39
+ /** A write in a read-only transaction (25006), such as one through a read handle. */
40
+ ReadOnlyTransaction: 'read_only_transaction',
41
+ /**
42
+ * A lock could not be taken without waiting (55P03), as with
43
+ * `FOR UPDATE NOWAIT` or `lock_timeout`.
44
+ */
45
+ LockNotAvailable: 'lock_not_available',
46
+ /** The statement was canceled (57014): by a timeout, or on request. */
47
+ QueryCanceled: 'query_canceled',
48
+ /** The database could not be reached, or the connection to it was lost (class 08). */
49
+ ConnectionFailure: 'connection_failure',
50
+ };
51
+ /**
52
+ * An error a database reported, or a failure to reach it.
53
+ *
54
+ * A failure to reach the database, which the server can't report, has
55
+ * `sqlState` `"08001"`, `code` `connection_failure`, the client's message
56
+ * and none of the optional fields. The caller's own mistakes, such as a
57
+ * parameter of the wrong type, and using a busy or closed handle, are plain
58
+ * errors instead.
59
+ *
60
+ * The optional fields are sent only for some errors (see
61
+ * https://www.postgresql.org/docs/current/protocol-error-fields.html); one
62
+ * being there says nothing about the others.
63
+ *
64
+ * Its `message` reads `ERROR: duplicate key value violates unique constraint
65
+ * "users_pkey" (Code unique_violation: SQLSTATE 23505)`. A subscription
66
+ * handler that throws one fails with the API error code of its SQLSTATE:
67
+ * `already_exists` for a unique violation.
68
+ */
69
+ export class DatabaseError extends Error {
70
+ /** What kind of error it is, by its SQLSTATE. */
71
+ code;
72
+ /** The SQLSTATE: `"23505"`. */
73
+ sqlState;
74
+ /** `ERROR`, `FATAL` or `PANIC`. */
75
+ severity;
76
+ /**
77
+ * A secondary message with more detail, such as the key a unique
78
+ * violation conflicted on.
79
+ */
80
+ detail;
81
+ /** A suggestion what to do about it. */
82
+ hint;
83
+ /** The schema of the object the error is about. */
84
+ schemaName;
85
+ /** The table the error is about. */
86
+ tableName;
87
+ /** The column the error is about. */
88
+ columnName;
89
+ /** The data type the error is about. */
90
+ dataTypeName;
91
+ /** The constraint the error is about; an index counts as one. */
92
+ constraintName;
93
+ constructor(fields) {
94
+ super(fields.message);
95
+ Object.defineProperty(this, 'name', {
96
+ value: 'DatabaseError',
97
+ enumerable: false,
98
+ configurable: true,
99
+ });
100
+ this.code = fields.code;
101
+ this.sqlState = fields.sqlState;
102
+ this.severity = fields.severity;
103
+ this.detail = fields.detail;
104
+ this.hint = fields.hint;
105
+ this.schemaName = fields.schemaName;
106
+ this.tableName = fields.tableName;
107
+ this.columnName = fields.columnName;
108
+ this.dataTypeName = fields.dataTypeName;
109
+ this.constraintName = fields.constraintName;
110
+ }
111
+ }
112
+ /** Thrown by `queryRow` and `rawQueryRow` for a query that returns more than one row. */
113
+ export class TooManyRowsError extends Error {
114
+ constructor() {
115
+ super('query returned more than one row');
116
+ Object.defineProperty(this, 'name', {
117
+ value: 'TooManyRowsError',
118
+ enumerable: false,
119
+ configurable: true,
120
+ });
121
+ }
122
+ }
123
+ /**
124
+ * Begins the message of an error the native module rejects with for a
125
+ * `DatabaseError`, which the rest of the message holds as JSON. The same as
126
+ * `DATABASE_ERROR_PREFIX` in `sdk/ts/src/postgres.rs`.
127
+ */
128
+ const DATABASE_ERROR_PREFIX = 'encore:postgres.DatabaseError:';
129
+ /**
130
+ * Awaits a native database call, throwing the error it rejects with as a
131
+ * `DatabaseError` if it is one.
132
+ */
133
+ export async function native(call) {
134
+ try {
135
+ return await call;
136
+ }
137
+ catch (err) {
138
+ throw fromNative(err);
139
+ }
140
+ }
141
+ /** `err`, a native database call's, as a `DatabaseError` if it is one. */
142
+ function fromNative(err) {
143
+ if (!(err instanceof Error) ||
144
+ !err.message.startsWith(DATABASE_ERROR_PREFIX)) {
145
+ return err;
146
+ }
147
+ const f = JSON.parse(err.message.slice(DATABASE_ERROR_PREFIX.length));
148
+ return new DatabaseError({
149
+ message: f.message,
150
+ code: f.code,
151
+ sqlState: f.sqlState,
152
+ severity: f.severity,
153
+ detail: f.detail ?? undefined,
154
+ hint: f.hint ?? undefined,
155
+ schemaName: f.schemaName ?? undefined,
156
+ tableName: f.tableName ?? undefined,
157
+ columnName: f.columnName ?? undefined,
158
+ dataTypeName: f.dataTypeName ?? undefined,
159
+ constraintName: f.constraintName ?? undefined,
160
+ });
161
+ }
162
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../storage/postgres/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,kDAAkD;IAClD,KAAK,EAAE,OAAO;IACd,yDAAyD;IACzD,gBAAgB,EAAE,oBAAoB;IACtC,0DAA0D;IAC1D,mBAAmB,EAAE,uBAAu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CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,OAAO,IAAI,aAAa,CAAC;QACvB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,SAAS;QAC7B,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,SAAS;QACzB,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,SAAS;QACrC,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,SAAS;QACnC,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,SAAS;QACrC,YAAY,EAAE,CAAC,CAAC,YAAY,IAAI,SAAS;QACzC,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,SAAS;KAC9C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * A Postgres `interval`, exactly as Postgres holds it: months, days and
3
+ * microseconds apart, since a month has no fixed number of days, nor a day
4
+ * (across a change of daylight saving time) of microseconds.
5
+ *
6
+ * An `interval` column comes back as a string in ISO 8601's form, as
7
+ * Postgres writes one (`'P1Y2M3DT4H5M6.5S'`, and `'P1M-2D'` where the parts'
8
+ * signs differ), which {@link Interval.parse} reads. A parameter of type
9
+ * `interval` takes an `Interval`, a `Temporal.Duration`, or a string in any
10
+ * form Postgres parses (`'1 day 02:00:00'`, `'P1DT2H'`, `'90 minutes'`).
11
+ *
12
+ * @example
13
+ * const row = await db.queryRow`SELECT ${new Interval(1, 0, 0)} + now() AS due`;
14
+ * const {d} = await db.queryRow`SELECT interval '1 day 2 hours' AS d`;
15
+ * Interval.parse(d); // months 0, days 1, microseconds 7_200_000_000
16
+ */
17
+ export declare class Interval {
18
+ readonly months: number;
19
+ readonly days: number;
20
+ readonly microseconds: number;
21
+ /**
22
+ * @param months - Whole months, within a Postgres `int4`.
23
+ * @param days - Whole days, within a Postgres `int4`.
24
+ * @param microseconds - Whole microseconds, a safe integer.
25
+ */
26
+ constructor(months: number, days: number, microseconds: number);
27
+ /**
28
+ * Parses an interval in ISO 8601's form (`P1Y2M3DT4H5M6.5S`, `P2W`), as
29
+ * an `interval` column comes back, or in the form Postgres writes one by
30
+ * default (`1 year 2 mons 3 days 04:05:06.5`, `-1 days +02:00:00`).
31
+ * Postgres's infinite intervals (`infinity`, `-infinity`) have no exact
32
+ * form, and throw. Each part but the seconds is a whole
33
+ * number. To have Postgres parse other forms, pass the string as a query
34
+ * parameter instead.
35
+ *
36
+ * @throws {TypeError} if `s` is in neither form.
37
+ */
38
+ static parse(s: string): Interval;
39
+ /** The interval in ISO 8601's form, as Postgres writes it: `P1Y2M3DT4H5M6.5S`, `PT0S`. */
40
+ toString(): string;
41
+ toJSON(): string;
42
+ private get __encore_interval();
43
+ }
44
+ //# sourceMappingURL=interval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interval.d.ts","sourceRoot":"","sources":["../../../storage/postgres/interval.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,QAAQ;IAOjB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM;IAR/B;;;;OAIG;gBAEQ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM;IAO/B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ;IAUjC,0FAA0F;IAC1F,QAAQ,IAAI,MAAM;IAqBlB,MAAM,IAAI,MAAM;IAIhB,OAAO,KAAK,iBAAiB,GAE5B;CACF"}
@@ -0,0 +1,153 @@
1
+ const MICROS_PER_SECOND = 1000000;
2
+ const MICROS_PER_MINUTE = 60 * MICROS_PER_SECOND;
3
+ const MICROS_PER_HOUR = 60 * MICROS_PER_MINUTE;
4
+ const INT32_MAX = 2 ** 31 - 1;
5
+ /**
6
+ * A Postgres `interval`, exactly as Postgres holds it: months, days and
7
+ * microseconds apart, since a month has no fixed number of days, nor a day
8
+ * (across a change of daylight saving time) of microseconds.
9
+ *
10
+ * An `interval` column comes back as a string in ISO 8601's form, as
11
+ * Postgres writes one (`'P1Y2M3DT4H5M6.5S'`, and `'P1M-2D'` where the parts'
12
+ * signs differ), which {@link Interval.parse} reads. A parameter of type
13
+ * `interval` takes an `Interval`, a `Temporal.Duration`, or a string in any
14
+ * form Postgres parses (`'1 day 02:00:00'`, `'P1DT2H'`, `'90 minutes'`).
15
+ *
16
+ * @example
17
+ * const row = await db.queryRow`SELECT ${new Interval(1, 0, 0)} + now() AS due`;
18
+ * const {d} = await db.queryRow`SELECT interval '1 day 2 hours' AS d`;
19
+ * Interval.parse(d); // months 0, days 1, microseconds 7_200_000_000
20
+ */
21
+ export class Interval {
22
+ months;
23
+ days;
24
+ microseconds;
25
+ /**
26
+ * @param months - Whole months, within a Postgres `int4`.
27
+ * @param days - Whole days, within a Postgres `int4`.
28
+ * @param microseconds - Whole microseconds, a safe integer.
29
+ */
30
+ constructor(months, days, microseconds) {
31
+ this.months = months;
32
+ this.days = days;
33
+ this.microseconds = microseconds;
34
+ check('months', months, INT32_MAX);
35
+ check('days', days, INT32_MAX);
36
+ check('microseconds', microseconds, Number.MAX_SAFE_INTEGER);
37
+ }
38
+ /**
39
+ * Parses an interval in ISO 8601's form (`P1Y2M3DT4H5M6.5S`, `P2W`), as
40
+ * an `interval` column comes back, or in the form Postgres writes one by
41
+ * default (`1 year 2 mons 3 days 04:05:06.5`, `-1 days +02:00:00`).
42
+ * Postgres's infinite intervals (`infinity`, `-infinity`) have no exact
43
+ * form, and throw. Each part but the seconds is a whole
44
+ * number. To have Postgres parse other forms, pass the string as a query
45
+ * parameter instead.
46
+ *
47
+ * @throws {TypeError} if `s` is in neither form.
48
+ */
49
+ static parse(s) {
50
+ const parsed = parseISO(s) ?? parsePostgres(s);
51
+ if (parsed === null) {
52
+ throw new TypeError(`invalid interval ${JSON.stringify(s)}: expected ISO 8601 ("P1M2DT3S") or Postgres ("1 mon 2 days 00:00:03")`);
53
+ }
54
+ return new Interval(parsed.months, parsed.days, parsed.microseconds);
55
+ }
56
+ /** The interval in ISO 8601's form, as Postgres writes it: `P1Y2M3DT4H5M6.5S`, `PT0S`. */
57
+ toString() {
58
+ const years = Math.trunc(this.months / 12);
59
+ const months = this.months % 12;
60
+ const hours = Math.trunc(this.microseconds / MICROS_PER_HOUR);
61
+ let rest = this.microseconds % MICROS_PER_HOUR;
62
+ const minutes = Math.trunc(rest / MICROS_PER_MINUTE);
63
+ rest %= MICROS_PER_MINUTE;
64
+ const date = part(years, 'Y') + part(months, 'M') + part(this.days, 'D');
65
+ let time = part(hours, 'H') + part(minutes, 'M');
66
+ if (rest !== 0) {
67
+ const sign = rest < 0 ? '-' : '';
68
+ const abs = Math.abs(rest);
69
+ const fraction = String(abs % MICROS_PER_SECOND)
70
+ .padStart(6, '0')
71
+ .replace(/0+$/, '');
72
+ time += `${sign}${Math.trunc(abs / MICROS_PER_SECOND)}${fraction ? '.' + fraction : ''}S`;
73
+ }
74
+ if (date === '' && time === '')
75
+ return 'PT0S';
76
+ return 'P' + date + (time ? 'T' + time : '');
77
+ }
78
+ toJSON() {
79
+ return this.toString();
80
+ }
81
+ get __encore_interval() {
82
+ return true;
83
+ }
84
+ }
85
+ function check(name, value, max) {
86
+ if (!Number.isInteger(value) || Math.abs(value) > max) {
87
+ throw new RangeError(`an Interval's ${name} must be an integer of at most ${max} in magnitude, not ${value}`);
88
+ }
89
+ }
90
+ function part(n, unit) {
91
+ return n === 0 ? '' : `${n}${unit}`;
92
+ }
93
+ const ISO = /^P(?:([+-]?\d+)Y)?(?:([+-]?\d+)M)?(?:([+-]?\d+)W)?(?:([+-]?\d+)D)?(?:T(?:([+-]?\d+)H)?(?:([+-]?\d+)M)?(?:([+-]?\d+(?:\.\d{1,6})?)S)?)?$/i;
94
+ function parseISO(s) {
95
+ const m = ISO.exec(s.trim());
96
+ // "P" and "PT" alone name no part.
97
+ if (m === null || m.slice(1).every(g => g === undefined))
98
+ return null;
99
+ const n = (g) => (g === undefined ? 0 : Number(g));
100
+ return {
101
+ months: n(m[1]) * 12 + n(m[2]),
102
+ days: n(m[3]) * 7 + n(m[4]),
103
+ microseconds: n(m[5]) * MICROS_PER_HOUR +
104
+ n(m[6]) * MICROS_PER_MINUTE +
105
+ seconds(m[7] ?? '0'),
106
+ };
107
+ }
108
+ const UNITS = {
109
+ year: 'years',
110
+ years: 'years',
111
+ mon: 'months',
112
+ mons: 'months',
113
+ day: 'days',
114
+ days: 'days',
115
+ };
116
+ const TIME = /^([+-])?(\d+):(\d{2}):(\d{2}(?:\.\d{1,6})?)$/;
117
+ function parsePostgres(s) {
118
+ const words = s.trim().split(/\s+/);
119
+ const parts = { months: 0, days: 0, microseconds: 0 };
120
+ let any = false;
121
+ for (let i = 0; i < words.length; i++) {
122
+ const time = TIME.exec(words[i]);
123
+ if (time !== null) {
124
+ const sign = time[1] === '-' ? -1 : 1;
125
+ parts.microseconds +=
126
+ sign *
127
+ (Number(time[2]) * MICROS_PER_HOUR +
128
+ Number(time[3]) * MICROS_PER_MINUTE +
129
+ seconds(time[4]));
130
+ any = true;
131
+ continue;
132
+ }
133
+ const unit = UNITS[words[i + 1]?.toLowerCase()];
134
+ if (!/^[+-]?\d+$/.test(words[i]) || unit === undefined)
135
+ return null;
136
+ const n = Number(words[i]);
137
+ if (unit === 'years')
138
+ parts.months += n * 12;
139
+ else
140
+ parts[unit] += n;
141
+ any = true;
142
+ i++;
143
+ }
144
+ return any ? parts : null;
145
+ }
146
+ /** `s`, a number of seconds with up to six decimals, in microseconds. */
147
+ function seconds(s) {
148
+ const negative = s.startsWith('-');
149
+ const [whole, fraction = ''] = s.replace(/^[+-]/, '').split('.');
150
+ const micros = Number(whole) * MICROS_PER_SECOND + Number(fraction.padEnd(6, '0'));
151
+ return negative ? -micros : micros;
152
+ }
153
+ //# sourceMappingURL=interval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interval.js","sourceRoot":"","sources":["../../../storage/postgres/interval.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,OAAS,CAAC;AACpC,MAAM,iBAAiB,GAAG,EAAE,GAAG,iBAAiB,CAAC;AACjD,MAAM,eAAe,GAAG,EAAE,GAAG,iBAAiB,CAAC;AAC/C,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAE9B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,QAAQ;IAOR;IACA;IACA;IARX;;;;OAIG;IACH,YACW,MAAc,EACd,IAAY,EACZ,YAAoB;QAFpB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,iBAAY,GAAZ,YAAY,CAAQ;QAE7B,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACnC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/B,KAAK,CAAC,cAAc,EAAE,YAAY,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,KAAK,CAAC,CAAS;QACpB,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,SAAS,CACjB,oBAAoB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,wEAAwE,CAC9G,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;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,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjE,MAAM,MAAM,GACV,MAAM,CAAC,KAAK,CAAC,GAAG,iBAAiB,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACrC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { Database, DatabaseRef, Queryable, Transaction, Connection, } from './database.js';
2
+ export { DatabaseError, ErrorCode, TooManyRowsError } from './errors.js';
3
+ export { Interval } from './interval.js';
4
+ export type { DatabaseConfig, ReadOptions, ExecResult, IsolationLevel, MigrationsConfig, Primitive, Row as ResultRow, TransactionOptions, } from './database.js';
5
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../storage/postgres/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,YAAY,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,GAAG,IAAI,SAAS,EAChB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Database, DatabaseRef, Queryable, Transaction, Connection, } from './database.js';
2
+ export { DatabaseError, ErrorCode, TooManyRowsError } from './errors.js';
3
+ export { Interval } from './interval.js';
4
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../storage/postgres/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAC,aAAa,EAAE,SAAS,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { Target } from './target.js';
2
+ import { Cmd } from './wire.js';
3
+ /** A bitfield integer's type: signed or unsigned, and its width: `"u8"`, `"i5"`. */
4
+ export type BitfieldType = `${'i' | 'u'}${number}`;
5
+ /**
6
+ * Where a bitfield integer starts: at a bit, or at a multiple of its type's
7
+ * width (`"#2"` of a `u8` is bit 16).
8
+ */
9
+ export type BitOffset = number | `#${number}`;
10
+ /**
11
+ * What a `set` or `incrBy` that leaves its type's range does, from the
12
+ * `overflow` that says so on: wrap around (the default), stop at the type's
13
+ * smallest or largest value, or fail, leaving the value as it was and replying
14
+ * `null`.
15
+ */
16
+ export type Overflow = 'wrap' | 'sat' | 'fail';
17
+ /**
18
+ * A string's bitfield integers, read only (`BITFIELD_RO`), made by
19
+ * `bitmap.bitfieldRo`: add the reads, then {@link BitfieldRo.invoke}.
20
+ */
21
+ export declare class BitfieldRo {
22
+ protected readonly t: Target;
23
+ protected readonly c: Cmd;
24
+ /** @internal */
25
+ constructor(t: Target, c: Cmd);
26
+ /** Reads the integer of type `type` at `offset`. */
27
+ get(type: BitfieldType, offset: BitOffset): this;
28
+ /**
29
+ * Runs the operations, replying one value per `get`, `set` and `incrBy`, in
30
+ * order: `null` for one an `overflow('fail')` stopped. Throws a
31
+ * `RangeError` for a value a `number` can't hold exactly.
32
+ */
33
+ invoke(): Promise<(number | null)[]>;
34
+ }
35
+ /**
36
+ * A string's bitfield integers, made by `bitmap.bitfield`: add the
37
+ * operations, which run in order as one command, then {@link Bitfield.invoke}.
38
+ */
39
+ export declare class Bitfield extends BitfieldRo {
40
+ /** Sets the integer of type `type` at `offset`, replying what it was. */
41
+ set(type: BitfieldType, offset: BitOffset, value: number | bigint): this;
42
+ /** Adds `increment` to the integer at `offset`, replying what it is then. */
43
+ incrBy(type: BitfieldType, offset: BitOffset, increment: number | bigint): this;
44
+ /** What the `set`s and `incrBy`s after this do when they leave their range. */
45
+ overflow(mode: Overflow): this;
46
+ }
47
+ /** A {@link BitfieldRo} being queued on a pipeline or a transaction. */
48
+ export declare class QueuedBitfieldRo {
49
+ protected readonly queued: Cmd[];
50
+ protected readonly c: Cmd;
51
+ /** @internal */
52
+ constructor(queued: Cmd[], c: Cmd);
53
+ /** Reads the integer of type `type` at `offset`. */
54
+ get(type: BitfieldType, offset: BitOffset): this;
55
+ /** Queues the operations, as one command. */
56
+ queue(): void;
57
+ }
58
+ /** A {@link Bitfield} being queued on a pipeline or a transaction. */
59
+ export declare class QueuedBitfield extends QueuedBitfieldRo {
60
+ /** Sets the integer of type `type` at `offset`, replying what it was. */
61
+ set(type: BitfieldType, offset: BitOffset, value: number | bigint): this;
62
+ /** Adds `increment` to the integer at `offset`, replying what it is then. */
63
+ incrBy(type: BitfieldType, offset: BitOffset, increment: number | bigint): this;
64
+ /** What the `set`s and `incrBy`s after this do when they leave their range. */
65
+ overflow(mode: Overflow): this;
66
+ }
67
+ //# sourceMappingURL=bitfield.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitfield.d.ts","sourceRoot":"","sources":["../../../storage/redis/bitfield.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,EAAC,GAAG,EAA0B,MAAM,QAAQ,CAAC;AAEpD,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG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AE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKxE,6EAA6E;IAC7E,MAAM,CACJ,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,GAAG,MAAM,GACzB,IAAI;IAKP,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;CAI/B"}
@@ -0,0 +1,114 @@
1
+ import { numberOf } from './reply.js';
2
+ import { ServerError } from './wire.js';
3
+ function get(c, type, offset) {
4
+ c.arg('GET').arg(type).arg(offset);
5
+ }
6
+ function set(c, type, offset, value) {
7
+ c.arg('SET').arg(type).arg(offset).arg(value);
8
+ }
9
+ function incrBy(c, type, offset, increment) {
10
+ c.arg('INCRBY').arg(type).arg(offset).arg(increment);
11
+ }
12
+ function overflow(c, mode) {
13
+ c.arg('OVERFLOW').arg(mode.toUpperCase());
14
+ }
15
+ /** A bitfield's replies, one per `get`, `set` and `incrBy`. */
16
+ function replies(v) {
17
+ if (v instanceof ServerError)
18
+ throw v;
19
+ if (!Array.isArray(v))
20
+ throw new TypeError('redis: BITFIELD replied no array');
21
+ return v.map(item => {
22
+ if (item === null)
23
+ return null;
24
+ if (typeof item === 'bigint' && !Number.isSafeInteger(Number(item))) {
25
+ throw new RangeError(`redis: the bitfield integer ${item} does not fit a number`);
26
+ }
27
+ return numberOf(item);
28
+ });
29
+ }
30
+ /**
31
+ * A string's bitfield integers, read only (`BITFIELD_RO`), made by
32
+ * `bitmap.bitfieldRo`: add the reads, then {@link BitfieldRo.invoke}.
33
+ */
34
+ export class BitfieldRo {
35
+ t;
36
+ c;
37
+ /** @internal */
38
+ constructor(t, c) {
39
+ this.t = t;
40
+ this.c = c;
41
+ }
42
+ /** Reads the integer of type `type` at `offset`. */
43
+ get(type, offset) {
44
+ get(this.c, type, offset);
45
+ return this;
46
+ }
47
+ /**
48
+ * Runs the operations, replying one value per `get`, `set` and `incrBy`, in
49
+ * order: `null` for one an `overflow('fail')` stopped. Throws a
50
+ * `RangeError` for a value a `number` can't hold exactly.
51
+ */
52
+ async invoke() {
53
+ return replies(await this.t.run(this.c));
54
+ }
55
+ }
56
+ /**
57
+ * A string's bitfield integers, made by `bitmap.bitfield`: add the
58
+ * operations, which run in order as one command, then {@link Bitfield.invoke}.
59
+ */
60
+ export class Bitfield extends BitfieldRo {
61
+ /** Sets the integer of type `type` at `offset`, replying what it was. */
62
+ set(type, offset, value) {
63
+ set(this.c, type, offset, value);
64
+ return this;
65
+ }
66
+ /** Adds `increment` to the integer at `offset`, replying what it is then. */
67
+ incrBy(type, offset, increment) {
68
+ incrBy(this.c, type, offset, increment);
69
+ return this;
70
+ }
71
+ /** What the `set`s and `incrBy`s after this do when they leave their range. */
72
+ overflow(mode) {
73
+ overflow(this.c, mode);
74
+ return this;
75
+ }
76
+ }
77
+ /** A {@link BitfieldRo} being queued on a pipeline or a transaction. */
78
+ export class QueuedBitfieldRo {
79
+ queued;
80
+ c;
81
+ /** @internal */
82
+ constructor(queued, c) {
83
+ this.queued = queued;
84
+ this.c = c;
85
+ }
86
+ /** Reads the integer of type `type` at `offset`. */
87
+ get(type, offset) {
88
+ get(this.c, type, offset);
89
+ return this;
90
+ }
91
+ /** Queues the operations, as one command. */
92
+ queue() {
93
+ this.queued.push(this.c);
94
+ }
95
+ }
96
+ /** A {@link Bitfield} being queued on a pipeline or a transaction. */
97
+ export class QueuedBitfield extends QueuedBitfieldRo {
98
+ /** Sets the integer of type `type` at `offset`, replying what it was. */
99
+ set(type, offset, value) {
100
+ set(this.c, type, offset, value);
101
+ return this;
102
+ }
103
+ /** Adds `increment` to the integer at `offset`, replying what it is then. */
104
+ incrBy(type, offset, increment) {
105
+ incrBy(this.c, type, offset, increment);
106
+ return this;
107
+ }
108
+ /** What the `set`s and `incrBy`s after this do when they leave their range. */
109
+ overflow(mode) {
110
+ overflow(this.c, mode);
111
+ return this;
112
+ }
113
+ }
114
+ //# sourceMappingURL=bitfield.js.map
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AC/E,QAAQ,CAAC,IAAc;QACrB,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,wEAAwE;AACxE,MAAM,OAAO,gBAAgB;IAGN;IACA;IAHrB,gBAAgB;IAChB,YACqB,MAAa,EACb,CAAM;QADN,WAAM,GAAN,MAAM,CAAO;QACb,MAAC,GAAD,CAAC,CAAK;IACxB,CAAC;IAEJ,oDAAoD;IACpD,GAAG,CAAC,IAAkB,EAAE,MAAiB;QACvC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;CACF;AAED,sEAAsE;AACtE,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IAClD,yEAAyE;IACzE,GAAG,CAAC,IAAkB,EAAE,MAAiB,EAAE,KAAsB;QAC/D,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6EAA6E;IAC7E,MAAM,CACJ,IAAkB,EAClB,MAAiB,EACjB,SAA0B;QAE1B,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,+EAA+E;IAC/E,QAAQ,CAAC,IAAc;QACrB,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,45 @@
1
+ import { ReplyPromise } from './reply.js';
2
+ import type { Target } from './target.js';
3
+ import { Cmd, type RedisArg } from './wire.js';
4
+ /**
5
+ * The command an app names itself: checked by the runtime against Redis's
6
+ * command table before it is sent.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare function rawCommand(name: string, readOnly: boolean): Cmd;
11
+ /**
12
+ * A command the command groups lack, made by `command()`: give its arguments
13
+ * in order with {@link CommandInvocation.key} and {@link CommandInvocation.arg},
14
+ * then {@link CommandInvocation.invoke}.
15
+ */
16
+ export declare class CommandInvocation {
17
+ private readonly t;
18
+ private readonly c;
19
+ /** @internal */
20
+ constructor(t: Target, c: Cmd);
21
+ /** The next argument, which is a key: it gets the database's prefix. */
22
+ key(key: string): this;
23
+ /** The next argument, which is not a key: it is sent as it is. */
24
+ arg(arg: RedisArg): this;
25
+ /**
26
+ * Sends the command, replying what the server did, but for the keys the
27
+ * pops and stream reads reply with, which lose the database's prefix. A
28
+ * command the runtime refuses fails with a `TypeError` saying why.
29
+ */
30
+ invoke(): ReplyPromise;
31
+ }
32
+ /** A command the command groups lack being queued on a pipeline or a transaction. */
33
+ export declare class QueuedCommandInvocation {
34
+ private readonly queued;
35
+ private readonly c;
36
+ /** @internal */
37
+ constructor(queued: Cmd[], c: Cmd);
38
+ /** The next argument, which is a key: it gets the database's prefix. */
39
+ key(key: string): this;
40
+ /** The next argument, which is not a key: it is sent as it is. */
41
+ arg(arg: RedisArg): this;
42
+ /** Queues the command. */
43
+ queue(): void;
44
+ }
45
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../storage/redis/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAC,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AACrC,OAAO,EAAC,GAAG,EAAE,KAAK,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,GAAG,CAK/D;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAG1B,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClB,OAAO,CAAC,QAAQ,CAAC,CAAC;IAHpB,gBAAgB;gBAEG,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,GAAG;IAGzB,wEAAwE;IACxE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKtB,kEAAkE;IAClE,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAKxB;;;;OAIG;IACH,MAAM,IAAI,YAAY;CAWvB;AAED,qFAAqF;AACrF,qBAAa,uBAAuB;IAGhC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,CAAC;IAHpB,gBAAgB;gBAEG,MAAM,EAAE,GAAG,EAAE,EACb,CAAC,EAAE,GAAG;IAGzB,wEAAwE;IACxE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKtB,kEAAkE;IAClE,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAKxB,0BAA0B;IAC1B,KAAK,IAAI,IAAI;CAGd"}