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

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 +271 -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 +1249 -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 +320 -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 +1249 -0
  414. package/internal/runtime/shutdown.test.ts +464 -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 +341 -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 +98 -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 +393 -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 +276 -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,1249 @@
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
+ appMeta(): AppMeta
751
+ runtimeConfig(): RuntimeConfig
752
+ }
753
+
754
+ export interface RuntimeConfig {
755
+ /** The service hosted by this process, if any. */
756
+ currentService?: string
757
+ /**
758
+ * The Worker of that service this process runs; none for its main
759
+ * process.
760
+ */
761
+ currentWorker?: string
762
+ /**
763
+ * Base URLs of the services this process can reach, keyed by service
764
+ * name.
765
+ */
766
+ services: Record<string, string>
767
+ }
768
+
769
+ /** One runtime log line. */
770
+ export interface RuntimeLogLine {
771
+ /** 1 ERROR, 2 WARN, 3 INFO, 4 DEBUG, 5 TRACE. */
772
+ level: number
773
+ /** The module path, or `file:line`, the line comes from. */
774
+ target: string
775
+ message: string
776
+ /** A JSON object of key-values, `exception.*` included. */
777
+ fields: string
778
+ /** The current span's 25-byte context when the line was logged. */
779
+ spanCtx?: Buffer
780
+ }
781
+
782
+ export interface RuntimeOptions {
783
+ testMode?: boolean
784
+ /**
785
+ * Whether the process is a test runner's, as the SDK finds from its
786
+ * environment: it is then in test mode without `encore test`, unless the
787
+ * core finds otherwise (`ENCORE_TEST=0`, `ENCORE_EXEC`, a runtime config
788
+ * in the environment).
789
+ */
790
+ testRunner?: boolean
791
+ typeConstructors: RuntimeTypeConstructors
792
+ }
793
+
794
+ export interface RuntimeTypeConstructors {
795
+ decimal: (...args: any[]) => any
796
+ }
797
+
798
+ /**
799
+ * What a database handle may do, which decides the connections its statements
800
+ * run on. See [`postgres::Access`].
801
+ */
802
+ export enum SQLAccess {
803
+ /** Read and write, on the primary: a write or admin handle. */
804
+ ReadWrite = 0,
805
+ /** Read only, from a read replica if the database has a read-only pool on one. */
806
+ Read = 1,
807
+ /** Read only, from the primary. */
808
+ ReadPrimary = 2
809
+ }
810
+
811
+ /** The isolation level of a transaction. See [`postgres::IsolationLevel`]. */
812
+ export enum SQLIsolationLevel {
813
+ ReadCommitted = 0,
814
+ RepeatableRead = 1,
815
+ Serializable = 2
816
+ }
817
+
818
+ export class Secret {
819
+ /** Returns the cached value of the secret. */
820
+ cached(): string
821
+ }
822
+
823
+ export interface SignedDownloadUrl {
824
+ url: string
825
+ }
826
+
827
+ export interface SignedUploadUrl {
828
+ url: string
829
+ }
830
+
831
+ export interface SpanContextData {
832
+ /** 25-byte context: trace id, span id, trace flags. */
833
+ ctx: Buffer
834
+ tracestate: string
835
+ }
836
+
837
+ export interface SpanStartResult {
838
+ /** The span's 25-byte context. */
839
+ ctx: Buffer
840
+ tracestate: string
841
+ startUnixNanos: bigint
842
+ startMonoNanos: bigint
843
+ }
844
+
845
+ export class SqlConn {
846
+ close(): Promise<void>
847
+ /**
848
+ * Whether the connection was acquired from a read handle: its
849
+ * transactions are read-only whatever their options say.
850
+ */
851
+ isReadOnly(): boolean
852
+ begin(options?: SqlTransactionOptions | undefined | null, source?: Buffer | undefined | null): Promise<Transaction>
853
+ query(query: string, args: QueryArgs, source?: Buffer | undefined | null): Promise<Cursor>
854
+ }
855
+ export type SQLConn = SqlConn
856
+
857
+ /** A handle to a database for one access level: see [`SQLDatabase::with_access`]. */
858
+ export class SqlDatabase {
859
+ /**
860
+ * A handle to the database for `access`, sharing this one's pool. A read
861
+ * handle runs on read-only connections: a statement that writes fails
862
+ * with SQLSTATE 25006, and the transactions it begins are read-only. See
863
+ * [`postgres::Pool::with_access`].
864
+ */
865
+ withAccess(access: SQLAccess): SqlDatabase
866
+ /**
867
+ * Reports the connection string to connect to this database with the
868
+ * handle's access. A read handle's connects as its statements run, its
869
+ * session read-only: see [`postgres::Database::proxy_conn_string`].
870
+ */
871
+ connString(): string
872
+ /**
873
+ * Whether the handle runs on read-only connections, as a read handle
874
+ * does: its transactions are read-only whatever their options say.
875
+ */
876
+ isReadOnly(): boolean
877
+ /** Begins a transaction, with `options` if given. */
878
+ begin(options?: SqlTransactionOptions | undefined | null, source?: Buffer | undefined | null): Promise<Transaction>
879
+ query(query: string, args: QueryArgs, source?: Buffer | undefined | null): Promise<Cursor>
880
+ /**
881
+ * Takes a connection out of the pool, in the context `source` names:
882
+ * the host's active span context, as a query is given it.
883
+ */
884
+ acquire(source?: Buffer | undefined | null): Promise<SQLConn>
885
+ }
886
+ export type SQLDatabase = SqlDatabase
887
+
888
+ /**
889
+ * How a transaction runs; what isn't set is the database's default. See
890
+ * [`postgres::TransactionOptions`].
891
+ */
892
+ export interface SqlTransactionOptions {
893
+ isolation?: SQLIsolationLevel
894
+ readOnly?: boolean
895
+ deferrable?: boolean
896
+ }
897
+ export type SQLTransactionOptions = SqlTransactionOptions
898
+
899
+ /** The test session a system test's process runs against. */
900
+ export class SystemTest {
901
+ /** The suite the process's tests are of. */
902
+ get suite(): string
903
+ /** The test session's id, as `encore run ls` lists it. */
904
+ get session(): string
905
+ /** The session's service proxy: `/<service>/…` there reaches the service. */
906
+ get proxyUrl(): string
907
+ /**
908
+ * The URL of the gateway or frontend `name` in the session, or null if
909
+ * the app has neither.
910
+ */
911
+ url(name: string): string | null
912
+ /** The names of the session's gateways, sorted. */
913
+ gateways(): Array<string>
914
+ }
915
+
916
+ /**
917
+ * What a system test's calls and messages carry of the test, for those
918
+ * whose context does not already hold it.
919
+ */
920
+ export interface TestCarried {
921
+ /** The name of the Request Context field that holds the test's id. */
922
+ fieldName: string
923
+ /** The field's value, in a field's wire form. */
924
+ field: string
925
+ /**
926
+ * The headers a call made for the test carries, by lowercase name: the
927
+ * field, and the test's span as `traceparent` and `tracestate`.
928
+ */
929
+ headers: Record<string, string>
930
+ /** The test's span as a `traceparent`, where the process records spans. */
931
+ traceparent?: string
932
+ /** The `tracestate` that goes with it. */
933
+ tracestate?: string
934
+ }
935
+
936
+ /**
937
+ * A message to hand a subscription's handler, and which delivery of it this
938
+ * is: 1 the first time.
939
+ */
940
+ export interface TestDelivery {
941
+ message: TestPublished
942
+ attempt: number
943
+ }
944
+
945
+ /** A message a test published. */
946
+ export interface TestPublished {
947
+ id: string
948
+ data: Buffer
949
+ attributes: Record<string, string>
950
+ orderingKey?: string
951
+ /** When it was published, in milliseconds since the Unix epoch. */
952
+ publishTime: number
953
+ }
954
+
955
+ /** One test's infrastructure and overrides, until it ends. */
956
+ export class TestScope {
957
+ /** The scope's id: what its resources are provisioned under. */
958
+ get id(): string
959
+ /**
960
+ * What the test's calls and messages carry of it, when it is a system
961
+ * test: null for a service's test.
962
+ */
963
+ carried(): TestCarried | null
964
+ /**
965
+ * Resolves once nothing the tests set in motion is still running or
966
+ * queued in the test session, waiting for at most `timeoutMs`, or the
967
+ * core's 30 seconds. Rejects, saying what was still under way, if it did
968
+ * not settle in time, and for a test that is no system test.
969
+ */
970
+ settled(timeoutMs?: number | undefined | null): Promise<void>
971
+ /**
972
+ * What the test session recorded for the test so far, as the JSON of
973
+ * the core's model (`Telemetry::to_json`): once the session has settled
974
+ * with `settle`, waiting as `settled` does. Rejects for a test that is no
975
+ * system test.
976
+ */
977
+ telemetry(settle: boolean, timeoutMs?: number | undefined | null): Promise<string>
978
+ /**
979
+ * The test's browser, which the test session runs for it, as JSON
980
+ * (`wsEndpoint`, `urls`, `recording`, `stepsUrl`): started at the first ask, the
981
+ * same one after that. `record` says when what it records is kept
982
+ * (`"failed"`, `"all"` or `"off"`), `args` are more arguments for it,
983
+ * and `width` and `height` its window's size. Rejects for a test that
984
+ * is no system test.
985
+ */
986
+ browser(record?: string | undefined | null, args?: Array<string> | undefined | null, width?: number | undefined | null, height?: number | undefined | null): Promise<string>
987
+ /**
988
+ * Says how the test ended, for the session to record when the test
989
+ * ends: `"passed"`, `"failed"` or `"skipped"`. Nothing for a test that is
990
+ * no system test.
991
+ */
992
+ setOutcome(outcome: 'passed' | 'failed' | 'skipped'): void
993
+ /**
994
+ * Ends the test: its resources are released, unless they are a
995
+ * fixture's. Its handles fail from then on.
996
+ */
997
+ end(): void
998
+ /**
999
+ * Makes the test's resources start from the fixture `name`, which must be
1000
+ * built, or from their initial state for null. Fails once the test has
1001
+ * used a resource, unless it is what they started from.
1002
+ */
1003
+ useFixture(name?: string | undefined | null): void
1004
+ /**
1005
+ * Saves what the fixture's setup left in this scope's resources as the
1006
+ * fixture `name`, ending the scope. Resolves once the daemon has saved
1007
+ * them.
1008
+ */
1009
+ saveFixture(name: string): Promise<void>
1010
+ /**
1011
+ * The test's instance of the database `name`, provisioned when first
1012
+ * asked for.
1013
+ */
1014
+ sqlDatabase(name: string): SqlDatabase
1015
+ /**
1016
+ * The test's instance of the ClickHouse database `name`, provisioned
1017
+ * (and migrated) when first asked for.
1018
+ */
1019
+ clickhouseDatabase(name: string): ClickHouseDatabase
1020
+ /**
1021
+ * The test's instance of the bucket `name`, provisioned when first asked
1022
+ * for.
1023
+ */
1024
+ bucket(name: string): Bucket
1025
+ /**
1026
+ * The test's instance of the Redis database `name`, provisioned when
1027
+ * first asked for.
1028
+ */
1029
+ redisDatabase(name: string): RedisDatabase
1030
+ /**
1031
+ * Records a message the test published to the topic `topic`, returning
1032
+ * its id. It is not sent: the test reads it back, or delivers it. Of the
1033
+ * Request Context attributes it keeps those of fields declared with
1034
+ * `pubsub`, as the runtime does when it publishes.
1035
+ */
1036
+ recordPublished(topic: string, data: Buffer, attributes?: Record<string, string> | undefined | null, orderingKey?: string | undefined | null): string
1037
+ /** What the test has published to the topic `topic`, in order. */
1038
+ published(topic: string): Array<TestPublished>
1039
+ /**
1040
+ * The next message the test published to `topic` that `subscription`
1041
+ * has not handled and its filter matches, or null. Settle it with
1042
+ * `settleDelivery` before asking for the next.
1043
+ */
1044
+ nextDelivery(topic: string, subscription: string): TestDelivery | null
1045
+ /**
1046
+ * Settles the message `nextDelivery` last handed `subscription`: past it
1047
+ * if `handled`, or handed over again next time, as its next attempt.
1048
+ */
1049
+ settleDelivery(topic: string, subscription: string, handled: boolean): void
1050
+ /** Gives the secret `name` a value for this test. */
1051
+ setSecret(name: string, value: Buffer): void
1052
+ /** The value the test has given the secret `name`, if it has. */
1053
+ secret(name: string): Buffer | null
1054
+ /**
1055
+ * Gives the config `name` a value for this test, once it satisfies the
1056
+ * config's schema. A config name has one scope across the app, so it is
1057
+ * the name alone. `value` and what it returns are JSON text: the value as
1058
+ * the runtime holds it, with placeholders for its secret fields.
1059
+ */
1060
+ setConfig(name: string, value: string): string
1061
+ /** The value the test has given a config, as JSON text, if it has. */
1062
+ config(name: string): string | null
1063
+ }
1064
+
1065
+ /** The tests of a runtime in test mode. */
1066
+ export class TestScopes {
1067
+ /**
1068
+ * Begins a test: a scope with no resources yet, each provisioned when the
1069
+ * test first asks for it. `name` is for diagnostics only.
1070
+ */
1071
+ begin(name?: string | undefined | null): TestScope
1072
+ /**
1073
+ * The most messages one `deliver` hands a subscription: more is a handler
1074
+ * that publishes to its own topic for ever.
1075
+ */
1076
+ get maxDeliveries(): number
1077
+ /**
1078
+ * The test session the process's tests run against, when they are
1079
+ * system tests: null for the tests of a service.
1080
+ */
1081
+ system(): SystemTest | null
1082
+ /**
1083
+ * Asks for the fixture `name`, which starts from the fixture `parent` if
1084
+ * there is one. Resolves to null once it is built — by this process or
1085
+ * another, which it waits for — or to a scope to build it in: run the
1086
+ * fixture's setup with its resources, then `saveFixture`, or
1087
+ * `failFixture` if the setup fails.
1088
+ */
1089
+ acquireFixture(name: string, parent?: string | undefined | null): Promise<TestScope | null>
1090
+ /**
1091
+ * Gives up building the fixture `name`, with the reason to show whoever
1092
+ * is waiting for it.
1093
+ */
1094
+ failFixture(name: string, message: string): void
1095
+ }
1096
+
1097
+ export class Transaction {
1098
+ isClosed(): boolean
1099
+ commit(): Promise<void>
1100
+ rollback(): Promise<void>
1101
+ query(query: string, args: QueryArgs, source?: Buffer | undefined | null): Promise<Cursor>
1102
+ }
1103
+
1104
+ export class TypedObjectError {
1105
+ kind: ObjectErrorKind
1106
+ message: string
1107
+ }
1108
+
1109
+ /**
1110
+ * Unset fields stay as they are, and `""` clears one (a cleared content type
1111
+ * is `application/octet-stream`). `metadata` replaces the whole map.
1112
+ */
1113
+ export interface UpdateAttrs {
1114
+ contentType?: string
1115
+ cacheControl?: string
1116
+ contentDisposition?: string
1117
+ metadata?: Record<string, string>
1118
+ }
1119
+
1120
+ export interface UpdateAttrsOptions {
1121
+ version?: string
1122
+ ifMatch?: Revision
1123
+ }
1124
+
1125
+ export interface UploadOptions {
1126
+ contentType?: string
1127
+ cacheControl?: string
1128
+ contentDisposition?: string
1129
+ metadata?: Record<string, string>
1130
+ storageClass?: string
1131
+ /** Milliseconds since the Unix epoch. */
1132
+ retainUntil?: number
1133
+ preconditions?: UploadPreconditions
1134
+ }
1135
+
1136
+ export interface UploadPreconditions {
1137
+ notExists?: boolean
1138
+ ifMatch?: Revision
1139
+ }
1140
+
1141
+ /** An upload in progress, fed one chunk at a time. */
1142
+ export class UploadStream {
1143
+ /**
1144
+ * Writes a chunk, waiting while the upload's buffer is full. Returns the
1145
+ * upload's error if it has failed; the upload is then over.
1146
+ */
1147
+ write(chunk: Buffer): Promise<TypedObjectError | null>
1148
+ /** Ends the data and waits for the object to be stored. */
1149
+ finish(): Promise<ObjectAttrs | TypedObjectError>
1150
+ /** Abandons the upload without storing anything. */
1151
+ abort(): Promise<void>
1152
+ }
1153
+
1154
+ export interface UploadUrlOptions {
1155
+ ttl?: number
1156
+ }
1157
+
1158
+ export class VersionIterator {
1159
+ next(): Promise<ObjectVersion | null | TypedObjectError>
1160
+ markDone(): void
1161
+ }
1162
+
1163
+ /**
1164
+ * One log record in the Encore log format, newline included, for the
1165
+ * logger to print. Absent, empty, and 0 are none. `level` is the
1166
+ * OpenTelemetry severity number, 1–24; `time_unix_millis` absent is now;
1167
+ * `span_ctx` is the span's 25-byte context: trace id, span id, flags;
1168
+ * `exception_stacktrace` is in JavaScript's format; `code_*` are the
1169
+ * caller's function, source file, line, and column; `runtime_target` is
1170
+ * the runtime module a line of the runtime's own comes from, logged under
1171
+ * the runtime's logger in place of `logger`; `attrs_json` is a JSON object
1172
+ * of the user's attributes. An attribute named like a reserved key is that
1173
+ * field when valid, `raw.<key>` otherwise; one named like a key of the
1174
+ * record's own fields is `raw.<key>`. Needs no runtime.
1175
+ */
1176
+ 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
1177
+
1178
+ /**
1179
+ * Lets the request of the `request` event `eventId` through, with
1180
+ * `headerEdits`, the Request Context fields in `context` set (or cleared,
1181
+ * with a null value), `attributes` for its edge span, and the Middleware's
1182
+ * later hooks in `skip` (2 request body, 4 response, 8 response body, 16
1183
+ * complete) skipped. False when no hook waits for it any more.
1184
+ */
1185
+ export declare function gatewayContinue(eventId: number, headerEdits: Array<GatewayHeaderEdit>, context: Array<GatewayField>, attributes: Array<GatewayAttribute>, skip: number): boolean
1186
+
1187
+ /**
1188
+ * How many body chunks and `complete` events were dropped, JavaScript not
1189
+ * keeping up.
1190
+ */
1191
+ export declare function gatewayDropped(): number
1192
+
1193
+ /**
1194
+ * Fails the hook of the event `eventId`, a `"request"` or `"response"`
1195
+ * event as `hook` says, with `message`, `how` it failed: `"error"`, an
1196
+ * error it threw; `"panic"`, one it did not mean to; `"timeout"`, it ran
1197
+ * out of time, which a fail-closed Middleware answers with 503 as it does
1198
+ * the gateway's own timeout. The Middleware's `onError` decides what
1199
+ * becomes of the request. False when no hook waits for it any more.
1200
+ */
1201
+ export declare function gatewayFail(eventId: number, hook: string, message: string, how: string): boolean
1202
+
1203
+ /**
1204
+ * Registers a Middleware, as its JSON spec states it, after those registered
1205
+ * before, and returns its id, which its events name. Names and interests
1206
+ * are checked when the gateway is served.
1207
+ */
1208
+ export declare function gatewayRegister(specJson: string): number
1209
+
1210
+ /**
1211
+ * Answers the request of the `request` event `eventId` itself, with
1212
+ * `status`: an Encore error when `code` is given, with `message`, else
1213
+ * `body` as it is. False when no hook waits for it any more.
1214
+ */
1215
+ export declare function gatewayRespond(eventId: number, status: number, code: string | undefined | null, message: string, headers: Array<GatewayHeader>, body?: Buffer | undefined | null): boolean
1216
+
1217
+ /**
1218
+ * Answers the `response` event `eventId` with `headerEdits` to the
1219
+ * response. False when no hook waits for it any more.
1220
+ */
1221
+ export declare function gatewayResponseEdits(eventId: number, headerEdits: Array<GatewayHeaderEdit>): boolean
1222
+
1223
+ /**
1224
+ * Serves the gateway the runtime config hosts, where the environment says,
1225
+ * with the Middleware registered, until the runtime's shutdown stops it.
1226
+ * Returns once it is listening, with where.
1227
+ *
1228
+ * Each batch of hook events is handed to `onEvents` on the event loop, in
1229
+ * the order the host queued them, and null once the gateway has stopped
1230
+ * and every event was handed on. Until then the event loop is kept alive.
1231
+ */
1232
+ export declare function gatewayServe(runtime: Runtime, onEvents: (events: Array<object> | null) => void): string
1233
+
1234
+ /**
1235
+ * How long, in milliseconds, the hook of the `request` or `response` event
1236
+ * `eventId` has waited for its answer; null once it waits no more, as when
1237
+ * its Middleware's timeout passed and the gateway went on without it. The
1238
+ * dispatcher runs a hook only while it is waited for, and for what is left
1239
+ * of its timeout.
1240
+ */
1241
+ export declare function gatewayWaited(eventId: number): number | null
1242
+
1243
+ /**
1244
+ * Hands the runtime's own log lines to `handler` on the event loop, or
1245
+ * drops them for `null`. Lines logged before the first call are handed
1246
+ * over first. Does not keep the process alive.
1247
+ */
1248
+ export declare function setRuntimeLogHandler(handler: ((line: RuntimeLogLine) => void) | null): void
1249
+