Skip to content

Fix DTS build: duplicate export and AnalyticsQuery type mismatch#632

Merged
hotlong merged 3 commits into
mainfrom
copilot/fix-build-and-test-again
Feb 12, 2026
Merged

Fix DTS build: duplicate export and AnalyticsQuery type mismatch#632
hotlong merged 3 commits into
mainfrom
copilot/fix-build-and-test-again

Conversation

Copilot AI commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

DTS build fails with TS2308 (duplicate AnalyticsQueryRequest export) and TS2416 (MemoryAnalyticsService.query incompatible with IAnalyticsService). Root cause: analytics.zod.ts and protocol.zod.ts both export AnalyticsQueryRequest, and the contracts AnalyticsQuery interface diverged from the Zod schema.

  • src/api/protocol.zod.ts — Remove export from 4 analytics type aliases that duplicate exports already in analytics.zod.ts. Kept as local types for IObjectStackProtocol interface usage.
  • src/contracts/analytics-service.ts — Align AnalyticsQuery with AnalyticsQuerySchema (Zod source of truth): cube → optional, measures → required.
  • packages/plugins/driver-memory/src/memory-analytics.ts — Add cube presence guard in query() and generateSql() now that the type reflects optionality.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel

vercel Bot commented Feb 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Feb 12, 2026 5:45am
spec Ready Ready Preview, Comment Feb 12, 2026 5:45am

Request Review

Copilot AI and others added 2 commits February 12, 2026 04:03
… AnalyticsQuery with Zod schema

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build and test issues Fix DTS build: duplicate export and AnalyticsQuery type mismatch Feb 12, 2026
Copilot AI requested a review from hotlong February 12, 2026 04:07
@hotlong
hotlong marked this pull request as ready for review February 12, 2026 04:15
Copilot AI review requested due to automatic review settings February 12, 2026 04:15
@hotlong
hotlong merged commit 492f992 into main Feb 12, 2026
3 of 5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes TypeScript build errors related to duplicate exports and type misalignment in the analytics module. The root cause was that both analytics.zod.ts and protocol.zod.ts exported the same type names, causing TS2308 errors, and the AnalyticsQuery contract interface diverged from its Zod schema source of truth.

Changes:

  • Removed duplicate export keywords from 4 analytics type aliases in protocol.zod.ts, converting them to non-exported types used only within that file's ObjectStackProtocol interface
  • Aligned the AnalyticsQuery contract interface with the Zod schema: made cube optional and measures required, with documentation explaining the 2-layer architecture pattern
  • Added runtime guards in MemoryAnalyticsService.query() and generateSql() to validate cube presence, since the type now reflects optionality

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/spec/src/api/protocol.zod.ts Changed 4 analytics type aliases from exported to non-exported (lines 1060-1063) to avoid duplicate exports with analytics.zod.ts
packages/spec/src/contracts/analytics-service.ts Made cube optional and measures required in AnalyticsQuery interface to align with AnalyticsQuerySchema Zod definition
packages/plugins/driver-memory/src/memory-analytics.ts Added cube presence validation in query() (lines 59-61) and generateSql() (lines 271-273) methods

Comment on lines +1060 to +1063
type AnalyticsQueryRequest = z.infer<typeof AnalyticsQueryRequestSchema>;
type AnalyticsResultResponse = z.infer<typeof AnalyticsResultResponseSchema>;
type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;
type GetAnalyticsMetaResponse = z.infer<typeof AnalyticsMetadataResponseSchema>;

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type AnalyticsResultResponse is referenced in the ObjectStackProtocol interface but is not exported from analytics.zod.ts, where the corresponding schema AnalyticsResultResponseSchema is defined.

Add the missing export to analytics.zod.ts:

export type AnalyticsResultResponse = z.infer<typeof AnalyticsResultResponseSchema>;

This export should be added alongside the other analytics type exports (after line 84 in analytics.zod.ts) to maintain consistency and allow external code to import this type when needed.

Suggested change
type AnalyticsQueryRequest = z.infer<typeof AnalyticsQueryRequestSchema>;
type AnalyticsResultResponse = z.infer<typeof AnalyticsResultResponseSchema>;
type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;
type GetAnalyticsMetaResponse = z.infer<typeof AnalyticsMetadataResponseSchema>;
export type AnalyticsQueryRequest = z.infer<typeof AnalyticsQueryRequestSchema>;
export type AnalyticsResultResponse = z.infer<typeof AnalyticsResultResponseSchema>;
export type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;
export type GetAnalyticsMetaResponse = z.infer<typeof AnalyticsMetadataResponseSchema>;

Copilot uses AI. Check for mistakes.
export type GetAnalyticsMetaResponse = z.infer<typeof AnalyticsMetadataResponseSchema>;
type AnalyticsQueryRequest = z.infer<typeof AnalyticsQueryRequestSchema>;
type AnalyticsResultResponse = z.infer<typeof AnalyticsResultResponseSchema>;
type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type GetAnalyticsMetaRequest is referenced in the ObjectStackProtocol interface but is not exported from analytics.zod.ts, where the corresponding schema GetAnalyticsMetaRequestSchema is defined.

Add the missing export to analytics.zod.ts:

export type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;

This export should be added alongside the other analytics type exports to allow external code to import this type when needed.

Suggested change
type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;
export type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;

Copilot uses AI. Check for mistakes.
type AnalyticsQueryRequest = z.infer<typeof AnalyticsQueryRequestSchema>;
type AnalyticsResultResponse = z.infer<typeof AnalyticsResultResponseSchema>;
type GetAnalyticsMetaRequest = z.infer<typeof GetAnalyticsMetaRequestSchema>;
type GetAnalyticsMetaResponse = z.infer<typeof AnalyticsMetadataResponseSchema>;

Copilot AI Feb 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a naming inconsistency: the schema is AnalyticsMetadataResponseSchema and the exported type in analytics.zod.ts is AnalyticsMetadataResponse, but here you're using the name GetAnalyticsMetaResponse.

For consistency, either:

  1. Use AnalyticsMetadataResponse (the already-exported name from analytics.zod.ts), OR
  2. Add an export for GetAnalyticsMetaResponse as an alias in analytics.zod.ts

Option 1 is recommended to match the existing export pattern in analytics.zod.ts line 85.

Suggested change
type GetAnalyticsMetaResponse = z.infer<typeof AnalyticsMetadataResponseSchema>;
type AnalyticsMetadataResponse = z.infer<typeof AnalyticsMetadataResponseSchema>;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants