@airdraft/next 0.1.2 → 0.1.4
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/CHANGELOG.md +19 -0
- package/README.md +79 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.4](https://github.com/aevrHQ/airdraft/compare/next@v0.1.3...next@v0.1.4) (2026-05-23)
|
|
6
|
+
|
|
7
|
+
### [0.1.3](https://github.com/aevrHQ/airdraft/compare/next@v0.1.1...next@v0.1.3) (2026-05-23)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add `story` field type with schema definition and UI support; include media file for demo ([f5d3f88](https://github.com/aevrHQ/airdraft/commit/f5d3f884afda98e613c50ce1a0ebb3c591a84511))
|
|
13
|
+
* enhance media field handling in renderTypes function to include metadata support ([b80245c](https://github.com/aevrHQ/airdraft/commit/b80245caf91e2a436172e875fff89c83a56b5ff3))
|
|
14
|
+
* enhance MIME type handling in FilesSdkMediaAdapter and withMedia plugin ([186d33f](https://github.com/aevrHQ/airdraft/commit/186d33f33d31431c579a821eaa1a7a5ea13be4e7))
|
|
15
|
+
* implement `blocks` field type with schema definition, validation, and UI support ([a3d57d1](https://github.com/aevrHQ/airdraft/commit/a3d57d11d82f38871fe044641bbb5a98cda3cb75))
|
|
16
|
+
* **react-content:** add support for media lists and urls ([2cb0891](https://github.com/aevrHQ/airdraft/commit/2cb089102b0530217f305c782435138592f7754d))
|
|
17
|
+
* **types:** add asCollectionConfig function for casting schema objects ([f5bcaaf](https://github.com/aevrHQ/airdraft/commit/f5bcaafa42fb43d749c89dfe7e7b075adcd18474))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Code Refactoring
|
|
21
|
+
|
|
22
|
+
* code structure for improved readability and maintainability ([410de76](https://github.com/aevrHQ/airdraft/commit/410de761725340ea8edbb50b7de122797b58d942))
|
|
23
|
+
|
|
5
24
|
### [0.1.1](https://github.com/aevrHQ/airdraft/compare/next@v0.1.0...next@v0.1.1) (2026-05-23)
|
|
6
25
|
|
|
7
26
|
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @airdraft/next
|
|
2
|
+
|
|
3
|
+
Next.js adapter for Airdraft. Provides the API route handler, server-side helpers, middleware, and revalidation utilities.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @airdraft/next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### API Route Handler
|
|
14
|
+
|
|
15
|
+
Create `app/api/cms/[...path]/route.ts`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createHandler } from '@airdraft/next'
|
|
19
|
+
import config from '../../../../airdraft.config'
|
|
20
|
+
|
|
21
|
+
const { GET, POST, PUT, DELETE, PATCH } = createHandler(config)
|
|
22
|
+
export { GET, POST, PUT, DELETE, PATCH }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`createHandler` automatically wraps all routes with audit logging when a plugin with `onAuditEvent` is registered.
|
|
26
|
+
|
|
27
|
+
### Server Client
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { getServerClient } from '@airdraft/next'
|
|
31
|
+
import config from '../airdraft.config'
|
|
32
|
+
|
|
33
|
+
const client = getServerClient(config)
|
|
34
|
+
const entries = await client.entries.list('posts')
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Middleware
|
|
38
|
+
|
|
39
|
+
Protect CMS routes in `middleware.ts`:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createCmsMiddleware } from '@airdraft/next'
|
|
43
|
+
import config from './airdraft.config'
|
|
44
|
+
|
|
45
|
+
export const middleware = createCmsMiddleware(config)
|
|
46
|
+
export const config = { matcher: ['/cms/:path*'] }
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Revalidation
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { revalidateEntry } from '@airdraft/next'
|
|
53
|
+
|
|
54
|
+
// Call after publishing an entry to trigger ISR
|
|
55
|
+
await revalidateEntry({ collection: 'posts', slug: 'hello-world' })
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Exports
|
|
59
|
+
|
|
60
|
+
| Export | Description |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `createHandler(config)` | Returns `{ GET, POST, PUT, DELETE, PATCH }` Next.js route handlers. |
|
|
63
|
+
| `getServerClient(config)` | Returns an `AirdraftClient` authenticated with the server API key. |
|
|
64
|
+
| `createCmsMiddleware(config)` | Next.js middleware that enforces authentication on CMS routes. |
|
|
65
|
+
| `revalidateEntry(options)` | Triggers Next.js ISR revalidation for an entry path. |
|
|
66
|
+
| `createTokenProvider()` | Token provider for client-side auth flows. |
|
|
67
|
+
|
|
68
|
+
## Audit Logging
|
|
69
|
+
|
|
70
|
+
When any plugin registers an `onAuditEvent` hook, `createHandler` wraps every route with `auditWrap`. Each request produces an `AuditEvent` that includes:
|
|
71
|
+
|
|
72
|
+
- `action`, `method`, `path`, `statusCode`, `durationMs`
|
|
73
|
+
- `collection`, `slug` (when applicable)
|
|
74
|
+
- `actor` — the raw API key / bearer token
|
|
75
|
+
- `error.message`, `error.code`, `error.details` — per-field validation failures are included in `details` for `VALIDATION_ERROR` responses
|
|
76
|
+
|
|
77
|
+
## Changelog
|
|
78
|
+
|
|
79
|
+
See [CHANGELOG.md](./CHANGELOG.md).
|