@pisell/pisellos 2.3.105 → 2.3.106

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.
@@ -697,14 +697,9 @@ function normalizeResource(raw) {
697
697
  var id = (_ref5 = (_raw$resourceId = raw.resourceId) !== null && _raw$resourceId !== void 0 ? _raw$resourceId : raw.resource_id) !== null && _ref5 !== void 0 ? _ref5 : raw.id;
698
698
  if (id === undefined || id === null || id === '') return null;
699
699
  var rawWindows = raw.windows || raw.times || [];
700
- return {
701
- id: id,
702
- formId: (_ref6 = (_raw$formId = raw.formId) !== null && _raw$formId !== void 0 ? _raw$formId : raw.form_id) !== null && _ref6 !== void 0 ? _ref6 : raw.resource_form_id,
703
- name: raw.resourceName || raw.main_field || raw.name || raw.title,
704
- code: raw.code,
705
- resourceType: normalizeResourceType(raw.type || raw.resourceType),
706
- capacity: Math.max(1, Number(raw.capacity || raw.max_capacity || 1) || 1),
707
- windows: (Array.isArray(rawWindows) ? rawWindows : []).flatMap(function (window) {
700
+ var rawExcludedWindows = raw.excludedWindows || raw.excluded_windows || [];
701
+ var normalizeWindows = function normalizeWindows(windows) {
702
+ return (Array.isArray(windows) ? windows : []).flatMap(function (window) {
708
703
  var range = normalizeAvailabilityLocalDateTimeRange({
709
704
  startAt: window.startAt || window.start_at || window.start,
710
705
  endAt: window.endAt || window.end_at || window.end,
@@ -718,7 +713,17 @@ function normalizeResource(raw) {
718
713
  source: window.source,
719
714
  raw: window
720
715
  }];
721
- }),
716
+ });
717
+ };
718
+ return {
719
+ id: id,
720
+ formId: (_ref6 = (_raw$formId = raw.formId) !== null && _raw$formId !== void 0 ? _raw$formId : raw.form_id) !== null && _ref6 !== void 0 ? _ref6 : raw.resource_form_id,
721
+ name: raw.resourceName || raw.main_field || raw.name || raw.title,
722
+ code: raw.code,
723
+ resourceType: normalizeResourceType(raw.type || raw.resourceType),
724
+ capacity: Math.max(1, Number(raw.capacity || raw.max_capacity || 1) || 1),
725
+ windows: normalizeWindows(rawWindows),
726
+ excludedWindows: normalizeWindows(rawExcludedWindows),
722
727
  raw: raw
723
728
  };
724
729
  }
@@ -742,6 +747,16 @@ function dateRangeDays(dateRange) {
742
747
  }
743
748
  return dates;
744
749
  }
750
+ function getExcludedScheduleDateOverrideTimePoints(date, schedule) {
751
+ var _schedule$repeat_rule;
752
+ if (!((_schedule$repeat_rule = schedule.repeat_rule) !== null && _schedule$repeat_rule !== void 0 && (_schedule$repeat_rule = _schedule$repeat_rule.excluded_date) !== null && _schedule$repeat_rule !== void 0 && _schedule$repeat_rule.length)) return [];
753
+ if (getScheduleStartEndTimePoints(date, [schedule]).length > 0) return [];
754
+ return getScheduleStartEndTimePoints(date, [_objectSpread(_objectSpread({}, schedule), {}, {
755
+ repeat_rule: _objectSpread(_objectSpread({}, schedule.repeat_rule), {}, {
756
+ excluded_date: []
757
+ })
758
+ })]);
759
+ }
745
760
  function normalizeResourceOccupancy(rawEvent, resourceId) {
746
761
  var _ref9, _ref10, _rawEvent$start_at, _ref11, _ref12, _rawEvent$end_at, _ref13, _ref14, _rawEvent$pax, _rawEvent$schedule_ev, _ref15, _rawEvent$schedule_ev2, _ref16, _rawEvent$booking_uid, _rawEvent$metadata, _ref17, _rawEvent$product_uid, _rawEvent$metadata2;
747
762
  var source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'remote';
@@ -848,7 +863,30 @@ export function buildAvailabilityResourcesFromV2(params) {
848
863
  });
849
864
  });
850
865
  });
866
+ var excludedWindows = dates.flatMap(function (date) {
867
+ return schedules.flatMap(function (schedule) {
868
+ return getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(function (slot) {
869
+ var range = normalizeAvailabilityLocalDateTimeRange({
870
+ startAt: slot.start_at,
871
+ endAt: slot.end_at,
872
+ fixedOffsetMinutes: fixedOffsetMinutes,
873
+ rollOverEnd: true
874
+ });
875
+ if (!range) return [];
876
+ return [{
877
+ startAt: range.startAt,
878
+ endAt: range.endAt,
879
+ source: "resource_schedule_excluded:".concat(schedule.id),
880
+ raw: {
881
+ scheduleId: schedule.id,
882
+ excludedDate: date
883
+ }
884
+ }];
885
+ });
886
+ });
887
+ });
851
888
  resource.windows = materializedWindows.length > 0 ? materializedWindows : explicitWindows;
