@tbox.cn/app-provider-mock 0.4.0 → 0.6.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.
@@ -9,40 +9,38 @@
9
9
  * - mallId 形状守卫(/^[\w-]{1,32}$/):畸形 ID 直接返回 undefined(S4 DoS 防线——
10
10
  * 记录≠校验教训:请求形状断言在 provider adapter 单测锁死)
11
11
  * - fail-soft 契约恒满足:本实现无 IO,不可能失败——契约面与真实档保持一致
12
- * - config 消费:MALL_INFO_CFG_DEFAULTS 为契约单源(name 空串 = 动态别名回退;
13
- * 双锁测试 tests/config-schema.test.ts)
12
+ * - 演示常量零配置冻结:CFG 值 ≡ 0.4.0 缺省(2026-09-20 拆分——config 消费随
13
+ * provider-mocktest 迁出)
14
14
  */
15
- import { resolveConfig, type CfgDefaults } from './config';
16
15
  import type { MallInfo, MallInfoPort } from '@tbox.cn/app-contracts-mall';
17
- import type { ServiceAdapterFactory } from '@tbox.cn/app-sdk/server';
16
+ import type { ServiceAdapterFactory } from '@tbox.cn/app-agent-sdk-server';
18
17
 
19
18
  export const MOCK_MALL_INFO_PROVIDER = 'mock';
20
19
  export const MOCK_MALL_INFO_IMPL = 'mock-mall-info@1';
21
20
 
22
- /** config 契约单源(键集/缺省/整数约束;lat/lon 分式合法——不进 intKeys) */
23
- export const MALL_INFO_CFG_DEFAULTS = {
21
+ /** 演示常量(零配置冻结——0.5.0 起本包无 config 面;值 ≡ 0.4.0 缺省) */
22
+ const CFG = {
24
23
  name: '', // '' 哨兵 = 动态别名回退
25
24
  address: '示例商场地址(demo)',
26
25
  latitude: 30.0,
27
26
  longitude: 120.0,
28
- } as const satisfies CfgDefaults;
29
- export const MALL_INFO_CFG_INT_KEYS: readonly string[] = [];
27
+ } as const;
30
28
 
31
29
  /** mallId 形状守卫(防注入类字符;畸形 → undefined——与真实厂商 adapter 同规则) */
32
30
  const MALL_ID_RE = /^[\w-]{1,32}$/;
33
31
 
34
32
  /** mock mall.info adapter 工厂(对齐真实厂商 adapter 工厂形态) */
35
33
  export const mockMallInfoFactory: ServiceAdapterFactory = (input): MallInfoPort => {
36
- const cfg = resolveConfig(input.config, MALL_INFO_CFG_DEFAULTS, MALL_INFO_CFG_INT_KEYS);
34
+ void input; // 零配置开箱(2026-09-20 拆分):config 面随 provider-mocktest 迁出,签名保持 adapter 通用形态
37
35
  return {
38
36
  async getMallInfo(mallId: string): Promise<MallInfo | undefined> {
39
37
  if (!MALL_ID_RE.test(mallId)) return undefined;
40
38
  return {
41
39
  mallId,
42
- name: cfg.name !== '' ? cfg.name : `示例商场(${mallId})`,
43
- address: cfg.address,
44
- latitude: cfg.latitude,
45
- longitude: cfg.longitude,
40
+ name: CFG.name !== '' ? CFG.name : `示例商场(${mallId})`,
41
+ address: CFG.address,
42
+ latitude: CFG.latitude,
43
+ longitude: CFG.longitude,
46
44
  };
47
45
  },
48
46
  };
@@ -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,24 @@ 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;
40
+
41
+ /**
42
+ * 卡面演示素材(平台 CDN,厂商中立门禁不禁)。恒发 black 深卡:模块叠字配色按真实厂商
43
+ * 世代契约配对(金/蓝/银浅底深字、黑卡深底浅金),black+深底图是唯一在恢复后 CSS 下可读
44
+ * 的演示配对——gold 变体配深图会退回「深字压深底」不可读态。素材规格须随卡面世代契约走
45
+ * (1344×694 + 顶70/左右20/底26 透明边);重制落地前为 3:2 原图,embedded contain 下两侧
46
+ * 留白属过渡态。
47
+ */
48
+ const CARD_FACE_URL = 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*sdTfQ5NaRN8AAAAAgEAAAAgAegitAQ/fmt.webp';
42
49
 
43
50
  /**
44
51
  * Mock member 状态单源(模块级共享):factory 每请求新建实例,但状态必须跨实例共享——
@@ -97,18 +104,15 @@ export class MockMemberServiceImpl implements MockMemberService {
97
104
  /** 登录页深链(同上,可选透传素材;供未登录引导卡跳转)。 */
98
105
  readonly loginUrl: string;
99
106
 
100
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ MEMBER_CFG_DEFAULTS) */
101
- private readonly cfg: typeof MEMBER_CFG_DEFAULTS;
102
107
  /** 积分流水(金额随 initialPoints 派生——与余额同源) */
