@builtbyfriends/bwf 0.0.0-stage → 1.9.2

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 (448) hide show
  1. package/AGENTS_TEMPLATE.md +4 -0
  2. package/LICENSE +22 -0
  3. package/README.md +48 -2
  4. package/dist/account-cmd-Ddt8lGeL.mjs +45 -0
  5. package/dist/agents-BLiMq9E1.mjs +113 -0
  6. package/dist/application-analysis-C9Ck2Yeg.mjs +1498 -0
  7. package/dist/application-routing-DbR-W5lG.mjs +25 -0
  8. package/dist/atomic-write-DA6eD1Kp.mjs +17 -0
  9. package/dist/auth-BKsUmWbT.d.mts +77 -0
  10. package/dist/auth-DkvoW5hB.mjs +33 -0
  11. package/dist/auth-aKyIWkdS.mjs +1 -0
  12. package/dist/auth-client-6-Ft9i9T.d.mts +5 -0
  13. package/dist/auth-client-DwCdwKbw.mjs +5 -0
  14. package/dist/auth-client-react-CJdeErvM.mjs +5 -0
  15. package/dist/auth-client-react-DvQLe5Zb.d.mts +5 -0
  16. package/dist/auth-link-CCl-hJol.mjs +26 -0
  17. package/dist/auth-migrations-DDeifS3v.mjs +206 -0
  18. package/dist/auth-router-BG74WFUf.mjs +66 -0
  19. package/dist/auth-xnkmpZUl.mjs +311 -0
  20. package/dist/base64-ikl9yBy3.mjs +15 -0
  21. package/dist/better-auth-shared-Br6TNaYJ.mjs +473 -0
  22. package/dist/better-auth-shared-CsBNvPOU.d.mts +56 -0
  23. package/dist/build-cmd-BnZezraT.mjs +153 -0
  24. package/dist/build-output-dir-Clj_unKN.mjs +402 -0
  25. package/dist/cancel-deploy-DKAj5U1Z.mjs +57 -0
  26. package/dist/cf-access-Bhz9wX6p.mjs +131 -0
  27. package/dist/cf-access-CUP5L08W.mjs +67 -0
  28. package/dist/cf-build-output-DA6uJomQ.mjs +1 -0
  29. package/dist/cf-build-output-DNQTwMNU.mjs +438 -0
  30. package/dist/cf-command-values-2kOtxMo1.mjs +26 -0
  31. package/dist/cf-config-migrate-COOCi4Ge.mjs +330 -0
  32. package/dist/cf-worker-settings-CIh4t_yG.mjs +41 -0
  33. package/dist/cli/cli.d.mts +1 -0
  34. package/dist/cli/cli.mjs +88 -0
  35. package/dist/cli/cloudflare-operation-process.d.mts +1 -0
  36. package/dist/cli/cloudflare-operation-process.mjs +1284 -0
  37. package/dist/cli/env-schema-probe.d.mts +43 -0
  38. package/dist/cli/env-schema-probe.mjs +165 -0
  39. package/dist/cli-main-BfYf6fnB.mjs +1846 -0
  40. package/dist/client-D3D5RM5h.mjs +940 -0
  41. package/dist/client-VF2Nzc7Z.mjs +1 -0
  42. package/dist/cloudflare-auth-DzkU9H6r.mjs +152 -0
  43. package/dist/cloudflare-cmd-Bm6UhzAQ.mjs +59 -0
  44. package/dist/cloudflare-config-i8yanry0.mjs +186 -0
  45. package/dist/cloudflare-connect-B4ItSbJi.mjs +55 -0
  46. package/dist/cloudflare-operations-BcK849ue.mjs +1 -0
  47. package/dist/cloudflare-operations-DGF7xH7O.mjs +627 -0
  48. package/dist/cloudflare-process-tThIjEB2.mjs +309 -0
  49. package/dist/cloudflare-user-output-CqONaAbP.mjs +19 -0
  50. package/dist/collect-8i0wU63d.mjs +1 -0
  51. package/dist/collect-C6Blu9yw.mjs +48 -0
  52. package/dist/config-CN_RFRkS.mjs +86 -0
  53. package/dist/config-D5G-Tx6o.mjs +1 -0
  54. package/dist/config-DOaFIK3w.mjs +88 -0
  55. package/dist/config-entry.d.mts +202 -0
  56. package/dist/config-entry.mjs +6 -0
  57. package/dist/config-tNx0HlFv.mjs +516 -0
  58. package/dist/connect-CSNWKLzB.mjs +84 -0
  59. package/dist/create-project-B35ux-LA.mjs +126 -0
  60. package/dist/create-project-tJ1KwNss.mjs +1 -0
  61. package/dist/database-provider-DkZo4VwN.mjs +5 -0
  62. package/dist/database-provider.d.mts +25 -0
  63. package/dist/database-provider.mjs +1 -0
  64. package/dist/db-SOv4E9wr.mjs +1735 -0
  65. package/dist/delete-BSKI7V23.mjs +65 -0
  66. package/dist/deploy-BCSQoKC0.mjs +2 -0
  67. package/dist/deploy-CWJ3JJs_.mjs +6512 -0
  68. package/dist/deploy.d.mts +31 -0
  69. package/dist/deploy.mjs +118 -0
  70. package/dist/dev-inbox-I0nqTCdf.mjs +216 -0
  71. package/dist/discover-DJPmQcL5.mjs +36 -0
  72. package/dist/discover-EVuydEoM.mjs +1 -0
  73. package/dist/dist-B6eN80gc.mjs +1612 -0
  74. package/dist/dist-Cp4b1_T9.mjs +1 -0
  75. package/dist/dist-DMYe8CZJ.mjs +48 -0
  76. package/dist/dist-STQXl8ck.mjs +1878 -0
  77. package/dist/domain-BJaAbxuQ.mjs +149 -0
  78. package/dist/dotenv-4NdUCXbB.mjs +156 -0
  79. package/dist/drizzle-DqVFXtlc.mjs +306 -0
  80. package/dist/drizzle-Ds5P0n-S.mjs +1 -0
  81. package/dist/edge.d.mts +2 -0
  82. package/dist/edge.mjs +1 -0
  83. package/dist/email-C_ATvNIG.mjs +2865 -0
  84. package/dist/email-cloudflare-oXk2G1G3.mjs +854 -0
  85. package/dist/email-protocol-CZ0bAkI8.mjs +81 -0
  86. package/dist/email-rIfZgVAB.mjs +742 -0
  87. package/dist/env-BGTu3KWZ.mjs +73 -0
  88. package/dist/env-DUyTzroe.mjs +88 -0
  89. package/dist/env-Dl4Wggec.mjs +71 -0
  90. package/dist/env-helpers-BX0APszT.mjs +135 -0
  91. package/dist/env-helpers-U56xuFgL.d.mts +20 -0
  92. package/dist/env-mask-BsHxq3R8.mjs +46 -0
  93. package/dist/env-public-Cw_xPi1D.d.mts +119 -0
  94. package/dist/env-raw-Bo6TtrHU.mjs +41 -0
  95. package/dist/env-types-Bg-dTh8u.mjs +56 -0
  96. package/dist/env-validation-BlXzGgLZ.mjs +1 -0
  97. package/dist/env-validation-DeqFUSKg.mjs +488 -0
  98. package/dist/fetch-CBgyyhzm.d.mts +87 -0
  99. package/dist/fetch-error-DmlRM6e4.mjs +264 -0
  100. package/dist/fetch-stream-2GUN3YN1.mjs +102 -0
  101. package/dist/fetch-stream-bUXynOyZ.d.mts +32 -0
  102. package/dist/fetch-tpPiSK10.mjs +25 -0
  103. package/dist/gen-dc13IRXh.mjs +509 -0
  104. package/dist/gen-kQqhFyOP.mjs +1 -0
  105. package/dist/generate-BgtlYpKg.mjs +1 -0
  106. package/dist/generate-Da9mWKzU.mjs +80 -0
  107. package/dist/generated-wrangler-config-CoDaaFsA.mjs +17 -0
  108. package/dist/git-metadata-Cukp5kV5.mjs +82 -0
  109. package/dist/github-cmd-DT5Onu6E.mjs +690 -0
  110. package/dist/handler-B_ocHStk.d.mts +279 -0
  111. package/dist/handler-CNq7aSs1.mjs +161 -0
  112. package/dist/help-BK35YcRa.mjs +1946 -0
  113. package/dist/help-DaRezBj7.mjs +1 -0
  114. package/dist/inbound-CqubE-9T.d.mts +311 -0
  115. package/dist/inbound-lHugZPuK.mjs +509 -0
  116. package/dist/index.d.mts +64 -0
  117. package/dist/index.mjs +4163 -0
  118. package/dist/info-CLQoCenb.mjs +109 -0
  119. package/dist/init-CXanf5ck.mjs +2486 -0
  120. package/dist/limits-CMmYT2l8.d.mts +16 -0
  121. package/dist/limits-D27Lp6FP.mjs +46 -0
  122. package/dist/link-DinwJnon.mjs +52 -0
  123. package/dist/list-B1WAE9Wt.mjs +130 -0
  124. package/dist/live-KkEeda1Z.d.mts +105 -0
  125. package/dist/live-saC8barp.mjs +410 -0
  126. package/dist/load-user-env-g0ahkZcj.mjs +34 -0
  127. package/dist/local-d1-bUoAtFUe.mjs +103 -0
  128. package/dist/log-JDnPc0cF.mjs +23 -0
  129. package/dist/login-BUzyiyHV.mjs +1 -0
  130. package/dist/login-Dbv_T3Ru.mjs +87 -0
  131. package/dist/logs-BjMJooJQ.mjs +129 -0
  132. package/dist/migrate-DjW9_-sS.mjs +1 -0
  133. package/dist/migrate-DtcfKqPW.mjs +125 -0
  134. package/dist/migration-handler-22qiuWPq.mjs +469 -0
  135. package/dist/migration-handler-Bb2BJh6g.d.mts +38 -0
  136. package/dist/mime-BMUN_QKG.mjs +1004 -0
  137. package/dist/mysql-migration-sql-CNuBSqdx.mjs +239 -0
  138. package/dist/neon-CJzQSycr.mjs +52 -0
  139. package/dist/node-tfv-3v0V.mjs +64 -0
  140. package/dist/operator-ai-logging-Ay7M4KWw.mjs +121 -0
  141. package/dist/operator-args-BiGmSlZx.mjs +722 -0
  142. package/dist/operator-auth-DdYZYEkO.mjs +47 -0
  143. package/dist/operator-client-DBujdELO.mjs +82 -0
  144. package/dist/operator-cmd-BsHKYJYt.mjs +1 -0
  145. package/dist/operator-cmd-DTIkOAnP.mjs +443 -0
  146. package/dist/output-Bb34lF0w.mjs +173 -0
  147. package/dist/output-CVolXKC1.mjs +1 -0
  148. package/dist/package-BX_giUBX.mjs +1444 -0
  149. package/dist/package-json-DvS6IFRv.mjs +43 -0
  150. package/dist/pg-DoyPxa_X.mjs +15 -0
  151. package/dist/picocolors-D1NxSLw-.mjs +71 -0
  152. package/dist/plan-BHNt1QhK.mjs +1 -0
  153. package/dist/plan-DX4_-OM5.mjs +58 -0
  154. package/dist/platform-args-C-DyuCNX.mjs +1 -0
  155. package/dist/platform-args-CyeQWaZ7.mjs +538 -0
  156. package/dist/platform-auth-config-BfXqKSyZ.mjs +371 -0
  157. package/dist/platform-auth-protection-5FR6qoP_.mjs +231 -0
  158. package/dist/platform-auth-recovery-B5ZlqA8K.mjs +309 -0
  159. package/dist/platform-cmd-CcFDxtrl.mjs +1 -0
  160. package/dist/platform-cmd-ChXeBrRH.mjs +193 -0
  161. package/dist/platform-discovery-Bxg9aZXU.mjs +40 -0
  162. package/dist/platform-domain-CwatS3cz.mjs +256 -0
  163. package/dist/platform-lifecycle-0cXTmMsh.mjs +8928 -0
  164. package/dist/platform-lifecycle-BcoBAMux.mjs +1 -0
  165. package/dist/platform-management-6Wbdbob5.mjs +1607 -0
  166. package/dist/platform-management-hhnczOzr.mjs +1 -0
  167. package/dist/platform-plans-config-CkbUKFpm.mjs +447 -0
  168. package/dist/platform-recovery-DgIwlqB-.mjs +96 -0
  169. package/dist/platform-registry-x1m9HBxf.mjs +450 -0
  170. package/dist/platform-runtime-logs-kkoiYFpF.mjs +72 -0
  171. package/dist/platform-setup-DX8y_6Kh.mjs +306 -0
  172. package/dist/prepare-B9mB47T5.mjs +84 -0
  173. package/dist/prepare-DNIq07so.mjs +13 -0
  174. package/dist/prepare-LHkyJqxi.mjs +1 -0
  175. package/dist/project-CC7eN00D.mjs +141 -0
  176. package/dist/project-DcSd4BeI.mjs +1 -0
  177. package/dist/project-cmd-BydRwr-x.mjs +109 -0
  178. package/dist/project-paths-iXHKRTTQ.mjs +159 -0
  179. package/dist/project-slug-BUy0lmyR.mjs +1 -0
  180. package/dist/project-slug-CO6ci9XG.mjs +7 -0
  181. package/dist/project-team-CvdLhDF2.mjs +129 -0
  182. package/dist/project-token-CwZdUEGu.mjs +70 -0
  183. package/dist/project-tsconfig-P9X952KG.mjs +98 -0
  184. package/dist/project-zero-trust-CKDoPdN1.mjs +64 -0
  185. package/dist/providers-Cd3c7wi0.mjs +64 -0
  186. package/dist/providers-Df69hb_X.d.mts +5 -0
  187. package/dist/provision-BA59NCPO.mjs +1 -0
  188. package/dist/provision-C90fULHJ.mjs +1814 -0
  189. package/dist/queues-Bc3FsBQT.d.mts +5 -0
  190. package/dist/r2-conditions-DSLmkiR5.mjs +60 -0
  191. package/dist/requests-DNhfyF3l.mjs +52 -0
  192. package/dist/resolve-project-BCsAMDRA.mjs +47 -0
  193. package/dist/resolve-project-DhU9_lIo.mjs +1 -0
  194. package/dist/resource-name-DlJ9QXzg.mjs +10 -0
  195. package/dist/response-HmNjB30w.mjs +29 -0
  196. package/dist/rollback-wi6WK5T6.mjs +150 -0
  197. package/dist/rolldown-runtime-uD8oG6U2.mjs +24 -0
  198. package/dist/route-types-CRWhr93D.mjs +592 -0
  199. package/dist/route-url-BIDZT78M.mjs +58 -0
  200. package/dist/route-url-Bla3Upsy.d.mts +42 -0
  201. package/dist/routes-stub.d.mts +24 -0
  202. package/dist/routes-stub.mjs +1 -0
  203. package/dist/routing-assets-CSheDWWM.mjs +54 -0
  204. package/dist/rpc-DcByS_q0.d.mts +39 -0
  205. package/dist/rpc-DtxIN9Tv.mjs +19 -0
  206. package/dist/runner-CPerdjIl.mjs +163 -0
  207. package/dist/runner-CUNtS5x7.mjs +1 -0
  208. package/dist/runner-mysql-BjSoQ-mW.mjs +1 -0
  209. package/dist/runner-mysql-BmTI2EiF.mjs +145 -0
  210. package/dist/runner-pg-2pjltt0t.mjs +1 -0
  211. package/dist/runner-pg-mYc75KfH.mjs +61 -0
  212. package/dist/runtime/ai.d.mts +50 -0
  213. package/dist/runtime/ai.mjs +455 -0
  214. package/dist/runtime/auth-client-react.d.mts +2 -0
  215. package/dist/runtime/auth-client-react.mjs +1 -0
  216. package/dist/runtime/auth-client.d.mts +2 -0
  217. package/dist/runtime/auth-client.mjs +1 -0
  218. package/dist/runtime/auth.d.mts +2 -0
  219. package/dist/runtime/auth.mjs +1 -0
  220. package/dist/runtime/better-auth-mysql.d.mts +5 -0
  221. package/dist/runtime/better-auth-mysql.mjs +21 -0
  222. package/dist/runtime/better-auth-pg.d.mts +5 -0
  223. package/dist/runtime/better-auth-pg.mjs +21 -0
  224. package/dist/runtime/better-auth.d.mts +6 -0
  225. package/dist/runtime/better-auth.mjs +22 -0
  226. package/dist/runtime/client-react.d.mts +5 -0
  227. package/dist/runtime/client-react.mjs +5 -0
  228. package/dist/runtime/client.d.mts +5 -0
  229. package/dist/runtime/client.mjs +5 -0
  230. package/dist/runtime/db-mysql.d.mts +2 -0
  231. package/dist/runtime/db-mysql.mjs +1 -0
  232. package/dist/runtime/db-pg.d.mts +2 -0
  233. package/dist/runtime/db-pg.mjs +1 -0
  234. package/dist/runtime/db.d.mts +17 -0
  235. package/dist/runtime/db.mjs +36 -0
  236. package/dist/runtime/drizzle-arktype.d.mts +1 -0
  237. package/dist/runtime/drizzle-arktype.mjs +2 -0
  238. package/dist/runtime/drizzle-valibot.d.mts +1 -0
  239. package/dist/runtime/drizzle-valibot.mjs +2 -0
  240. package/dist/runtime/drizzle-zod.d.mts +1 -0
  241. package/dist/runtime/drizzle-zod.mjs +2 -0
  242. package/dist/runtime/durable.d.mts +64 -0
  243. package/dist/runtime/durable.mjs +165 -0
  244. package/dist/runtime/email/testing.d.mts +108 -0
  245. package/dist/runtime/email/testing.mjs +268 -0
  246. package/dist/runtime/email-protocol.d.mts +25 -0
  247. package/dist/runtime/email-protocol.mjs +1 -0
  248. package/dist/runtime/email.d.mts +26 -0
  249. package/dist/runtime/email.mjs +524 -0
  250. package/dist/runtime/env-public-client.d.mts +19 -0
  251. package/dist/runtime/env-public-client.mjs +55 -0
  252. package/dist/runtime/env-public.d.mts +4 -0
  253. package/dist/runtime/env-public.mjs +277 -0
  254. package/dist/runtime/env.d.mts +12 -0
  255. package/dist/runtime/env.mjs +1 -0
  256. package/dist/runtime/fetch-server.d.mts +6 -0
  257. package/dist/runtime/fetch-server.mjs +29 -0
  258. package/dist/runtime/fetch-stream.d.mts +3 -0
  259. package/dist/runtime/fetch-stream.mjs +3 -0
  260. package/dist/runtime/fetch.d.mts +2 -0
  261. package/dist/runtime/fetch.mjs +3 -0
  262. package/dist/runtime/handler.d.mts +3 -0
  263. package/dist/runtime/handler.mjs +1 -0
  264. package/dist/runtime/kv.d.mts +45 -0
  265. package/dist/runtime/kv.mjs +103 -0
  266. package/dist/runtime/limits.d.mts +2 -0
  267. package/dist/runtime/limits.mjs +1 -0
  268. package/dist/runtime/live-client.d.mts +40 -0
  269. package/dist/runtime/live-client.mjs +282 -0
  270. package/dist/runtime/live-server.d.mts +11 -0
  271. package/dist/runtime/live-server.mjs +419 -0
  272. package/dist/runtime/live.d.mts +3 -0
  273. package/dist/runtime/live.mjs +1 -0
  274. package/dist/runtime/log.d.mts +24 -0
  275. package/dist/runtime/log.mjs +57 -0
  276. package/dist/runtime/migration-handler-mysql.d.mts +2 -0
  277. package/dist/runtime/migration-handler-mysql.mjs +111 -0
  278. package/dist/runtime/migration-handler-pg.d.mts +2 -0
  279. package/dist/runtime/migration-handler-pg.mjs +94 -0
  280. package/dist/runtime/migration-handler.d.mts +2 -0
  281. package/dist/runtime/migration-handler.mjs +1 -0
  282. package/dist/runtime/procedure.d.mts +27 -0
  283. package/dist/runtime/procedure.mjs +36 -0
  284. package/dist/runtime/procedures.d.mts +24 -0
  285. package/dist/runtime/procedures.mjs +56 -0
  286. package/dist/runtime/queues.d.mts +2 -0
  287. package/dist/runtime/queues.mjs +8 -0
  288. package/dist/runtime/remote/binding-handler.d.mts +11 -0
  289. package/dist/runtime/remote/binding-handler.mjs +227 -0
  290. package/dist/runtime/remote/index.d.mts +12 -0
  291. package/dist/runtime/remote/index.mjs +467 -0
  292. package/dist/runtime/response.d.mts +11 -0
  293. package/dist/runtime/response.mjs +1 -0
  294. package/dist/runtime/route-url.d.mts +2 -0
  295. package/dist/runtime/route-url.mjs +1 -0
  296. package/dist/runtime/routing.d.mts +53 -0
  297. package/dist/runtime/routing.mjs +425 -0
  298. package/dist/runtime/rpc-react.d.mts +16 -0
  299. package/dist/runtime/rpc-react.mjs +50 -0
  300. package/dist/runtime/rpc.d.mts +2 -0
  301. package/dist/runtime/rpc.mjs +1 -0
  302. package/dist/runtime/sandbox-container.d.mts +3 -0
  303. package/dist/runtime/sandbox-container.mjs +1 -0
  304. package/dist/runtime/sandbox.d.mts +5 -0
  305. package/dist/runtime/sandbox.mjs +196 -0
  306. package/dist/runtime/schema-d1.d.mts +1 -0
  307. package/dist/runtime/schema-d1.mjs +2 -0
  308. package/dist/runtime/schema-mysql.d.mts +1 -0
  309. package/dist/runtime/schema-mysql.mjs +2 -0
  310. package/dist/runtime/schema-pg.d.mts +1 -0
  311. package/dist/runtime/schema-pg.mjs +2 -0
  312. package/dist/runtime/seed.d.mts +34 -0
  313. package/dist/runtime/seed.mjs +5 -0
  314. package/dist/runtime/sse-client.d.mts +31 -0
  315. package/dist/runtime/sse-client.mjs +42 -0
  316. package/dist/runtime/sse.d.mts +32 -0
  317. package/dist/runtime/sse.mjs +1 -0
  318. package/dist/runtime/storage.d.mts +4 -0
  319. package/dist/runtime/storage.mjs +13 -0
  320. package/dist/runtime/validator.d.mts +2 -0
  321. package/dist/runtime/validator.mjs +1 -0
  322. package/dist/runtime/ws-server.d.mts +26 -0
  323. package/dist/runtime/ws-server.mjs +297 -0
  324. package/dist/runtime/ws.d.mts +2 -0
  325. package/dist/runtime/ws.mjs +108 -0
  326. package/dist/sandbox-CWDjoEG2.d.mts +50 -0
  327. package/dist/sandbox-container-BqamdFCx.d.mts +73 -0
  328. package/dist/sandbox-container-d1AHLpgn.mjs +291 -0
  329. package/dist/secret-D5XrWshs.mjs +146 -0
  330. package/dist/skills-Dr3AjuBF.mjs +63 -0
  331. package/dist/sqlite-validation-CLJXXN93.mjs +24 -0
  332. package/dist/sse-CxR30yMF.mjs +174 -0
  333. package/dist/standard-schema-CuDawHOC.d.mts +40 -0
  334. package/dist/static-asset-marker-mWMX2dLa.mjs +38 -0
  335. package/dist/subcommand-prompt-B9yUo--u.mjs +370 -0
  336. package/dist/terminal-log-text-DNsWJREL.mjs +31 -0
  337. package/dist/types-D7-4tBu7.d.mts +1 -0
  338. package/dist/untrusted-env-lL7RkYiC.mjs +50 -0
  339. package/dist/validate-B-zsjhiz.mjs +162 -0
  340. package/dist/validate-DbqGdPPY.mjs +1 -0
  341. package/dist/validator-8-NZs2Xr.mjs +168 -0
  342. package/dist/version-metadata-DPhqnpaa.mjs +23 -0
  343. package/dist/wrangler-C3uyPadQ.mjs +1 -0
  344. package/dist/wrangler-TqTvJFWS.mjs +1452 -0
  345. package/dist/ws-DZRiIpYw.d.mts +137 -0
  346. package/dist/yarn-pnp-DgWbE7z5.mjs +91 -0
  347. package/docs/guide/ai.md +273 -0
  348. package/docs/guide/app-types.md +101 -0
  349. package/docs/guide/auth.md +255 -0
  350. package/docs/guide/database/d1.md +86 -0
  351. package/docs/guide/database/mysql.md +72 -0
  352. package/docs/guide/database/postgresql.md +94 -0
  353. package/docs/guide/database.md +454 -0
  354. package/docs/guide/deployment.md +124 -0
  355. package/docs/guide/durable-state.md +192 -0
  356. package/docs/guide/edge/headers.md +47 -0
  357. package/docs/guide/edge/redirects.md +85 -0
  358. package/docs/guide/edge/rewrites.md +119 -0
  359. package/docs/guide/edge/static-assets.md +94 -0
  360. package/docs/guide/email/domains.md +119 -0
  361. package/docs/guide/email/receiving.md +142 -0
  362. package/docs/guide/email/sending.md +262 -0
  363. package/docs/guide/email.md +23 -0
  364. package/docs/guide/env-vars.md +115 -0
  365. package/docs/guide/index.md +37 -0
  366. package/docs/guide/jobs.md +80 -0
  367. package/docs/guide/kv.md +100 -0
  368. package/docs/guide/live.md +181 -0
  369. package/docs/guide/platform/administration/access.md +165 -0
  370. package/docs/guide/platform/administration/connected-apps.md +84 -0
  371. package/docs/guide/platform/administration/email.md +169 -0
  372. package/docs/guide/platform/administration/operations.md +100 -0
  373. package/docs/guide/platform/administration/plans.md +156 -0
  374. package/docs/guide/platform/administration/projects.md +74 -0
  375. package/docs/guide/platform/administration/zero-trust.md +205 -0
  376. package/docs/guide/platform/development/local.md +122 -0
  377. package/docs/guide/platform/development/runtime.md +115 -0
  378. package/docs/guide/platform/development/schema-ci.md +44 -0
  379. package/docs/guide/platform/installation/ci.md +62 -0
  380. package/docs/guide/platform/installation/credentials.md +140 -0
  381. package/docs/guide/platform/installation/domains.md +120 -0
  382. package/docs/guide/platform/installation/first-deployment.md +95 -0
  383. package/docs/guide/platform/installation/maintenance.md +250 -0
  384. package/docs/guide/platform/installation/prerequisites.md +176 -0
  385. package/docs/guide/platform/installation/setup.md +300 -0
  386. package/docs/guide/platform/installation/uninstall.md +110 -0
  387. package/docs/guide/platform-administration.md +19 -0
  388. package/docs/guide/platform-development.md +16 -0
  389. package/docs/guide/procedures.md +48 -0
  390. package/docs/guide/project-collaboration.md +99 -0
  391. package/docs/guide/queues.md +149 -0
  392. package/docs/guide/quickstart.md +129 -0
  393. package/docs/guide/remote-dev.md +67 -0
  394. package/docs/guide/sandboxes.md +134 -0
  395. package/docs/guide/self-hosted-platform.md +45 -0
  396. package/docs/guide/server-routing.md +283 -0
  397. package/docs/guide/sse.md +174 -0
  398. package/docs/guide/storage.md +82 -0
  399. package/docs/guide/testing.md +64 -0
  400. package/docs/guide/type-safety.md +270 -0
  401. package/docs/guide/typed-fetch.md +98 -0
  402. package/docs/guide/websockets.md +230 -0
  403. package/docs/index.md +102 -0
  404. package/docs/integrations/agents.md +38 -0
  405. package/docs/integrations/cloudflare.md +241 -0
  406. package/docs/integrations/hono.md +127 -0
  407. package/docs/reference/api/auth.md +195 -0
  408. package/docs/reference/api/client.md +90 -0
  409. package/docs/reference/api/database.md +118 -0
  410. package/docs/reference/api/deploy.md +63 -0
  411. package/docs/reference/api/durable.md +47 -0
  412. package/docs/reference/api/env.md +51 -0
  413. package/docs/reference/api/handlers.md +189 -0
  414. package/docs/reference/api/plugin.md +40 -0
  415. package/docs/reference/api/resources.md +116 -0
  416. package/docs/reference/api/rewrites.md +111 -0
  417. package/docs/reference/api/types.md +126 -0
  418. package/docs/reference/api.md +71 -0
  419. package/docs/reference/cli/auth.md +87 -0
  420. package/docs/reference/cli/database.md +159 -0
  421. package/docs/reference/cli/deploy.md +117 -0
  422. package/docs/reference/cli/domains.md +42 -0
  423. package/docs/reference/cli/email.md +145 -0
  424. package/docs/reference/cli/generate.md +113 -0
  425. package/docs/reference/cli/github.md +181 -0
  426. package/docs/reference/cli/platform-config.md +93 -0
  427. package/docs/reference/cli/platform-email.md +81 -0
  428. package/docs/reference/cli/platform-installation.md +166 -0
  429. package/docs/reference/cli/platform-operations.md +90 -0
  430. package/docs/reference/cli/platform-users.md +159 -0
  431. package/docs/reference/cli/platform-zero-trust.md +60 -0
  432. package/docs/reference/cli/platform.md +78 -0
  433. package/docs/reference/cli/project.md +208 -0
  434. package/docs/reference/cli/secrets.md +79 -0
  435. package/docs/reference/cli/setup.md +88 -0
  436. package/docs/reference/cli.md +115 -0
  437. package/docs/reference/config.md +478 -0
  438. package/docs/reference/resource-inference.md +72 -0
  439. package/docs/reference/structure.md +138 -0
  440. package/package.json +389 -3
  441. package/sandbox.Dockerfile +4 -0
  442. package/schema.json +353 -0
  443. package/skills/bwf/SKILL.md +100 -0
  444. package/skills/migrate-vite-cloudflare-to-bwf/SKILL.md +53 -0
  445. package/templates/assets/bwf.svg +5 -0
  446. package/templates/assets/icons.svg +49 -0
  447. package/templates/assets/react.svg +1 -0
  448. package/templates/assets/stack.svg +35 -0
