alepha 0.21.1 → 0.22.0

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 (481) hide show
  1. package/README.md +0 -1
  2. package/dist/api/audits/index.browser.js.map +1 -1
  3. package/dist/api/audits/index.d.ts +393 -403
  4. package/dist/api/audits/index.d.ts.map +1 -1
  5. package/dist/api/audits/index.js +25 -56
  6. package/dist/api/audits/index.js.map +1 -1
  7. package/dist/api/files/index.browser.js +31 -1
  8. package/dist/api/files/index.browser.js.map +1 -1
  9. package/dist/api/files/index.d.ts +353 -207
  10. package/dist/api/files/index.d.ts.map +1 -1
  11. package/dist/api/files/index.js +211 -45
  12. package/dist/api/files/index.js.map +1 -1
  13. package/dist/api/jobs/index.browser.js +2 -2
  14. package/dist/api/jobs/index.browser.js.map +1 -1
  15. package/dist/api/jobs/index.d.ts +289 -292
  16. package/dist/api/jobs/index.d.ts.map +1 -1
  17. package/dist/api/jobs/index.js +39 -33
  18. package/dist/api/jobs/index.js.map +1 -1
  19. package/dist/api/keys/index.d.ts +211 -216
  20. package/dist/api/keys/index.d.ts.map +1 -1
  21. package/dist/api/keys/index.js.map +1 -1
  22. package/dist/api/notifications/index.browser.js.map +1 -1
  23. package/dist/api/notifications/index.d.ts +188 -195
  24. package/dist/api/notifications/index.d.ts.map +1 -1
  25. package/dist/api/notifications/index.js.map +1 -1
  26. package/dist/api/oauth/index.d.ts +71 -76
  27. package/dist/api/oauth/index.d.ts.map +1 -1
  28. package/dist/api/oauth/index.js.map +1 -1
  29. package/dist/api/organizations/index.browser.js.map +1 -1
  30. package/dist/api/organizations/index.d.ts +104 -109
  31. package/dist/api/organizations/index.d.ts.map +1 -1
  32. package/dist/api/organizations/index.js.map +1 -1
  33. package/dist/api/parameters/index.browser.js +43 -16
  34. package/dist/api/parameters/index.browser.js.map +1 -1
  35. package/dist/api/parameters/index.d.ts +488 -344
  36. package/dist/api/parameters/index.d.ts.map +1 -1
  37. package/dist/api/parameters/index.js +175 -35
  38. package/dist/api/parameters/index.js.map +1 -1
  39. package/dist/api/payments/index.d.ts +396 -402
  40. package/dist/api/payments/index.d.ts.map +1 -1
  41. package/dist/api/payments/index.js.map +1 -1
  42. package/dist/api/subscriptions/index.d.ts +644 -652
  43. package/dist/api/subscriptions/index.d.ts.map +1 -1
  44. package/dist/api/subscriptions/index.js +1 -1
  45. package/dist/api/subscriptions/index.js.map +1 -1
  46. package/dist/api/users/index.browser.js +7 -0
  47. package/dist/api/users/index.browser.js.map +1 -1
  48. package/dist/api/users/index.d.ts +1072 -1005
  49. package/dist/api/users/index.d.ts.map +1 -1
  50. package/dist/api/users/index.js +311 -87
  51. package/dist/api/users/index.js.map +1 -1
  52. package/dist/api/verifications/index.browser.js +1 -0
  53. package/dist/api/verifications/index.browser.js.map +1 -1
  54. package/dist/api/verifications/index.d.ts +144 -133
  55. package/dist/api/verifications/index.d.ts.map +1 -1
  56. package/dist/api/verifications/index.js +5 -1
  57. package/dist/api/verifications/index.js.map +1 -1
  58. package/dist/background/index.d.ts +95 -0
  59. package/dist/background/index.d.ts.map +1 -0
  60. package/dist/background/index.js +121 -0
  61. package/dist/background/index.js.map +1 -0
  62. package/dist/background/index.workerd.js +110 -0
  63. package/dist/background/index.workerd.js.map +1 -0
  64. package/dist/batch/index.d.ts +5 -7
  65. package/dist/batch/index.d.ts.map +1 -1
  66. package/dist/batch/index.js.map +1 -1
  67. package/dist/bin/index.js.map +1 -1
  68. package/dist/bucket/index.d.ts +76 -54
  69. package/dist/bucket/index.d.ts.map +1 -1
  70. package/dist/bucket/index.js +58 -11
  71. package/dist/bucket/index.js.map +1 -1
  72. package/dist/bucket/index.workerd.js +200 -5
  73. package/dist/bucket/index.workerd.js.map +1 -1
  74. package/dist/cache/core/index.d.ts +7 -10
  75. package/dist/cache/core/index.d.ts.map +1 -1
  76. package/dist/cache/core/index.js.map +1 -1
  77. package/dist/cache/core/index.workerd.js.map +1 -1
  78. package/dist/cache/database/index.d.ts +22 -26
  79. package/dist/cache/database/index.d.ts.map +1 -1
  80. package/dist/cache/database/index.js.map +1 -1
  81. package/dist/cache/redis/index.d.ts +4 -7
  82. package/dist/cache/redis/index.d.ts.map +1 -1
  83. package/dist/cache/redis/index.js.map +1 -1
  84. package/dist/captcha/index.d.ts +3 -6
  85. package/dist/captcha/index.d.ts.map +1 -1
  86. package/dist/captcha/index.js.map +1 -1
  87. package/dist/cli/config/index.d.ts.map +1 -1
  88. package/dist/cli/config/index.js.map +1 -1
  89. package/dist/cli/core/index.d.ts +460 -188
  90. package/dist/cli/core/index.d.ts.map +1 -1
  91. package/dist/cli/core/index.js +411 -551
  92. package/dist/cli/core/index.js.map +1 -1
  93. package/dist/cli/devtools/index.d.ts +3 -5
  94. package/dist/cli/devtools/index.d.ts.map +1 -1
  95. package/dist/cli/devtools/index.js.map +1 -1
  96. package/dist/cli/i18n/index.d.ts +8 -12
  97. package/dist/cli/i18n/index.d.ts.map +1 -1
  98. package/dist/cli/i18n/index.js.map +1 -1
  99. package/dist/cli/platform/index.d.ts +127 -1382
  100. package/dist/cli/platform/index.d.ts.map +1 -1
  101. package/dist/cli/platform/index.js +188 -2493
  102. package/dist/cli/platform/index.js.map +1 -1
  103. package/dist/cli/platform-lib/index.d.ts +1446 -0
  104. package/dist/cli/platform-lib/index.d.ts.map +1 -0
  105. package/dist/cli/platform-lib/index.js +2597 -0
  106. package/dist/cli/platform-lib/index.js.map +1 -0
  107. package/dist/cli/vendor/index.d.ts +17 -21
  108. package/dist/cli/vendor/index.d.ts.map +1 -1
  109. package/dist/cli/vendor/index.js.map +1 -1
  110. package/dist/command/index.d.ts +21 -20
  111. package/dist/command/index.d.ts.map +1 -1
  112. package/dist/command/index.js +39 -10
  113. package/dist/command/index.js.map +1 -1
  114. package/dist/container/core/index.d.ts +236 -0
  115. package/dist/container/core/index.d.ts.map +1 -0
  116. package/dist/container/core/index.js +231 -0
  117. package/dist/container/core/index.js.map +1 -0
  118. package/dist/container/core/index.workerd.js +192 -0
  119. package/dist/container/core/index.workerd.js.map +1 -0
  120. package/dist/core/index.browser.js +27 -1
  121. package/dist/core/index.browser.js.map +1 -1
  122. package/dist/core/index.d.ts +48 -24
  123. package/dist/core/index.d.ts.map +1 -1
  124. package/dist/core/index.js +27 -1
  125. package/dist/core/index.js.map +1 -1
  126. package/dist/core/index.native.js +27 -1
  127. package/dist/core/index.native.js.map +1 -1
  128. package/dist/core/index.workerd.js +27 -1
  129. package/dist/core/index.workerd.js.map +1 -1
  130. package/dist/crypto/index.browser.js.map +1 -1
  131. package/dist/crypto/index.d.ts +5 -8
  132. package/dist/crypto/index.d.ts.map +1 -1
  133. package/dist/crypto/index.js.map +1 -1
  134. package/dist/datetime/index.d.ts +3 -4
  135. package/dist/datetime/index.d.ts.map +1 -1
  136. package/dist/datetime/index.js.map +1 -1
  137. package/dist/email/brevo/index.d.ts +2 -4
  138. package/dist/email/brevo/index.d.ts.map +1 -1
  139. package/dist/email/brevo/index.js.map +1 -1
  140. package/dist/email/cloudflare/index.d.ts +103 -0
  141. package/dist/email/cloudflare/index.d.ts.map +1 -0
  142. package/dist/email/cloudflare/index.js +153 -0
  143. package/dist/email/cloudflare/index.js.map +1 -0
  144. package/dist/email/core/index.d.ts +6 -9
  145. package/dist/email/core/index.d.ts.map +1 -1
  146. package/dist/email/core/index.js.map +1 -1
  147. package/dist/email/core/index.workerd.js.map +1 -1
  148. package/dist/email/smtp/index.d.ts +10 -13
  149. package/dist/email/smtp/index.d.ts.map +1 -1
  150. package/dist/email/smtp/index.js +107 -32
  151. package/dist/email/smtp/index.js.map +1 -1
  152. package/dist/fake/index.d.ts +1 -2
  153. package/dist/fake/index.d.ts.map +1 -1
  154. package/dist/fake/index.js.map +1 -1
  155. package/dist/lock/core/index.d.ts +9 -14
  156. package/dist/lock/core/index.d.ts.map +1 -1
  157. package/dist/lock/core/index.js.map +1 -1
  158. package/dist/lock/redis/index.d.ts +2 -4
  159. package/dist/lock/redis/index.d.ts.map +1 -1
  160. package/dist/lock/redis/index.js.map +1 -1
  161. package/dist/logger/index.d.ts +105 -76
  162. package/dist/logger/index.d.ts.map +1 -1
  163. package/dist/logger/index.js +196 -174
  164. package/dist/logger/index.js.map +1 -1
  165. package/dist/mcp/index.d.ts +16 -20
  166. package/dist/mcp/index.d.ts.map +1 -1
  167. package/dist/mcp/index.js.map +1 -1
  168. package/dist/orm/core/index.browser.js.map +1 -1
  169. package/dist/orm/core/index.bun.js +21 -3
  170. package/dist/orm/core/index.bun.js.map +1 -1
  171. package/dist/orm/core/index.d.ts +76 -62
  172. package/dist/orm/core/index.d.ts.map +1 -1
  173. package/dist/orm/core/index.js +22 -4
  174. package/dist/orm/core/index.js.map +1 -1
  175. package/dist/orm/postgres/index.bun.js.map +1 -1
  176. package/dist/orm/postgres/index.d.ts +28 -20
  177. package/dist/orm/postgres/index.d.ts.map +1 -1
  178. package/dist/orm/postgres/index.js.map +1 -1
  179. package/dist/queue/core/index.d.ts +12 -15
  180. package/dist/queue/core/index.d.ts.map +1 -1
  181. package/dist/queue/core/index.js.map +1 -1
  182. package/dist/queue/core/index.workerd.js.map +1 -1
  183. package/dist/queue/redis/index.d.ts +3 -5
  184. package/dist/queue/redis/index.d.ts.map +1 -1
  185. package/dist/queue/redis/index.js.map +1 -1
  186. package/dist/react/auth/index.browser.js +9 -2
  187. package/dist/react/auth/index.browser.js.map +1 -1
  188. package/dist/react/auth/index.d.ts +14 -9
  189. package/dist/react/auth/index.d.ts.map +1 -1
  190. package/dist/react/auth/index.js +9 -2
  191. package/dist/react/auth/index.js.map +1 -1
  192. package/dist/react/core/index.d.ts +7 -8
  193. package/dist/react/core/index.d.ts.map +1 -1
  194. package/dist/react/core/index.js +6 -3
  195. package/dist/react/core/index.js.map +1 -1
  196. package/dist/react/form/index.d.ts +38 -5
  197. package/dist/react/form/index.d.ts.map +1 -1
  198. package/dist/react/form/index.js +91 -3
  199. package/dist/react/form/index.js.map +1 -1
  200. package/dist/react/head/index.browser.js.map +1 -1
  201. package/dist/react/head/index.d.ts +2 -4
  202. package/dist/react/head/index.d.ts.map +1 -1
  203. package/dist/react/head/index.js.map +1 -1
  204. package/dist/react/i18n/index.d.ts +47 -11
  205. package/dist/react/i18n/index.d.ts.map +1 -1
  206. package/dist/react/i18n/index.js +33 -1
  207. package/dist/react/i18n/index.js.map +1 -1
  208. package/dist/react/intro/index.d.ts +1 -2
  209. package/dist/react/intro/index.d.ts.map +1 -1
  210. package/dist/react/intro/index.js +2 -2
  211. package/dist/react/intro/index.js.map +1 -1
  212. package/dist/react/router/index.browser.js +66 -20
  213. package/dist/react/router/index.browser.js.map +1 -1
  214. package/dist/react/router/index.d.ts +327 -222
  215. package/dist/react/router/index.d.ts.map +1 -1
  216. package/dist/react/router/index.js +66 -30
  217. package/dist/react/router/index.js.map +1 -1
  218. package/dist/react/testing/index.d.ts +1 -2
  219. package/dist/react/testing/index.d.ts.map +1 -1
  220. package/dist/react/testing/index.js +16 -17
  221. package/dist/react/testing/index.js.map +1 -1
  222. package/dist/react/ui/index.d.ts +20 -25
  223. package/dist/react/ui/index.d.ts.map +1 -1
  224. package/dist/react/ui/index.js.map +1 -1
  225. package/dist/redis/index.bun.js.map +1 -1
  226. package/dist/redis/index.d.ts +17 -19
  227. package/dist/redis/index.d.ts.map +1 -1
  228. package/dist/redis/index.js.map +1 -1
  229. package/dist/retry/index.d.ts +2 -4
  230. package/dist/retry/index.d.ts.map +1 -1
  231. package/dist/retry/index.js.map +1 -1
  232. package/dist/router/index.d.ts.map +1 -1
  233. package/dist/router/index.js.map +1 -1
  234. package/dist/scheduler/index.d.ts +10 -13
  235. package/dist/scheduler/index.d.ts.map +1 -1
  236. package/dist/scheduler/index.js.map +1 -1
  237. package/dist/scheduler/index.workerd.js.map +1 -1
  238. package/dist/security/index.browser.js.map +1 -1
  239. package/dist/security/index.d.ts +45 -48
  240. package/dist/security/index.d.ts.map +1 -1
  241. package/dist/security/index.js.map +1 -1
  242. package/dist/server/auth/index.browser.js.map +1 -1
  243. package/dist/server/auth/index.d.ts +167 -172
  244. package/dist/server/auth/index.d.ts.map +1 -1
  245. package/dist/server/auth/index.js +4 -8
  246. package/dist/server/auth/index.js.map +1 -1
  247. package/dist/server/cookies/index.browser.js.map +1 -1
  248. package/dist/server/cookies/index.d.ts +5 -7
  249. package/dist/server/cookies/index.d.ts.map +1 -1
  250. package/dist/server/cookies/index.js.map +1 -1
  251. package/dist/server/core/index.browser.js.map +1 -1
  252. package/dist/server/core/index.d.ts +88 -73
  253. package/dist/server/core/index.d.ts.map +1 -1
  254. package/dist/server/core/index.js +19 -0
  255. package/dist/server/core/index.js.map +1 -1
  256. package/dist/server/cors/index.d.ts +11 -14
  257. package/dist/server/cors/index.d.ts.map +1 -1
  258. package/dist/server/cors/index.js.map +1 -1
  259. package/dist/server/etag/index.d.ts +6 -9
  260. package/dist/server/etag/index.d.ts.map +1 -1
  261. package/dist/server/etag/index.js.map +1 -1
  262. package/dist/server/health/index.d.ts +18 -21
  263. package/dist/server/health/index.d.ts.map +1 -1
  264. package/dist/server/health/index.js.map +1 -1
  265. package/dist/server/links/index.browser.js +2 -0
  266. package/dist/server/links/index.browser.js.map +1 -1
  267. package/dist/server/links/index.d.ts +63 -67
  268. package/dist/server/links/index.d.ts.map +1 -1
  269. package/dist/server/links/index.js +2 -0
  270. package/dist/server/links/index.js.map +1 -1
  271. package/dist/server/metrics/index.d.ts +5 -7
  272. package/dist/server/metrics/index.d.ts.map +1 -1
  273. package/dist/server/metrics/index.js.map +1 -1
  274. package/dist/server/proxy/index.d.ts +3 -5
  275. package/dist/server/proxy/index.d.ts.map +1 -1
  276. package/dist/server/proxy/index.js.map +1 -1
  277. package/dist/server/rate-limit/index.d.ts +10 -13
  278. package/dist/server/rate-limit/index.d.ts.map +1 -1
  279. package/dist/server/rate-limit/index.js.map +1 -1
  280. package/dist/server/static/index.d.ts +3 -5
  281. package/dist/server/static/index.d.ts.map +1 -1
  282. package/dist/server/static/index.js.map +1 -1
  283. package/dist/server/swagger/index.d.ts +5 -8
  284. package/dist/server/swagger/index.d.ts.map +1 -1
  285. package/dist/server/swagger/index.js.map +1 -1
  286. package/dist/sms/index.d.ts +3 -5
  287. package/dist/sms/index.d.ts.map +1 -1
  288. package/dist/sms/index.js.map +1 -1
  289. package/dist/system/index.browser.js.map +1 -1
  290. package/dist/system/index.d.ts +2 -4
  291. package/dist/system/index.d.ts.map +1 -1
  292. package/dist/system/index.js.map +1 -1
  293. package/dist/system/index.workerd.js.map +1 -1
  294. package/dist/topic/core/index.d.ts +4 -6
  295. package/dist/topic/core/index.d.ts.map +1 -1
  296. package/dist/topic/core/index.js.map +1 -1
  297. package/dist/topic/redis/index.d.ts +5 -8
  298. package/dist/topic/redis/index.d.ts.map +1 -1
  299. package/dist/topic/redis/index.js.map +1 -1
  300. package/package.json +57 -12
  301. package/src/api/audits/__tests__/AuditService.spec.ts +18 -110
  302. package/src/api/audits/controllers/AdminAuditController.ts +14 -0
  303. package/src/api/audits/services/AuditService.ts +21 -88
  304. package/src/api/files/__tests__/FileService.spec.ts +207 -2
  305. package/src/api/files/controllers/FileController.ts +41 -1
  306. package/src/api/files/index.ts +3 -0
  307. package/src/api/files/providers/FileAccessProvider.ts +23 -1
  308. package/src/api/files/schemas/fileCreatorSummarySchema.ts +22 -0
  309. package/src/api/files/schemas/fileResourceSchema.ts +10 -1
  310. package/src/api/files/services/FileService.ts +175 -75
  311. package/src/api/jobs/__tests__/$job.spec.ts +24 -1
  312. package/src/api/jobs/index.ts +4 -3
  313. package/src/api/jobs/primitives/$job.ts +7 -3
  314. package/src/api/jobs/providers/DirectJobDispatcher.ts +17 -36
  315. package/src/api/jobs/providers/JobProvider.ts +53 -24
  316. package/src/api/jobs/schemas/jobConfigAtom.ts +1 -1
  317. package/src/api/jobs/schemas/jobExecutionResourceSchema.ts +4 -1
  318. package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +3 -1
  319. package/src/api/parameters/__tests__/$parameter.spec.ts +19 -2
  320. package/src/api/parameters/audits/ParameterAudits.ts +17 -0
  321. package/src/api/parameters/controllers/AdminParameterController.ts +95 -19
  322. package/src/api/parameters/index.ts +3 -0
  323. package/src/api/parameters/schemas/activateParameterBodySchema.ts +3 -3
  324. package/src/api/parameters/schemas/createParameterVersionBodySchema.ts +3 -2
  325. package/src/api/parameters/schemas/parameterCreatorSummarySchema.ts +25 -0
  326. package/src/api/parameters/schemas/parameterResponseSchema.ts +5 -0
  327. package/src/api/parameters/schemas/rollbackParameterBodySchema.ts +4 -2
  328. package/src/api/parameters/services/ParameterProvider.ts +69 -6
  329. package/src/api/subscriptions/jobs/SubscriptionJobs.ts +1 -1
  330. package/src/api/users/__tests__/AdminSessionController.spec.ts +37 -0
  331. package/src/api/users/audits/SessionAudits.ts +33 -0
  332. package/src/api/users/audits/UserAudits.ts +19 -43
  333. package/src/api/users/controllers/AdminUserController.ts +66 -1
  334. package/src/api/users/entities/sessions.ts +6 -0
  335. package/src/api/users/entities/users.ts +2 -0
  336. package/src/api/users/index.ts +9 -1
  337. package/src/api/users/primitives/$realm.ts +3 -0
  338. package/src/api/users/schemas/sessionResourceSchema.ts +16 -0
  339. package/src/api/users/schemas/updateUserSchema.ts +1 -8
  340. package/src/api/users/schemas/userQuerySchema.ts +7 -0
  341. package/src/api/users/services/CredentialService.ts +52 -32
  342. package/src/api/users/services/IdentityService.ts +2 -1
  343. package/src/api/users/services/RegistrationService.ts +2 -1
  344. package/src/api/users/services/SessionCrudService.ts +19 -2
  345. package/src/api/users/services/SessionService.ts +39 -19
  346. package/src/api/users/services/UserService.ts +106 -8
  347. package/src/api/verifications/entities/verifications.ts +8 -0
  348. package/src/api/verifications/services/VerificationService.ts +14 -0
  349. package/src/background/__tests__/BackgroundTaskProvider.spec.ts +96 -0
  350. package/src/background/index.ts +37 -0
  351. package/src/background/index.workerd.ts +28 -0
  352. package/src/background/providers/BackgroundTaskProvider.ts +70 -0
  353. package/src/background/providers/WorkerdBackgroundTaskProvider.ts +43 -0
  354. package/src/bucket/__tests__/$bucket.spec.ts +18 -0
  355. package/src/bucket/__tests__/LocalFileStorageProvider.spec.ts +5 -0
  356. package/src/bucket/__tests__/MemoryFileStorageProvider.spec.ts +5 -0
  357. package/src/bucket/__tests__/NodeS3BucketProvider.spec.ts +23 -4
  358. package/src/bucket/__tests__/shared.ts +30 -0
  359. package/src/bucket/index.ts +5 -5
  360. package/src/bucket/index.workerd.ts +11 -4
  361. package/src/bucket/primitives/$bucket.ts +27 -0
  362. package/src/bucket/providers/FileStorageProvider.ts +13 -0
  363. package/src/bucket/providers/LocalFileStorageProvider.ts +17 -1
  364. package/src/bucket/providers/MemoryFileStorageProvider.ts +7 -0
  365. package/src/bucket/providers/{CloudflareR2Provider.ts → R2FileStorageProvider.ts} +10 -1
  366. package/src/bucket/providers/{NodeS3BucketProvider.ts → S3FileStorageProvider.ts} +27 -5
  367. package/src/cli/core/__tests__/BuildDockerTask.spec.ts +49 -1
  368. package/src/cli/core/__tests__/init.spec.ts +0 -219
  369. package/src/cli/core/atoms/buildOptions.ts +15 -0
  370. package/src/cli/core/commands/__tests__/BuildCommand.spec.ts +43 -0
  371. package/src/cli/core/commands/build.ts +122 -32
  372. package/src/cli/core/commands/init.ts +0 -12
  373. package/src/cli/core/commands/pack.ts +133 -0
  374. package/src/cli/core/index.ts +3 -0
  375. package/src/cli/core/providers/ViteDevServerProvider.ts +40 -16
  376. package/src/cli/core/services/PackageManagerUtils.ts +0 -16
  377. package/src/cli/core/services/ProjectScaffolder.ts +29 -291
  378. package/src/cli/core/tasks/BuildAssetsTask.ts +3 -0
  379. package/src/cli/core/tasks/BuildClientTask.ts +3 -0
  380. package/src/cli/core/tasks/BuildCloudflareTask.ts +453 -13
  381. package/src/cli/core/tasks/BuildCompressTask.ts +3 -0
  382. package/src/cli/core/tasks/BuildDockerTask.ts +43 -2
  383. package/src/cli/core/tasks/BuildPrerenderTask.ts +3 -0
  384. package/src/cli/core/tasks/BuildPwaTask.ts +3 -0
  385. package/src/cli/core/tasks/BuildServerTask.ts +3 -0
  386. package/src/cli/core/tasks/BuildTask.ts +42 -0
  387. package/src/cli/core/templates/apiIndexTs.ts +1 -22
  388. package/src/cli/core/templates/mainCss.ts +0 -1
  389. package/src/cli/core/templates/webAppRouterTs.ts +0 -99
  390. package/src/cli/core/templates/webIndexTs.ts +1 -22
  391. package/src/cli/platform/__tests__/SecretsCommand.spec.ts +5 -3
  392. package/src/cli/platform/commands/SecretsCommand.ts +8 -6
  393. package/src/cli/platform/commands/platform.ts +265 -122
  394. package/src/cli/platform/index.ts +25 -53
  395. package/src/cli/{platform → platform-lib}/__tests__/CloudflareAdapter.spec.ts +426 -169
  396. package/src/cli/{platform → platform-lib}/__tests__/NamingService.spec.ts +81 -36
  397. package/src/cli/{platform → platform-lib}/__tests__/PlatformInspector.spec.ts +4 -48
  398. package/src/cli/{platform → platform-lib}/__tests__/VercelAdapter.spec.ts +56 -85
  399. package/src/cli/{platform → platform-lib}/adapters/CloudflareAdapter.ts +412 -199
  400. package/src/cli/{platform → platform-lib}/adapters/PlatformAdapter.ts +68 -33
  401. package/src/cli/{platform → platform-lib}/adapters/VercelAdapter.ts +11 -25
  402. package/src/cli/{platform → platform-lib}/atoms/platformOptions.ts +34 -6
  403. package/src/cli/platform-lib/index.ts +67 -0
  404. package/src/cli/platform-lib/services/NamingService.ts +136 -0
  405. package/src/cli/platform-lib/services/PlatformInspector.ts +153 -0
  406. package/src/cli/{platform → platform-lib}/services/PlatformOrchestrator.ts +80 -127
  407. package/src/cli/{platform → platform-lib}/services/WranglerApi.ts +4 -2
  408. package/src/command/__tests__/Runner.spec.ts +20 -0
  409. package/src/command/helpers/EnvUtils.ts +19 -3
  410. package/src/command/helpers/Runner.ts +12 -2
  411. package/src/command/providers/CliProvider.ts +34 -1
  412. package/src/container/core/__tests__/$container.spec.ts +83 -0
  413. package/src/container/core/index.ts +50 -0
  414. package/src/container/core/index.workerd.ts +53 -0
  415. package/src/container/core/interfaces/ContainerOptions.ts +69 -0
  416. package/src/container/core/primitives/$container.ts +100 -0
  417. package/src/container/core/providers/CloudflareContainerProvider.ts +70 -0
  418. package/src/container/core/providers/ContainerProvider.ts +92 -0
  419. package/src/container/core/providers/MockContainerProvider.ts +62 -0
  420. package/src/container/core/providers/NodeContainerProvider.ts +53 -0
  421. package/src/core/Alepha.ts +49 -1
  422. package/src/core/__tests__/$env.spec.ts +42 -0
  423. package/src/core/__tests__/dump.spec.ts +47 -0
  424. package/src/email/cloudflare/__tests__/CloudflareEmailProvider.spec.ts +182 -0
  425. package/src/email/cloudflare/index.ts +35 -0
  426. package/src/email/cloudflare/providers/CloudflareEmailProvider.ts +205 -0
  427. package/src/logger/__tests__/Logger.spec.ts +55 -0
  428. package/src/logger/index.ts +13 -0
  429. package/src/logger/services/Logger.ts +31 -1
  430. package/src/orm/__tests__/orm-showcase-tests.ts +27 -0
  431. package/src/orm/__tests__/orm-showcase.spec.ts +12 -0
  432. package/src/orm/core/interfaces/PgQuery.ts +4 -1
  433. package/src/orm/core/services/Repository.ts +38 -13
  434. package/src/react/auth/hooks/useAuth.ts +10 -5
  435. package/src/react/core/__tests__/useQuery.browser.spec.tsx +25 -0
  436. package/src/react/core/hooks/useAction.ts +14 -3
  437. package/src/react/core/hooks/useQuery.ts +24 -4
  438. package/src/react/form/hooks/useFormQuerySync.ts +0 -0
  439. package/src/react/form/index.ts +1 -0
  440. package/src/react/form/services/FormModel.ts +18 -2
  441. package/src/react/i18n/components/Translate.tsx +47 -0
  442. package/src/react/i18n/index.ts +2 -0
  443. package/src/react/intro/components/GettingStartedAdminSlide.tsx +2 -2
  444. package/src/react/router/__tests__/$page.spec.tsx +3 -2
  445. package/src/react/router/__tests__/page-can.spec.ts +18 -13
  446. package/src/react/router/hooks/useQueryParams.ts +114 -14
  447. package/src/react/router/primitives/$page.ts +85 -4
  448. package/src/react/router/providers/ReactBrowserProvider.ts +12 -3
  449. package/src/react/router/providers/ReactBrowserRouterProvider.ts +3 -7
  450. package/src/react/router/providers/ReactServerProvider.ts +4 -13
  451. package/src/react/ui/services/SchemaControl.ts +3 -4
  452. package/src/server/core/providers/ServerMultipartProvider.ts +19 -0
  453. package/src/server/links/providers/LinkProvider.ts +10 -0
  454. package/src/cli/core/templates/componentsJsonTs.ts +0 -39
  455. package/src/cli/core/templates/saasAdminLayoutTsx.ts +0 -77
  456. package/src/cli/core/templates/saasAdminPagesTsx.ts +0 -26
  457. package/src/cli/core/templates/saasAuthLayoutTsx.ts +0 -22
  458. package/src/cli/core/templates/saasAuthPagesTsx.ts +0 -62
  459. package/src/cli/core/templates/saasRealmProviderTs.ts +0 -52
  460. package/src/cli/platform/hooks/PlatformHook.ts +0 -51
  461. package/src/cli/platform/services/NamingService.ts +0 -55
  462. package/src/cli/platform/services/PlatformInspector.ts +0 -140
  463. package/src/orm/REFACTORING.md +0 -330
  464. /package/dist/orm/core/{chunk-o8xxKEmq.js → chunk-B4FMCO8f.js} +0 -0
  465. /package/dist/react/testing/{chunk-6Ep1yQYe.js → chunk-BpyX8vjI.js} +0 -0
  466. /package/src/cli/{platform → platform-lib}/__tests__/GitHubSecretStore.spec.ts +0 -0
  467. /package/src/cli/{platform → platform-lib}/__tests__/PlatformCacheProvider.spec.ts +0 -0
  468. /package/src/cli/{platform → platform-lib}/__tests__/PlatformOrchestrator.spec.ts +0 -0
  469. /package/src/cli/{platform → platform-lib}/__tests__/SecretFilterService.spec.ts +0 -0
  470. /package/src/cli/{platform → platform-lib}/__tests__/detectResources.spec.ts +0 -0
  471. /package/src/cli/{platform → platform-lib}/providers/GitHubSecretStore.ts +0 -0
  472. /package/src/cli/{platform → platform-lib}/providers/MemorySecretStore.ts +0 -0
  473. /package/src/cli/{platform → platform-lib}/providers/PlatformCacheProvider.ts +0 -0
  474. /package/src/cli/{platform → platform-lib}/providers/SecretStoreProvider.ts +0 -0
  475. /package/src/cli/{platform → platform-lib}/schemas/cloudflare.ts +0 -0
  476. /package/src/cli/{platform → platform-lib}/schemas/platform.ts +0 -0
  477. /package/src/cli/{platform → platform-lib}/schemas/vercel.ts +0 -0
  478. /package/src/cli/{platform → platform-lib}/services/CloudflareApi.ts +0 -0
  479. /package/src/cli/{platform → platform-lib}/services/SecretFilterService.ts +0 -0
  480. /package/src/cli/{platform → platform-lib}/services/VercelApi.ts +0 -0
  481. /package/src/cli/{platform → platform-lib}/services/VercelCli.ts +0 -0
