refactor: extract constants, parameterize validators, simplify factory #7

Merged
jleibl merged 1 commits from refactor/quick-wins-factory-validators-constants into main 2026-05-21 11:36:34 +00:00
Owner

Quick-win refactors from the Refactoring Guru catalog:

  • Replace Magic Number with Symbolic Constant: extract DEFAULT_TIMEOUT_MS,
    DEFAULT_MAX_RETRIES, DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE, default
    models per provider, and validation prompt into src/constants.ts.
  • Parameterize Method: collapse validateTemperature / validateTopP /
    validateMaxTokens (and the inline timeout/maxRetries checks) into a
    single validateNumberInRange helper with bounds metadata.
  • Inline Class / Remove Middle Man: drop the unused ProviderRegistry
    class from utils/factory.ts. createProvider now dispatches through
    the PROVIDER_REGISTRY const directly instead of a parallel switch.

Also fixes stale VERSION constant in src/index.ts (was 1.3.1).

Quick-win refactors from the Refactoring Guru catalog: - Replace Magic Number with Symbolic Constant: extract DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE, default models per provider, and validation prompt into src/constants.ts. - Parameterize Method: collapse validateTemperature / validateTopP / validateMaxTokens (and the inline timeout/maxRetries checks) into a single validateNumberInRange helper with bounds metadata. - Inline Class / Remove Middle Man: drop the unused ProviderRegistry class from utils/factory.ts. createProvider now dispatches through the PROVIDER_REGISTRY const directly instead of a parallel switch. Also fixes stale VERSION constant in src/index.ts (was 1.3.1).
jleibl added 1 commit 2026-05-21 11:36:26 +00:00
Quick-win refactors from the Refactoring Guru catalog:

- Replace Magic Number with Symbolic Constant: extract DEFAULT_TIMEOUT_MS,
  DEFAULT_MAX_RETRIES, DEFAULT_MAX_TOKENS, DEFAULT_TEMPERATURE, default
  models per provider, and validation prompt into src/constants.ts.
- Parameterize Method: collapse validateTemperature / validateTopP /
  validateMaxTokens (and the inline timeout/maxRetries checks) into a
  single validateNumberInRange helper with bounds metadata.
- Inline Class / Remove Middle Man: drop the unused ProviderRegistry
  class from utils/factory.ts. createProvider now dispatches through
  the PROVIDER_REGISTRY const directly instead of a parallel switch.

Also fixes stale VERSION constant in src/index.ts (was 1.3.1).
jleibl merged commit 8e73296ac2 into main 2026-05-21 11:36:34 +00:00
jleibl deleted branch refactor/quick-wins-factory-validators-constants 2026-05-21 11:36:37 +00:00
jleibl referenced this issue from a commit 2026-05-21 11:54:34 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jleibl/simple-ai-provider#7