@pisell/pisellos 0.10.8 → 0.10.10

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.
Files changed (129) hide show
  1. package/dist/core/index.js +0 -1
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
  4. package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
  6. package/dist/model/strategy/adapter/walletPass/type.d.ts +5 -0
  7. package/dist/model/strategy/adapter/walletPass/utils.js +57 -26
  8. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
  9. package/dist/modules/BookingContext/utils/productExtend.js +5 -9
  10. package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
  11. package/dist/modules/Customer/index.d.ts +4 -0
  12. package/dist/modules/Customer/index.js +91 -59
  13. package/dist/modules/Customer/types.d.ts +2 -0
  14. package/dist/modules/Discount/index.d.ts +2 -0
  15. package/dist/modules/Discount/index.js +38 -5
  16. package/dist/modules/Discount/types.d.ts +11 -0
  17. package/dist/modules/OpenData/types.d.ts +1 -0
  18. package/dist/modules/Order/index.d.ts +20 -1
  19. package/dist/modules/Order/index.js +976 -730
  20. package/dist/modules/Order/types.d.ts +6 -1
  21. package/dist/modules/Order/utils/virtualSettlement.d.ts +56 -0
  22. package/dist/modules/Order/utils/virtualSettlement.js +271 -0
  23. package/dist/modules/Order/utils.js +89 -48
  24. package/dist/modules/Payment/types.d.ts +2 -0
  25. package/dist/modules/Payment/utils.js +4 -1
  26. package/dist/modules/Payment/walletpass.d.ts +11 -0
  27. package/dist/modules/Payment/walletpass.js +235 -60
  28. package/dist/modules/Product/types.d.ts +23 -0
  29. package/dist/modules/ProductList/index.d.ts +15 -2
  30. package/dist/modules/ProductList/index.js +92 -13
  31. package/dist/modules/ResourcePlanner/index.d.ts +0 -22
  32. package/dist/modules/ResourcePlanner/index.js +1 -180
  33. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  34. package/dist/modules/ResourcePlanner/localClock.js +183 -0
  35. package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
  36. package/dist/modules/ResourcePlanner/planner.js +2019 -936
  37. package/dist/modules/ResourcePlanner/types.d.ts +346 -187
  38. package/dist/modules/ResourcePlanner/types.js +33 -1
  39. package/dist/modules/SalesSummary/index.d.ts +1 -0
  40. package/dist/modules/SalesSummary/index.js +4 -3
  41. package/dist/modules/SalesSummary/types.d.ts +1 -0
  42. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  43. package/dist/modules/SalesSummary/utils.js +21 -1
  44. package/dist/server/index.d.ts +9 -0
  45. package/dist/server/index.js +90 -58
  46. package/dist/server/modules/order/index.d.ts +1 -0
  47. package/dist/server/modules/order/index.js +252 -94
  48. package/dist/server/utils/small-ticket.js +2 -1
  49. package/dist/solution/BaseSales/index.d.ts +26 -2
  50. package/dist/solution/BaseSales/index.js +1310 -931
  51. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  52. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +78 -12
  53. package/dist/solution/BookingByStep/index.d.ts +4 -4
  54. package/dist/solution/BookingTicket/index.d.ts +5 -1
  55. package/dist/solution/BookingTicket/index.js +225 -161
  56. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  57. package/dist/solution/BookingTicket/utils/addProductDecision.js +5 -3
  58. package/dist/solution/ScanOrder/index.js +25 -64
  59. package/dist/solution/UnifiedBookingSales/index.d.ts +110 -73
  60. package/dist/solution/UnifiedBookingSales/index.js +3349 -971
  61. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  62. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
  63. package/dist/solution/UnifiedBookingSales/types.d.ts +133 -76
  64. package/dist/solution/UnifiedBookingSales/types.js +4 -9
  65. package/lib/core/index.js +0 -1
  66. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  67. package/lib/model/strategy/adapter/dataVariant/evaluator.js +170 -7
  68. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  69. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -2
  70. package/lib/model/strategy/adapter/walletPass/type.d.ts +5 -0
  71. package/lib/model/strategy/adapter/walletPass/utils.js +62 -11
  72. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
  73. package/lib/modules/BookingContext/utils/productExtend.js +4 -3
  74. package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
  75. package/lib/modules/Customer/index.d.ts +4 -0
  76. package/lib/modules/Customer/index.js +11 -0
  77. package/lib/modules/Customer/types.d.ts +2 -0
  78. package/lib/modules/Discount/index.d.ts +2 -0
  79. package/lib/modules/Discount/index.js +37 -3
  80. package/lib/modules/Discount/types.d.ts +11 -0
  81. package/lib/modules/OpenData/types.d.ts +1 -0
  82. package/lib/modules/Order/index.d.ts +20 -1
  83. package/lib/modules/Order/index.js +393 -128
  84. package/lib/modules/Order/types.d.ts +6 -1
  85. package/lib/modules/Order/utils/virtualSettlement.d.ts +56 -0
  86. package/lib/modules/Order/utils/virtualSettlement.js +300 -0
  87. package/lib/modules/Order/utils.js +65 -21
  88. package/lib/modules/Payment/types.d.ts +2 -0
  89. package/lib/modules/Payment/utils.js +5 -1
  90. package/lib/modules/Payment/walletpass.d.ts +11 -0
  91. package/lib/modules/Payment/walletpass.js +198 -17
  92. package/lib/modules/Product/types.d.ts +23 -0
  93. package/lib/modules/ProductList/index.d.ts +15 -2
  94. package/lib/modules/ProductList/index.js +85 -3
  95. package/lib/modules/ResourcePlanner/index.d.ts +0 -22
  96. package/lib/modules/ResourcePlanner/index.js +0 -123
  97. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  98. package/lib/modules/ResourcePlanner/localClock.js +270 -0
  99. package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
  100. package/lib/modules/ResourcePlanner/planner.js +1903 -798
  101. package/lib/modules/ResourcePlanner/types.d.ts +346 -187
  102. package/lib/modules/ResourcePlanner/types.js +19 -0
  103. package/lib/modules/SalesSummary/index.d.ts +1 -0
  104. package/lib/modules/SalesSummary/index.js +10 -2
  105. package/lib/modules/SalesSummary/types.d.ts +1 -0
  106. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  107. package/lib/modules/SalesSummary/utils.js +25 -1
  108. package/lib/server/index.d.ts +9 -0
  109. package/lib/server/index.js +54 -14
  110. package/lib/server/modules/order/index.d.ts +1 -0
  111. package/lib/server/modules/order/index.js +66 -2
  112. package/lib/server/utils/small-ticket.js +1 -1
  113. package/lib/solution/BaseSales/index.d.ts +26 -2
  114. package/lib/solution/BaseSales/index.js +261 -23
  115. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  116. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +61 -11
  117. package/lib/solution/BookingByStep/index.d.ts +4 -4
  118. package/lib/solution/BookingTicket/index.d.ts +5 -1
  119. package/lib/solution/BookingTicket/index.js +32 -3
  120. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  121. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -1
  122. package/lib/solution/ScanOrder/index.js +17 -54
  123. package/lib/solution/UnifiedBookingSales/index.d.ts +110 -73
  124. package/lib/solution/UnifiedBookingSales/index.js +2289 -374
  125. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  126. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +376 -0
  127. package/lib/solution/UnifiedBookingSales/types.d.ts +133 -76
  128. package/lib/solution/UnifiedBookingSales/types.js +3 -2
  129. package/package.json +1 -1
