kizunacms 0.0.0 → 0.1.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.MD +9 -0
- package/README.md +208 -0
- package/dist/access-4YiqVHXB.d.mts +1251 -0
- package/dist/access-CrrWP0hv.d.cts +1251 -0
- package/dist/db-Cnv0aXba.cjs +1603 -0
- package/dist/db-wUR_ude-.mjs +1274 -0
- package/dist/index.cjs +2716 -0
- package/dist/index.d.cts +545 -0
- package/dist/index.d.mts +545 -0
- package/dist/index.mjs +2701 -0
- package/dist/postgres.cjs +1152 -0
- package/dist/postgres.d.cts +99 -0
- package/dist/postgres.d.mts +99 -0
- package/dist/postgres.mjs +1151 -0
- package/package.json +96 -3
package/LICENSE.MD
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sondre Ørland
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Kizuna CMS
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kizunajs/kizuna) 
|
|
4
|
+
|
|
5
|
+
Define your content once in TypeScript. Get an admin for your editors, a typed API, Swift and Kotlin clients, and tools AI agents can use to read and write it.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Collections and globals**: describe your content in TypeScript, from articles to a site's settings
|
|
10
|
+
- **Typed everywhere**: every site, app and AI assistant reads content through the same typed API
|
|
11
|
+
- **Access**: say who reads, creates, updates and deletes, on every collection
|
|
12
|
+
- **Images**: uploads with alt text and a focal point the editor sets, kept on disk or in S3
|
|
13
|
+
- **Slugs and metadata**: slugs and search titles made from the title, and a share image per article
|
|
14
|
+
- **References**: a document another one points at can't be deleted by mistake
|
|
15
|
+
- **Admin**: editors work in an admin that runs inside your app
|
|
16
|
+
- **Clients and AI tools**: TypeScript, Swift and Kotlin clients, OpenAPI and MCP from the same content
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
1. Install the CMS and its Next.js parts.
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
pnpm add kizunacms kizunajs @kizunacms/next @kizunajs/next drizzle-orm pg
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
2. Connect a Postgres database.
|
|
27
|
+
|
|
28
|
+
`db.ts`
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
32
|
+
import { postgresAdapter } from 'kizunacms/postgres';
|
|
33
|
+
|
|
34
|
+
export const db = postgresAdapter(() => drizzle(process.env.DATABASE_URL!));
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
3. Make the `k` your collections are declared with.
|
|
38
|
+
|
|
39
|
+
`cms/k.ts`
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { Kizuna } from 'kizunacms';
|
|
43
|
+
import type { Config } from './kizuna.types';
|
|
44
|
+
|
|
45
|
+
export const k = new Kizuna<Config>();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
4. Declare a collection.
|
|
49
|
+
|
|
50
|
+
`cms/collections/articles.ts`
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { k } from '../k';
|
|
54
|
+
|
|
55
|
+
export const Articles = k.collection({
|
|
56
|
+
name: 'articles',
|
|
57
|
+
titleField: 'title',
|
|
58
|
+
auth: {
|
|
59
|
+
read: ['public'],
|
|
60
|
+
create: ['editor'],
|
|
61
|
+
update: ['editor'],
|
|
62
|
+
delete: ['editor'],
|
|
63
|
+
},
|
|
64
|
+
fields: [
|
|
65
|
+
{
|
|
66
|
+
name: 'title',
|
|
67
|
+
type: 'text',
|
|
68
|
+
required: true,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'body',
|
|
72
|
+
type: 'text',
|
|
73
|
+
multiline: true,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
5. Declare the users who log in to the admin. A collection with `login: true` keeps accounts, and the CMS adds its `email` field.
|
|
80
|
+
|
|
81
|
+
`cms/collections/users.ts`
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { k } from '../k';
|
|
85
|
+
|
|
86
|
+
export const Users = k.collection({
|
|
87
|
+
name: 'users',
|
|
88
|
+
login: true,
|
|
89
|
+
titleField: 'name',
|
|
90
|
+
auth: {
|
|
91
|
+
read: ['admin'],
|
|
92
|
+
create: ['admin'],
|
|
93
|
+
update: ['admin'],
|
|
94
|
+
delete: ['admin'],
|
|
95
|
+
},
|
|
96
|
+
fields: [
|
|
97
|
+
{
|
|
98
|
+
name: 'name',
|
|
99
|
+
type: 'text',
|
|
100
|
+
required: true,
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
6. Put both in the config. `users` names the collection the admin logs in from, and the CMS adds a `roles` field to it. `roles` lists the roles beside `admin`. Every CMS has `admin` built in, and it passes every `auth`.
|
|
107
|
+
|
|
108
|
+
`kizuna.cms.config.ts`
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { defineConfig } from 'kizunacms';
|
|
112
|
+
import { nextAdapter } from '@kizunajs/next';
|
|
113
|
+
import { Articles } from './cms/collections/articles';
|
|
114
|
+
import { Users } from './cms/collections/users';
|
|
115
|
+
import { db } from './db';
|
|
116
|
+
|
|
117
|
+
export default defineConfig({
|
|
118
|
+
adapter: nextAdapter(),
|
|
119
|
+
name: 'My site',
|
|
120
|
+
typescript: {
|
|
121
|
+
outputFile: './cms/kizuna.types.ts',
|
|
122
|
+
},
|
|
123
|
+
db,
|
|
124
|
+
collections: [Articles, Users],
|
|
125
|
+
users: Users,
|
|
126
|
+
roles: ['editor'],
|
|
127
|
+
baseUrl: 'http://localhost:3000/api',
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
7. Serve the API and the admin from a `(cms)` route group. The admin brings its own root layout, so move your site's `app/layout.tsx` into a `(site)` group beside it.
|
|
132
|
+
|
|
133
|
+
`app/(cms)/layout.tsx`
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
export { AdminLayout as default } from '@kizunacms/next';
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`app/(cms)/api/[...kizuna]/route.ts`
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import kizuna from '@/kizuna.cms.config';
|
|
143
|
+
|
|
144
|
+
export const { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS } = kizuna.api.mount({
|
|
145
|
+
basePath: '/api',
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
`app/(cms)/admin/[[...path]]/page.tsx`
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import { createAdmin } from '@kizunacms/next';
|
|
153
|
+
import kizuna from '@/kizuna.cms.config';
|
|
154
|
+
|
|
155
|
+
const admin = createAdmin(kizuna, {
|
|
156
|
+
path: '/admin',
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
async function action(state: unknown, formData: FormData) {
|
|
160
|
+
'use server';
|
|
161
|
+
return admin.action(state, formData);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export default admin.page(action);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
8. Generate the types, then start.
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
pnpm kizuna generate --config kizuna.cms.config.ts
|
|
171
|
+
pnpm next dev
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Open `/admin` and create the first account. In development the CMS creates its tables as it starts.
|
|
175
|
+
|
|
176
|
+
## Going to production
|
|
177
|
+
|
|
178
|
+
A production start leaves the database as it is, and refuses to run until the database matches the config. Install the CLI:
|
|
179
|
+
|
|
180
|
+
```sh
|
|
181
|
+
pnpm add -D @kizunacms/cli
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
After changing the config, write a migration and commit it:
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
pnpm kizunacms migrate new add-summary
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Then run the migrations in your deploy step, before the app starts:
|
|
191
|
+
|
|
192
|
+
```sh
|
|
193
|
+
pnpm kizunacms migrate
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Packages
|
|
197
|
+
|
|
198
|
+
| Package | Description |
|
|
199
|
+
| ----------------------- | ------------------------------------------------- |
|
|
200
|
+
| `kizunacms` | The CMS |
|
|
201
|
+
| `@kizunacms/next` | The admin in a Next.js app |
|
|
202
|
+
| `@kizunacms/ui` | The admin's controls and screens |
|
|
203
|
+
| `@kizunacms/cli` | The `kizunacms` command: write and run migrations |
|
|
204
|
+
| `@kizunacms/storage-s3` | Keep images and files in S3 |
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT
|