@encore.dev/sdk 2.0.0-beta.7 → 2.0.0-beta.9

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 (424) hide show
  1. package/README.md +109 -0
  2. package/app_meta.test.ts +25 -5
  3. package/app_meta.ts +51 -12
  4. package/config/config.test.ts +18 -15
  5. package/config/config.ts +89 -31
  6. package/config/mod.ts +4 -3
  7. package/config/secrets.ts +79 -53
  8. package/config/value.ts +13 -17
  9. package/cron/mod.test.ts +52 -0
  10. package/cron/mod.ts +41 -2
  11. package/dist/app_meta.d.ts +44 -12
  12. package/dist/app_meta.d.ts.map +1 -0
  13. package/dist/app_meta.js +2 -0
  14. package/dist/app_meta.js.map +1 -1
  15. package/dist/config/config.d.ts +58 -28
  16. package/dist/config/config.d.ts.map +1 -0
  17. package/dist/config/config.js +46 -18
  18. package/dist/config/config.js.map +1 -1
  19. package/dist/config/mod.d.ts +5 -4
  20. package/dist/config/mod.d.ts.map +1 -0
  21. package/dist/config/mod.js +2 -2
  22. package/dist/config/mod.js.map +1 -1
  23. package/dist/config/secrets.d.ts +71 -39
  24. package/dist/config/secrets.d.ts.map +1 -0
  25. package/dist/config/secrets.js +31 -38
  26. package/dist/config/secrets.js.map +1 -1
  27. package/dist/config/value.d.ts +8 -5
  28. package/dist/config/value.d.ts.map +1 -0
  29. package/dist/config/value.js +10 -7
  30. package/dist/config/value.js.map +1 -1
  31. package/dist/cron/mod.d.ts +36 -1
  32. package/dist/cron/mod.d.ts.map +1 -0
  33. package/dist/cron/mod.js +31 -1
  34. package/dist/cron/mod.js.map +1 -1
  35. package/dist/frontends/mod.d.ts +39 -0
  36. package/dist/frontends/mod.d.ts.map +1 -0
  37. package/dist/frontends/mod.js +47 -0
  38. package/dist/frontends/mod.js.map +1 -0
  39. package/dist/gateway/errors.d.ts +101 -0
  40. package/dist/gateway/errors.d.ts.map +1 -0
  41. package/dist/gateway/errors.js +146 -0
  42. package/dist/gateway/errors.js.map +1 -0
  43. package/dist/gateway/match.d.ts +127 -0
  44. package/dist/gateway/match.d.ts.map +1 -0
  45. package/dist/gateway/match.js +206 -0
  46. package/dist/gateway/match.js.map +1 -0
  47. package/dist/gateway/middleware.d.ts +108 -0
  48. package/dist/gateway/middleware.d.ts.map +1 -0
  49. package/dist/gateway/middleware.js +9 -0
  50. package/dist/gateway/middleware.js.map +1 -0
  51. package/dist/gateway/mod.d.ts +130 -0
  52. package/dist/gateway/mod.d.ts.map +1 -0
  53. package/dist/gateway/mod.js +188 -0
  54. package/dist/gateway/mod.js.map +1 -0
  55. package/dist/gateway/request.d.ts +304 -0
  56. package/dist/gateway/request.d.ts.map +1 -0
  57. package/dist/gateway/request.js +403 -0
  58. package/dist/gateway/request.js.map +1 -0
  59. package/dist/gateway/serve.d.ts +114 -0
  60. package/dist/gateway/serve.d.ts.map +1 -0
  61. package/dist/gateway/serve.js +510 -0
  62. package/dist/gateway/serve.js.map +1 -0
  63. package/dist/gateways/mod.d.ts +42 -0
  64. package/dist/gateways/mod.d.ts.map +1 -0
  65. package/dist/gateways/mod.js +55 -0
  66. package/dist/gateways/mod.js.map +1 -0
  67. package/dist/internal/clients/call.d.ts +147 -0
  68. package/dist/internal/clients/call.d.ts.map +1 -0
  69. package/dist/internal/clients/call.js +274 -0
  70. package/dist/internal/clients/call.js.map +1 -0
  71. package/dist/internal/clients/grpc.d.ts +90 -0
  72. package/dist/internal/clients/grpc.d.ts.map +1 -0
  73. package/dist/internal/clients/grpc.js +355 -0
  74. package/dist/internal/clients/grpc.js.map +1 -0
  75. package/dist/internal/clients/mod.d.ts +81 -0
  76. package/dist/internal/clients/mod.d.ts.map +1 -0
  77. package/dist/internal/clients/mod.js +237 -0
  78. package/dist/internal/clients/mod.js.map +1 -0
  79. package/dist/internal/fetch.d.ts +58 -0
  80. package/dist/internal/fetch.d.ts.map +1 -0
  81. package/dist/internal/fetch.js +251 -0
  82. package/dist/internal/fetch.js.map +1 -0
  83. package/dist/internal/otel/backend.d.ts +2 -0
  84. package/dist/internal/otel/backend.d.ts.map +1 -0
  85. package/dist/internal/otel/context.d.ts +1 -0
  86. package/dist/internal/otel/context.d.ts.map +1 -0
  87. package/dist/internal/otel/context_manager.d.ts +1 -0
  88. package/dist/internal/otel/context_manager.d.ts.map +1 -0
  89. package/dist/internal/otel/encode.d.ts +2 -0
  90. package/dist/internal/otel/encode.d.ts.map +1 -0
  91. package/dist/internal/otel/http.d.ts +11 -0
  92. package/dist/internal/otel/http.d.ts.map +1 -0
  93. package/dist/internal/otel/http.js +64 -0
  94. package/dist/internal/otel/http.js.map +1 -0
  95. package/dist/internal/otel/index.d.ts +2 -2
  96. package/dist/internal/otel/index.d.ts.map +1 -0
  97. package/dist/internal/otel/index.js +1 -2
  98. package/dist/internal/otel/index.js.map +1 -1
  99. package/dist/internal/otel/meter.d.ts +1 -0
  100. package/dist/internal/otel/meter.d.ts.map +1 -0
  101. package/dist/internal/otel/propagator.d.ts +1 -0
  102. package/dist/internal/otel/propagator.d.ts.map +1 -0
  103. package/dist/internal/otel/provider.d.ts +4 -0
  104. package/dist/internal/otel/provider.d.ts.map +1 -0
  105. package/dist/internal/otel/provider.js +3 -0
  106. package/dist/internal/otel/provider.js.map +1 -1
  107. package/dist/internal/otel/span.d.ts +15 -1
  108. package/dist/internal/otel/span.d.ts.map +1 -0
  109. package/dist/internal/otel/span.js +30 -2
  110. package/dist/internal/otel/span.js.map +1 -1
  111. package/dist/internal/otel/tracer.d.ts +1 -0
  112. package/dist/internal/otel/tracer.d.ts.map +1 -0
  113. package/dist/internal/otel/tracer.js +11 -5
  114. package/dist/internal/otel/tracer.js.map +1 -1
  115. package/dist/internal/reqfields.d.ts +170 -0
  116. package/dist/internal/reqfields.d.ts.map +1 -0
  117. package/dist/internal/reqfields.js +349 -0
  118. package/dist/internal/reqfields.js.map +1 -0
  119. package/dist/internal/runtime/meter.d.ts +1 -0
  120. package/dist/internal/runtime/meter.d.ts.map +1 -0
  121. package/dist/internal/runtime/mod.d.ts +6 -0
  122. package/dist/internal/runtime/mod.d.ts.map +1 -0
  123. package/dist/internal/runtime/mod.js +32 -2
  124. package/dist/internal/runtime/mod.js.map +1 -1
  125. package/dist/internal/runtime/napi/napi.cjs +192 -16
  126. package/dist/internal/runtime/napi/napi.d.cts +573 -33
  127. package/dist/internal/runtime/shutdown.d.ts +5 -0
  128. package/dist/internal/runtime/shutdown.d.ts.map +1 -0
  129. package/dist/internal/runtime/shutdown.js +9 -1
  130. package/dist/internal/runtime/shutdown.js.map +1 -1
  131. package/dist/internal/testing/carry.d.ts +49 -0
  132. package/dist/internal/testing/carry.d.ts.map +1 -0
  133. package/dist/internal/testing/carry.js +77 -0
  134. package/dist/internal/testing/carry.js.map +1 -0
  135. package/dist/internal/testing/runner.d.ts +2 -0
  136. package/dist/internal/testing/runner.d.ts.map +1 -0
  137. package/dist/internal/testing/runner.js +10 -0
  138. package/dist/internal/testing/runner.js.map +1 -0
  139. package/dist/internal/testing/scope.d.ts +109 -0
  140. package/dist/internal/testing/scope.d.ts.map +1 -0
  141. package/dist/internal/testing/scope.js +335 -0
  142. package/dist/internal/testing/scope.js.map +1 -0
  143. package/dist/internal/testing/steps.d.ts +55 -0
  144. package/dist/internal/testing/steps.d.ts.map +1 -0
  145. package/dist/internal/testing/steps.js +295 -0
  146. package/dist/internal/testing/steps.js.map +1 -0
  147. package/dist/internal/testing/telemetry.d.ts +305 -0
  148. package/dist/internal/testing/telemetry.d.ts.map +1 -0
  149. package/dist/internal/testing/telemetry.js +188 -0
  150. package/dist/internal/testing/telemetry.js.map +1 -0
  151. package/dist/internal/utils/constraints.d.ts +1 -0
  152. package/dist/internal/utils/constraints.d.ts.map +1 -0
  153. package/dist/log/index.d.ts +1 -0
  154. package/dist/log/index.d.ts.map +1 -0
  155. package/dist/log/logger.d.ts +2 -0
  156. package/dist/log/logger.d.ts.map +1 -0
  157. package/dist/log/runtime.d.ts +2 -0
  158. package/dist/log/runtime.d.ts.map +1 -0
  159. package/dist/log/stderr.d.ts +1 -0
  160. package/dist/log/stderr.d.ts.map +1 -0
  161. package/dist/metrics/mod.d.ts +45 -118
  162. package/dist/metrics/mod.d.ts.map +1 -0
  163. package/dist/metrics/mod.js +44 -179
  164. package/dist/metrics/mod.js.map +1 -1
  165. package/dist/mod.d.ts +2 -3
  166. package/dist/mod.d.ts.map +1 -0
  167. package/dist/mod.js +0 -1
  168. package/dist/mod.js.map +1 -1
  169. package/dist/otel.d.ts +1 -0
  170. package/dist/otel.d.ts.map +1 -0
  171. package/dist/pubsub/encoding.d.ts +5 -0
  172. package/dist/pubsub/encoding.d.ts.map +1 -0
  173. package/dist/pubsub/encoding.js +10 -2
  174. package/dist/pubsub/encoding.js.map +1 -1
  175. package/dist/pubsub/mod.d.ts +5 -4
  176. package/dist/pubsub/mod.d.ts.map +1 -0
  177. package/dist/pubsub/mod.js +2 -2
  178. package/dist/pubsub/mod.js.map +1 -1
  179. package/dist/pubsub/refs.d.ts +8 -0
  180. package/dist/pubsub/refs.d.ts.map +1 -0
  181. package/dist/pubsub/refs.js.map +1 -1
  182. package/dist/pubsub/subscription.d.ts +110 -15
  183. package/dist/pubsub/subscription.d.ts.map +1 -0
  184. package/dist/pubsub/subscription.js +98 -16
  185. package/dist/pubsub/subscription.js.map +1 -1
  186. package/dist/pubsub/topic.d.ts +101 -31
  187. package/dist/pubsub/topic.d.ts.map +1 -0
  188. package/dist/pubsub/topic.js +168 -51
  189. package/dist/pubsub/topic.js.map +1 -1
  190. package/dist/reqctx/mod.d.ts +174 -0
  191. package/dist/reqctx/mod.d.ts.map +1 -0
  192. package/dist/reqctx/mod.js +144 -0
  193. package/dist/reqctx/mod.js.map +1 -0
  194. package/dist/services/index.d.ts +147 -5
  195. package/dist/services/index.d.ts.map +1 -0
  196. package/dist/services/index.js +157 -9
  197. package/dist/services/index.js.map +1 -1
  198. package/dist/shutdown/mod.d.ts +1 -0
  199. package/dist/shutdown/mod.d.ts.map +1 -0
  200. package/dist/storage/objects/bucket.d.ts +313 -7
  201. package/dist/storage/objects/bucket.d.ts.map +1 -0
  202. package/dist/storage/objects/bucket.js +306 -15
  203. package/dist/storage/objects/bucket.js.map +1 -1
  204. package/dist/storage/objects/error.d.ts +10 -0
  205. package/dist/storage/objects/error.d.ts.map +1 -0
  206. package/dist/storage/objects/error.js +25 -1
  207. package/dist/storage/objects/error.js.map +1 -1
  208. package/dist/storage/objects/mod.d.ts +4 -3
  209. package/dist/storage/objects/mod.d.ts.map +1 -0
  210. package/dist/storage/objects/mod.js +1 -1
  211. package/dist/storage/objects/mod.js.map +1 -1
  212. package/dist/storage/objects/refs.d.ts +20 -4
  213. package/dist/storage/objects/refs.d.ts.map +1 -0
  214. package/dist/storage/objects/refs.js +6 -0
  215. package/dist/storage/objects/refs.js.map +1 -1
  216. package/dist/storage/postgres/database.d.ts +85 -25
  217. package/dist/storage/postgres/database.d.ts.map +1 -0
  218. package/dist/storage/postgres/database.js +129 -37
  219. package/dist/storage/postgres/database.js.map +1 -1
  220. package/dist/storage/postgres/errors.d.ts +120 -0
  221. package/dist/storage/postgres/errors.d.ts.map +1 -0
  222. package/dist/storage/postgres/errors.js +162 -0
  223. package/dist/storage/postgres/errors.js.map +1 -0
  224. package/dist/storage/postgres/interval.d.ts +44 -0
  225. package/dist/storage/postgres/interval.d.ts.map +1 -0
  226. package/dist/storage/postgres/interval.js +153 -0
  227. package/dist/storage/postgres/interval.js.map +1 -0
  228. package/dist/storage/postgres/mod.d.ts +4 -1
  229. package/dist/storage/postgres/mod.d.ts.map +1 -0
  230. package/dist/storage/postgres/mod.js +2 -0
  231. package/dist/storage/postgres/mod.js.map +1 -1
  232. package/dist/storage/redis/bitfield.d.ts +67 -0
  233. package/dist/storage/redis/bitfield.d.ts.map +1 -0
  234. package/dist/storage/redis/bitfield.js +114 -0
  235. package/dist/storage/redis/bitfield.js.map +1 -0
  236. package/dist/storage/redis/command.d.ts +45 -0
  237. package/dist/storage/redis/command.d.ts.map +1 -0
  238. package/dist/storage/redis/command.js +78 -0
  239. package/dist/storage/redis/command.js.map +1 -0
  240. package/dist/storage/redis/commands.d.ts +223 -139
  241. package/dist/storage/redis/commands.d.ts.map +1 -0
  242. package/dist/storage/redis/commands.js +128 -6
  243. package/dist/storage/redis/commands.js.map +1 -1
  244. package/dist/storage/redis/database.d.ts +56 -22
  245. package/dist/storage/redis/database.d.ts.map +1 -0
  246. package/dist/storage/redis/database.js +62 -0
  247. package/dist/storage/redis/database.js.map +1 -1
  248. package/dist/storage/redis/mod.d.ts +31 -4
  249. package/dist/storage/redis/mod.d.ts.map +1 -0
  250. package/dist/storage/redis/mod.js +26 -1
  251. package/dist/storage/redis/mod.js.map +1 -1
  252. package/dist/storage/redis/native.d.ts +8 -0
  253. package/dist/storage/redis/native.d.ts.map +1 -0
  254. package/dist/storage/redis/native.js +10 -0
  255. package/dist/storage/redis/native.js.map +1 -1
  256. package/dist/storage/redis/options.d.ts +1 -0
  257. package/dist/storage/redis/options.d.ts.map +1 -0
  258. package/dist/storage/redis/pubsub.d.ts +2 -0
  259. package/dist/storage/redis/pubsub.d.ts.map +1 -0
  260. package/dist/storage/redis/reply.d.ts +34 -0
  261. package/dist/storage/redis/reply.d.ts.map +1 -0
  262. package/dist/storage/redis/reply.js +40 -1
  263. package/dist/storage/redis/reply.js.map +1 -1
  264. package/dist/storage/redis/scan.d.ts +1 -0
  265. package/dist/storage/redis/scan.d.ts.map +1 -0
  266. package/dist/storage/redis/script.d.ts +1 -0
  267. package/dist/storage/redis/script.d.ts.map +1 -0
  268. package/dist/storage/redis/target.d.ts +5 -3
  269. package/dist/storage/redis/target.d.ts.map +1 -0
  270. package/dist/storage/redis/target.js +39 -28
  271. package/dist/storage/redis/target.js.map +1 -1
  272. package/dist/storage/redis/wire.d.ts +7 -10
  273. package/dist/storage/redis/wire.d.ts.map +1 -0
  274. package/dist/storage/redis/wire.js +8 -32
  275. package/dist/storage/redis/wire.js.map +1 -1
  276. package/dist/testing/bun.d.ts +8 -0
  277. package/dist/testing/bun.d.ts.map +1 -0
  278. package/dist/testing/bun.js +13 -0
  279. package/dist/testing/bun.js.map +1 -0
  280. package/dist/testing/jest.d.ts +8 -0
  281. package/dist/testing/jest.d.ts.map +1 -0
  282. package/dist/testing/jest.js +11 -0
  283. package/dist/testing/jest.js.map +1 -0
  284. package/dist/testing/mod.d.ts +183 -0
  285. package/dist/testing/mod.d.ts.map +1 -0
  286. package/dist/testing/mod.js +271 -0
  287. package/dist/testing/mod.js.map +1 -0
  288. package/dist/testing/node.d.ts +9 -0
  289. package/dist/testing/node.d.ts.map +1 -0
  290. package/dist/testing/node.js +12 -0
  291. package/dist/testing/node.js.map +1 -0
  292. package/dist/testing/playwright.d.ts +93 -0
  293. package/dist/testing/playwright.d.ts.map +1 -0
  294. package/dist/testing/playwright.js +164 -0
  295. package/dist/testing/playwright.js.map +1 -0
  296. package/dist/testing/puppeteer.d.ts +36 -0
  297. package/dist/testing/puppeteer.d.ts.map +1 -0
  298. package/dist/testing/puppeteer.js +70 -0
  299. package/dist/testing/puppeteer.js.map +1 -0
  300. package/dist/testing/system.d.ts +181 -0
  301. package/dist/testing/system.d.ts.map +1 -0
  302. package/dist/testing/system.js +255 -0
  303. package/dist/testing/system.js.map +1 -0
  304. package/dist/testing/vitest.d.ts +8 -0
  305. package/dist/testing/vitest.d.ts.map +1 -0
  306. package/dist/testing/vitest.js +13 -0
  307. package/dist/testing/vitest.js.map +1 -0
  308. package/dist/tracing/http.d.ts +11 -0
  309. package/dist/tracing/http.d.ts.map +1 -0
  310. package/dist/tracing/http.js +34 -0
  311. package/dist/tracing/http.js.map +1 -0
  312. package/dist/tracing/mod.d.ts +20 -0
  313. package/dist/tracing/mod.d.ts.map +1 -0
  314. package/dist/tracing/mod.js +47 -0
  315. package/dist/tracing/mod.js.map +1 -0
  316. package/dist/tracing/node.d.ts +10 -0
  317. package/dist/tracing/node.d.ts.map +1 -0
  318. package/dist/tracing/node.js +142 -0
  319. package/dist/tracing/node.js.map +1 -0
  320. package/dist/tsconfig.build.tsbuildinfo +1 -1
  321. package/dist/types/mod.d.ts +1 -0
  322. package/dist/types/mod.d.ts.map +1 -0
  323. package/frontends/mod.test.ts +51 -0
  324. package/frontends/mod.ts +50 -0
  325. package/gateway/errors.ts +172 -0
  326. package/gateway/gateway.e2e.test.ts +297 -0
  327. package/gateway/gateway.test.ts +891 -0
  328. package/gateway/match.ts +239 -0
  329. package/gateway/middleware.ts +134 -0
  330. package/gateway/mod.ts +211 -0
  331. package/gateway/request.ts +578 -0
  332. package/gateway/serve.ts +738 -0
  333. package/gateways/mod.ts +60 -0
  334. package/internal/clients/call.ts +389 -0
  335. package/internal/clients/grpc.test.ts +368 -0
  336. package/internal/clients/grpc.ts +485 -0
  337. package/internal/clients/mod.test.ts +464 -0
  338. package/internal/clients/mod.ts +337 -0
  339. package/internal/fetch.ts +287 -0
  340. package/internal/otel/http.ts +91 -0
  341. package/internal/otel/index.ts +1 -7
  342. package/internal/otel/provider.ts +3 -0
  343. package/internal/otel/span.ts +31 -2
  344. package/internal/otel/tracer.test.ts +43 -15
  345. package/internal/otel/tracer.ts +12 -5
  346. package/internal/reqfields.ts +423 -0
  347. package/internal/runtime/mod.ts +41 -2
  348. package/internal/runtime/napi/napi.cjs +192 -16
  349. package/internal/runtime/napi/napi.d.cts +573 -33
  350. package/internal/runtime/shutdown.ts +11 -1
  351. package/internal/testing/carry.test.ts +242 -0
  352. package/internal/testing/carry.ts +101 -0
  353. package/internal/testing/runner.ts +10 -0
  354. package/internal/testing/scope.ts +372 -0
  355. package/internal/testing/steps.test.ts +152 -0
  356. package/internal/testing/steps.ts +342 -0
  357. package/internal/testing/telemetry.test.ts +210 -0
  358. package/internal/testing/telemetry.ts +466 -0
  359. package/metrics/mod.test.ts +13 -16
  360. package/metrics/mod.ts +57 -226
  361. package/mod.ts +1 -8
  362. package/otel.test.ts +13 -6
  363. package/package.json +92 -15
  364. package/pubsub/encoding.ts +11 -1
  365. package/pubsub/mod.ts +16 -4
  366. package/pubsub/pubsub.test.ts +233 -14
  367. package/pubsub/refs.ts +16 -0
  368. package/pubsub/subscription.ts +200 -21
  369. package/pubsub/topic.test.ts +26 -0
  370. package/pubsub/topic.ts +255 -36
  371. package/reqctx/mod.ts +267 -0
  372. package/reqctx/reqctx.test.ts +216 -0
  373. package/scripts/postprocess-docs.test.ts +58 -0
  374. package/services/index.test.ts +341 -1
  375. package/services/index.ts +185 -9
  376. package/storage/objects/bucket.test.ts +573 -0
  377. package/storage/objects/bucket.ts +650 -20
  378. package/storage/objects/error.ts +28 -1
  379. package/storage/objects/mod.ts +15 -0
  380. package/storage/objects/refs.ts +51 -3
  381. package/storage/postgres/database.integration.test.ts +275 -0
  382. package/storage/postgres/database.test.ts +193 -6
  383. package/storage/postgres/database.ts +206 -55
  384. package/storage/postgres/errors.ts +186 -0
  385. package/storage/postgres/interval.test.ts +72 -0
  386. package/storage/postgres/interval.ts +170 -0
  387. package/storage/postgres/mod.ts +4 -0
  388. package/storage/redis/bitfield.ts +162 -0
  389. package/storage/redis/command.ts +84 -0
  390. package/storage/redis/commands.ts +271 -21
  391. package/storage/redis/database.ts +77 -23
  392. package/storage/redis/mod.ts +38 -2
  393. package/storage/redis/native.ts +11 -0
  394. package/storage/redis/redis.test.ts +170 -10
  395. package/storage/redis/reply.ts +76 -1
  396. package/storage/redis/runtime.test.ts +15 -0
  397. package/storage/redis/target.ts +47 -44
  398. package/storage/redis/wire.ts +8 -32
  399. package/testing/bun.ts +13 -0
  400. package/testing/jest.ts +11 -0
  401. package/testing/mod.ts +393 -0
  402. package/testing/node.ts +12 -0
  403. package/testing/playwright.ts +247 -0
  404. package/testing/puppeteer.ts +101 -0
  405. package/testing/system.test.ts +108 -0
  406. package/testing/system.ts +373 -0
  407. package/testing/vitest.ts +13 -0
  408. package/tracing/http.ts +49 -0
  409. package/tracing/mod.ts +83 -0
  410. package/tracing/native.test.ts +267 -0
  411. package/tracing/node.ts +176 -0
  412. package/tracing/tracing.test.ts +953 -0
  413. package/dist/internal/otel/request_context.d.ts +0 -11
  414. package/dist/internal/otel/request_context.js +0 -20
  415. package/dist/internal/otel/request_context.js.map +0 -1
  416. package/dist/internal/reqtrack/mod.d.ts +0 -6
  417. package/dist/internal/reqtrack/mod.js +0 -28
  418. package/dist/internal/reqtrack/mod.js.map +0 -1
  419. package/dist/req_meta.d.ts +0 -47
  420. package/dist/req_meta.js +0 -26
  421. package/dist/req_meta.js.map +0 -1
  422. package/internal/otel/request_context.ts +0 -32
  423. package/internal/reqtrack/mod.ts +0 -39
  424. package/req_meta.ts +0 -75