103
108
  private readonly usage: PointUsageRecord[];
104
109
 
105
110
  /** 默认访客(无种子):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;
111
+ constructor(initial: Record<string, number> = {}) {
112
+ this.enrollUrl = CFG.enrollUrl;
113
+ this.loginUrl = CFG.loginUrl;
110
114
  this.usage = [
111
- { usageRecordRef: 'demo:usage:1', title: '开卡礼', amount: `+${String(this.cfg.initialPoints)}`, usedAt: new Date().toISOString(), description: 'mock 演示流水' },
115
+ { usageRecordRef: 'demo:usage:1', title: '开卡礼', amount: `+${String(CFG.initialPoints)}`, usedAt: new Date().toISOString(), description: 'mock 演示流水' },
112
116
  ];
113
117
  for (const [userId, balance] of Object.entries(initial)) {
114
118
  mockMemberState.enrolled.add(userId);
@@ -127,22 +131,26 @@ export class MockMemberServiceImpl implements MockMemberService {
127
131
  }
128
132
 
129
133
  async getProfile(_userId: string): Promise<MemberProfileSnapshot> {
130
- return { labels: [{ labelRef: 'demo:label:1', name: this.cfg.memberName }], observedAt: new Date().toISOString() };
134
+ return { labels: [{ labelRef: 'demo:label:1', name: CFG.memberName }], observedAt: new Date().toISOString() };
131
135
  }
132
136
 
133
137
  async getCard(userId: string): Promise<MemberCardSnapshot | null> {
134
138
  if (!isMockMemberActive(userId)) return null;
135
139
  return {
136
140
  cardRef: `demo:card:${userId}`,
137
- cardDisplay: this.cfg.cardName,
141
+ cardDisplay: CFG.cardName,
138
142
  status: 'active',
139
- ...(this.cfg.levelName !== '' ? { levelName: this.cfg.levelName } : {}),
143
+ ...(CFG.levelName !== '' ? { levelName: CFG.levelName } : {}),
144
+ cardImageUrl: CARD_FACE_URL,
145
+ // 与真实 provider 同构的 dynamic face 数据(真实厂商集成亦恒发 presentation)——
146
+ // 模块运行时卡面渲染、CSS 档位配对都由该字段驱动,mock 缺发即运行时永无卡面图。
147
+ presentation: { variant: 'black', labelsEmbedded: true },
140
148
  observedAt: new Date().toISOString(),
141
149
  };
142
150
  }
143
151
 
144
152
  async queryPoints(userId: string): Promise<Points> {
145
- return { userId, balance: this.currentBalanceOf(userId), membershipLabel: this.cfg.cardName };
153
+ return { userId, balance: this.currentBalanceOf(userId), membershipLabel: CFG.cardName };
146
154
  }
147
155
 
148
156
  async getBenefits(userId: string): Promise<MemberBenefitsSnapshot> {
@@ -179,7 +187,7 @@ export class MockMemberServiceImpl implements MockMemberService {
179
187
  private currentBalanceOf(userId: string): number {
180
188
  const override = mockMemberState.balances.get(userId);
181
189
  if (override !== undefined) return override;
182
- return isMockMemberEnrolled(userId) ? this.cfg.initialPoints : 0;
190
+ return isMockMemberEnrolled(userId) ? CFG.initialPoints : 0;
183
191
  }
184
192
 
185
193
  async enroll(input: MemberEnrollmentInput): Promise<MemberEnrollmentResult> {
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { Router } from 'express';
16
16
  import type { Request, Response } from 'express';
17
- import { getRequestContext } from '@tbox.cn/app-sdk/server';
17
+ import { getRequestContext } from '@tbox.cn/app-agent-sdk-server';
18
18
  import { enrollMockMember, logoutMockMember } from './member';
19
19
 
20
20
  export type MockEnrollOutcome =
@@ -1,10 +1,14 @@
1
1
  /**
2
2
  * Mock parking 实现(provider-mock 自持——R3-1 裁决)。演示面最小集:报价/车辆/记录/
3
3
  * 综合信息/权益/寻车 + 三步支付链 mock 闭环(reconcile 恒 PAID 收口)。demo ref 恒
4
- * `demo:` 前缀,厂商中立;车牌未提供时以演示车(demo-plate)兜底。
5
- * config 消费:PARKING_CFG_DEFAULTS 为契约单源(fail-soft 快照;双锁测试 tests/config-schema.test.ts)。
4
+ * `demo:` 前缀,厂商中立。
5
+ * 车辆管理属人化:绑定按 登录身份(subjectId)×mallId 记入模块级共享 store(factory
6
+ * 每请求新建实例,状态必须跨实例共享——mockMemberState 先例);绑定序首辆 = 在场
7
+ * 演示位(parked 徽标与无线索查费扫描共用该语义)。写操作要求登录态(对齐真实厂商
8
+ * 「无令牌不可写」),读操作匿名降级为空车队;无车辆线索查费扫描属人车队,空车队
9
+ * 返回空(调用方引导绑定)。
10
+ * 演示常量零配置冻结:CFG 值 ≡ 0.4.0 缺省(2026-09-20 拆分——config 消费随 provider-mocktest 迁出)。
6
11
  */
