qarpeo 0.4.13 → 0.4.14

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 (299) hide show
  1. package/README.md +12 -6
  2. package/dist/apps/cms.d.ts +1 -1
  3. package/dist/apps/comments.d.ts +1 -1
  4. package/dist/apps/payments.d.ts +1 -1
  5. package/dist/apps/store.d.ts +1 -1
  6. package/dist/chunks/{manifest.get.mjs → tools.mjs} +445 -430
  7. package/dist/cli/index.mjs +756 -746
  8. package/dist/core/aliases.d.ts +1 -1
  9. package/dist/core/context.d.ts +1 -1
  10. package/dist/core/d1-migrate.d.ts +1 -1
  11. package/dist/core/devtools.d.ts +1 -1
  12. package/dist/core/nitro.d.ts +1 -1
  13. package/dist/core/schema.d.ts +1 -1
  14. package/dist/core/server-utils.d.ts +1 -1
  15. package/dist/core/wrangler.d.ts +1 -1
  16. package/dist/fate/index.d.ts +8 -8
  17. package/dist/fate/index.mjs +3 -1
  18. package/dist/features/agents.d.ts +1 -1
  19. package/dist/features/auth.d.ts +1 -1
  20. package/dist/features/bots.d.ts +1 -1
  21. package/dist/features/console.d.ts +1 -1
  22. package/dist/features/fate.d.ts +1 -1
  23. package/dist/features/mail.d.ts +1 -1
  24. package/dist/features/mcp.d.ts +1 -1
  25. package/dist/features/multitenant.d.ts +1 -1
  26. package/dist/features/notifications.d.ts +1 -1
  27. package/dist/features/realtime.d.ts +1 -1
  28. package/dist/features/studio.d.ts +4 -0
  29. package/dist/module.d.ts +1 -1
  30. package/dist/module.mjs +5139 -5067
  31. package/dist/primitives/ai.d.ts +1 -1
  32. package/dist/primitives/analytics.d.ts +1 -1
  33. package/dist/primitives/blob.d.ts +1 -1
  34. package/dist/primitives/browser.d.ts +1 -1
  35. package/dist/primitives/cache.d.ts +1 -1
  36. package/dist/primitives/d1.d.ts +1 -1
  37. package/dist/primitives/do.d.ts +1 -1
  38. package/dist/primitives/email.d.ts +1 -1
  39. package/dist/primitives/hyperdrive.d.ts +1 -1
  40. package/dist/primitives/kv.d.ts +1 -1
  41. package/dist/primitives/queue.d.ts +1 -1
  42. package/dist/primitives/ratelimit.d.ts +1 -1
  43. package/dist/primitives/vectorize.d.ts +1 -1
  44. package/dist/primitives/workflows.d.ts +1 -1
  45. package/dist/runtime/ai.mjs +4 -1
  46. package/dist/runtime/app/components/CMSEditor.vue +439 -0
  47. package/dist/runtime/app/components/CMSEditorImageNode.vue +90 -0
  48. package/dist/runtime/app/components/CMSEditorLinkPopover.vue +120 -0
  49. package/dist/runtime/app/components/QDropZone.vue +327 -0
  50. package/dist/runtime/app/components/QImageCropper.vue +658 -0
  51. package/dist/runtime/app/components/QImageStudio.vue +300 -0
  52. package/dist/runtime/app/components/QImg.vue +7 -4
  53. package/dist/runtime/app/composables/analytics.d.ts +8 -8
  54. package/dist/runtime/app/composables/api-tokens.d.ts +5 -5
  55. package/dist/runtime/app/composables/auth.d.ts +23 -19
  56. package/dist/runtime/app/composables/chat.d.ts +7 -6
  57. package/dist/runtime/app/composables/cms-preview.d.ts +7 -8
  58. package/dist/runtime/app/composables/cms.d.ts +6 -6
  59. package/dist/runtime/app/composables/comments.d.ts +5 -5
  60. package/dist/runtime/app/composables/comments.mjs +7 -4
  61. package/dist/runtime/app/composables/console.d.ts +6 -14
  62. package/dist/runtime/app/composables/docs-version.d.ts +8 -8
  63. package/dist/runtime/app/composables/impersonation.d.ts +5 -5
  64. package/dist/runtime/app/composables/organization.d.ts +5 -5
  65. package/dist/runtime/app/composables/passkey.d.ts +5 -5
  66. package/dist/runtime/app/composables/passwordless.d.ts +5 -5
  67. package/dist/runtime/app/composables/payments.d.ts +5 -5
  68. package/dist/runtime/app/composables/rbac.d.ts +5 -5
  69. package/dist/runtime/app/composables/site.d.ts +2 -2
  70. package/dist/runtime/app/composables/sse.d.ts +20 -33
  71. package/dist/runtime/app/composables/sse.mjs +6 -3
  72. package/dist/runtime/app/composables/storage.d.ts +6 -8
  73. package/dist/runtime/app/composables/store.d.ts +37 -36
  74. package/dist/runtime/app/composables/store.mjs +7 -6
  75. package/dist/runtime/app/composables/studio.d.ts +59 -0
  76. package/dist/runtime/app/composables/studio.mjs +129 -0
  77. package/dist/runtime/app/composables/tenant.d.ts +7 -7
  78. package/dist/runtime/app/composables/turnstile.d.ts +5 -5
  79. package/dist/runtime/app/composables/two-factor.d.ts +5 -5
  80. package/dist/runtime/app/pages/devtools/notifications.vue +1 -6
  81. package/dist/runtime/app/plugins/pwa.mjs +1 -3
  82. package/dist/runtime/app/utils/cms-editor.d.ts +25 -0
  83. package/dist/runtime/app/utils/cms-editor.mjs +43 -0
  84. package/dist/runtime/auth.d.ts +9 -9
  85. package/dist/runtime/blob.d.ts +1 -3
  86. package/dist/runtime/blob.mjs +3 -1
  87. package/dist/runtime/cache.d.ts +8 -6
  88. package/dist/runtime/cache.mjs +8 -11
  89. package/dist/runtime/db.d.ts +4 -3
  90. package/dist/runtime/drizzle.d.ts +2 -1
  91. package/dist/runtime/drizzle.mjs +2 -2
  92. package/dist/runtime/queue.d.ts +1 -0
  93. package/dist/runtime/replica.d.ts +6 -10
  94. package/dist/runtime/replica.mjs +3 -1
  95. package/dist/runtime/schema-mysql.d.ts +16 -32
  96. package/dist/runtime/schema-pg.d.ts +15 -31
  97. package/dist/runtime/schema-shared.d.ts +20 -17
  98. package/dist/runtime/schema.d.ts +21 -33
  99. package/dist/runtime/server/durable-objects/agent.mjs +4 -1
  100. package/dist/runtime/server/durable-objects/room.d.ts +4 -6
  101. package/dist/runtime/server/durable-objects/room.mjs +18 -8
  102. package/dist/runtime/server/plugins/comments.d.ts +2 -3
  103. package/dist/runtime/server/plugins/email-inbound.d.ts +1 -3
  104. package/dist/runtime/server/plugins/store.d.ts +2 -3
  105. package/dist/runtime/server/routes/__qarpeo/cloud/agents/run.post.d.ts +2 -2
  106. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.get.mjs +10 -2
  107. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.d.ts +2 -2
  108. package/dist/runtime/server/routes/__qarpeo/cloud/cms/entry.post.mjs +10 -2
  109. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.d.ts +2 -2
  110. package/dist/runtime/server/routes/__qarpeo/cloud/cms.get.mjs +7 -1
  111. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.d.ts +2 -2
  112. package/dist/runtime/server/routes/__qarpeo/cloud/comments/moderate.post.mjs +5 -1
  113. package/dist/runtime/server/routes/__qarpeo/cloud/comments.get.d.ts +1 -3
  114. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.d.ts +2 -2
  115. package/dist/runtime/server/routes/__qarpeo/cloud/extras.get.mjs +15 -4
  116. package/dist/runtime/server/routes/__qarpeo/cloud/mail/unsuppress.post.d.ts +2 -2
  117. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/cms.post.mjs +13 -4
  118. package/dist/runtime/server/routes/__qarpeo/cloud/migrate/products.post.mjs +1 -1
  119. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.d.ts +3 -3
  120. package/dist/runtime/server/routes/__qarpeo/cloud/migrate.post.mjs +22 -6
  121. package/dist/runtime/server/routes/__qarpeo/cloud/notifications/test.post.d.ts +2 -2
  122. package/dist/runtime/server/routes/__qarpeo/cloud/operations.get.d.ts +6 -5
  123. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.d.ts +1 -3
  124. package/dist/runtime/server/routes/__qarpeo/cloud/store/order-status.post.mjs +14 -2
  125. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.d.ts +1 -3
  126. package/dist/runtime/server/routes/__qarpeo/cloud/store/orders.get.mjs +7 -1
  127. package/dist/runtime/server/routes/__qarpeo/cloud/store/products.get.d.ts +1 -3
  128. package/dist/runtime/server/routes/__qarpeo/cloud/tasks/run.post.d.ts +2 -2
  129. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.d.ts +2 -2
  130. package/dist/runtime/server/routes/__qarpeo/cloud/users/action.post.mjs +5 -1
  131. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.d.ts +6 -5
  132. package/dist/runtime/server/routes/__qarpeo/cloud/users.get.mjs +1 -3
  133. package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +2 -2
  134. package/dist/runtime/server/routes/__qarpeo/manifest.get.d.ts +2 -2
  135. package/dist/runtime/server/routes/__qarpeo/og.get.d.ts +2 -2
  136. package/dist/runtime/server/routes/__qarpeo/rbac/me.get.d.ts +2 -2
  137. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.d.ts +2 -2
  138. package/dist/runtime/server/routes/__qarpeo/rbac/roles.delete.mjs +5 -1
  139. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.d.ts +2 -2
  140. package/dist/runtime/server/routes/__qarpeo/rbac/roles.get.mjs +1 -5
  141. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.d.ts +2 -2
  142. package/dist/runtime/server/routes/__qarpeo/rbac/roles.post.mjs +5 -1
  143. package/dist/runtime/server/routes/__qarpeo/rbac/users.post.d.ts +2 -2
  144. package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +1 -6
  145. package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +1 -6
  146. package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +1 -6
  147. package/dist/runtime/server/routes/auth/2fa/disable.post.mjs +5 -1
  148. package/dist/runtime/server/routes/auth/2fa/verify.post.mjs +7 -1
  149. package/dist/runtime/server/routes/auth/magic-link/send.post.mjs +1 -1
  150. package/dist/runtime/server/routes/auth/otp/send.post.mjs +1 -1
  151. package/dist/runtime/server/routes/cms/search.get.mjs +2 -6
  152. package/dist/runtime/server/routes/comments/[id]/report.post.mjs +1 -4
  153. package/dist/runtime/server/routes/comments/[id].patch.mjs +1 -4
  154. package/dist/runtime/server/routes/comments/batch.post.mjs +1 -3
  155. package/dist/runtime/server/routes/comments/index.post.mjs +1 -5
  156. package/dist/runtime/server/routes/fate.mjs +1 -1
  157. package/dist/runtime/server/routes/mail/webhooks.post.mjs +1 -1
  158. package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
  159. package/dist/runtime/server/routes/storage/presigned-r2.post.d.ts +5 -6
  160. package/dist/runtime/server/routes/storage/presigned-r2.post.mjs +1 -1
  161. package/dist/runtime/server/routes/store/cart/items/[id].delete.mjs +1 -1
  162. package/dist/runtime/server/routes/store/cart/items/[id].patch.mjs +1 -1
  163. package/dist/runtime/server/routes/store/currencies.get.mjs +1 -4
  164. package/dist/runtime/server/routes/store/orders/[id].get.mjs +1 -1
  165. package/dist/runtime/server/routes/store/orders/download/[token].get.mjs +13 -4
  166. package/dist/runtime/server/routes/store/orders/index.get.mjs +1 -1
  167. package/dist/runtime/server/routes/store/tax/calculate.post.d.ts +2 -1
  168. package/dist/runtime/server/routes/store/tax/calculate.post.mjs +12 -3
  169. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +4 -1
  170. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +4 -1
  171. package/dist/runtime/server/utils/ai.d.ts +38 -35
  172. package/dist/runtime/server/utils/ai.mjs +7 -11
  173. package/dist/runtime/server/utils/analytics-query.d.ts +4 -4
  174. package/dist/runtime/server/utils/auth.d.ts +25 -25
  175. package/dist/runtime/server/utils/auth.mjs +22 -8
  176. package/dist/runtime/server/utils/bots.d.ts +7 -7
  177. package/dist/runtime/server/utils/browser-utils.d.ts +26 -27
  178. package/dist/runtime/server/utils/cache.d.ts +20 -20
  179. package/dist/runtime/server/utils/cms/collections.mjs +1 -6
  180. package/dist/runtime/server/utils/cms/common.mjs +1 -0
  181. package/dist/runtime/server/utils/cms/markdown.d.ts +2 -2
  182. package/dist/runtime/server/utils/cms/markdown.mjs +5 -5
  183. package/dist/runtime/server/utils/cms/mutations.mjs +8 -23
  184. package/dist/runtime/server/utils/cms/navigation.mjs +4 -4
  185. package/dist/runtime/server/utils/cms/path.d.ts +1 -0
  186. package/dist/runtime/server/utils/cms/path.mjs +8 -2
  187. package/dist/runtime/server/utils/cms/references.mjs +1 -7
  188. package/dist/runtime/server/utils/cms/search.d.ts +2 -2
  189. package/dist/runtime/server/utils/cms/sync.mjs +4 -2
  190. package/dist/runtime/server/utils/cms/taxonomy.d.ts +2 -2
  191. package/dist/runtime/server/utils/cms.d.ts +1 -1
  192. package/dist/runtime/server/utils/cms.mjs +1 -5
  193. package/dist/runtime/server/utils/comments-filter.d.ts +9 -7
  194. package/dist/runtime/server/utils/comments.d.ts +68 -55
  195. package/dist/runtime/server/utils/comments.mjs +21 -9
  196. package/dist/runtime/server/utils/config.d.ts +2 -2
  197. package/dist/runtime/server/utils/console.d.ts +3 -5
  198. package/dist/runtime/server/utils/context.d.ts +10 -10
  199. package/dist/runtime/server/utils/crypto.d.ts +20 -20
  200. package/dist/runtime/server/utils/domains.mjs +3 -1
  201. package/dist/runtime/server/utils/drizzle.d.ts +24 -25
  202. package/dist/runtime/server/utils/drizzle.mjs +17 -17
  203. package/dist/runtime/server/utils/durable-object.d.ts +27 -25
  204. package/dist/runtime/server/utils/durable-object.mjs +3 -10
  205. package/dist/runtime/server/utils/email-inbound.d.ts +10 -10
  206. package/dist/runtime/server/utils/impersonation.d.ts +18 -18
  207. package/dist/runtime/server/utils/legacy-hash.d.ts +23 -27
  208. package/dist/runtime/server/utils/lock.d.ts +20 -23
  209. package/dist/runtime/server/utils/mail.d.ts +19 -19
  210. package/dist/runtime/server/utils/mail.mjs +4 -2
  211. package/dist/runtime/server/utils/mcp.d.ts +20 -20
  212. package/dist/runtime/server/utils/mcp.mjs +22 -38
  213. package/dist/runtime/server/utils/notifications.d.ts +49 -38
  214. package/dist/runtime/server/utils/oauth.d.ts +3 -9
  215. package/dist/runtime/server/utils/organization.d.ts +28 -28
  216. package/dist/runtime/server/utils/organization.mjs +15 -5
  217. package/dist/runtime/server/utils/passwordless.d.ts +24 -24
  218. package/dist/runtime/server/utils/payments/checkout.d.ts +12 -12
  219. package/dist/runtime/server/utils/payments/checkout.mjs +1 -3
  220. package/dist/runtime/server/utils/payments/common.d.ts +3 -3
  221. package/dist/runtime/server/utils/payments/paddle.d.ts +4 -1
  222. package/dist/runtime/server/utils/payments/polar.d.ts +4 -1
  223. package/dist/runtime/server/utils/payments/stripe.mjs +5 -7
  224. package/dist/runtime/server/utils/payments/subscriptions.d.ts +14 -14
  225. package/dist/runtime/server/utils/payments/subscriptions.mjs +2 -6
  226. package/dist/runtime/server/utils/payments/usage.mjs +1 -3
  227. package/dist/runtime/server/utils/payments/webhooks.mjs +2 -2
  228. package/dist/runtime/server/utils/queue.d.ts +54 -58
  229. package/dist/runtime/server/utils/queue.mjs +2 -6
  230. package/dist/runtime/server/utils/rag.d.ts +23 -23
  231. package/dist/runtime/server/utils/rag.mjs +10 -5
  232. package/dist/runtime/server/utils/ratelimit.d.ts +21 -18
  233. package/dist/runtime/server/utils/rbac.d.ts +13 -15
  234. package/dist/runtime/server/utils/rbac.mjs +44 -10
  235. package/dist/runtime/server/utils/realtime.d.ts +53 -52
  236. package/dist/runtime/server/utils/role-env.d.ts +5 -4
  237. package/dist/runtime/server/utils/scheduled-task.d.ts +14 -15
  238. package/dist/runtime/server/utils/session.d.ts +40 -40
  239. package/dist/runtime/server/utils/sse.d.ts +23 -33
  240. package/dist/runtime/server/utils/sse.mjs +5 -14
  241. package/dist/runtime/server/utils/sso.mjs +3 -1
  242. package/dist/runtime/server/utils/storage.d.ts +20 -22
  243. package/dist/runtime/server/utils/storage.mjs +2 -2
  244. package/dist/runtime/server/utils/store/cart.d.ts +5 -3
  245. package/dist/runtime/server/utils/store/cart.mjs +14 -10
  246. package/dist/runtime/server/utils/store/checkout.mjs +4 -1
  247. package/dist/runtime/server/utils/store/common.d.ts +1 -1
  248. package/dist/runtime/server/utils/store/common.mjs +36 -12
  249. package/dist/runtime/server/utils/store/inventory.mjs +3 -1
  250. package/dist/runtime/server/utils/store/orders.mjs +32 -24
  251. package/dist/runtime/server/utils/store-localization.d.ts +9 -27
  252. package/dist/runtime/server/utils/store-localization.mjs +3 -3
  253. package/dist/runtime/server/utils/table-names.d.ts +15 -15
  254. package/dist/runtime/server/utils/table-names.mjs +1 -1
  255. package/dist/runtime/server/utils/tenant.d.ts +12 -12
  256. package/dist/runtime/server/utils/tenant.mjs +7 -4
  257. package/dist/runtime/server/utils/totp.d.ts +18 -18
  258. package/dist/runtime/server/utils/tracker.d.ts +5 -5
  259. package/dist/runtime/server/utils/turnstile.d.ts +9 -9
  260. package/dist/runtime/server/utils/urn.d.ts +5 -8
  261. package/dist/runtime/server/utils/workflows.d.ts +30 -31
  262. package/dist/runtime/server/utils/workflows.mjs +2 -4
  263. package/dist/runtime/server.d.ts +2 -2
  264. package/dist/runtime/service.d.ts +10 -10
  265. package/dist/runtime/test-utils.d.ts +10 -10
  266. package/dist/runtime/test-utils.mjs +9 -2
  267. package/dist/runtime/types/ai.d.ts +14 -14
  268. package/dist/runtime/types/d1.d.ts +6 -11
  269. package/dist/runtime/types/durable-object.d.ts +4 -8
  270. package/dist/runtime/types/email.d.ts +3 -9
  271. package/dist/runtime/types/index.d.ts +15 -21
  272. package/dist/runtime/types/r2.d.ts +5 -5
  273. package/dist/runtime/types/workflows.d.ts +5 -6
  274. package/dist/runtime/workflows.d.ts +1 -3
  275. package/dist/types/ai.d.ts +10 -17
  276. package/dist/types/auth.d.ts +5 -3
  277. package/dist/types/cache.d.ts +7 -7
  278. package/dist/types/cms.d.ts +30 -5
  279. package/dist/types/comments.d.ts +23 -21
  280. package/dist/types/console.d.ts +1 -3
  281. package/dist/types/db.d.ts +7 -7
  282. package/dist/types/index.d.ts +1 -0
  283. package/dist/types/options.d.ts +36 -24
  284. package/dist/types/site.d.ts +8 -2
  285. package/dist/types/storage.d.ts +2 -1
  286. package/dist/types/store-options.d.ts +10 -26
  287. package/dist/types/studio.d.ts +79 -0
  288. package/dist/utils/bots.d.ts +7 -3
  289. package/dist/utils/cms-table-names.d.ts +1 -1
  290. package/dist/utils/drizzle.d.ts +13 -14
  291. package/dist/utils/email-inbound.d.ts +4 -4
  292. package/dist/utils/features.d.ts +19 -5
  293. package/dist/utils/mcp.d.ts +1 -0
  294. package/dist/utils/migration-lock.d.ts +15 -29
  295. package/dist/utils/pkg.d.ts +6 -7
  296. package/dist/utils/schema-diff.d.ts +7 -11
  297. package/dist/utils/store-schema.d.ts +4 -6
  298. package/dist/utils/tools.d.ts +3 -3
  299. package/package.json +55 -5
