@objectstack/runtime 1.0.10 → 1.0.12
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +315 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.js +315 -40
- package/dist/index.js.map +1 -1
- package/package.json +11 -4
- package/src/app-plugin.ts +29 -6
- package/src/http-dispatcher.root.test.ts +58 -0
- package/src/http-dispatcher.ts +322 -44
- package/src/rest-server.ts +45 -1
package/src/rest-server.ts
CHANGED
|
@@ -14,6 +14,7 @@ type NormalizedRestServerConfig = {
|
|
|
14
14
|
apiPath: string | undefined;
|
|
15
15
|
enableCrud: boolean;
|
|
16
16
|
enableMetadata: boolean;
|
|
17
|
+
enableUi: boolean;
|
|
17
18
|
enableBatch: boolean;
|
|
18
19
|
enableDiscovery: boolean;
|
|
19
20
|
documentation: RestApiConfig['documentation'];
|
|
@@ -120,6 +121,7 @@ export class RestServer {
|
|
|
120
121
|
apiPath: api.apiPath,
|
|
121
122
|
enableCrud: api.enableCrud ?? true,
|
|
122
123
|
enableMetadata: api.enableMetadata ?? true,
|
|
124
|
+
enableUi: api.enableUi ?? true,
|
|
123
125
|
enableBatch: api.enableBatch ?? true,
|
|
124
126
|
enableDiscovery: api.enableDiscovery ?? true,
|
|
125
127
|
documentation: api.documentation,
|
|
@@ -191,6 +193,11 @@ export class RestServer {
|
|
|
191
193
|
if (this.config.api.enableMetadata) {
|
|
192
194
|
this.registerMetadataEndpoints(basePath);
|
|
193
195
|
}
|
|
196
|
+
|
|
197
|
+
// UI endpoints
|
|
198
|
+
if (this.config.api.enableUi) {
|
|
199
|
+
this.registerUiEndpoints(basePath);
|
|
200
|
+
}
|
|
194
201
|
|
|
195
202
|
// CRUD endpoints
|
|
196
203
|
if (this.config.api.enableCrud) {
|
|
@@ -227,6 +234,10 @@ export class RestServer {
|
|
|
227
234
|
discovery.endpoints.metadata = `${basePath}${this.config.metadata.prefix}`;
|
|
228
235
|
}
|
|
229
236
|
|
|
237
|
+
if (this.config.api.enableUi) {
|
|
238
|
+
discovery.endpoints.ui = `${basePath}/ui`;
|
|
239
|
+
}
|
|
240
|
+
|
|
230
241
|
// Align auth endpoint with the versioned base path if present
|
|
231
242
|
if (discovery.endpoints.auth) {
|
|
232
243
|
discovery.endpoints.auth = `${basePath}/auth`;
|
|
@@ -279,7 +290,8 @@ export class RestServer {
|
|
|
279
290
|
path: `${metaPath}/:type`,
|
|
280
291
|
handler: async (req: any, res: any) => {
|
|
281
292
|
try {
|
|
282
|
-
const
|
|
293
|
+
const packageId = req.query?.package || undefined;
|
|
294
|
+
const items = await this.protocol.getMetaItems({ type: req.params.type, packageId });
|
|
283
295
|
res.json(items);
|
|
284
296
|
} catch (error: any) {
|
|
285
297
|
res.status(404).json({ error: error.message });
|
|
@@ -381,6 +393,38 @@ export class RestServer {
|
|
|
381
393
|
},
|
|
382
394
|
});
|
|
383
395
|
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Register UI endpoints
|
|
399
|
+
*/
|
|
400
|
+
private registerUiEndpoints(basePath: string): void {
|
|
401
|
+
const uiPath = `${basePath}/ui`;
|
|
402
|
+
|
|
403
|
+
// GET /ui/view/:object/:type - Resolve view for object
|
|
404
|
+
this.routeManager.register({
|
|
405
|
+
method: 'GET',
|
|
406
|
+
path: `${uiPath}/view/:object/:type`,
|
|
407
|
+
handler: async (req: any, res: any) => {
|
|
408
|
+
try {
|
|
409
|
+
if (this.protocol.getUiView) {
|
|
410
|
+
const view = await this.protocol.getUiView({
|
|
411
|
+
object: req.params.object,
|
|
412
|
+
type: req.params.type as any
|
|
413
|
+
});
|
|
414
|
+
res.json(view);
|
|
415
|
+
} else {
|
|
416
|
+
res.status(501).json({ error: 'UI View resolution not supported by protocol implementation' });
|
|
417
|
+
}
|
|
418
|
+
} catch (error: any) {
|
|
419
|
+
res.status(404).json({ error: error.message });
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
metadata: {
|
|
423
|
+
summary: 'Resolve UI View for object',
|
|
424
|
+
tags: ['ui'],
|
|
425
|
+
},
|
|
426
|
+
});
|
|
427
|
+
}
|
|
384
428
|
|
|
385
429
|
/**
|
|
386
430
|
* Register CRUD endpoints for data operations
|