@kyro-cms/admin 0.1.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/.astro/content.d.ts +154 -0
- package/.astro/settings.json +5 -0
- package/.astro/types.d.ts +2 -0
- package/astro.config.mjs +28 -0
- package/bun.lock +1374 -0
- package/dist/client/_astro/AdminLayout.DkDpng53.css +1 -0
- package/dist/client/_astro/AutoForm.3eJCmCJp.js +1 -0
- package/dist/client/_astro/client.DyczpTbx.js +9 -0
- package/dist/client/_astro/index.B02hbnpo.js +1 -0
- package/dist/client/fonts/Serotiva-Black.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Bold.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Medium.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Regular.woff2 +0 -0
- package/dist/client/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/dist/server/chunks/AdminLayout_D-_JeUqC.mjs +26 -0
- package/dist/server/chunks/_id__BzI_o0qT.mjs +50 -0
- package/dist/server/chunks/_id__Cd-jOuY3.mjs +238 -0
- package/dist/server/chunks/_id__DvbD--iR.mjs +992 -0
- package/dist/server/chunks/_id__vpVaEo16.mjs +128 -0
- package/dist/server/chunks/_virtual_astro_server-island-manifest_CQQ1F5PF.mjs +7 -0
- package/dist/server/chunks/_virtual_astro_session-driver_Bk3Q189E.mjs +4 -0
- package/dist/server/chunks/astro-component_Dbx3T2Nh.mjs +37 -0
- package/dist/server/chunks/audit-logs_DrnUMRvY.mjs +74 -0
- package/dist/server/chunks/config_CPXslElD.mjs +4221 -0
- package/dist/server/chunks/dataStore_Dl7cA2Qp.mjs +89 -0
- package/dist/server/chunks/index_CVqOkerS.mjs +2960 -0
- package/dist/server/chunks/index_CX8SQ4BF.mjs +55 -0
- package/dist/server/chunks/index_CYofDU51.mjs +58 -0
- package/dist/server/chunks/index_DdNRhuaM.mjs +55 -0
- package/dist/server/chunks/index_DupPvtIF.mjs +42 -0
- package/dist/server/chunks/index_YTS_M-B9.mjs +263 -0
- package/dist/server/chunks/index_YeCzuVps.mjs +53 -0
- package/dist/server/chunks/login_DLyqMRO8.mjs +93 -0
- package/dist/server/chunks/logout_CSbt5wea.mjs +50 -0
- package/dist/server/chunks/me_C04jlYhH.mjs +41 -0
- package/dist/server/chunks/new_BbQ9b55M.mjs +92 -0
- package/dist/server/chunks/node_9bvTewss.mjs +1014 -0
- package/dist/server/chunks/noop-entrypoint_BOlrdqWF.mjs +3 -0
- package/dist/server/chunks/sequence_9cl7AJy-.mjs +2503 -0
- package/dist/server/chunks/server_peBx9VXG.mjs +8117 -0
- package/dist/server/chunks/sharp_pmJ7nHES.mjs +142 -0
- package/dist/server/chunks/users_Dzddy_YR.mjs +137 -0
- package/dist/server/entry.mjs +5 -0
- package/dist/server/virtual_astro_middleware.mjs +48 -0
- package/package.json +33 -0
- package/public/fonts/Serotiva-Black.woff2 +0 -0
- package/public/fonts/Serotiva-Bold.woff2 +0 -0
- package/public/fonts/Serotiva-Medium.woff2 +0 -0
- package/public/fonts/Serotiva-Regular.woff2 +0 -0
- package/public/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/src/collections/auth/index.ts +155 -0
- package/src/components/ActionBar.tsx +215 -0
- package/src/components/Admin.tsx +214 -0
- package/src/components/AutoForm.tsx +1123 -0
- package/src/components/BulkActionsBar.tsx +80 -0
- package/src/components/CreateView.tsx +99 -0
- package/src/components/DetailView.tsx +329 -0
- package/src/components/Icons.tsx +23 -0
- package/src/components/ListView.tsx +192 -0
- package/src/components/StatusBadge.tsx +76 -0
- package/src/components/ThemeProvider.tsx +155 -0
- package/src/components/VersionHistoryPanel.tsx +205 -0
- package/src/components/fields/CheckboxField.tsx +37 -0
- package/src/components/fields/DateField.tsx +42 -0
- package/src/components/fields/NumberField.tsx +44 -0
- package/src/components/fields/RelationshipField.tsx +87 -0
- package/src/components/fields/SelectField.tsx +56 -0
- package/src/components/fields/TextField.tsx +49 -0
- package/src/components/index.ts +30 -0
- package/src/components/layout/Breadcrumbs.tsx +36 -0
- package/src/components/layout/Header.tsx +37 -0
- package/src/components/layout/Layout.tsx +25 -0
- package/src/components/layout/Sidebar.tsx +462 -0
- package/src/components/ui/Badge.tsx +14 -0
- package/src/components/ui/Button.tsx +41 -0
- package/src/components/ui/Dropdown.tsx +82 -0
- package/src/components/ui/Modal.tsx +135 -0
- package/src/components/ui/SlidePanel.tsx +73 -0
- package/src/components/ui/Spinner.tsx +24 -0
- package/src/components/ui/Toast.tsx +78 -0
- package/src/layouts/AdminLayout.astro +197 -0
- package/src/lib/config.ts +68 -0
- package/src/lib/dataStore.ts +111 -0
- package/src/middleware.ts +48 -0
- package/src/pages/[collection]/[id].astro +176 -0
- package/src/pages/[collection]/index.astro +180 -0
- package/src/pages/api/[collection]/[id].ts +258 -0
- package/src/pages/api/[collection]/index.ts +289 -0
- package/src/pages/api/auth/[id].ts +142 -0
- package/src/pages/api/auth/audit-logs.ts +80 -0
- package/src/pages/api/auth/login.ts +101 -0
- package/src/pages/api/auth/logout.ts +48 -0
- package/src/pages/api/auth/me.ts +36 -0
- package/src/pages/api/auth/users.ts +150 -0
- package/src/pages/audit/index.astro +110 -0
- package/src/pages/index.astro +225 -0
- package/src/pages/roles/index.astro +114 -0
- package/src/pages/users/[id].astro +174 -0
- package/src/pages/users/index.astro +142 -0
- package/src/pages/users/new.astro +91 -0
- package/src/styles/main.css +1449 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
class DataStore {
|
|
2
|
+
data = /* @__PURE__ */ new Map();
|
|
3
|
+
metadata = /* @__PURE__ */ new Map();
|
|
4
|
+
idCounters = /* @__PURE__ */ new Map();
|
|
5
|
+
initialize(collections) {
|
|
6
|
+
for (const [slug, config] of Object.entries(collections)) {
|
|
7
|
+
if (!this.data.has(slug)) {
|
|
8
|
+
this.data.set(slug, []);
|
|
9
|
+
this.idCounters.set(slug, 1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
generateId(slug) {
|
|
14
|
+
const counter = this.idCounters.get(slug) || 1;
|
|
15
|
+
this.idCounters.set(slug, counter + 1);
|
|
16
|
+
return `${slug}-${counter}`;
|
|
17
|
+
}
|
|
18
|
+
getTimestamp() {
|
|
19
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
20
|
+
}
|
|
21
|
+
find(slug, options = {}) {
|
|
22
|
+
const docs = this.data.get(slug) || [];
|
|
23
|
+
const page = options.page || 1;
|
|
24
|
+
const limit = options.limit || 25;
|
|
25
|
+
const start = (page - 1) * limit;
|
|
26
|
+
const end = start + limit;
|
|
27
|
+
return {
|
|
28
|
+
docs: docs.slice(start, end),
|
|
29
|
+
totalDocs: docs.length,
|
|
30
|
+
totalPages: Math.ceil(docs.length / limit),
|
|
31
|
+
page
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
findById(slug, id) {
|
|
35
|
+
const docs = this.data.get(slug) || [];
|
|
36
|
+
return docs.find((d) => d.id === id) || null;
|
|
37
|
+
}
|
|
38
|
+
create(slug, data) {
|
|
39
|
+
const docs = this.data.get(slug) || [];
|
|
40
|
+
const now = this.getTimestamp();
|
|
41
|
+
const newDoc = {
|
|
42
|
+
id: this.generateId(slug),
|
|
43
|
+
...data,
|
|
44
|
+
createdAt: now,
|
|
45
|
+
updatedAt: now
|
|
46
|
+
};
|
|
47
|
+
docs.push(newDoc);
|
|
48
|
+
this.data.set(slug, docs);
|
|
49
|
+
this.metadata.set(`${slug}:${newDoc.id}`, {
|
|
50
|
+
createdAt: now,
|
|
51
|
+
updatedAt: now
|
|
52
|
+
});
|
|
53
|
+
return newDoc;
|
|
54
|
+
}
|
|
55
|
+
update(slug, id, data) {
|
|
56
|
+
const docs = this.data.get(slug) || [];
|
|
57
|
+
const index = docs.findIndex((d) => d.id === id);
|
|
58
|
+
if (index === -1) return null;
|
|
59
|
+
const now = this.getTimestamp();
|
|
60
|
+
const updated = {
|
|
61
|
+
...docs[index],
|
|
62
|
+
...data,
|
|
63
|
+
id,
|
|
64
|
+
updatedAt: now
|
|
65
|
+
};
|
|
66
|
+
docs[index] = updated;
|
|
67
|
+
this.data.set(slug, docs);
|
|
68
|
+
this.metadata.set(`${slug}:${id}`, {
|
|
69
|
+
createdAt: docs[index].createdAt,
|
|
70
|
+
updatedAt: now
|
|
71
|
+
});
|
|
72
|
+
return updated;
|
|
73
|
+
}
|
|
74
|
+
delete(slug, id) {
|
|
75
|
+
const docs = this.data.get(slug) || [];
|
|
76
|
+
const index = docs.findIndex((d) => d.id === id);
|
|
77
|
+
if (index === -1) return false;
|
|
78
|
+
docs.splice(index, 1);
|
|
79
|
+
this.data.set(slug, docs);
|
|
80
|
+
this.metadata.delete(`${slug}:${id}`);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
count(slug) {
|
|
84
|
+
return (this.data.get(slug) || []).length;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const dataStore = new DataStore();
|
|
88
|
+
|
|
89
|
+
export { dataStore as d };
|