@pisell/pisellos 0.10.77 → 0.10.78
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.
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.d.ts +2 -0
- package/dist/modules/ProductList/index.js +125 -39
- package/dist/modules/ResourcePlanner/planner.js +5 -0
- package/dist/solution/BaseSales/index.d.ts +12 -1
- package/dist/solution/BaseSales/index.js +275 -185
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -13
- package/dist/solution/UnifiedBookingSales/index.d.ts +23 -1
- package/dist/solution/UnifiedBookingSales/index.js +1307 -635
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/sessionResourceCache.js +271 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +25 -2
- package/dist/solution/UnifiedBookingSales/types.js +2 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +277 -0
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ProductList/index.d.ts +2 -0
- package/lib/modules/ProductList/index.js +56 -0
- package/lib/modules/ResourcePlanner/planner.js +4 -0
- package/lib/solution/BaseSales/index.d.ts +12 -1
- package/lib/solution/BaseSales/index.js +65 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +1 -13
- package/lib/solution/UnifiedBookingSales/index.d.ts +23 -1
- package/lib/solution/UnifiedBookingSales/index.js +359 -5
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/sessionResourceCache.js +199 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +25 -2
- package/lib/solution/UnifiedBookingSales/types.js +1 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.d.ts +32 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +151 -0
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AvailabilityDateRange } from '../../modules/ResourcePlanner';
|
|
2
|
+
type ResourceId = number | string;
|
|
3
|
+
type RawResource = Record<string, any>;
|
|
4
|
+
export interface AvailabilitySessionResourceQuery {
|
|
5
|
+
resourceIds: ResourceId[];
|
|
6
|
+
dateRange: AvailabilityDateRange;
|
|
7
|
+
}
|
|
8
|
+
export interface AvailabilitySessionResourceLoadParams extends AvailabilitySessionResourceQuery {
|
|
9
|
+
/** The owner supplies shop/tenant, order cache, business and channel identity. */
|
|
10
|
+
scopeKey: string;
|
|
11
|
+
timezoneName: string;
|
|
12
|
+
/** Must reject transport/business errors; only a successful empty array is negative coverage. */
|
|
13
|
+
fetch: (query: AvailabilitySessionResourceQuery) => Promise<RawResource[]>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Opt-in venue-session snapshots. Unlike the legacy SWR cache, a covered resource/day is never
|
|
17
|
+
* refreshed or evicted during this session. Only missing cells are fetched, including when a new
|
|
18
|
+
* resource set partly overlaps an earlier one. The final backend submission remains authoritative.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AvailabilitySessionResourceCache {
|
|
21
|
+
private readonly cells;
|
|
22
|
+
private readonly pending;
|
|
23
|
+
private generation;
|
|
24
|
+
clear(): void;
|
|
25
|
+
load(params: AvailabilitySessionResourceLoadParams): Promise<RawResource[]>;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
var _excluded = ["event_list"];
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
7
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
11
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
16
|
+
import { cloneDeep } from 'lodash-es';
|
|
17
|
+
import { dateOrdinalFromLocalDate, formatLocalDate, localDateTimeToScalar, localDateToScalarStart, nextDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
|
|
18
|
+
function datesInRange(range) {
|
|
19
|
+
var count = dateOrdinalFromLocalDate(range.endDate) - dateOrdinalFromLocalDate(range.startDate) + 1;
|
|
20
|
+
// A legal 90-business-day projection may include its preceding opening and overnight tail.
|
|
21
|
+
if (count < 1 || count > 92) throw new Error('Resource coverage requires a valid range of at most 92 days.');
|
|
22
|
+
var dates = [];
|
|
23
|
+
var date = formatLocalDate(range.startDate);
|
|
24
|
+
for (var index = 0; index < count; index += 1) {
|
|
25
|
+
dates.push(date);
|
|
26
|
+
date = nextDate(date);
|
|
27
|
+
}
|
|
28
|
+
return dates;
|
|
29
|
+
}
|
|
30
|
+
function resourceIdOf(resource) {
|
|
31
|
+
var _ref, _resource$resourceId;
|
|
32
|
+
return (_ref = (_resource$resourceId = resource.resourceId) !== null && _resource$resourceId !== void 0 ? _resource$resourceId : resource.resource_id) !== null && _ref !== void 0 ? _ref : resource.id;
|
|
33
|
+
}
|
|
34
|
+
function eventTime(event, edge) {
|
|
35
|
+
var _ref2, _ref3, _ref4, _event;
|
|
36
|
+
return String((_ref2 = (_ref3 = (_ref4 = (_event = event["".concat(edge, "_at")]) !== null && _event !== void 0 ? _event : event["".concat(edge, "At")]) !== null && _ref4 !== void 0 ? _ref4 : event["".concat(edge, "_time")]) !== null && _ref3 !== void 0 ? _ref3 : event["".concat(edge, "Time")]) !== null && _ref2 !== void 0 ? _ref2 : '');
|
|
37
|
+
}
|
|
38
|
+
function stableValue(value) {
|
|
39
|
+
if (Array.isArray(value)) return value.map(stableValue);
|
|
40
|
+
if (value && _typeof(value) === 'object') {
|
|
41
|
+
return Object.keys(value).sort().reduce(function (result, key) {
|
|
42
|
+
result[key] = stableValue(value[key]);
|
|
43
|
+
return result;
|
|
44
|
+
}, {});
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
function eventIdentity(event) {
|
|
49
|
+
var _ref5, _ref6, _event$schedule_event;
|
|
50
|
+
var id = (_ref5 = (_ref6 = (_event$schedule_event = event.schedule_event_id) !== null && _event$schedule_event !== void 0 ? _event$schedule_event : event.scheduleEventId) !== null && _ref6 !== void 0 ? _ref6 : event.server_event_id) !== null && _ref5 !== void 0 ? _ref5 : event.id;
|
|
51
|
+
var isUniqueEvent = id !== undefined && id !== null && id !== '';
|
|
52
|
+
return {
|
|
53
|
+
// A booking/product UID can own several allocations. Only an actual event ID plus its
|
|
54
|
+
// interval identifies one event; otherwise retain the complete payload and its multiplicity.
|
|
55
|
+
key: isUniqueEvent ? "event:".concat(JSON.stringify([String(id), eventTime(event, 'start'), eventTime(event, 'end')])) : "raw:".concat(JSON.stringify(stableValue(event))),
|
|
56
|
+
isUniqueEvent: isUniqueEvent
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function eventsOnDate(events, date) {
|
|
60
|
+
var start = localDateToScalarStart(date);
|
|
61
|
+
var end = localDateToScalarStart(nextDate(date));
|
|
62
|
+
return events.filter(function (event) {
|
|
63
|
+
try {
|
|
64
|
+
var eventStart = localDateTimeToScalar(parseLocalDateTime(eventTime(event, 'start')));
|
|
65
|
+
var eventEnd = localDateTimeToScalar(parseLocalDateTime(eventTime(event, 'end')));
|
|
66
|
+
return eventStart < eventEnd && eventStart < end && eventEnd > start;
|
|
67
|
+
} catch (_unused) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Opt-in venue-session snapshots. Unlike the legacy SWR cache, a covered resource/day is never
|
|
75
|
+
* refreshed or evicted during this session. Only missing cells are fetched, including when a new
|
|
76
|
+
* resource set partly overlaps an earlier one. The final backend submission remains authoritative.
|
|
77
|
+
*/
|
|
78
|
+
export var AvailabilitySessionResourceCache = /*#__PURE__*/function () {
|
|
79
|
+
function AvailabilitySessionResourceCache() {
|
|
80
|
+
_classCallCheck(this, AvailabilitySessionResourceCache);
|
|
81
|
+
_defineProperty(this, "cells", new Map());
|
|
82
|
+
_defineProperty(this, "pending", new Map());
|
|
83
|
+
_defineProperty(this, "generation", 0);
|
|
84
|
+
}
|
|
85
|
+
_createClass(AvailabilitySessionResourceCache, [{
|
|
86
|
+
key: "clear",
|
|
87
|
+
value: function clear() {
|
|
88
|
+
this.generation += 1;
|
|
89
|
+
this.cells.clear();
|
|
90
|
+
this.pending.clear();
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "load",
|
|
94
|
+
value: function () {
|
|
95
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
96
|
+
var _this = this;
|
|
97
|
+
var generation, assertCurrent, resources, dates, key, waits, gaps, previousIds, result;
|
|
98
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
99
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
100
|
+
case 0:
|
|
101
|
+
generation = this.generation;
|
|
102
|
+
assertCurrent = function assertCurrent() {
|
|
103
|
+
if (generation !== _this.generation) {
|
|
104
|
+
throw Object.assign(new Error('Resource session changed while loading. Please prepare again.'), {
|
|
105
|
+
code: 'AVAILABILITY_CONTEXT_NOT_FOUND'
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
resources = Array.from(new Map(params.resourceIds.filter(function (id) {
|
|
110
|
+
return id !== undefined && id !== null && id !== '';
|
|
111
|
+
}).map(function (id) {
|
|
112
|
+
return [String(id), id];
|
|
113
|
+
})).values());
|
|
114
|
+
dates = datesInRange(params.dateRange);
|
|
115
|
+
key = function key(resourceId, date) {
|
|
116
|
+
return JSON.stringify([params.scopeKey, params.timezoneName, String(resourceId), date]);
|
|
117
|
+
};
|
|
118
|
+
waits = new Set();
|
|
119
|
+
gaps = [];
|
|
120
|
+
previousIds = '';
|
|
121
|
+
dates.forEach(function (date) {
|
|
122
|
+
var missing = resources.filter(function (resourceId) {
|
|
123
|
+
var cellKey = key(resourceId, date);
|
|
124
|
+
if (_this.cells.has(cellKey)) return false;
|
|
125
|
+
var pending = _this.pending.get(cellKey);
|
|
126
|
+
if (pending) {
|
|
127
|
+
waits.add(pending);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}).sort(function (left, right) {
|
|
132
|
+
return String(left).localeCompare(String(right));
|
|
133
|
+
});
|
|
134
|
+
var ids = JSON.stringify(missing.map(String));
|
|
135
|
+
var previous = gaps[gaps.length - 1];
|
|
136
|
+
if (missing.length && ids === previousIds && previous && nextDate(previous.dateRange.endDate) === date) {
|
|
137
|
+
previous.dateRange.endDate = date;
|
|
138
|
+
} else if (missing.length) {
|
|
139
|
+
gaps.push({
|
|
140
|
+
resourceIds: missing,
|
|
141
|
+
dateRange: {
|
|
142
|
+
startDate: date,
|
|
143
|
+
endDate: date
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
previousIds = ids;
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Reserve every missing cell synchronously before dispatching any request. This also deduplicates
|
|
151
|
+
// partial overlapping in-flight queries, rather than only identical or fully covering requests.
|
|
152
|
+
gaps.forEach(function (query) {
|
|
153
|
+
var queryDates = datesInRange(query.dateRange);
|
|
154
|
+
var cellKeys = query.resourceIds.flatMap(function (id) {
|
|
155
|
+
return queryDates.map(function (date) {
|
|
156
|
+
return key(id, date);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
var promise = Promise.resolve().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
160
|
+
var response, byId, updates;
|
|
161
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
162
|
+
while (1) switch (_context.prev = _context.next) {
|
|
163
|
+
case 0:
|
|
164
|
+
assertCurrent();
|
|
165
|
+
_context.next = 3;
|
|
166
|
+
return params.fetch(cloneDeep(query));
|
|
167
|
+
case 3:
|
|
168
|
+
response = _context.sent;
|
|
169
|
+
assertCurrent();
|
|
170
|
+
if (Array.isArray(response)) {
|
|
171
|
+
_context.next = 7;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
throw new Error('Booking resources returned an invalid response.');
|
|
175
|
+
case 7:
|
|
176
|
+
byId = new Map();
|
|
177
|
+
response.forEach(function (resource) {
|
|
178
|
+
if (!resource || _typeof(resource) !== 'object' || Array.isArray(resource)) {
|
|
179
|
+
throw new Error('Booking resources returned an invalid resource.');
|
|
180
|
+
}
|
|
181
|
+
var id = resourceIdOf(resource);
|
|
182
|
+
if (typeof id !== 'string' && typeof id !== 'number' || id === '' || typeof id === 'number' && !Number.isFinite(id) || resource.event_list != null && !Array.isArray(resource.event_list)) {
|
|
183
|
+
throw new Error('Booking resources returned invalid identity or occupancy data.');
|
|
184
|
+
}
|
|
185
|
+
byId.set(String(id), cloneDeep(resource));
|
|
186
|
+
});
|
|
187
|
+
// Assemble the response before publishing any cells, so malformed data cannot mark a
|
|
188
|
+
// partially successful range as covered. Missing resources in a valid response are cached too.
|
|
189
|
+
updates = new Map();
|
|
190
|
+
query.resourceIds.forEach(function (id) {
|
|
191
|
+
var raw = byId.get(String(id));
|
|
192
|
+
var events = Array.isArray(raw === null || raw === void 0 ? void 0 : raw.event_list) ? raw.event_list : [];
|
|
193
|
+
var metadata = raw ? function (_ref8) {
|
|
194
|
+
var _events = _ref8.event_list,
|
|
195
|
+
rest = _objectWithoutProperties(_ref8, _excluded);
|
|
196
|
+
return rest;
|
|
197
|
+
}(raw) : null;
|
|
198
|
+
queryDates.forEach(function (date) {
|
|
199
|
+
return updates.set(key(id, date), {
|
|
200
|
+
resource: metadata,
|
|
201
|
+
events: eventsOnDate(events, date)
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
assertCurrent();
|
|
206
|
+
updates.forEach(function (cell, cellKey) {
|
|
207
|
+
if (!_this.cells.has(cellKey)) _this.cells.set(cellKey, cell);
|
|
208
|
+
});
|
|
209
|
+
case 13:
|
|
210
|
+
case "end":
|
|
211
|
+
return _context.stop();
|
|
212
|
+
}
|
|
213
|
+
}, _callee);
|
|
214
|
+
}))).finally(function () {
|
|
215
|
+
cellKeys.forEach(function (cellKey) {
|
|
216
|
+
if (_this.pending.get(cellKey) === promise) _this.pending.delete(cellKey);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
cellKeys.forEach(function (cellKey) {
|
|
220
|
+
return _this.pending.set(cellKey, promise);
|
|
221
|
+
});
|
|
222
|
+
waits.add(promise);
|
|
223
|
+
});
|
|
224
|
+
_context2.next = 12;
|
|
225
|
+
return Promise.all(Array.from(waits));
|
|
226
|
+
case 12:
|
|
227
|
+
assertCurrent();
|
|
228
|
+
result = [];
|
|
229
|
+
resources.forEach(function (id) {
|
|
230
|
+
var metadata = null;
|
|
231
|
+
var events = new Map();
|
|
232
|
+
dates.forEach(function (date) {
|
|
233
|
+
var cell = _this.cells.get(key(id, date));
|
|
234
|
+
if (!cell) throw new Error('Resource session coverage was lost. Please prepare again.');
|
|
235
|
+
if (!metadata && cell.resource) metadata = cell.resource;
|
|
236
|
+
var occurrences = new Map();
|
|
237
|
+
cell.events.forEach(function (event) {
|
|
238
|
+
var identity = eventIdentity(event);
|
|
239
|
+
var occurrence = identity.isUniqueEvent ? 0 : occurrences.get(identity.key) || 0;
|
|
240
|
+
occurrences.set(identity.key, occurrence + 1);
|
|
241
|
+
var occupancyKey = JSON.stringify([identity.key, occurrence]);
|
|
242
|
+
// Merge the maximum count seen in a day, not a set of booking UIDs: anonymous duplicate
|
|
243
|
+
// allocations must still count twice, while one cross-midnight event counts only once.
|
|
244
|
+
if (!events.has(occupancyKey)) events.set(occupancyKey, _objectSpread(_objectSpread({}, event), {}, {
|
|
245
|
+
__availabilitySessionOccupancyKey: occupancyKey
|
|
246
|
+
}));
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
if (metadata) {
|
|
250
|
+
result.push(cloneDeep(_objectSpread(_objectSpread({}, metadata), {}, {
|
|
251
|
+
event_list: Array.from(events.values()).sort(function (left, right) {
|
|
252
|
+
return eventTime(left, 'start').localeCompare(eventTime(right, 'start')) || eventTime(left, 'end').localeCompare(eventTime(right, 'end'));
|
|
253
|
+
})
|
|
254
|
+
})));
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
return _context2.abrupt("return", result);
|
|
258
|
+
case 16:
|
|
259
|
+
case "end":
|
|
260
|
+
return _context2.stop();
|
|
261
|
+
}
|
|
262
|
+
}, _callee2, this);
|
|
263
|
+
}));
|
|
264
|
+
function load(_x) {
|
|
265
|
+
return _load.apply(this, arguments);
|
|
266
|
+
}
|
|
267
|
+
return load;
|
|
268
|
+
}()
|
|
269
|
+
}]);
|
|
270
|
+
return AvailabilitySessionResourceCache;
|
|
271
|
+
}();
|
|
@@ -6,6 +6,7 @@ import type { AvailabilityDateRange, AvailabilityErrorCode, AvailabilityId, Avai
|
|
|
6
6
|
import type { BookingTicketState } from '../BookingTicket/types';
|
|
7
7
|
import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
|
|
8
8
|
import type { SalesNoteDraftInput } from '../../modules/Order/types';
|
|
9
|
+
import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult } from '../BaseSales/types';
|
|
9
10
|
export type { ProductListStoreQueryParams } from '../../modules/ProductList';
|
|
10
11
|
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
12
|
export interface UnifiedBookingSalesState extends BookingTicketState {
|
|
@@ -19,6 +20,28 @@ export interface UnifiedBookingSalesCatalogQueryBatch {
|
|
|
19
20
|
/** Releases retained results. A disposed batch cannot be reused. */
|
|
20
21
|
dispose(): void;
|
|
21
22
|
}
|
|
23
|
+
/** Venue page lifetime pool. Reads/quotes stay local; explicit opening may hydrate a variant once. */
|
|
24
|
+
export interface UnifiedBookingSalesVenueCatalogSession {
|
|
25
|
+
queryCatalogSnapshot(params?: ProductListLoadProductsParams): Promise<ProductData[]>;
|
|
26
|
+
queryCatalogProductDetail(params: ProductListLoadProductsParams & {
|
|
27
|
+
product_id: number;
|
|
28
|
+
}): Promise<ProductData | undefined>;
|
|
29
|
+
/** User-initiated opening only. Non-variant products never load a detail endpoint. */
|
|
30
|
+
prepareProductDetail(params: ProductListLoadProductsParams & {
|
|
31
|
+
product_id: number;
|
|
32
|
+
retry?: boolean;
|
|
33
|
+
}): Promise<ProductData | undefined>;
|
|
34
|
+
calculateProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
|
|
35
|
+
/** Retries failed pool/detail loads; successfully loaded records remain cached. */
|
|
36
|
+
retry(): void;
|
|
37
|
+
dispose(): void;
|
|
38
|
+
}
|
|
39
|
+
export type UnifiedBookingSalesVenueCatalogSessionParams = ProductListLoadProductsParams & {
|
|
40
|
+
/** Stable page/order session identity shared by main and extras pools. */
|
|
41
|
+
sessionKey?: string;
|
|
42
|
+
/** Lets implicit order repricing select the originating pool without guessing by product ID. */
|
|
43
|
+
poolRole?: 'main' | 'extras';
|
|
44
|
+
};
|
|
22
45
|
export interface UnifiedBookingSalesPolicy {
|
|
23
46
|
id?: AvailabilityId;
|
|
24
47
|
title?: unknown;
|
|
@@ -85,8 +108,8 @@ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
|
|
|
85
108
|
publishCatalog?: boolean;
|
|
86
109
|
/** Await remote occupancy refresh instead of stale-while-revalidate. Ignores rawResources; does not lock resources. */
|
|
87
110
|
refreshOccupancies?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
occupancyCachePolicy?: 'cache_first';
|
|
111
|
+
/** cache_first: 30-second preview. session: retain resource/date coverage for this venue page, including commit; overrides refreshOccupancies. Omit for legacy SWR. */
|
|
112
|
+
occupancyCachePolicy?: 'cache_first' | 'session';
|
|
90
113
|
/** Enforce configured sale cutoffs and disable manual POS availability overrides for this context. Defaults to false. */
|
|
91
114
|
strictAvailability?: boolean;
|
|
92
115
|
rawResources?: Record<string, any>[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Read-only preview scope; existing solution queries remain fresh for selection and submission. */
|
|
2
2
|
|
|
3
|
+
/** Venue page lifetime pool. Reads/quotes stay local; explicit opening may hydrate a variant once. */
|
|
4
|
+
|
|
3
5
|
export var UnifiedBookingSalesHooks = /*#__PURE__*/function (UnifiedBookingSalesHooks) {
|
|
4
6
|
UnifiedBookingSalesHooks["onAvailabilityProjectionPrepared"] = "unifiedBookingSales:onAvailabilityProjectionPrepared";
|
|
5
7
|
UnifiedBookingSalesHooks["onAvailabilitySelectionCommitted"] = "unifiedBookingSales:onAvailabilitySelectionCommitted";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ProductData } from '../../modules/Product/types';
|
|
2
|
+
import type { ProductListLoadProductsParams } from '../../modules/ProductList';
|
|
3
|
+
import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult } from '../BaseSales/types';
|
|
4
|
+
import type { UnifiedBookingSalesVenueCatalogSession } from './types';
|
|
5
|
+
export type VenueCatalogRecord = Record<string, any>;
|
|
6
|
+
export interface VenueCatalogPool {
|
|
7
|
+
products: ProductData[];
|
|
8
|
+
menus: VenueCatalogRecord[];
|
|
9
|
+
/** Pricing menu_match follows the OS evaluator's full menu-definition contract. */
|
|
10
|
+
pricingMenus: VenueCatalogRecord[];
|
|
11
|
+
}
|
|
12
|
+
export declare function venueCatalogError(code: string, message: string): Error & {
|
|
13
|
+
code: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function readVenueCatalogList(response: any, description: string): VenueCatalogRecord[];
|
|
16
|
+
export declare function validateVenueMenus(records: VenueCatalogRecord[], ids: number[]): VenueCatalogRecord[];
|
|
17
|
+
/** Same ID/collection union as the local OS product query; variant selection stays with SKU validation. */
|
|
18
|
+
export declare function productMatchesVenueMenu(product: VenueCatalogRecord, menu: VenueCatalogRecord): boolean;
|
|
19
|
+
export declare function activeVenueMenus(menus: VenueCatalogRecord[], schedules: VenueCatalogRecord[], datetime: string, dateOnly?: boolean): VenueCatalogRecord[];
|
|
20
|
+
/** Internal loader injection is not exposed to material callers. Rejected loads remain rejected until explicit retry. */
|
|
21
|
+
export declare function createVenueCatalogSessionAdapter(options: {
|
|
22
|
+
assertCurrent(): void;
|
|
23
|
+
load(): Promise<VenueCatalogPool>;
|
|
24
|
+
snapshot(pool: VenueCatalogPool, params: ProductListLoadProductsParams): ProductData[];
|
|
25
|
+
prepareDetail(pool: VenueCatalogPool, params: ProductListLoadProductsParams & {
|
|
26
|
+
product_id: number;
|
|
27
|
+
retry?: boolean;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
quote(pool: VenueCatalogPool, params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
|
|
30
|
+
onDispose?(): void;
|
|
31
|
+
onRetry?(): void;
|
|
32
|
+
}): UnifiedBookingSalesVenueCatalogSession;
|