@hedhog/blog 0.0.12 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/dist/author/author.controller.d.ts +13 -5
  2. package/dist/author/author.controller.d.ts.map +1 -1
  3. package/dist/author/author.controller.js +7 -7
  4. package/dist/author/author.controller.js.map +1 -1
  5. package/dist/author/author.service.d.ts +9 -1
  6. package/dist/author/author.service.d.ts.map +1 -1
  7. package/dist/author/author.service.js +2 -1
  8. package/dist/author/author.service.js.map +1 -1
  9. package/dist/category/category.controller.d.ts +13 -5
  10. package/dist/category/category.controller.d.ts.map +1 -1
  11. package/dist/category/category.controller.js +9 -9
  12. package/dist/category/category.controller.js.map +1 -1
  13. package/dist/category/category.service.d.ts +9 -1
  14. package/dist/category/category.service.d.ts.map +1 -1
  15. package/dist/category/category.service.js +2 -1
  16. package/dist/category/category.service.js.map +1 -1
  17. package/dist/category/dto/create.dto.d.ts +1 -1
  18. package/dist/category/dto/create.dto.d.ts.map +1 -1
  19. package/dist/category/dto/create.dto.js +2 -2
  20. package/dist/category/dto/create.dto.js.map +1 -1
  21. package/dist/post/post.controller.d.ts +13 -5
  22. package/dist/post/post.controller.d.ts.map +1 -1
  23. package/dist/post/post.controller.js +7 -7
  24. package/dist/post/post.controller.js.map +1 -1
  25. package/dist/post/post.service.d.ts +9 -1
  26. package/dist/post/post.service.d.ts.map +1 -1
  27. package/dist/post/post.service.js +2 -1
  28. package/dist/post/post.service.js.map +1 -1
  29. package/hedhog.yaml +133 -133
  30. package/package.json +9 -5
  31. package/frontend/author/components/author.screen.ts +0 -105
  32. package/frontend/author/components/create-panel.tsx +0 -64
  33. package/frontend/author/components/update-panel.tsx +0 -75
  34. package/frontend/author/react-query/handlers.ts +0 -28
  35. package/frontend/author/react-query/requests.ts +0 -54
  36. package/frontend/category/components/category.screen.ts +0 -105
  37. package/frontend/category/components/create-panel.tsx +0 -53
  38. package/frontend/category/components/update-panel.tsx +0 -64
  39. package/frontend/category/react-query/handlers.ts +0 -28
  40. package/frontend/category/react-query/requests.ts +0 -55
  41. package/frontend/post/components/create-panel.tsx +0 -78
  42. package/frontend/post/components/post.screen.ts +0 -105
  43. package/frontend/post/components/update-panel.tsx +0 -89
  44. package/frontend/post/react-query/handlers.ts +0 -28
  45. package/frontend/post/react-query/requests.ts +0 -54
