qarpeo 0.1.30 → 0.1.32

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 (182) hide show
  1. package/README.md +9 -0
  2. package/dist/chunks/auth-schema.mjs +28 -16
  3. package/dist/chunks/wrangler.mjs +1 -1
  4. package/dist/module.d.ts +1 -1
  5. package/dist/module.mjs +405 -20
  6. package/dist/runtime/app/components/AuthRegister.vue +306 -0
  7. package/dist/runtime/app/components/AuthSessionsList.vue +137 -0
  8. package/dist/runtime/app/components/AuthSignIn.vue +298 -0
  9. package/dist/runtime/app/components/AuthState.vue +10 -0
  10. package/dist/runtime/app/components/CMSBookmarkButton.vue +59 -0
  11. package/dist/runtime/app/components/CMSComments.vue +202 -0
  12. package/dist/runtime/app/components/CMSNewsletter.vue +81 -0
  13. package/dist/runtime/app/components/CMSTableOfContents.vue +84 -0
  14. package/dist/runtime/app/components/NotificationBell.vue +263 -0
  15. package/dist/runtime/app/components/NotificationList.vue +205 -0
  16. package/dist/runtime/app/components/NotificationPrompt.vue +133 -0
  17. package/dist/runtime/app/components/PricingGated.vue +81 -0
  18. package/dist/runtime/app/components/PricingTable.vue +274 -0
  19. package/dist/runtime/app/components/RealtimeChat.vue +164 -0
  20. package/dist/runtime/app/components/RealtimeCursors.vue +139 -0
  21. package/dist/runtime/app/components/RealtimePresence.vue +129 -0
  22. package/dist/runtime/app/components/RealtimeStatus.vue +79 -0
  23. package/dist/runtime/app/components/SubscriptionCard.vue +207 -0
  24. package/dist/runtime/app/components/UserProfile.vue +558 -0
  25. package/dist/runtime/app/composables/cms-preview.mjs +14 -2
  26. package/dist/runtime/app/composables/cms.d.ts +107 -14
  27. package/dist/runtime/app/composables/cms.mjs +308 -11
  28. package/dist/runtime/app/composables/payments.d.ts +2 -0
  29. package/dist/runtime/app/composables/payments.mjs +22 -0
  30. package/dist/runtime/app/composables/realtime.d.ts +2 -0
  31. package/dist/runtime/app/composables/realtime.mjs +11 -0
  32. package/dist/runtime/app/composables/site.mjs +1 -1
  33. package/dist/runtime/app/pages/devtools/notifications.vue +355 -0
  34. package/dist/runtime/blob.mjs +22 -6
  35. package/dist/runtime/email.mjs +4 -4
  36. package/dist/runtime/kv.mjs +38 -0
  37. package/dist/runtime/server/db/cms-schema.d.ts +820 -1
  38. package/dist/runtime/server/db/cms-schema.mjs +109 -3
  39. package/dist/runtime/server/durable-objects/agent.mjs +4 -4
  40. package/dist/runtime/server/middleware/auth.mjs +9 -2
  41. package/dist/runtime/server/middleware/devtools.mjs +14 -1
  42. package/dist/runtime/server/middleware/ratelimit.mjs +9 -2
  43. package/dist/runtime/server/middleware/tracker.mjs +3 -1
  44. package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +3 -5
  45. package/dist/runtime/server/routes/analytics/events.get.mjs +10 -1
  46. package/dist/runtime/server/routes/analytics/pageviews.get.mjs +10 -1
  47. package/dist/runtime/server/routes/analytics/summary.get.mjs +10 -1
  48. package/dist/runtime/server/routes/auth/audit-logs.get.d.ts +5 -0
  49. package/dist/runtime/server/routes/auth/audit-logs.get.mjs +19 -0
  50. package/dist/runtime/server/routes/cms/[collection]/[id]/preview-token.post.mjs +1 -1
  51. package/dist/runtime/server/routes/cms/[collection]/[id]/publish.post.mjs +1 -1
  52. package/dist/runtime/server/routes/cms/[collection]/[id]/review.post.mjs +1 -1
  53. package/dist/runtime/server/routes/cms/[collection]/[id]/revisions/[revId]/restore.post.d.ts +4 -0
  54. package/dist/runtime/server/routes/cms/[collection]/[id]/revisions/[revId]/restore.post.mjs +21 -0
  55. package/dist/runtime/server/routes/cms/[collection]/[id]/revisions/index.get.d.ts +4 -0
  56. package/dist/runtime/server/routes/cms/[collection]/[id]/revisions/index.get.mjs +13 -0
  57. package/dist/runtime/server/routes/cms/[collection]/[id]/view.post.d.ts +12 -0
  58. package/dist/runtime/server/routes/cms/[collection]/[id]/view.post.mjs +20 -0
  59. package/dist/runtime/server/routes/cms/[collection]/[id].delete.mjs +1 -1
  60. package/dist/runtime/server/routes/cms/[collection]/[id].put.mjs +1 -1
  61. package/dist/runtime/server/routes/cms/[collection]/[slug].get.mjs +3 -1
  62. package/dist/runtime/server/routes/cms/[collection]/by-path.get.mjs +2 -2
  63. package/dist/runtime/server/routes/cms/[collection]/index.get.mjs +32 -4
  64. package/dist/runtime/server/routes/cms/[collection]/index.post.mjs +1 -1
  65. package/dist/runtime/server/routes/cms/[collection]/references.get.mjs +1 -1
  66. package/dist/runtime/server/routes/cms/bookmarks/[id].delete.d.ts +5 -0
  67. package/dist/runtime/server/routes/cms/bookmarks/[id].delete.mjs +23 -0
  68. package/dist/runtime/server/routes/cms/bookmarks/check.post.d.ts +4 -0
  69. package/dist/runtime/server/routes/cms/bookmarks/check.post.mjs +20 -0
  70. package/dist/runtime/server/routes/cms/bookmarks/index.get.d.ts +4 -0
  71. package/dist/runtime/server/routes/cms/bookmarks/index.get.mjs +16 -0
  72. package/dist/runtime/server/routes/cms/bookmarks/index.post.d.ts +5 -0
  73. package/dist/runtime/server/routes/cms/bookmarks/index.post.mjs +20 -0
  74. package/dist/runtime/server/routes/cms/categories/[id].delete.d.ts +5 -0
  75. package/dist/runtime/server/routes/cms/categories/[id].delete.mjs +13 -0
  76. package/dist/runtime/server/routes/cms/categories/[id].put.d.ts +5 -0
  77. package/dist/runtime/server/routes/cms/categories/[id].put.mjs +14 -0
  78. package/dist/runtime/server/routes/cms/categories.get.d.ts +5 -0
  79. package/dist/runtime/server/routes/cms/categories.get.mjs +6 -0
  80. package/dist/runtime/server/routes/cms/categories.post.d.ts +15 -0
  81. package/dist/runtime/server/routes/cms/categories.post.mjs +20 -0
  82. package/dist/runtime/server/routes/cms/collections/[id].delete.mjs +1 -1
  83. package/dist/runtime/server/routes/cms/collections/[id].put.mjs +1 -1
  84. package/dist/runtime/server/routes/cms/collections/index.get.mjs +4 -1
  85. package/dist/runtime/server/routes/cms/collections/index.post.mjs +1 -1
  86. package/dist/runtime/server/routes/cms/comments/[id].delete.d.ts +5 -0
  87. package/dist/runtime/server/routes/cms/comments/[id].delete.mjs +12 -0
  88. package/dist/runtime/server/routes/cms/comments/[id].get.d.ts +4 -0
  89. package/dist/runtime/server/routes/cms/comments/[id].get.mjs +13 -0
  90. package/dist/runtime/server/routes/cms/comments/[id].patch.d.ts +6 -0
  91. package/dist/runtime/server/routes/cms/comments/[id].patch.mjs +17 -0
  92. package/dist/runtime/server/routes/cms/comments.get.d.ts +5 -0
  93. package/dist/runtime/server/routes/cms/comments.get.mjs +43 -0
  94. package/dist/runtime/server/routes/cms/comments.post.d.ts +17 -0
  95. package/dist/runtime/server/routes/cms/comments.post.mjs +46 -0
  96. package/dist/runtime/server/routes/cms/components/index.get.mjs +2 -0
  97. package/dist/runtime/server/routes/cms/export.post.mjs +13 -5
  98. package/dist/runtime/server/routes/cms/newsletter.post.d.ts +12 -0
  99. package/dist/runtime/server/routes/cms/newsletter.post.mjs +31 -0
  100. package/dist/runtime/server/routes/cms/preview/disable.get.mjs +3 -0
  101. package/dist/runtime/server/routes/cms/preview/enable.get.mjs +8 -1
  102. package/dist/runtime/server/routes/cms/search.get.mjs +10 -4
  103. package/dist/runtime/server/routes/cms/subscribers/[id].delete.d.ts +5 -0
  104. package/dist/runtime/server/routes/cms/subscribers/[id].delete.mjs +12 -0
  105. package/dist/runtime/server/routes/cms/subscribers/[id].patch.d.ts +6 -0
  106. package/dist/runtime/server/routes/cms/subscribers/[id].patch.mjs +15 -0
  107. package/dist/runtime/server/routes/cms/subscribers.get.d.ts +5 -0
  108. package/dist/runtime/server/routes/cms/subscribers.get.mjs +11 -0
  109. package/dist/runtime/server/routes/cms/sync.post.mjs +1 -1
  110. package/dist/runtime/server/routes/cms/tags/[id].delete.d.ts +5 -0
  111. package/dist/runtime/server/routes/cms/tags/[id].delete.mjs +13 -0
  112. package/dist/runtime/server/routes/cms/tags.get.d.ts +4 -0
  113. package/dist/runtime/server/routes/cms/tags.get.mjs +6 -0
  114. package/dist/runtime/server/routes/cms/tags.post.d.ts +9 -0
  115. package/dist/runtime/server/routes/cms/tags.post.mjs +17 -0
  116. package/dist/runtime/server/routes/mail/bounce.post.mjs +10 -1
  117. package/dist/runtime/server/routes/mail/inbox/[id].get.mjs +3 -0
  118. package/dist/runtime/server/routes/mail/inbox.get.mjs +4 -1
  119. package/dist/runtime/server/routes/mail/suppressions/[email].delete.d.ts +1 -1
  120. package/dist/runtime/server/routes/mail/suppressions/[email].delete.mjs +17 -0
  121. package/dist/runtime/server/routes/mail/suppressions/index.get.d.ts +2 -1
  122. package/dist/runtime/server/routes/mail/suppressions/index.get.mjs +18 -1
  123. package/dist/runtime/server/routes/mail/suppressions/index.post.d.ts +2 -1
  124. package/dist/runtime/server/routes/mail/suppressions/index.post.mjs +17 -0
  125. package/dist/runtime/server/routes/mail/webhooks.post.mjs +10 -1
  126. package/dist/runtime/server/routes/notifications/send.post.d.ts +4 -0
  127. package/dist/runtime/server/routes/notifications/send.post.mjs +45 -0
  128. package/dist/runtime/server/routes/payments/checkout.post.mjs +2 -2
  129. package/dist/runtime/server/routes/payments/pause.post.mjs +6 -5
  130. package/dist/runtime/server/routes/payments/portal.post.mjs +1 -1
  131. package/dist/runtime/server/routes/payments/usage.post.mjs +16 -11
  132. package/dist/runtime/server/routes/payments/webhook.post.d.ts +1 -0
  133. package/dist/runtime/server/routes/realtime/broadcast.post.mjs +8 -0
  134. package/dist/runtime/server/routes/realtime/history.delete.mjs +8 -0
  135. package/dist/runtime/server/routes/realtime/ws.get.mjs +3 -0
  136. package/dist/runtime/server/routes/storage/file/[...key].delete.mjs +30 -1
  137. package/dist/runtime/server/routes/storage/files.get.mjs +12 -2
  138. package/dist/runtime/server/routes/storage/multipart/part.put.mjs +2 -2
  139. package/dist/runtime/server/tasks/cms/publish.d.ts +1 -3
  140. package/dist/runtime/server/tasks/cms/publish.mjs +0 -1
  141. package/dist/runtime/server/utils/audit.d.ts +32 -0
  142. package/dist/runtime/server/utils/audit.mjs +197 -0
  143. package/dist/runtime/server/utils/auth.d.ts +4 -4
  144. package/dist/runtime/server/utils/auth.mjs +53 -7
  145. package/dist/runtime/server/utils/bots.mjs +1 -0
  146. package/dist/runtime/server/utils/cache.mjs +5 -1
  147. package/dist/runtime/server/utils/cms/common.d.ts +6 -3
  148. package/dist/runtime/server/utils/cms/common.mjs +3 -5
  149. package/dist/runtime/server/utils/cms/git.mjs +6 -2
  150. package/dist/runtime/server/utils/cms/markdown.d.ts +5 -0
  151. package/dist/runtime/server/utils/cms/markdown.mjs +18 -3
  152. package/dist/runtime/server/utils/cms-events.mjs +8 -2
  153. package/dist/runtime/server/utils/cms.d.ts +151 -0
  154. package/dist/runtime/server/utils/cms.mjs +818 -104
  155. package/dist/runtime/server/utils/crypto.d.ts +2 -0
  156. package/dist/runtime/server/utils/crypto.mjs +10 -0
  157. package/dist/runtime/server/utils/domains.mjs +2 -1
  158. package/dist/runtime/server/utils/impersonation.mjs +4 -5
  159. package/dist/runtime/server/utils/mail-suppression.mjs +10 -2
  160. package/dist/runtime/server/utils/mail.mjs +4 -2
  161. package/dist/runtime/server/utils/notifications.mjs +1 -3
  162. package/dist/runtime/server/utils/oauth.d.ts +31 -0
  163. package/dist/runtime/server/utils/oauth.mjs +82 -0
  164. package/dist/runtime/server/utils/organization.mjs +4 -5
  165. package/dist/runtime/server/utils/passwordless.mjs +4 -5
  166. package/dist/runtime/server/utils/payments.d.ts +1 -0
  167. package/dist/runtime/server/utils/payments.mjs +42 -16
  168. package/dist/runtime/server/utils/schema-fallback.d.ts +5 -0
  169. package/dist/runtime/server/utils/schema-fallback.mjs +3 -0
  170. package/dist/runtime/server/utils/session.d.ts +4 -4
  171. package/dist/runtime/server/utils/sso.mjs +4 -2
  172. package/dist/runtime/server/utils/storage.mjs +1 -1
  173. package/dist/runtime/server/utils/tenant.mjs +11 -9
  174. package/dist/runtime/server/utils/turnstile.mjs +2 -1
  175. package/dist/runtime/server.d.ts +1 -0
  176. package/dist/runtime/server.mjs +1 -0
  177. package/dist/runtime/types/imports.d.ts +5 -0
  178. package/dist/runtime/types/index.d.ts +10 -0
  179. package/dist/runtime/types/r2.d.ts +22 -4
  180. package/dist/types.d.ts +104 -1
  181. package/dist/utils/auth-schema.d.ts +1 -1
  182. package/package.json +7 -7
