@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,1251 @@
1
+ /* tslint:disable */
2
+ /* eslint:disable */
3
+ // Automatically generated by gen_type_defs. Do not edit.
4
+
5
+ export interface AppMeta {
6
+ appId: string
7
+ appSlug: string
8
+ /**
9
+ * The API gateways the service is given, keyed by gateway name: those
10
+ * its code names, and the one it hosts.
11
+ */
12
+ gateways: Record<string, GatewayMeta>
13
+ /**
14
+ * The frontends the service is given, keyed by name: those its code
15
+ * names, and the one it hosts.
16
+ */
17
+ frontends: Record<string, FrontendMeta>
18
+ environment: EnvironmentMeta
19
+ build: BuildMeta
20
+ deploy: DeployMeta
21
+ }
22
+
23
+ export interface AttrsOptions {
24
+ version?: string
25
+ }
26
+
27
+ export class Bucket {
28
+ object(name: string): BucketObject
29
+ list(options?: ListOptions | undefined | null, source?: Buffer | undefined | null): Promise<ListIterator | TypedObjectError>
30
+ listVersions(options?: ListOptions | undefined | null, source?: Buffer | undefined | null): Promise<VersionIterator | TypedObjectError>
31
+ }
32
+
33
+ export class BucketObject {
34
+ attrs(options?: AttrsOptions | undefined | null, source?: Buffer | undefined | null): Promise<ObjectAttrs | TypedObjectError>
35
+ exists(options?: ExistsOptions | undefined | null, source?: Buffer | undefined | null): Promise<boolean | TypedObjectError>
36
+ /**
37
+ * Starts an upload whose bytes are written to the returned stream.
38
+ * Nothing is stored until it is finished: aborting it, or dropping it
39
+ * unfinished, stores nothing.
40
+ */
41
+ uploadStream(options?: UploadOptions | undefined | null, source?: Buffer | undefined | null): UploadStream | TypedObjectError
42
+ /** Replaces the attributes given and leaves the others as they are. */
43
+ updateAttrs(attrs: UpdateAttrs, options?: UpdateAttrsOptions | undefined | null, source?: Buffer | undefined | null): Promise<ObjectAttrs | TypedObjectError>
44
+ /** Keeps the object until `until`, in milliseconds since the Unix epoch. */
45
+ extendRetention(until: number, options?: ExtendRetentionOptions | undefined | null, source?: Buffer | undefined | null): Promise<ObjectAttrs | TypedObjectError>
46
+ signedUploadUrl(options?: UploadUrlOptions | undefined | null, source?: Buffer | undefined | null): Promise<SignedUploadUrl | TypedObjectError>
47
+ signedDownloadUrl(options?: DownloadUrlOptions | undefined | null, source?: Buffer | undefined | null): Promise<SignedDownloadUrl | TypedObjectError>
48
+ downloadAll(options?: DownloadOptions | undefined | null, source?: Buffer | undefined | null): Promise<Buffer | TypedObjectError>
49
+ /** Opens a download. A missing object fails here, before any bytes. */
50
+ downloadStream(options?: DownloadOptions | undefined | null, source?: Buffer | undefined | null): Promise<DownloadStream | TypedObjectError>
51
+ delete(options?: DeleteOptions | undefined | null, source?: Buffer | undefined | null): Promise<TypedObjectError | null>
52
+ publicUrl(): string
53
+ }
54
+
55
+ export interface BuildMeta {
56
+ revision: string
57
+ }
58
+
59
+ export interface ByteRange {
60
+ offset: number
61
+ length?: number
62
+ }
63
+
64
+ /** Which of a database's users a call is made as. See [`clickhouse::Access`]. */
65
+ export enum ClickHouseAccess {
66
+ Read = 0,
67
+ Write = 1,
68
+ Admin = 2
69
+ }
70
+
71
+ /** A query's rows, streamed. */
72
+ export class ClickHouseCursor {
73
+ /** The query's id on the server. */
74
+ get queryId(): string
75
+ /**
76
+ * The next rows: at least one, and as many more as have arrived, up to
77
+ * `max`; null once there are none. Each row is an object keyed by
78
+ * column name.
79
+ */
80
+ next(max?: number | undefined | null): Promise<Array<Record<string, any>> | null>
81
+ /** Stops reading: a read-only query stops on the server too. */
82
+ close(): Promise<void>
83
+ }
84
+
85
+ /**
86
+ * A ClickHouse database: each call says which access it is made with, as
87
+ * the SDK's handles hold it.
88
+ */
89
+ export class ClickHouseDatabase {
90
+ /**
91
+ * A URL for another ClickHouse client to connect to the database with,
92
+ * as `access`'s user: `http[s]://user:password@host:port/database`.
93
+ */
94
+ connectionString(access: ClickHouseAccess): string
95
+ /** Runs a query, its parameters `params`, and streams its rows. */
96
+ query(access: ClickHouseAccess, sql: string, params: ClickHouseParams, settings?: Record<string, string> | undefined | null, queryId?: string | undefined | null, source?: Buffer | undefined | null): Promise<ClickHouseCursor>
97
+ /** Runs a statement, discarding any rows it returns. */
98
+ exec(access: ClickHouseAccess, sql: string, params: ClickHouseParams, settings?: Record<string, string> | undefined | null, queryId?: string | undefined | null, source?: Buffer | undefined | null): Promise<ClickHouseSummary>
99
+ /** Inserts `rows` into `table` (`table` or `db.table`). */
100
+ insert(access: ClickHouseAccess, table: string, rows: ClickHouseInsertRows, settings?: Record<string, string> | undefined | null, queryId?: string | undefined | null, source?: Buffer | undefined | null): Promise<ClickHouseSummary>
101
+ }
102
+
103
+ /**
104
+ * Rows to insert, converted from JS: the columns are the union of the rows'
105
+ * keys, in the order they are first seen. A row without one of them leaves
106
+ * it out, so it gets the column's default.
107
+ */
108
+ export class ClickHouseInsertRows {
109
+ constructor(rows: Array<unknown>)
110
+ }
111
+
112
+ /**
113
+ * A query's parameters, converted from JS, with the type each is bound as
114
+ * when the SQL doesn't say: what a tagged template's `{pN:Type}` names.
115
+ */
116
+ export class ClickHouseParams {
117
+ /** Converts the values of the parameters `names`, in order. */
118
+ constructor(names: Array<string>, values: Array<unknown>)
119
+ /**
120
+ * The type of each parameter: the one `typed()` gave it, or the one its
121
+ * value is inferred to have.
122
+ */
123
+ types(): Array<string>
124
+ }
125
+
126
+ /**
127
+ * What a statement did, from the server's `X-ClickHouse-Summary`. Counts
128
+ * are numbers: no count reaches 2^53.
129
+ */
130
+ export interface ClickHouseSummary {
131
+ queryId: string
132
+ rowsRead: number
133
+ bytesRead: number
134
+ rowsWritten: number
135
+ bytesWritten: number
136
+ }
137
+
138
+ export enum CloudProvider {
139
+ AWS = 0,
140
+ GCP = 1,
141
+ Azure = 2,
142
+ Encore = 3,
143
+ Local = 4
144
+ }
145
+
146
+ /** What a JS thread's collector replies with, once. */
147
+ export class CollectReply {
148
+ /**
149
+ * The milliseconds left to send in: the collection goes on without
150
+ * what is sent later.
151
+ */
152
+ get timeout(): number
153
+ /**
154
+ * Sends the thread's observations: the `i`th is `values[i]` for the
155
+ * observable instrument `ids[i]`, with the attributes `attrs[i]`, a
156
+ * JSON object's text. Later calls do nothing.
157
+ */
158
+ send(ids: Array<number>, values: Array<number>, attrs: Array<string>): void
159
+ }
160
+
161
+ export class Config {
162
+ /** The value now. */
163
+ current(): ConfigRevision
164
+ /**
165
+ * The revision number now, cheaper than [`Config::current`] for telling
166
+ * whether a cached value is still current.
167
+ */
168
+ revision(): number
169
+ /** The config's JSON Schema, as JSON text. */
170
+ schema(): string
171
+ /**
172
+ * Calls `handler` on the event loop with each revision the value gets
173
+ * from now on, the revision's own value with it: the value now may be a
174
+ * later one by the time the handler runs. Revisions that come faster
175
+ * than the watch sees them are coalesced to the latest; each is passed
176
+ * once, in order. Does not keep the process alive. Stop it with the
177
+ * returned watch's `stop`.
178
+ */
179
+ onChange(handler: (revision: ConfigRevision) => void): ConfigWatch
180
+ }
181
+
182
+ /** A config's value at one point. */
183
+ export interface ConfigRevision {
184
+ /** Counts up from 0, the value the process started with. */
185
+ number: number
186
+ /**
187
+ * The value, as JSON text, with a placeholder
188
+ * (`{"$encore_secret": "<name>"}`) for each secret field.
189
+ */
190
+ value: string
191
+ }
192
+
193
+ /** Being told of a config's changes, until stopped. */
194
+ export class ConfigWatch {
195
+ /** Stops the calls. */
196
+ stop(): void
197
+ }
198
+
199
+ export class Cursor {
200
+ next(): Promise<Row | null>
201
+ rowsAffected(): Promise<bigint>
202
+ close(): Promise<void>
203
+ }
204
+
205
+ export class Decimal {
206
+ constructor(value: string)
207
+ toString(): string
208
+ add(other: Decimal): Decimal
209
+ sub(other: Decimal): Decimal
210
+ mul(other: Decimal): Decimal
211
+ div(other: Decimal): Decimal
212
+ }
213
+
214
+ export interface DeleteOptions {
215
+ version?: string
216
+ ifMatch?: Revision
217
+ }
218
+
219
+ export interface DeployMeta {
220
+ id: string
221
+ deployTime: string
222
+ hostedServices: Record<string, HostedService>
223
+ /** The Worker of its service the process runs; none for its main process. */
224
+ worker?: string
225
+ }
226
+
227
+ export interface DownloadOptions {
228
+ version?: string
229
+ range?: ByteRange
230
+ }
231
+
232
+ /** An open download, read one chunk at a time. */
233
+ export class DownloadStream {
234
+ /**
235
+ * The next chunk, or null at the end. The stream closes at the end and
236
+ * on an error.
237
+ */
238
+ next(): Promise<Buffer | null | TypedObjectError>
239
+ /** Stops the download, which ends its span. */
240
+ close(): Promise<void>
241
+ }
242
+
243
+ export interface DownloadUrlOptions {
244
+ ttl?: number
245
+ }
246
+
247
+ export interface EnvironmentMeta {
248
+ name: string
249
+ type: EnvironmentType
250
+ cloud: CloudProvider
251
+ }
252
+
253
+ export enum EnvironmentType {
254
+ Production = 0,
255
+ Development = 1,
256
+ Ephemeral = 2,
257
+ Test = 3
258
+ }
259
+
260
+ export interface ExistsOptions {
261
+ version?: string
262
+ }
263
+
264
+ export interface ExtendRetentionOptions {
265
+ version?: string
266
+ }
267
+
268
+ export interface FrontendMeta {
269
+ name: string
270
+ url: string
271
+ origins: Array<string>
272
+ }
273
+
274
+ /**
275
+ * An attribute of a request's edge span: an integer when `integer` is set
276
+ * and `value` a number.
277
+ */
278
+ export interface GatewayAttribute {
279
+ key: string
280
+ value: string | boolean | number
281
+ integer?: boolean
282
+ }
283
+
284
+ /**
285
+ * A Request Context field, encoded as on the wire. A null `value` clears
286
+ * it, in what a hook answers.
287
+ */
288
+ export interface GatewayField {
289
+ name: string
290
+ value?: string
291
+ }
292
+
293
+ /** A header of a response a Middleware answers with. */
294
+ export interface GatewayHeader {
295
+ name: string
296
+ value: string
297
+ }
298
+
299
+ /**
300
+ * An edit to a request's or response's headers: `op` 0 sets, 1 adds, 2
301
+ * removes the header.
302
+ */
303
+ export interface GatewayHeaderEdit {
304
+ op: number
305
+ name: string
306
+ value: string
307
+ }
308
+
309
+ /**
310
+ * A response's headers, of a `response` event, kept in Rust as a view's
311
+ * are.
312
+ */
313
+ export class GatewayHeaders {
314
+ /**
315
+ * Every value of the header `name`, in order, as later Middleware left
316
+ * them. Any case.
317
+ */
318
+ values(name: string): Array<string>
319
+ }
320
+
321
+ export interface GatewayMeta {
322
+ name: string
323
+ url: string
324
+ origins: Array<string>
325
+ }
326
+
327
+ /**
328
+ * A request, as a Middleware is shown it: all of its headers, query
329
+ * parameters and cookies, kept in Rust and handed to JavaScript only as a
330
+ * hook reads them, so what a hook does not read costs it nothing.
331
+ */
332
+ export class GatewayView {
333
+ /** The gateway serving it. */
334
+ get gateway(): string
335
+ /** The service it is routed to. */
336
+ get service(): string
337
+ /** The template of the route it matched. */
338
+ get route(): string
339
+ get method(): string
340
+ /** As it arrived: not percent-decoded. */
341
+ get path(): string
342
+ get host(): string | null
343
+ get clientIp(): string | null
344
+ get traceparent(): string | null
345
+ get tracestate(): string | null
346
+ /**
347
+ * The Request Context fields earlier Middleware set, each encoded as on
348
+ * the wire: base64url of its JSON. For a `complete` event, those the
349
+ * request was forwarded with.
350
+ */
351
+ get context(): Array<GatewayField>
352
+ /**
353
+ * The route's path parameter `name`, not percent-decoded; undefined when
354
+ * the route has none of that name.
355
+ */
356
+ pathParam(name: string): string | null
357
+ /**
358
+ * Every value of the header `name`, in order, as earlier Middleware
359
+ * left them. Any case.
360
+ */
361
+ headerValues(name: string): Array<string>
362
+ /** Every value of the query parameter `name`, percent-decoded, in order. */
363
+ queryValues(name: string): Array<string>
364
+ /**
365
+ * The value of the cookie `name`, from the `Cookie` headers as earlier
366
+ * Middleware left them; undefined when it is not sent.
367
+ */
368
+ cookie(name: string): string | null
369
+ }
370
+
371
+ export interface HostedService {
372
+ name: string
373
+ }
374
+
375
+ /** A registered instrument. */
376
+ export class Instrument {
377
+ /** Identifies an observable instrument's observations. */
378
+ get id(): number
379
+ /**
380
+ * Records `value` with `attrs`, a JSON object's text, taken in the
381
+ * span `span` (a 25-byte context). A measurement the instrument cannot
382
+ * take is dropped.
383
+ */
384
+ record(value: number, attrs?: string, span?: Buffer): void
385
+ }
386
+
387
+ /** An instrument to register, in its meter's instrumentation scope. */
388
+ export interface InstrumentOptions {
389
+ scopeName: string
390
+ scopeVersion?: string
391
+ scopeSchemaUrl?: string
392
+ /**
393
+ * 0 counter, 1 up-down counter, 2 histogram, 3 gauge, 4 observable
394
+ * counter, 5 observable up-down counter, 6 observable gauge.
395
+ */
396
+ kind: number
397
+ /** 0 `i64`, 1 `u64`, 2 `f64`. */
398
+ number: number
399
+ name: string
400
+ unit?: string
401
+ description?: string
402
+ /** A histogram's advisory explicit bucket boundaries. */
403
+ boundaries?: Array<number>
404
+ }
405
+
406
+ export interface ListEntry {
407
+ name: string
408
+ size: number
409
+ etag: string
410
+ /** A common prefix of a delimited listing rather than an object. */
411
+ isPrefix: boolean
412
+ }
413
+
414
+ export class ListIterator {
415
+ next(): Promise<ListEntry | null | TypedObjectError>
416
+ markDone(): void
417
+ }
418
+
419
+ export interface ListOptions {
420
+ prefix?: string
421
+ limit?: number
422
+ delimiter?: string
423
+ }
424
+
425
+ /** The meter provider, as JS registers instruments with it. */
426
+ export class Meters {
427
+ /**
428
+ * Registers an instrument. One identical to another shares its
429
+ * aggregation; every instrument records nothing when metrics are not
430
+ * exported.
431
+ */
432
+ instrument(opts: InstrumentOptions): Instrument
433
+ /**
434
+ * Adds this JS thread's collector, which a collection calls on the
435
+ * thread's event loop with a [`CollectReply`] to send every
436
+ * observation of the thread's observable instruments with. Does not
437
+ * keep the thread alive.
438
+ */
439
+ addCollector(collect: (reply: CollectReply) => void): void
440
+ }
441
+
442
+ export interface ObjectAttrs {
443
+ name: string
444
+ version?: string
445
+ size: number
446
+ contentType?: string
447
+ etag: string
448
+ cacheControl?: string
449
+ contentDisposition?: string
450
+ metadata: Record<string, string>
451
+ /** Milliseconds since the Unix epoch. */
452
+ lastModified?: number
453
+ storageClass?: 'standard' | 'infrequent' | 'cold' | 'auto'
454
+ /** Milliseconds since the Unix epoch. */
455
+ retainUntil?: number
456
+ }
457
+
458
+ export enum ObjectErrorKind {
459
+ NotFound = 0,
460
+ PreconditionFailed = 1,
461
+ InvalidArgument = 2,
462
+ Other = 3,
463
+ Internal = 4,
464
+ Retained = 5
465
+ }
466
+
467
+ export interface ObjectVersion {
468
+ name: string
469
+ version?: string
470
+ size: number
471
+ etag: string
472
+ latest: boolean
473
+ /** Milliseconds since the Unix epoch. */
474
+ lastModified?: number
475
+ }
476
+
477
+ /** Span lifecycle calls into the telemetry pipeline. */
478
+ export class Pipeline {
479
+ /**
480
+ * Starts a span. `parent`: 25-byte context, with `tracestate`.
481
+ * `packed`: start scope, attributes, and links in the packed layout.
482
+ */
483
+ startSpan(name: string, kind: number, parent: Buffer | undefined | null, tracestate: string | undefined | null, startUnixNanos: bigint | undefined | null, packed: Buffer): SpanStartResult
484
+ /** Ends a span. `packed`: the finished span in the packed layout. */
485
+ endSpan(packed: Buffer): void
486
+ /** The number of telemetry items dropped because the queue was full. */
487
+ dropped(): bigint
488
+ }
489
+
490
+ /**
491
+ * One message of a batch to publish: its raw payload, its attributes, and
492
+ * its ordering key, which an ordered topic's message needs and an unordered
493
+ * topic's cannot have.
494
+ */
495
+ export interface PubSubBatchEntry {
496
+ data: Buffer
497
+ attributes?: Record<string, string>
498
+ orderingKey?: string
499
+ }
500
+
501
+ /**
502
+ * A PubSub message delivered to a subscription handler.
503
+ *
504
+ * Carries the core message attributes. The payload is exposed as raw bytes
505
+ * via `data`; callers are responsible for deserializing it themselves.
506
+ */
507
+ export class PubSubMessage {
508
+ /** The unique message id assigned by the cloud provider. */
509
+ get id(): string
510
+ /** The raw message payload bytes. */
511
+ get data(): Buffer
512
+ /** The message attributes set when publishing. */
513
+ get attributes(): Record<string, string>
514
+ /** The key it was published with, on an ordered topic. */
515
+ get orderingKey(): string | null
516
+ /** The delivery attempt for this message, starting at 1. */
517
+ get deliveryAttempt(): number
518
+ /** The time the message was published. */
519
+ get publishTime(): Date
520
+ /**
521
+ * The context of the span its handler runs in, with the W3C tracestate
522
+ * carrying Encore's propagation mark; null when there is none.
523
+ */
524
+ get spanContext(): SpanContextData | null
525
+ }
526
+
527
+ /**
528
+ * What became of one message of a batch: its `id` if it was published,
529
+ * otherwise the `error` saying why not.
530
+ */
531
+ export interface PubSubPublishOutcome {
532
+ id?: string
533
+ error?: string
534
+ }
535
+
536
+ export class PubSubSubscription {
537
+ subscribe(): Promise<void>
538
+ }
539
+
540
+ export interface PubSubSubscriptionConfig {
541
+ topicName: string
542
+ subscriptionName: string
543
+ handler: (...args: any[]) => any
544
+ }
545
+
546
+ export class PubSubTopic {
547
+ /**
548
+ * Publish a message. `data` is the raw payload, delivered to subscribers
549
+ * verbatim, with its `attributes`. `orderingKey` is the message's ordering
550
+ * key, which an ordered topic's message needs and an unordered topic's
551
+ * cannot have.
552
+ */
553
+ publish(data: Buffer, attributes?: Record<string, string> | undefined | null, source?: Buffer | undefined | null, orderingKey?: string | undefined | null): Promise<string>
554
+ /**
555
+ * Publish up to 1000 messages, resolving to each one's outcome in the
556
+ * order given. It is not atomic: some messages can be published and
557
+ * others not. On an ordered topic the messages of one key are published
558
+ * in order, and none after one of them fails. It rejects, publishing
559
+ * nothing, only when the batch as a whole is refused, as one of more
560
+ * than 1000 messages is.
561
+ */
562
+ publishBatch(entries: Array<PubSubBatchEntry>, source?: Buffer | undefined | null): Promise<Array<PubSubPublishOutcome>>
563
+ }
564
+
565
+ export class QueryArgs {
566
+ constructor(params: Array<unknown>)
567
+ }
568
+
569
+ /**
570
+ * A connection taken out of a database's pool, until it is released. Its
571
+ * commands run one at a time.
572
+ */
573
+ export class RedisConnection {
574
+ /** [`RedisDatabase::execute`], on this connection. */
575
+ execute(cmd: Buffer, source?: Buffer | undefined | null): Promise<Buffer>
576
+ /**
577
+ * [`RedisDatabase::execute_each`], on this connection. `null` for a
578
+ * transaction that did not run because a watched key changed.
579
+ */
580
+ executeEach(batch: Buffer, atomic: boolean, source?: Buffer | undefined | null): Promise<Buffer | null>
581
+ /** Watches the encoded list of `keys`. */
582
+ watch(keys: Buffer, source?: Buffer | undefined | null): Promise<void>
583
+ /** Stops watching every key. */
584
+ unwatch(source?: Buffer | undefined | null): Promise<void>
585
+ /**
586
+ * Returns the connection to its pool. Keys it still watches are unwatched
587
+ * first, which is why it is dropped here, on the runtime, rather than
588
+ * whenever JavaScript collects it.
589
+ */
590
+ release(): Promise<void>
591
+ }
592
+
593
+ /** A Redis database, its client opened on first use. */
594
+ export class RedisDatabase {
595
+ /** The prefix every key of the database is stored under, if it has one. */
596
+ keyPrefix(): string | null
597
+ /**
598
+ * The URL a client other than this one connects to the database with,
599
+ * past its key prefix.
600
+ */
601
+ connectionUrl(): string
602
+ /** Runs an encoded command, resolving to its encoded reply. */
603
+ execute(cmd: Buffer, source?: Buffer | undefined | null): Promise<Buffer>
604
+ /**
605
+ * Runs an encoded batch in one round trip, as a transaction if `atomic`,
606
+ * resolving to the replies as one encoded array. A command the server
607
+ * rejects fails alone: its reply is the error.
608
+ */
609
+ executeEach(batch: Buffer, atomic: boolean, source?: Buffer | undefined | null): Promise<Buffer>
610
+ /** Takes a connection out of the pool. */
611
+ acquire(source?: Buffer | undefined | null): Promise<RedisConnection>
612
+ /**
613
+ * Subscribes to the encoded lists of `channels` and `patterns`, on a
614
+ * connection of its own.
615
+ */
616
+ subscribe(channels: Buffer, patterns: Buffer, source?: Buffer | undefined | null): Promise<RedisSubscription>
617
+ }
618
+
619
+ /** A message published to a channel. */
620
+ export interface RedisMessage {
621
+ /** The channel, without the database's prefix. */
622
+ channel: Buffer
623
+ payload: Buffer
624
+ }
625
+
626
+ /** An open subscription, on a connection of its own. */
627
+ export class RedisSubscription {
628
+ /** The next message, or `null` once the subscription is closed. */
629
+ next(): Promise<RedisMessage | null>
630
+ /**
631
+ * Closes the subscription and its connection, which unsubscribes: a
632
+ * waiting `next`, and any later one, returns `null`.
633
+ */
634
+ close(): Promise<void>
635
+ }
636
+
637
+ /** How a declared Request Context field travels. */
638
+ export interface ReqctxField {
639
+ /** Carried on the Pub/Sub messages published with it set. */
640
+ pubsub: boolean
641
+ /** Put on the spans started with it set. */
642
+ trace: boolean
643
+ }
644
+
645
+ /** One revision of an object, for an `ifMatch` precondition. */
646
+ export interface Revision {
647
+ etag: string
648
+ version?: string
649
+ }
650
+
651
+ export class Row {
652
+ /**
653
+ * The row's values by column name. An `int8` is a number, or a `bigint`
654
+ * outside the integers a JS number holds exactly, so it is never rounded.
655
+ */
656
+ values(): Record<string, unknown>
657
+ }
658
+
659
+ export class Runtime {
660
+ constructor(options: RuntimeOptions)
661
+ /**
662
+ * Runs until shutdown completes, returning the process exit code: waits
663
+ * for a shutdown signal, then drains the infrastructure integrations. A
664
+ * `cooperative` shutdown cleans up once the app has drained its own work
665
+ * too ([`Runtime::mark_application_drained`]), or the deadline passed.
666
+ * The JS caller exits the process from Node's main thread with the
667
+ * returned code.
668
+ */
669
+ runForever(cooperative?: boolean | undefined | null): Promise<number>
670
+ /**
671
+ * Starts the shutdown once; the first call chooses the mode. A
672
+ * cooperative shutdown waits for [`Runtime::mark_application_drained`]
673
+ * (or the deadline) before cleanup.
674
+ */
675
+ beginShutdown(cooperative: boolean): void
676
+ /** Tells the runtime the application has drained its work. */
677
+ markApplicationDrained(): void
678
+ /**
679
+ * Calls `handler` on the event loop as the shutdown begun with
680
+ * [`Runtime::begin_shutdown`] reaches each phase: `"started"`,
681
+ * `"cleanup"`, then `"completed"` with its result, `"success"`,
682
+ * `"timeout"` or `"failed"`. Unlike [`Runtime::shutdown_completed`],
683
+ * watching holds no handle open on the event loop.
684
+ */
685
+ watchShutdown(handler: (phase: string, result?: string) => void): void
686
+ /**
687
+ * The shutdown's phase: `"not-started"`, `"started"`, `"cleanup"` or
688
+ * `"completed"`.
689
+ */
690
+ shutdownPhase(): string
691
+ /**
692
+ * How long the shutdown may take before cleanup begins regardless, in
693
+ * milliseconds from its beginning.
694
+ */
695
+ shutdownTimeoutMs(): number
696
+ /**
697
+ * Begins cleanup without waiting for the app to drain. Fails if the
698
+ * shutdown has not begun.
699
+ */
700
+ forceShutdownCleanup(): void
701
+ /**
702
+ * Finishes the shutdown of an app that is exiting on its own, blocking
703
+ * until cleanup completes: from `process.on('exit')`, after which no
704
+ * JavaScript runs. Returns the exit code, as
705
+ * [`Runtime::shutdown_completed`] does.
706
+ */
707
+ finishShutdownSync(): number
708
+ /**
709
+ * Waits for cleanup to complete after [`Runtime::begin_shutdown`],
710
+ * returning its result: `"success"` when it finished within the
711
+ * deadline, `"timeout"` when it did not, or `"failed"`.
712
+ */
713
+ shutdownCompleted(): Promise<string>
714
+ sqlDatabase(encoreName: string): SqlDatabase
715
+ clickhouseDatabase(encoreName: string): ClickHouseDatabase
716
+ pubsubTopic(encoreName: string): PubSubTopic
717
+ bucket(encoreName: string): Bucket
718
+ redisDatabase(encoreName: string): RedisDatabase
719
+ pubsubSubscription(cfg: PubSubSubscriptionConfig): PubSubSubscription
720
+ /** Each test's infrastructure: null outside test mode. */
721
+ testScopes(): TestScopes | null
722
+ /**
723
+ * What the app's .env files set for a test process, for the SDK to set
724
+ * those `process.env` lacks: `encore test` started it with them, a test
725
+ * runner did not. Empty outside test mode.
726
+ */
727
+ testDotenv(): Record<string, string>
728
+ /**
729
+ * How the Request Context field `name` travels, as the app declares it;
730
+ * null when the runtime config lists no such field.
731
+ */
732
+ reqctxField(name: string): ReqctxField | null
733
+ /**
734
+ * The config given to the service this process hosts, whatever its
735
+ * scope, if the runtime config has one of the name: a config name has one
736
+ * scope across the app.
737
+ */
738
+ config(encoreName: string): Config | null
739
+ /**
740
+ * The secret given to the service this process hosts, whatever its scope:
741
+ * a name has one scope across the app.
742
+ */
743
+ secret(encoreName: string): Secret | null
744
+ /** The telemetry pipeline's span lifecycle calls. */
745
+ telemetry(): Pipeline
746
+ /** The meter provider's instrument calls. */
747
+ meters(): Meters
748
+ /** Returns the version of the Encore runtime being used */
749
+ static version(): string
750
+ /** Returns the git commit hash used to build the Encore runtime */
751
+ static buildCommit(): string
752
+ appMeta(): AppMeta
753
+ runtimeConfig(): RuntimeConfig
754
+ }
755
+
756
+ export interface RuntimeConfig {
757
+ /** The service hosted by this process, if any. */
758
+ currentService?: string
759
+ /**
760
+ * The Worker of that service this process runs; none for its main
761
+ * process.
762
+ */
763
+ currentWorker?: string
764
+ /**
765
+ * Base URLs of the services this process can reach, keyed by service
766
+ * name.
767
+ */
768
+ services: Record<string, string>
769
+ }
770
+
771
+ /** One runtime log line. */
772
+ export interface RuntimeLogLine {
773
+ /** 1 ERROR, 2 WARN, 3 INFO, 4 DEBUG, 5 TRACE. */
774
+ level: number
775
+ /** The module path, or `file:line`, the line comes from. */
776
+ target: string
777
+ message: string
778
+ /** A JSON object of key-values, `exception.*` included. */
779
+ fields: string
780
+ /** The current span's 25-byte context when the line was logged. */
781
+ spanCtx?: Buffer
782
+ }
783
+
784
+ export interface RuntimeOptions {
785
+ testMode?: boolean
786
+ /**
787
+ * Whether the process is a test runner's, as the SDK finds from its
788
+ * environment: it is then in test mode without `encore test`, unless the
789
+ * core finds otherwise (`ENCORE_TEST=0`, `ENCORE_EXEC`, a runtime config
790
+ * in the environment).
791
+ */
792
+ testRunner?: boolean
793
+ typeConstructors: RuntimeTypeConstructors
794
+ }
795
+
796
+ export interface RuntimeTypeConstructors {
797
+ decimal: (...args: any[]) => any
798
+ }
799
+
800
+ /**
801
+ * What a database handle may do, which decides the connections its statements
802
+ * run on. See [`postgres::Access`].
803
+ */
804
+ export enum SQLAccess {
805
+ /** Read and write, on the primary: a write or admin handle. */
806
+ ReadWrite = 0,
807
+ /** Read only, from a read replica if the database has a read-only pool on one. */
808
+ Read = 1,
809
+ /** Read only, from the primary. */
810
+ ReadPrimary = 2
811
+ }
812
+
813
+ /** The isolation level of a transaction. See [`postgres::IsolationLevel`]. */
814
+ export enum SQLIsolationLevel {
815
+ ReadCommitted = 0,
816
+ RepeatableRead = 1,
817
+ Serializable = 2
818
+ }
819
+
820
+ export class Secret {
821
+ /** Returns the cached value of the secret. */
822
+ cached(): string
823
+ }
824
+
825
+ export interface SignedDownloadUrl {
826
+ url: string
827
+ }
828
+
829
+ export interface SignedUploadUrl {
830
+ url: string
831
+ }
832
+
833
+ export interface SpanContextData {
834
+ /** 25-byte context: trace id, span id, trace flags. */
835
+ ctx: Buffer
836
+ tracestate: string
837
+ }
838
+
839
+ export interface SpanStartResult {
840
+ /** The span's 25-byte context. */
841
+ ctx: Buffer
842
+ tracestate: string
843
+ startUnixNanos: bigint
844
+ startMonoNanos: bigint
845
+ }
846
+
847
+ export class SqlConn {
848
+ close(): Promise<void>
849
+ /**
850
+ * Whether the connection was acquired from a read handle: its
851
+ * transactions are read-only whatever their options say.
852
+ */
853
+ isReadOnly(): boolean
854
+ begin(options?: SqlTransactionOptions | undefined | null, source?: Buffer | undefined | null): Promise<Transaction>
855
+ query(query: string, args: QueryArgs, source?: Buffer | undefined | null): Promise<Cursor>
856
+ }
857
+ export type SQLConn = SqlConn
858
+
859
+ /** A handle to a database for one access level: see [`SQLDatabase::with_access`]. */
860
+ export class SqlDatabase {
861
+ /**
862
+ * A handle to the database for `access`, sharing this one's pool. A read
863
+ * handle runs on read-only connections: a statement that writes fails
864
+ * with SQLSTATE 25006, and the transactions it begins are read-only. See
865
+ * [`postgres::Pool::with_access`].
866
+ */
867
+ withAccess(access: SQLAccess): SqlDatabase
868
+ /**
869
+ * Reports the connection string to connect to this database with the
870
+ * handle's access. A read handle's connects as its statements run, its
871
+ * session read-only: see [`postgres::Database::proxy_conn_string`].
872
+ */
873
+ connString(): string
874
+ /**
875
+ * Whether the handle runs on read-only connections, as a read handle
876
+ * does: its transactions are read-only whatever their options say.
877
+ */
878
+ isReadOnly(): boolean
879
+ /** Begins a transaction, with `options` if given. */
880
+ begin(options?: SqlTransactionOptions | undefined | null, source?: Buffer | undefined | null): Promise<Transaction>
881
+ query(query: string, args: QueryArgs, source?: Buffer | undefined | null): Promise<Cursor>
882
+ /**
883
+ * Takes a connection out of the pool, in the context `source` names:
884
+ * the host's active span context, as a query is given it.
885
+ */
886
+ acquire(source?: Buffer | undefined | null): Promise<SQLConn>
887
+ }
888
+ export type SQLDatabase = SqlDatabase
889
+
890
+ /**
891
+ * How a transaction runs; what isn't set is the database's default. See
892
+ * [`postgres::TransactionOptions`].
893
+ */
894
+ export interface SqlTransactionOptions {
895
+ isolation?: SQLIsolationLevel
896
+ readOnly?: boolean
897
+ deferrable?: boolean
898
+ }
899
+ export type SQLTransactionOptions = SqlTransactionOptions
900
+
901
+ /** The test session a system test's process runs against. */
902
+ export class SystemTest {
903
+ /** The suite the process's tests are of. */
904
+ get suite(): string
905
+ /** The test session's id, as `encore run ls` lists it. */
906
+ get session(): string
907
+ /** The session's service proxy: `/<service>/…` there reaches the service. */
908
+ get proxyUrl(): string
909
+ /**
910
+ * The URL of the gateway or frontend `name` in the session, or null if
911
+ * the app has neither.
912
+ */
913
+ url(name: string): string | null
914
+ /** The names of the session's gateways, sorted. */
915
+ gateways(): Array<string>
916
+ }
917
+
918
+ /**
919
+ * What a system test's calls and messages carry of the test, for those
920
+ * whose context does not already hold it.
921
+ */
922
+ export interface TestCarried {
923
+ /** The name of the Request Context field that holds the test's id. */
924
+ fieldName: string
925
+ /** The field's value, in a field's wire form. */
926
+ field: string
927
+ /**
928
+ * The headers a call made for the test carries, by lowercase name: the
929
+ * field, and the test's span as `traceparent` and `tracestate`.
930
+ */
931
+ headers: Record<string, string>
932
+ /** The test's span as a `traceparent`, where the process records spans. */
933
+ traceparent?: string
934
+ /** The `tracestate` that goes with it. */
935
+ tracestate?: string
936
+ }
937
+
938
+ /**
939
+ * A message to hand a subscription's handler, and which delivery of it this
940
+ * is: 1 the first time.
941
+ */
942
+ export interface TestDelivery {
943
+ message: TestPublished
944
+ attempt: number
945
+ }
946
+
947
+ /** A message a test published. */
948
+ export interface TestPublished {
949
+ id: string
950
+ data: Buffer
951
+ attributes: Record<string, string>
952
+ orderingKey?: string
953
+ /** When it was published, in milliseconds since the Unix epoch. */
954
+ publishTime: number
955
+ }
956
+
957
+ /** One test's infrastructure and overrides, until it ends. */
958
+ export class TestScope {
959
+ /** The scope's id: what its resources are provisioned under. */
960
+ get id(): string
961
+ /**
962
+ * What the test's calls and messages carry of it, when it is a system
963
+ * test: null for a service's test.
964
+ */
965
+ carried(): TestCarried | null
966
+ /**
967
+ * Resolves once nothing the tests set in motion is still running or
968
+ * queued in the test session, waiting for at most `timeoutMs`, or the
969
+ * core's 30 seconds. Rejects, saying what was still under way, if it did
970
+ * not settle in time, and for a test that is no system test.
971
+ */
972
+ settled(timeoutMs?: number | undefined | null): Promise<void>
973
+ /**
974
+ * What the test session recorded for the test so far, as the JSON of
975
+ * the core's model (`Telemetry::to_json`): once the session has settled
976
+ * with `settle`, waiting as `settled` does. Rejects for a test that is no
977
+ * system test.
978
+ */
979
+ telemetry(settle: boolean, timeoutMs?: number | undefined | null): Promise<string>
980
+ /**
981
+ * The test's browser, which the test session runs for it, as JSON
982
+ * (`wsEndpoint`, `urls`, `recording`, `stepsUrl`): started at the first ask, the
983
+ * same one after that. `record` says when what it records is kept
984
+ * (`"failed"`, `"all"` or `"off"`), `args` are more arguments for it,
985
+ * and `width` and `height` its window's size. Rejects for a test that
986
+ * is no system test.
987
+ */
988
+ browser(record?: string | undefined | null, args?: Array<string> | undefined | null, width?: number | undefined | null, height?: number | undefined | null): Promise<string>
989
+ /**
990
+ * Says how the test ended, for the session to record when the test
991
+ * ends: `"passed"`, `"failed"` or `"skipped"`. Nothing for a test that is
992
+ * no system test.
993
+ */
994
+ setOutcome(outcome: 'passed' | 'failed' | 'skipped'): void
995
+ /**
996
+ * Ends the test: its resources are released, unless they are a
997
+ * fixture's. Its handles fail from then on.
998
+ */
999
+ end(): void
1000
+ /**
1001
+ * Makes the test's resources start from the fixture `name`, which must be
1002
+ * built, or from their initial state for null. Fails once the test has
1003
+ * used a resource, unless it is what they started from.
1004
+ */
1005
+ useFixture(name?: string | undefined | null): void
1006
+ /**
1007
+ * Saves what the fixture's setup left in this scope's resources as the
1008
+ * fixture `name`, ending the scope. Resolves once the daemon has saved
1009
+ * them.
1010
+ */
1011
+ saveFixture(name: string): Promise<void>
1012
+ /**
1013
+ * The test's instance of the database `name`, provisioned when first
1014
+ * asked for.
1015
+ */
1016
+ sqlDatabase(name: string): SqlDatabase
1017
+ /**
1018
+ * The test's instance of the ClickHouse database `name`, provisioned
1019
+ * (and migrated) when first asked for.
1020
+ */
1021
+ clickhouseDatabase(name: string): ClickHouseDatabase
1022
+ /**
1023
+ * The test's instance of the bucket `name`, provisioned when first asked
1024
+ * for.
1025
+ */
1026
+ bucket(name: string): Bucket
1027
+ /**
1028
+ * The test's instance of the Redis database `name`, provisioned when
1029
+ * first asked for.
1030
+ */
1031
+ redisDatabase(name: string): RedisDatabase
1032
+ /**
1033
+ * Records a message the test published to the topic `topic`, returning
1034
+ * its id. It is not sent: the test reads it back, or delivers it. Of the
1035
+ * Request Context attributes it keeps those of fields declared with
1036
+ * `pubsub`, as the runtime does when it publishes.
1037
+ */
1038
+ recordPublished(topic: string, data: Buffer, attributes?: Record<string, string> | undefined | null, orderingKey?: string | undefined | null): string
1039
+ /** What the test has published to the topic `topic`, in order. */
1040
+ published(topic: string): Array<TestPublished>
1041
+ /**
1042
+ * The next message the test published to `topic` that `subscription`
1043
+ * has not handled and its filter matches, or null. Settle it with
1044
+ * `settleDelivery` before asking for the next.
1045
+ */
1046
+ nextDelivery(topic: string, subscription: string): TestDelivery | null
1047
+ /**
1048
+ * Settles the message `nextDelivery` last handed `subscription`: past it
1049
+ * if `handled`, or handed over again next time, as its next attempt.
1050
+ */
1051
+ settleDelivery(topic: string, subscription: string, handled: boolean): void
1052
+ /** Gives the secret `name` a value for this test. */
1053
+ setSecret(name: string, value: Buffer): void
1054
+ /** The value the test has given the secret `name`, if it has. */
1055
+ secret(name: string): Buffer | null
1056
+ /**
1057
+ * Gives the config `name` a value for this test, once it satisfies the
1058
+ * config's schema. A config name has one scope across the app, so it is
1059
+ * the name alone. `value` and what it returns are JSON text: the value as
1060
+ * the runtime holds it, with placeholders for its secret fields.
1061
+ */
1062
+ setConfig(name: string, value: string): string
1063
+ /** The value the test has given a config, as JSON text, if it has. */
1064
+ config(name: string): string | null
1065
+ }
1066
+
1067
+ /** The tests of a runtime in test mode. */
1068
+ export class TestScopes {
1069
+ /**
1070
+ * Begins a test: a scope with no resources yet, each provisioned when the
1071
+ * test first asks for it. `name` is for diagnostics only.
1072
+ */
1073
+ begin(name?: string | undefined | null): TestScope
1074
+ /**
1075
+ * The most messages one `deliver` hands a subscription: more is a handler
1076
+ * that publishes to its own topic for ever.
1077
+ */
1078
+ get maxDeliveries(): number
1079
+ /**
1080
+ * The test session the process's tests run against, when they are
1081
+ * system tests: null for the tests of a service.
1082
+ */
1083
+ system(): SystemTest | null
1084
+ /**
1085
+ * Asks for the fixture `name`, which starts from the fixture `parent` if
1086
+ * there is one. Resolves to null once it is built — by this process or
1087
+ * another, which it waits for — or to a scope to build it in: run the
1088
+ * fixture's setup with its resources, then `saveFixture`, or
1089
+ * `failFixture` if the setup fails.
1090
+ */
1091
+ acquireFixture(name: string, parent?: string | undefined | null): Promise<TestScope | null>
1092
+ /**
1093
+ * Gives up building the fixture `name`, with the reason to show whoever
1094
+ * is waiting for it.
1095
+ */
1096
+ failFixture(name: string, message: string): void
1097
+ }
1098
+
1099
+ export class Transaction {
1100
+ isClosed(): boolean
1101
+ commit(): Promise<void>
1102
+ rollback(): Promise<void>
1103
+ query(query: string, args: QueryArgs, source?: Buffer | undefined | null): Promise<Cursor>
1104
+ }
1105
+
1106
+ export class TypedObjectError {
1107
+ kind: ObjectErrorKind
1108
+ message: string
1109
+ }
1110
+
1111
+ /**
1112
+ * Unset fields stay as they are, and `""` clears one (a cleared content type
1113
+ * is `application/octet-stream`). `metadata` replaces the whole map.
1114
+ */
1115
+ export interface UpdateAttrs {
1116
+ contentType?: string
1117
+ cacheControl?: string
1118
+ contentDisposition?: string
1119
+ metadata?: Record<string, string>
1120
+ }
1121
+
1122
+ export interface UpdateAttrsOptions {
1123
+ version?: string
1124
+ ifMatch?: Revision
1125
+ }
1126
+
1127
+ export interface UploadOptions {
1128
+ contentType?: string
1129
+ cacheControl?: string
1130
+ contentDisposition?: string
1131
+ metadata?: Record<string, string>
1132
+ storageClass?: string
1133
+ /** Milliseconds since the Unix epoch. */
1134
+ retainUntil?: number
1135
+ preconditions?: UploadPreconditions
1136
+ }
1137
+
1138
+ export interface UploadPreconditions {
1139
+ notExists?: boolean
1140
+ ifMatch?: Revision
1141
+ }
1142
+
1143
+ /** An upload in progress, fed one chunk at a time. */
1144
+ export class UploadStream {
1145
+ /**
1146
+ * Writes a chunk, waiting while the upload's buffer is full. Returns the
1147
+ * upload's error if it has failed; the upload is then over.
1148
+ */
1149
+ write(chunk: Buffer): Promise<TypedObjectError | null>
1150
+ /** Ends the data and waits for the object to be stored. */
1151
+ finish(): Promise<ObjectAttrs | TypedObjectError>
1152
+ /** Abandons the upload without storing anything. */
1153
+ abort(): Promise<void>
1154
+ }
1155
+
1156
+ export interface UploadUrlOptions {
1157
+ ttl?: number
1158
+ }
1159
+
1160
+ export class VersionIterator {
1161
+ next(): Promise<ObjectVersion | null | TypedObjectError>
1162
+ markDone(): void
1163
+ }
1164
+
1165
+ /**
1166
+ * One log record in the Encore log format, newline included, for the
1167
+ * logger to print. Absent, empty, and 0 are none. `level` is the
1168
+ * OpenTelemetry severity number, 1–24; `time_unix_millis` absent is now;
1169
+ * `span_ctx` is the span's 25-byte context: trace id, span id, flags;
1170
+ * `exception_stacktrace` is in JavaScript's format; `code_*` are the
1171
+ * caller's function, source file, line, and column; `runtime_target` is
1172
+ * the runtime module a line of the runtime's own comes from, logged under
1173
+ * the runtime's logger in place of `logger`; `attrs_json` is a JSON object
1174
+ * of the user's attributes. An attribute named like a reserved key is that
1175
+ * field when valid, `raw.<key>` otherwise; one named like a key of the
1176
+ * record's own fields is `raw.<key>`. Needs no runtime.
1177
+ */
1178
+ export declare function encodeLog(level: number, timeUnixMillis: number | undefined | null, message: string, logger?: string | undefined | null, spanCtx?: Buffer | undefined | null, exceptionType?: string | undefined | null, exceptionMessage?: string | undefined | null, exceptionStacktrace?: string | undefined | null, codeFunction?: string | undefined | null, codeFile?: string | undefined | null, codeLine?: number | undefined | null, codeColumn?: number | undefined | null, runtimeTarget?: string | undefined | null, attrsJson?: string | undefined | null): Buffer
1179
+
1180
+ /**
1181
+ * Lets the request of the `request` event `eventId` through, with
1182
+ * `headerEdits`, the Request Context fields in `context` set (or cleared,
1183
+ * with a null value), `attributes` for its edge span, and the Middleware's
1184
+ * later hooks in `skip` (2 request body, 4 response, 8 response body, 16
1185
+ * complete) skipped. False when no hook waits for it any more.
1186
+ */
1187
+ export declare function gatewayContinue(eventId: number, headerEdits: Array<GatewayHeaderEdit>, context: Array<GatewayField>, attributes: Array<GatewayAttribute>, skip: number): boolean
1188
+
1189
+ /**
1190
+ * How many body chunks and `complete` events were dropped, JavaScript not
1191
+ * keeping up.
1192
+ */
1193
+ export declare function gatewayDropped(): number
1194
+
1195
+ /**
1196
+ * Fails the hook of the event `eventId`, a `"request"` or `"response"`
1197
+ * event as `hook` says, with `message`, `how` it failed: `"error"`, an
1198
+ * error it threw; `"panic"`, one it did not mean to; `"timeout"`, it ran
1199
+ * out of time, which a fail-closed Middleware answers with 503 as it does
1200
+ * the gateway's own timeout. The Middleware's `onError` decides what
1201
+ * becomes of the request. False when no hook waits for it any more.
1202
+ */
1203
+ export declare function gatewayFail(eventId: number, hook: string, message: string, how: string): boolean
1204
+
1205
+ /**
1206
+ * Registers a Middleware, as its JSON spec states it, after those registered
1207
+ * before, and returns its id, which its events name. Names and interests
1208
+ * are checked when the gateway is served.
1209
+ */
1210
+ export declare function gatewayRegister(specJson: string): number
1211
+
1212
+ /**
1213
+ * Answers the request of the `request` event `eventId` itself, with
1214
+ * `status`: an Encore error when `code` is given, with `message`, else
1215
+ * `body` as it is. False when no hook waits for it any more.
1216
+ */
1217
+ export declare function gatewayRespond(eventId: number, status: number, code: string | undefined | null, message: string, headers: Array<GatewayHeader>, body?: Buffer | undefined | null): boolean
1218
+
1219
+ /**
1220
+ * Answers the `response` event `eventId` with `headerEdits` to the
1221
+ * response. False when no hook waits for it any more.
1222
+ */
1223
+ export declare function gatewayResponseEdits(eventId: number, headerEdits: Array<GatewayHeaderEdit>): boolean
1224
+
1225
+ /**
1226
+ * Serves the gateway the runtime config hosts, where the environment says,
1227
+ * with the Middleware registered, until the runtime's shutdown stops it.
1228
+ * Returns once it is listening, with where.
1229
+ *
1230
+ * Each batch of hook events is handed to `onEvents` on the event loop, in
1231
+ * the order the host queued them, and null once the gateway has stopped
1232
+ * and every event was handed on. Until then the event loop is kept alive.
1233
+ */
1234
+ export declare function gatewayServe(runtime: Runtime, onEvents: (events: Array<object> | null) => void): string
1235
+
1236
+ /**
1237
+ * How long, in milliseconds, the hook of the `request` or `response` event
1238
+ * `eventId` has waited for its answer; null once it waits no more, as when
1239
+ * its Middleware's timeout passed and the gateway went on without it. The
1240
+ * dispatcher runs a hook only while it is waited for, and for what is left
1241
+ * of its timeout.
1242
+ */
1243
+ export declare function gatewayWaited(eventId: number): number | null
1244
+
1245
+ /**
1246
+ * Hands the runtime's own log lines to `handler` on the event loop, or
1247
+ * drops them for `null`. Lines logged before the first call are handed
1248
+ * over first. Does not keep the process alive.
1249
+ */
1250
+ export declare function setRuntimeLogHandler(handler: ((line: RuntimeLogLine) => void) | null): void
1251
+