@objectstack/rest 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/rest",
3
- "version": "4.0.4",
3
+ "version": "4.1.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "ObjectStack REST API Server - automatic REST endpoint generation from protocol",
6
6
  "type": "module",
@@ -14,13 +14,39 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "zod": "^4.3.6",
18
- "@objectstack/core": "4.0.4",
19
- "@objectstack/spec": "4.0.4"
17
+ "zod": "^4.4.3",
18
+ "@objectstack/core": "4.1.0",
19
+ "@objectstack/service-package": "4.1.0",
20
+ "@objectstack/spec": "4.1.0"
20
21
  },
21
22
  "devDependencies": {
22
- "typescript": "^6.0.2",
23
- "vitest": "^4.1.4"
23
+ "typescript": "^6.0.3",
24
+ "vitest": "^4.1.7"
25
+ },
26
+ "keywords": [
27
+ "objectstack",
28
+ "rest",
29
+ "api",
30
+ "crud",
31
+ "openapi"
32
+ ],
33
+ "author": "ObjectStack",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/objectstack-ai/framework.git",
37
+ "directory": "packages/rest"
38
+ },
39
+ "homepage": "https://objectstack.ai/docs",
40
+ "bugs": "https://github.com/objectstack-ai/framework/issues",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "files": [
45
+ "dist",
46
+ "README.md"
47
+ ],
48
+ "engines": {
49
+ "node": ">=18.0.0"
24
50
  },
