qarpeo 0.1.35 → 0.2.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 (363) hide show
  1. package/README.md +114 -26
  2. package/dist/apps/cms.d.ts +4 -0
  3. package/dist/apps/comments.d.ts +4 -0
  4. package/dist/apps/payments.d.ts +4 -0
  5. package/dist/apps/store.d.ts +4 -0
  6. package/dist/chunks/auth-schema.mjs +169 -30
  7. package/dist/chunks/tools.mjs +1680 -0
  8. package/dist/cli/index.mjs +1256 -221
  9. package/dist/core/aliases.d.ts +5 -0
  10. package/dist/core/context.d.ts +10 -0
  11. package/dist/core/cross-drive.d.ts +2 -0
  12. package/dist/core/d1-migrate.d.ts +4 -0
  13. package/dist/core/devtools.d.ts +4 -0
  14. package/dist/core/nitro.d.ts +4 -0
  15. package/dist/core/schema.d.ts +4 -0
  16. package/dist/core/server-utils.d.ts +4 -0
  17. package/dist/core/wrangler.d.ts +4 -0
  18. package/dist/dev/wrangler.d.ts +1 -0
  19. package/dist/fate/index.d.ts +8 -8
  20. package/dist/features/agents.d.ts +4 -0
  21. package/dist/features/auth.d.ts +4 -0
  22. package/dist/features/bots.d.ts +4 -0
  23. package/dist/features/fate.d.ts +4 -0
  24. package/dist/features/mail.d.ts +4 -0
  25. package/dist/features/mcp.d.ts +4 -0
  26. package/dist/features/multitenant.d.ts +4 -0
  27. package/dist/features/notifications.d.ts +4 -0
  28. package/dist/features/realtime.d.ts +4 -0
  29. package/dist/module.d.ts +10 -2
  30. package/dist/module.mjs +6313 -5118
  31. package/dist/primitives/ai.d.ts +4 -0
  32. package/dist/primitives/analytics.d.ts +4 -0
  33. package/dist/primitives/blob.d.ts +4 -0
  34. package/dist/primitives/browser.d.ts +4 -0
  35. package/dist/primitives/cache.d.ts +4 -0
  36. package/dist/primitives/d1.d.ts +4 -0
  37. package/dist/primitives/do.d.ts +4 -0
  38. package/dist/primitives/email.d.ts +4 -0
  39. package/dist/primitives/hyperdrive.d.ts +4 -0
  40. package/dist/primitives/kv.d.ts +4 -0
  41. package/dist/primitives/queue.d.ts +4 -0
  42. package/dist/primitives/ratelimit.d.ts +4 -0
  43. package/dist/primitives/vectorize.d.ts +4 -0
  44. package/dist/primitives/workflows.d.ts +4 -0
  45. package/dist/runtime/ai.d.ts +3 -3
  46. package/dist/runtime/ai.mjs +8 -1
  47. package/dist/runtime/app/components/RealtimeCursors.vue +2 -2
  48. package/dist/runtime/app/composables/ai.d.ts +56 -29
  49. package/dist/runtime/app/composables/analytics.d.ts +26 -106
  50. package/dist/runtime/app/composables/api-tokens.d.ts +31 -34
  51. package/dist/runtime/app/composables/auth.d.ts +147 -51
  52. package/dist/runtime/app/composables/auth.mjs +0 -7
  53. package/dist/runtime/app/composables/chat.d.ts +38 -35
  54. package/dist/runtime/app/composables/cms-preview.d.ts +30 -25
  55. package/dist/runtime/app/composables/cms.d.ts +57 -282
  56. package/dist/runtime/app/composables/cms.mjs +0 -35
  57. package/dist/runtime/app/composables/comments.d.ts +32 -5
  58. package/dist/runtime/app/composables/comments.mjs +29 -1
  59. package/dist/runtime/app/composables/docs-version.d.ts +25 -28
  60. package/dist/runtime/app/composables/impersonation.d.ts +22 -5
  61. package/dist/runtime/app/composables/organization.d.ts +38 -91
  62. package/dist/runtime/app/composables/passkey.d.ts +22 -6
  63. package/dist/runtime/app/composables/passwordless.d.ts +24 -7
  64. package/dist/runtime/app/composables/payments.d.ts +50 -34
  65. package/dist/runtime/app/composables/payments.mjs +1 -0
  66. package/dist/runtime/app/composables/sse.d.ts +76 -0
  67. package/dist/runtime/app/composables/sse.mjs +152 -0
  68. package/dist/runtime/app/composables/storage.d.ts +53 -65
  69. package/dist/runtime/app/composables/storage.mjs +17 -0
  70. package/dist/runtime/app/composables/store.d.ts +198 -0
  71. package/dist/runtime/app/composables/store.mjs +414 -0
  72. package/dist/runtime/app/composables/tenant.d.ts +31 -72
  73. package/dist/runtime/app/composables/turnstile.d.ts +16 -3
  74. package/dist/runtime/app/composables/two-factor.d.ts +23 -6
  75. package/dist/runtime/app/pages/devtools/notifications.vue +30 -27
  76. package/dist/runtime/app/pages/devtools/realtime.vue +19 -31
  77. package/dist/runtime/app/pages/devtools.vue +0 -7
  78. package/dist/runtime/auth.d.ts +9 -9
  79. package/dist/runtime/blob.d.ts +10 -1
  80. package/dist/runtime/blob.mjs +83 -0
  81. package/dist/runtime/cache.d.ts +48 -0
  82. package/dist/runtime/cache.mjs +92 -0
  83. package/dist/runtime/comments.d.ts +4 -0
  84. package/dist/runtime/comments.mjs +2 -0
  85. package/dist/runtime/db.d.ts +21 -1
  86. package/dist/runtime/db.mjs +54 -0
  87. package/dist/runtime/drizzle.d.ts +4 -2
  88. package/dist/runtime/drizzle.mjs +68 -1
  89. package/dist/runtime/durable-object.d.ts +2 -0
  90. package/dist/runtime/durable-object.mjs +2 -0
  91. package/dist/runtime/email.d.ts +1 -1
  92. package/dist/runtime/email.mjs +1 -1
  93. package/dist/runtime/kv.mjs +50 -1
  94. package/dist/runtime/mcp.d.ts +2 -0
  95. package/dist/runtime/mcp.mjs +2 -0
  96. package/dist/runtime/queue.d.ts +12 -2
  97. package/dist/runtime/queue.mjs +19 -1
  98. package/dist/runtime/ratelimit.d.ts +1 -0
  99. package/dist/runtime/ratelimit.mjs +7 -0
  100. package/dist/runtime/schema.d.ts +313 -0
  101. package/dist/runtime/schema.mjs +259 -0
  102. package/dist/runtime/server/db/cms-schema.d.ts +1225 -171
  103. package/dist/runtime/server/db/cms-schema.mjs +69 -70
  104. package/dist/runtime/server/db/store-schema.d.ts +4344 -0
  105. package/dist/runtime/server/db/store-schema.mjs +266 -0
  106. package/dist/runtime/server/durable-objects/agent.mjs +35 -0
  107. package/dist/runtime/server/durable-objects/room.mjs +0 -1
  108. package/dist/runtime/server/middleware/ratelimit.mjs +10 -8
  109. package/dist/runtime/server/plugins/comments.d.ts +7 -0
  110. package/dist/runtime/server/plugins/comments.mjs +7 -0
  111. package/dist/runtime/server/plugins/email-inbound.d.ts +5 -0
  112. package/dist/runtime/server/plugins/email-inbound.mjs +17 -0
  113. package/dist/runtime/server/plugins/store.d.ts +7 -0
  114. package/dist/runtime/server/plugins/store.mjs +7 -0
  115. package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +2 -2
  116. package/dist/runtime/server/routes/atom.xml.get.mjs +3 -1
  117. package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +13 -2
  118. package/dist/runtime/server/routes/auth/2fa/setup.post.mjs +9 -3
  119. package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +11 -3
  120. package/dist/runtime/server/routes/auth/account.delete.mjs +2 -1
  121. package/dist/runtime/server/routes/auth/audit-logs.get.mjs +1 -1
  122. package/dist/runtime/server/routes/auth/magic-link/send.post.d.ts +1 -9
  123. package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +8 -0
  124. package/dist/runtime/server/routes/auth/organization/sso/[id].delete.mjs +1 -1
  125. package/dist/runtime/server/routes/auth/organization/sso/index.get.mjs +1 -1
  126. package/dist/runtime/server/routes/auth/organization/sso/index.post.mjs +1 -1
  127. package/dist/runtime/server/routes/auth/otp/send.post.d.ts +1 -9
  128. package/dist/runtime/server/routes/auth/otp/send.post.mjs +8 -0
  129. package/dist/runtime/server/routes/auth/sso/login.get.mjs +3 -3
  130. package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +1 -1
  131. package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +2 -2
  132. package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
  133. package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +1 -1
  134. package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +2 -2
  135. package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +1 -1
  136. package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.mjs +1 -1
  137. package/dist/runtime/server/routes/cms/[collection]/atom.xml.get.mjs +3 -1
  138. package/dist/runtime/server/routes/cms/[collection]/feed.xml.get.mjs +3 -1
  139. package/dist/runtime/server/routes/cms/bookmarks/[id].delete.mjs +1 -1
  140. package/dist/runtime/server/routes/cms/bookmarks/check.post.mjs +1 -1
  141. package/dist/runtime/server/routes/cms/bookmarks/index.get.mjs +1 -1
  142. package/dist/runtime/server/routes/cms/bookmarks/index.post.mjs +1 -1
  143. package/dist/runtime/server/routes/cms/deploy.post.mjs +1 -1
  144. package/dist/runtime/server/routes/cms/export.post.mjs +4 -3
  145. package/dist/runtime/server/routes/cms/search.get.mjs +7 -5
  146. package/dist/runtime/server/routes/cms/sync.post.mjs +2 -1
  147. package/dist/runtime/server/routes/comments/[id]/react.post.mjs +1 -2
  148. package/dist/runtime/server/routes/comments/[id]/report.post.d.ts +1 -1
  149. package/dist/runtime/server/routes/comments/[id]/report.post.mjs +0 -2
  150. package/dist/runtime/server/routes/comments/[id].delete.mjs +8 -4
  151. package/dist/runtime/server/routes/comments/[id].get.d.ts +1 -1
  152. package/dist/runtime/server/routes/comments/[id].get.mjs +1 -2
  153. package/dist/runtime/server/routes/comments/[id].patch.d.ts +1 -1
  154. package/dist/runtime/server/routes/comments/[id].patch.mjs +6 -3
  155. package/dist/runtime/server/routes/comments/batch.post.d.ts +2 -0
  156. package/dist/runtime/server/routes/comments/batch.post.mjs +33 -0
  157. package/dist/runtime/server/routes/comments/index.get.d.ts +1 -1
  158. package/dist/runtime/server/routes/comments/index.get.mjs +6 -4
  159. package/dist/runtime/server/routes/comments/index.post.d.ts +1 -1
  160. package/dist/runtime/server/routes/comments/index.post.mjs +6 -2
  161. package/dist/runtime/server/routes/feed.xml.get.mjs +3 -1
  162. package/dist/runtime/server/routes/sitemap.xml.get.mjs +3 -1
  163. package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +17 -0
  164. package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +29 -0
  165. package/dist/runtime/server/routes/store/cart/index.delete.d.ts +6 -0
  166. package/dist/runtime/server/routes/store/cart/index.delete.mjs +11 -0
  167. package/dist/runtime/server/routes/store/cart/index.get.d.ts +5 -0
  168. package/dist/runtime/server/routes/store/cart/index.get.mjs +14 -0
  169. package/dist/runtime/server/routes/store/cart/items/[id].delete.d.ts +6 -0
  170. package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +25 -0
  171. package/dist/runtime/server/routes/store/cart/items/[id].patch.d.ts +6 -0
  172. package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +29 -0
  173. package/dist/runtime/server/routes/store/cart/items.post.d.ts +6 -0
  174. package/dist/runtime/server/routes/store/cart/items.post.mjs +36 -0
  175. package/dist/runtime/server/routes/store/categories/index.get.d.ts +2 -0
  176. package/dist/runtime/server/routes/store/categories/index.get.mjs +8 -0
  177. package/dist/runtime/server/routes/store/checkout.post.d.ts +6 -0
  178. package/dist/runtime/server/routes/store/checkout.post.mjs +21 -0
  179. package/dist/runtime/server/routes/store/coupons/apply.post.d.ts +7 -0
  180. package/dist/runtime/server/routes/store/coupons/apply.post.mjs +18 -0
  181. package/dist/runtime/server/routes/store/currencies.get.d.ts +15 -0
  182. package/dist/runtime/server/routes/store/currencies.get.mjs +13 -0
  183. package/dist/runtime/server/routes/store/orders/[id].get.d.ts +2 -0
  184. package/dist/runtime/server/routes/store/orders/[id].get.mjs +26 -0
  185. package/dist/runtime/server/routes/store/orders/download/[token].get.d.ts +7 -0
  186. package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +57 -0
  187. package/dist/runtime/server/routes/store/orders/index.get.d.ts +5 -0
  188. package/dist/runtime/server/routes/store/orders/index.get.mjs +30 -0
  189. package/dist/runtime/server/routes/store/products/[slug].get.d.ts +2 -0
  190. package/dist/runtime/server/routes/store/products/[slug].get.mjs +18 -0
  191. package/dist/runtime/server/routes/store/products/index.get.d.ts +5 -0
  192. package/dist/runtime/server/routes/store/products/index.get.mjs +33 -0
  193. package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +9 -0
  194. package/dist/runtime/server/routes/store/tax/calculate.post.mjs +18 -0
  195. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +14 -1
  196. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +14 -1
  197. package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +24 -1
  198. package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +6 -0
  199. package/dist/runtime/server/utils/ai.d.ts +146 -21
  200. package/dist/runtime/server/utils/ai.mjs +406 -11
  201. package/dist/runtime/server/utils/analytics-query.d.ts +13 -58
  202. package/dist/runtime/server/utils/audit.d.ts +5 -4
  203. package/dist/runtime/server/utils/audit.mjs +25 -14
  204. package/dist/runtime/server/utils/auth.d.ts +29 -12
  205. package/dist/runtime/server/utils/auth.mjs +88 -70
  206. package/dist/runtime/server/utils/bots.d.ts +20 -4
  207. package/dist/runtime/server/utils/bots.mjs +7 -3
  208. package/dist/runtime/server/utils/browser-utils.d.ts +23 -23
  209. package/dist/runtime/server/utils/cache.d.ts +3 -3
  210. package/dist/runtime/server/utils/cms/collections.d.ts +23 -0
  211. package/dist/runtime/server/utils/cms/collections.mjs +143 -0
  212. package/dist/runtime/server/utils/cms/common.d.ts +9 -0
  213. package/dist/runtime/server/utils/cms/common.mjs +28 -0
  214. package/dist/runtime/server/utils/cms/git.mjs +2 -2
  215. package/dist/runtime/server/utils/cms/navigation.d.ts +46 -0
  216. package/dist/runtime/server/utils/cms/navigation.mjs +683 -0
  217. package/dist/runtime/server/utils/cms/preview.d.ts +11 -0
  218. package/dist/runtime/server/utils/cms/preview.mjs +50 -0
  219. package/dist/runtime/server/utils/cms/search.d.ts +1 -1
  220. package/dist/runtime/server/utils/cms/search.mjs +11 -7
  221. package/dist/runtime/server/utils/cms/sync.d.ts +34 -0
  222. package/dist/runtime/server/utils/cms/sync.mjs +1082 -0
  223. package/dist/runtime/server/utils/cms/taxonomy.d.ts +103 -0
  224. package/dist/runtime/server/utils/cms/taxonomy.mjs +348 -0
  225. package/dist/runtime/server/utils/cms.d.ts +13 -249
  226. package/dist/runtime/server/utils/cms.mjs +108 -2350
  227. package/dist/runtime/server/utils/comments-filter.d.ts +45 -0
  228. package/dist/runtime/server/utils/comments-filter.mjs +541 -0
  229. package/dist/runtime/server/utils/comments.d.ts +71 -0
  230. package/dist/runtime/server/utils/comments.mjs +137 -61
  231. package/dist/runtime/server/utils/config.d.ts +4 -3
  232. package/dist/runtime/server/utils/config.mjs +7 -6
  233. package/dist/runtime/server/utils/context.d.ts +14 -0
  234. package/dist/runtime/server/utils/context.mjs +2 -2
  235. package/dist/runtime/server/utils/crypto.d.ts +44 -5
  236. package/dist/runtime/server/utils/crypto.mjs +18 -0
  237. package/dist/runtime/server/utils/domains.mjs +9 -5
  238. package/dist/runtime/server/utils/drizzle.d.ts +35 -3
  239. package/dist/runtime/server/utils/drizzle.mjs +115 -6
  240. package/dist/runtime/server/utils/durable-object.d.ts +106 -0
  241. package/dist/runtime/server/utils/durable-object.mjs +628 -0
  242. package/dist/runtime/server/utils/email-inbound.d.ts +29 -0
  243. package/dist/runtime/server/utils/email-inbound.mjs +76 -0
  244. package/dist/runtime/server/utils/impersonation.d.ts +32 -2
  245. package/dist/runtime/server/utils/impersonation.mjs +16 -13
  246. package/dist/runtime/server/utils/lock.d.ts +71 -0
  247. package/dist/runtime/server/utils/lock.mjs +139 -0
  248. package/dist/runtime/server/utils/mail-suppression.mjs +7 -7
  249. package/dist/runtime/server/utils/mail.d.ts +30 -19
  250. package/dist/runtime/server/utils/mcp.d.ts +44 -0
  251. package/dist/runtime/server/utils/mcp.mjs +308 -0
  252. package/dist/runtime/server/utils/notifications.d.ts +72 -7
  253. package/dist/runtime/server/utils/notifications.mjs +67 -55
  254. package/dist/runtime/server/utils/oauth.d.ts +27 -4
  255. package/dist/runtime/server/utils/organization.d.ts +63 -7
  256. package/dist/runtime/server/utils/organization.mjs +26 -21
  257. package/dist/runtime/server/utils/passwordless.d.ts +62 -33
  258. package/dist/runtime/server/utils/payments.d.ts +51 -12
  259. package/dist/runtime/server/utils/payments.mjs +472 -282
  260. package/dist/runtime/server/utils/queue.d.ts +106 -13
  261. package/dist/runtime/server/utils/queue.mjs +313 -28
  262. package/dist/runtime/server/utils/rag.d.ts +42 -14
  263. package/dist/runtime/server/utils/rag.mjs +169 -4
  264. package/dist/runtime/server/utils/ratelimit.d.ts +34 -5
  265. package/dist/runtime/server/utils/ratelimit.mjs +95 -14
  266. package/dist/runtime/server/utils/realtime.d.ts +68 -52
  267. package/dist/runtime/server/utils/scheduled-task.d.ts +42 -1
  268. package/dist/runtime/server/utils/scheduled-task.mjs +29 -0
  269. package/dist/runtime/server/utils/schema-fallback.d.ts +1 -1
  270. package/dist/runtime/server/utils/schema-fallback.mjs +1 -1
  271. package/dist/runtime/server/utils/session.d.ts +84 -10
  272. package/dist/runtime/server/utils/session.mjs +12 -10
  273. package/dist/runtime/server/utils/sse.d.ts +75 -0
  274. package/dist/runtime/server/utils/sse.mjs +147 -0
  275. package/dist/runtime/server/utils/sso.d.ts +1 -1
  276. package/dist/runtime/server/utils/storage.d.ts +53 -4
  277. package/dist/runtime/server/utils/storage.mjs +15 -11
  278. package/dist/runtime/server/utils/store-localization.d.ts +51 -0
  279. package/dist/runtime/server/utils/store-localization.mjs +417 -0
  280. package/dist/runtime/server/utils/store.d.ts +207 -0
  281. package/dist/runtime/server/utils/store.mjs +2227 -0
  282. package/dist/runtime/server/utils/table-names.d.ts +51 -0
  283. package/dist/runtime/server/utils/table-names.mjs +69 -0
  284. package/dist/runtime/server/utils/tenant.d.ts +26 -2
  285. package/dist/runtime/server/utils/tenant.mjs +16 -12
  286. package/dist/runtime/server/utils/tools-registry-fallback.d.ts +1 -0
  287. package/dist/runtime/server/utils/tools-registry-fallback.mjs +1 -0
  288. package/dist/runtime/server/utils/totp.d.ts +45 -2
  289. package/dist/runtime/server/utils/tracker.d.ts +10 -11
  290. package/dist/runtime/server/utils/turnstile.d.ts +16 -1
  291. package/dist/runtime/server/utils/workflows.d.ts +92 -0
  292. package/dist/runtime/server/utils/workflows.mjs +299 -0
  293. package/dist/runtime/server.d.ts +8 -1
  294. package/dist/runtime/server.mjs +8 -5
  295. package/dist/runtime/service.d.ts +10 -10
  296. package/dist/runtime/storage.d.ts +1 -0
  297. package/dist/runtime/storage.mjs +1 -0
  298. package/dist/runtime/store.d.ts +4 -0
  299. package/dist/runtime/store.mjs +2 -0
  300. package/dist/runtime/test-utils.d.ts +11 -10
  301. package/dist/runtime/test-utils.mjs +64 -4
  302. package/dist/runtime/types/ai.d.ts +21 -2
  303. package/dist/runtime/types/d1.d.ts +17 -0
  304. package/dist/runtime/types/drizzle.d.ts +2 -2
  305. package/dist/runtime/types/durable-object.d.ts +62 -2
  306. package/dist/runtime/types/email.d.ts +46 -0
  307. package/dist/runtime/types/imports.d.ts +6 -1
  308. package/dist/runtime/types/index.d.ts +58 -0
  309. package/dist/runtime/types/index.mjs +3 -0
  310. package/dist/runtime/types/mcp.d.ts +83 -0
  311. package/dist/runtime/types/mcp.mjs +0 -0
  312. package/dist/runtime/types/queue.d.ts +36 -0
  313. package/dist/runtime/types/r2.d.ts +41 -0
  314. package/dist/runtime/types/store.d.ts +313 -0
  315. package/dist/runtime/types/store.mjs +0 -0
  316. package/dist/runtime/types/workflows.d.ts +98 -0
  317. package/dist/runtime/types/workflows.mjs +0 -0
  318. package/dist/runtime/workflows.d.ts +5 -0
  319. package/dist/runtime/workflows.mjs +2 -0
  320. package/dist/types/ai.d.ts +721 -0
  321. package/dist/types/cms.d.ts +710 -0
  322. package/dist/types.d.ts +406 -1288
  323. package/dist/utils/auth-schema.d.ts +3 -2
  324. package/dist/utils/bots.d.ts +20 -0
  325. package/dist/utils/comments-schema.d.ts +5 -4
  326. package/dist/utils/drizzle.d.ts +83 -3
  327. package/dist/utils/durable-objects.d.ts +10 -0
  328. package/dist/utils/email-inbound.d.ts +10 -0
  329. package/dist/utils/local-db.d.ts +1 -3
  330. package/dist/utils/mcp.d.ts +24 -0
  331. package/dist/utils/notifications-schema.d.ts +5 -4
  332. package/dist/utils/payments-schema.d.ts +4 -3
  333. package/dist/utils/store-schema.d.ts +14 -0
  334. package/dist/utils/table-names.d.ts +1 -0
  335. package/dist/utils/tenants-schema.d.ts +4 -3
  336. package/dist/utils/tools.d.ts +20 -0
  337. package/dist/utils/workflows.d.ts +8 -0
  338. package/package.json +34 -4
  339. package/dist/chunks/wrangler.mjs +0 -897
  340. package/dist/runtime/app/components/AuthRegister.vue +0 -306
  341. package/dist/runtime/app/components/AuthSessionsList.vue +0 -137
  342. package/dist/runtime/app/components/AuthSignIn.vue +0 -298
  343. package/dist/runtime/app/components/CMSBookmarkButton.vue +0 -59
  344. package/dist/runtime/app/components/CMSImage.vue +0 -47
  345. package/dist/runtime/app/components/CMSLocaleSwitcher.vue +0 -110
  346. package/dist/runtime/app/components/CMSNewsletter.vue +0 -81
  347. package/dist/runtime/app/components/CMSPreviewBanner.vue +0 -83
  348. package/dist/runtime/app/components/CMSTableOfContents.vue +0 -84
  349. package/dist/runtime/app/components/CMSVersionBanner.vue +0 -53
  350. package/dist/runtime/app/components/CMSVersionSwitcher.vue +0 -140
  351. package/dist/runtime/app/components/Comments.vue +0 -411
  352. package/dist/runtime/app/components/FileUpload.vue +0 -200
  353. package/dist/runtime/app/components/ImpersonationBanner.vue +0 -61
  354. package/dist/runtime/app/components/NotificationBell.vue +0 -263
  355. package/dist/runtime/app/components/NotificationList.vue +0 -205
  356. package/dist/runtime/app/components/NotificationPrompt.vue +0 -133
  357. package/dist/runtime/app/components/PricingGated.vue +0 -81
  358. package/dist/runtime/app/components/PricingTable.vue +0 -274
  359. package/dist/runtime/app/components/RealtimeChat.vue +0 -164
  360. package/dist/runtime/app/components/RealtimePresence.vue +0 -129
  361. package/dist/runtime/app/components/RealtimeStatus.vue +0 -79
  362. package/dist/runtime/app/components/SubscriptionCard.vue +0 -207
  363. package/dist/runtime/app/components/UserProfile.vue +0 -558
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
- import { f as findSchemaFiles, r as resolveBinaryPath, e as ensurePackage, g as getLocalDatabaseContext, a as getJiti, s as spawnBinSync, b as resolveProjectName, c as checkDrizzleVersion, d as findLocalD1Database, v as version } from '../chunks/wrangler.mjs';
3
+ import { r as resolveDatabaseTarget, a as resolveBinaryPath, e as ensurePackage, g as getLocalDatabaseContext, d as discoverDatabases, b as getJiti, s as spawnBinSync, c as resolveProjectName, f as checkDrizzleVersion, h as findSchemaFiles, i as findLocalD1Database, j as findAgentFiles, k as findToolFiles, l as findBotFiles, m as findMcpFiles, n as findJobFiles, o as findWorkflowFiles, p as findEmailHandlerFiles, v as version } from '../chunks/tools.mjs';
4
4
  import { spawnSync, spawn } from 'node:child_process';