package/README.md CHANGED
@@ -116,6 +116,115 @@ handlers that parse JSON manually should use the decoded value, or explicitly
116
116
  select `encoding: "raw"`. Consumer termination no longer starts another consumer
117
117
  after a timer: failures are logged, and normal completion leaves it stopped.
118
118
 
119
+ ## Tracing
120
+
121
+ ```typescript
122
+ import {span} from '@encore.dev/sdk/tracing';
123
+ import log from '@encore.dev/sdk/log';
124
+
125
+ const items = await span(
126
+ 'place_order',
127
+ {attributes: {'order.id': orderId}},
128
+ async current => {
129
+ const count = await span('validate_order', () => validate(orderId));
130
+ current.setAttribute('order.items', count);
131
+ log.info('Order placed', {order_id: orderId});
132
+ return count;
133
+ },
134
+ );
135
+ ```
136
+
137
+ `span(name, callback)` omits attributes. The callback gets
138
+ an OpenTelemetry `Span`; the helper owns completion, so do not call `end()`.
139
+ Synchronous callbacks return or throw synchronously. PromiseLike results become
140
+ Promises, and the span ends after settlement. Throws and rejections record an
141
+ exception and ERROR status, preserving the original value. OTel's OK status is
142
+ final: setting it prevents a later ERROR status. Successful callbacks leave
143
+ status UNSET unless the callback sets it.
144
+
145
+ Use bounded span names; put order IDs and other variable data in attributes.
146
+ Nested spans, logs, metric exemplars, and service calls share the active context
147
+ across awaits and timers. Detached work must manage its own lifetime.
148
+
149
+ Encore always uses its cached, owned provider, independent of OTel globals.
150
+ Importing or using tracing registers no global provider, context manager,
151
+ propagator, meter, or logger. Native `span` works without OTel setup. For OTel
152
+ interop, the app owns its context manager and configures it through normal OTel
153
+ setup before instrumented work. Pass Encore's tracer provider explicitly:
154
+
155
+ ```typescript
156
+ import {span, tracerProvider} from '@encore.dev/sdk/tracing';
157
+
158
+ // Configure the app's OTel context manager before instrumented work.
159
+ const tracer = tracerProvider().getTracer('orders');
160
+ await tracer.startActiveSpan('order_request', async current => {
161
+ try {
162
+ await span('place_order', () => placeOrder());
163
+ } finally {
164
+ current.end(); // OTel callbacks own their span lifetime.
165
+ }
166
+ });
167
+ ```
168
+
169
+ The app may choose `trace.setGlobalTracerProvider(tracerProvider())` for libraries
170
+ that use the global API; Encore never does this automatically. `tracerProvider`
171
+ remains available from `@encore.dev/sdk`. See the paired
172
+ [tracing fixtures](../../../tests/ts/telemetry) for runnable examples.
173
+
174
+ ### HTTP handlers
175
+
176
+ Wrap a Web `Request` → `Response` handler to continue incoming traces:
177
+
178
+ ```typescript
179
+ import {instrumentHTTP} from '@encore.dev/sdk/tracing';
180
+
181
+ Bun.serve({fetch: instrumentHTTP(handleRequest)});
182
+ ```
183
+
184
+ `instrumentHTTP` extracts W3C trace context and Encore Request Context, then
185
+ runs the handler with an Encore-owned SERVER span active. Nested spans, logs,
186
+ metrics and service calls inherit it. Extra handler arguments and `this` are
187
+ preserved; no OTel globals are registered or replaced.
188
+
189
+ Span names use the HTTP method. Raw URL paths and queries are not recorded:
190
+ paths may contain credentials or personal identifiers. Framework adapters can
191
+ add a safe `http.route` template. Response status is recorded;
192
+ 5xx responses and thrown errors mark the span ERROR. Exceptions are rethrown.
193
+ The original response and its body are untouched: the span ends when the
194
+ handler returns a response, not when a streaming body finishes. Handlers must
195
+ return a `Response`; WebSocket upgrades need a runtime-specific adapter.
196
+ Only accept Encore Request Context headers from trusted Encore ingress; the
197
+ wrapper decodes them, not authenticates them.
198
+
199
+ ### Node HTTP handlers
200
+
201
+ ```typescript
202
+ import {createServer} from 'node:http';
203
+ import {instrumentHTTP} from '@encore.dev/sdk/tracing/node';
204
+
205
+ createServer(
206
+ instrumentHTTP((request, response) => {
207
+ response.writeHead(200);
208
+ response.end('ok');
209
+ }),
210
+ ).listen(3000);
211
+ ```
212
+
213
+ The Node adapter accepts native `IncomingMessage`/`ServerResponse` listeners;
214
+ request and response bodies are not converted or buffered. It shares trace
215
+ and Request Context extraction with the Fetch wrapper and preserves `this`.
216
+ During response processing, request/response event callbacks run in the
217
+ request's context.
218
+
219
+ Its span lasts until response `finish`, premature `close`, response error,
220
+ or a thrown/rejected handler failure. A handler returning before a streamed
221
+ response finishes does not end the span. Premature closes mark it ERROR.
222
+ The adapter records and rethrows handler failures; the application remains
223
+ responsible for error responses and handling rejected async listeners.
224
+ Failures before headers are sent have no recorded HTTP response status.
225
+ Synchronous return values are preserved; PromiseLike results become Promises.
226
+ HTTP upgrade and CONNECT events require separate instrumentation.
227
+
119
228
  ## Formatting and linting
