Commit Graph

116 Commits

Author SHA1 Message Date
6cb282147e Remove implicit first-visit heart grant from progress summary
All checks were successful
CI/CD Pipeline / Unit Tests (push) Successful in 18s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m15s
2026-06-09 18:18:17 +08:00
3ab009e338 Fix challenge service test mock queue
All checks were successful
CI/CD Pipeline / Unit Tests (push) Successful in 21s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m19s
2026-06-08 15:50:17 +08:00
5e7b7b1cda Add region-based leaderboard support
Some checks failed
CI/CD Pipeline / Unit Tests (push) Failing after 34s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
2026-06-08 15:43:54 +08:00
0317c34099 fix: handle Aliyun SMS validation errors
All checks were successful
CI/CD Pipeline / Unit Tests (push) Successful in 19s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m18s
2026-06-04 14:12:56 +08:00
48cbc200d1 fix: 使用 createRequire 加载阿里云 SDK,彻底解决 ESM/CJS 互操作问题
All checks were successful
CI/CD Pipeline / Unit Tests (push) Successful in 16s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m15s
oven/bun 容器中 node 兼容模式对 CJS __esModule 的解析行为与 Bun 原生模式和
Node.js 均不同,导致 import default 和命名导出均失败。
改用 createRequire + require() 直接走 CJS 路径,在所有运行时下行为一致。
2026-06-03 12:03:08 +08:00
ae4e2c37ba fix: 修复阿里云 SDK Request 类在 Node.js ESM 下为 undefined 的问题
All checks were successful
CI/CD Pipeline / Unit Tests (push) Successful in 16s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m14s
SDK 的 client.js 仅 export default Client,未 re-export 模型类。
Bun 的 CJS 互操作较宽松会自动合并,Node.js 则严格按 exports.xxx 解析,
导致 SendSmsVerifyCodeRequest / CheckSmsVerifyCodeRequest 在生产环境为 undefined。
改为从 dist/models/model.js 直接导入 Request 类。
2026-06-03 11:31:08 +08:00
950d6a5311 perf: 移除 CI 和 Docker 中的独立 typecheck 步骤,降低内存占用
All checks were successful
CI/CD Pipeline / Unit Tests (push) Successful in 22s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m16s
2026-06-03 11:17:34 +08:00
e4e0a026a8 fix: errorHandler 记录未预期错误日志,避免生产环境异常被静默吞掉
Some checks failed
CI/CD Pipeline / Code Quality (push) Failing after 21s
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
2026-06-03 10:39:22 +08:00
58db7d6063 feat: 实现阿里云短信验证码登录
All checks were successful
CI/CD Pipeline / Code Quality (push) Successful in 19s
CI/CD Pipeline / Unit Tests (push) Successful in 17s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m35s
通过阿里云号码认证服务 (DYPNS) 的 SendSmsVerifyCode / CheckSmsVerifyCode
实现手机号验证码两步登录流程,验证码由阿里云生成和管理,无需服务端存储。

新增端点:
- POST /v1/auth/phone/send-code (5次/分钟)
- POST /v1/auth/phone 核验+登录 (10次/分钟)

