everything-dev 1.53.2 → 2.0.0-rc.1

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 (713) hide show
  1. package/README.md +2 -11
  2. package/dist/_virtual/_rolldown/runtime.cjs +17 -2
  3. package/dist/_virtual/_rolldown/runtime.mjs +36 -0
  4. package/dist/api/auth-middleware.cjs +161 -0
  5. package/dist/api/auth-middleware.cjs.map +1 -0
  6. package/dist/api/auth-middleware.d.cts +69 -0
  7. package/dist/api/auth-middleware.d.mts +69 -0
  8. package/dist/api/auth-middleware.mjs +160 -0
  9. package/dist/api/auth-middleware.mjs.map +1 -0
  10. package/dist/api-contract.cjs +250 -62
  11. package/dist/api-contract.cjs.map +1 -1
  12. package/dist/api-contract.mjs +246 -65
  13. package/dist/api-contract.mjs.map +1 -1
  14. package/dist/app.cjs +99 -26
  15. package/dist/app.cjs.map +1 -1
  16. package/dist/app.d.cts +3 -0
  17. package/dist/app.d.mts +3 -0
  18. package/dist/app.mjs +100 -27
  19. package/dist/app.mjs.map +1 -1
  20. package/dist/auth-login.cjs +163 -0
  21. package/dist/auth-login.cjs.map +1 -0
  22. package/dist/auth-login.mjs +162 -0
  23. package/dist/auth-login.mjs.map +1 -0
  24. package/dist/auth-session.cjs +64 -0
  25. package/dist/auth-session.cjs.map +1 -0
  26. package/dist/auth-session.mjs +58 -0
  27. package/dist/auth-session.mjs.map +1 -0
  28. package/dist/auth-types-gen.cjs +0 -1
  29. package/dist/auth-types-gen.cjs.map +1 -1
  30. package/dist/build.cjs +37 -173
  31. package/dist/build.cjs.map +1 -1
  32. package/dist/build.mjs +37 -171
  33. package/dist/build.mjs.map +1 -1
  34. package/dist/bundle-cache.cjs +74 -0
  35. package/dist/bundle-cache.cjs.map +1 -0
  36. package/dist/bundle-cache.d.cts +27 -0
  37. package/dist/bundle-cache.d.mts +27 -0
  38. package/dist/bundle-cache.mjs +68 -0
  39. package/dist/bundle-cache.mjs.map +1 -0
  40. package/dist/bundle-fs-resolve.cjs +209 -0
  41. package/dist/bundle-fs-resolve.cjs.map +1 -0
  42. package/dist/bundle-fs-resolve.d.cts +76 -0
  43. package/dist/bundle-fs-resolve.d.mts +76 -0
  44. package/dist/bundle-fs-resolve.mjs +202 -0
  45. package/dist/bundle-fs-resolve.mjs.map +1 -0
  46. package/dist/cdn-deploy.cjs +126 -0
  47. package/dist/cdn-deploy.cjs.map +1 -0
  48. package/dist/cdn-deploy.mjs +124 -0
  49. package/dist/cdn-deploy.mjs.map +1 -0
  50. package/dist/cli/db-doctor.cjs +19 -19
  51. package/dist/cli/db-doctor.cjs.map +1 -1
  52. package/dist/cli/db-doctor.mjs +18 -18
  53. package/dist/cli/db-doctor.mjs.map +1 -1
  54. package/dist/cli/db-repair.cjs +9 -32
  55. package/dist/cli/db-repair.cjs.map +1 -1
  56. package/dist/cli/db-repair.mjs +9 -32
  57. package/dist/cli/db-repair.mjs.map +1 -1
  58. package/dist/cli/framework-version.cjs +7 -3
  59. package/dist/cli/framework-version.cjs.map +1 -1
  60. package/dist/cli/framework-version.mjs +7 -3
  61. package/dist/cli/framework-version.mjs.map +1 -1
  62. package/dist/cli/infra.cjs +159 -251
  63. package/dist/cli/infra.cjs.map +1 -1
  64. package/dist/cli/infra.mjs +154 -242
  65. package/dist/cli/infra.mjs.map +1 -1
  66. package/dist/cli/init.cjs +627 -199
  67. package/dist/cli/init.cjs.map +1 -1
  68. package/dist/cli/init.d.cts +61 -8
  69. package/dist/cli/init.d.mts +61 -8
  70. package/dist/cli/init.mjs +616 -197
  71. package/dist/cli/init.mjs.map +1 -1
  72. package/dist/cli/parse.cjs +8 -7
  73. package/dist/cli/parse.cjs.map +1 -1
  74. package/dist/cli/parse.mjs +9 -7
  75. package/dist/cli/parse.mjs.map +1 -1
  76. package/dist/cli/prompts.cjs +14 -1
  77. package/dist/cli/prompts.cjs.map +1 -1
  78. package/dist/cli/prompts.mjs +14 -1
  79. package/dist/cli/prompts.mjs.map +1 -1
  80. package/dist/cli/prune.cjs +220 -0
  81. package/dist/cli/prune.cjs.map +1 -0
  82. package/dist/cli/prune.mjs +220 -0
  83. package/dist/cli/prune.mjs.map +1 -0
  84. package/dist/cli/snapshot.cjs +2 -1
  85. package/dist/cli/snapshot.cjs.map +1 -1
  86. package/dist/cli/snapshot.mjs +2 -1
  87. package/dist/cli/snapshot.mjs.map +1 -1
  88. package/dist/cli/status.cjs +5 -4
  89. package/dist/cli/status.cjs.map +1 -1
  90. package/dist/cli/status.mjs +6 -5
  91. package/dist/cli/status.mjs.map +1 -1
  92. package/dist/cli/sync.cjs +156 -58
  93. package/dist/cli/sync.cjs.map +1 -1
  94. package/dist/cli/sync.mjs +158 -63
  95. package/dist/cli/sync.mjs.map +1 -1
  96. package/dist/cli/timing.cjs +0 -1
  97. package/dist/cli/timing.cjs.map +1 -1
  98. package/dist/cli/upgrade.cjs +95 -69
  99. package/dist/cli/upgrade.cjs.map +1 -1
  100. package/dist/cli/upgrade.mjs +97 -72
  101. package/dist/cli/upgrade.mjs.map +1 -1
  102. package/dist/cli/utils/helpers.cjs.map +1 -1
  103. package/dist/cli.cjs +320 -72
  104. package/dist/cli.cjs.map +1 -1
  105. package/dist/cli.mjs +316 -68
  106. package/dist/cli.mjs.map +1 -1
  107. package/dist/code-artifacts.cjs +76 -8
  108. package/dist/code-artifacts.cjs.map +1 -1
  109. package/dist/code-artifacts.mjs +76 -10
  110. package/dist/code-artifacts.mjs.map +1 -1
  111. package/dist/commands/build.cjs +65 -0
  112. package/dist/commands/build.cjs.map +1 -0
  113. package/dist/commands/build.mjs +65 -0
  114. package/dist/commands/build.mjs.map +1 -0
  115. package/dist/commands/config.cjs +77 -0
  116. package/dist/commands/config.cjs.map +1 -0
  117. package/dist/commands/config.d.cts +8 -0
  118. package/dist/commands/config.d.mts +8 -0
  119. package/dist/commands/config.mjs +74 -0
  120. package/dist/commands/config.mjs.map +1 -0
  121. package/dist/commands/db.cjs +107 -0
  122. package/dist/commands/db.cjs.map +1 -0
  123. package/dist/commands/db.mjs +107 -0
  124. package/dist/commands/db.mjs.map +1 -0
  125. package/dist/commands/deploy.cjs +336 -0
  126. package/dist/commands/deploy.cjs.map +1 -0
  127. package/dist/commands/deploy.mjs +334 -0
  128. package/dist/commands/deploy.mjs.map +1 -0
  129. package/dist/commands/dev.cjs +75 -0
  130. package/dist/commands/dev.cjs.map +1 -0
  131. package/dist/commands/dev.mjs +73 -0
  132. package/dist/commands/dev.mjs.map +1 -0
  133. package/dist/commands/init.cjs +234 -0
  134. package/dist/commands/init.cjs.map +1 -0
  135. package/dist/commands/init.mjs +231 -0
  136. package/dist/commands/init.mjs.map +1 -0
  137. package/dist/commands/keys.cjs +255 -0
  138. package/dist/commands/keys.cjs.map +1 -0
  139. package/dist/commands/keys.mjs +253 -0
  140. package/dist/commands/keys.mjs.map +1 -0
  141. package/dist/commands/ops.cjs +199 -0
  142. package/dist/commands/ops.cjs.map +1 -0
  143. package/dist/commands/ops.mjs +197 -0
  144. package/dist/commands/ops.mjs.map +1 -0
  145. package/dist/commands/plugins.cjs +211 -0
  146. package/dist/commands/plugins.cjs.map +1 -0
  147. package/dist/commands/plugins.mjs +211 -0
  148. package/dist/commands/plugins.mjs.map +1 -0
  149. package/dist/commands/shared.cjs +8 -0
  150. package/dist/commands/shared.cjs.map +1 -0
  151. package/dist/commands/shared.d.cts +6 -0
  152. package/dist/commands/shared.d.mts +6 -0
  153. package/dist/commands/shared.mjs +8 -0
  154. package/dist/commands/shared.mjs.map +1 -0
  155. package/dist/commands/upgrade.cjs +325 -0
  156. package/dist/commands/upgrade.cjs.map +1 -0
  157. package/dist/commands/upgrade.mjs +323 -0
  158. package/dist/commands/upgrade.mjs.map +1 -0
  159. package/dist/components/dev-render.cjs +340 -0
  160. package/dist/components/dev-render.cjs.map +1 -0
  161. package/dist/components/dev-render.mjs +332 -0
  162. package/dist/components/dev-render.mjs.map +1 -0
  163. package/dist/config.cjs +460 -221
  164. package/dist/config.cjs.map +1 -1
  165. package/dist/config.d.cts +491 -48
  166. package/dist/config.d.mts +491 -48
  167. package/dist/config.mjs +439 -212
  168. package/dist/config.mjs.map +1 -1
  169. package/dist/contract.cjs +327 -50
  170. package/dist/contract.cjs.map +1 -1
  171. package/dist/contract.d.cts +1951 -1062
  172. package/dist/contract.d.mts +1951 -1062
  173. package/dist/contract.meta.cjs +107 -12
  174. package/dist/contract.meta.cjs.map +1 -1
  175. package/dist/contract.meta.d.cts +166 -8
  176. package/dist/contract.meta.d.mts +166 -8
  177. package/dist/contract.meta.mjs +107 -11
  178. package/dist/contract.meta.mjs.map +1 -1
  179. package/dist/contract.mjs +580 -327
  180. package/dist/contract.mjs.map +1 -1
  181. package/dist/dag.cjs +5 -3
  182. package/dist/dag.cjs.map +1 -1
  183. package/dist/dag.mjs +6 -3
  184. package/dist/dag.mjs.map +1 -1
  185. package/dist/db/binding.cjs +80 -0
  186. package/dist/db/binding.cjs.map +1 -0
  187. package/dist/db/binding.d.cts +39 -0
  188. package/dist/db/binding.d.mts +39 -0
  189. package/dist/db/binding.mjs +78 -0
  190. package/dist/db/binding.mjs.map +1 -0
  191. package/dist/db/bindings.cjs +78 -0
  192. package/dist/db/bindings.cjs.map +1 -0
  193. package/dist/db/bindings.d.cts +34 -0
  194. package/dist/db/bindings.d.mts +34 -0
  195. package/dist/db/bindings.mjs +76 -0
  196. package/dist/db/bindings.mjs.map +1 -0
  197. package/dist/db/core.cjs +204 -0
  198. package/dist/db/core.cjs.map +1 -0
  199. package/dist/db/core.d.cts +69 -0
  200. package/dist/db/core.d.mts +69 -0
  201. package/dist/db/core.mjs +192 -0
  202. package/dist/db/core.mjs.map +1 -0
  203. package/dist/db/driver.cjs +167 -0
  204. package/dist/db/driver.cjs.map +1 -0
  205. package/dist/db/driver.d.cts +50 -0
  206. package/dist/db/driver.d.mts +50 -0
  207. package/dist/db/driver.mjs +165 -0
  208. package/dist/db/driver.mjs.map +1 -0
  209. package/dist/db/drizzle-kit.cjs +177 -0
  210. package/dist/db/drizzle-kit.cjs.map +1 -0
  211. package/dist/db/drizzle-kit.d.cts +25 -0
  212. package/dist/db/drizzle-kit.d.mts +25 -0
  213. package/dist/db/drizzle-kit.mjs +175 -0
  214. package/dist/db/drizzle-kit.mjs.map +1 -0
  215. package/dist/db/errors.cjs +27 -0
  216. package/dist/db/errors.cjs.map +1 -0
  217. package/dist/db/errors.d.cts +16 -0
  218. package/dist/db/errors.d.mts +16 -0
  219. package/dist/db/errors.mjs +26 -0
  220. package/dist/db/errors.mjs.map +1 -0
  221. package/dist/db/identity.cjs +55 -0
  222. package/dist/db/identity.cjs.map +1 -0
  223. package/dist/db/identity.d.cts +40 -0
  224. package/dist/db/identity.d.mts +40 -0
  225. package/dist/db/identity.mjs +53 -0
  226. package/dist/db/identity.mjs.map +1 -0
  227. package/dist/db/index.cjs +43 -0
  228. package/dist/db/index.d.cts +9 -0
  229. package/dist/db/index.d.mts +9 -0
  230. package/dist/db/index.mjs +10 -0
  231. package/dist/db/run-migrations.cjs +343 -0
  232. package/dist/db/run-migrations.cjs.map +1 -0
  233. package/dist/db/run-migrations.d.cts +87 -0
  234. package/dist/db/run-migrations.d.mts +87 -0
  235. package/dist/db/run-migrations.mjs +341 -0
  236. package/dist/db/run-migrations.mjs.map +1 -0
  237. package/dist/delegate-signer.cjs +85 -0
  238. package/dist/delegate-signer.cjs.map +1 -0
  239. package/dist/delegate-signer.mjs +84 -0
  240. package/dist/delegate-signer.mjs.map +1 -0
  241. package/dist/deploy-diff.cjs +119 -0
  242. package/dist/deploy-diff.cjs.map +1 -0
  243. package/dist/deploy-diff.mjs +109 -0
  244. package/dist/deploy-diff.mjs.map +1 -0
  245. package/dist/descriptor/constructors.cjs +49 -0
  246. package/dist/descriptor/constructors.cjs.map +1 -0
  247. package/dist/descriptor/constructors.d.cts +27 -0
  248. package/dist/descriptor/constructors.d.mts +27 -0
  249. package/dist/descriptor/constructors.mjs +45 -0
  250. package/dist/descriptor/constructors.mjs.map +1 -0
  251. package/dist/descriptor/index.cjs +24 -0
  252. package/dist/descriptor/index.d.cts +5 -0
  253. package/dist/descriptor/index.d.mts +5 -0
  254. package/dist/descriptor/index.mjs +6 -0
  255. package/dist/descriptor/resolve.cjs +258 -0
  256. package/dist/descriptor/resolve.cjs.map +1 -0
  257. package/dist/descriptor/resolve.d.cts +50 -0
  258. package/dist/descriptor/resolve.d.mts +50 -0
  259. package/dist/descriptor/resolve.mjs +252 -0
  260. package/dist/descriptor/resolve.mjs.map +1 -0
  261. package/dist/descriptor/schema.cjs +109 -0
  262. package/dist/descriptor/schema.cjs.map +1 -0
  263. package/dist/descriptor/schema.d.cts +217 -0
  264. package/dist/descriptor/schema.d.mts +217 -0
  265. package/dist/descriptor/schema.mjs +102 -0
  266. package/dist/descriptor/schema.mjs.map +1 -0
  267. package/dist/descriptor/serialize.cjs +45 -0
  268. package/dist/descriptor/serialize.cjs.map +1 -0
  269. package/dist/descriptor/serialize.d.cts +7 -0
  270. package/dist/descriptor/serialize.d.mts +7 -0
  271. package/dist/descriptor/serialize.mjs +45 -0
  272. package/dist/descriptor/serialize.mjs.map +1 -0
  273. package/dist/dev-log-pipeline.cjs +273 -0
  274. package/dist/dev-log-pipeline.cjs.map +1 -0
  275. package/dist/dev-log-pipeline.mjs +267 -0
  276. package/dist/dev-log-pipeline.mjs.map +1 -0
  277. package/dist/dev-logs.cjs +39 -8
  278. package/dist/dev-logs.cjs.map +1 -1
  279. package/dist/dev-logs.mjs +37 -9
  280. package/dist/dev-logs.mjs.map +1 -1
  281. package/dist/dev-program.cjs +405 -0
  282. package/dist/dev-program.cjs.map +1 -0
  283. package/dist/dev-program.d.cts +10 -0
  284. package/dist/dev-program.d.mts +10 -0
  285. package/dist/dev-program.mjs +395 -0
  286. package/dist/dev-program.mjs.map +1 -0
  287. package/dist/dev-session-data.d.cts +27 -0
  288. package/dist/dev-session-data.d.mts +27 -0
  289. package/dist/dev-session.cjs +178 -105
  290. package/dist/dev-session.cjs.map +1 -1
  291. package/dist/dev-session.mjs +180 -105
  292. package/dist/dev-session.mjs.map +1 -1
  293. package/dist/env/process-env.cjs +16 -0
  294. package/dist/env/process-env.cjs.map +1 -0
  295. package/dist/env/process-env.mjs +13 -0
  296. package/dist/env/process-env.mjs.map +1 -0
  297. package/dist/env/project-env.cjs +144 -0
  298. package/dist/env/project-env.cjs.map +1 -0
  299. package/dist/env/project-env.d.cts +1 -0
  300. package/dist/env/project-env.d.mts +1 -0
  301. package/dist/env/project-env.mjs +132 -0
  302. package/dist/env/project-env.mjs.map +1 -0
  303. package/dist/fastkv.cjs +59 -12
  304. package/dist/fastkv.cjs.map +1 -1
  305. package/dist/fastkv.d.cts +42 -6
  306. package/dist/fastkv.d.mts +42 -6
  307. package/dist/fastkv.mjs +58 -13
  308. package/dist/fastkv.mjs.map +1 -1
  309. package/dist/fingerprint.cjs +57 -0
  310. package/dist/fingerprint.cjs.map +1 -0
  311. package/dist/fingerprint.d.cts +14 -0
  312. package/dist/fingerprint.d.mts +14 -0
  313. package/dist/fingerprint.mjs +55 -0
  314. package/dist/fingerprint.mjs.map +1 -0
  315. package/dist/http-client.cjs +17 -17
  316. package/dist/http-client.cjs.map +1 -1
  317. package/dist/http-client.mjs +17 -17
  318. package/dist/http-client.mjs.map +1 -1
  319. package/dist/image-deploy.cjs +186 -0
  320. package/dist/image-deploy.cjs.map +1 -0
  321. package/dist/image-deploy.mjs +182 -0
  322. package/dist/image-deploy.mjs.map +1 -0
  323. package/dist/index.cjs +66 -18
  324. package/dist/index.d.cts +8 -7
  325. package/dist/index.d.mts +8 -7
  326. package/dist/index.mjs +6 -5
  327. package/dist/infra/docker.cjs +77 -0
  328. package/dist/infra/docker.cjs.map +1 -0
  329. package/dist/infra/docker.d.cts +10 -0
  330. package/dist/infra/docker.d.mts +10 -0
  331. package/dist/infra/docker.mjs +69 -0
  332. package/dist/infra/docker.mjs.map +1 -0
  333. package/dist/infra/materializer.cjs +74 -0
  334. package/dist/infra/materializer.cjs.map +1 -0
  335. package/dist/infra/materializer.mjs +70 -0
  336. package/dist/infra/materializer.mjs.map +1 -0
  337. package/dist/infra/planner.cjs +135 -103
  338. package/dist/infra/planner.cjs.map +1 -1
  339. package/dist/infra/planner.mjs +137 -104
  340. package/dist/infra/planner.mjs.map +1 -1
  341. package/dist/infra/port-ownership.cjs +57 -0
  342. package/dist/infra/port-ownership.cjs.map +1 -0
  343. package/dist/infra/port-ownership.mjs +57 -0
  344. package/dist/infra/port-ownership.mjs.map +1 -0
  345. package/dist/infra/preflight.cjs +45 -33
  346. package/dist/infra/preflight.cjs.map +1 -1
  347. package/dist/infra/preflight.d.cts +1 -0
  348. package/dist/infra/preflight.d.mts +1 -0
  349. package/dist/infra/preflight.mjs +46 -34
  350. package/dist/infra/preflight.mjs.map +1 -1
  351. package/dist/infra/types.cjs.map +1 -1
  352. package/dist/infra/types.d.cts +2 -0
  353. package/dist/infra/types.d.mts +2 -0
  354. package/dist/infra/types.mjs.map +1 -1
  355. package/dist/integrity.cjs +50 -61
  356. package/dist/integrity.cjs.map +1 -1
  357. package/dist/integrity.d.cts +16 -10
  358. package/dist/integrity.d.mts +16 -10
  359. package/dist/integrity.mjs +50 -59
  360. package/dist/integrity.mjs.map +1 -1
  361. package/dist/internal/manifest-normalizer.cjs +8 -2
  362. package/dist/internal/manifest-normalizer.cjs.map +1 -1
  363. package/dist/internal/manifest-normalizer.mjs +9 -3
  364. package/dist/internal/manifest-normalizer.mjs.map +1 -1
  365. package/dist/merge.cjs +19 -1
  366. package/dist/merge.cjs.map +1 -1
  367. package/dist/merge.d.cts +1 -1
  368. package/dist/merge.d.mts +1 -1
  369. package/dist/merge.mjs +19 -2
  370. package/dist/merge.mjs.map +1 -1
  371. package/dist/mf.cjs +190 -3
  372. package/dist/mf.cjs.map +1 -1
  373. package/dist/mf.d.cts +24 -2
  374. package/dist/mf.d.mts +24 -2
  375. package/dist/mf.mjs +189 -4
  376. package/dist/mf.mjs.map +1 -1
  377. package/dist/near-cli.cjs +59 -91
  378. package/dist/near-cli.cjs.map +1 -1
  379. package/dist/near-cli.mjs +58 -90
  380. package/dist/near-cli.mjs.map +1 -1
  381. package/dist/near-signer.cjs +73 -0
  382. package/dist/near-signer.cjs.map +1 -0
  383. package/dist/near-signer.mjs +70 -0
  384. package/dist/near-signer.mjs.map +1 -0
  385. package/dist/network.cjs +0 -1
  386. package/dist/network.cjs.map +1 -1
  387. package/dist/orchestrator.cjs +256 -87
  388. package/dist/orchestrator.cjs.map +1 -1
  389. package/dist/orchestrator.mjs +248 -87
  390. package/dist/orchestrator.mjs.map +1 -1
  391. package/dist/platform-deploy.cjs +81 -0
  392. package/dist/platform-deploy.cjs.map +1 -0
  393. package/dist/platform-deploy.mjs +80 -0
  394. package/dist/platform-deploy.mjs.map +1 -0
  395. package/dist/plugin.cjs +54 -1389
  396. package/dist/plugin.cjs.map +1 -1
  397. package/dist/plugin.d.cts +6 -896
  398. package/dist/plugin.d.mts +6 -896
  399. package/dist/plugin.mjs +53 -1387
  400. package/dist/plugin.mjs.map +1 -1
  401. package/dist/process-kill.cjs +44 -0
  402. package/dist/process-kill.cjs.map +1 -0
  403. package/dist/process-kill.mjs +43 -0
  404. package/dist/process-kill.mjs.map +1 -0
  405. package/dist/process-registry.cjs +64 -9
  406. package/dist/process-registry.cjs.map +1 -1
  407. package/dist/process-registry.mjs +61 -10
  408. package/dist/process-registry.mjs.map +1 -1
  409. package/dist/progress.cjs +45 -0
  410. package/dist/progress.cjs.map +1 -0
  411. package/dist/progress.d.cts +13 -0
  412. package/dist/progress.d.mts +13 -0
  413. package/dist/progress.mjs +42 -0
  414. package/dist/progress.mjs.map +1 -0
  415. package/dist/publish.cjs +513 -79
  416. package/dist/publish.cjs.map +1 -1
  417. package/dist/publish.mjs +515 -82
  418. package/dist/publish.mjs.map +1 -1
  419. package/dist/registry-use.cjs +41 -0
  420. package/dist/registry-use.cjs.map +1 -0
  421. package/dist/registry-use.mjs +40 -0
  422. package/dist/registry-use.mjs.map +1 -0
  423. package/dist/resolution/session.cjs +335 -0
  424. package/dist/resolution/session.cjs.map +1 -0
  425. package/dist/resolution/session.d.cts +105 -0
  426. package/dist/resolution/session.d.mts +105 -0
  427. package/dist/resolution/session.mjs +331 -0
  428. package/dist/resolution/session.mjs.map +1 -0
  429. package/dist/rollback.cjs +131 -0
  430. package/dist/rollback.cjs.map +1 -0
  431. package/dist/rollback.mjs +128 -0
  432. package/dist/rollback.mjs.map +1 -0
  433. package/dist/sdk.cjs +7 -7
  434. package/dist/sdk.d.cts +3 -3
  435. package/dist/sdk.d.mts +3 -3
  436. package/dist/sdk.mjs +2 -2
  437. package/dist/service-descriptor.cjs +67 -34
  438. package/dist/service-descriptor.cjs.map +1 -1
  439. package/dist/service-descriptor.d.cts +4 -1
  440. package/dist/service-descriptor.d.mts +3 -0
  441. package/dist/service-descriptor.mjs +63 -35
  442. package/dist/service-descriptor.mjs.map +1 -1
  443. package/dist/shared-deps.cjs +17 -16
  444. package/dist/shared-deps.cjs.map +1 -1
  445. package/dist/shared-deps.mjs +17 -16
  446. package/dist/shared-deps.mjs.map +1 -1
  447. package/dist/start-config-source.cjs +24 -0
  448. package/dist/start-config-source.cjs.map +1 -0
  449. package/dist/start-config-source.d.cts +29 -0
  450. package/dist/start-config-source.d.mts +29 -0
  451. package/dist/start-config-source.mjs +22 -0
  452. package/dist/start-config-source.mjs.map +1 -0
  453. package/dist/storage-upload.cjs +145 -0
  454. package/dist/storage-upload.cjs.map +1 -0
  455. package/dist/storage-upload.mjs +143 -0
  456. package/dist/storage-upload.mjs.map +1 -0
  457. package/dist/types.cjs +126 -20
  458. package/dist/types.cjs.map +1 -1
  459. package/dist/types.d.cts +867 -585
  460. package/dist/types.d.mts +867 -585
  461. package/dist/types.mjs +307 -208
  462. package/dist/types.mjs.map +1 -1
  463. package/dist/ui/api.cjs +105 -0
  464. package/dist/ui/api.cjs.map +1 -0
  465. package/dist/ui/api.d.cts +31 -0
  466. package/dist/ui/api.d.mts +31 -0
  467. package/dist/ui/api.mjs +99 -0
  468. package/dist/ui/api.mjs.map +1 -0
  469. package/dist/ui/auth-guards.cjs +50 -0
  470. package/dist/ui/auth-guards.cjs.map +1 -0
  471. package/dist/ui/auth-guards.d.cts +39 -0
  472. package/dist/ui/auth-guards.d.mts +39 -0
  473. package/dist/ui/auth-guards.mjs +48 -0
  474. package/dist/ui/auth-guards.mjs.map +1 -0
  475. package/dist/ui/auth.cjs +197 -0
  476. package/dist/ui/auth.cjs.map +1 -0
  477. package/dist/ui/auth.d.cts +56 -0
  478. package/dist/ui/auth.d.mts +56 -0
  479. package/dist/ui/auth.mjs +179 -0
  480. package/dist/ui/auth.mjs.map +1 -0
  481. package/dist/ui/entry.cjs +16 -0
  482. package/dist/ui/entry.cjs.map +1 -0
  483. package/dist/ui/entry.d.cts +12 -0
  484. package/dist/ui/entry.d.mts +12 -0
  485. package/dist/ui/entry.mjs +15 -0
  486. package/dist/ui/entry.mjs.map +1 -0
  487. package/dist/ui/head.cjs +14 -7
  488. package/dist/ui/head.cjs.map +1 -1
  489. package/dist/ui/head.mjs +15 -7
  490. package/dist/ui/head.mjs.map +1 -1
  491. package/dist/ui/hydrate.cjs +265 -0
  492. package/dist/ui/hydrate.cjs.map +1 -0
  493. package/dist/ui/hydrate.d.cts +48 -0
  494. package/dist/ui/hydrate.d.mts +48 -0
  495. package/dist/ui/hydrate.mjs +263 -0
  496. package/dist/ui/hydrate.mjs.map +1 -0
  497. package/dist/ui/i18n.cjs +153 -0
  498. package/dist/ui/i18n.cjs.map +1 -0
  499. package/dist/ui/i18n.d.cts +29 -0
  500. package/dist/ui/i18n.d.mts +29 -0
  501. package/dist/ui/i18n.mjs +140 -0
  502. package/dist/ui/i18n.mjs.map +1 -0
  503. package/dist/ui/index.cjs +19 -1
  504. package/dist/ui/index.d.cts +6 -3
  505. package/dist/ui/index.d.mts +6 -3
  506. package/dist/ui/index.mjs +5 -2
  507. package/dist/ui/locale.cjs +53 -0
  508. package/dist/ui/locale.cjs.map +1 -0
  509. package/dist/ui/locale.d.cts +18 -0
  510. package/dist/ui/locale.d.mts +18 -0
  511. package/dist/ui/locale.mjs +49 -0
  512. package/dist/ui/locale.mjs.map +1 -0
  513. package/dist/ui/manifest/index.cjs +25 -0
  514. package/dist/ui/manifest/index.cjs.map +1 -0
  515. package/dist/ui/manifest/index.d.cts +9 -0
  516. package/dist/ui/manifest/index.d.mts +9 -0
  517. package/dist/ui/manifest/index.mjs +13 -0
  518. package/dist/ui/manifest/index.mjs.map +1 -0
  519. package/dist/ui/manifest-generator.cjs +8 -0
  520. package/dist/ui/manifest-generator.d.cts +1 -0
  521. package/dist/ui/manifest-generator.d.mts +1 -0
  522. package/dist/ui/manifest-generator.mjs +3 -0
  523. package/dist/ui/message-catalogs.cjs +8 -0
  524. package/dist/ui/message-catalogs.cjs.map +1 -0
  525. package/dist/ui/message-catalogs.d.cts +5 -0
  526. package/dist/ui/message-catalogs.d.mts +5 -0
  527. package/dist/ui/message-catalogs.mjs +8 -0
  528. package/dist/ui/message-catalogs.mjs.map +1 -0
  529. package/dist/ui/metadata.cjs +0 -1
  530. package/dist/ui/metadata.cjs.map +1 -1
  531. package/dist/ui/metadata.d.cts +1 -1
  532. package/dist/ui/metadata.d.mts +1 -1
  533. package/dist/ui/plugin-path.cjs +37 -0
  534. package/dist/ui/plugin-path.cjs.map +1 -0
  535. package/dist/ui/plugin-path.d.cts +25 -0
  536. package/dist/ui/plugin-path.d.mts +25 -0
  537. package/dist/ui/plugin-path.mjs +35 -0
  538. package/dist/ui/plugin-path.mjs.map +1 -0
  539. package/dist/ui/router-client.cjs +61 -0
  540. package/dist/ui/router-client.cjs.map +1 -0
  541. package/dist/ui/router-client.d.cts +20 -0
  542. package/dist/ui/router-client.d.mts +20 -0
  543. package/dist/ui/router-client.mjs +60 -0
  544. package/dist/ui/router-client.mjs.map +1 -0
  545. package/dist/ui/router-defaults.cjs +48 -0
  546. package/dist/ui/router-defaults.cjs.map +1 -0
  547. package/dist/ui/router-defaults.d.cts +8 -0
  548. package/dist/ui/router-defaults.d.mts +8 -0
  549. package/dist/ui/router-defaults.mjs +45 -0
  550. package/dist/ui/router-defaults.mjs.map +1 -0
  551. package/dist/ui/router-error.cjs +70 -0
  552. package/dist/ui/router-error.cjs.map +1 -0
  553. package/dist/ui/router-error.d.cts +19 -0
  554. package/dist/ui/router-error.d.mts +19 -0
  555. package/dist/ui/router-error.mjs +69 -0
  556. package/dist/ui/router-error.mjs.map +1 -0
  557. package/dist/ui/router-server.cjs +153 -0
  558. package/dist/ui/router-server.cjs.map +1 -0
  559. package/dist/ui/router-server.d.cts +38 -0
  560. package/dist/ui/router-server.d.mts +38 -0
  561. package/dist/ui/router-server.mjs +152 -0
  562. package/dist/ui/router-server.mjs.map +1 -0
  563. package/dist/ui/router.cjs +4 -16
  564. package/dist/ui/router.cjs.map +1 -1
  565. package/dist/ui/router.mjs +4 -15
  566. package/dist/ui/router.mjs.map +1 -1
  567. package/dist/ui/runtime.cjs +5 -1
  568. package/dist/ui/runtime.cjs.map +1 -1
  569. package/dist/ui/runtime.d.cts +2 -1
  570. package/dist/ui/runtime.d.mts +2 -1
  571. package/dist/ui/runtime.mjs +5 -1
  572. package/dist/ui/runtime.mjs.map +1 -1
  573. package/dist/ui/slot.cjs +34 -0
  574. package/dist/ui/slot.cjs.map +1 -0
  575. package/dist/ui/slot.d.cts +43 -0
  576. package/dist/ui/slot.d.mts +43 -0
  577. package/dist/ui/slot.mjs +34 -0
  578. package/dist/ui/slot.mjs.map +1 -0
  579. package/dist/ui/tenant.cjs +300 -0
  580. package/dist/ui/tenant.cjs.map +1 -0
  581. package/dist/ui/tenant.d.cts +122 -0
  582. package/dist/ui/tenant.d.mts +122 -0
  583. package/dist/ui/tenant.mjs +279 -0
  584. package/dist/ui/tenant.mjs.map +1 -0
  585. package/dist/ui/types.d.cts +32 -2
  586. package/dist/ui/types.d.mts +32 -2
  587. package/dist/ui/version-check.cjs +47 -0
  588. package/dist/ui/version-check.cjs.map +1 -0
  589. package/dist/ui/version-check.d.cts +23 -0
  590. package/dist/ui/version-check.d.mts +23 -0
  591. package/dist/ui/version-check.mjs +46 -0
  592. package/dist/ui/version-check.mjs.map +1 -0
  593. package/dist/utils/banner.cjs +2 -2
  594. package/dist/utils/banner.cjs.map +1 -1
  595. package/dist/utils/banner.mjs +2 -2
  596. package/dist/utils/banner.mjs.map +1 -1
  597. package/dist/utils/linkify.cjs +1 -1
  598. package/dist/utils/linkify.cjs.map +1 -1
  599. package/dist/utils/linkify.mjs +1 -0
  600. package/dist/utils/linkify.mjs.map +1 -1
  601. package/dist/utils/run.cjs +6 -6
  602. package/dist/utils/run.cjs.map +1 -1
  603. package/dist/utils/run.mjs +6 -6
  604. package/dist/utils/run.mjs.map +1 -1
  605. package/dist/utils/save-config.cjs +12 -0
  606. package/dist/utils/save-config.cjs.map +1 -1
  607. package/dist/utils/save-config.mjs +12 -0
  608. package/dist/utils/save-config.mjs.map +1 -1
  609. package/dist/utils/snapshot-hash.cjs +10 -0
  610. package/dist/utils/snapshot-hash.cjs.map +1 -0
  611. package/dist/utils/snapshot-hash.mjs +10 -0
  612. package/dist/utils/snapshot-hash.mjs.map +1 -0
  613. package/dist/utils/string.cjs +0 -1
  614. package/dist/utils/string.cjs.map +1 -1
  615. package/dist/utils/theme.cjs +30 -12
  616. package/dist/utils/theme.cjs.map +1 -1
  617. package/dist/utils/theme.mjs +30 -11
  618. package/dist/utils/theme.mjs.map +1 -1
  619. package/dist/version-manifest-deploy.cjs +50 -0
  620. package/dist/version-manifest-deploy.cjs.map +1 -0
  621. package/dist/version-manifest-deploy.mjs +49 -0
  622. package/dist/version-manifest-deploy.mjs.map +1 -0
  623. package/dist/version-manifest-resolve.cjs +42 -0
  624. package/dist/version-manifest-resolve.cjs.map +1 -0
  625. package/dist/version-manifest-resolve.d.cts +38 -0
  626. package/dist/version-manifest-resolve.d.mts +38 -0
  627. package/dist/version-manifest-resolve.mjs +40 -0
  628. package/dist/version-manifest-resolve.mjs.map +1 -0
  629. package/dist/version-status.cjs +18 -0
  630. package/dist/version-status.cjs.map +1 -0
  631. package/dist/version-status.d.cts +22 -0
  632. package/dist/version-status.d.mts +22 -0
  633. package/dist/version-status.mjs +17 -0
  634. package/dist/version-status.mjs.map +1 -0
  635. package/dist/workspace-catalog.cjs +53 -0
  636. package/dist/workspace-catalog.cjs.map +1 -0
  637. package/dist/workspace-catalog.mjs +51 -0
  638. package/dist/workspace-catalog.mjs.map +1 -0
  639. package/dist/workspace.cjs +237 -0
  640. package/dist/workspace.cjs.map +1 -0
  641. package/dist/workspace.mjs +233 -0
  642. package/dist/workspace.mjs.map +1 -0
  643. package/package.json +179 -27
  644. package/skills/add-a-route/SKILL.md +132 -0
  645. package/skills/api-and-auth/SKILL.md +87 -21
  646. package/skills/api-and-auth/references/middleware.md +1 -1
  647. package/skills/cli-reference/SKILL.md +48 -21
  648. package/skills/code-style/SKILL.md +8 -0
  649. package/skills/dev-workflow/SKILL.md +50 -26
  650. package/skills/extends-config/SKILL.md +31 -19
  651. package/skills/init-upgrade/SKILL.md +29 -16
  652. package/skills/plugin-development/SKILL.md +46 -112
  653. package/skills/plugin-development/references/database.md +82 -0
  654. package/skills/plugin-development/references/request-context.md +67 -0
  655. package/skills/publish-sync/SKILL.md +99 -22
  656. package/skills/registry/SKILL.md +82 -0
  657. package/skills/super-app/SKILL.md +25 -15
  658. package/skills/talk-to-the-app/SKILL.md +138 -0
  659. package/skills/ui-integration/SKILL.md +93 -11
  660. package/dist/cli/db-studio.cjs +0 -131
  661. package/dist/cli/db-studio.cjs.map +0 -1
  662. package/dist/cli/db-studio.mjs +0 -127
  663. package/dist/cli/db-studio.mjs.map +0 -1
  664. package/dist/cli/init.d.cts.map +0 -1
  665. package/dist/cli/init.d.mts.map +0 -1
  666. package/dist/components/dev-view.cjs +0 -309
  667. package/dist/components/dev-view.cjs.map +0 -1
  668. package/dist/components/dev-view.mjs +0 -309
  669. package/dist/components/dev-view.mjs.map +0 -1
  670. package/dist/components/streaming-view.cjs +0 -134
  671. package/dist/components/streaming-view.cjs.map +0 -1
  672. package/dist/components/streaming-view.mjs +0 -132
  673. package/dist/components/streaming-view.mjs.map +0 -1
  674. package/dist/config.d.cts.map +0 -1
  675. package/dist/config.d.mts.map +0 -1
  676. package/dist/contract.d.cts.map +0 -1
  677. package/dist/contract.d.mts.map +0 -1
  678. package/dist/contract.meta.d.cts.map +0 -1
  679. package/dist/contract.meta.d.mts.map +0 -1
  680. package/dist/dag.d.cts.map +0 -1
  681. package/dist/dag.d.mts.map +0 -1
  682. package/dist/db.cjs +0 -81
  683. package/dist/db.cjs.map +0 -1
  684. package/dist/db.d.cts +0 -30
  685. package/dist/db.d.cts.map +0 -1
  686. package/dist/db.d.mts +0 -30
  687. package/dist/db.d.mts.map +0 -1
  688. package/dist/db.mjs +0 -75
  689. package/dist/db.mjs.map +0 -1
  690. package/dist/fastkv.d.cts.map +0 -1
  691. package/dist/fastkv.d.mts.map +0 -1
  692. package/dist/integrity.d.cts.map +0 -1
  693. package/dist/integrity.d.mts.map +0 -1
  694. package/dist/merge.d.cts.map +0 -1
  695. package/dist/merge.d.mts.map +0 -1
  696. package/dist/mf.d.cts.map +0 -1
  697. package/dist/mf.d.mts.map +0 -1
  698. package/dist/plugin.d.cts.map +0 -1
  699. package/dist/plugin.d.mts.map +0 -1
  700. package/dist/service-descriptor.d.cts.map +0 -1
  701. package/dist/service-descriptor.d.mts.map +0 -1
  702. package/dist/types.d.cts.map +0 -1
  703. package/dist/types.d.mts.map +0 -1
  704. package/dist/ui/head.d.cts.map +0 -1
  705. package/dist/ui/head.d.mts.map +0 -1
  706. package/dist/ui/metadata.d.cts.map +0 -1
  707. package/dist/ui/metadata.d.mts.map +0 -1
  708. package/dist/ui/router.d.cts.map +0 -1
  709. package/dist/ui/router.d.mts.map +0 -1
  710. package/dist/ui/runtime.d.cts.map +0 -1
  711. package/dist/ui/runtime.d.mts.map +0 -1
  712. package/dist/ui/types.d.cts.map +0 -1
  713. package/dist/ui/types.d.mts.map +0 -1
