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
@@ -341,40 +341,28 @@ function formatJson(val: any): string {
341
341
 
342
342
  <div class="flex items-center gap-2">
343
343
  <!-- Tab Navigation -->
344
- <div class="flex rounded-lg border border-default bg-elevated/40 p-0.5 text-xs">
345
- <button
346
- class="px-2.5 py-1 rounded-md transition-colors"
347
- :class="
348
- activeTab === 'presence'
349
- ? 'bg-primary text-primary-foreground font-medium'
350
- : 'text-muted hover:text-default'
351
- "
344
+ <div class="flex gap-1 p-0.5 text-xs">
345
+ <UButton
346
+ size="xs"
347
+ :color="activeTab === 'presence' ? 'primary' : 'neutral'"
348
+ :variant="activeTab === 'presence' ? 'solid' : 'ghost'"
349
+ :label="`Presence (${activeRoom?.presence.length || 0})`"
352
350
  @click="activeTab = 'presence'"
353
- >
354
- Presence ({{ activeRoom?.presence.length || 0 }})
355
- </button>
356
- <button
357
- class="px-2.5 py-1 rounded-md transition-colors"
358
- :class="
359
- activeTab === 'messages'
360
- ? 'bg-primary text-primary-foreground font-medium'
361
- : 'text-muted hover:text-default'
362
- "
351
+ />
352
+ <UButton
353
+ size="xs"
354
+ :color="activeTab === 'messages' ? 'primary' : 'neutral'"
355
+ :variant="activeTab === 'messages' ? 'solid' : 'ghost'"
356
+ :label="`Messages (${activeRoom?.messages.length || 0})`"
363
357
  @click="activeTab = 'messages'"
364
- >
365
- Messages ({{ activeRoom?.messages.length || 0 }})
366
- </button>
367
- <button
368
- class="px-2.5 py-1 rounded-md transition-colors"
369
- :class="
370
- activeTab === 'state'
371
- ? 'bg-primary text-primary-foreground font-medium'
372
- : 'text-muted hover:text-default'
373
- "
358
+ />
359
+ <UButton
360
+ size="xs"
361
+ :color="activeTab === 'state' ? 'primary' : 'neutral'"
362
+ :variant="activeTab === 'state' ? 'solid' : 'ghost'"
363
+ label="Room State"
374
364
  @click="activeTab = 'state'"
375
- >
376
- Room State
377
- </button>
365
+ />
378
366
  </div>
379
367
  </div>
380
368
  </div>
@@ -1,13 +1,6 @@
1
1
  <script setup lang="ts">
2
- import { useRoute, useFetch } from "nuxt/app"
3
2
  import { computed } from "vue"
4
3
 
5
- const route = useRoute()
6
-
7
- const { data: settingsData } = useFetch<any>("/_qarpeo/api/settings", {
8
- default: () => null,
9
- })
10
-
11
4
  // DevTools dock base path
12
5
  const basePath = computed(() => "/_qarpeo/devtools")
13
6
 
@@ -2,16 +2,16 @@
2
2
  * Standard auth user columns mixin for Tier 3 custom schema declarations.
3
3
  *
4
4
  * @example
5
- * ;```ts
6
- * import { sqliteTable, text } from "drizzle-orm/sqlite-core"
7
- * import { authUserFields } from "qarpeo/auth"
5
+ * ```ts
6
+ * import { snakeCase, text } from "drizzle-orm/sqlite-core"
7
+ * import { authUserFields } from "qarpeo/auth"
8
8
  *
9
- * export const users = sqliteTable("users", {
10
- * ...authUserFields,
11
- * bio: text("bio"),
12
- * customField: text("custom_field"),
13
- * })
14
- * ```
9
+ * export const users = snakeCase.table("users", {
10
+ * ...authUserFields,
11
+ * bio: text(),
12
+ * customField: text(),
13
+ * })
14
+ * ```
15
15
  */
16
16
  export declare const authUserFields: {
17
17
  id: import("drizzle-orm").IsPrimaryKey<import("drizzle-orm/sqlite-core").SQLiteTextBuilder<[string, ...string[]]>>;
@@ -1,5 +1,5 @@
1
1
  import type { CFEvent } from "./types/index";
2
- import type { QarpeoBlob, R2Bucket, BlobEnsureOptions } from "./types/r2";
2
+ import type { QarpeoBlob, QarpeoStorage, R2Bucket, BlobObject, BlobListResult, BlobPutOptions, BlobCopyOptions, BlobServeOptions, BlobEnsureOptions, StorageObject, StorageListResult } from "./types/r2";
3
3
  /** Returns the raw Cloudflare R2Bucket binding from the active environment. */
4
4
  export declare function getR2Binding(bindingName?: string, event?: CFEvent): R2Bucket;
5
5
  /** Parses size strings like '2MB', '500KB', '1GB' into integer bytes. */
@@ -24,3 +24,12 @@ export declare function createBlob(bindingName?: string, event?: CFEvent): Qarpe
24
24
  export declare const handleBlob: (bindingName?: string, event?: CFEvent) => QarpeoBlob;
25
25
  /** Auto-imported `blob` instance for direct Cloudflare R2 Blob operations. */
26
26
  export declare const blob: QarpeoBlob;
27
+ /**
28
+ * Auto-imported `storage` instance — alias for `blob` providing Void Cloud (`void/storage`) parity.
29
+ */
30
+ export declare const storage: QarpeoBlob;
31
+ /** Alias for createBlob */
32
+ export declare const createStorage: typeof createBlob;
33
+ /** Alias for handleBlob */
34
+ export declare const handleStorage: typeof handleBlob;
35
+ export type { QarpeoBlob, QarpeoStorage, StorageObject, StorageListResult, BlobCopyOptions, BlobPutOptions, BlobServeOptions, BlobListResult, BlobObject, };
@@ -6,6 +6,9 @@ function createHttpError(statusCode, statusMessage) {
6
6
  return err;
7
7
  }
8
8
  function decodePathname(pathname) {
9
+ if (!pathname || typeof pathname !== "string") {
10
+ return pathname;
11
+ }
9
12
  try {
10
13
  return decodeURIComponent(pathname);
11
14
  } catch {
@@ -32,6 +35,18 @@ function assertValidPathname(pathname) {
32
35
  }
33
36
  }
34
37
  }
38
+ function parseDurationToSeconds(input) {
39
+ const s = input.trim().toLowerCase();
40
+ const match = s.match(/^(\d+(?:\.\d+)?)\s*(s|sec|second|seconds|m|min|minute|minutes|h|hr|hour|hours|d|day|days|w|week|weeks)?$/);
41
+ if (!match) return parseInt(s, 10) || 900;
42
+ const n = parseFloat(match[1]);
43
+ const unit = match[2] || "s";
44
+ if (unit.startsWith("w")) return Math.round(n * 7 * 24 * 3600);
45
+ if (unit.startsWith("d")) return Math.round(n * 24 * 3600);
46
+ if (unit.startsWith("h")) return Math.round(n * 3600);
47
+ if (unit.startsWith("m")) return Math.round(n * 60);
48
+ return Math.round(n);
49
+ }
35
50
  export function getR2Binding(bindingName, event) {
36
51
  const resolvedBinding = resolveRuntimeBinding("blob", bindingName, "BLOB");
37
52
  const env = getCloudflareEnv(event);
@@ -218,6 +233,45 @@ export function createBlob(bindingName, event) {
218
233
  });
219
234
  return Object.assign(result, { blobs });
220
235
  },
236
+ copy: async (sourceKey, destinationKey, options) => {
237
+ const r2 = getR2();
238
+ const decodedSource = decodePathname(sourceKey);
239
+ const decodedDest = decodePathname(destinationKey);
240
+ assertValidPathname(decodedSource);
241
+ assertValidPathname(decodedDest);
242
+ const sourceObj = await r2.get(decodedSource);
243
+ if (!sourceObj) {
244
+ throw createHttpError(404, `Source blob not found: "${decodedSource}"`);
245
+ }
246
+ const contentType = options?.contentType || sourceObj.httpMetadata?.contentType || inferContentType(decodedDest);
247
+ const mergedHttpMetadata = {
248
+ ...sourceObj.httpMetadata,
249
+ ...options?.httpMetadata,
250
+ ...contentType ? { contentType } : {}
251
+ };
252
+ const mergedCustomMetadata = {
253
+ ...sourceObj.customMetadata,
254
+ ...options?.customMetadata
255
+ };
256
+ const res = await r2.put(decodedDest, sourceObj.body, {
257
+ httpMetadata: mergedHttpMetadata,
258
+ customMetadata: Object.keys(mergedCustomMetadata).length > 0 ? mergedCustomMetadata : void 0
259
+ });
260
+ return Object.assign(res, { pathname: decodedDest, contentType });
261
+ },
262
+ url: (pathname) => {
263
+ const decoded = decodePathname(pathname).replace(/^\/+/, "");
264
+ const env = globalThis.process?.env || {};
265
+ const cdn = env.NUXT_PUBLIC_QARPEO_BLOB_CDN_URL || env.QARPEO_BLOB_CDN_URL || env.NUXT_PUBLIC_QARPEO_STORAGE_CDN_URL;
266
+ if (cdn) {
267
+ return `${cdn.replace(/\/$/, "")}/${decoded}`;
268
+ }
269
+ const prefix = env.QARPEO_STORAGE_PREFIX || "/api/storage";
270
+ return `${prefix}/file/${decoded}`;
271
+ },
272
+ bucket: (bindingName2) => {
273
+ return createBlob(bindingName2, event);
274
+ },
221
275
  serve: async (event2, pathname, options) => {
222
276
  const r2 = getR2();
223
277
  const req = event2.req;
@@ -252,6 +306,7 @@ export function createBlob(bindingName, event) {
252
306
  const headers = new Headers();
253
307
  object.writeHttpMetadata?.(headers);
254
308
  headers.set("accept-ranges", "bytes");
309
+ headers.set("x-content-type-options", "nosniff");
255
310
  if (etag) {
256
311
  headers.set("etag", etag.startsWith('"') ? etag : `"${etag}"`);
257
312
  }
@@ -262,6 +317,11 @@ export function createBlob(bindingName, event) {
262
317
  }
263
318
  if (options?.contentDisposition) {
264
319
  headers.set("content-disposition", options.contentDisposition);
320
+ } else {
321
+ const ct = (headers.get("content-type") || "").toLowerCase();
322
+ if (ct.includes("text/html") || ct.includes("image/svg+xml")) {
323
+ headers.set("content-disposition", "attachment");
324
+ }
265
325
  }
266
326
  if (ifNoneMatch && cleanEtag && (ifNoneMatch === cleanEtag || ifNoneMatch === "*")) {
267
327
  return new Response(null, { status: 304, headers });
@@ -348,6 +408,26 @@ export function createBlob(bindingName, event) {
348
408
  assertValidPathname(decoded);
349
409
  return r2.resumeMultipartUpload(decoded, uploadId);
350
410
  },
411
+ createUploadUrl: async (pathname, options) => {
412
+ const r2 = getR2();
413
+ const decoded = decodePathname(pathname);
414
+ assertValidPathname(decoded);
415
+ const rawExpiry = options?.expiresIn ?? 900;
416
+ const expiresInSec = typeof rawExpiry === "number" ? rawExpiry : parseDurationToSeconds(rawExpiry);
417
+ const putOptions = {
418
+ expiresIn: expiresInSec,
419
+ method: "PUT"
420
+ };
421
+ if (options?.contentType) {
422
+ putOptions.httpHeaders = { "Content-Type": options.contentType };
423
+ }
424
+ const url = typeof r2.createPresignedUrl === "function" ? await r2.createPresignedUrl(decoded, putOptions) : `https://mock-r2.cloudflarestorage.com/${encodeURIComponent(decoded)}?expires=${expiresInSec}`;
425
+ return {
426
+ url,
427
+ key: decoded,
428
+ expiresAt: Date.now() + expiresInSec * 1e3
429
+ };
430
+ },
351
431
  raw: (bName) => {
352
432
  return getR2Binding(bName || resolvedBinding, event);
353
433
  }
@@ -355,3 +435,6 @@ export function createBlob(bindingName, event) {
355
435
  }
356
436
  export const handleBlob = createBlob;
357
437
  export const blob = createBlob();
438
+ export const storage = blob;
439
+ export const createStorage = createBlob;
440
+ export const handleStorage = handleBlob;
@@ -18,3 +18,51 @@ export interface EdgeCacheInterface {
18
18
  * @see https://developers.cloudflare.com/workers/runtime-apis/cache/
19
19
  */
20
20
  export declare function useEdgeCache(): EdgeCacheInterface | undefined;
21
+ /**
22
+ * On-demand edge cache revalidation & purging (Void Cloud parity).
23
+ *
24
+ * Purges cached responses from Cloudflare's Edge Cache (`caches.default`) for the given path(s).
25
+ *
26
+ * @param pathOrUrl Single path/URL or array of paths to revalidate (e.g. `/api/posts`, `https://example.com/blog`)
27
+ * @param event Optional event context for resolving host origin
28
+ */
29
+ export declare function revalidate(pathOrUrl: string | string[], event?: any): Promise<{
30
+ success: boolean;
31
+ purged: string[];
32
+ }>;
33
+ /** Alias for revalidate matching Next.js / Void Cloud semantics. */
34
+ export declare const revalidatePath: typeof revalidate;
35
+ /**
36
+ * Sets one or more semantic cache tags on an outgoing response.
37
+ * Cloudflare Edge Cache / CDN reads the `Cache-Tag` header for tag-based cache purging.
38
+ *
39
+ * @param eventOrResponse Nuxt/Nitro RequestEvent, standard Response object, or response headers container
40
+ * @param tags Single tag or array of tags (e.g. "products", ["blog", "post:123"])
41
+ */
42
+ export declare function setCacheTags(eventOrResponse: any, tags: string | string[]): void;
43
+ /** Alias for `setCacheTags`. */
44
+ export declare const tagCache: typeof setCacheTags;
45
+ export interface RevalidateTagOptions {
46
+ /** Cloudflare Zone ID (defaults to CLOUDFLARE_ZONE_ID or CF_ZONE_ID) */
47
+ zoneId?: string;
48
+ /** Cloudflare API Token (defaults to CLOUDFLARE_API_TOKEN or CF_API_TOKEN) */
49
+ apiToken?: string;
50
+ /** Whether to also purge internal KV/unstorage tag index (defaults to true) */
51
+ purgeStorage?: boolean;
52
+ }
53
+ export interface RevalidateTagResult {
54
+ success: boolean;
55
+ tags: string[];
56
+ purged: boolean;
57
+ error?: string;
58
+ }
59
+ /**
60
+ * On-demand edge cache tag purging (Void Cloud & Next.js parity).
61
+ *
62
+ * Purges cached entries associated with the specified tag(s) across Cloudflare's Edge CDN
63
+ * and internal edge storage.
64
+ *
65
+ * @param tagOrTags Single tag or array of tags to purge
66
+ * @param options Optional credentials and configuration overrides
67
+ */
68
+ export declare function revalidateTag(tagOrTags: string | string[], options?: RevalidateTagOptions): Promise<RevalidateTagResult>;
@@ -10,3 +10,95 @@ export function useEdgeCache() {
10
10
  }
11
11
  return void 0;
12
12
  }
13
+ export async function revalidate(pathOrUrl, event) {
14
+ const paths = Array.isArray(pathOrUrl) ? pathOrUrl : [pathOrUrl];
15
+ const purged = [];
16
+ let origin = "https://localhost";
17
+ if (event) {
18
+ try {
19
+ const req = event.req || event;
20
+ const url = req?.url ? new URL(req.url, "https://localhost") : void 0;
21
+ if (url?.origin && url.origin !== "null") {
22
+ origin = url.origin;
23
+ }
24
+ } catch {
25
+ }
26
+ }
27
+ const cache = useEdgeCache();
28
+ for (const p of paths) {
29
+ if (!p) continue;
30
+ const targetUrl = p.startsWith("http://") || p.startsWith("https://") ? p : `${origin}${p.startsWith("/") ? "" : "/"}${p}`;
31
+ if (cache) {
32
+ try {
33
+ await cache.delete(targetUrl);
34
+ purged.push(p);
35
+ } catch {
36
+ }
37
+ } else {
38
+ purged.push(p);
39
+ }
40
+ }
41
+ return { success: true, purged };
42
+ }
43
+ export const revalidatePath = revalidate;
44
+ export function setCacheTags(eventOrResponse, tags) {
45
+ if (!eventOrResponse || !tags) return;
46
+ const tagList = (Array.isArray(tags) ? tags : [tags]).map((t) => typeof t === "string" ? t.trim() : "").filter(Boolean);
47
+ if (tagList.length === 0) return;
48
+ const tagHeaderValue = tagList.join(",");
49
+ try {
50
+ if (typeof eventOrResponse.node?.res?.setHeader === "function") {
51
+ eventOrResponse.node.res.setHeader("Cache-Tag", tagHeaderValue);
52
+ } else if (eventOrResponse.headers && typeof eventOrResponse.headers.set === "function") {
53
+ eventOrResponse.headers.set("Cache-Tag", tagHeaderValue);
54
+ } else if (eventOrResponse.response?.headers && typeof eventOrResponse.response.headers.set === "function") {
55
+ eventOrResponse.response.headers.set("Cache-Tag", tagHeaderValue);
56
+ }
57
+ } catch {
58
+ }
59
+ }
60
+ export const tagCache = setCacheTags;
61
+ export async function revalidateTag(tagOrTags, options) {
62
+ const tags = (Array.isArray(tagOrTags) ? tagOrTags : [tagOrTags]).map((t) => typeof t === "string" ? t.trim() : "").filter(Boolean);
63
+ if (tags.length === 0) {
64
+ return { success: true, tags: [], purged: false };
65
+ }
66
+ if (options?.purgeStorage !== false) {
67
+ try {
68
+ const { purgeCacheTag } = await import("./server/utils/cache.mjs");
69
+ await purgeCacheTag(...tags);
70
+ } catch {
71
+ }
72
+ }
73
+ const zoneId = options?.zoneId || process.env.CLOUDFLARE_ZONE_ID || process.env.CF_ZONE_ID || process.env.QARPEO_ZONE_ID;
74
+ const apiToken = options?.apiToken || process.env.CLOUDFLARE_API_TOKEN || process.env.CF_API_TOKEN || process.env.CLOUDFLARE_TOKEN;
75
+ if (zoneId && apiToken) {
76
+ try {
77
+ const res = await fetch(
78
+ `https://api.cloudflare.com/client/v4/zones/${zoneId}/purge_cache`,
79
+ {
80
+ method: "POST",
81
+ headers: {
82
+ Authorization: `Bearer ${apiToken}`,
83
+ "Content-Type": "application/json"
84
+ },
85
+ body: JSON.stringify({ tags })
86
+ }
87
+ );
88
+ const data = await res.json();
89
+ if (data?.success) {
90
+ return { success: true, tags, purged: true };
91
+ }
92
+ const errMsg = data?.errors?.[0]?.message || `Cloudflare purge failed with status ${res.status}`;
93
+ return { success: false, tags, purged: false, error: errMsg };
94
+ } catch (err) {
95
+ return {
96
+ success: false,
97
+ tags,
98
+ purged: false,
99
+ error: err?.message || "Failed to contact Cloudflare purge API"
100
+ };
101
+ }
102
+ }
103
+ return { success: true, tags, purged: false };
104
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./server/utils/comments";
2
+ export * from "./server/utils/comments-filter";
3
+ export type * from "./app/composables/comments";
4
+ export type { CommentsOptions, CommentsModerationConfig } from "../types";
@@ -0,0 +1,2 @@
1
+ export * from "./server/utils/comments.mjs";
2
+ export * from "./server/utils/comments-filter.mjs";
@@ -1,5 +1,6 @@
1
- import type { QarpeoDB, D1Database } from "./types/d1";
1
+ import type { QarpeoDB, D1Database, DatabaseDialect, DatabaseInfo } from "./types/d1";
2
2
  import type { CFEvent } from "./types/index";
3
+ export type { DatabaseDialect, DatabaseInfo } from "./types/d1";
3
4
  /** Returns the raw Cloudflare D1Database binding from the active environment. */
4
5
  export declare function getD1Binding(bindingName?: string, event?: CFEvent): D1Database;
5
6
  /** Creates a typed D1 database interface for a specific binding and optional event. */
@@ -19,3 +20,22 @@ export declare const db: QarpeoDB;
19
20
  * D1 SQL operations even when `db` is mapped to an ORM.
20
21
  */
21
22
  export declare const d1: QarpeoDB;
23
+ /**
24
+ * Automatically infers the database dialect from a connection URL string.
25
+ *
26
+ * Rules:
27
+ * - `postgres://` or `postgresql://` -> `"postgres"`
28
+ * - `mysql://` or `mysql2://` -> `"mysql"`
29
+ * - otherwise (empty, sqlite://, file:) -> `"d1"` (Cloudflare D1 / SQLite default)
30
+ */
31
+ export declare function detectDatabaseDialect(url?: string): DatabaseDialect;
32
+ /**
33
+ * Returns active database connection info and inferred dialect based on DATABASE_URL,
34
+ * named Hyperdrive binding, or Cloudflare environment variables.
35
+ *
36
+ * @param bindingOrEvent Optional binding name / URL string, or CFEvent context
37
+ * @param maybeEvent Optional event context when first parameter is a binding name
38
+ */
39
+ export declare function getDatabaseInfo(bindingOrEvent?: string | CFEvent, maybeEvent?: CFEvent): DatabaseInfo;
40
+ /** Alias for getDatabaseInfo */
41
+ export declare const useDatabaseInfo: (bindingOrEvent?: string | CFEvent, maybeEvent?: CFEvent) => DatabaseInfo;
@@ -34,3 +34,57 @@ export const useDB = createDB;
34
34
  export const useD1 = createDB;
35
35
  export const db = createDB();
36
36
  export const d1 = createDB();
37
+ export function detectDatabaseDialect(url) {
38
+ if (!url || typeof url !== "string") return "d1";
39
+ const clean = url.trim().toLowerCase();
40
+ if (clean.startsWith("postgres://") || clean.startsWith("postgresql://")) {
41
+ return "postgres";
42
+ }
43
+ if (clean.startsWith("mysql://") || clean.startsWith("mysql2://")) {
44
+ return "mysql";
45
+ }
46
+ return "d1";
47
+ }
48
+ export function getDatabaseInfo(bindingOrEvent, maybeEvent) {
49
+ let bindingName;
50
+ let event;
51
+ if (typeof bindingOrEvent === "string") {
52
+ bindingName = bindingOrEvent;
53
+ event = maybeEvent;
54
+ } else {
55
+ event = bindingOrEvent;
56
+ }
57
+ let env = {};
58
+ try {
59
+ env = getCloudflareEnv(event);
60
+ } catch {
61
+ }
62
+ let hd;
63
+ let url;
64
+ if (bindingName) {
65
+ if (bindingName.startsWith("postgres://") || bindingName.startsWith("postgresql://") || bindingName.startsWith("mysql://") || bindingName.startsWith("mysql2://")) {
66
+ url = bindingName;
67
+ } else if (env[bindingName]?.connectionString) {
68
+ hd = env[bindingName];
69
+ url = hd.connectionString;
70
+ } else {
71
+ url = env[`${bindingName}_URL`] || globalThis.process?.env?.[`${bindingName}_URL`] || env[`${bindingName}_DATABASE_URL`] || globalThis.process?.env?.[`${bindingName}_DATABASE_URL`];
72
+ }
73
+ }
74
+ if (!url) {
75
+ hd = env["HYPERDRIVE"];
76
+ if (!bindingName || bindingName === "DB") {
77
+ url = hd?.connectionString || globalThis.process?.env?.DATABASE_URL || env["DATABASE_URL"] || void 0;
78
+ }
79
+ }
80
+ const dialect = detectDatabaseDialect(url);
81
+ return {
82
+ dialect,
83
+ isD1: dialect === "d1",
84
+ isPostgres: dialect === "postgres",
85
+ isMysql: dialect === "mysql",
86
+ url,
87
+ hasHyperdrive: Boolean(hd)
88
+ };
89
+ }
90
+ export const useDatabaseInfo = getDatabaseInfo;
@@ -2,10 +2,12 @@ import type { QarpeoDrizzleDB, InferDrizzleRelations } from "./types/drizzle";
2
2
  import type { CFEvent } from "./types/index";
3
3
  export type { QarpeoDrizzleDB, InferDrizzleRelations } from "./types/drizzle";
4
4
  /**
5
- * Creates or accesses a typed Drizzle ORM client connected to Cloudflare D1.
5
+ * Creates or accesses a typed Drizzle ORM client connected to Cloudflare D1 or PostgreSQL.
6
+ *
7
+ * Automatically detects whether to use D1 or PostgreSQL based on DATABASE_URL or Hyperdrive.
6
8
  *
7
9
  * @param schema The database schema containing tables
8
- * @param bindingName Optional Cloudflare D1 binding name (defaults to configured binding or 'DB')
10
+ * @param bindingName Optional Cloudflare D1 / Hyperdrive binding name (defaults to 'DB' or 'HYPERDRIVE')
9
11
  * @param event Optional event context
10
12
  */
11
13
  export declare function createDrizzle<TSchema extends Record<string, unknown>>(schema: TSchema, bindingName?: string, event?: CFEvent): QarpeoDrizzleDB<InferDrizzleRelations<TSchema>>;
@@ -1,8 +1,75 @@
1
1
  import { defineRelations } from "drizzle-orm";
2
2
  import { drizzle as drizzleD1 } from "drizzle-orm/d1";
3
- import { getD1Binding } from "./db.mjs";
3
+ import { drizzle as drizzlePostgres } from "drizzle-orm/postgres-js";
4
+ import postgres from "postgres";
5
+ import { getD1Binding, getDatabaseInfo } from "./db.mjs";
4
6
  const drizzleCache = /* @__PURE__ */ new WeakMap();
7
+ const pgDrizzleCache = /* @__PURE__ */ new Map();
5
8
  export function createDrizzle(schema, bindingName, event) {
9
+ const dbInfo = getDatabaseInfo(bindingName, event);
10
+ if (dbInfo.isPostgres && dbInfo.url) {
11
+ const cacheKey = dbInfo.url;
12
+ let pgInstance = pgDrizzleCache.get(cacheKey);
13
+ if (!pgInstance) {
14
+ const client = postgres(dbInfo.url, {
15
+ prepare: false,
16
+ // Cloudflare Hyperdrive and transaction poolers recommend disabling prepared statements
17
+ max: 1
18
+ // Edge workers are ephemeral per-request
19
+ });
20
+ const relations = defineRelations(schema);
21
+ const rawDrizzle = drizzlePostgres({
22
+ client,
23
+ relations,
24
+ schema
25
+ });
26
+ pgInstance = Object.assign(rawDrizzle, {
27
+ raw: () => client
28
+ });
29
+ pgDrizzleCache.set(cacheKey, pgInstance);
30
+ }
31
+ return pgInstance;
32
+ }
33
+ if (dbInfo.isMysql) {
34
+ if (!dbInfo.url) {
35
+ throw new Error(
36
+ `[qarpeo] MySQL database detected but no connection URL found.
37
+ Ensure your Hyperdrive binding exposes a connectionString (or set DATABASE_URL).`
38
+ );
39
+ }
40
+ let mysqlLib;
41
+ let drizzleMysql;
42
+ try {
43
+ const req = globalThis.require || (typeof globalThis.process !== "undefined" && typeof require !== "undefined" ? require : void 0);
44
+ if (req) {
45
+ mysqlLib = req("mysql2/promise");
46
+ drizzleMysql = req("drizzle-orm/mysql2").drizzle;
47
+ }
48
+ } catch {
49
+ }
50
+ if (!mysqlLib || !drizzleMysql) {
51
+ throw new Error(
52
+ `[qarpeo] MySQL runtime client requires the \`mysql2\` package.
53
+ Install it with: pnpm add mysql2`
54
+ );
55
+ }
56
+ const cacheKey = `mysql:${dbInfo.url}`;
57
+ let mysqlInstance = pgDrizzleCache.get(cacheKey);
58
+ if (!mysqlInstance) {
59
+ const pool = mysqlLib.createPool(dbInfo.url);
60
+ const relations = defineRelations(schema);
61
+ const rawDrizzle = drizzleMysql(pool, {
62
+ relations,
63
+ schema,
64
+ mode: "default"
65
+ });
66
+ mysqlInstance = Object.assign(rawDrizzle, {
67
+ raw: () => pool
68
+ });
69
+ pgDrizzleCache.set(cacheKey, mysqlInstance);
70
+ }
71
+ return mysqlInstance;
72
+ }
6
73
  const resolvedBinding = bindingName || globalThis.process?.env?.QARPEO_DEFAULT_DB_BINDING || globalThis.process?.env?.DB_BINDING || "DB";
7
74
  const d1 = getD1Binding(resolvedBinding, event);
8
75
  let instance = drizzleCache.get(d1);
@@ -0,0 +1,2 @@
1
+ export * from "./types/durable-object";
2
+ export * from "./server/utils/durable-object";
@@ -0,0 +1,2 @@
1
+ export * from "./types/durable-object.mjs";
2
+ export * from "./server/utils/durable-object.mjs";
@@ -1,6 +1,6 @@
1
1
  import type { EmailSenderIdentity, QarpeoEmail, SendEmailBinding, SendEmailOptions, SendEmailResult } from "./types/email";
2
2
  import type { CFEvent } from "./types/index";
3
- export type { EmailSenderIdentity, QarpeoEmail, SendEmailBinding, SendEmailOptions, SendEmailResult, } from "./types/email";
3
+ export type { EmailSenderIdentity, InboundEmailContext, InboundEmailHandler, InboundEmailMessage, QarpeoEmail, SendEmailBinding, SendEmailOptions, SendEmailResult, } from "./types/email";
4
4
  /**
5
5
  * Parses an email address label like "Support Team [support@myapp.com](mailto:support@myapp.com)"
6
6
  * into an EmailSenderIdentity.
@@ -177,7 +177,7 @@ export async function sendEmail(options, event) {
177
177
  const messageId = `<${crypto.randomUUID()}@qarpeo>`;
178
178
  const env = getCloudflareEnv(event);
179
179
  const binding = env[resolvedBinding];
180
- const isDev = import.meta.dev && (!binding || typeof binding.send !== "function");
180
+ const isDev = (import.meta.dev || procEnv.NODE_ENV === "test") && (!binding || typeof binding.send !== "function");
181
181
  if (isDev) {
182
182
  logDevMailbox(from, options.to, options.subject, options.text, options.html, messageId);
183
183
  const devMailboxArr = globalThis.__qarpeo_dev_mailbox__ ||= [];