@@ -0,0 +1,94 @@
1
+ import { t as disablePgPassFallback } from "../pg-DoyPxa_X.mjs";
2
+ // src/runtime/migration-handler-pg.ts
3
+ function createMigrationHandler(env, migrations, runAuthMigrations) {
4
+ return async (request) => {
5
+ const token = request.headers.get("x-nosam-internal");
6
+ if (!token || token !== env.__NOSAM_PROXY_TOKEN) return Response.json({
7
+ ok: false,
8
+ error: "unauthorized",
9
+ migrations: []
10
+ }, { status: 401 });
11
+ try {
12
+ const result = await runPgMigrations(env, migrations);
13
+ if (result.ok && runAuthMigrations) try {
14
+ await runAuthMigrations();
15
+ } catch (err) {
16
+ return Response.json({
17
+ ...result,
18
+ ok: false,
19
+ error: err instanceof Error ? err.message : String(err)
20
+ }, { status: 500 });
21
+ }
22
+ return Response.json(result);
23
+ } catch (err) {
24
+ return Response.json({
25
+ ok: false,
26
+ error: err instanceof Error ? err.message : String(err),
27
+ migrations: []
28
+ }, { status: 500 });
29
+ }
30
+ };
31
+ }
32
+ async function runPgMigrations(env, migrations) {
33
+ const hyperdrive = env.HYPERDRIVE;
34
+ if (!hyperdrive?.connectionString) return {
35
+ ok: false,
36
+ error: "no HYPERDRIVE binding found",
37
+ migrations: []
38
+ };
39
+ const { Client } = await import("pg");
40
+ const client = new Client({ connectionString: hyperdrive.connectionString });
41
+ disablePgPassFallback(client);
42
+ await client.connect();
43
+ try {
44
+ await client.query(`CREATE TABLE IF NOT EXISTS _void_migrations (
45
+ name TEXT PRIMARY KEY,
46
+ applied_at TEXT NOT NULL
47
+ )`);
48
+ const { rows } = await client.query("SELECT name FROM _void_migrations");
49
+ const applied = new Set(rows.map((r) => r.name));
50
+ const migrationResults = [];
51
+ for (const m of migrations) {
52
+ if (applied.has(m.name)) {
53
+ migrationResults.push({
54
+ name: m.name,
55
+ applied: false,
56
+ durationMs: 0
57
+ });
58
+ continue;
59
+ }
60
+ const start = Date.now();
61
+ try {
62
+ await client.query("BEGIN");
63
+ await client.query(m.sql);
64
+ await client.query("INSERT INTO _void_migrations (name, applied_at) VALUES ($1, $2)", [m.name, (/* @__PURE__ */ new Date()).toISOString()]);
65
+ await client.query("COMMIT");
66
+ migrationResults.push({
67
+ name: m.name,
68
+ applied: true,
69
+ durationMs: Date.now() - start
70
+ });
71
+ } catch (err) {
72
+ await client.query("ROLLBACK");
73
+ migrationResults.push({
74
+ name: m.name,
75
+ applied: false,
76
+ durationMs: Date.now() - start,
77
+ error: err instanceof Error ? err.message : String(err)
78
+ });
79
+ return {
80
+ ok: false,
81
+ migrations: migrationResults,
82
+ error: `migration ${m.name} failed`
83
+ };
84
+ }
85
+ }
86
+ return {
87
+ ok: true,
88
+ migrations: migrationResults
89
+ };
90
+ } finally {
91
+ await client.end();
92
+ }
93
+ }
94
+ export { createMigrationHandler };
@@ -0,0 +1,2 @@
1
+ import { a as splitMigrationSql, i as createMigrationHandler, n as MigrationResponse, r as MigrationResult, t as MigrationEntry } from "../migration-handler-Bb2BJh6g.mjs";
2
+ export { MigrationEntry, MigrationResponse, MigrationResult, createMigrationHandler, splitMigrationSql };
@@ -0,0 +1 @@
1
+ export { t as createMigrationHandler, n as splitMigrationSql } from "../migration-handler-22qiuWPq.mjs";
@@ -0,0 +1,27 @@
1
+ import { i as AuthUser } from "../auth-BKsUmWbT.mjs";
2
+ import { r as CloudBindings } from "../handler-B_ocHStk.mjs";
3
+ import { AuthProvider, anyOf, bearerAuth, createProcedures } from "@builtbyfriends/realtime";
4
+ /**
5
+ * Builders for files in `procedures/`. `env` in handlers and providers is typed from
6
+ * bwf's generated bindings. Leave the name out: bwf names each procedure from its
7
+ * file and export (`procedures/contacts.ts` exporting `get` is `contacts.get`).
8
+ */
9
+ declare const builders: ReturnType<typeof createProcedures<CloudBindings>>;
10
+ export declare const procedure: (name?: string) => ReturnType<typeof builders.procedure<string>>;
11
+ export declare const profile: typeof builders.profile;
12
+ /**
13
+ * The signed-in Better Auth user. bwf's auth middleware runs before procedures, so this
14
+ * reads the session it already resolved. Null (a 401) when nobody is signed in.
15
+ */
16
+ export declare const session: AuthProvider<AuthUser, CloudBindings>;
17
+ /** Someone signed in. Today that is a session; API keys join it once bwf has them. */
18
+ export declare const signedIn: AuthProvider<AuthUser, CloudBindings>;
19
+ /**
20
+ * API tokens for the CLI, agents and scripts: `Authorization: Bearer <token>`. `lookup`
21
+ * gets the token's SHA-256 hex digest, never the token, and returns the caller or null.
22
+ * Combine with `session` using `anyOf('signed-in', session, apiTokens(...))`.
23
+ */
24
+ export declare function apiTokens<User extends {
25
+ id: string;
26
+ }>(lookup: (hash: string, env: CloudBindings) => Promise<User | null | undefined> | User | null | undefined): AuthProvider<User, CloudBindings>;
27
+ export { type AuthProvider, anyOf, bearerAuth };
@@ -0,0 +1,36 @@
1
+ import { a as getUser } from "../auth-DkvoW5hB.mjs";
2
+ import { anyOf, bearerAuth, createProcedures } from "@builtbyfriends/realtime";
3
+ // src/runtime/procedure.ts
4
+ /**
5
+ * Builders for files in `procedures/`. `env` in handlers and providers is typed from
6
+ * bwf's generated bindings. Leave the name out: bwf names each procedure from its
7
+ * file and export (`procedures/contacts.ts` exporting `get` is `contacts.get`).
8
+ */
9
+ const builders = createProcedures();
10
+ const procedure = (name) => builders.procedure(name);
11
+ const profile = builders.profile;
12
+ /**
13
+ * The signed-in Better Auth user. bwf's auth middleware runs before procedures, so this
14
+ * reads the session it already resolved. Null (a 401) when nobody is signed in.
15
+ */
16
+ const session = {
17
+ name: "session",
18
+ resolve: () => getUser(),
19
+ actorId: (user) => user.id
20
+ };
21
+ /** Someone signed in. Today that is a session; API keys join it once bwf has them. */
22
+ const signedIn = session;
23
+ const sha256 = async (text) => [...new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text)))].map((b) => b.toString(16).padStart(2, "0")).join("");
24
+ /**
25
+ * API tokens for the CLI, agents and scripts: `Authorization: Bearer <token>`. `lookup`
26
+ * gets the token's SHA-256 hex digest, never the token, and returns the caller or null.
27
+ * Combine with `session` using `anyOf('signed-in', session, apiTokens(...))`.
28
+ */
29
+ function apiTokens(lookup) {
30
+ return bearerAuth({
31
+ name: "api-token",
32
+ verify: async (token, env) => lookup(await sha256(token), env),
33
+ actorId: (user) => user.id
34
+ });
35
+ }
36
+ export { anyOf, apiTokens, bearerAuth, procedure, profile, session, signedIn };
@@ -0,0 +1,24 @@
1
+ import { AnyProcedure, Registry } from "@builtbyfriends/realtime";
2
+ import { Hono } from "hono";
3
+ /** The Analytics Engine binding bwf adds when an app has procedures. */
4
+ export declare const ANALYTICS_BINDING = "ANALYTICS";
5
+ export declare const RPC_BASE_PATH = "/rpc";
6
+ export declare const MCP_PATH = "/mcp";
7
+ type ProcedureModule = readonly [prefix: string, exports: Record<string, unknown>];
8
+ /**
9
+ * Every procedure a module exports, named from its file unless it named itself.
10
+ * Unfinished builders are kept so the registry reports them instead of losing them.
11
+ */
12
+ export declare function collectProcedures(modules: ReadonlyArray<ProcedureModule>): Array<AnyProcedure>;
13
+ /**
14
+ * Builds the registry and serves it at /rpc. Called at the top of the generated route
15
+ * table, so a registry problem stops the Worker from starting and the deploy fails.
16
+ * In dev, events go to the console, so a remote-mode session never writes to the
17
+ * deployed project's Analytics Engine dataset.
18
+ */
19
+ export declare function mountProcedures(app: Pick<Hono, "all">, modules: ReadonlyArray<ProcedureModule>, options: {
20
+ dev: boolean;
21
+ name: string;
22
+ version: string;
23
+ }): Registry;
24
+ export {};
@@ -0,0 +1,56 @@
1
+ import { defineRegistry, withProcedureName } from "@builtbyfriends/realtime";
2
+ import { analyticsEngine } from "@builtbyfriends/realtime-analytics";
3
+ import { rpcHandler } from "@builtbyfriends/realtime-http";
4
+ // src/runtime/procedures.ts
5
+ /** The Analytics Engine binding bwf adds when an app has procedures. */
6
+ const ANALYTICS_BINDING = "ANALYTICS";
7
+ const RPC_BASE_PATH = "/rpc";
8
+ const MCP_PATH = "/mcp";
9
+ /**
10
+ * Every procedure a module exports, named from its file unless it named itself.
11
+ * Unfinished builders are kept so the registry reports them instead of losing them.
12
+ */
13
+ function collectProcedures(modules) {
14
+ const found = [];
15
+ for (const [prefix, exports] of modules) for (const [exportName, value] of Object.entries(exports)) {
16
+ const kind = value?.["~realtime"];
17
+ if (kind !== "procedure" && kind !== "builder") continue;
18
+ const name = [prefix, exportName === "default" ? "" : exportName].filter(Boolean).join(".");
19
+ found.push(withProcedureName(value, name));
20
+ }
21
+ return found;
22
+ }
23
+ const consoleAnalytics = {
24
+ name: "console",
25
+ track: (event) => console.log("[analytics]", JSON.stringify(event))
26
+ };
27
+ /**
28
+ * Builds the registry and serves it at /rpc. Called at the top of the generated route
29
+ * table, so a registry problem stops the Worker from starting and the deploy fails.
30
+ * In dev, events go to the console, so a remote-mode session never writes to the
31
+ * deployed project's Analytics Engine dataset.
32
+ */
33
+ function mountProcedures(app, modules, options) {
34
+ const registry = defineRegistry(collectProcedures(modules), { analytics: options.dev ? consoleAnalytics : analyticsEngine({ binding: ANALYTICS_BINDING }) });
35
+ const rpc = rpcHandler(registry, {
36
+ basePath: RPC_BASE_PATH,
37
+ openapi: {
38
+ title: options.name,
39
+ version: options.version
40
+ }
41
+ });
42
+ const handle = (c) => rpc(c.req.raw, c.env, { waitUntil: (p) => c.executionCtx.waitUntil(p) });
43
+ app.all(RPC_BASE_PATH, handle);
44
+ app.all(`${RPC_BASE_PATH}/*`, handle);
45
+ const mcp = (async () => {
46
+ const { mcpHandler } = await import("@builtbyfriends/realtime-mcp");
47
+ return mcpHandler(registry, {
48
+ name: options.name,
49
+ version: options.version,
50
+ route: MCP_PATH
51
+ });
52
+ })();
53
+ app.all(MCP_PATH, async (c) => (await mcp)(c.req.raw, c.env, { waitUntil: (p) => c.executionCtx.waitUntil(p) }));
54
+ return registry;
55
+ }
56
+ export { ANALYTICS_BINDING, MCP_PATH, RPC_BASE_PATH, collectProcedures, mountProcedures };
@@ -0,0 +1,2 @@
1
+ import { n as queues, t as QueueMap } from "../queues-Bc3FsBQT.mjs";
2
+ export { QueueMap, queues };
@@ -0,0 +1,8 @@
1
+ import { a as requireRuntimeBinding } from "../env-Dl4Wggec.mjs";
2
+ // src/runtime/queues.ts
3
+ /** Typed queue producers — resolves `QUEUE_*` bindings from the active runtime environment. */
4
+ const queues = new Proxy({}, { get(_, name) {
5
+ const bindingName = `QUEUE_${name.toUpperCase().replace(/[^A-Z0-9]/g, "_")}`;
6
+ return requireRuntimeBinding(bindingName);
7
+ } });
8
+ export { queues };
@@ -0,0 +1,11 @@
1
+ import { Hono } from "hono";
2
+ /**
3
+ * Creates a Hono app that handles `/__nosam/*` routes for native binding access.
4
+ * Deployed user workers expose this so the proxy can dispatch D1/KV/R2 operations
5
+ * via Workers for Platforms instead of the Cloudflare REST API (~1-5ms vs ~50-200ms).
6
+ *
7
+ * Authenticated via `x-nosam-internal` header against `env.__NOSAM_PROXY_TOKEN`.
8
+ * Response formats match the proxy's REST API responses, so ProxyClient
9
+ * handles both paths.
10
+ */
11
+ export declare function createBindingHandler(env: Record<string, unknown>): Hono;
@@ -0,0 +1,227 @@
1
+ import { t as base64ToBytes } from "../../base64-ikl9yBy3.mjs";
2
+ import { n as parseR2Conditional, r as parseR2HttpMetadata, t as R2_OBJECT_HEADER } from "../../r2-conditions-DSLmkiR5.mjs";
3
+ import { Hono } from "hono";
4
+ // src/runtime/remote/binding-handler.ts
5
+ /** Parse the body, answer 400 when `invalid` names a problem, and 404 for an unknown binding. */
6
+ async function readBindingRequest(c, env, invalid) {
7
+ const body = await c.req.json();
8
+ const error = invalid(body);
9
+ if (error) return c.json({ error }, 400);
10
+ const binding = env[body.binding];
11
+ if (!binding) return c.json({ error: `unknown binding "${body.binding}"` }, 404);
12
+ return {
13
+ body,
14
+ binding
15
+ };
16
+ }
17
+ function requireBinding(body) {
18
+ return body.binding ? void 0 : "binding required";
19
+ }
20
+ function requireKey(body) {
21
+ return body.binding && body.key ? void 0 : "binding and key required";
22
+ }
23
+ /** Object fields that ProxyR2Bucket reads. `contentType` serves older clients. */
24
+ function r2ObjectJson(obj) {
25
+ return {
26
+ key: obj.key,
27
+ size: obj.size,
28
+ etag: obj.etag,
29
+ version: obj.version,
30
+ lastModified: obj.uploaded.toISOString(),
31
+ contentType: obj.httpMetadata?.contentType ?? "application/octet-stream",
32
+ httpMetadata: obj.httpMetadata,
33
+ customMetadata: obj.customMetadata
34
+ };
35
+ }
36
+ function r2DeleteKeys(body) {
37
+ return body.keys ? body.keys : body.key ? [body.key] : [];
38
+ }
39
+ /**
40
+ * Creates a Hono app that handles `/__nosam/*` routes for native binding access.
41
+ * Deployed user workers expose this so the proxy can dispatch D1/KV/R2 operations
42
+ * via Workers for Platforms instead of the Cloudflare REST API (~1-5ms vs ~50-200ms).
43
+ *
44
+ * Authenticated via `x-nosam-internal` header against `env.__NOSAM_PROXY_TOKEN`.
45
+ * Response formats match the proxy's REST API responses, so ProxyClient
46
+ * handles both paths.
47
+ */
48
+ function createBindingHandler(env) {
49
+ const app = new Hono();
50
+ app.use("*", async (c, next) => {
51
+ const token = c.req.header("x-nosam-internal");
52
+ const expected = env.__NOSAM_PROXY_TOKEN;
53
+ if (!token || !expected || token !== expected) return c.json({ error: "unauthorized" }, 403);
54
+ await next();
55
+ });
56
+ app.post("/d1/query", async (c) => {
57
+ const request = await readBindingRequest(c, env, (body) => body.binding && body.sql ? void 0 : "binding and sql required");
58
+ if (request instanceof Response) return request;
59
+ const { body, binding: db } = request;
60
+ const stmt = db.prepare(body.sql).bind(...body.params ?? []);
61
+ switch (body.method) {
62
+ case "first": {
63
+ const row = await stmt.first();
64
+ return c.json(row);
65
+ }
66
+ case "raw": {
67
+ const raw = await stmt.raw({ columnNames: true });
68
+ const columns = raw.length > 0 ? raw[0] : [];
69
+ const results = raw.slice(1);
70
+ return c.json({
71
+ columns,
72
+ results,
73
+ meta: {}
74
+ });
75
+ }
76
+ case "run": {
77
+ const result = await stmt.run();
78
+ return c.json({
79
+ success: true,
80
+ meta: result.meta
81
+ });
82
+ }
83
+ default: {
84
+ const result = await stmt.all();
85
+ return c.json({
86
+ results: result.results,
87
+ success: true,
88
+ meta: result.meta
89
+ });
90
+ }
91
+ }
92
+ });
93
+ app.post("/d1/batch", async (c) => {
94
+ const request = await readBindingRequest(c, env, (body) => body.binding && Array.isArray(body.statements) ? void 0 : "binding and statements required");
95
+ if (request instanceof Response) return request;
96
+ const { body, binding: db } = request;
97
+ const stmts = body.statements.map((s) => db.prepare(s.sql).bind(...s.params ?? []));
98
+ const results = await db.batch(stmts);
99
+ return c.json(results.map((r) => ({
100
+ results: r.results,
101
+ success: true,
102
+ meta: r.meta
103
+ })));
104
+ });
105
+ app.post("/kv/get", async (c) => {
106
+ const request = await readBindingRequest(c, env, requireKey);
107
+ if (request instanceof Response) return request;
108
+ const { body, binding: kv } = request;
109
+ const type = body.type ?? "text";
110
+ if (type === "json") {
111
+ const val = await kv.get(body.key, "json");
112
+ return c.json(val);
113
+ }
114
+ if (type === "arrayBuffer") {
115
+ const val = await kv.get(body.key, "arrayBuffer");
116
+ if (val === null) return c.json(null);
117
+ return new Response(val, { headers: { "content-type": "application/octet-stream" } });
118
+ }
119
+ if (type === "stream") {
120
+ const val = await kv.get(body.key, "stream");
121
+ if (val === null) return c.json(null);
122
+ return new Response(val, { headers: { "content-type": "application/octet-stream" } });
123
+ }
124
+ return c.json(await kv.get(body.key, "text"));
125
+ });
126
+ app.post("/kv/put", async (c) => {
127
+ const request = await readBindingRequest(c, env, requireKey);
128
+ if (request instanceof Response) return request;
129
+ const { body, binding: kv } = request;
130
+ const opts = {};
131
+ if (body.expiration) opts.expiration = body.expiration;
132
+ if (body.expiration_ttl) opts.expirationTtl = body.expiration_ttl;
133
+ let value;
134
+ if (body.base64 && typeof body.value === "string") value = base64ToBytes(body.value).buffer;
135
+ else value = typeof body.value === "string" ? body.value : JSON.stringify(body.value);
136
+ await kv.put(body.key, value, opts);
137
+ return c.json({ success: true });
138
+ });
139
+ app.post("/kv/delete", async (c) => {
140
+ const request = await readBindingRequest(c, env, requireKey);
141
+ if (request instanceof Response) return request;
142
+ await request.binding.delete(request.body.key);
143
+ return c.json({ success: true });
144
+ });
145
+ app.post("/kv/list", async (c) => {
146
+ const request = await readBindingRequest(c, env, requireBinding);
147
+ if (request instanceof Response) return request;
148
+ const { body, binding: kv } = request;
149
+ const opts = {};
150
+ if (body.prefix) opts.prefix = body.prefix;
151
+ if (body.limit) opts.limit = body.limit;
152
+ if (body.cursor) opts.cursor = body.cursor;
153
+ const result = await kv.list(opts);
154
+ return c.json({
155
+ keys: result.keys,
156
+ list_complete: result.list_complete,
157
+ cursor: result.list_complete ? null : result.cursor
158
+ });
159
+ });
160
+ app.post("/r2/get", async (c) => {
161
+ const request = await readBindingRequest(c, env, requireKey);
162
+ if (request instanceof Response) return request;
163
+ const obj = await request.binding.get(request.body.key);
164
+ if (!obj) return c.json(null);
165
+ const headers = new Headers();
166
+ headers.set("content-type", obj.httpMetadata?.contentType ?? "application/octet-stream");
167
+ headers.set("content-length", String(obj.size));
168
+ if (obj.httpEtag) headers.set("etag", obj.httpEtag);
169
+ headers.set(R2_OBJECT_HEADER, encodeURIComponent(JSON.stringify(r2ObjectJson(obj))));
170
+ return new Response(obj.body, { headers });
171
+ });
172
+ app.on("POST", ["/r2/put", "/r2/put-conditional"], async (c) => {
173
+ const request = await readBindingRequest(c, env, requireKey);
174
+ if (request instanceof Response) return request;
175
+ const { body, binding: bucket } = request;
176
+ const data = body.base64 ? base64ToBytes(body.base64) : new TextEncoder().encode(body.value ?? "");
177
+ let httpMetadata;
178
+ let onlyIf;
179
+ try {
180
+ httpMetadata = body.httpMetadata === void 0 ? { contentType: body.contentType ?? "application/octet-stream" } : parseR2HttpMetadata(body.httpMetadata);
181
+ if (body.onlyIf !== void 0 || c.req.path.endsWith("/put-conditional")) onlyIf = parseR2Conditional(body.onlyIf);
182
+ } catch (error) {
183
+ return c.json({ error: String(error) }, 400);
184
+ }
185
+ const obj = await bucket.put(body.key, data, {
186
+ httpMetadata,
187
+ customMetadata: body.customMetadata,
188
+ onlyIf
189
+ });
190
+ if (!obj) return c.json(null);
191
+ return c.json(r2ObjectJson(obj));
192
+ });
193
+ app.post("/r2/delete", async (c) => {
194
+ const request = await readBindingRequest(c, env, (body) => requireBinding(body) ?? (r2DeleteKeys(body).length === 0 ? "key or keys required" : void 0));
195
+ if (request instanceof Response) return request;
196
+ await request.binding.delete(r2DeleteKeys(request.body));
197
+ return c.json({ success: true });
198
+ });
199
+ app.post("/r2/list", async (c) => {
200
+ const request = await readBindingRequest(c, env, requireBinding);
201
+ if (request instanceof Response) return request;
202
+ const { body, binding: bucket } = request;
203
+ const opts = {};
204
+ if (body.prefix) opts.prefix = body.prefix;
205
+ if (body.limit) opts.limit = body.limit;
206
+ if (body.cursor) opts.cursor = body.cursor;
207
+ if (body.delimiter) opts.delimiter = body.delimiter;
208
+ if (body.startAfter) opts.startAfter = body.startAfter;
209
+ if (Array.isArray(body.include)) opts.include = body.include;
210
+ const result = await bucket.list(opts);
211
+ return c.json({
212
+ objects: result.objects.map(r2ObjectJson),
213
+ truncated: result.truncated,
214
+ cursor: result.truncated ? result.cursor : null,
215
+ delimitedPrefixes: result.delimitedPrefixes
216
+ });
217
+ });
218
+ app.post("/r2/head", async (c) => {
219
+ const request = await readBindingRequest(c, env, requireKey);
220
+ if (request instanceof Response) return request;
221
+ const obj = await request.binding.head(request.body.key);
222
+ if (!obj) return c.json(null);
223
+ return c.json(r2ObjectJson(obj));
224
+ });
225
+ return app;
226
+ }
227
+ export { createBindingHandler };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Replace local D1/KV/R2 bindings with proxy-backed versions.
3
+ * Called from the generated worker entry point when `__NOSAM_REMOTE` is set.
4
+ *
5
+ * @deprecated Internal to bwf. The generated worker calls this in remote mode.
6
+ * `@builtbyfriends/bwf/remote` is not a supported import. Removed in the next major version.
7
+ */
8
+ export declare function createRemoteEnv(env: Record<string, unknown>, bindingNames?: {
9
+ d1?: string;
10
+ kv?: string;
11
+ r2?: string;
12
+ }): Record<string, unknown>;