refactor: merge standardConstants and standard in team plan#6549
refactor: merge standardConstants and standard in team plan#6549c121914yu merged 8 commits intolabring:mainfrom
Conversation
Preview sandbox Image: |
Preview mcp_server Image: |
Preview fastgpt Image: |
There was a problem hiding this comment.
Pull request overview
This PR refactors “team plan status” consumption across the app/service by replacing the standardConstants field with a unified standard plan object that represents effective limits (plan config defaults merged with DB overrides).
Changes:
- Introduces
TeamPlanStandardSchema/TeamPlanStandardTypeand updatesTeamPlanStatusSchemato expose[standard]as the merged plan object (removingstandardConstants). - Adds a
buildStandardPlanhelper to compute effective plan fields and updates service-level limit checks to usestandard.*fields. - Updates multiple API routes and UI components that read plan limits (upload counts/sizes, quotas) to use
teamPlanStatus.standard.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/app/src/pages/api/core/dataset/presignDatasetFilePostUrl.ts | Switches dataset upload presign limits to planStatus.standard.*. |
| projects/app/src/pages/api/core/dataset/data/insertImages.ts | Switches image insert upload frequency limits to planStatus.standard.*. |
| projects/app/src/pages/api/core/dataset/collection/create/images.ts | Switches collection image upload frequency limits to planStatus.standard.*. |
| projects/app/src/pages/api/core/chat/file/presignChatFilePostUrl.ts | Switches chat file presign limits to planStatus.standard.*. |
| projects/app/src/pages/api/common/file/presignTempFilePostUrl.ts | Switches temp file presign limits to planStatus.standard.*. |
| projects/app/src/pages/api/admin/support/appRegistration/create.ts | Reads app registration quota from teamPlanStatus.standard.*. |
| projects/app/src/pages/account/info/index.tsx | Updates plan/usage UI computations to reference teamPlanStatus.standard.*. |
| projects/app/src/pages/account/customDomain/index.tsx | Updates custom domain quota display to teamPlanStatus.standard.*. |
| projects/app/src/pageComponents/dataset/detail/Import/components/FileSelector.tsx | Updates dataset import file constraints to teamPlanStatus.standard.*. |
| projects/app/src/pageComponents/dashboard/TeamPlanStatusCard.tsx | Updates rendering guard from standardConstants to standard. |
| projects/app/src/pageComponents/app/detail/WorkflowComponents/Flow/nodes/NodePluginIO/InputTypeConfig.tsx | Updates node file selection constraints to teamPlanStatus.standard.*. |
| projects/app/src/components/Select/FileSelectorBox.tsx | Updates max size/count display/limits to teamPlanStatus.standard.*. |
| projects/app/src/components/core/chat/ChatContainer/ChatBox/hooks/useFileUpload.tsx | Updates chat upload constraints to teamPlanStatus.standard.*. |
| projects/app/src/components/core/app/FileSelector/index.tsx | Updates app file selector constraints to teamPlanStatus.standard.*. |
| projects/app/src/components/core/app/FileSelect.tsx | Updates app chat file selection constraints to teamPlanStatus.standard.*. |
| packages/service/support/wallet/sub/utils.ts | Adds merged-plan builder and changes plan status shape/derivations. |
| packages/service/support/permission/teamLimit.ts | Updates quota enforcement to use standard.* from new plan shape. |
| packages/global/support/wallet/sub/type.ts | Adds TeamPlanStandardSchema and updates plan status schema accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
测试内容:
|
PR Review: refactor: merge standardConstants and standard in team plan📊 变更概览
✅ 优点1. 代码质量提升
2. 可维护性改进
3. 一致性增强
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
74cb38a to
702e739
Compare
PR Review: refactor: merge standardConstants and standard in team plan📊 变更概览
✅ 优点
|
详细代码审查评论🔴 严重问题1. packages/service/support/wallet/sub/utils.ts:153-179问题: 当前代码: export const buildStandardPlan = (
standard: TeamSubSchemaType,
standardConstants: NonNullable<ReturnType<typeof getStandardPlanConfig>>
): TeamPlanStandardType => {问题分析:
建议修复: export const buildStandardPlan = (
standard: TeamSubSchemaType,
standardConstants: TeamStandardSubPlanItemType
): TeamPlanStandardType => {理由:
🟡 建议改进2. packages/global/support/wallet/sub/type.ts:32-43问题: Schema 合并使用了 spread 操作符,但缺少字段冲突的处理说明 当前代码: export const TeamPlanStandardSchema = z.object({
...TeamSubSchema.omit({
maxApp: true,
maxDataset: true
}).shape,
...TeamStandardSubPlanItemSchema.omit({
pointPrice: true
}).shape,
price: z.number().optional()
});建议: /**
* Merged plan type: combines DB subscription record metadata with effective plan limits
*
* Omits:
* - maxApp/maxDataset from TeamSubSchema: 这些字段在 DB 中存储,但在合并后的类型中使用 maxAppAmount/maxDatasetAmount
* - pointPrice from TeamStandardSubPlanItemSchema: 避免与 price 字段冲突
*
* Field priority: TeamStandardSubPlanItemSchema fields override TeamSubSchema fields when both exist
*/
export const TeamPlanStandardSchema = z.object({
...TeamSubSchema.omit({
maxApp: true,
maxDataset: true
}).shape,
...TeamStandardSubPlanItemSchema.omit({
pointPrice: true
}).shape,
price: z.number().optional()
});3. projects/app/src/components/support/wallet/StandardPlanContentList.tsx:404-407问题: 字段名映射不一致,增加理解成本 当前代码: maxAppAmount: standplan?.maxAppAmount ?? plan.maxAppAmount,
maxDatasetAmount: standplan?.maxDatasetAmount ?? plan.maxDatasetAmount,背景: 在 建议: 考虑在数据库层面统一字段命名,或者在类型定义中添加更清晰的注释说明这种映射关系。 替代方案: 如果无法修改数据库字段名,建议在 /**
* TeamSub Schema in DB.
* Configs are optional
*
* Note: maxApp maps to maxAppAmount in merged plan, maxDataset maps to maxDatasetAmount
*/4. packages/service/support/permission/teamLimit.ts建议: 使用可选链简化代码 当前代码: if (standard && newCount + memberCount > standard.maxTeamMember) {
return Promise.reject(TeamErrEnum.teamOverSize);
}建议优化: if (standard?.maxTeamMember && newCount + memberCount > standard.maxTeamMember) {
return Promise.reject(TeamErrEnum.teamOverSize);
}这样可以避免 🟢 可选优化5. test/cases/service/support/wallet/sub/utils.test.ts建议: 测试文件位置优化 当前位置: 建议位置: 理由:
6. packages/service/support/wallet/sub/utils.ts:216-233建议: 添加注释说明复杂的业务逻辑 当前代码: /** 配置里的套餐 */
const standardPlans = global.subPlans?.standard;
// ...
/** 数据库里的,用户目前 active 的套餐 */
const standardPlan = teamStandardPlans[0];
// ...
/** 静态的套餐配置,如果是 custom 则返回 advanced */
const standardConstants = ...优点: 已经添加了中文注释,这很好! 建议: 可以进一步补充说明为什么 custom 套餐要返回 advanced 配置: /**
* 静态的套餐配置
* 如果是 custom 套餐,返回 advanced 配置作为基础模板
* 因为 custom 套餐通常是在 advanced 基础上定制的
*/📋 测试覆盖分析测试文件 ✅ 已覆盖:
🎯 重构影响范围分析类型变更影响:
潜在风险:
建议:
|
No description provided.