Skip to content

Commit 5d862a2

Browse files
authored
Merge pull request #872 from objectstack-ai/copilot/fix-analytics-service-method-naming
2 parents dbefa99 + 3d0775e commit 5d862a2

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

ROADMAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ This strategy ensures rapid iteration while maintaining a clear path to producti
125125
| DashboardWidget discriminated union by type | 🔴 | Planned — chart/metric/pivot subtypes with type-specific required fields |
126126
| CI lint rule rejecting new `z.any()` | 🔴 | Planned — eslint or custom lint rule to block `z.any()` additions |
127127
| Dispatcher async `getService` bug fix || All `getService`/`getObjectQLService` calls in `http-dispatcher.ts` now properly `await` async service factories. Covers `handleAnalytics`, `handleAuth`, `handleStorage`, `handleAutomation`, `handleMetadata`, `handleUi`, `handlePackages`. All 7 framework adapters (Express, Fastify, Hono, Next.js, SvelteKit, NestJS, Nuxt) updated to use `getServiceAsync()` for auth service resolution. |
128+
| Analytics `getMetadata``getMeta` naming fix || `handleAnalytics` in `http-dispatcher.ts` called `getMetadata({ request })` which didn't match the `IAnalyticsService` contract (`getMeta(cubeName?: string)`). Renamed to `getMeta()` and aligned call signature. Updated test mocks accordingly. |
128129

129130
---
130131

packages/runtime/src/http-dispatcher.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ describe('HttpDispatcher', () => {
216216
it('should resolve analytics service from Promise (async factory)', async () => {
217217
const mockAnalytics = {
218218
query: vi.fn().mockResolvedValue({ rows: [{ id: 1 }], total: 1 }),
219-
getMetadata: vi.fn().mockResolvedValue({ tables: ['t1'] }),
219+
getMeta: vi.fn().mockResolvedValue({ tables: ['t1'] }),
220220
generateSql: vi.fn().mockResolvedValue({ sql: 'SELECT 1' }),
221221
};
222222
// Inject as Promise (simulates async factory registration)
@@ -245,7 +245,7 @@ describe('HttpDispatcher', () => {
245245

246246
it('should handle GET /analytics/meta with async service', async () => {
247247
const mockAnalytics = {
248-
getMetadata: vi.fn().mockResolvedValue({ tables: ['users', 'orders'] }),
248+
getMeta: vi.fn().mockResolvedValue({ tables: ['users', 'orders'] }),
249249
};
250250
(kernel as any).getService = vi.fn().mockResolvedValue(mockAnalytics);
251251

packages/runtime/src/http-dispatcher.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ export class HttpDispatcher {
526526
* Handles Analytics requests
527527
* path: sub-path after /analytics/
528528
*/
529-
async handleAnalytics(path: string, method: string, body: any, context: HttpProtocolContext): Promise<HttpDispatcherResult> {
529+
async handleAnalytics(path: string, method: string, body: any, _context: HttpProtocolContext): Promise<HttpDispatcherResult> {
530530
const analyticsService = await this.getService(CoreServiceName.enum.analytics);
531531
if (!analyticsService) return { handled: false }; // 404 handled by caller if unhandled
532532

@@ -535,20 +535,20 @@ export class HttpDispatcher {
535535

536536
// POST /analytics/query
537537
if (subPath === 'query' && m === 'POST') {
538-
const result = await analyticsService.query(body, { request: context.request });
538+
const result = await analyticsService.query(body);
539539
return { handled: true, response: this.success(result) };
540540
}
541541

542542
// GET /analytics/meta
543543
if (subPath === 'meta' && m === 'GET') {
544-
const result = await analyticsService.getMetadata({ request: context.request });
544+
const result = await analyticsService.getMeta();
545545
return { handled: true, response: this.success(result) };
546546
}
547547

548548
// POST /analytics/sql (Dry-run or debug)
549549
if (subPath === 'sql' && m === 'POST') {
550550
// Assuming service has generateSql method
551-
const result = await analyticsService.generateSql(body, { request: context.request });
551+
const result = await analyticsService.generateSql(body);
552552
return { handled: true, response: this.success(result) };
553553
}
554554

0 commit comments

Comments
 (0)