Repository navigation
feat: add well-known capabilities to API discovery #779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,3 +319,51 @@ describe('ObjectStack Protocol', () => { | |
| }); | ||
|
|
||
| }); | ||
|
|
||
| // ========================================== | ||
| // GetDiscoveryResponseSchema — capabilities | ||
| // ========================================== | ||
| import { GetDiscoveryResponseSchema } from './protocol.zod'; | ||
|
|
||
|
Comment on lines
+326
to
+327
|
||
| describe('GetDiscoveryResponseSchema (capabilities)', () => { | ||
| it('should accept response with well-known capabilities', () => { | ||
| const result = GetDiscoveryResponseSchema.safeParse({ | ||
| version: 'v1', | ||
| apiName: 'ObjectStack API', | ||
| capabilities: { | ||
| feed: true, | ||
| comments: true, | ||
| automation: false, | ||
| cron: false, | ||
| search: true, | ||
| export: false, | ||
| chunkedUpload: true, | ||
| }, | ||
| }); | ||
| expect(result.success).toBe(true); | ||
| if (result.success) { | ||
| expect(result.data.capabilities?.feed).toBe(true); | ||
| expect(result.data.capabilities?.automation).toBe(false); | ||
| } | ||
| }); | ||
|
|
||
| it('should accept response without capabilities (optional)', () => { | ||
| const result = GetDiscoveryResponseSchema.safeParse({ | ||
| version: 'v1', | ||
| apiName: 'ObjectStack API', | ||
| }); | ||
| expect(result.success).toBe(true); | ||
| if (result.success) { | ||
| expect(result.data.capabilities).toBeUndefined(); | ||
| } | ||
| }); | ||
|
|
||
| it('should reject capabilities with missing fields', () => { | ||
| const result = GetDiscoveryResponseSchema.safeParse({ | ||
| version: 'v1', | ||
| apiName: 'ObjectStack API', | ||
| capabilities: { feed: true }, | ||
| }); | ||
| expect(result.success).toBe(false); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| import { z } from 'zod'; | ||
| import { ViewSchema } from '../ui/view.zod'; | ||
| import { ApiRoutesSchema, ServiceInfoSchema } from './discovery.zod'; | ||
| import { ApiRoutesSchema, ServiceInfoSchema, WellKnownCapabilitiesSchema } from './discovery.zod'; | ||
| import { BatchUpdateRequestSchema, BatchUpdateResponseSchema, BatchOptionsSchema } from './batch.zod'; | ||
| import { MetadataCacheRequestSchema, MetadataCacheResponseSchema } from './http-cache.zod'; | ||
| import { QuerySchema } from '../data/query.zod'; | ||
|
|
@@ -129,6 +129,7 @@ export const GetDiscoveryResponseSchema = z.object({ | |
| apiName: z.string().describe('API name'), | ||
| routes: ApiRoutesSchema.optional().describe('Available endpoint paths'), | ||
| services: z.record(z.string(), ServiceInfoSchema).optional().describe('Per-service availability map'), | ||
| capabilities: WellKnownCapabilitiesSchema.optional().describe('Well-known capability flags for frontend adaptation'), | ||
|
||
| }); | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new tests validate the top-level
ObjectStackClient.capabilitiesgetter, but they’re nested underdescribe('ObjectStackClient.automation', ...), which makes the suite misleading and harder to find. Consider moving them into a dedicateddescribe('ObjectStackClient.capabilities', ...)block.