feat(api-gateway): add support for onlyViews parameter in meta endpoint#10809
feat(api-gateway): add support for onlyViews parameter in meta endpoint#10809vasilev-alex merged 3 commits intomasterfrom
Conversation
|
Claude finished @vasilev-alex's task in 2m 18s —— View job Code Review:
|
| } | ||
| const cubesConfig = metaConfig.cubes; | ||
| const cubesConfig = onlyViews | ||
| ? metaConfig.cubes.filter((c: any) => c.config?.type === 'view') |
There was a problem hiding this comment.
Nit: The (c: any) cast bypasses type safety. If metaConfig.cubes has a typed element interface, consider using it here. Same applies to the identical filter in metaExtended below (line 712).
That said, this is consistent with other patterns in this file (e.g., the response: { cubes: any[], ... } declarations), so this is low priority.
| await this.metaExtended({ | ||
| context: req.context, | ||
| res: this.resToResultFn(res), | ||
| onlyViews: 'onlyViews' in req.query, |
There was a problem hiding this comment.
Worth noting: since onlyViews is presence-based ('onlyViews' in req.query), a request like ?onlyViews=false will still activate filtering — which may confuse users. This is consistent with how extended works (line 438), so it's a preexisting pattern, but it might be worth documenting in the API reference that the parameter is a flag (presence-only, value is ignored).
| test('meta endpoint extended with onlyViews returns only views', async () => { | ||
| const { app } = await createApiGateway(); | ||
|
|
||
| const res = await request(app) | ||
| .get('/cubejs-api/v1/meta?extended&onlyViews') | ||
| .set('Authorization', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M') | ||
| .expect(200); | ||
|
|
||
| expect(res.body).toHaveProperty('cubes'); | ||
| expect(res.body.cubes).toHaveLength(1); | ||
| expect(res.body.cubes[0].name).toBe('FooView'); | ||
| }); |
There was a problem hiding this comment.
Consider adding an assertion that no cubes are present in the response:
| test('meta endpoint extended with onlyViews returns only views', async () => { | |
| const { app } = await createApiGateway(); | |
| const res = await request(app) | |
| .get('/cubejs-api/v1/meta?extended&onlyViews') | |
| .set('Authorization', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M') | |
| .expect(200); | |
| expect(res.body).toHaveProperty('cubes'); | |
| expect(res.body.cubes).toHaveLength(1); | |
| expect(res.body.cubes[0].name).toBe('FooView'); | |
| }); | |
| test('meta endpoint extended with onlyViews returns only views', async () => { | |
| const { app } = await createApiGateway(); | |
| const res = await request(app) | |
| .get('/cubejs-api/v1/meta?extended&onlyViews') | |
| .set('Authorization', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8x4iTMCda8Yhe3iZaWbvV5XKSTbuAn0M') | |
| .expect(200); | |
| expect(res.body).toHaveProperty('cubes'); | |
| expect(res.body.cubes).toHaveLength(1); | |
| expect(res.body.cubes[0].name).toBe('FooView'); | |
| expect(res.body.cubes.every(c => c.name !== 'Foo')).toBe(true); | |
| }); |
This makes it explicit that cubes (non-views) are excluded, not just that views are present.
| curl \ | ||
| -H "Authorization: TOKEN" \ | ||
| -G \ | ||
| http://localhost:4000/cubejs-api/v1/meta?onlyViews | ||
| ``` |
There was a problem hiding this comment.
Minor: the -G flag tells curl to append --data-urlencode params as query string, but here the query param is already embedded in the URL directly. The -G flag is harmless but redundant in this case. This matches the existing example above though, so it's consistent.
Codecov Report✅ All modified and coverable lines are covered by tests.
Additional details and impacted files@@ Coverage Diff @@
## master #10809 +/- ##
===========================================
- Coverage 83.36% 58.14% -25.22%
===========================================
Files 254 216 -38
Lines 75354 16884 -58470
Branches 0 3424 +3424
===========================================
- Hits 62818 9818 -53000
+ Misses 12536 6563 -5973
- Partials 0 503 +503
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Check List