@@ -67,7 +67,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
67
67
  product_ids?: number[];
68
68
  collection?: number | string[];
69
69
  schedule_date?: string;
70
- }): Promise<any>;
70
+ }): Promise<ProductData[]>;
71
71
  /**
72
72
  * 通过 schedule 来读取商品,适用于 session 类商品
73
73
  *
@@ -87,7 +87,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
87
87
  date: string;
88
88
  product_ids?: number[];
89
89
  category_ids?: number[];
90
- }): Promise<any>;
90
+ }): Promise<ProductData[]>;
91
91
  /**
92
92
  * 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
93
93
  *
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 6 | 4 | 3 | 5;
329
+ weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
345
345
  count: number;
346
346
  left: number;
347
347
  summaryCount: number;
348
- status: "lots_of_space" | "filling_up_fast" | "sold_out";
348
+ status: "sold_out" | "lots_of_space" | "filling_up_fast";
349
349
  }[];
350
350
  /**
351
351
  * 找到多个资源的公共可用时间段
@@ -64,6 +64,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
64
64
  scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
65
65
  private hydrateOrderCustomerFromScanDiscounts;
66
66
  private getDiscountCustomerId;
67
+ resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
68
+ /** 兼容既有优惠码扫码逻辑。 */
67
69
  private resolveCustomerByDiscountCustomerId;
