qarpeo 0.1.18 → 0.1.21

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 (237) hide show
  1. package/README.md +96 -96
  2. package/dist/chunks/auth-schema.mjs +3 -1
  3. package/dist/chunks/wrangler.mjs +22 -3
  4. package/dist/cli/index.mjs +448 -221
  5. package/dist/fate/index.d.ts +29 -22
  6. package/dist/fate/index.mjs +1 -3
  7. package/dist/module.d.ts +1 -1
  8. package/dist/module.mjs +103 -82
  9. package/dist/runtime/ai.d.ts +2 -2
  10. package/dist/runtime/app/components/BlobImage.vue +119 -107
  11. package/dist/runtime/app/components/CMSBlocks.vue +104 -93
  12. package/dist/runtime/app/components/CMSContent.vue +24 -23
  13. package/dist/runtime/app/components/CMSImage.vue +49 -49
  14. package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -110
  15. package/dist/runtime/app/components/CMSPreviewBanner.vue +83 -79
  16. package/dist/runtime/app/components/CMSVersionBanner.vue +53 -49
  17. package/dist/runtime/app/components/CMSVersionSwitcher.vue +140 -140
  18. package/dist/runtime/app/components/ContentRenderer.vue +83 -80
  19. package/dist/runtime/app/components/FileUpload.vue +200 -196
  20. package/dist/runtime/app/components/ImpersonationBanner.vue +61 -57
  21. package/dist/runtime/app/components/QarpeoWelcome.vue +84 -84
  22. package/dist/runtime/app/components/SignedIn.vue +13 -13
  23. package/dist/runtime/app/components/SignedOut.vue +13 -13
  24. package/dist/runtime/app/components/shiki.css +34 -34
  25. package/dist/runtime/app/composables/ai.d.ts +22 -22
  26. package/dist/runtime/app/composables/ai.mjs +3 -7
  27. package/dist/runtime/app/composables/analytics.mjs +1 -1
  28. package/dist/runtime/app/composables/api-tokens.mjs +1 -1
  29. package/dist/runtime/app/composables/auth.d.ts +6 -7
  30. package/dist/runtime/app/composables/auth.mjs +6 -3
  31. package/dist/runtime/app/composables/chat.mjs +3 -7
  32. package/dist/runtime/app/composables/cms-preview.d.ts +3 -3
  33. package/dist/runtime/app/composables/cms-preview.mjs +1 -1
  34. package/dist/runtime/app/composables/cms.d.ts +3 -5
  35. package/dist/runtime/app/composables/cms.mjs +2 -2
  36. package/dist/runtime/app/composables/docs-version.d.ts +8 -7
  37. package/dist/runtime/app/composables/docs-version.mjs +3 -3
  38. package/dist/runtime/app/composables/impersonation.mjs +1 -1
  39. package/dist/runtime/app/composables/notifications.d.ts +5 -5
  40. package/dist/runtime/app/composables/notifications.mjs +4 -5
  41. package/dist/runtime/app/composables/organization.mjs +1 -1
  42. package/dist/runtime/app/composables/passkey.mjs +1 -1
  43. package/dist/runtime/app/composables/passwordless.mjs +1 -1
  44. package/dist/runtime/app/composables/payments.d.ts +2 -1
  45. package/dist/runtime/app/composables/payments.mjs +1 -1
  46. package/dist/runtime/app/composables/realtime.d.ts +13 -13
  47. package/dist/runtime/app/composables/realtime.mjs +2 -2
  48. package/dist/runtime/app/composables/resumable-upload.d.ts +11 -11
  49. package/dist/runtime/app/composables/resumable-upload.mjs +1 -1
  50. package/dist/runtime/app/composables/site.mjs +1 -1
  51. package/dist/runtime/app/composables/storage.d.ts +151 -11
  52. package/dist/runtime/app/composables/storage.mjs +291 -33
  53. package/dist/runtime/app/composables/turnstile.mjs +1 -1
  54. package/dist/runtime/app/composables/two-factor.mjs +1 -1
  55. package/dist/runtime/app/pages/devtools/agents.vue +716 -716
  56. package/dist/runtime/app/pages/devtools/analytics.vue +616 -616
  57. package/dist/runtime/app/pages/devtools/auth.vue +381 -350
  58. package/dist/runtime/app/pages/devtools/blob.vue +743 -744
  59. package/dist/runtime/app/pages/devtools/db.vue +545 -545
  60. package/dist/runtime/app/pages/devtools/domains.vue +771 -771
  61. package/dist/runtime/app/pages/devtools/kv.vue +827 -828
  62. package/dist/runtime/app/pages/devtools/logs.vue +649 -653
  63. package/dist/runtime/app/pages/devtools/mail.vue +388 -388
  64. package/dist/runtime/app/pages/devtools/overview.vue +391 -389
  65. package/dist/runtime/app/pages/devtools/realtime.vue +89 -27
  66. package/dist/runtime/app/pages/devtools/security.vue +20 -5
  67. package/dist/runtime/app/pages/devtools/settings.vue +559 -559
  68. package/dist/runtime/app/pages/devtools/tasks.vue +26 -10
  69. package/dist/runtime/app/pages/devtools.vue +176 -176
  70. package/dist/runtime/app/plugins/seo.mjs +1 -1
  71. package/dist/runtime/app/plugins/shortcuts.client.d.ts +1 -4
  72. package/dist/runtime/app/public/sw-notifications.mjs +47 -52
  73. package/dist/runtime/blob.mjs +11 -4
  74. package/dist/runtime/browser.d.ts +1 -1
  75. package/dist/runtime/browser.mjs +12 -2
  76. package/dist/runtime/cache.d.ts +2 -1
  77. package/dist/runtime/kv.mjs +4 -1
  78. package/dist/runtime/providers/qarpeo.d.ts +3 -3
  79. package/dist/runtime/server/durable-objects/agent.mjs +1 -1
  80. package/dist/runtime/server/durable-objects/room.d.ts +2 -2
  81. package/dist/runtime/server/durable-objects/room.mjs +5 -5
  82. package/dist/runtime/server/middleware/devtools.mjs +6 -2
  83. package/dist/runtime/server/plugins/cms.d.ts +4 -2
  84. package/dist/runtime/server/plugins/dev-proxy.mjs +1 -1
  85. package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +2 -2
  86. package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +4 -1
  87. package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +1 -4
  88. package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +2 -2
  89. package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +5 -1
  90. package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +2 -2
  91. package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +1 -1
  92. package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +4 -1
  93. package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +1 -1
  94. package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +2 -2
  95. package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +2 -2
  96. package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.d.ts +2 -2
  97. package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.mjs +1 -1
  98. package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.d.ts +1 -4
  99. package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.mjs +1 -1
  100. package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.d.ts +1 -4
  101. package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.mjs +1 -1
  102. package/dist/runtime/server/routes/__qarpeo/realtime/room.get.d.ts +2 -2
  103. package/dist/runtime/server/routes/__qarpeo/realtime/rooms.get.d.ts +2 -2
  104. package/dist/runtime/server/routes/__qarpeo/security/analytics.get.d.ts +2 -2
  105. package/dist/runtime/server/routes/__qarpeo/security/ban.post.d.ts +1 -4
  106. package/dist/runtime/server/routes/__qarpeo/security/clear.post.d.ts +1 -4
  107. package/dist/runtime/server/routes/__qarpeo/security/unban.post.d.ts +1 -4
  108. package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +1 -1
  109. package/dist/runtime/server/routes/__qarpeo/tasks/run.post.mjs +3 -1
  110. package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +8 -2
  111. package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +8 -2
  112. package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +8 -2
  113. package/dist/runtime/server/routes/ai/embed.post.d.ts +1 -4
  114. package/dist/runtime/server/routes/ai/search.post.d.ts +2 -2
  115. package/dist/runtime/server/routes/auth/account.delete.mjs +1 -1
  116. package/dist/runtime/server/routes/auth/handler.mjs +6 -1
  117. package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +1 -1
  118. package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +7 -1
  119. package/dist/runtime/server/routes/auth/otp/verify.post.mjs +1 -1
  120. package/dist/runtime/server/routes/auth/sso/login.get.mjs +7 -1
  121. package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +8 -2
  122. package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +7 -2
  123. package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
  124. package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +7 -2
  125. package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +6 -1
  126. package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +6 -1
  127. package/dist/runtime/server/routes/browser/crawl.post.d.ts +1 -2
  128. package/dist/runtime/server/routes/browser/invoice.post.d.ts +1 -2
  129. package/dist/runtime/server/routes/browser/og-image.post.d.ts +2 -2
  130. package/dist/runtime/server/routes/browser/pdf.post.d.ts +1 -2
  131. package/dist/runtime/server/routes/browser/pdf.post.mjs +6 -1
  132. package/dist/runtime/server/routes/browser/screenshot.post.d.ts +2 -2
  133. package/dist/runtime/server/routes/browser/screenshot.post.mjs +5 -1
  134. package/dist/runtime/server/routes/cms/components/index.get.d.ts +2 -2
  135. package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +4 -3
  136. package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +8 -8
  137. package/dist/runtime/server/routes/cms/search.get.mjs +1 -1
  138. package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +7 -7
  139. package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +9 -2
  140. package/dist/runtime/server/routes/docs/search.get.d.ts +9 -9
  141. package/dist/runtime/server/routes/fate.mjs +5 -8
  142. package/dist/runtime/server/routes/mail/bounce.post.d.ts +2 -2
  143. package/dist/runtime/server/routes/mail/unsubscribe.d.ts +2 -2
  144. package/dist/runtime/server/routes/mail/webhooks.post.d.ts +2 -2
  145. package/dist/runtime/server/routes/mail/webhooks.post.mjs +7 -1
  146. package/dist/runtime/server/routes/payments/usage.get.d.ts +8 -8
  147. package/dist/runtime/server/routes/payments/usage.post.d.ts +2 -2
  148. package/dist/runtime/server/routes/realtime/history.delete.d.ts +4 -3
  149. package/dist/runtime/server/routes/realtime/history.get.d.ts +7 -6
  150. package/dist/runtime/server/routes/realtime/ws.get.mjs +6 -1
  151. package/dist/runtime/server/routes/robots.txt.get.mjs +1 -1
  152. package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
  153. package/dist/runtime/server/routes/storage/multipart/abort.post.d.ts +2 -2
  154. package/dist/runtime/server/routes/storage/multipart/complete.post.d.ts +2 -2
  155. package/dist/runtime/server/routes/storage/multipart/complete.post.mjs +2 -2
  156. package/dist/runtime/server/routes/storage/multipart/create.post.d.ts +2 -2
  157. package/dist/runtime/server/routes/storage/multipart/create.post.mjs +7 -3
  158. package/dist/runtime/server/routes/storage/multipart/part.put.d.ts +2 -2
  159. package/dist/runtime/server/routes/storage/multipart/part.put.mjs +1 -1
  160. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +2 -4
  161. package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +2 -4
  162. package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +1 -1
  163. package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +2 -4
  164. package/dist/runtime/server/tasks/cms/publish.mjs +1 -1
  165. package/dist/runtime/server/utils/ai.d.ts +9 -9
  166. package/dist/runtime/server/utils/ai.mjs +3 -3
  167. package/dist/runtime/server/utils/auth.d.ts +12 -16
  168. package/dist/runtime/server/utils/auth.mjs +15 -9
  169. package/dist/runtime/server/utils/bots.mjs +21 -7
  170. package/dist/runtime/server/utils/browser-utils.d.ts +44 -41
  171. package/dist/runtime/server/utils/browser-utils.mjs +14 -4
  172. package/dist/runtime/server/utils/cache.d.ts +5 -5
  173. package/dist/runtime/server/utils/cms/common.d.ts +26 -0
  174. package/dist/runtime/server/utils/cms/common.mjs +68 -0
  175. package/dist/runtime/server/utils/cms/git.d.ts +24 -0
  176. package/dist/runtime/server/utils/cms/git.mjs +240 -0
  177. package/dist/runtime/server/utils/cms/markdown.d.ts +22 -0
  178. package/dist/runtime/server/utils/cms/markdown.mjs +92 -0
  179. package/dist/runtime/server/utils/cms/path.d.ts +51 -0
  180. package/dist/runtime/server/utils/cms/path.mjs +127 -0
  181. package/dist/runtime/server/utils/cms/search.d.ts +22 -0
  182. package/dist/runtime/server/utils/cms/search.mjs +221 -0
  183. package/dist/runtime/server/utils/cms-events.d.ts +1 -1
  184. package/dist/runtime/server/utils/cms-events.mjs +2 -2
  185. package/dist/runtime/server/utils/cms-filter.mjs +2 -2
  186. package/dist/runtime/server/utils/cms.d.ts +17 -149
  187. package/dist/runtime/server/utils/cms.mjs +52 -761
  188. package/dist/runtime/server/utils/config.d.ts +5 -4
  189. package/dist/runtime/server/utils/domains.mjs +7 -4
  190. package/dist/runtime/server/utils/email-templates.d.ts +10 -7
  191. package/dist/runtime/server/utils/email-templates.mjs +20 -5
  192. package/dist/runtime/server/utils/feed.d.ts +2 -2
  193. package/dist/runtime/server/utils/feed.mjs +3 -1
  194. package/dist/runtime/server/utils/mail-suppression.d.ts +8 -24
  195. package/dist/runtime/server/utils/mail-suppression.mjs +2 -2
  196. package/dist/runtime/server/utils/mail.d.ts +7 -8
  197. package/dist/runtime/server/utils/mail.mjs +17 -12
  198. package/dist/runtime/server/utils/multipart-store.d.ts +2 -2
  199. package/dist/runtime/server/utils/notifications.d.ts +9 -23
  200. package/dist/runtime/server/utils/organization.mjs +4 -12
  201. package/dist/runtime/server/utils/passwordless.mjs +1 -1
  202. package/dist/runtime/server/utils/payments.d.ts +2 -6
  203. package/dist/runtime/server/utils/payments.mjs +1 -1
  204. package/dist/runtime/server/utils/queue.d.ts +21 -31
  205. package/dist/runtime/server/utils/rag.d.ts +4 -4
  206. package/dist/runtime/server/utils/rag.mjs +8 -8
  207. package/dist/runtime/server/utils/realtime-store.d.ts +2 -2
  208. package/dist/runtime/server/utils/realtime.d.ts +26 -28
  209. package/dist/runtime/server/utils/scheduled-task.d.ts +1 -3
  210. package/dist/runtime/server/utils/security-store.d.ts +2 -2
  211. package/dist/runtime/server/utils/session.d.ts +9 -11
  212. package/dist/runtime/server/utils/sso.d.ts +9 -15
  213. package/dist/runtime/server/utils/sso.mjs +4 -8
  214. package/dist/runtime/server/utils/storage.d.ts +19 -2
  215. package/dist/runtime/server/utils/storage.mjs +36 -7
  216. package/dist/runtime/server/utils/tenant.mjs +3 -1
  217. package/dist/runtime/server/utils/turnstile.d.ts +3 -5
  218. package/dist/runtime/server/utils/vapid.d.ts +5 -8
  219. package/dist/runtime/server/utils/vapid.mjs +26 -13
  220. package/dist/runtime/service.d.ts +13 -13
  221. package/dist/runtime/service.mjs +4 -2
  222. package/dist/runtime/test-utils.d.ts +20 -30
  223. package/dist/runtime/test-utils.mjs +5 -4
  224. package/dist/runtime/types/auth-globals.d.ts +14 -14
  225. package/dist/runtime/types/imports.d.ts +82 -82
  226. package/dist/runtime/types/index.d.ts +2 -2
  227. package/dist/runtime/types/r2.d.ts +5 -0
  228. package/dist/runtime/types/service.d.ts +11 -18
  229. package/dist/types.d.ts +100 -107
  230. package/dist/utils/auth-schema.d.ts +2 -2
  231. package/dist/utils/cms-sources.d.ts +3 -3
  232. package/dist/utils/local-db.d.ts +3 -3
  233. package/dist/utils/notifications-schema.d.ts +1 -3
  234. package/dist/utils/pkg.d.ts +7 -0
  235. package/dist/utils/queue.d.ts +3 -3
  236. package/dist/utils/tasks.d.ts +3 -2
  237. package/package.json +11 -8
