@pisell/pisellos 0.10.70 → 0.10.72

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 (42) hide show
  1. package/dist/modules/BookingContext/utils/productExtend.d.ts +5 -0
  2. package/dist/modules/BookingContext/utils/productExtend.js +61 -23
  3. package/dist/modules/OpenData/index.d.ts +1 -0
  4. package/dist/modules/OpenData/index.js +1 -0
  5. package/dist/modules/OpenData/salesSettings.d.ts +32 -0
  6. package/dist/modules/OpenData/salesSettings.js +80 -0
  7. package/dist/modules/OpenData/types.d.ts +13 -0
  8. package/dist/modules/Order/index.d.ts +13 -4
  9. package/dist/modules/Order/index.js +1401 -764
  10. package/dist/modules/Order/types.d.ts +24 -1
  11. package/dist/modules/Order/types.js +4 -0
  12. package/dist/server/index.js +5 -2
  13. package/dist/solution/BaseSales/index.d.ts +2 -2
  14. package/dist/solution/BaseSales/index.js +8 -8
  15. package/dist/solution/BookingTicket/index.d.ts +2 -2
  16. package/dist/solution/UnifiedBookingSales/index.d.ts +36 -1
  17. package/dist/solution/UnifiedBookingSales/index.js +1434 -709
  18. package/dist/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  19. package/dist/solution/UnifiedBookingSales/salesSettings.js +81 -0
  20. package/dist/solution/UnifiedBookingSales/types.d.ts +17 -1
  21. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  22. package/lib/modules/BookingContext/utils/productExtend.d.ts +5 -0
  23. package/lib/modules/BookingContext/utils/productExtend.js +36 -3
  24. package/lib/modules/OpenData/index.d.ts +1 -0
  25. package/lib/modules/OpenData/index.js +12 -0
  26. package/lib/modules/OpenData/salesSettings.d.ts +32 -0
  27. package/lib/modules/OpenData/salesSettings.js +70 -0
  28. package/lib/modules/OpenData/types.d.ts +13 -0
  29. package/lib/modules/Order/index.d.ts +13 -4
  30. package/lib/modules/Order/index.js +284 -24
  31. package/lib/modules/Order/types.d.ts +24 -1
  32. package/lib/modules/Order/types.js +2 -0
  33. package/lib/server/index.js +5 -1
  34. package/lib/solution/BaseSales/index.d.ts +2 -2
  35. package/lib/solution/BaseSales/index.js +2 -2
  36. package/lib/solution/BookingTicket/index.d.ts +2 -2
  37. package/lib/solution/UnifiedBookingSales/index.d.ts +36 -1
  38. package/lib/solution/UnifiedBookingSales/index.js +463 -45
  39. package/lib/solution/UnifiedBookingSales/salesSettings.d.ts +16 -0
  40. package/lib/solution/UnifiedBookingSales/salesSettings.js +72 -0
  41. package/lib/solution/UnifiedBookingSales/types.d.ts +17 -1
  42. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ import type { MultipleBookingScheduling } from '../../modules/OpenData';
