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,350 +1,381 @@
1
- <script setup lang="ts">
2
- import { useFetch } from "nuxt/app"
3
- import { computed, onMounted, ref } from "vue"
4
-
5
- interface UserRecord {
6
- id: string
7
- email: string
8
- name?: string
9
- avatarUrl?: string
10
- role?: string
11
- emailVerified?: number
12
- createdAt: number
13
- updatedAt?: number
14
- }
15
-
16
- interface SessionRecord {
17
- id: string
18
- userId: string
19
- userName?: string
20
- userEmail?: string
21
- clientType?: string
22
- userAgent?: string
23
- ipAddress?: string
24
- lastActive: number
25
- expiresAt: number
26
- }
27
-
28
- const activeTab = ref<"users" | "sessions">("users")
29
- const searchQuery = ref("")
30
- const revokingId = ref<string | null>(null)
31
-
32
- const {
33
- data: usersData,
34
- pending: usersPending,
35
- refresh: refreshUsers,
36
- } = useFetch<any>("/_qarpeo/api/auth/users", {
37
- default: () => ({ users: [], total: 0, isDevMock: false }),
38
- })
39
-
40
- const {
41
- data: sessionsData,
42
- pending: sessionsPending,
43
- refresh: refreshSessions,
44
- } = useFetch<any>("/_qarpeo/api/auth/sessions", {
45
- default: () => ({ sessions: [], isDevMock: false }),
46
- })
47
-
48
- const users = computed<UserRecord[]>(() => usersData.value?.users || [])
49
- const sessions = computed<SessionRecord[]>(() => sessionsData.value?.sessions || [])
50
- const isDevMock = computed(
51
- () => Boolean(usersData.value?.isDevMock || sessionsData.value?.isDevMock),
52
- )
53
-
54
- const filteredUsers = computed(() => {
55
- if (!searchQuery.value.trim()) return users.value
56
- const q = searchQuery.value.toLowerCase()
57
- return users.value.filter(
58
- (u) =>
59
- u.email.toLowerCase().includes(q) ||
60
- (u.name && u.name.toLowerCase().includes(q)) ||
61
- (u.role && u.role.toLowerCase().includes(q)),
62
- )
63
- })
64
-
65
- const filteredSessions = computed(() => {
66
- if (!searchQuery.value.trim()) return sessions.value
67
- const q = searchQuery.value.toLowerCase()
68
- return sessions.value.filter(
69
- (s) =>
70
- (s.userEmail && s.userEmail.toLowerCase().includes(q)) ||
71
- (s.userName && s.userName.toLowerCase().includes(q)) ||
72
- (s.ipAddress && s.ipAddress.includes(q)) ||
73
- (s.clientType && s.clientType.toLowerCase().includes(q)),
74
- )
75
- })
76
-
77
- const stats = computed(() => {
78
- const verifiedCount = users.value.filter((u) => Boolean(u.emailVerified)).length
79
- const adminCount = users.value.filter((u) => u.role === "admin").length
80
- return {
81
- totalUsers: users.value.length,
82
- activeSessions: sessions.value.length,
83
- verifiedCount,
84
- adminCount,
85
- }
86
- })
87
-
88
- function fmtDate(ts?: number) {
89
- if (!ts) return "—"
90
- return new Date(ts).toLocaleDateString([], {
91
- year: "numeric",
92
- month: "short",
93
- day: "numeric",
94
- hour: "2-digit",
95
- minute: "2-digit",
96
- })
97
- }
98
-
99
- function fmtRelative(ts?: number) {
100
- if (!ts) return "—"
101
- const diff = Date.now() - ts
102
- const mins = Math.floor(diff / 60000)
103
- if (mins < 1) return "Just now"
104
- if (mins < 60) return `${mins}m ago`
105
- const hours = Math.floor(mins / 60)
106
- if (hours < 24) return `${hours}h ago`
107
- return `${Math.floor(hours / 24)}d ago`
108
- }
109
-
110
- async function revokeSession(sessionId: string) {
111
- revokingId.value = sessionId
112
- try {
113
- await $fetch("/_qarpeo/api/auth/revoke-session", {
114
- method: "POST",
115
- body: { sessionId },
116
- })
117
- await refreshSessions()
118
- } finally {
119
- revokingId.value = null
120
- }
121
- }
122
-
123
- async function refreshAll() {
124
- await Promise.all([refreshUsers(), refreshSessions()])
125
- }
126
-
127
- onMounted(() => {
128
- refreshAll()
129
- })
130
- </script>
131
-
132
- <template>
133
- <UDashboardPanel id="devtools-auth">
134
- <template #header>
135
- <UDashboardNavbar>
136
- <template #title>
137
- <div class="flex items-center gap-2">
138
- <UIcon name="i-lucide-users" class="w-4 h-4 text-primary" />
139
- <span class="font-bold text-sm text-highlighted">Auth & Users</span>
140
- <UBadge size="xs" color="primary" variant="subtle">Tier 1 Auth</UBadge>
141
- <UBadge v-if="isDevMock" size="xs" color="warning" variant="subtle" icon="i-lucide-flask-conical">
142
- Preview Mode
143
- </UBadge>
144
- </div>
145
- </template>
146
-
147
- <template #right>
148
- <div class="flex items-center gap-2">
149
- <UButton
150
- icon="i-lucide-refresh-cw"
151
- size="xs"
152
- color="neutral"
153
- variant="ghost"
154
- title="Refresh auth data"
155
- :loading="usersPending || sessionsPending"
156
- @click="refreshAll"
157
- />
158
- </div>
159
- </template>
160
- </UDashboardNavbar>
161
-
162
- <!-- Toolbar with KPI cards and Search -->
163
- <UDashboardToolbar>
164
- <div class="flex flex-col gap-3 w-full py-2">
165
- <!-- KPI Summary Grid -->
166
- <div class="grid grid-cols-2 sm:grid-cols-4 gap-2 w-full">
167
- <div class="p-2.5 rounded-lg border border-default bg-card">
168
- <span class="text-xs text-muted">Total Users</span>
169
- <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.totalUsers }}</p>
170
- </div>
171
- <div class="p-2.5 rounded-lg border border-default bg-card">
172
- <span class="text-xs text-muted">Active Sessions</span>
173
- <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.activeSessions }}</p>
174
- </div>
175
- <div class="p-2.5 rounded-lg border border-default bg-card">
176
- <span class="text-xs text-muted">Verified Emails</span>
177
- <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.verifiedCount }}</p>
178
- </div>
179
- <div class="p-2.5 rounded-lg border border-default bg-card">
180
- <span class="text-xs text-muted">Administrators</span>
181
- <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.adminCount }}</p>
182
- </div>
183
- </div>
184
-
185
- <!-- Controls: Tabs + Search -->
186
- <div class="flex items-center justify-between flex-wrap gap-2 pt-1 border-t border-default">
187
- <div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
188
- <UButton
189
- label="Users"
190
- icon="i-lucide-user"
191
- size="xs"
192
- :color="activeTab === 'users' ? 'primary' : 'neutral'"
193
- :variant="activeTab === 'users' ? 'subtle' : 'ghost'"
194
- @click="activeTab = 'users'"
195
- >
196
- <template #trailing>
197
- <UBadge size="xs" :color="activeTab === 'users' ? 'primary' : 'neutral'" variant="subtle">
198
- {{ users.length }}
199
- </UBadge>
200
- </template>
201
- </UButton>
202
-
203
- <UButton
204
- label="Active Sessions"
205
- icon="i-lucide-shield-check"
206
- size="xs"
207
- :color="activeTab === 'sessions' ? 'primary' : 'neutral'"
208
- :variant="activeTab === 'sessions' ? 'subtle' : 'ghost'"
209
- @click="activeTab = 'sessions'"
210
- >
211
- <template #trailing>
212
- <UBadge size="xs" :color="activeTab === 'sessions' ? 'primary' : 'neutral'" variant="subtle">
213
- {{ sessions.length }}
214
- </UBadge>
215
- </template>
216
- </UButton>
217
- </div>
218
-
219
- <div class="w-full sm:w-64">
220
- <UInput
221
- v-model="searchQuery"
222
- icon="i-lucide-search"
223
- size="xs"
224
- placeholder="Filter by name, email, IP..."
225
- class="w-full"
226
- />
227
- </div>
228
- </div>
229
- </div>
230
- </UDashboardToolbar>
231
- </template>
232
-
233
- <!-- Main Content Area -->
234
- <div class="p-4 overflow-x-auto">
235
- <!-- ─── USERS TAB ─────────────────────────────────────────────────────────── -->
236
- <div v-if="activeTab === 'users'">
237
- <div v-if="filteredUsers.length === 0" class="text-center py-12 text-muted">
238
- <UIcon name="i-lucide-user-x" class="w-8 h-8 mx-auto mb-2 opacity-50" />
239
- <p class="text-sm font-medium">No users found</p>
240
- <p class="text-xs text-muted mt-1">Users register via OAuth, WebAuthn Passkeys, OTP, or Magic Links.</p>
241
- </div>
242
-
243
- <div v-else class="border border-default rounded-lg overflow-hidden bg-card">
244
- <table class="w-full text-left text-xs">
245
- <thead class="bg-muted border-b border-default text-muted font-medium">
246
- <tr>
247
- <th class="p-3">User</th>
248
- <th class="p-3">Role</th>
249
- <th class="p-3">Status</th>
250
- <th class="p-3">Registered</th>
251
- <th class="p-3">ID</th>
252
- </tr>
253
- </thead>
254
- <tbody class="divide-y divide-default">
255
- <tr v-for="u in filteredUsers" :key="u.id" class="hover:bg-muted/50 transition">
256
- <td class="p-3">
257
- <div class="flex items-center gap-2.5">
258
- <div class="w-7 h-7 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center font-bold text-primary text-xs shrink-0">
259
- {{ (u.name || u.email).charAt(0).toUpperCase() }}
260
- </div>
261
- <div>
262
- <p class="font-medium text-highlighted">{{ u.name || "—" }}</p>
263
- <p class="text-[11px] text-muted font-mono">{{ u.email }}</p>
264
- </div>
265
- </div>
266
- </td>
267
- <td class="p-3">
268
- <UBadge size="xs" :color="u.role === 'admin' ? 'primary' : 'neutral'" variant="subtle">
269
- {{ u.role || 'user' }}
270
- </UBadge>
271
- </td>
272
- <td class="p-3">
273
- <UBadge size="xs" :color="u.emailVerified ? 'success' : 'neutral'" variant="subtle">
274
- {{ u.emailVerified ? 'Verified' : 'Unverified' }}
275
- </UBadge>
276
- </td>
277
- <td class="p-3 text-muted">
278
- {{ fmtDate(u.createdAt) }}
279
- </td>
280
- <td class="p-3 font-mono text-[11px] text-muted">
281
- {{ u.id }}
282
- </td>
283
- </tr>
284
- </tbody>
285
- </table>
286
- </div>
287
- </div>
288
-
289
- <!-- ─── SESSIONS TAB ──────────────────────────────────────────────────────── -->
290
- <div v-else-if="activeTab === 'sessions'">
291
- <div v-if="filteredSessions.length === 0" class="text-center py-12 text-muted">
292
- <UIcon name="i-lucide-shield-alert" class="w-8 h-8 mx-auto mb-2 opacity-50" />
293
- <p class="text-sm font-medium">No active sessions</p>
294
- <p class="text-xs text-muted mt-1">Sessions are tracked across D1 and KV.</p>
295
- </div>
296
-
297
- <div v-else class="border border-default rounded-lg overflow-hidden bg-card">
298
- <table class="w-full text-left text-xs">
299
- <thead class="bg-muted border-b border-default text-muted font-medium">
300
- <tr>
301
- <th class="p-3">User</th>
302
- <th class="p-3">Client</th>
303
- <th class="p-3">IP Address</th>
304
- <th class="p-3">Last Active</th>
305
- <th class="p-3">Expires</th>
306
- <th class="p-3 text-right">Actions</th>
307
- </tr>
308
- </thead>
309
- <tbody class="divide-y divide-default">
310
- <tr v-for="s in filteredSessions" :key="s.id" class="hover:bg-muted/50 transition">
311
- <td class="p-3">
312
- <p class="font-medium text-highlighted">{{ s.userName || "Active User" }}</p>
313
- <p class="text-[11px] text-muted font-mono">{{ s.userEmail || s.userId }}</p>
314
- </td>
315
- <td class="p-3">
316
- <UBadge size="xs" color="neutral" variant="subtle">
317
- {{ s.clientType || 'web' }}
318
- </UBadge>
319
- <p class="text-[10px] text-muted truncate max-w-[200px] mt-0.5" :title="s.userAgent">
320
- {{ s.userAgent || '—' }}
321
- </p>
322
- </td>
323
- <td class="p-3 font-mono text-[11px]">
324
- {{ s.ipAddress || '—' }}
325
- </td>
326
- <td class="p-3 text-muted">
327
- {{ fmtRelative(s.lastActive) }}
328
- </td>
329
- <td class="p-3 text-muted">
330
- {{ fmtDate(s.expiresAt) }}
331
- </td>
332
- <td class="p-3 text-right">
333
- <UButton
334
- size="xs"
335
- color="error"
336
- variant="ghost"
337
- icon="i-lucide-log-out"
338
- label="Revoke"
339
- :loading="revokingId === s.id"
340
- @click="revokeSession(s.id)"
341
- />
342
- </td>
343
- </tr>
344
- </tbody>
345
- </table>
346
- </div>
347
- </div>
348
- </div>
349
- </UDashboardPanel>
350
- </template>
1
+ <script setup lang="ts">
2
+ import { useFetch } from "nuxt/app"
3
+ import { computed, onMounted, ref } from "vue"
4
+
5
+ interface UserRecord {
6
+ id: string
7
+ email: string
8
+ name?: string
9
+ avatarUrl?: string
10
+ role?: string
11
+ emailVerified?: number
12
+ createdAt: number
13
+ updatedAt?: number
14
+ }
15
+
16
+ interface SessionRecord {
17
+ id: string
18
+ userId: string
19
+ userName?: string
20
+ userEmail?: string
21
+ clientType?: string
22
+ userAgent?: string
23
+ ipAddress?: string
24
+ lastActive: number
25
+ expiresAt: number
26
+ }
27
+
28
+ const activeTab = ref<"users" | "sessions">("users")
29
+ const searchQuery = ref("")
30
+ const revokingId = ref<string | null>(null)
31
+
32
+ const {
33
+ data: usersData,
34
+ pending: usersPending,
35
+ refresh: refreshUsers,
36
+ } = useFetch<any>("/_qarpeo/api/auth/users", {
37
+ default: () => ({ users: [], total: 0, isDevMock: false }),
38
+ })
39
+
40
+ const {
41
+ data: sessionsData,
42
+ pending: sessionsPending,
43
+ refresh: refreshSessions,
44
+ } = useFetch<any>("/_qarpeo/api/auth/sessions", {
45
+ default: () => ({ sessions: [], isDevMock: false }),
46
+ })
47
+
48
+ const users = computed<UserRecord[]>(() => usersData.value?.users || [])
49
+ const sessions = computed<SessionRecord[]>(() => sessionsData.value?.sessions || [])
50
+ const isDevMock = computed(() =>
51
+ Boolean(usersData.value?.isDevMock || sessionsData.value?.isDevMock),
52
+ )
53
+
54
+ const filteredUsers = computed(() => {
55
+ if (!searchQuery.value.trim()) return users.value
56
+ const q = searchQuery.value.toLowerCase()
57
+ return users.value.filter(
58
+ (u) =>
59
+ u.email.toLowerCase().includes(q) ||
60
+ (u.name && u.name.toLowerCase().includes(q)) ||
61
+ (u.role && u.role.toLowerCase().includes(q)),
62
+ )
63
+ })
64
+
65
+ const filteredSessions = computed(() => {
66
+ if (!searchQuery.value.trim()) return sessions.value
67
+ const q = searchQuery.value.toLowerCase()
68
+ return sessions.value.filter(
69
+ (s) =>
70
+ (s.userEmail && s.userEmail.toLowerCase().includes(q)) ||
71
+ (s.userName && s.userName.toLowerCase().includes(q)) ||
72
+ (s.ipAddress && s.ipAddress.includes(q)) ||
73
+ (s.clientType && s.clientType.toLowerCase().includes(q)),
74
+ )
75
+ })
76
+
77
+ const stats = computed(() => {
78
+ const verifiedCount = users.value.filter((u) => Boolean(u.emailVerified)).length
79
+ const adminCount = users.value.filter((u) => u.role === "admin").length
80
+ return {
81
+ totalUsers: users.value.length,
82
+ activeSessions: sessions.value.length,
83
+ verifiedCount,
84
+ adminCount,
85
+ }
86
+ })
87
+
88
+ function fmtDate(ts?: number) {
89
+ if (!ts) return "—"
90
+ return new Date(ts).toLocaleDateString([], {
91
+ year: "numeric",
92
+ month: "short",
93
+ day: "numeric",
94
+ hour: "2-digit",
95
+ minute: "2-digit",
96
+ })
97
+ }
98
+
99
+ function fmtRelative(ts?: number) {
100
+ if (!ts) return "—"
101
+ const diff = Date.now() - ts
102
+ const mins = Math.floor(diff / 60000)
103
+ if (mins < 1) return "Just now"
104
+ if (mins < 60) return `${mins}m ago`
105
+ const hours = Math.floor(mins / 60)
106
+ if (hours < 24) return `${hours}h ago`
107
+ return `${Math.floor(hours / 24)}d ago`
108
+ }
109
+
110
+ async function revokeSession(sessionId: string) {
111
+ revokingId.value = sessionId
112
+ try {
113
+ await $fetch("/_qarpeo/api/auth/revoke-session", {
114
+ method: "POST",
115
+ body: { sessionId },
116
+ })
117
+ await refreshSessions()
118
+ } finally {
119
+ revokingId.value = null
120
+ }
121
+ }
122
+
123
+ async function refreshAll() {
124
+ await Promise.all([refreshUsers(), refreshSessions()])
125
+ }
126
+
127
+ onMounted(() => {
128
+ refreshAll()
129
+ })
130
+ </script>
131
+
132
+ <template>
133
+ <UDashboardPanel id="devtools-auth">
134
+ <template #header>
135
+ <UDashboardNavbar>
136
+ <template #title>
137
+ <div class="flex items-center gap-2">
138
+ <UIcon name="i-lucide-users" class="w-4 h-4 text-primary" />
139
+ <span class="font-bold text-sm text-highlighted">Auth & Users</span>
140
+ <UBadge size="xs" color="primary" variant="subtle">Tier 1 Auth</UBadge>
141
+ <UBadge
142
+ v-if="isDevMock"
143
+ size="xs"
144
+ color="warning"
145
+ variant="subtle"
146
+ icon="i-lucide-flask-conical"
147
+ >
148
+ Preview Mode
149
+ </UBadge>
150
+ </div>
151
+ </template>
152
+
153
+ <template #right>
154
+ <div class="flex items-center gap-2">
155
+ <UButton
156
+ icon="i-lucide-refresh-cw"
157
+ size="xs"
158
+ color="neutral"
159
+ variant="ghost"
160
+ title="Refresh auth data"
161
+ :loading="usersPending || sessionsPending"
162
+ @click="refreshAll"
163
+ />
164
+ </div>
165
+ </template>
166
+ </UDashboardNavbar>
167
+
168
+ <!-- Toolbar with KPI cards and Search -->
169
+ <UDashboardToolbar>
170
+ <div class="flex flex-col gap-3 w-full py-2">
171
+ <!-- KPI Summary Grid -->
172
+ <div class="grid grid-cols-2 sm:grid-cols-4 gap-2 w-full">
173
+ <div class="p-2.5 rounded-lg border border-default bg-card">
174
+ <span class="text-xs text-muted">Total Users</span>
175
+ <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.totalUsers }}</p>
176
+ </div>
177
+ <div class="p-2.5 rounded-lg border border-default bg-card">
178
+ <span class="text-xs text-muted">Active Sessions</span>
179
+ <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.activeSessions }}</p>
180
+ </div>
181
+ <div class="p-2.5 rounded-lg border border-default bg-card">
182
+ <span class="text-xs text-muted">Verified Emails</span>
183
+ <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.verifiedCount }}</p>
184
+ </div>
185
+ <div class="p-2.5 rounded-lg border border-default bg-card">
186
+ <span class="text-xs text-muted">Administrators</span>
187
+ <p class="text-lg font-bold text-highlighted mt-0.5">{{ stats.adminCount }}</p>
188
+ </div>
189
+ </div>
190
+
191
+ <!-- Controls: Tabs + Search -->
192
+ <div
193
+ class="flex items-center justify-between flex-wrap gap-2 pt-1 border-t border-default"
194
+ >
195
+ <div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
196
+ <UButton
197
+ label="Users"
198
+ icon="i-lucide-user"
199
+ size="xs"
200
+ :color="activeTab === 'users' ? 'primary' : 'neutral'"
201
+ :variant="activeTab === 'users' ? 'subtle' : 'ghost'"
202
+ @click="activeTab = 'users'"
203
+ >
204
+ <template #trailing>
205
+ <UBadge
206
+ size="xs"
207
+ :color="activeTab === 'users' ? 'primary' : 'neutral'"
208
+ variant="subtle"
209
+ >
210
+ {{ users.length }}
211
+ </UBadge>
212
+ </template>
213
+ </UButton>
214
+
215
+ <UButton
216
+ label="Active Sessions"
217
+ icon="i-lucide-shield-check"
218
+ size="xs"
219
+ :color="activeTab === 'sessions' ? 'primary' : 'neutral'"
220
+ :variant="activeTab === 'sessions' ? 'subtle' : 'ghost'"
221
+ @click="activeTab = 'sessions'"
222
+ >
223
+ <template #trailing>
224
+ <UBadge
225
+ size="xs"
226
+ :color="activeTab === 'sessions' ? 'primary' : 'neutral'"
227
+ variant="subtle"
228
+ >
229
+ {{ sessions.length }}
230
+ </UBadge>
231
+ </template>
232
+ </UButton>
233
+ </div>
234
+
235
+ <div class="w-full sm:w-64">
236
+ <UInput
237
+ v-model="searchQuery"
238
+ icon="i-lucide-search"
239
+ size="xs"
240
+ placeholder="Filter by name, email, IP..."
241
+ class="w-full"
242
+ />
243
+ </div>
244
+ </div>
245
+ </div>
246
+ </UDashboardToolbar>
247
+ </template>
248
+
249
+ <!-- Main Content Area -->
250
+ <div class="p-4 overflow-x-auto">
251
+ <!-- ─── USERS TAB ─────────────────────────────────────────────────────────── -->
252
+ <div v-if="activeTab === 'users'">
253
+ <div v-if="filteredUsers.length === 0" class="text-center py-12 text-muted">
254
+ <UIcon name="i-lucide-user-x" class="w-8 h-8 mx-auto mb-2 opacity-50" />
255
+ <p class="text-sm font-medium">No users found</p>
256
+ <p class="text-xs text-muted mt-1">
257
+ Users register via OAuth, WebAuthn Passkeys, OTP, or Magic Links.
258
+ </p>
259
+ </div>
260
+
261
+ <div v-else class="border border-default rounded-lg overflow-hidden bg-card">
262
+ <table class="w-full text-left text-xs">
263
+ <thead class="bg-muted border-b border-default text-muted font-medium">
264
+ <tr>
265
+ <th class="p-3">User</th>
266
+ <th class="p-3">Role</th>
267
+ <th class="p-3">Status</th>
268
+ <th class="p-3">Registered</th>
269
+ <th class="p-3">ID</th>
270
+ </tr>
271
+ </thead>
272
+ <tbody class="divide-y divide-default">
273
+ <tr v-for="u in filteredUsers" :key="u.id" class="hover:bg-muted/50 transition">
274
+ <td class="p-3">
275
+ <div class="flex items-center gap-2.5">
276
+ <div
277
+ class="w-7 h-7 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center font-bold text-primary text-xs shrink-0"
278
+ >
279
+ {{ (u.name || u.email).charAt(0).toUpperCase() }}
280
+ </div>
281
+ <div>
282
+ <p class="font-medium text-highlighted">{{ u.name || "—" }}</p>
283
+ <p class="text-[11px] text-muted font-mono">{{ u.email }}</p>
284
+ </div>
285
+ </div>
286
+ </td>
287
+ <td class="p-3">
288
+ <UBadge
289
+ size="xs"
290
+ :color="u.role === 'admin' ? 'primary' : 'neutral'"
291
+ variant="subtle"
292
+ >
293
+ {{ u.role || "user" }}
294
+ </UBadge>
295
+ </td>
296
+ <td class="p-3">
297
+ <UBadge
298
+ size="xs"
299
+ :color="u.emailVerified ? 'success' : 'neutral'"
300
+ variant="subtle"
301
+ >
302
+ {{ u.emailVerified ? "Verified" : "Unverified" }}
303
+ </UBadge>
304
+ </td>
305
+ <td class="p-3 text-muted">
306
+ {{ fmtDate(u.createdAt) }}
307
+ </td>
308
+ <td class="p-3 font-mono text-[11px] text-muted">
309
+ {{ u.id }}
310
+ </td>
311
+ </tr>
312
+ </tbody>
313
+ </table>
314
+ </div>
315
+ </div>
316
+
317
+ <!-- ─── SESSIONS TAB ──────────────────────────────────────────────────────── -->
318
+ <div v-else-if="activeTab === 'sessions'">
319
+ <div v-if="filteredSessions.length === 0" class="text-center py-12 text-muted">
320
+ <UIcon name="i-lucide-shield-alert" class="w-8 h-8 mx-auto mb-2 opacity-50" />
321
+ <p class="text-sm font-medium">No active sessions</p>
322
+ <p class="text-xs text-muted mt-1">Sessions are tracked across D1 and KV.</p>
323
+ </div>
324
+
325
+ <div v-else class="border border-default rounded-lg overflow-hidden bg-card">
326
+ <table class="w-full text-left text-xs">
327
+ <thead class="bg-muted border-b border-default text-muted font-medium">
328
+ <tr>
329
+ <th class="p-3">User</th>
330
+ <th class="p-3">Client</th>
331
+ <th class="p-3">IP Address</th>
332
+ <th class="p-3">Last Active</th>
333
+ <th class="p-3">Expires</th>
334
+ <th class="p-3 text-right">Actions</th>
335
+ </tr>
336
+ </thead>
337
+ <tbody class="divide-y divide-default">
338
+ <tr v-for="s in filteredSessions" :key="s.id" class="hover:bg-muted/50 transition">
339
+ <td class="p-3">
340
+ <p class="font-medium text-highlighted">{{ s.userName || "Active User" }}</p>
341
+ <p class="text-[11px] text-muted font-mono">{{ s.userEmail || s.userId }}</p>
342
+ </td>
343
+ <td class="p-3">
344
+ <UBadge size="xs" color="neutral" variant="subtle">
345
+ {{ s.clientType || "web" }}
346
+ </UBadge>
347
+ <p
348
+ class="text-[10px] text-muted truncate max-w-[200px] mt-0.5"
349
+ :title="s.userAgent"
350
+ >
351
+ {{ s.userAgent || "—" }}
352
+ </p>
353
+ </td>
354
+ <td class="p-3 font-mono text-[11px]">
355
+ {{ s.ipAddress || "—" }}
356
+ </td>
357
+ <td class="p-3 text-muted">
358
+ {{ fmtRelative(s.lastActive) }}
359
+ </td>
360
+ <td class="p-3 text-muted">
361
+ {{ fmtDate(s.expiresAt) }}
362
+ </td>
363
+ <td class="p-3 text-right">
364
+ <UButton
365
+ size="xs"
366
+ color="error"
367
+ variant="ghost"
368
+ icon="i-lucide-log-out"
369
+ label="Revoke"
370
+ :loading="revokingId === s.id"
371
+ @click="revokeSession(s.id)"
372
+ />
373
+ </td>
374
+ </tr>
375
+ </tbody>
376
+ </table>
377
+ </div>
378
+ </div>
379
+ </div>
380
+ </UDashboardPanel>
381
+ </template>