7
- import { resolveConfig, type CfgDefaults } from './config';
8
12
  import type {
9
13
  ParkingBenefit,
10
14
  ParkingInfo,
@@ -23,8 +27,8 @@ export type MockParkingService = ParkingQueryPort & ParkingPaymentPort & Parking
23
27
 
24
28
  const now = () => new Date().toISOString();
25
29
 
26
- /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
27
- export const PARKING_CFG_DEFAULTS = {
30
+ /** 演示常量(零配置冻结——0.5.0 起本包无 config 面;值 ≡ 0.4.0 缺省) */
31
+ const CFG = {
28
32
  parkName: '示例停车场',
29
33
  feeName: '停车费(3 小时)',
30
34
  feeCents: 1500,
@@ -37,27 +41,38 @@ export const PARKING_CFG_DEFAULTS = {
37
41
  vehicleFloor: 'B1',
38
42
  vehicleZone: 'A 区',
39
43
  vehicleSpaceNo: 'A-128',
40
- } as const satisfies CfgDefaults;
41
- export const PARKING_CFG_INT_KEYS = ['feeCents', 'remainingSpaces', 'memberBenefitDiscountCents'];
44
+ } as const;
45
+
46
+ /** 每用户绑定上限(与客户端车辆卡添加按钮上限同值——防御纵深:动作直调路径) */
47
+ const MAX_BOUND_VEHICLES = 3;
48
+
49
+ /**
50
+ * 属人车辆绑定共享 store(模块级):factory 每请求新建实例,绑定须跨请求/跨实例可见
51
+ * (mockMemberState 先例)。键 = `${subjectId}\u0000${mallId}`;值 = 车队(数组插入序
52
+ * = 绑定序,首辆 = 在场演示位)。
53
+ */
54
+ const mockParkingState = {
55
+ vehicles: new Map<string, ParkingVehicle[]>(),
56
+ };
57
+
58
+ /** 测试复位(沿 __resetMockMemberState 先例——模块级共享状态可重置) */
59
+ export function __resetMockParkingState(): void {
60
+ mockParkingState.vehicles.clear();
61
+ }
42
62
 
43
63
  export class MockParkingServiceImpl implements MockParkingService {
44
- private vehicles = new Map<string, ParkingVehicle>();
45
64
  private records: ParkingPaymentRecord[];
46
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ PARKING_CFG_DEFAULTS) */
47
- private readonly cfg: typeof PARKING_CFG_DEFAULTS;
48
65
 
49
- constructor(mallId = 'mall-demo', config: unknown = {}) {
66
+ constructor(mallId = 'mall-demo') {
50
67
  this.mallId = mallId;
51
- void this.mallId;
52
- this.cfg = resolveConfig(config, PARKING_CFG_DEFAULTS, PARKING_CFG_INT_KEYS);
53
68
  this.records = [
54
69
  {
55
70
  recordRef: 'demo:record:1',
56
71
  plateNo: 'demo-plate',
57
- amountCents: this.cfg.feeCents,
72
+ amountCents: CFG.feeCents,
58
73
  paidAt: now(),
59
74
  status: 'PAID',
60
- parkName: this.cfg.parkName,
75
+ parkName: CFG.parkName,
61
76
  orderCompleted: true,
62
77
  },
63
78
  ];
@@ -72,10 +87,10 @@ export class MockParkingServiceImpl implements MockParkingService {
72
87
  */
73
88
  private benefits(): ParkingBenefit[] {
74
89
  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 });
90
+ if (CFG.memberBenefitEnabled) {
91
+ benefits.push({ benefitRef: 'demo:benefit:member-discount', title: '会员 95 折', description: 'mock 演示权益', kind: 'discount', autoSelected: true, estimatedDiscountCents: CFG.memberBenefitDiscountCents });
77
92
  }
78
- if (this.cfg.pointsBenefitEnabled) {
93
+ if (CFG.pointsBenefitEnabled) {
79
94
  benefits.push({ benefitRef: 'demo:benefit:points-offset', title: '积分抵 5 元', description: 'mock 演示权益', kind: 'points', autoSelected: false, estimatedDiscountCents: 500, requiredPoints: 500, previewPayableCents: 1000 });
80
95
  }
81
96
  return benefits;
@@ -87,26 +102,36 @@ export class MockParkingServiceImpl implements MockParkingService {
87
102
  plateNo,
88
103
  mallId: q.scope.mallId ?? 'demo',
89
104
  entryAt: now(),
90
- feeItems: [{ name: this.cfg.feeName, amountCents: this.cfg.feeCents }],
91
- totalCents: this.cfg.feeCents,
105
+ feeItems: [{ name: CFG.feeName, amountCents: CFG.feeCents }],
106
+ totalCents: CFG.feeCents,
92
107
  discountCents: 0,
93
- payableCents: this.cfg.feeCents,
108
+ payableCents: CFG.feeCents,
94
109
  appliedBenefits: [],
95
110
  revision: 1,
96
111
  paymentState: 'UNPAID',
97
112
  };
98
113
  }
99
114
 
100
- async queryFee(q: ParkingQueryContext, input: { plateNo?: string; vehicleRef?: string }): Promise<readonly QuoteSnapshot[]> {
101
- const plateNo = input.plateNo ?? (input.vehicleRef ? this.vehicles.get(input.vehicleRef)?.plateNo : undefined) ?? 'demo-plate';
102
- const quote = this.quote(q, plateNo);
103
- return quote ? [quote] : [];
115
+ async queryFee(
116
+ q: ParkingQueryContext,
117
+ input: { plateNo?: string; vehicleRef?: string; barcode?: string },
118
+ ): Promise<readonly QuoteSnapshot[]> {
119
+ // 显式线索照查(厂商语义:指定车牌/条码即查,本人绑定校验在工具层收口;条码按占位
120
+ // 车牌出报价——演示语义);vehicleRef 先在属人车队解析,未命中落无线索扫描。
121
+ const fleet = this.readFleet(q);
122
+ const plateNo = input.plateNo
123
+ ?? (input.vehicleRef ? fleet.find((v) => v.vehicleRef === input.vehicleRef)?.plateNo : undefined)
124
+ ?? input.barcode;
125
+ if (plateNo) return [this.quote(q, plateNo)];
126
+ // 无车辆线索(「我的车」语义):扫描属人绑定车队——在场演示位(首辆)出报价;空车队返回空。
127
+ const inSite = fleet[0];
128
+ return inSite ? [this.quote(q, inSite.plateNo)] : [];
104
129
  }
105
130
 
106
- async listVehicles(): Promise<{ bound: readonly ParkingVehicle[] }> {
107
- // mock 有报价即视作在场:demo 里第一辆车恒有报价,其余按未入场
108
- const list = [...this.vehicles.values()];
109
- return { bound: list.map((v, i) => ({ ...v, parked: i === 0 })) };
131
+ async listVehicles(q: ParkingQueryContext): Promise<{ bound: readonly ParkingVehicle[] }> {
132
+ // 在场演示位:绑定序首辆恒在位(parked 徽标与无线索查费扫描共用该语义),其余按未入场
133
+ const bound = this.readFleet(q).map((v, i) => (i === 0 ? { ...v, parked: true } : v));
134
+ return { bound };
110
135
  }
111
136
 
112
137
  async listPaymentRecords(_q: ParkingQueryContext, page: number, pageSize: number): Promise<ParkingRecordPage> {
@@ -122,7 +147,7 @@ export class MockParkingServiceImpl implements MockParkingService {
122
147
  }
123
148
 
124
149
  async getInvoiceSettings(): Promise<{ parkingInvoiceEnabled: boolean }> {
125
- return { parkingInvoiceEnabled: this.cfg.invoiceEnabled };
150
+ return { parkingInvoiceEnabled: CFG.invoiceEnabled };
126
151
  }
127
152
 
128
153
  async listInvoiceableOrders(_q: ParkingQueryContext, page: number, pageSize: number): Promise<ParkingRecordPage> {
@@ -134,11 +159,11 @@ export class MockParkingServiceImpl implements MockParkingService {
134
159
  async queryParkingInfo(_q: ParkingQueryContext, kind: ParkingInfo['kind']): Promise<ParkingInfo> {
135
160
  return {
136
161
  kind,
137
- title: this.cfg.parkName,
162
+ title: CFG.parkName,
138
163
  entries: [
139
- { label: '剩余车位', value: String(this.cfg.remainingSpaces) },
140
- { label: '首小时费率', value: this.cfg.firstHourRate },
141
- { label: '会员权益', value: this.cfg.memberBenefitEnabled ? '会员 95 折' : '—' },
164
+ { label: '剩余车位', value: String(CFG.remainingSpaces) },
165
+ { label: '首小时费率', value: CFG.firstHourRate },
166
+ { label: '会员权益', value: CFG.memberBenefitEnabled ? '会员 95 折' : '—' },
142
167
  ],
143
168
  };
144
169
  }
@@ -148,7 +173,7 @@ export class MockParkingServiceImpl implements MockParkingService {
148
173
  }
149
174
 
150
175
  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 米' };
176
+ return { floorName: CFG.vehicleFloor, zoneName: CFG.vehicleZone, spaceNo: CFG.vehicleSpaceNo, walkingRoute: '电梯左转 50 米' };
152
177
  }
153
178
 
154
179
  // ===== 支付三步链(mock:reconcile 恒 PAID 收口) =====
@@ -158,7 +183,7 @@ export class MockParkingServiceImpl implements MockParkingService {
158
183
  }
159
184
 
160
185
  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 };
186
+ return { orderInfo: 'demo-order-info', channel: '50', payableFeeCents: CFG.feeCents };
162
187
  }
163
188
 
164
189
  async getPaymentSign(_q: ParkingQueryContext, _paymentRef: string): Promise<{ orderInfo: string }> {
@@ -191,21 +216,41 @@ export class MockParkingServiceImpl implements MockParkingService {
191
216
  }
192
217
  }
193
218
 
194
- // ===== 车辆管理 =====
219
+ // ===== 车辆管理(属人共享 store;写需登录态、读匿名降级——见文件头) =====
195
220
 
196
- async bindVehicle(_q: ParkingQueryContext, plateNo: string): Promise<ParkingVehicle> {
197
- const vehicle = { vehicleRef: `demo:vehicle:${plateNo}`, plateNo, boundAt: now() };
198
- this.vehicles.set(vehicle.vehicleRef, vehicle);
221
+ /** 车队读视图:匿名(未登录)降级为空车队——开箱首页/面板不因未登录报错 */
222
+ private readFleet(q: ParkingQueryContext): ParkingVehicle[] {
223
+ if (!q.subjectId) return [];
224
+ return mockParkingState.vehicles.get(`${q.subjectId}\u0000${q.scope?.mallId || this.mallId}`) ?? [];
225
+ }
226
+
227
+ /** 车队写句柄:无登录态显性报错(对齐真实厂商「无令牌不可写」,不造匿名共享桶) */
228
+ private writeFleet(q: ParkingQueryContext): ParkingVehicle[] {
229
+ if (!q.subjectId) throw new Error('mock:缺少用户身份,无法操作绑定车辆');
230
+ const key = `${q.subjectId}\u0000${q.scope?.mallId || this.mallId}`;
231
+ let fleet = mockParkingState.vehicles.get(key);
232
+ if (!fleet) mockParkingState.vehicles.set(key, (fleet = []));
233
+ return fleet;
234
+ }
235
+
236
+ async bindVehicle(q: ParkingQueryContext, plateNo: string): Promise<ParkingVehicle> {
237
+ const fleet = this.writeFleet(q);
238
+ const plate = plateNo.trim();
239
+ const existing = fleet.find((v) => v.plateNo.toUpperCase() === plate.toUpperCase());
240
+ if (existing) return existing; // 幂等:重复绑定返回既有,不重复计数
241
+ if (fleet.length >= MAX_BOUND_VEHICLES) throw new Error('最多绑定 3 辆车');
242
+ const vehicle: ParkingVehicle = { vehicleRef: `demo:vehicle:${plate}`, plateNo: plate, boundAt: now() };
243
+ fleet.push(vehicle);
199
244
  return vehicle;
200
245
  }
201
246
 
202
- async unbindVehicle(_q: ParkingQueryContext, input: { plateNo?: string; vehicleRef?: string }): Promise<void> {
203
- if (input.vehicleRef) this.vehicles.delete(input.vehicleRef);
204
- else if (input.plateNo) {
205
- for (const [ref, v] of this.vehicles) {
206
- if (v.plateNo === input.plateNo) this.vehicles.delete(ref);
207
- }
208
- }
247
+ async unbindVehicle(q: ParkingQueryContext, input: { plateNo?: string; vehicleRef?: string }): Promise<void> {
248
+ const fleet = this.writeFleet(q);
249
+ const index = fleet.findIndex((v) =>
250
+ input.vehicleRef ? v.vehicleRef === input.vehicleRef : v.plateNo === input.plateNo,
251
+ );
252
+ if (index < 0) throw new Error('未找到要解绑的车牌');
253
+ fleet.splice(index, 1);
209
254
  }
210
255
 
211
256
  }
@@ -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,22 @@ 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 演示)',
59
+ imageUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*LHeBTp64HUYAAAAARLAAAAgAegitAQ/fmt.webp',
64
60
  tags: ['通用'],
65
- validity: { start: ts, end: inDays(this.cfg.couponValidityDays) },
66
- facets: [{ kind: 'COUPON', discountType: 'AMOUNT', value: this.cfg.couponValueCents, thresholdCents: this.cfg.couponThresholdCents }],
61
+ validity: { start: ts, end: inDays(CFG.couponValidityDays) },
62
+ facets: [{ kind: 'COUPON', discountType: 'AMOUNT', value: CFG.couponValueCents, thresholdCents: CFG.couponThresholdCents }],
67
63
  availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: ts, authoritative: false },
68
64
  participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '领取', description: '点击领取后自动存入卡包' }] },
69
65
  };
@@ -72,18 +68,19 @@ export class MockPromotionServiceImpl implements MockPromotionService {
72
68
  offerType: 'GROUPON',
73
69
  title: '餐饮双人套餐 5 折',
74
70
  subtitle: 'mock 演示团购',
71
+ imageUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*GzryQrxX2WEAAAAATYAAAAgAegitAQ/fmt.webp',
75
72
  tags: ['餐饮'],
76
73
  validity: { start: ts, end: inDays(15) },
77
74
  facets: [{ kind: 'GROUPON', requiredParticipants: 2 }],
78
75
  availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: ts, authoritative: false },
79
76
  participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '购买', description: '按团购价下单' }] },