新增环境变量:ALIYUN_SMS_SIGN_NAME, ALIYUN_SMS_TEMPLATE_CODE,
ALIYUN_SMS_TEMPLATE_PARAM
2026-06-01 23:53:49 +08:00
68c1a8b343 fix: 使用 node 替代 bunx 运行 tsc 使内存限制生效
All checks were successful
CI/CD Pipeline / Code Quality (push) Successful in 17s
CI/CD Pipeline / Unit Tests (push) Successful in 15s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m24s
bunx 基于 Bun 运行时,忽略 NODE_OPTIONS 环境变量,
改用 node 直接调用 tsc 确保 --max-old-space-size 生效
2026-06-01 12:08:10 +08:00
79778424a7 perf: 限制 CI typecheck 内存占用避免 OOM
Some checks failed
CI/CD Pipeline / Code Quality (push) Failing after 18s
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
使用 CI 专用 tsconfig(关闭 sourceMap)并限制 V8 堆内存为 768MB,
防止 2GB 服务器上 tsc 被 OOM Killer 终止
2026-06-01 12:06:02 +08:00
0ca06df078 refactor: 移除阿里云融合认证集成,保留基础设施以备后续使用
Some checks failed
CI/CD Pipeline / Code Quality (push) Failing after 19s
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
移除 fusion-auth-client、融合认证路由和阿里云 SDK 依赖,
同时保留 findOrCreatePhone、appSettings 表、auth-providers
管理端和 /auth/providers 端点等基础设施。
2026-06-01 10:18:15 +08:00
32dd6a3190 perf: 移除 tsconfig 中不必要的 declaration 和 declarationMap 降低 CI 内存占用
All checks were successful
CI/CD Pipeline / Code Quality (push) Successful in 25s
CI/CD Pipeline / Unit Tests (push) Successful in 20s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m28s
API 服务器不需要生成 .d.ts 声明文件,这两个选项是 tsc 内存消耗的主要来源,
在内存受限的 CI runner 上会导致 OOM 被 SIGKILL。
2026-05-28 23:48:48 +08:00
7682bb2ae7 refactor: 融合认证 schemeCode 按平台拆分为独立环境变量
Some checks failed
CI/CD Pipeline / Code Quality (push) Failing after 18s
CI/CD Pipeline / Unit Tests (push) Has been skipped
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
不同端(Android/iOS/Harmony)在阿里云控制台使用不同的方案 Code,
单一 ALIYUN_FUSION_SCHEME_CODE 无法满足多端需求。改为按平台映射
三个独立环境变量,providers 端点也按平台精确判断可用性。

同步更新 API 文档:补充 fusion/token 请求参数表和 Harmony 平台支持。
2026-05-28 23:43:21 +08:00
b6fc6c5a9b fix: 移除导致 CI 失败的动态 import 测试用例
All checks were successful
CI/CD Pipeline / Code Quality (push) Successful in 23s
CI/CD Pipeline / Unit Tests (push) Successful in 17s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m39s
2026-05-27 22:57:43 +08:00
4e7a9e6d1f docs: 添加 agents 配置文档
Some checks failed
CI/CD Pipeline / Code Quality (push) Successful in 24s
CI/CD Pipeline / Unit Tests (push) Failing after 20s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
2026-05-27 22:53:14 +08:00
a2282975ca feat: 集成阿里云融合认证实现手机号一键登录与登录方式管理
- 新增 POST /auth/fusion/token 获取 SDK 鉴权 Token
- 新增 POST /auth/fusion/verify 用 verifyToken 换取手机号并登录/注册
- 新增 GET /auth/providers 按平台返回可用登录方式列表
- 新增 PUT /admin/auth-providers 管理端热切换第三方登录开关
- 新增 appSettings 表存储运行时配置,支持不重启生效
- 修复 schema 中超长外键名称导致的 db:push 失败
2026-05-27 22:50:11 +08:00
6507d9e9ac fix: 登录响应结构与 API 文档对齐
All checks were successful
CI/CD Pipeline / Code Quality (push) Successful in 20s
CI/CD Pipeline / Unit Tests (push) Successful in 14s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m29s
- LoginResponse 的 tokens 嵌入 tokens 对象,移除平铺的 accessToken/refreshToken
- user 移除 xpTotal/streakDays(文档中未定义)
- refreshJwt 同时返回 accessToken 和 refreshToken,复用 signTokens
2026-05-25 00:37:12 +08:00
b2e5b8f789 docs: 补充 POST /v1/auth/link 接口文档与 CLAUDE.md 项目约定
- 新增 /auth/link 游客账号关联接口的完整 API 文档
  (认证表、请求/响应格式、场景说明、幂等保证、错误码 CONFLICT)
- CLAUDE.md 补充相关项目引用和编码行为约定
2026-05-24 00:41:39 +08:00
1116b9a2ec feat: 实现 POST /v1/auth/link 游客账号关联与数据合并
All checks were successful
CI/CD Pipeline / Code Quality (push) Successful in 27s
CI/CD Pipeline / Unit Tests (push) Successful in 17s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 1m29s
新增游客到正式账号的关联接口,支持 Apple Sign In,
采用 server_account_first 合并策略:
- 场景 A(新用户):游客行原地升级为 Apple 账号
- 场景 B(老用户):事务内合并答题记录、奖励流水等,
  不覆盖老账号的订阅、余额、库存、连续学习

