@vitnode/blog 1.2.0-canary.22 → 1.2.0-canary.23
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/src/api/modules/categories/categories.module.d.ts +5 -0
- package/dist/src/api/modules/categories/categories.module.d.ts.map +1 -1
- package/dist/src/api/modules/categories/routes/create.route.d.ts.map +1 -1
- package/dist/src/api/modules/categories/routes/create.route.js +1 -1
- package/dist/src/api/modules/categories/routes/get.route.d.ts +5 -0
- package/dist/src/api/modules/categories/routes/get.route.d.ts.map +1 -1
- package/dist/src/api/modules/categories/routes/get.route.js +1 -1
- package/dist/src/api/modules/posts/routes/create.route.js +1 -1
- package/dist/src/api/modules/posts/routes/get.route.d.ts +48 -0
- package/dist/src/api/modules/posts/routes/get.route.d.ts.map +1 -1
- package/dist/src/api/modules/posts/routes/get.route.js +1 -1
- package/dist/src/app_admin/blog/categories/page.js +1 -1
- package/dist/src/app_admin/blog/posts/page.js +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.d.ts.map +1 -1
- package/dist/src/views/admin/categories/actions/create-edit/create-edit.js +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts +2 -2
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts.map +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.js +1 -1
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts +11 -0
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.d.ts.map +1 -0
- package/dist/src/views/admin/posts/actions/create-edit/mutation-api.js +1 -0
- package/dist/src/views/admin/posts/posts-admin-view.d.ts.map +1 -1
- package/dist/src/views/admin/posts/posts-admin-view.js +1 -1
- package/dist/src/views/admin/posts/row-actions/edit-action.d.ts +9 -0
- package/dist/src/views/admin/posts/row-actions/edit-action.d.ts.map +1 -0
- package/dist/src/views/admin/posts/row-actions/edit-action.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/app_admin/blog/categories/page.tsx +1 -1
- package/src/app_admin/blog/posts/page.tsx +1 -1
- package/src/locales/en.json +6 -2
|
@@ -2,6 +2,7 @@ export declare const categoriesModule: import("@vitnode/core/api/lib/module").Bu
|
|
|
2
2
|
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
|
|
3
3
|
in: {
|
|
4
4
|
query: {
|
|
5
|
+
search?: string | undefined;
|
|
5
6
|
orderBy?: "updatedAt" | undefined;
|
|
6
7
|
cursor?: string | undefined;
|
|
7
8
|
first?: string | undefined;
|
|
@@ -11,6 +12,7 @@ export declare const categoriesModule: import("@vitnode/core/api/lib/module").Bu
|
|
|
11
12
|
};
|
|
12
13
|
out: {
|
|
13
14
|
query: {
|
|
15
|
+
search?: string | undefined;
|
|
14
16
|
orderBy?: "updatedAt" | undefined;
|
|
15
17
|
cursor?: string | undefined;
|
|
16
18
|
first?: string | undefined;
|
|
@@ -47,13 +49,16 @@ export declare const categoriesModule: import("@vitnode/core/api/lib/module").Bu
|
|
|
47
49
|
} & {
|
|
48
50
|
order: import("zod").ZodOptional<import("zod").ZodEnum<["asc", "desc"]>>;
|
|
49
51
|
orderBy: import("zod").ZodOptional<import("zod").ZodEnum<["updatedAt"]>>;
|
|
52
|
+
search: import("zod").ZodOptional<import("zod").ZodString>;
|
|
50
53
|
}, "strip", import("zod").ZodTypeAny, {
|
|
54
|
+
search?: string | undefined;
|
|
51
55
|
orderBy?: "updatedAt" | undefined;
|
|
52
56
|
cursor?: string | undefined;
|
|
53
57
|
first?: string | undefined;
|
|
54
58
|
last?: string | undefined;
|
|
55
59
|
order?: "asc" | "desc" | undefined;
|
|
56
60
|
}, {
|
|
61
|
+
search?: string | undefined;
|
|
57
62
|
orderBy?: "updatedAt" | undefined;
|
|
58
63
|
cursor?: string | undefined;
|
|
59
64
|
first?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"categories.module.d.ts","sourceRoot":"","sources":["../../../../../src/api/modules/categories/categories.module.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"categories.module.d.ts","sourceRoot":"","sources":["../../../../../src/api/modules/categories/categories.module.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wRAS3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/create.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAStC,eAAO,MAAM,uBAAuB;;;;;;
|
|
1
|
+
{"version":3,"file":"create.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/create.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAStC,eAAO,MAAM,uBAAuB;;;;;;EAElC,CAAC;AASH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyD9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters}from"@vitnode/core/lib/special-characters";import{eq}from"drizzle-orm";import{HTTPException}from"hono/http-exception";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";export const zodCreateCategorySchema=z.object({title:z.string()
|
|
1
|
+
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters}from"@vitnode/core/lib/special-characters";import{eq}from"drizzle-orm";import{HTTPException}from"hono/http-exception";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";export const zodCreateCategorySchema=z.object({title:z.string()});const zodCategoryResponseSchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const createCategoryRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"post",path:"/",request:{body:{content:{"application/json":{schema:zodCreateCategorySchema}}}},responses:{201:{content:{"application/json":{schema:zodCategoryResponseSchema}},description:"Category created successfully"},400:{description:"Bad request - Invalid input data"}}},handler:async c=>{const{title}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);const[titleSEODuplocate]=await c.get("db").select({titleSeo:blog_categories.titleSeo}).from(blog_categories).where(eq(blog_categories.titleSeo,titleSeo)).limit(1);if(titleSEODuplocate?.titleSeo===titleSeo){throw new HTTPException(400,{message:"Category with this title already exists."})}const[category]=await c.get("db").insert(blog_categories).values({title,titleSeo:removeSpecialCharacters(title)}).returning();return c.json(category,201)}});
|
|
@@ -3,6 +3,7 @@ export declare const categoriesRoute: {
|
|
|
3
3
|
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
|
|
4
4
|
in: {
|
|
5
5
|
query: {
|
|
6
|
+
search?: string | undefined;
|
|
6
7
|
orderBy?: "updatedAt" | undefined;
|
|
7
8
|
cursor?: string | undefined;
|
|
8
9
|
first?: string | undefined;
|
|
@@ -12,6 +13,7 @@ export declare const categoriesRoute: {
|
|
|
12
13
|
};
|
|
13
14
|
out: {
|
|
14
15
|
query: {
|
|
16
|
+
search?: string | undefined;
|
|
15
17
|
orderBy?: "updatedAt" | undefined;
|
|
16
18
|
cursor?: string | undefined;
|
|
17
19
|
first?: string | undefined;
|
|
@@ -48,13 +50,16 @@ export declare const categoriesRoute: {
|
|
|
48
50
|
} & {
|
|
49
51
|
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
50
52
|
orderBy: z.ZodOptional<z.ZodEnum<["updatedAt"]>>;
|
|
53
|
+
search: z.ZodOptional<z.ZodString>;
|
|
51
54
|
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
search?: string | undefined;
|
|
52
56
|
orderBy?: "updatedAt" | undefined;
|
|
53
57
|
cursor?: string | undefined;
|
|
54
58
|
first?: string | undefined;
|
|
55
59
|
last?: string | undefined;
|
|
56
60
|
order?: "asc" | "desc" | undefined;
|
|
57
61
|
}, {
|
|
62
|
+
search?: string | undefined;
|
|
58
63
|
orderBy?: "updatedAt" | undefined;
|
|
59
64
|
cursor?: string | undefined;
|
|
60
65
|
first?: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/get.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"get.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/get.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAmBtC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiE1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{withPagination,zodPaginationPageInfo,zodPaginationQuery}from"@vitnode/core/api/lib/with-pagination";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";const zodCategorySchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const categoriesRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"get",path:"/",request:{query:zodPaginationQuery.extend({order:z.enum(["asc","desc"]).optional(),orderBy:z.enum(["updatedAt"]).optional()})},responses:{200:{content:{"application/json":{schema:z.object({edges:z.array(zodCategorySchema),pageInfo:zodPaginationPageInfo})}},description:"Categories retrieved successfully"}}},handler:async c=>{const query=c.req.valid("query");const data=await withPagination({c,params:{query},primaryCursor:blog_categories.id,query:async({limit,where,orderBy})=>await c.get("db").select().from(blog_categories).where(
|
|
1
|
+
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{withPagination,zodPaginationPageInfo,zodPaginationQuery}from"@vitnode/core/api/lib/with-pagination";import{and,ilike}from"drizzle-orm";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";const zodCategorySchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const categoriesRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"get",path:"/",request:{query:zodPaginationQuery.extend({order:z.enum(["asc","desc"]).optional(),orderBy:z.enum(["updatedAt"]).optional(),search:z.string().optional()})},responses:{200:{content:{"application/json":{schema:z.object({edges:z.array(zodCategorySchema),pageInfo:zodPaginationPageInfo})}},description:"Categories retrieved successfully"}}},handler:async c=>{const query=c.req.valid("query");const data=await withPagination({c,params:{query},primaryCursor:blog_categories.id,query:async({limit,where,orderBy})=>{const searchCondition=query.search?ilike(blog_categories.title,`%${query.search}%`):undefined;const combinedWhere=searchCondition?where?and(where,searchCondition):searchCondition:where;return await c.get("db").select().from(blog_categories).where(combinedWhere).orderBy(orderBy).limit(limit)},table:blog_categories,orderBy:{column:query.orderBy?blog_categories[query.orderBy]:blog_categories.updatedAt,order:query.order??"desc"}});return c.json(data)}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters}from"@vitnode/core/lib/special-characters";import{eq}from"drizzle-orm";import{HTTPException}from"hono/http-exception";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";export const zodCreatePostSchema=z.object({title:z.string().min(3,"Title must be at least 3 characters long").max(255,"Title must not exceed 255 characters"),content:z.string()
|
|
1
|
+
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{removeSpecialCharacters}from"@vitnode/core/lib/special-characters";import{eq}from"drizzle-orm";import{HTTPException}from"hono/http-exception";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";export const zodCreatePostSchema=z.object({title:z.string().min(3,"Title must be at least 3 characters long").max(255,"Title must not exceed 255 characters"),content:z.string(),categoryId:z.number()});const zodPostResponseSchema=z.object({id:z.number(),title:z.string(),titleSeo:z.string(),content:z.string(),categoryId:z.number(),createdAt:z.date(),updatedAt:z.date()});export const createPostRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"post",path:"/",request:{body:{content:{"application/json":{schema:zodCreatePostSchema}}}},responses:{201:{content:{"application/json":{schema:zodPostResponseSchema}},description:"Post created successfully"},400:{description:"Bad request - Invalid input data"},404:{description:"Category not found"}}},handler:async c=>{const{title,content,categoryId}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);const[category]=await c.get("db").select({id:blog_categories.id}).from(blog_categories).where(eq(blog_categories.id,categoryId)).limit(1);if(!category){throw new HTTPException(404,{message:"Category not found."})}const[titleSEODuplicate]=await c.get("db").select({titleSeo:blog_posts.titleSeo}).from(blog_posts).where(eq(blog_posts.titleSeo,titleSeo)).limit(1);if(titleSEODuplicate?.titleSeo===titleSeo){throw new HTTPException(400,{message:"Post with this title already exists."})}const[post]=await c.get("db").insert(blog_posts).values({title,titleSeo,content,categoryId}).returning();return c.json(post,201)}});
|
|
@@ -1,4 +1,52 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
+
export declare const zodPostSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
titleSeo: z.ZodString;
|
|
6
|
+
content: z.ZodString;
|
|
7
|
+
categoryId: z.ZodNumber;
|
|
8
|
+
createdAt: z.ZodDate;
|
|
9
|
+
updatedAt: z.ZodDate;
|
|
10
|
+
category: z.ZodObject<{
|
|
11
|
+
id: z.ZodNumber;
|
|
12
|
+
title: z.ZodString;
|
|
13
|
+
titleSeo: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
id: number;
|
|
16
|
+
title: string;
|
|
17
|
+
titleSeo: string;
|
|
18
|
+
}, {
|
|
19
|
+
id: number;
|
|
20
|
+
title: string;
|
|
21
|
+
titleSeo: string;
|
|
22
|
+
}>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
id: number;
|
|
25
|
+
title: string;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
titleSeo: string;
|
|
29
|
+
content: string;
|
|
30
|
+
category: {
|
|
31
|
+
id: number;
|
|
32
|
+
title: string;
|
|
33
|
+
titleSeo: string;
|
|
34
|
+
};
|
|
35
|
+
categoryId: number;
|
|
36
|
+
}, {
|
|
37
|
+
id: number;
|
|
38
|
+
title: string;
|
|
39
|
+
createdAt: Date;
|
|
40
|
+
updatedAt: Date;
|
|
41
|
+
titleSeo: string;
|
|
42
|
+
content: string;
|
|
43
|
+
category: {
|
|
44
|
+
id: number;
|
|
45
|
+
title: string;
|
|
46
|
+
titleSeo: string;
|
|
47
|
+
};
|
|
48
|
+
categoryId: number;
|
|
49
|
+
}>;
|
|
2
50
|
export declare const postsRoute: {
|
|
3
51
|
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/", {
|
|
4
52
|
in: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/posts/routes/get.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"get.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/posts/routes/get.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAatC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAaxB,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ErB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{withPagination,zodPaginationPageInfo,zodPaginationQuery}from"@vitnode/core/api/lib/with-pagination";import{eq}from"drizzle-orm";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";const zodPostSchema=z.object({id:z.number(),title:z.string(),titleSeo:z.string(),content:z.string(),categoryId:z.number(),createdAt:z.date(),updatedAt:z.date(),category:z.object({id:z.number(),title:z.string(),titleSeo:z.string()})});export const postsRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"get",path:"/",request:{query:zodPaginationQuery.extend({order:z.enum(["asc","desc"]).optional(),orderBy:z.enum(["updatedAt","createdAt"]).optional(),categoryId:z.string().transform(Number).optional()})},responses:{200:{content:{"application/json":{schema:z.object({edges:z.array(zodPostSchema),pageInfo:zodPaginationPageInfo})}},description:"Posts retrieved successfully"}}},handler:async c=>{const query=c.req.valid("query");const data=await withPagination({c,params:{query},primaryCursor:blog_posts.id,query:async({limit,where,orderBy})=>await c.get("db").select({id:blog_posts.id,title:blog_posts.title,titleSeo:blog_posts.titleSeo,content:blog_posts.content,categoryId:blog_posts.categoryId,createdAt:blog_posts.createdAt,updatedAt:blog_posts.updatedAt,category:{id:blog_categories.id,title:blog_categories.title,titleSeo:blog_categories.titleSeo}}).from(blog_posts).innerJoin(blog_categories,eq(blog_posts.categoryId,blog_categories.id)).where(query.categoryId?eq(blog_posts.categoryId,query.categoryId):where).orderBy(orderBy).limit(limit),table:blog_posts,orderBy:{column:query.orderBy?blog_posts[query.orderBy]:blog_posts.updatedAt,order:query.order??"desc"}});return c.json(data)}});
|
|
1
|
+
import{z}from"@hono/zod-openapi";import{buildRoute}from"@vitnode/core/api/lib/route";import{withPagination,zodPaginationPageInfo,zodPaginationQuery}from"@vitnode/core/api/lib/with-pagination";import{eq}from"drizzle-orm";import{CONFIG_PLUGIN}from"../../../../const.js";import{blog_categories}from"../../../../database/categories.js";import{blog_posts}from"../../../../database/posts.js";export const zodPostSchema=z.object({id:z.number(),title:z.string(),titleSeo:z.string(),content:z.string(),categoryId:z.number(),createdAt:z.date(),updatedAt:z.date(),category:z.object({id:z.number(),title:z.string(),titleSeo:z.string()})});export const postsRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"get",path:"/",request:{query:zodPaginationQuery.extend({order:z.enum(["asc","desc"]).optional(),orderBy:z.enum(["updatedAt","createdAt"]).optional(),categoryId:z.string().transform(Number).optional()})},responses:{200:{content:{"application/json":{schema:z.object({edges:z.array(zodPostSchema),pageInfo:zodPaginationPageInfo})}},description:"Posts retrieved successfully"}}},handler:async c=>{const query=c.req.valid("query");const data=await withPagination({c,params:{query},primaryCursor:blog_posts.id,query:async({limit,where,orderBy})=>await c.get("db").select({id:blog_posts.id,title:blog_posts.title,titleSeo:blog_posts.titleSeo,content:blog_posts.content,categoryId:blog_posts.categoryId,createdAt:blog_posts.createdAt,updatedAt:blog_posts.updatedAt,category:{id:blog_categories.id,title:blog_categories.title,titleSeo:blog_categories.titleSeo}}).from(blog_posts).innerJoin(blog_categories,eq(blog_posts.categoryId,blog_categories.id)).where(query.categoryId?eq(blog_posts.categoryId,query.categoryId):where).orderBy(orderBy).limit(limit),table:blog_posts,orderBy:{column:query.orderBy?blog_posts[query.orderBy]:blog_posts.updatedAt,order:query.order??"desc"}});return c.json(data)}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{I18nProvider}from"@vitnode/core/components/i18n-provider";import{HeaderContent}from"@vitnode/core/components/ui/header-content";import{getTranslations}from"next-intl/server";import{CategoriesAdminView}from"../../../views/admin/categories/categories-admin-view.js";import{ActionsCategoriesAdmin}from"../../../views/admin/categories/actions/actions.js";export const generateMetadata=async()=>{const t=await getTranslations("@vitnode/blog.admin.nav");return{title:t("categories")}};export default async function CategoriesPage(params){const[t,tNav]=await Promise.all([getTranslations("@vitnode/blog.admin.categories"),getTranslations("@vitnode/blog.admin.nav")]);return _jsx(I18nProvider,{namespaces:["@vitnode/blog.admin.categories"],children:_jsxs("div",{className:"
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{I18nProvider}from"@vitnode/core/components/i18n-provider";import{HeaderContent}from"@vitnode/core/components/ui/header-content";import{getTranslations}from"next-intl/server";import{CategoriesAdminView}from"../../../views/admin/categories/categories-admin-view.js";import{ActionsCategoriesAdmin}from"../../../views/admin/categories/actions/actions.js";export const generateMetadata=async()=>{const t=await getTranslations("@vitnode/blog.admin.nav");return{title:t("categories")}};export default async function CategoriesPage(params){const[t,tNav]=await Promise.all([getTranslations("@vitnode/blog.admin.categories"),getTranslations("@vitnode/blog.admin.nav")]);return _jsx(I18nProvider,{namespaces:["@vitnode/blog.admin.categories"],children:_jsxs("div",{className:"p-4",children:[_jsx(HeaderContent,{desc:t("desc"),h1:tNav("categories"),children:_jsx(ActionsCategoriesAdmin,{})}),_jsx(CategoriesAdminView,{...params})]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{I18nProvider}from"@vitnode/core/components/i18n-provider";import{HeaderContent}from"@vitnode/core/components/ui/header-content";import{getTranslations}from"next-intl/server";import{ActionsPostsAdmin}from"../../../views/admin/posts/actions/actions.js";import{PostsAdminView}from"../../../views/admin/posts/posts-admin-view.js";export const generateMetadata=async()=>{const t=await getTranslations("@vitnode/blog.admin.nav");return{title:t("posts")}};export default async function PostsPage(params){const[t,tNav]=await Promise.all([getTranslations("@vitnode/blog.admin.posts"),getTranslations("@vitnode/blog.admin.nav")]);return _jsx(I18nProvider,{namespaces:["@vitnode/blog.admin.posts"],children:_jsxs("div",{className:"
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{I18nProvider}from"@vitnode/core/components/i18n-provider";import{HeaderContent}from"@vitnode/core/components/ui/header-content";import{getTranslations}from"next-intl/server";import{ActionsPostsAdmin}from"../../../views/admin/posts/actions/actions.js";import{PostsAdminView}from"../../../views/admin/posts/posts-admin-view.js";export const generateMetadata=async()=>{const t=await getTranslations("@vitnode/blog.admin.nav");return{title:t("posts")}};export default async function PostsPage(params){const[t,tNav]=await Promise.all([getTranslations("@vitnode/blog.admin.posts"),getTranslations("@vitnode/blog.admin.nav")]);return _jsx(I18nProvider,{namespaces:["@vitnode/blog.admin.posts"],children:_jsxs("div",{className:"p-4",children:[_jsx(HeaderContent,{desc:t("desc"),h1:tNav("posts"),children:_jsx(ActionsPostsAdmin,{})}),_jsx(PostsAdminView,{...params})]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-edit.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/categories/actions/create-edit/create-edit.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAI5F,eAAO,MAAM,+BAA+B,GAAI,WAE7C;IACD,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE,
|
|
1
|
+
{"version":3,"file":"create-edit.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/categories/actions/create-edit/create-edit.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAI5F,eAAO,MAAM,+BAA+B,GAAI,WAE7C;IACD,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;CACjE,4CAqEA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{AutoForm}from"@vitnode/core/components/form/auto-form";import{AutoFormInput}from"@vitnode/core/components/form/fields/input";import{useDialog}from"@vitnode/core/components/ui/dialog";import{usePathname,useRouter}from"@vitnode/core/lib/navigation";import{useTranslations}from"next-intl";import{toast}from"sonner";import{z}from"zod";import{createMutationApi,editMutationApi}from"./mutation-api.js";export const CreateEditActionCategoriesAdmin=({data})=>{const t=useTranslations("@vitnode/blog.admin.categories");const tCore=useTranslations("core.global.errors");const{setOpen}=useDialog();const{push}=useRouter();const pathname=usePathname();const formSchema=z.object({title:z.string().
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{AutoForm}from"@vitnode/core/components/form/auto-form";import{AutoFormInput}from"@vitnode/core/components/form/fields/input";import{useDialog}from"@vitnode/core/components/ui/dialog";import{usePathname,useRouter}from"@vitnode/core/lib/navigation";import{useTranslations}from"next-intl";import{toast}from"sonner";import{z}from"zod";import{createMutationApi,editMutationApi}from"./mutation-api.js";export const CreateEditActionCategoriesAdmin=({data})=>{const t=useTranslations("@vitnode/blog.admin.categories");const tCore=useTranslations("core.global.errors");const{setOpen}=useDialog();const{push}=useRouter();const pathname=usePathname();const formSchema=z.object({title:z.string().default(data?.title??"")});const onSubmit=async(values,form)=>{let error="";if(data?.id){const mutation=await editMutationApi({id:data.id,...values});if(mutation?.error){error=mutation.error}}else{const mutation=await createMutationApi(values);if(mutation?.error){error=mutation.error}}if(error){if(error.includes("already exists")){form.setError("title",{type:"manual",message:t("create.form.title.already_exists")});return}toast.error(tCore("title"),{description:tCore("internal_server_error")});return}setOpen?.(false);push(pathname)};return _jsx(AutoForm,{fields:[{id:"title",component:props=>_jsx(AutoFormInput,{label:t("create.form.title.label"),...props})}],formSchema:formSchema,onSubmit:onSubmit,submitButtonProps:{children:t(`${data?"edit":"create"}.submit`)}})};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type {
|
|
2
|
+
import type { zodPostSchema } from '../../../../../api/modules/posts/routes/get.route';
|
|
3
3
|
export declare const CreateEditActionPostsAdmin: ({ data, }: {
|
|
4
|
-
data?: z.infer<typeof
|
|
4
|
+
data?: z.infer<typeof zodPostSchema> & {
|
|
5
5
|
id?: number;
|
|
6
6
|
};
|
|
7
7
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-edit.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/posts/actions/create-edit/create-edit.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-edit.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/posts/actions/create-edit/create-edit.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAM1E,eAAO,MAAM,0BAA0B,GAAI,WAExC;IACD,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxD,4CAiIA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{AutoForm}from"@vitnode/core/components/form/auto-form";import{AutoFormInput}from"@vitnode/core/components/form/fields/input";import{AutoFormTextarea}from"@vitnode/core/components/form/fields/textarea";import{useTranslations}from"next-intl";import{z}from"zod";export const CreateEditActionPostsAdmin=({data})=>{const t=useTranslations("@vitnode/blog.admin.posts");const tCore=useTranslations("core.global.errors");const formSchema=z.object({title:z.string().min(3,{message:tCore("field_min_length",{min:3})}).default(data?.title??""),content:z.string().
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{AutoForm}from"@vitnode/core/components/form/auto-form";import{AutoFormComboboxAsync}from"@vitnode/core/components/form/fields/combobox-async";import{AutoFormInput}from"@vitnode/core/components/form/fields/input";import{AutoFormTextarea}from"@vitnode/core/components/form/fields/textarea";import{useDialog}from"@vitnode/core/components/ui/dialog";import{fetcherClient}from"@vitnode/core/lib/fetcher-client";import{usePathname,useRouter}from"@vitnode/core/lib/navigation";import{useTranslations}from"next-intl";import{toast}from"sonner";import{z}from"zod";import{categoriesModule}from"../../../../../api/modules/categories/categories.module.js";import{createMutationApi,editMutationApi}from"./mutation-api.js";export const CreateEditActionPostsAdmin=({data})=>{const t=useTranslations("@vitnode/blog.admin.posts");const tCore=useTranslations("core.global.errors");const{setOpen}=useDialog();const{push}=useRouter();const pathname=usePathname();const formSchema=z.object({title:z.string().min(3,{message:tCore("field_min_length",{min:3})}).default(data?.title??""),content:z.string().default(data?.content??""),categoryId:z.object({value:z.string(),label:z.string()}).refine(value=>value.value!=="",{message:tCore("field_required")}).default(data?.category?{value:data.category.id.toString(),label:data.category.title}:{value:"",label:""})});const onSubmit=async(values,form)=>{let error="";if(data?.id){const mutation=await editMutationApi({id:data.id,...values,categoryId:parseInt(values.categoryId.value,10)});if(mutation?.error){error=mutation.error}}else{const mutation=await createMutationApi({...values,categoryId:parseInt(values.categoryId.value,10)});if(mutation?.error){error=mutation.error}}if(error){if(error.includes("already exists")){form.setError("title",{type:"manual",message:t("create.form.title.already_exists")});return}toast.error(tCore("title"),{description:tCore("internal_server_error")});return}setOpen?.(false);push(pathname)};return _jsx(AutoForm,{fields:[{id:"title",component:props=>_jsx(AutoFormInput,{label:t("create.form.title.label"),...props})},{id:"categoryId",component:props=>_jsx(AutoFormComboboxAsync,{fetchData:async({search})=>{const res=await fetcherClient(categoriesModule,{path:"/",method:"get",module:"categories",args:{query:{search}}});const data=await res.json();return data.edges.map(category=>({label:category.title,value:category.id.toString()}))},id:"categoryId",label:t("create.form.category"),...props})},{id:"content",component:props=>_jsx(AutoFormTextarea,{label:t("create.form.content"),rows:10,...props})}],formSchema:formSchema,onSubmit:onSubmit,submitButtonProps:{children:t(`${data?"edit":"create"}.submit`)}})};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { zodCreatePostSchema } from '../../../../../api/modules/posts/routes/create.route';
|
|
3
|
+
export declare const createMutationApi: (body: z.infer<typeof zodCreatePostSchema>) => Promise<{
|
|
4
|
+
error: string;
|
|
5
|
+
} | undefined>;
|
|
6
|
+
export declare const editMutationApi: ({ id, ...body }: z.infer<typeof zodCreatePostSchema> & {
|
|
7
|
+
id: number;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
error: string;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
//# sourceMappingURL=mutation-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-api.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/posts/actions/create-edit/mutation-api.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAK7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAInF,eAAO,MAAM,iBAAiB,GAC5B,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC;;cAmB1C,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,iBAGnC,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;;cAqBtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use server";import{fetcher}from"@vitnode/core/lib/fetcher";import{revalidatePath}from"next/cache";import{postsModule}from"../../../../../api/modules/posts/posts.module.js";export const createMutationApi=async body=>{const res=await fetcher(postsModule,{method:"post",module:"posts",path:"/",args:{body}});if(res.status!==201){return{error:await res.text()}}revalidatePath("/[locale]/admin/(auth)/(plugins)/(vitnode-blog)/blog/posts","page")};export const editMutationApi=async({id,...body})=>{const res=await fetcher(postsModule,{method:"put",module:"posts",path:"/{id}",args:{params:{id},body}});if(res.status!==200){return{error:await res.text()}}revalidatePath("/[locale]/admin/(auth)/(plugins)/(vitnode-blog)/blog/posts","page")};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posts-admin-view.d.ts","sourceRoot":"","sources":["../../../../../src/views/admin/posts/posts-admin-view.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"posts-admin-view.d.ts","sourceRoot":"","sources":["../../../../../src/views/admin/posts/posts-admin-view.tsx"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,GAAU,mBAElC;IACD,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;CACtE,qDAgEA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{DateFormat}from"@vitnode/core/components/date-format";import{DataTable}from"@vitnode/core/components/table/data-table";import{fetcher}from"@vitnode/core/lib/fetcher";import{getTranslations}from"next-intl/server";import{postsModule}from"../../../api/modules/posts/posts.module.js";import{DeleteAction}from"./row-actions/delete/delete-action.js";export const PostsAdminView=async({searchParams})=>{const t=await getTranslations("@vitnode/blog.admin.posts.table");const query=await searchParams;const res=await fetcher(postsModule,{path:"/",method:"get",module:"posts",args:{query},withPagination:true,options:{cache:"force-cache"}});const data=await res.json();return _jsx(DataTable,{columns:[{id:"id",label:"ID",className:"w-24"},{id:"title",label:t("title")},{id:"category",label:t("category"),className:"w-48",cell:({row})=>row.category.title},{id:"updatedAt",label:t("updated_at"),className:"w-48",cell:({row})=>_jsx(DateFormat,{date:row.updatedAt})},{id:"actions",label:"",className:"w-10",cell:({row})=>_jsx(DeleteAction,{...row})}],edges:data.edges.map(edge=>({...edge})),order:{columns:["createdAt","updatedAt"],defaultOrder:{column:"createdAt",order:"desc"}},pageInfo:data.pageInfo})};
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{DateFormat}from"@vitnode/core/components/date-format";import{DataTable}from"@vitnode/core/components/table/data-table";import{fetcher}from"@vitnode/core/lib/fetcher";import{getTranslations}from"next-intl/server";import{postsModule}from"../../../api/modules/posts/posts.module.js";import{DeleteAction}from"./row-actions/delete/delete-action.js";import{EditAction}from"./row-actions/edit-action.js";export const PostsAdminView=async({searchParams})=>{const t=await getTranslations("@vitnode/blog.admin.posts.table");const query=await searchParams;const res=await fetcher(postsModule,{path:"/",method:"get",module:"posts",args:{query},withPagination:true,options:{cache:"force-cache"}});const data=await res.json();return _jsx(DataTable,{columns:[{id:"id",label:"ID",className:"w-24"},{id:"title",label:t("title")},{id:"category",label:t("category"),className:"w-48",cell:({row})=>row.category.title},{id:"updatedAt",label:t("updated_at"),className:"w-48",cell:({row})=>_jsx(DateFormat,{date:row.updatedAt})},{id:"actions",label:"",className:"w-10",cell:({row})=>_jsxs(_Fragment,{children:[_jsx(EditAction,{data:row}),_jsx(DeleteAction,{...row})]})}],edges:data.edges.map(edge=>({...edge})),order:{columns:["createdAt","updatedAt"],defaultOrder:{column:"createdAt",order:"desc"}},pageInfo:data.pageInfo})};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const CreateEditActionPostsAdmin: React.LazyExoticComponent<({ data, }: {
|
|
3
|
+
data?: import("zod").TypeOf<typeof import("../../../../api/modules/posts/routes/get.route").zodPostSchema> & {
|
|
4
|
+
id?: number;
|
|
5
|
+
};
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element>;
|
|
7
|
+
export declare const EditAction: (props: Required<React.ComponentProps<typeof CreateEditActionPostsAdmin>>) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=edit-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-action.d.ts","sourceRoot":"","sources":["../../../../../../src/views/admin/posts/row-actions/edit-action.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,0BAA0B;QAeL,CAAC;UACG,CAAC;;8CAZ/B,CAAC;AAEF,eAAO,MAAM,UAAU,GACrB,OAAO,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,0BAA0B,CAAC,CAAC,4CA+BzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Button}from"@vitnode/core/components/ui/button";import{Dialog,DialogContent,DialogDescription,DialogHeader,DialogTitle,DialogTrigger}from"@vitnode/core/components/ui/dialog";import{Loader}from"@vitnode/core/components/ui/loader";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"@vitnode/core/components/ui/tooltip";import{PencilIcon}from"lucide-react";import{useTranslations}from"next-intl";import React from"react";const CreateEditActionPostsAdmin=React.lazy(async()=>import("../actions/create-edit/create-edit.js").then(mod=>({default:mod.CreateEditActionPostsAdmin})));export const EditAction=props=>{const t=useTranslations("@vitnode/blog.admin.posts.edit");return _jsxs(Dialog,{children:[_jsx(TooltipProvider,{children:_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(DialogTrigger,{asChild:true,children:_jsx(Button,{size:"icon",variant:"ghost",children:_jsx(PencilIcon,{})})})}),_jsx(TooltipContent,{children:t("title")})]})}),_jsxs(DialogContent,{children:[_jsxs(DialogHeader,{children:[_jsx(DialogTitle,{children:t("title")}),_jsx(DialogDescription,{children:props.data.title})]}),_jsx(React.Suspense,{fallback:_jsx(Loader,{}),children:_jsx(CreateEditActionPostsAdmin,{...props})})]})]})};
|