80
77
  };
81
- this.offers = this.cfg.grouponEnabled ? [couponOffer, grouponOffer] : [couponOffer];
78
+ this.offers = CFG.grouponEnabled ? [couponOffer, grouponOffer] : [couponOffer];
82
79
  this.entitlements = [
83
80
  {
84
81
  entitlementRef: 'demo:entitlement:1',
85
82
  offerRef: 'demo:coupon:1001',
86
- title: this.cfg.couponTitle,
83
+ title: CFG.couponTitle,
87
84
  entitlementType: 'COUPON',
88
85
  status: 'EFFECTIVE',
89
86
  codeMasked: 'DEMO-****-1001',
@@ -92,8 +89,9 @@ export class MockPromotionServiceImpl implements MockPromotionService {
92
89
  this.activities = [
93
90
  {
94
91
  activityRef: 'demo:activity:3001',
95
- title: this.cfg.activityTitle,
92
+ title: CFG.activityTitle,
96
93
  subtitle: 'mock 演示活动',
94
+ coverUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*DIRTQ6CBBC0AAAAAgEAAAAgAegitAQ/fmt.webp',
97
95
  registrationRequired: false,
98
96
  offerRefs: ['demo:coupon:1001'],
99
97
  },
@@ -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,
@@ -35,6 +34,7 @@ interface ShopSeed {
35
34
  merchantId: string;
36
35
  name: string;
37
36
  brand?: string;
37
+ logoUrl?: string;
38
38
  businessCategories: string[];
39
39
  unitName: string;
40
40
  status: { code: 'enabled' | 'disabled'; label: string };
@@ -50,15 +50,14 @@ interface DemoBuilding {
50
50
  floors: DemoFloor[];
51
51
  }
52
52
 
53
- /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
54
- export const SHOPPING_CFG_DEFAULTS = {
53
+ /** 演示常量(零配置冻结——0.5.0 起本包无 config 面;值 ≡ 0.4.0 缺省) */
54
+ const CFG = {
55
55
  extraShopName: '', // '' = 不追加门店(空串 = 缺省/不生效语义)
56
56
  extraShopCategory: '餐饮',
57
57
  extraShopFloor: '3 楼',
58
58
  extraShopUnit: '304',
59
59
  extraShopOpen: true,
60
- } as const satisfies CfgDefaults;
61
- export const SHOPPING_CFG_INT_KEYS: readonly string[] = [];
60
+ } as const;
62
61
  /** 楼层白名单(消费点守卫 + schema enum 同值——防手编楼层不在目录内) */
63
62
  export const SHOPPING_FLOORS = ['B1', '1 楼', '2 楼', '3 楼', '4 楼'] as const;
64
63
 
@@ -70,38 +69,38 @@ const DEMO_BUILDINGS: DemoBuilding[] = [
70
69
  {
71
70
  floorName: 'B1',
72
71
  shops: [
73
- { merchantId: 'demo-shop-1001', name: '永辉超市', businessCategories: ['超市'], unitName: 'B1-01', status: { code: 'enabled', label: '营业中' } },
72
+ { merchantId: 'demo-shop-1001', name: '永辉超市', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*5Y45SqtTrvcAAAAAQCAAAAgAegitAQ/original', businessCategories: ['超市'], unitName: 'B1-01', status: { code: 'enabled', label: '营业中' } },
74
73
  ],
75
74
  },
76
75
  {
77
76
  floorName: '1 楼',
78
77
  shops: [
79
- { merchantId: 'demo-shop-1002', name: '星巴克', businessCategories: ['餐饮'], unitName: '101', status: { code: 'enabled', label: '营业中' } },
80
- { merchantId: 'demo-shop-1003', name: '周大福', businessCategories: ['珠宝'], unitName: '102', status: { code: 'enabled', label: '营业中' } },
81
- { merchantId: 'demo-shop-1004', name: '屈臣氏', businessCategories: ['美妆'], unitName: '103', status: { code: 'enabled', label: '营业中' } },
78
+ { merchantId: 'demo-shop-1002', name: '星巴克', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*pa08SZMqBNYAAAAAQEAAAAgAegitAQ/original', businessCategories: ['餐饮'], unitName: '101', status: { code: 'enabled', label: '营业中' } },
79
+ { merchantId: 'demo-shop-1003', name: '周大福', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*WKXJTqR3BwQAAAAAQCAAAAgAegitAQ/original', businessCategories: ['珠宝'], unitName: '102', status: { code: 'enabled', label: '营业中' } },
80
+ { merchantId: 'demo-shop-1004', name: '屈臣氏', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*c7cRQIe83NYAAAAAQFAAAAgAegitAQ/original', businessCategories: ['美妆'], unitName: '103', status: { code: 'enabled', label: '营业中' } },
82
81
  ],
83
82
  },
84
83
  {
85
84
  floorName: '2 楼',
86
85
  shops: [
87
- { merchantId: 'demo-shop-1005', name: '华为', businessCategories: ['数码'], unitName: '201', status: { code: 'enabled', label: '营业中' } },
88
- { merchantId: 'demo-shop-1006', name: '小米', businessCategories: ['数码'], unitName: '202', status: { code: 'enabled', label: '营业中' } },
86
+ { merchantId: 'demo-shop-1005', name: '华为', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*BrpxQ6dwGj0AAAAAQCAAAAgAegitAQ/original', businessCategories: ['数码'], unitName: '201', status: { code: 'enabled', label: '营业中' } },
87
+ { merchantId: 'demo-shop-1006', name: '小米', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*6FBqSYVXFDEAAAAAMrAAAAgAegitAQ/original', businessCategories: ['数码'], unitName: '202', status: { code: 'enabled', label: '营业中' } },
89
88
  ],
90
89
  },
91
90
  {
92
91
  floorName: '3 楼',
93
92
  shops: [
94
- { merchantId: 'demo-shop-1007', name: 'NIKE 专卖店', brand: 'NIKE', businessCategories: ['运动服饰'], unitName: '301', status: { code: 'enabled', label: '营业中' } },
95
- { merchantId: 'demo-shop-1008', name: 'NIKE 跑步体验店', brand: 'NIKE', businessCategories: ['运动服饰'], unitName: '302', status: { code: 'enabled', label: '营业中' } },
96
- { merchantId: 'demo-shop-1009', name: '安踏', businessCategories: ['运动服饰'], unitName: '303', status: { code: 'enabled', label: '营业中' } },
93
+ { merchantId: 'demo-shop-1007', name: 'NIKE 专卖店', brand: 'NIKE', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*dFmuSKEMDwIAAAAAQCAAAAgAegitAQ/original', businessCategories: ['运动服饰'], unitName: '301', status: { code: 'enabled', label: '营业中' } },
94
+ { merchantId: 'demo-shop-1008', name: 'NIKE 跑步体验店', brand: 'NIKE', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*dFmuSKEMDwIAAAAAQCAAAAgAegitAQ/original', businessCategories: ['运动服饰'], unitName: '302', status: { code: 'enabled', label: '营业中' } },
95
+ { merchantId: 'demo-shop-1009', name: '安踏', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*edsgTpDq0GUAAAAAQDAAAAgAegitAQ/original', businessCategories: ['运动服饰'], unitName: '303', status: { code: 'enabled', label: '营业中' } },
97
96
  ],
98
97
  },
99
98
  {
100
99
  floorName: '4 楼',
101
100
  shops: [
102
- { merchantId: 'demo-shop-1010', name: '海底捞', businessCategories: ['餐饮'], unitName: '401', status: { code: 'enabled', label: '营业中' } },
103
- { merchantId: 'demo-shop-1011', name: '外婆家', businessCategories: ['餐饮'], unitName: '402', status: { code: 'enabled', label: '营业中' } },
104
- { merchantId: 'demo-shop-1012', name: '西贝莜面村', businessCategories: ['餐饮'], unitName: '403', status: { code: 'disabled', label: '休息中' } },
101
+ { merchantId: 'demo-shop-1010', name: '海底捞', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*18hVSI5dg6EAAAAAQCAAAAgAegitAQ/original', businessCategories: ['餐饮'], unitName: '401', status: { code: 'enabled', label: '营业中' } },
102
+ { merchantId: 'demo-shop-1011', name: '外婆家', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*_uaLSZqH8-4AAAAASOAAAAgAegitAQ/fmt.webp', businessCategories: ['餐饮'], unitName: '402', status: { code: 'enabled', label: '营业中' } },
103
+ { merchantId: 'demo-shop-1012', name: '西贝莜面村', logoUrl: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*9X-US6dZvcIAAAAARAAAAAgAegitAQ/fmt.webp', businessCategories: ['餐饮'], unitName: '403', status: { code: 'disabled', label: '休息中' } },
105
104
  ],
106
105
  },
107
106
  ],
@@ -117,6 +116,7 @@ function flattenShops(buildings: readonly DemoBuilding[]): ShopRecord[] {
117
116
  merchantId: seed.merchantId,
118
117
  name: seed.name,
119
118
  ...(seed.brand ? { brand: seed.brand } : {}),
119
+ ...(seed.logoUrl ? { logoUrl: seed.logoUrl } : {}),
120
120
  businessCategories: [...seed.businessCategories],
121
121
  location: {
122
122
  displayText: [b.buildingName, f.floorName, seed.unitName].filter(Boolean).join(' '),
@@ -151,14 +151,11 @@ function toFloorRecord(floor: DemoFloor): FloorRecord {
151
151
 
152
152
  export class MockShoppingServiceImpl implements
153
153
  CatalogQueryPort, ShopDirectoryQueryPort, CommercialCategoryQueryPort, MallDirectoryQueryPort {
154
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ SHOPPING_CFG_DEFAULTS) */
155
- private readonly cfg: typeof SHOPPING_CFG_DEFAULTS;
156
154
  private readonly buildings: readonly DemoBuilding[];
157
155
  private readonly shops: ShopRecord[];
158
156
  private readonly categories: CategoryRecord[];
159
157
 
160
- constructor(seed: readonly DemoBuilding[] = DEMO_BUILDINGS, config: unknown = {}) {
161
- this.cfg = resolveConfig(config, SHOPPING_CFG_DEFAULTS, SHOPPING_CFG_INT_KEYS);
158
+ constructor(seed: readonly DemoBuilding[] = DEMO_BUILDINGS) {
162
159
  const withExtra = this.withExtraShop(seed);
163
160
  this.buildings = withExtra;
164
161
  this.shops = flattenShops(withExtra);
@@ -167,17 +164,17 @@ export class MockShoppingServiceImpl implements
167
164
 
168
165
  /** extraShopName 非空 → 指定楼层追加演示门店(名称 trim 判空 + 楼层白名单回退——消费点守卫) */
169
166
  private withExtraShop(seed: readonly DemoBuilding[]): readonly DemoBuilding[] {
170
- const name = this.cfg.extraShopName.trim();
167
+ const name = CFG.extraShopName.trim();
171
168
  if (!name) return seed;
172
- const floor = (SHOPPING_FLOORS as readonly string[]).includes(this.cfg.extraShopFloor)
173
- ? this.cfg.extraShopFloor
169
+ const floor = (SHOPPING_FLOORS as readonly string[]).includes(CFG.extraShopFloor)
170
+ ? CFG.extraShopFloor
174
171
  : '3 楼';
175
172
  const extra: ShopSeed = {
176
173
  merchantId: 'demo-shop-1013',
177
174
  name,
178
- businessCategories: [this.cfg.extraShopCategory],
179
- unitName: this.cfg.extraShopUnit,
180
- status: this.cfg.extraShopOpen ? { code: 'enabled', label: '营业中' } : { code: 'disabled', label: '休息中' },
175
+ businessCategories: [CFG.extraShopCategory],
176
+ unitName: CFG.extraShopUnit,
177
+ status: CFG.extraShopOpen ? { code: 'enabled', label: '营业中' } : { code: 'disabled', label: '休息中' },
181
178
  };
182
179
  return seed.map((b) => ({
183
180
  ...b,