@@ -9,6 +9,7 @@ import {
9
9
  import { describe, test } from "vitest";
10
10
  import { CloudflareAdapter } from "../adapters/CloudflareAdapter.ts";
11
11
  import type { PlatformContext } from "../adapters/PlatformAdapter.ts";
12
+ import { platformOptions } from "../atoms/platformOptions.ts";
12
13
  import { CloudflareApi } from "../services/CloudflareApi.ts";
13
14
  import { NamingService } from "../services/NamingService.ts";
14
15
 
@@ -203,7 +204,14 @@ describe("CloudflareAdapter", () => {
203
204
  project: "acme-portal",
204
205
  env: "production",
205
206
  envConfig: { adapter: "cloudflare" },
206
- apps: [],
207
+ entry: { root: "/project", server: "src/main.ts" },
208
+ resources: {
209
+ hasDatabase: false,
210
+ hasBucket: false,
211
+ hasKV: false,
212
+ hasQueue: false,
213
+ hasCron: false,
214
+ },
207
215
  root: "/project",
208
216
  naming: naming.forContext("acme-portal", "production"),
209
217
  ...overrides,
@@ -270,20 +278,14 @@ describe("CloudflareAdapter", () => {
270
278
  }) => {
271
279
  const { adapter, naming, api } = createTestEnv();
272
280
  const ctx = makeCtx(naming, {
273
- apps: [
274
- {
275
- name: "api",
276
- path: "apps/api",
277
- entry: { root: "/project/apps/api", server: "src/main.ts" },
278
- resources: {
279
- hasDatabase: true,
280
- hasBucket: false,
281
- hasKV: false,
282
- hasQueue: false,
283
- hasCron: false,
284
- },
285
- },
286
- ],
281
+ entry: { root: "/project", server: "src/main.ts" },
282
+ resources: {
283
+ hasDatabase: true,
284
+ hasBucket: false,
285
+ hasKV: false,
286
+ hasQueue: false,
287
+ hasCron: false,
288
+ },
287
289
  });
288
290
 
289
291
  const run = createMockRun();
@@ -298,20 +300,14 @@ describe("CloudflareAdapter", () => {
298
300
  }) => {
299
301
  const { adapter, naming, api } = createTestEnv();
300
302
  const ctx = makeCtx(naming, {
301
- apps: [
302
- {
303
- name: "api",
304
- path: "apps/api",
305
- entry: { root: "/project/apps/api", server: "src/main.ts" },
306
- resources: {
307
- hasDatabase: true,
308
- hasBucket: false,
309
- hasKV: false,
310
- hasQueue: false,
311
- hasCron: false,
312
- },
313
- },
314
- ],
303
+ entry: { root: "/project", server: "src/main.ts" },
304
+ resources: {
305
+ hasDatabase: true,
306
+ hasBucket: false,
307
+ hasKV: false,
308
+ hasQueue: false,
309
+ hasCron: false,
310
+ },
315
311
  });
316
312
 
317
313
  // Pre-seed existing database
@@ -333,20 +329,14 @@ describe("CloudflareAdapter", () => {
333
329
  }) => {
334
330
  const { adapter, naming, api } = createTestEnv();
335
331
  const ctx = makeCtx(naming, {
336
- apps: [
337
- {
338
- name: "api",
339
- path: "apps/api",
340
- entry: { root: "/project/apps/api", server: "src/main.ts" },
341
- resources: {
342
- hasDatabase: false,
343
- hasBucket: true,
344
- hasKV: false,
345
- hasQueue: false,
346
- hasCron: false,
347
- },
348
- },
349
- ],
332
+ entry: { root: "/project", server: "src/main.ts" },
333
+ resources: {
334
+ hasDatabase: false,
335
+ hasBucket: true,
336
+ hasKV: false,
337
+ hasQueue: false,
338
+ hasCron: false,
339
+ },
350
340
  });
351
341
 
352
342
  const run = createMockRun();
@@ -361,20 +351,14 @@ describe("CloudflareAdapter", () => {
361
351
  }) => {
362
352
  const { adapter, naming, api } = createTestEnv();
363
353
  const ctx = makeCtx(naming, {
364
- apps: [
365
- {
366
- name: "api",
367
- path: "apps/api",
368
- entry: { root: "/project/apps/api", server: "src/main.ts" },
369
- resources: {
370
- hasDatabase: false,
371
- hasBucket: false,
372
- hasKV: true,
373
- hasQueue: false,
374
- hasCron: false,
375
- },
376
- },
377
- ],
354
+ entry: { root: "/project", server: "src/main.ts" },
355
+ resources: {
356
+ hasDatabase: false,
357
+ hasBucket: false,
358
+ hasKV: true,
359
+ hasQueue: false,
360
+ hasCron: false,
361
+ },
378
362
  });
379
363
 
380
364
  const run = createMockRun();
@@ -389,20 +373,14 @@ describe("CloudflareAdapter", () => {
389
373
  }) => {
390
374
  const { adapter, naming, api } = createTestEnv();
391
375
  const ctx = makeCtx(naming, {
392
- apps: [
393
- {
394
- name: "api",
395
- path: "apps/api",
396
- entry: { root: "/project/apps/api", server: "src/main.ts" },
397
- resources: {
398
- hasDatabase: false,
399
- hasBucket: false,
400
- hasKV: false,
401
- hasQueue: true,
402
- hasCron: false,
403
- },
404
- },
405
- ],
376
+ entry: { root: "/project", server: "src/main.ts" },
377
+ resources: {
378
+ hasDatabase: false,
379
+ hasBucket: false,
380
+ hasKV: false,
381
+ hasQueue: true,
382
+ hasCron: false,
383
+ },
406
384
  });
407
385
 
408
386
  const run = createMockRun();
@@ -419,20 +397,14 @@ describe("CloudflareAdapter", () => {
419
397
  }) => {
420
398
  const { adapter, fs, naming, api } = createTestEnv();
421
399
  const ctx = makeCtx(naming, {
422
- apps: [
423
- {
424
- name: "api",
425
- path: "apps/api",
426
- entry: { root: "/project/apps/api", server: "src/main.ts" },
427
- resources: {
428
- hasDatabase: false,
429
- hasBucket: false,
430
- hasKV: false,
431
- hasQueue: false,
432
- hasCron: false,
433
- },
434
- },
435
- ],
400
+ entry: { root: "/project", server: "src/main.ts" },
401
+ resources: {
402
+ hasDatabase: false,
403
+ hasBucket: false,
404
+ hasKV: false,
405
+ hasQueue: false,
406
+ hasCron: false,
407
+ },
436
408
  });
437
409
 
438
410
  await fs.writeFile(
@@ -457,23 +429,293 @@ describe("CloudflareAdapter", () => {
457
429
  expect(names).toEqual(["APP_SECRET", "GOOGLE_API_KEY"]);
458
430
  });
459
431
 
432
+ test("with platform.secrets.keys, resolves the allowlist from process.env (no .env file) and ignores ambient vars", async ({
433
+ expect,
434
+ }) => {
435
+ const { adapter, alepha, naming, api } = createTestEnv();
436
+ // Declare an explicit allowlist — the CI shape: secrets arrive via the
437
+ // job environment, there is no .env.production on the runner.
438
+ alepha.set(platformOptions, {
439
+ secrets: { keys: ["APP_SECRET", "GOOGLE_CLIENT_ID", "EMAIL_FROM"] },
440
+ environments: { production: { adapter: "cloudflare" } },
441
+ } as any);
442
+
443
+ const ctx = makeCtx(naming, {
444
+ entry: { root: "/project", server: "src/main.ts" },
445
+ resources: {
446
+ hasDatabase: false,
447
+ hasBucket: false,
448
+ hasKV: false,
449
+ hasQueue: false,
450
+ hasCron: false,
451
+ },
452
+ });
453
+
454
+ process.env.APP_SECRET = "from-env-secret";
455
+ process.env.GOOGLE_CLIENT_ID = "from-env-google";
456
+ // EMAIL_FROM intentionally unset → declared but unresolved, not pushed.
457
+ // PATH-style ambient var that must never leak into worker secrets.
458
+ process.env.AMBIENT_RUNNER_VAR = "leak-me-not";
459
+ try {
460
+ const run = createMockRun();
461
+ await adapter.secrets(ctx, run);
462
+ } finally {
463
+ delete process.env.APP_SECRET;
464
+ delete process.env.GOOGLE_CLIENT_ID;
465
+ delete process.env.AMBIENT_RUNNER_VAR;
466
+ }
467
+
468
+ const pushed = api.secrets.get("acme-portal-production") ?? [];
469
+ const names = pushed.map((s) => s.name).sort();
470
+ expect(names).toEqual(["APP_SECRET", "GOOGLE_CLIENT_ID"]);
471
+ });
472
+
473
+ test("with platform.secrets.keys, the .env file overrides process.env per key", async ({
474
+ expect,
475
+ }) => {
476
+ const { adapter, alepha, fs, naming, api } = createTestEnv();
477
+ alepha.set(platformOptions, {
478
+ secrets: { keys: ["APP_SECRET", "GOOGLE_CLIENT_ID"] },
479
+ environments: { production: { adapter: "cloudflare" } },
480
+ } as any);
481
+
482
+ const ctx = makeCtx(naming, {
483
+ entry: { root: "/project", server: "src/main.ts" },
484
+ resources: {
485
+ hasDatabase: false,
486
+ hasBucket: false,
487
+ hasKV: false,
488
+ hasQueue: false,
489
+ hasCron: false,
490
+ },
491
+ });
492
+
493
+ // APP_SECRET in the file → file wins. GOOGLE_CLIENT_ID only in env → env.
494
+ await fs.writeFile(
495
+ "/project/.env.production",
496
+ ["APP_SECRET=from-file", ""].join("\n"),
497
+ );
498
+ process.env.APP_SECRET = "from-env";
499
+ process.env.GOOGLE_CLIENT_ID = "env-google";
500
+ try {
501
+ const run = createMockRun();
502
+ await adapter.secrets(ctx, run);
503
+ } finally {
504
+ delete process.env.APP_SECRET;
505
+ delete process.env.GOOGLE_CLIENT_ID;
506
+ }
507
+
508
+ // Secret *values* land in the full binding set (api.bindings); the
509
+ // api.secrets projection only keeps names.
510
+ const bindings = api.bindings.get("acme-portal-production") ?? [];
511
+ const byName = Object.fromEntries(
512
+ bindings
513
+ .filter((b) => b.type === "secret_text")
514
+ .map((b) => [b.name, b.text]),
515
+ );
516
+ expect(byName.APP_SECRET).toBe("from-file");
517
+ expect(byName.GOOGLE_CLIENT_ID).toBe("env-google");
518
+ });
519
+
520
+ test("uses dist/manifest.json `env` as the default allowlist, resolved from process.env", async ({
521
+ expect,
522
+ }) => {
523
+ const { adapter, fs, naming, api } = createTestEnv();
524
+ // No platform.secrets.keys and no .env file → the manifest's declared
525
+ // env list is the allowlist. This is the CI shape.
526
+ const ctx = makeCtx(naming, {
527
+ entry: { root: "/project", server: "src/main.ts" },
528
+ resources: {
529
+ hasDatabase: false,
530
+ hasBucket: false,
531
+ hasKV: false,
532
+ hasQueue: false,
533
+ hasCron: false,
534
+ },
535
+ });
536
+
537
+ await fs.writeFile(
538
+ "/project/dist/manifest.json",
539
+ JSON.stringify({
540
+ env: [
541
+ "APP_SECRET",
542
+ "GOOGLE_CLIENT_ID",
543
+ "CLOUDFLARE_ZONE",
544
+ "LOG_LEVEL",
545
+ ],
546
+ }),
547
+ );
548
+
549
+ process.env.APP_SECRET = "s1";
550
+ process.env.GOOGLE_CLIENT_ID = "g1";
551
+ process.env.CLOUDFLARE_ZONE = "example.com"; // declared but EXCLUDED
552
+ // LOG_LEVEL is declared + ambient in the runner, but EXCLUDED (infra knob).
553
+ try {
554
+ const run = createMockRun();
555
+ await adapter.secrets(ctx, run);
556
+ } finally {
557
+ delete process.env.APP_SECRET;
558
+ delete process.env.GOOGLE_CLIENT_ID;
559
+ delete process.env.CLOUDFLARE_ZONE;
560
+ }
561
+
562
+ const pushed = api.secrets.get("acme-portal-production") ?? [];
563
+ expect(pushed.map((s) => s.name).sort()).toEqual([
564
+ "APP_SECRET",
565
+ "GOOGLE_CLIENT_ID",
566
+ ]);
567
+ });
568
+
569
+ test("pushes per-deploy keys from .env.<env>.local even when not in the manifest", async ({
570
+ expect,
571
+ }) => {
572
+ const { adapter, fs, naming, api } = createTestEnv();
573
+ const ctx = makeCtx(naming, {
574
+ entry: { root: "/project", server: "src/main.ts" },
575
+ resources: {
576
+ hasDatabase: false,
577
+ hasBucket: false,
578
+ hasKV: false,
579
+ hasQueue: false,
580
+ hasCron: false,
581
+ },
582
+ });
583
+
584
+ // Manifest declares only APP_SECRET…
585
+ await fs.writeFile(
586
+ "/project/dist/manifest.json",
587
+ JSON.stringify({ env: ["APP_SECRET"] }),
588
+ );
589
+ // …but an orchestrator (Rocket) injected CLUB_CONFIG_JSON into the
590
+ // per-deploy override file. It must still be pushed.
591
+ await fs.writeFile(
592
+ "/project/.env.production.local",
593
+ ["APP_SECRET=s1", 'CLUB_CONFIG_JSON={"id":"b14"}', ""].join("\n"),
594
+ );
595
+
596
+ const run = createMockRun();
597
+ await adapter.secrets(ctx, run);
598
+
599
+ const pushed = api.secrets.get("acme-portal-production") ?? [];
600
+ expect(pushed.map((s) => s.name).sort()).toEqual([
601
+ "APP_SECRET",
602
+ "CLUB_CONFIG_JSON",
603
+ ]);
604
+ });
605
+
606
+ test("platform.secrets.keys overrides the manifest `env` allowlist", async ({
607
+ expect,
608
+ }) => {
609
+ const { adapter, alepha, fs, naming, api } = createTestEnv();
610
+ alepha.set(platformOptions, {
611
+ secrets: { keys: ["APP_SECRET"] }, // narrow override
612
+ environments: { production: { adapter: "cloudflare" } },
613
+ } as any);
614
+
615
+ const ctx = makeCtx(naming, {
616
+ entry: { root: "/project", server: "src/main.ts" },
617
+ resources: {
618
+ hasDatabase: false,
619
+ hasBucket: false,
620
+ hasKV: false,
621
+ hasQueue: false,
622
+ hasCron: false,
623
+ },
624
+ });
625
+
626
+ // Manifest lists more keys, but the explicit override wins.
627
+ await fs.writeFile(
628
+ "/project/dist/manifest.json",
629
+ JSON.stringify({ env: ["APP_SECRET", "GOOGLE_CLIENT_ID"] }),
630
+ );
631
+
632
+ process.env.APP_SECRET = "s1";
633
+ process.env.GOOGLE_CLIENT_ID = "g1";
634
+ try {
635
+ const run = createMockRun();
636
+ await adapter.secrets(ctx, run);
637
+ } finally {
638
+ delete process.env.APP_SECRET;
639
+ delete process.env.GOOGLE_CLIENT_ID;
640
+ }
641
+
642
+ const pushed = api.secrets.get("acme-portal-production") ?? [];
643
+ expect(pushed.map((s) => s.name)).toEqual(["APP_SECRET"]);
644
+ });
645
+
646
+ test("auto-derives PUBLIC_URL from the configured domain", async ({
647
+ expect,
648
+ }) => {
649
+ const { adapter, fs, naming, api } = createTestEnv();
650
+ const ctx = makeCtx(naming, {
651
+ envConfig: { adapter: "cloudflare", domain: "lore.alepha.dev" },
652
+ });
653
+
654
+ await fs.writeFile(
655
+ "/project/.env.production",
656
+ ["APP_SECRET=my-secret", ""].join("\n"),
657
+ );
658
+
659
+ const run = createMockRun();
660
+ await adapter.secrets(ctx, run);
661
+
662
+ const bindings = api.bindings.get("acme-portal-production") ?? [];
663
+ const publicUrl = bindings.find((b) => b.name === "PUBLIC_URL");
664
+ expect(publicUrl?.text).toBe("https://lore.alepha.dev");
665
+ });
666
+
667
+ test("derives PUBLIC_URL for a tenant subdomain", async ({ expect }) => {
668
+ const { adapter, fs, naming, api } = createTestEnv();
669
+ const ctx = makeCtx(naming, {
670
+ envConfig: { adapter: "cloudflare", domain: "alepha.dev" },
671
+ tenant: "acme",
672
+ });
673
+
674
+ await fs.writeFile(
675
+ "/project/.env.production",
676
+ ["APP_SECRET=my-secret", ""].join("\n"),
677
+ );
678
+
679
+ const run = createMockRun();
680
+ await adapter.secrets(ctx, run);
681
+
682
+ const bindings = api.bindings.get("acme-portal-production") ?? [];
683
+ const publicUrl = bindings.find((b) => b.name === "PUBLIC_URL");
684
+ expect(publicUrl?.text).toBe("https://acme.alepha.dev");
685
+ });
686
+
687
+ test("honors an explicit PUBLIC_URL over the derived one", async ({
688
+ expect,
689
+ }) => {
690
+ const { adapter, fs, naming, api } = createTestEnv();
691
+ const ctx = makeCtx(naming, {
692
+ envConfig: { adapter: "cloudflare", domain: "lore.alepha.dev" },
693
+ });
694
+
695
+ await fs.writeFile(
696
+ "/project/.env.production",
697
+ ["PUBLIC_URL=https://custom.example.com", ""].join("\n"),
698
+ );
699
+
700
+ const run = createMockRun();
701
+ await adapter.secrets(ctx, run);
702
+
703
+ const bindings = api.bindings.get("acme-portal-production") ?? [];
704
+ const publicUrl = bindings.find((b) => b.name === "PUBLIC_URL");
705
+ expect(publicUrl?.text).toBe("https://custom.example.com");
706
+ });
707
+
460
708
  test("skips when no env file exists", async ({ expect }) => {
461
709
  const { adapter, naming, api } = createTestEnv();
462
710
  const ctx = makeCtx(naming, {
463
- apps: [
464
- {
465
- name: "api",
466
- path: "apps/api",
467
- entry: { root: "/project/apps/api", server: "src/main.ts" },
468
- resources: {
469
- hasDatabase: false,
470
- hasBucket: false,
471
- hasKV: false,
472
- hasQueue: false,
473
- hasCron: false,
474
- },
475
- },
476
- ],
711
+ entry: { root: "/project", server: "src/main.ts" },
712
+ resources: {
713
+ hasDatabase: false,
714
+ hasBucket: false,
715
+ hasKV: false,
716
+ hasQueue: false,
717
+ hasCron: false,
718
+ },
477
719
  });
478
720
 
479
721
  const run = createMockRun();
@@ -485,20 +727,14 @@ describe("CloudflareAdapter", () => {
485
727
  test("skips comments and empty lines", async ({ expect }) => {
486
728
  const { adapter, fs, naming, api } = createTestEnv();
487
729
  const ctx = makeCtx(naming, {
488
- apps: [
489
- {
490
- name: "api",
491
- path: "apps/api",
492
- entry: { root: "/project/apps/api", server: "src/main.ts" },
493
- resources: {
494
- hasDatabase: false,
495
- hasBucket: false,
496
- hasKV: false,
497
- hasQueue: false,
498
- hasCron: false,
499
- },
500
- },
501
- ],
730
+ entry: { root: "/project", server: "src/main.ts" },
731
+ resources: {
732
+ hasDatabase: false,
733
+ hasBucket: false,
734
+ hasKV: false,
735
+ hasQueue: false,
736
+ hasCron: false,
737
+ },
502
738
  });
503
739
 
504
740
  await fs.writeFile(
@@ -518,20 +754,14 @@ describe("CloudflareAdapter", () => {
518
754
  }) => {
519
755
  const { adapter, fs, naming, api } = createTestEnv();
520
756
  const ctx = makeCtx(naming, {
521
- apps: [
522
- {
523
- name: "api",
524
- path: "apps/api",
525
- entry: { root: "/project/apps/api", server: "src/main.ts" },
526
- resources: {
527
- hasDatabase: false,
528
- hasBucket: false,
529
- hasKV: false,
530
- hasQueue: false,
531
- hasCron: false,
532
- },
533
- },
534
- ],
757
+ entry: { root: "/project", server: "src/main.ts" },
758
+ resources: {
759
+ hasDatabase: false,
760
+ hasBucket: false,
761
+ hasKV: false,
762
+ hasQueue: false,
763
+ hasCron: false,
764
+ },
535
765
  });
536
766
 
537
767
  await fs.writeFile(
@@ -570,20 +800,14 @@ describe("CloudflareAdapter", () => {
570
800
  test("PATCHes when secrets changed (hash mismatch)", async ({ expect }) => {
571
801
  const { adapter, fs, naming, api } = createTestEnv();
572
802
  const ctx = makeCtx(naming, {
573
- apps: [
574
- {
575
- name: "api",
576
- path: "apps/api",
577
- entry: { root: "/project/apps/api", server: "src/main.ts" },
578
- resources: {
579
- hasDatabase: false,
580
- hasBucket: false,
581
- hasKV: false,
582
- hasQueue: false,
583
- hasCron: false,
584
- },
585
- },
586
- ],
803
+ entry: { root: "/project", server: "src/main.ts" },
804
+ resources: {
805
+ hasDatabase: false,
806
+ hasBucket: false,
807
+ hasKV: false,
808
+ hasQueue: false,
809
+ hasCron: false,
810
+ },
587
811
  });
588
812
 
589
813
  await fs.writeFile("/project/.env.production", "APP_SECRET=v1");
@@ -614,20 +838,14 @@ describe("CloudflareAdapter", () => {
614
838
  }) => {
615
839
  const { adapter, naming, api } = createTestEnv();
616
840
  const ctx = makeCtx(naming, {
617
- apps: [
618
- {
619
- name: "api",
620
- path: "apps/api",
621
- entry: { root: "/project/apps/api", server: "src/main.ts" },
622
- resources: {
623
- hasDatabase: true,
624
- hasBucket: true,
625
- hasKV: false,
626
- hasQueue: false,
627
- hasCron: false,
628
- },
629
- },
630
- ],
841
+ entry: { root: "/project", server: "src/main.ts" },
842
+ resources: {
843
+ hasDatabase: true,
844
+ hasBucket: true,
845
+ hasKV: false,
846
+ hasQueue: false,
847
+ hasCron: false,
848
+ },
631
849
  });
632
850
 
633
851
  // Pre-seed existing resources
@@ -664,20 +882,14 @@ describe("CloudflareAdapter", () => {
664
882
  test("deletes resources via REST API", async ({ expect }) => {
665
883
  const { adapter, naming, api } = createTestEnv();
666
884
  const ctx = makeCtx(naming, {
667
- apps: [
668
- {
669
- name: "api",
670
- path: "apps/api",
671
- entry: { root: "/project/apps/api", server: "src/main.ts" },
672
- resources: {
673
- hasDatabase: true,
674
- hasBucket: true,
675
- hasKV: true,
676
- hasQueue: false,
677
- hasCron: false,
678
- },
679
- },
680
- ],
885
+ entry: { root: "/project", server: "src/main.ts" },
886
+ resources: {
887
+ hasDatabase: true,
888
+ hasBucket: true,
889
+ hasKV: true,
890
+ hasQueue: false,
891
+ hasCron: false,
892
+ },
681
893
  });
682
894
 
683
895
  // Pre-seed existing resources
@@ -702,6 +914,51 @@ describe("CloudflareAdapter", () => {
702
914
  expect(api.kvNamespaces).toHaveLength(0);
703
915
  });
704
916
  });
917
+
918
+ describe("exportDb", () => {
919
+ test("dumps remote D1 and imports it into a local SQLite snapshot", async ({
920
+ expect,
921
+ }) => {
922
+ const { adapter, naming } = createTestEnv();
923
+ const ctx = makeCtx(naming, {
924
+ resources: {
925
+ hasDatabase: true,
926
+ hasBucket: false,
927
+ hasKV: false,
928
+ hasQueue: false,
929
+ hasCron: false,
930
+ },
931
+ });
932
+
933
+ // Record the raw shell strings exportDb issues via run().
934
+ const commands: string[] = [];
935
+ const run: any = async (cmd: any) => {
936
+ if (typeof cmd === "string") commands.push(cmd);
937
+ };
938
+ run.pause = () => {};
939
+ run.resume = () => {};
940
+ run.end = () => {};
941
+
942
+ await adapter.exportDb(ctx, run, {
943
+ output: "/tmp/snap.db",
944
+ keepSql: true,
945
+ });
946
+
947
+ expect(
948
+ commands.some((c) => /^wrangler d1 export .+ --remote /.test(c)),
949
+ ).toBe(true);
950
+ expect(commands.some((c) => /sqlite3 '\/tmp\/snap\.db' < /.test(c))).toBe(
951
+ true,
952
+ );
953
+ });
954
+
955
+ test("refuses when no database is detected", async ({ expect }) => {
956
+ const { adapter, naming } = createTestEnv();
957
+ const ctx = makeCtx(naming); // resources.hasDatabase defaults to false
958
+ const run = createMockRun();
959
+ await expect(adapter.exportDb(ctx, run)).rejects.toThrow(/no database/i);
960
+ });
961
+ });
705
962
  });
706
963
 
707
964
  /**