package/hedhog.yaml CHANGED
@@ -1,133 +1,133 @@
1
- data:
2
- route:
3
- - url: /auth/login
4
- method: POST
5
- - url: /post
6
- method: GET
7
- - url: /post/:id
8
- method: GET
9
- - url: /author
10
- method: GET
11
- relations: &a1
12
- role:
13
- - where:
14
- slug: admin
15
- - url: /author/:id
16
- method: GET
17
- relations: *a1
18
- - url: /category
19
- method: GET
20
- relations: &a2
21
- role:
22
- - where:
23
- slug: admin
24
- - url: /category/:id
25
- method: GET
26
- relations: *a2
27
- menu:
28
- - name:
29
- en: Author
30
- pt: Author
31
- icon: file
32
- url: /author
33
- slug: author
34
- relations: *a1
35
- - name:
36
- en: Category
37
- pt: Category
38
- icon: file
39
- url: /category
40
- slug: category
41
- relations: *a2
42
- - name:
43
- en: Post
44
- pt: Post
45
- icon: file
46
- url: /post
47
- slug: post
48
- relations:
49
- role:
50
- - where:
51
- slug: admin
52
- screen:
53
- - name:
54
- en: Author
55
- pt: Author
56
- slug: author
57
- description:
58
- en: Screen to manage author
59
- pt: Tela para gerenciar author
60
- icon: file
61
- - name:
62
- en: Category
63
- pt: Category
64
- slug: category
65
- description:
66
- en: Screen to manage category
67
- pt: Tela para gerenciar category
68
- icon: file
69
- - name:
70
- en: Post
71
- pt: Post
72
- slug: post
73
- description:
74
- en: Screen to manage post
75
- pt: Tela para gerenciar post
76
- icon: file
77
- tables:
78
- author:
79
- columns:
80
- - type: pk
81
- - name: name
82
- - name: email
83
- ifNotExists: true
84
- category:
85
- columns:
86
- - type: pk
87
- - type: slug
88
- - type: created_at
89
- - type: updated_at
90
- ifNotExists: true
91
- category_locale:
92
- columns:
93
- - name: category_id
94
- type: fk
95
- isPrimary: true
96
- references:
97
- table: category
98
- column: id
99
- onDelete: RESTRICT
100
- - name: locale_id
101
- type: fk
102
- isPrimary: true
103
- references:
104
- table: locale
105
- column: id
106
- onDelete: RESTRICT
107
- - name: name
108
- length: 100
109
- - name: description
110
- length: 512
111
- - type: created_at
112
- - type: updated_at
113
- post:
114
- columns:
115
- - type: pk
116
- - name: title
117
- - name: content
118
- type: text
119
- - name: author_id
120
- type: fk
121
- references:
122
- table: author
123
- column: id
124
- onDelete: CASCADE
125
- - name: category_id
126
- type: fk
127
- references:
128
- table: category
129
- column: id
130
- onDelete: RESTRICT
131
- - type: created_at
132
- - type: updated_at
133
- ifNotExists: true
1
+ data:
2
+ route:
3
+ - url: /auth/login
4
+ method: POST
5
+ - url: /post
6
+ method: GET
7
+ - url: /post/:id
8
+ method: GET
9
+ - url: /author
10
+ method: GET
11
+ relations: &a1
12
+ role:
13
+ - where:
14
+ slug: admin
15
+ - url: /author/:id
16
+ method: GET
17
+ relations: *a1
18
+ - url: /category
19
+ method: GET
20
+ relations: &a2
21
+ role:
22
+ - where:
23
+ slug: admin
24
+ - url: /category/:id
25
+ method: GET
26
+ relations: *a2
27
+ menu:
28
+ - name:
29
+ en: Author
30
+ pt: Author
31
+ icon: file
32
+ url: /author
33
+ slug: author
34
+ relations: *a1
35
+ - name:
36
+ en: Category
37
+ pt: Category
38
+ icon: file
39
+ url: /category
40
+ slug: category
41
+ relations: *a2
42
+ - name:
43
+ en: Post
44
+ pt: Post
45
+ icon: file
46
+ url: /post
47
+ slug: post
48
+ relations:
49
+ role:
50
+ - where:
51
+ slug: admin
52
+ screen:
53
+ - name:
54
+ en: Author
55
+ pt: Author
56
+ slug: author
57
+ description:
58
+ en: Screen to manage author
59
+ pt: Tela para gerenciar author
60
+ icon: file
61
+ - name:
62
+ en: Category
63
+ pt: Category
64
+ slug: category
65
+ description:
66
+ en: Screen to manage category
67
+ pt: Tela para gerenciar category
68
+ icon: file
69
+ - name:
70
+ en: Post
71
+ pt: Post
72
+ slug: post
73
+ description:
74
+ en: Screen to manage post
75
+ pt: Tela para gerenciar post
76
+ icon: file
77
+ tables:
78
+ author:
79
+ columns:
80
+ - type: pk
81
+ - name: name
82
+ - name: email
83
+ ifNotExists: true
84
+ category:
85
+ columns:
86
+ - type: pk
87
+ - type: slug
88
+ - type: created_at
89
+ - type: updated_at
90
+ ifNotExists: true
91
+ category_locale:
92
+ columns:
93
+ - name: category_id
94
+ type: fk
95
+ isPrimary: true
96
+ references:
97
+ table: category
98
+ column: id
99
+ onDelete: RESTRICT
100
+ - name: locale_id
101
+ type: fk
102
+ isPrimary: true
103
+ references:
104
+ table: locale
105
+ column: id
106
+ onDelete: RESTRICT
107
+ - name: name
108
+ length: 100
109
+ - name: description
110
+ length: 512
111
+ - type: created_at
112
+ - type: updated_at
113
+ post:
114
+ columns:
115
+ - type: pk
116
+ - name: title
117
+ - name: content
118
+ type: text
119
+ - name: author_id
120
+ type: fk
121
+ references:
122
+ table: author
123
+ column: id
124
+ onDelete: CASCADE
125
+ - name: category_id
126
+ type: fk
127
+ references:
128
+ table: category
129
+ column: id
130
+ onDelete: RESTRICT
131
+ - type: created_at
132
+ - type: updated_at
133
+ ifNotExists: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedhog/blog",
3
- "version": "0.0.12",
3
+ "version": "0.3.1",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -23,13 +23,17 @@
23
23
  "description": "",
