@objectstack/nextjs 4.0.3 → 4.0.5

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.3",
3
+ "version": "4.0.5",
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.3"
11
+ "@objectstack/runtime": "^4.0.5"
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.3"
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.5",
19
+ "@objectstack/runtime": "4.0.5"
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.3 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
- CJS dist/index.js 8.99 KB
14
- CJS dist/index.js.map 16.97 KB
15
- CJS ⚡️ Build success in 70ms
16
- ESM dist/index.mjs 7.73 KB
17
- ESM dist/index.mjs.map 16.92 KB
18
- ESM ⚡️ Build success in 70ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 9961ms
21
- DTS dist/index.d.mts 2.63 KB
22
- DTS dist/index.d.ts 2.63 KB
package/CHANGELOG.md DELETED
@@ -1,371 +0,0 @@
1
- # @objectstack/nextjs
2
-
3
- ## 4.0.3
4
-
5
- ### Patch Changes
6
-
7
- - @objectstack/runtime@4.0.3
8
-
9
- ## 4.0.2
10
-
11
- ### Patch Changes
12
-
13
- - 5f659e9: fix ai
14
- - @objectstack/runtime@4.0.2
15
-
16
- ## 4.0.0
17
-
18
- ### Patch Changes
19
-
20
- - f08ffc3: Fix discovery API endpoint routing and protocol consistency.
21
-
22
- **Discovery route standardization:**
23
-
24
- - All adapters (Express, Fastify, Hono, NestJS, Next.js, Nuxt, SvelteKit) now mount the discovery endpoint at `{prefix}/discovery` instead of `{prefix}` root.
25
- - `.well-known/objectstack` redirects now point to `{prefix}/discovery`.
26
- - Client `connect()` fallback URL changed from `/api/v1` to `/api/v1/discovery`.
27
- - Runtime dispatcher handles both `/discovery` (standard) and `/` (legacy) for backward compatibility.
28
-
29
- **Schema & route alignment:**
30
-
31
- - Added `storage` (service: `file-storage`) and `feed` (service: `data`) routes to `DEFAULT_DISPATCHER_ROUTES`.
32
- - Added `feed` and `discovery` fields to `ApiRoutesSchema`.
33
- - Unified `GetDiscoveryResponseSchema` with `DiscoverySchema` as single source of truth.
34
- - Client `getRoute('feed')` fallback updated from `/api/v1/data` to `/api/v1/feed`.
35
-
36
- **Type safety:**
37
-
38
- - Extracted `ApiRouteType` from `ApiRoutes` keys for type-safe client route resolution.
39
- - Removed `as any` type casting in client route access.
40
-
41
- - Updated dependencies [f08ffc3]
42
- - Updated dependencies [e0b0a78]
43
- - @objectstack/runtime@4.0.0
44
-
45
- ## 3.3.1
46
-
47
- ### Patch Changes
48
-
49
- - @objectstack/runtime@3.3.1
50
-
51
- ## 3.3.0
52
-
53
- ### Patch Changes
54
-
55
- - @objectstack/runtime@3.3.0
56
-
57
- ## 3.2.9
58
-
59
- ### Patch Changes
60
-
61
- - @objectstack/runtime@3.2.9
62
-
63
- ## 3.2.8
64
-
65
- ### Patch Changes
66
-
67
- - @objectstack/runtime@3.2.8
68
-
69
- ## 3.2.8
70
-
71
- ### Patch Changes
72
-
73
- - 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
74
- - Only auth (service check), storage (formData), GraphQL (raw result), and discovery (response wrapper) remain as explicit routes
75
-
76
- ## 3.2.7
77
-
78
- ### Patch Changes
79
-
80
- - @objectstack/runtime@3.2.7
81
-
82
- ## 3.2.6
83
-
84
- ### Patch Changes
85
-
86
- - @objectstack/runtime@3.2.6
87
-
88
- ## 3.2.5
89
-
90
- ### Patch Changes
91
-
92
- - @objectstack/runtime@3.2.5
93
-
94
- ## 3.2.4
95
-
96
- ### Patch Changes
97
-
98
- - @objectstack/runtime@3.2.4
99
-
100
- ## 3.2.3
101
-
102
- ### Patch Changes
103
-
104
- - @objectstack/runtime@3.2.3
105
-
106
- ## 3.2.2
107
-
108
- ### Patch Changes
109
-
110
- - @objectstack/runtime@3.2.2
111
-
112
- ## 3.2.1
113
-
114
- ### Patch Changes
115
-
116
- - @objectstack/runtime@3.2.1
117
-
118
- ## 3.2.0
119
-
120
- ### Patch Changes
121
-
122
- - @objectstack/runtime@3.2.0
123
-
124
- ## 3.1.1
125
-
126
- ### Patch Changes
127
-
128
- - @objectstack/runtime@3.1.1
129
-
130
- ## 3.1.0
131
-
132
- ### Patch Changes
133
-
134
- - @objectstack/runtime@3.1.0
135
-
136
- ## 3.0.11
137
-
138
- ### Patch Changes
139
-
140
- - @objectstack/runtime@3.0.11
141
-
142
- ## 3.0.10
143
-
144
- ### Patch Changes
145
-
146
- - @objectstack/runtime@3.0.10
147
-
148
- ## 3.0.9
149
-
150
- ### Patch Changes
151
-
152
- - @objectstack/runtime@3.0.9
153
-
154
- ## 3.0.8
155
-
156
- ### Patch Changes
157
-
158
- - @objectstack/runtime@3.0.8
159
-
160
- ## 3.0.7
161
-
162
- ### Patch Changes
163
-
164
- - @objectstack/runtime@3.0.7
165
-
166
- ## 3.0.6
167
-
168
- ### Patch Changes
169
-
170
- - @objectstack/runtime@3.0.6
171
-
172
- ## 3.0.5
173
-
174
- ### Patch Changes
175
-
176
- - @objectstack/runtime@3.0.5
177
-
178
- ## 3.0.4
179
-
180
- ### Patch Changes
181
-
182
- - @objectstack/runtime@3.0.4
183
-
184
- ## 3.0.3
185
-
186
- ### Patch Changes
187
-
188
- - c7267f6: Patch release for maintenance updates and improvements.
189
- - Updated dependencies [c7267f6]
190
- - @objectstack/runtime@3.0.3
191
-
192
- ## 3.0.2
193
-
194
- ### Patch Changes
195
-
196
- - @objectstack/runtime@3.0.2
197
-
198
- ## 3.0.1
199
-
200
- ### Patch Changes
201
-
202
- - @objectstack/runtime@3.0.1
203
-
204
- ## 3.0.0
205
-
206
- ### Major Changes
207
-
208
- - Release v3.0.0 — unified version bump for all ObjectStack packages.
209
-
210
- ### Patch Changes
211
-
212
- - Updated dependencies
213
- - @objectstack/runtime@3.0.0
214
-
215
- ## 2.0.7
216
-
217
- ### Patch Changes
218
-
219
- - @objectstack/runtime@2.0.7
220
-
221
- ## 2.0.6
222
-
223
- ### Patch Changes
224
-
225
- - Patch release for maintenance and stability improvements
226
- - Updated dependencies
227
- - @objectstack/runtime@2.0.6
228
-
229
- ## 2.0.5
230
-
231
- ### Patch Changes
232
-
233
- - @objectstack/runtime@2.0.5
234
-
235
- ## 2.0.4
236
-
237
- ### Patch Changes
238
-
239
- - Patch release for maintenance and stability improvements
240
- - Updated dependencies
241
- - @objectstack/runtime@2.0.4
242
-
243
- ## 2.0.3
244
-
245
- ### Patch Changes
246
-
247
- - Patch release for maintenance and stability improvements
248
- - Updated dependencies
249
- - @objectstack/runtime@2.0.3
250
-
251
- ## 2.0.2
252
-
253
- ### Patch Changes
254
-
255
- - @objectstack/runtime@2.0.2
256
-
257
- ## 2.0.1
258
-
259
- ### Patch Changes
260
-
261
- - Patch release for maintenance and stability improvements
262
- - Updated dependencies
263
- - @objectstack/runtime@2.0.1
264
-
265
- ## 2.0.0
266
-
267
- ### Patch Changes
268
-
269
- - @objectstack/runtime@2.0.0
270
-
271
- ## 1.0.12
272
-
273
- ### Patch Changes
274
-
275
- - Updated dependencies
276
- - @objectstack/runtime@1.0.12
277
-
278
- ## 1.0.11
279
-
280
- ### Patch Changes
281
-
282
- - @objectstack/runtime@1.0.11
283
-
284
- ## 1.0.10
285
-
286
- ### Patch Changes
287
-
288
- - @objectstack/runtime@1.0.10
289
-
290
- ## 1.0.9
291
-
292
- ### Patch Changes
293
-
294
- - @objectstack/runtime@1.0.9
295
-
296
- ## 1.0.8
297
-
298
- ### Patch Changes
299
-
300
- - 8f2a3a2: fix: standardize discovery endpoint response to include 'data' wrapper
301
- - @objectstack/runtime@1.0.8
302
-
303
- ## 1.0.7
304
-
305
- ### Patch Changes
306
-
307
- - ebdf787: feat: implement standard service discovery via `/.well-known/objectstack`
308
- - Updated dependencies [ebdf787]
309
- - @objectstack/runtime@1.0.7
310
-
311
- ## 1.0.6
312
-
313
- ### Patch Changes
314
-
315
- - @objectstack/runtime@1.0.6
316
-
317
- ## 1.0.5
318
-
319
- ### Patch Changes
320
-
321
- - b1d24bd: refactor: migrate build system from tsc to tsup for faster builds
322
- - Replaced `tsc` with `tsup` (using esbuild) across all packages
323
- - Added shared `tsup.config.ts` in workspace root
324
- - Added `tsup` as workspace dev dependency
325
- - significantly improved build performance
326
- - Updated dependencies [b1d24bd]
327
- - Updated dependencies [877b864]
328
- - @objectstack/runtime@1.0.5
329
-
330
- ## 1.0.4
331
-
332
- ### Patch Changes
333
-
334
- - @objectstack/runtime@1.0.4
335
-
336
- ## 1.0.3
337
-
338
- ### Patch Changes
339
-
340
- - Updated dependencies [fb2eabd]
341
- - @objectstack/runtime@1.0.3
342
-
343
- ## 1.0.2
344
-
345
- ### Patch Changes
346
-
347
- - 109fc5b: Unified patch release to align all package versions.
348
- - Updated dependencies [a0a6c85]
349
- - Updated dependencies [109fc5b]
350
- - @objectstack/runtime@1.0.2
351
-
352
- ## 1.0.1
353
-
354
- ### Patch Changes
355
-
356
- - Updated dependencies
357
- - @objectstack/runtime@1.0.1
358
-
359
- ## 1.0.0
360
-
361
- ### Major Changes
362
-
363
- - Major version release for ObjectStack Protocol v1.0.
364
- - Stabilized Protocol Definitions
365
- - Enhanced Runtime Plugin Support
366
- - Fixed Type Compliance across Monorepo
367
-
368
- ### Patch Changes
369
-
370
- - Updated dependencies
371
- - @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;