@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.
@@ -2,20 +2,8 @@
2
2
  import { randomBytes } from "crypto";
3
3
  import { readLoginMallId } from "@tbox.cn/app-contracts-mall";
4
4
 
5
- // src/server/config.ts
6
- function resolveConfig(raw, defaults, intKeys = []) {
7
- const src = raw && typeof raw === "object" ? raw : {};
8
- const out = {};
9
- for (const [key, fallback] of Object.entries(defaults)) {
10
- const value = src[key];
11
- const ok = typeof value === typeof fallback && (typeof value !== "number" || Number.isFinite(value) && (!intKeys.includes(key) || Number.isInteger(value))) && (typeof value !== "string" || value !== "");
12
- out[key] = ok ? value : fallback;
13
- }
14
- return out;
15
- }
16
-
17
5
  // src/server/member.ts
18
- var MEMBER_CFG_DEFAULTS = {
6
+ var CFG = {
19
7
  memberName: "\u793A\u4F8B\u4F1A\u5458",
20
8
  cardName: "\u793A\u4F8B\u4F1A\u5458\u5361",
21
9
  levelName: "",
@@ -24,7 +12,7 @@ var MEMBER_CFG_DEFAULTS = {
24
12
  enrollUrl: "alipays://platformapi/startapp?appId=demo&page=v/index/index",
25
13
  loginUrl: "alipays://platformapi/startapp?appId=demo&page=v/login/index"
26
14
  };
27
- var MEMBER_CFG_INT_KEYS = ["initialPoints"];
15
+ var CARD_FACE_URL = "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*sdTfQ5NaRN8AAAAAgEAAAAgAegitAQ/fmt.webp";
28
16
  var mockMemberState = {
29
17
  enrolled: /* @__PURE__ */ new Set(),
30
18
  balances: /* @__PURE__ */ new Map(),
@@ -62,17 +50,14 @@ var MockMemberServiceImpl = class {
62
50
  enrollUrl;
63
51
  /** 登录页深链(同上,可选透传素材;供未登录引导卡跳转)。 */
64
52
  loginUrl;
65
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ MEMBER_CFG_DEFAULTS) */
66
- cfg;
67
53
  /** 积分流水(金额随 initialPoints 派生——与余额同源) */
68
54
  usage;
69
55
  /** 默认访客(无种子):demo-user 初始 not_enrolled,经入会闭环翻为 active */
70
- constructor(initial = {}, config = {}) {
71
- this.cfg = resolveConfig(config, MEMBER_CFG_DEFAULTS, MEMBER_CFG_INT_KEYS);
72
- this.enrollUrl = this.cfg.enrollUrl;
73
- this.loginUrl = this.cfg.loginUrl;
56
+ constructor(initial = {}) {
57
+ this.enrollUrl = CFG.enrollUrl;
58
+ this.loginUrl = CFG.loginUrl;
74
59
  this.usage = [
75
- { usageRecordRef: "demo:usage:1", title: "\u5F00\u5361\u793C", amount: `+${String(this.cfg.initialPoints)}`, usedAt: (/* @__PURE__ */ new Date()).toISOString(), description: "mock \u6F14\u793A\u6D41\u6C34" }
60
+ { usageRecordRef: "demo:usage:1", title: "\u5F00\u5361\u793C", amount: `+${String(CFG.initialPoints)}`, usedAt: (/* @__PURE__ */ new Date()).toISOString(), description: "mock \u6F14\u793A\u6D41\u6C34" }
76
61
  ];
77
62
  for (const [userId, balance] of Object.entries(initial)) {
78
63
  mockMemberState.enrolled.add(userId);
@@ -89,20 +74,24 @@ var MockMemberServiceImpl = class {
89
74
  };
90
75
  }
91
76
  async getProfile(_userId) {
92
- return { labels: [{ labelRef: "demo:label:1", name: this.cfg.memberName }], observedAt: (/* @__PURE__ */ new Date()).toISOString() };
77
+ return { labels: [{ labelRef: "demo:label:1", name: CFG.memberName }], observedAt: (/* @__PURE__ */ new Date()).toISOString() };
93
78
  }
94
79
  async getCard(userId) {
95
80
  if (!isMockMemberActive(userId)) return null;
96
81
  return {
97
82
  cardRef: `demo:card:${userId}`,
98
- cardDisplay: this.cfg.cardName,
83
+ cardDisplay: CFG.cardName,
99
84
  status: "active",
100
- ...this.cfg.levelName !== "" ? { levelName: this.cfg.levelName } : {},
85
+ ...CFG.levelName !== "" ? { levelName: CFG.levelName } : {},
86
+ cardImageUrl: CARD_FACE_URL,
87
+ // 与真实 provider 同构的 dynamic face 数据(真实厂商集成亦恒发 presentation)——
88
+ // 模块运行时卡面渲染、CSS 档位配对都由该字段驱动,mock 缺发即运行时永无卡面图。
89
+ presentation: { variant: "black", labelsEmbedded: true },
101
90
  observedAt: (/* @__PURE__ */ new Date()).toISOString()
102
91
  };
103
92
  }
104
93
  async queryPoints(userId) {
105
- return { userId, balance: this.currentBalanceOf(userId), membershipLabel: this.cfg.cardName };
94
+ return { userId, balance: this.currentBalanceOf(userId), membershipLabel: CFG.cardName };
106
95
  }
107
96
  async getBenefits(userId) {
108
97
  return { availablePoints: this.currentBalanceOf(userId), levelName: "\u793A\u4F8B\u7B49\u7EA7", observedAt: (/* @__PURE__ */ new Date()).toISOString() };
@@ -132,7 +121,7 @@ var MockMemberServiceImpl = class {
132
121
  currentBalanceOf(userId) {
133
122
  const override = mockMemberState.balances.get(userId);
134
123
  if (override !== void 0) return override;
135
- return isMockMemberEnrolled(userId) ? this.cfg.initialPoints : 0;
124
+ return isMockMemberEnrolled(userId) ? CFG.initialPoints : 0;
136
125
  }
137
126
  async enroll(input) {
138
127
  enrollMockMember(input.userId);
@@ -157,7 +146,7 @@ var MockMemberServiceImpl = class {
157
146
 
158
147
  // src/server/parking.ts
159
148
  var now = () => (/* @__PURE__ */ new Date()).toISOString();
160
- var PARKING_CFG_DEFAULTS = {
149
+ var CFG2 = {
161
150
  parkName: "\u793A\u4F8B\u505C\u8F66\u573A",
162
151
  feeName: "\u505C\u8F66\u8D39\uFF083 \u5C0F\u65F6\uFF09",
163
152
  feeCents: 1500,
@@ -171,24 +160,25 @@ var PARKING_CFG_DEFAULTS = {
171
160
  vehicleZone: "A \u533A",
172
161
  vehicleSpaceNo: "A-128"
173
162
  };
174
- var PARKING_CFG_INT_KEYS = ["feeCents", "remainingSpaces", "memberBenefitDiscountCents"];
163
+ var MAX_BOUND_VEHICLES = 3;
164
+ var mockParkingState = {
165
+ vehicles: /* @__PURE__ */ new Map()
166
+ };
167
+ function __resetMockParkingState() {
168
+ mockParkingState.vehicles.clear();
169
+ }
175
170
  var MockParkingServiceImpl = class {
176
- vehicles = /* @__PURE__ */ new Map();
177
171
  records;
178
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ PARKING_CFG_DEFAULTS) */
179
- cfg;
180
- constructor(mallId = "mall-demo", config = {}) {
172
+ constructor(mallId = "mall-demo") {
181
173
  this.mallId = mallId;
182
- void this.mallId;
183
- this.cfg = resolveConfig(config, PARKING_CFG_DEFAULTS, PARKING_CFG_INT_KEYS);
184
174
  this.records = [
185
175
  {
186
176
  recordRef: "demo:record:1",
187
177
  plateNo: "demo-plate",
188
- amountCents: this.cfg.feeCents,
178
+ amountCents: CFG2.feeCents,
189
179
  paidAt: now(),
190
180
  status: "PAID",
191
- parkName: this.cfg.parkName,
181
+ parkName: CFG2.parkName,
192
182
  orderCompleted: true
193
183
  }
194
184
  ];
@@ -201,10 +191,10 @@ var MockParkingServiceImpl = class {
201
191
  */
202
192
  benefits() {
203
193
  const benefits = [];
204
- if (this.cfg.memberBenefitEnabled) {
205
- benefits.push({ benefitRef: "demo:benefit:member-discount", title: "\u4F1A\u5458 95 \u6298", description: "mock \u6F14\u793A\u6743\u76CA", kind: "discount", autoSelected: true, estimatedDiscountCents: this.cfg.memberBenefitDiscountCents });
194
+ if (CFG2.memberBenefitEnabled) {
195
+ benefits.push({ benefitRef: "demo:benefit:member-discount", title: "\u4F1A\u5458 95 \u6298", description: "mock \u6F14\u793A\u6743\u76CA", kind: "discount", autoSelected: true, estimatedDiscountCents: CFG2.memberBenefitDiscountCents });
206
196
  }
207
- if (this.cfg.pointsBenefitEnabled) {
197
+ if (CFG2.pointsBenefitEnabled) {
208
198
  benefits.push({ benefitRef: "demo:benefit:points-offset", title: "\u79EF\u5206\u62B5 5 \u5143", description: "mock \u6F14\u793A\u6743\u76CA", kind: "points", autoSelected: false, estimatedDiscountCents: 500, requiredPoints: 500, previewPayableCents: 1e3 });
209
199
  }
210
200
  return benefits;
@@ -215,23 +205,25 @@ var MockParkingServiceImpl = class {
215
205
  plateNo,
216
206
  mallId: q.scope.mallId ?? "demo",
217
207
  entryAt: now(),
218
- feeItems: [{ name: this.cfg.feeName, amountCents: this.cfg.feeCents }],
219
- totalCents: this.cfg.feeCents,
208
+ feeItems: [{ name: CFG2.feeName, amountCents: CFG2.feeCents }],
209
+ totalCents: CFG2.feeCents,
220
210
  discountCents: 0,
221
- payableCents: this.cfg.feeCents,
211
+ payableCents: CFG2.feeCents,
222
212
  appliedBenefits: [],
223
213
  revision: 1,
224
214
  paymentState: "UNPAID"
225
215
  };
226
216
  }
227
217
  async queryFee(q, input) {
228
- const plateNo = input.plateNo ?? (input.vehicleRef ? this.vehicles.get(input.vehicleRef)?.plateNo : void 0) ?? "demo-plate";
229
- const quote = this.quote(q, plateNo);
230
- return quote ? [quote] : [];
218
+ const fleet = this.readFleet(q);
219
+ const plateNo = input.plateNo ?? (input.vehicleRef ? fleet.find((v) => v.vehicleRef === input.vehicleRef)?.plateNo : void 0) ?? input.barcode;
220
+ if (plateNo) return [this.quote(q, plateNo)];
221
+ const inSite = fleet[0];
222
+ return inSite ? [this.quote(q, inSite.plateNo)] : [];
231
223
  }
232
- async listVehicles() {
233
- const list = [...this.vehicles.values()];
234
- return { bound: list.map((v, i) => ({ ...v, parked: i === 0 })) };
224
+ async listVehicles(q) {
225
+ const bound = this.readFleet(q).map((v, i) => i === 0 ? { ...v, parked: true } : v);
226
+ return { bound };
235
227
  }
236
228
  async listPaymentRecords(_q, page, pageSize) {
237
229
  const start = (page - 1) * pageSize;
@@ -244,7 +236,7 @@ var MockParkingServiceImpl = class {
244
236
  return record;
245
237
  }
246
238
  async getInvoiceSettings() {
247
- return { parkingInvoiceEnabled: this.cfg.invoiceEnabled };
239
+ return { parkingInvoiceEnabled: CFG2.invoiceEnabled };
248
240
  }
249
241
  async listInvoiceableOrders(_q, page, pageSize) {
250
242
  const all = this.records.filter((r) => r.orderCompleted === true);
@@ -254,11 +246,11 @@ var MockParkingServiceImpl = class {
254
246
  async queryParkingInfo(_q, kind) {
255
247
  return {
256
248
  kind,
257
- title: this.cfg.parkName,
249
+ title: CFG2.parkName,
258
250
  entries: [
259
- { label: "\u5269\u4F59\u8F66\u4F4D", value: String(this.cfg.remainingSpaces) },
260
- { label: "\u9996\u5C0F\u65F6\u8D39\u7387", value: this.cfg.firstHourRate },
261
- { label: "\u4F1A\u5458\u6743\u76CA", value: this.cfg.memberBenefitEnabled ? "\u4F1A\u5458 95 \u6298" : "\u2014" }
251
+ { label: "\u5269\u4F59\u8F66\u4F4D", value: String(CFG2.remainingSpaces) },
252
+ { label: "\u9996\u5C0F\u65F6\u8D39\u7387", value: CFG2.firstHourRate },
253
+ { label: "\u4F1A\u5458\u6743\u76CA", value: CFG2.memberBenefitEnabled ? "\u4F1A\u5458 95 \u6298" : "\u2014" }
262
254
  ]
263
255
  };
264
256
  }
@@ -266,14 +258,14 @@ var MockParkingServiceImpl = class {
266
258
  return this.benefits();
267
259
  }
268
260
  async locateVehicle(_q, _plateNo) {
269
- return { floorName: this.cfg.vehicleFloor, zoneName: this.cfg.vehicleZone, spaceNo: this.cfg.vehicleSpaceNo, walkingRoute: "\u7535\u68AF\u5DE6\u8F6C 50 \u7C73" };
261
+ return { floorName: CFG2.vehicleFloor, zoneName: CFG2.vehicleZone, spaceNo: CFG2.vehicleSpaceNo, walkingRoute: "\u7535\u68AF\u5DE6\u8F6C 50 \u7C73" };
270
262
  }
271
263
  // ===== 支付三步链(mock:reconcile 恒 PAID 收口) =====
272
264
  async createOrder(_q, quoteRef) {
273
265
  return { payOrderId: `demo:pay:${quoteRef}`, paymentRef: `demo:payment:${quoteRef}` };
274
266
  }
275
267
  async getOrderInfo(_q, _paymentRef) {
276
- return { orderInfo: "demo-order-info", channel: "50", payableFeeCents: this.cfg.feeCents };
268
+ return { orderInfo: "demo-order-info", channel: "50", payableFeeCents: CFG2.feeCents };
277
269
  }
278
270
  async getPaymentSign(_q, _paymentRef) {
279
271
  return { orderInfo: "demo-order-info" };
@@ -298,26 +290,44 @@ var MockParkingServiceImpl = class {
298
290
  throw new Error(`mock\uFF1A\u5F00\u7968\u8BB0\u5F55\u4E0D\u5B58\u5728 ${recordRef}`);
299
291
  }
300
292
  }
301
- // ===== 车辆管理 =====
302
- async bindVehicle(_q, plateNo) {
303
- const vehicle = { vehicleRef: `demo:vehicle:${plateNo}`, plateNo, boundAt: now() };
304
- this.vehicles.set(vehicle.vehicleRef, vehicle);
293
+ // ===== 车辆管理(属人共享 store;写需登录态、读匿名降级——见文件头) =====
294
+ /** 车队读视图:匿名(未登录)降级为空车队——开箱首页/面板不因未登录报错 */
295
+ readFleet(q) {
296
+ if (!q.subjectId) return [];
297
+ return mockParkingState.vehicles.get(`${q.subjectId}\0${q.scope?.mallId || this.mallId}`) ?? [];
298
+ }
299
+ /** 车队写句柄:无登录态显性报错(对齐真实厂商「无令牌不可写」,不造匿名共享桶) */
300
+ writeFleet(q) {
301
+ if (!q.subjectId) throw new Error("mock\uFF1A\u7F3A\u5C11\u7528\u6237\u8EAB\u4EFD\uFF0C\u65E0\u6CD5\u64CD\u4F5C\u7ED1\u5B9A\u8F66\u8F86");
302
+ const key = `${q.subjectId}\0${q.scope?.mallId || this.mallId}`;
303
+ let fleet = mockParkingState.vehicles.get(key);
304
+ if (!fleet) mockParkingState.vehicles.set(key, fleet = []);
305
+ return fleet;
306
+ }
307
+ async bindVehicle(q, plateNo) {
308
+ const fleet = this.writeFleet(q);
309
+ const plate = plateNo.trim();
310
+ const existing = fleet.find((v) => v.plateNo.toUpperCase() === plate.toUpperCase());
311
+ if (existing) return existing;
312
+ if (fleet.length >= MAX_BOUND_VEHICLES) throw new Error("\u6700\u591A\u7ED1\u5B9A 3 \u8F86\u8F66");
313
+ const vehicle = { vehicleRef: `demo:vehicle:${plate}`, plateNo: plate, boundAt: now() };
314
+ fleet.push(vehicle);
305
315
  return vehicle;
306
316
  }
307
- async unbindVehicle(_q, input) {
308
- if (input.vehicleRef) this.vehicles.delete(input.vehicleRef);
309
- else if (input.plateNo) {
310
- for (const [ref, v] of this.vehicles) {
311
- if (v.plateNo === input.plateNo) this.vehicles.delete(ref);
312
- }
313
- }
317
+ async unbindVehicle(q, input) {
318
+ const fleet = this.writeFleet(q);
319
+ const index = fleet.findIndex(
320
+ (v) => input.vehicleRef ? v.vehicleRef === input.vehicleRef : v.plateNo === input.plateNo
321
+ );
322
+ if (index < 0) throw new Error("\u672A\u627E\u5230\u8981\u89E3\u7ED1\u7684\u8F66\u724C");
323
+ fleet.splice(index, 1);
314
324
  }
315
325
  };
316
326
 
317
327
  // src/server/promotion.ts
318
328
  var now2 = () => (/* @__PURE__ */ new Date()).toISOString();
319
329
  var inDays = (d) => new Date(Date.now() + d * 864e5).toISOString();
320
- var PROMOTION_CFG_DEFAULTS = {
330
+ var CFG3 = {
321
331
  couponTitle: "\u6EE1 100 \u51CF 20 \u5143\u5238",
322
332
  couponValueCents: 2e3,
323
333
  couponThresholdCents: 1e4,
@@ -325,25 +335,22 @@ var PROMOTION_CFG_DEFAULTS = {
325
335
  grouponEnabled: true,
326
336
  activityTitle: "\u793A\u4F8B\u5546\u573A\u5468\u5E74\u5E86"
327
337
  };
328
- var PROMOTION_CFG_INT_KEYS = ["couponValueCents", "couponThresholdCents", "couponValidityDays"];
329
338
  var MockPromotionServiceImpl = class {
330
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ PROMOTION_CFG_DEFAULTS) */
331
- cfg;
332
339
  /** 供/资产/活动三表(构造期按 cfg 构建——请求级实例,成本可忽略) */
333
340
  offers;
334
341
  entitlements;
335
342
  activities;
336
- constructor(config = {}) {
337
- this.cfg = resolveConfig(config, PROMOTION_CFG_DEFAULTS, PROMOTION_CFG_INT_KEYS);
343
+ constructor() {
338
344
  const ts = now2();
339
345
  const couponOffer = {
340
346
  offerRef: "demo:coupon:1001",
341
347
  offerType: "COUPON",
342
- title: this.cfg.couponTitle,
348
+ title: CFG3.couponTitle,
343
349
  subtitle: "\u5168\u573A\u901A\u7528\uFF08mock \u6F14\u793A\uFF09",
350
+ imageUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*LHeBTp64HUYAAAAARLAAAAgAegitAQ/fmt.webp",
344
351
  tags: ["\u901A\u7528"],
345
- validity: { start: ts, end: inDays(this.cfg.couponValidityDays) },
346
- facets: [{ kind: "COUPON", discountType: "AMOUNT", value: this.cfg.couponValueCents, thresholdCents: this.cfg.couponThresholdCents }],
352
+ validity: { start: ts, end: inDays(CFG3.couponValidityDays) },
353
+ facets: [{ kind: "COUPON", discountType: "AMOUNT", value: CFG3.couponValueCents, thresholdCents: CFG3.couponThresholdCents }],
347
354
  availability: { status: "AVAILABLE", reasonCodes: [], evaluatedAt: ts, authoritative: false },
348
355
  participation: { mode: "CLAIM_THEN_PURCHASE", steps: [{ title: "\u9886\u53D6", description: "\u70B9\u51FB\u9886\u53D6\u540E\u81EA\u52A8\u5B58\u5165\u5361\u5305" }] }
349
356
  };
@@ -352,18 +359,19 @@ var MockPromotionServiceImpl = class {
352
359
  offerType: "GROUPON",
353
360
  title: "\u9910\u996E\u53CC\u4EBA\u5957\u9910 5 \u6298",
354
361
  subtitle: "mock \u6F14\u793A\u56E2\u8D2D",
362
+ imageUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*GzryQrxX2WEAAAAATYAAAAgAegitAQ/fmt.webp",
355
363
  tags: ["\u9910\u996E"],
356
364
  validity: { start: ts, end: inDays(15) },
357
365
  facets: [{ kind: "GROUPON", requiredParticipants: 2 }],
358
366
  availability: { status: "AVAILABLE", reasonCodes: [], evaluatedAt: ts, authoritative: false },
359
367
  participation: { mode: "CLAIM_THEN_PURCHASE", steps: [{ title: "\u8D2D\u4E70", description: "\u6309\u56E2\u8D2D\u4EF7\u4E0B\u5355" }] }
360
368
  };
361
- this.offers = this.cfg.grouponEnabled ? [couponOffer, grouponOffer] : [couponOffer];
369
+ this.offers = CFG3.grouponEnabled ? [couponOffer, grouponOffer] : [couponOffer];
362
370
  this.entitlements = [
363
371
  {
364
372
  entitlementRef: "demo:entitlement:1",
365
373
  offerRef: "demo:coupon:1001",
366
- title: this.cfg.couponTitle,
374
+ title: CFG3.couponTitle,
367
375
  entitlementType: "COUPON",
368
376
  status: "EFFECTIVE",
369
377
  codeMasked: "DEMO-****-1001"
@@ -372,8 +380,9 @@ var MockPromotionServiceImpl = class {
372
380
  this.activities = [
373
381
  {
374
382
  activityRef: "demo:activity:3001",
375
- title: this.cfg.activityTitle,
383
+ title: CFG3.activityTitle,
376
384
  subtitle: "mock \u6F14\u793A\u6D3B\u52A8",
385
+ coverUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*DIRTQ6CBBC0AAAAAgEAAAAgAegitAQ/fmt.webp",
377
386
  registrationRequired: false,
378
387
  offerRefs: ["demo:coupon:1001"]
379
388
  }
@@ -429,7 +438,7 @@ var MockPromotionServiceImpl = class {
429
438
  };
430
439
 
431
440
  // src/server/shopping.ts
432
- var SHOPPING_CFG_DEFAULTS = {
441
+ var CFG4 = {
433
442
  extraShopName: "",
434
443
  // '' = 不追加门店(空串 = 缺省/不生效语义)
435
444
  extraShopCategory: "\u9910\u996E",
@@ -437,7 +446,6 @@ var SHOPPING_CFG_DEFAULTS = {
437
446
  extraShopUnit: "304",
438
447
  extraShopOpen: true
439
448
  };
440
- var SHOPPING_CFG_INT_KEYS = [];
441
449
  var SHOPPING_FLOORS = ["B1", "1 \u697C", "2 \u697C", "3 \u697C", "4 \u697C"];
442
450
  var DEMO_BUILDINGS = [
443
451
  {
@@ -446,38 +454,38 @@ var DEMO_BUILDINGS = [
446
454
  {
447
455
  floorName: "B1",
448
456
  shops: [
449
- { merchantId: "demo-shop-1001", name: "\u6C38\u8F89\u8D85\u5E02", businessCategories: ["\u8D85\u5E02"], unitName: "B1-01", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
457
+ { merchantId: "demo-shop-1001", name: "\u6C38\u8F89\u8D85\u5E02", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*5Y45SqtTrvcAAAAAQCAAAAgAegitAQ/original", businessCategories: ["\u8D85\u5E02"], unitName: "B1-01", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
450
458
  ]
451
459
  },
452
460
  {
453
461
  floorName: "1 \u697C",
454
462
  shops: [
455
- { merchantId: "demo-shop-1002", name: "\u661F\u5DF4\u514B", businessCategories: ["\u9910\u996E"], unitName: "101", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
456
- { merchantId: "demo-shop-1003", name: "\u5468\u5927\u798F", businessCategories: ["\u73E0\u5B9D"], unitName: "102", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
457
- { merchantId: "demo-shop-1004", name: "\u5C48\u81E3\u6C0F", businessCategories: ["\u7F8E\u5986"], unitName: "103", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
463
+ { merchantId: "demo-shop-1002", name: "\u661F\u5DF4\u514B", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*pa08SZMqBNYAAAAAQEAAAAgAegitAQ/original", businessCategories: ["\u9910\u996E"], unitName: "101", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
464
+ { merchantId: "demo-shop-1003", name: "\u5468\u5927\u798F", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*WKXJTqR3BwQAAAAAQCAAAAgAegitAQ/original", businessCategories: ["\u73E0\u5B9D"], unitName: "102", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
465
+ { merchantId: "demo-shop-1004", name: "\u5C48\u81E3\u6C0F", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*c7cRQIe83NYAAAAAQFAAAAgAegitAQ/original", businessCategories: ["\u7F8E\u5986"], unitName: "103", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
458
466
  ]
459
467
  },
460
468
  {
461
469
  floorName: "2 \u697C",
462
470
  shops: [
463
- { merchantId: "demo-shop-1005", name: "\u534E\u4E3A", businessCategories: ["\u6570\u7801"], unitName: "201", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
464
- { merchantId: "demo-shop-1006", name: "\u5C0F\u7C73", businessCategories: ["\u6570\u7801"], unitName: "202", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
471
+ { merchantId: "demo-shop-1005", name: "\u534E\u4E3A", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*BrpxQ6dwGj0AAAAAQCAAAAgAegitAQ/original", businessCategories: ["\u6570\u7801"], unitName: "201", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
472
+ { merchantId: "demo-shop-1006", name: "\u5C0F\u7C73", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*6FBqSYVXFDEAAAAAMrAAAAgAegitAQ/original", businessCategories: ["\u6570\u7801"], unitName: "202", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
465
473
  ]
466
474
  },
467
475
  {
468
476
  floorName: "3 \u697C",
469
477
  shops: [
470
- { merchantId: "demo-shop-1007", name: "NIKE \u4E13\u5356\u5E97", brand: "NIKE", businessCategories: ["\u8FD0\u52A8\u670D\u9970"], unitName: "301", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
471
- { merchantId: "demo-shop-1008", name: "NIKE \u8DD1\u6B65\u4F53\u9A8C\u5E97", brand: "NIKE", businessCategories: ["\u8FD0\u52A8\u670D\u9970"], unitName: "302", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
472
- { merchantId: "demo-shop-1009", name: "\u5B89\u8E0F", businessCategories: ["\u8FD0\u52A8\u670D\u9970"], unitName: "303", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
478
+ { merchantId: "demo-shop-1007", name: "NIKE \u4E13\u5356\u5E97", brand: "NIKE", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*dFmuSKEMDwIAAAAAQCAAAAgAegitAQ/original", businessCategories: ["\u8FD0\u52A8\u670D\u9970"], unitName: "301", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
479
+ { merchantId: "demo-shop-1008", name: "NIKE \u8DD1\u6B65\u4F53\u9A8C\u5E97", brand: "NIKE", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*dFmuSKEMDwIAAAAAQCAAAAgAegitAQ/original", businessCategories: ["\u8FD0\u52A8\u670D\u9970"], unitName: "302", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
480
+ { merchantId: "demo-shop-1009", name: "\u5B89\u8E0F", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*edsgTpDq0GUAAAAAQDAAAAgAegitAQ/original", businessCategories: ["\u8FD0\u52A8\u670D\u9970"], unitName: "303", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } }
473
481
  ]
474
482
  },
475
483
  {
476
484
  floorName: "4 \u697C",
477
485
  shops: [
478
- { merchantId: "demo-shop-1010", name: "\u6D77\u5E95\u635E", businessCategories: ["\u9910\u996E"], unitName: "401", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
479
- { merchantId: "demo-shop-1011", name: "\u5916\u5A46\u5BB6", businessCategories: ["\u9910\u996E"], unitName: "402", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
480
- { merchantId: "demo-shop-1012", name: "\u897F\u8D1D\u839C\u9762\u6751", businessCategories: ["\u9910\u996E"], unitName: "403", status: { code: "disabled", label: "\u4F11\u606F\u4E2D" } }
486
+ { merchantId: "demo-shop-1010", name: "\u6D77\u5E95\u635E", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*18hVSI5dg6EAAAAAQCAAAAgAegitAQ/original", businessCategories: ["\u9910\u996E"], unitName: "401", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
487
+ { merchantId: "demo-shop-1011", name: "\u5916\u5A46\u5BB6", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*_uaLSZqH8-4AAAAASOAAAAgAegitAQ/fmt.webp", businessCategories: ["\u9910\u996E"], unitName: "402", status: { code: "enabled", label: "\u8425\u4E1A\u4E2D" } },
488
+ { merchantId: "demo-shop-1012", name: "\u897F\u8D1D\u839C\u9762\u6751", logoUrl: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*9X-US6dZvcIAAAAARAAAAAgAegitAQ/fmt.webp", businessCategories: ["\u9910\u996E"], unitName: "403", status: { code: "disabled", label: "\u4F11\u606F\u4E2D" } }
481
489
  ]
482
490
  }
483
491
  ]
@@ -491,6 +499,7 @@ function flattenShops(buildings) {
491
499
  merchantId: seed.merchantId,
492
500
  name: seed.name,
493
501
  ...seed.brand ? { brand: seed.brand } : {},
502
+ ...seed.logoUrl ? { logoUrl: seed.logoUrl } : {},
494
503
  businessCategories: [...seed.businessCategories],
495
504
  location: {
496
505
  displayText: [b.buildingName, f.floorName, seed.unitName].filter(Boolean).join(" "),
@@ -519,13 +528,10 @@ function toFloorRecord(floor) {
519
528
  return { floorCode: floor.floorName, floorName: floor.floorName, businessCategories: cats, merchantCount: floor.shops.length };
520
529
  }
521
530
  var MockShoppingServiceImpl = class {
522
- /** 配置快照(fail-soft,构造期一次解析;键集 ≡ SHOPPING_CFG_DEFAULTS) */
523
- cfg;
524
531
  buildings;
525
532
  shops;
526
533
  categories;
527
- constructor(seed = DEMO_BUILDINGS, config = {}) {
528
- this.cfg = resolveConfig(config, SHOPPING_CFG_DEFAULTS, SHOPPING_CFG_INT_KEYS);
534
+ constructor(seed = DEMO_BUILDINGS) {
529
535
  const withExtra = this.withExtraShop(seed);
530
536
  this.buildings = withExtra;
531
537
  this.shops = flattenShops(withExtra);
@@ -533,15 +539,15 @@ var MockShoppingServiceImpl = class {
533
539
  }
534
540
  /** extraShopName 非空 → 指定楼层追加演示门店(名称 trim 判空 + 楼层白名单回退——消费点守卫) */
535
541
  withExtraShop(seed) {
536
- const name = this.cfg.extraShopName.trim();
542
+ const name = CFG4.extraShopName.trim();
537
543
  if (!name) return seed;
538
- const floor = SHOPPING_FLOORS.includes(this.cfg.extraShopFloor) ? this.cfg.extraShopFloor : "3 \u697C";
544
+ const floor = SHOPPING_FLOORS.includes(CFG4.extraShopFloor) ? CFG4.extraShopFloor : "3 \u697C";
539
545
  const extra = {
540
546
  merchantId: "demo-shop-1013",
541
547
  name,
542
- businessCategories: [this.cfg.extraShopCategory],
543
- unitName: this.cfg.extraShopUnit,
544
- status: this.cfg.extraShopOpen ? { code: "enabled", label: "\u8425\u4E1A\u4E2D" } : { code: "disabled", label: "\u4F11\u606F\u4E2D" }
548
+ businessCategories: [CFG4.extraShopCategory],
549
+ unitName: CFG4.extraShopUnit,
550
+ status: CFG4.extraShopOpen ? { code: "enabled", label: "\u8425\u4E1A\u4E2D" } : { code: "disabled", label: "\u4F11\u606F\u4E2D" }
545
551
  };
546
552
  return seed.map((b) => ({
547
553
  ...b,
@@ -611,26 +617,25 @@ var MockShoppingServiceImpl = class {
611
617
  // src/server/mall-info.ts
612
618
  var MOCK_MALL_INFO_PROVIDER = "mock";
613
619
  var MOCK_MALL_INFO_IMPL = "mock-mall-info@1";
614
- var MALL_INFO_CFG_DEFAULTS = {
620
+ var CFG5 = {
615
621
  name: "",
616
622
  // '' 哨兵 = 动态别名回退
617
623
  address: "\u793A\u4F8B\u5546\u573A\u5730\u5740\uFF08demo\uFF09",
618
624
  latitude: 30,
619
625
  longitude: 120
620
626
  };
621
- var MALL_INFO_CFG_INT_KEYS = [];
622
627
  var MALL_ID_RE = /^[\w-]{1,32}$/;
623
628
  var mockMallInfoFactory = (input) => {
624
- const cfg = resolveConfig(input.config, MALL_INFO_CFG_DEFAULTS, MALL_INFO_CFG_INT_KEYS);
629
+ void input;
625
630
  return {
626
631
  async getMallInfo(mallId) {
627
632
  if (!MALL_ID_RE.test(mallId)) return void 0;
628
633
  return {
629
634
  mallId,
630
- name: cfg.name !== "" ? cfg.name : `\u793A\u4F8B\u5546\u573A\uFF08${mallId}\uFF09`,
631
- address: cfg.address,
632
- latitude: cfg.latitude,
633
- longitude: cfg.longitude
635
+ name: CFG5.name !== "" ? CFG5.name : `\u793A\u4F8B\u5546\u573A\uFF08${mallId}\uFF09`,
636
+ address: CFG5.address,
637
+ latitude: CFG5.latitude,
638
+ longitude: CFG5.longitude
634
639
  };
635
640
  }
636
641
  };
@@ -638,7 +643,7 @@ var mockMallInfoFactory = (input) => {
638
643
 
639
644
  // src/server/mock-enroll-route.ts
640
645
  import { Router } from "express";
641
- import { getRequestContext } from "@tbox.cn/app-sdk/server";
646
+ import { getRequestContext } from "@tbox.cn/app-agent-sdk-server";
642
647
  function resolveMockEnroll(input) {
643
648
  if ((input.nodeEnv ?? process.env.NODE_ENV) === "production") {
644
649
  return { status: 503, body: { error: "mock-only" } };
@@ -684,14 +689,14 @@ var MOCK_MEMBER_IMPL = "mock-member@1";
684
689
  var MOCK_PARKING_IMPL = "mock-parking@1";
685
690
  var MOCK_PROMOTION_IMPL = "mock-promotion@1";
686
691
  var MOCK_SHOPPING_IMPL = "mock-shopping@1";
687
- var memberFactory = (input) => new MockMemberServiceImpl({}, input.config);
688
- var parkingFactory = (input) => new MockParkingServiceImpl(input.instanceId || "mall-demo", input.config);
689
- var promotionFactory = (input) => new MockPromotionServiceImpl(input.config);
692
+ var memberFactory = () => new MockMemberServiceImpl({});
693
+ var parkingFactory = (input) => new MockParkingServiceImpl(input.instanceId || "mall-demo");
694
+ var promotionFactory = () => new MockPromotionServiceImpl();
690
695
  var shoppingFactory = (input) => {
691
696
  if (input.service !== "shopping-guide.catalog" && input.service !== "shopping-guide.shops" && input.service !== "shopping-guide.categories" && input.service !== "shopping-guide.directory") {
692
697
  throw new Error(`mock guide \u5DE5\u5382\u4E0D\u4F9B\u7ED9\u69FD\uFF1A${input.service}`);
693
698
  }
694
- return new MockShoppingServiceImpl(void 0, input.config);
699
+ return new MockShoppingServiceImpl(void 0);
695
700
  };
696
701
  var mallInfoFactory = (input) => mockMallInfoFactory(input);
697
702
  function createMockAlipayLoginExchange(integrations) {
@@ -766,6 +771,7 @@ export {
766
771
  MockPromotionServiceImpl,
767
772
  MockShoppingServiceImpl,
768
773
  __resetMockMemberState,
774
+ __resetMockParkingState,
769
775
  createMockEnrollRouter,
770
776
  enrollMockMember,
771
777
  isMockMemberEnrolled,
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-provider-mock",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
- "description": "商圈 Mock Provider 包(17 槽全 local:true:member×5 / parking×3 / promotion×4 / guide×4 + mall.info):模板缺省开箱演示——免传输/凭据/实例配置,裸跑即完整 mock 演示;全槽 config schema(schemas/×5 域共享)+ 内存 config 消费(改配置重启即变)。",
5
+ "description": "商圈 Mock Provider 包(极简零配置):17 槽 local 供给开箱即用——免传输/凭据/实例配置/集成配置;config 消费与配置验证面见 @tbox.cn/app-provider-mocktest。",
6
6
  "exports": {
7
7
  ".": {
8
8
  "types": "./dist/index.d.ts",
@@ -14,9 +14,10 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@tbox.cn/app-sdk": "0.20.0",
18
- "@tbox.cn/app-contracts": "0.11.0",
19
- "@tbox.cn/app-contracts-mall": "0.11.0"
17
+ "@tbox.cn/app-contracts": "0.12.0",
18
+ "@tbox.cn/app-contracts-mall": "0.12.1",
19
+ "@tbox.cn/app-agent-sdk-client": "0.1.1",
20
+ "@tbox.cn/app-agent-sdk-server": "0.1.1"
20
21
  },
21
22
  "devDependencies": {
22
23
  "@types/express": "4.17.25",
@@ -28,7 +29,6 @@
28
29
  },
29
30
  "files": [
30
31
  "dist",
31
- "schemas",
32
32
  "src",
33
33
  "tests",
34
34
  "tbox.module.json",
@@ -12,8 +12,8 @@
12
12
  * (catalog 空 + shop/category/directory 纯 mock 数据);assistance/navigation 本地知识库域
13
13
  * 归模块本地 adapter,不属 provider 供给面。
14
14
  *
15
- * config 消费:五域工厂透传 input.config → 各 impl 构造期 fail-soft 快照
16
- * (src/server/config.ts;键集/缺省双锁 tests/config-schema.test.ts);零配置 = 零行为变化。
15
+ * 零配置开箱(2026-09-20 拆分):五域工厂不带 config——演示常量冻结在各 impl
16
+ * (值 ≡ 0.4.0 缺省);config 消费面随 provider-mocktest 迁出。
17
17
  *
18
18
  * 隐式默认单实例(零拓扑部署兜底):register 期经 ctx.integrations.declareProviderInstances
19
19
  * 声明 mall-demo——显式 instances/defaultInstanceId 恒赢(融合规则见 contracts-mall
@@ -29,8 +29,8 @@
29
29
  * 回调 + curl 联调)。
30
30
  */
31
31
  import { randomBytes } from 'node:crypto';
32
- import type { ServerContext, ServerModule } from '@tbox.cn/app-sdk/server';
33
- import type { ServiceAdapterFactory } from '@tbox.cn/app-sdk/server';
32
+ import type { ServerContext, ServerModule } from '@tbox.cn/app-agent-sdk-server';
33
+ import type { ServiceAdapterFactory } from '@tbox.cn/app-agent-sdk-server';
34
34
  import type { ExchangeResult } from '@tbox.cn/app-contracts';
35
35
  import { readLoginMallId } from '@tbox.cn/app-contracts-mall';
36
36
  import {
@@ -51,15 +51,15 @@ export const MOCK_PROMOTION_IMPL = 'mock-promotion@1';
51
51
  export const MOCK_SHOPPING_IMPL = 'mock-shopping@1';
52
52
 
53
53
  export { MockMemberServiceImpl, MOCK_SHELL_USER_ID, enrollMockMember, isMockMemberEnrolled, logoutMockMember, isMockMemberLoggedOut, __resetMockMemberState } from './member';
54
- export { MockParkingServiceImpl } from './parking';
54
+ export { MockParkingServiceImpl, __resetMockParkingState } from './parking';
55
55
  export { MockPromotionServiceImpl } from './promotion';
56
56
  export { MockShoppingServiceImpl } from './shopping';
57
57
  export { MOCK_MALL_INFO_PROVIDER, MOCK_MALL_INFO_IMPL, mockMallInfoFactory } from './mall-info';
58
58
  export { createMockEnrollRouter } from './mock-enroll-route';
59
59
 
60
- const memberFactory: ServiceAdapterFactory = (input) => new MockMemberServiceImpl({}, input.config);
61
- const parkingFactory: ServiceAdapterFactory = (input) => new MockParkingServiceImpl(input.instanceId || 'mall-demo', input.config);
62
- const promotionFactory: ServiceAdapterFactory = (input) => new MockPromotionServiceImpl(input.config);
60
+ const memberFactory: ServiceAdapterFactory = () => new MockMemberServiceImpl({});
61
+ const parkingFactory: ServiceAdapterFactory = (input) => new MockParkingServiceImpl(input.instanceId || 'mall-demo');
62
+ const promotionFactory: ServiceAdapterFactory = () => new MockPromotionServiceImpl();
63
63
  /** shopping-guide:四槽分支(017 槽位原子化)——MockShoppingServiceImpl 实现全部四 Port,
64
64
  * 结构类型满足任一槽产物(catalog 槽 = mock 空商品数据,对齐真实档无商品端点形态)。 */
65
65
  const shoppingFactory: ServiceAdapterFactory = (input) => {
@@ -71,7 +71,7 @@ const shoppingFactory: ServiceAdapterFactory = (input) => {
71
71
  ) {
72
72
  throw new Error(`mock guide 工厂不供给槽:${input.service}`);
73
73
  }
74
- return new MockShoppingServiceImpl(undefined, input.config);
74
+ return new MockShoppingServiceImpl(undefined);
75
75
  };
76
76
  /** mall.info:动态商场演示源(任意合法 mallId → 确定性别名;对齐真实厂商 mall-info adapter 通用形态) */
77
77
  const mallInfoFactory: ServiceAdapterFactory = (input) => mockMallInfoFactory(input);