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
@@ -0,0 +1,308 @@
1
+ function makeOkResponse(id, result) {
2
+ return { jsonrpc: "2.0", id: id ?? null, result };
3
+ }
4
+ function makeErrorResponse(id, code, message, data) {
5
+ return { jsonrpc: "2.0", id: id ?? null, error: { code, message, data } };
6
+ }
7
+ function getAvailableTools(toolsInput) {
8
+ if (toolsInput) {
9
+ return Array.isArray(toolsInput) ? toolsInput : Object.values(toolsInput);
10
+ }
11
+ const g = globalThis;
12
+ const registry = g["__qarpeo_tool_registry__"];
13
+ if (registry && registry instanceof Map) {
14
+ return Array.from(registry.values());
15
+ }
16
+ return [];
17
+ }
18
+ export function agentToolsToMcpTools(tools) {
19
+ if (!tools) return [];
20
+ const toolList = Array.isArray(tools) ? tools : Object.values(tools);
21
+ return toolList.map((tool) => ({
22
+ name: tool.name || "unknown",
23
+ description: tool.description,
24
+ inputSchema: tool.parameters || { type: "object", properties: {} }
25
+ }));
26
+ }
27
+ export function defineMcpServer(definition) {
28
+ return async (event) => {
29
+ if (definition.authorize) {
30
+ let allowed = false;
31
+ try {
32
+ allowed = await definition.authorize(event);
33
+ } catch {
34
+ allowed = false;
35
+ }
36
+ if (!allowed) {
37
+ const errBody = makeErrorResponse(
38
+ null,
39
+ -32001,
40
+ "Unauthorized"
41
+ );
42
+ return new Response(JSON.stringify(errBody), {
43
+ status: 401,
44
+ headers: { "Content-Type": "application/json" }
45
+ });
46
+ }
47
+ }
48
+ let req;
49
+ try {
50
+ if (typeof event?.node?.req?.on === "function") {
51
+ const body = await new Promise((resolve, reject) => {
52
+ let data = "";
53
+ event.node.req.on("data", (chunk) => {
54
+ data += chunk.toString();
55
+ });
56
+ event.node.req.on("end", () => resolve(data));
57
+ event.node.req.on("error", reject);
58
+ });
59
+ req = JSON.parse(body);
60
+ } else if (event?._body !== void 0) {
61
+ req = typeof event._body === "string" ? JSON.parse(event._body) : event._body;
62
+ } else if (typeof event?.request?.json === "function") {
63
+ req = await event.request.json();
64
+ } else if (typeof event?.json === "function") {
65
+ req = await event.json();
66
+ } else {
67
+ req = event;
68
+ }
69
+ } catch {
70
+ const errBody = makeErrorResponse(null, -32700, "Parse error");
71
+ return new Response(JSON.stringify(errBody), {
72
+ status: 400,
73
+ headers: { "Content-Type": "application/json" }
74
+ });
75
+ }
76
+ if (!req || req.jsonrpc !== "2.0" || !req.method) {
77
+ const errBody = makeErrorResponse(req?.id, -32600, "Invalid Request");
78
+ return new Response(JSON.stringify(errBody), {
79
+ status: 400,
80
+ headers: { "Content-Type": "application/json" }
81
+ });
82
+ }
83
+ const { id, method, params } = req;
84
+ try {
85
+ switch (method) {
86
+ // ── initialize ──────────────────────────────────────────────────────
87
+ case "initialize": {
88
+ return jsonRpc(makeOkResponse(id, {
89
+ protocolVersion: "2024-11-05",
90
+ capabilities: {
91
+ tools: {},
92
+ resources: {},
93
+ prompts: {}
94
+ },
95
+ serverInfo: {
96
+ name: definition.name,
97
+ version: definition.version ?? "1.0.0"
98
+ },
99
+ ...definition.instructions ? { instructions: definition.instructions } : {}
100
+ }));
101
+ }
102
+ // ── tools/list ───────────────────────────────────────────────────────
103
+ case "tools/list": {
104
+ const tools = agentToolsToMcpTools(getAvailableTools(definition.tools));
105
+ return jsonRpc(makeOkResponse(id, { tools }));
106
+ }
107
+ // ── tools/call ───────────────────────────────────────────────────────
108
+ case "tools/call": {
109
+ const toolName = params?.name;
110
+ const toolArgs = params?.arguments ?? {};
111
+ const toolList = getAvailableTools(definition.tools);
112
+ const tool = toolList.find((t) => t.name === toolName);
113
+ if (!tool) {
114
+ return jsonRpc(
115
+ makeErrorResponse(id, -32602, `Tool not found: ${toolName}`)
116
+ );
117
+ }
118
+ try {
119
+ const result = await tool.execute(toolArgs);
120
+ const content = typeof result === "string" ? [{ type: "text", text: result }] : [{ type: "text", text: JSON.stringify(result) }];
121
+ return jsonRpc(makeOkResponse(id, { content }));
122
+ } catch (err) {
123
+ return jsonRpc(
124
+ makeErrorResponse(
125
+ id,
126
+ -32603,
127
+ `Tool execution failed: ${err?.message ?? String(err)}`
128
+ )
129
+ );
130
+ }
131
+ }
132
+ // ── resources/list ───────────────────────────────────────────────────
133
+ case "resources/list": {
134
+ const resources = (definition.resources ?? []).map((r) => ({
135
+ uri: r.uri,
136
+ name: r.name,
137
+ description: r.description,
138
+ mimeType: r.mimeType
139
+ }));
140
+ return jsonRpc(makeOkResponse(id, { resources }));
141
+ }
142
+ // ── resources/read ───────────────────────────────────────────────────
143
+ case "resources/read": {
144
+ const uri = params?.uri;
145
+ const resource = (definition.resources ?? []).find((r) => r.uri === uri);
146
+ if (!resource) {
147
+ return jsonRpc(
148
+ makeErrorResponse(id, -32602, `Resource not found: ${uri}`)
149
+ );
150
+ }
151
+ if (!resource.read) {
152
+ return jsonRpc(
153
+ makeErrorResponse(id, -32602, `Resource is not readable: ${uri}`)
154
+ );
155
+ }
156
+ const contents = await resource.read(uri, event);
157
+ const text = typeof contents === "string" ? contents : JSON.stringify(contents);
158
+ return jsonRpc(
159
+ makeOkResponse(id, {
160
+ contents: [{ uri, mimeType: resource.mimeType ?? "text/plain", text }]
161
+ })
162
+ );
163
+ }
164
+ // ── prompts/list ─────────────────────────────────────────────────────
165
+ case "prompts/list": {
166
+ const prompts = (definition.prompts ?? []).map((p) => ({
167
+ name: p.name,
168
+ description: p.description,
169
+ arguments: p.arguments ?? []
170
+ }));
171
+ return jsonRpc(makeOkResponse(id, { prompts }));
172
+ }
173
+ // ── prompts/get ──────────────────────────────────────────────────────
174
+ case "prompts/get": {
175
+ const promptName = params?.name;
176
+ const promptArgs = params?.arguments ?? {};
177
+ const prompt = (definition.prompts ?? []).find((p) => p.name === promptName);
178
+ if (!prompt) {
179
+ return jsonRpc(
180
+ makeErrorResponse(id, -32602, `Prompt not found: ${promptName}`)
181
+ );
182
+ }
183
+ if (!prompt.get) {
184
+ return jsonRpc(
185
+ makeErrorResponse(id, -32602, `Prompt has no get handler: ${promptName}`)
186
+ );
187
+ }
188
+ const raw = await prompt.get(promptArgs, event);
189
+ const messages = typeof raw === "string" ? [{ role: "user", content: raw }] : raw;
190
+ return jsonRpc(makeOkResponse(id, { messages }));
191
+ }
192
+ // ── ping ─────────────────────────────────────────────────────────────
193
+ case "ping": {
194
+ return jsonRpc(makeOkResponse(id, {}));
195
+ }
196
+ // ── unknown method ───────────────────────────────────────────────────
197
+ default: {
198
+ return jsonRpc(
199
+ makeErrorResponse(id, -32601, `Method not found: ${method}`)
200
+ );
201
+ }
202
+ }
203
+ } catch (err) {
204
+ return jsonRpc(
205
+ makeErrorResponse(
206
+ id,
207
+ -32603,
208
+ `Internal error: ${err?.message ?? String(err)}`
209
+ )
210
+ );
211
+ }
212
+ };
213
+ }
214
+ function jsonRpc(body) {
215
+ return new Response(JSON.stringify(body), {
216
+ headers: { "Content-Type": "application/json" }
217
+ });
218
+ }
219
+ let _mcpClientIdCounter = 0;
220
+ export function createMcpClient(url, options = {}) {
221
+ const { headers: extraHeaders = {}, timeoutMs } = options;
222
+ async function rpc(method, params) {
223
+ const id = ++_mcpClientIdCounter;
224
+ const body = { jsonrpc: "2.0", id, method, params };
225
+ const fetchOptions = {
226
+ method: "POST",
227
+ headers: {
228
+ "Content-Type": "application/json",
229
+ ...extraHeaders
230
+ },
231
+ body: JSON.stringify(body)
232
+ };
233
+ if (timeoutMs && typeof AbortController !== "undefined") {
234
+ const controller = new AbortController();
235
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
236
+ fetchOptions.signal = controller.signal;
237
+ try {
238
+ const res = await fetch(url, fetchOptions);
239
+ clearTimeout(timer);
240
+ const json = await res.json();
241
+ if (json.error) throw new Error(json.error.message);
242
+ return json.result;
243
+ } catch (err) {
244
+ clearTimeout(timer);
245
+ throw err;
246
+ }
247
+ } else {
248
+ const res = await fetch(url, fetchOptions);
249
+ const json = await res.json();
250
+ if (json.error) throw new Error(json.error.message);
251
+ return json.result;
252
+ }
253
+ }
254
+ return {
255
+ async listTools() {
256
+ const result = await rpc("tools/list");
257
+ return result?.tools ?? [];
258
+ },
259
+ async getTools() {
260
+ const mcpTools = await this.listTools();
261
+ const record = {};
262
+ for (const t of mcpTools) {
263
+ const toolName = t.name;
264
+ const tool = {
265
+ name: toolName,
266
+ description: t.description ?? "",
267
+ parameters: t.inputSchema ?? { type: "object", properties: {} },
268
+ execute: (args) => this.callTool(toolName, args)
269
+ };
270
+ record[toolName] = tool;
271
+ }
272
+ return record;
273
+ },
274
+ async callTool(name, args) {
275
+ const result = await rpc("tools/call", { name, arguments: args ?? {} });
276
+ if (Array.isArray(result?.content)) {
277
+ const textContent = result.content.find((c) => c.type === "text");
278
+ if (textContent) {
279
+ try {
280
+ return JSON.parse(textContent.text);
281
+ } catch {
282
+ return textContent.text;
283
+ }
284
+ }
285
+ }
286
+ return result;
287
+ },
288
+ async listResources() {
289
+ const result = await rpc("resources/list");
290
+ return result?.resources ?? [];
291
+ },
292
+ async readResource(uri) {
293
+ const result = await rpc("resources/read", { uri });
294
+ const contents = result?.contents ?? [];
295
+ if (contents.length > 0) return contents[0].text ?? "";
296
+ return "";
297
+ },
298
+ async ping() {
299
+ try {
300
+ await rpc("ping");
301
+ return true;
302
+ } catch {
303
+ return false;
304
+ }
305
+ }
306
+ };
307
+ }
308
+ export const useMcpClient = createMcpClient;
@@ -3,6 +3,16 @@ import type { NotificationRecord, PushSubscriptionRecord, SendNotificationReques
3
3
  /**
4
4
  * Send a notification via one or more channels (in-app, push, email). Persists to D1 for in-app
5
5
  * channel.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * await sendNotification({
10
+ * userId: "user_123",
11
+ * title: "Order Shipped",
12
+ * body: "Your order #42 has been shipped!",
13
+ * channels: ["in-app", "email"],
14
+ * }, event)
15
+ * ```
6
16
  */
7
17
  export declare function sendNotification(request: SendNotificationRequest, event?: RequestEvent): Promise<void>;
8
18
  /** Alias for sendNotification */
@@ -13,23 +23,78 @@ export interface GetNotificationsOptions {
13
23
  unreadOnly?: boolean;
14
24
  tenantId?: string;
15
25
  }
16
- /** Get paginated notifications for a user from D1. */
26
+ /**
27
+ * Get paginated notifications for a user from D1.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const { notifications, total, unread } = await getNotifications(user.id, {
32
+ * limit: 10,
33
+ * unreadOnly: true,
34
+ * }, event)
35
+ * ```
36
+ */
17
37
  export declare function getNotifications(userId: string, options?: GetNotificationsOptions, event?: RequestEvent): Promise<{
18
38
  notifications: NotificationRecord[];
19
39
  total: number;
20
40
  unread: number;
21
41
  }>;
22
- /** Mark a single notification as read. */
42
+ /**
43
+ * Mark a single notification as read.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * await markNotificationRead(notificationId, user.id, event)
48
+ * ```
49
+ */
23
50
  export declare function markNotificationRead(id: string, userId: string, event?: RequestEvent): Promise<void>;
24
- /** Mark all notifications as read for a user. */
51
+ /**
52
+ * Mark all notifications as read for a user.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * await markAllNotificationsRead(user.id, event)
57
+ * ```
58
+ */
25
59
  export declare function markAllNotificationsRead(userId: string, event?: RequestEvent): Promise<void>;
26
- /** Delete a notification. */
60
+ /**
61
+ * Delete a notification.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * await deleteNotification(notificationId, user.id, event)
66
+ * ```
67
+ */
27
68
  export declare function deleteNotification(id: string, userId: string, event?: RequestEvent): Promise<void>;
28
- /** Save a Web Push subscription for a user. */
69
+ /**
70
+ * Save a Web Push subscription for a user.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * await savePushSubscription(user.id, subscription, undefined, event)
75
+ * ```
76
+ */
29
77
  export declare function savePushSubscription(userId: string, subscription: PushSubscriptionRecord, tenantId?: string, event?: RequestEvent): Promise<void>;
30
- /** Remove a Web Push subscription by endpoint. */
78
+ /**
79
+ * Remove a Web Push subscription by endpoint.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * await removePushSubscription(subscription.endpoint, event)
84
+ * ```
85
+ */
31
86
  export declare function removePushSubscription(endpoint: string, event?: RequestEvent): Promise<void>;
32
- /** Send a Web Push notification to all subscriptions for a user. */
87
+ /**
88
+ * Send a Web Push notification to all subscriptions for a user.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * await sendWebPush(user.id, {
93
+ * title: "New Message",
94
+ * body: "Alice sent you a direct message.",
95
+ * }, event)
96
+ * ```
97
+ */
33
98
  export declare function sendWebPush(userId: string, payload: {
34
99
  title: string;
35
100
  body?: string;
@@ -1,6 +1,7 @@
1
1
  import { getCloudflareEnv } from "../../bindings.mjs";
2
2
  import { nanoid } from "./crypto.mjs";
3
3
  import { sendMail } from "./mail.mjs";
4
+ import { resolveTableName } from "./table-names.mjs";
4
5
  import { signVapidHeader, encryptWebPushPayload } from "./vapid.mjs";
5
6
  function getD1(event) {
6
7
  const env = getCloudflareEnv(event);
@@ -9,11 +10,11 @@ function getD1(event) {
9
10
  if (!db) throw new Error("[qarpeo/notifications] D1 database binding not found");
10
11
  return db;
11
12
  }
12
- function getTable() {
13
- return process.env.QARPEO_NOTIFICATIONS_TABLE || "_qarpeo_notifications";
13
+ function getTable(event) {
14
+ return process.env.QARPEO_NOTIFICATIONS_TABLE || resolveTableName("notification", event);
14
15
  }
15
- function getPushTable() {
16
- return "_qarpeo_push_subscriptions";
16
+ function getPushTable(event) {
17
+ return resolveTableName("push_subscription", event);
17
18
  }
18
19
  function parseChannels(raw) {
19
20
  try {
@@ -45,7 +46,7 @@ export async function sendNotification(request, event) {
45
46
  if (channels.includes("in-app")) {
46
47
  try {
47
48
  const db = getD1(event);
48
- const table = getTable();
49
+ const table = getTable(event);
49
50
  await db.prepare(
50
51
  `INSERT INTO ${table} (id, user_id, tenant_id, title, body, icon, action_url, channels, read, created_at, metadata)
51
52
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?)`
@@ -84,20 +85,26 @@ export async function sendNotification(request, event) {
84
85
  if (channels.includes("email")) {
85
86
  try {
86
87
  const emailOpts = request.emailOptions || {};
87
- await sendMail(
88
- {
89
- to: request.userId,
90
- // userId should be an email when using email channel
91
- subject: emailOpts.subject || request.title,
92
- from: emailOpts.from,
93
- markdown: `# ${request.title}
88
+ const targetEmail = emailOpts.to || (typeof request.userId === "string" && request.userId.includes("@") ? request.userId : void 0);
89
+ if (targetEmail) {
90
+ await sendMail(
91
+ {
92
+ to: targetEmail,
93
+ subject: emailOpts.subject || request.title,
94
+ from: emailOpts.from,
95
+ markdown: `# ${request.title}
94
96
 
95
97
  ${request.body || ""}
96
98
 
97
99
  ${request.actionUrl ? `[View \u2192](${request.actionUrl})` : ""}`
98
- },
99
- event
100
- );
100
+ },
101
+ event
102
+ );
103
+ } else {
104
+ console.warn(
105
+ `[qarpeo/notifications] Skipped email channel: userId "${request.userId}" is not an email address and no emailOptions.to was provided.`
106
+ );
107
+ }
101
108
  } catch (err) {
102
109
  console.error("[qarpeo/notifications] Failed to send email notification:", err);
103
110
  }
@@ -106,7 +113,7 @@ ${request.actionUrl ? `[View \u2192](${request.actionUrl})` : ""}`
106
113
  export const notify = sendNotification;
107
114
  export async function getNotifications(userId, options = {}, event) {
108
115
  const db = getD1(event);
109
- const table = getTable();
116
+ const table = getTable(event);
110
117
  const limit = options.limit ?? 20;
111
118
  const offset = options.offset ?? 0;
112
119
  let where = "WHERE user_id = ?";
@@ -131,22 +138,22 @@ export async function getNotifications(userId, options = {}, event) {
131
138
  }
132
139
  export async function markNotificationRead(id, userId, event) {
133
140
  const db = getD1(event);
134
- const table = getTable();
141
+ const table = getTable(event);
135
142
  await db.prepare(`UPDATE ${table} SET read = 1, read_at = ? WHERE id = ? AND user_id = ?`).bind(Date.now(), id, userId).run();
136
143
  }
137
144
  export async function markAllNotificationsRead(userId, event) {
138
145
  const db = getD1(event);
139
- const table = getTable();
146
+ const table = getTable(event);
140
147
  await db.prepare(`UPDATE ${table} SET read = 1, read_at = ? WHERE user_id = ? AND read = 0`).bind(Date.now(), userId).run();
141
148
  }
142
149
  export async function deleteNotification(id, userId, event) {
143
150
  const db = getD1(event);
144
- const table = getTable();
151
+ const table = getTable(event);
145
152
  await db.prepare(`DELETE FROM ${table} WHERE id = ? AND user_id = ?`).bind(id, userId).run();
146
153
  }
147
154
  export async function savePushSubscription(userId, subscription, tenantId, event) {
148
155
  const db = getD1(event);
149
- const table = getPushTable();
156
+ const table = getPushTable(event);
150
157
  await db.prepare(
151
158
  `INSERT OR REPLACE INTO ${table} (endpoint, user_id, tenant_id, keys_p256dh, keys_auth, created_at)
152
159
  VALUES (?, ?, ?, ?, ?, ?)`
@@ -161,12 +168,12 @@ export async function savePushSubscription(userId, subscription, tenantId, event
161
168
  }
162
169
  export async function removePushSubscription(endpoint, event) {
163
170
  const db = getD1(event);
164
- const table = getPushTable();
171
+ const table = getPushTable(event);
165
172
  await db.prepare(`DELETE FROM ${table} WHERE endpoint = ?`).bind(endpoint).run();
166
173
  }
167
174
  export async function sendWebPush(userId, payload, event) {
168
175
  const db = getD1(event);
169
- const table = getPushTable();
176
+ const table = getPushTable(event);
170
177
  const rows = await db.prepare(`SELECT * FROM ${table} WHERE user_id = ?`).bind(userId).all();
171
178
  if (!rows.results?.length) return;
172
179
  const env = getCloudflareEnv(event);
@@ -177,39 +184,44 @@ export async function sendWebPush(userId, payload, event) {
177
184
  console.warn("[qarpeo/notifications] VAPID keys not configured \u2014 skipping web push");
178
185
  return;
179
186
  }
180
- await Promise.allSettled(
181
- rows.results.map(async (row) => {
182
- const subscription = {
183
- endpoint: row.endpoint,
184
- keys: { p256dh: row.keys_p256dh, auth: row.keys_auth }
185
- };
186
- try {
187
- const authHeader = await signVapidHeader(
188
- subscription.endpoint,
189
- vapidSubject,
190
- vapidPublicKey,
191
- vapidPrivateKey
192
- );
193
- const { body, headers } = await encryptWebPushPayload(subscription, payload);
194
- const response = await fetch(subscription.endpoint, {
195
- method: "POST",
196
- headers: {
197
- Authorization: authHeader,
198
- TTL: "86400",
199
- ...headers
200
- },
201
- body
202
- });
203
- if (response.status === 410 || response.status === 404) {
204
- await removePushSubscription(subscription.endpoint, event);
205
- } else if (!response.ok) {
206
- console.warn(
207
- `[qarpeo/notifications] Push failed for ${subscription.endpoint}: ${response.status}`
187
+ const subscriptions = rows.results || [];
188
+ const BATCH_SIZE = 5;
189
+ for (let i = 0; i < subscriptions.length; i += BATCH_SIZE) {
190
+ const chunk = subscriptions.slice(i, i + BATCH_SIZE);
191
+ await Promise.allSettled(
192
+ chunk.map(async (row) => {
193
+ const subscription = {
194
+ endpoint: row.endpoint,
195
+ keys: { p256dh: row.keys_p256dh, auth: row.keys_auth }
196
+ };
197
+ try {
198
+ const authHeader = await signVapidHeader(
199
+ subscription.endpoint,
200
+ vapidSubject,
201
+ vapidPublicKey,
202
+ vapidPrivateKey
208
203
  );
204
+ const { body, headers } = await encryptWebPushPayload(subscription, payload);
205
+ const response = await fetch(subscription.endpoint, {
206
+ method: "POST",
207
+ headers: {
208
+ Authorization: authHeader,
209
+ TTL: "86400",
210
+ ...headers
211
+ },
212
+ body
213
+ });
214
+ if (response.status === 410 || response.status === 404) {
215
+ await removePushSubscription(subscription.endpoint, event);
216
+ } else if (!response.ok) {
217
+ console.warn(
218
+ `[qarpeo/notifications] Push failed for ${subscription.endpoint}: ${response.status}`
219
+ );
220
+ }
221
+ } catch (err) {
222
+ console.error(`[qarpeo/notifications] Push error for ${subscription.endpoint}:`, err);
209
223
  }
210
- } catch (err) {
211
- console.error(`[qarpeo/notifications] Push error for ${subscription.endpoint}:`, err);
212
- }
213
- })
214
- );
224
+ })
225
+ );
226
+ }
215
227
  }
@@ -1,3 +1,16 @@
1
+ /**
2
+ * @internal
3
+ * INTERNAL MODULE — Not part of the public Qarpeo API surface.
4
+ *
5
+ * This file provides internal fallback event handler factories for OAuth authentication
6
+ * when `nuxt-auth-utils` is not installed. Direct imports from this file are unsupported;
7
+ * configure OAuth providers via `nuxt.config.ts` (`qarpeo.auth.providers`) and use the
8
+ * built-in `/auth/[provider]` routes.
9
+ */
10
+ import { type RequestEvent } from "nuxt/server";
11
+ /**
12
+ * @internal User profile returned by Google OAuth userinfo endpoint.
13
+ */
1
14
  export interface OAuthGoogleUser {
2
15
  sub: string;
3
16
  email: string;
@@ -8,6 +21,9 @@ export interface OAuthGoogleUser {
8
21
  family_name?: string;
9
22
  [key: string]: any;
10
23
  }
24
+ /**
25
+ * @internal Payload passed to internal onSuccess callback.
26
+ */
11
27
  export interface OAuthSuccessPayload<T = OAuthGoogleUser> {
12
28
  user: T;
13
29
  tokens: {
@@ -20,12 +36,19 @@ export interface OAuthSuccessPayload<T = OAuthGoogleUser> {
20
36
  [key: string]: any;
21
37
  };
22
38
  }
39
+ /**
40
+ * @internal Configuration options for internal Google OAuth event handler.
41
+ */
23
42
  export interface DefineOAuthGoogleOptions {
24
- onSuccess: (event: any, payload: OAuthSuccessPayload<OAuthGoogleUser>) => any | Promise<any>;
25
- onError?: (event: any, error: any) => any | Promise<any>;
43
+ onSuccess: (event: RequestEvent, payload: OAuthSuccessPayload<OAuthGoogleUser>) => unknown | Promise<unknown>;
44
+ onError?: (event: RequestEvent, error: unknown) => unknown | Promise<unknown>;
26
45
  }
27
46
  /**
28
- * Creates an event handler for Google OAuth 2.0 authentication flow. Fully self-contained — no
29
- * external auth dependencies required.
47
+ * @internal
48
+ * INTERNAL ONLY — Not part of the public Qarpeo API surface.
49
+ *
50
+ * Internal event handler factory for Google OAuth 2.0 authentication flow.
51
+ * Used exclusively as a fallback by `/api/auth/[provider]` route when `nuxt-auth-utils`
52
+ * is not installed. Do not import or call directly in user code.
30
53
  */
31
54
  export declare function defineOAuthGoogleEventHandler(options: DefineOAuthGoogleOptions): any;