@arch-cadre/blog-module 1.0.7 → 1.0.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/dist/actions/index.d.ts +38 -5
- package/dist/actions/index.js +149 -0
- package/dist/components/BlogStatsWidget.d.ts +1 -2
- package/dist/components/BlogStatsWidget.js +17 -0
- package/dist/components/RecentCommentsWidget.d.ts +1 -2
- package/dist/components/RecentCommentsWidget.js +24 -0
- package/dist/components/RecentPostsWidget.d.ts +1 -2
- package/dist/components/RecentPostsWidget.js +24 -0
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/button.js +33 -0
- package/dist/components/ui/card.js +12 -0
- package/dist/components/ui/input.js +8 -0
- package/dist/components/ui/table.js +16 -0
- package/dist/components/ui/textarea.js +8 -0
- package/dist/index.js +98 -0
- package/dist/lib/{utils.mjs → utils.js} +1 -1
- package/dist/lib/validation.d.ts +2 -2
- package/dist/lib/validation.js +11 -0
- package/dist/navigation.js +21 -0
- package/dist/routes.js +55 -0
- package/dist/schema.js +60 -0
- package/dist/ui/views.d.ts +5 -6
- package/dist/ui/views.js +119 -0
- package/package.json +11 -17
- package/src/actions/index.d.ts +67 -0
- package/src/actions/index.js +149 -0
- package/src/actions/index.ts +157 -0
- package/src/components/BlogStatsWidget.d.ts +1 -0
- package/src/components/BlogStatsWidget.js +17 -0
- package/src/components/BlogStatsWidget.tsx +46 -0
- package/src/components/RecentCommentsWidget.d.ts +1 -0
- package/src/components/RecentCommentsWidget.js +24 -0
- package/src/components/RecentCommentsWidget.tsx +71 -0
- package/src/components/RecentPostsWidget.d.ts +1 -0
- package/src/components/RecentPostsWidget.js +24 -0
- package/src/components/RecentPostsWidget.tsx +68 -0
- package/src/components/ui/button.d.ts +11 -0
- package/src/components/ui/button.js +33 -0
- package/src/components/ui/button.tsx +56 -0
- package/src/components/ui/card.d.ts +6 -0
- package/src/components/ui/card.js +12 -0
- package/src/components/ui/card.tsx +51 -0
- package/src/components/ui/input.d.ts +5 -0
- package/src/components/ui/input.js +8 -0
- package/{dist/components/ui/input.mjs → src/components/ui/input.tsx} +17 -13
- package/src/components/ui/table.d.ts +8 -0
- package/src/components/ui/table.js +16 -0
- package/src/components/ui/table.tsx +83 -0
- package/src/components/ui/textarea.d.ts +5 -0
- package/src/components/ui/textarea.js +8 -0
- package/{dist/components/ui/textarea.mjs → src/components/ui/textarea.tsx} +16 -12
- package/src/index.d.ts +3 -0
- package/src/index.js +98 -0
- package/{dist/index.mjs → src/index.ts} +44 -18
- package/src/lib/utils.d.ts +2 -0
- package/src/lib/utils.js +5 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/validation.d.ts +24 -0
- package/src/lib/validation.js +11 -0
- package/{dist/lib/validation.mjs → src/lib/validation.ts} +5 -2
- package/src/navigation.d.ts +2 -0
- package/src/navigation.js +21 -0
- package/{dist/navigation.mjs → src/navigation.ts} +9 -7
- package/src/routes.d.ts +3 -0
- package/src/routes.js +55 -0
- package/{dist/routes.mjs → src/routes.tsx} +30 -24
- package/src/schema.d.ts +736 -0
- package/src/schema.js +60 -0
- package/src/schema.ts +67 -0
- package/src/styles/globals.css +123 -0
- package/src/ui/views.d.ts +15 -0
- package/src/ui/views.js +119 -0
- package/src/ui/views.tsx +538 -0
- package/dist/actions/index.cjs +0 -158
- package/dist/actions/index.mjs +0 -121
- package/dist/components/BlogStatsWidget.cjs +0 -45
- package/dist/components/BlogStatsWidget.mjs +0 -13
- package/dist/components/RecentCommentsWidget.cjs +0 -47
- package/dist/components/RecentCommentsWidget.mjs +0 -28
- package/dist/components/RecentPostsWidget.cjs +0 -47
- package/dist/components/RecentPostsWidget.mjs +0 -28
- package/dist/components/ui/button.cjs +0 -53
- package/dist/components/ui/button.mjs +0 -44
- package/dist/components/ui/card.cjs +0 -46
- package/dist/components/ui/card.mjs +0 -35
- package/dist/components/ui/input.cjs +0 -23
- package/dist/components/ui/table.cjs +0 -66
- package/dist/components/ui/table.mjs +0 -59
- package/dist/components/ui/textarea.cjs +0 -21
- package/dist/index.cjs +0 -100
- package/dist/lib/utils.cjs +0 -11
- package/dist/lib/validation.cjs +0 -16
- package/dist/navigation.cjs +0 -23
- package/dist/routes.cjs +0 -74
- package/dist/schema.cjs +0 -62
- package/dist/schema.mjs +0 -53
- package/dist/styles/globals.css +0 -1
- package/dist/ui/views.cjs +0 -448
- package/dist/ui/views.mjs +0 -232
- /package/{dist → src}/intl.d.ts +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { cn } from "../../lib/utils.mjs";
|
|
3
|
-
const Table = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement("div", { className: "relative w-full overflow-auto" }, /* @__PURE__ */ React.createElement(
|
|
4
|
-
"table",
|
|
5
|
-
{
|
|
6
|
-
ref,
|
|
7
|
-
className: cn("w-full caption-bottom text-sm", className),
|
|
8
|
-
...props
|
|
9
|
-
}
|
|
10
|
-
)));
|
|
11
|
-
Table.displayName = "Table";
|
|
12
|
-
const TableHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
13
|
-
TableHeader.displayName = "TableHeader";
|
|
14
|
-
const TableBody = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
15
|
-
"tbody",
|
|
16
|
-
{
|
|
17
|
-
ref,
|
|
18
|
-
className: cn("[&_tr:last-child]:border-0", className),
|
|
19
|
-
...props
|
|
20
|
-
}
|
|
21
|
-
));
|
|
22
|
-
TableBody.displayName = "TableBody";
|
|
23
|
-
const TableRow = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
24
|
-
"tr",
|
|
25
|
-
{
|
|
26
|
-
ref,
|
|
27
|
-
className: cn(
|
|
28
|
-
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
29
|
-
className
|
|
30
|
-
),
|
|
31
|
-
...props
|
|
32
|
-
}
|
|
33
|
-
));
|
|
34
|
-
TableRow.displayName = "TableRow";
|
|
35
|
-
const TableHead = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
36
|
-
"th",
|
|
37
|
-
{
|
|
38
|
-
ref,
|
|
39
|
-
className: cn(
|
|
40
|
-
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
41
|
-
className
|
|
42
|
-
),
|
|
43
|
-
...props
|
|
44
|
-
}
|
|
45
|
-
));
|
|
46
|
-
TableHead.displayName = "TableHead";
|
|
47
|
-
const TableCell = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
48
|
-
"td",
|
|
49
|
-
{
|
|
50
|
-
ref,
|
|
51
|
-
className: cn(
|
|
52
|
-
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
53
|
-
className
|
|
54
|
-
),
|
|
55
|
-
...props
|
|
56
|
-
}
|
|
57
|
-
));
|
|
58
|
-
TableCell.displayName = "TableCell";
|
|
59
|
-
export { Table, TableHeader, TableBody, TableHead, TableRow, TableCell };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Textarea = void 0;
|
|
7
|
-
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _utils = require("../../lib/utils.cjs");
|
|
9
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
-
const Textarea = exports.Textarea = React.forwardRef(({
|
|
12
|
-
className,
|
|
13
|
-
...props
|
|
14
|
-
}, ref) => {
|
|
15
|
-
return /* @__PURE__ */React.createElement("textarea", {
|
|
16
|
-
className: (0, _utils.cn)("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50", className),
|
|
17
|
-
ref,
|
|
18
|
-
...props
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
Textarea.displayName = "Textarea";
|
package/dist/index.cjs
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _server = require("@arch-cadre/core/server");
|
|
8
|
-
var _drizzleOrm = require("drizzle-orm");
|
|
9
|
-
var _manifest = _interopRequireDefault(require("../manifest.json"));
|
|
10
|
-
var _BlogStatsWidget = _interopRequireDefault(require("./components/BlogStatsWidget.cjs"));
|
|
11
|
-
var _RecentCommentsWidget = _interopRequireDefault(require("./components/RecentCommentsWidget.cjs"));
|
|
12
|
-
var _RecentPostsWidget = _interopRequireDefault(require("./components/RecentPostsWidget.cjs"));
|
|
13
|
-
var _navigation = require("./navigation.cjs");
|
|
14
|
-
var _routes = require("./routes.cjs");
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
const BLOG_PERMISSIONS = [{
|
|
17
|
-
name: "post:create",
|
|
18
|
-
description: "Allow creating blog posts"
|
|
19
|
-
}, {
|
|
20
|
-
name: "post:update",
|
|
21
|
-
description: "Allow updating blog posts"
|
|
22
|
-
}, {
|
|
23
|
-
name: "post:delete",
|
|
24
|
-
description: "Allow deleting blog posts"
|
|
25
|
-
}, {
|
|
26
|
-
name: "comment:create",
|
|
27
|
-
description: "Allow creating comments"
|
|
28
|
-
}, {
|
|
29
|
-
name: "comment:update",
|
|
30
|
-
description: "Allow updating comments"
|
|
31
|
-
}, {
|
|
32
|
-
name: "comment:delete",
|
|
33
|
-
description: "Allow deleting comments"
|
|
34
|
-
}];
|
|
35
|
-
const blogModule = {
|
|
36
|
-
manifest: _manifest.default,
|
|
37
|
-
init: async () => {
|
|
38
|
-
console.log("[BlogModule] ready.");
|
|
39
|
-
},
|
|
40
|
-
widgets: [{
|
|
41
|
-
id: "blog-stats",
|
|
42
|
-
name: "Blog Stats",
|
|
43
|
-
area: "dashboard-stats",
|
|
44
|
-
component: _BlogStatsWidget.default,
|
|
45
|
-
priority: 20
|
|
46
|
-
}, {
|
|
47
|
-
id: "recent-posts",
|
|
48
|
-
name: "Recent Posts",
|
|
49
|
-
area: "dashboard-main",
|
|
50
|
-
component: _RecentPostsWidget.default,
|
|
51
|
-
priority: 20
|
|
52
|
-
}, {
|
|
53
|
-
id: "recent-comments",
|
|
54
|
-
name: "Recent Comments",
|
|
55
|
-
area: "dashboard-main",
|
|
56
|
-
component: _RecentCommentsWidget.default,
|
|
57
|
-
priority: 30
|
|
58
|
-
}],
|
|
59
|
-
onEnable: async () => {
|
|
60
|
-
console.log("[BlogModule] enabling and registering permissions...");
|
|
61
|
-
try {
|
|
62
|
-
for (const perm of BLOG_PERMISSIONS) {
|
|
63
|
-
await (0, _server.createPermission)(perm.name, perm.description);
|
|
64
|
-
}
|
|
65
|
-
const roles = await (0, _server.getRoles)();
|
|
66
|
-
const adminRole = roles.find(r => r.name === "admin");
|
|
67
|
-
if (adminRole) {
|
|
68
|
-
const blogPermNames = BLOG_PERMISSIONS.map(p => p.name);
|
|
69
|
-
const blogPerms = await _server.db.select().from(_server.permissionsTable).where((0, _drizzleOrm.inArray)(_server.permissionsTable.name, blogPermNames));
|
|
70
|
-
for (const p of blogPerms) {
|
|
71
|
-
await (0, _server.assignPermissionToRole)(adminRole.id, p.id);
|
|
72
|
-
}
|
|
73
|
-
console.log("[BlogModule] Permissions assigned to admin role.");
|
|
74
|
-
}
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error("[BlogModule] Error during permission registration:", error);
|
|
77
|
-
}
|
|
78
|
-
console.log("[BlogModule] enabled.");
|
|
79
|
-
},
|
|
80
|
-
onDisable: async () => {
|
|
81
|
-
console.log("[Blog] onDisable: Cleaning up tables and permissions...");
|
|
82
|
-
try {
|
|
83
|
-
const blogPermNames = BLOG_PERMISSIONS.map(p => p.name);
|
|
84
|
-
await _server.db.delete(_server.permissionsTable).where((0, _drizzleOrm.inArray)(_server.permissionsTable.name, blogPermNames));
|
|
85
|
-
console.log("[BlogModule] Permissions and mappings removed.");
|
|
86
|
-
const tables = ["blog_posts", "blog_comments"];
|
|
87
|
-
for (const table of tables) {
|
|
88
|
-
await _server.db.execute(_drizzleOrm.sql.raw(`DROP TABLE IF EXISTS ${table} CASCADE`));
|
|
89
|
-
}
|
|
90
|
-
} catch (e) {
|
|
91
|
-
console.error("[Blog] onDisable Error:", e);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
routes: {
|
|
95
|
-
public: _routes.publicRoutes,
|
|
96
|
-
private: _routes.privateRoutes
|
|
97
|
-
},
|
|
98
|
-
navigation: _navigation.navigation
|
|
99
|
-
};
|
|
100
|
-
module.exports = blogModule;
|
package/dist/lib/utils.cjs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.cn = cn;
|
|
7
|
-
var _clsx = require("clsx");
|
|
8
|
-
var _tailwindMerge = require("tailwind-merge");
|
|
9
|
-
function cn(...inputs) {
|
|
10
|
-
return (0, _tailwindMerge.twMerge)((0, _clsx.clsx)(inputs));
|
|
11
|
-
}
|
package/dist/lib/validation.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.postSchema = exports.commentSchema = void 0;
|
|
7
|
-
var _zod = require("zod");
|
|
8
|
-
const postSchema = exports.postSchema = _zod.z.object({
|
|
9
|
-
title: _zod.z.string().min(3, "Title must be at least 3 characters"),
|
|
10
|
-
content: _zod.z.string().min(10, "Content must be at least 10 characters"),
|
|
11
|
-
slug: _zod.z.string().min(3, "Slug is required")
|
|
12
|
-
});
|
|
13
|
-
const commentSchema = exports.commentSchema = _zod.z.object({
|
|
14
|
-
content: _zod.z.string().min(2, "Comment is too short"),
|
|
15
|
-
postId: _zod.z.string().uuid()
|
|
16
|
-
});
|
package/dist/navigation.cjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.navigation = void 0;
|
|
7
|
-
var _intl = require("@arch-cadre/intl");
|
|
8
|
-
const navigation = exports.navigation = {
|
|
9
|
-
public: [{
|
|
10
|
-
title: (0, _intl.i18n)("Blog"),
|
|
11
|
-
url: "/blog",
|
|
12
|
-
icon: "solar:pen-2-broken"
|
|
13
|
-
}],
|
|
14
|
-
admin: {
|
|
15
|
-
[(0, _intl.i18n)("CMS")]: [{
|
|
16
|
-
title: (0, _intl.i18n)("Blog Manager"),
|
|
17
|
-
url: "/blog",
|
|
18
|
-
icon: "solar:posts-carousel-vertical-broken",
|
|
19
|
-
roles: ["admin"],
|
|
20
|
-
permissions: ["post:create", "post:update", "post:delete"]
|
|
21
|
-
}]
|
|
22
|
-
}
|
|
23
|
-
};
|
package/dist/routes.cjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.publicRoutes = exports.privateRoutes = void 0;
|
|
7
|
-
var _server = require("@arch-cadre/core/server");
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _actions = require("./actions/index.cjs");
|
|
10
|
-
var _views = require("./ui/views.cjs");
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
|
-
const publicRoutes = exports.publicRoutes = [{
|
|
14
|
-
path: "/blog",
|
|
15
|
-
component: async () => {
|
|
16
|
-
const posts = await (0, _actions.getPosts)();
|
|
17
|
-
return /* @__PURE__ */React.createElement(_views.BlogListPage, {
|
|
18
|
-
posts
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
auth: false
|
|
22
|
-
}, {
|
|
23
|
-
path: "/blog/:slug",
|
|
24
|
-
component: async ({
|
|
25
|
-
params
|
|
26
|
-
}) => {
|
|
27
|
-
const {
|
|
28
|
-
slug
|
|
29
|
-
} = await params;
|
|
30
|
-
const post = await (0, _actions.getPostBySlug)(slug);
|
|
31
|
-
const comments = post ? await (0, _actions.getComments)(post.id) : [];
|
|
32
|
-
const session = await (0, _server.getCurrentSession)();
|
|
33
|
-
return /* @__PURE__ */React.createElement(_views.PostDetailPage, {
|
|
34
|
-
post,
|
|
35
|
-
comments,
|
|
36
|
-
currentUser: session?.user
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
auth: false
|
|
40
|
-
}];
|
|
41
|
-
const privateRoutes = exports.privateRoutes = [{
|
|
42
|
-
path: "/blog",
|
|
43
|
-
component: async () => {
|
|
44
|
-
const posts = await (0, _actions.getPosts)();
|
|
45
|
-
return /* @__PURE__ */React.createElement(_views.BlogAdminPage, {
|
|
46
|
-
posts
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
auth: true,
|
|
50
|
-
roles: ["admin"],
|
|
51
|
-
permissions: ["post:create", "post:update", "post:delete"]
|
|
52
|
-
}, {
|
|
53
|
-
path: "/blog/new",
|
|
54
|
-
component: _views.CreatePostForm,
|
|
55
|
-
auth: true,
|
|
56
|
-
roles: ["admin"],
|
|
57
|
-
permissions: ["post:create"]
|
|
58
|
-
}, {
|
|
59
|
-
path: "/blog/edit/:id",
|
|
60
|
-
component: async ({
|
|
61
|
-
params
|
|
62
|
-
}) => {
|
|
63
|
-
const {
|
|
64
|
-
id
|
|
65
|
-
} = await params;
|
|
66
|
-
const post = await (0, _actions.getPostById)(id);
|
|
67
|
-
return /* @__PURE__ */React.createElement(_views.EditPostForm, {
|
|
68
|
-
post
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
auth: true,
|
|
72
|
-
roles: ["admin"],
|
|
73
|
-
permissions: ["post:update"]
|
|
74
|
-
}];
|
package/dist/schema.cjs
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.relations = exports.postsTable = exports.commentsTable = exports.blogSchema = void 0;
|
|
7
|
-
var _core = require("@arch-cadre/core");
|
|
8
|
-
var _drizzleOrm = require("drizzle-orm");
|
|
9
|
-
var _pgCore = require("drizzle-orm/pg-core");
|
|
10
|
-
const postsTable = exports.postsTable = (0, _pgCore.pgTable)("blog_posts", {
|
|
11
|
-
id: (0, _pgCore.text)("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
12
|
-
title: (0, _pgCore.text)("title").notNull(),
|
|
13
|
-
slug: (0, _pgCore.text)("slug").unique().notNull(),
|
|
14
|
-
content: (0, _pgCore.text)("content").notNull(),
|
|
15
|
-
authorId: (0, _pgCore.text)("author_id").references(() => _core.userTable.id, {
|
|
16
|
-
onDelete: "cascade"
|
|
17
|
-
}).notNull(),
|
|
18
|
-
createdAt: (0, _pgCore.timestamp)("created_at").defaultNow().notNull()
|
|
19
|
-
});
|
|
20
|
-
const commentsTable = exports.commentsTable = (0, _pgCore.pgTable)("blog_comments", {
|
|
21
|
-
id: (0, _pgCore.text)("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
22
|
-
postId: (0, _pgCore.text)("post_id").references(() => postsTable.id, {
|
|
23
|
-
onDelete: "cascade"
|
|
24
|
-
}).notNull(),
|
|
25
|
-
authorId: (0, _pgCore.text)("author_id").references(() => _core.userTable.id, {
|
|
26
|
-
onDelete: "cascade"
|
|
27
|
-
}).notNull(),
|
|
28
|
-
content: (0, _pgCore.text)("content").notNull(),
|
|
29
|
-
createdAt: (0, _pgCore.timestamp)("created_at").defaultNow().notNull()
|
|
30
|
-
});
|
|
31
|
-
const blogSchema = exports.blogSchema = {
|
|
32
|
-
postsTable,
|
|
33
|
-
commentsTable
|
|
34
|
-
};
|
|
35
|
-
const relations = exports.relations = (0, _drizzleOrm.defineRelations)({
|
|
36
|
-
user: _core.userTable,
|
|
37
|
-
post: postsTable,
|
|
38
|
-
comment: commentsTable
|
|
39
|
-
}, r => ({
|
|
40
|
-
user: {
|
|
41
|
-
posts: r.many.post({
|
|
42
|
-
from: r.user.id,
|
|
43
|
-
to: r.post.authorId
|
|
44
|
-
}),
|
|
45
|
-
comments: r.many.comment({
|
|
46
|
-
from: r.user.id,
|
|
47
|
-
to: r.comment.authorId
|
|
48
|
-
})
|
|
49
|
-
},
|
|
50
|
-
post: {
|
|
51
|
-
comments: r.many.comment({
|
|
52
|
-
from: r.post.id,
|
|
53
|
-
to: r.comment.postId
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
|
-
comment: {
|
|
57
|
-
post: r.one.post({
|
|
58
|
-
from: r.comment.postId,
|
|
59
|
-
to: r.post.id
|
|
60
|
-
})
|
|
61
|
-
}
|
|
62
|
-
}));
|
package/dist/schema.mjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { userTable } from "@arch-cadre/core";
|
|
2
|
-
import { defineRelations } from "drizzle-orm";
|
|
3
|
-
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
4
|
-
export const postsTable = pgTable("blog_posts", {
|
|
5
|
-
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
6
|
-
title: text("title").notNull(),
|
|
7
|
-
slug: text("slug").unique().notNull(),
|
|
8
|
-
content: text("content").notNull(),
|
|
9
|
-
authorId: text("author_id").references(() => userTable.id, { onDelete: "cascade" }).notNull(),
|
|
10
|
-
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
11
|
-
});
|
|
12
|
-
export const commentsTable = pgTable("blog_comments", {
|
|
13
|
-
id: text("id").primaryKey().$defaultFn(() => crypto.randomUUID()),
|
|
14
|
-
postId: text("post_id").references(() => postsTable.id, { onDelete: "cascade" }).notNull(),
|
|
15
|
-
authorId: text("author_id").references(() => userTable.id, { onDelete: "cascade" }).notNull(),
|
|
16
|
-
content: text("content").notNull(),
|
|
17
|
-
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
18
|
-
});
|
|
19
|
-
export const blogSchema = {
|
|
20
|
-
postsTable,
|
|
21
|
-
commentsTable
|
|
22
|
-
};
|
|
23
|
-
export const relations = defineRelations(
|
|
24
|
-
{
|
|
25
|
-
user: userTable,
|
|
26
|
-
post: postsTable,
|
|
27
|
-
comment: commentsTable
|
|
28
|
-
},
|
|
29
|
-
(r) => ({
|
|
30
|
-
user: {
|
|
31
|
-
posts: r.many.post({
|
|
32
|
-
from: r.user.id,
|
|
33
|
-
to: r.post.authorId
|
|
34
|
-
}),
|
|
35
|
-
comments: r.many.comment({
|
|
36
|
-
from: r.user.id,
|
|
37
|
-
to: r.comment.authorId
|
|
38
|
-
})
|
|
39
|
-
},
|
|
40
|
-
post: {
|
|
41
|
-
comments: r.many.comment({
|
|
42
|
-
from: r.post.id,
|
|
43
|
-
to: r.comment.postId
|
|
44
|
-
})
|
|
45
|
-
},
|
|
46
|
-
comment: {
|
|
47
|
-
post: r.one.post({
|
|
48
|
-
from: r.comment.postId,
|
|
49
|
-
to: r.post.id
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
);
|
package/dist/styles/globals.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "tailwindcss";@import "tw-animate-css";@custom-variant dark (&:is(.dark *));:root{--background:oklch(1 0 0);--foreground:oklch(0.145 0 0);--card:oklch(1 0 0);--card-foreground:oklch(0.145 0 0);--popover:oklch(1 0 0);--popover-foreground:oklch(0.145 0 0);--primary:oklch(0.205 0 0);--primary-foreground:oklch(0.985 0 0);--secondary:oklch(0.97 0 0);--secondary-foreground:oklch(0.205 0 0);--muted:oklch(0.97 0 0);--muted-foreground:oklch(0.556 0 0);--accent:oklch(0.97 0 0);--accent-foreground:oklch(0.205 0 0);--destructive:oklch(0.577 0.245 27.325);--destructive-foreground:oklch(0.577 0.245 27.325);--border:oklch(0.922 0 0);--input:oklch(0.922 0 0);--ring:oklch(0.708 0 0);--chart-1:oklch(0.646 0.222 41.116);--chart-2:oklch(0.6 0.118 184.704);--chart-3:oklch(0.398 0.07 227.392);--chart-4:oklch(0.828 0.189 84.429);--chart-5:oklch(0.769 0.188 70.08);--radius:0.625rem;--sidebar:oklch(0.985 0 0);--sidebar-foreground:oklch(0.145 0 0);--sidebar-primary:oklch(0.205 0 0);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.97 0 0);--sidebar-accent-foreground:oklch(0.205 0 0);--sidebar-border:oklch(0.922 0 0);--sidebar-ring:oklch(0.708 0 0)}.dark{--background:oklch(0.145 0 0);--foreground:oklch(0.985 0 0);--card:oklch(0.145 0 0);--card-foreground:oklch(0.985 0 0);--popover:oklch(0.145 0 0);--popover-foreground:oklch(0.985 0 0);--primary:oklch(0.985 0 0);--primary-foreground:oklch(0.205 0 0);--secondary:oklch(0.269 0 0);--secondary-foreground:oklch(0.985 0 0);--muted:oklch(0.269 0 0);--muted-foreground:oklch(0.708 0 0);--accent:oklch(0.269 0 0);--accent-foreground:oklch(0.985 0 0);--destructive:oklch(0.396 0.141 25.723);--destructive-foreground:oklch(0.637 0.237 25.331);--border:oklch(0.269 0 0);--input:oklch(0.269 0 0);--ring:oklch(0.439 0 0);--chart-1:oklch(0.488 0.243 264.376);--chart-2:oklch(0.696 0.17 162.48);--chart-3:oklch(0.769 0.188 70.08);--chart-4:oklch(0.627 0.265 303.9);--chart-5:oklch(0.645 0.246 16.439);--sidebar:oklch(0.205 0 0);--sidebar-foreground:oklch(0.985 0 0);--sidebar-primary:oklch(0.488 0.243 264.376);--sidebar-primary-foreground:oklch(0.985 0 0);--sidebar-accent:oklch(0.269 0 0);--sidebar-accent-foreground:oklch(0.985 0 0);--sidebar-border:oklch(0.269 0 0);--sidebar-ring:oklch(0.439 0 0)}@theme inline{--color-background:var(--background);--color-foreground:var(--foreground);--color-card:var(--card);--color-card-foreground:var(--card-foreground);--color-popover:var(--popover);--color-popover-foreground:var(--popover-foreground);--color-primary:var(--primary);--color-primary-foreground:var(--primary-foreground);--color-secondary:var(--secondary);--color-secondary-foreground:var(--secondary-foreground);--color-muted:var(--muted);--color-muted-foreground:var(--muted-foreground);--color-accent:var(--accent);--color-accent-foreground:var(--accent-foreground);--color-destructive:var(--destructive);--color-destructive-foreground:var(--destructive-foreground);--color-border:var(--border);--color-input:var(--input);--color-ring:var(--ring);--color-chart-1:var(--chart-1);--color-chart-2:var(--chart-2);--color-chart-3:var(--chart-3);--color-chart-4:var(--chart-4);--color-chart-5:var(--chart-5);--radius-sm:calc(var(--radius) - 4px);--radius-md:calc(var(--radius) - 2px);--radius-lg:var(--radius);--radius-xl:calc(var(--radius) + 4px);--color-sidebar:var(--sidebar);--color-sidebar-foreground:var(--sidebar-foreground);--color-sidebar-primary:var(--sidebar-primary);--color-sidebar-primary-foreground:var(--sidebar-primary-foreground);--color-sidebar-accent:var(--sidebar-accent);--color-sidebar-accent-foreground:var(--sidebar-accent-foreground);--color-sidebar-border:var(--sidebar-border);--color-sidebar-ring:var(--sidebar-ring)}@layer base{*{@apply border-border outline-ring/50}body{@apply bg-background text-foreground}}
|