5
- import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, statSync } from 'node:fs';
5
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, statSync, readdirSync } from 'node:fs';
6
6
  import { loadNuxtConfig } from '@nuxt/kit';
7
- import { resolve, join, extname } from 'pathe';
7
+ import { resolve, join, relative, basename, extname } from 'pathe';
8
8
  import { reset, seed } from 'drizzle-seed';
9
9
  import { stdin, stdout } from 'node:process';
10
10
  import readline from 'node:readline/promises';
@@ -21,6 +21,10 @@ const generate = defineCommand({
21
21
  description: "Generate SQL migrations from your Drizzle database schema"
22
22
  },
23
23
  args: {
24
+ db: {
25
+ type: "string",
26
+ description: "Target database name (e.g. --db analytics) or omit for primary DB"
27
+ },
24
28
  name: {
25
29
  type: "string",
26
30
  description: "Migration file name (e.g. --name add_users)"
@@ -38,32 +42,48 @@ const generate = defineCommand({
38
42
  },
39
43
  async run({ args }) {
40
44
  const cwd = resolve(process.cwd(), args.cwd);
41
- console.log("\u26A1 [qarpeo] Preparing database schema for migration generation...");
42
45
  const nuxtConfig = await loadNuxtConfig({ cwd });
46
+ const qarpeoOpts = nuxtConfig.qarpeo || {};
43
47
  const layers = nuxtConfig._layers || [{ cwd, config: nuxtConfig }];
44
- const schemaFiles = findSchemaFiles(layers);
48
+ let target;
49
+ try {
50
+ target = resolveDatabaseTarget(layers, args.db, qarpeoOpts);
51
+ } catch (err) {
52
+ console.error(`\u274C [qarpeo] ${err.message}`);
53
+ process.exit(1);
54
+ }
55
+ console.log(
56
+ `\u26A1 [qarpeo] Preparing database schema for "${target.name}" migration generation...`
57
+ );
58
+ const schemaFiles = target.schemaFiles;
45
59
  if (schemaFiles.length === 0) {
60
+ const targetHint = target.isPrimary ? "db/d1/schema/" : `db/${target.dirName}/schema/`;
46
61
  console.error(
47
- "\u274C [qarpeo] No database schema files found. Create a schema file at server/db/schema.ts first."
62
+ `\u274C [qarpeo] No database schema files found for database "${target.name}". Create a schema file at ${targetHint} first.`
48
63
  );
49
64
  process.exit(1);
50
65
  }
51
66
  const qarpeoDir = resolve(cwd, ".qarpeo");
52
- const schemaPath = resolve(qarpeoDir, "schema.ts");
67
+ const schemaFileName = target.isPrimary ? "schema.ts" : `schema-${target.name}.ts`;
68
+ const schemaPath = resolve(qarpeoDir, schemaFileName);
53
69
  if (!existsSync(qarpeoDir)) {
54
70
  mkdirSync(qarpeoDir, { recursive: true });
55
71
  }
56
- const schemaLines = ["// Auto-generated by qarpeo across all Nuxt layers"];
57
- const nuxtDir = resolve(cwd, ".nuxt/qarpeo");
58
- const builtInSchemas = [
59
- { name: "auth", path: resolve(nuxtDir, "auth-schema.ts") },
60
- { name: "cms", path: resolve(nuxtDir, "cms-schema.ts") },
61
- { name: "payments", path: resolve(nuxtDir, "payments-schema.ts") },
62
- { name: "tenants", path: resolve(nuxtDir, "tenants-schema.ts") }
72
+ const schemaLines = [
73
+ `// Auto-generated by qarpeo across all Nuxt layers for database: ${target.name}`
63
74
  ];
64
- for (const s of builtInSchemas) {
65
- if (existsSync(s.path)) {
66
- schemaLines.push(`export * from "${s.path.replace(/\\/g, "/").replace(/\.ts$/, "")}";`);
75
+ if (target.isPrimary) {
76
+ const nuxtDir = resolve(cwd, ".nuxt/qarpeo");
77
+ const builtInSchemas = [
78
+ { name: "auth", path: resolve(nuxtDir, "auth-schema.ts") },
79
+ { name: "cms", path: resolve(nuxtDir, "cms-schema.ts") },
80
+ { name: "payments", path: resolve(nuxtDir, "payments-schema.ts") },
81
+ { name: "tenants", path: resolve(nuxtDir, "tenants-schema.ts") }
82
+ ];
83
+ for (const s of builtInSchemas) {
84
+ if (existsSync(s.path)) {
85
+ schemaLines.push(`export * from "${s.path.replace(/\\/g, "/").replace(/\.ts$/, "")}";`);
86
+ }
67
87
  }
68
88
  }
69
89
  for (const f of schemaFiles) {
@@ -71,19 +91,20 @@ const generate = defineCommand({
71
91
  }
72
92
  const schemaContent = schemaLines.join("\n");
73
93
  writeFileSync(schemaPath, schemaContent, "utf-8");
74
- const serverDir = nuxtConfig.serverDir || resolve(nuxtConfig.rootDir || cwd, "server");
75
- const migrationsDir = resolve(serverDir, "db/migrations");
94
+ const migrationsDir = target.migrationsDir;
76
95
  if (!existsSync(migrationsDir)) {
77
96
  mkdirSync(migrationsDir, { recursive: true });
78
97
  }
79
- console.log(`\u{1F4E6} [qarpeo] Discovered ${schemaFiles.length} schema file(s):`);
98
+ console.log(
99
+ `\u{1F4E6} [qarpeo] Discovered ${schemaFiles.length} schema file(s) for database "${target.name}":`
100
+ );
80
101
  for (const f of schemaFiles) {
81
102
  console.log(` - ${f}`);
82
103
  }
83
104
  const drizzleKitArgs = [
84
105
  "generate",
85
106
  "--dialect",
86
- "sqlite",
107
+ target.dialect,
87
108
  "--schema",
88
109
  schemaPath,
89
110
  "--out",
@@ -127,6 +148,10 @@ const cleanCommand = defineCommand({
127
148
  description: "Clean/truncate all tables in local Cloudflare D1 database (reset data)"
128
149
  },
129
150
  args: {
151
+ db: {
152
+ type: "string",
153
+ description: "Target database name (e.g. --db analytics) or omit for primary DB"
154
+ },
130
155
  remote: {
131
156
  type: "boolean",
132
157
  description: "Restricted \u2014 database cleaning is blocked on production to prevent data loss",
@@ -150,7 +175,7 @@ const cleanCommand = defineCommand({
150
175
  console.log("\u23F3 [qarpeo] Connecting to local D1 database...");
151
176
  let ctx;
152
177
  try {
153
- ctx = await getLocalDatabaseContext(cwd, nuxtConfig);
178
+ ctx = await getLocalDatabaseContext(cwd, nuxtConfig, args.db);
154
179
  } catch (err) {
155
180
  console.error(`\u274C [qarpeo] ${err?.message || err}`);
156
181
  process.exit(1);
@@ -169,10 +194,10 @@ const cleanCommand = defineCommand({
169
194
  }
170
195
  });
171
196
 
172
- function getWranglerBin$6(cwd) {
197
+ function getWranglerBin$8(cwd) {
173
198
  return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
174
199
  }
175
- function loadDotEnv$7(cwd) {
200
+ function loadDotEnv$9(cwd) {
176
201
  const envPath = join(cwd, ".env");
177
202
  if (!existsSync(envPath)) return;
178
203
  try {
@@ -217,7 +242,7 @@ const create = defineCommand({
217
242
  },
218
243
  async run({ args }) {
219
244
  const cwd = resolve(process.cwd(), args.cwd);
220
- loadDotEnv$7(cwd);
245
+ loadDotEnv$9(cwd);
221
246
  let dbName = args.name;
222
247
  if (!dbName && stdin.isTTY) {
223
248
  const rl = readline.createInterface({ input: stdin, output: stdout });
@@ -235,7 +260,7 @@ const create = defineCommand({
235
260
  cwd,
236
261
  purpose: "creating Cloudflare D1 database"
237
262
  });
238
- const wrangler = getWranglerBin$6(cwd);
263
+ const wrangler = getWranglerBin$8(cwd);
239
264
  console.log(`
240
265
  \u26A1 [qarpeo] Creating D1 database "${dbName}" on Cloudflare...
241
266
  `);
@@ -261,10 +286,10 @@ const create = defineCommand({
261
286
  }
262
287
  });
263
288
 
264
- function getWranglerBin$5(cwd) {
289
+ function getWranglerBin$7(cwd) {
265
290
  return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
266
291
  }
267
- function loadDotEnv$6(cwd) {
292
+ function loadDotEnv$8(cwd) {
268
293
  const envPath = join(cwd, ".env");
269
294
  if (!existsSync(envPath)) return;
270
295
  try {
@@ -311,7 +336,7 @@ const deleteDb = defineCommand({
311
336
  },
312
337
  async run({ args }) {
313
338
  const cwd = resolve(process.cwd(), args.cwd);
314
- loadDotEnv$6(cwd);
339
+ loadDotEnv$8(cwd);
315
340
  let dbName = args.name;
316
341
  if (!dbName && stdin.isTTY) {
317
342
  const rl = readline.createInterface({ input: stdin, output: stdout });
@@ -341,7 +366,7 @@ const deleteDb = defineCommand({
341
366
  cwd,
342
367
  purpose: "deleting Cloudflare D1 database"
343
368
  });
344
- const wrangler = getWranglerBin$5(cwd);
369
+ const wrangler = getWranglerBin$7(cwd);
345
370
  console.log(`
346
371
  \u{1F5D1}\uFE0F [qarpeo] Deleting D1 database "${dbName}" on Cloudflare...
347
372
  `);
@@ -366,10 +391,10 @@ const deleteDb = defineCommand({
366
391
  }
367
392
  });
368
393
 
369
- function getWranglerBin$4(cwd) {
394
+ function getWranglerBin$6(cwd) {
370
395
  return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
371
396
  }
372
- function loadDotEnv$5(cwd) {
397
+ function loadDotEnv$7(cwd) {
373
398
  const envPath = join(cwd, ".env");
374
399
  if (!existsSync(envPath)) return;
375
400
  try {
@@ -391,7 +416,7 @@ function loadDotEnv$5(cwd) {
391
416
  } catch {
392
417
  }
393
418
  }
394
- const list = defineCommand({
419
+ const list$2 = defineCommand({
395
420
  meta: {
396
421
  name: "list",
397
422
  description: "List all Cloudflare D1 databases in your account with their UUIDs"
@@ -410,12 +435,12 @@ const list = defineCommand({
410
435
  },
411
436
  async run({ args }) {
412
437
  const cwd = resolve(process.cwd(), args.cwd);
413
- loadDotEnv$5(cwd);
438
+ loadDotEnv$7(cwd);
414
439
  await ensurePackage("wrangler", {
415
440
  cwd,
416
441
  purpose: "listing Cloudflare D1 databases"
417
442
  });
418
- const wrangler = getWranglerBin$4(cwd);
443
+ const wrangler = getWranglerBin$6(cwd);
419
444
  console.log("\u{1F50D} [qarpeo] Fetching D1 databases from Cloudflare...\n");
420
445
  const wranglerArgs = ["d1", "list"];
421
446
  if (args.json) {
@@ -447,6 +472,15 @@ const migrate = defineCommand({
447
472
  description: "Apply database migrations to Cloudflare D1 (local or remote)"
448
473
  },
449
474
  args: {
475
+ db: {
476
+ type: "string",
477
+ description: "Target database name (e.g. --db analytics) or omit for primary DB"
478
+ },
479
+ all: {
480
+ type: "boolean",
481
+ description: "Apply migrations to all discovered databases in sequence",
482
+ default: false
483
+ },
450
484
  remote: {
451
485
  type: "boolean",
452
486
  description: "Apply migrations to remote Cloudflare D1 database (production)",
@@ -464,7 +498,7 @@ const migrate = defineCommand({
464
498
  },
465
499
  prune: {
466
500
  type: "boolean",
467
- description: "Safely drop deprecated _qarpeo_* auth tables when corresponding features are disabled in nuxt.config.ts",
501
+ description: "Safely drop unused auth tables when corresponding features are disabled in nuxt.config.ts",
468
502
  default: false
469
503
  },
470
504
  cwd: {
@@ -477,18 +511,7 @@ const migrate = defineCommand({
477
511
  const cwd = resolve(process.cwd(), args.cwd);
478
512
  const nuxtConfig = await loadNuxtConfig({ cwd });
479
513
  const qarpeoOpts = nuxtConfig.qarpeo || {};
480
- const dbOpts = typeof qarpeoOpts.db === "object" ? qarpeoOpts.db : {};
481
- const dbBinding = dbOpts.binding || process.env.QARPEO_DB_BINDING || "DB";
482
- const dbName = dbBinding;
483
- if (args.dryRun) {
484
- console.log(
485
- `\u{1F50D} [qarpeo] Dry-run preview for Cloudflare D1 migrations (${args.remote ? "remote" : "local dev"})...`
486
- );
487
- } else {
488
- console.log(
489
- `\u26A1 [qarpeo] Applying migrations to Cloudflare D1 (${args.remote ? "remote" : "local dev"})...`
490
- );
491
- }
514
+ const layers = nuxtConfig._layers || [{ cwd, config: nuxtConfig }];
492
515
  let execPath = resolveBinaryPath("wrangler", cwd);
493
516
  if (!execPath) {
494
517
  const ok = await ensurePackage("wrangler", {
@@ -509,7 +532,7 @@ const migrate = defineCommand({
509
532
  } else if (existsSync(resolve(cwd, ".nuxt/wrangler.json"))) {
510
533
  wranglerConfigPath = resolve(cwd, ".nuxt/wrangler.json");
511
534
  } else {
512
- const { generateDevWranglerConfig } = await import('../chunks/wrangler.mjs').then(function (n) { return n.w; });
535
+ const { generateDevWranglerConfig } = await import('../chunks/tools.mjs').then(function (n) { return n.E; });
513
536
  const buildDir = resolve(cwd, ".nuxt");
514
537
  wranglerConfigPath = await generateDevWranglerConfig(
515
538
  {
@@ -525,66 +548,109 @@ const migrate = defineCommand({
525
548
  }
526
549
  );
527
550
  }
528
- if (args.backup && args.remote && !args.dryRun) {
529
- console.log(
530
- `\u{1F6E1}\uFE0F [qarpeo] Creating automatic snapshot backup of remote D1 database "${dbName}"...`
531
- );
532
- const backupArgs = ["d1", "backup", "create", dbName];
533
- if (wranglerConfigPath) backupArgs.push("-c", wranglerConfigPath);
534
- const backupRes = spawnSync(execPath, backupArgs, {
551
+ let targets = [];
552
+ if (args.all) {
553
+ const allDbs = discoverDatabases(layers, qarpeoOpts);
554
+ targets = allDbs.filter((d) => d.dialect === "sqlite");
555
+ if (targets.length === 0) {
556
+ console.error("\u274C [qarpeo] No D1 databases found to migrate.");
557
+ process.exit(1);
558
+ }
559
+ } else {
560
+ try {
561
+ const single = resolveDatabaseTarget(layers, args.db, qarpeoOpts);
562
+ targets = [single];
563
+ } catch (err) {
564
+ console.error(`\u274C [qarpeo] ${err.message}`);
565
+ process.exit(1);
566
+ }
567
+ }
568
+ for (let i = 0; i < targets.length; i++) {
569
+ const target = targets[i];
570
+ const dbName = target.binding;
571
+ if (targets.length > 1) {
572
+ console.log(
573
+ `
574
+ \u{1F4E6} [qarpeo] (${i + 1}/${targets.length}) Database "${target.name}" [${dbName}]...`
575
+ );
576
+ }
577
+ if (args.dryRun) {
578
+ console.log(
579
+ `\u{1F50D} [qarpeo] Dry-run preview for D1 database "${dbName}" (${args.remote ? "remote" : "local dev"})...`
580
+ );
581
+ } else {
582
+ console.log(
583
+ `\u26A1 [qarpeo] Applying migrations to D1 database "${dbName}" (${args.remote ? "remote" : "local dev"})...`
584
+ );
585
+ }
586
+ if (args.backup && args.remote && !args.dryRun) {
587
+ console.log(
588
+ `\u{1F6E1}\uFE0F [qarpeo] Creating automatic snapshot backup of remote D1 database "${dbName}"...`
589
+ );
590
+ const backupArgs = ["d1", "backup", "create", dbName];
591
+ if (wranglerConfigPath) backupArgs.push("-c", wranglerConfigPath);
592
+ const backupRes = spawnSync(execPath, backupArgs, {
593
+ cwd,
594
+ stdio: "inherit",
595
+ shell: process.platform === "win32"
596
+ });
597
+ if (backupRes.status === 0) {
598
+ console.log(`\u2705 [qarpeo] Backup created successfully prior to migration.`);
599
+ } else {
600
+ console.warn(
601
+ `\u26A0\uFE0F [qarpeo] Backup command exited with code ${backupRes.status}. Continuing...`
602
+ );
603
+ }
604
+ }
605
+ const wranglerArgs = ["d1", "migrations", "apply", dbName];
606
+ if (wranglerConfigPath) {
607
+ wranglerArgs.push("-c", wranglerConfigPath);
608
+ }
609
+ if (args.dryRun) {
610
+ wranglerArgs.push("--dry-run");
611
+ }
612
+ if (args.remote) {
613
+ wranglerArgs.push("--remote");
614
+ } else {
615
+ wranglerArgs.push("--local", "--persist-to", resolve(cwd, ".wrangler/state"));
616
+ }
617
+ console.log(`\u{1F680} [qarpeo] Running: wrangler ${wranglerArgs.join(" ")}`);
618
+ const result = spawnSync(execPath, wranglerArgs, {
535
619
  cwd,
536
620
  stdio: "inherit",
537
621
  shell: process.platform === "win32"
622
+ // .cmd files require shell:true on Windows
538
623
  });
539
- if (backupRes.status === 0) {
540
- console.log(`\u2705 [qarpeo] Backup created successfully prior to migration.`);
541
- } else {
542
- console.warn(
543
- `\u26A0\uFE0F [qarpeo] Backup command exited with code ${backupRes.status}. Continuing...`
544
- );
624
+ if (result.status !== 0) {
625
+ console.error(`\u274C [qarpeo] Migration failed for database "${dbName}".`);
626
+ process.exit(result.status ?? 1);
545
627
  }
628
+ console.log(`\u2705 [qarpeo] Migrations for "${dbName}" applied successfully!`);
546
629
  }
547
- const wranglerArgs = ["d1", "migrations", "apply", dbName];
548
- if (wranglerConfigPath) {
549
- wranglerArgs.push("-c", wranglerConfigPath);
550
- }
551
- if (args.dryRun) {
552
- wranglerArgs.push("--dry-run");
553
- }
554
- if (args.remote) {
555
- wranglerArgs.push("--remote");
556
- } else {
557
- wranglerArgs.push("--local", "--persist-to", resolve(cwd, ".wrangler/state"));
558
- }
559
- console.log(`\u{1F680} [qarpeo] Running: wrangler ${wranglerArgs.join(" ")}`);
560
- const result = spawnSync(execPath, wranglerArgs, {
561
- cwd,
562
- stdio: "inherit",
563
- shell: process.platform === "win32"
564
- // .cmd files require shell:true on Windows
565
- });
566
- if (result.status !== 0) {
567
- process.exit(result.status ?? 1);
630
+ if (targets.length > 1) {
631
+ console.log(`
632
+ \u{1F389} [qarpeo] All ${targets.length} database(s) migrated successfully!`);
568
633
  }
569
- console.log(`\u2705 [qarpeo] Migrations applied successfully!`);
570
- if (args.prune) {
571
- const { getActiveAuthTableNames, ALL_AUTH_TABLE_NAMES } = await import('../chunks/auth-schema.mjs');
572
- const { findLocalD1Database } = await import('../chunks/wrangler.mjs').then(function (n) { return n.p; });
634
+ if (args.prune && targets.some((t) => t.isPrimary)) {
635
+ const primaryTarget = targets.find((t) => t.isPrimary);
636
+ const primaryBinding = primaryTarget.binding;
637
+ const { getActiveAuthTableNames, ALL_AUTH_TABLE_NAMES } = await import('../chunks/auth-schema.mjs').then(function (n) { return n.c; });
638
+ const { findLocalD1Database } = await import('../chunks/tools.mjs').then(function (n) { return n.D; });
573
639
  const authConfig = nuxtConfig.qarpeo?.auth || nuxtConfig.auth;
574
640
  const activeTables = getActiveAuthTableNames(authConfig);
575
- const deprecatedTables = ALL_AUTH_TABLE_NAMES.filter(
641
+ const unusedTables = ALL_AUTH_TABLE_NAMES.filter(
576
642
  (tbl) => !activeTables.includes(tbl)
577
643
  );
578
- if (deprecatedTables.length > 0) {
644
+ if (unusedTables.length > 0) {
579
645
  console.log(`
580
- \u{1F9F9} [qarpeo] Checking for deprecated auth tables to prune...`);
646
+ \u{1F9F9} [qarpeo] Checking for unused auth tables to prune...`);
581
647
  if (!args.remote) {
582
648
  const sqlitePath = findLocalD1Database(cwd);
583
649
  if (sqlitePath) {
584
650
  try {
585
651
  const { DatabaseSync } = await import('node:sqlite');
586
652
  const sqlite = new DatabaseSync(sqlitePath);
587
- for (const tbl of deprecatedTables) {
653
+ for (const tbl of unusedTables) {
588
654
  try {
589
655
  sqlite.exec(`DROP TABLE IF EXISTS ${tbl};`);
590
656
  console.log(` \u2713 Dropped table: ${tbl}`);
@@ -598,11 +664,11 @@ const migrate = defineCommand({
598
664
  }
599
665
  }
600
666
  } else {
601
- for (const tbl of deprecatedTables) {
667
+ for (const tbl of unusedTables) {
602
668
  const dropArgs = [
603
669
  "d1",
604
670
  "execute",
605
- dbName,
671
+ primaryBinding,
606
672
  "--remote",
607
673
  `--command=DROP TABLE IF EXISTS ${tbl};`
608
674
  ];
@@ -629,6 +695,10 @@ const push = defineCommand({
629
695
  description: "Directly push schema changes to local D1 SQLite database (prototyping)"
630
696
  },
631
697
  args: {
698
+ db: {
699
+ type: "string",
700
+ description: "Target database name (e.g. --db analytics) or omit for primary DB"
701
+ },
632
702
  force: {
633
703
  type: "boolean",
634
704
  description: "Auto-approve all statements",
@@ -642,21 +712,33 @@ const push = defineCommand({
642
712
  },
643
713
  async run({ args }) {
644
714
  const cwd = resolve(process.cwd(), args.cwd);
645
- console.log("\u26A1 [qarpeo] Preparing database schema for push...");
646
715
  const nuxtConfig = await loadNuxtConfig({ cwd });
716
+ const qarpeoOpts = nuxtConfig.qarpeo || {};
647
717
  const layers = nuxtConfig._layers || [{ cwd, config: nuxtConfig }];
648
- const schemaFiles = findSchemaFiles(layers);
718
+ let target;
719
+ try {
720
+ target = resolveDatabaseTarget(layers, args.db, qarpeoOpts);
721
+ } catch (err) {
722
+ console.error(`\u274C [qarpeo] ${err.message}`);
723
+ process.exit(1);
724
+ }
725
+ console.log(`\u26A1 [qarpeo] Preparing database schema for "${target.name}" push...`);
726
+ const schemaFiles = target.schemaFiles;
649
727
  if (schemaFiles.length === 0) {
650
- console.error("\u274C [qarpeo] No schema files found in server/db/schema.ts");
728
+ const targetHint = target.isPrimary ? "db/d1/schema/" : `db/${target.dirName}/schema/`;
729
+ console.error(
730
+ `\u274C [qarpeo] No schema files found for database "${target.name}". Create a schema file at ${targetHint} first.`
731
+ );
651
732
  process.exit(1);
652
733
  }
653
734
  const qarpeoDir = resolve(cwd, ".qarpeo");
654
- const schemaPath = resolve(qarpeoDir, "schema.ts");
735
+ const schemaFileName = target.isPrimary ? "schema.ts" : `schema-${target.name}.ts`;
736
+ const schemaPath = resolve(qarpeoDir, schemaFileName);
655
737
  if (!existsSync(qarpeoDir)) {
656
738
  mkdirSync(qarpeoDir, { recursive: true });
657
739
  }
658
740
  const schemaContent = [
659
- "// Auto-generated by qarpeo across all Nuxt layers",
741
+ `// Auto-generated by qarpeo across all Nuxt layers for database: ${target.name}`,
660
742
  ...schemaFiles.map((f) => `export * from "${f.replace(/\\/g, "/").replace(/\.ts$/, "")}";`)
661
743
  ].join("\n");
662
744
  writeFileSync(schemaPath, schemaContent, "utf-8");
@@ -672,11 +754,11 @@ const push = defineCommand({
672
754
  }
673
755
  execPath = resolveBinaryPath("drizzle-kit", cwd) || (process.platform === "win32" ? "drizzle-kit.cmd" : "drizzle-kit");
674
756
  }
675
- const drizzleArgs = ["push", "--dialect", "sqlite", "--schema", schemaPath];
757
+ const drizzleArgs = ["push", "--dialect", target.dialect, "--schema", schemaPath];
676
758
  if (args.force) {
677
759
  drizzleArgs.push("--force");
678
760
  }
679
- console.log("\u{1F680} [qarpeo] Running drizzle-kit push...");
761
+ console.log(`\u{1F680} [qarpeo] Running drizzle-kit push for "${target.name}"...`);
680
762
  const result = spawnSync(execPath, drizzleArgs, {
681
763
  cwd,
682
764
  stdio: "inherit",
@@ -686,14 +768,14 @@ const push = defineCommand({
686
768
  if (result.status !== 0) {
687
769
  process.exit(result.status ?? 1);
688
770
  }
689
- console.log("\u2705 [qarpeo] Schema push completed!");
771
+ console.log(`\u2705 [qarpeo] Schema push completed for "${target.name}"!`);
690
772
  }
691
773
  });
692
774
 
693
- function getWranglerBin$3(cwd) {
775
+ function getWranglerBin$5(cwd) {
694
776
  return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
695
777
  }
696
- function loadDotEnv$4(cwd) {
778
+ function loadDotEnv$6(cwd) {
697
779
  const envPath = join(cwd, ".env");
698
780
  if (!existsSync(envPath)) return;
699
781
  try {
@@ -738,7 +820,7 @@ const rollback = defineCommand({
738
820
  },
739
821
  async run({ args }) {
740
822
  const cwd = resolve(process.cwd(), args.cwd);
741
- loadDotEnv$4(cwd);
823
+ loadDotEnv$6(cwd);
742
824
  const nuxtConfig = await loadNuxtConfig({ cwd }).catch(() => ({}));
743
825
  const qarpeoOpts = nuxtConfig?.qarpeo || {};
744
826
  const dbOpts = typeof qarpeoOpts.db === "object" ? qarpeoOpts.db : {};
@@ -747,7 +829,7 @@ const rollback = defineCommand({
747
829
  cwd,
748
830
  purpose: "restoring Cloudflare D1 backup"
749
831
  });
750
- const wrangler = getWranglerBin$3(cwd);
832
+ const wrangler = getWranglerBin$5(cwd);
751
833
  let wranglerConfigPath = null;
752
834
  if (existsSync(resolve(cwd, "wrangler.jsonc"))) {
753
835
  wranglerConfigPath = resolve(cwd, "wrangler.jsonc");
@@ -813,6 +895,10 @@ const seedCommand = defineCommand({
813
895
  description: "Seed local Cloudflare D1 database with mock data or custom seed script"
814
896
  },
815
897
  args: {
898
+ db: {
899
+ type: "string",
900
+ description: "Target database name (e.g. --db analytics) or omit for primary DB"
901
+ },
816
902
  clean: {
817
903
  type: "boolean",
818
904
  description: "Clean/truncate existing records before seeding",
@@ -855,7 +941,7 @@ const seedCommand = defineCommand({
855
941
  console.log("\u{1F331} [qarpeo] Preparing database for seeding...");
856
942
  let ctx;
857
943
  try {
858
- ctx = await getLocalDatabaseContext(cwd, nuxtConfig);
944
+ ctx = await getLocalDatabaseContext(cwd, nuxtConfig, args.db);
859
945
  } catch (err) {
860
946
  console.error(`\u274C [qarpeo] ${err?.message || err}`);
861
947
  process.exit(1);
@@ -909,8 +995,8 @@ const db = defineCommand({
909
995
  description: "Manage Cloudflare D1 database, Drizzle ORM migrations, and seeding"
910
996
  },
911
997
  subCommands: {
912
- list,
913
- ls: list,
998
+ list: list$2,
999
+ ls: list$2,
914
1000
  create,
915
1001
  delete: deleteDb,
916
1002
  drop: deleteDb,
@@ -1018,10 +1104,10 @@ async function deleteCloudflareWorker(auth, workerName) {
1018
1104
  return data.success === true;
1019
1105
  }
1020
1106
 
1021
- function getWranglerBin$2(cwd) {
1107
+ function getWranglerBin$4(cwd) {
1022
1108
  return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
1023
1109
  }
1024
- function loadDotEnv$3(cwd) {
1110
+ function loadDotEnv$5(cwd) {
1025
1111
  const envPath = join(cwd, ".env");
1026
1112
  if (!existsSync(envPath)) return;
1027
1113
  try {
@@ -1083,7 +1169,7 @@ const deleteCommand = defineCommand({
1083
1169
  },
1084
1170
  async run({ args }) {
1085
1171
  const cwd = resolve(process.cwd(), args.cwd);
1086
- loadDotEnv$3(cwd);
1172
+ loadDotEnv$5(cwd);
1087
1173
  const auth = await getCloudflareAuth(cwd);
1088
1174
  let workerName = args.name;
1089
1175
  if (!workerName) {
@@ -1177,7 +1263,7 @@ const deleteCommand = defineCommand({
1177
1263
  cwd,
1178
1264
  purpose: "deleting Cloudflare Worker"
1179
1265
  });
1180
- const wrangler = getWranglerBin$2(cwd);
1266
+ const wrangler = getWranglerBin$4(cwd);
1181
1267
  const wranglerArgs = ["delete", workerName, "--force"];
1182
1268
  if (args.env) {
1183
1269
  wranglerArgs.push("--env", args.env);
@@ -1198,7 +1284,7 @@ const deleteCommand = defineCommand({
1198
1284
  }
1199
1285
  });
1200
1286
 
1201
- function loadDotEnv$2(cwd) {
1287
+ function loadDotEnv$4(cwd) {
1202
1288
  const envPath = join(cwd, ".env");
1203
1289
  if (!existsSync(envPath)) return;
1204
1290
  try {
@@ -1329,7 +1415,7 @@ const deploy = defineCommand({
1329
1415
  async run({ args }) {
1330
1416
  const targetDir = args.dir && args.dir !== "." ? args.dir : args.cwd;
1331
1417
  const cwd = resolve(process.cwd(), targetDir);
1332
- loadDotEnv$2(cwd);
1418
+ loadDotEnv$4(cwd);
1333
1419
  const isPreview = Boolean(args.preview);
1334
1420
  const branch = getGitBranch(cwd);
1335
1421
  const previewSuffix = branch && branch !== "main" && branch !== "master" && branch !== "HEAD" ? sanitizeSuffix(branch) : "preview";
@@ -1419,7 +1505,7 @@ const deploy = defineCommand({
1419
1505
  if (!wranglerConfigPath) {
1420
1506
  try {
1421
1507
  const { loadNuxtConfig } = await import('@nuxt/kit');
1422
- const { generateDevWranglerConfig } = await import('../chunks/wrangler.mjs').then(function (n) { return n.w; });
1508
+ const { generateDevWranglerConfig } = await import('../chunks/tools.mjs').then(function (n) { return n.E; });
1423
1509
  const nuxtConfig = await loadNuxtConfig({ cwd });
1424
1510
  const qarpeoOpts = nuxtConfig.qarpeo || {};
1425
1511
  const buildDir = resolve(cwd, ".nuxt");
@@ -1531,8 +1617,11 @@ const deploy = defineCommand({
1531
1617
  } catch {
1532
1618
  }
1533
1619
  for (const d1 of config.d1_databases) {
1534
- const explicitId = isPreview ? process.env.QARPEO_PREVIEW_DB_ID || process.env.PREVIEW_DB_ID || process.env.PREVIEW_DATABASE_ID : process.env.QARPEO_PROD_DB_ID || process.env.QARPEO_DB_ID || process.env.DB_ID || process.env.DATABASE_ID;
1535
- const explicitName = isPreview ? process.env.QARPEO_PREVIEW_DB_NAME || process.env.PREVIEW_DB_NAME : process.env.QARPEO_PROD_DB_NAME || process.env.QARPEO_DB_NAME || process.env.DB_NAME;
1620
+ const bindingName = (d1.binding || "DB").toUpperCase();
1621
+ const isPrimary = bindingName === "DB";
1622
+ const nameSuffix = bindingName.replace(/_DB$/, "");
1623
+ const explicitId = isPreview ? isPrimary ? process.env.QARPEO_PREVIEW_DB_ID || process.env.PREVIEW_DB_ID || process.env.PREVIEW_DATABASE_ID : process.env[`PREVIEW_D1_${nameSuffix}_ID`] || process.env[`D1_${nameSuffix}_PREVIEW_ID`] || process.env[`D1_${nameSuffix}_ID`] : isPrimary ? process.env.QARPEO_PROD_DB_ID || process.env.QARPEO_DB_ID || process.env.DB_ID || process.env.DATABASE_ID : process.env[`D1_${nameSuffix}_ID`] || process.env[`DATABASE_${nameSuffix}_ID`] || (d1.database_id && !d1.database_id.includes("LOCAL") ? d1.database_id : void 0);
1624
+ const explicitName = isPreview ? isPrimary ? process.env.QARPEO_PREVIEW_DB_NAME || process.env.PREVIEW_DB_NAME : process.env[`PREVIEW_D1_${nameSuffix}_NAME`] || process.env[`D1_${nameSuffix}_PREVIEW_NAME`] : isPrimary ? process.env.QARPEO_PROD_DB_NAME || process.env.QARPEO_DB_NAME || process.env.DB_NAME : process.env[`D1_${nameSuffix}_NAME`];
1536
1625
  const targetDbName = explicitName || (isPreview ? `${d1.database_name}_preview` : d1.database_name);
1537
1626
  if (explicitId) {
1538
1627
  console.log(
@@ -1650,38 +1739,53 @@ const deploy = defineCommand({
1650
1739
  }
1651
1740
  if (args.migrate && !args.dryRun) {
1652
1741
  try {
1653
- const candidateMigDirs = [
1654
- resolve(cwd, "server/db/migrations"),
1655
- resolve(cwd, "migrations"),
1656
- resolve(cwd, ".output/server/migrations")
1657
- ];
1658
- const migDir = candidateMigDirs.find((d) => existsSync(d));
1659
- if (migDir && Array.isArray(config.d1_databases) && config.d1_databases.length > 0) {
1742
+ if (Array.isArray(config.d1_databases) && config.d1_databases.length > 0) {
1743
+ const migConfigPath = rootConfigPath || wranglerConfigPath;
1660
1744
  for (const d1 of config.d1_databases) {
1661
1745
  const hasId = d1.database_id && !d1.database_id.includes("LOCAL");
1662
- if (hasId && d1.database_name) {
1663
- console.log(
1664
- `
1665
- \u26A1 [qarpeo] Applying D1 migrations for ${d1.database_name} (${isPreview ? "preview" : "remote"})...`
1746
+ const dbName = d1.database_name || d1.binding;
1747
+ if (hasId && dbName) {
1748
+ const explicitMigDir = d1.migrations_dir ? resolve(cwd, d1.migrations_dir) : null;
1749
+ const isPrimary = (d1.binding || "DB").toUpperCase() === "DB";
1750
+ const secName = (d1.binding || "").toLowerCase().replace(/_db$/, "");
1751
+ const candidateMigDirs = [
1752
+ explicitMigDir,
1753
+ isPrimary ? resolve(cwd, "db/d1/migrations") : null,
1754
+ isPrimary ? resolve(cwd, "db/migrations") : null,
1755
+ !isPrimary ? resolve(cwd, `db/d1-${secName}/migrations`) : null,
1756
+ !isPrimary ? resolve(cwd, `db/migrations/${secName}`) : null,
1757
+ resolve(cwd, "migrations"),
1758
+ resolve(cwd, ".output/server/migrations")
1759
+ ].filter(Boolean);
1760
+ const hasMigrations = candidateMigDirs.some(
1761
+ (d) => existsSync(d) && statSync(d).isDirectory() && readdirSync(d).some(
1762
+ (f) => f.endsWith(".sql") || existsSync(join(d, f)) && statSync(join(d, f)).isDirectory()
1763
+ )
1666
1764
  );
1667
- const migConfigPath = rootConfigPath || wranglerConfigPath;
1668
- const migArgs = [
1669
- "d1",
1670
- "migrations",
1671
- "apply",
1672
- d1.database_name,
1673
- "--remote",
1674
- "-c",
1675
- migConfigPath
1676
- ];
1677
- spawnBinSync(wranglerBin, migArgs, {
1678
- cwd,
1679
- stdio: "inherit"
1680
- });
1765
+ if (hasMigrations || d1.migrations_dir) {
1766
+ console.log(
1767
+ `
1768
+ \u26A1 [qarpeo] Applying D1 migrations for ${dbName} (${isPreview ? "preview" : "remote"})...`
1769
+ );
1770
+ const migArgs = [
1771
+ "d1",
1772
+ "migrations",
1773
+ "apply",
1774
+ dbName,
1775
+ "--remote",
1776
+ "-c",
1777
+ migConfigPath
1778
+ ];
1779
+ spawnBinSync(wranglerBin, migArgs, {
1780
+ cwd,
1781
+ stdio: "inherit"
1782
+ });
1783
+ }
1681
1784
  }
1682
1785
  }
1683
1786
  }
1684
- } catch {
1787
+ } catch (err) {
1788
+ console.warn(`\u26A0\uFE0F [qarpeo] Migration execution warning: ${err?.message ?? String(err)}`);
1685
1789
  }
1686
1790
  }
1687
1791
  if (args.preflight) {
@@ -1743,7 +1847,7 @@ const deploy = defineCommand({
1743
1847
  }
1744
1848
  });
1745
1849
 
1746
- function loadDotEnv$1(cwd) {
1850
+ function loadDotEnv$3(cwd) {
1747
1851
  const envPath = join(cwd, ".env");
1748
1852
  if (!existsSync(envPath)) return;
1749
1853
  try {
@@ -1784,7 +1888,7 @@ const doctor = defineCommand({
1784
1888
  },
1785
1889
  async run({ args }) {
1786
1890
  const cwd = resolve(process.cwd(), args.cwd);
1787
- loadDotEnv$1(cwd);
1891
+ loadDotEnv$3(cwd);
1788
1892
  const isRemote = Boolean(args.remote);
1789
1893
  const categories = [];
1790
1894
  console.log(`
@@ -1886,22 +1990,6 @@ const doctor = defineCommand({
1886
1990
  help: "Add 'qarpeo' to the `modules` list in nuxt.config.ts."
1887
1991
  });
1888
1992
  }
1889
- if (qarpeoConfig.cf) {
1890
- configItems.push({
1891
- status: "warn",
1892
- title: "Legacy Config: `cf`",
1893
- message: "Deprecated 'qarpeo.cf' object detected. Options have moved directly to top-level 'qarpeo: {}'",
1894
- help: "Replace 'qarpeo: { cf: { ... } }' with top-level keys like 'qarpeo: { db: true, kv: true }'."
1895
- });
1896
- }
1897
- if (qarpeoConfig.storage) {
1898
- configItems.push({
1899
- status: "warn",
1900
- title: "Deprecated Option: `storage`",
1901
- message: "'storage' option is deprecated. Use 'blob' instead.",
1902
- help: "Replace 'qarpeo: { storage: true }' with 'qarpeo: { blob: true }'."
1903
- });
1904
- }
1905
1993
  const featureKeys = [
1906
1994
  "db",
1907
1995
  "blob",
@@ -1911,6 +1999,11 @@ const doctor = defineCommand({
1911
1999
  "realtime",
1912
2000
  "payments",
1913
2001
  "ai",
2002
+ "agents",
2003
+ "bots",
2004
+ "mcp",
2005
+ "jobs",
2006
+ "workflows",
1914
2007
  "vectorize",
1915
2008
  "queue",
1916
2009
  "analytics",
@@ -1985,8 +2078,10 @@ const doctor = defineCommand({
1985
2078
  message: "Local dev uses Miniflare emulation (no account ID required)"
1986
2079
  });
1987
2080
  }
1988
- const isDbEnabled = Boolean(
1989
- qarpeoConfig.db || qarpeoConfig.d1 || qarpeoConfig.cms || qarpeoConfig.auth || qarpeoConfig.payments
2081
+ const layers = nuxtConfig?._layers || [{ cwd }];
2082
+ const discoveredDatabases = discoverDatabases(layers, qarpeoConfig);
2083
+ const isDbEnabled = qarpeoConfig.db !== false && Boolean(
2084
+ qarpeoConfig.db || qarpeoConfig.d1 || qarpeoConfig.cms || qarpeoConfig.auth || qarpeoConfig.payments || discoveredDatabases.some((d) => d.schemaFiles.length > 0)
1990
2085
  );
1991
2086
  if (isDbEnabled) {
1992
2087
  const dbBinding = typeof qarpeoConfig.db === "object" && qarpeoConfig.db?.binding ? qarpeoConfig.db.binding : process.env.QARPEO_DB_BINDING || "DB";
@@ -2012,6 +2107,40 @@ const doctor = defineCommand({
2012
2107
  message: `Binding '${dbBinding}' active (Miniflare emulation)`
2013
2108
  });
2014
2109
  }
2110
+ for (const secDb of discoveredDatabases.filter((d) => !d.isPrimary)) {
2111
+ if (secDb.dialect === "sqlite") {
2112
+ const secId = secDb.databaseId;
2113
+ if (isRemote) {
2114
+ if (!secId || secId.includes("LOCAL_DEV")) {
2115
+ bindingItems.push({
2116
+ status: "info",
2117
+ title: `D1 Secondary Binding (${secDb.binding})`,
2118
+ message: `Secondary binding '${secDb.binding}' will be automatically provisioned on Cloudflare during 'qp deploy'`
2119
+ });
2120
+ } else {
2121
+ bindingItems.push({
2122
+ status: "pass",
2123
+ title: `D1 Secondary Binding (${secDb.binding})`,
2124
+ message: `Binding '${secDb.binding}' bound to remote ID ${secId}`
2125
+ });
2126
+ }
2127
+ } else {
2128
+ const folderDesc = secDb.dir ? relative(cwd, secDb.dir).replace(/\\/g, "/") : `db/${secDb.dirName}`;
2129
+ bindingItems.push({
2130
+ status: "pass",
2131
+ title: `D1 Secondary Binding (${secDb.binding})`,
2132
+ message: `Binding '${secDb.binding}' active (folder: ${folderDesc})`
2133
+ });
2134
+ }
2135
+ } else if (secDb.dialect === "postgres" || secDb.dialect === "mysql") {
2136
+ const dialectLabel = secDb.dialect === "mysql" ? "MySQL" : "PostgreSQL";
2137
+ bindingItems.push({
2138
+ status: "pass",
2139
+ title: `Hyperdrive Binding (${secDb.binding})`,
2140
+ message: `${dialectLabel} connection pooling active via Hyperdrive (binding: ${secDb.binding})`
2141
+ });
2142
+ }
2143
+ }
2015
2144
  }
2016
2145
  const isBlobEnabled = Boolean(
2017
2146
  qarpeoConfig.blob || qarpeoConfig.r2 || qarpeoConfig.cms || qarpeoConfig.storage
@@ -2079,76 +2208,86 @@ const doctor = defineCommand({
2079
2208
  message: "Bundled directly by Qarpeo runtime"
2080
2209
  });
2081
2210
  }
2082
- const layers = nuxtConfig?._layers || [{ cwd }];
2083
2211
  const schemaFiles = findSchemaFiles(layers);
2212
+ if (discoveredDatabases.length > 1) {
2213
+ const dbSummary = discoveredDatabases.map((d) => `${d.name} (${d.binding}, ${d.dialect})`).join(", ");
2214
+ dbItems.push({
2215
+ status: "pass",
2216
+ title: "Multi-Database Architecture",
2217
+ message: `Discovered ${discoveredDatabases.length} database(s): ${dbSummary}`
2218
+ });
2219
+ }
2084
2220
  if (schemaFiles.length > 0) {
2085
2221
  dbItems.push({
2086
2222
  status: "pass",
2087
2223
  title: "Schema Definitions",
2088
- message: `Found ${schemaFiles.length} schema file(s)`
2224
+ message: `Found ${schemaFiles.length} schema file(s) across ${discoveredDatabases.length} database(s)`
2089
2225
  });
2090
2226
  } else {
2091
2227
  dbItems.push({
2092
2228
  status: "warn",
2093
2229
  title: "Schema Definitions",
2094
- message: "No custom Drizzle schema files found in server/db/schema/",
2095
- help: "Create table definitions in server/db/schema/ (e.g. server/db/schema/users.ts)."
2230
+ message: "No custom Drizzle schema files found in db/",
2231
+ help: "Create table definitions in db/d1/schema.ts or db/d1/schema/."
2096
2232
  });
2097
2233
  }
2098
- const migrationsDir = resolve(cwd, "server/db/migrations");
2099
- if (existsSync(migrationsDir)) {
2100
- try {
2101
- const migrationEntries = readdirSync(migrationsDir).filter((e) => {
2102
- const p = join(migrationsDir, e);
2103
- return statSync(p).isDirectory() || e.endsWith(".sql");
2104
- });
2105
- if (migrationEntries.length === 0) {
2106
- dbItems.push({
2107
- status: schemaFiles.length > 0 ? "warn" : "info",
2108
- title: "D1 Migrations",
2109
- message: "Migrations directory exists but contains no migration files",
2110
- help: "Run `qp generate` to create initial D1 SQL migrations."
2234
+ for (const db of discoveredDatabases) {
2235
+ const migrationsDir = db.migrationsDir;
2236
+ const dbLabel = db.isPrimary ? "Primary D1" : `D1 "${db.name}"`;
2237
+ if (existsSync(migrationsDir)) {
2238
+ try {
2239
+ const migrationEntries = readdirSync(migrationsDir).filter((e) => {
2240
+ const p = join(migrationsDir, e);
2241
+ return statSync(p).isDirectory() || e.endsWith(".sql");
2111
2242
  });
2112
- } else {
2113
- let latestMigrationMtime = 0;
2114
- for (const entry of migrationEntries) {
2115
- const mtime = statSync(join(migrationsDir, entry)).mtimeMs;
2116
- if (mtime > latestMigrationMtime) latestMigrationMtime = mtime;
2117
- }
2118
- let newestSchemaMtime = 0;
2119
- for (const s of schemaFiles) {
2120
- const mtime = statSync(s).mtimeMs;
2121
- if (mtime > newestSchemaMtime) newestSchemaMtime = mtime;
2122
- }
2123
- if (newestSchemaMtime > latestMigrationMtime + 3e3) {
2243
+ if (migrationEntries.length === 0) {
2124
2244
  dbItems.push({
2125
- status: "warn",
2126
- title: "D1 Migrations Freshness",
2127
- message: `${migrationEntries.length} migration(s) found, but schema files were modified more recently`,
2128
- help: "Run `qp generate` to generate new migrations for the latest schema changes."
2245
+ status: db.schemaFiles.length > 0 ? "warn" : "info",
2246
+ title: `${dbLabel} Migrations`,
2247
+ message: `Migrations directory exists for ${db.name} (${db.dirName}) but contains no migration files`,
2248
+ help: `Run \`qp db generate${db.isPrimary ? "" : ` --db ${db.name}`}\` to create initial SQL migrations.`
2129
2249
  });
2130
2250
  } else {
2131
- dbItems.push({
2132
- status: "pass",
2133
- title: "D1 Migrations",
2134
- message: `${migrationEntries.length} migration(s) generated and up to date with schemas`
2135
- });
2251
+ let latestMigrationMtime = 0;
2252
+ for (const entry of migrationEntries) {
2253
+ const mtime = statSync(join(migrationsDir, entry)).mtimeMs;
2254
+ if (mtime > latestMigrationMtime) latestMigrationMtime = mtime;
2255
+ }
2256
+ let newestSchemaMtime = 0;
2257
+ for (const s of db.schemaFiles) {
2258
+ const mtime = statSync(s).mtimeMs;
2259
+ if (mtime > newestSchemaMtime) newestSchemaMtime = mtime;
2260
+ }
2261
+ if (newestSchemaMtime > latestMigrationMtime + 3e3) {
2262
+ dbItems.push({
2263
+ status: "warn",
2264
+ title: `${dbLabel} Migrations Freshness`,
2265
+ message: `${migrationEntries.length} migration(s) found, but schema files were modified more recently`,
2266
+ help: `Run \`qp db generate${db.isPrimary ? "" : ` --db ${db.name}`}\` to generate new migrations for the latest schema changes.`
2267
+ });
2268
+ } else {
2269
+ dbItems.push({
2270
+ status: "pass",
2271
+ title: `${dbLabel} Migrations`,
2272
+ message: `${migrationEntries.length} migration(s) generated and up to date with schemas`
2273
+ });
2274
+ }
2136
2275
  }
2276
+ } catch {
2277
+ dbItems.push({
2278
+ status: "info",
2279
+ title: `${dbLabel} Migrations`,
2280
+ message: `Unable to inspect migrations directory for ${db.name}`
2281
+ });
2137
2282
  }
2138
- } catch {
2283
+ } else if (db.schemaFiles.length > 0) {
2139
2284
  dbItems.push({
2140
- status: "info",
2141
- title: "D1 Migrations",
2142
- message: "Unable to inspect migrations directory"
2285
+ status: "warn",
2286
+ title: `${dbLabel} Migrations`,
2287
+ message: `No migrations directory found for database "${db.name}" (${db.dirName})`,
2288
+ help: `Run \`qp db generate${db.isPrimary ? "" : ` --db ${db.name}`}\` to generate migrations.`
2143
2289
  });
2144
2290
  }
2145
- } else if (schemaFiles.length > 0) {
2146
- dbItems.push({
2147
- status: "warn",
2148
- title: "D1 Migrations",
2149
- message: "No server/db/migrations directory found",
2150
- help: "Run `qp generate` to generate D1 migrations from your schema files."
2151
- });
2152
2291
  }
2153
2292
  if (!isRemote) {
2154
2293
  const localDbPath = findLocalD1Database(cwd);
@@ -2174,8 +2313,8 @@ const doctor = defineCommand({
2174
2313
  }
2175
2314
  if (qarpeoConfig.auth) {
2176
2315
  const authItems = [];
2177
- const secret = process.env.NUXT_APP_SECRET || process.env.NUXT_SESSION_PASSWORD;
2178
- const isDummySecret = secret === "dev-app-secret-must-be-at-least-32-chars-long" || secret === "dev-session-password-must-be-at-least-32-chars-long";
2316
+ const secret = process.env.NUXT_APP_SECRET;
2317
+ const isDummySecret = secret === "dev-app-secret-must-be-at-least-32-chars-long";
2179
2318
  if (!secret) {
2180
2319
  authItems.push({
2181
2320
  status: isRemote ? "fail" : "warn",
@@ -2276,6 +2415,76 @@ const doctor = defineCommand({
2276
2415
  items: paymentItems
2277
2416
  });
2278
2417
  }
2418
+ const primitiveItems = [];
2419
+ const discoveredAgents = findAgentFiles(layers);
2420
+ const discoveredTools = findToolFiles(layers);
2421
+ const discoveredBots = findBotFiles(
2422
+ layers,
2423
+ typeof qarpeoConfig.bots === "object" ? qarpeoConfig.bots : void 0
2424
+ );
2425
+ const discoveredMcp = findMcpFiles(
2426
+ layers,
2427
+ typeof qarpeoConfig.mcp === "object" ? qarpeoConfig.mcp : void 0
2428
+ );
2429
+ const discoveredJobs = findJobFiles(layers);
2430
+ const discoveredWorkflows = findWorkflowFiles(layers);
2431
+ const discoveredEmail = findEmailHandlerFiles(layers);
2432
+ if (discoveredAgents.length > 0) {
2433
+ primitiveItems.push({
2434
+ status: "pass",
2435
+ title: "AI Agents (server/agents/)",
2436
+ message: `${discoveredAgents.length} agent(s) discovered: ${discoveredAgents.map((a) => a.name).join(", ")}`
2437
+ });
2438
+ }
2439
+ if (discoveredTools.length > 0) {
2440
+ primitiveItems.push({
2441
+ status: "pass",
2442
+ title: "Agent Tools (server/tools/)",
2443
+ message: `${discoveredTools.length} tool file(s) discovered: ${discoveredTools.map((t) => t.name).join(", ")}`
2444
+ });
2445
+ }
2446
+ if (discoveredBots.length > 0) {
2447
+ primitiveItems.push({
2448
+ status: "pass",
2449
+ title: "Bot Webhooks (server/bots/)",
2450
+ message: `${discoveredBots.length} bot webhook(s) auto-routed: ${discoveredBots.map((b) => `${b.name} (${b.route})`).join(", ")}`
2451
+ });
2452
+ }
2453
+ if (discoveredMcp.length > 0) {
2454
+ primitiveItems.push({
2455
+ status: "pass",
2456
+ title: "MCP Servers (server/mcp/)",
2457
+ message: `${discoveredMcp.length} MCP server(s) mounted: ${discoveredMcp.map((m) => `${m.name} (${m.route})`).join(", ")}`
2458
+ });
2459
+ }
2460
+ if (discoveredJobs.length > 0) {
2461
+ primitiveItems.push({
2462
+ status: "pass",
2463
+ title: "Background Jobs (server/jobs/)",
2464
+ message: `${discoveredJobs.length} job(s) discovered: ${discoveredJobs.map((j) => j.name).join(", ")}`
2465
+ });
2466
+ }
2467
+ if (discoveredWorkflows.length > 0) {
2468
+ primitiveItems.push({
2469
+ status: "pass",
2470
+ title: "Workflows (server/workflows/)",
2471
+ message: `${discoveredWorkflows.length} workflow(s) discovered: ${discoveredWorkflows.map((w) => w.name).join(", ")}`
2472
+ });
2473
+ }
2474
+ if (discoveredEmail.length > 0) {
2475
+ primitiveItems.push({
2476
+ status: "pass",
2477
+ title: "Email Handlers (server/email/)",
2478
+ message: `${discoveredEmail.length} inbound email handler(s) discovered: ${discoveredEmail.map((e) => e.name).join(", ")}`
2479
+ });
2480
+ }
2481
+ if (primitiveItems.length > 0) {
2482
+ categories.push({
2483
+ title: "Zero-Config Edge Primitives & AI",
2484
+ icon: "\u{1F916}",
2485
+ items: primitiveItems
2486
+ });
2487
+ }
2279
2488
  let passCount = 0;
2280
2489
  let warnCount = 0;
2281
2490
  let failCount = 0;
@@ -2326,7 +2535,7 @@ ${cat.icon} ${cat.title}`);
2326
2535
  }
2327
2536
  });
2328
2537
 
2329
- function loadDotEnv(cwd) {
2538
+ function loadDotEnv$2(cwd) {
2330
2539
  const envPath = join(cwd, ".env");
2331
2540
  if (!existsSync(envPath)) return;
2332
2541
  try {
@@ -2367,7 +2576,7 @@ const listCommand = defineCommand({
2367
2576
  },
2368
2577
  async run({ args }) {
2369
2578
  const cwd = resolve(process.cwd(), args.cwd);
2370
- loadDotEnv(cwd);
2579
+ loadDotEnv$2(cwd);
2371
2580
  const auth = await getCloudflareAuth(cwd);
2372
2581
  if (!auth) {
2373
2582
  console.error("\n\u274C [qarpeo] Not authenticated with Cloudflare.");
@@ -2406,7 +2615,7 @@ const listCommand = defineCommand({
2406
2615
  }
2407
2616
  });
2408
2617
 
2409
- function getWranglerBin$1() {
2618
+ function getWranglerBin$3() {
2410
2619
  return resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
2411
2620
  }
2412
2621
  const login = defineCommand({
@@ -2427,7 +2636,7 @@ const login = defineCommand({
2427
2636
  await ensurePackage("wrangler", {
2428
2637
  purpose: "authenticating with Cloudflare"
2429
2638
  });
2430
- const wrangler = getWranglerBin$1();
2639
+ const wrangler = getWranglerBin$3();
2431
2640
  const wranglerArgs = ["login"];
2432
2641
  if (!args.browser) {
2433
2642
  wranglerArgs.push("--no-browser");
@@ -2457,7 +2666,7 @@ const logout = defineCommand({
2457
2666
  await ensurePackage("wrangler", {
2458
2667
  purpose: "logging out of Cloudflare"
2459
2668
  });
2460
- const wrangler = getWranglerBin$1();
2669
+ const wrangler = getWranglerBin$3();
2461
2670
  const result = spawnBinSync(wrangler, ["logout"], {
2462
2671
  stdio: "inherit",
2463
2672
  env: process.env
@@ -2480,7 +2689,7 @@ const whoami = defineCommand({
2480
2689
  await ensurePackage("wrangler", {
2481
2690
  purpose: "checking Cloudflare account status"
2482
2691
  });
2483
- const wrangler = getWranglerBin$1();
2692
+ const wrangler = getWranglerBin$3();
2484
2693
  const result = spawnBinSync(wrangler, ["whoami"], {
2485
2694
  stdio: "inherit",
2486
2695
  env: process.env
@@ -2614,6 +2823,828 @@ const logs = defineCommand({
2614
2823
  }
2615
2824
  });
2616
2825
 
2826
+ function getWranglerBin$2(cwd) {
2827
+ return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
2828
+ }
2829
+ function loadDotEnv$1(cwd) {
2830
+ const envPath = join(cwd, ".env");
2831
+ if (!existsSync(envPath)) return;
2832
+ try {
2833
+ const raw = readFileSync(envPath, "utf8");
2834
+ for (const line of raw.split(/\r?\n/)) {
2835
+ const trimmed = line.trim();
2836
+ if (!trimmed || trimmed.startsWith("#")) continue;
2837
+ const eqIdx = trimmed.indexOf("=");
2838
+ if (eqIdx === -1) continue;
2839
+ const key = trimmed.slice(0, eqIdx).trim();
2840
+ let val = trimmed.slice(eqIdx + 1).trim();
2841
+ if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
2842
+ val = val.slice(1, -1);
2843
+ }
2844
+ if (process.env[key] === void 0) {
2845
+ process.env[key] = val;
2846
+ }
2847
+ }
2848
+ } catch {
2849
+ }
2850
+ }
2851
+ function readWranglerConfig$1(cwd) {
2852
+ const candidateConfigs = [
2853
+ resolve(cwd, ".output/server/wrangler.json"),
2854
+ resolve(cwd, "wrangler.jsonc"),
2855
+ resolve(cwd, "wrangler.json"),
2856
+ resolve(cwd, ".nuxt/wrangler.json")
2857
+ ];
2858
+ for (const p of candidateConfigs) {
2859
+ if (existsSync(p)) {
2860
+ try {
2861
+ return JSON.parse(readFileSync(p, "utf8"));
2862
+ } catch {
2863
+ }
2864
+ }
2865
+ }
2866
+ return null;
2867
+ }
2868
+ function resolveKvTargetArgs(cwd, args) {
2869
+ const result = [];
2870
+ if (args.namespaceId) {
2871
+ result.push("--namespace-id", args.namespaceId);
2872
+ } else if (args.binding) {
2873
+ result.push("--binding", args.binding);
2874
+ } else if (process.env.QARPEO_KV_ID || process.env.KV_ID) {
2875
+ result.push("--namespace-id", process.env.QARPEO_KV_ID || process.env.KV_ID);
2876
+ } else if (process.env.QARPEO_KV_BINDING || process.env.KV_BINDING) {
2877
+ result.push("--binding", process.env.QARPEO_KV_BINDING || process.env.KV_BINDING);
2878
+ } else {
2879
+ const config = readWranglerConfig$1(cwd);
2880
+ const firstKv = config?.kv_namespaces?.[0];
2881
+ if (firstKv?.binding) {
2882
+ result.push("--binding", firstKv.binding);
2883
+ } else if (firstKv?.id) {
2884
+ result.push("--namespace-id", firstKv.id);
2885
+ } else {
2886
+ result.push("--binding", "KV");
2887
+ }
2888
+ }
2889
+ if (args.remote) {
2890
+ result.push("--remote");
2891
+ } else if (args.local) {
2892
+ result.push("--local");
2893
+ }
2894
+ return result;
2895
+ }
2896
+
2897
+ const deleteKv = defineCommand({
2898
+ meta: {
2899
+ name: "delete",
2900
+ description: "Delete a key from Cloudflare KV"
2901
+ },
2902
+ args: {
2903
+ key: {
2904
+ type: "positional",
2905
+ description: "Key name to delete",
2906
+ required: true
2907
+ },
2908
+ binding: {
2909
+ type: "string",
2910
+ description: "KV binding name from wrangler.json (defaults to auto-detected or 'KV')"
2911
+ },
2912
+ namespaceId: {
2913
+ type: "string",
2914
+ description: "KV namespace ID"
2915
+ },
2916
+ local: {
2917
+ type: "boolean",
2918
+ description: "Interact with local development KV store",
2919
+ default: false
2920
+ },
2921
+ remote: {
2922
+ type: "boolean",
2923
+ description: "Interact with remote Cloudflare KV store",
2924
+ default: false
2925
+ },
2926
+ cwd: {
2927
+ type: "string",
2928
+ description: "Working directory",
2929
+ default: "."
2930
+ }
2931
+ },
2932
+ async run({ args }) {
2933
+ const cwd = resolve(process.cwd(), args.cwd);
2934
+ loadDotEnv$1(cwd);
2935
+ await ensurePackage("wrangler", {
2936
+ cwd,
2937
+ purpose: "managing Cloudflare KV"
2938
+ });
2939
+ const wrangler = getWranglerBin$2(cwd);
2940
+ const targetArgs = resolveKvTargetArgs(cwd, args);
2941
+ const wranglerArgs = ["kv", "key", "delete", args.key, ...targetArgs];
2942
+ console.log(`\u{1F5D1}\uFE0F [qarpeo] Deleting KV key "${args.key}"...`);
2943
+ const result = spawnSync(wrangler, wranglerArgs, {
2944
+ cwd,
2945
+ stdio: "inherit",
2946
+ env: process.env,
2947
+ shell: process.platform === "win32"
2948
+ });
2949
+ if (result.status !== 0) {
2950
+ process.exit(result.status ?? 1);
2951
+ }
2952
+ }
2953
+ });
2954
+
2955
+ const get = defineCommand({
2956
+ meta: {
2957
+ name: "get",
2958
+ description: "Get the value of a key in Cloudflare KV"
2959
+ },
2960
+ args: {
2961
+ key: {
2962
+ type: "positional",
2963
+ description: "Key name to retrieve",
2964
+ required: true
2965
+ },
2966
+ binding: {
2967
+ type: "string",
2968
+ description: "KV binding name from wrangler.json (defaults to auto-detected or 'KV')"
2969
+ },
2970
+ namespaceId: {
2971
+ type: "string",
2972
+ description: "KV namespace ID"
2973
+ },
2974
+ text: {
2975
+ type: "boolean",
2976
+ description: "Decode value as plain text",
2977
+ default: true
2978
+ },
2979
+ local: {
2980
+ type: "boolean",
2981
+ description: "Interact with local development KV store",
2982
+ default: false
2983
+ },
2984
+ remote: {
2985
+ type: "boolean",
2986
+ description: "Interact with remote Cloudflare KV store",
2987
+ default: false
2988
+ },
2989
+ cwd: {
2990
+ type: "string",
2991
+ description: "Working directory",
2992
+ default: "."
2993
+ }
2994
+ },
2995
+ async run({ args }) {
2996
+ const cwd = resolve(process.cwd(), args.cwd);
2997
+ loadDotEnv$1(cwd);
2998
+ await ensurePackage("wrangler", {
2999
+ cwd,
3000
+ purpose: "managing Cloudflare KV"
3001
+ });
3002
+ const wrangler = getWranglerBin$2(cwd);
3003
+ const targetArgs = resolveKvTargetArgs(cwd, args);
3004
+ const wranglerArgs = ["kv", "key", "get", args.key, ...targetArgs];
3005
+ if (args.text) {
3006
+ wranglerArgs.push("--text");
3007
+ }
3008
+ const result = spawnSync(wrangler, wranglerArgs, {
3009
+ cwd,
3010
+ stdio: "inherit",
3011
+ env: process.env,
3012
+ shell: process.platform === "win32"
3013
+ });
3014
+ if (result.status !== 0) {
3015
+ process.exit(result.status ?? 1);
3016
+ }
3017
+ }
3018
+ });
3019
+
3020
+ const list$1 = defineCommand({
3021
+ meta: {
3022
+ name: "list",
3023
+ description: "List keys in a Cloudflare KV namespace"
3024
+ },
3025
+ args: {
3026
+ prefix: {
3027
+ type: "string",
3028
+ description: "Filter keys with a specific prefix"
3029
+ },
3030
+ binding: {
3031
+ type: "string",
3032
+ description: "KV binding name from wrangler.json (defaults to auto-detected or 'KV')"
3033
+ },
3034
+ namespaceId: {
3035
+ type: "string",
3036
+ description: "KV namespace ID"
3037
+ },
3038
+ local: {
3039
+ type: "boolean",
3040
+ description: "Interact with local development KV store",
3041
+ default: false
3042
+ },
3043
+ remote: {
3044
+ type: "boolean",
3045
+ description: "Interact with remote Cloudflare KV store",
3046
+ default: false
3047
+ },
3048
+ json: {
3049
+ type: "boolean",
3050
+ description: "Output in JSON format",
3051
+ default: false
3052
+ },
3053
+ cwd: {
3054
+ type: "string",
3055
+ description: "Working directory",
3056
+ default: "."
3057
+ }
3058
+ },
3059
+ async run({ args }) {
3060
+ const cwd = resolve(process.cwd(), args.cwd);
3061
+ loadDotEnv$1(cwd);
3062
+ await ensurePackage("wrangler", {
3063
+ cwd,
3064
+ purpose: "managing Cloudflare KV"
3065
+ });
3066
+ const wrangler = getWranglerBin$2(cwd);
3067
+ const targetArgs = resolveKvTargetArgs(cwd, args);
3068
+ const wranglerArgs = ["kv", "key", "list", ...targetArgs];
3069
+ if (args.prefix) {
3070
+ wranglerArgs.push("--prefix", args.prefix);
3071
+ }
3072
+ if (args.json) {
3073
+ wranglerArgs.push("--json");
3074
+ }
3075
+ console.log(`\u{1F50D} [qarpeo] Listing KV keys...`);
3076
+ const result = spawnSync(wrangler, wranglerArgs, {
3077
+ cwd,
3078
+ stdio: "inherit",
3079
+ env: process.env,
3080
+ shell: process.platform === "win32"
3081
+ });
3082
+ if (result.status !== 0) {
3083
+ process.exit(result.status ?? 1);
3084
+ }
3085
+ }
3086
+ });
3087
+
3088
+ const namespaces = defineCommand({
3089
+ meta: {
3090
+ name: "namespaces",
3091
+ description: "List all KV namespaces in your Cloudflare account"
3092
+ },
3093
+ args: {
3094
+ json: {
3095
+ type: "boolean",
3096
+ description: "Output in JSON format",
3097
+ default: false
3098
+ },
3099
+ cwd: {
3100
+ type: "string",
3101
+ description: "Working directory",
3102
+ default: "."
3103
+ }
3104
+ },
3105
+ async run({ args }) {
3106
+ const cwd = resolve(process.cwd(), args.cwd);
3107
+ loadDotEnv$1(cwd);
3108
+ await ensurePackage("wrangler", {
3109
+ cwd,
3110
+ purpose: "managing Cloudflare KV"
3111
+ });
3112
+ const wrangler = getWranglerBin$2(cwd);
3113
+ console.log(`\u{1F4CB} [qarpeo] Fetching Cloudflare KV namespaces...
3114
+ `);
3115
+ const wranglerArgs = ["kv", "namespace", "list"];
3116
+ if (args.json) {
3117
+ wranglerArgs.push("--json");
3118
+ }
3119
+ const result = spawnSync(wrangler, wranglerArgs, {
3120
+ cwd,
3121
+ stdio: "inherit",
3122
+ env: process.env,
3123
+ shell: process.platform === "win32"
3124
+ });
3125
+ if (result.status !== 0) {
3126
+ process.exit(result.status ?? 1);
3127
+ }
3128
+ }
3129
+ });
3130
+
3131
+ const set = defineCommand({
3132
+ meta: {
3133
+ name: "set",
3134
+ description: "Set the value of a key in Cloudflare KV"
3135
+ },
3136
+ args: {
3137
+ key: {
3138
+ type: "positional",
3139
+ description: "Key name to store",
3140
+ required: true
3141
+ },
3142
+ value: {
3143
+ type: "positional",
3144
+ description: "Value to store",
3145
+ required: true
3146
+ },
3147
+ ttl: {
3148
+ type: "string",
3149
+ description: "Time to live in seconds (minimum 60 seconds)"
3150
+ },
3151
+ expiration: {
3152
+ type: "string",
3153
+ description: "Expiration timestamp (seconds since Unix epoch)"
3154
+ },
3155
+ binding: {
3156
+ type: "string",
3157
+ description: "KV binding name from wrangler.json (defaults to auto-detected or 'KV')"
3158
+ },
3159
+ namespaceId: {
3160
+ type: "string",
3161
+ description: "KV namespace ID"
3162
+ },
3163
+ local: {
3164
+ type: "boolean",
3165
+ description: "Interact with local development KV store",
3166
+ default: false
3167
+ },
3168
+ remote: {
3169
+ type: "boolean",
3170
+ description: "Interact with remote Cloudflare KV store",
3171
+ default: false
3172
+ },
3173
+ cwd: {
3174
+ type: "string",
3175
+ description: "Working directory",
3176
+ default: "."
3177
+ }
3178
+ },
3179
+ async run({ args }) {
3180
+ const cwd = resolve(process.cwd(), args.cwd);
3181
+ loadDotEnv$1(cwd);
3182
+ await ensurePackage("wrangler", {
3183
+ cwd,
3184
+ purpose: "managing Cloudflare KV"
3185
+ });
3186
+ const wrangler = getWranglerBin$2(cwd);
3187
+ const targetArgs = resolveKvTargetArgs(cwd, args);
3188
+ const wranglerArgs = ["kv", "key", "put", args.key, args.value, ...targetArgs];
3189
+ if (args.ttl) {
3190
+ wranglerArgs.push("--ttl", args.ttl);
3191
+ }
3192
+ if (args.expiration) {
3193
+ wranglerArgs.push("--expiration", args.expiration);
3194
+ }
3195
+ console.log(`\u26A1 [qarpeo] Setting KV key "${args.key}"...`);
3196
+ const result = spawnSync(wrangler, wranglerArgs, {
3197
+ cwd,
3198
+ stdio: "inherit",
3199
+ env: process.env,
3200
+ shell: process.platform === "win32"
3201
+ });
3202
+ if (result.status !== 0) {
3203
+ process.exit(result.status ?? 1);
3204
+ }
3205
+ }
3206
+ });
3207
+
3208
+ const kv = defineCommand({
3209
+ meta: {
3210
+ name: "kv",
3211
+ description: "Manage Cloudflare Workers KV key-value storage"
3212
+ },
3213
+ subCommands: {
3214
+ list: list$1,
3215
+ ls: list$1,
3216
+ get,
3217
+ set,
3218
+ put: set,
3219
+ delete: deleteKv,
3220
+ del: deleteKv,
3221
+ rm: deleteKv,
3222
+ namespaces,
3223
+ ns: namespaces
3224
+ }
3225
+ });
3226
+
3227
+ function getWranglerBin$1(cwd) {
3228
+ return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
3229
+ }
3230
+ function loadDotEnv(cwd) {
3231
+ const envPath = join(cwd, ".env");
3232
+ if (!existsSync(envPath)) return;
3233
+ try {
3234
+ const raw = readFileSync(envPath, "utf8");
3235
+ for (const line of raw.split(/\r?\n/)) {
3236
+ const trimmed = line.trim();
3237
+ if (!trimmed || trimmed.startsWith("#")) continue;
3238
+ const eqIdx = trimmed.indexOf("=");
3239
+ if (eqIdx === -1) continue;
3240
+ const key = trimmed.slice(0, eqIdx).trim();
3241
+ let val = trimmed.slice(eqIdx + 1).trim();
3242
+ if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
3243
+ val = val.slice(1, -1);
3244
+ }
3245
+ if (process.env[key] === void 0) {
3246
+ process.env[key] = val;
3247
+ }
3248
+ }
3249
+ } catch {
3250
+ }
3251
+ }
3252
+ function readWranglerConfig(cwd) {
3253
+ const candidateConfigs = [
3254
+ resolve(cwd, ".output/server/wrangler.json"),
3255
+ resolve(cwd, "wrangler.jsonc"),
3256
+ resolve(cwd, "wrangler.json"),
3257
+ resolve(cwd, ".nuxt/wrangler.json")
3258
+ ];
3259
+ for (const p of candidateConfigs) {
3260
+ if (existsSync(p)) {
3261
+ try {
3262
+ return JSON.parse(readFileSync(p, "utf8"));
3263
+ } catch {
3264
+ }
3265
+ }
3266
+ }
3267
+ return null;
3268
+ }
3269
+ function resolveStorageBucket(cwd, args) {
3270
+ if (args.bucket) {
3271
+ return args.bucket;
3272
+ }
3273
+ const envBucket = process.env.QARPEO_STORAGE_BUCKET || process.env.QARPEO_BLOB_BUCKET || process.env.STORAGE_BUCKET || process.env.BLOB_NAME;
3274
+ if (envBucket) {
3275
+ return envBucket;
3276
+ }
3277
+ const config = readWranglerConfig(cwd);
3278
+ if (Array.isArray(config?.r2_buckets) && config.r2_buckets.length > 0) {
3279
+ if (args.binding) {
3280
+ const matched = config.r2_buckets.find((b) => b.binding === args.binding);
3281
+ if (matched?.bucket_name) return matched.bucket_name;
3282
+ }
3283
+ const first = config.r2_buckets[0];
3284
+ if (first?.bucket_name) return first.bucket_name;
3285
+ }
3286
+ return "storage";
3287
+ }
3288
+
3289
+ const buckets = defineCommand({
3290
+ meta: {
3291
+ name: "buckets",
3292
+ description: "List all R2 buckets in your Cloudflare account"
3293
+ },
3294
+ args: {
3295
+ json: {
3296
+ type: "boolean",
3297
+ description: "Output in JSON format",
3298
+ default: false
3299
+ },
3300
+ cwd: {
3301
+ type: "string",
3302
+ description: "Working directory",
3303
+ default: "."
3304
+ }
3305
+ },
3306
+ async run({ args }) {
3307
+ const cwd = resolve(process.cwd(), args.cwd);
3308
+ loadDotEnv(cwd);
3309
+ await ensurePackage("wrangler", {
3310
+ cwd,
3311
+ purpose: "managing Cloudflare R2 / Storage"
3312
+ });
3313
+ const wrangler = getWranglerBin$1(cwd);
3314
+ console.log(`\u{1F4CB} [qarpeo] Fetching Cloudflare R2 buckets...
3315
+ `);
3316
+ const wranglerArgs = ["r2", "bucket", "list"];
3317
+ if (args.json) {
3318
+ wranglerArgs.push("--json");
3319
+ }
3320
+ const result = spawnSync(wrangler, wranglerArgs, {
3321
+ cwd,
3322
+ stdio: "inherit",
3323
+ env: process.env,
3324
+ shell: process.platform === "win32"
3325
+ });
3326
+ if (result.status !== 0) {
3327
+ process.exit(result.status ?? 1);
3328
+ }
3329
+ }
3330
+ });
3331
+
3332
+ const deleteStorage = defineCommand({
3333
+ meta: {
3334
+ name: "delete",
3335
+ description: "Delete an object from Cloudflare R2 / Storage"
3336
+ },
3337
+ args: {
3338
+ key: {
3339
+ type: "positional",
3340
+ description: "Remote storage key to delete",
3341
+ required: true
3342
+ },
3343
+ bucket: {
3344
+ type: "string",
3345
+ description: "R2 bucket name (defaults to auto-detected or 'storage')"
3346
+ },
3347
+ binding: {
3348
+ type: "string",
3349
+ description: "R2 binding name from wrangler.json"
3350
+ },
3351
+ local: {
3352
+ type: "boolean",
3353
+ description: "Interact with local development R2 store",
3354
+ default: false
3355
+ },
3356
+ remote: {
3357
+ type: "boolean",
3358
+ description: "Interact with remote Cloudflare R2 store",
3359
+ default: false
3360
+ },
3361
+ cwd: {
3362
+ type: "string",
3363
+ description: "Working directory",
3364
+ default: "."
3365
+ }
3366
+ },
3367
+ async run({ args }) {
3368
+ const cwd = resolve(process.cwd(), args.cwd);
3369
+ loadDotEnv(cwd);
3370
+ await ensurePackage("wrangler", {
3371
+ cwd,
3372
+ purpose: "managing Cloudflare R2 / Storage"
3373
+ });
3374
+ const wrangler = getWranglerBin$1(cwd);
3375
+ const bucket = resolveStorageBucket(cwd, args);
3376
+ console.log(`\u{1F5D1}\uFE0F [qarpeo] Deleting "${bucket}/${args.key}" from storage...`);
3377
+ const wranglerArgs = ["r2", "object", "delete", `${bucket}/${args.key}`];
3378
+ if (args.local) {
3379
+ wranglerArgs.push("--local");
3380
+ } else if (args.remote) {
3381
+ wranglerArgs.push("--remote");
3382
+ }
3383
+ const result = spawnSync(wrangler, wranglerArgs, {
3384
+ cwd,
3385
+ stdio: "inherit",
3386
+ env: process.env,
3387
+ shell: process.platform === "win32"
3388
+ });
3389
+ if (result.status !== 0) {
3390
+ process.exit(result.status ?? 1);
3391
+ }
3392
+ }
3393
+ });
3394
+
3395
+ const download = defineCommand({
3396
+ meta: {
3397
+ name: "download",
3398
+ description: "Download an object from Cloudflare R2 / Storage to a local file"
3399
+ },
3400
+ args: {
3401
+ key: {
3402
+ type: "positional",
3403
+ description: "Remote storage key to download",
3404
+ required: true
3405
+ },
3406
+ file: {
3407
+ type: "positional",
3408
+ description: "Destination local file path (defaults to key basename)",
3409
+ required: false
3410
+ },
3411
+ bucket: {
3412
+ type: "string",
3413
+ description: "R2 bucket name (defaults to auto-detected or 'storage')"
3414
+ },
3415
+ binding: {
3416
+ type: "string",
3417
+ description: "R2 binding name from wrangler.json"
3418
+ },
3419
+ local: {
3420
+ type: "boolean",
3421
+ description: "Interact with local development R2 store",
3422
+ default: false
3423
+ },
3424
+ remote: {
3425
+ type: "boolean",
3426
+ description: "Interact with remote Cloudflare R2 store",
3427
+ default: false
3428
+ },
3429
+ cwd: {
3430
+ type: "string",
3431
+ description: "Working directory",
3432
+ default: "."
3433
+ }
3434
+ },
3435
+ async run({ args }) {
3436
+ const cwd = resolve(process.cwd(), args.cwd);
3437
+ loadDotEnv(cwd);
3438
+ const destinationFile = resolve(cwd, args.file || basename(args.key));
3439
+ await ensurePackage("wrangler", {
3440
+ cwd,
3441
+ purpose: "managing Cloudflare R2 / Storage"
3442
+ });
3443
+ const wrangler = getWranglerBin$1(cwd);
3444
+ const bucket = resolveStorageBucket(cwd, args);
3445
+ console.log(
3446
+ `\u2B07\uFE0F [qarpeo] Downloading "${bucket}/${args.key}" to "${destinationFile}"...`
3447
+ );
3448
+ const wranglerArgs = [
3449
+ "r2",
3450
+ "object",
3451
+ "get",
3452
+ `${bucket}/${args.key}`,
3453
+ "--file",
3454
+ destinationFile
3455
+ ];
3456
+ if (args.local) {
3457
+ wranglerArgs.push("--local");
3458
+ } else if (args.remote) {
3459
+ wranglerArgs.push("--remote");
3460
+ }
3461
+ const result = spawnSync(wrangler, wranglerArgs, {
3462
+ cwd,
3463
+ stdio: "inherit",
3464
+ env: process.env,
3465
+ shell: process.platform === "win32"
3466
+ });
3467
+ if (result.status !== 0) {
3468
+ process.exit(result.status ?? 1);
3469
+ }
3470
+ }
3471
+ });
3472
+
3473
+ const list = defineCommand({
3474
+ meta: {
3475
+ name: "list",
3476
+ description: "List objects in a Cloudflare R2 / Storage bucket"
3477
+ },
3478
+ args: {
3479
+ bucket: {
3480
+ type: "string",
3481
+ description: "R2 bucket name (defaults to auto-detected or 'storage')"
3482
+ },
3483
+ binding: {
3484
+ type: "string",
3485
+ description: "R2 binding name from wrangler.json"
3486
+ },
3487
+ prefix: {
3488
+ type: "string",
3489
+ description: "Filter objects with a specific key prefix"
3490
+ },
3491
+ local: {
3492
+ type: "boolean",
3493
+ description: "Interact with local development R2 store",
3494
+ default: false
3495
+ },
3496
+ remote: {
3497
+ type: "boolean",
3498
+ description: "Interact with remote Cloudflare R2 store",
3499
+ default: false
3500
+ },
3501
+ json: {
3502
+ type: "boolean",
3503
+ description: "Output in JSON format",
3504
+ default: false
3505
+ },
3506
+ cwd: {
3507
+ type: "string",
3508
+ description: "Working directory",
3509
+ default: "."
3510
+ }
3511
+ },
3512
+ async run({ args }) {
3513
+ const cwd = resolve(process.cwd(), args.cwd);
3514
+ loadDotEnv(cwd);
3515
+ await ensurePackage("wrangler", {
3516
+ cwd,
3517
+ purpose: "managing Cloudflare R2 / Storage"
3518
+ });
3519
+ const wrangler = getWranglerBin$1(cwd);
3520
+ const bucket = resolveStorageBucket(cwd, args);
3521
+ console.log(`\u{1F50D} [qarpeo] Listing objects in bucket "${bucket}"...`);
3522
+ const wranglerArgs = ["r2", "object", "list", bucket];
3523
+ if (args.prefix) {
3524
+ wranglerArgs.push("--prefix", args.prefix);
3525
+ }
3526
+ if (args.local) {
3527
+ wranglerArgs.push("--local");
3528
+ } else if (args.remote) {
3529
+ wranglerArgs.push("--remote");
3530
+ }
3531
+ if (args.json) {
3532
+ wranglerArgs.push("--json");
3533
+ }
3534
+ const result = spawnSync(wrangler, wranglerArgs, {
3535
+ cwd,
3536
+ stdio: "inherit",
3537
+ env: process.env,
3538
+ shell: process.platform === "win32"
3539
+ });
3540
+ if (result.status !== 0) {
3541
+ process.exit(result.status ?? 1);
3542
+ }
3543
+ }
3544
+ });
3545
+
3546
+ const upload = defineCommand({
3547
+ meta: {
3548
+ name: "upload",
3549
+ description: "Upload a local file to Cloudflare R2 / Storage"
3550
+ },
3551
+ args: {
3552
+ file: {
3553
+ type: "positional",
3554
+ description: "Path to local file to upload",
3555
+ required: true
3556
+ },
3557
+ key: {
3558
+ type: "positional",
3559
+ description: "Destination key in storage (defaults to filename)",
3560
+ required: false
3561
+ },
3562
+ bucket: {
3563
+ type: "string",
3564
+ description: "R2 bucket name (defaults to auto-detected or 'storage')"
3565
+ },
3566
+ binding: {
3567
+ type: "string",
3568
+ description: "R2 binding name from wrangler.json"
3569
+ },
3570
+ local: {
3571
+ type: "boolean",
3572
+ description: "Interact with local development R2 store",
3573
+ default: false
3574
+ },
3575
+ remote: {
3576
+ type: "boolean",
3577
+ description: "Interact with remote Cloudflare R2 store",
3578
+ default: false
3579
+ },
3580
+ cwd: {
3581
+ type: "string",
3582
+ description: "Working directory",
3583
+ default: "."
3584
+ }
3585
+ },
3586
+ async run({ args }) {
3587
+ const cwd = resolve(process.cwd(), args.cwd);
3588
+ loadDotEnv(cwd);
3589
+ const localFilePath = resolve(cwd, args.file);
3590
+ if (!existsSync(localFilePath)) {
3591
+ console.error(`\u274C [qarpeo] File not found: ${localFilePath}`);
3592
+ process.exit(1);
3593
+ }
3594
+ const destinationKey = args.key || basename(localFilePath);
3595
+ await ensurePackage("wrangler", {
3596
+ cwd,
3597
+ purpose: "managing Cloudflare R2 / Storage"
3598
+ });
3599
+ const wrangler = getWranglerBin$1(cwd);
3600
+ const bucket = resolveStorageBucket(cwd, args);
3601
+ console.log(
3602
+ `\u2B06\uFE0F [qarpeo] Uploading "${args.file}" to "${bucket}/${destinationKey}"...`
3603
+ );
3604
+ const wranglerArgs = [
3605
+ "r2",
3606
+ "object",
3607
+ "put",
3608
+ `${bucket}/${destinationKey}`,
3609
+ "--file",
3610
+ localFilePath
3611
+ ];
3612
+ if (args.local) {
3613
+ wranglerArgs.push("--local");
3614
+ } else if (args.remote) {
3615
+ wranglerArgs.push("--remote");
3616
+ }
3617
+ const result = spawnSync(wrangler, wranglerArgs, {
3618
+ cwd,
3619
+ stdio: "inherit",
3620
+ env: process.env,
3621
+ shell: process.platform === "win32"
3622
+ });
3623
+ if (result.status !== 0) {
3624
+ process.exit(result.status ?? 1);
3625
+ }
3626
+ }
3627
+ });
3628
+
3629
+ const storage = defineCommand({
3630
+ meta: {
3631
+ name: "storage",
3632
+ description: "Manage Cloudflare R2 / Blob object storage"
3633
+ },
3634
+ subCommands: {
3635
+ list,
3636
+ ls: list,
3637
+ upload,
3638
+ put: upload,
3639
+ download,
3640
+ get: download,
3641
+ delete: deleteStorage,
3642
+ del: deleteStorage,
3643
+ rm: deleteStorage,
3644
+ buckets
3645
+ }
3646
+ });
3647
+
2617
3648
  function getWranglerBin(cwd) {
2618
3649
  return resolveBinaryPath("wrangler", cwd) || resolveBinaryPath("wrangler") || (process.platform === "win32" ? "wrangler.cmd" : "wrangler");
2619
3650
  }
@@ -3172,7 +4203,9 @@ const ALIASES = {
3172
4203
  tail: "logs",
3173
4204
  tun: "tunnel",
3174
4205
  tasks: "task",
3175
- secrets: "secret"
4206
+ secrets: "secret",
4207
+ blob: "storage",
4208
+ r2: "storage"
3176
4209
  };
3177
4210
  const invokedCmd = process.argv[2];
3178
4211
  if (invokedCmd && ALIASES[invokedCmd]) {
@@ -3186,6 +4219,8 @@ const main = defineCommand({
3186
4219
  },
3187
4220
  subCommands: {
3188
4221
  db,
4222
+ kv,
4223
+ storage,
3189
4224
  deploy,
3190
4225
  delete: deleteCommand,
3191
4226
  logs,