@pisell/pisellos 2.3.72 → 2.3.74

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 (74) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +109 -65
  3. package/dist/modules/OpenData/types.d.ts +1 -0
  4. package/dist/modules/Order/index.d.ts +1 -1
  5. package/dist/modules/Order/utils.js +6 -1
  6. package/dist/modules/Quotation/index.d.ts +6 -0
  7. package/dist/modules/Quotation/index.js +75 -19
  8. package/dist/modules/ResourcePlanner/index.d.ts +0 -22
  9. package/dist/modules/ResourcePlanner/index.js +1 -180
  10. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  11. package/dist/modules/ResourcePlanner/localClock.js +183 -0
  12. package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
  13. package/dist/modules/ResourcePlanner/planner.js +2019 -936
  14. package/dist/modules/ResourcePlanner/types.d.ts +346 -187
  15. package/dist/modules/ResourcePlanner/types.js +33 -1
  16. package/dist/plugins/request.d.ts +1 -0
  17. package/dist/server/index.d.ts +8 -2
  18. package/dist/server/index.js +206 -140
  19. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  20. package/dist/server/modules/floor-plan/index.js +240 -98
  21. package/dist/server/modules/menu/index.js +48 -23
  22. package/dist/server/modules/order/index.d.ts +17 -7
  23. package/dist/server/modules/order/index.js +419 -207
  24. package/dist/server/modules/products/index.d.ts +8 -2
  25. package/dist/server/modules/products/index.js +167 -75
  26. package/dist/server/modules/resource/index.js +21 -13
  27. package/dist/solution/BookingByStep/index.d.ts +1 -1
  28. package/dist/solution/BookingTicket/index.js +4 -2
  29. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  30. package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -2
  31. package/dist/solution/UnifiedBookingSales/index.d.ts +110 -73
  32. package/dist/solution/UnifiedBookingSales/index.js +3349 -971
  33. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  34. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
  35. package/dist/solution/UnifiedBookingSales/types.d.ts +133 -76
  36. package/dist/solution/UnifiedBookingSales/types.js +4 -9
  37. package/lib/core/index.d.ts +7 -0
  38. package/lib/core/index.js +20 -2
  39. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  40. package/lib/modules/OpenData/types.d.ts +1 -0
  41. package/lib/modules/Order/index.d.ts +1 -1
  42. package/lib/modules/Order/utils.js +5 -1
  43. package/lib/modules/Quotation/index.d.ts +6 -0
  44. package/lib/modules/Quotation/index.js +49 -5
  45. package/lib/modules/ResourcePlanner/index.d.ts +0 -22
  46. package/lib/modules/ResourcePlanner/index.js +0 -123
  47. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  48. package/lib/modules/ResourcePlanner/localClock.js +270 -0
  49. package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
  50. package/lib/modules/ResourcePlanner/planner.js +1903 -798
  51. package/lib/modules/ResourcePlanner/types.d.ts +346 -187
  52. package/lib/modules/ResourcePlanner/types.js +19 -0
  53. package/lib/plugins/request.d.ts +1 -0
  54. package/lib/server/index.d.ts +8 -2
  55. package/lib/server/index.js +52 -17
  56. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  57. package/lib/server/modules/floor-plan/index.js +54 -6
  58. package/lib/server/modules/menu/index.js +31 -5
  59. package/lib/server/modules/order/index.d.ts +17 -7
  60. package/lib/server/modules/order/index.js +197 -40
  61. package/lib/server/modules/products/index.d.ts +8 -2
  62. package/lib/server/modules/products/index.js +97 -24
  63. package/lib/server/modules/resource/index.js +7 -2
  64. package/lib/solution/BookingByStep/index.d.ts +1 -1
  65. package/lib/solution/BookingTicket/index.js +2 -1
  66. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  67. package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -0
  68. package/lib/solution/UnifiedBookingSales/index.d.ts +110 -73
  69. package/lib/solution/UnifiedBookingSales/index.js +2289 -374
  70. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  71. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +376 -0
  72. package/lib/solution/UnifiedBookingSales/types.d.ts +133 -76
  73. package/lib/solution/UnifiedBookingSales/types.js +3 -2
  74. package/package.json +1 -1
@@ -1,91 +1,163 @@
1
- import type { ResourcePlannerModule } from '../../modules';
2
1
  import type { OpenDataConfig } from '../../modules/OpenData';