120
229
 
121
230
  Use Node.js 24 LTS for SDK development and install dependencies with `npm ci`.
package/app_meta.test.ts CHANGED
@@ -53,11 +53,23 @@ describe('appMeta', () => {
53
53
  expect(Object.keys(md.gateways).sort()).toEqual(['admin', 'api']);
54
54
  expect(md.gateways.api).toEqual({
55
55
  name: 'api',
56
- baseUrl: 'https://api.example.com',
56
+ url: 'https://api.example.com',
57
+ origins: ['https://api.example.com', '*'],
57
58
  });
58
59
  expect(md.gateways.admin).toEqual({
59
60
  name: 'admin',
60
- baseUrl: 'https://admin.example.com',
61
+ url: 'https://admin.example.com',
62
+ origins: ['https://admin.example.com'],
63
+ });
64
+ });
65
+
66
+ test('reports every frontend, keyed by name', () => {
67
+ expect(md.frontends).toEqual({
68
+ web: {
69
+ name: 'web',
70
+ url: 'https://example.com',
71
+ origins: ['https://example.com', 'https://*.example.com'],
72
+ },
61
73
  });
62
74
  });
63
75
 
@@ -108,19 +120,27 @@ function runtimeConfig(): string {
108
120
  ...enumField(5, 1), // TYPE_DEVELOPMENT
109
121
  ...enumField(6, 4), // CLOUD_GCP
110
122
  ];
