@objectstack/nextjs 4.0.4 → 4.1.0

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/README.md CHANGED
@@ -1,13 +1,21 @@
1
1
  # @objectstack/nextjs
2
2
 
3
- The official Next.js adapter for ObjectStack.
3
+ > Next.js adapter for ObjectStack — App Router route handlers and server actions for the generated REST API.
4
4
 
5
- ## Features
6
- - Works with App Router (`app/api/...`)
7
- - Server Actions support (Planned)
8
- - Type-safe integration
5
+ [![npm](https://img.shields.io/npm/v/@objectstack/nextjs.svg)](https://www.npmjs.com/package/@objectstack/nextjs)
6
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
9
7
 
10
- ## Usage
8
+ ## Overview
9
+
10
+ Bridges Next.js App Router to `HttpDispatcher`. Provides one catch-all route handler that supports `/api/[...objectstack]`, a dedicated `/api/v1/discovery` handler, and typed server actions for CRUD and batch operations from React Server Components.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pnpm add @objectstack/nextjs next
16
+ ```
17
+
18
+ ## Quick Start
11
19
 
12
20
  ```typescript
13
21
  // app/api/[...objectstack]/route.ts
@@ -16,5 +24,62 @@ import { kernel } from '@/lib/kernel';
16
24
 
17
25
  const handler = createRouteHandler({ kernel });
18
26
 
19
- export { handler as GET, handler as POST };
27
+ export { handler as GET, handler as POST, handler as PUT, handler as PATCH, handler as DELETE };
28
+ ```
29
+
30
+ ```typescript
31
+ // app/api/v1/discovery/route.ts
32
+ import { createDiscoveryHandler } from '@objectstack/nextjs';
33
+ import { kernel } from '@/lib/kernel';
34
+
35
+ export const GET = createDiscoveryHandler({ kernel });
36
+ ```
37
+
38
+ ### Server actions
39
+
40
+ ```typescript
41
+ // app/actions.ts
42
+ 'use server';
43
+ import { createServerActions } from '@objectstack/nextjs';
44
+ import { kernel } from '@/lib/kernel';
45
+
46
+ export const { find, findOne, create, update, remove } = createServerActions({ kernel });
20
47
  ```
48
+
49
+ ## Key Exports
50
+
51
+ | Export | Kind | Description |
52
+ |:---|:---|:---|
53
+ | `createRouteHandler(options)` | function | Catch-all App Router handler. |
54
+ | `createDiscoveryHandler(options)` | function | `/api/v1/discovery` handler. |
55
+ | `createServerActions(options)` | function | Returns typed server actions. |
56
+ | `NextAdapterOptions` | interface | `{ kernel, prefix? }`. |
57
+ | `ServerActionResult<T>` | type | `{ success: boolean; data?: T; error?: string }` envelope. |
58
+
59
+ ## Edge vs Node
60
+
61
+ - Default runtime is Node.js. To use Edge, export `runtime = 'edge'` from the route file and pair with an edge-compatible driver ([`@objectstack/driver-turso`](../../plugins/driver-turso)).
62
+ - `HttpDispatcher` is isomorphic; the adapter emits `NextResponse` which works in both runtimes.
63
+
64
+ ## When to use
65
+
66
+ - ✅ Next.js App Router projects.
67
+ - ✅ React Server Components that need type-safe data mutations via server actions.
68
+
69
+ ## When not to use
70
+
71
+ - ❌ Pages Router projects — use [`@objectstack/express`](../express) with `next-connect` or migrate to App Router.
72
+
73
+ ## Related Packages
74
+
75
+ - [`@objectstack/client-react`](../../client-react) — client-side hooks.
76
+ - [`@objectstack/runtime`](../../runtime), [`@objectstack/rest`](../../rest).
77
+
78
+ ## Links
79
+
80
+ - 📖 Docs: <https://objectstack.ai/docs>
81
+ - 📚 API Reference: <https://objectstack.ai/docs/references>
82
+
83
+ ## License
84
+
85
+ Apache-2.0 © ObjectStack
package/package.json CHANGED
@@ -1,22 +1,48 @@
1
1
  {
2
2
  "name": "@objectstack/nextjs",
3
- "version": "4.0.4",
3
+ "version": "4.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "peerDependencies": {
8
- "next": "^16.2.3",
8
+ "next": "^16.2.4",
9
9
  "react": "^19.2.5",
10
10
  "react-dom": "^19.2.5",
11
- "@objectstack/runtime": "^4.0.4"
11
+ "@objectstack/runtime": "^4.1.0"
12
12
  },
13
13
  "devDependencies": {
14
- "next": "^16.2.3",
15
- "react": "^19.2.5",
16
- "react-dom": "^19.2.5",
17
- "typescript": "^6.0.2",
18
- "vitest": "^4.1.4",
19
- "@objectstack/runtime": "4.0.4"
14
+ "next": "^16.2.6",
15
+ "react": "^19.2.6",
16
+ "react-dom": "^19.2.6",
17
+ "typescript": "^6.0.3",
18
+ "vitest": "^4.1.7",
19
+ "@objectstack/runtime": "4.1.0"
20
+ },
21
+ "description": "Next.js adapter for ObjectStack — App Router route handlers for the ObjectStack REST API.",
22
+ "keywords": [
23
+ "objectstack",
24
+ "nextjs",
25
+ "adapter",
26
+ "app-router",
27
+ "rest"
28
+ ],
29
+ "author": "ObjectStack",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/objectstack-ai/framework.git",
33
+ "directory": "packages/adapters/nextjs"
34
+ },
35
+ "homepage": "https://objectstack.ai/docs",
36
+ "bugs": "https://github.com/objectstack-ai/framework/issues",
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "README.md"
43
+ ],
44
+ "engines": {
45
+ "node": ">=18.0.0"
20
46
  },
21
47
  "scripts": {
22
48
  "build": "tsup --config ../../../tsup.config.ts",
@@ -1,22 +0,0 @@
1
-
2
- > @objectstack/nextjs@4.0.4 build /home/runner/work/framework/framework/packages/adapters/nextjs
3
- > tsup --config ../../../tsup.config.ts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Using tsup config: /home/runner/work/framework/framework/tsup.config.ts
9
- CLI Target: es2020
10
- CLI Cleaning output folder
11
- ESM Build start
12
- CJS Build start
13
- ESM dist/index.mjs 7.73 KB
14
- ESM dist/index.mjs.map 16.92 KB
15
- ESM ⚡️ Build success in 68ms
16
- CJS dist/index.js 8.99 KB
17
- CJS dist/index.js.map 16.97 KB
18
- CJS ⚡️ Build success in 75ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 14090ms
21
- DTS dist/index.d.mts 2.63 KB
22
- DTS dist/index.d.ts 2.63 KB
package/CHANGELOG.md DELETED
@@ -1,377 +0,0 @@
1
- # @objectstack/nextjs
2
-
3
- ## 4.0.4
4
-
5
- ### Patch Changes
6
-
7
- - @objectstack/runtime@4.0.4
8
-
9
- ## 4.0.3
10
-
11
- ### Patch Changes
12
-
13
- - @objectstack/runtime@4.0.3
14
-
15
- ## 4.0.2
16
-
17
- ### Patch Changes
18
-
19
- - 5f659e9: fix ai
20
- - @objectstack/runtime@4.0.2
21
-
22
- ## 4.0.0
23
-
24
- ### Patch Changes
25
-
26
- - f08ffc3: Fix discovery API endpoint routing and protocol consistency.
27
-
28
- **Discovery route standardization:**
29
-
30
- - All adapters (Express, Fastify, Hono, NestJS, Next.js, Nuxt, SvelteKit) now mount the discovery endpoint at `{prefix}/discovery` instead of `{prefix}` root.
31
- - `.well-known/objectstack` redirects now point to `{prefix}/discovery`.
32
- - Client `connect()` fallback URL changed from `/api/v1` to `/api/v1/discovery`.
33
- - Runtime dispatcher handles both `/discovery` (standard) and `/` (legacy) for backward compatibility.
34
-
35
- **Schema & route alignment:**
36
-
37
- - Added `storage` (service: `file-storage`) and `feed` (service: `data`) routes to `DEFAULT_DISPATCHER_ROUTES`.
38
- - Added `feed` and `discovery` fields to `ApiRoutesSchema`.
39
- - Unified `GetDiscoveryResponseSchema` with `DiscoverySchema` as single source of truth.
40
- - Client `getRoute('feed')` fallback updated from `/api/v1/data` to `/api/v1/feed`.
41
-
42
- **Type safety:**
43
-
44
- - Extracted `ApiRouteType` from `ApiRoutes` keys for type-safe client route resolution.
45
- - Removed `as any` type casting in client route access.
46
-
47
- - Updated dependencies [f08ffc3]
48
- - Updated dependencies [e0b0a78]
49
- - @objectstack/runtime@4.0.0
50
-
51
- ## 3.3.1
52
-
53
- ### Patch Changes
54
-
55
- - @objectstack/runtime@3.3.1
56
-
57
- ## 3.3.0
58
-
59
- ### Patch Changes
60
-
61
- - @objectstack/runtime@3.3.0
62
-
63
- ## 3.2.9
64
-
65
- ### Patch Changes
66
-
67
- - @objectstack/runtime@3.2.9
68
-
69
- ## 3.2.8
70
-
71
- ### Patch Changes
72
-
73
- - @objectstack/runtime@3.2.8
74
-
75
- ## 3.2.8
76
-
77
- ### Patch Changes
78
-
79
- - fix: unified catch-all dispatch pattern — `createRouteHandler()` now delegates all non-framework-specific routes to `HttpDispatcher.dispatch()`, automatically supporting packages, analytics, automation, i18n, ui, openapi, custom endpoints, and any future routes
80
- - Only auth (service check), storage (formData), GraphQL (raw result), and discovery (response wrapper) remain as explicit routes
81
-
82
- ## 3.2.7
83
-
84
- ### Patch Changes
85
-
86
- - @objectstack/runtime@3.2.7
87
-
88
- ## 3.2.6
89
-
90
- ### Patch Changes
91
-
92
- - @objectstack/runtime@3.2.6
93
-
94
- ## 3.2.5
95
-
96
- ### Patch Changes
97
-
98
- - @objectstack/runtime@3.2.5
99
-
100
- ## 3.2.4
101
-
102
- ### Patch Changes
103
-
104
- - @objectstack/runtime@3.2.4
105
-
106
- ## 3.2.3
107
-
108
- ### Patch Changes
109
-
110
- - @objectstack/runtime@3.2.3
111
-
112
- ## 3.2.2
113
-
114
- ### Patch Changes
115
-
116
- - @objectstack/runtime@3.2.2
117
-
118
- ## 3.2.1
119
-
120
- ### Patch Changes
121
-
122
- - @objectstack/runtime@3.2.1
123
-
124
- ## 3.2.0
125
-
126
- ### Patch Changes
127
-
128
- - @objectstack/runtime@3.2.0
129
-
130
- ## 3.1.1
131
-
132
- ### Patch Changes
133
-
134
- - @objectstack/runtime@3.1.1
135
-
136
- ## 3.1.0
137
-
138
- ### Patch Changes
139
-
140
- - @objectstack/runtime@3.1.0
141
-
142
- ## 3.0.11
143
-
144
- ### Patch Changes
145
-
146
- - @objectstack/runtime@3.0.11
147
-
148
- ## 3.0.10
149
-
150
- ### Patch Changes
151
-
152
- - @objectstack/runtime@3.0.10
153
-
154
- ## 3.0.9
155
-
156
- ### Patch Changes
157
-
158
- - @objectstack/runtime@3.0.9
159
-
160
- ## 3.0.8
161
-
162
- ### Patch Changes
163
-
164
- - @objectstack/runtime@3.0.8
165
-
166
- ## 3.0.7
167
-
168
- ### Patch Changes
169
-
170
- - @objectstack/runtime@3.0.7
171
-
172
- ## 3.0.6
173
-
174
- ### Patch Changes
175
-
176
- - @objectstack/runtime@3.0.6
177
-
178
- ## 3.0.5
179
-
180
- ### Patch Changes
181
-
182
- - @objectstack/runtime@3.0.5
183
-
184
- ## 3.0.4
185
-
186
- ### Patch Changes
187
-
188
- - @objectstack/runtime@3.0.4
189
-
190
- ## 3.0.3
191
-
192
- ### Patch Changes
193
-
194
- - c7267f6: Patch release for maintenance updates and improvements.
195
- - Updated dependencies [c7267f6]
196
- - @objectstack/runtime@3.0.3
197
-
198
- ## 3.0.2
199
-
200
- ### Patch Changes
201
-
202
- - @objectstack/runtime@3.0.2
203
-
204
- ## 3.0.1
205
-
206
- ### Patch Changes
207
-
208
- - @objectstack/runtime@3.0.1
209
-
210
- ## 3.0.0
211
-
212
- ### Major Changes
213
-
214
- - Release v3.0.0 — unified version bump for all ObjectStack packages.
215
-
216
- ### Patch Changes
217
-
218
- - Updated dependencies
219
- - @objectstack/runtime@3.0.0
220
-
221
- ## 2.0.7
222
-
223
- ### Patch Changes
224
-
225
- - @objectstack/runtime@2.0.7
226
-
227
- ## 2.0.6
228
-
229
- ### Patch Changes
230
-
231
- - Patch release for maintenance and stability improvements
232
- - Updated dependencies
233
- - @objectstack/runtime@2.0.6
234
-
235
- ## 2.0.5
236
-
237
- ### Patch Changes
238
-
239
- - @objectstack/runtime@2.0.5
240
-
241
- ## 2.0.4
242
-
243
- ### Patch Changes
244
-
245
- - Patch release for maintenance and stability improvements
246
- - Updated dependencies
247
- - @objectstack/runtime@2.0.4
248
-
249
- ## 2.0.3
250
-
251
- ### Patch Changes
252
-
253
- - Patch release for maintenance and stability improvements
254
- - Updated dependencies
255
- - @objectstack/runtime@2.0.3
256
-
257
- ## 2.0.2
258
-
259
- ### Patch Changes
260
-
261
- - @objectstack/runtime@2.0.2
262
-
263
- ## 2.0.1
264
-
265
- ### Patch Changes
266
-
267
- - Patch release for maintenance and stability improvements
268
- - Updated dependencies
269
- - @objectstack/runtime@2.0.1
270
-
271
- ## 2.0.0
272
-
273
- ### Patch Changes
274
-
275
- - @objectstack/runtime@2.0.0
276
-
277
- ## 1.0.12
278
-
279
- ### Patch Changes
280
-
281
- - Updated dependencies
282
- - @objectstack/runtime@1.0.12
283
-
284
- ## 1.0.11
285
-
286
- ### Patch Changes
287
-
288
- - @objectstack/runtime@1.0.11
289
-
290
- ## 1.0.10
291
-
292
- ### Patch Changes
293
-
294
- - @objectstack/runtime@1.0.10
295
-
296
- ## 1.0.9
297
-
298
- ### Patch Changes
299
-
300
- - @objectstack/runtime@1.0.9
301
-
302
- ## 1.0.8
303
-
304
- ### Patch Changes
305
-
306
- - 8f2a3a2: fix: standardize discovery endpoint response to include 'data' wrapper
307
- - @objectstack/runtime@1.0.8
308
-
309
- ## 1.0.7
310
-
311
- ### Patch Changes
312
-
313
- - ebdf787: feat: implement standard service discovery via `/.well-known/objectstack`
314
- - Updated dependencies [ebdf787]
315
- - @objectstack/runtime@1.0.7
316
-
317
- ## 1.0.6
318
-
319
- ### Patch Changes
320
-
321
- - @objectstack/runtime@1.0.6
322
-
323
- ## 1.0.5
324
-
325
- ### Patch Changes
326
-
327
- - b1d24bd: refactor: migrate build system from tsc to tsup for faster builds
328
- - Replaced `tsc` with `tsup` (using esbuild) across all packages
329
- - Added shared `tsup.config.ts` in workspace root
330
- - Added `tsup` as workspace dev dependency
331
- - significantly improved build performance
332
- - Updated dependencies [b1d24bd]
333
- - Updated dependencies [877b864]
334
- - @objectstack/runtime@1.0.5
335
-
336
- ## 1.0.4
337
-
338
- ### Patch Changes
339
-
340
- - @objectstack/runtime@1.0.4
341
-
342
- ## 1.0.3
343
-
344
- ### Patch Changes
345
-
346
- - Updated dependencies [fb2eabd]
347
- - @objectstack/runtime@1.0.3
348
-
349
- ## 1.0.2
350
-
351
- ### Patch Changes
352
-
353
- - 109fc5b: Unified patch release to align all package versions.
354
- - Updated dependencies [a0a6c85]
355
- - Updated dependencies [109fc5b]
356
- - @objectstack/runtime@1.0.2
357
-
358
- ## 1.0.1
359
-
360
- ### Patch Changes
361
-
362
- - Updated dependencies
363
- - @objectstack/runtime@1.0.1
364
-
365
- ## 1.0.0
366
-
367
- ### Major Changes
368
-
369
- - Major version release for ObjectStack Protocol v1.0.
370
- - Stabilized Protocol Definitions
371
- - Enhanced Runtime Plugin Support
372
- - Fixed Type Compliance across Monorepo
373
-
374
- ### Patch Changes
375
-
376
- - Updated dependencies
377
- - @objectstack/runtime@1.0.0
@@ -1,4 +0,0 @@
1
- // Stub for @objectstack/runtime - replaced by vi.mock in tests
2
- export const HttpDispatcher = class {};
3
- export type ObjectKernel = any;
4
- export type HttpDispatcherResult = any;