@tbox.cn/app-provider-mock 0.3.0 → 0.5.0

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.
@@ -2,9 +2,8 @@
2
2
  * Mock member 实现(provider-mock 自持——R3-1 裁决:provider 不得依赖业务模块,实现自持
3
3
  * 而非包装 module-member InMemory)。演示面最小集:开户/卡面/积分/流水/入会闭环
4
4
  * (demo ref 恒 `demo:` 前缀,厂商中立)。
5
- * config 消费:MEMBER_CFG_DEFAULTS 为契约单源(fail-soft 快照;双锁测试 tests/config-schema.test.ts)。
5
+ * 演示常量零配置冻结:CFG 值 ≡ 0.4.0 缺省(2026-09-20 拆分——config 消费随 provider-mocktest 迁出)。
6
6
  */
7
- import { resolveConfig, type CfgDefaults } from './config';
8
7
  import type {
9
8
  MemberAccountPort,
10
9
  MemberAccountSnapshot,
@@ -29,16 +28,15 @@ export type MockMemberService = MemberAccountPort &
29
28
  MemberBenefitsPort &
30
29
  MemberEnrollmentPort;
31
30
 
32
- /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
33
- export const MEMBER_CFG_DEFAULTS = {
31
+ /** 演示常量(零配置冻结——0.5.0 起本包无 config 面;值 ≡ 0.4.0 缺省) */
32
+ const CFG = {
34
33
  memberName: '示例会员',
35
34
  cardName: '示例会员卡',
36
35
  levelName: '', // '' 哨兵 = 不展示等级区(MemberCardSnapshot.levelName 可选位)
37
36
  initialPoints: 300,
38
37
  enrollUrl: 'alipays://platformapi/startapp?appId=demo&page=v/index/index',
39
38
  loginUrl: 'alipays://platformapi/startapp?appId=demo&page=v/login/index',
40
- } as const satisfies CfgDefaults;
41
- export const MEMBER_CFG_INT_KEYS = ['initialPoints'];
39
+ } as const;
42
40
 
43
41
  /**
44
42
  * Mock member 状态单源(模块级共享):factory 每请求新建实例,但状态必须跨实例共享——
@@ -97,18 +95,15 @@ export class MockMemberServiceImpl implements MockMemberService {
97
95
  /** 登录页深链(同上,可选透传素材;供未登录引导卡跳转)。 */
98
96
  readonly loginUrl: string;
99
97
 
100
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ MEMBER_CFG_DEFAULTS) */
101
- private readonly cfg: typeof MEMBER_CFG_DEFAULTS;
102
98
  /** 积分流水(金额随 initialPoints 派生——与余额同源) */
103
99
  private readonly usage: PointUsageRecord[];
104
100
 
105
101
  /** 默认访客(无种子):demo-user 初始 not_enrolled,经入会闭环翻为 active */
