Skip to content

refactor: Convert WebSearchSource enum to const object with Zod schema#12866

Merged
kangfenmao merged 1 commit intomainfrom
refactor/web-search-source
Feb 12, 2026
Merged

refactor: Convert WebSearchSource enum to const object with Zod schema#12866
kangfenmao merged 1 commit intomainfrom
refactor/web-search-source

Conversation

@EurFelux
Copy link
Copy Markdown
Collaborator

What this PR does

Before this PR:
WebSearchSource was defined as a TypeScript enum.

After this PR:
WebSearchSource is converted to an as const object (WEB_SEARCH_SOURCE) with a Zod schema (WebSearchSourceSchema) and a derived type (WebSearchSource).

Part of #12846 — split out as a separate PR to reduce the number of files to review in the final refactor PR.

Why we need it and why it was done in this way

This aligns WebSearchSource with the project's existing convention of using as const objects instead of enums (e.g., EFFORT_RATIO, FILE_TYPE). The Zod schema integration also enables runtime validation.

The following tradeoffs were made:

  • The value object is renamed to WEB_SEARCH_SOURCE (UPPER_SNAKE_CASE) to follow the const object convention, while the type name WebSearchSource is preserved for backward compatibility.

The following alternatives were considered:

  • Keeping the enum — rejected because it diverges from the project's established pattern.

Breaking changes

None. All runtime string values remain identical. This is a purely internal refactor.

Special notes for your reviewer

  • This is a mechanical rename across 16 files with no behavioral changes.
  • pnpm build:check passes (lint + 3026 tests + typecheck).
  • One pre-existing commented-out line in AiSdkToChunkAdapter.ts:35 still references the old WebSearchSource name — can be cleaned up separately.

Checklist

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Documentation: Not required (internal refactor only)

Release note

NONE

@kangfenmao kangfenmao merged commit 40317cd into main Feb 12, 2026
3 checks passed
@kangfenmao kangfenmao deleted the refactor/web-search-source branch February 12, 2026 16:25
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.

2 participants