@dyrected/admin 2.4.0 → 2.4.2
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/App.d.ts +1 -0
- package/dist/admin.css +2 -0
- package/dist/components/auth/auth-gate.d.ts +13 -0
- package/dist/components/error-boundary.d.ts +16 -0
- package/dist/components/forms/field-renderer.d.ts +22 -0
- package/dist/components/forms/fields/block-builder.d.ts +9 -0
- package/dist/components/forms/fields/date-picker.d.ts +8 -0
- package/dist/components/forms/fields/json-editor.d.ts +8 -0
- package/dist/components/forms/fields/media-picker.d.ts +12 -0
- package/dist/components/forms/fields/multi-select.d.ts +19 -0
- package/dist/components/forms/fields/radio-field.d.ts +8 -0
- package/dist/components/forms/fields/relationship-picker.d.ts +10 -0
- package/dist/components/forms/fields/rich-text-editor.d.ts +9 -0
- package/dist/components/forms/fields/select-field.d.ts +8 -0
- package/dist/components/forms/fields/switch-field.d.ts +6 -0
- package/dist/components/forms/fields/text-area-field.d.ts +8 -0
- package/dist/components/forms/fields/text-field.d.ts +8 -0
- package/dist/components/forms/form-engine.d.ts +14 -0
- package/dist/components/forms/form-field-renderer.d.ts +20 -0
- package/dist/components/forms/utils.d.ts +11 -0
- package/dist/components/layout/admin-shell.d.ts +5 -0
- package/dist/components/layout/branding-provider.d.ts +4 -0
- package/dist/components/live-preview/LivePreviewPane.d.ts +7 -0
- package/dist/components/media/focal-point-picker.d.ts +12 -0
- package/dist/components/media/media-card.d.ts +8 -0
- package/dist/components/media/media-grid.d.ts +8 -0
- package/dist/components/media/media-library-dialog.d.ts +11 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/calendar.d.ts +8 -0
- package/dist/components/ui/card.d.ts +8 -0
- package/dist/components/ui/checkbox.d.ts +4 -0
- package/dist/components/ui/command.d.ts +80 -0
- package/dist/components/ui/data-table.d.ts +14 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/form.d.ts +23 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/page-header.d.ts +10 -0
- package/dist/components/ui/pagination.d.ts +11 -0
- package/dist/components/ui/popover.d.ts +6 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/render-cell.d.ts +8 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/select.d.ts +13 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/sheet.d.ts +25 -0
- package/dist/components/ui/sidebar.d.ts +65 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-preferences.d.ts +6 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.mjs +69091 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/main.d.ts +0 -0
- package/dist/pages/auth/first-user-page.d.ts +4 -0
- package/dist/pages/auth/login-page.d.ts +4 -0
- package/dist/pages/collections/edit-page.d.ts +1 -0
- package/dist/pages/collections/list-page.d.ts +5 -0
- package/dist/pages/dashboard/dashboard.d.ts +1 -0
- package/dist/pages/globals/editor-page.d.ts +1 -0
- package/dist/pages/media/media-page.d.ts +4 -0
- package/dist/pages/setup/setup-prompt.d.ts +6 -0
- package/dist/providers/dyrected-provider.d.ts +29 -0
- package/dist/providers/query-provider.d.ts +3 -0
- package/package.json +6 -3
- package/CHANGELOG.md +0 -153
- package/components.json +0 -17
- package/eslint.config.js +0 -22
- package/index.html +0 -13
- package/postcss.config.js +0 -6
- package/scripts/prefix-tailwind-precision.py +0 -98
- package/scripts/prefix-tailwind.py +0 -67
- package/src/App.css +0 -184
- package/src/App.tsx +0 -25
- package/src/assets/dyrected.svg +0 -155
- package/src/assets/hero.png +0 -0
- package/src/assets/react.svg +0 -1
- package/src/assets/vite.svg +0 -1
- package/src/components/auth/auth-gate.tsx +0 -64
- package/src/components/error-boundary.tsx +0 -45
- package/src/components/forms/field-renderer.tsx +0 -111
- package/src/components/forms/fields/block-builder.tsx +0 -213
- package/src/components/forms/fields/date-picker.tsx +0 -60
- package/src/components/forms/fields/json-editor.tsx +0 -62
- package/src/components/forms/fields/media-picker.tsx +0 -286
- package/src/components/forms/fields/multi-select.tsx +0 -145
- package/src/components/forms/fields/radio-field.tsx +0 -51
- package/src/components/forms/fields/relationship-picker.tsx +0 -143
- package/src/components/forms/fields/rich-text-editor.tsx +0 -224
- package/src/components/forms/fields/select-field.tsx +0 -35
- package/src/components/forms/fields/switch-field.tsx +0 -16
- package/src/components/forms/fields/text-area-field.tsx +0 -15
- package/src/components/forms/fields/text-field.tsx +0 -24
- package/src/components/forms/form-engine.tsx +0 -87
- package/src/components/forms/form-field-renderer.tsx +0 -269
- package/src/components/forms/utils.ts +0 -97
- package/src/components/layout/admin-shell.tsx +0 -479
- package/src/components/layout/branding-provider.tsx +0 -112
- package/src/components/live-preview/LivePreviewPane.tsx +0 -128
- package/src/components/media/focal-point-picker.tsx +0 -66
- package/src/components/media/media-card.tsx +0 -44
- package/src/components/media/media-grid.tsx +0 -32
- package/src/components/media/media-library-dialog.tsx +0 -465
- package/src/components/ui/aspect-ratio.tsx +0 -7
- package/src/components/ui/badge.tsx +0 -36
- package/src/components/ui/button.tsx +0 -56
- package/src/components/ui/calendar.tsx +0 -214
- package/src/components/ui/card.tsx +0 -79
- package/src/components/ui/checkbox.tsx +0 -28
- package/src/components/ui/command.tsx +0 -151
- package/src/components/ui/data-table.tsx +0 -219
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/dropdown-menu.tsx +0 -200
- package/src/components/ui/form.tsx +0 -178
- package/src/components/ui/input.tsx +0 -24
- package/src/components/ui/label.tsx +0 -24
- package/src/components/ui/page-header.tsx +0 -30
- package/src/components/ui/pagination.tsx +0 -57
- package/src/components/ui/popover.tsx +0 -29
- package/src/components/ui/progress.tsx +0 -26
- package/src/components/ui/radio-group.tsx +0 -42
- package/src/components/ui/render-cell.tsx +0 -110
- package/src/components/ui/scroll-area.tsx +0 -46
- package/src/components/ui/select.tsx +0 -160
- package/src/components/ui/separator.tsx +0 -29
- package/src/components/ui/sheet.tsx +0 -140
- package/src/components/ui/sidebar.tsx +0 -771
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -27
- package/src/components/ui/switch.tsx +0 -27
- package/src/components/ui/table.tsx +0 -117
- package/src/components/ui/tabs.tsx +0 -53
- package/src/components/ui/textarea.tsx +0 -22
- package/src/components/ui/toggle.tsx +0 -43
- package/src/components/ui/tooltip.tsx +0 -28
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/hooks/use-preferences.ts +0 -56
- package/src/index.css +0 -111
- package/src/index.tsx +0 -198
- package/src/lib/utils.ts +0 -36
- package/src/main.tsx +0 -10
- package/src/pages/auth/first-user-page.tsx +0 -115
- package/src/pages/auth/login-page.tsx +0 -91
- package/src/pages/collections/edit-page.tsx +0 -280
- package/src/pages/collections/list-page.tsx +0 -343
- package/src/pages/dashboard/dashboard.tsx +0 -150
- package/src/pages/globals/editor-page.tsx +0 -122
- package/src/pages/media/media-page.tsx +0 -564
- package/src/pages/setup/setup-prompt.tsx +0 -181
- package/src/providers/dyrected-provider.tsx +0 -122
- package/src/providers/query-provider.tsx +0 -19
- package/src/types/jexl.d.ts +0 -11
- package/tailwind.config.ts +0 -103
- package/tsconfig.app.json +0 -28
- package/tsconfig.json +0 -12
- package/tsconfig.node.json +0 -25
- package/vite.config.ts +0 -39
- /package/{public → dist}/favicon.svg +0 -0
- /package/{public → dist}/icons.svg +0 -0
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Copy,
|
|
4
|
-
Check,
|
|
5
|
-
ExternalLink,
|
|
6
|
-
Terminal,
|
|
7
|
-
Sparkles,
|
|
8
|
-
ShieldCheck,
|
|
9
|
-
} from "lucide-react";
|
|
10
|
-
import { cn } from "../../lib/utils";
|
|
11
|
-
import { Button } from "../../components/ui/button";
|
|
12
|
-
import { generateAIPrompt, generateFreshSetupPrompt, type SetupPromptConfig } from "@dyrected/sdk";
|
|
13
|
-
|
|
14
|
-
export type { SetupPromptConfig };
|
|
15
|
-
|
|
16
|
-
export interface SetupPromptProps {
|
|
17
|
-
config: SetupPromptConfig;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function SetupPromptUI({ config }: SetupPromptProps) {
|
|
21
|
-
const [copied, setCopied] = useState<string | null>(null);
|
|
22
|
-
const [isFresh, setIsFresh] = useState(false);
|
|
23
|
-
const [activeTab, setActiveTab] = useState<"next" | "nuxt" | "react" | "vue">("next");
|
|
24
|
-
|
|
25
|
-
const promptText = isFresh
|
|
26
|
-
? generateFreshSetupPrompt(activeTab, config)
|
|
27
|
-
: generateAIPrompt(activeTab, config);
|
|
28
|
-
|
|
29
|
-
const copyToClipboard = (text: string, id: string) => {
|
|
30
|
-
navigator.clipboard.writeText(text);
|
|
31
|
-
setCopied(id);
|
|
32
|
-
setTimeout(() => setCopied(null), 2000);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<div className="dy-max-w-4xl dy-mx-auto dy-space-y-8 dy-py-8 dy-animate-in dy-slide-in-from-bottom-4 dy-duration-700">
|
|
37
|
-
<div className="dy-text-center dy-space-y-4">
|
|
38
|
-
<div className="dy-inline-flex dy-items-center dy-gap-2 dy-px-3 dy-py-1 dy-rounded-full dy-bg-primary/10 dy-text-primary dy-text-xs dy-font-bold dy-uppercase dy-tracking-wider dy-mb-2">
|
|
39
|
-
<Sparkles className="dy-h-3 dy-w-3" />
|
|
40
|
-
Integration Guide
|
|
41
|
-
</div>
|
|
42
|
-
<h1 className="dy-text-2xl dy-font-semibold dy-tracking-tight lg:dy-text-5xl dy-text-foreground">
|
|
43
|
-
Connect Your Application
|
|
44
|
-
</h1>
|
|
45
|
-
<p className="dy-text-lg dy-text-muted-foreground dy-max-w-2xl dy-mx-auto">
|
|
46
|
-
{isFresh
|
|
47
|
-
? "Get a conversational walkthrough to set up Dyrected from scratch."
|
|
48
|
-
: "Use the AI prompt below to set up your frontend automatically, or follow the steps manually."}
|
|
49
|
-
</p>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
<div className="dy-grid dy-gap-6">
|
|
53
|
-
{/* Site Credentials */}
|
|
54
|
-
<section className="dy-rounded-2xl dy-border dy-bg-card dy-overflow-hidden dy-shadow-xl">
|
|
55
|
-
<div className="dy-p-4 dy-border-b dy-bg-muted/30">
|
|
56
|
-
<h3 className="dy-text-lg dy-font-semibold dy-flex dy-items-center dy-gap-2">
|
|
57
|
-
<ShieldCheck className="dy-h-5 dy-w-5 dy-text-primary" />
|
|
58
|
-
Site Credentials
|
|
59
|
-
</h3>
|
|
60
|
-
</div>
|
|
61
|
-
<div className="dy-p-4">
|
|
62
|
-
<div className="dy-grid dy-gap-4 sm:dy-grid-cols-2 lg:dy-grid-cols-3">
|
|
63
|
-
{[
|
|
64
|
-
{ label: "Site ID", value: config.siteId, id: "siteId" },
|
|
65
|
-
{ label: "API Key", value: config.apiKey, id: "apiKey" },
|
|
66
|
-
{ label: "Base URL", value: config.baseUrl, id: "baseUrl" },
|
|
67
|
-
].map((item) => (
|
|
68
|
-
<div key={item.id} className="dy-space-y-2">
|
|
69
|
-
<label className="dy-text-xs dy-font-bold dy-text-muted-foreground dy-uppercase">
|
|
70
|
-
{item.label}
|
|
71
|
-
</label>
|
|
72
|
-
<div className="dy-relative dy-group">
|
|
73
|
-
<div className="dy-p-3 dy-pr-10 dy-rounded-lg dy-bg-muted dy-text-sm dy-font-mono dy-truncate dy-border dy-border-transparent dy-group-hover:dy-border-primary/20 dy-transition-all">
|
|
74
|
-
{item.value}
|
|
75
|
-
</div>
|
|
76
|
-
<button
|
|
77
|
-
onClick={() => copyToClipboard(item.value || "", item.id)}
|
|
78
|
-
className="dy-absolute dy-right-2 dy-top-1/2 dy--translate-y-1/2 dy-p-1.5 dy-rounded-md hover:dy-bg-background dy-transition-colors dy-text-muted-foreground"
|
|
79
|
-
>
|
|
80
|
-
{copied === item.id ? (
|
|
81
|
-
<Check className="dy-h-4 dy-w-4 dy-text-green-500" />
|
|
82
|
-
) : (
|
|
83
|
-
<Copy className="dy-h-4 dy-w-4" />
|
|
84
|
-
)}
|
|
85
|
-
</button>
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
))}
|
|
89
|
-
</div>
|
|
90
|
-
</div>
|
|
91
|
-
</section>
|
|
92
|
-
|
|
93
|
-
{/* AI Prompt */}
|
|
94
|
-
<section className="dy-rounded-2xl dy-border dy-bg-white dy-overflow-hidden dy-shadow-xl dy-ring-1 dy-ring-primary/20">
|
|
95
|
-
<div className="dy-p-6 dy-border-b dy-bg-primary/5 dy-flex dy-items-center dy-justify-between dy-gap-4 dy-flex-wrap">
|
|
96
|
-
<div className="dy-space-y-3">
|
|
97
|
-
<h3 className="dy-text-lg dy-font-semibold dy-flex dy-items-center dy-gap-2">
|
|
98
|
-
<Sparkles className="dy-h-5 dy-w-5 dy-text-primary dy-animate-pulse" />
|
|
99
|
-
AI Integration Prompt
|
|
100
|
-
</h3>
|
|
101
|
-
<div className="dy-flex dy-gap-2 dy-bg-muted/50 dy-p-1 dy-rounded-lg dy-w-fit">
|
|
102
|
-
{(["next", "nuxt", "react", "vue"] as const).map((tab) => (
|
|
103
|
-
<button
|
|
104
|
-
key={tab}
|
|
105
|
-
onClick={() => setActiveTab(tab)}
|
|
106
|
-
className={cn(
|
|
107
|
-
"dy-px-4 dy-py-1.5 dy-rounded-md dy-text-xs dy-font-medium dy-transition-all dy-capitalize",
|
|
108
|
-
activeTab === tab
|
|
109
|
-
? "dy-bg-background dy-text-foreground dy-shadow-sm"
|
|
110
|
-
: "dy-text-muted-foreground hover:dy-text-foreground"
|
|
111
|
-
)}
|
|
112
|
-
>
|
|
113
|
-
{tab === "next" ? "Next.js" : tab === "nuxt" ? "Nuxt.js" : tab}
|
|
114
|
-
</button>
|
|
115
|
-
))}
|
|
116
|
-
</div>
|
|
117
|
-
<div className="dy-flex dy-gap-2 dy-bg-muted/50 dy-p-1 dy-rounded-lg dy-w-fit">
|
|
118
|
-
<button
|
|
119
|
-
onClick={() => setIsFresh(false)}
|
|
120
|
-
className={cn(
|
|
121
|
-
"dy-px-4 dy-py-1.5 dy-rounded-md dy-text-xs dy-font-medium dy-transition-all",
|
|
122
|
-
!isFresh
|
|
123
|
-
? "dy-bg-background dy-text-foreground dy-shadow-sm"
|
|
124
|
-
: "dy-text-muted-foreground hover:dy-text-foreground"
|
|
125
|
-
)}
|
|
126
|
-
>
|
|
127
|
-
Existing Project
|
|
128
|
-
</button>
|
|
129
|
-
<button
|
|
130
|
-
onClick={() => setIsFresh(true)}
|
|
131
|
-
className={cn(
|
|
132
|
-
"dy-px-4 dy-py-1.5 dy-rounded-md dy-text-xs dy-font-medium dy-transition-all",
|
|
133
|
-
isFresh
|
|
134
|
-
? "dy-bg-background dy-text-foreground dy-shadow-sm"
|
|
135
|
-
: "dy-text-muted-foreground hover:dy-text-foreground"
|
|
136
|
-
)}
|
|
137
|
-
>
|
|
138
|
-
Fresh Installation
|
|
139
|
-
</button>
|
|
140
|
-
</div>
|
|
141
|
-
<p className="dy-text-sm dy-text-muted-foreground">
|
|
142
|
-
Copy and paste this into your AI developer to handle everything automatically
|
|
143
|
-
</p>
|
|
144
|
-
</div>
|
|
145
|
-
<Button
|
|
146
|
-
onClick={() => copyToClipboard(promptText, "ai-developer")}
|
|
147
|
-
className="dy-relative dy-overflow-hidden dy-group dy-shrink-0"
|
|
148
|
-
>
|
|
149
|
-
<div className="dy-flex dy-items-center dy-gap-2">
|
|
150
|
-
{copied === "ai-developer" ? (
|
|
151
|
-
<Check className="dy-h-4 dy-w-4" />
|
|
152
|
-
) : (
|
|
153
|
-
<Copy className="dy-h-4 dy-w-4" />
|
|
154
|
-
)}
|
|
155
|
-
{copied === "ai-developer" ? "Copied!" : "Copy Full Prompt"}
|
|
156
|
-
</div>
|
|
157
|
-
</Button>
|
|
158
|
-
</div>
|
|
159
|
-
<div className="dy-p-6 dy-bg-slate-950 dy-text-slate-300 dy-font-mono dy-text-xs dy-leading-relaxed dy-max-h-[400px] dy-overflow-y-auto dy-scrollbar-thin dy-scrollbar-thumb-white/10">
|
|
160
|
-
<pre className="dy-whitespace-pre-wrap">{promptText}</pre>
|
|
161
|
-
</div>
|
|
162
|
-
</section>
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
<div className="dy-flex dy-justify-center dy-gap-4 dy-pt-4">
|
|
166
|
-
<Button variant="outline" asChild>
|
|
167
|
-
<a
|
|
168
|
-
href={`${config.baseUrl}/api/docs`}
|
|
169
|
-
target="_blank"
|
|
170
|
-
rel="noopener noreferrer"
|
|
171
|
-
className="dy-flex dy-items-center dy-gap-2"
|
|
172
|
-
>
|
|
173
|
-
<Terminal className="dy-h-4 dy-w-4" />
|
|
174
|
-
API Documentation
|
|
175
|
-
<ExternalLink className="dy-h-3 dy-w-3" />
|
|
176
|
-
</a>
|
|
177
|
-
</Button>
|
|
178
|
-
</div>
|
|
179
|
-
</div>
|
|
180
|
-
);
|
|
181
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useState, useEffect } from "react";
|
|
2
|
-
import { createClient, DyrectedClient } from "@dyrected/sdk";
|
|
3
|
-
|
|
4
|
-
interface DyrectedContextType {
|
|
5
|
-
client: DyrectedClient | null;
|
|
6
|
-
config: {
|
|
7
|
-
baseUrl: string;
|
|
8
|
-
apiKey: string | undefined;
|
|
9
|
-
siteId: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
setAuth: (baseUrl: string, apiKey: string, siteId?: string) => void;
|
|
12
|
-
logout: () => void;
|
|
13
|
-
isAuthenticated: boolean;
|
|
14
|
-
schemas: { collections: any[]; globals: any[]; admin?: any } | null;
|
|
15
|
-
user: any | null;
|
|
16
|
-
setToken: (token: string) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const DyrectedContext = createContext<DyrectedContextType | undefined>(undefined);
|
|
20
|
-
|
|
21
|
-
export interface DyrectedProviderProps {
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
apiKey?: string;
|
|
24
|
-
baseUrl?: string;
|
|
25
|
-
siteId?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function DyrectedProvider({
|
|
29
|
-
children,
|
|
30
|
-
apiKey: initialApiKey,
|
|
31
|
-
baseUrl: initialBaseUrl,
|
|
32
|
-
siteId: initialSiteId
|
|
33
|
-
}: DyrectedProviderProps) {
|
|
34
|
-
const [baseUrl, setBaseUrl] = useState<string>(() => initialBaseUrl || (typeof window !== 'undefined' ? localStorage.getItem("dyrected_url") : null) || "");
|
|
35
|
-
const [apiKey, setApiKey] = useState<string | undefined>(() => initialApiKey || (typeof window !== 'undefined' ? localStorage.getItem("dyrected_key") : null) || undefined);
|
|
36
|
-
const [siteId, setSiteId] = useState<string | undefined>(() => initialSiteId || (typeof window !== 'undefined' ? localStorage.getItem("dyrected_site_id") : null) || undefined);
|
|
37
|
-
const [client, setClient] = useState<DyrectedClient | null>(null);
|
|
38
|
-
const [schemas, setSchemas] = useState<{ collections: any[]; globals: any[]; admin?: any } | null>(null);
|
|
39
|
-
const [user, setUser] = useState<any | null>(null);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (baseUrl) {
|
|
43
|
-
const newClient = createClient({
|
|
44
|
-
baseUrl,
|
|
45
|
-
apiKey: apiKey || undefined,
|
|
46
|
-
siteId: siteId || undefined,
|
|
47
|
-
});
|
|
48
|
-
setClient(newClient);
|
|
49
|
-
|
|
50
|
-
// Fetch schemas
|
|
51
|
-
newClient.getSchemas().then(setSchemas).catch(err => {
|
|
52
|
-
console.error("Failed to fetch schemas:", err);
|
|
53
|
-
setSchemas(null);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}, [baseUrl, apiKey, siteId]);
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const token = localStorage.getItem("dyrected_token");
|
|
60
|
-
if (token && client && schemas && !user) {
|
|
61
|
-
setToken(token);
|
|
62
|
-
}
|
|
63
|
-
}, [client, schemas, user]);
|
|
64
|
-
|
|
65
|
-
const setAuth = (newUrl: string, newKey: string, newSiteId?: string) => {
|
|
66
|
-
localStorage.setItem("dyrected_url", newUrl);
|
|
67
|
-
localStorage.setItem("dyrected_key", newKey);
|
|
68
|
-
if (newSiteId) localStorage.setItem("dyrected_site_id", newSiteId);
|
|
69
|
-
else localStorage.removeItem("dyrected_site_id");
|
|
70
|
-
|
|
71
|
-
setBaseUrl(newUrl);
|
|
72
|
-
setApiKey(newKey);
|
|
73
|
-
setSiteId(newSiteId);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const setToken = (token: string) => {
|
|
77
|
-
localStorage.setItem("dyrected_token", token);
|
|
78
|
-
if (client) {
|
|
79
|
-
client.setToken(token);
|
|
80
|
-
// Prefer __admins for the dashboard session; fall back to the first auth collection.
|
|
81
|
-
const authCollection =
|
|
82
|
-
schemas?.collections.find((c: any) => c.slug === '__admins') ??
|
|
83
|
-
schemas?.collections.find((c: any) => c.auth);
|
|
84
|
-
if (authCollection) {
|
|
85
|
-
client.collection(authCollection.slug).me().then(setUser).catch(() => setUser(null));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const logout = () => {
|
|
91
|
-
localStorage.removeItem("dyrected_url");
|
|
92
|
-
localStorage.removeItem("dyrected_key");
|
|
93
|
-
localStorage.removeItem("dyrected_site_id");
|
|
94
|
-
localStorage.removeItem("dyrected_token");
|
|
95
|
-
setBaseUrl("");
|
|
96
|
-
setApiKey(undefined);
|
|
97
|
-
setSiteId(undefined);
|
|
98
|
-
setClient(null);
|
|
99
|
-
setUser(null);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<DyrectedContext.Provider value={{
|
|
104
|
-
client,
|
|
105
|
-
config: { baseUrl, apiKey, siteId },
|
|
106
|
-
setAuth,
|
|
107
|
-
setToken,
|
|
108
|
-
logout,
|
|
109
|
-
isAuthenticated: !!baseUrl && !!apiKey,
|
|
110
|
-
schemas,
|
|
111
|
-
user
|
|
112
|
-
}}>
|
|
113
|
-
{children}
|
|
114
|
-
</DyrectedContext.Provider>
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export const useDyrected = () => {
|
|
119
|
-
const context = useContext(DyrectedContext);
|
|
120
|
-
if (!context) throw new Error("useDyrected must be used within a DyrectedProvider");
|
|
121
|
-
return context;
|
|
122
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
|
|
4
|
-
export function QueryProvider({ children }: { children: React.ReactNode }) {
|
|
5
|
-
const [queryClient] = useState(() => new QueryClient({
|
|
6
|
-
defaultOptions: {
|
|
7
|
-
queries: {
|
|
8
|
-
staleTime: 60 * 1000,
|
|
9
|
-
retry: 1,
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<QueryClientProvider client={queryClient}>
|
|
16
|
-
{children}
|
|
17
|
-
</QueryClientProvider>
|
|
18
|
-
);
|
|
19
|
-
}
|
package/src/types/jexl.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare module 'jexl' {
|
|
2
|
-
const jexl: {
|
|
3
|
-
evalSync: (expression: string, context: any) => any;
|
|
4
|
-
eval: (expression: string, context: any) => Promise<any>;
|
|
5
|
-
addFunction: (name: string, fn: (...args: any[]) => any) => void;
|
|
6
|
-
addTransform: (name: string, fn: (...args: any[]) => any) => void;
|
|
7
|
-
addBinaryOp: (name: string, precedence: number, fn: (a: any, b: any) => any) => void;
|
|
8
|
-
addUnaryOp: (name: string, fn: (a: any) => any) => void;
|
|
9
|
-
};
|
|
10
|
-
export default jexl;
|
|
11
|
-
}
|
package/tailwind.config.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { Config } from "tailwindcss"
|
|
2
|
-
import tailwindAnimate from "tailwindcss-animate"
|
|
3
|
-
|
|
4
|
-
const config: Config = {
|
|
5
|
-
prefix: 'dy-',
|
|
6
|
-
darkMode: ["class"],
|
|
7
|
-
content: [
|
|
8
|
-
'./pages/**/*.{ts,tsx}',
|
|
9
|
-
'./components/**/*.{ts,tsx}',
|
|
10
|
-
'./app/**/*.{ts,tsx}',
|
|
11
|
-
'./src/**/*.{ts,tsx}',
|
|
12
|
-
],
|
|
13
|
-
theme: {
|
|
14
|
-
container: {
|
|
15
|
-
center: true,
|
|
16
|
-
padding: '2rem',
|
|
17
|
-
screens: {
|
|
18
|
-
'2xl': '1400px'
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
extend: {
|
|
22
|
-
fontFamily: {
|
|
23
|
-
sans: ['var(--font-sans)', 'ui-sans-serif', 'system-ui', 'sans-serif'],
|
|
24
|
-
serif: ['var(--font-serif)', 'ui-serif', 'Georgia', 'serif'],
|
|
25
|
-
},
|
|
26
|
-
colors: {
|
|
27
|
-
border: 'hsl(var(--border))',
|
|
28
|
-
input: 'hsl(var(--input))',
|
|
29
|
-
ring: 'hsl(var(--ring))',
|
|
30
|
-
background: 'hsl(var(--background))',
|
|
31
|
-
foreground: 'hsl(var(--foreground))',
|
|
32
|
-
primary: {
|
|
33
|
-
DEFAULT: 'hsl(var(--primary))',
|
|
34
|
-
foreground: 'hsl(var(--primary-foreground))'
|
|
35
|
-
},
|
|
36
|
-
secondary: {
|
|
37
|
-
DEFAULT: 'hsl(var(--secondary))',
|
|
38
|
-
foreground: 'hsl(var(--secondary-foreground))'
|
|
39
|
-
},
|
|
40
|
-
destructive: {
|
|
41
|
-
DEFAULT: 'hsl(var(--destructive))',
|
|
42
|
-
foreground: 'hsl(var(--destructive-foreground))'
|
|
43
|
-
},
|
|
44
|
-
muted: {
|
|
45
|
-
DEFAULT: 'hsl(var(--muted))',
|
|
46
|
-
foreground: 'hsl(var(--muted-foreground))'
|
|
47
|
-
},
|
|
48
|
-
accent: {
|
|
49
|
-
DEFAULT: 'hsl(var(--accent))',
|
|
50
|
-
foreground: 'hsl(var(--accent-foreground))'
|
|
51
|
-
},
|
|
52
|
-
popover: {
|
|
53
|
-
DEFAULT: 'hsl(var(--popover))',
|
|
54
|
-
foreground: 'hsl(var(--popover-foreground))'
|
|
55
|
-
},
|
|
56
|
-
card: {
|
|
57
|
-
DEFAULT: 'hsl(var(--card))',
|
|
58
|
-
foreground: 'hsl(var(--card-foreground))'
|
|
59
|
-
},
|
|
60
|
-
sidebar: {
|
|
61
|
-
DEFAULT: 'hsl(var(--sidebar-background))',
|
|
62
|
-
foreground: 'hsl(var(--sidebar-foreground))',
|
|
63
|
-
primary: 'hsl(var(--sidebar-primary))',
|
|
64
|
-
'primary-foreground': 'hsl(var(--sidebar-primary-foreground))',
|
|
65
|
-
accent: 'hsl(var(--sidebar-accent))',
|
|
66
|
-
'accent-foreground': 'hsl(var(--sidebar-accent-foreground))',
|
|
67
|
-
border: 'hsl(var(--sidebar-border))',
|
|
68
|
-
ring: 'hsl(var(--sidebar-ring))'
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
borderRadius: {
|
|
72
|
-
lg: 'var(--radius)',
|
|
73
|
-
md: 'calc(var(--radius) - 2px)',
|
|
74
|
-
sm: 'calc(var(--radius) - 4px)'
|
|
75
|
-
},
|
|
76
|
-
keyframes: {
|
|
77
|
-
'accordion-down': {
|
|
78
|
-
from: {
|
|
79
|
-
height: '0'
|
|
80
|
-
},
|
|
81
|
-
to: {
|
|
82
|
-
height: 'var(--radix-accordion-content-height)'
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
'accordion-up': {
|
|
86
|
-
from: {
|
|
87
|
-
height: 'var(--radix-accordion-content-height)'
|
|
88
|
-
},
|
|
89
|
-
to: {
|
|
90
|
-
height: '0'
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
animation: {
|
|
95
|
-
'accordion-down': 'accordion-down 0.2s ease-out',
|
|
96
|
-
'accordion-up': 'accordion-up 0.2s ease-out'
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
plugins: [tailwindAnimate],
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export default config
|
package/tsconfig.app.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
-
"target": "es2023",
|
|
5
|
-
"lib": ["ES2023", "DOM"],
|
|
6
|
-
"module": "esnext",
|
|
7
|
-
"types": ["vite/client"],
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"paths": {
|
|
10
|
-
"@/*": ["./src/*"]
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
/* Bundler mode */
|
|
14
|
-
"moduleResolution": "bundler",
|
|
15
|
-
"allowImportingTsExtensions": true,
|
|
16
|
-
"verbatimModuleSyntax": true,
|
|
17
|
-
"moduleDetection": "force",
|
|
18
|
-
"noEmit": true,
|
|
19
|
-
"jsx": "react-jsx",
|
|
20
|
-
|
|
21
|
-
/* Linting */
|
|
22
|
-
"noUnusedLocals": true,
|
|
23
|
-
"noUnusedParameters": true,
|
|
24
|
-
"erasableSyntaxOnly": true,
|
|
25
|
-
"noFallthroughCasesInSwitch": true
|
|
26
|
-
},
|
|
27
|
-
"include": ["src"]
|
|
28
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.node.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
-
"target": "es2023",
|
|
5
|
-
"lib": ["ES2023"],
|
|
6
|
-
"module": "esnext",
|
|
7
|
-
"types": ["node"],
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"paths": {},
|
|
10
|
-
|
|
11
|
-
/* Bundler mode */
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"verbatimModuleSyntax": true,
|
|
15
|
-
"moduleDetection": "force",
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
|
|
18
|
-
/* Linting */
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"erasableSyntaxOnly": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true
|
|
23
|
-
},
|
|
24
|
-
"include": ["vite.config.ts"]
|
|
25
|
-
}
|
package/vite.config.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { defineConfig } from "vite";
|
|
3
|
-
import react from "@vitejs/plugin-react";
|
|
4
|
-
import { nodePolyfills } from "vite-plugin-node-polyfills";
|
|
5
|
-
import dts from "vite-plugin-dts";
|
|
6
|
-
|
|
7
|
-
// https://vite.dev/config/
|
|
8
|
-
export default defineConfig({
|
|
9
|
-
plugins: [
|
|
10
|
-
react(),
|
|
11
|
-
dts({
|
|
12
|
-
tsconfigPath: "./tsconfig.app.json",
|
|
13
|
-
insertTypesEntry: true,
|
|
14
|
-
}),
|
|
15
|
-
nodePolyfills({
|
|
16
|
-
// Whether to polyfill `node:` protocol imports.
|
|
17
|
-
protocolImports: true,
|
|
18
|
-
}),
|
|
19
|
-
],
|
|
20
|
-
build: {
|
|
21
|
-
lib: {
|
|
22
|
-
entry: path.resolve(__dirname, "src/index.tsx"),
|
|
23
|
-
name: "DyrectedAdmin",
|
|
24
|
-
fileName: () => "index.mjs",
|
|
25
|
-
formats: ["es"],
|
|
26
|
-
},
|
|
27
|
-
rollupOptions: {
|
|
28
|
-
output: {
|
|
29
|
-
format: "es",
|
|
30
|
-
manualChunks: undefined,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
resolve: {
|
|
35
|
-
alias: {
|
|
36
|
-
"@": path.resolve(__dirname, "./src"),
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
});
|
|
File without changes
|
|
File without changes
|