@@ -1,388 +1,388 @@
1
- <script setup lang="ts">
2
- import { useRoute, useFetch, navigateTo } from "nuxt/app"
3
- import type { NavigationMenuItem } from "@nuxt/ui"
4
- import { computed, onMounted, onUnmounted, ref } from "vue"
5
-
6
- const route = useRoute()
7
-
8
- const {
9
- data: mailData,
10
- status: mailStatus,
11
- pending: mailPending,
12
- execute: executeLoadMail,
13
- } = useFetch<any>("/_qarpeo/api/mail/inbox", {
14
- immediate: false,
15
- lazy: true,
16
- default: () => ({ emails: [] }),
17
- })
18
-
19
- const mailLoading = computed(
20
- () => mailPending.value || mailStatus.value === "idle" || mailStatus.value === "pending",
21
- )
22
- const mailEmails = computed(() => mailData.value?.emails || [])
23
- const sendingTest = ref(false)
24
- const clearingMail = ref(false)
25
- const mailSearch = ref("")
26
- const mailViewMode = ref<"html" | "text" | "json">("html")
27
- const isPolling = ref(false)
28
- let pollTimer: ReturnType<typeof setInterval> | null = null
29
-
30
- // selectedId is derived from the ?id= query param
31
- const selectedId = computed(() => (route.query.id as string) || null)
32
-
33
- const selectedMail = computed(() => mailEmails.value.find((e) => e.id === selectedId.value) || null)
34
-
35
- function fmtTime(time?: number | string) {
36
- if (!time) return "—"
37
- const d = new Date(time)
38
- return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
39
- }
40
-
41
- function fmtFullDate(time?: number | string) {
42
- if (!time) return "—"
43
- return new Date(time).toLocaleString()
44
- }
45
-
46
- const filteredEmails = computed(() => {
47
- if (!mailSearch.value.trim()) return mailEmails.value
48
- const q = mailSearch.value.toLowerCase()
49
- return mailEmails.value.filter(
50
- (e) =>
51
- e.subject?.toLowerCase().includes(q) ||
52
- e.from?.toLowerCase().includes(q) ||
53
- String(e.to).toLowerCase().includes(q),
54
- )
55
- })
56
-
57
- const mailNavItems = computed<NavigationMenuItem[]>(() =>
58
- filteredEmails.value.map((e) => ({
59
- label: e.subject || "(No Subject)",
60
- icon: selectedId.value === e.id ? "i-lucide-mail-open" : "i-lucide-mail",
61
- value: e.id,
62
- badge: {
63
- label: fmtTime(e.timestamp || e.receivedAt),
64
- size: "sm" as const,
65
- color: "neutral" as const,
66
- variant: "subtle" as const,
67
- },
68
- class: "text-xs",
69
- to: { query: { ...route.query, id: e.id } },
70
- active: route.query.id === e.id,
71
- })),
72
- )
73
-
74
- async function loadMail() {
75
- await executeLoadMail()
76
- }
77
-
78
- async function sendTestEmail() {
79
- sendingTest.value = true
80
- try {
81
- await $fetch("/_qarpeo/api/mail/send-test", { method: "POST" })
82
- await loadMail()
83
- if (mailEmails.value.length > 0) {
84
- const latest = mailEmails.value[mailEmails.value.length - 1]
85
- await navigateTo({ query: { ...route.query, id: latest.id } })
86
- }
87
- } catch (err) {
88
- console.error("Failed to send test email", err)
89
- } finally {
90
- sendingTest.value = false
91
- }
92
- }
93
-
94
- async function clearMailbox() {
95
- clearingMail.value = true
96
- try {
97
- await $fetch("/_qarpeo/api/mail/clear", { method: "POST" })
98
- await navigateTo({ query: { ...route.query, id: undefined } })
99
- await loadMail()
100
- } finally {
101
- clearingMail.value = false
102
- }
103
- }
104
-
105
- function copyHtml() {
106
- if (selectedMail.value?.html && typeof navigator !== "undefined") {
107
- navigator.clipboard?.writeText(selectedMail.value.html)
108
- }
109
- }
110
-
111
- function togglePolling() {
112
- isPolling.value = !isPolling.value
113
- if (isPolling.value) {
114
- pollTimer = setInterval(() => {
115
- executeLoadMail()
116
- }, 3000)
117
- } else {
118
- if (pollTimer) {
119
- clearInterval(pollTimer)
120
- pollTimer = null
121
- }
122
- }
123
- }
124
-
125
- onMounted(() => {
126
- loadMail()
127
- })
128
-
129
- onUnmounted(() => {
130
- if (pollTimer) {
131
- clearInterval(pollTimer)
132
- pollTimer = null
133
- }
134
- })
135
- </script>
136
-
137
- <template>
138
- <!-- ── Panel 1: Email List ─────────────────────────────────────────── -->
139
- <UDashboardPanel id="mail-list" :default-size="25" :min-size="20" :max-size="40" resizable>
140
- <template #header>
141
- <UDashboardNavbar>
142
- <template #title>
143
- <div class="flex items-center gap-2">
144
- <UIcon name="i-lucide-mail" class="w-4 h-4 text-primary" />
145
- <span class="font-bold text-sm text-highlighted">Dev Mailbox</span>
146
- <span
147
- v-if="isPolling"
148
- class="w-2 h-2 rounded-full bg-success animate-pulse inline-block"
149
- title="Live polling active (3s)"
150
- />
151
- <UBadge size="xs" color="neutral" variant="subtle">
152
- {{ filteredEmails.length }}
153
- </UBadge>
154
- </div>
155
- </template>
156
- <template #right>
157
- <div class="flex items-center gap-1">
158
- <UButton
159
- :icon="isPolling ? 'i-lucide-pause' : 'i-lucide-play'"
160
- size="xs"
161
- :color="isPolling ? 'success' : 'neutral'"
162
- :variant="isPolling ? 'subtle' : 'ghost'"
163
- :title="isPolling ? 'Pause live polling (3s)' : 'Start live polling (3s)'"
164
- @click="togglePolling"
165
- />
166
- <UButton
167
- icon="i-lucide-send"
168
- size="xs"
169
- color="primary"
170
- variant="subtle"
171
- title="Send test email"
172
- :loading="sendingTest"
173
- @click="sendTestEmail"
174
- />
175
- <UButton
176
- icon="i-lucide-trash"
177
- size="xs"
178
- color="neutral"
179
- variant="ghost"
180
- title="Clear mailbox"
181
- :loading="clearingMail"
182
- @click="clearMailbox"
183
- />
184
- <UButton
185
- icon="i-lucide-refresh-cw"
186
- size="xs"
187
- color="neutral"
188
- variant="ghost"
189
- title="Refresh inbox"
190
- :loading="mailLoading"
191
- @click="loadMail"
192
- />
193
- </div>
194
- </template>
195
- </UDashboardNavbar>
196
-
197
- <UDashboardToolbar>
198
- <UInput
199
- v-model="mailSearch"
200
- icon="i-lucide-search"
201
- placeholder="Search emails…"
202
- class="w-full"
203
- />
204
- </UDashboardToolbar>
205
- </template>
206
-
207
- <template #body>
208
- <!-- Loading Skeleton/State -->
209
- <div v-if="mailLoading" class="p-3 space-y-2">
210
- <div
211
- v-for="i in 5"
212
- :key="i"
213
- class="h-8 rounded bg-muted/60 animate-pulse flex items-center justify-between px-3"
214
- >
215
- <div class="flex items-center gap-2">
216
- <div class="h-3.5 w-3.5 rounded bg-muted/40"></div>
217
- <div class="h-3 w-28 rounded bg-muted/40"></div>
218
- </div>
219
- <div class="h-3 w-10 rounded bg-muted/40"></div>
220
- </div>
221
- </div>
222
-
223
- <template v-else>
224
- <UNavigationMenu
225
- v-model="selectedId"
226
- :items="mailNavItems"
227
- orientation="vertical"
228
- variant="pill"
229
- />
230
-
231
- <div v-if="!filteredEmails.length" class="text-xs text-muted p-6 text-center space-y-3">
232
- <div>No emails captured.</div>
233
- <UButton
234
- label="Send Test Email"
235
- icon="i-lucide-send"
236
- size="xs"
237
- color="primary"
238
- variant="subtle"
239
- :loading="sendingTest"
240
- @click="sendTestEmail"
241
- />
242
- </div>
243
- </template>
244
- </template>
245
- </UDashboardPanel>
246
-
247
- <!-- ── Panel 2: Email Content Viewer ────────────────────────────────── -->
248
- <UDashboardPanel id="mail-viewer" class="hidden lg:flex flex-1">
249
- <template #header>
250
- <UDashboardNavbar>
251
- <template #title>
252
- <div v-if="selectedMail" class="flex items-center gap-2 min-w-0">
253
- <UIcon name="i-lucide-mail-open" class="w-4 h-4 text-primary shrink-0" />
254
- <span class="font-bold text-sm text-highlighted truncate">{{
255
- selectedMail.subject || "(No Subject)"
256
- }}</span>
257
- </div>
258
- <span v-else class="text-sm font-semibold text-muted">Select an email</span>
259
- </template>
260
-
261
- <template #right>
262
- <div v-if="selectedMail" class="flex items-center gap-2">
263
- <!-- View Mode Tabs -->
264
- <div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
265
- <UButton
266
- label="HTML"
267
- size="xs"
268
- :color="mailViewMode === 'html' ? 'primary' : 'neutral'"
269
- :variant="mailViewMode === 'html' ? 'subtle' : 'ghost'"
270
- @click="mailViewMode = 'html'"
271
- />
272
- <UButton
273
- label="Text"
274
- size="xs"
275
- :color="mailViewMode === 'text' ? 'primary' : 'neutral'"
276
- :variant="mailViewMode === 'text' ? 'subtle' : 'ghost'"
277
- @click="mailViewMode = 'text'"
278
- />
279
- <UButton
280
- label="JSON"
281
- size="xs"
282
- :color="mailViewMode === 'json' ? 'primary' : 'neutral'"
283
- :variant="mailViewMode === 'json' ? 'subtle' : 'ghost'"
284
- @click="mailViewMode = 'json'"
285
- />
286
- </div>
287
-
288
- <UButton
289
- icon="i-lucide-copy"
290
- size="xs"
291
- color="neutral"
292
- variant="subtle"
293
- title="Copy HTML"
294
- @click="copyHtml"
295
- />
296
- </div>
297
- </template>
298
- </UDashboardNavbar>
299
- </template>
300
-
301
- <template #body>
302
- <div v-if="selectedMail" class="flex flex-col h-full p-6 space-y-4 overflow-y-auto">
303
- <!-- Metadata Header Card -->
304
- <UCard>
305
- <div class="space-y-3">
306
- <div class="flex items-start justify-between gap-4">
307
- <h2 class="font-bold text-base text-highlighted">
308
- {{ selectedMail.subject || "(No Subject)" }}
309
- </h2>
310
- <UBadge
311
- v-if="selectedMail.template"
312
- size="xs"
313
- color="primary"
314
- variant="subtle"
315
- class="font-mono"
316
- >
317
- template: {{ selectedMail.template }}
318
- </UBadge>
319
- </div>
320
-
321
- <div
322
- class="grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs font-mono pt-2 border-t border-default text-muted"
323
- >
324
- <div>
325
- <span class="text-muted/70">From:</span>
326
- <span class="text-default font-semibold ml-1.5">{{ selectedMail.from }}</span>
327
- </div>
328
- <div>
329
- <span class="text-muted/70">To:</span>
330
- <span class="text-default font-semibold ml-1.5">{{
331
- Array.isArray(selectedMail.to) ? selectedMail.to.join(", ") : selectedMail.to
332
- }}</span>
333
- </div>
334
- <div>
335
- <span class="text-muted/70">Received:</span>
336
- <span class="text-default ml-1.5">{{
337
- fmtFullDate(selectedMail.timestamp || selectedMail.receivedAt)
338
- }}</span>
339
- </div>
340
- </div>
341
- </div>
342
- </UCard>
343
-
344
- <!-- Message Body -->
345
- <UCard class="flex-1 flex flex-col min-h-0 overflow-hidden">
346
- <template #header>
347
- <div class="flex items-center justify-between">
348
- <span class="text-xs font-semibold text-muted flex items-center gap-1.5">
349
- <UIcon name="i-lucide-file-text" class="w-3.5 h-3.5 text-primary" />
350
- Message Body ({{ mailViewMode.toUpperCase() }})
351
- </span>
352
- <span class="text-[11px] font-mono text-muted">id: {{ selectedMail.id }}</span>
353
- </div>
354
- </template>
355
-
356
- <div class="flex-1 overflow-auto min-h-[350px]">
357
- <!-- HTML Mode -->
358
- <div
359
- v-if="mailViewMode === 'html'"
360
- class="h-full bg-white text-slate-900 rounded-md p-6 overflow-auto border border-default shadow-inner"
361
- v-html="selectedMail.html || '<p class=\'text-muted text-sm\'>No HTML content.</p>'"
362
- ></div>
363
-
364
- <!-- Plain Text Mode -->
365
- <pre
366
- v-else-if="mailViewMode === 'text'"
367
- class="font-mono text-xs text-default bg-muted/30 p-4 rounded-md border border-default whitespace-pre-wrap overflow-auto h-full"
368
- >{{ selectedMail.text || selectedMail.body || "(Empty text content)" }}</pre>
369
-
370
- <!-- Raw JSON Mode -->
371
- <pre
372
- v-else
373
- class="font-mono text-xs text-default bg-muted/40 p-4 rounded-md border border-default overflow-auto h-full whitespace-pre-wrap break-all"
374
- >{{ JSON.stringify(selectedMail, null, 2) }}</pre>
375
- </div>
376
- </UCard>
377
- </div>
378
-
379
- <div
380
- v-else
381
- class="flex-1 flex flex-col items-center justify-center text-muted text-xs p-12 text-center"
382
- >
383
- <UIcon name="i-lucide-mail" class="w-8 h-8 mb-2 opacity-50 text-muted" />
384
- Select an email from the list to view its contents and headers.
385
- </div>
386
- </template>
387
- </UDashboardPanel>
388
- </template>
1
+ <script setup lang="ts">
2
+ import type { NavigationMenuItem } from "@nuxt/ui"
3
+ import { useRoute, useFetch, navigateTo } from "nuxt/app"
4
+ import { computed, onMounted, onUnmounted, ref } from "vue"
5
+
6
+ const route = useRoute()
7
+
8
+ const {
9
+ data: mailData,
10
+ status: mailStatus,
11
+ pending: mailPending,
12
+ execute: executeLoadMail,
13
+ } = useFetch<any>("/_qarpeo/api/mail/inbox", {
14
+ immediate: false,
15
+ lazy: true,
16
+ default: () => ({ emails: [] }),
17
+ })
18
+
19
+ const mailLoading = computed(
20
+ () => mailPending.value || mailStatus.value === "idle" || mailStatus.value === "pending",
21
+ )
22
+ const mailEmails = computed(() => mailData.value?.emails || [])
23
+ const sendingTest = ref(false)
24
+ const clearingMail = ref(false)
25
+ const mailSearch = ref("")
26
+ const mailViewMode = ref<"html" | "text" | "json">("html")
27
+ const isPolling = ref(false)
28
+ let pollTimer: ReturnType<typeof setInterval> | null = null
29
+
30
+ // selectedId is derived from the ?id= query param
31
+ const selectedId = computed(() => (route.query.id as string) || null)
32
+
33
+ const selectedMail = computed(() => mailEmails.value.find((e) => e.id === selectedId.value) || null)
34
+
35
+ function fmtTime(time?: number | string) {
36
+ if (!time) return "—"
37
+ const d = new Date(time)
38
+ return d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })
39
+ }
40
+
41
+ function fmtFullDate(time?: number | string) {
42
+ if (!time) return "—"
43
+ return new Date(time).toLocaleString()
44
+ }
45
+
46
+ const filteredEmails = computed(() => {
47
+ if (!mailSearch.value.trim()) return mailEmails.value
48
+ const q = mailSearch.value.toLowerCase()
49
+ return mailEmails.value.filter(
50
+ (e) =>
51
+ e.subject?.toLowerCase().includes(q) ||
52
+ e.from?.toLowerCase().includes(q) ||
53
+ String(e.to).toLowerCase().includes(q),
54
+ )
55
+ })
56
+
57
+ const mailNavItems = computed<NavigationMenuItem[]>(() =>
58
+ filteredEmails.value.map((e) => ({
59
+ label: e.subject || "(No Subject)",
60
+ icon: selectedId.value === e.id ? "i-lucide-mail-open" : "i-lucide-mail",
61
+ value: e.id,
62
+ badge: {
63
+ label: fmtTime(e.timestamp || e.receivedAt),
64
+ size: "sm" as const,
65
+ color: "neutral" as const,
66
+ variant: "subtle" as const,
67
+ },
68
+ class: "text-xs",
69
+ to: { query: { ...route.query, id: e.id } },
70
+ active: route.query.id === e.id,
71
+ })),
72
+ )
73
+
74
+ async function loadMail() {
75
+ await executeLoadMail()
76
+ }
77
+
78
+ async function sendTestEmail() {
79
+ sendingTest.value = true
80
+ try {
81
+ await $fetch("/_qarpeo/api/mail/send-test", { method: "POST" })
82
+ await loadMail()
83
+ if (mailEmails.value.length > 0) {
84
+ const latest = mailEmails.value[mailEmails.value.length - 1]
85
+ await navigateTo({ query: { ...route.query, id: latest.id } })
86
+ }
87
+ } catch (err) {
88
+ console.error("Failed to send test email", err)
89
+ } finally {
90
+ sendingTest.value = false
91
+ }
92
+ }
93
+
94
+ async function clearMailbox() {
95
+ clearingMail.value = true
96
+ try {
97
+ await $fetch("/_qarpeo/api/mail/clear", { method: "POST" })
98
+ await navigateTo({ query: { ...route.query, id: undefined } })
99
+ await loadMail()
100
+ } finally {
101
+ clearingMail.value = false
102
+ }
103
+ }
104
+
105
+ function copyHtml() {
106
+ if (selectedMail.value?.html && typeof navigator !== "undefined") {
107
+ navigator.clipboard?.writeText(selectedMail.value.html)
108
+ }
109
+ }
110
+
111
+ function togglePolling() {
112
+ isPolling.value = !isPolling.value
113
+ if (isPolling.value) {
114
+ pollTimer = setInterval(() => {
115
+ executeLoadMail()
116
+ }, 3000)
117
+ } else {
118
+ if (pollTimer) {
119
+ clearInterval(pollTimer)
120
+ pollTimer = null
121
+ }
122
+ }
123
+ }
124
+
125
+ onMounted(() => {
126
+ loadMail()
127
+ })
128
+
129
+ onUnmounted(() => {
130
+ if (pollTimer) {
131
+ clearInterval(pollTimer)
132
+ pollTimer = null
133
+ }
134
+ })
135
+ </script>
136
+
137
+ <template>
138
+ <!-- ── Panel 1: Email List ─────────────────────────────────────────── -->
139
+ <UDashboardPanel id="mail-list" :default-size="25" :min-size="20" :max-size="40" resizable>
140
+ <template #header>
141
+ <UDashboardNavbar>
142
+ <template #title>
143
+ <div class="flex items-center gap-2">
144
+ <UIcon name="i-lucide-mail" class="w-4 h-4 text-primary" />
145
+ <span class="font-bold text-sm text-highlighted">Dev Mailbox</span>
146
+ <span
147
+ v-if="isPolling"
148
+ class="w-2 h-2 rounded-full bg-success animate-pulse inline-block"
149
+ title="Live polling active (3s)"
150
+ />
151
+ <UBadge size="xs" color="neutral" variant="subtle">
152
+ {{ filteredEmails.length }}
153
+ </UBadge>
154
+ </div>
155
+ </template>
156
+ <template #right>
157
+ <div class="flex items-center gap-1">
158
+ <UButton
159
+ :icon="isPolling ? 'i-lucide-pause' : 'i-lucide-play'"
160
+ size="xs"
161
+ :color="isPolling ? 'success' : 'neutral'"
162
+ :variant="isPolling ? 'subtle' : 'ghost'"
163
+ :title="isPolling ? 'Pause live polling (3s)' : 'Start live polling (3s)'"
164
+ @click="togglePolling"
165
+ />
166
+ <UButton
167
+ icon="i-lucide-send"
168
+ size="xs"
169
+ color="primary"
170
+ variant="subtle"
171
+ title="Send test email"
172
+ :loading="sendingTest"
173
+ @click="sendTestEmail"
174
+ />
175
+ <UButton
176
+ icon="i-lucide-trash"
177
+ size="xs"
178
+ color="neutral"
179
+ variant="ghost"
180
+ title="Clear mailbox"
181
+ :loading="clearingMail"
182
+ @click="clearMailbox"
183
+ />
184
+ <UButton
185
+ icon="i-lucide-refresh-cw"
186
+ size="xs"
187
+ color="neutral"
188
+ variant="ghost"
189
+ title="Refresh inbox"
190
+ :loading="mailLoading"
191
+ @click="loadMail"
192
+ />
193
+ </div>
194
+ </template>
195
+ </UDashboardNavbar>
196
+
197
+ <UDashboardToolbar>
198
+ <UInput
199
+ v-model="mailSearch"
200
+ icon="i-lucide-search"
201
+ placeholder="Search emails…"
202
+ class="w-full"
203
+ />
204
+ </UDashboardToolbar>
205
+ </template>
206
+
207
+ <template #body>
208
+ <!-- Loading Skeleton/State -->
209
+ <div v-if="mailLoading" class="p-3 space-y-2">
210
+ <div
211
+ v-for="i in 5"
212
+ :key="i"
213
+ class="h-8 rounded bg-muted/60 animate-pulse flex items-center justify-between px-3"
214
+ >
215
+ <div class="flex items-center gap-2">
216
+ <div class="h-3.5 w-3.5 rounded bg-muted/40"></div>
217
+ <div class="h-3 w-28 rounded bg-muted/40"></div>
218
+ </div>
219
+ <div class="h-3 w-10 rounded bg-muted/40"></div>
220
+ </div>
221
+ </div>
222
+
223
+ <template v-else>
224
+ <UNavigationMenu
225
+ v-model="selectedId"
226
+ :items="mailNavItems"
227
+ orientation="vertical"
228
+ variant="pill"
229
+ />
230
+
231
+ <div v-if="!filteredEmails.length" class="text-xs text-muted p-6 text-center space-y-3">
232
+ <div>No emails captured.</div>
233
+ <UButton
234
+ label="Send Test Email"
235
+ icon="i-lucide-send"
236
+ size="xs"
237
+ color="primary"
238
+ variant="subtle"
239
+ :loading="sendingTest"
240
+ @click="sendTestEmail"
241
+ />
242
+ </div>
243
+ </template>
244
+ </template>
245
+ </UDashboardPanel>
246
+
247
+ <!-- ── Panel 2: Email Content Viewer ────────────────────────────────── -->
248
+ <UDashboardPanel id="mail-viewer" class="hidden lg:flex flex-1">
249
+ <template #header>
250
+ <UDashboardNavbar>
251
+ <template #title>
252
+ <div v-if="selectedMail" class="flex items-center gap-2 min-w-0">
253
+ <UIcon name="i-lucide-mail-open" class="w-4 h-4 text-primary shrink-0" />
254
+ <span class="font-bold text-sm text-highlighted truncate">{{
255
+ selectedMail.subject || "(No Subject)"
256
+ }}</span>
257
+ </div>
258
+ <span v-else class="text-sm font-semibold text-muted">Select an email</span>
259
+ </template>
260
+
261
+ <template #right>
262
+ <div v-if="selectedMail" class="flex items-center gap-2">
263
+ <!-- View Mode Tabs -->
264
+ <div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
265
+ <UButton
266
+ label="HTML"
267
+ size="xs"
268
+ :color="mailViewMode === 'html' ? 'primary' : 'neutral'"
269
+ :variant="mailViewMode === 'html' ? 'subtle' : 'ghost'"
270
+ @click="mailViewMode = 'html'"
271
+ />
272
+ <UButton
273
+ label="Text"
274
+ size="xs"
275
+ :color="mailViewMode === 'text' ? 'primary' : 'neutral'"
276
+ :variant="mailViewMode === 'text' ? 'subtle' : 'ghost'"
277
+ @click="mailViewMode = 'text'"
278
+ />
279
+ <UButton
280
+ label="JSON"
281
+ size="xs"
282
+ :color="mailViewMode === 'json' ? 'primary' : 'neutral'"
283
+ :variant="mailViewMode === 'json' ? 'subtle' : 'ghost'"
284
+ @click="mailViewMode = 'json'"
285
+ />
286
+ </div>
287
+
288
+ <UButton
289
+ icon="i-lucide-copy"
290
+ size="xs"
291
+ color="neutral"
292
+ variant="subtle"
293
+ title="Copy HTML"
294
+ @click="copyHtml"
295
+ />
296
+ </div>
297
+ </template>
298
+ </UDashboardNavbar>
299
+ </template>
300
+
301
+ <template #body>
302
+ <div v-if="selectedMail" class="flex flex-col h-full p-6 space-y-4 overflow-y-auto">
303
+ <!-- Metadata Header Card -->
304
+ <UCard>
305
+ <div class="space-y-3">
306
+ <div class="flex items-start justify-between gap-4">
307
+ <h2 class="font-bold text-base text-highlighted">
308
+ {{ selectedMail.subject || "(No Subject)" }}
309
+ </h2>
310
+ <UBadge
311
+ v-if="selectedMail.template"
312
+ size="xs"
313
+ color="primary"
314
+ variant="subtle"
315
+ class="font-mono"
316
+ >
317
+ template: {{ selectedMail.template }}
318
+ </UBadge>
319
+ </div>
320
+
321
+ <div
322
+ class="grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs font-mono pt-2 border-t border-default text-muted"
323
+ >
324
+ <div>
325
+ <span class="text-muted/70">From:</span>
326
+ <span class="text-default font-semibold ml-1.5">{{ selectedMail.from }}</span>
327
+ </div>
328
+ <div>
329
+ <span class="text-muted/70">To:</span>
330
+ <span class="text-default font-semibold ml-1.5">{{
331
+ Array.isArray(selectedMail.to) ? selectedMail.to.join(", ") : selectedMail.to
332
+ }}</span>
333
+ </div>
334
+ <div>
335
+ <span class="text-muted/70">Received:</span>
336
+ <span class="text-default ml-1.5">{{
337
+ fmtFullDate(selectedMail.timestamp || selectedMail.receivedAt)
338
+ }}</span>
339
+ </div>
340
+ </div>
341
+ </div>
342
+ </UCard>
343
+
344
+ <!-- Message Body -->
345
+ <UCard class="flex-1 flex flex-col min-h-0 overflow-hidden">
346
+ <template #header>
347
+ <div class="flex items-center justify-between">
348
+ <span class="text-xs font-semibold text-muted flex items-center gap-1.5">
349
+ <UIcon name="i-lucide-file-text" class="w-3.5 h-3.5 text-primary" />
350
+ Message Body ({{ mailViewMode.toUpperCase() }})
351
+ </span>
352
+ <span class="text-[11px] font-mono text-muted">id: {{ selectedMail.id }}</span>
353
+ </div>
354
+ </template>
355
+
356
+ <div class="flex-1 overflow-auto min-h-[350px]">
357
+ <!-- HTML Mode -->
358
+ <div
359
+ v-if="mailViewMode === 'html'"
360
+ class="h-full bg-white text-slate-900 rounded-md p-6 overflow-auto border border-default shadow-inner"
361
+ v-html="selectedMail.html || '<p class=\'text-muted text-sm\'>No HTML content.</p>'"
362
+ ></div>
363
+
364
+ <!-- Plain Text Mode -->
365
+ <pre
366
+ v-else-if="mailViewMode === 'text'"
367
+ class="font-mono text-xs text-default bg-muted/30 p-4 rounded-md border border-default whitespace-pre-wrap overflow-auto h-full"
368
+ >{{ selectedMail.text || selectedMail.body || "(Empty text content)" }}</pre>
369
+
370
+ <!-- Raw JSON Mode -->
371
+ <pre
372
+ v-else
373
+ class="font-mono text-xs text-default bg-muted/40 p-4 rounded-md border border-default overflow-auto h-full whitespace-pre-wrap break-all"
374
+ >{{ JSON.stringify(selectedMail, null, 2) }}</pre>
375
+ </div>
376
+ </UCard>
377
+ </div>
378
+
379
+ <div
380
+ v-else
381
+ class="flex-1 flex flex-col items-center justify-center text-muted text-xs p-12 text-center"
382
+ >
383
+ <UIcon name="i-lucide-mail" class="w-8 h-8 mb-2 opacity-50 text-muted" />
384
+ Select an email from the list to view its contents and headers.
385
+ </div>
386
+ </template>
387
+ </UDashboardPanel>
388
+ </template>