nextjs-cms 0.0.1 → 0.5.1
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/LICENSE +21 -0
- package/README.md +289 -0
- package/dist/api/axios/axiosInstance.d.ts +2 -0
- package/dist/api/axios/axiosInstance.d.ts.map +1 -0
- package/dist/api/axios/axiosInstance.js +8 -0
- package/dist/api/index.d.ts +856 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +12 -0
- package/dist/api/lib/serverActions.d.ts +240 -0
- package/dist/api/lib/serverActions.d.ts.map +1 -0
- package/dist/api/lib/serverActions.js +834 -0
- package/dist/api/root.d.ts +829 -0
- package/dist/api/root.d.ts.map +1 -0
- package/dist/api/root.js +30 -0
- package/dist/api/routers/accountSettings.d.ts +61 -0
- package/dist/api/routers/accountSettings.d.ts.map +1 -0
- package/dist/api/routers/accountSettings.js +108 -0
- package/dist/api/routers/admins.d.ts +106 -0
- package/dist/api/routers/admins.d.ts.map +1 -0
- package/dist/api/routers/admins.js +219 -0
- package/dist/api/routers/auth.d.ts +48 -0
- package/dist/api/routers/auth.d.ts.map +1 -0
- package/dist/api/routers/auth.js +25 -0
- package/dist/api/routers/categorySection.d.ts +104 -0
- package/dist/api/routers/categorySection.d.ts.map +1 -0
- package/dist/api/routers/categorySection.js +38 -0
- package/dist/api/routers/cmsSettings.d.ts +49 -0
- package/dist/api/routers/cmsSettings.d.ts.map +1 -0
- package/dist/api/routers/cmsSettings.js +51 -0
- package/dist/api/routers/cpanel.d.ts +84 -0
- package/dist/api/routers/cpanel.d.ts.map +1 -0
- package/dist/api/routers/cpanel.js +216 -0
- package/dist/api/routers/files.d.ts +48 -0
- package/dist/api/routers/files.d.ts.map +1 -0
- package/dist/api/routers/files.js +23 -0
- package/dist/api/routers/gallery.d.ts +36 -0
- package/dist/api/routers/gallery.d.ts.map +1 -0
- package/dist/api/routers/gallery.js +62 -0
- package/dist/api/routers/googleAnalytics.d.ts +31 -0
- package/dist/api/routers/googleAnalytics.d.ts.map +1 -0
- package/dist/api/routers/googleAnalytics.js +7 -0
- package/dist/api/routers/hasItemsSection.d.ts +140 -0
- package/dist/api/routers/hasItemsSection.d.ts.map +1 -0
- package/dist/api/routers/hasItemsSection.js +34 -0
- package/dist/api/routers/navigation.d.ts +52 -0
- package/dist/api/routers/navigation.d.ts.map +1 -0
- package/dist/api/routers/navigation.js +11 -0
- package/dist/api/routers/simpleSection.d.ts +58 -0
- package/dist/api/routers/simpleSection.d.ts.map +1 -0
- package/dist/api/routers/simpleSection.js +12 -0
- package/dist/api/trpc.d.ts +107 -0
- package/dist/api/trpc.d.ts.map +1 -0
- package/dist/api/trpc.js +72 -0
- package/dist/auth/axios/axiosInstance.d.ts +2 -0
- package/dist/auth/axios/axiosInstance.d.ts.map +1 -0
- package/dist/auth/axios/axiosInstance.js +8 -0
- package/dist/auth/csrf.d.ts +30 -0
- package/dist/auth/csrf.d.ts.map +1 -0
- package/dist/auth/csrf.js +76 -0
- package/dist/auth/hooks/index.d.ts +4 -0
- package/dist/auth/hooks/index.d.ts.map +1 -0
- package/dist/auth/hooks/index.js +3 -0
- package/dist/auth/hooks/useAxiosPrivate.d.ts +5 -0
- package/dist/auth/hooks/useAxiosPrivate.d.ts.map +1 -0
- package/dist/auth/hooks/useAxiosPrivate.js +74 -0
- package/dist/auth/hooks/useRefreshToken.d.ts +7 -0
- package/dist/auth/hooks/useRefreshToken.d.ts.map +1 -0
- package/dist/auth/hooks/useRefreshToken.js +79 -0
- package/dist/auth/index.d.ts +23 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +44 -0
- package/dist/auth/jwt.d.ts +6 -0
- package/dist/auth/jwt.d.ts.map +1 -0
- package/dist/auth/jwt.js +25 -0
- package/dist/auth/lib/actions.d.ts +33 -0
- package/dist/auth/lib/actions.d.ts.map +1 -0
- package/dist/auth/lib/actions.js +209 -0
- package/dist/auth/lib/client.d.ts +4 -0
- package/dist/auth/lib/client.d.ts.map +1 -0
- package/dist/auth/lib/client.js +46 -0
- package/dist/auth/lib/index.d.ts +3 -0
- package/dist/auth/lib/index.d.ts.map +1 -0
- package/dist/auth/lib/index.js +2 -0
- package/dist/auth/react.d.ts +106 -0
- package/dist/auth/react.d.ts.map +1 -0
- package/dist/auth/react.js +347 -0
- package/dist/auth/trpc.d.ts +6 -0
- package/dist/auth/trpc.d.ts.map +1 -0
- package/dist/auth/trpc.js +81 -0
- package/dist/core/config/config-loader.d.ts +92 -0
- package/dist/core/config/config-loader.d.ts.map +1 -0
- package/dist/core/config/config-loader.js +230 -0
- package/dist/core/config/index.d.ts +3 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +1 -0
- package/dist/core/config/loader.d.ts +2 -0
- package/dist/core/config/loader.d.ts.map +1 -0
- package/dist/core/config/loader.js +42 -0
- package/dist/core/db/index.d.ts +2 -0
- package/dist/core/db/index.d.ts.map +1 -0
- package/dist/core/db/index.js +1 -0
- package/dist/core/db/table-checker/DbTable.d.ts +6 -0
- package/dist/core/db/table-checker/DbTable.d.ts.map +1 -0
- package/dist/core/db/table-checker/DbTable.js +5 -0
- package/dist/core/db/table-checker/MysqlTable.d.ts +34 -0
- package/dist/core/db/table-checker/MysqlTable.d.ts.map +1 -0
- package/dist/core/db/table-checker/MysqlTable.js +102 -0
- package/dist/core/db/table-checker/index.d.ts +2 -0
- package/dist/core/db/table-checker/index.d.ts.map +1 -0
- package/dist/core/db/table-checker/index.js +1 -0
- package/dist/core/factories/FieldFactory.d.ts +124 -0
- package/dist/core/factories/FieldFactory.d.ts.map +1 -0
- package/dist/core/factories/FieldFactory.js +411 -0
- package/dist/core/factories/SectionFactory.d.ts +110 -0
- package/dist/core/factories/SectionFactory.d.ts.map +1 -0
- package/dist/core/factories/SectionFactory.js +415 -0
- package/dist/core/factories/index.d.ts +3 -0
- package/dist/core/factories/index.d.ts.map +1 -0
- package/dist/core/factories/index.js +2 -0
- package/dist/core/fields/checkbox.d.ts +63 -0
- package/dist/core/fields/checkbox.d.ts.map +1 -0
- package/dist/core/fields/checkbox.js +62 -0
- package/dist/core/fields/color.d.ts +84 -0
- package/dist/core/fields/color.d.ts.map +1 -0
- package/dist/core/fields/color.js +91 -0
- package/dist/core/fields/date.d.ts +100 -0
- package/dist/core/fields/date.d.ts.map +1 -0
- package/dist/core/fields/date.js +108 -0
- package/dist/core/fields/document.d.ts +180 -0
- package/dist/core/fields/document.d.ts.map +1 -0
- package/dist/core/fields/document.js +277 -0
- package/dist/core/fields/field-group.d.ts +18 -0
- package/dist/core/fields/field-group.d.ts.map +1 -0
- package/dist/core/fields/field-group.js +6 -0
- package/dist/core/fields/field.d.ts +126 -0
- package/dist/core/fields/field.d.ts.map +1 -0
- package/dist/core/fields/field.js +148 -0
- package/dist/core/fields/fileField.d.ts +15 -0
- package/dist/core/fields/fileField.d.ts.map +1 -0
- package/dist/core/fields/fileField.js +5 -0
- package/dist/core/fields/index.d.ts +65 -0
- package/dist/core/fields/index.d.ts.map +1 -0
- package/dist/core/fields/index.js +18 -0
- package/dist/core/fields/map.d.ts +167 -0
- package/dist/core/fields/map.d.ts.map +1 -0
- package/dist/core/fields/map.js +152 -0
- package/dist/core/fields/number.d.ts +186 -0
- package/dist/core/fields/number.d.ts.map +1 -0
- package/dist/core/fields/number.js +241 -0
- package/dist/core/fields/password.d.ts +109 -0
- package/dist/core/fields/password.d.ts.map +1 -0
- package/dist/core/fields/password.js +133 -0
- package/dist/core/fields/photo.d.ts +289 -0
- package/dist/core/fields/photo.d.ts.map +1 -0
- package/dist/core/fields/photo.js +410 -0
- package/dist/core/fields/richText.d.ts +295 -0
- package/dist/core/fields/richText.d.ts.map +1 -0
- package/dist/core/fields/richText.js +338 -0
- package/dist/core/fields/select.d.ts +366 -0
- package/dist/core/fields/select.d.ts.map +1 -0
- package/dist/core/fields/select.js +499 -0
- package/dist/core/fields/selectMultiple.d.ts +236 -0
- package/dist/core/fields/selectMultiple.d.ts.map +1 -0
- package/dist/core/fields/selectMultiple.js +417 -0
- package/dist/core/fields/tags.d.ts +131 -0
- package/dist/core/fields/tags.d.ts.map +1 -0
- package/dist/core/fields/tags.js +105 -0
- package/dist/core/fields/text.d.ts +136 -0
- package/dist/core/fields/text.d.ts.map +1 -0
- package/dist/core/fields/text.js +157 -0
- package/dist/core/fields/textArea.d.ts +107 -0
- package/dist/core/fields/textArea.d.ts.map +1 -0
- package/dist/core/fields/textArea.js +126 -0
- package/dist/core/fields/video.d.ts +148 -0
- package/dist/core/fields/video.d.ts.map +1 -0
- package/dist/core/fields/video.js +248 -0
- package/dist/core/helpers/entity.d.ts +8 -0
- package/dist/core/helpers/entity.d.ts.map +1 -0
- package/dist/core/helpers/entity.js +27 -0
- package/dist/core/helpers/index.d.ts +5 -0
- package/dist/core/helpers/index.d.ts.map +1 -0
- package/dist/core/helpers/index.js +3 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/sections/category.d.ts +283 -0
- package/dist/core/sections/category.d.ts.map +1 -0
- package/dist/core/sections/category.js +147 -0
- package/dist/core/sections/hasItems.d.ts +632 -0
- package/dist/core/sections/hasItems.d.ts.map +1 -0
- package/dist/core/sections/hasItems.js +144 -0
- package/dist/core/sections/index.d.ts +5 -0
- package/dist/core/sections/index.d.ts.map +1 -0
- package/dist/core/sections/index.js +4 -0
- package/dist/core/sections/section.d.ts +226 -0
- package/dist/core/sections/section.d.ts.map +1 -0
- package/dist/core/sections/section.js +341 -0
- package/dist/core/sections/simple.d.ts +99 -0
- package/dist/core/sections/simple.d.ts.map +1 -0
- package/dist/core/sections/simple.js +95 -0
- package/dist/core/security/dom.d.ts +11 -0
- package/dist/core/security/dom.d.ts.map +1 -0
- package/dist/core/security/dom.js +92 -0
- package/dist/core/submit/ItemEditSubmit.d.ts +76 -0
- package/dist/core/submit/ItemEditSubmit.d.ts.map +1 -0
- package/dist/core/submit/ItemEditSubmit.js +186 -0
- package/dist/core/submit/NewItemSubmit.d.ts +14 -0
- package/dist/core/submit/NewItemSubmit.d.ts.map +1 -0
- package/dist/core/submit/NewItemSubmit.js +93 -0
- package/dist/core/submit/SimpleSectionSubmit.d.ts +13 -0
- package/dist/core/submit/SimpleSectionSubmit.d.ts.map +1 -0
- package/dist/core/submit/SimpleSectionSubmit.js +93 -0
- package/dist/core/submit/index.d.ts +5 -0
- package/dist/core/submit/index.d.ts.map +1 -0
- package/dist/core/submit/index.js +4 -0
- package/dist/core/submit/submit.d.ts +116 -0
- package/dist/core/submit/submit.d.ts.map +1 -0
- package/dist/core/submit/submit.js +479 -0
- package/dist/core/types/index.d.ts +280 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +1 -0
- package/dist/db/client.d.ts +9 -0
- package/dist/db/client.d.ts.map +1 -0
- package/dist/db/client.js +19 -0
- package/dist/db/config.d.ts +6 -0
- package/dist/db/config.d.ts.map +1 -0
- package/dist/db/config.js +22 -0
- package/dist/db/drizzle.config.d.ts +6 -0
- package/dist/db/drizzle.config.d.ts.map +1 -0
- package/dist/db/drizzle.config.js +18 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +3 -0
- package/dist/db/schema.d.ts +639 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +73 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/translations/dictionaries/ar.json +279 -0
- package/dist/translations/dictionaries/en.json +279 -0
- package/dist/translations/index.d.ts +3 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +15 -0
- package/dist/utils/CpanelApi.d.ts +25 -0
- package/dist/utils/CpanelApi.d.ts.map +1 -0
- package/dist/utils/CpanelApi.js +64 -0
- package/dist/utils/constants.d.ts +14 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +61 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/utils.d.ts +60 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +132 -0
- package/dist/validators/checkbox.d.ts +4 -0
- package/dist/validators/checkbox.d.ts.map +1 -0
- package/dist/validators/checkbox.js +12 -0
- package/dist/validators/color.d.ts +4 -0
- package/dist/validators/color.d.ts.map +1 -0
- package/dist/validators/color.js +7 -0
- package/dist/validators/date.d.ts +4 -0
- package/dist/validators/date.d.ts.map +1 -0
- package/dist/validators/date.js +5 -0
- package/dist/validators/document.d.ts +4 -0
- package/dist/validators/document.d.ts.map +1 -0
- package/dist/validators/document.js +57 -0
- package/dist/validators/index.d.ts +15 -0
- package/dist/validators/index.d.ts.map +1 -0
- package/dist/validators/index.js +14 -0
- package/dist/validators/map.d.ts +4 -0
- package/dist/validators/map.d.ts.map +1 -0
- package/dist/validators/map.js +5 -0
- package/dist/validators/number.d.ts +4 -0
- package/dist/validators/number.d.ts.map +1 -0
- package/dist/validators/number.js +20 -0
- package/dist/validators/password.d.ts +4 -0
- package/dist/validators/password.d.ts.map +1 -0
- package/dist/validators/password.js +11 -0
- package/dist/validators/photo.d.ts +4 -0
- package/dist/validators/photo.d.ts.map +1 -0
- package/dist/validators/photo.js +100 -0
- package/dist/validators/richText.d.ts +4 -0
- package/dist/validators/richText.d.ts.map +1 -0
- package/dist/validators/richText.js +8 -0
- package/dist/validators/select-multiple.d.ts +10 -0
- package/dist/validators/select-multiple.d.ts.map +1 -0
- package/dist/validators/select-multiple.js +20 -0
- package/dist/validators/select.d.ts +4 -0
- package/dist/validators/select.d.ts.map +1 -0
- package/dist/validators/select.js +5 -0
- package/dist/validators/text.d.ts +4 -0
- package/dist/validators/text.d.ts.map +1 -0
- package/dist/validators/text.js +7 -0
- package/dist/validators/textarea.d.ts +4 -0
- package/dist/validators/textarea.d.ts.map +1 -0
- package/dist/validators/textarea.js +7 -0
- package/dist/validators/video.d.ts +4 -0
- package/dist/validators/video.d.ts.map +1 -0
- package/dist/validators/video.js +57 -0
- package/package.json +150 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 nextjs-cms
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# nextjs-cms
|
|
2
|
+
|
|
3
|
+
A headless and comprehensive type-safe content management system built with Nextjs. This package provides all the core functionality for building dynamic CMS-powered websites with authentication, database integration, and extensible content sections.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Type-Safe API**: Built with tRPC for end-to-end type safety
|
|
8
|
+
- **Authentication System**: JWT-based authentication with React hooks
|
|
9
|
+
- **Database Integration**: Drizzle ORM with MySQL support
|
|
10
|
+
- **Extensible Content Sections**: Modular section system with custom fields
|
|
11
|
+
- **File Management**: Built-in file upload and management capabilities
|
|
12
|
+
- **Internationalization**: Multi-language support with i18next
|
|
13
|
+
- **Validation**: Zod schema validation throughout
|
|
14
|
+
- **Testing**: Comprehensive unit and integration tests
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Please install using the create-nextjs-cms package:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx create-nextjs-cms
|
|
22
|
+
# or
|
|
23
|
+
yarn create nextjs-cms
|
|
24
|
+
# or
|
|
25
|
+
pnpm create nextjs-cms
|
|
26
|
+
# or
|
|
27
|
+
bun create nextjs-cms
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
### 1. Configure Your CMS
|
|
33
|
+
|
|
34
|
+
Create a `cms.config.ts` file in your project root:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { CMSConfig } from 'nextjs-cms/core/config'
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
siteName: 'My CMS Site',
|
|
41
|
+
sectionsFolder: './sections',
|
|
42
|
+
api: {
|
|
43
|
+
baseUrl: process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3000'
|
|
44
|
+
},
|
|
45
|
+
files: {
|
|
46
|
+
upload: {
|
|
47
|
+
uploadPath: './public/uploads',
|
|
48
|
+
keepFileExtension: true
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
database: {
|
|
52
|
+
url: process.env.DATABASE_URL
|
|
53
|
+
}
|
|
54
|
+
} satisfies CMSConfig
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### 2. Create Content Sections
|
|
59
|
+
|
|
60
|
+
Create a section file in your sections folder. Sections are created using helper functions (`simpleSection`, `hasItemsSection`, or `categorySection`), and fields are created using field helper functions.
|
|
61
|
+
|
|
62
|
+
#### Simple Section Example
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// sections/about.section.ts
|
|
66
|
+
import { richTextField } from 'nextjs-cms/core/fields'
|
|
67
|
+
import { simpleSection } from 'nextjs-cms/core/sections'
|
|
68
|
+
|
|
69
|
+
const about = richTextField({
|
|
70
|
+
name: 'about',
|
|
71
|
+
label: 'About',
|
|
72
|
+
required: true,
|
|
73
|
+
order: 1,
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
export default simpleSection({
|
|
77
|
+
name: 'about',
|
|
78
|
+
order: 1,
|
|
79
|
+
title: 'About Page',
|
|
80
|
+
db: {
|
|
81
|
+
table: 'about',
|
|
82
|
+
},
|
|
83
|
+
fields: [about],
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### Has Items Section Example
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// sections/blog.section.ts
|
|
91
|
+
import { textField, richTextField, dateField, photoField } from 'nextjs-cms/core/fields'
|
|
92
|
+
import { hasItemsSection } from 'nextjs-cms/core/sections'
|
|
93
|
+
|
|
94
|
+
const title = textField({
|
|
95
|
+
name: 'title',
|
|
96
|
+
label: 'Title',
|
|
97
|
+
required: true,
|
|
98
|
+
order: 1,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const content = richTextField({
|
|
102
|
+
name: 'content',
|
|
103
|
+
label: 'Content',
|
|
104
|
+
required: true,
|
|
105
|
+
order: 2,
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const publishDate = dateField({
|
|
109
|
+
name: 'publish_date',
|
|
110
|
+
label: 'Publish Date',
|
|
111
|
+
required: false,
|
|
112
|
+
order: 3,
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const coverPhoto = photoField({
|
|
116
|
+
name: 'coverphoto',
|
|
117
|
+
label: 'Cover Photo',
|
|
118
|
+
required: false,
|
|
119
|
+
order: 4,
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
export default hasItemsSection({
|
|
123
|
+
name: 'blog',
|
|
124
|
+
order: 1,
|
|
125
|
+
headingField: title,
|
|
126
|
+
title: {
|
|
127
|
+
section: 'Blog',
|
|
128
|
+
singular: 'Post',
|
|
129
|
+
plural: 'Posts',
|
|
130
|
+
},
|
|
131
|
+
db: {
|
|
132
|
+
table: 'blog',
|
|
133
|
+
},
|
|
134
|
+
fields: [title, content, publishDate, coverPhoto],
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Category Section Example
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// sections/categories.section.ts
|
|
142
|
+
import { textField, photoField } from 'nextjs-cms/core/fields'
|
|
143
|
+
import { categorySection } from 'nextjs-cms/core/sections'
|
|
144
|
+
|
|
145
|
+
const title = textField({
|
|
146
|
+
name: 'title',
|
|
147
|
+
label: 'Title',
|
|
148
|
+
required: true,
|
|
149
|
+
order: 1,
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const image = photoField({
|
|
153
|
+
name: 'image',
|
|
154
|
+
label: 'Image',
|
|
155
|
+
required: false,
|
|
156
|
+
order: 2,
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
export default categorySection({
|
|
160
|
+
name: 'categories',
|
|
161
|
+
order: 1,
|
|
162
|
+
headingField: title,
|
|
163
|
+
title: {
|
|
164
|
+
section: 'Categories',
|
|
165
|
+
singular: 'Category',
|
|
166
|
+
plural: 'Categories',
|
|
167
|
+
},
|
|
168
|
+
db: {
|
|
169
|
+
table: 'categories',
|
|
170
|
+
},
|
|
171
|
+
fields: [title, image],
|
|
172
|
+
depth: 2, // Allow nested categories
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## API Reference
|
|
177
|
+
|
|
178
|
+
### Core Modules
|
|
179
|
+
|
|
180
|
+
#### API (`nextjs-cms/api`)
|
|
181
|
+
- **appRouter**: Main tRPC router with all CMS endpoints
|
|
182
|
+
- **createCaller**: Server-side API caller factory
|
|
183
|
+
- **createTRPCContext**: Context factory for tRPC requests
|
|
184
|
+
|
|
185
|
+
#### Authentication (`nextjs-cms/auth`)
|
|
186
|
+
- **JWT Management**: Token creation, verification, and refresh
|
|
187
|
+
- **React Hooks**: `useAxiosPrivate`, `useRefreshToken`
|
|
188
|
+
- **Server Actions**: Authentication utilities for server components
|
|
189
|
+
|
|
190
|
+
#### Core (`nextjs-cms/core`)
|
|
191
|
+
- **Config**: CMS configuration management (`CMSConfig`)
|
|
192
|
+
- **Fields**: Content field helper functions (`textField`, `richTextField`, `dateField`, `photoField`, etc.)
|
|
193
|
+
- **Sections**: Section helper functions (`simpleSection`, `hasItemsSection`, `categorySection`)
|
|
194
|
+
- **Submit**: Form submission handlers (`SimpleSectionSubmit`)
|
|
195
|
+
- **Factories**: Section factory for loading sections (`SectionFactory`)
|
|
196
|
+
|
|
197
|
+
#### Database (`nextjs-cms/db`)
|
|
198
|
+
- **Client**: Database connection and query utilities
|
|
199
|
+
- **Schema**: Database schema definitions
|
|
200
|
+
- **Migrations**: Drizzle migration helpers
|
|
201
|
+
|
|
202
|
+
#### Validators (`nextjs-cms/validators`)
|
|
203
|
+
Zod validators for all field types:
|
|
204
|
+
- Text fields, numbers, dates
|
|
205
|
+
- File uploads (images, documents, videos)
|
|
206
|
+
- Rich text content
|
|
207
|
+
- Select fields and checkboxes
|
|
208
|
+
|
|
209
|
+
#### Translations (`nextjs-cms/translations`)
|
|
210
|
+
- Multi-language support
|
|
211
|
+
- Dictionary management
|
|
212
|
+
- i18next integration
|
|
213
|
+
|
|
214
|
+
## Field Types
|
|
215
|
+
|
|
216
|
+
The CMS supports various field types out of the box. Each field is created using a helper function that accepts a configuration object:
|
|
217
|
+
|
|
218
|
+
- **Text**: `textField({ name, label, required, order, ... })` - Single-line text input
|
|
219
|
+
- **TextArea**: `textAreaField({ name, label, required, order, ... })` - Multi-line text input
|
|
220
|
+
- **RichText**: `richTextField({ name, label, required, order, ... })` - Rich text editor (TinyMCE)
|
|
221
|
+
- **Number**: `numberField({ name, label, required, order, ... })` - Numeric input
|
|
222
|
+
- **Date**: `dateField({ name, label, required, order, ... })` - Date picker
|
|
223
|
+
- **Select**: `selectField({ name, label, required, order, options, ... })` - Dropdown selection
|
|
224
|
+
- **SelectMultiple**: `selectMultipleField({ name, label, required, order, ... })` - Multi-select field
|
|
225
|
+
- **Checkbox**: `checkboxField({ name, label, required, order, ... })` - Boolean checkbox
|
|
226
|
+
- **Photo**: `photoField({ name, label, required, order, size, thumbnail, ... })` - Image upload
|
|
227
|
+
- **Video**: `videoField({ name, label, required, order, ... })` - Video file upload
|
|
228
|
+
- **Document**: `documentField({ name, label, required, order, type, ... })` - Document file upload
|
|
229
|
+
- **Color**: `colorField({ name, label, required, order, ... })` - Color picker
|
|
230
|
+
- **Map**: `mapField({ name, label, required, order, ... })` - Location/map field
|
|
231
|
+
- **Tags**: `tagsField({ name, label, required, order, ... })` - Tag input field
|
|
232
|
+
- **Password**: `passwordField({ name, label, required, order, ... })` - Password input
|
|
233
|
+
- **FieldGroup**: `fieldGroup({ title, order, fields })` - Group multiple fields together
|
|
234
|
+
|
|
235
|
+
### Field Configuration
|
|
236
|
+
|
|
237
|
+
All fields require at minimum:
|
|
238
|
+
- `name`: string - Unique field identifier (used in database)
|
|
239
|
+
- `label`: string - Display label for the field
|
|
240
|
+
- `required`: boolean - Whether the field is required
|
|
241
|
+
- `order`: number - Display order of the field
|
|
242
|
+
|
|
243
|
+
Additional options vary by field type. See the API documentation for each field type for complete configuration options.
|
|
244
|
+
|
|
245
|
+
## Section Types
|
|
246
|
+
|
|
247
|
+
### Simple Section
|
|
248
|
+
Basic content sections with a single record. Use `simpleSection()` for pages like "About", "Contact", or "Settings" that have only one instance.
|
|
249
|
+
|
|
250
|
+
**Key characteristics:**
|
|
251
|
+
- Single record (always has ID = 1)
|
|
252
|
+
- No listing/browse page
|
|
253
|
+
- Direct edit page
|
|
254
|
+
- Requires `title` property
|
|
255
|
+
|
|
256
|
+
**Example use cases:** About page, Privacy Policy, Site Settings
|
|
257
|
+
|
|
258
|
+
### Has Items Section
|
|
259
|
+
Sections that can contain multiple items. Use `hasItemsSection()` for collections like blog posts, products, or articles.
|
|
260
|
+
|
|
261
|
+
**Key characteristics:**
|
|
262
|
+
- Multiple records
|
|
263
|
+
- Browse/listing page with pagination
|
|
264
|
+
- Individual item pages
|
|
265
|
+
- Requires `headingField` and `title` object with `section`, `singular`, and `plural` properties
|
|
266
|
+
- Optional `coverPhotoField`, `search`, and `gallery` configuration
|
|
267
|
+
|
|
268
|
+
**Example use cases:** Blog posts, Products, News articles, Events
|
|
269
|
+
|
|
270
|
+
### Category Section
|
|
271
|
+
Sections organized by categories with hierarchical structure. Use `categorySection()` for nested category systems.
|
|
272
|
+
|
|
273
|
+
**Key characteristics:**
|
|
274
|
+
- Hierarchical structure (configurable depth)
|
|
275
|
+
- Parent-child relationships
|
|
276
|
+
- Requires `headingField` and `title` object
|
|
277
|
+
- Optional `depth` property (default: 1, no nesting)
|
|
278
|
+
- Automatically adds `parent_id` and `level` fields when depth > 1
|
|
279
|
+
|
|
280
|
+
**Example use cases:** Product categories, Content categories, Navigation menus
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
## Contributing
|
|
284
|
+
|
|
285
|
+
Contributions are welcome! Please read our contributing guidelines and submit pull requests to the main repository.
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT License - see LICENSE file for details.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axiosInstance.d.ts","sourceRoot":"","sources":["../../../src/api/axios/axiosInstance.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,+BAMvB,CAAA"}
|