25
51
  "scripts": {
26
52
  "build": "tsup --config ../../tsup.config.ts",
@@ -1,22 +0,0 @@
1
-
2
- > @objectstack/rest@4.0.4 build /home/runner/work/framework/framework/packages/rest
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.cjs 22.27 KB
14
- CJS dist/index.cjs.map 51.54 KB
15
- CJS ⚡️ Build success in 143ms
16
- ESM dist/index.js 21.14 KB
17
- ESM dist/index.js.map 51.03 KB
18
- ESM ⚡️ Build success in 178ms
19
- DTS Build start
20
- DTS ⚡️ Build success in 12998ms
21
- DTS dist/index.d.ts 6.42 KB
22
- DTS dist/index.d.cts 6.42 KB
package/CHANGELOG.md DELETED
@@ -1,481 +0,0 @@
1
- # @objectstack/rest
2
-
3
- ## 4.0.4
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [326b66b]
8
- - @objectstack/spec@4.0.4
9
- - @objectstack/core@4.0.4
10
-
11
- ## 4.0.3
12
-
13
- ### Patch Changes
14
-
15
- - @objectstack/spec@4.0.3
16
- - @objectstack/core@4.0.3
17
-
18
- ## 4.0.2
19
-
20
- ### Patch Changes
21
-
22
- - Updated dependencies [5f659e9]
23
- - @objectstack/spec@4.0.2
24
- - @objectstack/core@4.0.2
25
-
26
- ## 4.0.0
27
-
28
- ### Patch Changes
29
-
30
- - Updated dependencies [f08ffc3]
31
- - Updated dependencies [e0b0a78]
32
- - @objectstack/spec@4.0.0
33
- - @objectstack/core@4.0.0
34
-
35
- ## 3.3.1
36
-
37
- ### Patch Changes
38
-
39
- - @objectstack/spec@3.3.1
40
- - @objectstack/core@3.3.1
41
-
42
- ## 3.3.0
43
-
44
- ### Patch Changes
45
-
46
- - @objectstack/spec@3.3.0
47
- - @objectstack/core@3.3.0
48
-
49
- ## 3.2.9
50
-
51
- ### Patch Changes
52
-
53
- - @objectstack/spec@3.2.9
54
- - @objectstack/core@3.2.9
55
-
56
- ## 3.2.8
57
-
58
- ### Patch Changes
59
-
60
- - @objectstack/spec@3.2.8
61
- - @objectstack/core@3.2.8
62
-
63
- ## 3.2.7
64
-
65
- ### Patch Changes
66
-
67
- - @objectstack/spec@3.2.7
68
- - @objectstack/core@3.2.7
69
-
70
- ## 3.2.6
71
-
72
- ### Patch Changes
73
-
74
- - @objectstack/spec@3.2.6
75
- - @objectstack/core@3.2.6
76
-
77
- ## 3.2.5
78
-
79
- ### Patch Changes
80
-
81
- - @objectstack/spec@3.2.5
82
- - @objectstack/core@3.2.5
83
-
84
- ## 3.2.4
85
-
86
- ### Patch Changes
87
-
88
- - @objectstack/spec@3.2.4
89
- - @objectstack/core@3.2.4
90
-
91
- ## 3.2.3
92
-
93
- ### Patch Changes
94
-
95
- - @objectstack/spec@3.2.3
96
- - @objectstack/core@3.2.3
97
-
98
- ## 3.2.2
99
-
100
- ### Patch Changes
101
-
102
- - Updated dependencies [46defbb]
103
- - @objectstack/spec@3.2.2
104
- - @objectstack/core@3.2.2
105
-
106
- ## 3.2.1
107
-
108
- ### Patch Changes
109
-
110
- - Updated dependencies [850b546]
111
- - @objectstack/spec@3.2.1
112
- - @objectstack/core@3.2.1
113
-
114
- ## 3.2.0
115
-
116
- ### Patch Changes
117
-
118
- - Updated dependencies [5901c29]
119
- - @objectstack/spec@3.2.0
120
- - @objectstack/core@3.2.0
121
-
122
- ## 3.1.1
123
-
124
- ### Patch Changes
125
-
126
- - Updated dependencies [953d667]
127
- - @objectstack/spec@3.1.1
128
- - @objectstack/core@3.1.1
129
-
130
- ## 3.1.0
131
-
132
- ### Patch Changes
133
-
134
- - Updated dependencies [0088830]
135
- - @objectstack/spec@3.1.0
136
- - @objectstack/core@3.1.0
137
-
138
- ## 3.0.11
139
-
140
- ### Patch Changes
141
-
142
- - Updated dependencies [92d9d99]
143
- - @objectstack/spec@3.0.11
144
- - @objectstack/core@3.0.11
145
-
146
- ## 3.0.10
147
-
148
- ### Patch Changes
149
-
150
- - Updated dependencies [d1e5d31]
151
- - @objectstack/spec@3.0.10
152
- - @objectstack/core@3.0.10
153
-
154
- ## 3.0.9
155
-
156
- ### Patch Changes
157
-
158
- - Updated dependencies [15e0df6]
159
- - @objectstack/spec@3.0.9
160
- - @objectstack/core@3.0.9
161
-
162
- ## 3.0.8
163
-
164
- ### Patch Changes
165
-
166
- - Updated dependencies [5a968a2]
167
- - @objectstack/spec@3.0.8
168
- - @objectstack/core@3.0.8
169
-
170
- ## 3.0.7
171
-
172
- ### Patch Changes
173
-
174
- - Updated dependencies [0119bd7]
175
- - Updated dependencies [5426bdf]
176
- - @objectstack/spec@3.0.7
177
- - @objectstack/core@3.0.7
178
-
179
- ## 3.0.6
180
-
181
- ### Patch Changes
182
-
183
- - Updated dependencies [5df254c]
184
- - @objectstack/spec@3.0.6
185
- - @objectstack/core@3.0.6
186
-
187
- ## 3.0.5
188
-
189
- ### Patch Changes
190
-
191
- - Updated dependencies [23a4a68]
192
- - @objectstack/spec@3.0.5
193
- - @objectstack/core@3.0.5
194
-
195
- ## 3.0.4
196
-
197
- ### Patch Changes
198
-
199
- - Updated dependencies [d738987]
200
- - @objectstack/spec@3.0.4
201
- - @objectstack/core@3.0.4
202
-
203
- ## 3.0.3
204
-
205
- ### Patch Changes
206
-
207
- - c7267f6: Patch release for maintenance updates and improvements.
208
- - Updated dependencies [c7267f6]
209
- - @objectstack/spec@3.0.3
210
- - @objectstack/core@3.0.3
211
-
212
- ## 3.0.2
213
-
214
- ### Patch Changes
215
-
216
- - Updated dependencies [28985f5]
217
- - @objectstack/spec@3.0.2
218
- - @objectstack/core@3.0.2
219
-
220
- ## 3.0.1
221
-
222
- ### Patch Changes
223
-
224
- - Updated dependencies [389725a]
225
- - @objectstack/spec@3.0.1
226
- - @objectstack/core@3.0.1
227
-
228
- ## 3.0.0
229
-
230
- ### Major Changes
231
-
232
- - Release v3.0.0 — unified version bump for all ObjectStack packages.
233
-
234
- ### Patch Changes
235
-
236
- - Updated dependencies
237
- - @objectstack/spec@3.0.0
238
- - @objectstack/core@3.0.0
239
-
240
- ## 2.0.7
241
-
242
- ### Patch Changes
243
-
244
- - Updated dependencies
245
- - @objectstack/spec@2.0.7
246
- - @objectstack/core@2.0.7
247
-
248
- ## 2.0.6
249
-
250
- ### Patch Changes
251
-
252
- - Patch release for maintenance and stability improvements
253
- - Updated dependencies
254
- - @objectstack/spec@2.0.6
255
- - @objectstack/core@2.0.6
256
-
257
- ## 2.0.5
258
-
259
- ### Patch Changes
260
-
261
- - Updated dependencies
262
- - @objectstack/spec@2.0.5
263
- - @objectstack/core@2.0.5
264
-
265
- ## 2.0.4
266
-
267
- ### Patch Changes
268
-
269
- - Patch release for maintenance and stability improvements
270
- - Updated dependencies
271
- - @objectstack/spec@2.0.4
272
- - @objectstack/core@2.0.4
273
-
274
- ## 2.0.3
275
-
276
- ### Patch Changes
277
-
278
- - Patch release for maintenance and stability improvements
279
- - Updated dependencies
280
- - @objectstack/spec@2.0.3
281
- - @objectstack/core@2.0.3
282
-
283
- ## 2.0.2
284
-
285
- ### Patch Changes
286
-
287
- - Updated dependencies [1db8559]
288
- - @objectstack/spec@2.0.2
289
- - @objectstack/core@2.0.2
290
-
291
- ## 2.0.1
292
-
293
- ### Patch Changes
294
-
295
- - Patch release for maintenance and stability improvements
296
- - Updated dependencies
297
- - @objectstack/spec@2.0.1
298
- - @objectstack/core@2.0.1
299
-
300
- ## 2.0.0
301
-
302
- ### Patch Changes
303
-
304
- - Updated dependencies [38e5dd5]
305
- - Updated dependencies [38e5dd5]
306
- - @objectstack/spec@2.0.0
307
- - @objectstack/core@2.0.0
308
-
309
- ## 1.1.1
310
-
311
- ### Patch Changes
312
-
313
- - Updated dependencies
314
- - @objectstack/spec@2.0.0
315
- - @objectstack/core@2.0.0
316
-
317
- ## 1.1.1
318
-
319
- ### Patch Changes
320
-
321
- - Updated dependencies
322
- - @objectstack/spec@2.0.0
323
- - @objectstack/core@2.0.0
324
-
325
- ## 1.1.1
326
-
327
- ### Patch Changes
328
-
329
- - Updated dependencies
330
- - @objectstack/spec@2.0.0
331
- - @objectstack/core@2.0.0
332
-
333
- ## 2.0.0
334
-
335
- ### Patch Changes
336
-
337
- - Updated dependencies
338
- - @objectstack/spec@2.0.0
339
- - @objectstack/core@2.0.0
340
-
341
- ## 1.1.1
342
-
343
- ### Patch Changes
344
-
345
- - Updated dependencies
346
- - @objectstack/spec@1.1.1
347
- - @objectstack/core@1.1.1
348
-
349
- ## 1.1.1
350
-
351
- ### Patch Changes
352
-
353
- - Updated dependencies
354
- - @objectstack/spec@2.0.0
355
- - @objectstack/core@2.0.0
356
-
357
- ## 1.2.0
358
-
359
- ### Minor Changes
360
-
361
- - ## New Features
362
-
363
- - **@objectstack/rest** (new package): Extracted REST server, route management, and `createRestApiPlugin` into a dedicated package
364
- - **@objectstack/runtime**: Add `createDispatcherPlugin` for structured route management (auth, graphql, analytics, packages, hub, storage, automation)
365
- - **@objectstack/cli**: Dev mode (`--dev`) now auto-enables Studio UI at `/_studio/` — no need for `--ui` flag; use `--no-ui` to disable
366
- - **@objectstack/cli**: Root URL `/` redirects to `/_studio/` in dev mode for convenience
367
- - **@objectstack/cli**: Removed Vite dev server fallback — always serves pre-built dist, no extra port
368
- - **@objectstack/studio**: Interactive API Console in Object Explorer (request builder, response viewer, history)
369
- - **@objectstack/spec**: Studio Plugin schema, MCP Protocol schemas, API versioning, Dispatcher protocol
370
- - **@objectstack/spec**: Comprehensive `.describe()` annotations across all Zod schemas
371
- - **@objectstack/core**: Production hot reload and dynamic plugin loading protocol
372
-
373
- ## Migration Guide (from 1.1.0)
374
-
375
- ### RuntimeConfig.api removed
376
-
377
- ```ts
378
- // Before (1.1.0) — implicit
379
- const runtime = new Runtime({ api: { basePath: "/api/v1" } });
380
-
381
- // After (1.2.0) — explicit
382
- import { createRestApiPlugin } from "@objectstack/rest";
383
- const runtime = new Runtime();
384
- runtime.use(createRestApiPlugin({ basePath: "/api/v1" }));
385
- ```
386
-
387
- ### z.any() → z.unknown() (~30 fields)
388
-
389
- Fields like `metadata`, `defaultValue`, `filters`, `config`, `data` now use `z.unknown()`. Add type narrowing where needed.
390
-
391
- ### Hub schemas relocated
392
-
393
- Barrel imports via `Hub.*` still work. Direct path imports (`hub/license.zod.ts` → `system/license.zod.ts`) need updating.
394
-
395
- ### MetricType renamed
396
-
397
- `MetricType` (analytics) → `AggregationMetricType`, `MetricType` (licensing) → `LicenseMetricType`
398
-
399
- ### Deprecations
400
-
401
- - `HttpDispatcher` → `createDispatcherPlugin()`
402
- - `createHonoApp` → `HonoServerPlugin`
403
-
404
- ### Patch Changes
405
-
406
- - Updated dependencies
407
- - @objectstack/spec@2.0.0
408
- - @objectstack/core@2.0.0
409
-
410
- ## 1.2.0
411
-
412
- ### Minor Changes
413
-
414
- - ## New Features
415
-
416
- - **@objectstack/rest** (new package): Extracted REST server, route management, and `createRestApiPlugin` into a dedicated package
417
- - **@objectstack/runtime**: Add `createDispatcherPlugin` for structured route management (auth, graphql, analytics, packages, hub, storage, automation)
418
- - **@objectstack/cli**: Dev mode (`--dev`) now auto-enables Studio UI at `/_studio/` — no need for `--ui` flag; use `--no-ui` to disable
419
- - **@objectstack/cli**: Root URL `/` redirects to `/_studio/` in dev mode for convenience
420
- - **@objectstack/cli**: Removed Vite dev server fallback — always serves pre-built dist, no extra port
421
- - **@objectstack/studio**: Interactive API Console in Object Explorer (request builder, response viewer, history)
422
- - **@objectstack/spec**: Studio Plugin schema (`Studio.PluginManifest`)
423
- - **@objectstack/spec**: MCP (Model Context Protocol) schemas for AI tools, resources, prompts, transport
424
- - **@objectstack/spec**: API versioning schema with multiple strategies
425
- - **@objectstack/spec**: Dispatcher protocol schema
426
- - **@objectstack/spec**: Comprehensive `.describe()` annotations across all Zod schemas for JSON Schema generation
427
- - **@objectstack/core**: Production hot reload and dynamic plugin loading protocol
428
-
429
- ## Migration Guide (from 1.1.0)
430
-
431
- ### RuntimeConfig.api removed
432
-
433
- REST API is now opt-in. If you relied on automatic REST registration:
434
-
435
- ```ts
436
- // Before (1.1.0) — implicit
437
- const runtime = new Runtime({ api: { basePath: "/api/v1" } });
438
-
439
- // After (1.2.0) — explicit
440
- import { createRestApiPlugin } from "@objectstack/rest";
441
- const runtime = new Runtime();
442
- runtime.use(createRestApiPlugin({ basePath: "/api/v1" }));
443
- ```
444
-
445
- ### z.any() → z.unknown() (~30 fields)
446
-
447
- Fields like `metadata`, `defaultValue`, `filters`, `config`, `data` in spec schemas changed from `z.any()` to `z.unknown()`. If you consume inferred types, add type narrowing:
448
-
449
- ```ts
450
- // Before — worked silently
451
- const val: string = record.metadata.foo;
452
-
453
- // After — requires narrowing
454
- const meta = record.metadata as Record<string, string>;
455
- const val = meta.foo;
456
- ```
457
-
458
- ### Hub schemas relocated
459
-
460
- - `hub/composer.zod.ts`, `hub/marketplace.zod.ts`, `hub/space.zod.ts`, `hub/hub-federation.zod.ts` — removed
461
- - `hub/plugin-registry.zod.ts` → `kernel/plugin-registry.zod.ts`
462
- - `hub/license.zod.ts` → `system/license.zod.ts`
463
- - `hub/tenant.zod.ts` → `system/tenant.zod.ts`
464
-
465
- Barrel imports via `Hub.*` namespace still work. Direct path imports need updating.
466
-
467
- ### MetricType renamed
468
-
469
- - `MetricType` (data analytics) → `AggregationMetricType`
470
- - `MetricType` (hub licensing) → `LicenseMetricType`
471
-
472
- ### Deprecations
473
-
474
- - `HttpDispatcher` → use `createDispatcherPlugin()` instead
475
- - `createHonoApp` → use `HonoServerPlugin` instead
476
-
477
- ### Patch Changes
478
-
479
- - Updated dependencies
480
- - @objectstack/spec@2.0.0
481
- - @objectstack/core@2.0.0
package/src/index.ts DELETED
@@ -1,12 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- // REST Server
4
- export { RestServer } from './rest-server.js';
5
-
6
- // Route Management
7
- export { RouteManager, RouteGroupBuilder } from './route-manager.js';
8
- export type { RouteEntry } from './route-manager.js';
9
-
10
- // REST API Plugin
11
- export { createRestApiPlugin } from './rest-api-plugin.js';
12
- export type { RestApiPluginConfig } from './rest-api-plugin.js';
@@ -1,72 +0,0 @@
1
- // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2
-
3
- import { Plugin, PluginContext, IHttpServer } from '@objectstack/core';
4
- import { RestServer } from './rest-server.js';
5
- import { ObjectStackProtocol, RestServerConfig } from '@objectstack/spec/api';
6
-
7
- export interface RestApiPluginConfig {
8
- serverServiceName?: string;
9
- protocolServiceName?: string;
10
- api?: RestServerConfig;
11
- }
12
-
13
- /**
14
- * REST API Plugin
15
- *
16
- * Responsibilities:
17
- * 1. Consumes 'http.server' (or configured service)
18
- * 2. Consumes 'protocol' (ObjectStackProtocol)
19
- * 3. Instantiates RestServer to auto-generate routes
20
- */
21
- export function createRestApiPlugin(config: RestApiPluginConfig = {}): Plugin {
22
- return {
23
- name: 'com.objectstack.rest.api',
24
- version: '1.0.0',
25
-
26
- init: async (_ctx: PluginContext) => {
27
- // No service registration, this is a consumer plugin
28
- },
29
-
30
- start: async (ctx: PluginContext) => {
31
- const serverService = config.serverServiceName || 'http.server';
32
- const protocolService = config.protocolServiceName || 'protocol';
33
-
34
- let server: IHttpServer | undefined;
35
- let protocol: ObjectStackProtocol | undefined;
36
-
37
- try {
38
- server = ctx.getService<IHttpServer>(serverService);
39
- } catch (e) {
40
- // Ignore missing service
41
- }
42
-
43
- try {
44
- protocol = ctx.getService<ObjectStackProtocol>(protocolService);
45
- } catch (e) {
46
- // Ignore missing service
47
- }
48
-
49
- if (!server) {
50
- ctx.logger.warn(`RestApiPlugin: HTTP Server service '${serverService}' not found. REST routes skipped.`);
51
- return;
52
- }
53
-
54
- if (!protocol) {
55
- ctx.logger.warn(`RestApiPlugin: Protocol service '${protocolService}' not found. REST routes skipped.`);
56
- return;
57
- }
58
-
59
- ctx.logger.info('Hydrating REST API from Protocol...');
60
-
61
- try {
62
- const restServer = new RestServer(server, protocol, config.api as any);
63
- restServer.registerRoutes();
64
-
65
- ctx.logger.info('REST API successfully registered');
66
- } catch (err: any) {
67
- ctx.logger.error('Failed to register REST API routes', { error: err.message } as any);
68
- throw err;
69
- }
70
- }
71
- };
72
- }