111
- // Gateway{rid=1, encore_name=2, base_url=3}
123
+ // Gateway{rid=1, encore_name=2, origins=3}
112
124
  const api = [
113
125
  ...str(1, 'gw:api'),
114
126
  ...str(2, 'api'),
115
127
  ...str(3, 'https://api.example.com'),
128
+ ...str(3, '*'),
116
129
  ];
117
130
  const admin = [
118
131
  ...str(1, 'gw:admin'),
119
132
  ...str(2, 'admin'),
120
133
  ...str(3, 'https://admin.example.com'),
121
134
  ];
122
- // Infrastructure.Resources{gateways=1}; Infrastructure{resources=1}
123
- const infra = msg(1, [...msg(1, api), ...msg(1, admin)]);
135
+ // Frontend{rid=1, encore_name=2, origins=3}
136
+ const web = [
137
+ ...str(1, 'fe:web'),
138
+ ...str(2, 'web'),
139
+ ...str(3, 'https://example.com'),
140
+ ...str(3, 'https://*.example.com'),
141
+ ];
142
+ // Infrastructure.Resources{gateways=1, frontends=11}; Infrastructure{resources=1}
143
+ const infra = msg(1, [...msg(1, api), ...msg(1, admin), ...msg(11, web)]);
124
144
  // Deployment{deploy_id=1, hosted_services=5, revision=11}
