@vitnode/blog 1.2.0-canary.21 → 1.2.0-canary.22
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/routes/edit.route.d.ts +0 -7
- package/dist/src/api/modules/categories/routes/edit.route.d.ts.map +1 -1
- package/dist/src/api/modules/categories/routes/edit.route.js +1 -1
- package/dist/src/api/modules/posts/routes/edit.route.d.ts +0 -13
- package/dist/src/api/modules/posts/routes/edit.route.d.ts.map +1 -1
- package/dist/src/api/modules/posts/routes/edit.route.js +1 -1
- package/dist/src/app_admin/blog/posts/page.d.ts.map +1 -1
- package/dist/src/app_admin/blog/posts/page.js +1 -1
- package/dist/src/views/admin/categories/row-actions/delete/delete-action.js +1 -1
- package/dist/src/views/admin/posts/actions/actions.d.ts +2 -0
- package/dist/src/views/admin/posts/actions/actions.d.ts.map +1 -0
- package/dist/src/views/admin/posts/actions/actions.js +1 -0
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts +8 -0
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.d.ts.map +1 -0
- package/dist/src/views/admin/posts/actions/create-edit/create-edit.js +1 -0
- package/dist/src/views/admin/posts/row-actions/delete/delete-action.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/app_admin/blog/posts/page.tsx +4 -1
- package/src/locales/en.json +13 -0
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
-
export declare const zodEditCategorySchema: z.ZodObject<{
|
|
3
|
-
title: z.ZodString;
|
|
4
|
-
}, "strip", z.ZodTypeAny, {
|
|
5
|
-
title: string;
|
|
6
|
-
}, {
|
|
7
|
-
title: string;
|
|
8
|
-
}>;
|
|
9
2
|
export declare const editCategoryRoute: {
|
|
10
3
|
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
|
|
11
4
|
in: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/categories/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAkBtC,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiF5B,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";
|
|
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{zodCreateCategorySchema}from"./create.route.js";const zodCategoryResponseSchema=z.object({id:z.number(),title:z.string(),createdAt:z.date(),updatedAt:z.date()});export const editCategoryRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"put",path:"/{id}",request:{params:z.object({id:z.string().transform(Number)}),body:{content:{"application/json":{schema:zodCreateCategorySchema}}}},responses:{200:{content:{"application/json":{schema:zodCategoryResponseSchema}},description:"Category updated successfully"},400:{description:"Bad request - Invalid input data"},404:{description:"Category not found"}}},handler:async c=>{const{id}=c.req.valid("param");const{title}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);const[editData]=await c.get("db").select({titleSeo:blog_categories.titleSeo}).from(blog_categories).where(eq(blog_categories.id,id)).limit(1);if(!editData){throw new HTTPException(404)}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&&titleSEODuplocate.titleSeo!==editData.titleSeo){throw new HTTPException(400,{message:"Category with this title already exists."})}const[category]=await c.get("db").update(blog_categories).set({title,titleSeo:removeSpecialCharacters(title)}).where(eq(blog_categories.id,id)).returning();return c.json(category)}});
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
|
-
export declare const zodEditPostSchema: z.ZodObject<{
|
|
3
|
-
title: z.ZodString;
|
|
4
|
-
content: z.ZodString;
|
|
5
|
-
categoryId: z.ZodNumber;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
title: string;
|
|
8
|
-
content: string;
|
|
9
|
-
categoryId: number;
|
|
10
|
-
}, {
|
|
11
|
-
title: string;
|
|
12
|
-
content: string;
|
|
13
|
-
categoryId: number;
|
|
14
|
-
}>;
|
|
15
2
|
export declare const editPostRoute: {
|
|
16
3
|
handler: (c: import("hono").Context<import("@vitnode/core/api/middlewares/global/global").EnvVitNode, "/:id", {
|
|
17
4
|
in: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/posts/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"edit.route.d.ts","sourceRoot":"","sources":["../../../../../../src/api/modules/posts/routes/edit.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAsBtC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FxB,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";import{blog_posts}from"../../../../database/posts.js";
|
|
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";import{zodCreatePostSchema}from"./create.route.js";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 editPostRoute=buildRoute({...CONFIG_PLUGIN,route:{method:"put",path:"/{id}",request:{params:z.object({id:z.string().transform(Number)}),body:{content:{"application/json":{schema:zodCreatePostSchema}}}},responses:{200:{content:{"application/json":{schema:zodPostResponseSchema}},description:"Post updated successfully"},400:{description:"Bad request - Invalid input data"},404:{description:"Post or category not found"}}},handler:async c=>{const{id}=c.req.valid("param");const{title,content,categoryId}=c.req.valid("json");const titleSeo=removeSpecialCharacters(title);const[existingPost]=await c.get("db").select({titleSeo:blog_posts.titleSeo}).from(blog_posts).where(eq(blog_posts.id,id)).limit(1);if(!existingPost){throw new HTTPException(404,{message:"Post not found."})}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&&titleSEODuplicate.titleSeo!==existingPost.titleSeo){throw new HTTPException(400,{message:"Post with this title already exists."})}const[post]=await c.get("db").update(blog_posts).set({title,titleSeo,content,categoryId}).where(eq(blog_posts.id,id)).returning();return c.json(post)}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../../src/app_admin/blog/posts/page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../../src/app_admin/blog/posts/page.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAOrC,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAEtE,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,QAAQ,CAMzD,CAAC;AAEF,wBAA8B,SAAS,CACrC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,cAAc,CAAC,oDAkBpD"}
|
|
@@ -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{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:"container mx-auto p-4",children:[_jsx(HeaderContent,{desc:t("desc"),h1:tNav("posts")}),_jsx(PostsAdminView,{...params})]})})}
|
|
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:"container mx-auto p-4",children:[_jsx(HeaderContent,{desc:t("desc"),h1:tNav("posts"),children:_jsx(ActionsPostsAdmin,{})}),_jsx(PostsAdminView,{...params})]})})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{AlertDialog,AlertDialogAction,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,AlertDialogTitle,AlertDialogTrigger}from"@vitnode/core/components/ui/alert-dialog";import{Button}from"@vitnode/core/components/ui/button";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"@vitnode/core/components/ui/tooltip";import{Trash2Icon}from"lucide-react";import{useTranslations}from"next-intl";import{toast}from"sonner";import{mutationApi}from"./mutation-api.js";export const DeleteAction=({title,id})=>{const t=useTranslations("@vitnode/blog.admin.categories.delete");const tGlobal=useTranslations("core.global");return _jsxs(AlertDialog,{children:[_jsx(TooltipProvider,{children:_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(AlertDialogTrigger,{asChild:true,children:_jsx(Button,{size:"icon",variant:"
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{AlertDialog,AlertDialogAction,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,AlertDialogTitle,AlertDialogTrigger}from"@vitnode/core/components/ui/alert-dialog";import{Button}from"@vitnode/core/components/ui/button";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"@vitnode/core/components/ui/tooltip";import{Trash2Icon}from"lucide-react";import{useTranslations}from"next-intl";import{toast}from"sonner";import{mutationApi}from"./mutation-api.js";export const DeleteAction=({title,id})=>{const t=useTranslations("@vitnode/blog.admin.categories.delete");const tGlobal=useTranslations("core.global");return _jsxs(AlertDialog,{children:[_jsx(TooltipProvider,{children:_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(AlertDialogTrigger,{asChild:true,children:_jsx(Button,{size:"icon",variant:"destructiveGhost",children:_jsx(Trash2Icon,{className:"size-4"})})})}),_jsx(TooltipContent,{children:t("title")})]})}),_jsxs(AlertDialogContent,{children:[_jsxs(AlertDialogHeader,{children:[_jsx(AlertDialogTitle,{children:t("title")}),_jsx(AlertDialogDescription,{children:t.rich("desc",{title:()=>_jsx("span",{className:"text-foreground font-bold",children:title})})})]}),_jsxs(AlertDialogFooter,{children:[_jsx(AlertDialogCancel,{children:tGlobal("cancel")}),_jsx(AlertDialogAction,{onClick:async()=>{const mutation=await mutationApi(id);if(mutation?.error){toast.error(tGlobal("errors.title"),{description:tGlobal("errors.internal_server_error")});return}toast.success(t("success"),{description:title})},children:t("confirm")})]})]})]})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../../../src/views/admin/posts/actions/actions.tsx"],"names":[],"mappings":"AAsBA,eAAO,MAAM,iBAAiB,+CAwB7B,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{PlusIcon}from"lucide-react";import{useTranslations}from"next-intl";import React from"react";const CreateEditActionPostsAdmin=React.lazy(async()=>import("./create-edit/create-edit.js").then(module=>({default:module.CreateEditActionPostsAdmin})));export const ActionsPostsAdmin=()=>{const t=useTranslations("@vitnode/blog.admin.posts.create");return _jsxs(Dialog,{children:[_jsx(DialogTrigger,{asChild:true,children:_jsxs(Button,{children:[_jsx(PlusIcon,{}),t("title")]})}),_jsxs(DialogContent,{children:[_jsxs(DialogHeader,{children:[_jsx(DialogTitle,{children:t("title")}),_jsx(DialogDescription,{children:t("desc")})]}),_jsx(React.Suspense,{fallback:_jsx(Loader,{}),children:_jsx(CreateEditActionPostsAdmin,{})})]})]})};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { zodCreatePostSchema } from '../../../../../api/modules/posts/routes/create.route';
|
|
3
|
+
export declare const CreateEditActionPostsAdmin: ({ data, }: {
|
|
4
|
+
data?: z.infer<typeof zodCreatePostSchema> & {
|
|
5
|
+
id?: number;
|
|
6
|
+
};
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=create-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-edit.d.ts","sourceRoot":"","sources":["../../../../../../../src/views/admin/posts/actions/create-edit/create-edit.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,eAAO,MAAM,0BAA0B,GAAI,WAExC;IACD,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9D,4CA2CA,CAAC"}
|
|
@@ -0,0 +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().min(1,{message:tCore("field_required")})});return _jsx(AutoForm,{fields:[{id:"title",component:props=>_jsx(AutoFormInput,{label:t("create.form.title"),...props})},{id:"content",component:props=>_jsx(AutoFormTextarea,{label:t("create.form.content"),rows:10,...props})}],formSchema:formSchema,submitButtonProps:{children:t(`${data?"edit":"create"}.submit`)}})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{AlertDialog,AlertDialogAction,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,AlertDialogTitle,AlertDialogTrigger}from"@vitnode/core/components/ui/alert-dialog";import{Button}from"@vitnode/core/components/ui/button";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"@vitnode/core/components/ui/tooltip";import{Trash2Icon}from"lucide-react";import{useTranslations}from"next-intl";import{toast}from"sonner";import{mutationApi}from"./mutation-api.js";export const DeleteAction=({title,id})=>{const t=useTranslations("@vitnode/blog.admin.posts.delete");const tGlobal=useTranslations("core.global");return _jsxs(AlertDialog,{children:[_jsx(TooltipProvider,{children:_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(AlertDialogTrigger,{asChild:true,children:_jsx(Button,{size:"icon",variant:"
|
|
1
|
+
"use client";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{AlertDialog,AlertDialogAction,AlertDialogCancel,AlertDialogContent,AlertDialogDescription,AlertDialogFooter,AlertDialogHeader,AlertDialogTitle,AlertDialogTrigger}from"@vitnode/core/components/ui/alert-dialog";import{Button}from"@vitnode/core/components/ui/button";import{Tooltip,TooltipContent,TooltipProvider,TooltipTrigger}from"@vitnode/core/components/ui/tooltip";import{Trash2Icon}from"lucide-react";import{useTranslations}from"next-intl";import{toast}from"sonner";import{mutationApi}from"./mutation-api.js";export const DeleteAction=({title,id})=>{const t=useTranslations("@vitnode/blog.admin.posts.delete");const tGlobal=useTranslations("core.global");return _jsxs(AlertDialog,{children:[_jsx(TooltipProvider,{children:_jsxs(Tooltip,{children:[_jsx(TooltipTrigger,{asChild:true,children:_jsx(AlertDialogTrigger,{asChild:true,children:_jsx(Button,{size:"icon",variant:"destructiveGhost",children:_jsx(Trash2Icon,{className:"size-4"})})})}),_jsx(TooltipContent,{children:t("title")})]})}),_jsxs(AlertDialogContent,{children:[_jsxs(AlertDialogHeader,{children:[_jsx(AlertDialogTitle,{children:t("title")}),_jsx(AlertDialogDescription,{children:t.rich("desc",{title:()=>_jsx("span",{className:"text-foreground font-bold",children:title})})})]}),_jsxs(AlertDialogFooter,{children:[_jsx(AlertDialogCancel,{children:tGlobal("cancel")}),_jsx(AlertDialogAction,{onClick:async()=>{const mutation=await mutationApi(id);if(mutation?.error){toast.error(tGlobal("errors.title"),{description:tGlobal("errors.internal_server_error")});return}toast.success(t("success"),{description:title})},children:t("confirm")})]})]})]})};
|