68
70
  private findCustomerById;
69
71
  private normalizeCustomer;
@@ -126,7 +128,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
126
128
  loadProducts(params?: ILoadProductsParams, options?: {
127
129
  callback?: (result: any) => void;
128
130
  subscriberId?: string;
129
- }): Promise<any>;
131
+ }): Promise<ProductData[]>;
130
132
  /**
131
133
  * 获取加时商品列表。
132
134
  *
@@ -285,6 +287,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
285
287
  private buildOrderCustomerPayload;
286
288
  protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
287
289
  protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
290
+ protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
291
+ protected preferAuthoritativeProductQueryPrice(): boolean;
288
292
  /**
289
293
  * 获取客户分页信息
290
294
  * @returns 分页信息
@@ -399,7 +399,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
399
399
  }
400
400
  return null;
401
401
  }
402
- async resolveCustomerByDiscountCustomerId(customerId) {
402
+ async resolveCustomerById(customerId) {
403
403
  var _a;
404
404
  const localCustomers = this.store.customer.getCustomers();
405
405
  const localCustomer = this.findCustomerById(localCustomers, customerId);
@@ -413,7 +413,23 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
413
413
  num: 1
414
414
  });
415
415
  const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
416
- return remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null;
416
+ if (remoteCustomer) {
417
+ return this.normalizeCustomer(remoteCustomer);
418
+ }
419
+ try {
420
+ const detailCustomer = await this.store.customer.queryCustomerDetail(customerId);
421
+ return detailCustomer ? this.normalizeCustomer(detailCustomer) : null;
422
+ } catch (error) {
423
+ console.warn(
424
+ "[BookingTicket] resolveCustomerById detail request failed",
425
+ { customerId, error }
426
+ );
427
+ return null;
428
+ }
429
+ }
430
+ /** 兼容既有优惠码扫码逻辑。 */
431
+ resolveCustomerByDiscountCustomerId(customerId) {
432
+ return this.resolveCustomerById(customerId);
417
433
  }
