@pisell/pisellos 0.10.61 → 0.10.62

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.
@@ -338,12 +338,21 @@ export var InventoryController = /*#__PURE__*/function () {
338
338
  return _this4.availabilityForKey(key);
339
339
  });
340
340
  if (!states.length) return this.availabilityForKey();
341
- var quantity = states.every(function (entry) {
341
+ // Unmapped variants are not offered by this source. Exclude even their last
342
+ // known quantities, while preserving errors on variants that are configured.
343
+ var mappedStates = states.filter(function (entry) {
344
+ return entry.status !== 'unmapped';
345
+ });
346
+ if (!mappedStates.length) return {
347
+ status: 'unmapped',
348
+ message: this.source.message('unmapped')
349
+ };
350
+ var quantity = mappedStates.every(function (entry) {
342
351
  return entry.quantity !== undefined;
343
- }) ? states.reduce(function (sum, entry) {
352
+ }) ? mappedStates.reduce(function (sum, entry) {
344
353
  return sum + entry.quantity;
345
354
  }, 0) : undefined;
346
- var failed = states.find(function (entry) {
355
+ var failed = mappedStates.find(function (entry) {
347
356
  return entry.status !== 'ready';
348
357
  });
349
358
  if (quantity !== undefined && !Number.isSafeInteger(quantity)) return {
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
373
373
  };
374
374
  setOtherData(key: string, value: any): void;
375
375
  getOtherData(key: string): any;
376
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
376
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
377
377
  /**
378
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
379
379
  *
@@ -465,19 +465,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
465
465
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
466
466
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
467
467
  */
468
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
469
- action: "reloadCatalog";
470
- } | {
471
- action: "add";
472
- cacheItem: any;
473
- } | {
474
- action: "requiresDetail";
475
- payload: AddProductRequiresDetailPayload;
476
- } | {
477
- action: "requiresBookingEdit";
478
- cacheItem: any;
479
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
480
- };
468
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
481
469
  /** 规格弹窗 callback 后的第二段决策。 */
482
470
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
483
471
  /**
@@ -175,8 +175,15 @@ class InventoryController {
175
175
  const keys = [...new Set(this.products.get(String(id))?.values() || [])];
176
176
  const states = keys.map(key => this.availabilityForKey(key));
177
177
  if (!states.length) return this.availabilityForKey();
178
- const quantity = states.every(entry => entry.quantity !== undefined) ? states.reduce((sum, entry) => sum + entry.quantity, 0) : undefined;
179
- const failed = states.find(entry => entry.status !== 'ready');
178
+ // Unmapped variants are not offered by this source. Exclude even their last
179
+ // known quantities, while preserving errors on variants that are configured.
180
+ const mappedStates = states.filter(entry => entry.status !== 'unmapped');
181
+ if (!mappedStates.length) return {
182
+ status: 'unmapped',
183
+ message: this.source.message('unmapped')
184
+ };
185
+ const quantity = mappedStates.every(entry => entry.quantity !== undefined) ? mappedStates.reduce((sum, entry) => sum + entry.quantity, 0) : undefined;
186
+ const failed = mappedStates.find(entry => entry.status !== 'ready');
180
187
  if (quantity !== undefined && !Number.isSafeInteger(quantity)) return {
181
188
  status: 'error',
182
189
  message: this.source.message('unavailable')
@@ -1,46 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
- enumerable: true,
8
- get: function () {
9
- return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
- }
11
- });
12
- Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
- enumerable: true,
14
- get: function () {
15
- return _examples.ITEM_REWARD_STRATEGY;
16
- }
17
- });
18
- Object.defineProperty(exports, "PromotionAdapter", {
19
- enumerable: true,
20
- get: function () {
21
- return _adapter.PromotionAdapter;
22
- }
23
- });
24
- Object.defineProperty(exports, "PromotionEvaluator", {
25
- enumerable: true,
26
- get: function () {
27
- return _evaluator.PromotionEvaluator;
28
- }
29
- });
30
- Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
- enumerable: true,
32
- get: function () {
33
- return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
- }
35
- });
36
- Object.defineProperty(exports, "default", {
37
- enumerable: true,
38
- get: function () {
39
- return _adapter.default;
40
- }
41
- });
42
- var _evaluator = require("./evaluator");
43
- var _adapter = _interopRequireWildcard(require("./adapter"));
44
- var _examples = require("./examples");
45
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
1
+ "use strict";
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
373
373
  };
374
374
  setOtherData(key: string, value: any): void;
375
375
  getOtherData(key: string): any;
376
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
376
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
377
377
  /**
378
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
379
379
  *
@@ -465,19 +465,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
465
465
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
466
466
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
467
467
  */
468
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
469
- action: "reloadCatalog";
470
- } | {
471
- action: "add";
472
- cacheItem: any;
473
- } | {
474
- action: "requiresDetail";
475
- payload: AddProductRequiresDetailPayload;
476
- } | {
477
- action: "requiresBookingEdit";
478
- cacheItem: any;
479
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
480
- };
468
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
481
469
  /** 规格弹窗 callback 后的第二段决策。 */
482
470
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
483
471
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.61",
4
+ "version": "0.10.62",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",