openadminjs 0.1.7 → 0.1.9
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 +114 -18
- package/dist/create-project.js +27 -4
- package/dist/create-project.test.js +57 -41
- package/dist/index.js +16 -5
- package/package.json +4 -2
- package/template/.env.example +2 -2
- package/template/README.md +24 -5
- package/template/apps/admin/app/api/auth/login/route.ts +51 -0
- package/template/apps/admin/app/api/auth/logout/route.ts +11 -0
- package/template/apps/admin/app/api/auth/refresh/route.ts +46 -0
- package/template/apps/admin/app/api-tokens/page.tsx +253 -0
- package/template/apps/admin/app/audit-logs/page.tsx +5 -0
- package/template/apps/admin/app/dashboard/page.tsx +392 -0
- package/template/apps/admin/app/files/page.tsx +5 -0
- package/template/apps/admin/app/globals.css +206 -0
- package/template/apps/admin/app/jobs/page.tsx +19 -0
- package/template/apps/admin/app/layout.tsx +57 -0
- package/template/apps/admin/app/login/page.test.tsx +18 -0
- package/template/apps/admin/app/login/page.tsx +161 -0
- package/template/apps/admin/app/login/safe-next-param.ts +4 -0
- package/template/apps/admin/app/notifications/page.tsx +146 -0
- package/template/apps/admin/app/page.tsx +5 -0
- package/template/apps/admin/app/plugins/page.tsx +407 -0
- package/template/apps/admin/app/profile/page.tsx +116 -0
- package/template/apps/admin/app/resources/[resource]/[id]/edit/page.tsx +45 -0
- package/template/apps/admin/app/resources/[resource]/[id]/page.tsx +449 -0
- package/template/apps/admin/app/resources/[resource]/create/page.tsx +34 -0
- package/template/apps/admin/app/resources/[resource]/page.tsx +100 -0
- package/template/apps/admin/app/settings/page.tsx +233 -0
- package/template/apps/admin/components/ai-assistant-widget.tsx +684 -0
- package/template/apps/admin/components/app-shell.tsx +305 -0
- package/template/apps/admin/components/auth-guard.test.tsx +55 -0
- package/template/apps/admin/components/auth-guard.tsx +39 -0
- package/template/apps/admin/components/jobs-panel.tsx +103 -0
- package/template/apps/admin/components/logo.tsx +30 -0
- package/template/apps/admin/components/resource-form.tsx +349 -0
- package/template/apps/admin/components/resource-table.tsx +277 -0
- package/template/apps/admin/lib/ai-events.ts +23 -0
- package/template/apps/admin/lib/api.test.ts +118 -0
- package/template/apps/admin/lib/api.ts +135 -0
- package/template/apps/admin/lib/auth-flow.e2e.test.ts +79 -0
- package/template/apps/admin/lib/brand.ts +14 -0
- package/template/apps/admin/lib/locale.ts +49 -0
- package/template/apps/admin/lib/tokens.ts +93 -0
- package/template/apps/admin/middleware.ts +58 -0
- package/template/apps/admin/next-env.d.ts +6 -0
- package/template/apps/admin/next.config.mjs +7 -0
- package/template/apps/admin/package.json +44 -0
- package/template/apps/admin/postcss.config.mjs +6 -0
- package/template/apps/admin/public/brand/apple-touch-icon.png +0 -0
- package/template/apps/admin/public/brand/favicon.svg +1 -0
- package/template/apps/admin/public/brand/og-image.png +0 -0
- package/template/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
- package/template/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/template/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
- package/template/apps/admin/tailwind.config.ts +37 -0
- package/template/apps/admin/tsconfig.json +23 -0
- package/template/apps/admin/vitest.config.ts +7 -0
- package/template/apps/api/package.json +56 -0
- package/template/apps/api/plugins.manifest.example.json +34 -0
- package/template/apps/api/plugins.manifest.json +4 -0
- package/template/apps/api/src/access/catalog.ts +112 -0
- package/template/apps/api/src/access/derive-permissions.test.ts +26 -0
- package/template/apps/api/src/access/derive-permissions.ts +36 -0
- package/template/apps/api/src/access/public-catalog.ts +28 -0
- package/template/apps/api/src/admin/admin-ai.controller.ts +125 -0
- package/template/apps/api/src/admin/admin-ai.events.ts +23 -0
- package/template/apps/api/src/admin/admin-ai.service.ts +1271 -0
- package/template/apps/api/src/admin/admin-analytics.service.ts +164 -0
- package/template/apps/api/src/admin/admin-plugins.controller.ts +32 -0
- package/template/apps/api/src/admin/admin-plugins.service.ts +267 -0
- package/template/apps/api/src/admin/admin-resource.service.test.ts +118 -0
- package/template/apps/api/src/admin/admin-resource.service.ts +375 -0
- package/template/apps/api/src/admin/admin.controller.ts +72 -0
- package/template/apps/api/src/admin/admin.module.ts +30 -0
- package/template/apps/api/src/admin/dto/plugins.dto.ts +55 -0
- package/template/apps/api/src/admin/validate-resource-payload.test.ts +44 -0
- package/template/apps/api/src/admin/validate-resource-payload.ts +103 -0
- package/template/apps/api/src/app.module.ts +45 -0
- package/template/apps/api/src/auth/auth.controller.ts +70 -0
- package/template/apps/api/src/auth/auth.dto.ts +49 -0
- package/template/apps/api/src/auth/auth.module.ts +30 -0
- package/template/apps/api/src/auth/auth.service.test.ts +75 -0
- package/template/apps/api/src/auth/auth.service.ts +231 -0
- package/template/apps/api/src/common/auth-realm.decorator.ts +6 -0
- package/template/apps/api/src/common/auth.guard.test.ts +61 -0
- package/template/apps/api/src/common/auth.guard.ts +78 -0
- package/template/apps/api/src/common/casl-ability.factory.test.ts +33 -0
- package/template/apps/api/src/common/casl-ability.factory.ts +41 -0
- package/template/apps/api/src/common/current-user.decorator.ts +6 -0
- package/template/apps/api/src/common/permission.decorator.ts +7 -0
- package/template/apps/api/src/common/permissions.guard.ts +31 -0
- package/template/apps/api/src/common/prisma.service.ts +13 -0
- package/template/apps/api/src/health/health.controller.ts +25 -0
- package/template/apps/api/src/mail/mail.module.ts +9 -0
- package/template/apps/api/src/mail/mail.service.ts +115 -0
- package/template/apps/api/src/main.ts +37 -0
- package/template/apps/api/src/plugins/bootstrap.ts +4 -0
- package/template/apps/api/src/plugins/bundled/admin-widget.plugin.ts +25 -0
- package/template/apps/api/src/plugins/bundled/hello.plugin.ts +19 -0
- package/template/apps/api/src/plugins/bundled/image-optimizer.plugin.ts +22 -0
- package/template/apps/api/src/plugins/bundled/registry.ts +13 -0
- package/template/apps/api/src/plugins/bundled/seo.plugin.ts +25 -0
- package/template/apps/api/src/plugins/manifest-path.ts +35 -0
- package/template/apps/api/src/plugins/manifest.schema.test.ts +36 -0
- package/template/apps/api/src/plugins/manifest.schema.ts +58 -0
- package/template/apps/api/src/plugins/plugin-api.interceptor.ts +47 -0
- package/template/apps/api/src/plugins/plugin-loader.ts +134 -0
- package/template/apps/api/src/plugins/plugin-runtime.test.ts +24 -0
- package/template/apps/api/src/plugins/plugin-runtime.ts +85 -0
- package/template/apps/api/src/queue/queue.controller.ts +28 -0
- package/template/apps/api/src/queue/queue.module.ts +23 -0
- package/template/apps/api/src/queue/queue.processor.ts +47 -0
- package/template/apps/api/src/queue/queue.service.ts +50 -0
- package/template/apps/api/src/resources/categories.resource.ts +21 -0
- package/template/apps/api/src/resources/commerce.resource.ts +157 -0
- package/template/apps/api/src/resources/operations.resource.ts +111 -0
- package/template/apps/api/src/resources/posts.resource.ts +88 -0
- package/template/apps/api/src/resources/registry.ts +27 -0
- package/template/apps/api/src/resources/resource-hooks.install.ts +18 -0
- package/template/apps/api/src/resources/resource-hooks.registry.test.ts +72 -0
- package/template/apps/api/src/resources/resource-hooks.registry.ts +66 -0
- package/template/apps/api/src/resources/resource-hooks.runner.ts +93 -0
- package/template/apps/api/src/resources/system.resource.ts +51 -0
- package/template/apps/api/src/resources/users.resource.ts +19 -0
- package/template/apps/api/src/store/payment/payment.controller.ts +98 -0
- package/template/apps/api/src/store/payment/payment.module.ts +14 -0
- package/template/apps/api/src/store/payment/payment.provider.ts +38 -0
- package/template/apps/api/src/store/payment/payment.service.ts +235 -0
- package/template/apps/api/src/store/store.controller.ts +26 -0
- package/template/apps/api/src/store/store.module.ts +12 -0
- package/template/apps/api/src/test-setup.ts +1 -0
- package/template/apps/api/tsconfig.json +11 -0
- package/template/apps/api/vitest.config.ts +21 -0
- package/template/apps/web/lib/openadmin-client.ts +11 -0
- package/template/apps/web/lib/seo.test.ts +41 -0
- package/template/apps/web/lib/seo.ts +24 -13
- package/template/apps/web/next-env.d.ts +4 -0
- package/template/apps/web/package.json +2 -1
- package/template/apps/web/test/next-stub.ts +7 -0
- package/template/apps/web/vitest.config.ts +19 -0
- package/template/package.json +18 -11
- package/template/packages/auth/package.json +17 -0
- package/template/packages/auth/src/index.test.ts +10 -0
- package/template/packages/auth/src/index.ts +17 -0
- package/template/packages/auth/tsconfig.json +8 -0
- package/template/packages/brand/apps/admin/public/brand/apple-touch-icon.png +0 -0
- package/template/packages/brand/apps/admin/public/brand/favicon.svg +1 -0
- package/template/packages/brand/apps/admin/public/brand/og-image.png +0 -0
- package/template/packages/brand/apps/admin/public/brand/openadminjs-icon-new.png +0 -0
- package/template/packages/brand/apps/admin/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/template/packages/brand/apps/admin/public/brand/openadminjs-logo-new.png +0 -0
- package/template/packages/brand/apps/web/public/brand/apple-touch-icon.png +0 -0
- package/template/packages/brand/apps/web/public/brand/favicon.svg +1 -0
- package/template/packages/brand/apps/web/public/brand/og-image.png +0 -0
- package/template/packages/brand/apps/web/public/brand/openadminjs-icon-new.png +0 -0
- package/template/packages/brand/apps/web/public/brand/openadminjs-logo-monochrome.png +0 -0
- package/template/packages/brand/apps/web/public/brand/openadminjs-logo-new.png +0 -0
- package/template/packages/brand/package.json +19 -0
- package/template/packages/brand/site/assets/brand/favicon.svg +1 -0
- package/template/packages/brand/site/assets/brand/og-image.svg +1 -0
- package/template/packages/brand/site/assets/brand/openadminjs-icon.svg +1 -0
- package/template/packages/brand/site/assets/brand/openadminjs-logo-dark.svg +1 -0
- package/template/packages/brand/site/assets/brand/openadminjs-logo-horizontal.svg +1 -0
- package/template/packages/brand/site/assets/brand/openadminjs-logo-monochrome.svg +1 -0
- package/template/packages/brand/site/assets/brand/openadminjs-logo.svg +1 -0
- package/template/packages/brand/src/generate-assets.mjs +182 -0
- package/template/packages/brand/src/index.test.ts +9 -0
- package/template/packages/brand/src/index.ts +7 -0
- package/template/packages/brand/tsconfig.json +7 -0
- package/template/packages/core/package.json +20 -0
- package/template/packages/core/src/index.js +1 -0
- package/template/packages/core/src/index.test.ts +27 -0
- package/template/packages/core/src/index.ts +61 -0
- package/template/packages/core/tsconfig.json +8 -0
- package/template/packages/mail/package.json +18 -0
- package/template/packages/mail/src/index.test.ts +23 -0
- package/template/packages/mail/src/index.ts +246 -0
- package/template/packages/mail/tsconfig.json +5 -0
- package/template/packages/notifications/package.json +16 -0
- package/template/packages/notifications/src/index.test.ts +9 -0
- package/template/packages/notifications/src/index.ts +5 -0
- package/template/packages/notifications/tsconfig.json +5 -0
- package/template/packages/payments/package.json +15 -0
- package/template/packages/payments/src/index.ts +256 -0
- package/template/packages/payments/tsconfig.json +9 -0
- package/template/packages/permissions/package.json +17 -0
- package/template/packages/permissions/src/blueprints.js +57 -0
- package/template/packages/permissions/src/blueprints.test.ts +62 -0
- package/template/packages/permissions/src/blueprints.ts +89 -0
- package/template/packages/permissions/src/index.js +11 -0
- package/template/packages/permissions/src/index.test.ts +34 -0
- package/template/packages/permissions/src/index.ts +22 -0
- package/template/packages/permissions/tsconfig.json +8 -0
- package/template/packages/plugin-sdk/package.json +26 -0
- package/template/packages/plugin-sdk/src/hooks.ts +135 -0
- package/template/packages/plugin-sdk/src/index.ts +42 -0
- package/template/packages/plugin-sdk/src/sdk.test.ts +13 -0
- package/template/packages/plugin-sdk/tsconfig.json +8 -0
- package/template/packages/plugin-sdk/vitest.config.ts +5 -0
- package/template/packages/queue/package.json +16 -0
- package/template/packages/queue/src/index.test.ts +12 -0
- package/template/packages/queue/src/index.ts +6 -0
- package/template/packages/queue/tsconfig.json +5 -0
- package/template/packages/resource/package.json +17 -0
- package/template/packages/resource/src/index.js +177 -0
- package/template/packages/resource/src/index.test.ts +151 -0
- package/template/packages/resource/src/index.ts +344 -0
- package/template/packages/resource/tsconfig.json +8 -0
- package/template/packages/storage/package.json +16 -0
- package/template/packages/storage/src/index.test.ts +10 -0
- package/template/packages/storage/src/index.ts +23 -0
- package/template/packages/storage/tsconfig.json +5 -0
- package/template/prisma/migrations/20260505151751_baseline_init_all_tables/migration.sql +371 -0
- package/template/prisma/migrations/migration_lock.toml +3 -0
- package/template/prisma/schema.prisma +291 -0
- package/template/prisma/seed.ts +217 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
@layer base {
|
|
6
|
+
:root {
|
|
7
|
+
--brand-blue: #2454ff;
|
|
8
|
+
--brand-blue-hover: #1a3dcc;
|
|
9
|
+
--brand-blue-soft: #eef3ff;
|
|
10
|
+
--brand-teal: #0ea5a4;
|
|
11
|
+
--brand-teal-soft: #e9fbfa;
|
|
12
|
+
--admin-ink: #0f172a;
|
|
13
|
+
--admin-muted: #64748b;
|
|
14
|
+
--admin-line: #e2e8f0;
|
|
15
|
+
--admin-surface: #ffffff;
|
|
16
|
+
--admin-bg: #f8fafc;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
html {
|
|
20
|
+
-webkit-font-smoothing: antialiased;
|
|
21
|
+
-moz-osx-font-smoothing: grayscale;
|
|
22
|
+
text-rendering: optimizeLegibility;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
background: var(--admin-bg);
|
|
27
|
+
color: var(--admin-ink);
|
|
28
|
+
letter-spacing: -0.012em;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
::-webkit-scrollbar {
|
|
32
|
+
width: 6px;
|
|
33
|
+
height: 6px;
|
|
34
|
+
}
|
|
35
|
+
::-webkit-scrollbar-track {
|
|
36
|
+
background: transparent;
|
|
37
|
+
}
|
|
38
|
+
::-webkit-scrollbar-thumb {
|
|
39
|
+
background: #cbd5e1;
|
|
40
|
+
border-radius: 999px;
|
|
41
|
+
}
|
|
42
|
+
::-webkit-scrollbar-thumb:hover {
|
|
43
|
+
background: #94a3b8;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
*:focus-visible {
|
|
47
|
+
outline: 2px solid var(--brand-blue);
|
|
48
|
+
outline-offset: 2px;
|
|
49
|
+
border-radius: 8px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@layer components {
|
|
54
|
+
/* Card with hover lift */
|
|
55
|
+
.card {
|
|
56
|
+
@apply rounded-2xl border border-slate-200 bg-white;
|
|
57
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
|
|
58
|
+
transition: box-shadow 0.2s ease, transform 0.2s ease;
|
|
59
|
+
}
|
|
60
|
+
.card-hover:hover {
|
|
61
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06), 0 16px 40px rgba(0, 0, 0, 0.08);
|
|
62
|
+
transform: translateY(-2px);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Primary button */
|
|
66
|
+
.btn-primary {
|
|
67
|
+
@apply inline-flex items-center justify-center gap-2 rounded-xl bg-[#2454ff] px-4 py-2.5 text-sm font-semibold text-white;
|
|
68
|
+
box-shadow: 0 4px 14px rgba(36, 84, 255, 0.28);
|
|
69
|
+
transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
|
|
70
|
+
}
|
|
71
|
+
.btn-primary:hover:not(:disabled) {
|
|
72
|
+
background: #1a3dcc;
|
|
73
|
+
box-shadow: 0 6px 20px rgba(36, 84, 255, 0.4);
|
|
74
|
+
transform: translateY(-1px);
|
|
75
|
+
}
|
|
76
|
+
.btn-primary:active:not(:disabled) {
|
|
77
|
+
transform: translateY(0);
|
|
78
|
+
}
|
|
79
|
+
.btn-primary:disabled {
|
|
80
|
+
@apply cursor-not-allowed opacity-60;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Ghost button */
|
|
84
|
+
.btn-ghost {
|
|
85
|
+
@apply inline-flex items-center justify-center gap-2 rounded-xl border border-slate-200 bg-white px-4 py-2.5 text-sm font-medium text-slate-600;
|
|
86
|
+
transition: border-color 0.15s ease, background 0.15s ease;
|
|
87
|
+
}
|
|
88
|
+
.btn-ghost:hover {
|
|
89
|
+
@apply border-slate-300 bg-slate-50;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Input */
|
|
93
|
+
.input-base {
|
|
94
|
+
@apply w-full rounded-xl border border-slate-200 bg-slate-50 px-3.5 py-2.5 text-sm text-slate-900 outline-none;
|
|
95
|
+
transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
|
|
96
|
+
}
|
|
97
|
+
.input-base:hover {
|
|
98
|
+
@apply border-slate-300;
|
|
99
|
+
}
|
|
100
|
+
.input-base:focus {
|
|
101
|
+
@apply border-[#2454ff] bg-white;
|
|
102
|
+
box-shadow: 0 0 0 3px rgba(36, 84, 255, 0.12);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Badges */
|
|
106
|
+
.badge {
|
|
107
|
+
@apply inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-semibold;
|
|
108
|
+
}
|
|
109
|
+
.badge-blue { @apply bg-blue-50 text-blue-700; }
|
|
110
|
+
.badge-teal { @apply bg-teal-50 text-teal-700; }
|
|
111
|
+
.badge-green { @apply bg-emerald-50 text-emerald-700; }
|
|
112
|
+
.badge-yellow { @apply bg-yellow-50 text-yellow-700; }
|
|
113
|
+
.badge-red { @apply bg-red-50 text-red-700; }
|
|
114
|
+
.badge-slate { @apply bg-slate-100 text-slate-600; }
|
|
115
|
+
|
|
116
|
+
/* Skeleton shimmer */
|
|
117
|
+
.skeleton {
|
|
118
|
+
background: linear-gradient(90deg, #f1f5f9 25%, #e8edf4 50%, #f1f5f9 75%);
|
|
119
|
+
background-size: 200% 100%;
|
|
120
|
+
animation: shimmer 1.6s ease-in-out infinite;
|
|
121
|
+
@apply rounded-md;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@layer utilities {
|
|
126
|
+
/* Entrance animations */
|
|
127
|
+
.animate-in {
|
|
128
|
+
animation: fadeUp 0.35s ease both;
|
|
129
|
+
}
|
|
130
|
+
.stagger-1 { animation-delay: 0ms; }
|
|
131
|
+
.stagger-2 { animation-delay: 60ms; }
|
|
132
|
+
.stagger-3 { animation-delay: 120ms; }
|
|
133
|
+
.stagger-4 { animation-delay: 180ms; }
|
|
134
|
+
.stagger-5 { animation-delay: 240ms; }
|
|
135
|
+
.stagger-6 { animation-delay: 300ms; }
|
|
136
|
+
.stagger-7 { animation-delay: 360ms; }
|
|
137
|
+
.stagger-8 { animation-delay: 420ms; }
|
|
138
|
+
|
|
139
|
+
.fade-in {
|
|
140
|
+
animation: fadeIn 0.25s ease both;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@keyframes fadeUp {
|
|
145
|
+
from { opacity: 0; transform: translateY(12px); }
|
|
146
|
+
to { opacity: 1; transform: translateY(0); }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@keyframes fadeIn {
|
|
150
|
+
from { opacity: 0; }
|
|
151
|
+
to { opacity: 1; }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@keyframes shimmer {
|
|
155
|
+
0% { background-position: 200% 0; }
|
|
156
|
+
100% { background-position: -200% 0; }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* Dark mode CSS custom properties */
|
|
160
|
+
.dark {
|
|
161
|
+
--brand-blue-soft: #1e2a4a;
|
|
162
|
+
--brand-teal-soft: #0d2b2b;
|
|
163
|
+
--admin-ink: #f1f5f9;
|
|
164
|
+
--admin-muted: #94a3b8;
|
|
165
|
+
--admin-line: #1e293b;
|
|
166
|
+
--admin-surface: #0f172a;
|
|
167
|
+
--admin-bg: #0a0f1e;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.dark body {
|
|
171
|
+
background: var(--admin-bg);
|
|
172
|
+
color: var(--admin-ink);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.dark ::-webkit-scrollbar-thumb {
|
|
176
|
+
background: #334155;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/* Dark mode card & input overrides */
|
|
180
|
+
.dark .card {
|
|
181
|
+
@apply border-slate-700/60 bg-slate-900;
|
|
182
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.25);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.dark .input-base {
|
|
186
|
+
@apply border-slate-700 bg-slate-800 text-slate-100;
|
|
187
|
+
}
|
|
188
|
+
.dark .input-base:hover {
|
|
189
|
+
@apply border-slate-600;
|
|
190
|
+
}
|
|
191
|
+
.dark .input-base:focus {
|
|
192
|
+
@apply border-[#2454ff] bg-slate-800;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.dark .btn-ghost {
|
|
196
|
+
@apply border-slate-700 bg-slate-800 text-slate-300;
|
|
197
|
+
}
|
|
198
|
+
.dark .btn-ghost:hover {
|
|
199
|
+
@apply border-slate-600 bg-slate-700;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Dark skeleton */
|
|
203
|
+
.dark .skeleton {
|
|
204
|
+
background: linear-gradient(90deg, #1e293b 25%, #2d3f55 50%, #1e293b 75%);
|
|
205
|
+
background-size: 200% 100%;
|
|
206
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AppShell } from "../../components/app-shell";
|
|
2
|
+
import { JobsPanel } from "../../components/jobs-panel";
|
|
3
|
+
|
|
4
|
+
export default function JobsPage() {
|
|
5
|
+
return (
|
|
6
|
+
<AppShell>
|
|
7
|
+
<div className="space-y-5">
|
|
8
|
+
<div>
|
|
9
|
+
<p className="text-xs font-bold uppercase tracking-wide text-[#0b8585]">Queue runtime</p>
|
|
10
|
+
<h1 className="mt-1 text-3xl font-bold tracking-normal text-[#24324b]">Jobs</h1>
|
|
11
|
+
<p className="text-sm text-[#637083]">Dispatch and monitor background processing through BullMQ.</p>
|
|
12
|
+
</div>
|
|
13
|
+
<div className="rounded-2xl border border-[#e4e8f0] bg-white p-6 shadow-[0_12px_34px_rgba(36,50,75,0.07)] dark:border-zinc-800 dark:bg-zinc-950">
|
|
14
|
+
<JobsPanel />
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</AppShell>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Metadata } from "next";
|
|
2
|
+
import { Inter } from "next/font/google";
|
|
3
|
+
import { ThemeProvider } from "next-themes";
|
|
4
|
+
import { AuthGuard } from "../components/auth-guard";
|
|
5
|
+
import { BRAND } from "../lib/brand";
|
|
6
|
+
import "./globals.css";
|
|
7
|
+
|
|
8
|
+
const inter = Inter({
|
|
9
|
+
subsets: ["latin", "cyrillic"],
|
|
10
|
+
variable: "--font-inter",
|
|
11
|
+
display: "swap"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function resolveMetadataBase(): URL {
|
|
15
|
+
const origin = process.env.ADMIN_ORIGIN ?? "http://localhost:3000";
|
|
16
|
+
try {
|
|
17
|
+
return new URL(origin);
|
|
18
|
+
} catch {
|
|
19
|
+
return new URL("http://localhost:3000");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const metadata: Metadata = {
|
|
24
|
+
metadataBase: resolveMetadataBase(),
|
|
25
|
+
title: "OpenAdminJS Admin",
|
|
26
|
+
description: "Resource-driven admin panel",
|
|
27
|
+
icons: {
|
|
28
|
+
icon: [
|
|
29
|
+
{ url: BRAND.favicon, type: "image/svg+xml" },
|
|
30
|
+
{ url: BRAND.faviconPng, sizes: "32x32", type: "image/png" }
|
|
31
|
+
],
|
|
32
|
+
shortcut: BRAND.favicon,
|
|
33
|
+
apple: BRAND.appleTouch
|
|
34
|
+
},
|
|
35
|
+
openGraph: {
|
|
36
|
+
title: "OpenAdminJS Admin",
|
|
37
|
+
description: "Resource-driven admin panel",
|
|
38
|
+
images: [{ url: BRAND.ogImage, width: 1200, height: 630, alt: "OpenAdminJS" }]
|
|
39
|
+
},
|
|
40
|
+
twitter: {
|
|
41
|
+
card: "summary_large_image",
|
|
42
|
+
title: "OpenAdminJS Admin",
|
|
43
|
+
images: [BRAND.ogImage]
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
48
|
+
return (
|
|
49
|
+
<html lang="en" suppressHydrationWarning className={inter.variable}>
|
|
50
|
+
<body className={inter.className}>
|
|
51
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
|
|
52
|
+
<AuthGuard>{children}</AuthGuard>
|
|
53
|
+
</ThemeProvider>
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { safeNextParam } from "./safe-next-param";
|
|
3
|
+
|
|
4
|
+
describe("login safeNextParam", () => {
|
|
5
|
+
it("defaults to dashboard for empty values", () => {
|
|
6
|
+
expect(safeNextParam(null)).toBe("/dashboard");
|
|
7
|
+
expect(safeNextParam("")).toBe("/dashboard");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("rejects protocol-relative values", () => {
|
|
11
|
+
expect(safeNextParam("//evil.example")).toBe("/dashboard");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("accepts internal paths", () => {
|
|
15
|
+
expect(safeNextParam("/dashboard")).toBe("/dashboard");
|
|
16
|
+
expect(safeNextParam("/resources/posts")).toBe("/resources/posts");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useRouter } from "next/navigation";
|
|
5
|
+
import { ArrowRight, Lock, Loader2, Mail } from "lucide-react";
|
|
6
|
+
import { hasUsableAccessToken } from "../../lib/api";
|
|
7
|
+
import { Logo } from "../../components/logo";
|
|
8
|
+
import { safeNextParam } from "./safe-next-param";
|
|
9
|
+
|
|
10
|
+
export default function LoginPage() {
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const [error, setError] = useState("");
|
|
13
|
+
const [loading, setLoading] = useState(false);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!hasUsableAccessToken()) return;
|
|
17
|
+
const next = safeNextParam(new URLSearchParams(window.location.search).get("next"));
|
|
18
|
+
router.replace(next);
|
|
19
|
+
}, [router]);
|
|
20
|
+
|
|
21
|
+
async function submit(formData: FormData) {
|
|
22
|
+
setError("");
|
|
23
|
+
setLoading(true);
|
|
24
|
+
try {
|
|
25
|
+
// POST to the Next.js BFF route — it proxies to the NestJS API and sets HttpOnly-friendly cookies
|
|
26
|
+
const res = await fetch("/api/auth/login", {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: { "content-type": "application/json" },
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
email: formData.get("email"),
|
|
31
|
+
password: formData.get("password"),
|
|
32
|
+
realm: "admin"
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
const data = (await res.json().catch(() => ({}))) as { ok?: boolean; message?: string };
|
|
36
|
+
if (!res.ok) {
|
|
37
|
+
let msg =
|
|
38
|
+
typeof data.message === "string" && data.message.length > 0
|
|
39
|
+
? data.message
|
|
40
|
+
: "Invalid email or password. Please try again.";
|
|
41
|
+
if (res.status >= 500 && (msg === "Internal Server Error" || msg === "Internal server error")) {
|
|
42
|
+
msg =
|
|
43
|
+
"Server error while signing in. Check that the API is running, PostgreSQL is up, migrations are applied, and apps/api/.env defines JWT_SECRET (see README).";
|
|
44
|
+
}
|
|
45
|
+
setError(msg);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const next = safeNextParam(new URLSearchParams(window.location.search).get("next"));
|
|
49
|
+
router.push(next);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
setError(
|
|
52
|
+
e instanceof TypeError
|
|
53
|
+
? "Cannot reach the server. Ensure the app is running and NEXT_PUBLIC_API_URL is set correctly."
|
|
54
|
+
: e instanceof Error
|
|
55
|
+
? e.message
|
|
56
|
+
: "Network error"
|
|
57
|
+
);
|
|
58
|
+
} finally {
|
|
59
|
+
setLoading(false);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<main className="relative grid min-h-screen place-items-center overflow-hidden bg-[#f8fafc] px-4">
|
|
65
|
+
{/* Background decorations */}
|
|
66
|
+
<div className="pointer-events-none absolute inset-0 overflow-hidden" aria-hidden>
|
|
67
|
+
<div className="absolute -left-48 -top-48 h-[600px] w-[600px] rounded-full bg-blue-100/70 blur-3xl" />
|
|
68
|
+
<div className="absolute -bottom-48 -right-48 h-[600px] w-[600px] rounded-full bg-teal-100/70 blur-3xl" />
|
|
69
|
+
<div className="absolute left-1/2 top-1/2 h-[400px] w-[700px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-indigo-50/50 blur-3xl" />
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div className="relative z-10 w-full max-w-[420px] animate-in">
|
|
73
|
+
{/* Card */}
|
|
74
|
+
<div className="overflow-hidden rounded-3xl border border-slate-200/80 bg-white/95 shadow-[0_8px_40px_rgba(0,0,0,0.1)] backdrop-blur-sm">
|
|
75
|
+
{/* Top gradient bar */}
|
|
76
|
+
<div className="h-1 w-full bg-gradient-to-r from-[#2454ff] via-[#7c3aed] to-[#0ea5a4]" />
|
|
77
|
+
|
|
78
|
+
<div className="px-8 pb-8 pt-7">
|
|
79
|
+
{/* Logo */}
|
|
80
|
+
<div className="mb-7">
|
|
81
|
+
<Logo />
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
{/* Heading */}
|
|
85
|
+
<div className="mb-6">
|
|
86
|
+
<h1 className="text-[1.6rem] font-bold tracking-tight text-slate-900">
|
|
87
|
+
Welcome back
|
|
88
|
+
</h1>
|
|
89
|
+
<p className="mt-1 text-sm text-slate-500">
|
|
90
|
+
Sign in to continue to your admin panel
|
|
91
|
+
</p>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
{/* Form */}
|
|
95
|
+
<form action={submit} className="space-y-4">
|
|
96
|
+
<label className="block space-y-1.5">
|
|
97
|
+
<span className="text-sm font-medium text-slate-700">Email address</span>
|
|
98
|
+
<div className="relative">
|
|
99
|
+
<Mail className="pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400" />
|
|
100
|
+
<input
|
|
101
|
+
name="email"
|
|
102
|
+
type="email"
|
|
103
|
+
placeholder="you@company.com"
|
|
104
|
+
className="input-base pl-10"
|
|
105
|
+
autoComplete="email"
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
</label>
|
|
109
|
+
|
|
110
|
+
<label className="block space-y-1.5">
|
|
111
|
+
<div className="flex items-center justify-between">
|
|
112
|
+
<span className="text-sm font-medium text-slate-700">Password</span>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="relative">
|
|
115
|
+
<Lock className="pointer-events-none absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400" />
|
|
116
|
+
<input
|
|
117
|
+
name="password"
|
|
118
|
+
type="password"
|
|
119
|
+
placeholder="Enter your password"
|
|
120
|
+
className="input-base pl-10"
|
|
121
|
+
autoComplete="current-password"
|
|
122
|
+
/>
|
|
123
|
+
</div>
|
|
124
|
+
</label>
|
|
125
|
+
|
|
126
|
+
{error && (
|
|
127
|
+
<div className="flex items-center gap-2 rounded-xl bg-red-50 px-4 py-3 text-sm text-red-600 fade-in">
|
|
128
|
+
<div className="h-1.5 w-1.5 shrink-0 rounded-full bg-red-500" />
|
|
129
|
+
{error}
|
|
130
|
+
</div>
|
|
131
|
+
)}
|
|
132
|
+
|
|
133
|
+
<button
|
|
134
|
+
type="submit"
|
|
135
|
+
disabled={loading}
|
|
136
|
+
className="btn-primary mt-2 w-full py-3"
|
|
137
|
+
>
|
|
138
|
+
{loading ? (
|
|
139
|
+
<>
|
|
140
|
+
<Loader2 className="h-4 w-4 animate-spin" />
|
|
141
|
+
Signing in...
|
|
142
|
+
</>
|
|
143
|
+
) : (
|
|
144
|
+
<>
|
|
145
|
+
Sign in
|
|
146
|
+
<ArrowRight className="h-4 w-4" />
|
|
147
|
+
</>
|
|
148
|
+
)}
|
|
149
|
+
</button>
|
|
150
|
+
</form>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
{/* Footer note */}
|
|
155
|
+
<p className="mt-5 text-center text-xs text-slate-400">
|
|
156
|
+
OpenAdminJS · Free open-source admin framework for Node.js
|
|
157
|
+
</p>
|
|
158
|
+
</div>
|
|
159
|
+
</main>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { AppShell } from "../../components/app-shell";
|
|
5
|
+
import { api } from "../../lib/api";
|
|
6
|
+
|
|
7
|
+
type NotificationRecord = {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
body: string | null;
|
|
11
|
+
readAt: string | null;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type ListResponse<T> = {
|
|
16
|
+
data: T[];
|
|
17
|
+
meta: { total: number };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default function NotificationsPage() {
|
|
21
|
+
const [rows, setRows] = useState<NotificationRecord[]>([]);
|
|
22
|
+
const [title, setTitle] = useState("");
|
|
23
|
+
const [body, setBody] = useState("");
|
|
24
|
+
const [loading, setLoading] = useState(false);
|
|
25
|
+
const [error, setError] = useState<string | null>(null);
|
|
26
|
+
|
|
27
|
+
async function load() {
|
|
28
|
+
setLoading(true);
|
|
29
|
+
try {
|
|
30
|
+
const response = await api<ListResponse<NotificationRecord>>("/admin/resources/notifications?sort=createdAt:desc&limit=50");
|
|
31
|
+
setRows(response.data ?? []);
|
|
32
|
+
setError(null);
|
|
33
|
+
} catch (loadError) {
|
|
34
|
+
setError(loadError instanceof Error ? loadError.message : "Failed to load notifications");
|
|
35
|
+
} finally {
|
|
36
|
+
setLoading(false);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
load();
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
async function createNotification(event: React.FormEvent<HTMLFormElement>) {
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
if (!title.trim()) return;
|
|
47
|
+
try {
|
|
48
|
+
await api("/admin/resources/notifications", {
|
|
49
|
+
method: "POST",
|
|
50
|
+
body: JSON.stringify({ title: title.trim(), body: body.trim() || null })
|
|
51
|
+
});
|
|
52
|
+
setTitle("");
|
|
53
|
+
setBody("");
|
|
54
|
+
await load();
|
|
55
|
+
} catch (createError) {
|
|
56
|
+
setError(createError instanceof Error ? createError.message : "Failed to create notification");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function act(id: string, action: "mark-read" | "mark-unread") {
|
|
61
|
+
try {
|
|
62
|
+
await api(`/admin/resources/notifications/${id}/actions/${action}`, { method: "POST" });
|
|
63
|
+
await load();
|
|
64
|
+
} catch (actionError) {
|
|
65
|
+
setError(actionError instanceof Error ? actionError.message : "Failed to update notification");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function remove(id: string) {
|
|
70
|
+
try {
|
|
71
|
+
await api(`/admin/resources/notifications/${id}`, { method: "DELETE" });
|
|
72
|
+
await load();
|
|
73
|
+
} catch (deleteError) {
|
|
74
|
+
setError(deleteError instanceof Error ? deleteError.message : "Failed to delete notification");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<AppShell>
|
|
80
|
+
<div className="space-y-5">
|
|
81
|
+
<div>
|
|
82
|
+
<p className="text-xs font-bold uppercase tracking-wide text-[#0b8585]">Workspace communication</p>
|
|
83
|
+
<h1 className="mt-1 text-3xl font-bold tracking-normal text-[#24324b]">Notifications</h1>
|
|
84
|
+
<p className="text-sm text-[#637083]">Create, read, and manage notification lifecycle.</p>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
{error ? <p className="rounded-xl bg-red-50 px-3 py-2 text-sm text-red-700">{error}</p> : null}
|
|
88
|
+
|
|
89
|
+
<section className="rounded-2xl border border-[#e4e8f0] bg-white p-5 shadow-[0_12px_34px_rgba(36,50,75,0.07)]">
|
|
90
|
+
<h2 className="text-lg font-bold text-[#24324b]">Create notification</h2>
|
|
91
|
+
<form onSubmit={createNotification} className="mt-4 grid gap-3">
|
|
92
|
+
<input
|
|
93
|
+
value={title}
|
|
94
|
+
onChange={(event) => setTitle(event.target.value)}
|
|
95
|
+
className="rounded-xl border border-[#e4e8f0] bg-[#f6f8fc] px-3 py-2 text-sm"
|
|
96
|
+
placeholder="Title"
|
|
97
|
+
/>
|
|
98
|
+
<textarea
|
|
99
|
+
value={body}
|
|
100
|
+
onChange={(event) => setBody(event.target.value)}
|
|
101
|
+
className="min-h-24 rounded-xl border border-[#e4e8f0] bg-[#f6f8fc] px-3 py-2 text-sm"
|
|
102
|
+
placeholder="Body"
|
|
103
|
+
/>
|
|
104
|
+
<button type="submit" className="w-fit rounded-xl bg-gradient-to-r from-[#2454ff] to-[#0ea5a4] px-4 py-2 text-sm font-bold text-white">
|
|
105
|
+
Create notification
|
|
106
|
+
</button>
|
|
107
|
+
</form>
|
|
108
|
+
</section>
|
|
109
|
+
|
|
110
|
+
<section className="rounded-2xl border border-[#e4e8f0] bg-white p-5 shadow-[0_12px_34px_rgba(36,50,75,0.07)]">
|
|
111
|
+
<h2 className="text-lg font-bold text-[#24324b]">Inbox</h2>
|
|
112
|
+
<div className="mt-4 space-y-3">
|
|
113
|
+
{loading ? <p className="text-sm text-[#637083]">Loading notifications...</p> : null}
|
|
114
|
+
{!loading && rows.length === 0 ? <p className="text-sm text-[#637083]">No notifications yet.</p> : null}
|
|
115
|
+
{rows.map((row) => (
|
|
116
|
+
<article key={row.id} className="rounded-xl border border-[#eef2fb] bg-[#f9fbff] p-3">
|
|
117
|
+
<div className="flex items-center justify-between gap-2">
|
|
118
|
+
<h3 className="font-semibold text-[#24324b]">{row.title}</h3>
|
|
119
|
+
<span className={`rounded-full px-2 py-1 text-xs font-semibold ${row.readAt ? "bg-[#e5ecff] text-[#2454ff]" : "bg-[#e9fbfa] text-[#0b8585]"}`}>
|
|
120
|
+
{row.readAt ? "Read" : "Unread"}
|
|
121
|
+
</span>
|
|
122
|
+
</div>
|
|
123
|
+
{row.body ? <p className="mt-1 text-sm text-[#637083]">{row.body}</p> : null}
|
|
124
|
+
<p className="mt-1 text-xs text-[#8a95a8]">{new Date(row.createdAt).toLocaleString()}</p>
|
|
125
|
+
<div className="mt-2 flex items-center gap-2">
|
|
126
|
+
{row.readAt ? (
|
|
127
|
+
<button type="button" onClick={() => act(row.id, "mark-unread")} className="rounded-lg border border-[#dce4f6] bg-white px-3 py-1.5 text-xs font-semibold text-[#24324b]">
|
|
128
|
+
Mark unread
|
|
129
|
+
</button>
|
|
130
|
+
) : (
|
|
131
|
+
<button type="button" onClick={() => act(row.id, "mark-read")} className="rounded-lg border border-[#dce4f6] bg-white px-3 py-1.5 text-xs font-semibold text-[#24324b]">
|
|
132
|
+
Mark read
|
|
133
|
+
</button>
|
|
134
|
+
)}
|
|
135
|
+
<button type="button" onClick={() => remove(row.id)} className="rounded-lg border border-red-200 bg-red-50 px-3 py-1.5 text-xs font-semibold text-red-700">
|
|
136
|
+
Delete
|
|
137
|
+
</button>
|
|
138
|
+
</div>
|
|
139
|
+
</article>
|
|
140
|
+
))}
|
|
141
|
+
</div>
|
|
142
|
+
</section>
|
|
143
|
+
</div>
|
|
144
|
+
</AppShell>
|
|
145
|
+
);
|
|
146
|
+
}
|