418
434
  findCustomerById(customers = [], customerId) {
419
435
  return customers.find((customer) => {
@@ -1020,6 +1036,18 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1020
1036
  waitForOrderCustomerPromotionRefresh() {
1021
1037
  return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
1022
1038
  }
1039
+ async prepareProductPriceQueryContext(customerId) {
1040
+ await Promise.resolve();
1041
+ const normalizedCustomerId = Number(customerId || 0);
1042
+ const refreshTask = this.orderCustomerDiscountRefreshInFlight;
1043
+ const shouldWait = normalizedCustomerId > 1 && this.orderCustomerDiscountRefreshCustomerId === normalizedCustomerId && Boolean(refreshTask);
1044
+ if (shouldWait && refreshTask) {
1045
+ await refreshTask;
1046
+ }
1047
+ }
1048
+ preferAuthoritativeProductQueryPrice() {
1049
+ return true;
1050
+ }
1023
1051
  /**
1024
1052
  * 获取客户分页信息
1025
1053
  * @returns 分页信息
@@ -1360,7 +1388,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1360
1388
  date,
1361
1389
  presetStartTime: (extra == null ? void 0 : extra.presetStartTime) ?? (0, import_BookingContext.derivePresetStartTimeFromDate)(date),
1362
1390
  customerId: orderCustomerId,
1363
- ...extra || {}
1391
+ ...extra || {},
1392
+ channel: this.getSubmitOrderSalesChannel()
1364
1393
  };
1365
1394
  }
1366
1395
  /**
@@ -5,7 +5,7 @@ import type { OrderProduct, OrderProductIdentity, AddProductBookingInput } from
5
5
  * cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
6
6
  *
7
7
  * 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
8
- * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(门禁:`getIsAutoClose` on prepared cacheItem)
8
+ * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(kiosk 强制进入;其他渠道由 `getIsAutoClose` 决定)
9
9
  * 3. `add`:两关均通过,直接 transform + 加车
10
10
  */
11
11
  export type AddProductDecision = {
@@ -65,6 +65,7 @@ export interface AddProductDecideContext extends BookingCalcContext {
65
65
  type?: 'select' | 'detail';
66
66
  quantity?: number;
67
67
  customerId?: number | string;
68
+ channel?: string;
68
69
  }
69
70
  /**
70
71
  * 统一补齐预约商品的运行态字段。
@@ -57,6 +57,8 @@ function needsSpecDetailModal(item) {
57
57
  function needsBookingEdit(cacheItem, ctx) {
58
58
  if (isNormalBookingProduct(cacheItem))
59
59
  return false;
60
+ if ((ctx == null ? void 0 : ctx.channel) === "kiosk")
61
+ return true;
60
62
  const isAutoAllocationOn = (ctx == null ? void 0 : ctx.isAutoAllocationOn) || (() => true);
61
63
  return !(0, import_BookingContext.getIsAutoClose)(cacheItem, isAutoAllocationOn);
62
64
  }
@@ -277,7 +279,7 @@ function transformDetailToProductAndBooking(cacheItem, ctx) {
277
279
  return { product: productInput, booking, cacheItem: preparedCacheItem };
278
280
  }
279
281
  function buildBasePayloadFromCacheItem(cacheItem, ctx) {
280
- var _a, _b, _c, _d;
282
+ var _a, _b, _c, _d, _e, _f;
281
283
  const other = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) || {};
282
284
  const quantity = (ctx == null ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) ?? 1;
283
285
  const resolvedPid = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
@@ -304,6 +306,7 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
304
306
  bundle_edit: extend == null ? void 0 : extend.bundle_edit,
305
307
  discount_reason: extend == null ? void 0 : extend.discount_reason,
306
308
  discount_list: cacheItem == null ? void 0 : cacheItem.discount_list,
309
+ selected_settlement_snapshot: ((_e = cacheItem == null ? void 0 : cacheItem.metadata) == null ? void 0 : _e.selected_settlement_snapshot) ?? ((_f = extend == null ? void 0 : extend.metadata) == null ? void 0 : _f.selected_settlement_snapshot),
307
310
  _extend: extend
308
311
  };
309
312
  }
@@ -1708,60 +1708,23 @@ var _ScanOrderImpl = class extends import_BaseSales.BaseSalesImpl {
1708
1708
  schedule_datetime: scheduleDatetime,
1709
1709
  cacheId: this.cacheId
1710
1710
  });
1711
- if (Array.isArray(loaded)) {
1712
- const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1713
- loaded,
1714
- normalizedResourceId
1715
- );
1716
- const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1717
- this.enabledReservationRuleProducts = ruleProductsForResource;
1718
- const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1719
- if (occupancyMinutes !== void 0) {
1720
- tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1721
- }
1722
- if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1723
- pendingRequestEntryPax = 1;
1724
- const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1725
- if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1726
- pendingRequestPaxMin = paxBounds.min;
1727
- if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1728
- pendingRequestPaxMax = paxBounds.max;
1729
- }
1730
- } else {
1731
- this.enabledReservationRuleProducts = [];
1732
- const error = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1733
- this.logMethodError("loadReservationRuleProducts", error, {
1734
- resourceId: normalizedResourceId,
1735
- reservationLinkIds,
1736
- scheduleDate,
1737
- scheduleDatetime,
1738
- cacheId: this.cacheId
1739
- });
1740
- if (Array.isArray(loaded)) {
1741
- this.enabledReservationRuleProducts = loaded;
1742
- const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(loaded);
1743
- if (occupancyMinutes !== void 0) {
1744
- tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1745
- }
1746
- if ((0, import_utils.hasCustomCapacityProduct)(loaded)) {
1747
- pendingRequestEntryPax = 1;
1748
- const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
1749
- if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1750
- pendingRequestPaxMin = paxBounds.min;
1751
- if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1752
- pendingRequestPaxMax = paxBounds.max;
1753
- }
1754
- } else {
1755
- this.enabledReservationRuleProducts = [];
1756
- const error2 = loaded instanceof Error ? loaded : new Error("预约规则商品列表接口返回异常");
1757
- this.logMethodError("loadReservationRuleProducts", error2, {
1758
- resourceId,
1759
- reservationLinkIds,
1760
- scheduleDate,
1761
- scheduleDatetime,
1762
- cacheId: this.cacheId
1763
- });
1764
- }
1711
+ const matchedRuleProduct = (0, import_utils.findReservationRuleProductByResourceId)(
1712
+ loaded,
1713
+ normalizedResourceId
1714
+ );
1715
+ const ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
1716
+ this.enabledReservationRuleProducts = ruleProductsForResource;
1717
+ const occupancyMinutes = (0, import_utils.pickFirstDurationMinutesFromProducts)(ruleProductsForResource);
1718
+ if (occupancyMinutes !== void 0) {
1719
+ tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1720
+ }
1721
+ if ((0, import_utils.hasCustomCapacityProduct)(ruleProductsForResource)) {
1722
+ pendingRequestEntryPax = 1;
1723
+ const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(ruleProductsForResource);
1724
+ if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0)
1725
+ pendingRequestPaxMin = paxBounds.min;
1726
+ if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0)
1727
+ pendingRequestPaxMax = paxBounds.max;
1765
1728
  }
1766
1729
  const occupyDetails = await this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
1767
1730
  const occupyDetail = occupyDetails[0] ?? null;
@@ -1,12 +1,13 @@
1
- import type { Module } from '../../types';
1
+ import type { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import type { ProductData } from '../../modules';
3
3
  import type { OpenDataConfig } from '../../modules/OpenData';
4
4
  import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
5
5
  import type { ProductListLoadProductsParams } from '../../modules/ProductList';
6
- import type { ResourcePlannerAssignment, ResourcePlannerAssignableSlotResult, ResourcePlannerEvent, ResourcePlannerProduct, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerResource, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from '../../modules/ResourcePlanner';
7
- import type { UnifiedBookingSalesCommitPlannerSelectionParams, UnifiedBookingSalesCommitResult, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadPlannerContextParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesStagePlannerProductsParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
6
+ import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
7
+ import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
8
8
  import { BookingTicket } from '../BookingTicket';
9
9
  export * from './types';
10
+ export { AvailabilityError } from '../../modules/ResourcePlanner';
10
11
  /**
11
12
  * Converts Rules/Order discount internals into a small UI-facing diagnostic. The result keeps
12
13
  * candidate-card state separate from line-level applications: a selected card is not proof that
@@ -22,39 +23,37 @@ export declare function buildPlannerDiscountResult(params: {
22
23
  preferredDiscountId?: number | string;
23
24
  preferredDiscountFound?: boolean;
24
25
  }): UnifiedBookingSalesDiscountResult;
25
- /** Converts a ProductList record into the pure input shape consumed by ResourcePlanner. */
26
- export declare function normalizeProductForPlanner(product: ProductData | Record<string, any>): ResourcePlannerProduct;
26
+ /** Converts ProductList and schedule records into the pure Availability vocabulary. */
27
+ export declare function normalizeProductForAvailability(product: ProductData | Record<string, any>, scheduleList?: ScheduleItem[], fixedOffsetMinutes?: number): AvailabilityProduct;
27
28
  /**
28
29
  * Materializes resource work windows locally from v2's schedule ids, then keeps its flat
29
- * event_list as planner events. This deliberately avoids the older API's times -> event_list
30
+ * event_list as resource occupancy records. This deliberately avoids the older API's times -> event_list
30
31
  * response nesting and lets one resource response serve any requested date range.
31
32
  */
32
- export declare function buildPlannerResourcesFromV2(params: {
33
+ export declare function buildAvailabilityResourcesFromV2(params: {
33
34
  rawResources: Record<string, any>[];
34
35
  scheduleList: ScheduleItem[];
35
- dateRange?: ResourcePlannerQuery['dateRange'];
36
+ dateRange?: AvailabilityDateRange;
37
+ fixedOffsetMinutes?: number;
36
38
  }): {
37
- resources: ResourcePlannerResource[];
38
- externalEvents: ResourcePlannerEvent[];
39
+ resources: AvailabilityResource[];
40
+ resourceOccupancies: AvailabilityOccupancy[];
39
41
  };
40
42
  /** Combines URL-locked resources with every resource referenced by the selected products. */
41
- export declare function collectPlannerResourceIds(products: ResourcePlannerProduct[], explicitResourceIds?: Array<number | string>): Array<number | string>;
42
- /** Convenience wrapper for the usual one-resource booking case. */
43
- export declare function buildBookingFromAssignment(params: {
44
- assignment: ResourcePlannerAssignment;
45
- product: ResourcePlannerProduct;
43
+ export declare function collectAvailabilityResourceIds(products: AvailabilityProduct[], explicitResourceIds?: Array<number | string>): Array<number | string>;
44
+ export declare function buildAvailabilityLineIdentity(product: Record<string, any>): Record<string, any>;
45
+ export declare function buildBookingFromAvailabilityAssignment(params: {
46
+ assignment: Record<string, any>;
47
+ product: AvailabilityProduct;
48
+ timezone?: string;
49
+ fixedOffsetMinutes?: number;
46
50
  }): Record<string, any>;
47
- /**
48
- * Converts all resources needed by one product/time interval into the one booking expected by
49
- * OrderModule. Callers must group assignments before this function so a multi-form booking does
50
- * not become several competing bookings.
51
- */
52
- export declare function buildBookingFromAssignments(params: {
53
- assignments: ResourcePlannerAssignment[];
54
- product: ResourcePlannerProduct;
51
+ export declare function buildBookingFromAvailabilityAssignments(params: {
52
+ assignments: Record<string, any>[];
53
+ product: AvailabilityProduct;
54
+ timezone?: string;
55
+ fixedOffsetMinutes?: number;
55
56
  }): Record<string, any>;
56
- /** Builds the exact identity BaseSales needs to remove only this solution's order lines. */
57
- export declare function buildPlannerLineIdentity(product: Record<string, any>): Record<string, any>;
58
57
  export declare class UnifiedBookingSalesImpl extends BookingTicket {
59
58
  protected defaultName: string;
60
59
  protected defaultVersion: string;
@@ -63,7 +62,52 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
63
62
  private openDataTarget;
64
63
  private loadOpenDataInFlight;
65
64
  private loadOpenDataInFlightTarget;
65
+ private availabilityRuntimeOffsetMinutes;
66
+ private availabilityScheduleCatalog;
67
+ private availabilityProjectionSequence;
68
+ private availabilityContextSequence;
69
+ private availabilityLifecycleGeneration;
70
+ private availabilityContextRegistry;
71
+ private availabilityProjectionPool;
72
+ private availabilityPrepareInFlight;
73
+ private availabilityProjectionRefreshInFlight;
74
+ private availabilityRemoteOccupancyCache;
75
+ private availabilityRemoteResourceQueryInFlight;
76
+ private availabilityRemoteResourceQuerySequence;
77
+ private availabilityRemoteResourceEpoch;
78
+ private availabilityCommitLocks;
79
+ initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
66
80
  protected getSubmitOrderSalesChannel(): string;
81
+ private createAvailabilityFacadeError;
82
+ private getAvailabilityScopeDescriptor;
83
+ private normalizeAvailabilityIdList;
84
+ private normalizeAvailabilityStringList;
85
+ private normalizeAvailabilityPrepareDescriptor;
86
+ private resolveAvailabilityPrepareDefaults;
87
+ private buildAvailabilityPrepareKey;
88
+ private clearAvailabilityRemoteResourceState;
89
+ private buildAvailabilityRemoteResourceScopeKey;
90
+ private buildAvailabilityRemoteResourceQueryKey;
91
+ setOtherParams(params: Record<string, any>, { cover }?: {
92
+ cover?: boolean;
93
+ }): Promise<void>;
94
+ destroy(): Promise<void>;
95
+ private createAvailabilityContextId;
96
+ private buildAvailabilityProjectionKey;
97
+ private getAvailabilityRuntimeOffsetMinutes;
98
+ private getAvailabilityRuntimeDateTime;
99
+ private cloneAvailabilityPrepareParams;
100
+ private getAvailabilityDurationCandidateAnchorAt;
101
+ private createAvailabilityContextRef;
102
+ private emitAvailabilityDiagnostic;
103
+ private touchAvailabilityContext;
104
+ private touchAvailabilityProjection;
105
+ private removeAvailabilityProjection;
106
+ private removeAvailabilityContext;
107
+ private evictAvailabilityProjectionPool;
108
+ private evictAvailabilityContextRegistry;
109
+ private invalidateAvailabilityContextsAfterCommit;
110
+ private resetAvailabilityProjectionState;
67
111
  protected isSessionStoragePersistEnabled(): boolean;
68
112
  protected shouldUseSessionStorageForSubModule(moduleName?: string): boolean;
69
113
  /**
@@ -133,17 +177,10 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
133
177
  * diagnostic boundary for new booking skins: no pricing logic is duplicated in the planner.
134
178
  */
135
179
  applyPlannerDiscounts(params?: UnifiedBookingSalesApplyPlannerDiscountsParams): Promise<UnifiedBookingSalesDiscountResult>;
136
- /** ResourcePlanner is a required child module; fail early instead of producing partial availability. */
137
- private getPlanner;
138
180
  private buildUnifiedOrderProduct;
139
181
  /** Replacing a staged selection is idempotent and never removes unrelated cart lines. */
140
182
  private removeExistingStagedLines;
141
183
  private stageProducts;
142
- /**
143
- * Adds the current product choice to an otherwise clean planner cart without creating bookings.
144
- * This separates "what the customer wants" from the later time/resource confirmation step.
145
- */
146
- stagePlannerProducts(params: UnifiedBookingSalesStagePlannerProductsParams): Promise<Record<string, any> | null>;
147
184
  /**
148
185
  * Adds ordinary retail products without asking ResourcePlanner for booking facts.
149
186
  * Its staged lines have separate ownership so planner and retail skins can coexist safely.
@@ -155,50 +192,50 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
155
192
  * "replace the staged selection" for demo and wizard-like callers.
156
193
  */
157
194
  addRetailProduct(params: UnifiedBookingSalesAddRetailProductParams): Promise<Record<string, any>[]>;
158
- /** Normalizes caller-provided products or loads the catalog before any resource request is made. */
159
- private loadPlannerProducts;
160
- /** Loads the reusable store-level schedule catalog on demand. */
161
- private ensurePlannerSchedulesLoaded;
162
- /**
163
- * v2 resources reference schedule ids rather than expanded work times. Refresh once when the
164
- * cached schedule catalog cannot materialize all referenced ids.
165
- */
166
- private ensurePlannerSchedulesForResources;
195
+ private normalizeAvailabilityDateRange;
196
+ private assertAvailabilityPrepareParams;
197
+ private captureAvailabilityScheduleCatalog;
198
+ /** Returns the solution-lifetime schedule snapshot captured after initialization. */
199
+ private getAvailabilityScheduleCatalog;
200
+ private buildAvailabilityOperatingHoursSnapshot;
201
+ private loadAvailabilityProducts;
167
202
  /**
168
203
  * Fetches resource metadata plus flat occupied events. Work windows are intentionally derived
169
- * locally in buildPlannerResourcesFromV2 from /schedule, rather than requested from the legacy
204
+ * locally in buildAvailabilityResourcesFromV2 from /schedule, rather than requested from the legacy
170
205
  * resource dates endpoint.
171
206
  */
172
- private fetchPlannerResourcesV2;
173
- /**
174
- * Resolves the Planner context in precedence order: explicit normalized context, test raw data,
175
- * then the v2 resource API inferred from selected product requirements and any URL lock.
176
- */
177
- private loadPlannerResources;
178
- /**
179
- * Boundary between IO and pure planning. Once this returns, all later availability/slot calls
180
- * operate on the ResourcePlanner snapshot and do not issue resource requests themselves.
181
- */
182
- loadPlannerContext(params?: UnifiedBookingSalesLoadPlannerContextParams): Promise<ResourcePlannerSnapshot>;
183
- /** Returns cells, date summaries and a derived grid; cells are continuous ranges, not UI slots. */
184
- queryPlannerAvailability(query?: ResourcePlannerQuery): Promise<ResourcePlannerProjection>;
185
- /** Turns compatible availability ranges into user-selectable intervals and ready-to-commit assignments. */
186
- resolveAssignableSlots(query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
187
- /** Stores a UI choice only. It is deliberately side-effect free with respect to tempOrder. */
188
- setPlannerSelection(patch: ResourcePlannerSelectionPatch): ResourcePlannerSnapshot;
189
- /**
190
- * Legacy-friendly automatic assignment for already fixed intervals. Duration products without a
191
- * start time intentionally remain unresolved; callers offering a picker should use slots.
192
- */
193
- autoAssignPlanner(query?: ResourcePlannerQuery): Promise<ResourcePlannerSnapshot>;
194
- /** Rechecks remote events, capacity and conflicts among the current selection before committing. */
195
- validatePlannerSelection(): ResourcePlannerValidationResult;
196
- /** Read-only snapshot for UI diagnostics and progressive flow steps. */
197
- getPlannerSnapshot(): ResourcePlannerSnapshot;
198
- /**
199
- * Validates then writes assignments to tempOrder. Real order submission is opt-in so UI callers
200
- * can safely preview the cart; pass submitAfterCommit only after an explicit confirmation.
201
- */
202
- commitPlannerSelection(params?: UnifiedBookingSalesCommitPlannerSelectionParams): Promise<UnifiedBookingSalesCommitResult>;
207
+ private fetchAvailabilityResourcesV2;
208
+ private fetchAndPublishAvailabilityResourcesV2;
209
+ private refreshAvailabilityRemoteResourceQuery;
210
+ private loadAvailabilityResources;
211
+ private resolveEditingOccupancyExclusions;
212
+ private occupancyIsExcluded;
213
+ private collectCartResourceOccupancies;
214
+ private getCurrentOrderRevision;
215
+ private getAvailabilityContextEntry;
216
+ private getAvailabilityProjectionByKey;
217
+ private getActiveAvailabilityProjectionEntry;
218
+ private decorateAvailabilityCandidate;
219
+ private assertAvailabilityCandidateFreshness;
220
+ private assertContextualQueryFreshness;
221
+ private storeAvailabilityProjectionEntry;
222
+ private buildAvailabilityProjectionSnapshot;
223
+ private getSharedPreparedAvailabilitySnapshot;
224
+ private refreshAvailabilityContextProjection;
225
+ private ensureAvailabilityContextProjection;
226
+ private tryAcquireAvailabilityCommitLock;
227
+ private releaseAvailabilityCommitLock;
228
+ /** IO boundary: loads catalog, schedules, resources, occupancies, and registers one context. */
229
+ prepareAvailabilityProjection(params: UnifiedBookingSalesPrepareAvailabilityProjectionParams): Promise<AvailabilityContextRef>;
230
+ /** Pure configuration calculation over the current context projection. */
231
+ getProductTimeRanges(contextId: string, request?: GetProductTimeRangesRequest): Promise<ContextualProductTimeRangeGroup[]>;
232
+ /** Thin facade: auto-refresh on cart drift, then delegate to the pure projection query. */
233
+ queryBookingAvailability(contextId: string, request: ContextualAvailabilityQuery): Promise<ContextualAvailabilityQueryResult>;
234
+ releaseAvailabilityContext(contextId: string): void;
235
+ private assertAvailabilityCommitWriteCAS;
236
+ private findProductLineByUid;
237
+ private findLinkedBooking;
238
+ /** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
239
+ commitAvailabilitySelection(contextId: string, params: ContextualCommitAvailabilitySelectionParams): Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
203
240
  }
204
241
  export declare const UnifiedBookingSales: typeof UnifiedBookingSalesImpl;