24
24
  "peerDependencies": {
25
25
  "@hedhog/admin": "latest",
26
+ "@hedhog/locale": "latest",
26
27
  "@hedhog/pagination": "latest",
27
- "@hedhog/prisma": "latest"
28
+ "@hedhog/prisma": "latest",
29
+ "@hedhog/utils": "latest"
28
30
  },
29
31
  "devDependencies": {
30
- "@hedhog/admin": "^0.0.108",
31
- "@hedhog/pagination": "^0.0.17",
32
- "@hedhog/prisma": "^0.0.11",
32
+ "@hedhog/admin": "^0.0.124",
33
+ "@hedhog/locale": "^0.0.24",
34
+ "@hedhog/pagination": "^0.0.18",
35
+ "@hedhog/prisma": "^0.0.12",
36
+ "@hedhog/utils": "^0.0.27",
33
37
  "@nestjs/mapped-types": "^2.0.5"
34
38
  }
35
39
  }
@@ -1,105 +0,0 @@
1
- import { PageTitle } from "@/components/custom/page-title";
2
- import DataPanel from "@/components/panels/data-panel";
3
- import { useAuthorDelete } from "@/features/blog/author";
4
- import { useApp } from "@/hooks/use-app";
5
- import { isPlural } from "@/lib/utils";
6
- import { Author } from "@/types/models";
7
- import { IconEdit, IconPlus, IconTrash } from "@tabler/icons-react";
8
- import { useState } from "react";
9
- import { useTranslation } from "react-i18next";
10
- import AuthorCreatePanel from "./components/author-create-panel";
11
- import AuthorUpdatePanel from "./components/author-update-panel";
12
-
13
- export default function Page() {
14
- const [selectedItems, setSelectedItems] = useState<Author[]>([]);
15
- const { mutate: deleteAuthor } = useAuthorDelete();
16
- const { openSheet, confirm, closeSheet } = useApp();
17
- const { t } = useTranslation(["author", "modules", "actions"]);
18
-
19
- const openCreate = () => {
20
- const id = openSheet({
21
- title: t("create", { ns: "actions" }),
22
- description: t("createText", { ns: "author" }),
23
- children: () => <AuthorCreatePanel onCreated={() => closeSheet(id)} />,
24
- });
25
-
26
- return id;
27
- };
28
-
29
- const openDelete = (items: Author[]) => {
30
- return confirm({
31
- title: `${t("delete", { ns: "actions" })} ${items.length} ${isPlural(items.length) ? t("items", { ns: "actions" }) : t("item", { ns: "actions" })}`,
32
- description: t("deleteText", { ns: "author" }),
33
- })
34
- .then(() =>
35
- deleteAuthor(
36
- items.map((item) => item.id).filter((id) => id !== undefined),
37
- ),
38
- )
39
- .catch(() => setSelectedItems(items));
40
- };
41
-
42
- const openUpdate = (item: Author) => {
43
- const id = openSheet({
44
- children: () => (
45
- <AuthorUpdatePanel data={item} onUpdated={() => closeSheet(id)} />
46
- ),
47
- title: t("edit", { ns: "author" }),
48
- description: t("editText", { ns: "author" }),
49
- });
50
-
51
- return id;
52
- };
53
-
54
- return (
55
- <>
56
- <PageTitle title={t("author", { ns: "modules" })} />
57
- <DataPanel
58
- url="/author"
59
- layout="table"
60
- id="author"
61
- selectable
62
- columns={[
63
- { key: "id", header: "ID", width: 64 },
64
- { key: "name", header: t("name", { ns: "author" }) },
65
- ]}
66
- selected={selectedItems as Author[]}
67
- multiple
68
- hasSearch
69
- sortable
70
- onItemDoubleClick={(item) => openUpdate(item)}
71
- menuActions={[
72
- {
73
- icon: <IconEdit className="mr-1 w-8 cursor-pointer" />,
74
- label: t("edit", { ns: "actions" }),
75
- tooltip: t("editTooltip", { ns: "author" }),
76
- handler: (items: Author[]) => {
77
- if (items.length === 1) openUpdate(items[0]);
78
- },
79
- show: "once",
80
- },
81
- {
82
- icon: <IconTrash className="mr-1 w-8 cursor-pointer" />,
83
- label: t("delete", { ns: "actions" }),
84
- tooltip: t("deleteTooltip", { ns: "author" }),
85
- variant: "destructive",
86
- handler: (items: Author[]) => {
87
- openDelete(items);
88
- },
89
- show: "some",
90
- },
91
- {
92
- icon: <IconPlus className="mr-1 w-8 cursor-pointer" />,
93
- label: t("create", { ns: "actions" }),
94
- tooltip: t("createTooltip", { ns: "author" }),
95
- variant: "default",
96
- handler: () => {
97
- openCreate();
98
- },
99
- show: "none",
100
- },
101
- ]}
102
- />
103
- </>
104
- );
105
- }
@@ -1,64 +0,0 @@
1
- import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
- import { EnumFieldType } from "@/enums/EnumFieldType";
3
- import { useAuthorCreate } from "@/features/blog/author";
4
- import { Author } from "@/types/models";
5
- import { forwardRef, useImperativeHandle, useRef } from "react";
6
- import { useTranslation } from "react-i18next";
7
-
8
- export type AuthorCreatePanelRef = {
9
- submit: () => void;
10
- };
11
-
12
- export type AuthorCreatePanelProps = {
13
- onCreated?: (data: Author) => void;
14
- };
15
-
16
- const AuthorCreatePanel = forwardRef(
17
- ({ onCreated }: AuthorCreatePanelProps, ref) => {
18
- const formRef = useRef<FormPanelRef>(null);
19
- const { t } = useTranslation(["author", "actions"]);
20
- const { mutateAsync: createAuthor } = useAuthorCreate();
21
-
22
- useImperativeHandle(
23
- ref,
24
- () => ({
25
- submit: () => {
26
- formRef.current?.submit();
27
- },
28
- }),
29
- [formRef],
30
- );
31
-
32
- return (
33
- <FormPanel
34
- ref={formRef}
35
- fields={[
36
- {
37
- name: "name",
38
- label: { text: t("name", { ns: "translation" }) },
39
- type: EnumFieldType.TEXT,
40
- required: true,
41
- },
42
-
43
- {
44
- name: "email",
45
- label: { text: t("email", { ns: "translation" }) },
46
- type: EnumFieldType.TEXT,
47
- required: true,
48
- },
49
- ]}
50
- button={{ text: t("create", { ns: "actions" }) }}
51
- onSubmit={async (data) => {
52
- const createdData = await createAuthor(data);
53
- if (typeof onCreated === "function") {
54
- onCreated(createdData);
55
- }
56
- }}
57
- />
58
- );
59
- },
60
- );
61
-
62
- AuthorCreatePanel.displayName = "AuthorCreatePanel";
63
-
64
- export default AuthorCreatePanel;
@@ -1,75 +0,0 @@
1
- import FormPanel, { FormPanelRef } from "@/components/panels/form-panel";
2
- import { Overlay } from "@/components/custom/overlay";
3
- import { TabPanel } from "@/components/panels/tab-panel";
4
- import { EnumFieldType } from "@/enums/EnumFieldType";
5
- import { useAuthorGet, useAuthorUpdate } from "@/features/blog/author";
6
- import useEffectAfterFirstUpdate from "@/hooks/use-effect-after-first-update";
7
- import { Author } from "@/types/models";
8
- import { forwardRef, useImperativeHandle, useRef } from "react";
9
- import { useTranslation } from "react-i18next";
10
-
11
- export type AuthorUpdatePanelProps = {
12
- data: Author;
13
- onUpdated?: (data: Author) => void;
14
- };
15
-
16
- const AuthorUpdatePanel = forwardRef(
17
- ({ data, onUpdated }: AuthorUpdatePanelProps, ref) => {
18
- const { t } = useTranslation(["person-types", "actions"]);
19
- const { data: item, isLoading } = useAuthorGet(data.id as number);
20
- const { mutate: authorUpdate } = useAuthorUpdate();
21
- const formRef = useRef<FormPanelRef>(null);
22
-
23
- useEffectAfterFirstUpdate(() => {
24
- if (item && formRef.current) {
25
- formRef.current.setValuesFromItem(item);
26
- }
27
- }, [item]);
28
-
29
- useImperativeHandle(ref, () => ({}));
30
-
31
- return (
32
- <TabPanel
33
- activeTabIndex={0}
34
- tabs={[
35
- {
36
- title: t("details", { ns: "actions" }),
37
- children: (
38
- <Overlay loading={isLoading}>
39
- <FormPanel
40
- ref={formRef}
41
- fields={[
42
- {
43
- name: "name",
44
- label: { text: t("name", { ns: "translation" }) },
45
- type: EnumFieldType.TEXT,
46
- required: true,
47
- },
48
-
49
- {
50
- name: "email",
51
- label: { text: t("email", { ns: "translation" }) },
52
- type: EnumFieldType.TEXT,
53
- required: true,
54
- },
55
- ]}
56
- button={{ text: t("save", { ns: "actions" }) }}
57
- onSubmit={(data) => {
58
- authorUpdate({ id: data.id, data });
59
- if (typeof onUpdated === "function") {
60
- onUpdated(data);
61
- }
62
- }}
63
- />
64
- </Overlay>
65
- ),
66
- },
67
- ]}
68
- />
69
- );
70
- },
71
- );
72
-
73
- AuthorUpdatePanel.displayName = "AuthorUpdatePanel";
74
-
75
- export default AuthorUpdatePanel;
@@ -1,28 +0,0 @@
1
- import { useDefaultMutation } from "@/hooks/use-default-mutation";
2
- import { useQuery } from "@tanstack/react-query";
3
- import { requests } from "./requests";
4
-
5
- const scope = "author";
6
-
7
- export function useAuthorCreate() {
8
- const { authorCreate } = requests();
9
- return useDefaultMutation(scope, "create", authorCreate);
10
- }
11
-
12
- export function useAuthorDelete() {
13
- const { authorDelete } = requests();
14
- return useDefaultMutation(scope, "delete", authorDelete);
15
- }
16
-
17
- export function useAuthorUpdate() {
18
- const { authorUpdate } = requests();
19
- return useDefaultMutation(scope, "update", authorUpdate);
20
- }
21
-
22
- export function useAuthorGet(id: number) {
23
- const { authorGet } = requests();
24
- return useQuery({
25
- queryKey: [scope, "get"],
26
- queryFn: () => authorGet(id),
27
- });
28
- }
@@ -1,54 +0,0 @@
1
- import { useApp } from "@/hooks/use-app";
2
- import { Delete, PaginationParams, PaginationResult } from "@/types";
3
- import { Author } from "@/types/models";
4
- import { HttpMethod } from "@/types/http-method";
5
-
6
- export function requests() {
7
- const { request } = useApp();
8
-
9
- const authorList = async (params: PaginationParams) => {
10
- return request<PaginationResult<Author>>({
11
- url: "/author",
12
- params,
13
- }).then((res) => res.data);
14
- };
15
-
16
- const authorGet = async (id: number) => {
17
- return request<Author>({
18
- url: `/author/${id}`,
19
- }).then((res) => res.data);
20
- };
21
-
22
- const authorCreate = async (data: Author) => {
23
- return request<Author>({
24
- url: "/author",
25
- method: HttpMethod.POST,
26
- data: data,
27
- }).then((res) => res.data);
28
- };
29
-
30
- const authorDelete = async (ids: number[]) => {
31
- return request<Delete>({
32
- url: "/author",
33
- data: { ids },
34
- method: HttpMethod.DELETE,
35
- }).then((res) => res.data);
36
- };
37
-
38
- const authorUpdate = async (params: { id: number; data: Author }) => {
39
- const { id, data } = params;
40
- return request<Author>({
41
- url: `/author/${id}`,
42
- method: HttpMethod.PATCH,
43
- data: data,
44
- }).then((res) => res.data);
45
- };
46
-
47
- return {
48
- authorCreate,
49
- authorUpdate,
50
- authorDelete,
51
- authorList,
52
- authorGet,
53
- };
54
- }