@ancon/wildcat-utils 1.43.4 → 1.44.0-timezone-refactor.1
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/_baseIsEqual-12d01a44.mjs +169 -0
- package/_baseIsEqual-bcac9024.js +1 -0
- package/_baseIteratee-075c204c.js +1 -0
- package/_baseIteratee-4c4d0995.mjs +97 -0
- package/_baseSlice-4d543985.mjs +10 -0
- package/_baseSlice-e1b41ceb.js +1 -0
- package/_getTag-4e44633b.mjs +382 -0
- package/_getTag-b8923c48.js +1 -0
- package/card/index.d.ts +2 -0
- package/card/index.js +1 -1
- package/card/index.mjs +5 -3
- package/card/isWalletDebitTransaction.d.ts +2 -0
- package/card/isWalletDebitTransaction.js +1 -0
- package/card/isWalletDebitTransaction.mjs +13 -0
- package/checkout/getCheckoutOrderStatusTexts.js +1 -1
- package/checkout/getCheckoutOrderStatusTexts.mjs +7 -5
- package/checkout/index.js +1 -1
- package/checkout/index.mjs +49 -47
- package/checkout/isCheckoutItemsAreEqual.js +1 -1
- package/checkout/isCheckoutItemsAreEqual.mjs +14 -13
- package/date/createLocalTimezoneDate.d.ts +8 -0
- package/date/createLocalTimezoneDate.js +1 -0
- package/date/createLocalTimezoneDate.mjs +8 -0
- package/date/createLocalTimezoneMoment.d.ts +9 -0
- package/date/createLocalTimezoneMoment.js +1 -0
- package/date/createLocalTimezoneMoment.mjs +8 -0
- package/date/getFormattedUTCDateTime.d.ts +10 -0
- package/date/getFormattedUTCDateTime.js +1 -0
- package/date/getFormattedUTCDateTime.mjs +8 -0
- package/date/index.d.ts +4 -0
- package/date/index.js +1 -0
- package/date/index.mjs +9 -0
- package/identity-1bae7cf8.js +1 -0
- package/identity-6eafe87b.mjs +64 -0
- package/index.d.ts +2 -0
- package/index.js +1 -1
- package/index.mjs +96 -74
- package/logger/index.js +1 -1
- package/logger/index.mjs +8 -7
- package/logger/pascalCaseFormatter.js +1 -1
- package/logger/pascalCaseFormatter.mjs +21 -27
- package/order/getCheckOrderItemsMappedByTicketItemStatus.js +1 -1
- package/order/getCheckOrderItemsMappedByTicketItemStatus.mjs +15 -13
- package/order/getCheckOrderMinimumStatusTicketItem.js +1 -1
- package/order/getCheckOrderMinimumStatusTicketItem.mjs +19 -17
- package/order/index.js +1 -1
- package/order/index.mjs +11 -9
- package/outlet/getExpressAvailableOrderFormats.js +1 -1
- package/outlet/getExpressAvailableOrderFormats.mjs +27 -26
- package/outlet/getExpressNextAvailabilityShiftTime.d.ts +2 -2
- package/outlet/getExpressNextAvailabilityShiftTime.js +1 -1
- package/outlet/getExpressNextAvailabilityShiftTime.mjs +19 -18
- package/outlet/getExpressServiceIntervalEnd.d.ts +2 -2
- package/outlet/getExpressServiceIntervalEnd.js +1 -1
- package/outlet/getExpressServiceIntervalEnd.mjs +7 -9
- package/outlet/getExpressServiceIntervalStart.d.ts +2 -2
- package/outlet/getExpressServiceIntervalStart.js +1 -1
- package/outlet/getExpressServiceIntervalStart.mjs +7 -9
- package/outlet/getListOutletOpeningHoursTable.d.ts +1 -1
- package/outlet/getListOutletOpeningHoursTable.js +1 -1
- package/outlet/getListOutletOpeningHoursTable.mjs +135 -150
- package/outlet/getMomentFromDateAndTimeString.js +1 -1
- package/outlet/getMomentFromDateAndTimeString.mjs +1 -1
- package/outlet/getOutletActiveOpeningInterval.d.ts +2 -2
- package/outlet/getOutletActiveOpeningInterval.js +1 -1
- package/outlet/getOutletActiveOpeningInterval.mjs +15 -12
- package/outlet/getOutletAvailabilityInfo.js +1 -1
- package/outlet/getOutletAvailabilityInfo.mjs +23 -25
- package/outlet/getOutletCurrentActiveOperatingHour.js +1 -1
- package/outlet/getOutletCurrentActiveOperatingHour.mjs +16 -15
- package/outlet/getOutletCurrentAvailabilityInfo.js +1 -1
- package/outlet/getOutletCurrentAvailabilityInfo.mjs +27 -26
- package/outlet/getOutletCurrentClosingTimeText.js +1 -1
- package/outlet/getOutletCurrentClosingTimeText.mjs +14 -10
- package/outlet/getOutletDeliveryFee.js +1 -1
- package/outlet/getOutletDeliveryFee.mjs +5 -5
- package/outlet/getOutletFormattedAddress.d.ts +9 -1
- package/outlet/getOutletFormattedAddress.js +1 -1
- package/outlet/getOutletFormattedAddress.mjs +9 -4
- package/outlet/getOutletNextOpeningTagInformation.js +1 -1
- package/outlet/getOutletNextOpeningTagInformation.mjs +8 -7
- package/outlet/getOutletNextOpeningTimeText.js +1 -1
- package/outlet/getOutletNextOpeningTimeText.mjs +10 -8
- package/outlet/getOutletNextReadyToOrderTime.js +1 -1
- package/outlet/getOutletNextReadyToOrderTime.mjs +11 -11
- package/outlet/getOutletPickerTimesForDay.js +1 -1
- package/outlet/getOutletPickerTimesForDay.mjs +33 -34
- package/outlet/getOutletPickerTimesForWeek.js +1 -1
- package/outlet/getOutletPickerTimesForWeek.mjs +4 -3
- package/outlet/getOutletTagInformation.d.ts +1 -1
- package/outlet/getOutletTagInformation.js +1 -1
- package/outlet/getOutletTagInformation.mjs +69 -70
- package/outlet/getOutletTodayOpeningTimes.js +1 -1
- package/outlet/getOutletTodayOpeningTimes.mjs +43 -39
- package/outlet/getPartitionedOutletsList.js +1 -1
- package/outlet/getPartitionedOutletsList.mjs +4 -4
- package/outlet/getPickerIntervalsForDay.js +1 -1
- package/outlet/getPickerIntervalsForDay.mjs +20 -12
- package/outlet/getServiceIntervalEnd.d.ts +1 -1
- package/outlet/getServiceIntervalEnd.js +1 -1
- package/outlet/getServiceIntervalEnd.mjs +12 -10
- package/outlet/getServiceIntervalRange.d.ts +1 -2
- package/outlet/getServiceIntervalRange.js +1 -1
- package/outlet/getServiceIntervalRange.mjs +8 -12
- package/outlet/getServiceIntervalStart.d.ts +1 -1
- package/outlet/getServiceIntervalStart.js +1 -1
- package/outlet/getServiceIntervalStart.mjs +6 -7
- package/outlet/getServiceIntervalsForOrderFormat.d.ts +7 -8
- package/outlet/getStructuredOutletAddress.js +1 -1
- package/outlet/getStructuredOutletAddress.mjs +7 -7
- package/outlet/index.js +1 -1
- package/outlet/index.mjs +73 -68
- package/outlet/searchNextOpeningMoment.d.ts +1 -1
- package/outlet/searchNextOpeningMoment.js +1 -1
- package/outlet/searchNextOpeningMoment.mjs +49 -56
- package/outlet/serviceDateTimesFromOpeningHours.d.ts +3 -5
- package/outlet/serviceDateTimesFromOpeningHours.js +1 -1
- package/outlet/serviceDateTimesFromOpeningHours.mjs +342 -27
- package/outlet/types.d.ts +0 -2
- package/package.json +26 -1
- package/time/getEndTimeSpanOfTimePeriod.js +1 -1
- package/time/getEndTimeSpanOfTimePeriod.mjs +5 -9
- package/{toString-e631a957.mjs → toString-3b91b335.mjs} +12 -11
- package/toString-9eae9442.js +1 -0
- package/_baseIsEqual-39cef2eb.mjs +0 -530
- package/_baseIsEqual-b3df9240.js +0 -1
- package/_baseIteratee-13e892b8.mjs +0 -151
- package/_baseIteratee-be26bb18.js +0 -1
- package/toString-425512fc.js +0 -1
|
@@ -1,203 +1,188 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { OrderFormat as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import W from "moment";
|
|
2
|
+
import { OrderFormat as p, DayOfWeek as f, IntervalType as l, IntervalState as F } from "@ancon/wildcat-types";
|
|
3
|
+
import H from "../shared/isWithinFlag.mjs";
|
|
4
|
+
import I from "../shared/generateId.mjs";
|
|
5
5
|
import "react";
|
|
6
|
+
import T from "../time/getTimeSpanParts.mjs";
|
|
7
|
+
import M from "../date/createLocalTimezoneMoment.mjs";
|
|
6
8
|
const k = [
|
|
7
|
-
{ id:
|
|
8
|
-
{ id:
|
|
9
|
-
{ id:
|
|
10
|
-
{ id:
|
|
11
|
-
{ id:
|
|
9
|
+
{ id: p.EatIn, name: "eatIn" },
|
|
10
|
+
{ id: p.TakeAway, name: "takeaway" },
|
|
11
|
+
{ id: p.TableOrder, name: "tableOrder" },
|
|
12
|
+
{ id: p.Delivery, name: "delivery" },
|
|
13
|
+
{ id: p.BoxPickup, name: "boxPickup" }
|
|
12
14
|
];
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
for (let n = 0,
|
|
16
|
-
|
|
17
|
-
return
|
|
15
|
+
function h(r) {
|
|
16
|
+
const s = W(r).subtract(1, "day").startOf("day"), e = [];
|
|
17
|
+
for (let n = 0, t = s; n < 7; n += 1)
|
|
18
|
+
t = t.clone().add(1, "day").startOf("day"), e.push(t.clone());
|
|
19
|
+
return e;
|
|
18
20
|
}
|
|
19
|
-
function
|
|
20
|
-
return [...
|
|
21
|
+
function Y(r) {
|
|
22
|
+
return [...r].sort((s, e) => s.isoWeekday() - e.isoWeekday());
|
|
21
23
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (e.type === c.Interval) {
|
|
30
|
-
let a = o.clone().add(n, "hour").add(s, "minute");
|
|
31
|
-
const d = a.clone().add(r, "hour").add(p, "minute").date() - o.date();
|
|
32
|
-
d !== 0 && (a = a.subtract(d, "day"));
|
|
33
|
-
const f = a.clone().add(m, "hour").add(u, "minute");
|
|
24
|
+
function x(r, s) {
|
|
25
|
+
const e = T(r.from), n = T(r.duration);
|
|
26
|
+
if (r.type === l.Normal) {
|
|
27
|
+
let t = s.clone().add(e.hours, "hour").add(e.minutes, "minute");
|
|
28
|
+
const i = t.date() - s.date();
|
|
29
|
+
i !== 0 && (t = t.subtract(i, "day"));
|
|
30
|
+
const o = t.clone().add(n);
|
|
34
31
|
return {
|
|
35
|
-
id:
|
|
36
|
-
start:
|
|
37
|
-
end:
|
|
32
|
+
id: r.id,
|
|
33
|
+
start: t.format("YYYY-MM-DDTHH:mm:ss"),
|
|
34
|
+
end: o.format("YYYY-MM-DDTHH:mm:ss")
|
|
38
35
|
};
|
|
39
36
|
}
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
37
|
+
if (r.type === l.Exception) {
|
|
38
|
+
const t = M(r.periodFrom), i = M(r.periodTo);
|
|
39
|
+
if (s.isBetween(t, i, void 0, "[]")) {
|
|
40
|
+
const o = s.clone().add(e.hours, "hour").add(e.minutes, "minute"), a = o.clone().add(n);
|
|
44
41
|
return {
|
|
45
|
-
id:
|
|
46
|
-
start:
|
|
47
|
-
end:
|
|
48
|
-
reason:
|
|
42
|
+
id: r.id,
|
|
43
|
+
start: o.format("YYYY-MM-DDTHH:mm:ss"),
|
|
44
|
+
end: a.format("YYYY-MM-DDTHH:mm:ss"),
|
|
45
|
+
reason: r.reason
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
48
|
return null;
|
|
52
49
|
}
|
|
53
50
|
throw new Error("Invalid interval type");
|
|
54
51
|
}
|
|
55
|
-
function
|
|
56
|
-
const
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
64
|
-
[
|
|
52
|
+
function D(r, s, e) {
|
|
53
|
+
const n = {
|
|
54
|
+
[f.Monday]: 1,
|
|
55
|
+
[f.Tuesday]: 2,
|
|
56
|
+
[f.Wednesday]: 3,
|
|
57
|
+
[f.Thursday]: 4,
|
|
58
|
+
[f.Friday]: 5,
|
|
59
|
+
[f.Saturday]: 6,
|
|
60
|
+
[f.Sunday]: 7,
|
|
61
|
+
[f.Everyday]: null
|
|
65
62
|
};
|
|
66
|
-
for (let
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
isoWeekday:
|
|
63
|
+
for (let t = 0; t < s.length; t += 1) {
|
|
64
|
+
const i = s[t], o = i.isoWeekday(), a = r.dayOfWeek, m = (n[a] ?? null) === o || a === f.Everyday;
|
|
65
|
+
if (e[o] || (e[o] = {
|
|
66
|
+
isoWeekday: o,
|
|
70
67
|
key: "",
|
|
71
68
|
open: [],
|
|
72
69
|
adjusted: [],
|
|
73
70
|
closed: []
|
|
74
|
-
}),
|
|
75
|
-
const d = x(
|
|
76
|
-
|
|
77
|
-
u,
|
|
78
|
-
n
|
|
79
|
-
);
|
|
80
|
-
d && (t[r].key += d.id, e.type === c.Interval && e.state === g.Open ? t[r].open.push(d) : e.type === c.Interval && e.state === g.Closed ? t[r].closed.push(d) : e.type === c.Exception && e.state === g.Open ? t[r].adjusted.push(d) : e.type === c.Exception && e.state === g.Closed && t[r].closed.push(d));
|
|
71
|
+
}), m) {
|
|
72
|
+
const d = x(r, i);
|
|
73
|
+
d && (e[o].key += d.id, r.type === l.Normal && r.state === F.Opened ? e[o].open.push(d) : r.type === l.Normal && r.state === F.Closed ? e[o].closed.push(d) : r.type === l.Exception && r.state === F.Opened ? e[o].adjusted.push(d) : r.type === l.Exception && r.state === F.Closed && e[o].closed.push(d));
|
|
81
74
|
}
|
|
82
75
|
}
|
|
83
76
|
}
|
|
84
|
-
function
|
|
85
|
-
switch (
|
|
86
|
-
case
|
|
87
|
-
return
|
|
88
|
-
case
|
|
89
|
-
return
|
|
77
|
+
function v(r) {
|
|
78
|
+
switch (r.type) {
|
|
79
|
+
case l.Exception:
|
|
80
|
+
return I("interval-exception");
|
|
81
|
+
case l.Normal:
|
|
82
|
+
return I("interval-normal");
|
|
90
83
|
default:
|
|
91
|
-
return
|
|
84
|
+
return I("interval-unknown");
|
|
92
85
|
}
|
|
93
86
|
}
|
|
94
|
-
function E(
|
|
95
|
-
const
|
|
96
|
-
(t, n)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{}
|
|
107
|
-
);
|
|
108
|
-
return Object.values(o);
|
|
87
|
+
function E(r) {
|
|
88
|
+
const s = r.reduce((e, n) => (k.forEach((t) => {
|
|
89
|
+
H(t.id, n.orderFormats) && (e[t.id] || (e[t.id] = {
|
|
90
|
+
orderFormat: t,
|
|
91
|
+
intervals: []
|
|
92
|
+
}), e[t.id].intervals.push(
|
|
93
|
+
...n.intervals.sort(
|
|
94
|
+
(i, o) => i.dayOfWeek - o.dayOfWeek
|
|
95
|
+
)
|
|
96
|
+
));
|
|
97
|
+
}), e), {});
|
|
98
|
+
return Object.values(s);
|
|
109
99
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
return
|
|
100
|
+
function S(r, s) {
|
|
101
|
+
const e = s.reduce((n, t) => t <= r ? n + 1 : n, 0);
|
|
102
|
+
return r - e;
|
|
113
103
|
}
|
|
114
|
-
function
|
|
115
|
-
const { mergedTables:
|
|
116
|
-
(
|
|
117
|
-
const
|
|
118
|
-
(
|
|
119
|
-
(
|
|
120
|
-
(
|
|
104
|
+
function j(r) {
|
|
105
|
+
const { mergedTables: s } = r.reduce(
|
|
106
|
+
(e, n, t) => {
|
|
107
|
+
const i = e.mergedTables.findIndex(
|
|
108
|
+
(o) => o !== n && !o.orderFormats.some(
|
|
109
|
+
(a) => n.orderFormats.some(
|
|
110
|
+
(u) => u.id === a.id
|
|
121
111
|
)
|
|
122
|
-
) &&
|
|
123
|
-
(
|
|
112
|
+
) && o.openingHours.every(
|
|
113
|
+
(a) => n.openingHours.some((u) => u.key === a.key)
|
|
124
114
|
) && n.openingHours.every(
|
|
125
|
-
(
|
|
115
|
+
(a) => o.openingHours.some((u) => u.key === a.key)
|
|
126
116
|
)
|
|
127
117
|
);
|
|
128
|
-
if (
|
|
129
|
-
if (
|
|
130
|
-
(
|
|
118
|
+
if (i >= 0) {
|
|
119
|
+
if (e.skipOrderFormats.some(
|
|
120
|
+
(d) => n.orderFormats.every((y) => y.id === d.id)
|
|
131
121
|
))
|
|
132
|
-
return
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
...
|
|
136
|
-
orderFormats: [...n.orderFormats, ...
|
|
122
|
+
return e;
|
|
123
|
+
const a = e.mergedTables[i];
|
|
124
|
+
e.mergedTables.splice(i, 1, {
|
|
125
|
+
...a,
|
|
126
|
+
orderFormats: [...n.orderFormats, ...a.orderFormats]
|
|
137
127
|
});
|
|
138
|
-
const
|
|
139
|
-
(
|
|
128
|
+
const u = a.orderFormats.filter(
|
|
129
|
+
(d) => !e.skipOrderFormats.some((y) => y.id === d.id)
|
|
140
130
|
);
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
return
|
|
131
|
+
u.length > 0 && e.skipOrderFormats.push(...u);
|
|
132
|
+
const m = S(t, [...e.removedIndexes]);
|
|
133
|
+
return e.mergedTables.splice(m, 1), e.removedIndexes.push(t), e;
|
|
144
134
|
}
|
|
145
|
-
return
|
|
135
|
+
return e;
|
|
146
136
|
},
|
|
147
|
-
{ mergedTables: [...
|
|
137
|
+
{ mergedTables: [...r], removedIndexes: [], skipOrderFormats: [] }
|
|
148
138
|
);
|
|
149
|
-
return
|
|
139
|
+
return s;
|
|
150
140
|
}
|
|
151
|
-
function
|
|
152
|
-
return
|
|
153
|
-
...
|
|
154
|
-
intervals:
|
|
155
|
-
...
|
|
156
|
-
id:
|
|
141
|
+
function w(r) {
|
|
142
|
+
return r.map((s) => ({
|
|
143
|
+
...s,
|
|
144
|
+
intervals: s.intervals.map((e) => ({
|
|
145
|
+
...e,
|
|
146
|
+
id: v(e)
|
|
157
147
|
}))
|
|
158
148
|
}));
|
|
159
149
|
}
|
|
160
|
-
function
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
), n =
|
|
164
|
-
(
|
|
165
|
-
f,
|
|
166
|
-
s,
|
|
167
|
-
d,
|
|
168
|
-
e.timeZoneOffset
|
|
169
|
-
), d), a[i.orderFormat.id]), a),
|
|
150
|
+
function L(r, s) {
|
|
151
|
+
const e = E(
|
|
152
|
+
w(r.serviceDateTimes)
|
|
153
|
+
), n = h(s), t = Y(n), i = e.reduce(
|
|
154
|
+
(m, d) => (m[d.orderFormat.id] || (m[d.orderFormat.id] = {}), d.intervals.reduce((y, c) => (D(c, t, y), y), m[d.orderFormat.id]), m),
|
|
170
155
|
{}
|
|
171
|
-
),
|
|
172
|
-
[
|
|
173
|
-
[
|
|
174
|
-
[
|
|
175
|
-
[
|
|
176
|
-
[
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
).map(([
|
|
180
|
-
orderFormats: [
|
|
181
|
-
openingHours: Object.entries(
|
|
182
|
-
([
|
|
183
|
-
isoWeekday: Number(
|
|
184
|
-
key:
|
|
185
|
-
open:
|
|
186
|
-
(
|
|
156
|
+
), o = {
|
|
157
|
+
[p.EatIn]: k[0],
|
|
158
|
+
[p.TakeAway]: k[1],
|
|
159
|
+
[p.TableOrder]: k[2],
|
|
160
|
+
[p.Delivery]: k[3],
|
|
161
|
+
[p.BoxPickup]: k[4]
|
|
162
|
+
}, a = Object.entries(
|
|
163
|
+
i
|
|
164
|
+
).map(([m, d]) => ({
|
|
165
|
+
orderFormats: [o[Number(m)]],
|
|
166
|
+
openingHours: Object.entries(d).map(
|
|
167
|
+
([y, c]) => ({
|
|
168
|
+
isoWeekday: Number(y),
|
|
169
|
+
key: c.key,
|
|
170
|
+
open: c.open.sort(
|
|
171
|
+
(g, O) => g.start.localeCompare(O.start)
|
|
187
172
|
),
|
|
188
|
-
adjusted:
|
|
189
|
-
(
|
|
173
|
+
adjusted: c.adjusted.sort(
|
|
174
|
+
(g, O) => g.start.localeCompare(O.start)
|
|
190
175
|
),
|
|
191
|
-
closed:
|
|
192
|
-
(
|
|
176
|
+
closed: c.closed.sort(
|
|
177
|
+
(g, O) => g.start.localeCompare(O.start)
|
|
193
178
|
)
|
|
194
179
|
})
|
|
195
180
|
)
|
|
196
181
|
}));
|
|
197
|
-
return
|
|
198
|
-
(
|
|
182
|
+
return j(a).sort(
|
|
183
|
+
(m, d) => m.orderFormats[0].id - d.orderFormats[0].id
|
|
199
184
|
);
|
|
200
185
|
}
|
|
201
186
|
export {
|
|
202
|
-
|
|
187
|
+
L as default
|
|
203
188
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const m=require("moment");function u(t){const[e,r,n]=t.split(":");return m().startOf("day").set({hour:Number(e),minute:Number(r),second:Number(n),millisecond:0})}function i(t,e){const[r,n,o]=t.split("-");return u(e).year(Number(r)).month(Number(n)-1).date(Number(o))}module.exports=i;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpeningHoursInterval, OrderFormat } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
3
|
/**
|
|
4
4
|
* Get the active opening interval for the given outlet opening hours, date and order format
|
|
@@ -8,4 +8,4 @@ import { Moment } from 'moment';
|
|
|
8
8
|
* @param orderFormat - The order format to check
|
|
9
9
|
* @returns The active opening interval or undefined if no interval is active for the given date and order format
|
|
10
10
|
*/
|
|
11
|
-
export default function getOutletActiveOpeningInterval(date: Moment, openingHours:
|
|
11
|
+
export default function getOutletActiveOpeningInterval(date: Moment, openingHours: OpeningHoursInterval[], orderFormat: OrderFormat): OpeningHoursInterval | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("@ancon/wildcat-types"),
|
|
1
|
+
"use strict";const n=require("@ancon/wildcat-types"),f=require("../shared/constants.js"),p=require("../date/createLocalTimezoneMoment.js");require("moment");function y(r,c,i){const a=c.reduce((t,e)=>{if((e.orderFormat&i)===i)switch(e.type){case n.IntervalType.Exception:{const s=p(e.periodFrom),l=p(e.periodTo);r.isBetween(s,l,"day","[]")&&(e.state===n.IntervalState.Closed?t.closedExceptions.push(e):t.openExceptions.push(e))}break;case n.IntervalType.Normal:default:(e.dayOfWeek===n.DayOfWeek.Everyday||e.dayOfWeek===f.DaysOfWeekMap[r.isoWeekday()])&&t.openIntervals.push(e);break}return t},{closedExceptions:[],openExceptions:[],openIntervals:[]}),{closedExceptions:d,openExceptions:o,openIntervals:u}=a;if(!d.length){if(o.length){if(o.length>1){const[t]=o.sort((e,s)=>e.position-s.position);return t}return o[0]}return u[0]}}module.exports=y;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { DayOfWeek as
|
|
2
|
-
import i from "moment";
|
|
1
|
+
import { DayOfWeek as u, IntervalType as r, IntervalState as m } from "@ancon/wildcat-types";
|
|
3
2
|
import { DaysOfWeekMap as y } from "../shared/constants.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import i from "../date/createLocalTimezoneMoment.mjs";
|
|
4
|
+
import "moment";
|
|
5
|
+
function O(s, c, p) {
|
|
6
|
+
const f = c.reduce(
|
|
6
7
|
(o, e) => {
|
|
7
8
|
if ((e.orderFormat & p) === p)
|
|
8
9
|
switch (e.type) {
|
|
9
10
|
case r.Exception:
|
|
10
11
|
{
|
|
11
|
-
const n = i(
|
|
12
|
-
|
|
12
|
+
const n = i(
|
|
13
|
+
e.periodFrom
|
|
14
|
+
), l = i(e.periodTo);
|
|
15
|
+
s.isBetween(n, l, "day", "[]") && (e.state === m.Closed ? o.closedExceptions.push(e) : o.openExceptions.push(e));
|
|
13
16
|
}
|
|
14
17
|
break;
|
|
15
|
-
case r.
|
|
18
|
+
case r.Normal:
|
|
16
19
|
default:
|
|
17
20
|
// Every day in the week
|
|
18
|
-
(e.dayOfWeek ===
|
|
21
|
+
(e.dayOfWeek === u.Everyday || // Specific day in the week
|
|
19
22
|
e.dayOfWeek === y[s.isoWeekday()]) && o.openIntervals.push(e);
|
|
20
23
|
break;
|
|
21
24
|
}
|
|
@@ -26,8 +29,8 @@ function k(s, f, p) {
|
|
|
26
29
|
openExceptions: [],
|
|
27
30
|
openIntervals: []
|
|
28
31
|
}
|
|
29
|
-
), { closedExceptions:
|
|
30
|
-
if (!
|
|
32
|
+
), { closedExceptions: a, openExceptions: t, openIntervals: d } = f;
|
|
33
|
+
if (!a.length) {
|
|
31
34
|
if (t.length) {
|
|
32
35
|
if (t.length > 1) {
|
|
33
36
|
const [o] = t.sort(
|
|
@@ -37,9 +40,9 @@ function k(s, f, p) {
|
|
|
37
40
|
}
|
|
38
41
|
return t[0];
|
|
39
42
|
}
|
|
40
|
-
return
|
|
43
|
+
return d[0];
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
export {
|
|
44
|
-
|
|
47
|
+
O as default
|
|
45
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("moment"),s=require("@ancon/wildcat-types"),m=60;var u=(e=>(e[e.Today=0]="Today",e[e.Tomorrow=1]="Tomorrow",e))(u||{});function n(e,l,r=!1){let t=null;if(e.openNow&&e.closingTime!==null)(e.closingTime.diff(l,"minutes")<m||r)&&(t={time:e.closingTime.format("LT"),state:s.OutletState.Closed});else if(!e.openNow&&e.openingTime)if(e.openingTime.isSame(l,"d"))t={time:o(e.openingTime).calendar(),state:s.OutletState.Opened};else{const d=o().add(1,"day"),i=o(e.openingTime);i.isSame(d,"d")?t={time:i.format("LT"),state:s.OutletState.Opened,day:1}:i.isAfter(l.clone().add(1,"week"))?t={time:i.format("D MMMM LT"),state:s.OutletState.Opened}:i&&(t={time:i.format("ddd LT"),state:s.OutletState.Opened})}return t}exports.OutletAvailabilityDay=u;exports.default=n;
|
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { OutletState as
|
|
3
|
-
const
|
|
4
|
-
var
|
|
5
|
-
function
|
|
1
|
+
import m from "moment";
|
|
2
|
+
import { OutletState as t } from "@ancon/wildcat-types";
|
|
3
|
+
const r = 60;
|
|
4
|
+
var T = /* @__PURE__ */ ((e) => (e[e.Today = 0] = "Today", e[e.Tomorrow = 1] = "Tomorrow", e))(T || {});
|
|
5
|
+
function p(e, o, l = !1) {
|
|
6
6
|
let s = null;
|
|
7
7
|
if (e.openNow && e.closingTime !== null)
|
|
8
|
-
(e.closingTime.diff(
|
|
9
|
-
time: e.closingTime.
|
|
10
|
-
state:
|
|
8
|
+
(e.closingTime.diff(o, "minutes") < r || l) && (s = {
|
|
9
|
+
time: e.closingTime.format("LT"),
|
|
10
|
+
state: t.Closed
|
|
11
11
|
});
|
|
12
12
|
else if (!e.openNow && e.openingTime)
|
|
13
|
-
if (e.openingTime.isSame(
|
|
13
|
+
if (e.openingTime.isSame(o, "d"))
|
|
14
14
|
s = {
|
|
15
|
-
time:
|
|
16
|
-
state:
|
|
15
|
+
time: m(e.openingTime).calendar(),
|
|
16
|
+
state: t.Opened
|
|
17
17
|
};
|
|
18
18
|
else {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
time: f.format("LT"),
|
|
24
|
-
state: i.Open,
|
|
19
|
+
const d = m().add(1, "day"), i = m(e.openingTime);
|
|
20
|
+
i.isSame(d, "d") ? s = {
|
|
21
|
+
time: i.format("LT"),
|
|
22
|
+
state: t.Opened,
|
|
25
23
|
day: 1
|
|
26
24
|
/* Tomorrow */
|
|
27
|
-
} :
|
|
28
|
-
time:
|
|
29
|
-
state:
|
|
30
|
-
} :
|
|
31
|
-
time:
|
|
32
|
-
state:
|
|
25
|
+
} : i.isAfter(o.clone().add(1, "week")) ? s = {
|
|
26
|
+
time: i.format("D MMMM LT"),
|
|
27
|
+
state: t.Opened
|
|
28
|
+
} : i && (s = {
|
|
29
|
+
time: i.format("ddd LT"),
|
|
30
|
+
state: t.Opened
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
33
|
return s;
|
|
36
34
|
}
|
|
37
35
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
T as OutletAvailabilityDay,
|
|
37
|
+
p as default
|
|
40
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const a=require("@ancon/wildcat-types"),
|
|
1
|
+
"use strict";const a=require("@ancon/wildcat-types"),l=require("../time/getTimeSpanParts.js"),s=require("./getMomentFromDateAndTimeString.js");require("moment");function f(r,e,c){if(e.exception){const{exception:t}=e;if(t.type===a.IntervalType.Normal){const n=l(t.duration),i=s(r,t.from),o=i.clone().add(n);if(c.isBetween(i,o))return e.exception}}else for(let t=0;t<e.intervals.length;t+=1){const n=e.intervals[t],i=l(n.duration),o=s(r,n.from),u=o.clone().add(i);if(c.isBetween(o,u))return n}return null}module.exports=f;
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import { IntervalType as
|
|
2
|
-
import
|
|
1
|
+
import { IntervalType as f } from "@ancon/wildcat-types";
|
|
2
|
+
import c from "../time/getTimeSpanParts.mjs";
|
|
3
|
+
import m from "./getMomentFromDateAndTimeString.mjs";
|
|
3
4
|
import "moment";
|
|
4
|
-
function
|
|
5
|
+
function g(r, n, l) {
|
|
5
6
|
if (n.exception) {
|
|
6
7
|
const { exception: t } = n;
|
|
7
|
-
if (t.type ===
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
t.
|
|
11
|
-
),
|
|
12
|
-
if (l.isBetween(
|
|
8
|
+
if (t.type === f.Normal) {
|
|
9
|
+
const e = c(t.duration), o = m(
|
|
10
|
+
r,
|
|
11
|
+
t.from
|
|
12
|
+
), i = o.clone().add(e);
|
|
13
|
+
if (l.isBetween(o, i))
|
|
13
14
|
return n.exception;
|
|
14
15
|
}
|
|
15
16
|
} else
|
|
16
17
|
for (let t = 0; t < n.intervals.length; t += 1) {
|
|
17
|
-
const e = n.intervals[t],
|
|
18
|
-
|
|
19
|
-
e.
|
|
20
|
-
),
|
|
21
|
-
if (l.isBetween(
|
|
18
|
+
const e = n.intervals[t], o = c(e.duration), i = m(
|
|
19
|
+
r,
|
|
20
|
+
e.from
|
|
21
|
+
), s = i.clone().add(o);
|
|
22
|
+
if (l.isBetween(i, s))
|
|
22
23
|
return e;
|
|
23
24
|
}
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
26
27
|
export {
|
|
27
|
-
|
|
28
|
+
g as default
|
|
28
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const f=require("@ancon/wildcat-types"),T=require("moment"),u=require("./getOutletTagInformation.js"),p=require("./getOutletAvailabilityInfo.js");require("../date/createLocalTimezoneMoment.js");require("../time/getTimeSpanParts.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getMomentFromDateAndTimeString.js");require("./searchNextOpeningMoment.js");function a(o,e){let{openingTime:n}=o,{closingTime:i}=o;return!!e.openingTime&&!!e.closingTime?(o.openingTime?o.openingTime.isBetween(e.openingTime,e.closingTime)&&(n=e.openingTime):n=e.openingTime,o.closingTime?o.closingTime.isBetween(e.openingTime,e.closingTime)&&(i=e.closingTime):i=e.closingTime):((!n&&e.openingTime||e.openingTime&&n&&e.openingTime.isBefore(n))&&(n=e.openingTime),!i&&e.closingTime?i=e.closingTime:e.closingTime&&i&&(e.closingTime.isBefore(i)||(i=e.closingTime))),{openingTime:n,closingTime:i}}function d(o){const{serviceDateTimes:e,state:n}=o,i=T(),g=n===f.OutletState.Opened,r=e.reduce((s,l)=>{const m=(l==null?void 0:l.intervals)||[],t=u.default(m,g,i,i);return s?s.openNow&&!t.openNow?s:{...a(s,t),openNow:s.openNow||t.openNow,openDuringSpecifiedTime:s.openDuringSpecifiedTime||t.openDuringSpecifiedTime}:t},void 0);return r?p.default(r,i,!1):null}module.exports=d;
|