3
- import type { ResourcePlannerAssignment, ResourcePlannerAssignableSlotResult, ResourcePlannerContextInput, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from '../../modules/ResourcePlanner';
4
2
  import type { ProductListLoadProductsParams } from '../../modules/ProductList';
5
3
  import type { LoadScheduleAvailableDateParams } from '../../modules/Schedule/types';
4
+ import type { AvailabilityDateRange, AvailabilityErrorCode, AvailabilityId, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProjection, AvailabilityQuery, AvailabilityRequirementSelection, AvailabilityResource, AvailabilitySelectionValidationResult, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, ResourceAvailabilityGroup, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem } from '../../modules/ResourcePlanner';
6
5
  import type { BookingTicketState } from '../BookingTicket/types';
7
- export declare enum UnifiedBookingSalesHooks {
8
- onPlannerContextLoaded = "unifiedBookingSales:onPlannerContextLoaded",
9
- onPlannerCommitted = "unifiedBookingSales:onPlannerCommitted"
10
- }
6
+ export type { AvailabilityAbsoluteRange, AvailabilityAssignment, AvailabilityCell, AvailabilityDateRange, AvailabilityDisplayRange, AvailabilityErrorCode, AvailabilityId, AvailabilityMode, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProductKind, AvailabilityProjection, AvailabilityProjectionInput, AvailabilityProjectionMeta, AvailabilityQuery, AvailabilityQueryResult, AvailabilityRequirementGroup, AvailabilityRequirementGroupResult, AvailabilityRequirementSelection, AvailabilityResource, AvailabilityResourceOption, AvailabilityResourceType, AvailabilityResourceWindow, AvailabilityScheduleMode, AvailabilityScheduleRef, AvailabilityScheduleRule, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, AvailabilitySessionRange, AvailabilityStatus, DateAvailabilityGroup, DateAvailabilityItem, DateAvailabilityQuery, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityGroup, ProductAvailabilityItem, ProductAvailabilityQuery, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, QueryAvailabilityBaseRequest, ResourceAvailabilityGroup, ResourceAvailabilityQuery, ResourceAvailabilityQueryResult, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem, TimeAvailabilityQuery, TimeAvailabilityQueryResult, } from '../../modules/ResourcePlanner';
11
7
  export interface UnifiedBookingSalesState extends BookingTicketState {
12
- resourcePlanner: ResourcePlannerModule;
8
+ }
9
+ export declare enum UnifiedBookingSalesHooks {
10
+ onAvailabilityProjectionPrepared = "unifiedBookingSales:onAvailabilityProjectionPrepared",
11
+ onAvailabilitySelectionCommitted = "unifiedBookingSales:onAvailabilitySelectionCommitted",
12
+ onAvailabilityProjectionDiagnostic = "unifiedBookingSales:onAvailabilityProjectionDiagnostic"
13
13
  }
14
14
  export interface UnifiedBookingSalesOtherParams extends Record<string, any> {
15
- /**
16
- * Persist the active order workspace in sessionStorage, partitioned by cacheId.
17
- * Disabled by default and ignored when cacheId is missing.
18
- */
19
15
  enableSessionStoragePersist?: boolean;
20
16
  }
21
- /** Explicit OpenData target used by page-level UnifiedBookingSales skins. */
22
17
  export interface UnifiedBookingSalesLoadOpenDataParams {
23
18
  businessCode: string;
24
19
  channel: string;
25
- /** Bypasses the target-scoped in-memory cache. */
26
20
  force?: boolean;
27
21
  }
28
- export interface UnifiedBookingSalesLoadPlannerContextParams extends ResourcePlannerQuery {
29
- /** ProductList request options used only when products are not supplied as raw/context data. */
30
- productLoadParams?: ProductListLoadProductsParams;
31
- /** Escape hatch for tests or callers that already own raw ProductList records. */
32
- rawProducts?: Record<string, any>[];
33
- /** Escape hatch for tests or callers that already own raw resource records. */
34
- rawResources?: Record<string, any>[];
35
- /** Fully normalized Planner context; takes precedence over API loading for supplied fields. */
36
- context?: ResourcePlannerContextInput;
37
- /** Enables the v2 resource API + schedule materialization path. */
38
- useResourceDateApi?: boolean;
39
- }
40
- export interface UnifiedBookingSalesCommitPlannerSelectionParams {
41
- /** Optional selection patch applied before validation and order mutation. */
42
- selection?: ResourcePlannerSelectionPatch;
43
- /** Directly supplies selected resource/time facts, usually from resolveAssignableSlots(). */
44
- assignments?: ResourcePlannerAssignment[];
45
- /** Defaults to false. True performs the real BaseSales / OrderModule submit after tempOrder is written. */
46
- submitAfterCommit?: boolean;
47
- }
48
22
  export interface UnifiedBookingSalesLoadProductsByScheduleDateParams extends Omit<ProductListLoadProductsParams, 'schedule_date' | 'product_ids'> {
49
- /** The chosen calendar date, used for both availability lookup and ProductList schedule_date. */
50
23
  date: string;
51
- /** Optional caller-side filter applied after the availability result produces its product pool. */
52
24
  product_ids?: number[];
53
- /** Required by the availability API; this is not the low-code page id. */
54
25
  custom_page_id?: number;
55
- /** Availability API channel, commonly pc. ProductList keeps its own sales application channel. */
56
26
  channel?: string;
57
27
  }
58
- export interface UnifiedBookingSalesStagePlannerProductsParams {
59
- /** Products the customer selected before a time/resource booking exists. */
28
+ export type UnifiedBookingSalesCatalogScope = {
29
+ type: 'schedule';
30
+ customPageId: number;
31
+ channel: string;
32
+ } | {
33
+ type: 'productList';
34
+ params: ProductListLoadProductsParams;
35
+ };
36
+ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
37
+ productIds?: number[];
38
+ resourceIds?: AvailabilityId[];
39
+ dateRange?: Partial<AvailabilityDateRange>;
40
+ catalogScope?: UnifiedBookingSalesCatalogScope;
41
+ rawProducts?: Record<string, any>[];
42
+ rawResources?: Record<string, any>[];
43
+ rawOccupancies?: AvailabilityOccupancy[];
44
+ editingProductLineUids?: string[];
45
+ timezone?: string;
46
+ slotStepMinutes?: number;
47
+ businessHours?: {
48
+ startTime: string;
49
+ endTime: string;
50
+ };
51
+ mode?: 'appointment' | 'scan_order' | 'venue_grid';
52
+ }
53
+ export interface AvailabilityContextRef {
54
+ contextId: string;
55
+ }
56
+ export interface ContextualProductTimeRange extends ProductTimeRange {
57
+ availabilityContextId: string;
58
+ availabilityContextVersion: number;
59
+ }
60
+ export interface ContextualProductTimeRangeGroup extends Omit<ProductTimeRangeGroup, 'ranges'> {
61
+ ranges: ContextualProductTimeRange[];
62
+ }
63
+ export type ContextualAvailabilityQuery = Omit<Extract<AvailabilityQuery, {
64
+ target: 'product';
65
+ }>, never> | Omit<Extract<AvailabilityQuery, {
66
+ target: 'date';
67
+ }>, never> | (Omit<Extract<AvailabilityQuery, {
68
+ target: 'time';
69
+ }>, 'candidates'> & {
70
+ candidates: ContextualProductTimeRange[];
71
+ }) | (Omit<Extract<AvailabilityQuery, {
72
+ target: 'resource';
73
+ }>, 'selectedRanges'> & {
74
+ selectedRanges: ContextualProductTimeRange[];
75
+ });
76
+ export type ContextualTimeAvailabilityItem = Omit<TimeAvailabilityItem, keyof ProductTimeRange> & ContextualProductTimeRange;
77
+ export interface ContextualTimeAvailabilityGroup extends Omit<TimeAvailabilityGroup, 'times'> {
78
+ times: ContextualTimeAvailabilityItem[];
79
+ }
80
+ export interface ContextualResourceAvailabilityRangeGroup extends Omit<ResourceAvailabilityRangeGroup, 'range'> {
81
+ range: ContextualProductTimeRange;
82
+ }
83
+ export interface ContextualResourceAvailabilityGroup extends Omit<ResourceAvailabilityGroup, 'ranges'> {
84
+ ranges: ContextualResourceAvailabilityRangeGroup[];
85
+ }
86
+ type ContextualAvailabilityQueryResultMeta = {
87
+ contextId: string;
88
+ contextVersion: number;
89
+ refreshed: boolean;
90
+ };
91
+ export type ContextualAvailabilityQueryResult = (ProductAvailabilityQueryResult & ContextualAvailabilityQueryResultMeta) | (DateAvailabilityQueryResult & ContextualAvailabilityQueryResultMeta) | ({
92
+ target: 'time';
93
+ evaluatedAt: string;
94
+ snapshotId: string;
95
+ data: ContextualTimeAvailabilityGroup[];
96
+ } & ContextualAvailabilityQueryResultMeta) | ({
97
+ target: 'resource';
98
+ evaluatedAt: string;
99
+ snapshotId: string;
100
+ data: ContextualResourceAvailabilityGroup[];
101
+ } & ContextualAvailabilityQueryResultMeta);
102
+ export type UnifiedBookingSalesAvailabilityCandidate = ContextualProductTimeRange;
103
+ export type UnifiedBookingSalesProductTimeRangeGroup = ContextualProductTimeRangeGroup;
104
+ export type UnifiedBookingSalesAvailabilityQueryResult = ContextualAvailabilityQueryResult;
105
+ export interface UnifiedBookingSalesAvailabilityPreparedPayload {
106
+ context: AvailabilityContextRef;
107
+ contextVersion: number;
108
+ projection: AvailabilityProjection;
109
+ refreshed: boolean;
110
+ reason?: string;
111
+ previousOrderRevision?: AvailabilityId;
112
+ }
113
+ export interface UnifiedBookingSalesAvailabilityDiagnosticPayload {
114
+ contextId: string | null;
115
+ contextVersion: number | null;
116
+ reason: string;
117
+ projection: AvailabilityProjection | null;
118
+ action: 'prepare' | 'refresh' | 'release' | 'destroy' | 'set_other_params_reset' | 'commit_lock_wait' | 'commit_lock_acquired' | 'commit_lock_released';
119
+ snapshotId?: string;
120
+ orderRevision?: AvailabilityId;
121
+ previousOrderRevision?: AvailabilityId;
122
+ registrySize: number;
123
+ projectionPoolSize: number;
124
+ }
125
+ export interface UnifiedBookingSalesStageRetailProductsParams {
60
126
  productIds: Array<number | string>;
61
127
  productLoadParams?: ProductListLoadProductsParams;
62
128
  rawProducts?: Record<string, any>[];
63
129
  }
64
- /** Ordinary retail product staging. No resource, time, or booking facts are required. */
65
- export type UnifiedBookingSalesStageRetailProductsParams = UnifiedBookingSalesStagePlannerProductsParams;
66
- /** Adds one ordinary retail product without replacing other retail lines already in the cart. */
67
130
  export interface UnifiedBookingSalesAddRetailProductParams {
68
- /** Prefer a supplied catalog record when the UI has already loaded it. */
69
131
  product?: Record<string, any>;
70
- /** Used to resolve a product from the current catalog or load it on demand. */
71
132
  productId?: number | string;
72
- /** Defaults to one. */
73
133
  quantity?: number;
74
- /** Only used when the product is not already present in the solution catalog. */
75
134
  productLoadParams?: ProductListLoadProductsParams;
76
135
  }
77
- export interface UnifiedBookingSalesCommitResult {
136
+ export interface ContextualCommitAvailabilitySelectionParams {
137
+ mode: 'add' | 'edit';
138
+ productLineUid?: string;
139
+ orderProduct: Record<string, any>;
140
+ candidate: ContextualProductTimeRange;
141
+ requirementSelections: AvailabilityRequirementSelection[];
142
+ partySize: number;
143
+ bookingCount?: number;
144
+ }
145
+ export type UnifiedBookingSalesCommitAvailabilitySelectionParams = ContextualCommitAvailabilitySelectionParams;
146
+ export interface UnifiedBookingSalesCommitAvailabilitySelectionResult {
147
+ contextId: string;
148
+ contextVersion: number;
78
149
  tempOrder: Record<string, any> | null;
79
- assignments: ResourcePlannerAssignment[];
80
- validation: ResourcePlannerValidationResult;
81
- submitResult?: unknown;
150
+ validation: AvailabilitySelectionValidationResult;
151
+ candidate: ContextualProductTimeRange;
152
+ productLineUid?: string;
153
+ bookingUid?: string;
154
+ productLineUids?: string[];
155
+ bookingUids?: string[];
82
156
  }
157
+ export type UnifiedBookingSalesAvailabilityErrorCode = AvailabilityErrorCode;
83
158
  export interface UnifiedBookingSalesApplyPlannerDiscountsParams {
84
- /** Customer whose cards/coupons should be loaded. Defaults to tempOrder.customer_id. */
85
159
  customerId?: number | string;
86
- /** Optional explicit card/coupon id. When provided, Rules applies this card instead of auto-picking another card. */
87
160
  preferredDiscountId?: number | string;
88
- /** Defaults to true: after loading eligible cards, let Rules choose the best valid combination. */
89
161
  applyBestDiscount?: boolean;
90
162
  }
91
163
  export interface UnifiedBookingSalesDiscountItem {
@@ -110,7 +182,6 @@ export interface UnifiedBookingSalesDiscountResult {
110
182
  status: 'applied' | 'loaded' | 'no_customer';
111
183
  customerId: number | null;
112
184
  preferredDiscountFound?: boolean;
113
- /** True only when the requested card is both selected and written into a planner product line. */
114
185
  preferredDiscountApplied?: boolean;
115
186
  availableDiscounts: UnifiedBookingSalesDiscountItem[];
116
187
  selectedDiscounts: UnifiedBookingSalesDiscountItem[];
@@ -119,32 +190,18 @@ export interface UnifiedBookingSalesDiscountResult {
119
190
  summaryAfter?: unknown;
120
191
  }
121
192
  export interface UnifiedBookingSalesApi {
122
- /** Loads board OpenData for a concrete business + channel target. */
123
193
  loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
124
- /** Returns the latest OpenData payload cached by this solution instance. */
125
- getOpenData: () => OpenDataConfig | null;
126
- /** Date-first calendar availability backed by ScheduleModule. */
194
+ getOpenData: () => Promise<OpenDataConfig | null>;
127
195
  loadScheduleAvailableDate: (params: LoadScheduleAvailableDateParams) => Promise<unknown>;
128
- /** Date-first product pool derived from schedule date ids and globally sellable products. */
129
196
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
130
- /** Adds product lines only; booking creation is intentionally deferred. */
131
- stagePlannerProducts: (params: UnifiedBookingSalesStagePlannerProductsParams) => Promise<Record<string, any> | null>;
132
- /** Adds ordinary product lines only. It never creates bookings or invokes ResourcePlanner. */
133
197
  stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
134
- /** Adds one ordinary retail line while preserving all existing cart lines. */
135
198
  addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
136
- /** Loads and normalizes all IO data needed for the pure ResourcePlanner. */
137
- loadPlannerContext: (params?: UnifiedBookingSalesLoadPlannerContextParams) => Promise<ResourcePlannerSnapshot>;
138
- /** Reads continuous availability cells and UI-oriented aggregates. */
139
- queryPlannerAvailability: (query?: ResourcePlannerQuery) => Promise<ResourcePlannerProjection>;
140
- /** Produces selectable slots and the assignments required to commit them. */
141
- resolveAssignableSlots: (query?: ResourcePlannerQuery) => ResourcePlannerAssignableSlotResult;
142
- setPlannerSelection: (patch: ResourcePlannerSelectionPatch) => ResourcePlannerSnapshot;
143
- autoAssignPlanner: (query?: ResourcePlannerQuery) => Promise<ResourcePlannerSnapshot>;
144
- validatePlannerSelection: () => ResourcePlannerValidationResult;
145
- /** Validates, writes to tempOrder, and only optionally makes a real submit request. */
146
- commitPlannerSelection: (params?: UnifiedBookingSalesCommitPlannerSelectionParams) => Promise<UnifiedBookingSalesCommitResult>;
147
- /** Loads the current customer's cards/coupons, optionally applies the best one, and reports line applications. */
199
+ prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
200
+ getProductTimeRanges: (contextId: string, request?: GetProductTimeRangesRequest) => Promise<ContextualProductTimeRangeGroup[]>;
201
+ queryBookingAvailability: (contextId: string, request: ContextualAvailabilityQuery) => Promise<ContextualAvailabilityQueryResult>;
202
+ commitAvailabilitySelection: (contextId: string, params: ContextualCommitAvailabilitySelectionParams) => Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
203
+ releaseAvailabilityContext: (contextId: string) => void;
148
204
  applyPlannerDiscounts: (params?: UnifiedBookingSalesApplyPlannerDiscountsParams) => Promise<UnifiedBookingSalesDiscountResult>;
149
- getPlannerSnapshot: () => ResourcePlannerSnapshot;
150
205
  }
206
+ export type UnifiedBookingSalesNormalizedProduct = AvailabilityProduct;
207
+ export type UnifiedBookingSalesNormalizedResource = AvailabilityResource;
@@ -1,11 +1,6 @@
1
1
  export var UnifiedBookingSalesHooks = /*#__PURE__*/function (UnifiedBookingSalesHooks) {
2
- UnifiedBookingSalesHooks["onPlannerContextLoaded"] = "unifiedBookingSales:onPlannerContextLoaded";
3
- UnifiedBookingSalesHooks["onPlannerCommitted"] = "unifiedBookingSales:onPlannerCommitted";
2
+ UnifiedBookingSalesHooks["onAvailabilityProjectionPrepared"] = "unifiedBookingSales:onAvailabilityProjectionPrepared";
3
+ UnifiedBookingSalesHooks["onAvailabilitySelectionCommitted"] = "unifiedBookingSales:onAvailabilitySelectionCommitted";
4
+ UnifiedBookingSalesHooks["onAvailabilityProjectionDiagnostic"] = "unifiedBookingSales:onAvailabilityProjectionDiagnostic";
4
5
  return UnifiedBookingSalesHooks;
5
- }({});
6
-
7
- /** Explicit OpenData target used by page-level UnifiedBookingSales skins. */
8
-
9
- /** Ordinary retail product staging. No resource, time, or booking facts are required. */
10
-
11
- /** Adds one ordinary retail product without replacing other retail lines already in the cart. */
6
+ }({});
@@ -12,8 +12,15 @@ declare class PisellOSCore implements PisellCore {
12
12
  context: BusinessContext;
13
13
  server: any;
14
14
  serverOptions?: ServerOptions;
15
+ private serverModulePromise?;
15
16
  constructor(options?: PisellOSOptions);
16
17
  private initialize;
18
+ /**
19
+ * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
20
+ * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
21
+ */
22
+ preloadServerModule(): Promise<void>;
23
+ private loadServerModule;
17
24
  /**
18
25
  * 初始化 Server(公开方法,需要外部显式调用并等待)
19
26
  * Server 配置从构造函数传入的 options.server 中获取
package/lib/core/index.js CHANGED
@@ -36,7 +36,6 @@ module.exports = __toCommonJS(core_exports);
36
36
  var import_createStore = require("../store/createStore");
37
37
  var import_effects = require("../effects");
38
38
  var PisellOSCore = class {
39
- // 保存 Server 配置
40
39
  constructor(options) {
41
40
  this.plugins = /* @__PURE__ */ new Map();
42
41
  this.modules = /* @__PURE__ */ new Map();
@@ -50,6 +49,7 @@ var PisellOSCore = class {
50
49
  this.serverOptions = options.server;
51
50
  }
52
51
  this.initialize(options);
52
+ console.log("constructor1234567890");
53
53
  }
54
54
  initialize(options) {
55
55
  if (options == null ? void 0 : options.plugins) {
@@ -64,6 +64,24 @@ var PisellOSCore = class {
64
64
  }
65
65
  this.log("[PisellOS] 核心初始化完成");
66
66
  }
67
+ /**
68
+ * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
69
+ * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
70
+ */
71
+ async preloadServerModule() {
72
+ if (this.server || !this.serverOptions)
73
+ return;
74
+ await this.loadServerModule();
75
+ }
76
+ loadServerModule() {
77
+ if (!this.serverModulePromise) {
78
+ this.serverModulePromise = import("../server").catch((error) => {
79
+ this.serverModulePromise = void 0;
80
+ throw error;
81
+ });
82
+ }
83
+ return this.serverModulePromise;
84
+ }
67
85
  /**
68
86
  * 初始化 Server(公开方法,需要外部显式调用并等待)
69
87
  * Server 配置从构造函数传入的 options.server 中获取
@@ -78,7 +96,7 @@ var PisellOSCore = class {
78
96
  return;
79
97
  }
80
98
  try {
81
- const ServerModule = await import("../server");
99
+ const ServerModule = await this.loadServerModule();
82
100
  const Server = ServerModule.default;
83
101
  this.server = new Server(this);
84
102
  this.log("Server 实例已创建");
@@ -1,51 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
34
- PromotionAdapter: () => import_adapter.PromotionAdapter,
35
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
36
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
37
- default: () => import_adapter2.default
38
- });
39
- module.exports = __toCommonJS(promotion_exports);
40
- var import_evaluator = require("./evaluator");
41
- var import_adapter = require("./adapter");
42
- var import_adapter2 = __toESM(require("./adapter"));
43
- var import_examples = require("./examples");
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- BUY_X_GET_Y_FREE_STRATEGY,
47
- ITEM_REWARD_STRATEGY,
48
- PromotionAdapter,
49
- PromotionEvaluator,
50
- X_ITEMS_FOR_Y_PRICE_STRATEGY
51
- });
@@ -23,6 +23,7 @@ export interface OpenDataConfig {
23
23
  'reservation.auto_confirm'?: boolean;
24
24
  'reservation.auto_confirm_mode'?: string;
25
25
  'reservation.auto_confirm_delay_seconds'?: number;
26
+ 'reservation.time_slice'?: number | string;
26
27
  'sale.allow_item_notes'?: boolean;
27
28
  'sale.allow_order_notes'?: boolean;
28
29
  'sale.enable_item_rules'?: boolean;
@@ -512,7 +512,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
512
512
  generateIdempotencyToken(): string;
513
513
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
514
514
  createOrder(params: CommitOrderParams['query']): {
515
- type: "virtual" | "appointment_booking";
515
+ type: "appointment_booking" | "virtual";
516
516
  platform: string;
517
517
  sales_channel: string;
518
518
  order_sales_channel: string;
@@ -994,7 +994,11 @@ function buildSubmitPayload(params) {
994
994
  let submitType = type ?? tempOrder.type;
995
995
  if (!submitType) {
996
996
  if ((_a = tempOrder == null ? void 0 : tempOrder.bookings) == null ? void 0 : _a.length) {
997
- submitType = "appointment_booking";
997
+ if (businessCode === "dine_in") {
998
+ submitType = "table-order";
999
+ } else {
1000
+ submitType = "appointment_booking";
1001
+ }
998
1002
  } else {
999
1003
  submitType = "virtual";
1000
1004
  }
@@ -9,6 +9,8 @@ export declare class QuotationModule extends BaseModule implements Module {
9
9
  private request;
10
10
  private store;
11
11
  private scheduleResolver?;
12
+ private app;
13
+ private quotationListUpdatedListener?;
12
14
  constructor(name?: string, version?: string);
13
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
16
  loadQuotations(params?: {
@@ -16,6 +18,7 @@ export declare class QuotationModule extends BaseModule implements Module {
16
18
  customer_id?: number | string;
17
19
  }): Promise<void>;
18
20
  getQuotationList(): QuotationItem[];
21
+ setQuotationListUpdatedListener(listener?: () => void): void;
19
22
  getQuotationCustomerScopeInfo(): QuotationCustomerScopeInfo;
20
23
  /**
21
24
  * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
@@ -60,6 +63,9 @@ export declare class QuotationModule extends BaseModule implements Module {
60
63
  customer_id?: number | string;
61
64
  }): Map<string, string | null>;
62
65
  setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
66
+ private applyQuotationResponse;
67
+ private notifyQuotationListUpdated;
68
+ private getQuotationCacheKeyData;
63
69
  private isQuotationVisibleForCustomer;
64
70
  private hasValidCustomerId;
65
71
  private normalizeCustomerId;
@@ -32,32 +32,49 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
32
32
  this.store = { list: [] };
33
33
  }
34
34
  async initialize(core, options) {
35
+ var _a, _b;
35
36
  this.core = core;
36
37
  this.request = core.getPlugin("request");
37
38
  if (!this.request)
38
39
  throw new Error("QuotationModule 需要 request 插件支持");
40
+ this.app = (_b = (_a = core.getPlugin("app")) == null ? void 0 : _a.getApp) == null ? void 0 : _b.call(_a);
39
41
  this.store = { list: [] };
40
42
  }
41
43
  async loadQuotations(params) {
42
- var _a;
43
44
  const query = {};
44
45
  if (params == null ? void 0 : params.channel)
45
46
  query.channel = params.channel;
46
47
  if ((params == null ? void 0 : params.channel) === "online_store") {
47
48
  query.channel = "online-store";
48
49
  }
50
+ let initialResultApplied = false;
51
+ const applyRemoteUpdate = (response) => {
52
+ this.applyQuotationResponse(response);
53
+ if (initialResultApplied) {
54
+ this.notifyQuotationListUpdated();
55
+ }
56
+ };
49
57
  const res = await this.request.get(
50
58
  "/quotation/available",
51
59
  query,
52
- { useCache: false, osServer: true }
60
+ {
61
+ cache: {
62
+ type: "indexDB",
63
+ updateCache: true,
64
+ cacheKeyData: this.getQuotationCacheKeyData(query)
65
+ },
66
+ cacheUpdateChange: applyRemoteUpdate
67
+ }
53
68
  );
54
- const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
55
- list.sort((a, b) => b.sort - a.sort);
56
- this.store.list = list;
69
+ this.applyQuotationResponse(res);
70
+ initialResultApplied = true;
57
71
  }
58
72
  getQuotationList() {
59
73
  return this.store.list;
60
74
  }
75
+ setQuotationListUpdatedListener(listener) {
76
+ this.quotationListUpdatedListener = listener;
77
+ }
61
78
  getQuotationCustomerScopeInfo() {
62
79
  const customerById = /* @__PURE__ */ new Map();
63
80
  const quotationScopes = this.store.list.filter((quotation) => Array.isArray(quotation.customer) && quotation.customer.length > 0).map((quotation) => {
@@ -156,6 +173,33 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
156
173
  setScheduleResolver(resolver) {
157
174
  this.scheduleResolver = resolver;
158
175
  }
176
+ applyQuotationResponse(response) {
177
+ var _a;
178
+ const source = ((_a = response == null ? void 0 : response.data) == null ? void 0 : _a.list) || (response == null ? void 0 : response.list) || [];
179
+ this.store.list = [...source].sort((a, b) => Number(b.sort || 0) - Number(a.sort || 0));
180
+ }
181
+ notifyQuotationListUpdated() {
182
+ var _a;
183
+ try {
184
+ (_a = this.quotationListUpdatedListener) == null ? void 0 : _a.call(this);
185
+ } catch (error) {
186
+ console.warn("[QuotationModule] 报价单后台更新回调失败", error);
187
+ }
188
+ }
189
+ getQuotationCacheKeyData(query) {
190
+ var _a, _b, _c;
191
+ let shopId = "";
192
+ try {
193
+ const storedCore = (_c = (_b = (_a = this.app) == null ? void 0 : _a.storage) == null ? void 0 : _b.getStorage) == null ? void 0 : _c.call(_b, "core");
194
+ const coreInfo = typeof storedCore === "string" ? JSON.parse(storedCore || "{}") : storedCore || {};
195
+ shopId = String((coreInfo == null ? void 0 : coreInfo.id) || "");
196
+ } catch {
197
+ }
198
+ return {
199
+ ...query,
200
+ shop_id: shopId
201
+ };
202
+ }
159
203
  isQuotationVisibleForCustomer(quotation, customerId) {
160
204
  const customers = quotation.customer || [];
161
205
  if (customers.length === 0)
@@ -1,24 +1,2 @@
1
- import { BaseModule } from '../BaseModule';
2
- import type { Module, ModuleOptions, PisellCore } from '../../types';
3
- import type { ResourcePlannerAssignmentResult, ResourcePlannerAssignableSlotResult, ResourcePlannerContextInput, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from './types';
4
1
  export * from './types';
5
2
  export * from './planner';
6
- export declare enum ResourcePlannerHooks {
7
- onContextChanged = "resourcePlanner:onContextChanged",
8
- onSelectionChanged = "resourcePlanner:onSelectionChanged",
9
- onProjectionChanged = "resourcePlanner:onProjectionChanged"
10
- }
11
- export declare class ResourcePlannerModule extends BaseModule implements Module {
12
- protected defaultName: string;
13
- protected defaultVersion: string;
14
- private store;
15
- initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
16
- setContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
17
- mergeContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
18
- setSelectionPatch(patch: ResourcePlannerSelectionPatch): ResourcePlannerSnapshot;
19
- queryAvailability(query?: ResourcePlannerQuery): ResourcePlannerProjection;
20
- autoAssign(query?: ResourcePlannerQuery): ResourcePlannerAssignmentResult;
21
- resolveAssignableSlots(query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
22
- validateSelection(): ResourcePlannerValidationResult;
23
- getSnapshot(): ResourcePlannerSnapshot;
24
- }