@kyro-cms/admin 0.3.1 → 0.3.4
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/dist/EditorClient-XEUOVAAC.js +466 -0
- package/dist/EditorClient-XEUOVAAC.js.map +1 -0
- package/dist/EditorClient-YLCGVDXY.cjs +468 -0
- package/dist/EditorClient-YLCGVDXY.cjs.map +1 -0
- package/dist/chunk-7KPIUCGT.js +384 -0
- package/dist/chunk-7KPIUCGT.js.map +1 -0
- package/dist/chunk-GOACG6R7.cjs +473 -0
- package/dist/chunk-GOACG6R7.cjs.map +1 -0
- package/dist/index.cjs +14861 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +1661 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +563 -0
- package/dist/index.js +14784 -0
- package/dist/index.js.map +1 -0
- package/package.json +19 -19
- package/src/components/ActionBar.tsx +7 -43
- package/src/components/Admin.tsx +138 -277
- package/src/components/ApiKeysManager.tsx +428 -419
- package/src/components/AuditLogsPage.tsx +35 -39
- package/src/components/AuthBridge.tsx +51 -0
- package/src/components/AutoForm.tsx +495 -1230
- package/src/components/BrandingHub.tsx +18 -19
- package/src/components/BulkActionsBar.tsx +1 -1
- package/src/components/CreateView.tsx +22 -36
- package/src/components/Dashboard.tsx +60 -84
- package/src/components/DetailView.tsx +113 -91
- package/src/components/DeveloperCenter.tsx +200 -198
- package/src/components/FieldRenderer.tsx +206 -0
- package/src/components/GraphQLPlayground.tsx +340 -480
- package/src/components/ListView.tsx +828 -254
- package/src/components/LoginPage.tsx +3 -4
- package/src/components/MarketplaceManager.tsx +254 -0
- package/src/components/MediaGallery.tsx +856 -1192
- package/src/components/PluginsManager.tsx +277 -0
- package/src/components/RestPlayground.tsx +398 -560
- package/src/components/SessionsManager.tsx +211 -0
- package/src/components/Sidebar.astro +179 -151
- package/src/components/ThemeProvider.tsx +7 -161
- package/src/components/UserManagement.tsx +162 -146
- package/src/components/UserMenu.tsx +110 -0
- package/src/components/WebhookManager.tsx +305 -367
- package/src/components/blocks/AccordionBlock.tsx +4 -4
- package/src/components/blocks/ArrayBlock.tsx +3 -3
- package/src/components/blocks/BlockEditModal.tsx +8 -8
- package/src/components/blocks/BlockWrapper.tsx +61 -0
- package/src/components/blocks/ButtonBlock.tsx +4 -4
- package/src/components/blocks/ChildBlocksTree.tsx +23 -25
- package/src/components/blocks/CodeBlock.tsx +15 -15
- package/src/components/blocks/ColumnsBlock.tsx +6 -44
- package/src/components/blocks/DividerBlock.tsx +3 -3
- package/src/components/blocks/FileBlock.tsx +4 -4
- package/src/components/blocks/HeadingBlock.tsx +6 -38
- package/src/components/blocks/HeroBlock.tsx +4 -4
- package/src/components/blocks/ImageBlock.tsx +4 -4
- package/src/components/blocks/LinkBlock.tsx +4 -4
- package/src/components/blocks/ListBlock.tsx +3 -3
- package/src/components/blocks/ParagraphBlock.tsx +12 -42
- package/src/components/blocks/RelationshipBlock.tsx +4 -4
- package/src/components/blocks/RichTextBlock.tsx +4 -4
- package/src/components/blocks/VStackBlock.tsx +5 -37
- package/src/components/blocks/VideoBlock.tsx +4 -4
- package/src/components/blocks/types.ts +11 -0
- package/src/components/fields/AccordionField.tsx +1 -1
- package/src/components/fields/ArrayField.tsx +2 -2
- package/src/components/fields/ArrayLayout.tsx +93 -0
- package/src/components/fields/BlocksField.tsx +122 -111
- package/src/components/fields/ButtonField.tsx +1 -1
- package/src/components/fields/CheckboxField.tsx +14 -15
- package/src/components/fields/ChildrenField.tsx +2 -2
- package/src/components/fields/CodeField.tsx +3 -3
- package/src/components/fields/ColumnsField.tsx +2 -2
- package/src/components/fields/DateField.tsx +13 -26
- package/src/components/fields/EditorClient.tsx +26 -28
- package/src/components/fields/FieldLayout.tsx +52 -0
- package/src/components/fields/GroupLayout.tsx +35 -0
- package/src/components/fields/JSONField.tsx +7 -7
- package/src/components/fields/LinkField.tsx +1 -1
- package/src/components/fields/MarkdownField.tsx +1 -1
- package/src/components/fields/NumberField.tsx +13 -26
- package/src/components/fields/PortableTextField.tsx +4 -4
- package/src/components/fields/PortableTextRenderer.tsx +1 -1
- package/src/components/fields/RelationshipBlockField.tsx +31 -23
- package/src/components/fields/RelationshipField.tsx +14 -14
- package/src/components/fields/SelectField.tsx +17 -26
- package/src/components/fields/TabsLayout.tsx +69 -0
- package/src/components/fields/TextField.tsx +85 -38
- package/src/components/fields/UploadField.tsx +71 -41
- package/src/components/fields/VideoField.tsx +1 -1
- package/src/components/fields/extensions/blockComponents.tsx +2 -2
- package/src/components/fields/extensions/blocksStore.ts +207 -193
- package/src/components/fields/types.ts +22 -0
- package/src/components/layout/Layout.tsx +1 -1
- package/src/components/ui/ActionMenu.tsx +63 -0
- package/src/components/ui/Badge.tsx +59 -5
- package/src/components/ui/BlockDrawer.tsx +4 -5
- package/src/components/ui/CommandPalette.tsx +58 -36
- package/src/components/ui/CommandPaletteWrapper.tsx +18 -17
- package/src/components/ui/Dropdown.tsx +18 -16
- package/src/components/ui/EmptyState.tsx +25 -0
- package/src/components/ui/GlobalModal.tsx +49 -0
- package/src/components/ui/IconButton.tsx +44 -0
- package/src/components/ui/Modal.tsx +19 -20
- package/src/components/ui/PageHeader.tsx +158 -0
- package/src/components/ui/Pagination.tsx +61 -0
- package/src/components/ui/PromptModal.tsx +1 -1
- package/src/components/ui/SearchInput.tsx +57 -0
- package/src/components/ui/SeoPreview.tsx +31 -0
- package/src/components/ui/SessionModal.tsx +0 -0
- package/src/components/ui/SlidePanel.tsx +2 -0
- package/src/components/ui/Toast.tsx +65 -122
- package/src/components/ui/Toaster.tsx +18 -0
- package/src/components/ui/icons.tsx +112 -0
- package/src/components/users/UserDetail.tsx +290 -0
- package/src/components/users/UserForm.tsx +242 -0
- package/src/components/users/UsersList.tsx +338 -0
- package/src/env.d.ts +13 -13
- package/src/fields/index.ts +2 -1
- package/src/global.d.ts +7 -0
- package/src/hooks/data.ts +2 -9
- package/src/hooks/useAsyncData.ts +36 -0
- package/src/hooks/useAutoFormState.ts +527 -0
- package/src/hooks/useSelection.ts +49 -0
- package/src/hooks/useSession.ts +0 -0
- package/src/index.ts +11 -1
- package/src/integration.ts +86 -11
- package/src/kyro-cms.d.ts +209 -0
- package/src/layouts/AdminLayout.astro +128 -11
- package/src/layouts/AuthLayout.astro +21 -5
- package/src/lib/api.ts +175 -55
- package/src/lib/autoform-store.ts +435 -0
- package/src/lib/config.ts +82 -34
- package/src/lib/createRegistry.ts +29 -0
- package/src/lib/default-kyro-config.ts +4 -0
- package/src/lib/globals.ts +50 -0
- package/src/lib/media-utils.ts +18 -0
- package/src/lib/object-utils.ts +77 -0
- package/src/lib/paths.ts +61 -0
- package/src/lib/stores/index.ts +370 -0
- package/src/lib/types.ts +43 -0
- package/src/lib/useResourceManager.ts +105 -0
- package/src/pages/403.astro +67 -0
- package/src/pages/[collection]/[id].astro +14 -180
- package/src/pages/[collection]/index.astro +11 -6
- package/src/pages/api-explorer.astro +173 -0
- package/src/pages/audit/index.astro +2 -0
- package/src/pages/auth/login.astro +122 -0
- package/src/pages/auth/register.astro +167 -0
- package/src/pages/graphql-explorer.astro +59 -0
- package/src/pages/{admin/graphql.astro → graphql.astro} +51 -17
- package/src/pages/index.astro +577 -0
- package/src/pages/index_ALT.astro +3 -0
- package/src/pages/keys.astro +11 -0
- package/src/pages/marketplace.astro +11 -0
- package/src/pages/media.astro +3 -0
- package/src/pages/plugins.astro +8 -0
- package/src/pages/preview/[collection]/[id].astro +188 -123
- package/src/pages/rest-playground.astro +62 -0
- package/src/pages/roles/index.astro +183 -76
- package/src/pages/sessions.astro +8 -0
- package/src/pages/settings/[slug].astro +92 -114
- package/src/pages/settings/index.astro +5 -3
- package/src/pages/users/[id].astro +25 -154
- package/src/pages/users/index.astro +19 -130
- package/src/pages/users/new.astro +9 -86
- package/src/pages/webhooks.astro +11 -0
- package/src/routes.ts +80 -0
- package/src/styles/main.css +119 -79
- package/src/theme/tokens.ts +1 -0
- package/src/vite-env.d.ts +14 -0
- package/src/collections/auth/index.ts +0 -155
- package/src/collections/portfolio/index.ts +0 -343
- package/src/components/ApiExplorer.tsx +0 -325
- package/src/components/EnhancedListView.tsx +0 -889
- package/src/components/GraphQLExplorer.tsx +0 -675
- package/src/components/Icons.tsx +0 -23
- package/src/components/StatusBadge.tsx +0 -76
- package/src/lib/MediaService.ts +0 -541
- package/src/lib/auth/sqlite-adapter.ts +0 -319
- package/src/lib/dataStore.ts +0 -226
- package/src/lib/db/adapter.ts +0 -54
- package/src/lib/db/drizzle-mysql-adapter.ts +0 -194
- package/src/lib/db/drizzle-mysql-auth-adapter.ts +0 -327
- package/src/lib/db/drizzle-postgres-adapter.ts +0 -202
- package/src/lib/db/drizzle-postgres-auth-adapter.ts +0 -304
- package/src/lib/db/drizzle-sqlite-adapter.ts +0 -227
- package/src/lib/db/drizzle-sqlite-auth-adapter.ts +0 -548
- package/src/lib/db/index.ts +0 -449
- package/src/lib/db/mongodb-adapter.ts +0 -207
- package/src/lib/db/mongodb-auth-adapter.ts +0 -305
- package/src/lib/db/schema/mysql-auth.ts +0 -113
- package/src/lib/db/schema/mysql-content.ts +0 -20
- package/src/lib/db/schema/postgres-auth.ts +0 -116
- package/src/lib/db/schema/postgres-content.ts +0 -35
- package/src/lib/db/schema/postgres-media.ts +0 -52
- package/src/lib/db/schema/postgres-settings.ts +0 -11
- package/src/lib/db/schema/sqlite-auth.ts +0 -112
- package/src/lib/db/schema/sqlite-content.ts +0 -20
- package/src/lib/db/version-adapter.ts +0 -248
- package/src/lib/graphql/index.ts +0 -1
- package/src/lib/graphql/schema.ts +0 -443
- package/src/lib/rate-limit.ts +0 -267
- package/src/lib/storage.ts +0 -374
- package/src/lib/store.ts +0 -85
- package/src/middleware.ts +0 -177
- package/src/pages/admin/api-explorer.astro +0 -98
- package/src/pages/admin/graphql-explorer.astro +0 -40
- package/src/pages/admin/index.astro +0 -286
- package/src/pages/admin/keys.astro +0 -8
- package/src/pages/admin/rest-playground.astro +0 -44
- package/src/pages/admin/webhooks.astro +0 -8
- package/src/pages/api/[collection]/[id]/publish.ts +0 -52
- package/src/pages/api/[collection]/[id]/unpublish.ts +0 -42
- package/src/pages/api/[collection]/[id]/versions.ts +0 -66
- package/src/pages/api/[collection]/[id].ts +0 -213
- package/src/pages/api/[collection]/index.ts +0 -209
- package/src/pages/api/auth/[id].ts +0 -121
- package/src/pages/api/auth/audit-logs.ts +0 -57
- package/src/pages/api/auth/login.ts +0 -211
- package/src/pages/api/auth/logout.ts +0 -66
- package/src/pages/api/auth/me.ts +0 -36
- package/src/pages/api/auth/refresh.ts +0 -119
- package/src/pages/api/auth/register.ts +0 -188
- package/src/pages/api/auth/users.ts +0 -97
- package/src/pages/api/collections.ts +0 -59
- package/src/pages/api/globals/[slug].ts +0 -42
- package/src/pages/api/graphql.ts +0 -90
- package/src/pages/api/health.ts +0 -426
- package/src/pages/api/keys/[id].ts +0 -26
- package/src/pages/api/keys/index.ts +0 -75
- package/src/pages/api/media/[id].ts +0 -309
- package/src/pages/api/media/folders.ts +0 -609
- package/src/pages/api/media/index.ts +0 -146
- package/src/pages/api/media/resize.ts +0 -267
- package/src/pages/api/search.ts +0 -82
- package/src/pages/api/slug-availability.ts +0 -70
- package/src/pages/api/storage-config.ts +0 -20
- package/src/pages/api/storage-status.ts +0 -206
- package/src/pages/api/upload.ts +0 -334
- package/src/pages/api/webhooks/index.ts +0 -71
- package/src/pages/login.astro +0 -82
- package/src/pages/register.astro +0 -102
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
import AdminLayout from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
7
|
-
import { collections } from '@/lib/config';
|
|
2
|
+
import AdminLayout from "../../../layouts/AdminLayout.astro";
|
|
3
|
+
import { renderRichText, richTextStyles } from "@kyro-cms/core/client";
|
|
4
|
+
import { collections } from "../../../lib/config";
|
|
5
|
+
|
|
6
|
+
import { adminPath, apiPath } from "../../../lib/paths";
|
|
8
7
|
|
|
9
8
|
const { collection, id } = Astro.params;
|
|
10
9
|
|
|
11
10
|
if (!collection || !collections[collection]) {
|
|
12
|
-
return Astro.redirect(
|
|
11
|
+
return Astro.redirect(adminPath);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
const config = collections[collection];
|
|
@@ -19,10 +18,13 @@ let error = null;
|
|
|
19
18
|
|
|
20
19
|
if (id) {
|
|
21
20
|
try {
|
|
22
|
-
const response = await fetch(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
const response = await fetch(
|
|
22
|
+
`${Astro.url.origin}${apiPath}/${collection}/${id}`,
|
|
23
|
+
{
|
|
24
|
+
headers: Astro.request.headers,
|
|
25
|
+
credentials: "include",
|
|
26
|
+
},
|
|
27
|
+
);
|
|
26
28
|
if (response.ok) {
|
|
27
29
|
const result = await response.json();
|
|
28
30
|
doc = result.data || null;
|
|
@@ -30,34 +32,53 @@ if (id) {
|
|
|
30
32
|
error = `Failed to load document: ${response.status}`;
|
|
31
33
|
}
|
|
32
34
|
} catch (e) {
|
|
33
|
-
error =
|
|
35
|
+
error = "Failed to fetch document";
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
const title = doc
|
|
39
|
+
const title = doc
|
|
40
|
+
? `Preview: ${doc.title || doc.name || doc.slug || id}`
|
|
41
|
+
: "Preview";
|
|
38
42
|
---
|
|
39
43
|
|
|
40
44
|
<AdminLayout title={title}>
|
|
41
45
|
<Fragment set:html={`<style>${richTextStyles}</style>`} />
|
|
42
|
-
<div class="flex-1 overflow-y-auto
|
|
46
|
+
<div class="flex-1 overflow-y-auto space-y-6">
|
|
43
47
|
<div class="surface-tile p-6 flex items-center justify-between">
|
|
44
48
|
<div class="flex items-center gap-4">
|
|
45
49
|
<a
|
|
46
|
-
href={
|
|
50
|
+
href={`${adminPath}/${collection}/${id}`}
|
|
47
51
|
class="inline-flex items-center justify-center w-10 h-10 rounded-xl border border-[var(--kyro-border)] text-[var(--kyro-text-secondary)] hover:text-[var(--kyro-text-primary)] hover:bg-[var(--kyro-surface-accent)] transition-colors"
|
|
48
52
|
>
|
|
49
|
-
<svg
|
|
50
|
-
|
|
53
|
+
<svg
|
|
54
|
+
class="w-4 h-4"
|
|
55
|
+
fill="none"
|
|
56
|
+
stroke="currentColor"
|
|
57
|
+
viewBox="0 0 24 24"
|
|
58
|
+
>
|
|
59
|
+
<path
|
|
60
|
+
stroke-linecap="round"
|
|
61
|
+
stroke-linejoin="round"
|
|
62
|
+
stroke-width="2.5"
|
|
63
|
+
d="M15 19l-7-7 7-7"></path>
|
|
51
64
|
</svg>
|
|
52
65
|
</a>
|
|
53
66
|
<div>
|
|
54
|
-
<h1
|
|
55
|
-
|
|
67
|
+
<h1
|
|
68
|
+
class="text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]"
|
|
69
|
+
>
|
|
70
|
+
Preview Mode
|
|
71
|
+
</h1>
|
|
72
|
+
<p class="text-sm text-[var(--kyro-text-secondary)] mt-0.5">
|
|
73
|
+
Showing draft content
|
|
74
|
+
</p>
|
|
56
75
|
</div>
|
|
57
76
|
</div>
|
|
58
77
|
<div class="flex items-center gap-3">
|
|
59
|
-
<span
|
|
60
|
-
|
|
78
|
+
<span
|
|
79
|
+
class="px-3 py-1.5 bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-secondary)] text-xs font-bold rounded-lg border border-[var(--kyro-border)]"
|
|
80
|
+
>
|
|
81
|
+
{doc?.status || "draft"}
|
|
61
82
|
</span>
|
|
62
83
|
<a
|
|
63
84
|
href={`/${collection}/${id}`}
|
|
@@ -68,111 +89,155 @@ const title = doc ? `Preview: ${doc.title || doc.name || doc.slug || id}` : 'Pre
|
|
|
68
89
|
</div>
|
|
69
90
|
</div>
|
|
70
91
|
|
|
71
|
-
{
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
{
|
|
93
|
+
error && (
|
|
94
|
+
<div class="surface-tile p-6 border border-red-500/30 bg-red-500/10">
|
|
95
|
+
<p class="text-red-400">{error}</p>
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
76
99
|
|
|
77
|
-
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
{
|
|
101
|
+
doc && (
|
|
102
|
+
<div class="space-y-6">
|
|
103
|
+
{config.fields.map((field: any) => {
|
|
104
|
+
const value = doc[field.name];
|
|
105
|
+
if (value === undefined || value === null) return null;
|
|
82
106
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{value.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
107
|
+
return (
|
|
108
|
+
<div class="surface-tile p-6">
|
|
109
|
+
<h3 class="text-xs font-bold text-[var(--kyro-text-muted)] tracking-[0.15em] mb-3">
|
|
110
|
+
{field.label || field.name}
|
|
111
|
+
</h3>
|
|
112
|
+
<div class="text-sm text-[var(--kyro-text-primary)]">
|
|
113
|
+
{field.type === "text" && (
|
|
114
|
+
<p class="whitespace-pre-wrap">{value}</p>
|
|
115
|
+
)}
|
|
116
|
+
{field.type === "textarea" && (
|
|
117
|
+
<p class="whitespace-pre-wrap">{value}</p>
|
|
118
|
+
)}
|
|
119
|
+
{field.type === "richtext" && (
|
|
120
|
+
<div set:html={renderRichText(value)} />
|
|
121
|
+
)}
|
|
122
|
+
{field.type === "markdown" && (
|
|
123
|
+
<div class="prose prose-sm max-w-none">
|
|
124
|
+
<pre class="whitespace-pre-wrap bg-transparent p-0">
|
|
125
|
+
{value}
|
|
126
|
+
</pre>
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
{field.type === "number" && <p>{value}</p>}
|
|
130
|
+
{field.type === "boolean" && (
|
|
131
|
+
<span class={value ? "text-green-400" : "text-red-400"}>
|
|
132
|
+
{value ? "Yes" : "No"}
|
|
133
|
+
</span>
|
|
134
|
+
)}
|
|
135
|
+
{field.type === "select" && (
|
|
136
|
+
<span class="px-2 py-1 bg-[var(--kyro-surface-accent)] rounded text-xs">
|
|
137
|
+
{value}
|
|
138
|
+
</span>
|
|
139
|
+
)}
|
|
140
|
+
{field.type === "date" && (
|
|
141
|
+
<p>{new Date(value).toLocaleString()}</p>
|
|
142
|
+
)}
|
|
143
|
+
{field.type === "upload" && value.url && (
|
|
144
|
+
<div>
|
|
145
|
+
{value.url.match(
|
|
146
|
+
/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i,
|
|
147
|
+
) ? (
|
|
148
|
+
<img
|
|
149
|
+
src={value.url}
|
|
150
|
+
alt={value.filename || "Image"}
|
|
151
|
+
class="max-w-md rounded-lg border border-[var(--kyro-border)]"
|
|
152
|
+
/>
|
|
153
|
+
) : (
|
|
154
|
+
<a
|
|
155
|
+
href={value.url}
|
|
156
|
+
class="text-blue-400 hover:underline"
|
|
157
|
+
>
|
|
158
|
+
{value.filename || "Download"}
|
|
159
|
+
</a>
|
|
160
|
+
)}
|
|
161
|
+
</div>
|
|
162
|
+
)}
|
|
163
|
+
{field.type === "gallery" && Array.isArray(value) && (
|
|
164
|
+
<div class="grid grid-cols-4 gap-3">
|
|
165
|
+
{value.map((item: any, idx: number) =>
|
|
166
|
+
item?.url ? (
|
|
167
|
+
item.url.match(
|
|
168
|
+
/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i,
|
|
169
|
+
) ? (
|
|
170
|
+
<img
|
|
171
|
+
src={item.url}
|
|
172
|
+
alt={item.filename || `Image ${idx + 1}`}
|
|
173
|
+
class="w-full h-24 object-cover rounded-lg border border-[var(--kyro-border)]"
|
|
174
|
+
/>
|
|
175
|
+
) : (
|
|
176
|
+
<div class="h-24 flex items-center justify-center bg-[var(--kyro-surface-accent)] rounded-lg border border-[var(--kyro-border)] text-xs">
|
|
177
|
+
{item.filename || "File"}
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
180
|
+
) : null,
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
)}
|
|
184
|
+
{field.type === "array" && Array.isArray(value) && (
|
|
185
|
+
<div class="space-y-2">
|
|
186
|
+
{value.map((item: any) => (
|
|
187
|
+
<div class="p-3 bg-[var(--kyro-surface-accent)] rounded border border-[var(--kyro-border)] text-xs">
|
|
188
|
+
{Object.entries(item)
|
|
189
|
+
.filter(([, v]) => v !== undefined)
|
|
190
|
+
.map(([k, v]) => (
|
|
191
|
+
<div class="flex gap-2">
|
|
192
|
+
<span class="text-[var(--kyro-text-muted)]">
|
|
193
|
+
{k}:
|
|
194
|
+
</span>
|
|
195
|
+
<span>
|
|
196
|
+
{typeof v === "object"
|
|
197
|
+
? JSON.stringify(v)
|
|
198
|
+
: String(v)}
|
|
199
|
+
</span>
|
|
200
|
+
</div>
|
|
201
|
+
))}
|
|
202
|
+
</div>
|
|
203
|
+
))}
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
{field.type === "relationship" && (
|
|
207
|
+
<p class="text-[var(--kyro-text-secondary)]">
|
|
208
|
+
{value.title ||
|
|
209
|
+
value.name ||
|
|
210
|
+
value.slug ||
|
|
211
|
+
JSON.stringify(value)}
|
|
212
|
+
</p>
|
|
213
|
+
)}
|
|
214
|
+
{field.type === "json" && (
|
|
215
|
+
<pre class="text-xs bg-[var(--kyro-surface-accent)] p-3 rounded overflow-x-auto">
|
|
216
|
+
{JSON.stringify(value, null, 2)}
|
|
217
|
+
</pre>
|
|
218
|
+
)}
|
|
219
|
+
{field.type === "code" && (
|
|
220
|
+
<pre class="text-xs bg-[var(--kyro-surface-accent)] p-3 rounded overflow-x-auto">
|
|
221
|
+
{value}
|
|
222
|
+
</pre>
|
|
223
|
+
)}
|
|
224
|
+
{(!field.type || ["text", "string"].includes(field.type)) && (
|
|
225
|
+
<p>{value}</p>
|
|
226
|
+
)}
|
|
227
|
+
</div>
|
|
165
228
|
</div>
|
|
166
|
-
|
|
167
|
-
)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
229
|
+
);
|
|
230
|
+
})}
|
|
231
|
+
</div>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
171
234
|
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
235
|
+
{
|
|
236
|
+
!doc && !error && (
|
|
237
|
+
<div class="surface-tile p-6">
|
|
238
|
+
<p class="text-[var(--kyro-text-muted)]">Document not found</p>
|
|
239
|
+
</div>
|
|
240
|
+
)
|
|
241
|
+
}
|
|
177
242
|
</div>
|
|
178
243
|
</AdminLayout>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
import AdminLayout from "../layouts/AdminLayout.astro";
|
|
3
|
+
import { RestPlayground } from "../components/RestPlayground";
|
|
4
|
+
|
|
5
|
+
import { adminPath, apiPath } from "../lib/paths";
|
|
6
|
+
|
|
7
|
+
const collectionsResponse = await fetch(
|
|
8
|
+
`${Astro.url.origin}${apiPath}/collections`,
|
|
9
|
+
);
|
|
10
|
+
const collectionsData = await collectionsResponse.json();
|
|
11
|
+
const collections = collectionsData.collections || [];
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<AdminLayout title="REST Playground">
|
|
15
|
+
<div class="flex-1 overflow-hidden">
|
|
16
|
+
<!-- Header -->
|
|
17
|
+
<div class="mb-6 surface-tile">
|
|
18
|
+
<div class="flex items-center justify-between mb-4">
|
|
19
|
+
<div>
|
|
20
|
+
<h1
|
|
21
|
+
class="text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]"
|
|
22
|
+
>
|
|
23
|
+
REST Playground
|
|
24
|
+
</h1>
|
|
25
|
+
<p
|
|
26
|
+
class="text-[var(--kyro-text-secondary)] font-bold mt-2 text-sm tracking-wider"
|
|
27
|
+
>
|
|
28
|
+
Saved collections, history, and environment variables
|
|
29
|
+
</p>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="flex items-center gap-4">
|
|
32
|
+
<a
|
|
33
|
+
href={`${adminPath}/api-explorer`}
|
|
34
|
+
class="flex items-center gap-2 px-4 py-2 bg-[var(--kyro-surface-accent)] text-[var(--kyro-text-primary)] rounded-lg font-bold text-sm hover:bg-[var(--kyro-surface)] transition-all border border-[var(--kyro-border)]"
|
|
35
|
+
>
|
|
36
|
+
<svg
|
|
37
|
+
class="w-4 h-4"
|
|
38
|
+
fill="none"
|
|
39
|
+
stroke="currentColor"
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
>
|
|
42
|
+
<path
|
|
43
|
+
stroke-linecap="round"
|
|
44
|
+
stroke-linejoin="round"
|
|
45
|
+
stroke-width="2"
|
|
46
|
+
d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
47
|
+
></path>
|
|
48
|
+
</svg>
|
|
49
|
+
Explorer
|
|
50
|
+
</a>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<!-- Playground Container -->
|
|
56
|
+
<div class="h-[calc(100vh-200px)] surface-tile overflow-hidden">
|
|
57
|
+
<div class="surface-tile h-full overflow-hidden">
|
|
58
|
+
<RestPlayground client:load collections={collections} />
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</AdminLayout>
|