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.
- package/README.md +96 -96
- package/dist/chunks/auth-schema.mjs +3 -1
- package/dist/chunks/wrangler.mjs +22 -3
- package/dist/cli/index.mjs +448 -221
- package/dist/fate/index.d.ts +29 -22
- package/dist/fate/index.mjs +1 -3
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +103 -82
- package/dist/runtime/ai.d.ts +2 -2
- package/dist/runtime/app/components/BlobImage.vue +119 -107
- package/dist/runtime/app/components/CMSBlocks.vue +104 -93
- package/dist/runtime/app/components/CMSContent.vue +24 -23
- package/dist/runtime/app/components/CMSImage.vue +49 -49
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -110
- package/dist/runtime/app/components/CMSPreviewBanner.vue +83 -79
- package/dist/runtime/app/components/CMSVersionBanner.vue +53 -49
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +140 -140
- package/dist/runtime/app/components/ContentRenderer.vue +83 -80
- package/dist/runtime/app/components/FileUpload.vue +200 -196
- package/dist/runtime/app/components/ImpersonationBanner.vue +61 -57
- package/dist/runtime/app/components/QarpeoWelcome.vue +84 -84
- package/dist/runtime/app/components/SignedIn.vue +13 -13
- package/dist/runtime/app/components/SignedOut.vue +13 -13
- package/dist/runtime/app/components/shiki.css +34 -34
- package/dist/runtime/app/composables/ai.d.ts +22 -22
- package/dist/runtime/app/composables/ai.mjs +3 -7
- package/dist/runtime/app/composables/analytics.mjs +1 -1
- package/dist/runtime/app/composables/api-tokens.mjs +1 -1
- package/dist/runtime/app/composables/auth.d.ts +6 -7
- package/dist/runtime/app/composables/auth.mjs +6 -3
- package/dist/runtime/app/composables/chat.mjs +3 -7
- package/dist/runtime/app/composables/cms-preview.d.ts +3 -3
- package/dist/runtime/app/composables/cms-preview.mjs +1 -1
- package/dist/runtime/app/composables/cms.d.ts +3 -5
- package/dist/runtime/app/composables/cms.mjs +2 -2
- package/dist/runtime/app/composables/docs-version.d.ts +8 -7
- package/dist/runtime/app/composables/docs-version.mjs +3 -3
- package/dist/runtime/app/composables/impersonation.mjs +1 -1
- package/dist/runtime/app/composables/notifications.d.ts +5 -5
- package/dist/runtime/app/composables/notifications.mjs +4 -5
- package/dist/runtime/app/composables/organization.mjs +1 -1
- package/dist/runtime/app/composables/passkey.mjs +1 -1
- package/dist/runtime/app/composables/passwordless.mjs +1 -1
- package/dist/runtime/app/composables/payments.d.ts +2 -1
- package/dist/runtime/app/composables/payments.mjs +1 -1
- package/dist/runtime/app/composables/realtime.d.ts +13 -13
- package/dist/runtime/app/composables/realtime.mjs +2 -2
- package/dist/runtime/app/composables/resumable-upload.d.ts +11 -11
- package/dist/runtime/app/composables/resumable-upload.mjs +1 -1
- package/dist/runtime/app/composables/site.mjs +1 -1
- package/dist/runtime/app/composables/storage.d.ts +151 -11
- package/dist/runtime/app/composables/storage.mjs +291 -33
- package/dist/runtime/app/composables/turnstile.mjs +1 -1
- package/dist/runtime/app/composables/two-factor.mjs +1 -1
- package/dist/runtime/app/pages/devtools/agents.vue +716 -716
- package/dist/runtime/app/pages/devtools/analytics.vue +616 -616
- package/dist/runtime/app/pages/devtools/auth.vue +381 -350
- package/dist/runtime/app/pages/devtools/blob.vue +743 -744
- package/dist/runtime/app/pages/devtools/db.vue +545 -545
- package/dist/runtime/app/pages/devtools/domains.vue +771 -771
- package/dist/runtime/app/pages/devtools/kv.vue +827 -828
- package/dist/runtime/app/pages/devtools/logs.vue +649 -653
- package/dist/runtime/app/pages/devtools/mail.vue +388 -388
- package/dist/runtime/app/pages/devtools/overview.vue +391 -389
- package/dist/runtime/app/pages/devtools/realtime.vue +89 -27
- package/dist/runtime/app/pages/devtools/security.vue +20 -5
- package/dist/runtime/app/pages/devtools/settings.vue +559 -559
- package/dist/runtime/app/pages/devtools/tasks.vue +26 -10
- package/dist/runtime/app/pages/devtools.vue +176 -176
- package/dist/runtime/app/plugins/seo.mjs +1 -1
- package/dist/runtime/app/plugins/shortcuts.client.d.ts +1 -4
- package/dist/runtime/app/public/sw-notifications.mjs +47 -52
- package/dist/runtime/blob.mjs +11 -4
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.mjs +12 -2
- package/dist/runtime/cache.d.ts +2 -1
- package/dist/runtime/kv.mjs +4 -1
- package/dist/runtime/providers/qarpeo.d.ts +3 -3
- package/dist/runtime/server/durable-objects/agent.mjs +1 -1
- package/dist/runtime/server/durable-objects/room.d.ts +2 -2
- package/dist/runtime/server/durable-objects/room.mjs +5 -5
- package/dist/runtime/server/middleware/devtools.mjs +6 -2
- package/dist/runtime/server/plugins/cms.d.ts +4 -2
- package/dist/runtime/server/plugins/dev-proxy.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +4 -1
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +4 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +2 -2
- package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/room.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/rooms.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/analytics.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/ban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/unban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/tasks/run.post.mjs +3 -1
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +8 -2
- package/dist/runtime/server/routes/ai/embed.post.d.ts +1 -4
- package/dist/runtime/server/routes/ai/search.post.d.ts +2 -2
- package/dist/runtime/server/routes/auth/account.delete.mjs +1 -1
- package/dist/runtime/server/routes/auth/handler.mjs +6 -1
- package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +7 -1
- package/dist/runtime/server/routes/auth/otp/verify.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +7 -1
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +8 -2
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +6 -1
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/crawl.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/invoice.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/og-image.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/pdf.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/pdf.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/screenshot.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/screenshot.post.mjs +5 -1
- package/dist/runtime/server/routes/cms/components/index.get.d.ts +2 -2
- package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +4 -3
- package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +8 -8
- package/dist/runtime/server/routes/cms/search.get.mjs +1 -1
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +7 -7
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +9 -2
- package/dist/runtime/server/routes/docs/search.get.d.ts +9 -9
- package/dist/runtime/server/routes/fate.mjs +5 -8
- package/dist/runtime/server/routes/mail/bounce.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/unsubscribe.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +7 -1
- package/dist/runtime/server/routes/payments/usage.get.d.ts +8 -8
- package/dist/runtime/server/routes/payments/usage.post.d.ts +2 -2
- package/dist/runtime/server/routes/realtime/history.delete.d.ts +4 -3
- package/dist/runtime/server/routes/realtime/history.get.d.ts +7 -6
- package/dist/runtime/server/routes/realtime/ws.get.mjs +6 -1
- package/dist/runtime/server/routes/robots.txt.get.mjs +1 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
- package/dist/runtime/server/routes/storage/multipart/abort.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.mjs +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.mjs +7 -3
- package/dist/runtime/server/routes/storage/multipart/part.put.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/part.put.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +2 -4
- package/dist/runtime/server/tasks/cms/publish.mjs +1 -1
- package/dist/runtime/server/utils/ai.d.ts +9 -9
- package/dist/runtime/server/utils/ai.mjs +3 -3
- package/dist/runtime/server/utils/auth.d.ts +12 -16
- package/dist/runtime/server/utils/auth.mjs +15 -9
- package/dist/runtime/server/utils/bots.mjs +21 -7
- package/dist/runtime/server/utils/browser-utils.d.ts +44 -41
- package/dist/runtime/server/utils/browser-utils.mjs +14 -4
- package/dist/runtime/server/utils/cache.d.ts +5 -5
- package/dist/runtime/server/utils/cms/common.d.ts +26 -0
- package/dist/runtime/server/utils/cms/common.mjs +68 -0
- package/dist/runtime/server/utils/cms/git.d.ts +24 -0
- package/dist/runtime/server/utils/cms/git.mjs +240 -0
- package/dist/runtime/server/utils/cms/markdown.d.ts +22 -0
- package/dist/runtime/server/utils/cms/markdown.mjs +92 -0
- package/dist/runtime/server/utils/cms/path.d.ts +51 -0
- package/dist/runtime/server/utils/cms/path.mjs +127 -0
- package/dist/runtime/server/utils/cms/search.d.ts +22 -0
- package/dist/runtime/server/utils/cms/search.mjs +221 -0
- package/dist/runtime/server/utils/cms-events.d.ts +1 -1
- package/dist/runtime/server/utils/cms-events.mjs +2 -2
- package/dist/runtime/server/utils/cms-filter.mjs +2 -2
- package/dist/runtime/server/utils/cms.d.ts +17 -149
- package/dist/runtime/server/utils/cms.mjs +52 -761
- package/dist/runtime/server/utils/config.d.ts +5 -4
- package/dist/runtime/server/utils/domains.mjs +7 -4
- package/dist/runtime/server/utils/email-templates.d.ts +10 -7
- package/dist/runtime/server/utils/email-templates.mjs +20 -5
- package/dist/runtime/server/utils/feed.d.ts +2 -2
- package/dist/runtime/server/utils/feed.mjs +3 -1
- package/dist/runtime/server/utils/mail-suppression.d.ts +8 -24
- package/dist/runtime/server/utils/mail-suppression.mjs +2 -2
- package/dist/runtime/server/utils/mail.d.ts +7 -8
- package/dist/runtime/server/utils/mail.mjs +17 -12
- package/dist/runtime/server/utils/multipart-store.d.ts +2 -2
- package/dist/runtime/server/utils/notifications.d.ts +9 -23
- package/dist/runtime/server/utils/organization.mjs +4 -12
- package/dist/runtime/server/utils/passwordless.mjs +1 -1
- package/dist/runtime/server/utils/payments.d.ts +2 -6
- package/dist/runtime/server/utils/payments.mjs +1 -1
- package/dist/runtime/server/utils/queue.d.ts +21 -31
- package/dist/runtime/server/utils/rag.d.ts +4 -4
- package/dist/runtime/server/utils/rag.mjs +8 -8
- package/dist/runtime/server/utils/realtime-store.d.ts +2 -2
- package/dist/runtime/server/utils/realtime.d.ts +26 -28
- package/dist/runtime/server/utils/scheduled-task.d.ts +1 -3
- package/dist/runtime/server/utils/security-store.d.ts +2 -2
- package/dist/runtime/server/utils/session.d.ts +9 -11
- package/dist/runtime/server/utils/sso.d.ts +9 -15
- package/dist/runtime/server/utils/sso.mjs +4 -8
- package/dist/runtime/server/utils/storage.d.ts +19 -2
- package/dist/runtime/server/utils/storage.mjs +36 -7
- package/dist/runtime/server/utils/tenant.mjs +3 -1
- package/dist/runtime/server/utils/turnstile.d.ts +3 -5
- package/dist/runtime/server/utils/vapid.d.ts +5 -8
- package/dist/runtime/server/utils/vapid.mjs +26 -13
- package/dist/runtime/service.d.ts +13 -13
- package/dist/runtime/service.mjs +4 -2
- package/dist/runtime/test-utils.d.ts +20 -30
- package/dist/runtime/test-utils.mjs +5 -4
- package/dist/runtime/types/auth-globals.d.ts +14 -14
- package/dist/runtime/types/imports.d.ts +82 -82
- package/dist/runtime/types/index.d.ts +2 -2
- package/dist/runtime/types/r2.d.ts +5 -0
- package/dist/runtime/types/service.d.ts +11 -18
- package/dist/types.d.ts +100 -107
- package/dist/utils/auth-schema.d.ts +2 -2
- package/dist/utils/cms-sources.d.ts +3 -3
- package/dist/utils/local-db.d.ts +3 -3
- package/dist/utils/notifications-schema.d.ts +1 -3
- package/dist/utils/pkg.d.ts +7 -0
- package/dist/utils/queue.d.ts +3 -3
- package/dist/utils/tasks.d.ts +3 -2
- package/package.json +11 -8
|
@@ -1,828 +1,827 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useRoute, useFetch, navigateTo } from "nuxt/app"
|
|
3
|
-
import { computed, onMounted, ref, watch } from "vue"
|
|
4
|
-
|
|
5
|
-
const route = useRoute()
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
data: kvData,
|
|
9
|
-
status: kvStatus,
|
|
10
|
-
pending: kvPending,
|
|
11
|
-
execute: executeLoadKV,
|
|
12
|
-
} = useFetch<any>("/_qarpeo/api/kv/keys", {
|
|
13
|
-
query: { limit: 100 },
|
|
14
|
-
immediate: false,
|
|
15
|
-
lazy: true,
|
|
16
|
-
default: () => ({ keys: [] }),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const kvLoading = computed(
|
|
20
|
-
() => kvPending.value || kvStatus.value === "idle" || kvStatus.value === "pending",
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
const kvKeys = computed(() => kvData.value?.keys || [])
|
|
24
|
-
const kvSearch = ref("")
|
|
25
|
-
const filterCategory = ref<"all" | "session" | "cache" | "ratelimit" | "other">("all")
|
|
26
|
-
|
|
27
|
-
const kvSelected = ref<any>(null)
|
|
28
|
-
const kvValueLoading = ref(false)
|
|
29
|
-
const kvEditing = ref(false)
|
|
30
|
-
const kvEditValue = ref("")
|
|
31
|
-
const kvEditTtl = ref("")
|
|
32
|
-
const kvDeleting = ref(false)
|
|
33
|
-
const showDeleteKeyModal = ref(false)
|
|
34
|
-
|
|
35
|
-
const viewMode = ref<"raw" | "pretty">("pretty")
|
|
36
|
-
const copiedKey = ref(false)
|
|
37
|
-
const copiedValue = ref(false)
|
|
38
|
-
|
|
39
|
-
const kvNewKey = ref("")
|
|
40
|
-
const kvNewValue = ref("")
|
|
41
|
-
const kvNewTtl = ref("")
|
|
42
|
-
const kvAdding = ref(false)
|
|
43
|
-
const showAddKeyModal = ref(false)
|
|
44
|
-
|
|
45
|
-
const isJsonValue = computed(() => {
|
|
46
|
-
const val = kvSelected.value?.value
|
|
47
|
-
if (!val || typeof val !== "string") return false
|
|
48
|
-
const trimmed = val.trim()
|
|
49
|
-
if (
|
|
50
|
-
!(
|
|
51
|
-
(trimmed.startsWith("{") && trimmed.endsWith("}")) ||
|
|
52
|
-
(trimmed.startsWith("[") && trimmed.endsWith("]"))
|
|
53
|
-
)
|
|
54
|
-
) {
|
|
55
|
-
return false
|
|
56
|
-
}
|
|
57
|
-
try {
|
|
58
|
-
JSON.parse(trimmed)
|
|
59
|
-
return true
|
|
60
|
-
} catch {
|
|
61
|
-
return false
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
const displayValue = computed(() => {
|
|
66
|
-
const val = kvSelected.value?.value
|
|
67
|
-
if (!val) return "(empty)"
|
|
68
|
-
if (viewMode.value === "pretty" && isJsonValue.value) {
|
|
69
|
-
try {
|
|
70
|
-
return JSON.stringify(JSON.parse(val), null, 2)
|
|
71
|
-
} catch {
|
|
72
|
-
return val
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return val
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
function formatJsonInEdit() {
|
|
79
|
-
try {
|
|
80
|
-
const parsed = JSON.parse(kvEditValue.value)
|
|
81
|
-
kvEditValue.value = JSON.stringify(parsed, null, 2)
|
|
82
|
-
} catch {
|
|
83
|
-
// ignore
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// selectedKey is derived from / synced to the ?key= query param
|
|
88
|
-
const selectedKey = computed({
|
|
89
|
-
get: () => (route.query.key as string) || null,
|
|
90
|
-
set: (key: string | null) => {
|
|
91
|
-
navigateTo({ query: { ...route.query, key: key ?? undefined } })
|
|
92
|
-
},
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
const selectedKeyData = computed(
|
|
96
|
-
() => kvKeys.value.find((k) => k.name === selectedKey.value) || null,
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
const isSlideoverOpen = computed({
|
|
100
|
-
get: () => Boolean(selectedKey.value),
|
|
101
|
-
set: (val: boolean) => {
|
|
102
|
-
if (!val) {
|
|
103
|
-
selectedKey.value = null
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
function fmtExpiry(exp?: number) {
|
|
109
|
-
if (!exp) return "Persistent"
|
|
110
|
-
const diff = exp - Math.floor(Date.now() / 1000)
|
|
111
|
-
if (diff < 0) return "Expired"
|
|
112
|
-
if (diff < 60) return `${diff}s left`
|
|
113
|
-
if (diff < 3600) return `${Math.floor(diff / 60)}m left`
|
|
114
|
-
if (diff < 86400) return `${Math.floor(diff / 3600)}h left`
|
|
115
|
-
return new Date(exp * 1000).toLocaleDateString()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function fmtFullExpiry(exp?: number) {
|
|
119
|
-
if (!exp) return "Never (Persistent key)"
|
|
120
|
-
return new Date(exp * 1000).toLocaleString()
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function getKeyIcon(name: string): string {
|
|
124
|
-
if (name.startsWith("session:") || name.startsWith("auth:")) return "i-lucide-user-check"
|
|
125
|
-
if (name.startsWith("cache:") || name.startsWith("swr:")) return "i-lucide-database"
|
|
126
|
-
if (name.startsWith("ratelimit:") || name.startsWith("rl:")) return "i-lucide-shield-alert"
|
|
127
|
-
if (name.startsWith("domain:") || name.startsWith("tenant:")) return "i-lucide-globe"
|
|
128
|
-
return "i-lucide-key"
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function getKeyPrefix(name: string): string {
|
|
132
|
-
if (name.includes(":")) {
|
|
133
|
-
return name.split(":")[0]
|
|
134
|
-
}
|
|
135
|
-
return "default"
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const counts = computed(() => {
|
|
139
|
-
let session = 0
|
|
140
|
-
let cache = 0
|
|
141
|
-
let ratelimit = 0
|
|
142
|
-
let other = 0
|
|
143
|
-
|
|
144
|
-
for (const k of kvKeys.value) {
|
|
145
|
-
if (k.name.startsWith("session:") || k.name.startsWith("auth:")) {
|
|
146
|
-
session++
|
|
147
|
-
} else if (k.name.startsWith("cache:") || k.name.startsWith("swr:")) {
|
|
148
|
-
cache++
|
|
149
|
-
} else if (k.name.startsWith("ratelimit:") || k.name.startsWith("rl:")) {
|
|
150
|
-
ratelimit++
|
|
151
|
-
} else {
|
|
152
|
-
other++
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return { all: kvKeys.value.length, session, cache, ratelimit, other }
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
const filteredKeys = computed(() => {
|
|
160
|
-
let list = kvKeys.value
|
|
161
|
-
|
|
162
|
-
if (filterCategory.value === "session") {
|
|
163
|
-
list = list.filter((k) => k.name.startsWith("session:") || k.name.startsWith("auth:"))
|
|
164
|
-
} else if (filterCategory.value === "cache") {
|
|
165
|
-
list = list.filter((k) => k.name.startsWith("cache:") || k.name.startsWith("swr:"))
|
|
166
|
-
} else if (filterCategory.value === "ratelimit") {
|
|
167
|
-
list = list.filter((k) => k.name.startsWith("ratelimit:") || k.name.startsWith("rl:"))
|
|
168
|
-
} else if (filterCategory.value === "other") {
|
|
169
|
-
list = list.filter(
|
|
170
|
-
(k) =>
|
|
171
|
-
!k.name.startsWith("session:") &&
|
|
172
|
-
!k.name.startsWith("auth:") &&
|
|
173
|
-
!k.name.startsWith("cache:") &&
|
|
174
|
-
!k.name.startsWith("swr:") &&
|
|
175
|
-
!k.name.startsWith("ratelimit:") &&
|
|
176
|
-
!k.name.startsWith("rl:"),
|
|
177
|
-
)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (kvSearch.value.trim()) {
|
|
181
|
-
const q = kvSearch.value.toLowerCase()
|
|
182
|
-
list = list.filter((k) => k.name.toLowerCase().includes(q))
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return list
|
|
186
|
-
})
|
|
187
|
-
|
|
188
|
-
// Re-fetch key value whenever URL ?key= param changes
|
|
189
|
-
watch(
|
|
190
|
-
selectedKey,
|
|
191
|
-
async (key) => {
|
|
192
|
-
if (key) {
|
|
193
|
-
await fetchKeyValue(key)
|
|
194
|
-
} else {
|
|
195
|
-
kvSelected.value = null
|
|
196
|
-
kvEditing.value = false
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
{ immediate: true },
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
async function loadKVKeys() {
|
|
203
|
-
await executeLoadKV()
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async function fetchKeyValue(key: string) {
|
|
207
|
-
kvValueLoading.value = true
|
|
208
|
-
try {
|
|
209
|
-
const data = await $fetch<any>("/_qarpeo/api/kv/get", { query: { key } }).catch(() => null)
|
|
210
|
-
kvSelected.value = data ? { ...data, key } : { key, value: "(error loading value)" }
|
|
211
|
-
kvEditing.value = false
|
|
212
|
-
} finally {
|
|
213
|
-
kvValueLoading.value = false
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function selectKey(item: any) {
|
|
218
|
-
selectedKey.value = item.name
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function toggleKvEdit() {
|
|
222
|
-
kvEditing.value = !kvEditing.value
|
|
223
|
-
kvEditValue.value = kvSelected.value?.value || ""
|
|
224
|
-
const exp = selectedKeyData.value?.expiration || kvSelected.value?.expiration
|
|
225
|
-
if (exp) {
|
|
226
|
-
const diff = exp - Math.floor(Date.now() / 1000)
|
|
227
|
-
kvEditTtl.value = diff > 0 ? String(diff) : ""
|
|
228
|
-
} else {
|
|
229
|
-
kvEditTtl.value = ""
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
async function saveKVEdit() {
|
|
234
|
-
if (!kvSelected.value) return
|
|
235
|
-
await $fetch("/_qarpeo/api/kv/set", {
|
|
236
|
-
method: "POST",
|
|
237
|
-
body: {
|
|
238
|
-
key: kvSelected.value.key,
|
|
239
|
-
value: kvEditValue.value,
|
|
240
|
-
ttl: kvEditTtl.value ? parseInt(kvEditTtl.value, 10) : undefined,
|
|
241
|
-
},
|
|
242
|
-
})
|
|
243
|
-
kvSelected.value.value = kvEditValue.value
|
|
244
|
-
if (kvEditTtl.value) {
|
|
245
|
-
kvSelected.value.expiration = Math.floor(Date.now() / 1000) + parseInt(kvEditTtl.value, 10)
|
|
246
|
-
}
|
|
247
|
-
kvEditing.value = false
|
|
248
|
-
await loadKVKeys()
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async function deleteKVKey(key: string) {
|
|
252
|
-
kvDeleting.value = true
|
|
253
|
-
try {
|
|
254
|
-
await $fetch("/_qarpeo/api/kv/delete", {
|
|
255
|
-
method: "POST",
|
|
256
|
-
body: { key },
|
|
257
|
-
})
|
|
258
|
-
showDeleteKeyModal.value = false
|
|
259
|
-
selectedKey.value = null
|
|
260
|
-
await loadKVKeys()
|
|
261
|
-
} finally {
|
|
262
|
-
kvDeleting.value = false
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
async function addKVKey() {
|
|
267
|
-
if (!kvNewKey.value || !kvNewValue.value) return
|
|
268
|
-
kvAdding.value = true
|
|
269
|
-
const addedKey = kvNewKey.value
|
|
270
|
-
try {
|
|
271
|
-
await $fetch("/_qarpeo/api/kv/set", {
|
|
272
|
-
method: "POST",
|
|
273
|
-
body: {
|
|
274
|
-
key: kvNewKey.value,
|
|
275
|
-
value: kvNewValue.value,
|
|
276
|
-
ttl: kvNewTtl.value ? parseInt(kvNewTtl.value, 10) : undefined,
|
|
277
|
-
},
|
|
278
|
-
})
|
|
279
|
-
kvNewKey.value = ""
|
|
280
|
-
kvNewValue.value = ""
|
|
281
|
-
kvNewTtl.value = ""
|
|
282
|
-
showAddKeyModal.value = false
|
|
283
|
-
await loadKVKeys()
|
|
284
|
-
selectedKey.value = addedKey
|
|
285
|
-
} finally {
|
|
286
|
-
kvAdding.value = false
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function copyKeyName(key?: string) {
|
|
291
|
-
if (!key) return
|
|
292
|
-
if (typeof navigator !== "undefined") {
|
|
293
|
-
navigator.clipboard?.writeText(key)
|
|
294
|
-
copiedKey.value = true
|
|
295
|
-
setTimeout(() => {
|
|
296
|
-
copiedKey.value = false
|
|
297
|
-
}, 1500)
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function copyValue() {
|
|
302
|
-
if (kvSelected.value?.value && typeof navigator !== "undefined") {
|
|
303
|
-
navigator.clipboard?.writeText(displayValue.value)
|
|
304
|
-
copiedValue.value = true
|
|
305
|
-
setTimeout(() => {
|
|
306
|
-
copiedValue.value = false
|
|
307
|
-
}, 1500)
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
onMounted(() => {
|
|
312
|
-
loadKVKeys()
|
|
313
|
-
})
|
|
314
|
-
</script>
|
|
315
|
-
|
|
316
|
-
<template>
|
|
317
|
-
<!-- ── Single Full-Width Panel with Media/Card Grid ─────────────────── -->
|
|
318
|
-
<UDashboardPanel id="devtools-kv">
|
|
319
|
-
<template #header>
|
|
320
|
-
<UDashboardNavbar>
|
|
321
|
-
<template #title>
|
|
322
|
-
<div class="flex items-center gap-2">
|
|
323
|
-
<UIcon name="i-lucide-zap" class="w-4 h-4 text-primary" />
|
|
324
|
-
<span class="font-bold text-sm text-highlighted">KV Store</span>
|
|
325
|
-
<UBadge size="xs" color="neutral" variant="subtle">Cloudflare KV</UBadge>
|
|
326
|
-
<UBadge size="xs" color="neutral" variant="subtle">
|
|
327
|
-
{{ filteredKeys.length }}
|
|
328
|
-
</UBadge>
|
|
329
|
-
</div>
|
|
330
|
-
</template>
|
|
331
|
-
|
|
332
|
-
<template #right>
|
|
333
|
-
<div class="flex items-center gap-1.5">
|
|
334
|
-
<UButton
|
|
335
|
-
icon="i-lucide-plus"
|
|
336
|
-
label="Add Key"
|
|
337
|
-
size="xs"
|
|
338
|
-
color="primary"
|
|
339
|
-
@click="showAddKeyModal = true"
|
|
340
|
-
/>
|
|
341
|
-
<UButton
|
|
342
|
-
icon="i-lucide-refresh-cw"
|
|
343
|
-
size="xs"
|
|
344
|
-
color="neutral"
|
|
345
|
-
variant="ghost"
|
|
346
|
-
title="Refresh keys"
|
|
347
|
-
:loading="kvLoading"
|
|
348
|
-
@click="loadKVKeys"
|
|
349
|
-
/>
|
|
350
|
-
</div>
|
|
351
|
-
</template>
|
|
352
|
-
</UDashboardNavbar>
|
|
353
|
-
|
|
354
|
-
<!-- Category Filter & Search Toolbar -->
|
|
355
|
-
<UDashboardToolbar>
|
|
356
|
-
<div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
|
|
357
|
-
<UButton
|
|
358
|
-
label="All"
|
|
359
|
-
size="xs"
|
|
360
|
-
:color="filterCategory === 'all' ? 'primary' : 'neutral'"
|
|
361
|
-
:variant="filterCategory === 'all' ? 'subtle' : 'ghost'"
|
|
362
|
-
@click="filterCategory = 'all'"
|
|
363
|
-
>
|
|
364
|
-
<template #trailing>
|
|
365
|
-
<UBadge
|
|
366
|
-
size="xs"
|
|
367
|
-
:color="filterCategory === 'all' ? 'primary' : 'neutral'"
|
|
368
|
-
variant="subtle"
|
|
369
|
-
>
|
|
370
|
-
{{ counts.all }}
|
|
371
|
-
</UBadge>
|
|
372
|
-
</template>
|
|
373
|
-
</UButton>
|
|
374
|
-
|
|
375
|
-
<UButton
|
|
376
|
-
label="Sessions"
|
|
377
|
-
icon="i-lucide-user-check"
|
|
378
|
-
size="xs"
|
|
379
|
-
:color="filterCategory === 'session' ? 'primary' : 'neutral'"
|
|
380
|
-
:variant="filterCategory === 'session' ? 'subtle' : 'ghost'"
|
|
381
|
-
@click="filterCategory = 'session'"
|
|
382
|
-
>
|
|
383
|
-
<template #trailing>
|
|
384
|
-
<UBadge
|
|
385
|
-
size="xs"
|
|
386
|
-
:color="filterCategory === 'session' ? 'primary' : 'neutral'"
|
|
387
|
-
variant="subtle"
|
|
388
|
-
>
|
|
389
|
-
{{ counts.session }}
|
|
390
|
-
</UBadge>
|
|
391
|
-
</template>
|
|
392
|
-
</UButton>
|
|
393
|
-
|
|
394
|
-
<UButton
|
|
395
|
-
label="Cache"
|
|
396
|
-
icon="i-lucide-database"
|
|
397
|
-
size="xs"
|
|
398
|
-
:color="filterCategory === 'cache' ? 'primary' : 'neutral'"
|
|
399
|
-
:variant="filterCategory === 'cache' ? 'subtle' : 'ghost'"
|
|
400
|
-
@click="filterCategory = 'cache'"
|
|
401
|
-
>
|
|
402
|
-
<template #trailing>
|
|
403
|
-
<UBadge
|
|
404
|
-
size="xs"
|
|
405
|
-
:color="filterCategory === 'cache' ? 'primary' : 'neutral'"
|
|
406
|
-
variant="subtle"
|
|
407
|
-
>
|
|
408
|
-
{{ counts.cache }}
|
|
409
|
-
</UBadge>
|
|
410
|
-
</template>
|
|
411
|
-
</UButton>
|
|
412
|
-
|
|
413
|
-
<UButton
|
|
414
|
-
label="Rate Limit"
|
|
415
|
-
icon="i-lucide-shield-alert"
|
|
416
|
-
size="xs"
|
|
417
|
-
:color="filterCategory === 'ratelimit' ? 'primary' : 'neutral'"
|
|
418
|
-
:variant="filterCategory === 'ratelimit' ? 'subtle' : 'ghost'"
|
|
419
|
-
@click="filterCategory = 'ratelimit'"
|
|
420
|
-
>
|
|
421
|
-
<template #trailing>
|
|
422
|
-
<UBadge
|
|
423
|
-
size="xs"
|
|
424
|
-
:color="filterCategory === 'ratelimit' ? 'primary' : 'neutral'"
|
|
425
|
-
variant="subtle"
|
|
426
|
-
>
|
|
427
|
-
{{ counts.ratelimit }}
|
|
428
|
-
</UBadge>
|
|
429
|
-
</template>
|
|
430
|
-
</UButton>
|
|
431
|
-
|
|
432
|
-
<UButton
|
|
433
|
-
label="Other"
|
|
434
|
-
size="xs"
|
|
435
|
-
:color="filterCategory === 'other' ? 'primary' : 'neutral'"
|
|
436
|
-
:variant="filterCategory === 'other' ? 'subtle' : 'ghost'"
|
|
437
|
-
@click="filterCategory = 'other'"
|
|
438
|
-
>
|
|
439
|
-
<template #trailing>
|
|
440
|
-
<UBadge
|
|
441
|
-
size="xs"
|
|
442
|
-
:color="filterCategory === 'other' ? 'primary' : 'neutral'"
|
|
443
|
-
variant="subtle"
|
|
444
|
-
>
|
|
445
|
-
{{ counts.other }}
|
|
446
|
-
</UBadge>
|
|
447
|
-
</template>
|
|
448
|
-
</UButton>
|
|
449
|
-
</div>
|
|
450
|
-
|
|
451
|
-
<!-- Search Input -->
|
|
452
|
-
<div class="flex items-center gap-2 max-w-xs flex-1">
|
|
453
|
-
<UInput
|
|
454
|
-
v-model="kvSearch"
|
|
455
|
-
icon="i-lucide-search"
|
|
456
|
-
placeholder="Search keys…"
|
|
457
|
-
class="w-full"
|
|
458
|
-
/>
|
|
459
|
-
</div>
|
|
460
|
-
</UDashboardToolbar>
|
|
461
|
-
</template>
|
|
462
|
-
|
|
463
|
-
<template #body>
|
|
464
|
-
<div class="space-y-4">
|
|
465
|
-
<!-- Loading Skeleton Grid -->
|
|
466
|
-
<div
|
|
467
|
-
v-if="kvLoading"
|
|
468
|
-
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3.5"
|
|
469
|
-
>
|
|
470
|
-
<div
|
|
471
|
-
v-for="i in 10"
|
|
472
|
-
:key="i"
|
|
473
|
-
class="bg-elevated/40 border border-default rounded-xl p-3.5 flex flex-col justify-between h-28 animate-pulse"
|
|
474
|
-
>
|
|
475
|
-
<div class="flex items-start justify-between gap-2">
|
|
476
|
-
<div class="flex items-center gap-2">
|
|
477
|
-
<div class="w-8 h-8 rounded-lg bg-muted"></div>
|
|
478
|
-
<div class="h-4 w-12 rounded bg-muted"></div>
|
|
479
|
-
</div>
|
|
480
|
-
<div class="h-4 w-14 rounded bg-muted"></div>
|
|
481
|
-
</div>
|
|
482
|
-
<div class="h-3 w-3/4 rounded bg-muted"></div>
|
|
483
|
-
<div class="h-2 w-1/2 rounded bg-muted"></div>
|
|
484
|
-
</div>
|
|
485
|
-
</div>
|
|
486
|
-
|
|
487
|
-
<!-- Interactive KV Cards Grid -->
|
|
488
|
-
<div
|
|
489
|
-
v-else-if="filteredKeys.length"
|
|
490
|
-
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3.5"
|
|
491
|
-
>
|
|
492
|
-
<UCard v-for="item in filteredKeys" :key="item.name" @click="selectKey(item)">
|
|
493
|
-
<!-- Card Header: Icon + Namespace Tag + TTL Badge -->
|
|
494
|
-
<div class="flex items-start justify-between gap-2 mb-2">
|
|
495
|
-
<div class="flex items-center gap-2 min-w-0">
|
|
496
|
-
<div
|
|
497
|
-
class="w-8 h-8 rounded-lg bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0 text-primary group-hover:scale-105 transition-transform"
|
|
498
|
-
>
|
|
499
|
-
<UIcon :name="getKeyIcon(item.name)" class="w-4 h-4" />
|
|
500
|
-
</div>
|
|
501
|
-
<div class="min-w-0">
|
|
502
|
-
<UBadge size="xs" color="neutral" variant="subtle" class="font-mono text-[10px]">
|
|
503
|
-
{{ getKeyPrefix(item.name) }}
|
|
504
|
-
</UBadge>
|
|
505
|
-
</div>
|
|
506
|
-
</div>
|
|
507
|
-
|
|
508
|
-
<UBadge
|
|
509
|
-
size="xs"
|
|
510
|
-
:color="item.expiration ? 'warning' : 'neutral'"
|
|
511
|
-
variant="subtle"
|
|
512
|
-
class="font-mono text-[10px] shrink-0"
|
|
513
|
-
>
|
|
514
|
-
{{ fmtExpiry(item.expiration) }}
|
|
515
|
-
</UBadge>
|
|
516
|
-
</div>
|
|
517
|
-
|
|
518
|
-
<!-- Card Body: Key Name -->
|
|
519
|
-
<div class="my-1.5 min-w-0">
|
|
520
|
-
<div
|
|
521
|
-
class="font-mono text-xs font-bold text-highlighted group-hover:text-primary transition-colors truncate"
|
|
522
|
-
:title="item.name"
|
|
523
|
-
>
|
|
524
|
-
{{ item.name }}
|
|
525
|
-
</div>
|
|
526
|
-
</div>
|
|
527
|
-
</UCard>
|
|
528
|
-
</div>
|
|
529
|
-
|
|
530
|
-
<!-- Empty State -->
|
|
531
|
-
<div v-else class="flex flex-col items-center justify-center py-20 text-center space-y-3">
|
|
532
|
-
<div
|
|
533
|
-
class="w-12 h-12 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center text-primary"
|
|
534
|
-
>
|
|
535
|
-
<UIcon name="i-lucide-zap" class="w-6 h-6" />
|
|
536
|
-
</div>
|
|
537
|
-
<div class="font-bold text-sm text-highlighted">No KV keys found</div>
|
|
538
|
-
<p class="text-xs text-muted max-w-sm">
|
|
539
|
-
Store ultra-low latency global key-value data directly on Cloudflare Edge with optional
|
|
540
|
-
TTL expiration.
|
|
541
|
-
</p>
|
|
542
|
-
<UButton
|
|
543
|
-
label="Add First Key"
|
|
544
|
-
icon="i-lucide-plus"
|
|
545
|
-
size="sm"
|
|
546
|
-
color="primary"
|
|
547
|
-
@click="showAddKeyModal = true"
|
|
548
|
-
/>
|
|
549
|
-
</div>
|
|
550
|
-
</div>
|
|
551
|
-
</template>
|
|
552
|
-
</UDashboardPanel>
|
|
553
|
-
|
|
554
|
-
<!-- ── Right Side Slideover for Key Value Inspector & Editor ──────────── -->
|
|
555
|
-
<USlideover v-model:open="isSlideoverOpen" side="right" :title="selectedKey || undefined">
|
|
556
|
-
<template #title>
|
|
557
|
-
<div class="flex items-center gap-2 min-w-0 pr-4">
|
|
558
|
-
<UIcon :name="getKeyIcon(selectedKey || '')" class="w-4 h-4 text-primary shrink-0" />
|
|
559
|
-
<span
|
|
560
|
-
class="font-mono font-bold text-sm text-highlighted truncate"
|
|
561
|
-
:title="selectedKey || ''"
|
|
562
|
-
>
|
|
563
|
-
{{ selectedKey }}
|
|
564
|
-
</span>
|
|
565
|
-
</div>
|
|
566
|
-
</template>
|
|
567
|
-
|
|
568
|
-
<template #body>
|
|
569
|
-
<div v-if="selectedKey" class="space-y-6">
|
|
570
|
-
<!-- Metadata Info Card -->
|
|
571
|
-
<div class="space-y-3">
|
|
572
|
-
<div class="text-xs font-semibold uppercase tracking-wider text-muted">Key Details</div>
|
|
573
|
-
|
|
574
|
-
<div
|
|
575
|
-
class="divide-y divide-default rounded-lg border border-default bg-elevated/40 text-xs font-mono"
|
|
576
|
-
>
|
|
577
|
-
<div class="flex items-center justify-between p-3">
|
|
578
|
-
<span class="text-muted">Key Name</span>
|
|
579
|
-
<div class="flex items-center gap-1.5 min-w-0 ml-2">
|
|
580
|
-
<span class="text-highlighted font-bold truncate">{{ selectedKey }}</span>
|
|
581
|
-
<UButton
|
|
582
|
-
type="button"
|
|
583
|
-
icon="i-lucide-copy"
|
|
584
|
-
color="neutral"
|
|
585
|
-
variant="ghost"
|
|
586
|
-
size="xs"
|
|
587
|
-
title="Copy key name"
|
|
588
|
-
@click="copyKeyName(selectedKey)"
|
|
589
|
-
/>
|
|
590
|
-
</div>
|
|
591
|
-
</div>
|
|
592
|
-
|
|
593
|
-
<div class="flex items-center justify-between p-3">
|
|
594
|
-
<span class="text-muted">Namespace Prefix</span>
|
|
595
|
-
<span class="text-default font-semibold">{{ getKeyPrefix(selectedKey) }}</span>
|
|
596
|
-
</div>
|
|
597
|
-
|
|
598
|
-
<div class="flex items-center justify-between p-3">
|
|
599
|
-
<span class="text-muted">Expiration</span>
|
|
600
|
-
<span class="text-default">{{
|
|
601
|
-
fmtFullExpiry(selectedKeyData?.expiration || kvSelected?.expiration)
|
|
602
|
-
}}</span>
|
|
603
|
-
</div>
|
|
604
|
-
</div>
|
|
605
|
-
</div>
|
|
606
|
-
|
|
607
|
-
<!-- Value Section (View / Edit Mode) -->
|
|
608
|
-
<div class="space-y-3">
|
|
609
|
-
<div class="flex items-center justify-between">
|
|
610
|
-
<span
|
|
611
|
-
class="text-xs font-semibold uppercase tracking-wider text-muted flex items-center gap-1.5"
|
|
612
|
-
>
|
|
613
|
-
<UIcon name="i-lucide-code" class="w-3.5 h-3.5 text-primary" />
|
|
614
|
-
Stored Value
|
|
615
|
-
</span>
|
|
616
|
-
<div class="flex items-center gap-1.5">
|
|
617
|
-
<!-- JSON Format Mode Toggle (only when value is JSON) -->
|
|
618
|
-
<div
|
|
619
|
-
v-if="!kvEditing && isJsonValue"
|
|
620
|
-
class="flex items-center bg-muted/60 rounded p-0.5 border border-default text-[10px]"
|
|
621
|
-
>
|
|
622
|
-
<UButton
|
|
623
|
-
label="Pretty JSON"
|
|
624
|
-
size="xs"
|
|
625
|
-
:color="viewMode === 'pretty' ? 'primary' : 'neutral'"
|
|
626
|
-
:variant="viewMode === 'pretty' ? 'subtle' : 'ghost'"
|
|
627
|
-
@click="viewMode = 'pretty'"
|
|
628
|
-
/>
|
|
629
|
-
<UButton
|
|
630
|
-
label="Raw"
|
|
631
|
-
size="xs"
|
|
632
|
-
:color="viewMode === 'raw' ? 'primary' : 'neutral'"
|
|
633
|
-
:variant="viewMode === 'raw' ? 'subtle' : 'ghost'"
|
|
634
|
-
@click="viewMode = 'raw'"
|
|
635
|
-
/>
|
|
636
|
-
</div>
|
|
637
|
-
|
|
638
|
-
<UButton
|
|
639
|
-
v-if="!kvEditing"
|
|
640
|
-
:icon="copiedValue ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
641
|
-
size="xs"
|
|
642
|
-
:color="copiedValue ? 'success' : 'neutral'"
|
|
643
|
-
variant="ghost"
|
|
644
|
-
:title="copiedValue ? 'Copied to clipboard!' : 'Copy value'"
|
|
645
|
-
@click="copyValue"
|
|
646
|
-
/>
|
|
647
|
-
<UButton
|
|
648
|
-
:label="kvEditing ? 'Cancel Edit' : 'Edit Value'"
|
|
649
|
-
:icon="kvEditing ? 'i-lucide-x' : 'i-lucide-edit'"
|
|
650
|
-
size="xs"
|
|
651
|
-
color="neutral"
|
|
652
|
-
variant="subtle"
|
|
653
|
-
@click="toggleKvEdit"
|
|
654
|
-
/>
|
|
655
|
-
</div>
|
|
656
|
-
</div>
|
|
657
|
-
|
|
658
|
-
<!-- Loading state -->
|
|
659
|
-
<div
|
|
660
|
-
v-if="kvValueLoading"
|
|
661
|
-
class="bg-muted/30 border border-default rounded-xl p-8 text-center text-xs text-muted font-mono"
|
|
662
|
-
>
|
|
663
|
-
<UIcon name="i-lucide-loader" class="w-5 h-5 animate-spin mx-auto mb-2 text-primary" />
|
|
664
|
-
Loading value from KV store…
|
|
665
|
-
</div>
|
|
666
|
-
|
|
667
|
-
<!-- Edit Mode -->
|
|
668
|
-
<div v-else-if="kvEditing" class="space-y-3">
|
|
669
|
-
<div class="flex items-center justify-between text-xs text-muted">
|
|
670
|
-
<span>Value editor</span>
|
|
671
|
-
<UButton
|
|
672
|
-
icon="i-lucide-sparkles"
|
|
673
|
-
label="Format JSON"
|
|
674
|
-
size="xs"
|
|
675
|
-
color="primary"
|
|
676
|
-
variant="ghost"
|
|
677
|
-
class="cursor-pointer"
|
|
678
|
-
@click="formatJsonInEdit"
|
|
679
|
-
/>
|
|
680
|
-
</div>
|
|
681
|
-
<UTextarea
|
|
682
|
-
v-model="kvEditValue"
|
|
683
|
-
class="font-mono text-xs w-full"
|
|
684
|
-
:rows="12"
|
|
685
|
-
placeholder="Enter new value…"
|
|
686
|
-
/>
|
|
687
|
-
|
|
688
|
-
<!-- TTL Field in Edit Mode -->
|
|
689
|
-
<div>
|
|
690
|
-
<div class="text-[11px] text-muted mb-1 flex items-center gap-1">
|
|
691
|
-
<UIcon name="i-lucide-clock" class="w-3 h-3 text-primary" />
|
|
692
|
-
TTL (Seconds from now, leave blank to keep unchanged)
|
|
693
|
-
</div>
|
|
694
|
-
<UInput
|
|
695
|
-
v-model="kvEditTtl"
|
|
696
|
-
type="number"
|
|
697
|
-
placeholder="e.g. 86400 (24h)"
|
|
698
|
-
size="xs"
|
|
699
|
-
class="font-mono"
|
|
700
|
-
/>
|
|
701
|
-
</div>
|
|
702
|
-
|
|
703
|
-
<div class="flex justify-end gap-2 pt-2">
|
|
704
|
-
<UButton
|
|
705
|
-
label="Cancel"
|
|
706
|
-
color="neutral"
|
|
707
|
-
variant="ghost"
|
|
708
|
-
size="xs"
|
|
709
|
-
@click="toggleKvEdit"
|
|
710
|
-
/>
|
|
711
|
-
<UButton
|
|
712
|
-
label="Save Changes"
|
|
713
|
-
size="xs"
|
|
714
|
-
color="primary"
|
|
715
|
-
icon="i-lucide-check"
|
|
716
|
-
@click="saveKVEdit"
|
|
717
|
-
/>
|
|
718
|
-
</div>
|
|
719
|
-
</div>
|
|
720
|
-
|
|
721
|
-
<!-- View Mode -->
|
|
722
|
-
<div
|
|
723
|
-
v-else
|
|
724
|
-
class="bg-muted/30 border border-default rounded-xl p-4 overflow-auto max-h-[380px]"
|
|
725
|
-
>
|
|
726
|
-
<pre class="font-mono text-xs text-default whitespace-pre-wrap break-all">{{
|
|
727
|
-
displayValue
|
|
728
|
-
}}</pre>
|
|
729
|
-
</div>
|
|
730
|
-
</div>
|
|
731
|
-
</div>
|
|
732
|
-
</template>
|
|
733
|
-
|
|
734
|
-
<template #footer>
|
|
735
|
-
<div v-if="selectedKey" class="flex items-center justify-between w-full gap-2">
|
|
736
|
-
<UButton
|
|
737
|
-
:label="copiedKey ? 'Copied!' : 'Copy Key'"
|
|
738
|
-
:icon="copiedKey ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
739
|
-
size="xs"
|
|
740
|
-
:color="copiedKey ? 'success' : 'neutral'"
|
|
741
|
-
variant="subtle"
|
|
742
|
-
@click="copyKeyName(selectedKey)"
|
|
743
|
-
/>
|
|
744
|
-
<UButton
|
|
745
|
-
label="Delete Key"
|
|
746
|
-
icon="i-lucide-trash"
|
|
747
|
-
size="xs"
|
|
748
|
-
color="error"
|
|
749
|
-
variant="subtle"
|
|
750
|
-
@click="showDeleteKeyModal = true"
|
|
751
|
-
/>
|
|
752
|
-
</div>
|
|
753
|
-
</template>
|
|
754
|
-
</USlideover>
|
|
755
|
-
|
|
756
|
-
<!-- Delete Key Confirmation Modal -->
|
|
757
|
-
<UModal v-model:open="showDeleteKeyModal" title="Delete KV Key">
|
|
758
|
-
<template #body>
|
|
759
|
-
<div class="space-y-3">
|
|
760
|
-
<p class="text-xs text-default">
|
|
761
|
-
Are you sure you want to delete
|
|
762
|
-
<span class="font-mono font-bold text-highlighted">{{ selectedKey }}</span
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
<
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
<
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
<
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
<UButton
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
:
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useRoute, useFetch, navigateTo } from "nuxt/app"
|
|
3
|
+
import { computed, onMounted, ref, watch } from "vue"
|
|
4
|
+
|
|
5
|
+
const route = useRoute()
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
data: kvData,
|
|
9
|
+
status: kvStatus,
|
|
10
|
+
pending: kvPending,
|
|
11
|
+
execute: executeLoadKV,
|
|
12
|
+
} = useFetch<any>("/_qarpeo/api/kv/keys", {
|
|
13
|
+
query: { limit: 100 },
|
|
14
|
+
immediate: false,
|
|
15
|
+
lazy: true,
|
|
16
|
+
default: () => ({ keys: [] }),
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const kvLoading = computed(
|
|
20
|
+
() => kvPending.value || kvStatus.value === "idle" || kvStatus.value === "pending",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const kvKeys = computed(() => kvData.value?.keys || [])
|
|
24
|
+
const kvSearch = ref("")
|
|
25
|
+
const filterCategory = ref<"all" | "session" | "cache" | "ratelimit" | "other">("all")
|
|
26
|
+
|
|
27
|
+
const kvSelected = ref<any>(null)
|
|
28
|
+
const kvValueLoading = ref(false)
|
|
29
|
+
const kvEditing = ref(false)
|
|
30
|
+
const kvEditValue = ref("")
|
|
31
|
+
const kvEditTtl = ref("")
|
|
32
|
+
const kvDeleting = ref(false)
|
|
33
|
+
const showDeleteKeyModal = ref(false)
|
|
34
|
+
|
|
35
|
+
const viewMode = ref<"raw" | "pretty">("pretty")
|
|
36
|
+
const copiedKey = ref(false)
|
|
37
|
+
const copiedValue = ref(false)
|
|
38
|
+
|
|
39
|
+
const kvNewKey = ref("")
|
|
40
|
+
const kvNewValue = ref("")
|
|
41
|
+
const kvNewTtl = ref("")
|
|
42
|
+
const kvAdding = ref(false)
|
|
43
|
+
const showAddKeyModal = ref(false)
|
|
44
|
+
|
|
45
|
+
const isJsonValue = computed(() => {
|
|
46
|
+
const val = kvSelected.value?.value
|
|
47
|
+
if (!val || typeof val !== "string") return false
|
|
48
|
+
const trimmed = val.trim()
|
|
49
|
+
if (
|
|
50
|
+
!(
|
|
51
|
+
(trimmed.startsWith("{") && trimmed.endsWith("}")) ||
|
|
52
|
+
(trimmed.startsWith("[") && trimmed.endsWith("]"))
|
|
53
|
+
)
|
|
54
|
+
) {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
JSON.parse(trimmed)
|
|
59
|
+
return true
|
|
60
|
+
} catch {
|
|
61
|
+
return false
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const displayValue = computed(() => {
|
|
66
|
+
const val = kvSelected.value?.value
|
|
67
|
+
if (!val) return "(empty)"
|
|
68
|
+
if (viewMode.value === "pretty" && isJsonValue.value) {
|
|
69
|
+
try {
|
|
70
|
+
return JSON.stringify(JSON.parse(val), null, 2)
|
|
71
|
+
} catch {
|
|
72
|
+
return val
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return val
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
function formatJsonInEdit() {
|
|
79
|
+
try {
|
|
80
|
+
const parsed = JSON.parse(kvEditValue.value)
|
|
81
|
+
kvEditValue.value = JSON.stringify(parsed, null, 2)
|
|
82
|
+
} catch {
|
|
83
|
+
// ignore
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// selectedKey is derived from / synced to the ?key= query param
|
|
88
|
+
const selectedKey = computed({
|
|
89
|
+
get: () => (route.query.key as string) || null,
|
|
90
|
+
set: (key: string | null) => {
|
|
91
|
+
navigateTo({ query: { ...route.query, key: key ?? undefined } })
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const selectedKeyData = computed(
|
|
96
|
+
() => kvKeys.value.find((k) => k.name === selectedKey.value) || null,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
const isSlideoverOpen = computed({
|
|
100
|
+
get: () => Boolean(selectedKey.value),
|
|
101
|
+
set: (val: boolean) => {
|
|
102
|
+
if (!val) {
|
|
103
|
+
selectedKey.value = null
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
function fmtExpiry(exp?: number) {
|
|
109
|
+
if (!exp) return "Persistent"
|
|
110
|
+
const diff = exp - Math.floor(Date.now() / 1000)
|
|
111
|
+
if (diff < 0) return "Expired"
|
|
112
|
+
if (diff < 60) return `${diff}s left`
|
|
113
|
+
if (diff < 3600) return `${Math.floor(diff / 60)}m left`
|
|
114
|
+
if (diff < 86400) return `${Math.floor(diff / 3600)}h left`
|
|
115
|
+
return new Date(exp * 1000).toLocaleDateString()
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function fmtFullExpiry(exp?: number) {
|
|
119
|
+
if (!exp) return "Never (Persistent key)"
|
|
120
|
+
return new Date(exp * 1000).toLocaleString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function getKeyIcon(name: string): string {
|
|
124
|
+
if (name.startsWith("session:") || name.startsWith("auth:")) return "i-lucide-user-check"
|
|
125
|
+
if (name.startsWith("cache:") || name.startsWith("swr:")) return "i-lucide-database"
|
|
126
|
+
if (name.startsWith("ratelimit:") || name.startsWith("rl:")) return "i-lucide-shield-alert"
|
|
127
|
+
if (name.startsWith("domain:") || name.startsWith("tenant:")) return "i-lucide-globe"
|
|
128
|
+
return "i-lucide-key"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function getKeyPrefix(name: string): string {
|
|
132
|
+
if (name.includes(":")) {
|
|
133
|
+
return name.split(":")[0]
|
|
134
|
+
}
|
|
135
|
+
return "default"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const counts = computed(() => {
|
|
139
|
+
let session = 0
|
|
140
|
+
let cache = 0
|
|
141
|
+
let ratelimit = 0
|
|
142
|
+
let other = 0
|
|
143
|
+
|
|
144
|
+
for (const k of kvKeys.value) {
|
|
145
|
+
if (k.name.startsWith("session:") || k.name.startsWith("auth:")) {
|
|
146
|
+
session++
|
|
147
|
+
} else if (k.name.startsWith("cache:") || k.name.startsWith("swr:")) {
|
|
148
|
+
cache++
|
|
149
|
+
} else if (k.name.startsWith("ratelimit:") || k.name.startsWith("rl:")) {
|
|
150
|
+
ratelimit++
|
|
151
|
+
} else {
|
|
152
|
+
other++
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return { all: kvKeys.value.length, session, cache, ratelimit, other }
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const filteredKeys = computed(() => {
|
|
160
|
+
let list = kvKeys.value
|
|
161
|
+
|
|
162
|
+
if (filterCategory.value === "session") {
|
|
163
|
+
list = list.filter((k) => k.name.startsWith("session:") || k.name.startsWith("auth:"))
|
|
164
|
+
} else if (filterCategory.value === "cache") {
|
|
165
|
+
list = list.filter((k) => k.name.startsWith("cache:") || k.name.startsWith("swr:"))
|
|
166
|
+
} else if (filterCategory.value === "ratelimit") {
|
|
167
|
+
list = list.filter((k) => k.name.startsWith("ratelimit:") || k.name.startsWith("rl:"))
|
|
168
|
+
} else if (filterCategory.value === "other") {
|
|
169
|
+
list = list.filter(
|
|
170
|
+
(k) =>
|
|
171
|
+
!k.name.startsWith("session:") &&
|
|
172
|
+
!k.name.startsWith("auth:") &&
|
|
173
|
+
!k.name.startsWith("cache:") &&
|
|
174
|
+
!k.name.startsWith("swr:") &&
|
|
175
|
+
!k.name.startsWith("ratelimit:") &&
|
|
176
|
+
!k.name.startsWith("rl:"),
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (kvSearch.value.trim()) {
|
|
181
|
+
const q = kvSearch.value.toLowerCase()
|
|
182
|
+
list = list.filter((k) => k.name.toLowerCase().includes(q))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return list
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
// Re-fetch key value whenever URL ?key= param changes
|
|
189
|
+
watch(
|
|
190
|
+
selectedKey,
|
|
191
|
+
async (key) => {
|
|
192
|
+
if (key) {
|
|
193
|
+
await fetchKeyValue(key)
|
|
194
|
+
} else {
|
|
195
|
+
kvSelected.value = null
|
|
196
|
+
kvEditing.value = false
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{ immediate: true },
|
|
200
|
+
)
|
|
201
|
+
|
|
202
|
+
async function loadKVKeys() {
|
|
203
|
+
await executeLoadKV()
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async function fetchKeyValue(key: string) {
|
|
207
|
+
kvValueLoading.value = true
|
|
208
|
+
try {
|
|
209
|
+
const data = await $fetch<any>("/_qarpeo/api/kv/get", { query: { key } }).catch(() => null)
|
|
210
|
+
kvSelected.value = data ? { ...data, key } : { key, value: "(error loading value)" }
|
|
211
|
+
kvEditing.value = false
|
|
212
|
+
} finally {
|
|
213
|
+
kvValueLoading.value = false
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function selectKey(item: any) {
|
|
218
|
+
selectedKey.value = item.name
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function toggleKvEdit() {
|
|
222
|
+
kvEditing.value = !kvEditing.value
|
|
223
|
+
kvEditValue.value = kvSelected.value?.value || ""
|
|
224
|
+
const exp = selectedKeyData.value?.expiration || kvSelected.value?.expiration
|
|
225
|
+
if (exp) {
|
|
226
|
+
const diff = exp - Math.floor(Date.now() / 1000)
|
|
227
|
+
kvEditTtl.value = diff > 0 ? String(diff) : ""
|
|
228
|
+
} else {
|
|
229
|
+
kvEditTtl.value = ""
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async function saveKVEdit() {
|
|
234
|
+
if (!kvSelected.value) return
|
|
235
|
+
await $fetch("/_qarpeo/api/kv/set", {
|
|
236
|
+
method: "POST",
|
|
237
|
+
body: {
|
|
238
|
+
key: kvSelected.value.key,
|
|
239
|
+
value: kvEditValue.value,
|
|
240
|
+
ttl: kvEditTtl.value ? parseInt(kvEditTtl.value, 10) : undefined,
|
|
241
|
+
},
|
|
242
|
+
})
|
|
243
|
+
kvSelected.value.value = kvEditValue.value
|
|
244
|
+
if (kvEditTtl.value) {
|
|
245
|
+
kvSelected.value.expiration = Math.floor(Date.now() / 1000) + parseInt(kvEditTtl.value, 10)
|
|
246
|
+
}
|
|
247
|
+
kvEditing.value = false
|
|
248
|
+
await loadKVKeys()
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
async function deleteKVKey(key: string) {
|
|
252
|
+
kvDeleting.value = true
|
|
253
|
+
try {
|
|
254
|
+
await $fetch("/_qarpeo/api/kv/delete", {
|
|
255
|
+
method: "POST",
|
|
256
|
+
body: { key },
|
|
257
|
+
})
|
|
258
|
+
showDeleteKeyModal.value = false
|
|
259
|
+
selectedKey.value = null
|
|
260
|
+
await loadKVKeys()
|
|
261
|
+
} finally {
|
|
262
|
+
kvDeleting.value = false
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async function addKVKey() {
|
|
267
|
+
if (!kvNewKey.value || !kvNewValue.value) return
|
|
268
|
+
kvAdding.value = true
|
|
269
|
+
const addedKey = kvNewKey.value
|
|
270
|
+
try {
|
|
271
|
+
await $fetch("/_qarpeo/api/kv/set", {
|
|
272
|
+
method: "POST",
|
|
273
|
+
body: {
|
|
274
|
+
key: kvNewKey.value,
|
|
275
|
+
value: kvNewValue.value,
|
|
276
|
+
ttl: kvNewTtl.value ? parseInt(kvNewTtl.value, 10) : undefined,
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
kvNewKey.value = ""
|
|
280
|
+
kvNewValue.value = ""
|
|
281
|
+
kvNewTtl.value = ""
|
|
282
|
+
showAddKeyModal.value = false
|
|
283
|
+
await loadKVKeys()
|
|
284
|
+
selectedKey.value = addedKey
|
|
285
|
+
} finally {
|
|
286
|
+
kvAdding.value = false
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function copyKeyName(key?: string) {
|
|
291
|
+
if (!key) return
|
|
292
|
+
if (typeof navigator !== "undefined") {
|
|
293
|
+
navigator.clipboard?.writeText(key)
|
|
294
|
+
copiedKey.value = true
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
copiedKey.value = false
|
|
297
|
+
}, 1500)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function copyValue() {
|
|
302
|
+
if (kvSelected.value?.value && typeof navigator !== "undefined") {
|
|
303
|
+
navigator.clipboard?.writeText(displayValue.value)
|
|
304
|
+
copiedValue.value = true
|
|
305
|
+
setTimeout(() => {
|
|
306
|
+
copiedValue.value = false
|
|
307
|
+
}, 1500)
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
onMounted(() => {
|
|
312
|
+
loadKVKeys()
|
|
313
|
+
})
|
|
314
|
+
</script>
|
|
315
|
+
|
|
316
|
+
<template>
|
|
317
|
+
<!-- ── Single Full-Width Panel with Media/Card Grid ─────────────────── -->
|
|
318
|
+
<UDashboardPanel id="devtools-kv">
|
|
319
|
+
<template #header>
|
|
320
|
+
<UDashboardNavbar>
|
|
321
|
+
<template #title>
|
|
322
|
+
<div class="flex items-center gap-2">
|
|
323
|
+
<UIcon name="i-lucide-zap" class="w-4 h-4 text-primary" />
|
|
324
|
+
<span class="font-bold text-sm text-highlighted">KV Store</span>
|
|
325
|
+
<UBadge size="xs" color="neutral" variant="subtle">Cloudflare KV</UBadge>
|
|
326
|
+
<UBadge size="xs" color="neutral" variant="subtle">
|
|
327
|
+
{{ filteredKeys.length }}
|
|
328
|
+
</UBadge>
|
|
329
|
+
</div>
|
|
330
|
+
</template>
|
|
331
|
+
|
|
332
|
+
<template #right>
|
|
333
|
+
<div class="flex items-center gap-1.5">
|
|
334
|
+
<UButton
|
|
335
|
+
icon="i-lucide-plus"
|
|
336
|
+
label="Add Key"
|
|
337
|
+
size="xs"
|
|
338
|
+
color="primary"
|
|
339
|
+
@click="showAddKeyModal = true"
|
|
340
|
+
/>
|
|
341
|
+
<UButton
|
|
342
|
+
icon="i-lucide-refresh-cw"
|
|
343
|
+
size="xs"
|
|
344
|
+
color="neutral"
|
|
345
|
+
variant="ghost"
|
|
346
|
+
title="Refresh keys"
|
|
347
|
+
:loading="kvLoading"
|
|
348
|
+
@click="loadKVKeys"
|
|
349
|
+
/>
|
|
350
|
+
</div>
|
|
351
|
+
</template>
|
|
352
|
+
</UDashboardNavbar>
|
|
353
|
+
|
|
354
|
+
<!-- Category Filter & Search Toolbar -->
|
|
355
|
+
<UDashboardToolbar>
|
|
356
|
+
<div class="flex items-center gap-1 bg-muted p-0.5 rounded border border-default">
|
|
357
|
+
<UButton
|
|
358
|
+
label="All"
|
|
359
|
+
size="xs"
|
|
360
|
+
:color="filterCategory === 'all' ? 'primary' : 'neutral'"
|
|
361
|
+
:variant="filterCategory === 'all' ? 'subtle' : 'ghost'"
|
|
362
|
+
@click="filterCategory = 'all'"
|
|
363
|
+
>
|
|
364
|
+
<template #trailing>
|
|
365
|
+
<UBadge
|
|
366
|
+
size="xs"
|
|
367
|
+
:color="filterCategory === 'all' ? 'primary' : 'neutral'"
|
|
368
|
+
variant="subtle"
|
|
369
|
+
>
|
|
370
|
+
{{ counts.all }}
|
|
371
|
+
</UBadge>
|
|
372
|
+
</template>
|
|
373
|
+
</UButton>
|
|
374
|
+
|
|
375
|
+
<UButton
|
|
376
|
+
label="Sessions"
|
|
377
|
+
icon="i-lucide-user-check"
|
|
378
|
+
size="xs"
|
|
379
|
+
:color="filterCategory === 'session' ? 'primary' : 'neutral'"
|
|
380
|
+
:variant="filterCategory === 'session' ? 'subtle' : 'ghost'"
|
|
381
|
+
@click="filterCategory = 'session'"
|
|
382
|
+
>
|
|
383
|
+
<template #trailing>
|
|
384
|
+
<UBadge
|
|
385
|
+
size="xs"
|
|
386
|
+
:color="filterCategory === 'session' ? 'primary' : 'neutral'"
|
|
387
|
+
variant="subtle"
|
|
388
|
+
>
|
|
389
|
+
{{ counts.session }}
|
|
390
|
+
</UBadge>
|
|
391
|
+
</template>
|
|
392
|
+
</UButton>
|
|
393
|
+
|
|
394
|
+
<UButton
|
|
395
|
+
label="Cache"
|
|
396
|
+
icon="i-lucide-database"
|
|
397
|
+
size="xs"
|
|
398
|
+
:color="filterCategory === 'cache' ? 'primary' : 'neutral'"
|
|
399
|
+
:variant="filterCategory === 'cache' ? 'subtle' : 'ghost'"
|
|
400
|
+
@click="filterCategory = 'cache'"
|
|
401
|
+
>
|
|
402
|
+
<template #trailing>
|
|
403
|
+
<UBadge
|
|
404
|
+
size="xs"
|
|
405
|
+
:color="filterCategory === 'cache' ? 'primary' : 'neutral'"
|
|
406
|
+
variant="subtle"
|
|
407
|
+
>
|
|
408
|
+
{{ counts.cache }}
|
|
409
|
+
</UBadge>
|
|
410
|
+
</template>
|
|
411
|
+
</UButton>
|
|
412
|
+
|
|
413
|
+
<UButton
|
|
414
|
+
label="Rate Limit"
|
|
415
|
+
icon="i-lucide-shield-alert"
|
|
416
|
+
size="xs"
|
|
417
|
+
:color="filterCategory === 'ratelimit' ? 'primary' : 'neutral'"
|
|
418
|
+
:variant="filterCategory === 'ratelimit' ? 'subtle' : 'ghost'"
|
|
419
|
+
@click="filterCategory = 'ratelimit'"
|
|
420
|
+
>
|
|
421
|
+
<template #trailing>
|
|
422
|
+
<UBadge
|
|
423
|
+
size="xs"
|
|
424
|
+
:color="filterCategory === 'ratelimit' ? 'primary' : 'neutral'"
|
|
425
|
+
variant="subtle"
|
|
426
|
+
>
|
|
427
|
+
{{ counts.ratelimit }}
|
|
428
|
+
</UBadge>
|
|
429
|
+
</template>
|
|
430
|
+
</UButton>
|
|
431
|
+
|
|
432
|
+
<UButton
|
|
433
|
+
label="Other"
|
|
434
|
+
size="xs"
|
|
435
|
+
:color="filterCategory === 'other' ? 'primary' : 'neutral'"
|
|
436
|
+
:variant="filterCategory === 'other' ? 'subtle' : 'ghost'"
|
|
437
|
+
@click="filterCategory = 'other'"
|
|
438
|
+
>
|
|
439
|
+
<template #trailing>
|
|
440
|
+
<UBadge
|
|
441
|
+
size="xs"
|
|
442
|
+
:color="filterCategory === 'other' ? 'primary' : 'neutral'"
|
|
443
|
+
variant="subtle"
|
|
444
|
+
>
|
|
445
|
+
{{ counts.other }}
|
|
446
|
+
</UBadge>
|
|
447
|
+
</template>
|
|
448
|
+
</UButton>
|
|
449
|
+
</div>
|
|
450
|
+
|
|
451
|
+
<!-- Search Input -->
|
|
452
|
+
<div class="flex items-center gap-2 max-w-xs flex-1">
|
|
453
|
+
<UInput
|
|
454
|
+
v-model="kvSearch"
|
|
455
|
+
icon="i-lucide-search"
|
|
456
|
+
placeholder="Search keys…"
|
|
457
|
+
class="w-full"
|
|
458
|
+
/>
|
|
459
|
+
</div>
|
|
460
|
+
</UDashboardToolbar>
|
|
461
|
+
</template>
|
|
462
|
+
|
|
463
|
+
<template #body>
|
|
464
|
+
<div class="space-y-4">
|
|
465
|
+
<!-- Loading Skeleton Grid -->
|
|
466
|
+
<div
|
|
467
|
+
v-if="kvLoading"
|
|
468
|
+
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3.5"
|
|
469
|
+
>
|
|
470
|
+
<div
|
|
471
|
+
v-for="i in 10"
|
|
472
|
+
:key="i"
|
|
473
|
+
class="bg-elevated/40 border border-default rounded-xl p-3.5 flex flex-col justify-between h-28 animate-pulse"
|
|
474
|
+
>
|
|
475
|
+
<div class="flex items-start justify-between gap-2">
|
|
476
|
+
<div class="flex items-center gap-2">
|
|
477
|
+
<div class="w-8 h-8 rounded-lg bg-muted"></div>
|
|
478
|
+
<div class="h-4 w-12 rounded bg-muted"></div>
|
|
479
|
+
</div>
|
|
480
|
+
<div class="h-4 w-14 rounded bg-muted"></div>
|
|
481
|
+
</div>
|
|
482
|
+
<div class="h-3 w-3/4 rounded bg-muted"></div>
|
|
483
|
+
<div class="h-2 w-1/2 rounded bg-muted"></div>
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
|
|
487
|
+
<!-- Interactive KV Cards Grid -->
|
|
488
|
+
<div
|
|
489
|
+
v-else-if="filteredKeys.length"
|
|
490
|
+
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3.5"
|
|
491
|
+
>
|
|
492
|
+
<UCard v-for="item in filteredKeys" :key="item.name" @click="selectKey(item)">
|
|
493
|
+
<!-- Card Header: Icon + Namespace Tag + TTL Badge -->
|
|
494
|
+
<div class="flex items-start justify-between gap-2 mb-2">
|
|
495
|
+
<div class="flex items-center gap-2 min-w-0">
|
|
496
|
+
<div
|
|
497
|
+
class="w-8 h-8 rounded-lg bg-primary/10 border border-primary/20 flex items-center justify-center shrink-0 text-primary group-hover:scale-105 transition-transform"
|
|
498
|
+
>
|
|
499
|
+
<UIcon :name="getKeyIcon(item.name)" class="w-4 h-4" />
|
|
500
|
+
</div>
|
|
501
|
+
<div class="min-w-0">
|
|
502
|
+
<UBadge size="xs" color="neutral" variant="subtle" class="font-mono text-[10px]">
|
|
503
|
+
{{ getKeyPrefix(item.name) }}
|
|
504
|
+
</UBadge>
|
|
505
|
+
</div>
|
|
506
|
+
</div>
|
|
507
|
+
|
|
508
|
+
<UBadge
|
|
509
|
+
size="xs"
|
|
510
|
+
:color="item.expiration ? 'warning' : 'neutral'"
|
|
511
|
+
variant="subtle"
|
|
512
|
+
class="font-mono text-[10px] shrink-0"
|
|
513
|
+
>
|
|
514
|
+
{{ fmtExpiry(item.expiration) }}
|
|
515
|
+
</UBadge>
|
|
516
|
+
</div>
|
|
517
|
+
|
|
518
|
+
<!-- Card Body: Key Name -->
|
|
519
|
+
<div class="my-1.5 min-w-0">
|
|
520
|
+
<div
|
|
521
|
+
class="font-mono text-xs font-bold text-highlighted group-hover:text-primary transition-colors truncate"
|
|
522
|
+
:title="item.name"
|
|
523
|
+
>
|
|
524
|
+
{{ item.name }}
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
</UCard>
|
|
528
|
+
</div>
|
|
529
|
+
|
|
530
|
+
<!-- Empty State -->
|
|
531
|
+
<div v-else class="flex flex-col items-center justify-center py-20 text-center space-y-3">
|
|
532
|
+
<div
|
|
533
|
+
class="w-12 h-12 rounded-full bg-primary/10 border border-primary/20 flex items-center justify-center text-primary"
|
|
534
|
+
>
|
|
535
|
+
<UIcon name="i-lucide-zap" class="w-6 h-6" />
|
|
536
|
+
</div>
|
|
537
|
+
<div class="font-bold text-sm text-highlighted">No KV keys found</div>
|
|
538
|
+
<p class="text-xs text-muted max-w-sm">
|
|
539
|
+
Store ultra-low latency global key-value data directly on Cloudflare Edge with optional
|
|
540
|
+
TTL expiration.
|
|
541
|
+
</p>
|
|
542
|
+
<UButton
|
|
543
|
+
label="Add First Key"
|
|
544
|
+
icon="i-lucide-plus"
|
|
545
|
+
size="sm"
|
|
546
|
+
color="primary"
|
|
547
|
+
@click="showAddKeyModal = true"
|
|
548
|
+
/>
|
|
549
|
+
</div>
|
|
550
|
+
</div>
|
|
551
|
+
</template>
|
|
552
|
+
</UDashboardPanel>
|
|
553
|
+
|
|
554
|
+
<!-- ── Right Side Slideover for Key Value Inspector & Editor ──────────── -->
|
|
555
|
+
<USlideover v-model:open="isSlideoverOpen" side="right" :title="selectedKey || undefined">
|
|
556
|
+
<template #title>
|
|
557
|
+
<div class="flex items-center gap-2 min-w-0 pr-4">
|
|
558
|
+
<UIcon :name="getKeyIcon(selectedKey || '')" class="w-4 h-4 text-primary shrink-0" />
|
|
559
|
+
<span
|
|
560
|
+
class="font-mono font-bold text-sm text-highlighted truncate"
|
|
561
|
+
:title="selectedKey || ''"
|
|
562
|
+
>
|
|
563
|
+
{{ selectedKey }}
|
|
564
|
+
</span>
|
|
565
|
+
</div>
|
|
566
|
+
</template>
|
|
567
|
+
|
|
568
|
+
<template #body>
|
|
569
|
+
<div v-if="selectedKey" class="space-y-6">
|
|
570
|
+
<!-- Metadata Info Card -->
|
|
571
|
+
<div class="space-y-3">
|
|
572
|
+
<div class="text-xs font-semibold uppercase tracking-wider text-muted">Key Details</div>
|
|
573
|
+
|
|
574
|
+
<div
|
|
575
|
+
class="divide-y divide-default rounded-lg border border-default bg-elevated/40 text-xs font-mono"
|
|
576
|
+
>
|
|
577
|
+
<div class="flex items-center justify-between p-3">
|
|
578
|
+
<span class="text-muted">Key Name</span>
|
|
579
|
+
<div class="flex items-center gap-1.5 min-w-0 ml-2">
|
|
580
|
+
<span class="text-highlighted font-bold truncate">{{ selectedKey }}</span>
|
|
581
|
+
<UButton
|
|
582
|
+
type="button"
|
|
583
|
+
icon="i-lucide-copy"
|
|
584
|
+
color="neutral"
|
|
585
|
+
variant="ghost"
|
|
586
|
+
size="xs"
|
|
587
|
+
title="Copy key name"
|
|
588
|
+
@click="copyKeyName(selectedKey)"
|
|
589
|
+
/>
|
|
590
|
+
</div>
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
<div class="flex items-center justify-between p-3">
|
|
594
|
+
<span class="text-muted">Namespace Prefix</span>
|
|
595
|
+
<span class="text-default font-semibold">{{ getKeyPrefix(selectedKey) }}</span>
|
|
596
|
+
</div>
|
|
597
|
+
|
|
598
|
+
<div class="flex items-center justify-between p-3">
|
|
599
|
+
<span class="text-muted">Expiration</span>
|
|
600
|
+
<span class="text-default">{{
|
|
601
|
+
fmtFullExpiry(selectedKeyData?.expiration || kvSelected?.expiration)
|
|
602
|
+
}}</span>
|
|
603
|
+
</div>
|
|
604
|
+
</div>
|
|
605
|
+
</div>
|
|
606
|
+
|
|
607
|
+
<!-- Value Section (View / Edit Mode) -->
|
|
608
|
+
<div class="space-y-3">
|
|
609
|
+
<div class="flex items-center justify-between">
|
|
610
|
+
<span
|
|
611
|
+
class="text-xs font-semibold uppercase tracking-wider text-muted flex items-center gap-1.5"
|
|
612
|
+
>
|
|
613
|
+
<UIcon name="i-lucide-code" class="w-3.5 h-3.5 text-primary" />
|
|
614
|
+
Stored Value
|
|
615
|
+
</span>
|
|
616
|
+
<div class="flex items-center gap-1.5">
|
|
617
|
+
<!-- JSON Format Mode Toggle (only when value is JSON) -->
|
|
618
|
+
<div
|
|
619
|
+
v-if="!kvEditing && isJsonValue"
|
|
620
|
+
class="flex items-center bg-muted/60 rounded p-0.5 border border-default text-[10px]"
|
|
621
|
+
>
|
|
622
|
+
<UButton
|
|
623
|
+
label="Pretty JSON"
|
|
624
|
+
size="xs"
|
|
625
|
+
:color="viewMode === 'pretty' ? 'primary' : 'neutral'"
|
|
626
|
+
:variant="viewMode === 'pretty' ? 'subtle' : 'ghost'"
|
|
627
|
+
@click="viewMode = 'pretty'"
|
|
628
|
+
/>
|
|
629
|
+
<UButton
|
|
630
|
+
label="Raw"
|
|
631
|
+
size="xs"
|
|
632
|
+
:color="viewMode === 'raw' ? 'primary' : 'neutral'"
|
|
633
|
+
:variant="viewMode === 'raw' ? 'subtle' : 'ghost'"
|
|
634
|
+
@click="viewMode = 'raw'"
|
|
635
|
+
/>
|
|
636
|
+
</div>
|
|
637
|
+
|
|
638
|
+
<UButton
|
|
639
|
+
v-if="!kvEditing"
|
|
640
|
+
:icon="copiedValue ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
641
|
+
size="xs"
|
|
642
|
+
:color="copiedValue ? 'success' : 'neutral'"
|
|
643
|
+
variant="ghost"
|
|
644
|
+
:title="copiedValue ? 'Copied to clipboard!' : 'Copy value'"
|
|
645
|
+
@click="copyValue"
|
|
646
|
+
/>
|
|
647
|
+
<UButton
|
|
648
|
+
:label="kvEditing ? 'Cancel Edit' : 'Edit Value'"
|
|
649
|
+
:icon="kvEditing ? 'i-lucide-x' : 'i-lucide-edit'"
|
|
650
|
+
size="xs"
|
|
651
|
+
color="neutral"
|
|
652
|
+
variant="subtle"
|
|
653
|
+
@click="toggleKvEdit"
|
|
654
|
+
/>
|
|
655
|
+
</div>
|
|
656
|
+
</div>
|
|
657
|
+
|
|
658
|
+
<!-- Loading state -->
|
|
659
|
+
<div
|
|
660
|
+
v-if="kvValueLoading"
|
|
661
|
+
class="bg-muted/30 border border-default rounded-xl p-8 text-center text-xs text-muted font-mono"
|
|
662
|
+
>
|
|
663
|
+
<UIcon name="i-lucide-loader" class="w-5 h-5 animate-spin mx-auto mb-2 text-primary" />
|
|
664
|
+
Loading value from KV store…
|
|
665
|
+
</div>
|
|
666
|
+
|
|
667
|
+
<!-- Edit Mode -->
|
|
668
|
+
<div v-else-if="kvEditing" class="space-y-3">
|
|
669
|
+
<div class="flex items-center justify-between text-xs text-muted">
|
|
670
|
+
<span>Value editor</span>
|
|
671
|
+
<UButton
|
|
672
|
+
icon="i-lucide-sparkles"
|
|
673
|
+
label="Format JSON"
|
|
674
|
+
size="xs"
|
|
675
|
+
color="primary"
|
|
676
|
+
variant="ghost"
|
|
677
|
+
class="cursor-pointer"
|
|
678
|
+
@click="formatJsonInEdit"
|
|
679
|
+
/>
|
|
680
|
+
</div>
|
|
681
|
+
<UTextarea
|
|
682
|
+
v-model="kvEditValue"
|
|
683
|
+
class="font-mono text-xs w-full"
|
|
684
|
+
:rows="12"
|
|
685
|
+
placeholder="Enter new value…"
|
|
686
|
+
/>
|
|
687
|
+
|
|
688
|
+
<!-- TTL Field in Edit Mode -->
|
|
689
|
+
<div>
|
|
690
|
+
<div class="text-[11px] text-muted mb-1 flex items-center gap-1">
|
|
691
|
+
<UIcon name="i-lucide-clock" class="w-3 h-3 text-primary" />
|
|
692
|
+
TTL (Seconds from now, leave blank to keep unchanged)
|
|
693
|
+
</div>
|
|
694
|
+
<UInput
|
|
695
|
+
v-model="kvEditTtl"
|
|
696
|
+
type="number"
|
|
697
|
+
placeholder="e.g. 86400 (24h)"
|
|
698
|
+
size="xs"
|
|
699
|
+
class="font-mono"
|
|
700
|
+
/>
|
|
701
|
+
</div>
|
|
702
|
+
|
|
703
|
+
<div class="flex justify-end gap-2 pt-2">
|
|
704
|
+
<UButton
|
|
705
|
+
label="Cancel"
|
|
706
|
+
color="neutral"
|
|
707
|
+
variant="ghost"
|
|
708
|
+
size="xs"
|
|
709
|
+
@click="toggleKvEdit"
|
|
710
|
+
/>
|
|
711
|
+
<UButton
|
|
712
|
+
label="Save Changes"
|
|
713
|
+
size="xs"
|
|
714
|
+
color="primary"
|
|
715
|
+
icon="i-lucide-check"
|
|
716
|
+
@click="saveKVEdit"
|
|
717
|
+
/>
|
|
718
|
+
</div>
|
|
719
|
+
</div>
|
|
720
|
+
|
|
721
|
+
<!-- View Mode -->
|
|
722
|
+
<div
|
|
723
|
+
v-else
|
|
724
|
+
class="bg-muted/30 border border-default rounded-xl p-4 overflow-auto max-h-[380px]"
|
|
725
|
+
>
|
|
726
|
+
<pre class="font-mono text-xs text-default whitespace-pre-wrap break-all">{{
|
|
727
|
+
displayValue
|
|
728
|
+
}}</pre>
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
</div>
|
|
732
|
+
</template>
|
|
733
|
+
|
|
734
|
+
<template #footer>
|
|
735
|
+
<div v-if="selectedKey" class="flex items-center justify-between w-full gap-2">
|
|
736
|
+
<UButton
|
|
737
|
+
:label="copiedKey ? 'Copied!' : 'Copy Key'"
|
|
738
|
+
:icon="copiedKey ? 'i-lucide-check' : 'i-lucide-copy'"
|
|
739
|
+
size="xs"
|
|
740
|
+
:color="copiedKey ? 'success' : 'neutral'"
|
|
741
|
+
variant="subtle"
|
|
742
|
+
@click="copyKeyName(selectedKey)"
|
|
743
|
+
/>
|
|
744
|
+
<UButton
|
|
745
|
+
label="Delete Key"
|
|
746
|
+
icon="i-lucide-trash"
|
|
747
|
+
size="xs"
|
|
748
|
+
color="error"
|
|
749
|
+
variant="subtle"
|
|
750
|
+
@click="showDeleteKeyModal = true"
|
|
751
|
+
/>
|
|
752
|
+
</div>
|
|
753
|
+
</template>
|
|
754
|
+
</USlideover>
|
|
755
|
+
|
|
756
|
+
<!-- Delete Key Confirmation Modal -->
|
|
757
|
+
<UModal v-model:open="showDeleteKeyModal" title="Delete KV Key">
|
|
758
|
+
<template #body>
|
|
759
|
+
<div class="space-y-3">
|
|
760
|
+
<p class="text-xs text-default">
|
|
761
|
+
Are you sure you want to delete
|
|
762
|
+
<span class="font-mono font-bold text-highlighted">{{ selectedKey }}</span>?
|
|
763
|
+
</p>
|
|
764
|
+
<p class="text-xs text-muted">
|
|
765
|
+
This key will be permanently removed from the Cloudflare KV namespace. Any clients or
|
|
766
|
+
sessions relying on it will receive null.
|
|
767
|
+
</p>
|
|
768
|
+
</div>
|
|
769
|
+
</template>
|
|
770
|
+
<template #footer>
|
|
771
|
+
<div class="flex justify-end gap-2">
|
|
772
|
+
<UButton
|
|
773
|
+
label="Cancel"
|
|
774
|
+
color="neutral"
|
|
775
|
+
variant="ghost"
|
|
776
|
+
size="xs"
|
|
777
|
+
@click="showDeleteKeyModal = false"
|
|
778
|
+
/>
|
|
779
|
+
<UButton
|
|
780
|
+
label="Confirm Delete"
|
|
781
|
+
color="error"
|
|
782
|
+
size="xs"
|
|
783
|
+
icon="i-lucide-trash"
|
|
784
|
+
:loading="kvDeleting"
|
|
785
|
+
@click="selectedKey && deleteKVKey(selectedKey)"
|
|
786
|
+
/>
|
|
787
|
+
</div>
|
|
788
|
+
</template>
|
|
789
|
+
</UModal>
|
|
790
|
+
|
|
791
|
+
<!-- Add Key Modal -->
|
|
792
|
+
<UModal v-model:open="showAddKeyModal" title="Add KV Key">
|
|
793
|
+
<template #body>
|
|
794
|
+
<div class="space-y-3">
|
|
795
|
+
<div>
|
|
796
|
+
<div class="text-xs text-muted mb-1">Key Name</div>
|
|
797
|
+
<UInput v-model="kvNewKey" placeholder="e.g. session:user_123" class="font-mono" />
|
|
798
|
+
</div>
|
|
799
|
+
<div>
|
|
800
|
+
<div class="text-xs text-muted mb-1">Value (String or JSON)</div>
|
|
801
|
+
<UTextarea
|
|
802
|
+
v-model="kvNewValue"
|
|
803
|
+
placeholder="{ ... }"
|
|
804
|
+
:rows="4"
|
|
805
|
+
class="font-mono text-xs"
|
|
806
|
+
/>
|
|
807
|
+
</div>
|
|
808
|
+
<div>
|
|
809
|
+
<div class="text-xs text-muted mb-1">TTL (Seconds, optional)</div>
|
|
810
|
+
<UInput v-model="kvNewTtl" type="number" placeholder="86400" />
|
|
811
|
+
</div>
|
|
812
|
+
</div>
|
|
813
|
+
</template>
|
|
814
|
+
<template #footer>
|
|
815
|
+
<div class="flex justify-end gap-2">
|
|
816
|
+
<UButton label="Cancel" color="neutral" variant="ghost" @click="showAddKeyModal = false" />
|
|
817
|
+
<UButton
|
|
818
|
+
label="Create Key"
|
|
819
|
+
color="primary"
|
|
820
|
+
:loading="kvAdding"
|
|
821
|
+
:disabled="!kvNewKey || !kvNewValue"
|
|
822
|
+
@click="addKVKey"
|
|
823
|
+
/>
|
|
824
|
+
</div>
|
|
825
|
+
</template>
|
|
826
|
+
</UModal>
|
|
827
|
+
</template>
|