package/dist/fastkv.mjs CHANGED
@@ -4,29 +4,34 @@ import { fetchJsonOrNull } from "./http-client.mjs";
4
4
  function getNetworkIdForAccount(accountId) {
5
5
  return accountId.endsWith(".testnet") ? "testnet" : "mainnet";
6
6
  }
7
+ const FASTKV_TESTNET_URL = "https://kv.test.fastnear.com";
8
+ const FASTKV_MAINNET_URL = "https://kv.main.fastnear.com";
9
+ const REGISTRY_NAMESPACE_TESTNET = "dev.allthethings.testnet";
10
+ const REGISTRY_NAMESPACE_MAINNET = "dev.everything.near";
7
11
  function getFastKvBaseUrlForNetwork(network) {
8
- return network === "testnet" ? process.env.REGISTRY_FASTKV_TESTNET_URL || "https://kv.test.fastnear.com" : process.env.REGISTRY_FASTKV_MAINNET_URL || "https://kv.main.fastnear.com";
12
+ return network === "testnet" ? FASTKV_TESTNET_URL : FASTKV_MAINNET_URL;
9
13
  }
10
14
  function getFastKvBaseUrlForAccount(accountId) {
11
15
  return getNetworkIdForAccount(accountId) === "testnet" ? getFastKvBaseUrlForNetwork("testnet") : getFastKvBaseUrlForNetwork("mainnet");
12
16
  }
