Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis set of changes introduces a comprehensive refactor and extension of the configuration schema, validation, and normalization logic across the backend and shared packages. It includes stricter schema enforcement, improved type safety, new migration and sanitization utilities, expanded TypeScript type helpers, and enhanced schema introspection. Several new utility modules and functions are added for currency and date handling, and documentation is updated to clarify the config system. Minor adjustments and cleanups are made in various backend scripts and handlers to align with the new config logic. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Route
participant Config_Lib
participant Schema_Utils
Client->>API_Route: PATCH /internal/email-templates/[templateId]
API_Route->>Config_Lib: overrideEnvironmentConfigOverride({ tsxSource, themeId? })
Config_Lib->>Schema_Utils: sanitizeEnvironmentConfig
Schema_Utils-->>Config_Lib: Sanitized config
Config_Lib-->>API_Route: Save override if valid
API_Route-->>Client: Response
sequenceDiagram
participant Backend
participant Config_Lib
participant Schema_Utils
Backend->>Config_Lib: validateEnvironmentConfigOverride(override)
Config_Lib->>Schema_Utils: getConfigOverrideErrors
Schema_Utils-->>Config_Lib: Result<null, string>
Config_Lib-->>Backend: Validation result
Estimated code review effort🎯 5 (Critical) | ⏱️ ~90+ minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Greptile Summary
This PR implements a comprehensive refactor of Stack Auth's configuration management system. The changes introduce several key improvements:
Configuration System Overhaul: The core configuration system has been completely refactored with enhanced validation, migration support, and sanitization. The new system provides better error categorization (FORMAT ERROR, ERROR, WARNING) and includes comprehensive test coverage. Configuration rendering now includes normalization and sanitization steps, with migration support for backwards compatibility.
Type Safety Improvements: Significant enhancements to TypeScript utility types have been added, including better handling of union/intersection types, object manipulation utilities, and more precise type assertions. The configuration schemas now use more sophisticated typing with OptionalKeys and RequiredKeys to distinguish between required and optional fields.
Domain Storage Refactor: The trusted domains configuration has been changed from an array structure to a Map-like object structure where each domain gets a unique UUID as a key. This improves indexing, lookup performance, and follows the codebase pattern for dynamic key configurations.
Enhanced Schema Infrastructure: New schema introspection capabilities have been added through hasNested and enhanced getNested methods, along with a metadata system (stackSchemaInfo) that tracks schema types for better validation and error reporting.
Payment System Foundation: New currency handling utilities and money amount schemas have been introduced, suggesting preparation for billing/subscription features with Stripe integration.
Bug Fixes: Several critical issues were addressed, including a security vulnerability in the development key override logic and proper indentation fixes in the database seed script for GitHub OAuth account creation.
Developer Experience: Various improvements including file watching for migration imports, better error messages with deindent formatting, and more consistent import organization across the codebase.
These changes represent a significant architectural improvement that maintains the same public API while substantially enhancing the internal implementation for better reliability, type safety, and maintainability.
Confidence score: 3/5
• This PR introduces substantial architectural changes that require careful testing, particularly around the configuration validation and migration systems.
• The score reflects concerns about the complexity of the new configuration system, potential runtime issues with the date interval mutations, and incomplete currency handling implementation.
• Files needing attention: packages/stack-shared/src/utils/dates.tsx (mutation issues), packages/stack-shared/src/utils/currencies.tsx (incomplete implementation), and apps/backend/src/lib/config.tsx (complex validation logic).
21 files reviewed, 9 comments
Important
This PR enhances project config with advanced TypeScript utilities, improved validation, and support for currency conversions, while fixing bugs and refactoring for better schema enforcement.
This description was created by
for 68ea382. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation
Chores