Skip to content

Commit 5dc89f4

Browse files
committed
feat: add UI endpoint configuration and schema support for REST server
1 parent 36a2c2a commit 5dc89f4

8 files changed

Lines changed: 73 additions & 0 deletions

File tree

packages/runtime/src/rest-server.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type NormalizedRestServerConfig = {
1414
apiPath: string | undefined;
1515
enableCrud: boolean;
1616
enableMetadata: boolean;
17+
enableUi: boolean;
1718
enableBatch: boolean;
1819
enableDiscovery: boolean;
1920
documentation: RestApiConfig['documentation'];
@@ -120,6 +121,7 @@ export class RestServer {
120121
apiPath: api.apiPath,
121122
enableCrud: api.enableCrud ?? true,
122123
enableMetadata: api.enableMetadata ?? true,
124+
enableUi: api.enableUi ?? true,
123125
enableBatch: api.enableBatch ?? true,
124126
enableDiscovery: api.enableDiscovery ?? true,
125127
documentation: api.documentation,
@@ -191,6 +193,11 @@ export class RestServer {
191193
if (this.config.api.enableMetadata) {
192194
this.registerMetadataEndpoints(basePath);
193195
}
196+
197+
// UI endpoints
198+
if (this.config.api.enableUi) {
199+
this.registerUiEndpoints(basePath);
200+
}
194201

195202
// CRUD endpoints
196203
if (this.config.api.enableCrud) {
@@ -227,6 +234,10 @@ export class RestServer {
227234
discovery.endpoints.metadata = `${basePath}${this.config.metadata.prefix}`;
228235
}
229236

237+
if (this.config.api.enableUi) {
238+
discovery.endpoints.ui = `${basePath}/ui`;
239+
}
240+
230241
// Align auth endpoint with the versioned base path if present
231242
if (discovery.endpoints.auth) {
232243
discovery.endpoints.auth = `${basePath}/auth`;
@@ -381,6 +392,38 @@ export class RestServer {
381392
},
382393
});
383394
}
395+
396+
/**
397+
* Register UI endpoints
398+
*/
399+
private registerUiEndpoints(basePath: string): void {
400+
const uiPath = `${basePath}/ui`;
401+
402+
// GET /ui/view/:object/:type - Resolve view for object
403+
this.routeManager.register({
404+
method: 'GET',
405+
path: `${uiPath}/view/:object/:type`,
406+
handler: async (req: any, res: any) => {
407+
try {
408+
if (this.protocol.getUiView) {
409+
const view = await this.protocol.getUiView({
410+
object: req.params.object,
411+
type: req.params.type as any
412+
});
413+
res.json(view);
414+
} else {
415+
res.status(501).json({ error: 'UI View resolution not supported by protocol implementation' });
416+
}
417+
} catch (error: any) {
418+
res.status(404).json({ error: error.message });
419+
}
420+
},
421+
metadata: {
422+
summary: 'Resolve UI View for object',
423+
tags: ['ui'],
424+
},
425+
});
426+
}
384427

385428
/**
386429
* Register CRUD endpoints for data operations

packages/spec/json-schema/api/ApiRoutes.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"type": "string",
1313
"description": "e.g. /api/meta"
1414
},
15+
"ui": {
16+
"type": "string",
17+
"description": "e.g. /api/ui"
18+
},
1519
"auth": {
1620
"type": "string",
1721
"description": "e.g. /api/auth"

packages/spec/json-schema/api/Discovery.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
"type": "string",
3030
"description": "e.g. /api/meta"
3131
},
32+
"ui": {
33+
"type": "string",
34+
"description": "e.g. /api/ui"
35+
},
3236
"auth": {
3337
"type": "string",
3438
"description": "e.g. /api/auth"

packages/spec/json-schema/api/GetDiscoveryResponse.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
"type": "string",
5757
"description": "e.g. /api/meta"
5858
},
59+
"ui": {
60+
"type": "string",
61+
"description": "e.g. /api/ui"
62+
},
5963
"auth": {
6064
"type": "string",
6165
"description": "e.g. /api/auth"

packages/spec/json-schema/api/RestApiConfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"default": true,
3030
"description": "Enable metadata API endpoints"
3131
},
32+
"enableUi": {
33+
"type": "boolean",
34+
"default": true,
35+
"description": "Enable UI API endpoints (Views, Menus, Layouts)"
36+
},
3237
"enableBatch": {
3338
"type": "boolean",
3439
"default": true,

packages/spec/json-schema/api/RestServerConfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"default": true,
3333
"description": "Enable metadata API endpoints"
3434
},
35+
"enableUi": {
36+
"type": "boolean",
37+
"default": true,
38+
"description": "Enable UI API endpoints (Views, Menus, Layouts)"
39+
},
3540
"enableBatch": {
3641
"type": "boolean",
3742
"default": true,

packages/spec/src/api/discovery.zod.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export const ApiRoutesSchema = z.object({
2424

2525
/** Base URL for Schema Definitions (Metadata Protocol) */
2626
metadata: z.string().describe('e.g. /api/meta'),
27+
28+
/** Base URL for UI Configurations (Views, Menus) */
29+
ui: z.string().optional().describe('e.g. /api/ui'),
2730

2831
/** Base URL for Authentication */
2932
auth: z.string().describe('e.g. /api/auth'),

packages/spec/src/api/rest-server.zod.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ export const RestApiConfigSchema = z.object({
6767
*/
6868
enableMetadata: z.boolean().default(true).describe('Enable metadata API endpoints'),
6969

70+
/**
71+
* Enable UI API endpoints
72+
*/
73+
enableUi: z.boolean().default(true).describe('Enable UI API endpoints (Views, Menus, Layouts)'),
74+
7075
/**
7176
* Enable batch operation endpoints
7277
*/

0 commit comments

Comments
 (0)