@tbox.cn/app-module-promotion 0.2.0 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/AGENTS.md +16 -0
  2. package/README.md +90 -11
  3. package/dist/chunk-QOTX4XDS.js +1745 -0
  4. package/dist/chunk-S7CVFCML.js +1330 -0
  5. package/dist/client/index.d.ts +21 -3
  6. package/dist/client/index.js +4 -2
  7. package/dist/index.d.ts +4 -3
  8. package/dist/index.js +16 -4
  9. package/dist/promotion-6L7HLRC2.css +2135 -0
  10. package/dist/server/index.d.ts +2481 -41
  11. package/dist/server/index.js +13 -3
  12. package/package.json +28 -15
  13. package/skills/promotion/SKILL.md +137 -0
  14. package/skills/promotion/references/claim-loop.md +18 -0
  15. package/src/client/cards/index.ts +10 -0
  16. package/src/client/cards/promotion-activity-category-list/index.tsx +34 -0
  17. package/src/client/cards/promotion-activity-detail/index.tsx +84 -0
  18. package/src/client/cards/promotion-activity-list/index.tsx +56 -0
  19. package/src/client/cards/promotion-best-deal/index.tsx +18 -0
  20. package/src/client/cards/promotion-entitlement-list/index.tsx +161 -0
  21. package/src/client/cards/promotion-offer-detail/index.tsx +116 -0
  22. package/src/client/cards/promotion-offer-list/index.tsx +283 -0
  23. package/src/client/cards/view.ts +72 -0
  24. package/src/client/components/CouponQrCode.tsx +48 -0
  25. package/src/client/components/CouponSheet.tsx +124 -0
  26. package/src/client/components/ImageWithFallback.tsx +39 -0
  27. package/src/client/index.ts +23 -4
  28. package/src/client/styles/promotion.css +2135 -0
  29. package/src/client/types/css.d.ts +2 -0
  30. package/src/client/utils/sanitize-activity-html.ts +48 -0
  31. package/src/client/utils/scroll-card-bottom.ts +40 -0
  32. package/src/server/actions.ts +217 -0
  33. package/src/server/cards/index.ts +19 -0
  34. package/src/server/cards/promotion-activity-category-list/meta.ts +13 -0
  35. package/src/server/cards/promotion-activity-detail/meta.ts +29 -0
  36. package/src/server/cards/promotion-activity-list/meta.ts +13 -0
  37. package/src/server/cards/promotion-best-deal/meta.ts +20 -0
  38. package/src/server/cards/promotion-entitlement-list/meta.ts +17 -0
  39. package/src/server/cards/promotion-entitlement-list/samples.ts +51 -0
  40. package/src/server/cards/promotion-offer-detail/meta.ts +25 -0
  41. package/src/server/cards/promotion-offer-list/meta.ts +20 -0
  42. package/src/server/cards/promotion-offer-list/samples.ts +154 -0
  43. package/src/server/handler.ts +378 -16
  44. package/src/server/index.ts +117 -22
  45. package/src/server/navigation.ts +23 -0
  46. package/src/server/ports.ts +56 -0
  47. package/src/server/service.ts +243 -24
  48. package/src/server/tools.ts +789 -0
  49. package/tbox.module.json +126 -0
  50. package/tests/cards-render.test.tsx +656 -0
  51. package/tests/ports-resolve.test.ts +96 -0
  52. package/tests/pretool-coupons.test.ts +63 -0
  53. package/tests/promotion.test.ts +976 -0
  54. package/tests/samples.test.ts +42 -0
  55. package/tests/view.test.ts +61 -0
  56. package/tsup.config.ts +9 -1
  57. package/dist/chunk-AD6OLHSM.js +0 -86
  58. package/dist/chunk-LQGF6337.js +0 -32
  59. package/src/client/cards/coupon/index.tsx +0 -12
  60. package/src/server/cards/coupon/meta.ts +0 -23
  61. package/tbox.component.json +0 -20
  62. package/tests/service.test.ts +0 -31
