@tbox.cn/app-module-member 0.9.6 → 0.9.7
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.
- package/AGENTS.md +6 -8
- package/INTEGRATION.md +21 -0
- package/dist/{chunk-VU73BWYZ.js → chunk-KLQHDDSD.js} +3 -3
- package/dist/index.js +1 -1
- package/dist/server/index.d.ts +78 -78
- package/dist/server/index.js +1 -1
- package/package.json +5 -4
- package/src/client/cards/index.ts +1 -1
- package/src/client/cards/member-enrollment-form/index.tsx +2 -2
- package/src/client/cards/member-enrollment-status/index.tsx +2 -2
- package/src/client/cards/view.ts +1 -1
- package/src/client/components/ImageWithFallback.tsx +1 -1
- package/src/client/index.ts +1 -1
- package/src/client/types/css.d.ts +1 -1
- package/src/server/action.ts +14 -14
- package/src/server/handler.ts +3 -3
- package/src/server/index.ts +11 -4
- package/src/server/service.ts +4 -4
- package/src/server/tool.ts +2 -2
- package/src/server/util.ts +1 -1
package/AGENTS.md
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
# module-member —— 集成指引(AI 助手用)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- 服务槽清单:见 `tbox.module.json` 的 `contributes.services`(demand 侧,含 title/description meta)。
|
|
3
|
+
本模块为商圈业务模块(会员:会员注册、卡面与权益查询)。服务槽、接口清单、接入依赖与可选降级见本包
|
|
4
|
+
`INTEGRATION.md`(真源);结构事实(槽位/必选性)见本包 `tbox.module.json`。
|
|
6
5
|
|
|
7
6
|
## 自定义 API 对接(AI 集成)
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
本模块 Port 接口为 adapter 的实现契约(输入 `ServiceAdapterInput`:config/instanceId/credentialRef)。
|
|
8
|
+
见本包 `INTEGRATION.md`(接入语义真源);实施落点与流程见应用根 `INTEGRATION.md`
|
|
9
|
+
与 `packages/provider-custom/INTEGRATION.md`。
|
|
12
10
|
|
|
13
11
|
## 真实厂商接入
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
见本包 `INTEGRATION.md`;官方 provider 包形态用 `tbox-app new provider <name>` 骨架
|
|
14
|
+
(应用态 `packages/provider-<id>` local 形态 / 仓库态 `modules/provider-<id>` 发布形态)。
|
package/INTEGRATION.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# INTEGRATION —— module-member(会员积分)接入指引
|
|
2
|
+
|
|
3
|
+
> 结构事实以本包 `tbox.module.json` 为准(`declare.consumes`:槽位与必选性、`declare.owns`:
|
|
4
|
+
> 服务归属);接口签名以消费的契约包 Port 为准(`packages/contracts-mall/src/services/`);本文件只写二者推不出的接入语义。
|
|
5
|
+
|
|
6
|
+
## 服务与依赖
|
|
7
|
+
|
|
8
|
+
- **五槽全必选**(consumes `optional:false`):member.account / member.profile / member.card /
|
|
9
|
+
member.benefits / member.enrollment——自定义 API 接入须逐一落声明并实现;`member.snapshot`
|
|
10
|
+
聚合槽由底层槽派生,落声明时跳过。
|
|
11
|
+
- **身份键**:各 Port 方法入参 `userId` 由平台传入(登录态身份)——你的后端需能以该标识
|
|
12
|
+
定位会员;若后端会员体系与平台 userId 无映射,需在接入时约定映射方案。
|
|
13
|
+
- **接入顺序**:入会链(member.enrollment 两步授权)依赖平台登录态先行(登录换码由
|
|
14
|
+
mall-core 承接——见 `packages/module-mall-core/INTEGRATION.md`);账户/卡面/权益/积分
|
|
15
|
+
四读槽相互独立可并行实施。
|
|
16
|
+
- **可选能力**:`MemberEnrollmentPort.getEnrollmentFormDefinition?` 可选——后端无表单端点
|
|
17
|
+
可不实现,调用方降级(入会走固定授权流,不出动态表单)。
|
|
18
|
+
- **幂等**:入会 `enroll` 由模块生成幂等键(`sha256(userId\0mallId\0formVersion)`)——
|
|
19
|
+
同键重入应返回首果。
|
|
20
|
+
- **验收注意**:本模块无 InMemory 兜底(fail-visible)——绑定后未实施 adapter,工具调用
|
|
21
|
+
报 `PROVIDER_NOT_IMPLEMENTED`,消失即接入完成。
|
|
@@ -867,7 +867,7 @@ function createQueryMemberInfoTool(ports) {
|
|
|
867
867
|
const infoCard = {
|
|
868
868
|
cardType: "member-info",
|
|
869
869
|
data: facts,
|
|
870
|
-
// note
|
|
870
|
+
// note 契约:账户态中文化 + 姓名要点
|
|
871
871
|
note: `\u4F1A\u5458\u8D26\u6237\uFF08${memberStateLabel(facts.state)}\uFF09${facts.displayName ? ` \xB7 ${facts.displayName}` : ""}`
|
|
872
872
|
};
|
|
873
873
|
if (account.state !== "active") {
|
|
@@ -1080,7 +1080,7 @@ function createMemberHandler(ctx) {
|
|
|
1080
1080
|
return {
|
|
1081
1081
|
id: "member",
|
|
1082
1082
|
// match:'exact':偏好按钮发出的是固定整句值(member-card-summary 按钮组),
|
|
1083
|
-
// 整句全等命中——不入 BM25 词袋(相似查询「2
|
|
1083
|
+
// 整句全等命中——不入 BM25 词袋(相似查询「2楼有啥美食可逛」曾被词袋误吞)
|
|
1084
1084
|
intents: [{ patterns: [...MEMBER_PREFERENCE_VALUES], match: "exact" }],
|
|
1085
1085
|
handle: async (action, payload, _ctx, reqCtx) => {
|
|
1086
1086
|
if (action === "intent") {
|
|
@@ -1426,7 +1426,7 @@ function createMemberActions(ctx, resolveMember) {
|
|
|
1426
1426
|
};
|
|
1427
1427
|
}
|
|
1428
1428
|
},
|
|
1429
|
-
/** 4.
|
|
1429
|
+
/** 4. 入会状态显式刷新(无自动轮询) */
|
|
1430
1430
|
queryEnrollmentStatus: {
|
|
1431
1431
|
actionId: "member.query-enrollment-status",
|
|
1432
1432
|
moduleId: "member",
|
package/dist/index.js
CHANGED
package/dist/server/index.d.ts
CHANGED
|
@@ -6,13 +6,13 @@ import { ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
|
6
6
|
import { MemberAccountPort, MemberProfilePort, MemberCardPort, MemberBenefitsPort, MemberEnrollmentPort, MemberAccountSnapshot, MemberProfileSnapshot, MemberCardSnapshot, Points, MemberBenefitsSnapshot, MemberEnrollmentFormDefinition, PointUsageRecord, DiscountRule, MemberEnrollmentInput, MemberEnrollmentResult, MemberEnrollmentStatus } from '@tbox.cn/app-contracts-mall';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* MemberService
|
|
9
|
+
* MemberService:商圈会员完整实现(六 Port + 015 入会升级)。
|
|
10
10
|
* extends 契约 Port(保证满足消费方子集约束);完整接口只在本模块包内。
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
13
|
* InMemory 演示实现(仅供隔离单测;运行时注册与 Provider 解析不得使用)。
|
|
14
14
|
* 017 槽位原子化后非 Port 成员归位:getEnrollmentFormDefinition 已收编
|
|
15
|
-
* MemberEnrollmentPort optional
|
|
15
|
+
* MemberEnrollmentPort optional 方法;enrollUrl/loginUrl 为槽产物自由属性
|
|
16
16
|
* (enrollment/account 槽的类型视图见 ports.ts);audit 转 InMemory 私有观测成员。
|
|
17
17
|
*/
|
|
18
18
|
interface MemberService extends MemberAccountPort, MemberProfilePort, MemberCardPort, MemberBenefitsPort, MemberEnrollmentPort {
|
|
@@ -103,19 +103,19 @@ declare const memberCards: {
|
|
|
103
103
|
labelRef: zod.ZodString;
|
|
104
104
|
name: zod.ZodString;
|
|
105
105
|
}, "strip", zod.ZodTypeAny, {
|
|
106
|
-
labelRef: string;
|
|
107
106
|
name: string;
|
|
108
|
-
}, {
|
|
109
107
|
labelRef: string;
|
|
108
|
+
}, {
|
|
110
109
|
name: string;
|
|
110
|
+
labelRef: string;
|
|
111
111
|
}>, "many">;
|
|
112
112
|
}, "strip", zod.ZodTypeAny, {
|
|
113
113
|
userId: string;
|
|
114
|
-
authState: "authenticated" | "unauthenticated";
|
|
115
114
|
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
115
|
+
authState: "authenticated" | "unauthenticated";
|
|
116
116
|
labels: {
|
|
117
|
-
labelRef: string;
|
|
118
117
|
name: string;
|
|
118
|
+
labelRef: string;
|
|
119
119
|
}[];
|
|
120
120
|
displayName?: string | undefined;
|
|
121
121
|
avatarUrl?: string | undefined;
|
|
@@ -124,11 +124,11 @@ declare const memberCards: {
|
|
|
124
124
|
registeredAt?: string | undefined;
|
|
125
125
|
}, {
|
|
126
126
|
userId: string;
|
|
127
|
-
authState: "authenticated" | "unauthenticated";
|
|
128
127
|
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
128
|
+
authState: "authenticated" | "unauthenticated";
|
|
129
129
|
labels: {
|
|
130
|
-
labelRef: string;
|
|
131
130
|
name: string;
|
|
131
|
+
labelRef: string;
|
|
132
132
|
}[];
|
|
133
133
|
displayName?: string | undefined;
|
|
134
134
|
avatarUrl?: string | undefined;
|
|
@@ -185,13 +185,13 @@ declare const memberCards: {
|
|
|
185
185
|
text: zod.ZodOptional<zod.ZodString>;
|
|
186
186
|
}, "strip", zod.ZodTypeAny, {
|
|
187
187
|
kind: "toast" | "miniapp" | "dialog";
|
|
188
|
-
title?: string | undefined;
|
|
189
188
|
url?: string | undefined;
|
|
189
|
+
title?: string | undefined;
|
|
190
190
|
text?: string | undefined;
|
|
191
191
|
}, {
|
|
192
192
|
kind: "toast" | "miniapp" | "dialog";
|
|
193
|
-
title?: string | undefined;
|
|
194
193
|
url?: string | undefined;
|
|
194
|
+
title?: string | undefined;
|
|
195
195
|
text?: string | undefined;
|
|
196
196
|
}>>;
|
|
197
197
|
}, "strip", zod.ZodTypeAny, {
|
|
@@ -200,8 +200,8 @@ declare const memberCards: {
|
|
|
200
200
|
description?: string | undefined;
|
|
201
201
|
action?: {
|
|
202
202
|
kind: "toast" | "miniapp" | "dialog";
|
|
203
|
-
title?: string | undefined;
|
|
204
203
|
url?: string | undefined;
|
|
204
|
+
title?: string | undefined;
|
|
205
205
|
text?: string | undefined;
|
|
206
206
|
} | undefined;
|
|
207
207
|
iconUrl?: string | undefined;
|
|
@@ -211,8 +211,8 @@ declare const memberCards: {
|
|
|
211
211
|
description?: string | undefined;
|
|
212
212
|
action?: {
|
|
213
213
|
kind: "toast" | "miniapp" | "dialog";
|
|
214
|
-
title?: string | undefined;
|
|
215
214
|
url?: string | undefined;
|
|
215
|
+
title?: string | undefined;
|
|
216
216
|
text?: string | undefined;
|
|
217
217
|
} | undefined;
|
|
218
218
|
iconUrl?: string | undefined;
|
|
@@ -228,8 +228,8 @@ declare const memberCards: {
|
|
|
228
228
|
query: string;
|
|
229
229
|
}>, "many">>;
|
|
230
230
|
}, "strip", zod.ZodTypeAny, {
|
|
231
|
-
userId: string;
|
|
232
231
|
status: "unknown" | "active" | "inactive" | "frozen" | "expired";
|
|
232
|
+
userId: string;
|
|
233
233
|
cardRef: string;
|
|
234
234
|
cardDisplay: string;
|
|
235
235
|
availablePoints: number;
|
|
@@ -254,8 +254,8 @@ declare const memberCards: {
|
|
|
254
254
|
description?: string | undefined;
|
|
255
255
|
action?: {
|
|
256
256
|
kind: "toast" | "miniapp" | "dialog";
|
|
257
|
-
title?: string | undefined;
|
|
258
257
|
url?: string | undefined;
|
|
258
|
+
title?: string | undefined;
|
|
259
259
|
text?: string | undefined;
|
|
260
260
|
} | undefined;
|
|
261
261
|
iconUrl?: string | undefined;
|
|
@@ -265,8 +265,8 @@ declare const memberCards: {
|
|
|
265
265
|
query: string;
|
|
266
266
|
}[] | undefined;
|
|
267
267
|
}, {
|
|
268
|
-
userId: string;
|
|
269
268
|
status: "unknown" | "active" | "inactive" | "frozen" | "expired";
|
|
269
|
+
userId: string;
|
|
270
270
|
cardRef: string;
|
|
271
271
|
cardDisplay: string;
|
|
272
272
|
availablePoints: number;
|
|
@@ -291,8 +291,8 @@ declare const memberCards: {
|
|
|
291
291
|
description?: string | undefined;
|
|
292
292
|
action?: {
|
|
293
293
|
kind: "toast" | "miniapp" | "dialog";
|
|
294
|
-
title?: string | undefined;
|
|
295
294
|
url?: string | undefined;
|
|
295
|
+
title?: string | undefined;
|
|
296
296
|
text?: string | undefined;
|
|
297
297
|
} | undefined;
|
|
298
298
|
iconUrl?: string | undefined;
|
|
@@ -313,42 +313,42 @@ declare const memberCards: {
|
|
|
313
313
|
usedAt: zod.ZodOptional<zod.ZodString>;
|
|
314
314
|
description: zod.ZodOptional<zod.ZodString>;
|
|
315
315
|
}, "strip", zod.ZodTypeAny, {
|
|
316
|
-
usageRecordRef: string;
|
|
317
316
|
title: string;
|
|
317
|
+
usageRecordRef: string;
|
|
318
318
|
amount: string;
|
|
319
|
-
usedAt?: string | undefined;
|
|
320
319
|
description?: string | undefined;
|
|
320
|
+
usedAt?: string | undefined;
|
|
321
321
|
}, {
|
|
322
|
-
usageRecordRef: string;
|
|
323
322
|
title: string;
|
|
323
|
+
usageRecordRef: string;
|
|
324
324
|
amount: string;
|
|
325
|
-
usedAt?: string | undefined;
|
|
326
325
|
description?: string | undefined;
|
|
326
|
+
usedAt?: string | undefined;
|
|
327
327
|
}>, "many">;
|
|
328
328
|
total: zod.ZodNumber;
|
|
329
329
|
}, "strip", zod.ZodTypeAny, {
|
|
330
330
|
userId: string;
|
|
331
|
-
|
|
331
|
+
total: number;
|
|
332
332
|
items: {
|
|
333
|
-
usageRecordRef: string;
|
|
334
333
|
title: string;
|
|
334
|
+
usageRecordRef: string;
|
|
335
335
|
amount: string;
|
|
336
|
-
usedAt?: string | undefined;
|
|
337
336
|
description?: string | undefined;
|
|
337
|
+
usedAt?: string | undefined;
|
|
338
338
|
}[];
|
|
339
|
-
|
|
339
|
+
balance: number;
|
|
340
340
|
membershipLabel?: string | undefined;
|
|
341
341
|
}, {
|
|
342
342
|
userId: string;
|
|
343
|
-
|
|
343
|
+
total: number;
|
|
344
344
|
items: {
|
|
345
|
-
usageRecordRef: string;
|
|
346
345
|
title: string;
|
|
346
|
+
usageRecordRef: string;
|
|
347
347
|
amount: string;
|
|
348
|
-
usedAt?: string | undefined;
|
|
349
348
|
description?: string | undefined;
|
|
349
|
+
usedAt?: string | undefined;
|
|
350
350
|
}[];
|
|
351
|
-
|
|
351
|
+
balance: number;
|
|
352
352
|
membershipLabel?: string | undefined;
|
|
353
353
|
}>>;
|
|
354
354
|
readonly 'member-enrollment-form': _tbox_cn_app_contracts.CardMeta<zod.ZodObject<{
|
|
@@ -390,14 +390,14 @@ declare const memberCards: {
|
|
|
390
390
|
required: zod.ZodBoolean;
|
|
391
391
|
url: zod.ZodOptional<zod.ZodString>;
|
|
392
392
|
}, "strip", zod.ZodTypeAny, {
|
|
393
|
-
title: string;
|
|
394
393
|
required: boolean;
|
|
394
|
+
title: string;
|
|
395
395
|
version: string;
|
|
396
396
|
consentId: string;
|
|
397
397
|
url?: string | undefined;
|
|
398
398
|
}, {
|
|
399
|
-
title: string;
|
|
400
399
|
required: boolean;
|
|
400
|
+
title: string;
|
|
401
401
|
version: string;
|
|
402
402
|
consentId: string;
|
|
403
403
|
url?: string | undefined;
|
|
@@ -415,7 +415,6 @@ declare const memberCards: {
|
|
|
415
415
|
manualNotice: zod.ZodOptional<zod.ZodString>;
|
|
416
416
|
}, "strip", zod.ZodTypeAny, {
|
|
417
417
|
userId: string;
|
|
418
|
-
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
419
418
|
authorization: {
|
|
420
419
|
status: "unavailable" | "required" | "authorized";
|
|
421
420
|
mobileMasked?: string | undefined;
|
|
@@ -430,10 +429,11 @@ declare const memberCards: {
|
|
|
430
429
|
prefill?: string | undefined;
|
|
431
430
|
placeholder?: string | undefined;
|
|
432
431
|
}[];
|
|
432
|
+
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
433
433
|
formVersion: string;
|
|
434
434
|
consents: {
|
|
435
|
-
title: string;
|
|
436
435
|
required: boolean;
|
|
436
|
+
title: string;
|
|
437
437
|
version: string;
|
|
438
438
|
consentId: string;
|
|
439
439
|
url?: string | undefined;
|
|
@@ -441,7 +441,6 @@ declare const memberCards: {
|
|
|
441
441
|
manualNotice?: string | undefined;
|
|
442
442
|
}, {
|
|
443
443
|
userId: string;
|
|
444
|
-
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
445
444
|
authorization: {
|
|
446
445
|
status: "unavailable" | "required" | "authorized";
|
|
447
446
|
mobileMasked?: string | undefined;
|
|
@@ -456,10 +455,11 @@ declare const memberCards: {
|
|
|
456
455
|
prefill?: string | undefined;
|
|
457
456
|
placeholder?: string | undefined;
|
|
458
457
|
}[];
|
|
458
|
+
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
459
459
|
formVersion: string;
|
|
460
460
|
consents: {
|
|
461
|
-
title: string;
|
|
462
461
|
required: boolean;
|
|
462
|
+
title: string;
|
|
463
463
|
version: string;
|
|
464
464
|
consentId: string;
|
|
465
465
|
url?: string | undefined;
|
|
@@ -474,15 +474,15 @@ declare const memberCards: {
|
|
|
474
474
|
message: zod.ZodOptional<zod.ZodString>;
|
|
475
475
|
}, "strip", zod.ZodTypeAny, {
|
|
476
476
|
userId: string;
|
|
477
|
-
state: "
|
|
478
|
-
memberRef?: string | undefined;
|
|
477
|
+
state: "failed" | "active" | "pending_confirmation" | "confirmation_timeout";
|
|
479
478
|
message?: string | undefined;
|
|
479
|
+
memberRef?: string | undefined;
|
|
480
480
|
attemptRef?: string | undefined;
|
|
481
481
|
}, {
|
|
482
482
|
userId: string;
|
|
483
|
-
state: "
|
|
484
|
-
memberRef?: string | undefined;
|
|
483
|
+
state: "failed" | "active" | "pending_confirmation" | "confirmation_timeout";
|
|
485
484
|
message?: string | undefined;
|
|
485
|
+
memberRef?: string | undefined;
|
|
486
486
|
attemptRef?: string | undefined;
|
|
487
487
|
}>>;
|
|
488
488
|
readonly 'member-enrollment-cta': _tbox_cn_app_contracts.CardMeta<zod.ZodObject<{
|
|
@@ -495,16 +495,16 @@ declare const memberCards: {
|
|
|
495
495
|
perks: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
496
496
|
}, "strip", zod.ZodTypeAny, {
|
|
497
497
|
userId: string;
|
|
498
|
-
authState: "authenticated";
|
|
499
498
|
state: "not_enrolled" | "closed";
|
|
499
|
+
authState: "authenticated";
|
|
500
500
|
title?: string | undefined;
|
|
501
501
|
subtitle?: string | undefined;
|
|
502
502
|
enrollUrl?: string | undefined;
|
|
503
503
|
perks?: string[] | undefined;
|
|
504
504
|
}, {
|
|
505
505
|
userId: string;
|
|
506
|
-
authState: "authenticated";
|
|
507
506
|
state: "not_enrolled" | "closed";
|
|
507
|
+
authState: "authenticated";
|
|
508
508
|
title?: string | undefined;
|
|
509
509
|
subtitle?: string | undefined;
|
|
510
510
|
enrollUrl?: string | undefined;
|
|
@@ -541,19 +541,19 @@ declare const serverModule: {
|
|
|
541
541
|
labelRef: zod.ZodString;
|
|
542
542
|
name: zod.ZodString;
|
|
543
543
|
}, "strip", zod.ZodTypeAny, {
|
|
544
|
-
labelRef: string;
|
|
545
544
|
name: string;
|
|
546
|
-
}, {
|
|
547
545
|
labelRef: string;
|
|
546
|
+
}, {
|
|
548
547
|
name: string;
|
|
548
|
+
labelRef: string;
|
|
549
549
|
}>, "many">;
|
|
550
550
|
}, "strip", zod.ZodTypeAny, {
|
|
551
551
|
userId: string;
|
|
552
|
-
authState: "authenticated" | "unauthenticated";
|
|
553
552
|
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
553
|
+
authState: "authenticated" | "unauthenticated";
|
|
554
554
|
labels: {
|
|
555
|
-
labelRef: string;
|
|
556
555
|
name: string;
|
|
556
|
+
labelRef: string;
|
|
557
557
|
}[];
|
|
558
558
|
displayName?: string | undefined;
|
|
559
559
|
avatarUrl?: string | undefined;
|
|
@@ -562,11 +562,11 @@ declare const serverModule: {
|
|
|
562
562
|
registeredAt?: string | undefined;
|
|
563
563
|
}, {
|
|
564
564
|
userId: string;
|
|
565
|
-
authState: "authenticated" | "unauthenticated";
|
|
566
565
|
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
566
|
+
authState: "authenticated" | "unauthenticated";
|
|
567
567
|
labels: {
|
|
568
|
-
labelRef: string;
|
|
569
568
|
name: string;
|
|
569
|
+
labelRef: string;
|
|
570
570
|
}[];
|
|
571
571
|
displayName?: string | undefined;
|
|
572
572
|
avatarUrl?: string | undefined;
|
|
@@ -623,13 +623,13 @@ declare const serverModule: {
|
|
|
623
623
|
text: zod.ZodOptional<zod.ZodString>;
|
|
624
624
|
}, "strip", zod.ZodTypeAny, {
|
|
625
625
|
kind: "toast" | "miniapp" | "dialog";
|
|
626
|
-
title?: string | undefined;
|
|
627
626
|
url?: string | undefined;
|
|
627
|
+
title?: string | undefined;
|
|
628
628
|
text?: string | undefined;
|
|
629
629
|
}, {
|
|
630
630
|
kind: "toast" | "miniapp" | "dialog";
|
|
631
|
-
title?: string | undefined;
|
|
632
631
|
url?: string | undefined;
|
|
632
|
+
title?: string | undefined;
|
|
633
633
|
text?: string | undefined;
|
|
634
634
|
}>>;
|
|
635
635
|
}, "strip", zod.ZodTypeAny, {
|
|
@@ -638,8 +638,8 @@ declare const serverModule: {
|
|
|
638
638
|
description?: string | undefined;
|
|
639
639
|
action?: {
|
|
640
640
|
kind: "toast" | "miniapp" | "dialog";
|
|
641
|
-
title?: string | undefined;
|
|
642
641
|
url?: string | undefined;
|
|
642
|
+
title?: string | undefined;
|
|
643
643
|
text?: string | undefined;
|
|
644
644
|
} | undefined;
|
|
645
645
|
iconUrl?: string | undefined;
|
|
@@ -649,8 +649,8 @@ declare const serverModule: {
|
|
|
649
649
|
description?: string | undefined;
|
|
650
650
|
action?: {
|
|
651
651
|
kind: "toast" | "miniapp" | "dialog";
|
|
652
|
-
title?: string | undefined;
|
|
653
652
|
url?: string | undefined;
|
|
653
|
+
title?: string | undefined;
|
|
654
654
|
text?: string | undefined;
|
|
655
655
|
} | undefined;
|
|
656
656
|
iconUrl?: string | undefined;
|
|
@@ -666,8 +666,8 @@ declare const serverModule: {
|
|
|
666
666
|
query: string;
|
|
667
667
|
}>, "many">>;
|
|
668
668
|
}, "strip", zod.ZodTypeAny, {
|
|
669
|
-
userId: string;
|
|
670
669
|
status: "unknown" | "active" | "inactive" | "frozen" | "expired";
|
|
670
|
+
userId: string;
|
|
671
671
|
cardRef: string;
|
|
672
672
|
cardDisplay: string;
|
|
673
673
|
availablePoints: number;
|
|
@@ -692,8 +692,8 @@ declare const serverModule: {
|
|
|
692
692
|
description?: string | undefined;
|
|
693
693
|
action?: {
|
|
694
694
|
kind: "toast" | "miniapp" | "dialog";
|
|
695
|
-
title?: string | undefined;
|
|
696
695
|
url?: string | undefined;
|
|
696
|
+
title?: string | undefined;
|
|
697
697
|
text?: string | undefined;
|
|
698
698
|
} | undefined;
|
|
699
699
|
iconUrl?: string | undefined;
|
|
@@ -703,8 +703,8 @@ declare const serverModule: {
|
|
|
703
703
|
query: string;
|
|
704
704
|
}[] | undefined;
|
|
705
705
|
}, {
|
|
706
|
-
userId: string;
|
|
707
706
|
status: "unknown" | "active" | "inactive" | "frozen" | "expired";
|
|
707
|
+
userId: string;
|
|
708
708
|
cardRef: string;
|
|
709
709
|
cardDisplay: string;
|
|
710
710
|
availablePoints: number;
|
|
@@ -729,8 +729,8 @@ declare const serverModule: {
|
|
|
729
729
|
description?: string | undefined;
|
|
730
730
|
action?: {
|
|
731
731
|
kind: "toast" | "miniapp" | "dialog";
|
|
732
|
-
title?: string | undefined;
|
|
733
732
|
url?: string | undefined;
|
|
733
|
+
title?: string | undefined;
|
|
734
734
|
text?: string | undefined;
|
|
735
735
|
} | undefined;
|
|
736
736
|
iconUrl?: string | undefined;
|
|
@@ -751,42 +751,42 @@ declare const serverModule: {
|
|
|
751
751
|
usedAt: zod.ZodOptional<zod.ZodString>;
|
|
752
752
|
description: zod.ZodOptional<zod.ZodString>;
|
|
753
753
|
}, "strip", zod.ZodTypeAny, {
|
|
754
|
-
usageRecordRef: string;
|
|
755
754
|
title: string;
|
|
755
|
+
usageRecordRef: string;
|
|
756
756
|
amount: string;
|
|
757
|
-
usedAt?: string | undefined;
|
|
758
757
|
description?: string | undefined;
|
|
758
|
+
usedAt?: string | undefined;
|
|
759
759
|
}, {
|
|
760
|
-
usageRecordRef: string;
|
|
761
760
|
title: string;
|
|
761
|
+
usageRecordRef: string;
|
|
762
762
|
amount: string;
|
|
763
|
-
usedAt?: string | undefined;
|
|
764
763
|
description?: string | undefined;
|
|
764
|
+
usedAt?: string | undefined;
|
|
765
765
|
}>, "many">;
|
|
766
766
|
total: zod.ZodNumber;
|
|
767
767
|
}, "strip", zod.ZodTypeAny, {
|
|
768
768
|
userId: string;
|
|
769
|
-
|
|
769
|
+
total: number;
|
|
770
770
|
items: {
|
|
771
|
-
usageRecordRef: string;
|
|
772
771
|
title: string;
|
|
772
|
+
usageRecordRef: string;
|
|
773
773
|
amount: string;
|
|
774
|
-
usedAt?: string | undefined;
|
|
775
774
|
description?: string | undefined;
|
|
775
|
+
usedAt?: string | undefined;
|
|
776
776
|
}[];
|
|
777
|
-
|
|
777
|
+
balance: number;
|
|
778
778
|
membershipLabel?: string | undefined;
|
|
779
779
|
}, {
|
|
780
780
|
userId: string;
|
|
781
|
-
|
|
781
|
+
total: number;
|
|
782
782
|
items: {
|
|
783
|
-
usageRecordRef: string;
|
|
784
783
|
title: string;
|
|
784
|
+
usageRecordRef: string;
|
|
785
785
|
amount: string;
|
|
786
|
-
usedAt?: string | undefined;
|
|
787
786
|
description?: string | undefined;
|
|
787
|
+
usedAt?: string | undefined;
|
|
788
788
|
}[];
|
|
789
|
-
|
|
789
|
+
balance: number;
|
|
790
790
|
membershipLabel?: string | undefined;
|
|
791
791
|
}>>;
|
|
792
792
|
readonly 'member-enrollment-form': _tbox_cn_app_contracts.CardMeta<zod.ZodObject<{
|
|
@@ -828,14 +828,14 @@ declare const serverModule: {
|
|
|
828
828
|
required: zod.ZodBoolean;
|
|
829
829
|
url: zod.ZodOptional<zod.ZodString>;
|
|
830
830
|
}, "strip", zod.ZodTypeAny, {
|
|
831
|
-
title: string;
|
|
832
831
|
required: boolean;
|
|
832
|
+
title: string;
|
|
833
833
|
version: string;
|
|
834
834
|
consentId: string;
|
|
835
835
|
url?: string | undefined;
|
|
836
836
|
}, {
|
|
837
|
-
title: string;
|
|
838
837
|
required: boolean;
|
|
838
|
+
title: string;
|
|
839
839
|
version: string;
|
|
840
840
|
consentId: string;
|
|
841
841
|
url?: string | undefined;
|
|
@@ -853,7 +853,6 @@ declare const serverModule: {
|
|
|
853
853
|
manualNotice: zod.ZodOptional<zod.ZodString>;
|
|
854
854
|
}, "strip", zod.ZodTypeAny, {
|
|
855
855
|
userId: string;
|
|
856
|
-
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
857
856
|
authorization: {
|
|
858
857
|
status: "unavailable" | "required" | "authorized";
|
|
859
858
|
mobileMasked?: string | undefined;
|
|
@@ -868,10 +867,11 @@ declare const serverModule: {
|
|
|
868
867
|
prefill?: string | undefined;
|
|
869
868
|
placeholder?: string | undefined;
|
|
870
869
|
}[];
|
|
870
|
+
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
871
871
|
formVersion: string;
|
|
872
872
|
consents: {
|
|
873
|
-
title: string;
|
|
874
873
|
required: boolean;
|
|
874
|
+
title: string;
|
|
875
875
|
version: string;
|
|
876
876
|
consentId: string;
|
|
877
877
|
url?: string | undefined;
|
|
@@ -879,7 +879,6 @@ declare const serverModule: {
|
|
|
879
879
|
manualNotice?: string | undefined;
|
|
880
880
|
}, {
|
|
881
881
|
userId: string;
|
|
882
|
-
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
883
882
|
authorization: {
|
|
884
883
|
status: "unavailable" | "required" | "authorized";
|
|
885
884
|
mobileMasked?: string | undefined;
|
|
@@ -894,10 +893,11 @@ declare const serverModule: {
|
|
|
894
893
|
prefill?: string | undefined;
|
|
895
894
|
placeholder?: string | undefined;
|
|
896
895
|
}[];
|
|
896
|
+
state: "unknown" | "active" | "not_enrolled" | "closed";
|
|
897
897
|
formVersion: string;
|
|
898
898
|
consents: {
|
|
899
|
-
title: string;
|
|
900
899
|
required: boolean;
|
|
900
|
+
title: string;
|
|
901
901
|
version: string;
|
|
902
902
|
consentId: string;
|
|
903
903
|
url?: string | undefined;
|
|
@@ -912,15 +912,15 @@ declare const serverModule: {
|
|
|
912
912
|
message: zod.ZodOptional<zod.ZodString>;
|
|
913
913
|
}, "strip", zod.ZodTypeAny, {
|
|
914
914
|
userId: string;
|
|
915
|
-
state: "
|
|
916
|
-
memberRef?: string | undefined;
|
|
915
|
+
state: "failed" | "active" | "pending_confirmation" | "confirmation_timeout";
|
|
917
916
|
message?: string | undefined;
|
|
917
|
+
memberRef?: string | undefined;
|
|
918
918
|
attemptRef?: string | undefined;
|
|
919
919
|
}, {
|
|
920
920
|
userId: string;
|
|
921
|
-
state: "
|
|
922
|
-
memberRef?: string | undefined;
|
|
921
|
+
state: "failed" | "active" | "pending_confirmation" | "confirmation_timeout";
|
|
923
922
|
message?: string | undefined;
|
|
923
|
+
memberRef?: string | undefined;
|
|
924
924
|
attemptRef?: string | undefined;
|
|
925
925
|
}>>;
|
|
926
926
|
readonly 'member-enrollment-cta': _tbox_cn_app_contracts.CardMeta<zod.ZodObject<{
|
|
@@ -933,16 +933,16 @@ declare const serverModule: {
|
|
|
933
933
|
perks: zod.ZodOptional<zod.ZodArray<zod.ZodString, "many">>;
|
|
934
934
|
}, "strip", zod.ZodTypeAny, {
|
|
935
935
|
userId: string;
|
|
936
|
-
authState: "authenticated";
|
|
937
936
|
state: "not_enrolled" | "closed";
|
|
937
|
+
authState: "authenticated";
|
|
938
938
|
title?: string | undefined;
|
|
939
939
|
subtitle?: string | undefined;
|
|
940
940
|
enrollUrl?: string | undefined;
|
|
941
941
|
perks?: string[] | undefined;
|
|
942
942
|
}, {
|
|
943
943
|
userId: string;
|
|
944
|
-
authState: "authenticated";
|
|
945
944
|
state: "not_enrolled" | "closed";
|
|
945
|
+
authState: "authenticated";
|
|
946
946
|
title?: string | undefined;
|
|
947
947
|
subtitle?: string | undefined;
|
|
948
948
|
enrollUrl?: string | undefined;
|
package/dist/server/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-module-member",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "商圈会员模块:会员账户、会员卡、积分流水与入会流程(codegen 源)。",
|
|
6
6
|
"exports": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@tbox.cn/app-contracts": "0.12.3",
|
|
22
22
|
"@tbox.cn/app-contracts-mall": "0.12.4",
|
|
23
|
-
"@tbox.cn/app-agent-sdk-client": "0.1.
|
|
24
|
-
"@tbox.cn/app-agent-sdk-server": "0.1
|
|
23
|
+
"@tbox.cn/app-agent-sdk-client": "0.1.4",
|
|
24
|
+
"@tbox.cn/app-agent-sdk-server": "0.2.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"zod": "3.25.76",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"README.md",
|
|
51
51
|
"LICENSE",
|
|
52
52
|
"skills",
|
|
53
|
-
"AGENTS.md"
|
|
53
|
+
"AGENTS.md",
|
|
54
|
+
"INTEGRATION.md"
|
|
54
55
|
],
|
|
55
56
|
"engines": {
|
|
56
57
|
"node": ">=20.0.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* module-member 客户端卡片聚合(0.4.0
|
|
2
|
+
* module-member 客户端卡片聚合(0.4.0 一卡一目录;券面 0.4.0 净删——promotion 承接)。
|
|
3
3
|
*/
|
|
4
4
|
export { default as MemberInfoCard } from './member-info';
|
|
5
5
|
export { default as MemberCardSummaryCard } from './member-card-summary';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* member-enrollment-form 富卡(0.4.0
|
|
2
|
+
* member-enrollment-form 富卡(0.4.0/):受控表单 + select 渲染 + readOnly 预填锁定
|
|
3
3
|
* + 用户显式授权(无 mount 副作用)+ 客户端必填/必选校验。
|
|
4
4
|
* payload 形状与 server inputSchema 一致(fieldValues Record / acceptedConsentIds / formVersion)。
|
|
5
5
|
*/
|
|
@@ -177,5 +177,5 @@ export function MemberEnrollmentFormCard(props: {
|
|
|
177
177
|
);
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
// 0.4.0
|
|
180
|
+
// 0.4.0 评审补位:提交/授权按钮全在卡内(依赖表单/授权上下文),自持动作跳过 SDK 默认按钮条
|
|
181
181
|
export default markSelfRendering(MemberEnrollmentFormCard);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* member-enrollment-status 富卡(0.4.0
|
|
2
|
+
* member-enrollment-status 富卡(0.4.0/):四态变体 + pending 刷新。
|
|
3
3
|
*/
|
|
4
4
|
import { useRef, useState } from 'react';
|
|
5
5
|
import { ArrowClockwise, CheckCircle, Clock, WarningCircle } from '@phosphor-icons/react';
|
|
@@ -61,5 +61,5 @@ export function MemberEnrollmentStatusCard(props: {
|
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
// 0.4.0
|
|
64
|
+
// 0.4.0 评审补位:卡内"刷新状态"按钮(attemptRef 依赖卡数据)自持动作,跳过 SDK 默认按钮条
|
|
65
65
|
export default markSelfRendering(MemberEnrollmentStatusCard);
|
package/src/client/cards/view.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* member 展示纯函数(0.4.0
|
|
2
|
+
* member 展示纯函数(0.4.0 状态文案/金额色/图标映射,可单测;券面函数 0.4.0 净删——promotion 承接)。
|
|
3
3
|
*/
|
|
4
4
|
/** 积分流水金额类:负支出 → 红(--tbox-primary),正收入 → 绿(--tbox-success) */
|
|
5
5
|
export function pointAmountClass(amount: string): 'member-pu__amount--spend' | 'member-pu__amount--income' {
|
package/src/client/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* module-member 客户端入口(与服务端 serverModule 对称)。
|
|
3
3
|
*/
|
|
4
|
-
import './styles/member.css'; // 0.4.0
|
|
4
|
+
import './styles/member.css'; // 0.4.0 模块自持 CSS(副作用 import,首行保证先行加载)
|
|
5
5
|
|
|
6
6
|
import type { CardComponent } from '@tbox.cn/app-contracts';
|
|
7
7
|
import type { ClientContext, ClientModule } from '@tbox.cn/app-agent-sdk-client';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** 0.4.0
|
|
1
|
+
/** 0.4.0 模块自持 CSS(经 tsup loader: { '.css': 'copy' } 出货,样式在应用侧生效) */
|
|
2
2
|
declare module '*.css';
|
package/src/server/action.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* member
|
|
2
|
+
* member 写动作(入会协议首验切片)。
|
|
3
3
|
*
|
|
4
4
|
* 四动作(全 singleUse + grant 闭环;cards key = meta.cardType):
|
|
5
5
|
* - member.request-alipay-authorization:返回授权 effect(dispatcher 补签 → client getAuthCode)
|
|
6
6
|
* - member.complete-alipay-authorization:回调动作——消费 SDK createAlipayUserAuthorization
|
|
7
|
-
*
|
|
7
|
+
* 入会授权 PII 暂存(下沉物首个消费方):PII 经 ctx.state TTL 30min 最小集暂存
|
|
8
8
|
* - member.enroll:身份解析(授权 profile 可信 mobile 强制覆盖 / manual 正则)+ consent 校验
|
|
9
|
-
* + 幂等键 sha256(userId\0mallId\0formVersion)
|
|
10
|
-
* - member.query-enrollment-status:显式刷新(
|
|
9
|
+
* + 幂等键 sha256(userId\0mallId\0formVersion)(模块顶层 InMemoryIdempotencyStore)
|
|
10
|
+
* - member.query-enrollment-status:显式刷新(POC 自动轮询不迁)
|
|
11
11
|
*/
|
|
12
12
|
import { createHash } from 'node:crypto';
|
|
13
13
|
import type { ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
@@ -16,13 +16,13 @@ import { parseMallScope } from '@tbox.cn/app-contracts-mall';
|
|
|
16
16
|
import type { CardActionResult, RequestContext } from '@tbox.cn/app-contracts';
|
|
17
17
|
import { z } from 'zod';
|
|
18
18
|
|
|
19
|
-
/** PII 暂存命名空间(
|
|
19
|
+
/** PII 暂存命名空间(TTL 30min + 最小字段 + enroll 成功即 consume 删除) */
|
|
20
20
|
export const MEMBER_PROFILE_NAMESPACE = 'member.enrollment.profile';
|
|
21
21
|
const PROFILE_TTL_MS = 30 * 60 * 1000;
|
|
22
22
|
|
|
23
23
|
const MOBILE_PATTERN = /^1[3-9]\d{9}$/;
|
|
24
24
|
|
|
25
|
-
/** 授权 profile
|
|
25
|
+
/** 授权 profile 最小集(不落完整厂商响应) */
|
|
26
26
|
export interface StoredAuthorizationProfile {
|
|
27
27
|
readonly mobile?: string;
|
|
28
28
|
readonly displayName?: string;
|
|
@@ -37,7 +37,7 @@ const ENROLLMENT_CONSENTS = [
|
|
|
37
37
|
{ consentId: 'membership-terms', version: '1', title: '会员服务条款', required: false },
|
|
38
38
|
] as const;
|
|
39
39
|
|
|
40
|
-
/** 模块顶层幂等单例(
|
|
40
|
+
/** 模块顶层幂等单例(IdempotencyStore 挂 HTTP gateway 非 ctx,模块自持) */
|
|
41
41
|
const enrollmentIdempotency = new InMemoryIdempotencyStore();
|
|
42
42
|
|
|
43
43
|
export function buildEnrollmentIdempotencyKey(userId: string, mallId: string, formVersion: string): string {
|
|
@@ -145,7 +145,7 @@ export function createMemberActions(
|
|
|
145
145
|
text: '授权未完成,已切换手动填写模式',
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
//
|
|
148
|
+
// 下沉物首个消费方:authCode → alipay.user.info.share
|
|
149
149
|
let profile: StoredAuthorizationProfile;
|
|
150
150
|
try {
|
|
151
151
|
const authorized = await createAlipayUserAuthorization().authorizeUserProfile(authCode);
|
|
@@ -167,7 +167,7 @@ export function createMemberActions(
|
|
|
167
167
|
text: '授权资料获取失败,已切换手动填写模式',
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
//
|
|
170
|
+
// PII 最小集 TTL 30min 暂存(enroll 时 consume 取走 = 用后即删)
|
|
171
171
|
await state.put(MEMBER_PROFILE_NAMESPACE, userId, profile, PROFILE_TTL_MS);
|
|
172
172
|
return {
|
|
173
173
|
card: buildFormCard({
|
|
@@ -222,7 +222,7 @@ export function createMemberActions(
|
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
// 身份解析:授权 profile(consume 取走 =
|
|
225
|
+
// 身份解析:授权 profile(consume 取走 = 用后即删)可信 mobile 强制覆盖
|
|
226
226
|
const authorized = (await state.consume<StoredAuthorizationProfile>(MEMBER_PROFILE_NAMESPACE, userId)) ?? undefined;
|
|
227
227
|
const manualMobile = fieldValues.mobile ?? '';
|
|
228
228
|
const mobile = authorized?.mobile ?? manualMobile;
|
|
@@ -234,8 +234,8 @@ export function createMemberActions(
|
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
//
|
|
238
|
-
// 评审修复(015 #5):payload 存 sha256
|
|
237
|
+
// 幂等(同键重入返回首果)
|
|
238
|
+
// 评审修复(015 #5):payload 存 sha256 摘要——幂等占位不再驻留明文手机号(单一暂存位语义)
|
|
239
239
|
const idempotencyKey = buildEnrollmentIdempotencyKey(userId, mallIdOf(reqCtx), ENROLLMENT_FORM_VERSION);
|
|
240
240
|
const payloadTag = createHash('sha256').update(`${identity}:${mobile}`).digest('hex').slice(0, 16);
|
|
241
241
|
const acquired = await enrollmentIdempotency.tryAcquire(idempotencyKey, payloadTag);
|
|
@@ -294,7 +294,7 @@ export function createMemberActions(
|
|
|
294
294
|
},
|
|
295
295
|
},
|
|
296
296
|
|
|
297
|
-
/** 4.
|
|
297
|
+
/** 4. 入会状态显式刷新(无自动轮询) */
|
|
298
298
|
queryEnrollmentStatus: {
|
|
299
299
|
actionId: 'member.query-enrollment-status',
|
|
300
300
|
moduleId: 'member',
|
|
@@ -307,7 +307,7 @@ export function createMemberActions(
|
|
|
307
307
|
const userId = reqCtx?.identity?.userId ?? '';
|
|
308
308
|
const member = await resolveMember(reqCtx);
|
|
309
309
|
if (!userId || !attemptRef || !member) {
|
|
310
|
-
//
|
|
310
|
+
// 原地更新:防御分支返回可见失败态(原 text 在 update 路径无消费者)
|
|
311
311
|
return {
|
|
312
312
|
update: {
|
|
313
313
|
data: {
|
package/src/server/handler.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* member handler
|
|
2
|
+
* member handler;015:写动作拆至 action.ts,此处只保留意图路径出卡)。
|
|
3
3
|
* - 查积分/信息/卡 → 出对应卡(LLM 路径走同名工具)。
|
|
4
4
|
* - 会员偏好长期记忆(017 PRD):三项声明式 intent → ctx.memory 保存 + continueWith 续接导购。
|
|
5
5
|
* - 上下文统一化:userId 来源 = 运行身份(reqCtx.identity.userId,handler 第四参)——
|
|
6
|
-
* 旧 payload.userId
|
|
6
|
+
* 旧 payload.userId 是模型注入面,已删除;偏好分支同经 reqCtx 显式读取。
|
|
7
7
|
*/
|
|
8
8
|
import type { HandlerDefinition, ServerContext } from '@tbox.cn/app-agent-sdk-server';
|
|
9
9
|
import {
|
|
@@ -33,7 +33,7 @@ export function createMemberHandler(ctx: ServerContext): HandlerDefinition {
|
|
|
33
33
|
return {
|
|
34
34
|
id: 'member',
|
|
35
35
|
// match:'exact':偏好按钮发出的是固定整句值(member-card-summary 按钮组),
|
|
36
|
-
// 整句全等命中——不入 BM25 词袋(相似查询「2
|
|
36
|
+
// 整句全等命中——不入 BM25 词袋(相似查询「2楼有啥美食可逛」曾被词袋误吞)
|
|
37
37
|
intents: [{ patterns: [...MEMBER_PREFERENCE_VALUES], match: 'exact' }],
|
|
38
38
|
handle: async (action, payload, _ctx, reqCtx) => {
|
|
39
39
|
if (action === 'intent') {
|
package/src/server/index.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* module-member 服务端入口(双端自注册闭环——见模块 AGENTS.md 与 INTEGRATION.md)。
|
|
3
|
+
* 职责:会员账户/资料/卡面/权益积分/入会五槽解析 + 查询工具四枚 + 门禁卡与入会表单卡六枚 +
|
|
4
|
+
* 会员门禁状态服务('member.status')与跨模块快览工厂('member.snapshot')。
|
|
5
|
+
* 入口约定:register 只注册不解析(resolveService 仅 handle/事件回调内);cards map 的
|
|
6
|
+
* key = meta.cardType;模块对象 satisfies ServerModule(禁类型标注——cards 泛化失效)。
|
|
7
|
+
*/
|
|
1
8
|
import type { ServerContext, ServerModule } from '@tbox.cn/app-agent-sdk-server';
|
|
2
9
|
import { loadModuleSkills, withCardEmissionHint, withEarlyExecution } from '@tbox.cn/app-agent-sdk-server';
|
|
3
10
|
import type { RequestContext } from '@tbox.cn/app-contracts';
|
|
@@ -57,7 +64,7 @@ const memberPorts = {
|
|
|
57
64
|
};
|
|
58
65
|
|
|
59
66
|
/** 工具实例顶层创建;每次 execute 解析当前请求的真实 C 端 Provider。
|
|
60
|
-
*
|
|
67
|
+
* (2026-09-01):出卡工具创建点单点 wrap(description 追加预告知句)——
|
|
61
68
|
* 注册即 wrapped 实例;CTA/表单卡承载操作入口带 actions 句。
|
|
62
69
|
* PR-2:三个纯查询工具(只读/幂等/execCtx 仅消费 requestContext)标注尽早执行
|
|
63
70
|
* 白名单——env TBOX_EARLY_TOOL_EXECUTION=1 时参数流完即预执行;缺省 off 零行为。 */
|
|
@@ -145,16 +152,16 @@ export const serverModule = {
|
|
|
145
152
|
ctx.cards.registerMap(cards);
|
|
146
153
|
ctx.handlers.register(createMemberHandler(ctx));
|
|
147
154
|
|
|
148
|
-
//
|
|
155
|
+
// 入会四动作(register 闭包 ctx——动作 execute 内经 enrollment 槽解析 + ctx.state PII 暂存)
|
|
149
156
|
const actions = createMemberActions(ctx, (reqCtx) => resolveMemberEnrollmentPort(reqCtx, ctx));
|
|
150
157
|
for (const action of Object.values(actions)) {
|
|
151
158
|
ctx.cardActions.register(action);
|
|
152
159
|
}
|
|
153
160
|
|
|
154
|
-
//
|
|
161
|
+
// 主体绑定(promotion acquire 消费;ctx.services 跨模块 resolveService)
|
|
155
162
|
ctx.services.register('member.subject-binding', createSubjectBinding(ctx));
|
|
156
163
|
|
|
157
|
-
// 会员快览工厂(member.snapshot
|
|
164
|
+
// 会员快览工厂(member.snapshot):首页联单面板跨模块消费面
|
|
158
165
|
// (账户/授权三态 + 积分 + 入会引导)。三槽组装——enrollment 槽 fail-soft
|
|
159
166
|
// (缺席不拖垮账户/积分主面);工厂运行期执行(注册期纯净铁律)。
|
|
160
167
|
ctx.services.register(
|
package/src/server/service.ts
CHANGED
|
@@ -20,13 +20,13 @@ import type {
|
|
|
20
20
|
} from '@tbox.cn/app-contracts-mall';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* MemberService
|
|
23
|
+
* MemberService:商圈会员完整实现(六 Port + 015 入会升级)。
|
|
24
24
|
* extends 契约 Port(保证满足消费方子集约束);完整接口只在本模块包内。
|
|
25
25
|
*/
|
|
26
26
|
/**
|
|
27
27
|
* InMemory 演示实现(仅供隔离单测;运行时注册与 Provider 解析不得使用)。
|
|
28
28
|
* 017 槽位原子化后非 Port 成员归位:getEnrollmentFormDefinition 已收编
|
|
29
|
-
* MemberEnrollmentPort optional
|
|
29
|
+
* MemberEnrollmentPort optional 方法;enrollUrl/loginUrl 为槽产物自由属性
|
|
30
30
|
* (enrollment/account 槽的类型视图见 ports.ts);audit 转 InMemory 私有观测成员。
|
|
31
31
|
*/
|
|
32
32
|
export interface MemberService
|
|
@@ -44,7 +44,7 @@ export interface MemberService
|
|
|
44
44
|
readonly loginUrl?: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
// Form 族归源 TIER1
|
|
47
|
+
// Form 族归源 TIER1(下沉:provider 出参与模块投影共用同一契约面)
|
|
48
48
|
export type {
|
|
49
49
|
MemberEnrollmentConsentDefinition,
|
|
50
50
|
MemberEnrollmentFormFieldDefinition,
|
|
@@ -196,7 +196,7 @@ export class InMemoryMemberService implements MemberService {
|
|
|
196
196
|
// ===== 6. MemberEnrollmentPort(015:授权预填 + 幂等 + pending 收口) =====
|
|
197
197
|
|
|
198
198
|
async enroll(input: MemberEnrollmentInput): Promise<MemberEnrollmentResult> {
|
|
199
|
-
// 幂等:同 idempotencyKey
|
|
199
|
+
// 幂等:同 idempotencyKey 重入返回首果(语义,模块顶层 IdempotencyStore 之上的双保险)
|
|
200
200
|
const existing = this.enrollmentAttempts.get(input.idempotencyKey);
|
|
201
201
|
if (existing) return existing.result;
|
|
202
202
|
|
package/src/server/tool.ts
CHANGED
|
@@ -276,7 +276,7 @@ export function createQueryMemberInfoTool(
|
|
|
276
276
|
const infoCard = {
|
|
277
277
|
cardType: 'member-info',
|
|
278
278
|
data: facts,
|
|
279
|
-
// note
|
|
279
|
+
// note 契约:账户态中文化 + 姓名要点
|
|
280
280
|
note: `会员账户(${memberStateLabel(facts.state)})${facts.displayName ? ` · ${facts.displayName}` : ''}`,
|
|
281
281
|
};
|
|
282
282
|
if (account.state !== 'active') {
|
|
@@ -463,7 +463,7 @@ export function createQueryEnrollmentFormTool(
|
|
|
463
463
|
const notEnrolled =
|
|
464
464
|
account.authState === 'authenticated' &&
|
|
465
465
|
(account.state === 'not_enrolled' || account.state === 'closed');
|
|
466
|
-
// getEnrollmentFormDefinition = Port optional
|
|
466
|
+
// getEnrollmentFormDefinition = Port optional 能力口(收编):无表单端点厂商可缺省,typeof 守卫降级
|
|
467
467
|
const definition =
|
|
468
468
|
notEnrolled && typeof enrollmentPort.getEnrollmentFormDefinition === 'function'
|
|
469
469
|
? await enrollmentPort.getEnrollmentFormDefinition(userId)
|
package/src/server/util.ts
CHANGED