125
145
  const deployment = [
126
146
  ...str(1, 'deploy-1'),
package/app_meta.ts CHANGED
@@ -19,15 +19,25 @@ export interface AppMeta {
19
19
  appSlug: string;
20
20
 
21
21
  /**
22
- * The API gateways that serve this application, keyed by gateway name.
22
+ * The API gateways of this application this service is given, keyed by
23
+ * gateway name: those its code looks up the URL of, and the one it hosts.
23
24
  *
24
25
  * An application can declare several gateways, so there is no single base URL for
25
- * the API — look up the gateway you mean by name. Every process lists them,
26
- * whether it serves one or not; one told of none, as under `encore test`,
27
- * reports an empty object.
26
+ * the API — look up the gateway you mean by name. A service's processes, its
27
+ * Workers' included, list the gateways its code names (`url("api")` from
28
+ * `@encore.dev/sdk/gateways`) and the one it hosts, and no other, the default
29
+ * included; one told of none, as under `encore test`, reports an empty object.
28
30
  */
29
31
  gateways: Record<string, GatewayMeta>;
30
32
 
33
+ /**
34
+ * The frontends of this application this service is given — those its code
35
+ * looks up the URL of (`url("web")` from `@encore.dev/sdk/frontends`), and
36
+ * the one it hosts — keyed by name, with where each is reached. One the
37
+ * environment gives no origins is left out.
38
+ */
39
+ frontends: Record<string, FrontendMeta>;
40
+
31
41
  /** Information about the environment the app is running in. */
32
42
  environment: EnvironmentMeta;
33
43
 
@@ -44,15 +54,35 @@ export interface GatewayMeta {
44
54
  name: string;
45
55
 
46
56
  /**
47
- * The base URL which can be used to call the API of this running application
48
- * through this gateway.
49
- *
50
- * For local development it is "http://localhost:<port>", typically "http://localhost:4000".
51
- *
52
- * If a custom domain is used for this environment it is returned here, but note that
53
- * changes only take effect at the time of deployment while custom domains can be updated at any time.
57
+ * The URL the API of this running application is called at through this
58
+ * gateway: the first of its origins. Empty when the environment gives the
59
+ * gateway no origins.
60
+ */
61
+ url: string;
62
+
63
+ /**
64
+ * Every origin the gateway is reached at in this environment
65
+ * (`scheme://host[:port]`), the first its URL. After the first, an entry may
66
+ * be a pattern of one, `https://*.example.com`, or `*`, which makes the
67
+ * gateway the one serving requests no other origin matches.
68
+ */
69
+ origins: string[];
70
+ }
71
+
72
+ /** Describes a frontend of the application, and where it is reached. */
73
+ export interface FrontendMeta {
74
+ /** The name of the frontend: for one a service hosts, the service's. */
75
+ name: string;
76
+
77
+ /** The URL the frontend is reached at: the first of its origins. */
78
+ url: string;
79
+
80
+ /**
81
+ * Every origin the frontend is reached at in this environment, the first its
82
+ * URL; after the first, an entry may be a pattern of one,
83
+ * `https://*.example.com`.
54
84
  */
55
- baseUrl: string;
85
+ origins: string[];
56
86
  }
57
87
 
58
88
  /** Describes the environment the Encore application is running in. */
@@ -111,6 +141,13 @@ export interface DeployMeta {
111
141
 
112
142
  /** The services hosted by this deployment, keyed by the service name. */
113
143
  hostedServices: Record<string, HostedService>;
144
+
145
+ /**
146
+ * The Worker of its service this process runs: a long-running process of
147
+ * the service that serves no requests, declared in the `workers` section of
148
+ * its `encore.service.json`. Undefined for the service's main process.
149
+ */
150
+ worker?: string;
114
151
  }
115
152
 
116
153
  export interface HostedService {
@@ -132,6 +169,7 @@ export function appMeta(): AppMeta {
132
169
  appId: rt.appId,
133
170
  appSlug: rt.appSlug,
134
171
  gateways: rt.gateways,
172
+ frontends: rt.frontends,
135
173
  environment: {
136
174
  name: rt.environment.name,
137
175
  type: envType(rt.environment.type),
@@ -144,6 +182,7 @@ export function appMeta(): AppMeta {
144
182
  id: rt.deploy.id,
145
183
  time: new Date(rt.deploy.deployTime),
146
184
  hostedServices: rt.deploy.hostedServices,
185
+ worker: rt.deploy.worker ?? undefined,
147
186
  },
148
187
  };
149
188
  }
@@ -86,7 +86,7 @@ describe('build', () => {
86
86
  },
87
87
  ],
88
88
  },
89
- apiKey: {'x-encore-secret': {name: 'StripeKey', scope: 'shared'}},
89
+ apiKey: {'x-encore-secret': 'StripeKey'},
90
90
  name: {type: 'string'},
91
91
  },
92
92
  };