889
+ resource.excludedWindows = [].concat(_toConsumableArray(resource.excludedWindows || []), _toConsumableArray(excludedWindows));
852
890
  if (resource.windows.length === 0 && missingScheduleIds.length > 0) {
853
891
  resource.windows = buildResourceWindowFallbackTimes({
854
892
  raw: raw,
@@ -1116,7 +1154,7 @@ function buildBookingFromAvailabilitySelection(params) {
1116
1154
  } : {})
1117
1155
  });
1118
1156
  }
1119
- var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
1157
+ var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'schedule_excluded_date', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
1120
1158
  // A required group whose selected resource is outside its window is surfaced
1121
1159
  // as missing_resource at group level. Structural validation below still
1122
1160
  // rejects a genuinely missing selection.
@@ -3319,12 +3357,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3319
3357
  }] : [];
3320
3358
  });
3321
3359
  });
3322
- return {
3360
+ var excludedWindows = dateRangeDays(params.dateRange).flatMap(function (date) {
3361
+ return schedules.flatMap(function (schedule) {
3362
+ return getExcludedScheduleDateOverrideTimePoints(date, schedule).flatMap(function (slot) {
3363
+ var range = normalizeAvailabilityLocalDateTimeRange({
3364
+ startAt: slot.start_at,
3365
+ endAt: slot.end_at,
3366
+ fixedOffsetMinutes: _this4.getAvailabilityRuntimeOffsetMinutes(),
3367
+ rollOverEnd: true
3368
+ });
3369
+ return range ? [{
3370
+ startAt: range.startAt,
3371
+ endAt: range.endAt,
3372
+ source: "operating_schedule_excluded:".concat(schedule.id),
3373
+ raw: {
3374
+ scheduleId: schedule.id,
3375
+ excludedDate: date
3376
+ }
3377
+ }] : [];
3378
+ });
3379
+ });
3380
+ });
3381
+ return _objectSpread({
3323
3382
  source: descriptor.source,
3324
3383
  scheduleIds: _toConsumableArray(descriptor.scheduleIds),
3325
3384
  missingScheduleIds: missingScheduleIds,
3326
3385
  windows: windows
3327
- };
3386
+ }, excludedWindows.length > 0 ? {
3387
+ excludedWindows: excludedWindows
3388
+ } : {});
3328
3389
  }