package/AGENTS.md ADDED
@@ -0,0 +1,16 @@
1
+ # module-promotion —— 集成指引(AI 助手用)
2
+
3
+ 本模块为商圈业务模块,声明消费以下服务槽(Port 接口定义见 `src/server/ports/`):
4
+
5
+ - 服务槽清单:见 `tbox.module.json` 的 `contributes.services`(demand 侧,含 title/description meta)。
6
+
7
+ ## 自定义 API 对接(AI 集成)
8
+
9
+ 用户为本模块服务槽配置「自定义 API」后,adapter 实施落点 = `packages/provider-custom/`
10
+ (促销:优惠券与促销活动)。实施步骤与完成判据见 `packages/provider-custom/AGENTS.md`;
11
+ 本模块 Port 接口为 adapter 的实现契约(输入 `ServiceAdapterInput`:config/instanceId/credentialRef)。
12
+
13
+ ## 真实厂商接入
14
+
15
+ 官方 provider 包形态(manifest 槽声明 + 独立包发布)参照 `modules/provider-mock` 结构样例与
16
+ docs/reference/providers.md;厂商中立措辞纪律见该参考(本文件受 vendor-neutrality 门禁扫描)。
package/README.md CHANGED
@@ -1,17 +1,96 @@
1
- # @tbox.cn/app-module-promotion
1
+ # module-promotion · 营销业务组件
2
2
 
3
- 商圈营销模块:资格校验、推荐降级链、券卡(codegen 源)。
3
+ 商圈营销域承接组件(`@tbox.cn/app-module-promotion`,componentId `promotion`)。
4
+ 查询四族(活动/优惠/权益/套餐)+ 券领取与参与写动作 + 最划算计算;provider 包供给
5
+ (业务模块零 vendor);联单活动整单分流给 alipay-activity。15 工具全量 withCardEmissionHint,
6
+ 其中 3 个带 actions 句(预告卡面可拉起动作)。
4
7
 
5
- ## 安装
8
+ ## 业务职责
6
9
 
7
- ```sh
8
- pnpm add @tbox.cn/app-module-promotion
9
- ```
10
+ | 能力族 | 承接 |
11
+ |---|---|
12
+ | 活动 | 类目/列表/详情/场次/参与指引(含联单分流)|
13
+ | 优惠 | 检索/详情/推荐(presentation 效果词表:list/detail/coupon...)|
14
+ | 权益 | 我的券/权益列表(写动作:领取)|
15
+ | 套餐 | 套餐详情/列表与垂直购买引导点 |
16
+ | 咨询 | not-supplied 时按非接入面话术应答 |
10
17
 
11
- ## 用法
18
+ ## 架构分层
12
19
 
13
- 在生成应用中:
20
+ src/
21
+ server/
22
+ index.ts 模块注册(7 卡 + 15 工具,index.ts:85-87)
23
+ tools.ts 15 工具定义(~770 行;createPromotionTools tools.ts:318)
24
+ actions.ts 写动作链(券领取/参与确认续接)
25
+ navigation.ts 跳转导航策略(领券后跳转等)
26
+ ports.ts Port 解析(provider 供给)
27
+ client/cards/ 7 张卡组件
14
28
 