2
+ export interface ResolveDefaultBookingStartParams {
3
+ /** Product bookings in cart insertion order; unrelated order-level bookings are excluded by the facade. */
4
+ bookings: readonly Record<string, any>[];
5
+ holderIds?: unknown;
6
+ mode?: MultipleBookingScheduling;
7
+ fallback?: string;
8
+ }
9
+ /** Normalize scalar/array holder identities without merging the no-holder group with real holders. */
10
+ export declare function normalizeBookingHolderIds(value: unknown): string[];
11
+ export declare function getBookingHolderIds(booking: Record<string, any>): string[];
12
+ /** Validate input and convert absolute ISO values to the runtime-local date/time used by booking fields. */
13
+ export declare function normalizeBookingDateTime(value: unknown): string | undefined;
14
+ export declare function getBookingBoundary(booking: Record<string, any>, edge: 'start' | 'end'): string | undefined;
15
+ /** Select a default only; availability and resource occupancy remain the commit path's authority. */
16
+ export declare function resolveDefaultBookingStart({ bookings, holderIds, mode, fallback, }: ResolveDefaultBookingStartParams): string | undefined;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBookingBoundary = getBookingBoundary;
7
+ exports.getBookingHolderIds = getBookingHolderIds;
8
+ exports.normalizeBookingDateTime = normalizeBookingDateTime;
9
+ exports.normalizeBookingHolderIds = normalizeBookingHolderIds;
10
+ exports.resolveDefaultBookingStart = resolveDefaultBookingStart;
11
+ var _dayjs = _interopRequireDefault(require("dayjs"));
12
+ var _pickupTiming = require("../../modules/Order/pickupTiming");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ /** Normalize scalar/array holder identities without merging the no-holder group with real holders. */
15
+ function normalizeBookingHolderIds(value) {
16
+ const values = Array.isArray(value) ? value : value == null ? [] : [value];
17
+ return Array.from(new Set(values.flatMap(id => {
18
+ if (typeof id !== 'string' && typeof id !== 'number') return [];
19
+ const text = String(id).trim();
20
+ return text && text !== '0' ? [text] : [];
21
+ })));
22
+ }
23
+ function getBookingHolderIds(booking) {
24
+ return normalizeBookingHolderIds(booking.holder_id ?? booking.metadata?.holder_id ?? booking.holder?.form_record ?? booking.metadata?.holder?.form_record ?? booking._extend?.holder_id ?? booking._extend?.holder?.form_record);
25
+ }
26
+
27
+ /** Validate input and convert absolute ISO values to the runtime-local date/time used by booking fields. */
28
+ function normalizeBookingDateTime(value) {
29
+ if (typeof value !== 'string') return undefined;
30
+ const text = value.trim().replace(' ', 'T');
31
+ const match = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d{1,3})?)?(Z|[+-]\d{2}:\d{2})?$/.exec(text);
32
+ if (!match) return undefined;
33
+ const [, y, m, d, h, minute, second = '0', zone] = match;
34
+ const calendar = new Date(`${y}-${m}-${d}T00:00:00.000Z`);
35
+ if (!Number.isFinite(calendar.getTime()) || calendar.toISOString().slice(0, 10) !== `${y}-${m}-${d}` || Number(h) > 23 || Number(minute) > 59 || Number(second) > 59 || !(0, _dayjs.default)(text).isValid()) return undefined;
36
+ return zone ? (0, _dayjs.default)(text).format('YYYY-MM-DDTHH:mm:ss') : text;
37
+ }
38
+ function getBookingBoundary(booking, edge) {
39
+ const direct = booking[`${edge}At`] ?? booking[`${edge}_at`];
40
+ const directTime = normalizeBookingDateTime(direct);
41
+ if (directTime) return directTime;
42
+ const date = booking[`${edge}_date`];
43
+ const time = booking[`${edge}_time`];
44
+ if (typeof date !== 'string') return undefined;
45
+ return typeof time === 'string' ? normalizeBookingDateTime(`${date.slice(0, 10)}T${time}`) : normalizeBookingDateTime(date);
46
+ }
47
+
48
+ /** Select a default only; availability and resource occupancy remain the commit path's authority. */
49
+ function resolveDefaultBookingStart({
50
+ bookings,
51
+ holderIds,
52
+ mode = 'one_after_another',
53
+ fallback
54
+ }) {
55
+ const holders = new Set(normalizeBookingHolderIds(holderIds));
56
+ const related = bookings.flatMap(booking => {
57
+ if (!booking || (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || booking.deleted_at) return [];
58
+ const previousHolders = getBookingHolderIds(booking);
59
+ const matches = holders.size === 0 ? previousHolders.length === 0 : previousHolders.some(holder => holders.has(holder));
60
+ if (!matches) return [];
61
+ const start = getBookingBoundary(booking, 'start');
62
+ const end = getBookingBoundary(booking, 'end');
63
+ if (!start || !end || !(0, _dayjs.default)(end).isAfter((0, _dayjs.default)(start))) return [];
64
+ return [{
65
+ start,
66
+ end
67
+ }];
68
+ });
69
+ if (!related.length) return normalizeBookingDateTime(fallback);
70
+ if (mode === 'same_start_time') return related[related.length - 1].start;
71
+ return related.reduce((latest, booking) => (0, _dayjs.default)(booking.end).isAfter((0, _dayjs.default)(latest)) ? booking.end : latest, related[0].end);
72
+ }
@@ -59,6 +59,12 @@ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
59
59
  dateRange?: Partial<AvailabilityDateRange>;
60
60
  catalogScope?: UnifiedBookingSalesCatalogScope;
61
61
  rawProducts?: Record<string, any>[];
62
+ /** Keep an independent catalog/projection without replacing the public sales catalog. Defaults to true. */
63
+ publishCatalog?: boolean;
64
+ /** Await remote occupancy refresh instead of stale-while-revalidate. Ignores rawResources; does not lock resources. */
65
+ refreshOccupancies?: boolean;
66
+ /** Enforce configured sale cutoffs and disable manual POS availability overrides for this context. Defaults to false. */
67
+ strictAvailability?: boolean;
62
68
  rawResources?: Record<string, any>[];
63
69
  rawOccupancies?: AvailabilityOccupancy[];
64
70
  editingProductLineUids?: string[];
@@ -152,10 +158,20 @@ export interface UnifiedBookingSalesAddRetailProductParams {
152
158
  productId?: number | string;
153
159
  quantity?: number;
154
160
  productLoadParams?: ProductListLoadProductsParams;
161
+ salesNotes?: SalesNoteDraftInput[];
162
+ availabilityCommitGuard?: () => void;
155
163
  }
156
164
  export interface ContextualCommitAvailabilitySelectionParams {
157
- mode: 'add' | 'edit';
165
+ mode: 'add' | 'edit' | 'replace';
166
+ /** Local UI intent guard, checked again immediately before the Order mutation. */
167
+ availabilityCommitGuard?: () => void;
158
168
  productLineUid?: string;
169
+ /**
170
+ * Confirmed complete Party extras set (configured, service-datetime-repriced retail source products).
171
+ * Required for replace; edit opts into the same atomic path. Existing extras keep their own
172
+ * metadata.unique_identification_number; new extras omit it. [] explicitly removes all owned extras.
173
+ */
174
+ relatedRetailProducts?: Record<string, any>[];
159
175
  orderProduct: Record<string, any>;
160
176
  candidate: ContextualProductTimeRange;
161
177
  requirementSelections: AvailabilityRequirementSelection[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.70",
4
+ "version": "0.10.72",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",