3329
3390
  }, {
3330
3391
  key: "loadAvailabilityProducts",
@@ -4498,7 +4559,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4498
4559
  allowOutsideOperatingHoursForRequestedStartTimes: true
4499
4560
  } : {}), {
4500
4561
  evaluatedAt: this.getAvailabilityRuntimeDateTime(),
4501
- allowSessionCustomRanges: isPosAvailabilityRequest
4562
+ useExactDurationCandidateMinute: isPosAvailabilityRequest,
4563
+ allowSessionCustomRanges: isPosAvailabilityRequest,
4564
+ allowExcludedScheduleDateOverride: isPosAvailabilityRequest
4502
4565
  }).map(function (group) {
4503
4566
  return _objectSpread(_objectSpread({}, group), {}, {
4504
4567
  ranges: group.ranges.map(function (candidate) {
@@ -4521,7 +4584,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4521
4584
  key: "queryBookingAvailability",
4522
4585
  value: (function () {
4523
4586
  var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(contextId, request) {
4524
- var _yield$this$ensureAva2, context, projectionEntry, refreshed, result, contextVersion, contextualResult;
4587
+ var _this$otherParams$pla2, _this$otherParams25;
4588
+ var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
4525
4589
  return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4526
4590
  while (1) switch (_context41.prev = _context41.next) {
4527
4591
  case 0:
@@ -4533,7 +4597,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4533
4597
  projectionEntry = _yield$this$ensureAva2.projectionEntry;
4534
4598
  refreshed = _yield$this$ensureAva2.refreshed;
4535
4599
  this.assertContextualQueryFreshness(context, request);
4536
- result = queryAvailabilityProjection(projectionEntry.projection, request);
4600
+ isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4601
+ result = queryAvailabilityProjection(projectionEntry.projection, request, {
4602
+ useExactDurationCandidateMinute: isPosAvailabilityRequest,
4603
+ allowExcludedScheduleDateOverride: isPosAvailabilityRequest
4604
+ });
4537
4605
  contextVersion = context.activeVersion;
4538
4606
  contextualResult = result.target === 'time' ? _objectSpread(_objectSpread({}, result), {}, {
4539
4607
  data: result.data.map(function (group) {
@@ -4565,7 +4633,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4565
4633
  contextVersion: contextVersion,
4566
4634
  refreshed: refreshed
4567
4635
  }));
4568
- case 11:
4636
+ case 12:
4569
4637
  case "end":
4570
4638
  return _context41.stop();
4571
4639
  }
@@ -4642,7 +4710,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4642
4710
  key: "commitAvailabilitySelection",
4643
4711
  value: (function () {
4644
4712
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(contextId, params) {
4645
- var normalizedContextId, _params$bookingCount, _ref51, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla2, _this$otherParams25, _ref52, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref53, _ref54, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref55, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4713
+ var normalizedContextId, _params$bookingCount, _ref51, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams26, _ref52, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref53, _ref54, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref55, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4646
4714
  return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4647
4715
  while (1) switch (_context42.prev = _context42.next) {
4648
4716
  case 0:
@@ -4872,7 +4940,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4872
4940
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4873
4941
  candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
4874
4942
  candidateStartTime = getCandidateStartTime(params.candidate);
4875
- allowPosAvailabilityOverride = String((_this$otherParams$pla2 = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
4943
+ allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
4876
4944
  refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
4877
4945
  productIds: [params.candidate.productId],
4878
4946
  dateRange: {
@@ -4886,7 +4954,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4886
4954
  }, allowPosAvailabilityOverride ? {
4887
4955
  allowOutsideOperatingHoursForRequestedStartTimes: true
4888
4956
  } : {}) : {}) : {}), {
4889
- allowSessionCustomRanges: allowPosAvailabilityOverride
4957
+ useExactDurationCandidateMinute: allowPosAvailabilityOverride,
4958
+ allowSessionCustomRanges: allowPosAvailabilityOverride,
4959
+ allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
4890
4960
  }).flatMap(function (group) {
4891
4961
  return group.ranges;
4892
4962
  });
@@ -4919,6 +4989,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4919
4989
  requirementSelections: params.requirementSelections,
4920
4990
  partySize: partySize,
4921
4991
  bookingCount: bookingCount
4992
+ }, {
4993
+ useExactDurationCandidateMinute: allowPosAvailabilityOverride,
4994
+ allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
4922
4995
  });
4923
4996
  if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(function (conflict) {
4924
4997
  return POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code);
@@ -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";
@@ -5122,6 +5122,23 @@ class OrderModule extends _BaseModule.BaseModule {
5122
5122
  row.metadata.booking_uid = row.booking_uid;
5123
5123
  }
5124
5124
  row = (0, _bundleDiscountHydration.restoreHydratedBundleDiscounts)(row, _utils.normalizeOrderProductDiscountList);
5125
+ const rawOriginalPrice = Number(row.original_price);
5126
+ const rawSellingPrice = Number(row.selling_price);
5127
+ const hasProductDiscounts = Array.isArray(row.discount_list) && row.discount_list.length > 0;
5128
+ const hasBundleDiscounts = row.product_bundle.some(bundle => Array.isArray(bundle?.discount_list) && bundle.discount_list.length > 0);
5129
+ const isUndiscountedV2Line = String(row.metadata.price_schema_version) === '2' && Number.isFinite(rawOriginalPrice) && Number.isFinite(rawSellingPrice) && new _decimal.default(rawOriginalPrice).eq(rawSellingPrice) && !hasProductDiscounts && !hasBundleDiscounts;
5130
+ if (isUndiscountedV2Line) {
5131
+ const hasPriceValue = value => value !== undefined && value !== null && value !== '';
5132
+ row.product_bundle = row.product_bundle.map(bundle => {
5133
+ if (!bundle || (0, _utils.isMarkdownBundle)(bundle) || hasPriceValue(bundle.original_price) || hasPriceValue(bundle.product_price) || !hasPriceValue(bundle.bundle_selling_price)) {
5134
+ return bundle;
5135
+ }
5136
+ return {
5137
+ ...bundle,
5138
+ original_price: bundle.bundle_selling_price
5139
+ };
5140
+ });
5141
+ }
5125
5142
  const existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
5126
5143
  if (!existingIdentity) {
5127
5144
  row.metadata.unique_identification_number = (0, _utils.createUuidV4)();
@@ -1,5 +1,5 @@
1
1
  import type { AvailabilityProjection, AvailabilityProjectionInput, AvailabilityQuery, AvailabilityQueryResult, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, GetProductTimeRangesRequest, GetProductTimeRangesRuntimeOptions, ProductTimeRangeGroup } from './types';
2
2
  export declare function createAvailabilityProjection(input: AvailabilityProjectionInput): AvailabilityProjection;
3
3
  export declare function getProductTimeRanges(projection: AvailabilityProjection, request?: GetProductTimeRangesRequest, runtimeOptions?: GetProductTimeRangesRuntimeOptions): ProductTimeRangeGroup[];
4
- export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery): AvailabilityQueryResult;
5
- export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams): AvailabilitySelectionValidationResult;
4
+ export declare function queryAvailabilityProjection(projection: AvailabilityProjection, request: AvailabilityQuery, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilityQueryResult;
5
+ export declare function validateAvailabilitySelection(projection: AvailabilityProjection, params: AvailabilitySelectionValidationParams, runtimeOptions?: GetProductTimeRangesRuntimeOptions): AvailabilitySelectionValidationResult;