106
- constructor(initial: Record<string, number> = {}, config: unknown = {}) {
107
- this.cfg = resolveConfig(config, MEMBER_CFG_DEFAULTS, MEMBER_CFG_INT_KEYS);
108
- this.enrollUrl = this.cfg.enrollUrl;
109
- this.loginUrl = this.cfg.loginUrl;
102
+ constructor(initial: Record<string, number> = {}) {
103
+ this.enrollUrl = CFG.enrollUrl;
104
+ this.loginUrl = CFG.loginUrl;
110
105
  this.usage = [
111
- { usageRecordRef: 'demo:usage:1', title: '开卡礼', amount: `+${String(this.cfg.initialPoints)}`, usedAt: new Date().toISOString(), description: 'mock 演示流水' },
106
+ { usageRecordRef: 'demo:usage:1', title: '开卡礼', amount: `+${String(CFG.initialPoints)}`, usedAt: new Date().toISOString(), description: 'mock 演示流水' },
112
107
  ];
113
108
  for (const [userId, balance] of Object.entries(initial)) {
114
109
  mockMemberState.enrolled.add(userId);
@@ -127,22 +122,22 @@ export class MockMemberServiceImpl implements MockMemberService {
127
122
  }
128
123
 
129
124
  async getProfile(_userId: string): Promise<MemberProfileSnapshot> {
130
- return { labels: [{ labelRef: 'demo:label:1', name: this.cfg.memberName }], observedAt: new Date().toISOString() };
125
+ return { labels: [{ labelRef: 'demo:label:1', name: CFG.memberName }], observedAt: new Date().toISOString() };
131
126
  }
132
127
 
133
128
  async getCard(userId: string): Promise<MemberCardSnapshot | null> {
134
129
  if (!isMockMemberActive(userId)) return null;
135
130
  return {
136
131
  cardRef: `demo:card:${userId}`,
137
- cardDisplay: this.cfg.cardName,
132
+ cardDisplay: CFG.cardName,
138
133
  status: 'active',
139
- ...(this.cfg.levelName !== '' ? { levelName: this.cfg.levelName } : {}),
134
+ ...(CFG.levelName !== '' ? { levelName: CFG.levelName } : {}),
140
135
  observedAt: new Date().toISOString(),
141
136
  };
142
137
  }
143
138
 
144
139
  async queryPoints(userId: string): Promise<Points> {
145
- return { userId, balance: this.currentBalanceOf(userId), membershipLabel: this.cfg.cardName };
140
+ return { userId, balance: this.currentBalanceOf(userId), membershipLabel: CFG.cardName };
146
141
  }
147
142
 
148
143
  async getBenefits(userId: string): Promise<MemberBenefitsSnapshot> {
@@ -179,7 +174,7 @@ export class MockMemberServiceImpl implements MockMemberService {
179
174
  private currentBalanceOf(userId: string): number {
180
175
  const override = mockMemberState.balances.get(userId);
181
176
  if (override !== undefined) return override;
182
- return isMockMemberEnrolled(userId) ? this.cfg.initialPoints : 0;
177
+ return isMockMemberEnrolled(userId) ? CFG.initialPoints : 0;
183
178
  }
184
179
 
185
180
  async enroll(input: MemberEnrollmentInput): Promise<MemberEnrollmentResult> {
@@ -2,10 +2,11 @@
2
2
  * Mock 入会落地点路由(入会体验闭环 C5):POST /api/m/provider-mock/demo/member-enroll。
3
3
  *
4
4
  * 容器 mock-enrollment 页(dev 脚手架)与 curl 联调共用:
5
- * - body `{userId?}`:缺省 MOCK_SHELL_USER_ID(mock 页无参——与真实 gate 无参协议面一致;
6
- * curl 可定向翻 dev_h5 等浏览器 dev 用户造会员态调试)。
5
+ * - body `{userId?}`:缺省 = 调用方 token 身份(统一登录改造 T11 收口——固定 demo-user
6
+ * 缺省退役,IDOR 写任意用户面收窄为「已鉴权调用方声明 demo 主体」;gate 页经 query
7
+ * 透传 H5 身份,curl 可定向翻指定访客造会员态调试)。
7
8
  * - 幂等(Set.add / 余额保守写);NODE_ENV=production → 503(provider-mock 不进生产装配,双保险)。
8
- * - 经全局 /api 鉴权(AUTH_MODE 缺省 required)——调用方须携 dev-login 令牌;
9
+ * - 经全局 /api 鉴权(AUTH_MODE 缺省 required)——调用方须携登录令牌;
9
10
  * 匿名写显式拒绝(不随 AUTH_MODE 放宽)。
10
11
  * - doctor naked-write-route:/demo 前缀在白名单内(webhook/upload/demo/run)。
11
12
  *
@@ -13,18 +14,18 @@
13
14
  */
14
15
  import { Router } from 'express';
15
16
  import type { Request, Response } from 'express';
16
- import { getRequestContext } from '@tbox.cn/app-sdk/server';
17
- import { MOCK_SHELL_USER_ID, enrollMockMember, logoutMockMember } from './member';
17
+ import { getRequestContext } from '@tbox.cn/app-agent-sdk-server';
18
+ import { enrollMockMember, logoutMockMember } from './member';
18
19
 
19
20
  export type MockEnrollOutcome =
20
21
  | { status: 200; body: { state: 'active'; memberRef: string } }
21
22
  | { status: 401; body: { error: string } }
22
23
  | { status: 503; body: { error: string } };
23
24
 
24
- /** 纯决策:production 拒 503 → 匿名/无身份拒 401 → 翻状态返 200(幂等) */
25
+ /** 纯决策:production 拒 503 → 匿名/无身份拒 401 → 翻状态返 200(幂等;主体缺省 = 调用方) */
25
26
  export function resolveMockEnroll(input: {
26
27
  body?: unknown;
27
- identity?: { source: string } | null;
28
+ identity?: { source: string; userId?: string } | null;
28
29
  nodeEnv?: string;
29
30
  }): MockEnrollOutcome {
30
31
  if ((input.nodeEnv ?? process.env.NODE_ENV) === 'production') {
@@ -36,7 +37,7 @@ export function resolveMockEnroll(input: {
36
37
  const body = (input.body ?? {}) as { userId?: unknown };
37
38
  const userId = typeof body.userId === 'string' && body.userId.trim()
38
39
  ? body.userId.trim()
39
- : MOCK_SHELL_USER_ID;
40
+ : (input.identity.userId ?? `guest_${Date.now()}`);
40
41
  enrollMockMember(userId);
41
42
  return { status: 200, body: { state: 'active', memberRef: `demo:member:${userId}` } };
42
43
  }
@@ -46,10 +47,10 @@ export type MockLogoutOutcome =
46
47
  | { status: 401; body: { error: string } }
47
48
  | { status: 503; body: { error: string } };
48
49
 
49
- /** 纯决策:production 拒 503 → 匿名/无身份拒 401 → 翻登出态返 200(与 enroll 同形) */
50
+ /** 纯决策:production 拒 503 → 匿名/无身份拒 401 → 翻登出态返 200(与 enroll 同形;主体缺省 = 调用方) */
50
51
  export function resolveMockLogout(input: {
51
52
  body?: unknown;
52
- identity?: { source: string } | null;
53
+ identity?: { source: string; userId?: string } | null;
53
54
  nodeEnv?: string;
54
55
  }): MockLogoutOutcome {
55
56
  if ((input.nodeEnv ?? process.env.NODE_ENV) === 'production') {
@@ -61,7 +62,7 @@ export function resolveMockLogout(input: {
61
62
  const body = (input.body ?? {}) as { userId?: unknown };
62
63
  const userId = typeof body.userId === 'string' && body.userId.trim()
63
64
  ? body.userId.trim()
64
- : MOCK_SHELL_USER_ID;
65
+ : (input.identity.userId ?? `guest_${Date.now()}`);
65
66
  logoutMockMember(userId);
66
67
  return { status: 200, body: { state: 'logged_out' } };
67
68
  }
@@ -2,9 +2,8 @@
2
2
  * Mock parking 实现(provider-mock 自持——R3-1 裁决)。演示面最小集:报价/车辆/记录/
3
3
  * 综合信息/权益/寻车 + 三步支付链 mock 闭环(reconcile 恒 PAID 收口)。demo ref 恒
4
4
  * `demo:` 前缀,厂商中立;车牌未提供时以演示车(demo-plate)兜底。
5
- * config 消费:PARKING_CFG_DEFAULTS 为契约单源(fail-soft 快照;双锁测试 tests/config-schema.test.ts)。
5
+ * 演示常量零配置冻结:CFG 值 ≡ 0.4.0 缺省(2026-09-20 拆分——config 消费随 provider-mocktest 迁出)。
6
6
  */
7
- import { resolveConfig, type CfgDefaults } from './config';
8
7
  import type {
9
8
  ParkingBenefit,
10
9
  ParkingInfo,
@@ -23,8 +22,8 @@ export type MockParkingService = ParkingQueryPort & ParkingPaymentPort & Parking
23
22
 
24
23
  const now = () => new Date().toISOString();
25
24
 
26
- /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
27
- export const PARKING_CFG_DEFAULTS = {
25
+ /** 演示常量(零配置冻结——0.5.0 起本包无 config 面;值 ≡ 0.4.0 缺省) */
26
+ const CFG = {
28
27
  parkName: '示例停车场',
29
28
  feeName: '停车费(3 小时)',
30
29
  feeCents: 1500,
@@ -37,27 +36,23 @@ export const PARKING_CFG_DEFAULTS = {
37
36
  vehicleFloor: 'B1',
38
37
  vehicleZone: 'A 区',
39
38
  vehicleSpaceNo: 'A-128',
40
- } as const satisfies CfgDefaults;
41
- export const PARKING_CFG_INT_KEYS = ['feeCents', 'remainingSpaces', 'memberBenefitDiscountCents'];
39
+ } as const;
42
40
 
43
41
  export class MockParkingServiceImpl implements MockParkingService {
44
42
  private vehicles = new Map<string, ParkingVehicle>();
45
43
  private records: ParkingPaymentRecord[];
46
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ PARKING_CFG_DEFAULTS) */
47
- private readonly cfg: typeof PARKING_CFG_DEFAULTS;
48
44
 
49
- constructor(mallId = 'mall-demo', config: unknown = {}) {
45
+ constructor(mallId = 'mall-demo') {
50
46
  this.mallId = mallId;
51
47
  void this.mallId;
52
- this.cfg = resolveConfig(config, PARKING_CFG_DEFAULTS, PARKING_CFG_INT_KEYS);
53
48
  this.records = [
54
49
  {
55
50
  recordRef: 'demo:record:1',
56
51
  plateNo: 'demo-plate',
57
- amountCents: this.cfg.feeCents,
52
+ amountCents: CFG.feeCents,
58
53
  paidAt: now(),
59
54
  status: 'PAID',
60
- parkName: this.cfg.parkName,
55
+ parkName: CFG.parkName,
61
56
  orderCompleted: true,
62
57
  },
63
58
  ];
@@ -72,10 +67,10 @@ export class MockParkingServiceImpl implements MockParkingService {
72
67
  */
73
68
  private benefits(): ParkingBenefit[] {
74
69
  const benefits: ParkingBenefit[] = [];
75
- if (this.cfg.memberBenefitEnabled) {
76
- benefits.push({ benefitRef: 'demo:benefit:member-discount', title: '会员 95 折', description: 'mock 演示权益', kind: 'discount', autoSelected: true, estimatedDiscountCents: this.cfg.memberBenefitDiscountCents });
70
+ if (CFG.memberBenefitEnabled) {
71
+ benefits.push({ benefitRef: 'demo:benefit:member-discount', title: '会员 95 折', description: 'mock 演示权益', kind: 'discount', autoSelected: true, estimatedDiscountCents: CFG.memberBenefitDiscountCents });
77
72
  }
78
- if (this.cfg.pointsBenefitEnabled) {
73
+ if (CFG.pointsBenefitEnabled) {
79
74
  benefits.push({ benefitRef: 'demo:benefit:points-offset', title: '积分抵 5 元', description: 'mock 演示权益', kind: 'points', autoSelected: false, estimatedDiscountCents: 500, requiredPoints: 500, previewPayableCents: 1000 });
80
75
  }
81
76
  return benefits;
@@ -87,10 +82,10 @@ export class MockParkingServiceImpl implements MockParkingService {
87
82
  plateNo,
88
83
  mallId: q.scope.mallId ?? 'demo',
89
84
  entryAt: now(),
90
- feeItems: [{ name: this.cfg.feeName, amountCents: this.cfg.feeCents }],
91
- totalCents: this.cfg.feeCents,
85
+ feeItems: [{ name: CFG.feeName, amountCents: CFG.feeCents }],
86
+ totalCents: CFG.feeCents,
92
87
  discountCents: 0,
93
- payableCents: this.cfg.feeCents,
88
+ payableCents: CFG.feeCents,
94
89
  appliedBenefits: [],
95
90
  revision: 1,
96
91
  paymentState: 'UNPAID',
@@ -122,7 +117,7 @@ export class MockParkingServiceImpl implements MockParkingService {
122
117
  }
123
118
 
124
119
  async getInvoiceSettings(): Promise<{ parkingInvoiceEnabled: boolean }> {
125
- return { parkingInvoiceEnabled: this.cfg.invoiceEnabled };
120
+ return { parkingInvoiceEnabled: CFG.invoiceEnabled };
126
121
  }
127
122
 
128
123
  async listInvoiceableOrders(_q: ParkingQueryContext, page: number, pageSize: number): Promise<ParkingRecordPage> {
@@ -134,11 +129,11 @@ export class MockParkingServiceImpl implements MockParkingService {
134
129
  async queryParkingInfo(_q: ParkingQueryContext, kind: ParkingInfo['kind']): Promise<ParkingInfo> {
135
130
  return {
136
131
  kind,
137
- title: this.cfg.parkName,
132
+ title: CFG.parkName,
138
133
  entries: [
139
- { label: '剩余车位', value: String(this.cfg.remainingSpaces) },
140
- { label: '首小时费率', value: this.cfg.firstHourRate },
141
- { label: '会员权益', value: this.cfg.memberBenefitEnabled ? '会员 95 折' : '—' },
134
+ { label: '剩余车位', value: String(CFG.remainingSpaces) },
135
+ { label: '首小时费率', value: CFG.firstHourRate },
136
+ { label: '会员权益', value: CFG.memberBenefitEnabled ? '会员 95 折' : '—' },
142
137
  ],
143
138
  };
144
139
  }
@@ -148,7 +143,7 @@ export class MockParkingServiceImpl implements MockParkingService {
148
143
  }
149
144
 
150
145
  async locateVehicle(_q: ParkingQueryContext, _plateNo: string): Promise<ParkingLocation | null> {
151
- return { floorName: this.cfg.vehicleFloor, zoneName: this.cfg.vehicleZone, spaceNo: this.cfg.vehicleSpaceNo, walkingRoute: '电梯左转 50 米' };
146
+ return { floorName: CFG.vehicleFloor, zoneName: CFG.vehicleZone, spaceNo: CFG.vehicleSpaceNo, walkingRoute: '电梯左转 50 米' };
152
147
  }
153
148
 
154
149
  // ===== 支付三步链(mock:reconcile 恒 PAID 收口) =====
@@ -158,7 +153,7 @@ export class MockParkingServiceImpl implements MockParkingService {
158
153
  }
159
154
 
160
155
  async getOrderInfo(_q: ParkingQueryContext, _paymentRef: string): Promise<{ orderInfo?: string; channel: string; payableFeeCents: number | undefined }> {
161
- return { orderInfo: 'demo-order-info', channel: '50', payableFeeCents: this.cfg.feeCents };
156
+ return { orderInfo: 'demo-order-info', channel: '50', payableFeeCents: CFG.feeCents };
162
157
  }
163
158
 
164
159
  async getPaymentSign(_q: ParkingQueryContext, _paymentRef: string): Promise<{ orderInfo: string }> {
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Mock promotion 实现(provider-mock 自持——R3-1 裁决)。演示面最小集:搜索/精查/推荐/
3
3
  * 资产列表/活动列表/领取闭环(acquire 恒 SUCCEEDED)。demo ref 恒 `demo:` 前缀,厂商中立。
4
- * config 消费:PROMOTION_CFG_DEFAULTS 为契约单源(fail-soft 快照;双锁测试 tests/config-schema.test.ts)。
4
+ * 演示常量零配置冻结:CFG 值 ≡ 0.4.0 缺省(2026-09-20 拆分——config 消费随 provider-mocktest 迁出)。
5
5
  */
6
- import { resolveConfig, type CfgDefaults } from './config';
7
6
  import type {
8
7
  PromotionOffer,
9
8
  PromotionOfferPage,
@@ -29,16 +28,15 @@ export type MockPromotionService = PromotionOfferQueryPort &
29
28
  const now = () => new Date().toISOString();
30
29
  const inDays = (d: number) => new Date(Date.now() + d * 86400_000).toISOString();
31
30
 
32
- /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
33
- export const PROMOTION_CFG_DEFAULTS = {
31
+ /** 演示常量(零配置冻结——0.5.0 起本包无 config 面;值 ≡ 0.4.0 缺省) */
32
+ const CFG = {
34
33
  couponTitle: '满 100 减 20 元券',
35
34
  couponValueCents: 2000,
36
35
  couponThresholdCents: 10000,
37
36
  couponValidityDays: 30,
38
37
  grouponEnabled: true,
39
38
  activityTitle: '示例商场周年庆',
40
- } as const satisfies CfgDefaults;
41
- export const PROMOTION_CFG_INT_KEYS = ['couponValueCents', 'couponThresholdCents', 'couponValidityDays'];
39
+ } as const;
42
40
 
43
41
  const emptyPage = (): PromotionOfferPage & PromotionEntitlementPage & PromotionActivityPage => ({
44
42
  items: [],
@@ -46,24 +44,21 @@ const emptyPage = (): PromotionOfferPage & PromotionEntitlementPage & PromotionA
46
44
  });
47
45
 
48
46
  export class MockPromotionServiceImpl implements MockPromotionService {
49
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ PROMOTION_CFG_DEFAULTS) */
50
- private readonly cfg: typeof PROMOTION_CFG_DEFAULTS;
51
47
  /** 供/资产/活动三表(构造期按 cfg 构建——请求级实例,成本可忽略) */
52
48
  private readonly offers: PromotionOffer[];
53
49
  private readonly entitlements: PromotionEntitlement[];
54
50
  private readonly activities: PromotionActivity[];
55
51
 
56
- constructor(config: unknown = {}) {
57
- this.cfg = resolveConfig(config, PROMOTION_CFG_DEFAULTS, PROMOTION_CFG_INT_KEYS);
52
+ constructor() {
58
53
  const ts = now();
59
54
  const couponOffer: PromotionOffer = {
60
55
  offerRef: 'demo:coupon:1001',
61
56
  offerType: 'COUPON',
62
- title: this.cfg.couponTitle,
57
+ title: CFG.couponTitle,
63
58
  subtitle: '全场通用(mock 演示)',
64
59
  tags: ['通用'],
65
- validity: { start: ts, end: inDays(this.cfg.couponValidityDays) },
66
- facets: [{ kind: 'COUPON', discountType: 'AMOUNT', value: this.cfg.couponValueCents, thresholdCents: this.cfg.couponThresholdCents }],
60
+ validity: { start: ts, end: inDays(CFG.couponValidityDays) },
61
+ facets: [{ kind: 'COUPON', discountType: 'AMOUNT', value: CFG.couponValueCents, thresholdCents: CFG.couponThresholdCents }],
67
62
  availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: ts, authoritative: false },
68
63
  participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '领取', description: '点击领取后自动存入卡包' }] },
69
64
  };
@@ -78,12 +73,12 @@ export class MockPromotionServiceImpl implements MockPromotionService {
78
73
  availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: ts, authoritative: false },
79
74
  participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '购买', description: '按团购价下单' }] },
80
75
  };
81
- this.offers = this.cfg.grouponEnabled ? [couponOffer, grouponOffer] : [couponOffer];
76
+ this.offers = CFG.grouponEnabled ? [couponOffer, grouponOffer] : [couponOffer];
82
77
  this.entitlements = [
83
78
  {
84
79
  entitlementRef: 'demo:entitlement:1',
85
80
  offerRef: 'demo:coupon:1001',
86
- title: this.cfg.couponTitle,
81
+ title: CFG.couponTitle,
87
82
  entitlementType: 'COUPON',
88
83
  status: 'EFFECTIVE',
89
84
  codeMasked: 'DEMO-****-1001',
@@ -92,7 +87,7 @@ export class MockPromotionServiceImpl implements MockPromotionService {
92
87
  this.activities = [
93
88
  {
94
89
  activityRef: 'demo:activity:3001',
95
- title: this.cfg.activityTitle,
90
+ title: CFG.activityTitle,
96
91
  subtitle: 'mock 演示活动',
97
92
  registrationRequired: false,
98
93
  offerRefs: ['demo:coupon:1001'],
@@ -10,9 +10,8 @@
10
10
  * - merchantId 连字符格式(demo-shop-NNNN):LLM 从卡片 value 提取友好;getShop 入参 trim。
11
11
  * - catalog 空实现(对齐真实档 C 端):演示面不覆盖商品目录,门店链路为演示重点。
12
12
  * - 构造器接受 seed(默认 DEMO_BUILDINGS):测试可注入定制数据。
13
- * - config 消费:SHOPPING_CFG_DEFAULTS 为契约单源(fail-soft 快照;extraShop* 追加演示门店)。
13
+ * - 演示常量零配置冻结:CFG 值 ≡ 0.4.0 缺省(2026-09-20 拆分——config 消费随 provider-mocktest 迁出)。
14
14
  */
15
- import { resolveConfig, type CfgDefaults } from './config';
16
15
  import type {
17
16
  CatalogQueryPort,
18
17
  CategoryRecord,
@@ -50,15 +49,14 @@ interface DemoBuilding {
50
49
  floors: DemoFloor[];
51
50
  }
52
51
 
53
- /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
54
- export const SHOPPING_CFG_DEFAULTS = {
52
+ /** 演示常量(零配置冻结——0.5.0 起本包无 config 面;值 ≡ 0.4.0 缺省) */
53
+ const CFG = {
55
54
  extraShopName: '', // '' = 不追加门店(空串 = 缺省/不生效语义)
56
55
  extraShopCategory: '餐饮',
57
56
  extraShopFloor: '3 楼',
58
57
  extraShopUnit: '304',
59
58
  extraShopOpen: true,
60
- } as const satisfies CfgDefaults;
61
- export const SHOPPING_CFG_INT_KEYS: readonly string[] = [];
59
+ } as const;
62
60
  /** 楼层白名单(消费点守卫 + schema enum 同值——防手编楼层不在目录内) */
63
61
  export const SHOPPING_FLOORS = ['B1', '1 楼', '2 楼', '3 楼', '4 楼'] as const;
64
62
 
@@ -151,14 +149,11 @@ function toFloorRecord(floor: DemoFloor): FloorRecord {
151
149
 
152
150
  export class MockShoppingServiceImpl implements
153
151
  CatalogQueryPort, ShopDirectoryQueryPort, CommercialCategoryQueryPort, MallDirectoryQueryPort {
154
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ SHOPPING_CFG_DEFAULTS) */
155
- private readonly cfg: typeof SHOPPING_CFG_DEFAULTS;
156
152
  private readonly buildings: readonly DemoBuilding[];
157
153
  private readonly shops: ShopRecord[];
158
154
  private readonly categories: CategoryRecord[];
159
155
 
160
- constructor(seed: readonly DemoBuilding[] = DEMO_BUILDINGS, config: unknown = {}) {
161
- this.cfg = resolveConfig(config, SHOPPING_CFG_DEFAULTS, SHOPPING_CFG_INT_KEYS);
156
+ constructor(seed: readonly DemoBuilding[] = DEMO_BUILDINGS) {
162
157
  const withExtra = this.withExtraShop(seed);
163
158
  this.buildings = withExtra;
164
159
  this.shops = flattenShops(withExtra);
@@ -167,17 +162,17 @@ export class MockShoppingServiceImpl implements
167
162
 
168
163
  /** extraShopName 非空 → 指定楼层追加演示门店(名称 trim 判空 + 楼层白名单回退——消费点守卫) */
169
164
  private withExtraShop(seed: readonly DemoBuilding[]): readonly DemoBuilding[] {
170
- const name = this.cfg.extraShopName.trim();
165
+ const name = CFG.extraShopName.trim();
171
166
  if (!name) return seed;
172
- const floor = (SHOPPING_FLOORS as readonly string[]).includes(this.cfg.extraShopFloor)
173
- ? this.cfg.extraShopFloor
167
+ const floor = (SHOPPING_FLOORS as readonly string[]).includes(CFG.extraShopFloor)
168
+ ? CFG.extraShopFloor
174
169
  : '3 楼';
175
170
  const extra: ShopSeed = {
176
171
  merchantId: 'demo-shop-1013',
177
172
  name,
178
- businessCategories: [this.cfg.extraShopCategory],
179
- unitName: this.cfg.extraShopUnit,
180
- status: this.cfg.extraShopOpen ? { code: 'enabled', label: '营业中' } : { code: 'disabled', label: '休息中' },
173
+ businessCategories: [CFG.extraShopCategory],
174
+ unitName: CFG.extraShopUnit,
175
+ status: CFG.extraShopOpen ? { code: 'enabled', label: '营业中' } : { code: 'disabled', label: '休息中' },
181
176
  };
182
177
  return seed.map((b) => ({
183
178
  ...b,
package/tbox.module.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "name": "provider-mock",
3
+ "id": "provider-mock",
4
+ "name": "Mock",
5
+ "description": "全槽本地演示供给:零配置开箱(免传输/凭据/实例配置/集成配置)",
4
6
  "version": "0.1.0",
5
7
  "kind": "business",
6
8
  "risk": {
@@ -10,7 +12,11 @@
10
12
  "distribution": {
11
13
  "defaultMode": "codegen"
12
14
  },
13
- "contributes": {
15
+ "dependencies": {
16
+ "modules": []
17
+ },
18
+ "env": [],
19
+ "declare": {
14
20
  "handlers": [],
15
21
  "tools": [],
16
22
  "cards": [],
@@ -24,143 +30,122 @@
24
30
  "credentialType": "-",
25
31
  "local": true,
26
32
  "provider": "mock",
27
- "implementation": "mock-member@1",
28
- "configSchema": "schemas/member.config.json"
33
+ "implementation": "mock-member@1"
29
34
  },
30
35
  {
31
36
  "service": "member.profile",
32
37
  "credentialType": "-",
33
38
  "local": true,
34
39
  "provider": "mock",
35
- "implementation": "mock-member@1",
36
- "configSchema": "schemas/member.config.json"
40
+ "implementation": "mock-member@1"
37
41
  },
38
42
  {
39
43
  "service": "member.card",
40
44
  "credentialType": "-",
41
45
  "local": true,
42
46
  "provider": "mock",
43
- "implementation": "mock-member@1",
44
- "configSchema": "schemas/member.config.json"
47
+ "implementation": "mock-member@1"
45
48
  },
46
49
  {
47
50
  "service": "member.benefits",
48
51
  "credentialType": "-",
49
52
  "local": true,
50
53
  "provider": "mock",
51
- "implementation": "mock-member@1",
52
- "configSchema": "schemas/member.config.json"
54
+ "implementation": "mock-member@1"
53
55
  },
54
56
  {
55
57
  "service": "member.enrollment",
56
58
  "credentialType": "-",
57
59
  "local": true,
58
60
  "provider": "mock",
59
- "implementation": "mock-member@1",
60
- "configSchema": "schemas/member.config.json"
61
+ "implementation": "mock-member@1"
61
62
  },
62
63
  {
63
64
  "service": "parking.query",
64
65
  "credentialType": "-",
65
66
  "local": true,
66
67
  "provider": "mock",
67
- "implementation": "mock-parking@1",
68
- "configSchema": "schemas/parking.config.json"
68
+ "implementation": "mock-parking@1"
69
69
  },
70
70
  {
71
71
  "service": "parking.payment",
72
72
  "credentialType": "-",
73
73
  "local": true,
74
74
  "provider": "mock",
75
- "implementation": "mock-parking@1",
76
- "configSchema": "schemas/parking.config.json"
75
+ "implementation": "mock-parking@1"
77
76
  },
78
77
  {
79
78
  "service": "parking.vehicle",
80
79
  "credentialType": "-",
81
80
  "local": true,
82
81
  "provider": "mock",
83
- "implementation": "mock-parking@1",
84
- "configSchema": "schemas/parking.config.json"
82
+ "implementation": "mock-parking@1"
85
83
  },
86
84
  {
87
85
  "service": "promotion.offers",
88
86
  "credentialType": "-",
89
87
  "local": true,
90
88
  "provider": "mock",
91
- "implementation": "mock-promotion@1",
92
- "configSchema": "schemas/promotion.config.json"
89
+ "implementation": "mock-promotion@1"
93
90
  },
94
91
  {
95
92
  "service": "promotion.entitlements",
96
93
  "credentialType": "-",
97
94
  "local": true,
98
95
  "provider": "mock",
99
- "implementation": "mock-promotion@1",
100
- "configSchema": "schemas/promotion.config.json"
96
+ "implementation": "mock-promotion@1"
101
97
  },
102
98
  {
103
99
  "service": "promotion.activities",
104
100
  "credentialType": "-",
105
101
  "local": true,
106
102
  "provider": "mock",
107
- "implementation": "mock-promotion@1",
108
- "configSchema": "schemas/promotion.config.json"
103
+ "implementation": "mock-promotion@1"
109
104
  },
110
105
  {
111
106
  "service": "promotion.acquisition",
112
107
  "credentialType": "-",
113
108
  "local": true,
114
109
  "provider": "mock",
115
- "implementation": "mock-promotion@1",
116
- "configSchema": "schemas/promotion.config.json"
110
+ "implementation": "mock-promotion@1"
117
111
  },
118
112
  {
119
113
  "service": "shopping-guide.catalog",
120
114
  "credentialType": "-",
121
115
  "local": true,
122
116
  "provider": "mock",
123
- "implementation": "mock-shopping@1",
124
- "configSchema": "schemas/shopping.config.json"
117
+ "implementation": "mock-shopping@1"
125
118
  },
126
119
  {
127
120
  "service": "shopping-guide.shops",
128
121
  "credentialType": "-",
129
122
  "local": true,
130
123
  "provider": "mock",
131
- "implementation": "mock-shopping@1",
132
- "configSchema": "schemas/shopping.config.json"
124
+ "implementation": "mock-shopping@1"
133
125
  },
134
126
  {
135
127
  "service": "shopping-guide.categories",
136
128
  "credentialType": "-",
137
129
  "local": true,
138
130
  "provider": "mock",
139
- "implementation": "mock-shopping@1",
140
- "configSchema": "schemas/shopping.config.json"
131
+ "implementation": "mock-shopping@1"
141
132
  },
142
133
  {
143
134
  "service": "shopping-guide.directory",
144
135
  "credentialType": "-",
145
136
  "local": true,
146
137
  "provider": "mock",
147
- "implementation": "mock-shopping@1",
148
- "configSchema": "schemas/shopping.config.json"
138
+ "implementation": "mock-shopping@1"
149
139
  },
150
140
  {
151
141
  "service": "mall.info",
152
142
  "credentialType": "-",
153
143
  "local": true,
154
144
  "provider": "mock",
155
- "implementation": "mock-mall-info@1",
156
- "configSchema": "schemas/mall-info.config.json"
145
+ "implementation": "mock-mall-info@1"
157
146
  }
158
147
  ]
159
148
  },
160
- "services": []
161
- },
162
- "dependencies": {
163
- "modules": []
164
- },
165
- "env": []
149
+ "consumes": []
150
+ }
166
151
  }