@@ -0,0 +1,298 @@
1
+ <script lang="ts" setup>
2
+ import { navigateTo, useRuntimeConfig } from "nuxt/app"
3
+ import { computed, ref } from "vue"
4
+
5
+ import { useAuth } from "../composables/auth"
6
+ import { usePasskey } from "../composables/passkey"
7
+ import { usePasswordless } from "../composables/passwordless"
8
+
9
+ interface Props {
10
+ title?: string
11
+ description?: string
12
+ redirect?: string
13
+ signUpUrl?: string
14
+ providers?: string[]
15
+ allowMagicLink?: boolean
16
+ allowPasskey?: boolean
17
+ }
18
+
19
+ const props = withDefaults(defineProps<Props>(), {
20
+ title: "Welcome back",
21
+ description: "Sign in to your account",
22
+ redirect: "/",
23
+ signUpUrl: "/register",
24
+ providers: () => ["github", "google"],
25
+ allowMagicLink: true,
26
+ allowPasskey: true,
27
+ })
28
+
29
+ const emit = defineEmits<{
30
+ success: [session: any]
31
+ error: [err: any]
32
+ }>()
33
+
34
+ const runtimeConfig = useRuntimeConfig()
35
+ const authConfig = (runtimeConfig.public as any)?.qarpeo?.auth || {}
36
+ const authPrefix = authConfig.prefix || "/api/auth"
37
+
38
+ const { signIn, fetch: refreshSession } = useAuth()
39
+ const { loginWithPasskey, loading: passkeyLoading } = usePasskey()
40
+ const { sendMagicLink, loading: magicLinkLoading } = usePasswordless()
41
+
42
+ // Form mode: 'password' | 'magic-link'
43
+ const mode = ref<"password" | "magic-link">("password")
44
+ const email = ref("")
45
+ const password = ref("")
46
+ const rememberMe = ref(true)
47
+ const loading = ref(false)
48
+ const errorMessage = ref("")
49
+ const successMessage = ref("")
50
+
51
+ const isLoading = computed(() => loading.value || passkeyLoading.value || magicLinkLoading.value)
52
+
53
+ async function handlePasswordSignIn() {
54
+ if (!email.value || !password.value) {
55
+ errorMessage.value = "Please fill in all fields"
56
+ return
57
+ }
58
+ loading.value = true
59
+ errorMessage.value = ""
60
+ try {
61
+ const res = await signIn.email({
62
+ email: email.value,
63
+ password: password.value,
64
+ rememberMe: rememberMe.value,
65
+ })
66
+ if ((res as any)?.error) {
67
+ throw new Error((res as any).error.message || "Failed to sign in")
68
+ }
69
+ await refreshSession()
70
+ emit("success", res)
71
+ if (props.redirect) {
72
+ await navigateTo(props.redirect)
73
+ }
74
+ } catch (err: any) {
75
+ errorMessage.value = err?.data?.message || err?.message || "Invalid credentials"
76
+ emit("error", err)
77
+ } finally {
78
+ loading.value = false
79
+ }
80
+ }
81
+
82
+ async function handleMagicLinkSignIn() {
83
+ if (!email.value) {
84
+ errorMessage.value = "Please enter your email"
85
+ return
86
+ }
87
+ errorMessage.value = ""
88
+ successMessage.value = ""
89
+ try {
90
+ await sendMagicLink(email.value)
91
+ successMessage.value = "Check your email for the magic sign-in link!"
92
+ } catch (err: any) {
93
+ errorMessage.value = err?.data?.message || err?.message || "Failed to send magic link"
94
+ emit("error", err)
95
+ }
96
+ }
97
+
98
+ async function handlePasskeySignIn() {
99
+ errorMessage.value = ""
100
+ try {
101
+ const res = await loginWithPasskey()
102
+ await refreshSession()
103
+ emit("success", res)
104
+ if (props.redirect) {
105
+ await navigateTo(props.redirect)
106
+ }
107
+ } catch (err: any) {
108
+ errorMessage.value = err?.data?.message || err?.message || "Passkey sign-in cancelled or failed"
109
+ emit("error", err)
110
+ }
111
+ }
112
+
113
+ function handleOAuthSignIn(provider: string) {
114
+ if (typeof window !== "undefined") {
115
+ const callbackUrl = encodeURIComponent(window.location.origin + props.redirect)
116
+ window.location.href = `${authPrefix}/sign-in/social?provider=${provider}&callbackURL=${callbackUrl}`
117
+ }
118
+ }
119
+ </script>
120
+
121
+ <template>
122
+ <div
123
+ class="mx-auto w-full max-w-md rounded-2xl border border-neutral-200 bg-white p-8 shadow-sm dark:border-neutral-800 dark:bg-neutral-900"
124
+ >
125
+ <div class="mb-6 text-center">
126
+ <h2 class="text-2xl font-bold tracking-tight text-neutral-900 dark:text-neutral-50">
127
+ {{ title }}
128
+ </h2>
129
+ <p class="mt-1 text-sm text-neutral-500 dark:text-neutral-400">
130
+ {{ description }}
131
+ </p>
132
+ </div>
133
+
134
+ <!-- Error & Success Banners -->
135
+ <div
136
+ v-if="errorMessage"
137
+ class="mb-4 rounded-lg bg-red-50 p-3 text-sm text-red-700 dark:bg-red-950/50 dark:text-red-400"
138
+ >
139
+ {{ errorMessage }}
140
+ </div>
141
+ <div
142
+ v-if="successMessage"
143
+ class="mb-4 rounded-lg bg-emerald-50 p-3 text-sm text-emerald-700 dark:bg-emerald-950/50 dark:text-emerald-400"
144
+ >
145
+ {{ successMessage }}
146
+ </div>
147
+
148
+ <!-- Social OAuth Providers -->
149
+ <div v-if="providers.length > 0" class="space-y-3">
150
+ <div class="grid grid-cols-1 gap-2" :class="providers.length > 1 ? 'sm:grid-cols-2' : ''">
151
+ <button
152
+ v-for="provider in providers"
153
+ :key="provider"
154
+ type="button"
155
+ class="flex items-center justify-center gap-2 rounded-lg border border-neutral-200 bg-white px-4 py-2 text-sm font-medium text-neutral-700 hover:bg-neutral-50 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-200 dark:hover:bg-neutral-700"
156
+ @click="handleOAuthSignIn(provider)"
157
+ >
158
+ <span class="capitalize">{{ provider }}</span>
159
+ </button>
160
+ </div>
161
+
162
+ <div class="relative my-4 flex items-center justify-center">
163
+ <div class="w-full border-t border-neutral-200 dark:border-neutral-700" />
164
+ <span class="absolute bg-white px-3 text-xs text-neutral-400 dark:bg-neutral-900"
165
+ >or continue with</span
166
+ >
167
+ </div>
168
+ </div>
169
+
170
+ <!-- Form Mode Tabs (Password vs Magic Link) -->
171
+ <div v-if="allowMagicLink" class="mb-4 flex rounded-lg bg-neutral-100 p-1 dark:bg-neutral-800">
172
+ <button
173
+ type="button"
174
+ class="flex-1 rounded-md py-1.5 text-xs font-semibold transition"
175
+ :class="
176
+ mode === 'password'
177
+ ? 'bg-white shadow text-neutral-900 dark:bg-neutral-700 dark:text-white'
178
+ : 'text-neutral-500 hover:text-neutral-700 dark:text-neutral-400'
179
+ "
180
+ @click="mode = 'password'"
181
+ >
182
+ Password
183
+ </button>
184
+ <button
185
+ type="button"
186
+ class="flex-1 rounded-md py-1.5 text-xs font-semibold transition"
187
+ :class="
188
+ mode === 'magic-link'
189
+ ? 'bg-white shadow text-neutral-900 dark:bg-neutral-700 dark:text-white'
190
+ : 'text-neutral-500 hover:text-neutral-700 dark:text-neutral-400'
191
+ "
192
+ @click="mode = 'magic-link'"
193
+ >
194
+ Magic Link
195
+ </button>
196
+ </div>
197
+
198
+ <!-- Password Sign In Form -->
199
+ <form v-if="mode === 'password'" class="space-y-4" @submit.prevent="handlePasswordSignIn">
200
+ <div>
201
+ <label class="block text-xs font-medium text-neutral-700 dark:text-neutral-300"
202
+ >Email Address</label
203
+ >
204
+ <input
205
+ v-model="email"
206
+ type="email"
207
+ required
208
+ autocomplete="email"
209
+ placeholder="you@example.com"
210
+ class="mt-1 block w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-900 focus:outline-none dark:border-neutral-700 dark:bg-neutral-800 dark:text-white dark:focus:border-neutral-400"
211
+ />
212
+ </div>
213
+
214
+ <div>
215
+ <label class="block text-xs font-medium text-neutral-700 dark:text-neutral-300"
216
+ >Password</label
217
+ >
218
+ <input
219
+ v-model="password"
220
+ type="password"
221
+ required
222
+ autocomplete="current-password"
223
+ placeholder="••••••••"
224
+ class="mt-1 block w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-900 focus:outline-none dark:border-neutral-700 dark:bg-neutral-800 dark:text-white dark:focus:border-neutral-400"
225
+ />
226
+ </div>
227
+
228
+ <div class="flex items-center justify-between text-xs">
229
+ <label class="flex items-center gap-2 text-neutral-600 dark:text-neutral-400">
230
+ <input
231
+ v-model="rememberMe"
232
+ type="checkbox"
233
+ class="rounded border-neutral-300 dark:border-neutral-700"
234
+ />
235
+ <span>Remember me</span>
236
+ </label>
237
+ </div>
238
+
239
+ <button
240
+ type="submit"
241
+ :disabled="isLoading"
242
+ class="flex w-full items-center justify-center rounded-lg bg-neutral-900 py-2.5 text-sm font-medium text-white transition hover:bg-neutral-800 disabled:opacity-50 dark:bg-neutral-100 dark:text-neutral-900 dark:hover:bg-white"
243
+ >
244
+ <span v-if="loading">Signing in...</span>
245
+ <span v-else>Sign In</span>
246
+ </button>
247
+ </form>
248
+
249
+ <!-- Magic Link Form -->
250
+ <form v-else class="space-y-4" @submit.prevent="handleMagicLinkSignIn">
251
+ <div>
252
+ <label class="block text-xs font-medium text-neutral-700 dark:text-neutral-300"
253
+ >Email Address</label
254
+ >
255
+ <input
256
+ v-model="email"
257
+ type="email"
258
+ required
259
+ autocomplete="email"
260
+ placeholder="you@example.com"
261
+ class="mt-1 block w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm text-neutral-900 placeholder:text-neutral-400 focus:border-neutral-900 focus:outline-none dark:border-neutral-700 dark:bg-neutral-800 dark:text-white dark:focus:border-neutral-400"
262
+ />
263
+ </div>
264
+
265
+ <button
266
+ type="submit"
267
+ :disabled="isLoading"
268
+ class="flex w-full items-center justify-center rounded-lg bg-neutral-900 py-2.5 text-sm font-medium text-white transition hover:bg-neutral-800 disabled:opacity-50 dark:bg-neutral-100 dark:text-neutral-900 dark:hover:bg-white"
269
+ >
270
+ <span v-if="magicLinkLoading">Sending link...</span>
271
+ <span v-else>Send Magic Sign-in Link</span>
272
+ </button>
273
+ </form>
274
+
275
+ <!-- Passkey Button -->
276
+ <div v-if="allowPasskey" class="mt-4 pt-4 border-t border-neutral-100 dark:border-neutral-800">
277
+ <button
278
+ type="button"
279
+ :disabled="isLoading"
280
+ class="flex w-full items-center justify-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 py-2 text-xs font-medium text-neutral-700 hover:bg-neutral-100 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-750"
281
+ @click="handlePasskeySignIn"
282
+ >
283
+ <span>Sign in with Passkey / Biometrics</span>
284
+ </button>
285
+ </div>
286
+
287
+ <!-- Sign up footer -->
288
+ <div v-if="signUpUrl" class="mt-6 text-center text-xs text-neutral-500 dark:text-neutral-400">
289
+ Don't have an account?
290
+ <a
291
+ :href="signUpUrl"
292
+ class="font-medium text-neutral-900 underline hover:text-neutral-700 dark:text-neutral-100"
293
+ >
294
+ Create an account
295
+ </a>
296
+ </div>
297
+ </div>
298
+ </template>
@@ -0,0 +1,10 @@
1
+ <script setup lang="ts">
2
+ import { useUserSession } from "../composables/auth"
3
+
4
+ const { loggedIn, user, session, ready } = useUserSession()
5
+ </script>
6
+
7
+ <template>
8
+ <slot v-if="ready" :logged-in="loggedIn" :user="user" :session="session" />
9
+ <slot v-else name="placeholder" />
10
+ </template>
@@ -0,0 +1,59 @@
1
+ <script setup lang="ts">
2
+ import { ref, onMounted } from "vue"
3
+
4
+ import { useCMSBookmarks } from "../composables/cms"
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ entryId: string
9
+ showLabel?: boolean
10
+ }>(),
11
+ {
12
+ showLabel: false,
13
+ },
14
+ )
15
+
16
+ const { toggle, check, loading } = useCMSBookmarks()
17
+ const isBookmarked = ref(false)
18
+
19
+ onMounted(async () => {
20
+ if (props.entryId) {
21
+ isBookmarked.value = await check(props.entryId)
22
+ }
23
+ })
24
+
25
+ async function handleToggle() {
26
+ if (loading.value) return
27
+ isBookmarked.value = await toggle(props.entryId)
28
+ }
29
+ </script>
30
+
31
+ <template>
32
+ <button
33
+ type="button"
34
+ :disabled="loading"
35
+ class="qarpeo-bookmark-btn inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-xs font-medium transition hover:bg-neutral-100 disabled:opacity-50 dark:hover:bg-neutral-800"
36
+ :class="
37
+ isBookmarked
38
+ ? 'border-primary-500 text-primary-600 bg-primary-50/50 dark:bg-primary-950/20'
39
+ : 'text-neutral-600 dark:text-neutral-300'
40
+ "
41
+ @click="handleToggle"
42
+ >
43
+ <svg
44
+ xmlns="http://www.w3.org/2000/svg"
45
+ class="h-4 w-4"
46
+ :fill="isBookmarked ? 'currentColor' : 'none'"
47
+ viewBox="0 0 24 24"
48
+ stroke="currentColor"
49
+ stroke-width="2"
50
+ >
51
+ <path
52
+ stroke-linecap="round"
53
+ stroke-linejoin="round"
54
+ d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"
55
+ />
56
+ </svg>
57
+ <span v-if="showLabel">{{ isBookmarked ? "Saved" : "Save" }}</span>
58
+ </button>
59
+ </template>
@@ -0,0 +1,202 @@
1
+ <script setup lang="ts">
2
+ import { ref, computed } from "vue"
3
+
4
+ import { useCMSComments } from "../composables/cms"
5
+
6
+ const props = withDefaults(
7
+ defineProps<{
8
+ entryId: string
9
+ title?: string
10
+ allowReplies?: boolean
11
+ placeholder?: string
12
+ }>(),
13
+ {
14
+ title: "Comments",
15
+ allowReplies: true,
16
+ placeholder: "Write a constructive comment...",
17
+ },
18
+ )
19
+
20
+ const { comments, loading, error, postComment } = useCMSComments(() => props.entryId)
21
+
22
+ const authorName = ref("")
23
+ const authorEmail = ref("")
24
+ const newContent = ref("")
25
+ const replyToId = ref<string | null>(null)
26
+ const submitting = ref(false)
27
+ const submitSuccess = ref(false)
28
+
29
+ const rootComments = computed(() => {
30
+ return comments.value.filter((c: any) => !c.parentId && !c.parent_id)
31
+ })
32
+
33
+ function getReplies(parentId: string) {
34
+ return comments.value.filter((c: any) => (c.parentId || c.parent_id) === parentId)
35
+ }
36
+
37
+ async function handleSubmit(parentId?: string | null) {
38
+ if (!newContent.value.trim() || !authorName.value.trim()) return
39
+ submitting.value = true
40
+ submitSuccess.value = false
41
+ try {
42
+ await postComment({
43
+ content: newContent.value.trim(),
44
+ authorName: authorName.value.trim(),
45
+ authorEmail: authorEmail.value.trim() || undefined,
46
+ parentId: parentId || undefined,
47
+ })
48
+ newContent.value = ""
49
+ replyToId.value = null
50
+ submitSuccess.value = true
51
+ setTimeout(() => {
52
+ submitSuccess.value = false
53
+ }, 4000)
54
+ } finally {
55
+ submitting.value = false
56
+ }
57
+ }
58
+ </script>
59
+
60
+ <template>
61
+ <section class="qarpeo-cms-comments space-y-6">
62
+ <div class="flex items-center justify-between border-b pb-3">
63
+ <h3 class="text-lg font-bold">
64
+ {{ title }}
65
+ <span class="ml-1 text-sm font-normal text-neutral-500">({{ comments.length }})</span>
66
+ </h3>
67
+ </div>
68
+
69
+ <!-- New Comment Form -->
70
+ <form
71
+ class="space-y-3 rounded-xl border bg-neutral-50/50 p-4 dark:bg-neutral-900/50"
72
+ @submit.prevent="handleSubmit(null)"
73
+ >
74
+ <div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
75
+ <input
76
+ v-model="authorName"
77
+ type="text"
78
+ placeholder="Your name *"
79
+ required
80
+ class="w-full rounded-lg border bg-white px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-primary-500 dark:bg-neutral-800"
81
+ />
82
+ <input
83
+ v-model="authorEmail"
84
+ type="email"
85
+ placeholder="Your email (optional)"
86
+ class="w-full rounded-lg border bg-white px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-primary-500 dark:bg-neutral-800"
87
+ />
88
+ </div>
89
+
90
+ <textarea
91
+ v-model="newContent"
92
+ rows="3"
93
+ :placeholder="placeholder"
94
+ required
95
+ class="w-full rounded-lg border bg-white p-3 text-sm outline-none focus:ring-2 focus:ring-primary-500 dark:bg-neutral-800"
96
+ />
97
+
98
+ <div class="flex items-center justify-between">
99
+ <span v-if="submitSuccess" class="text-xs font-medium text-emerald-600">
100
+ Comment submitted successfully!
101
+ </span>
102
+ <span v-else-if="error" class="text-xs text-red-500"> Failed to load comments </span>
103
+ <span v-else />
104
+
105
+ <button
106
+ type="submit"
107
+ :disabled="submitting || !newContent.trim() || !authorName.trim()"
108
+ class="rounded-lg bg-neutral-900 px-4 py-2 text-xs font-semibold text-white transition hover:bg-neutral-800 disabled:opacity-50 dark:bg-white dark:text-neutral-900"
109
+ >
110
+ {{ submitting ? "Posting..." : "Post Comment" }}
111
+ </button>
112
+ </div>
113
+ </form>
114
+
115
+ <!-- Comments List -->
116
+ <div v-if="loading && comments.length === 0" class="py-6 text-center text-sm text-neutral-500">
117
+ Loading comments...
118
+ </div>
119
+
120
+ <div v-else-if="rootComments.length === 0" class="py-6 text-center text-sm text-neutral-500">
121
+ No comments yet. Be the first to share your thoughts!
122
+ </div>
123
+
124
+ <div v-else class="space-y-4">
125
+ <div
126
+ v-for="comment in rootComments"
127
+ :key="comment.id"
128
+ class="space-y-3 rounded-lg border p-4"
129
+ >
130
+ <div class="flex items-center justify-between">
131
+ <div class="flex items-center gap-2">
132
+ <div
133
+ class="flex h-8 w-8 items-center justify-center rounded-full bg-neutral-200 text-xs font-bold text-neutral-700 dark:bg-neutral-700 dark:text-neutral-200"
134
+ >
135
+ {{ (comment.authorName || "A")[0].toUpperCase() }}
136
+ </div>
137
+ <div>
138
+ <p class="text-sm font-semibold">{{ comment.authorName }}</p>
139
+ <p class="text-[11px] text-neutral-500">
140
+ {{ comment.createdAt ? new Date(comment.createdAt).toLocaleDateString() : "" }}
141
+ </p>
142
+ </div>
143
+ </div>
144
+ <button
145
+ v-if="allowReplies"
146
+ type="button"
147
+ class="text-xs font-medium text-neutral-500 hover:text-neutral-900 dark:hover:text-white"
148
+ @click="replyToId = replyToId === comment.id ? null : comment.id"
149
+ >
150
+ {{ replyToId === comment.id ? "Cancel" : "Reply" }}
151
+ </button>
152
+ </div>
153
+
154
+ <p class="text-sm text-neutral-700 dark:text-neutral-300">
155
+ {{ comment.content }}
156
+ </p>
157
+
158
+ <!-- Nested Replies -->
159
+ <div v-if="getReplies(comment.id).length > 0" class="ml-6 space-y-3 border-l-2 pl-4">
160
+ <div v-for="reply in getReplies(comment.id)" :key="reply.id" class="space-y-1">
161
+ <div class="flex items-center gap-2">
162
+ <span class="text-xs font-semibold">{{ reply.authorName }}</span>
163
+ <span class="text-[10px] text-neutral-500">
164
+ {{ reply.createdAt ? new Date(reply.createdAt).toLocaleDateString() : "" }}
165
+ </span>
166
+ </div>
167
+ <p class="text-xs text-neutral-600 dark:text-neutral-400">
168
+ {{ reply.content }}
169
+ </p>
170
+ </div>
171
+ </div>
172
+
173
+ <!-- Inline Reply Box -->
174
+ <div v-if="replyToId === comment.id" class="ml-6 mt-3 space-y-2 border-l-2 pl-4">
175
+ <textarea
176
+ v-model="newContent"
177
+ rows="2"
178
+ placeholder="Write your reply..."
179
+ class="w-full rounded-lg border p-2 text-xs outline-none focus:ring-1 focus:ring-primary-500 dark:bg-neutral-800"
180
+ />
181
+ <div class="flex justify-end gap-2">
182
+ <button
183
+ type="button"
184
+ class="rounded px-3 py-1 text-xs text-neutral-500 hover:bg-neutral-100 dark:hover:bg-neutral-800"
185
+ @click="replyToId = null"
186
+ >
187
+ Cancel
188
+ </button>
189
+ <button
190
+ type="button"
191
+ :disabled="submitting || !newContent.trim()"
192
+ class="rounded bg-neutral-900 px-3 py-1 text-xs font-medium text-white hover:bg-neutral-800 dark:bg-white dark:text-neutral-900"
193
+ @click="handleSubmit(comment.id)"
194
+ >
195
+ Reply
196
+ </button>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ </div>
201
+ </section>
202
+ </template>
@@ -0,0 +1,81 @@
1
+ <script setup lang="ts">
2
+ import { ref } from "vue"
3
+
4
+ import { useCMSNewsletter } from "../composables/cms"
5
+
6
+ withDefaults(
7
+ defineProps<{
8
+ title?: string
9
+ description?: string
10
+ source?: string
11
+ variant?: "card" | "inline"
12
+ }>(),
13
+ {
14
+ title: "Subscribe to our Newsletter",
15
+ description: "Get the latest articles, updates, and resources directly to your inbox.",
16
+ source: "website",
17
+ variant: "card",
18
+ },
19
+ )
20
+
21
+ const email = ref("")
22
+ const { loading, message, success, error, subscribe, reset } = useCMSNewsletter()
23
+
24
+ async function handleSubscribe(sourceName: string) {
25
+ if (!email.value) return
26
+ const ok = await subscribe(email.value, sourceName)
27
+ if (ok) {
28
+ email.value = ""
29
+ }
30
+ }
31
+ </script>
32
+
33
+ <template>
34
+ <div
35
+ class="qarpeo-newsletter"
36
+ :class="
37
+ variant === 'card'
38
+ ? 'rounded-2xl border bg-neutral-50/50 p-6 sm:p-8 text-center dark:bg-neutral-900/50'
39
+ : 'space-y-3'
40
+ "
41
+ >
42
+ <div v-if="variant === 'card'" class="mx-auto max-w-md space-y-2">
43
+ <h3 class="text-xl font-bold tracking-tight text-neutral-900 dark:text-white">
44
+ {{ title }}
45
+ </h3>
46
+ <p class="text-xs text-neutral-600 dark:text-neutral-400">
47
+ {{ description }}
48
+ </p>
49
+ </div>
50
+
51
+ <form
52
+ class="mt-4 flex flex-col gap-2 sm:flex-row sm:items-center"
53
+ :class="variant === 'card' ? 'mx-auto max-w-md' : ''"
54
+ @submit.prevent="handleSubscribe(source)"
55
+ >
56
+ <input
57
+ v-model="email"
58
+ type="email"
59
+ required
60
+ placeholder="Enter your email"
61
+ :disabled="loading"
62
+ class="flex-1 rounded-lg border bg-white px-3.5 py-2 text-sm outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 dark:bg-neutral-800"
63
+ @input="reset"
64
+ />
65
+ <button
66
+ type="submit"
67
+ :disabled="loading || !email"
68
+ class="rounded-lg bg-neutral-900 px-5 py-2 text-sm font-semibold text-white transition hover:bg-neutral-800 disabled:opacity-50 dark:bg-white dark:text-neutral-900"
69
+ >
70
+ {{ loading ? "Joining..." : "Subscribe" }}
71
+ </button>
72
+ </form>
73
+
74
+ <p v-if="success" class="mt-2 text-xs font-medium text-emerald-600 dark:text-emerald-400">
75
+ {{ message }}
76
+ </p>
77
+ <p v-else-if="error" class="mt-2 text-xs font-medium text-red-500">
78
+ {{ error }}
79
+ </p>
80
+ </div>
81
+ </template>