@@ -147,9 +147,7 @@ export class InMemorySqlStorage {
147
147
  filteredRows = filteredRows.slice(0, limitVal);
148
148
  }
149
149
  if (/COUNT\s*\(\s*\*\s*\)/i.test(selectFields)) {
150
- const countRows = [
151
- { "count(*)": filteredRows.length, count: filteredRows.length }
152
- ];
150
+ const countRows = [{ "count(*)": filteredRows.length, count: filteredRows.length }];
153
151
  return new InMemorySqlStorageCursor(countRows, ["count"], rowsRead, 0);
154
152
  }
155
153
  let resultRows;
@@ -173,9 +171,7 @@ export class InMemorySqlStorage {
173
171
  return new InMemorySqlStorageCursor([], [], 0, 0);
174
172
  }
175
173
  if (upper.startsWith("UPDATE")) {
176
- const match = trimmed.match(
177
- /UPDATE\s+([^\s]+)\s+SET\s+([\s\S]+?)(?:\s+WHERE\s+([\s\S]+))?$/i
178
- );
174
+ const match = trimmed.match(/UPDATE\s+([^\s]+)\s+SET\s+([\s\S]+?)(?:\s+WHERE\s+([\s\S]+))?$/i);
179
175
  if (match) {
180
176
  const tableName = match[1].replace(/["`]/g, "").trim().toLowerCase();
181
177
  const setClause = match[2].trim();
@@ -503,10 +499,7 @@ async function dispatchHttpRpc(instance, request) {
503
499
  const result = await instance[methodName](...args);
504
500
  return Response.json({ success: true, result });
505
501
  } catch (err) {
506
- return Response.json(
507
- { success: false, error: err?.message || String(err) },
508
- { status: 500 }
509
- );
502
+ return Response.json({ success: false, error: err?.message || String(err) }, { status: 500 });
510
503
  }
511
504
  }
512
505
  function createSimulatedNamespace(bindingNameOrClass) {
@@ -3,27 +3,27 @@ import type { InboundEmailContext, InboundEmailHandler } from "../../types/email
3
3
  * Defines an inbound email handler for Cloudflare Email Workers.
4
4
  *
5
5
  * @example
6
- * ```ts [server/email/incoming.ts]
7
- * export default defineEmailHandler(async ({ message, forward, reply }) => {
6
+ * ```ts [server/email/incoming.ts]
7
+ * export default defineEmailHandler(async ({ message, forward, reply }) => {
8
8
  * console.log("From:", message.from)
9
9
  * console.log("Subject:", message.headers.get("subject"))
10
10
  * const text = await message.text()
11
11
  *
12
12
  * if (message.from.endsWith("@spam.com")) {
13
- * message.setReject("Spam not accepted")
14
- * return
13
+ * message.setReject("Spam not accepted")
14
+ * return
15
15
  * }
16
16
  *
17
17
  * await reply({
18
- * subject: "Received your message",
19
- * text: "Thank you for contacting us!",
18
+ * subject: "Received your message",
19
+ * text: "Thank you for contacting us!",
20
20
  * })
21
- * })
22
- * ```
21
+ * })
22
+ * ```
23
23
  */
24
24
  export declare function defineEmailHandler(handler: InboundEmailHandler): InboundEmailHandler;
25
25
  /**
26
- * Wraps raw Cloudflare `ForwardableEmailMessage` (or a mock/simulated message)
27
- * into a typed, convenient InboundEmailContext.
26
+ * Wraps raw Cloudflare `ForwardableEmailMessage` (or a mock/simulated message) into a typed,
27
+ * convenient InboundEmailContext.
28
28
  */
29
29
  export declare function createInboundEmailContext(rawMessage: any, env?: any, ctx?: any): InboundEmailContext;
@@ -5,9 +5,9 @@ import type { QarpeoUser } from "../../types/auth";
5
5
  * The admin's original identity is preserved in `session.impersonator`.
6
6
  *
7
7
  * @example
8
- * ```ts
9
- * const { user } = await startImpersonation(event, targetUserId)
10
- * ```
8
+ * ```ts
9
+ * const { user } = await startImpersonation(event, targetUserId)
10
+ * ```
11
11
  */
12
12
  export declare function startImpersonation(event: RequestEvent, targetUserId: string): Promise<{
13
13
  success: boolean;
@@ -17,9 +17,9 @@ export declare function startImpersonation(event: RequestEvent, targetUserId: st
17
17
  * Stops impersonation and restores the admin's original identity.
18
18
  *
19
19
  * @example
20
- * ```ts
21
- * const { user } = await stopImpersonation(event)
22
- * ```
20
+ * ```ts
21
+ * const { user } = await stopImpersonation(event)
22
+ * ```
23
23
  */
24
24
  export declare function stopImpersonation(event: RequestEvent): Promise<{
25
25
  success: boolean;
@@ -30,12 +30,12 @@ export declare function stopImpersonation(event: RequestEvent): Promise<{
30
30
  * the SHA-256 hash is stored.
31
31
  *
32
32
  * @example
33
- * ```ts
34
- * const { token, id } = await createApiToken(event, {
35
- * name: "CLI Token",
36
- * scopes: ["read", "write"],
37
- * })
38
- * ```
33
+ * ```ts
34
+ * const { token, id } = await createApiToken(event, {
35
+ * name: "CLI Token",
36
+ * scopes: ["read", "write"],
37
+ * })
38
+ * ```
39
39
  */
40
40
  export declare function createApiToken(event: RequestEvent, input: {
41
41
  name: string;
@@ -67,9 +67,9 @@ export declare function revokeApiToken(event: RequestEvent, tokenId: string): Pr
67
67
  * token metadata if valid; throws 401 if invalid/expired.
68
68
  *
69
69
  * @example
70
- * ```ts
71
- * const { user, scopes } = await verifyApiToken(event, rawToken)
72
- * ```
70
+ * ```ts
71
+ * const { user, scopes } = await verifyApiToken(event, rawToken)
72
+ * ```
73
73
  */
74
74
  export declare function verifyApiToken(event: RequestEvent, rawToken: string): Promise<{
75
75
  user: QarpeoUser;
@@ -84,9 +84,9 @@ export declare function hasApiTokenScope(scopes: string[], required: string): bo
84
84
  * no/invalid token. Returns the verified token context.
85
85
  *
86
86
  * @example
87
- * ```ts
88
- * const { user, scopes } = await requireApiToken(event, { scope: "read:files" })
89
- * ```
87
+ * ```ts
88
+ * const { user, scopes } = await requireApiToken(event, { scope: "read:files" })
89
+ * ```
90
90
  */
91
91
  export declare function requireApiToken(event: RequestEvent, options?: {
92
92
  scope?: string;
@@ -1,18 +1,20 @@
1
1
  /**
2
2
  * Legacy password hash verification helpers for migrating users from other auth systems.
3
3
  *
4
- * Better Auth uses `scrypt` (via `@noble/hashes/scrypt`) for all new hashes. This module
5
- * provides pure-Web-Crypto / pure-JS fallbacks to verify passwords stored in older formats so
6
- * that users can log in with their existing password, which is then transparently re-hashed to
7
- * scrypt on successful verification.
4
+ * Better Auth uses `scrypt` (via `@noble/hashes/scrypt`) for all new hashes. This module provides
5
+ * pure-Web-Crypto / pure-JS fallbacks to verify passwords stored in older formats so that users can
6
+ * log in with their existing password, which is then transparently re-hashed to scrypt on
7
+ * successful verification.
8
8
  *
9
9
  * Supported legacy formats:
10
- * - bcrypt — `$2a$`, `$2b$`, `$2x$`, `$2y$` prefix (requires `bcryptjs` dev dep)
11
- * - Django PBKDF2-SHA256 — `pbkdf2_sha256$<iterations>$<salt>$<hash>` format (pure Web Crypto)
12
- * - SHA-1 — 40-char hex (plain SHA-1, common in very old Rails / PHP apps)
13
- * - MD5 — 32-char hex (plain MD5 — not supported, Web Crypto lacks MD5)
10
+ *
11
+ * - Bcrypt — `$2a$`, `$2b$`, `$2x$`, `$2y$` prefix (requires `bcryptjs` dev dep)
12
+ * - Django PBKDF2-SHA256 — `pbkdf2_sha256$<iterations>$<salt>$<hash>` format (pure Web Crypto)
13
+ * - SHA-1 — 40-char hex (plain SHA-1, common in very old Rails / PHP apps)
14
+ * - MD5 — 32-char hex (plain MD5 — not supported, Web Crypto lacks MD5)
14
15
  *
15
16
  * Usage in `defineQarpeoAuth`:
17
+ *
16
18
  * ```ts
17
19
  * emailAndPassword: {
18
20
  * verifyLegacyPassword: async (password, hash) => {
@@ -21,43 +23,37 @@
21
23
  * }
22
24
  * ```
23
25
  */
24
- /**
25
- * Returns true if `hash` looks like a bcrypt hash (`$2a$`, `$2b$`, `$2x$`, `$2y$`).
26
- */
26
+ /** Returns true if `hash` looks like a bcrypt hash (`$2a$`, `$2b$`, `$2x$`, `$2y$`). */
27
27
  export declare function isBcryptHash(hash: string): boolean;
28
28
  /**
29
29
  * Verifies a password against a bcrypt hash using `bcryptjs` (pure JS, works on CF Workers).
30
- * Returns `false` if `bcryptjs` is not installed — install it as a dev dependency and add it
31
- * to `optimizeDeps.include` / `noExternal` if needed.
30
+ * Returns `false` if `bcryptjs` is not installed — install it as a dev dependency and add it to
31
+ * `optimizeDeps.include` / `noExternal` if needed.
32
32
  */
33
33
  export declare function verifyBcrypt(password: string, hash: string): Promise<boolean>;
34
34
  /**
35
- * Returns true if `hash` is a Django-style PBKDF2-SHA256 hash.
36
- * Format: `pbkdf2_sha256$<iterations>$<salt>$<hash_base64>`
35
+ * Returns true if `hash` is a Django-style PBKDF2-SHA256 hash. Format:
36
+ * `pbkdf2_sha256$<iterations>$<salt>$<hash_base64>`
37
37
  */
38
38
  export declare function isDjangoPbkdf2Hash(hash: string): boolean;
39
39
  /**
40
- * Verifies a password against a Django PBKDF2-SHA256 hash using the Web Crypto API.
41
- * This works without any external library on Cloudflare Workers.
40
+ * Verifies a password against a Django PBKDF2-SHA256 hash using the Web Crypto API. This works
41
+ * without any external library on Cloudflare Workers.
42
42
  */
43
43
  export declare function verifyDjangoPbkdf2(password: string, hash: string): Promise<boolean>;
44
- /**
45
- * Returns true if `hash` looks like a plain 40-char hex SHA-1 digest.
46
- */
44
+ /** Returns true if `hash` looks like a plain 40-char hex SHA-1 digest. */
47
45
  export declare function isSha1Hash(hash: string): boolean;
48
46
  /**
49
- * Verifies a password against a plain SHA-1 hex hash using Web Crypto.
50
- * Note: SHA-1 is cryptographically broken — this is provided only for migration.
47
+ * Verifies a password against a plain SHA-1 hex hash using Web Crypto. Note: SHA-1 is
48
+ * cryptographically broken — this is provided only for migration.
51
49
  */
52
50
  export declare function verifySha1(password: string, hash: string): Promise<boolean>;
53
51
  export type LegacyHashType = "bcrypt" | "pbkdf2_sha256" | "sha1" | "unknown";
54
- /**
55
- * Detects the hash type from the hash string.
56
- */
52
+ /** Detects the hash type from the hash string. */
57
53
  export declare function detectHashType(hash: string): LegacyHashType;
58
54
  /**
59
- * Verifies a password against any supported legacy hash format.
60
- * Returns `{ valid: boolean; type: LegacyHashType }`.
55
+ * Verifies a password against any supported legacy hash format. Returns `{ valid: boolean; type:
56
+ * LegacyHashType }`.
61
57
  *
62
58
  * Use this inside `verifyLegacyPassword` callback in `defineQarpeoAuth` options:
63
59
  *
@@ -1,22 +1,19 @@
1
1
  import type { CFEvent } from "../../types/index";
2
2
  export interface LockOptions {
3
3
  /**
4
- * Time-to-live for the lock, e.g. "5 minutes", "30 seconds", or milliseconds.
5
- * Prevents deadlocks if the isolate or worker terminates unexpectedly.
4
+ * Time-to-live for the lock, e.g. "5 minutes", "30 seconds", or milliseconds. Prevents deadlocks
5
+ * if the isolate or worker terminates unexpectedly.
6
6
  *
7
7
  * @default "5 minutes" (300,000ms)
8
8
  */
9
9
  ttl?: string | number;
10
- /**
11
- * Optional event context for resolving Cloudflare bindings.
12
- */
10
+ /** Optional event context for resolving Cloudflare bindings. */
13
11
  event?: CFEvent;
14
- /**
15
- * Custom lock token (identifier of the lock holder). Defaults to random UUID.
16
- */
12
+ /** Custom lock token (identifier of the lock holder). Defaults to random UUID. */
17
13
  token?: string;
18
14
  /**
19
15
  * Behavior when the lock cannot be acquired:
16
+ *
20
17
  * - `"return"` (default): return null / false
21
18
  * - `"throw"`: throw a LockConflictError
22
19
  */
@@ -50,32 +47,32 @@ export declare function acquireLock(key: string, options?: LockOptions): Promise
50
47
  */
51
48
  export declare function releaseLock(key: string, token: string, event?: CFEvent): Promise<boolean>;
52
49
  /**
53
- * Runs an asynchronous callback within a distributed lock.
54
- * Automatically acquires the lock before running and releases it afterwards,
55
- * ensuring proper cleanup even if the callback throws an error.
50
+ * Runs an asynchronous callback within a distributed lock. Automatically acquires the lock before
51
+ * running and releases it afterwards, ensuring proper cleanup even if the callback throws an
52
+ * error.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const result = await withLock("sync-inventory", { ttl: "2 minutes" }, async () => {
57
+ * return await syncProductsFromShopify()
58
+ * })
59
+ * ```
56
60
  *
57
61
  * @param key Unique lock resource key
58
62
  * @param optionsOrCallback LockOptions or callback function
59
63
  * @param maybeCallback Callback function when options are provided as second argument
60
64
  * @returns Result of callback, or `null` if the lock could not be acquired
61
- *
62
- * @example
63
- * ```ts
64
- * const result = await withLock("sync-inventory", { ttl: "2 minutes" }, async () => {
65
- * return await syncProductsFromShopify()
66
- * })
67
- * ```
68
65
  */
69
66
  export declare function withLock<T>(key: string, optionsOrCallback: LockOptions | (() => Promise<T> | T), maybeCallback?: () => Promise<T> | T): Promise<T | null>;
70
67
  /**
71
68
  * Convenience helper to run a database migration callback with an exclusive distributed lock.
72
69
  *
73
70
  * @example
74
- * ```ts
75
- * await withMigrationLock("analytics", { ttl: "10m" }, async () => {
76
- * await runDrizzleMigrations()
77
- * })
78
- * ```
71
+ * ```ts
72
+ * await withMigrationLock("analytics", { ttl: "10m" }, async () => {
73
+ * await runDrizzleMigrations()
74
+ * })
75
+ * ```
79
76
  */
80
77
  export declare function withMigrationLock<T>(dbName: string, optionsOrCallback: LockOptions | (() => Promise<T> | T), maybeCallback?: () => Promise<T> | T): Promise<T | null>;
81
78
  /** Clears all in-memory locks (used during test teardown). */
@@ -65,22 +65,22 @@ export declare function deliverMailDirect(options: {
65
65
  * tracking, queue-backed delivery, and dev mailbox capture.
66
66
  *
67
67
  * @example
68
- * ```ts
69
- * // Markdown content:
70
- * await sendMail({
71
- * to: "user@example.com",
72
- * subject: "Welcome to Acme",
73
- * markdown:
74
- * "# Welcome!\nWe are glad you joined us.\n\n[btn: Go to Dashboard](https://myapp.com)",
75
- * })
68
+ * ```ts
69
+ * // Markdown content:
70
+ * await sendMail({
71
+ * to: "user@example.com",
72
+ * subject: "Welcome to Acme",
73
+ * markdown:
74
+ * "# Welcome!\nWe are glad you joined us.\n\n[btn: Go to Dashboard](https://myapp.com)",
75
+ * })
76
76
  *
77
- * // Template:
78
- * await sendMail({
79
- * to: "user@example.com",
80
- * template: "welcome",
81
- * data: { name: "Alice", actionUrl: "https://myapp.com/dashboard" },
82
- * })
83
- * ```
77
+ * // Template:
78
+ * await sendMail({
79
+ * to: "user@example.com",
80
+ * template: "welcome",
81
+ * data: { name: "Alice", actionUrl: "https://myapp.com/dashboard" },
82
+ * })
83
+ * ```
84
84
  */
85
85
  export declare function sendMail(request: SendMailRequest, event?: RequestEvent): Promise<MailResult>;
86
86
  export interface UseMailReturn {
@@ -93,10 +93,10 @@ export interface UseMailReturn {
93
93
  * Access the Qarpeo Transactional Mail client.
94
94
  *
95
95
  * @example
96
- * ```ts
97
- * const mail = useMail(event)
98
- * await mail.send({ to: "user@example.com", subject: "Hello", text: "Welcome" })
99
- * ```
96
+ * ```ts
97
+ * const mail = useMail(event)
98
+ * await mail.send({ to: "user@example.com", subject: "Hello", text: "Welcome" })
99
+ * ```
100
100
  */
101
101
  export declare function useMail(event?: RequestEvent): UseMailReturn;
102
102
  export { suppressEmail, isEmailSuppressed, unsuppressEmail, listSuppressedEmails, recordSoftBounce, generateUnsubscribeToken, verifyUnsubscribeToken, buildListUnsubscribeHeaders, } from "./mail-suppression";
@@ -1,8 +1,8 @@
1
1
  import { resolveRuntimeBinding } from "../../bindings.mjs";
2
2
  import { sendEmail } from "../../email.mjs";
3
3
  import { useQueue } from "../../queue.mjs";
4
- import { renderEmailTemplate, renderMarkdownEmail } from "./email-templates.mjs";
5
4
  import { signHmacSha256 } from "./crypto.mjs";
5
+ import { renderEmailTemplate, renderMarkdownEmail } from "./email-templates.mjs";
6
6
  import { buildListUnsubscribeHeaders, isEmailSuppressed } from "./mail-suppression.mjs";
7
7
  function getSharedMailbox() {
8
8
  return globalThis.__qarpeo_dev_mailbox__ ||= [];
@@ -52,7 +52,9 @@ export async function injectEmailTracking(html, options) {
52
52
  }
53
53
  }
54
54
  for (const match of matches) {
55
- const sig = await signHmacSha256(`${options.messageId}:${match.href}`, options.secret).catch(() => "");
55
+ const sig = await signHmacSha256(`${options.messageId}:${match.href}`, options.secret).catch(
56
+ () => ""
57
+ );
56
58
  const sigParam = sig ? `&sig=${encodeURIComponent(sig)}` : "";
57
59
  const trackUrl = `${base}/__qarpeo/mail/track/click/${encodeURIComponent(options.messageId)}?url=${encodeURIComponent(match.href)}${sigParam}`;
58
60
  result = result.replace(match.full, `<a${match.prefix}href="${trackUrl}"${match.suffix}>`);
@@ -4,7 +4,7 @@ import type { McpServerDefinition, McpTool, McpClient, McpClientOptions } from "
4
4
  * Converts Qarpeo AgentTool array or record to MCP tool descriptors.
5
5
  *
6
6
  * @example
7
- * const mcpTools = agentToolsToMcpTools({ search: defineTool({ ... }) })
7
+ * const mcpTools = agentToolsToMcpTools({ search: defineTool({ ... }) })
8
8
  */
9
9
  export declare function agentToolsToMcpTools(tools: Record<string, AgentTool> | AgentTool[] | undefined): McpTool[];
10
10
  /**
@@ -13,31 +13,31 @@ export declare function agentToolsToMcpTools(tools: Record<string, AgentTool> |
13
13
  * The returned handler can be used directly in a Nuxt server route:
14
14
  *
15
15
  * @example
16
- * ```ts
17
- * // server/routes/mcp.post.ts
18
- * export default defineMcpServer({
19
- * name: "my-mcp",
20
- * version: "1.0.0",
21
- * tools: {
22
- * search: defineTool({
23
- * description: "Search the database",
24
- * parameters: { type: "object", properties: { q: { type: "string" } } },
25
- * execute: async ({ q }) => db.search(q),
26
- * }),
27
- * },
28
- * })
29
- * ```
16
+ * ```ts
17
+ * // server/routes/mcp.post.ts
18
+ * export default defineMcpServer({
19
+ * name: "my-mcp",
20
+ * version: "1.0.0",
21
+ * tools: {
22
+ * search: defineTool({
23
+ * description: "Search the database",
24
+ * parameters: { type: "object", properties: { q: { type: "string" } } },
25
+ * execute: async ({ q }) => db.search(q),
26
+ * }),
27
+ * },
28
+ * })
29
+ * ```
30
30
  */
31
31
  export declare function defineMcpServer(definition: McpServerDefinition): (event: any) => Promise<Response>;
32
32
  /**
33
33
  * Creates a typed MCP client that sends JSON-RPC 2.0 requests to a remote MCP server.
34
34
  *
35
35
  * @example
36
- * ```ts
37
- * const client = createMcpClient("https://mcp.example.com/api/mcp")
38
- * const tools = await client.getTools()
39
- * const result = await client.callTool("search", { q: "hello" })
40
- * ```
36
+ * ```ts
37
+ * const client = createMcpClient("https://mcp.example.com/api/mcp")
38
+ * const tools = await client.getTools()
39
+ * const result = await client.callTool("search", { q: "hello" })
40
+ * ```
41
41
  */
42
42
  export declare function createMcpClient(url: string, options?: McpClientOptions): McpClient;
43
43
  /** Alias for {@link createMcpClient}. */
@@ -34,11 +34,7 @@ export function defineMcpServer(definition) {
34
34
  allowed = false;
35
35
  }
36
36
  if (!allowed) {
37
- const errBody = makeErrorResponse(
38
- null,
39
- -32001,
40
- "Unauthorized"
41
- );
37
+ const errBody = makeErrorResponse(null, -32001, "Unauthorized");
42
38
  return new Response(JSON.stringify(errBody), {
43
39
  status: 401,
44
40
  headers: { "Content-Type": "application/json" }
@@ -85,19 +81,21 @@ export function defineMcpServer(definition) {
85
81
  switch (method) {
86
82
  // ── initialize ──────────────────────────────────────────────────────
87
83
  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
- }));
84
+ return jsonRpc(
85
+ makeOkResponse(id, {
86
+ protocolVersion: "2024-11-05",
87
+ capabilities: {
88
+ tools: {},
89
+ resources: {},
90
+ prompts: {}
91
+ },
92
+ serverInfo: {
93
+ name: definition.name,
94
+ version: definition.version ?? "1.0.0"
95
+ },
96
+ ...definition.instructions ? { instructions: definition.instructions } : {}
97
+ })
98
+ );
101
99
  }
102
100
  // ── tools/list ───────────────────────────────────────────────────────
103
101
  case "tools/list": {
@@ -111,9 +109,7 @@ export function defineMcpServer(definition) {
111
109
  const toolList = getAvailableTools(definition.tools);
112
110
  const tool = toolList.find((t) => t.name === toolName);
113
111
  if (!tool) {
114
- return jsonRpc(
115
- makeErrorResponse(id, -32602, `Tool not found: ${toolName}`)
116
- );
112
+ return jsonRpc(makeErrorResponse(id, -32602, `Tool not found: ${toolName}`));
117
113
  }
118
114
  try {
119
115
  const result = await tool.execute(toolArgs);
@@ -144,14 +140,10 @@ export function defineMcpServer(definition) {
144
140
  const uri = params?.uri;
145
141
  const resource = (definition.resources ?? []).find((r) => r.uri === uri);
146
142
  if (!resource) {
147
- return jsonRpc(
148
- makeErrorResponse(id, -32602, `Resource not found: ${uri}`)
149
- );
143
+ return jsonRpc(makeErrorResponse(id, -32602, `Resource not found: ${uri}`));
150
144
  }
151
145
  if (!resource.read) {
152
- return jsonRpc(
153
- makeErrorResponse(id, -32602, `Resource is not readable: ${uri}`)
154
- );
146
+ return jsonRpc(makeErrorResponse(id, -32602, `Resource is not readable: ${uri}`));
155
147
  }
156
148
  const contents = await resource.read(uri, event);
157
149
  const text = typeof contents === "string" ? contents : JSON.stringify(contents);
@@ -176,9 +168,7 @@ export function defineMcpServer(definition) {
176
168
  const promptArgs = params?.arguments ?? {};
177
169
  const prompt = (definition.prompts ?? []).find((p) => p.name === promptName);
178
170
  if (!prompt) {
179
- return jsonRpc(
180
- makeErrorResponse(id, -32602, `Prompt not found: ${promptName}`)
181
- );
171
+ return jsonRpc(makeErrorResponse(id, -32602, `Prompt not found: ${promptName}`));
182
172
  }
183
173
  if (!prompt.get) {
184
174
  return jsonRpc(
@@ -195,18 +185,12 @@ export function defineMcpServer(definition) {
195
185
  }
196
186
  // ── unknown method ───────────────────────────────────────────────────
197
187
  default: {
198
- return jsonRpc(
199
- makeErrorResponse(id, -32601, `Method not found: ${method}`)
200
- );
188
+ return jsonRpc(makeErrorResponse(id, -32601, `Method not found: ${method}`));
201
189
  }
202
190
  }
203
191
  } catch (err) {
204
192
  return jsonRpc(
205
- makeErrorResponse(
206
- id,
207
- -32603,
208
- `Internal error: ${err?.message ?? String(err)}`
209
- )
193
+ makeErrorResponse(id, -32603, `Internal error: ${err?.message ?? String(err)}`)
210
194
  );
211
195
  }
212
196
  };