@tbox.cn/app-provider-mock 0.4.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.
@@ -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,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> {
@@ -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 =
@@ -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,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "name": "provider-mock",
4
- "title": "Mock",
5
- "description": "全槽本地演示供给:免真实厂商接入的完整商圈演示",
3
+ "id": "provider-mock",
4
+ "name": "Mock",
5
+ "description": "全槽本地演示供给:零配置开箱(免传输/凭据/实例配置/集成配置)",
6
6
  "version": "0.1.0",
7
7
  "kind": "business",
8
8
  "risk": {
@@ -12,7 +12,11 @@
12
12
  "distribution": {
13
13
  "defaultMode": "codegen"
14
14
  },
15
- "contributes": {
15
+ "dependencies": {
16
+ "modules": []
17
+ },
18
+ "env": [],
19
+ "declare": {
16
20
  "handlers": [],
17
21
  "tools": [],
18
22
  "cards": [],
@@ -26,143 +30,122 @@
26
30
  "credentialType": "-",
27
31
  "local": true,
28
32
  "provider": "mock",
29
- "implementation": "mock-member@1",
30
- "configSchema": "schemas/member.config.json"
33
+ "implementation": "mock-member@1"
31
34
  },
32
35
  {
33
36
  "service": "member.profile",
34
37
  "credentialType": "-",
35
38
  "local": true,
36
39
  "provider": "mock",
37
- "implementation": "mock-member@1",
38
- "configSchema": "schemas/member.config.json"
40
+ "implementation": "mock-member@1"
39
41
  },
40
42
  {
41
43
  "service": "member.card",
42
44
  "credentialType": "-",
43
45
  "local": true,
44
46
  "provider": "mock",
45
- "implementation": "mock-member@1",
46
- "configSchema": "schemas/member.config.json"
47
+ "implementation": "mock-member@1"
47
48
  },
48
49
  {
49
50
  "service": "member.benefits",
50
51
  "credentialType": "-",
51
52
  "local": true,
52
53
  "provider": "mock",
53
- "implementation": "mock-member@1",
54
- "configSchema": "schemas/member.config.json"
54
+ "implementation": "mock-member@1"
55
55
  },
56
56
  {
57
57
  "service": "member.enrollment",
58
58
  "credentialType": "-",
59
59
  "local": true,
60
60
  "provider": "mock",
61
- "implementation": "mock-member@1",
62
- "configSchema": "schemas/member.config.json"
61
+ "implementation": "mock-member@1"
63
62
  },
64
63
  {
65
64
  "service": "parking.query",
66
65
  "credentialType": "-",
67
66
  "local": true,
68
67
  "provider": "mock",
69
- "implementation": "mock-parking@1",
70
- "configSchema": "schemas/parking.config.json"
68
+ "implementation": "mock-parking@1"
71
69
  },
72
70
  {
73
71
  "service": "parking.payment",
74
72
  "credentialType": "-",
75
73
  "local": true,
76
74
  "provider": "mock",
77
- "implementation": "mock-parking@1",
78
- "configSchema": "schemas/parking.config.json"
75
+ "implementation": "mock-parking@1"
79
76
  },
80
77
  {
81
78
  "service": "parking.vehicle",
82
79
  "credentialType": "-",
83
80
  "local": true,
84
81
  "provider": "mock",
85
- "implementation": "mock-parking@1",
86
- "configSchema": "schemas/parking.config.json"
82
+ "implementation": "mock-parking@1"
87
83
  },
88
84
  {
89
85
  "service": "promotion.offers",
90
86
  "credentialType": "-",
91
87
  "local": true,
92
88
  "provider": "mock",
93
- "implementation": "mock-promotion@1",
94
- "configSchema": "schemas/promotion.config.json"
89
+ "implementation": "mock-promotion@1"
95
90
  },
96
91
  {
97
92
  "service": "promotion.entitlements",
98
93
  "credentialType": "-",
99
94
  "local": true,
100
95
  "provider": "mock",
101
- "implementation": "mock-promotion@1",
102
- "configSchema": "schemas/promotion.config.json"
96
+ "implementation": "mock-promotion@1"
103
97
  },
104
98
  {
105
99
  "service": "promotion.activities",
106
100
  "credentialType": "-",
107
101
  "local": true,
108
102
  "provider": "mock",
109
- "implementation": "mock-promotion@1",
110
- "configSchema": "schemas/promotion.config.json"
103
+ "implementation": "mock-promotion@1"
111
104
  },
112
105
  {
113
106
  "service": "promotion.acquisition",
114
107
  "credentialType": "-",
115
108
  "local": true,
116
109
  "provider": "mock",
117
- "implementation": "mock-promotion@1",
118
- "configSchema": "schemas/promotion.config.json"
110
+ "implementation": "mock-promotion@1"
119
111
  },
120
112
  {
121
113
  "service": "shopping-guide.catalog",
122
114
  "credentialType": "-",
123
115
  "local": true,
124
116
  "provider": "mock",
125
- "implementation": "mock-shopping@1",
126
- "configSchema": "schemas/shopping.config.json"
117
+ "implementation": "mock-shopping@1"
127
118
  },
128
119
  {
129
120
  "service": "shopping-guide.shops",
130
121
  "credentialType": "-",
131
122
  "local": true,
132
123
  "provider": "mock",
133
- "implementation": "mock-shopping@1",
134
- "configSchema": "schemas/shopping.config.json"
124
+ "implementation": "mock-shopping@1"
135
125
  },
136
126
  {
137
127
  "service": "shopping-guide.categories",
138
128
  "credentialType": "-",
139
129
  "local": true,
140
130
  "provider": "mock",
141
- "implementation": "mock-shopping@1",
142
- "configSchema": "schemas/shopping.config.json"
131
+ "implementation": "mock-shopping@1"
143
132
  },
144
133
  {
145
134
  "service": "shopping-guide.directory",
146
135
  "credentialType": "-",
147
136
  "local": true,
148
137
  "provider": "mock",
149
- "implementation": "mock-shopping@1",
150
- "configSchema": "schemas/shopping.config.json"
138
+ "implementation": "mock-shopping@1"
151
139
  },
152
140
  {
153
141
  "service": "mall.info",
154
142
  "credentialType": "-",
155
143
  "local": true,
156
144
  "provider": "mock",
157
- "implementation": "mock-mall-info@1",
158
- "configSchema": "schemas/mall-info.config.json"
145
+ "implementation": "mock-mall-info@1"
159
146
  }
160
147
  ]
161
148
  },
162
- "services": []
163
- },
164
- "dependencies": {
165
- "modules": []
166
- },
167
- "env": []
149
+ "consumes": []
150
+ }
168
151
  }