@@ -100,10 +100,10 @@ describe('build', () => {
100
100
  retries: ['1s', '5s'],
101
101
  windows: {eu: '2m'},
102
102
  payment: {kind: 'card', hold: '10m'},
103
- apiKey: {$encore_secret: {name: 'StripeKey', scope: 'shared'}},
103
+ apiKey: {$encore_secret: 'StripeKey'},
104
104
  name: '30s',
105
105
  },
106
- (name, scope) => `secret ${name} (${scope})`,
106
+ name => `secret ${name}`,
107
107
  ) as any;
108
108
  expect(value.timeout).toBeInstanceOf(Duration);
109
109
  expect(value.timeout.seconds).toBe(30);
@@ -111,13 +111,13 @@ describe('build', () => {
111
111
  expect(value.retries.map((d: Duration) => d.seconds)).toEqual([1, 5]);
112
112
  expect(value.windows.eu.seconds).toBe(120);
113
113
  expect(value.payment.hold.seconds).toBe(600);
114
- expect(value.apiKey).toBe('secret StripeKey (shared)');
114
+ expect(value.apiKey).toBe('secret StripeKey');
115
115
  // A string the schema doesn't mark stays a string.
116
116
  expect(value.name).toBe('30s');
117
117
  });
118
118
 
119
119
  test('makes a secret only of a field the schema says reads one', () => {
120
- const forged = {$encore_secret: {name: 'StripeKey', scope: 'shared'}};
120
+ const forged = {$encore_secret: 'StripeKey'};
121
121
  const value = build(
122
122
  {type: 'object', properties: {extra: {}, name: {type: 'string'}}},
123
123
  {extra: forged},
@@ -129,11 +129,7 @@ describe('build', () => {
129
129
 
130
130
  const secretOf = (name: string) => `secret ${name}`;
131
131
  expect(() =>
132
- build(
133
- schema,
134
- {apiKey: {$encore_secret: {name: 'Other', scope: 'shared'}}},
135
- secretOf,
136
- ),
132
+ build(schema, {apiKey: {$encore_secret: 'Other'}}, secretOf),
137
133
  ).toThrow('a secret field reads the secret StripeKey');
138
134
  expect(() => build(schema, {apiKey: 'sk_live_123'}, secretOf)).not.toThrow(
139
135
  /sk_live/,
@@ -186,11 +182,13 @@ describe('config', () => {
186
182
  const mod = JSON.stringify(`${import.meta.dir}/mod`);
187
183
  const out = run(`
188
184
  import { writeFileSync } from "node:fs";
189
- import { config, sharedConfig, Duration } from ${mod};
185
+ import { config, secret, Duration } from ${mod};
190
186
  const checkout = config("checkout");
191
- const flags = sharedConfig("flags");
187
+ const flags = config("flags", { scope: "shared" });
192
188
  const missing = config("nothing");
193
189
  const a = checkout(), b = checkout();
190
+ let unset;
191
+ try { secret("Unset")(); } catch (e) { unset = e.message; }
194
192
  console.log(JSON.stringify({
195
193
  maxItems: a.max_items,
196
194
  timeout: a.timeout instanceof Duration ? a.timeout.seconds : null,
@@ -201,6 +199,7 @@ describe('config', () => {
201
199
  flagKey: flags().key(),
202
200
  missing: missing(),
203
201
  name: checkout.name,
202
+ unset,
204
203
  }));
205
204
  const stop = checkout.onChange((v) => {
206
205
  console.log(JSON.stringify({ changed: v.max_items, timeout: v.timeout.seconds, now: checkout().max_items }));
@@ -223,6 +222,8 @@ describe('config', () => {
223
222
  flagKey: 'shared-flag-key',
224
223
  missing: {},
225
224
  name: 'checkout',
225
+ // Not set is an error wherever the app runs, locally too.
226
+ unset: 'secret Unset is not set',
226
227
  });
227
228
  expect(out[1]).toEqual({changed: 7, timeout: 60, now: 7});
228
229
  });
@@ -321,7 +322,7 @@ function runtimeConfig(live: string): string {
321
322
  properties: {
322
323
  max_items: {type: 'integer', minimum: 1},
323
324
  timeout: {type: 'string', 'x-encore-format': 'duration'},
324
- stripe_key: {'x-encore-secret': {name: 'StripeKey', scope: 'service'}},
325
+ stripe_key: {'x-encore-secret': 'StripeKey'},
325
326
  },
326
327
  required: ['max_items'],
327
328
  additionalProperties: false,
@@ -330,11 +331,12 @@ function runtimeConfig(live: string): string {
330
331
  type: 'object',
331
332
  properties: {
332
333
  new_checkout: {type: 'boolean'},
333
- key: {'x-encore-secret': {name: 'FlagKey', scope: 'shared'}},
334
+ key: {'x-encore-secret': 'FlagKey'},
334
335
  },
335
336
  additionalProperties: false,
336
337
  };
337
- // AppConfig{rid=1, encore_name=2, service=3, json_schema=4, value=5}
338
+ // AppConfig{rid=1, encore_name=2, services=3, json_schema=4, value=5}: the
339
+ // service's own config given to orders, the shared one to every service.
338
340
  const checkout = [
339
341
  ...str(1, 'config:orders.checkout'),
340
342
  ...str(2, 'checkout'),
@@ -345,6 +347,7 @@ function runtimeConfig(live: string): string {
345
347
  const flags = [
346
348
  ...str(1, 'config:flags'),
347
349
  ...str(2, 'flags'),
350
+ ...str(3, '*'),
348
351
  ...str(4, JSON.stringify(flagsSchema)),
349
352
  ...str(5, JSON.stringify({new_checkout: true})),
350
353
  ];
package/config/config.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as runtime from '../internal/runtime/mod';
2
+ import {lookupScope, testMode, type Scope} from '../internal/testing/scope';
2
3
  import {secretOfField} from './secrets';
3
4
  import {build} from './value';
4
5
 
@@ -8,24 +9,24 @@ export {Duration} from './value';
8
9
  * A config: a typed value a service reads, written in files beside the code
9
10
  * and changed while the app runs. Calling it reads the value now.
10
11
  *
11
- * Declare one with {@link config}, {@link sharedConfig} or
12
- * {@link globalConfig}, giving the value's type as the type argument. Encore
13
- * reads that type to know what the config's files may hold, and checks them
14
- * against it before the value reaches the code.
12
+ * Declare one with {@link config}, giving the value's type as the type
13
+ * argument. Encore reads that type to know what the config's files may hold,
14
+ * and checks them against it before the value reaches the code.
15
15
  *
16
- * @example
17
- * import { config, type Min, type Max, type Duration } from "@encore.dev/sdk/config";
16
+ * ```ts
17
+ * import { config, type Min, type Max, type Duration } from "@encore.dev/sdk/config";
18
18
  *
19
- * interface Checkout {
20
- * // Most items one order may hold.
21
- * maxItems: number & Int & Min<1> & Max<500>;
22
- * currencies?: string[];
23
- * paymentTimeout: Duration;
24
- * }
19
+ * interface Checkout {
20
+ * // Most items one order may hold.
21
+ * maxItems: number & Int & Min<1> & Max<500>;
22
+ * currencies?: string[];
23
+ * paymentTimeout: Duration;
24
+ * }
25
25
  *
26
- * export const checkout = config<Checkout>("checkout");
26
+ * export const checkout = config<Checkout>("checkout");
27
27
  *
28
- * if (items.length > checkout().maxItems) { ... }
28
+ * if (items.length > checkout().maxItems) { ... }
29
+ * ```
29
30
  *
30
31
  * # Values
31
32
  *
@@ -57,31 +58,83 @@ export interface Config<T> {
57
58
  onChange(listener: (value: T) => void): () => void;
58
59
  }
59
60
 
60
- /**
61
- * config declares a {@link Config} belonging to the service that declares it,
62
- * which holds its own value for it. Two services may each declare a config of
63
- * the same name. The declaration must live inside a service, as a module-level
64
- * `export const`, with the name a string literal.
65
- */
66
- export function config<T>(name: string): Config<T> {
67
- return makeConfig<T>(name, runtime.RT.config(name));
61
+ /** The options a config is declared with. */
62
+ export interface ConfigOptions {
63
+ /**
64
+ * Who the config belongs to, written as a string literal for Encore to
65
+ * read:
66
+ *
67
+ * - `"service"`, the default: the service that declares it, which holds
68
+ * its own value for it. Two services may each declare a config of the
69
+ * same name. The declaration must live inside a service.
70
+ * - `"shared"`: the whole app, with one value. A service that reads it is
71
+ * recorded as using it. It may be declared outside a service.
72
+ * - `"global"`: the whole app, with one value available to every service
73
+ * without being recorded as used. It may be declared outside a service.
74
+ *
75
+ * A config name has one scope across the app, as a secret's has: a name
76
+ * declared shared or global can't also be a service's own.
77
+ */
78
+ scope?: 'service' | 'shared' | 'global';
79
+
80
+ /**
81
+ * Tags that classify the config, for policies to read: written out as
82
+ * string literals, as in `{data: "pci"}`. Keys and values are lowercase
83
+ * letters, digits, `_` and `-`, at most 63 characters; a key starts with a
84
+ * letter, and not with `encore`, which is reserved. At most 32 tags.
85
+ */
86
+ tags?: Record<string, string>;
68
87
  }
69
88
 
70
89
  /**
71
- * sharedConfig declares a {@link Config} with one value for the whole app. A
72
- * service that reads it is recorded as using it. Unlike {@link config} it may
73
- * be declared outside a service.
90
+ * config declares a {@link Config}, by default belonging to the service that
91
+ * declares it (see {@link ConfigOptions.scope}). The declaration is a
92
+ * module-level `export const`, with the name a string literal.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * // A config several services read.
97
+ * export const flags = config<Flags>("flags", {scope: "shared"});
98
+ * ```
74
99
  */
75
- export function sharedConfig<T>(name: string): Config<T> {
76
- return makeConfig<T>(name, runtime.RT.sharedConfig(name));
100
+ export function config<T>(
101
+ name: string,
102
+ // The options are Encore's parser's to read: a config is read by name
103
+ // whatever its scope, a name having one scope across the app.
104
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
105
+ opts?: ConfigOptions,
106
+ ): Config<T> {
107
+ const handle = makeConfig<T>(name, runtime.RT.config(name));
108
+ names.set(handle, name);
109
+ return handle;
77
110
  }
78
111
 
112
+ /** The name of the config each handle reads. */
113
+ const names = new WeakMap<Config<any>, string>();
114
+
79
115
  /**
80
- * globalConfig declares a {@link Config} with one value for the whole app,
81
- * available to every service without being recorded as used.
116
+ * Gives `cfg` the value `value` for the test `scope`, once the core has
117
+ * checked it against the config's schema: reading the config in the test
118
+ * returns it from then on. For `@encore.dev/sdk/testing`.
119
+ *
120
+ * @internal
82
121
  */
83
- export function globalConfig<T>(name: string): Config<T> {
84
- return makeConfig<T>(name, runtime.RT.sharedConfig(name));
122
+ export function setTestValue<T>(scope: Scope, cfg: Config<T>, value: T): void {
123
+ const name = names.get(cfg);
124
+ if (name === undefined) {
125
+ throw new TypeError('setConfig takes a config declared with `config()`');
126
+ }
127
+ const json = JSON.stringify(value);
128
+ if (json === undefined) {
129
+ throw new TypeError(`config ${name}: the value has no JSON form`);
130
+ }
131
+ const prepared = JSON.parse(scope.native.setConfig(name, json));
132
+ const impl = runtime.RT.config(name);
133
+ const built =
134
+ impl === null
135
+ ? prepared
136
+ : build(JSON.parse(impl.schema()), prepared, secretOfField);
137
+ scope.configs.set(name, built);
85
138
  }
86
139
 
87
140
  /** The native handle to a config, when the runtime config has it. */
@@ -116,6 +169,11 @@ function makeConfig<T>(name: string, impl: Impl | null): Config<T> {
116
169
  };
117
170
 
118
171
  const read = (): T => {
172
+ if (testMode) {
173
+ // The value the current test gave it, if it did.
174
+ const configs = lookupScope()?.configs;
175
+ if (configs?.has(name)) return configs.get(name) as T;
176
+ }
119
177
  if (impl === null) {
120
178
  // No value at all: every field takes its default, which in TypeScript is
121
179
  // none. The runtime config has every config the app declares, so this
package/config/mod.ts CHANGED
@@ -1,7 +1,8 @@
1
- export type {Secret, AnySecret} from './secrets';
2
- export {secret, sharedSecret, globalSecret} from './secrets';
1
+ export type {Secret, AnySecret, SecretOptions} from './secrets';
2
+ export {secret} from './secrets';
3
3
  export type {
4
4
  Config,
5
+ ConfigOptions,
5
6
  Min,
6
7
  Max,
7
8
  Int,
@@ -11,4 +12,4 @@ export type {
11
12
  MinItems,
12
13
  MaxItems,
13
14
  } from './config';
14
- export {config, sharedConfig, globalConfig, Duration} from './config';
15
+ export {config, Duration} from './config';