包含幂等迁移追踪(accountMigrations 表)、
Apple identity token 验证(jose + JWKS)、
防竞态的原子迁移槽位抢占,
以及 12 个单元测试覆盖两种场景和各类边界。
2026-05-23 13:50:16 +08:00
7dcaf65585 Refresh API reference for current routes 2026-05-18 11:55:54 +08:00
cd7e9e2a41 修复游戏化测试与奖励边界
All checks were successful
CI/CD Pipeline / Code Quality (push) Successful in 21s
CI/CD Pipeline / Unit Tests (push) Successful in 18s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Successful in 12m39s
2026-05-17 00:22:55 +08:00
2a3413c4d5 完成游戏化服务端全部 Phase G0-G6
Some checks failed
CI/CD Pipeline / Code Quality (push) Successful in 43s
CI/CD Pipeline / Unit Tests (push) Failing after 20s
CI/CD Pipeline / Build & Deploy Test (push) Has been skipped
CI/CD Pipeline / Build & Deploy Production (push) Has been skipped
最终验证通过 typecheck(零错误)、eslint(零错误)、git diff --check。
覆盖规则常量、挑战组、XP/等级、金币/商店、广告恢复、周榜排行榜、
Admin 查看、集成测试、定时任务调度和 API 文档更新。
2026-05-13 22:46:51 +08:00
c24be16b6a 增加定时任务调度入口和 Admin 触发路由
- 新增 scheduler/index.ts 统一调度周榜结算和订阅过期检查
- 支持 CLI 入口:bun run src/services/scheduler/index.ts weekly-settlement --dry-run
- 支持 Admin 手动触发:GET/POST /v1/admin/jobs
- 所有任务支持 dry-run 模式预览不写库
2026-05-13 22:39:35 +08:00
1d9c67b30c 增加游戏化核心流程集成测试
新增 gamification-flow.test.ts,覆盖挑战 XP 累加→金币发放→周榜
分组、广告恢复爱心→rewardLedger、组内排名统计 3 个跨服务集成场景。
验证 addXp 写入 userWeeklyXp 含 groupId、grantCoins 幂等、
completeAdRecoverySession 写入统一奖励流水。
2026-05-13 22:33:47 +08:00
f64c8e2fe4 增加 Admin 游戏化数据只读查看
新增 5 个 Admin 端点查看用户金币钱包、道具库存、奖励流水、
广告恢复记录和资源变更流水,全部只读 GET,支持分页。
路由注册在 /v1/admin/gamification/ 下。
2026-05-13 22:24:23 +08:00
cff1c148de 更新实施计划索引添加 Game Economy 阶段
- implementation-plan.md 新增 Phase 1d Game Economy 索引
- 更新总体进度表、依赖图、成功标准
- 链接到 gamification-server-plan.md 和 GAMIFICATION_DESIGN.md
- Success Criteria 新增游戏化相关验收条目
2026-05-13 22:20:07 +08:00
0ee3522280 更新 API 参考文档对齐游戏化变更
- 排行榜响应新增 meta 字段含周信息/分组/奖励预览
- xp 改为本周 XP,说明排名基于 20-30 人分组
- 广告恢复 session 新增 Plus 用户 subscriptionBenefits 响应
- 标注旧恢复接口已废弃,指向 session+complete 两步流程
2026-05-13 22:11:52 +08:00
407a2b9b32 添加排行榜回归测试覆盖 G5-6
新增 leaderboard-service.test.ts,覆盖周 XP 累加与首次分组/加入
未满组/不重分配、组内排名、无记录、dryRun 预览/正式结算/多组
独立奖励、周榜元信息与奖励预览 10 个场景。Phase G5 全部完成。
2026-05-13 22:03:38 +08:00
6c63b6e24a 暴露周榜元信息到排行榜 API
- 新增 LeaderboardMetaDto 含 weekStart/weekEnd/nextRefreshAt/groupId/rank/rewardPreview
- leaderboard-service 新增 getLeaderboardMeta() 获取当前周元信息
- /leaderboards 和 /leaderboards/me 响应中附带 meta 字段
- 奖励预览返回前 3 名的 300/150/50 金币配置
2026-05-13 21:48:54 +08:00
a3da577bf3 实现排行榜前三奖励结算
- weeklySettlement 按组结算,每组前 3 名发 300/150/50 金币
- 奖励通过 grantCoins 幂等发放,idempotencyKey 包含组+排名+用户
- 结算返回 SettlementResult 含 rewards 列表和 groupCount
- coin-service 新增 leaderboard_settlement 奖励来源
- schema inventoryTransactions.sourceType 新增 leaderboard_settlement 枚举值
2026-05-13 21:43:14 +08:00
66112c30f8 实现排行榜 20-30 人分组
- 用户本周首次获得 XP 时自动分配到 20-30 人榜组
- 分组策略:查找未满组加入,否则创建新组
- 组 ID 格式 week-{date}-group-{序号},方便调试
- 排行榜查询和我的排名改为组内排名
- getLeaderboard 新增 userId 参数获取用户所在组
2026-05-13 21:30:08 +08:00
08461485d5 实现每周一刷新逻辑与幂等周结算
- weeklySettlement 改为结算上一周数据(周一当前周 XP 为 0)
- 快照写入使用 onDuplicateKeyUpdate 保证幂等
- userWeeklyXp.settled 标记防止重复结算
- 新增 dryRun 模式返回结算预览不写库
- 时区策略注释:所有周榜计算统一 UTC,客户端本地转换
2026-05-13 21:06:15 +08:00
d7d5f8109c 改造排行榜数据源为本周 XP
- addXp() 每次获得 XP 时同步累加 userWeeklyXp 表的本周统计
- 使用 INSERT ON DUPLICATE KEY UPDATE 实现幂等周 XP 累加
- leaderboard-service 从 userWeeklyXp 查询本周 XP 排名替代累计 XP
- leaderboard-api-service DTO 中 xp 字段改为展示本周 XP
- weeklySettlement() 基于 userWeeklyXp 生成周快照
2026-05-13 21:00:48 +08:00
eee2116633 添加广告恢复回归测试覆盖 G4-7
新增 ad-recovery-service.test.ts,覆盖幂等 session 创建、Plus 拦截
与权益摘要、每日上限、会话过期、provider token 缺失、信任测试
provider、已完成会话幂等返回、rewardLedger 幂等命中 8 个场景。
Phase G4 全部完成。
2026-05-13 20:34:55 +08:00
de0055e794 标记旧恢复接口废弃并明确 Plus 用户分支
- 在 3 个旧恢复路由上标记 [废弃] 注释,指向新的 ad-recovery 两步流程
- Plus 用户调用广告恢复接口时返回 subscriptionBenefits 权益摘要
- 包含 tier、unlimitedHearts、dailyHighRewardSessions 供客户端展示
2026-05-13 20:24:32 +08:00
8401d8c714 对齐广告恢复奖励到统一奖励结算层
将 ad-recovery-service 的 applyReward() 从直接操作 users 表改为通过
rewardLedger 统一结算层发放,使用 ad_recovery:{sessionId} 幂等 key
防止重复结算,记录 stateBefore/After 资源快照便于审计追溯。
2026-05-13 20:04:32 +08:00
7aa53657fc 补齐金币商店测试覆盖 2026-05-13 17:45:58 +08:00
6bf9db9820 扩展游戏化启动与商店 DTO 2026-05-13 17:38:54 +08:00
b74201d6e0 实现游戏化道具使用接口 2026-05-13 17:31:54 +08:00
ff75c34873 实现游戏化商店购买接口 2026-05-13 17:16:30 +08:00
5a29c59cf0 实现游戏化道具库存服务 2026-05-13 16:57:34 +08:00
3bcaf0fbf3 实现游戏化宝箱奖励服务 2026-05-13 16:41:57 +08:00
18865e17ca 实现游戏化金币发放服务 2026-05-13 13:01:00 +08:00
1ad26d0fe8 补齐 XP 与连续学习测试覆盖 2026-05-13 10:55:17 +08:00
c08d3f75b9 实现每日首次进入红心补给 2026-05-13 10:53:27 +08:00
d71c45b2f1 实现连续学习里程碑奖励 2026-05-13 10:51:01 +08:00
447cef3dea 按挑战组完成更新连续学习 2026-05-13 10:47:46 +08:00
b5b3aaf3a7 实现游戏化 XP 来源与连对奖励 2026-05-13 10:26:21 +08:00
b590e60bce feat: implement non-linear 50-level XP curve (G2-1)
Replace flat 400 XP/level formula with the segmented curve from
LEVEL_RULES: Lv.1-5 steep ramp, Lv.6-10 moderate, Lv.11-20 linear +80,
Lv.21-35 +120, Lv.36-50 +180. Level 50 is hard-capped with xpToNextLevel=0.

Uses binary search over pre-computed cumulative thresholds for O(log n)
level lookup.
2026-05-12 11:04:23 +08:00