Files
dukang/.cursor/rules/packages-shared.mdc
T
2026-07-01 15:04:53 +08:00

37 lines
1.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: 杜康好客共享包(shared-types / domain / shared-ui)规范
globs: packages/**/*.{ts,tsx}
alwaysApply: false
---
# 共享包规范
## 包职责
| 包 | 用途 | 约束 |
|----|------|------|
| `@dukang/shared-types` | DTO、枚举、错误码、JWT Payload | 前后端唯一契约 |
| `@dukang/domain` | 纯函数业务规则 | **禁止 IO**,含 Vitest 单测 |
| `@dukang/shared-ui` | H5 共享组件 + `tokens.css` | 仅 H5 三端使用 |
## shared-types
- 枚举用 `SCREAMING_SNAKE_CASE`(如 `OrderStatus.PENDING_PAY`
- API Tab 查询用 snake_case`pending_pay`
- **加法优先**:新字段 optional;删除/改名先 deprecated
- 改 API 必须同步 V2 手册 §六 与 shared-types
## domain
纯规则示例(无数据库/HTTP):
```typescript
const benefitAmount = product.benefitAmount ?? product.price;
// 同城起购 2 瓶 / 跨城 6 瓶
// 核销上限 ¥500
```
## 破坏性改动
`packages/*` 改动需全员 + tech-lead ReviewPrisma schema 迁移需全部 Owner Review。