15
- ```sh
16
- tbox-app module add @tbox.cn/app-module-promotion
17
- ```
29
+ ## 领域模型(契约真源)
30
+
31
+ - contracts-mall promotion 分节:PromotionActivityPort(类目/列表/详情/场次四方法,
32
+ adapter 侧 listActivitySessions/getActivityDetail 精确 ref 校验)、PromotionOfferPort、
33
+ PromotionEntitlementPort、PromotionQueryContext(scope + reqCtx 但合)。
34
+ - offerRef 即约定标识(如 `<provider>:offer:<id>` / `alipay:bumpin:prize:<id>`),是跨模块
35
+ 卡面与工具输入姻的编解码键。
36
+
37
+ ## 工具清单(tools.ts;createPromotionTools:318;hint 包裹 754-768;注册 index.ts:85-87)
38
+
39
+ | 工具 | 定义行 | oneLiner | carding | actions |
40
+ |---|---|---|---|---|
41
+ | listActivityCategories | tools.ts:410 | 活动类目列表;联单分流判定 delegateLinkedActivity(320-326)| promotion-activity-category-list | 无 |
42
+ | listActivities | tools.ts:437 | 活动列表(categoryId/keyword/dataScope(CURRENT|HISTORY)/registrationRequired/startsAfter/endsBefore/cursor/limit 缺省 10;条件解析 resolveCategoryId 456-457)| promotion-activity-list | 无 |
43
+ | getActivityDetail | tools.ts:481 | 活动详情;keyword 无 ref 时取列表第一条兜底(352-363)| promotion-activity-detail | 无 |
44
+ | listActivitySessions | tools.ts:497 | 活动脉次;详情无 sections 时降级 detail.sessions(507-509)| 无(validation rows)| 无 |
45
+ | getActivityGuide | tools.ts:516 | 参与指引 facts | 无 | 无 |
46
+ | searchOffers | tools.ts:532 | 优惠检索(presentation 辞表约束卡选型)| promotion-offer-list | 无 |
47
+ | getOfferDetail | tools.ts:550 | 优惠详情 + 领取入口 | promotion-offer-detail | 是 |
48
+ | listEntitlements | tools.ts:582 | 我的权益/券列表 | promotion-entitlement-list | 无 |
49
+ | listPromotions | tools.ts:599 | 营销活动专题列表 | promotion-activity-list | 无 |
50
+ | getPromotionDetail | tools.ts:618 | 专题详情 | promotion-activity-detail | 无 |
51
+ | getParticipationGuide | tools.ts:631 | 参与步骤 facts | 无 | 无 |
52
+ | listCoupons | tools.ts:644 | 可领券列表 | promotion-offer-list | 是 |
53
+ | getPackageDetail | tools.ts:677 | 套餐详情 + 引导点 | promotion-offer-detail | 是 |
54
+ | recommendOffers | tools.ts:693 | 推荐优惠(oneLiner 引导句拼装)| promotion-offer-list | 无 |
55
+ | calculateBestDeal | tools.ts:719 | 最划算试算(输入 currentAmountCents + candidateOfferRefs;输出 estimatedSavingCents/reason/candidatesConsidered);not-supplied 不出卡(tools.ts:728-730)| 无 | 无 |
56
+
57
+ 细节机制:
58
+ - **联单分流 delegateLinkedActivity**(tools.ts:320-326):listActivityCategories 结果中
59
+ 命中 alipay-activity handler 且无 continueWith 整单委托——活动中心问句直出碰一碰
60
+ 联单卡,不经本模块活动列表。
61
+ - not-supplied 面与真实供给面双声明(index.ts:107/109):1030 §6.2 的接入面收口点。
62
+ - 写动作链(actions.ts):领取/参与确认工具产出带 actions 的卡面或动作结果,导航跳转策略
63
+ 由 navigation.ts 统一(跳转链路与安卓侧 pending 观测项相关)。
64
+
65
+ ## 门禁
66
+
67
+ - 会员相关查询携 authState:GUEST 可查活动(公开营销面),领取动作由卡面 actions 拉起
68
+ 客户端续接(未登录时由 member 门禁兜底)。
69
+
70
+ ## 写动作面
71
+
72
+ | 动作 | 状态空间 | 入口 |
73
+ |---|---|---|
74
+ | 领取券 | StateStore: promotion.entitlements.* | getOfferDetail/listCoupons 卡面 actions |
75
+ | 参与确认 | StateStore: promotion.participations.* | getPackageDetail/getParticipationGuide 链路 |
76
+
77
+ ## 卡片清单(7 张)
78
+
79
+ promotion-activity-category-list、promotion-activity-list、promotion-activity-detail、
80
+ promotion-offer-list、promotion-offer-detail、promotion-entitlement-list、
81
+ promotion-best-deal。
82
+
83
+ ## 跨模块协作
84
+
85
+ - ↔ alipay-activity:联单活动整单委托(delegateLinkedActivity)。
86
+ - ← shopping-guide:券信息面消费(领取动作回流本模块写动作面)。
87
+
88
+ ## 铁律摘要
89
+
90
+ - import 边界、register 只注册不解析、卡 key = cardType(同全仓)。
91
+ - 词表外 presentation 值不得进入卡选型(tools.ts 常量词表收口)。
92
+
93
+ ## 已知限制与文档漂移
94
+
95
+ - `hasActiveQuote` 字段不存在(1030 曾误登,已在本回合撤销)。
96
+ - `@vendor-contract` JSDoc 待 Phase 1 增补(PromotionActivityPort 语义现摘自普通 JSDoc)。