13
- function buildRegistryConfigUrl(accountId, gatewayId) {
17
+ function buildRegistryConfigUrl(accountId, gatewayId, registry) {
14
18
  const baseUrl = getFastKvBaseUrlForAccount(accountId);
15
- const namespace = getRegistryNamespaceForAccount(accountId);
19
+ const namespace = getRegistryNamespaceForAccount(accountId, registry);
16
20
  const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId));
17
21
  return `${baseUrl}/v0/latest/${encodeURIComponent(namespace)}/${encodeURIComponent(accountId)}/${key}`;
18
22
  }
19
- function buildRegistryConfigUrlForNetwork(network, accountId, gatewayId) {
23
+ function buildRegistryConfigUrlForNetwork(network, accountId, gatewayId, registry) {
20
24
  const baseUrl = getFastKvBaseUrlForNetwork(network);
21
- const namespace = getRegistryNamespaceForNetwork(network);
25
+ const namespace = getRegistryNamespaceForNetwork(network, registry);
22
26
  const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId));
23
27
  return `${baseUrl}/v0/latest/${encodeURIComponent(namespace)}/${encodeURIComponent(accountId)}/${key}`;
24
28
  }
25
- function getRegistryNamespaceForAccount(accountId) {
26
- return accountId.endsWith(".testnet") ? process.env.REGISTRY_FASTKV_TESTNET_NAMESPACE || "dev.everything.near" : process.env.REGISTRY_FASTKV_MAINNET_NAMESPACE || "dev.everything.near";
29
+ function getRegistryNamespaceForAccount(accountId, registry) {
30
+ return registry ?? getRegistryNamespaceForNetwork(getNetworkIdForAccount(accountId));
27
31
  }
28
- function getRegistryNamespaceForNetwork(network) {
29
- return network === "testnet" ? process.env.REGISTRY_FASTKV_TESTNET_NAMESPACE || "dev.everything.near" : process.env.REGISTRY_FASTKV_MAINNET_NAMESPACE || "dev.everything.near";
32
+ function getRegistryNamespaceForNetwork(network, registry) {
33
+ if (registry) return registry;
34
+ return network === "testnet" ? REGISTRY_NAMESPACE_TESTNET : REGISTRY_NAMESPACE_MAINNET;
30
35
  }
31
36
  function getRegistryConfigKey(accountId, gatewayId, pathSegments = []) {
32
37
  return `apps/${accountId}/${gatewayId}${pathSegments.length > 0 ? `/${pathSegments.map((segment) => encodeURIComponent(segment)).join("/")}` : ""}/bos.config.json`;
@@ -44,17 +49,57 @@ function parseBosUrl(bosUrl) {
44
49
  pathSegments: pathSegmentsTail
45
50
  };
46
51
  }
47
- async function fetchBosConfigFromFastKv(bosUrl) {
52
+ async function fetchBosConfigFromFastKv(bosUrl, registry) {
48
53
  const { accountId, gatewayId, pathSegments } = parseBosUrl(bosUrl);
49
54
  const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId, pathSegments));
50
- const value = (await fetchJson(`${getFastKvBaseUrlForAccount(accountId)}/v0/latest/${encodeURIComponent(getRegistryNamespaceForAccount(accountId))}/${encodeURIComponent(accountId)}/${key}`))?.entries?.find(Boolean)?.value;
55
+ const value = (await fetchJson(`${getFastKvBaseUrlForAccount(accountId)}/v0/latest/${encodeURIComponent(getRegistryNamespaceForAccount(accountId, registry))}/${encodeURIComponent(accountId)}/${key}`))?.entries?.find(Boolean)?.value;
51
56
  if (!value) throw new Error(`No config found for ${bosUrl}`);
52
57
  if (typeof value === "string") return JSON.parse(value);
53
58
  if (typeof value !== "object") throw new Error(`Invalid config value for ${bosUrl}`);
54
59
  return value;
55
60
  }
61
+ const FASTKV_HISTORY_MAX_LIMIT = 200;
62
+ /**
63
+ * Publish history for the registry config key (atomic-deploys 11): the
64
+ * exact-key variant of FastData's history endpoint, newest-first. The API
65
+ * caps a page at 200 rows; a config key's write history fits well inside
66
+ * that, so a single request is the whole story (the limit param is clamped).
67
+ */
68
+ async function fetchConfigHistory(opts) {
69
+ const key = encodeURIComponent(getRegistryConfigKey(opts.accountId, opts.gatewayId));
70
+ const limit = Math.max(1, Math.min(opts.limit ?? 20, FASTKV_HISTORY_MAX_LIMIT));
71
+ return ((await fetchJson(`${getFastKvBaseUrlForAccount(opts.accountId)}/v0/history/${encodeURIComponent(getRegistryNamespaceForAccount(opts.accountId, opts.registry))}/${encodeURIComponent(opts.accountId)}/${key}?limit=${limit}`))?.entries ?? []).filter(Boolean).map((entry) => ({
72
+ blockHeight: entry.block_height ?? 0,
73
+ blockTimestampNs: String(entry.block_timestamp ?? ""),
74
+ ...entry.tx_hash ? { txHash: entry.tx_hash } : {},
75
+ value: typeof entry.value === "string" && entry.value.length > 0 ? JSON.parse(entry.value) : entry.value
76
+ })).sort((a, b) => b.blockHeight - a.blockHeight);
77
+ }
78
+ /**
79
+ * The per-deploy audit trail (atomic-deploys 03/12): every publish writes
80
+ * `apps/<account>/<gateway>/manifests/<ts>.json` atomically with the pointer
81
+ * swap — this lists that key family newest-first via the history-by-prefix
82
+ * endpoint.
83
+ */
84
+ async function fetchDeployManifests(opts) {
85
+ const keyPrefix = encodeURIComponent(`${getRegistryConfigKey(opts.accountId, opts.gatewayId).replace(/bos\.config\.json$/, "")}manifests/`);
86
+ return ((await fetchJson(`${getFastKvBaseUrlForAccount(opts.accountId)}/v0/history/${encodeURIComponent(getRegistryNamespaceForAccount(opts.accountId, opts.registry))}/${encodeURIComponent(opts.accountId)}`, {
87
+ method: "POST",
88
+ body: JSON.stringify({
89
+ key_prefix: decodeURIComponent(keyPrefix),
90
+ asc: false,
91
+ limit: Math.max(1, Math.min(opts.limit ?? 20, FASTKV_HISTORY_MAX_LIMIT))
92
+ })
93
+ }))?.entries ?? []).filter(Boolean).map((entry) => ({
94
+ key: entry.key ?? "",
95
+ blockHeight: entry.block_height ?? 0,
96
+ blockTimestampNs: String(entry.block_timestamp ?? ""),
97
+ value: typeof entry.value === "string" && entry.value.length > 0 ? JSON.parse(entry.value) : entry.value
98
+ })).sort((a, b) => b.blockHeight - a.blockHeight);
99
+ }
56
100
  async function fetchRemotePluginManifest(cdnUrl) {
57
- return fetchJsonOrNull(`${cdnUrl.replace(/\/$/, "")}/plugin.manifest.json`, { retries: 0 });
101
+ const baseUrl = cdnUrl.replace(/\/$/, "");
102
+ return fetchJsonOrNull(`${baseUrl}/plugin.manifest.json`, { retries: 2 });
58
103
  }
59
104
  async function fetchJson(url, init) {
60
105
  const headers = {
@@ -71,5 +116,5 @@ async function fetchJson(url, init) {
71
116
  }
72
117
 
73
118
  //#endregion
74
- export { buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, fetchBosConfigFromFastKv, fetchRemotePluginManifest, getFastKvBaseUrlForNetwork, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, parseBosUrl };
119
+ export { buildRegistryConfigUrl, buildRegistryConfigUrlForNetwork, fetchBosConfigFromFastKv, fetchConfigHistory, fetchDeployManifests, fetchRemotePluginManifest, getFastKvBaseUrlForNetwork, getRegistryNamespaceForAccount, getRegistryNamespaceForNetwork, parseBosUrl };
75
120
  //# sourceMappingURL=fastkv.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fastkv.mjs","names":[],"sources":["../src/fastkv.ts"],"sourcesContent":["export type NetworkId = \"mainnet\" | \"testnet\";\n\ninterface FastKvEntry {\n value: unknown;\n}\n\ninterface FastKvListResponse {\n entries?: Array<FastKvEntry | null>;\n}\n\nimport { fetchJsonOrNull } from \"./http-client\";\n\nfunction getNetworkIdForAccount(accountId: string): NetworkId {\n return accountId.endsWith(\".testnet\") ? \"testnet\" : \"mainnet\";\n}\n\nexport function getFastKvBaseUrlForNetwork(network: NetworkId): string {\n return network === \"testnet\"\n ? process.env.REGISTRY_FASTKV_TESTNET_URL || \"https://kv.test.fastnear.com\"\n : process.env.REGISTRY_FASTKV_MAINNET_URL || \"https://kv.main.fastnear.com\";\n}\n\nfunction getFastKvBaseUrlForAccount(accountId: string): string {\n return getNetworkIdForAccount(accountId) === \"testnet\"\n ? getFastKvBaseUrlForNetwork(\"testnet\")\n : getFastKvBaseUrlForNetwork(\"mainnet\");\n}\n\nexport function buildRegistryConfigUrl(accountId: string, gatewayId: string): string {\n const baseUrl = getFastKvBaseUrlForAccount(accountId);\n const namespace = getRegistryNamespaceForAccount(accountId);\n const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId));\n return `${baseUrl}/v0/latest/${encodeURIComponent(namespace)}/${encodeURIComponent(accountId)}/${key}`;\n}\n\nexport function buildRegistryConfigUrlForNetwork(\n network: NetworkId,\n accountId: string,\n gatewayId: string,\n): string {\n const baseUrl = getFastKvBaseUrlForNetwork(network);\n const namespace = getRegistryNamespaceForNetwork(network);\n const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId));\n return `${baseUrl}/v0/latest/${encodeURIComponent(namespace)}/${encodeURIComponent(accountId)}/${key}`;\n}\n\nexport function getRegistryNamespaceForAccount(accountId: string): string {\n return accountId.endsWith(\".testnet\")\n ? process.env.REGISTRY_FASTKV_TESTNET_NAMESPACE || \"dev.everything.near\"\n : process.env.REGISTRY_FASTKV_MAINNET_NAMESPACE || \"dev.everything.near\";\n}\n\nexport function getRegistryNamespaceForNetwork(network: NetworkId): string {\n return network === \"testnet\"\n ? process.env.REGISTRY_FASTKV_TESTNET_NAMESPACE || \"dev.everything.near\"\n : process.env.REGISTRY_FASTKV_MAINNET_NAMESPACE || \"dev.everything.near\";\n}\n\nfunction getRegistryConfigKey(\n accountId: string,\n gatewayId: string,\n pathSegments: string[] = [],\n): string {\n const suffix =\n pathSegments.length > 0\n ? `/${pathSegments.map((segment) => encodeURIComponent(segment)).join(\"/\")}`\n : \"\";\n return `apps/${accountId}/${gatewayId}${suffix}/bos.config.json`;\n}\n\nexport function parseBosUrl(bosUrl: string): {\n accountId: string;\n gatewayId: string;\n pathSegments: string[];\n} {\n const strippedUrl = bosUrl.split(\"#\")[0];\n const match = strippedUrl.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match?.[1] || !match[2]) {\n throw new Error(`Invalid BOS URL: ${bosUrl}`);\n }\n\n const pathSegments = match[2]\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => decodeURIComponent(segment));\n if (pathSegments.length === 0) {\n throw new Error(`Invalid BOS URL: ${bosUrl}`);\n }\n\n const [gatewayId, ...pathSegmentsTail] = pathSegments;\n if (!gatewayId) {\n throw new Error(`Invalid BOS URL: ${bosUrl}`);\n }\n\n return {\n accountId: match[1],\n gatewayId,\n pathSegments: pathSegmentsTail,\n };\n}\n\nexport async function fetchBosConfigFromFastKv<T>(bosUrl: string): Promise<T> {\n const { accountId, gatewayId, pathSegments } = parseBosUrl(bosUrl);\n const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId, pathSegments));\n const payload = await fetchJson<FastKvListResponse>(\n `${getFastKvBaseUrlForAccount(accountId)}/v0/latest/${encodeURIComponent(getRegistryNamespaceForAccount(accountId))}/${encodeURIComponent(accountId)}/${key}`,\n );\n const value = payload?.entries?.find(Boolean)?.value;\n\n if (!value) {\n throw new Error(`No config found for ${bosUrl}`);\n }\n\n if (typeof value === \"string\") {\n return JSON.parse(value) as T;\n }\n\n if (typeof value !== \"object\") {\n throw new Error(`Invalid config value for ${bosUrl}`);\n }\n\n return value as T;\n}\n\nexport interface PluginManifest {\n schemaVersion: number;\n kind: string;\n plugin: { name: string; version: string };\n runtime: { remoteEntry: string };\n contract: {\n kind: string;\n types: { path: string; exportName: string; typeName: string; sha256: string };\n };\n additionalExports?: Array<{ path: string; exports: string[]; sha256: string }>;\n}\n\nexport async function fetchRemotePluginManifest(cdnUrl: string): Promise<PluginManifest | null> {\n const baseUrl = cdnUrl.replace(/\\/$/, \"\");\n return fetchJsonOrNull<PluginManifest>(`${baseUrl}/plugin.manifest.json`, { retries: 0 });\n}\n\nasync function fetchJson<T>(url: string, init?: RequestInit): Promise<T | null> {\n const headers: Record<string, string> = {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n ...(init?.headers as Record<string, string> | undefined),\n };\n return fetchJsonOrNull<T>(url, {\n method: init?.method,\n headers,\n body: init?.body ?? undefined,\n retries: 3,\n });\n}\n"],"mappings":";;;AAYA,SAAS,uBAAuB,WAA8B;CAC5D,OAAO,UAAU,SAAS,UAAU,IAAI,YAAY;AACtD;AAEA,SAAgB,2BAA2B,SAA4B;CACrE,OAAO,YAAY,YACf,QAAQ,IAAI,+BAA+B,iCAC3C,QAAQ,IAAI,+BAA+B;AACjD;AAEA,SAAS,2BAA2B,WAA2B;CAC7D,OAAO,uBAAuB,SAAS,MAAM,YACzC,2BAA2B,SAAS,IACpC,2BAA2B,SAAS;AAC1C;AAEA,SAAgB,uBAAuB,WAAmB,WAA2B;CACnF,MAAM,UAAU,2BAA2B,SAAS;CACpD,MAAM,YAAY,+BAA+B,SAAS;CAC1D,MAAM,MAAM,mBAAmB,qBAAqB,WAAW,SAAS,CAAC;CACzE,OAAO,GAAG,QAAQ,aAAa,mBAAmB,SAAS,EAAE,GAAG,mBAAmB,SAAS,EAAE,GAAG;AACnG;AAEA,SAAgB,iCACd,SACA,WACA,WACQ;CACR,MAAM,UAAU,2BAA2B,OAAO;CAClD,MAAM,YAAY,+BAA+B,OAAO;CACxD,MAAM,MAAM,mBAAmB,qBAAqB,WAAW,SAAS,CAAC;CACzE,OAAO,GAAG,QAAQ,aAAa,mBAAmB,SAAS,EAAE,GAAG,mBAAmB,SAAS,E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1J,EACqB,EAAE,SAAS,KAAK,OAAO,CAAC,EAAE;CAE/C,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,uBAAuB,QAAQ;CAGjD,IAAI,OAAO,UAAU,UACnB,OAAO,KAAK,MAAM,KAAK;CAGzB,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,MAAM,4BAA4B,QAAQ;CAGtD,OAAO;AACT;AAcA,eAAsB,0BAA0B,QAAgD;CAE9F,OAAO,gBAAgC,GADvB,OAAO,QAAQ,OAAO,EACU,EAAE,wBAAwB,EAAE,SAAS,EAAE,CAAC;AAC1F;AAEA,eAAe,UAAa,KAAa,MAAuC;CAC9E,MAAM,UAAkC;EACtC,QAAQ;EACR,gBAAgB;EAChB,GAAI,MAAM;CACZ;CACA,OAAO,gBAAmB,KAAK;EAC7B,QAAQ,MAAM;EACd;EACA,MAAM,MAAM,QAAQ;EACpB,SAAS;CACX,CAAC;AACH"}
1
+ {"version":3,"file":"fastkv.mjs","names":[],"sources":["../src/fastkv.ts"],"sourcesContent":["export type NetworkId = \"mainnet\" | \"testnet\";\n\ninterface FastKvEntry {\n value: unknown;\n}\n\ninterface FastKvListResponse {\n entries?: Array<FastKvEntry | null>;\n}\n\nimport { fetchJsonOrNull } from \"./http-client\";\n\nfunction getNetworkIdForAccount(accountId: string): NetworkId {\n return accountId.endsWith(\".testnet\") ? \"testnet\" : \"mainnet\";\n}\n\nconst FASTKV_TESTNET_URL = \"https://kv.test.fastnear.com\";\nconst FASTKV_MAINNET_URL = \"https://kv.main.fastnear.com\";\nconst REGISTRY_NAMESPACE_TESTNET = \"dev.allthethings.testnet\";\nconst REGISTRY_NAMESPACE_MAINNET = \"dev.everything.near\";\n\nexport function getFastKvBaseUrlForNetwork(network: NetworkId): string {\n return network === \"testnet\" ? FASTKV_TESTNET_URL : FASTKV_MAINNET_URL;\n}\n\nfunction getFastKvBaseUrlForAccount(accountId: string): string {\n return getNetworkIdForAccount(accountId) === \"testnet\"\n ? getFastKvBaseUrlForNetwork(\"testnet\")\n : getFastKvBaseUrlForNetwork(\"mainnet\");\n}\n\nexport function buildRegistryConfigUrl(\n accountId: string,\n gatewayId: string,\n registry?: string,\n): string {\n const baseUrl = getFastKvBaseUrlForAccount(accountId);\n const namespace = getRegistryNamespaceForAccount(accountId, registry);\n const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId));\n return `${baseUrl}/v0/latest/${encodeURIComponent(namespace)}/${encodeURIComponent(accountId)}/${key}`;\n}\n\nexport function buildRegistryConfigUrlForNetwork(\n network: NetworkId,\n accountId: string,\n gatewayId: string,\n registry?: string,\n): string {\n const baseUrl = getFastKvBaseUrlForNetwork(network);\n const namespace = getRegistryNamespaceForNetwork(network, registry);\n const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId));\n return `${baseUrl}/v0/latest/${encodeURIComponent(namespace)}/${encodeURIComponent(accountId)}/${key}`;\n}\n\nexport function getRegistryNamespaceForAccount(accountId: string, registry?: string): string {\n return registry ?? getRegistryNamespaceForNetwork(getNetworkIdForAccount(accountId));\n}\n\nexport function getRegistryNamespaceForNetwork(network: NetworkId, registry?: string): string {\n if (registry) return registry;\n return network === \"testnet\" ? REGISTRY_NAMESPACE_TESTNET : REGISTRY_NAMESPACE_MAINNET;\n}\n\nfunction getRegistryConfigKey(\n accountId: string,\n gatewayId: string,\n pathSegments: string[] = [],\n): string {\n const suffix =\n pathSegments.length > 0\n ? `/${pathSegments.map((segment) => encodeURIComponent(segment)).join(\"/\")}`\n : \"\";\n return `apps/${accountId}/${gatewayId}${suffix}/bos.config.json`;\n}\n\nexport function parseBosUrl(bosUrl: string): {\n accountId: string;\n gatewayId: string;\n pathSegments: string[];\n} {\n const strippedUrl = bosUrl.split(\"#\")[0]!;\n const match = strippedUrl.match(/^bos:\\/\\/([^/]+)\\/(.+)$/);\n if (!match?.[1] || !match[2]) {\n throw new Error(`Invalid BOS URL: ${bosUrl}`);\n }\n\n const pathSegments = match[2]\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => decodeURIComponent(segment));\n if (pathSegments.length === 0) {\n throw new Error(`Invalid BOS URL: ${bosUrl}`);\n }\n\n const [gatewayId, ...pathSegmentsTail] = pathSegments;\n if (!gatewayId) {\n throw new Error(`Invalid BOS URL: ${bosUrl}`);\n }\n\n return {\n accountId: match[1],\n gatewayId,\n pathSegments: pathSegmentsTail,\n };\n}\n\nexport async function fetchBosConfigFromFastKv<T>(bosUrl: string, registry?: string): Promise<T> {\n const { accountId, gatewayId, pathSegments } = parseBosUrl(bosUrl);\n const key = encodeURIComponent(getRegistryConfigKey(accountId, gatewayId, pathSegments));\n const payload = await fetchJson<FastKvListResponse>(\n `${getFastKvBaseUrlForAccount(accountId)}/v0/latest/${encodeURIComponent(getRegistryNamespaceForAccount(accountId, registry))}/${encodeURIComponent(accountId)}/${key}`,\n );\n const value = payload?.entries?.find(Boolean)?.value;\n\n if (!value) {\n throw new Error(`No config found for ${bosUrl}`);\n }\n\n if (typeof value === \"string\") {\n return JSON.parse(value) as T;\n }\n\n if (typeof value !== \"object\") {\n throw new Error(`Invalid config value for ${bosUrl}`);\n }\n\n return value as T;\n}\n\nexport interface ConfigHistoryEntry {\n blockHeight: number;\n blockTimestampNs: string;\n txHash?: string;\n value: unknown;\n}\n\ninterface FastKvHistoryEntry {\n block_height?: number;\n block_timestamp?: string | number;\n tx_hash?: string;\n value?: unknown;\n}\n\ninterface FastKvHistoryResponse {\n entries?: Array<FastKvHistoryEntry | null>;\n}\n\nconst FASTKV_HISTORY_MAX_LIMIT = 200;\n\n/**\n * Publish history for the registry config key (atomic-deploys 11): the\n * exact-key variant of FastData's history endpoint, newest-first. The API\n * caps a page at 200 rows; a config key's write history fits well inside\n * that, so a single request is the whole story (the limit param is clamped).\n */\nexport async function fetchConfigHistory(opts: {\n accountId: string;\n gatewayId: string;\n registry?: string;\n limit?: number;\n}): Promise<ConfigHistoryEntry[]> {\n const key = encodeURIComponent(getRegistryConfigKey(opts.accountId, opts.gatewayId));\n const limit = Math.max(1, Math.min(opts.limit ?? 20, FASTKV_HISTORY_MAX_LIMIT));\n const url = `${getFastKvBaseUrlForAccount(opts.accountId)}/v0/history/${encodeURIComponent(getRegistryNamespaceForAccount(opts.accountId, opts.registry))}/${encodeURIComponent(opts.accountId)}/${key}?limit=${limit}`;\n const payload = await fetchJson<FastKvHistoryResponse>(url);\n const entries = (payload?.entries ?? []).filter(Boolean) as FastKvHistoryEntry[];\n\n return entries\n .map((entry) => ({\n blockHeight: entry.block_height ?? 0,\n blockTimestampNs: String(entry.block_timestamp ?? \"\"),\n ...(entry.tx_hash ? { txHash: entry.tx_hash } : {}),\n value:\n typeof entry.value === \"string\" && entry.value.length > 0\n ? (JSON.parse(entry.value) as unknown)\n : entry.value,\n }))\n .sort((a, b) => b.blockHeight - a.blockHeight);\n}\n\nexport interface DeployManifestEntry {\n key: string;\n blockHeight: number;\n blockTimestampNs: string;\n value: unknown;\n}\n\n/**\n * The per-deploy audit trail (atomic-deploys 03/12): every publish writes\n * `apps/<account>/<gateway>/manifests/<ts>.json` atomically with the pointer\n * swap — this lists that key family newest-first via the history-by-prefix\n * endpoint.\n */\nexport async function fetchDeployManifests(opts: {\n accountId: string;\n gatewayId: string;\n registry?: string;\n limit?: number;\n}): Promise<DeployManifestEntry[]> {\n const keyPrefix = encodeURIComponent(\n `${getRegistryConfigKey(opts.accountId, opts.gatewayId).replace(/bos\\.config\\.json$/, \"\")}manifests/`,\n );\n const url = `${getFastKvBaseUrlForAccount(opts.accountId)}/v0/history/${encodeURIComponent(getRegistryNamespaceForAccount(opts.accountId, opts.registry))}/${encodeURIComponent(opts.accountId)}`;\n const payload = await fetchJson<FastKvHistoryResponse>(url, {\n method: \"POST\",\n body: JSON.stringify({\n key_prefix: decodeURIComponent(keyPrefix),\n asc: false,\n limit: Math.max(1, Math.min(opts.limit ?? 20, FASTKV_HISTORY_MAX_LIMIT)),\n }),\n });\n const entries = (payload?.entries ?? []).filter(Boolean) as Array<\n FastKvHistoryEntry & { key?: string }\n >;\n\n return entries\n .map((entry) => ({\n key: entry.key ?? \"\",\n blockHeight: entry.block_height ?? 0,\n blockTimestampNs: String(entry.block_timestamp ?? \"\"),\n value:\n typeof entry.value === \"string\" && entry.value.length > 0\n ? (JSON.parse(entry.value) as unknown)\n : entry.value,\n }))\n .sort((a, b) => b.blockHeight - a.blockHeight);\n}\n\nexport interface PluginManifest {\n schemaVersion: number;\n kind: string;\n plugin: { name: string; version: string };\n runtime: { remoteEntry: string };\n contract: {\n kind: string;\n types: { path: string; exportName: string; typeName: string; sha256: string };\n };\n additionalExports?: Array<{ path: string; exports: string[]; sha256: string }>;\n}\n\nexport async function fetchRemotePluginManifest(cdnUrl: string): Promise<PluginManifest | null> {\n const baseUrl = cdnUrl.replace(/\\/$/, \"\");\n return fetchJsonOrNull<PluginManifest>(`${baseUrl}/plugin.manifest.json`, { retries: 2 });\n}\n\nasync function fetchJson<T>(url: string, init?: RequestInit): Promise<T | null> {\n const headers: Record<string, string> = {\n accept: \"application/json\",\n \"content-type\": \"application/json\",\n ...(init?.headers as Record<string, string> | undefined),\n };\n return fetchJsonOrNull<T>(url, {\n method: init?.method,\n headers,\n body: init?.body ?? undefined,\n retries: 3,\n });\n}\n"],"mappings":";;;AAYA,SAAS,uBAAuB,WAA8B;CAC5D,OAAO,UAAU,SAAS,UAAU,IAAI,YAAY;AACtD;AAEA,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,6BAA6B;AACnC,MAAM,6BAA6B;AAEnC,SAAgB,2BAA2B,SAA4B;CACrE,OAAO,YAAY,YAAY,qBAAqB;AACtD;AAEA,SAAS,2BAA2B,WAA2B;CAC7D,OAAO,uBAAuB,SAAS,MAAM,YACzC,2BAA2B,SAAS,IACpC,2BAA2B,SAAS;AAC1C;AAEA,SAAgB,uBACd,WACA,WACA,UACQ;CACR,MAAM,UAAU,2BAA2B,SAAS;CACpD,MAAM,YAAY,+BAA+B,WAAW,QAAQ;CACpE,MAAM,MAAM,mBAAmB,qBAAqB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,0 +1,57 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let node_crypto = require("node:crypto");
3
+
4
+ //#region src/fingerprint.ts
5
+ /**
6
+ * The published pointer's version identity (atomic-deploys 08/12): a hash
7
+ * over every slot's `pin` — cheap to compute (no version-manifest fetch), and
8
+ * stable exactly when the deployed set is. Shared so the CLI and the host
9
+ * compute the same identity for the same pointer.
10
+ */
11
+ function pointerFingerprint(config) {
12
+ const parts = [];
13
+ const slot = (prefix, s) => {
14
+ if (!s) return;
15
+ const pin = s.pin;
16
+ const pinPart = pin && typeof pin.manifest === "string" && typeof pin.integrity === "string" ? `${pin.manifest}:${pin.integrity}` : "";
17
+ const directPart = typeof s.integrity === "string" ? s.integrity : "";
18
+ parts.push(`${prefix}:${pinPart}:${directPart}`);
19
+ };
20
+ for (const [key, entry] of Object.entries(config.app ?? {})) {
21
+ slot(`app.${key}`, entry);
22
+ slot(`app.${key}.ui`, entry.ui);
23
+ }
24
+ for (const [key, entry] of Object.entries(config.plugins ?? {})) {
25
+ if (typeof entry === "string") {
26
+ parts.push(`plugins.${key}:${entry}`);
27
+ continue;
28
+ }
29
+ slot(`plugins.${key}`, entry);
30
+ slot(`plugins.${key}.ui`, entry.ui);
31
+ }
32
+ return (0, node_crypto.createHash)("sha256").update(parts.join("|")).digest("hex").slice(0, 16);
33
+ }
34
+ /** Per-slot pin ids for display (slot → versioned manifest filename). */
35
+ function slotPins(config) {
36
+ const pins = {};
37
+ const slot = (prefix, s) => {
38
+ if (!s) return;
39
+ const manifest = s.pin?.manifest;
40
+ if (typeof manifest === "string") pins[prefix] = manifest;
41
+ };
42
+ for (const [key, entry] of Object.entries(config.app ?? {})) {
43
+ slot(`app.${key}`, entry);
44
+ slot(`app.${key}.ui`, entry.ui);
45
+ }
46
+ for (const [key, entry] of Object.entries(config.plugins ?? {})) {
47
+ if (typeof entry === "string") continue;
48
+ slot(`plugins.${key}`, entry);
49
+ slot(`plugins.${key}.ui`, entry.ui);
50
+ }
51
+ return pins;
52
+ }
53
+
54
+ //#endregion
55
+ exports.pointerFingerprint = pointerFingerprint;
56
+ exports.slotPins = slotPins;
57
+ //# sourceMappingURL=fingerprint.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.cjs","names":["createHash"],"sources":["../src/fingerprint.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { BosConfig } from \"./types\";\n\n/**\n * The published pointer's version identity (atomic-deploys 08/12): a hash\n * over every slot's `pin` — cheap to compute (no version-manifest fetch), and\n * stable exactly when the deployed set is. Shared so the CLI and the host\n * compute the same identity for the same pointer.\n */\nexport function pointerFingerprint(config: BosConfig): string {\n const parts: Array<string> = [];\n const slot = (prefix: string, s: { pin?: unknown; integrity?: unknown } | undefined) => {\n if (!s) return;\n const pin = s.pin as { manifest?: unknown; integrity?: unknown } | undefined;\n const pinPart =\n pin && typeof pin.manifest === \"string\" && typeof pin.integrity === \"string\"\n ? `${pin.manifest}:${pin.integrity}`\n : \"\";\n const directPart = typeof s.integrity === \"string\" ? s.integrity : \"\";\n parts.push(`${prefix}:${pinPart}:${directPart}`);\n };\n for (const [key, entry] of Object.entries(config.app ?? {})) {\n slot(`app.${key}`, entry);\n slot(`app.${key}.ui`, (entry as { ui?: { pin?: unknown; integrity?: unknown } }).ui);\n }\n for (const [key, entry] of Object.entries(config.plugins ?? {})) {\n if (typeof entry === \"string\") {\n parts.push(`plugins.${key}:${entry}`);\n continue;\n }\n slot(`plugins.${key}`, entry);\n slot(`plugins.${key}.ui`, (entry as { ui?: { pin?: unknown; integrity?: unknown } }).ui);\n }\n return createHash(\"sha256\").update(parts.join(\"|\")).digest(\"hex\").slice(0, 16);\n}\n\n/** Per-slot pin ids for display (slot → versioned manifest filename). */\nexport function slotPins(config: BosConfig): Record<string, string> {\n const pins: Record<string, string> = {};\n const slot = (prefix: string, s: { pin?: unknown } | undefined) => {\n if (!s) return;\n const manifest = (s.pin as { manifest?: unknown } | undefined)?.manifest;\n if (typeof manifest === \"string\") pins[prefix] = manifest;\n };\n for (const [key, entry] of Object.entries(config.app ?? {})) {\n slot(`app.${key}`, entry);\n slot(`app.${key}.ui`, (entry as { ui?: { pin?: unknown } }).ui);\n }\n for (const [key, entry] of Object.entries(config.plugins ?? {})) {\n if (typeof entry === \"string\") continue;\n slot(`plugins.${key}`, entry);\n slot(`plugins.${key}.ui`, (entry as { ui?: { pin?: unknown } }).ui);\n }\n return pins;\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,mBAAmB,QAA2B;CAC5D,MAAM,QAAuB,CAAC;CAC9B,MAAM,QAAQ,QAAgB,MAA0D;EACtF,IAAI,CAAC,GAAG;EACR,MAAM,MAAM,EAAE;EACd,MAAM,UACJ,OAAO,OAAO,IAAI,aAAa,YAAY,OAAO,IAAI,cAAc,WAChE,GAAG,IAAI,SAAS,GAAG,IAAI,cACvB;EACN,MAAM,aAAa,OAAO,EAAE,cAAc,WAAW,EAAE,YAAY;EACnE,MAAM,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY;CACjD;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,GAAG;EAC3D,KAAK,OAAO,OAAO,KAAK;EACxB,KAAK,OAAO,IAAI,MAAO,MAA0D,EAAE;CACrF;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,WAAW,CAAC,CAAC,GAAG;EAC/D,IAAI,OAAO,UAAU,UAAU;GAC7B,MAAM,KAAK,WAAW,IAAI,GAAG,OAAO;GACpC;EACF;EACA,KAAK,WAAW,OAAO,KAAK;EAC5B,KAAK,WAAW,IAAI,MAAO,MAA0D,EAAE;CACzF;CACA,WAAOA,wBAAW,QAAQ,CAAC,CAAC,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AAC/E;;AAGA,SAAgB,SAAS,QAA2C;CAClE,MAAM,OAA+B,CAAC;CACtC,MAAM,QAAQ,QAAgB,MAAqC;EACjE,IAAI,CAAC,GAAG;EACR,MAAM,WAAY,EAAE,KAA4C;EAChE,IAAI,OAAO,aAAa,UAAU,KAAK,UAAU;CACnD;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,GAAG;EAC3D,KAAK,OAAO,OAAO,KAAK;EACxB,KAAK,OAAO,IAAI,MAAO,MAAqC,EAAE;CAChE;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,WAAW,CAAC,CAAC,GAAG;EAC/D,IAAI,OAAO,UAAU,UAAU;EAC/B,KAAK,WAAW,OAAO,KAAK;EAC5B,KAAK,WAAW,IAAI,MAAO,MAAqC,EAAE;CACpE;CACA,OAAO;AACT"}
@@ -0,0 +1,14 @@
1
+ import { BosConfig } from "./types.cjs";
2
+ //#region src/fingerprint.d.ts
3
+ /**
4
+ * The published pointer's version identity (atomic-deploys 08/12): a hash
5
+ * over every slot's `pin` — cheap to compute (no version-manifest fetch), and
6
+ * stable exactly when the deployed set is. Shared so the CLI and the host
7
+ * compute the same identity for the same pointer.
8
+ */
9
+ declare function pointerFingerprint(config: BosConfig): string;
10
+ /** Per-slot pin ids for display (slot → versioned manifest filename). */
11
+ declare function slotPins(config: BosConfig): Record<string, string>;
12
+ //#endregion
13
+ export { pointerFingerprint, slotPins };
14
+ //# sourceMappingURL=fingerprint.d.cts.map
@@ -0,0 +1,14 @@
1
+ import { BosConfig } from "./types.mjs";
2
+ //#region src/fingerprint.d.ts
3
+ /**
4
+ * The published pointer's version identity (atomic-deploys 08/12): a hash
5
+ * over every slot's `pin` — cheap to compute (no version-manifest fetch), and
6
+ * stable exactly when the deployed set is. Shared so the CLI and the host
7
+ * compute the same identity for the same pointer.
8
+ */
9
+ declare function pointerFingerprint(config: BosConfig): string;
10
+ /** Per-slot pin ids for display (slot → versioned manifest filename). */
11
+ declare function slotPins(config: BosConfig): Record<string, string>;
12
+ //#endregion
13
+ export { pointerFingerprint, slotPins };
14
+ //# sourceMappingURL=fingerprint.d.mts.map
@@ -0,0 +1,55 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ //#region src/fingerprint.ts
4
+ /**
5
+ * The published pointer's version identity (atomic-deploys 08/12): a hash
6
+ * over every slot's `pin` — cheap to compute (no version-manifest fetch), and
7
+ * stable exactly when the deployed set is. Shared so the CLI and the host
8
+ * compute the same identity for the same pointer.
9
+ */
10
+ function pointerFingerprint(config) {
11
+ const parts = [];
12
+ const slot = (prefix, s) => {
13
+ if (!s) return;
14
+ const pin = s.pin;
15
+ const pinPart = pin && typeof pin.manifest === "string" && typeof pin.integrity === "string" ? `${pin.manifest}:${pin.integrity}` : "";
16
+ const directPart = typeof s.integrity === "string" ? s.integrity : "";
17
+ parts.push(`${prefix}:${pinPart}:${directPart}`);
18
+ };
19
+ for (const [key, entry] of Object.entries(config.app ?? {})) {
20
+ slot(`app.${key}`, entry);
21
+ slot(`app.${key}.ui`, entry.ui);
22
+ }
23
+ for (const [key, entry] of Object.entries(config.plugins ?? {})) {
24
+ if (typeof entry === "string") {
25
+ parts.push(`plugins.${key}:${entry}`);
26
+ continue;
27
+ }
28
+ slot(`plugins.${key}`, entry);
29
+ slot(`plugins.${key}.ui`, entry.ui);
30
+ }
31
+ return createHash("sha256").update(parts.join("|")).digest("hex").slice(0, 16);
32
+ }
33
+ /** Per-slot pin ids for display (slot → versioned manifest filename). */
34
+ function slotPins(config) {
35
+ const pins = {};
36
+ const slot = (prefix, s) => {
37
+ if (!s) return;
38
+ const manifest = s.pin?.manifest;
39
+ if (typeof manifest === "string") pins[prefix] = manifest;
40
+ };
41
+ for (const [key, entry] of Object.entries(config.app ?? {})) {
42
+ slot(`app.${key}`, entry);
43
+ slot(`app.${key}.ui`, entry.ui);
44
+ }
45
+ for (const [key, entry] of Object.entries(config.plugins ?? {})) {
46
+ if (typeof entry === "string") continue;
47
+ slot(`plugins.${key}`, entry);
48
+ slot(`plugins.${key}.ui`, entry.ui);
49
+ }
50
+ return pins;
51
+ }
52
+
53
+ //#endregion
54
+ export { pointerFingerprint, slotPins };
55
+ //# sourceMappingURL=fingerprint.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.mjs","names":[],"sources":["../src/fingerprint.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport type { BosConfig } from \"./types\";\n\n/**\n * The published pointer's version identity (atomic-deploys 08/12): a hash\n * over every slot's `pin` — cheap to compute (no version-manifest fetch), and\n * stable exactly when the deployed set is. Shared so the CLI and the host\n * compute the same identity for the same pointer.\n */\nexport function pointerFingerprint(config: BosConfig): string {\n const parts: Array<string> = [];\n const slot = (prefix: string, s: { pin?: unknown; integrity?: unknown } | undefined) => {\n if (!s) return;\n const pin = s.pin as { manifest?: unknown; integrity?: unknown } | undefined;\n const pinPart =\n pin && typeof pin.manifest === \"string\" && typeof pin.integrity === \"string\"\n ? `${pin.manifest}:${pin.integrity}`\n : \"\";\n const directPart = typeof s.integrity === \"string\" ? s.integrity : \"\";\n parts.push(`${prefix}:${pinPart}:${directPart}`);\n };\n for (const [key, entry] of Object.entries(config.app ?? {})) {\n slot(`app.${key}`, entry);\n slot(`app.${key}.ui`, (entry as { ui?: { pin?: unknown; integrity?: unknown } }).ui);\n }\n for (const [key, entry] of Object.entries(config.plugins ?? {})) {\n if (typeof entry === \"string\") {\n parts.push(`plugins.${key}:${entry}`);\n continue;\n }\n slot(`plugins.${key}`, entry);\n slot(`plugins.${key}.ui`, (entry as { ui?: { pin?: unknown; integrity?: unknown } }).ui);\n }\n return createHash(\"sha256\").update(parts.join(\"|\")).digest(\"hex\").slice(0, 16);\n}\n\n/** Per-slot pin ids for display (slot → versioned manifest filename). */\nexport function slotPins(config: BosConfig): Record<string, string> {\n const pins: Record<string, string> = {};\n const slot = (prefix: string, s: { pin?: unknown } | undefined) => {\n if (!s) return;\n const manifest = (s.pin as { manifest?: unknown } | undefined)?.manifest;\n if (typeof manifest === \"string\") pins[prefix] = manifest;\n };\n for (const [key, entry] of Object.entries(config.app ?? {})) {\n slot(`app.${key}`, entry);\n slot(`app.${key}.ui`, (entry as { ui?: { pin?: unknown } }).ui);\n }\n for (const [key, entry] of Object.entries(config.plugins ?? {})) {\n if (typeof entry === \"string\") continue;\n slot(`plugins.${key}`, entry);\n slot(`plugins.${key}.ui`, (entry as { ui?: { pin?: unknown } }).ui);\n }\n return pins;\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,mBAAmB,QAA2B;CAC5D,MAAM,QAAuB,CAAC;CAC9B,MAAM,QAAQ,QAAgB,MAA0D;EACtF,IAAI,CAAC,GAAG;EACR,MAAM,MAAM,EAAE;EACd,MAAM,UACJ,OAAO,OAAO,IAAI,aAAa,YAAY,OAAO,IAAI,cAAc,WAChE,GAAG,IAAI,SAAS,GAAG,IAAI,cACvB;EACN,MAAM,aAAa,OAAO,EAAE,cAAc,WAAW,EAAE,YAAY;EACnE,MAAM,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY;CACjD;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,GAAG;EAC3D,KAAK,OAAO,OAAO,KAAK;EACxB,KAAK,OAAO,IAAI,MAAO,MAA0D,EAAE;CACrF;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,WAAW,CAAC,CAAC,GAAG;EAC/D,IAAI,OAAO,UAAU,UAAU;GAC7B,MAAM,KAAK,WAAW,IAAI,GAAG,OAAO;GACpC;EACF;EACA,KAAK,WAAW,OAAO,KAAK;EAC5B,KAAK,WAAW,IAAI,MAAO,MAA0D,EAAE;CACzF;CACA,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AAC/E;;AAGA,SAAgB,SAAS,QAA2C;CAClE,MAAM,OAA+B,CAAC;CACtC,MAAM,QAAQ,QAAgB,MAAqC;EACjE,IAAI,CAAC,GAAG;EACR,MAAM,WAAY,EAAE,KAA4C;EAChE,IAAI,OAAO,aAAa,UAAU,KAAK,UAAU;CACnD;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC,GAAG;EAC3D,KAAK,OAAO,OAAO,KAAK;EACxB,KAAK,OAAO,IAAI,MAAO,MAAqC,EAAE;CAChE;CACA,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,WAAW,CAAC,CAAC,GAAG;EAC/D,IAAI,OAAO,UAAU,UAAU;EAC/B,KAAK,WAAW,OAAO,KAAK;EAC5B,KAAK,WAAW,IAAI,MAAO,MAAqC,EAAE;CACpE;CACA,OAAO;AACT"}
@@ -14,27 +14,24 @@ const isRetryable = (error) => {
14
14
  if (error instanceof FetchHttpError) return error.status >= 500;
15
15
  return false;
16
16
  };
17
+ const runFetch = (url, init) => fetch(url, init);
17
18
  const fetchRawEff = (url, options) => effect.Effect.tryPromise({
18
19
  try: async () => {
19
- const timeoutMs = effect.Duration.toMillis(effect.Duration.decode(options?.timeout ?? DEFAULT_TIMEOUT));
20
- const controller = new AbortController();
21
- const timer = setTimeout(() => controller.abort(), timeoutMs);
20
+ const timeoutMs = effect.Duration.toMillis(options?.timeout ?? DEFAULT_TIMEOUT);
22
21
  try {
23
- return await fetch(url, {
22
+ return await runFetch(url, {
24
23
  method: options?.method ?? "GET",
25
24
  headers: options?.headers,
26
25
  body: options?.body,
27
26
  redirect: options?.redirect,
28
- signal: controller.signal
27
+ signal: AbortSignal.timeout(timeoutMs)
29
28
  });
30
29
  } catch (error) {
31
- if (error instanceof Error && error.name === "AbortError") throw new FetchTimeoutError({ url });
30
+ if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) throw new FetchTimeoutError({ url });
32
31
  throw new FetchNetworkError({
33
32
  url,
34
33
  cause: error
35
34
  });
36
- } finally {
37
- clearTimeout(timer);
38
35
  }
39
36
  },
40
37
  catch: (error) => {
@@ -45,19 +42,22 @@ const fetchRawEff = (url, options) => effect.Effect.tryPromise({
45
42
  });
46
43
  }
47
44
  });
48
- const fetchEff = (url, options) => fetchRawEff(url, options).pipe(effect.Effect.flatMap((response) => {
49
- if (response.ok) return effect.Effect.succeed(response);
50
- return effect.Effect.fail(new FetchHttpError({
51
- url,
52
- status: response.status,
53
- statusText: response.statusText
54
- }));
45
+ const fetchEff = (url, options) => fetchRawEff(url, options).pipe(effect.Effect.filterOrFail((response) => response.ok, (response) => new FetchHttpError({
46
+ url,
47
+ status: response.status,
48
+ statusText: response.statusText
49
+ })));
50
+ const retrySchedule = effect.Schedule.exponential(EXPONENTIAL_BASE).pipe(effect.Schedule.upTo({
51
+ duration: EXPONENTIAL_CAP,
52
+ times: DEFAULT_RETRIES
55
53
  }));
56
- const retrySchedule = effect.Schedule.exponential(EXPONENTIAL_BASE).pipe(effect.Schedule.upTo(EXPONENTIAL_CAP), effect.Schedule.intersect(effect.Schedule.recurs(DEFAULT_RETRIES)));
57
54
  const fetchWithRetryEff = (url, options) => {
58
55
  const retries = options?.retries ?? DEFAULT_RETRIES;
59
56
  if (retries <= 0) return fetchEff(url, options);
60
- const schedule = options?.retries !== void 0 ? effect.Schedule.exponential(EXPONENTIAL_BASE).pipe(effect.Schedule.upTo(EXPONENTIAL_CAP), effect.Schedule.intersect(effect.Schedule.recurs(retries))) : retrySchedule;
57
+ const schedule = options?.retries !== void 0 ? effect.Schedule.exponential(EXPONENTIAL_BASE).pipe(effect.Schedule.upTo({
58
+ duration: EXPONENTIAL_CAP,
59
+ times: retries
60
+ })) : retrySchedule;
61
61
  return fetchEff(url, options).pipe(effect.Effect.retry({
62
62
  schedule,
63
63
  while: isRetryable
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.cjs","names":["Data","Duration","Effect","Schedule"],"sources":["../src/http-client.ts"],"sourcesContent":["import { Data, Duration, Effect, Schedule } from \"effect\";\n\n// --- Tagged errors ---\n\nexport class FetchNetworkError extends Data.TaggedError(\"FetchNetworkError\")<{\n url: string;\n cause: unknown;\n}> {}\n\nexport class FetchTimeoutError extends Data.TaggedError(\"FetchTimeoutError\")<{\n url: string;\n}> {}\n\nexport class FetchHttpError extends Data.TaggedError(\"FetchHttpError\")<{\n url: string;\n status: number;\n statusText: string;\n}> {}\n\nexport type FetchError = FetchNetworkError | FetchTimeoutError | FetchHttpError;\n\n// --- Options ---\n\nexport interface FetchOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit;\n redirect?: RequestRedirect;\n timeout?: Duration.DurationInput;\n}\n\nexport interface FetchWithRetryOptions extends FetchOptions {\n retries?: number;\n}\n\n// --- Defaults ---\n\nconst DEFAULT_TIMEOUT = \"10 seconds\";\nconst DEFAULT_RETRIES = 3;\n\nconst EXPONENTIAL_BASE = Duration.seconds(1);\nconst EXPONENTIAL_CAP = Duration.seconds(15);\n\n// --- Helpers ---\n\nconst isRetryable = (error: FetchError): boolean => {\n if (error instanceof FetchNetworkError) return true;\n if (error instanceof FetchTimeoutError) return true;\n if (error instanceof FetchHttpError) return error.status >= 500;\n return false;\n};\n\n// --- Low-level: just timeout + error classification, returns Response regardless of HTTP status ---\n\nconst fetchRawEff = (\n url: string,\n options?: FetchOptions,\n): Effect.Effect<Response, FetchNetworkError | FetchTimeoutError> =>\n Effect.tryPromise({\n try: async () => {\n const timeoutMs = Duration.toMillis(Duration.decode(options?.timeout ?? DEFAULT_TIMEOUT));\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetch(url, {\n method: options?.method ?? \"GET\",\n headers: options?.headers,\n body: options?.body,\n redirect: options?.redirect,\n signal: controller.signal,\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new FetchTimeoutError({ url });\n }\n throw new FetchNetworkError({ url, cause: error });\n } finally {\n clearTimeout(timer);\n }\n },\n catch: (error) => {\n if (error instanceof FetchNetworkError || error instanceof FetchTimeoutError) {\n return error;\n }\n return new FetchNetworkError({ url, cause: error });\n },\n });\n\n// --- Adds HTTP status checking: non-2xx becomes FetchHttpError ---\n\nconst fetchEff = (url: string, options?: FetchOptions): Effect.Effect<Response, FetchError> =>\n fetchRawEff(url, options).pipe(\n Effect.flatMap((response) => {\n if (response.ok) return Effect.succeed(response);\n return Effect.fail(\n new FetchHttpError({ url, status: response.status, statusText: response.statusText }),\n );\n }),\n );\n\n// --- With retry ---\n\nconst retrySchedule = Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo(EXPONENTIAL_CAP),\n Schedule.intersect(Schedule.recurs(DEFAULT_RETRIES)),\n);\n\nexport const fetchWithRetryEff = (\n url: string,\n options?: FetchWithRetryOptions,\n): Effect.Effect<Response, FetchError> => {\n const retries = options?.retries ?? DEFAULT_RETRIES;\n\n if (retries <= 0) return fetchEff(url, options);\n\n const schedule =\n options?.retries !== undefined\n ? Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo(EXPONENTIAL_CAP),\n Schedule.intersect(Schedule.recurs(retries)),\n )\n : retrySchedule;\n\n return fetchEff(url, options).pipe(\n Effect.retry({\n schedule,\n while: isRetryable,\n }),\n );\n};\n\n// --- In-memory GET cache (per-process, prevents duplicate round trips) ---\n\nconst getCache = new Map<string, { data: unknown; expiresAt: number }>();\nconst GET_CACHE_TTL_MS = 30_000;\n\nfunction isCacheable(_url: string, options?: FetchWithRetryOptions): boolean {\n if (options?.method && options.method !== \"GET\") return false;\n if (options?.body) return false;\n return true;\n}\n\n// --- Promise wrappers (bridge for non-Effect code) ---\n\nexport const fetchResponse = (url: string, options?: FetchOptions): Promise<Response> =>\n Effect.runPromise(fetchRawEff(url, options));\n\nexport const fetchJsonOrNull = async <T>(\n url: string,\n options?: FetchWithRetryOptions,\n): Promise<T | null> => {\n if (isCacheable(url, options)) {\n const cached = getCache.get(url);\n if (cached && cached.expiresAt > Date.now()) {\n return cached.data as T;\n }\n }\n\n const retries = options?.retries ?? DEFAULT_RETRIES;\n const eff =\n retries > 0 ? fetchWithRetryEff(url, { ...options, retries }) : fetchEff(url, options);\n\n try {\n const res = await Effect.runPromise(eff);\n const data = (await res.json()) as T;\n if (isCacheable(url, options)) {\n getCache.set(url, { data, expiresAt: Date.now() + GET_CACHE_TTL_MS });\n }\n return data;\n } catch (error) {\n const msg =\n error instanceof FetchNetworkError\n ? `[http] Network error: ${error.url} — ${String(error.cause)}`\n : error instanceof FetchTimeoutError\n ? `[http] Timeout: ${error.url}`\n : error instanceof FetchHttpError\n ? `[http] HTTP ${error.status}: ${error.url}`\n : `[http] Unknown error while fetching ${url}`;\n console.error(msg);\n return null;\n }\n};\n"],"mappings":";;;AAIA,IAAa,oBAAb,cAAuCA,YAAK,YAAY,mBAAmB,CAAC,CAGzE,CAAC;AAEJ,IAAa,oBAAb,cAAuCA,YAAK,YAAY,mBAAmB,CAAC,CAEzE,CAAC;AAEJ,IAAa,iBAAb,cAAoCA,YAAK,YAAY,gBAAgB,CAAC,CAInE,CAAC;AAoBJ,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AAExB,MAAM,mBAAmBC,gBAAS,QAAQ,CAAC;AAC3C,MAAM,kBAAkBA,gBAAS,QAAQ,EAAE;AAI3C,MAAM,eAAe,UAA+B;CAClD,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,gBAAgB,OAAO,MAAM,UAAU;CAC5D,OAAO;AACT;AAIA,MAAM,eACJ,KACA,YAEAC,cAAO,WAAW;CAChB,KAAK,YAAY;EACf,MAAM,YAAYD,gBAAS,SAASA,gBAAS,OAAO,SAAS,WAAW,eAAe,CAAC;EACxF,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,SAAS;EAC5D,IAAI;GACF,OAAO,MAAM,MAAM,KAAK;IACtB,QAAQ,SAAS,UAAU;IAC3B,S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,SAAS,YAAY,MAAc,SAA0C;CAC3E,IAAI,SAAS,UAAU,QAAQ,WAAW,OAAO,OAAO;CACxD,IAAI,SAAS,MAAM,OAAO;CAC1B,OAAO;AACT;AAIA,MAAa,iBAAiB,KAAa,YACzCA,cAAO,WAAW,YAAY,KAAK,OAAO,CAAC;AAE7C,MAAa,kBAAkB,OAC7B,KACA,YACsB;CACtB,IAAI,YAAY,KAAK,OAAO,GAAG;EAC7B,MAAM,SAAS,SAAS,IAAI,GAAG;EAC/B,IAAI,UAAU,OAAO,YAAY,KAAK,IAAI,GACxC,OAAO,OAAO;CAElB;CAEA,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,MACJ,UAAU,IAAI,kBAAkB,KAAK;EAAE,GAAG;EAAS;CAAQ,CAAC,IAAI,SAAS,KAAK,OAAO;CAEvF,IAAI;EAEF,MAAM,OAAQ,OAAM,MADFA,cAAO,WAAW,GAAG,EAChB,CAAC,KAAK;EAC7B,IAAI,YAAY,KAAK,OAAO,GAC1B,SAAS,IAAI,KAAK;GAAE;GAAM,WAAW,KAAK,IAAI,IAAI;EAAiB,CAAC;EAEtE,OAAO;CACT,SAAS,OAAO;EACd,MAAM,MACJ,iBAAiB,oBACb,yBAAyB,MAAM,IAAI,KAAK,OAAO,MAAM,KAAK,MAC1D,iBAAiB,oBACf,mBAAmB,MAAM,QACzB,iBAAiB,iBACf,eAAe,MAAM,OAAO,IAAI,MAAM,QACtC,uCAAuC;EACjD,QAAQ,MAAM,GAAG;EACjB,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"http-client.cjs","names":["Data","Duration","Effect","Schedule"],"sources":["../src/http-client.ts"],"sourcesContent":["import { Data, Duration, Effect, Schedule } from \"effect\";\n\n// --- Tagged errors ---\n\nexport class FetchNetworkError extends Data.TaggedError(\"FetchNetworkError\")<{\n url: string;\n cause: unknown;\n}> {}\n\nexport class FetchTimeoutError extends Data.TaggedError(\"FetchTimeoutError\")<{\n url: string;\n}> {}\n\nexport class FetchHttpError extends Data.TaggedError(\"FetchHttpError\")<{\n url: string;\n status: number;\n statusText: string;\n}> {}\n\nexport type FetchError = FetchNetworkError | FetchTimeoutError | FetchHttpError;\n\n// --- Options ---\n\nexport interface FetchOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit;\n redirect?: RequestRedirect;\n timeout?: Duration.Input;\n}\n\nexport interface FetchWithRetryOptions extends FetchOptions {\n retries?: number;\n}\n\n// --- Defaults ---\n\nconst DEFAULT_TIMEOUT = \"10 seconds\";\nconst DEFAULT_RETRIES = 3;\n\nconst EXPONENTIAL_BASE = Duration.seconds(1);\nconst EXPONENTIAL_CAP = Duration.seconds(15);\n\n// --- Helpers ---\n\nconst isRetryable = (error: FetchError): boolean => {\n if (error instanceof FetchNetworkError) return true;\n if (error instanceof FetchTimeoutError) return true;\n if (error instanceof FetchHttpError) return error.status >= 500;\n return false;\n};\n\n// --- Low-level: just timeout + error classification, returns Response regardless of HTTP status ---\n\nconst runFetch = (url: string, init?: RequestInit): Promise<Response> => fetch(url, init);\n\nconst fetchRawEff = (\n url: string,\n options?: FetchOptions,\n): Effect.Effect<Response, FetchNetworkError | FetchTimeoutError> =>\n Effect.tryPromise({\n try: async () => {\n const timeoutMs = Duration.toMillis(options?.timeout ?? DEFAULT_TIMEOUT);\n try {\n return await runFetch(url, {\n method: options?.method ?? \"GET\",\n headers: options?.headers,\n body: options?.body,\n redirect: options?.redirect,\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n if (\n error instanceof Error &&\n (error.name === \"AbortError\" || error.name === \"TimeoutError\")\n ) {\n throw new FetchTimeoutError({ url });\n }\n throw new FetchNetworkError({ url, cause: error });\n }\n },\n catch: (error) => {\n if (error instanceof FetchNetworkError || error instanceof FetchTimeoutError) {\n return error;\n }\n return new FetchNetworkError({ url, cause: error });\n },\n });\n\n// --- Adds HTTP status checking: non-2xx becomes FetchHttpError ---\n\nconst fetchEff = (url: string, options?: FetchOptions): Effect.Effect<Response, FetchError> =>\n fetchRawEff(url, options).pipe(\n Effect.filterOrFail(\n (response) => response.ok,\n (response) =>\n new FetchHttpError({ url, status: response.status, statusText: response.statusText }),\n ),\n );\n\n// --- With retry ---\n\nconst retrySchedule = Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo({ duration: EXPONENTIAL_CAP, times: DEFAULT_RETRIES }),\n);\n\nexport const fetchWithRetryEff = (\n url: string,\n options?: FetchWithRetryOptions,\n): Effect.Effect<Response, FetchError> => {\n const retries = options?.retries ?? DEFAULT_RETRIES;\n\n if (retries <= 0) return fetchEff(url, options);\n\n const schedule =\n options?.retries !== undefined\n ? Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo({ duration: EXPONENTIAL_CAP, times: retries }),\n )\n : retrySchedule;\n\n return fetchEff(url, options).pipe(\n Effect.retry({\n schedule,\n while: isRetryable,\n }),\n );\n};\n\n// --- In-memory GET cache (per-process, prevents duplicate round trips) ---\n\nconst getCache = new Map<string, { data: unknown; expiresAt: number }>();\nconst GET_CACHE_TTL_MS = 30_000;\n\nexport function clearHttpCache(): void {\n getCache.clear();\n}\n\nfunction isCacheable(_url: string, options?: FetchWithRetryOptions): boolean {\n if (options?.method && options.method !== \"GET\") return false;\n if (options?.body) return false;\n return true;\n}\n\n// --- Promise wrappers (bridge for non-Effect code) ---\n\nexport const fetchResponse = (url: string, options?: FetchOptions): Promise<Response> =>\n Effect.runPromise(fetchRawEff(url, options));\n\nexport const fetchJsonOrNull = async <T>(\n url: string,\n options?: FetchWithRetryOptions,\n): Promise<T | null> => {\n if (isCacheable(url, options)) {\n const cached = getCache.get(url);\n if (cached && cached.expiresAt > Date.now()) {\n return cached.data as T;\n }\n }\n\n const retries = options?.retries ?? DEFAULT_RETRIES;\n const eff =\n retries > 0 ? fetchWithRetryEff(url, { ...options, retries }) : fetchEff(url, options);\n\n try {\n const res = await Effect.runPromise(eff);\n const data = (await res.json()) as T;\n if (isCacheable(url, options)) {\n getCache.set(url, { data, expiresAt: Date.now() + GET_CACHE_TTL_MS });\n }\n return data;\n } catch (error) {\n const msg =\n error instanceof FetchNetworkError\n ? `[http] Network error: ${error.url} — ${String(error.cause)}`\n : error instanceof FetchTimeoutError\n ? `[http] Timeout: ${error.url}`\n : error instanceof FetchHttpError\n ? `[http] HTTP ${error.status}: ${error.url}`\n : `[http] Unknown error while fetching ${url}`;\n console.error(msg);\n return null;\n }\n};\n"],"mappings":";;;AAIA,IAAa,oBAAb,cAAuCA,YAAK,YAAY,mBAAmB,CAAC,CAGzE,CAAC;AAEJ,IAAa,oBAAb,cAAuCA,YAAK,YAAY,mBAAmB,CAAC,CAEzE,CAAC;AAEJ,IAAa,iBAAb,cAAoCA,YAAK,YAAY,gBAAgB,CAAC,CAInE,CAAC;AAoBJ,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AAExB,MAAM,mBAAmBC,gBAAS,QAAQ,CAAC;AAC3C,MAAM,kBAAkBA,gBAAS,QAAQ,EAAE;AAI3C,MAAM,eAAe,UAA+B;CAClD,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,gBAAgB,OAAO,MAAM,UAAU;CAC5D,OAAO;AACT;AAIA,MAAM,YAAY,KAAa,SAA0C,MAAM,KAAK,IAAI;AAExF,MAAM,eACJ,KACA,YAEAC,cAAO,WAAW;CAChB,KAAK,YAAY;EACf,MAAM,YAAYD,gBAAS,SAAS,SAAS,WAAW,eAAe;EACvE,IAAI;GACF,OAAO,MAAM,SAAS,KAAK;IACzB,QAAQ,SAAS,UAAU;IAC3B,SAAS,SAAS;IAClB,MAAM,SAAS;IACf,UAAU,SAAS;IACnB,QAAQ,YAAY,QAAQ,SAAS;GACvC,CAAC;EACH,SAAS,OAAO;GACd,IACE,iBAAiB,UAChB,MAAM,SAAS,gBAAgB,MAAM,SAAS,iBAE/C,MAAM,IAAI,kBAAkB,EAAE,IAAI,CAAC;GAErC,MAAM,IAAI,kBAAkB;IAA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AAK,IAAI,GACxC,OAAO,OAAO;CAElB;CAEA,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,MACJ,UAAU,IAAI,kBAAkB,KAAK;EAAE,GAAG;EAAS;CAAQ,CAAC,IAAI,SAAS,KAAK,OAAO;CAEvF,IAAI;EAEF,MAAM,OAAQ,OAAM,MADFA,cAAO,WAAW,GAAG,EAChB,CAAC,KAAK;EAC7B,IAAI,YAAY,KAAK,OAAO,GAC1B,SAAS,IAAI,KAAK;GAAE;GAAM,WAAW,KAAK,IAAI,IAAI;EAAiB,CAAC;EAEtE,OAAO;CACT,SAAS,OAAO;EACd,MAAM,MACJ,iBAAiB,oBACb,yBAAyB,MAAM,IAAI,KAAK,OAAO,MAAM,KAAK,MAC1D,iBAAiB,oBACf,mBAAmB,MAAM,QACzB,iBAAiB,iBACf,eAAe,MAAM,OAAO,IAAI,MAAM,QACtC,uCAAuC;EACjD,QAAQ,MAAM,GAAG;EACjB,OAAO;CACT;AACF"}
@@ -14,27 +14,24 @@ const isRetryable = (error) => {
14
14
  if (error instanceof FetchHttpError) return error.status >= 500;
15
15
  return false;
16
16
  };
17
+ const runFetch = (url, init) => fetch(url, init);
17
18
  const fetchRawEff = (url, options) => Effect.tryPromise({
18
19
  try: async () => {
19
- const timeoutMs = Duration.toMillis(Duration.decode(options?.timeout ?? DEFAULT_TIMEOUT));
20
- const controller = new AbortController();
21
- const timer = setTimeout(() => controller.abort(), timeoutMs);
20
+ const timeoutMs = Duration.toMillis(options?.timeout ?? DEFAULT_TIMEOUT);
22
21
  try {
23
- return await fetch(url, {
22
+ return await runFetch(url, {
24
23
  method: options?.method ?? "GET",
25
24
  headers: options?.headers,
26
25
  body: options?.body,
27
26
  redirect: options?.redirect,
28
- signal: controller.signal
27
+ signal: AbortSignal.timeout(timeoutMs)
29
28
  });
30
29
  } catch (error) {
31
- if (error instanceof Error && error.name === "AbortError") throw new FetchTimeoutError({ url });
30
+ if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) throw new FetchTimeoutError({ url });
32
31
  throw new FetchNetworkError({
33
32
  url,
34
33
  cause: error
35
34
  });
36
- } finally {
37
- clearTimeout(timer);
38
35
  }
39
36
  },
40
37
  catch: (error) => {
@@ -45,19 +42,22 @@ const fetchRawEff = (url, options) => Effect.tryPromise({
45
42
  });
46
43
  }
47
44
  });
48
- const fetchEff = (url, options) => fetchRawEff(url, options).pipe(Effect.flatMap((response) => {
49
- if (response.ok) return Effect.succeed(response);
50
- return Effect.fail(new FetchHttpError({
51
- url,
52
- status: response.status,
53
- statusText: response.statusText
54
- }));
45
+ const fetchEff = (url, options) => fetchRawEff(url, options).pipe(Effect.filterOrFail((response) => response.ok, (response) => new FetchHttpError({
46
+ url,
47
+ status: response.status,
48
+ statusText: response.statusText
49
+ })));
50
+ const retrySchedule = Schedule.exponential(EXPONENTIAL_BASE).pipe(Schedule.upTo({
51
+ duration: EXPONENTIAL_CAP,
52
+ times: DEFAULT_RETRIES
55
53
  }));
56
- const retrySchedule = Schedule.exponential(EXPONENTIAL_BASE).pipe(Schedule.upTo(EXPONENTIAL_CAP), Schedule.intersect(Schedule.recurs(DEFAULT_RETRIES)));
57
54
  const fetchWithRetryEff = (url, options) => {
58
55
  const retries = options?.retries ?? DEFAULT_RETRIES;
59
56
  if (retries <= 0) return fetchEff(url, options);
60
- const schedule = options?.retries !== void 0 ? Schedule.exponential(EXPONENTIAL_BASE).pipe(Schedule.upTo(EXPONENTIAL_CAP), Schedule.intersect(Schedule.recurs(retries))) : retrySchedule;
57
+ const schedule = options?.retries !== void 0 ? Schedule.exponential(EXPONENTIAL_BASE).pipe(Schedule.upTo({
58
+ duration: EXPONENTIAL_CAP,
59
+ times: retries
60
+ })) : retrySchedule;
61
61
  return fetchEff(url, options).pipe(Effect.retry({
62
62
  schedule,
63
63
  while: isRetryable
@@ -1 +1 @@
1
- {"version":3,"file":"http-client.mjs","names":[],"sources":["../src/http-client.ts"],"sourcesContent":["import { Data, Duration, Effect, Schedule } from \"effect\";\n\n// --- Tagged errors ---\n\nexport class FetchNetworkError extends Data.TaggedError(\"FetchNetworkError\")<{\n url: string;\n cause: unknown;\n}> {}\n\nexport class FetchTimeoutError extends Data.TaggedError(\"FetchTimeoutError\")<{\n url: string;\n}> {}\n\nexport class FetchHttpError extends Data.TaggedError(\"FetchHttpError\")<{\n url: string;\n status: number;\n statusText: string;\n}> {}\n\nexport type FetchError = FetchNetworkError | FetchTimeoutError | FetchHttpError;\n\n// --- Options ---\n\nexport interface FetchOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit;\n redirect?: RequestRedirect;\n timeout?: Duration.DurationInput;\n}\n\nexport interface FetchWithRetryOptions extends FetchOptions {\n retries?: number;\n}\n\n// --- Defaults ---\n\nconst DEFAULT_TIMEOUT = \"10 seconds\";\nconst DEFAULT_RETRIES = 3;\n\nconst EXPONENTIAL_BASE = Duration.seconds(1);\nconst EXPONENTIAL_CAP = Duration.seconds(15);\n\n// --- Helpers ---\n\nconst isRetryable = (error: FetchError): boolean => {\n if (error instanceof FetchNetworkError) return true;\n if (error instanceof FetchTimeoutError) return true;\n if (error instanceof FetchHttpError) return error.status >= 500;\n return false;\n};\n\n// --- Low-level: just timeout + error classification, returns Response regardless of HTTP status ---\n\nconst fetchRawEff = (\n url: string,\n options?: FetchOptions,\n): Effect.Effect<Response, FetchNetworkError | FetchTimeoutError> =>\n Effect.tryPromise({\n try: async () => {\n const timeoutMs = Duration.toMillis(Duration.decode(options?.timeout ?? DEFAULT_TIMEOUT));\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n return await fetch(url, {\n method: options?.method ?? \"GET\",\n headers: options?.headers,\n body: options?.body,\n redirect: options?.redirect,\n signal: controller.signal,\n });\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new FetchTimeoutError({ url });\n }\n throw new FetchNetworkError({ url, cause: error });\n } finally {\n clearTimeout(timer);\n }\n },\n catch: (error) => {\n if (error instanceof FetchNetworkError || error instanceof FetchTimeoutError) {\n return error;\n }\n return new FetchNetworkError({ url, cause: error });\n },\n });\n\n// --- Adds HTTP status checking: non-2xx becomes FetchHttpError ---\n\nconst fetchEff = (url: string, options?: FetchOptions): Effect.Effect<Response, FetchError> =>\n fetchRawEff(url, options).pipe(\n Effect.flatMap((response) => {\n if (response.ok) return Effect.succeed(response);\n return Effect.fail(\n new FetchHttpError({ url, status: response.status, statusText: response.statusText }),\n );\n }),\n );\n\n// --- With retry ---\n\nconst retrySchedule = Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo(EXPONENTIAL_CAP),\n Schedule.intersect(Schedule.recurs(DEFAULT_RETRIES)),\n);\n\nexport const fetchWithRetryEff = (\n url: string,\n options?: FetchWithRetryOptions,\n): Effect.Effect<Response, FetchError> => {\n const retries = options?.retries ?? DEFAULT_RETRIES;\n\n if (retries <= 0) return fetchEff(url, options);\n\n const schedule =\n options?.retries !== undefined\n ? Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo(EXPONENTIAL_CAP),\n Schedule.intersect(Schedule.recurs(retries)),\n )\n : retrySchedule;\n\n return fetchEff(url, options).pipe(\n Effect.retry({\n schedule,\n while: isRetryable,\n }),\n );\n};\n\n// --- In-memory GET cache (per-process, prevents duplicate round trips) ---\n\nconst getCache = new Map<string, { data: unknown; expiresAt: number }>();\nconst GET_CACHE_TTL_MS = 30_000;\n\nfunction isCacheable(_url: string, options?: FetchWithRetryOptions): boolean {\n if (options?.method && options.method !== \"GET\") return false;\n if (options?.body) return false;\n return true;\n}\n\n// --- Promise wrappers (bridge for non-Effect code) ---\n\nexport const fetchResponse = (url: string, options?: FetchOptions): Promise<Response> =>\n Effect.runPromise(fetchRawEff(url, options));\n\nexport const fetchJsonOrNull = async <T>(\n url: string,\n options?: FetchWithRetryOptions,\n): Promise<T | null> => {\n if (isCacheable(url, options)) {\n const cached = getCache.get(url);\n if (cached && cached.expiresAt > Date.now()) {\n return cached.data as T;\n }\n }\n\n const retries = options?.retries ?? DEFAULT_RETRIES;\n const eff =\n retries > 0 ? fetchWithRetryEff(url, { ...options, retries }) : fetchEff(url, options);\n\n try {\n const res = await Effect.runPromise(eff);\n const data = (await res.json()) as T;\n if (isCacheable(url, options)) {\n getCache.set(url, { data, expiresAt: Date.now() + GET_CACHE_TTL_MS });\n }\n return data;\n } catch (error) {\n const msg =\n error instanceof FetchNetworkError\n ? `[http] Network error: ${error.url} — ${String(error.cause)}`\n : error instanceof FetchTimeoutError\n ? `[http] Timeout: ${error.url}`\n : error instanceof FetchHttpError\n ? `[http] HTTP ${error.status}: ${error.url}`\n : `[http] Unknown error while fetching ${url}`;\n console.error(msg);\n return null;\n }\n};\n"],"mappings":";;;AAIA,IAAa,oBAAb,cAAuC,KAAK,YAAY,mBAAmB,CAAC,CAGzE,CAAC;AAEJ,IAAa,oBAAb,cAAuC,KAAK,YAAY,mBAAmB,CAAC,CAEzE,CAAC;AAEJ,IAAa,iBAAb,cAAoC,KAAK,YAAY,gBAAgB,CAAC,CAInE,CAAC;AAoBJ,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AAExB,MAAM,mBAAmB,SAAS,QAAQ,CAAC;AAC3C,MAAM,kBAAkB,SAAS,QAAQ,EAAE;AAI3C,MAAM,eAAe,UAA+B;CAClD,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,gBAAgB,OAAO,MAAM,UAAU;CAC5D,OAAO;AACT;AAIA,MAAM,eACJ,KACA,YAEA,OAAO,WAAW;CAChB,KAAK,YAAY;EACf,MAAM,YAAY,SAAS,SAAS,SAAS,OAAO,SAAS,WAAW,eAAe,CAAC;EACxF,MAAM,aAAa,IAAI,gBAAgB;EACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,SAAS;EAC5D,IAAI;GACF,OAAO,MAAM,MAAM,KAAK;IACtB,QAAQ,SAAS,UAAU;IAC3B,SAAS,SAAS;IAClB,MAA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,UAAU,QAAQ,WAAW,OAAO,OAAO;CACxD,IAAI,SAAS,MAAM,OAAO;CAC1B,OAAO;AACT;AAIA,MAAa,iBAAiB,KAAa,YACzC,OAAO,WAAW,YAAY,KAAK,OAAO,CAAC;AAE7C,MAAa,kBAAkB,OAC7B,KACA,YACsB;CACtB,IAAI,YAAY,KAAK,OAAO,GAAG;EAC7B,MAAM,SAAS,SAAS,IAAI,GAAG;EAC/B,IAAI,UAAU,OAAO,YAAY,KAAK,IAAI,GACxC,OAAO,OAAO;CAElB;CAEA,MAAM,UAAU,SAAS,WAAW;CACpC,MAAM,MACJ,UAAU,IAAI,kBAAkB,KAAK;EAAE,GAAG;EAAS;CAAQ,CAAC,IAAI,SAAS,KAAK,OAAO;CAEvF,IAAI;EAEF,MAAM,OAAQ,OAAM,MADF,OAAO,WAAW,GAAG,EAChB,CAAC,KAAK;EAC7B,IAAI,YAAY,KAAK,OAAO,GAC1B,SAAS,IAAI,KAAK;GAAE;GAAM,WAAW,KAAK,IAAI,IAAI;EAAiB,CAAC;EAEtE,OAAO;CACT,SAAS,OAAO;EACd,MAAM,MACJ,iBAAiB,oBACb,yBAAyB,MAAM,IAAI,KAAK,OAAO,MAAM,KAAK,MAC1D,iBAAiB,oBACf,mBAAmB,MAAM,QACzB,iBAAiB,iBACf,eAAe,MAAM,OAAO,IAAI,MAAM,QACtC,uCAAuC;EACjD,QAAQ,MAAM,GAAG;EACjB,OAAO;CACT;AACF"}
1
+ {"version":3,"file":"http-client.mjs","names":[],"sources":["../src/http-client.ts"],"sourcesContent":["import { Data, Duration, Effect, Schedule } from \"effect\";\n\n// --- Tagged errors ---\n\nexport class FetchNetworkError extends Data.TaggedError(\"FetchNetworkError\")<{\n url: string;\n cause: unknown;\n}> {}\n\nexport class FetchTimeoutError extends Data.TaggedError(\"FetchTimeoutError\")<{\n url: string;\n}> {}\n\nexport class FetchHttpError extends Data.TaggedError(\"FetchHttpError\")<{\n url: string;\n status: number;\n statusText: string;\n}> {}\n\nexport type FetchError = FetchNetworkError | FetchTimeoutError | FetchHttpError;\n\n// --- Options ---\n\nexport interface FetchOptions {\n method?: string;\n headers?: Record<string, string>;\n body?: BodyInit;\n redirect?: RequestRedirect;\n timeout?: Duration.Input;\n}\n\nexport interface FetchWithRetryOptions extends FetchOptions {\n retries?: number;\n}\n\n// --- Defaults ---\n\nconst DEFAULT_TIMEOUT = \"10 seconds\";\nconst DEFAULT_RETRIES = 3;\n\nconst EXPONENTIAL_BASE = Duration.seconds(1);\nconst EXPONENTIAL_CAP = Duration.seconds(15);\n\n// --- Helpers ---\n\nconst isRetryable = (error: FetchError): boolean => {\n if (error instanceof FetchNetworkError) return true;\n if (error instanceof FetchTimeoutError) return true;\n if (error instanceof FetchHttpError) return error.status >= 500;\n return false;\n};\n\n// --- Low-level: just timeout + error classification, returns Response regardless of HTTP status ---\n\nconst runFetch = (url: string, init?: RequestInit): Promise<Response> => fetch(url, init);\n\nconst fetchRawEff = (\n url: string,\n options?: FetchOptions,\n): Effect.Effect<Response, FetchNetworkError | FetchTimeoutError> =>\n Effect.tryPromise({\n try: async () => {\n const timeoutMs = Duration.toMillis(options?.timeout ?? DEFAULT_TIMEOUT);\n try {\n return await runFetch(url, {\n method: options?.method ?? \"GET\",\n headers: options?.headers,\n body: options?.body,\n redirect: options?.redirect,\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n if (\n error instanceof Error &&\n (error.name === \"AbortError\" || error.name === \"TimeoutError\")\n ) {\n throw new FetchTimeoutError({ url });\n }\n throw new FetchNetworkError({ url, cause: error });\n }\n },\n catch: (error) => {\n if (error instanceof FetchNetworkError || error instanceof FetchTimeoutError) {\n return error;\n }\n return new FetchNetworkError({ url, cause: error });\n },\n });\n\n// --- Adds HTTP status checking: non-2xx becomes FetchHttpError ---\n\nconst fetchEff = (url: string, options?: FetchOptions): Effect.Effect<Response, FetchError> =>\n fetchRawEff(url, options).pipe(\n Effect.filterOrFail(\n (response) => response.ok,\n (response) =>\n new FetchHttpError({ url, status: response.status, statusText: response.statusText }),\n ),\n );\n\n// --- With retry ---\n\nconst retrySchedule = Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo({ duration: EXPONENTIAL_CAP, times: DEFAULT_RETRIES }),\n);\n\nexport const fetchWithRetryEff = (\n url: string,\n options?: FetchWithRetryOptions,\n): Effect.Effect<Response, FetchError> => {\n const retries = options?.retries ?? DEFAULT_RETRIES;\n\n if (retries <= 0) return fetchEff(url, options);\n\n const schedule =\n options?.retries !== undefined\n ? Schedule.exponential(EXPONENTIAL_BASE).pipe(\n Schedule.upTo({ duration: EXPONENTIAL_CAP, times: retries }),\n )\n : retrySchedule;\n\n return fetchEff(url, options).pipe(\n Effect.retry({\n schedule,\n while: isRetryable,\n }),\n );\n};\n\n// --- In-memory GET cache (per-process, prevents duplicate round trips) ---\n\nconst getCache = new Map<string, { data: unknown; expiresAt: number }>();\nconst GET_CACHE_TTL_MS = 30_000;\n\nexport function clearHttpCache(): void {\n getCache.clear();\n}\n\nfunction isCacheable(_url: string, options?: FetchWithRetryOptions): boolean {\n if (options?.method && options.method !== \"GET\") return false;\n if (options?.body) return false;\n return true;\n}\n\n// --- Promise wrappers (bridge for non-Effect code) ---\n\nexport const fetchResponse = (url: string, options?: FetchOptions): Promise<Response> =>\n Effect.runPromise(fetchRawEff(url, options));\n\nexport const fetchJsonOrNull = async <T>(\n url: string,\n options?: FetchWithRetryOptions,\n): Promise<T | null> => {\n if (isCacheable(url, options)) {\n const cached = getCache.get(url);\n if (cached && cached.expiresAt > Date.now()) {\n return cached.data as T;\n }\n }\n\n const retries = options?.retries ?? DEFAULT_RETRIES;\n const eff =\n retries > 0 ? fetchWithRetryEff(url, { ...options, retries }) : fetchEff(url, options);\n\n try {\n const res = await Effect.runPromise(eff);\n const data = (await res.json()) as T;\n if (isCacheable(url, options)) {\n getCache.set(url, { data, expiresAt: Date.now() + GET_CACHE_TTL_MS });\n }\n return data;\n } catch (error) {\n const msg =\n error instanceof FetchNetworkError\n ? `[http] Network error: ${error.url} — ${String(error.cause)}`\n : error instanceof FetchTimeoutError\n ? `[http] Timeout: ${error.url}`\n : error instanceof FetchHttpError\n ? `[http] HTTP ${error.status}: ${error.url}`\n : `[http] Unknown error while fetching ${url}`;\n console.error(msg);\n return null;\n }\n};\n"],"mappings":";;;AAIA,IAAa,oBAAb,cAAuC,KAAK,YAAY,mBAAmB,CAAC,CAGzE,CAAC;AAEJ,IAAa,oBAAb,cAAuC,KAAK,YAAY,mBAAmB,CAAC,CAEzE,CAAC;AAEJ,IAAa,iBAAb,cAAoC,KAAK,YAAY,gBAAgB,CAAC,CAInE,CAAC;AAoBJ,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AAExB,MAAM,mBAAmB,SAAS,QAAQ,CAAC;AAC3C,MAAM,kBAAkB,SAAS,QAAQ,EAAE;AAI3C,MAAM,eAAe,UAA+B;CAClD,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,mBAAmB,OAAO;CAC/C,IAAI,iBAAiB,gBAAgB,OAAO,MAAM,UAAU;CAC5D,OAAO;AACT;AAIA,MAAM,YAAY,KAAa,SAA0C,MAAM,KAAK,IAAI;AAExF,MAAM,eACJ,KACA,YAEA,OAAO,WAAW;CAChB,KAAK,YAAY;EACf,MAAM,YAAY,SAAS,SAAS,SAAS,WAAW,eAAe;EACvE,IAAI;GACF,OAAO,MAAM,SAAS,KAAK;IACzB,QAAQ,SAAS,UAAU;IAC3B,SAAS,SAAS;IAClB,MAAM,SAAS;IACf,UAAU,SAAS;IACnB,QAAQ,YAAY,QAAQ,SAAS;GACvC,CAAC;EACH,SAAS,OAAO;GACd,IACE,iBAAiB,UAChB,MAAM,SAAS,gBAAgB,MAAM,SAAS,iBAE/C,MAAM,IAAI,kBAAkB,EAAE,IAAI,CAAC;GAErC,MAAM,IAAI,kBAAkB;IAAE;IAAK,OAAO;GAAM,CAAC;EACnD;CACF;CACA,QAAQ,UAAU;EAChB,IAAI,iBAAiB,qB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