@ancon/wildcat-utils 1.43.7 → 1.44.0-r13-2.2
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/checkout/getCheckoutOrderStatusTexts.js +1 -1
- package/checkout/getCheckoutOrderStatusTexts.mjs +7 -5
- package/checkout/index.js +1 -1
- package/checkout/index.mjs +55 -53
- 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/hangfire/createHangfirePoller.d.ts +8 -2
- package/hangfire/createHangfirePoller.js +1 -1
- package/hangfire/createHangfirePoller.mjs +72 -62
- package/hangfire/createMakeHangfireRequest.d.ts +10 -1
- package/hangfire/createMakeHangfireRequest.js +1 -1
- package/hangfire/createMakeHangfireRequest.mjs +16 -14
- 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 +80 -58
- 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 +21 -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,65 +1,66 @@
|
|
|
1
|
-
import { OrderFormat as s, DayOfWeek as g, IntervalType as
|
|
2
|
-
import
|
|
3
|
-
import { DaysOfWeekMap as
|
|
1
|
+
import { OrderFormat as s, DayOfWeek as g, IntervalType as p, IntervalState as l } from "@ancon/wildcat-types";
|
|
2
|
+
import F from "moment";
|
|
3
|
+
import { DaysOfWeekMap as x } from "../shared/constants.mjs";
|
|
4
|
+
import d from "../date/createLocalTimezoneMoment.mjs";
|
|
4
5
|
import f from "./getExpressServiceIntervalStart.mjs";
|
|
5
6
|
import c from "./getExpressServiceIntervalEnd.mjs";
|
|
6
7
|
import "../time/getTimeSpanParts.mjs";
|
|
7
|
-
const
|
|
8
|
-
function
|
|
9
|
-
var
|
|
10
|
-
if (!((
|
|
8
|
+
const D = [s.TakeAway, s.EatIn];
|
|
9
|
+
function A(m) {
|
|
10
|
+
var i;
|
|
11
|
+
if (!((i = m.openingHours) != null && i.length))
|
|
11
12
|
return [];
|
|
12
|
-
const
|
|
13
|
-
(
|
|
13
|
+
const t = F(), { openingHours: u, supportedOrderFormats: y, timeZoneOffset: o } = m, O = [...u].reduce(
|
|
14
|
+
(r, e, I, T) => {
|
|
14
15
|
switch (e.type) {
|
|
15
|
-
case
|
|
16
|
+
case p.Exception:
|
|
16
17
|
{
|
|
17
|
-
const a =
|
|
18
|
+
const a = d(e.periodFrom), n = d(e.periodTo), k = f(
|
|
18
19
|
a,
|
|
19
20
|
e,
|
|
20
21
|
o
|
|
21
|
-
),
|
|
22
|
+
), E = c(
|
|
22
23
|
n,
|
|
23
24
|
e,
|
|
24
25
|
o
|
|
25
26
|
);
|
|
26
|
-
if (
|
|
27
|
-
return e.state ===
|
|
27
|
+
if (t.isBetween(k, E, void 0, "[]"))
|
|
28
|
+
return e.state === l.Closed ? (T.splice(1), s.None) : e.orderFormat;
|
|
28
29
|
}
|
|
29
30
|
break;
|
|
30
|
-
case
|
|
31
|
+
case p.Normal:
|
|
31
32
|
default:
|
|
32
33
|
if (
|
|
33
34
|
// Every day in the week
|
|
34
35
|
e.dayOfWeek === g.Everyday || // Specific day in the week
|
|
35
|
-
e.dayOfWeek ===
|
|
36
|
+
e.dayOfWeek === x[t.isoWeekday()]
|
|
36
37
|
) {
|
|
37
38
|
const a = f(
|
|
38
|
-
|
|
39
|
+
t,
|
|
39
40
|
e,
|
|
40
41
|
o
|
|
41
42
|
), n = c(
|
|
42
|
-
|
|
43
|
+
t,
|
|
43
44
|
e,
|
|
44
45
|
o
|
|
45
46
|
);
|
|
46
|
-
if (
|
|
47
|
-
return
|
|
47
|
+
if (t.isBetween(a, n, void 0, "[]"))
|
|
48
|
+
return r | e.orderFormat;
|
|
48
49
|
}
|
|
49
50
|
break;
|
|
50
51
|
}
|
|
51
|
-
return
|
|
52
|
+
return r;
|
|
52
53
|
},
|
|
53
54
|
s.None
|
|
54
55
|
);
|
|
55
|
-
return
|
|
56
|
-
(
|
|
56
|
+
return D.filter(
|
|
57
|
+
(r) => (
|
|
57
58
|
// Check if the order format is available
|
|
58
|
-
(O &
|
|
59
|
-
(y &
|
|
59
|
+
(O & r) === r && // Check if the order format is supported by the outlet
|
|
60
|
+
(y & r) === r
|
|
60
61
|
)
|
|
61
62
|
);
|
|
62
63
|
}
|
|
63
64
|
export {
|
|
64
|
-
|
|
65
|
+
A as default
|
|
65
66
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpeningHoursInterval } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
|
-
export default function getExpressNextAvailabilityShiftTime(openingHours: Array<
|
|
3
|
+
export default function getExpressNextAvailabilityShiftTime(openingHours: Array<OpeningHoursInterval>, outletTimezoneOffset?: string): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("@ancon/wildcat-types"),
|
|
1
|
+
"use strict";const o=require("@ancon/wildcat-types"),u=require("moment"),m=require("../shared/constants.js"),d=require("../date/createLocalTimezoneMoment.js"),x=require("./getExpressServiceIntervalStart.js"),E=require("./getExpressServiceIntervalEnd.js");require("../time/getTimeSpanParts.js");function T(p,s){const t=u();let r=t.clone().add(1,"day").startOf("day");function i(e){const n=e.type===o.IntervalType.Exception,y=n?d(e.periodFrom):t,f=n?d(e.periodTo):t,a=x(y,e,s),c=E(f,e,s);a.isBetween(t,r)?r=a:c.isBetween(t,r)&&(r=c)}return p.forEach(e=>{switch(e.type){case o.IntervalType.Exception:i(e);break;case o.IntervalType.Normal:default:(e.dayOfWeek===o.DayOfWeek.Everyday||e.dayOfWeek===m.DaysOfWeekMap[t.isoWeekday()])&&i(e);break}}),r}module.exports=T;
|
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import { DayOfWeek as y, IntervalType as r } from "@ancon/wildcat-types";
|
|
2
|
-
import
|
|
3
|
-
import { DaysOfWeekMap as
|
|
4
|
-
import
|
|
5
|
-
import k from "./
|
|
2
|
+
import x from "moment";
|
|
3
|
+
import { DaysOfWeekMap as E } from "../shared/constants.mjs";
|
|
4
|
+
import f from "../date/createLocalTimezoneMoment.mjs";
|
|
5
|
+
import k from "./getExpressServiceIntervalStart.mjs";
|
|
6
|
+
import S from "./getExpressServiceIntervalEnd.mjs";
|
|
6
7
|
import "../time/getTimeSpanParts.mjs";
|
|
7
|
-
function
|
|
8
|
-
const t =
|
|
8
|
+
function O(n, i) {
|
|
9
|
+
const t = x();
|
|
9
10
|
let o = t.clone().add(1, "day").startOf("day");
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
function a(e) {
|
|
12
|
+
const m = e.type === r.Exception, p = m ? f(e.periodFrom) : t, d = m ? f(e.periodTo) : t, s = k(
|
|
13
|
+
p,
|
|
13
14
|
e,
|
|
14
|
-
|
|
15
|
-
),
|
|
15
|
+
i
|
|
16
|
+
), c = S(
|
|
16
17
|
d,
|
|
17
18
|
e,
|
|
18
|
-
|
|
19
|
+
i
|
|
19
20
|
);
|
|
20
|
-
|
|
21
|
+
s.isBetween(t, o) ? o = s : c.isBetween(t, o) && (o = c);
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return n.forEach((e) => {
|
|
23
24
|
switch (e.type) {
|
|
24
25
|
case r.Exception:
|
|
25
|
-
|
|
26
|
+
a(e);
|
|
26
27
|
break;
|
|
27
|
-
case r.
|
|
28
|
+
case r.Normal:
|
|
28
29
|
default:
|
|
29
30
|
// Every day in the week
|
|
30
31
|
(e.dayOfWeek === y.Everyday || // Specific day in the week
|
|
31
|
-
e.dayOfWeek ===
|
|
32
|
+
e.dayOfWeek === E[t.isoWeekday()]) && a(e);
|
|
32
33
|
break;
|
|
33
34
|
}
|
|
34
35
|
}), o;
|
|
35
36
|
}
|
|
36
37
|
export {
|
|
37
|
-
|
|
38
|
+
O as default
|
|
38
39
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpeningHoursInterval } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
|
-
export default function getExpressServiceIntervalEnd(date: Moment, interval:
|
|
3
|
+
export default function getExpressServiceIntervalEnd(date: Moment, interval: OpeningHoursInterval, outletTimezoneOffset?: string): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const e=require("../time/getTimeSpanParts.js");function a(s,n,o){const c=e(n.from),u=e(n.duration),t=s.clone().hour(c.hours).minute(c.minutes).second(0).millisecond(0);if(t.add(u),o){const i=e(o),r=i.hours*60+i.minutes,f=s.utcOffset()-r;t.add(f,"minute")}return t}module.exports=a;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
function m(
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
r = i.hours * 60 + i.minutes;
|
|
1
|
+
import e from "../time/getTimeSpanParts.mjs";
|
|
2
|
+
function m(n, s, o) {
|
|
3
|
+
const c = e(s.from), f = e(s.duration), t = n.clone().hour(c.hours).minute(c.minutes).second(0).millisecond(0);
|
|
4
|
+
if (t.add(f), o) {
|
|
5
|
+
const i = e(o), u = i.hours * 60 + i.minutes, r = n.utcOffset() - u;
|
|
6
|
+
t.add(r, "minute");
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
return Math.abs(d) && t.subtract(d, "day"), t.add(a.hours, "hour").add(a.minutes, "minute"), t;
|
|
8
|
+
return t;
|
|
11
9
|
}
|
|
12
10
|
export {
|
|
13
11
|
m as default
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpeningHoursInterval } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
|
-
export default function getExpressServiceIntervalStart(date: Moment, interval:
|
|
3
|
+
export default function getExpressServiceIntervalStart(date: Moment, interval: OpeningHoursInterval, outletTimezoneOffset?: string): Moment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const i=require("../time/getTimeSpanParts.js");function f(t,o,e){const s=i(o.from),n=t.clone().hour(s.hours).minute(s.minutes).second(0).millisecond(0);if(e){const c=i(e),r=c.hours*60+c.minutes,u=t.utcOffset()-r;n.add(u,"minute")}return n}module.exports=f;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
function m(t,
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
r = o.hours * 60 + o.minutes;
|
|
1
|
+
import c from "../time/getTimeSpanParts.mjs";
|
|
2
|
+
function m(t, f, e) {
|
|
3
|
+
const s = c(f.from), n = t.clone().hour(s.hours).minute(s.minutes).second(0).millisecond(0);
|
|
4
|
+
if (e) {
|
|
5
|
+
const o = c(e), i = o.hours * 60 + o.minutes, r = t.utcOffset() - i;
|
|
6
|
+
n.add(r, "minute");
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
return Math.abs(n) && e.subtract(n, "day"), e;
|
|
8
|
+
return n;
|
|
11
9
|
}
|
|
12
10
|
export {
|
|
13
11
|
m as default
|
|
@@ -27,5 +27,5 @@ export declare type OpeningHoursTable = {
|
|
|
27
27
|
* @param nowISOString Optional ISO date string of current datetime
|
|
28
28
|
* @returns Opening hours table
|
|
29
29
|
*/
|
|
30
|
-
export default function getListOutletOpeningHoursTable(outlet: OutletListItem,
|
|
30
|
+
export default function getListOutletOpeningHoursTable(outlet: OutletListItem, nowLocaleString?: string): OpeningHoursTable[];
|
|
31
31
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const T=require("moment"),t=require("@ancon/wildcat-types"),g=require("../shared/isWithinFlag.js"),O=require("../shared/generateId.js");require("react");const F=require("../time/getTimeSpanParts.js"),I=require("../date/createLocalTimezoneMoment.js"),l=[{id:t.OrderFormat.EatIn,name:"eatIn"},{id:t.OrderFormat.TakeAway,name:"takeaway"},{id:t.OrderFormat.TableOrder,name:"tableOrder"},{id:t.OrderFormat.Delivery,name:"delivery"},{id:t.OrderFormat.BoxPickup,name:"boxPickup"}];function W(r){const n=T(r).subtract(1,"day").startOf("day"),e=[];for(let d=0,o=n;d<7;d+=1)o=o.clone().add(1,"day").startOf("day"),e.push(o.clone());return e}function v(r){return[...r].sort((n,e)=>n.isoWeekday()-e.isoWeekday())}function D(r,n){const e=F(r.from),d=F(r.duration);if(r.type===t.IntervalType.Normal){let o=n.clone().add(e.hours,"hour").add(e.minutes,"minute");const m=o.date()-n.date();m!==0&&(o=o.subtract(m,"day"));const s=o.clone().add(d);return{id:r.id,start:o.format("YYYY-MM-DDTHH:mm:ss"),end:s.format("YYYY-MM-DDTHH:mm:ss")}}if(r.type===t.IntervalType.Exception){const o=I(r.periodFrom),m=I(r.periodTo);if(n.isBetween(o,m,void 0,"[]")){const s=n.clone().add(e.hours,"hour").add(e.minutes,"minute"),i=s.clone().add(d);return{id:r.id,start:s.format("YYYY-MM-DDTHH:mm:ss"),end:i.format("YYYY-MM-DDTHH:mm:ss"),reason:r.reason}}return null}throw new Error("Invalid interval type")}function M(r,n,e){const d={[t.DayOfWeek.Monday]:1,[t.DayOfWeek.Tuesday]:2,[t.DayOfWeek.Wednesday]:3,[t.DayOfWeek.Thursday]:4,[t.DayOfWeek.Friday]:5,[t.DayOfWeek.Saturday]:6,[t.DayOfWeek.Sunday]:7,[t.DayOfWeek.Everyday]:null};for(let o=0;o<n.length;o+=1){const m=n[o],s=m.isoWeekday(),i=r.dayOfWeek,u=(d[i]??null)===s||i===t.DayOfWeek.Everyday;if(e[s]||(e[s]={isoWeekday:s,key:"",open:[],adjusted:[],closed:[]}),u){const a=D(r,m);a&&(e[s].key+=a.id,r.type===t.IntervalType.Normal&&r.state===t.IntervalState.Opened?e[s].open.push(a):r.type===t.IntervalType.Normal&&r.state===t.IntervalState.Closed?e[s].closed.push(a):r.type===t.IntervalType.Exception&&r.state===t.IntervalState.Opened?e[s].adjusted.push(a):r.type===t.IntervalType.Exception&&r.state===t.IntervalState.Closed&&e[s].closed.push(a))}}}function h(r){switch(r.type){case t.IntervalType.Exception:return O("interval-exception");case t.IntervalType.Normal:return O("interval-normal");default:return O("interval-unknown")}}function H(r){const n=r.reduce((e,d)=>(l.forEach(o=>{g(o.id,d.orderFormats)&&(e[o.id]||(e[o.id]={orderFormat:o,intervals:[]}),e[o.id].intervals.push(...d.intervals.sort((m,s)=>m.dayOfWeek-s.dayOfWeek)))}),e),{});return Object.values(n)}function Y(r,n){const e=n.reduce((d,o)=>o<=r?d+1:d,0);return r-e}function x(r){const{mergedTables:n}=r.reduce((e,d,o)=>{const m=e.mergedTables.findIndex(s=>s!==d&&!s.orderFormats.some(i=>d.orderFormats.some(p=>p.id===i.id))&&s.openingHours.every(i=>d.openingHours.some(p=>p.key===i.key))&&d.openingHours.every(i=>s.openingHours.some(p=>p.key===i.key)));if(m>=0){if(e.skipOrderFormats.some(a=>d.orderFormats.every(y=>y.id===a.id)))return e;const i=e.mergedTables[m];e.mergedTables.splice(m,1,{...i,orderFormats:[...d.orderFormats,...i.orderFormats]});const p=i.orderFormats.filter(a=>!e.skipOrderFormats.some(y=>y.id===a.id));p.length>0&&e.skipOrderFormats.push(...p);const u=Y(o,[...e.removedIndexes]);return e.mergedTables.splice(u,1),e.removedIndexes.push(o),e}return e},{mergedTables:[...r],removedIndexes:[],skipOrderFormats:[]});return n}function S(r){return r.map(n=>({...n,intervals:n.intervals.map(e=>({...e,id:h(e)}))}))}function E(r,n){const e=H(S(r.serviceDateTimes)),d=W(n),o=v(d),m=e.reduce((u,a)=>(u[a.orderFormat.id]||(u[a.orderFormat.id]={}),a.intervals.reduce((y,f)=>(M(f,o,y),y),u[a.orderFormat.id]),u),{}),s={[t.OrderFormat.EatIn]:l[0],[t.OrderFormat.TakeAway]:l[1],[t.OrderFormat.TableOrder]:l[2],[t.OrderFormat.Delivery]:l[3],[t.OrderFormat.BoxPickup]:l[4]},i=Object.entries(m).map(([u,a])=>({orderFormats:[s[Number(u)]],openingHours:Object.entries(a).map(([y,f])=>({isoWeekday:Number(y),key:f.key,open:f.open.sort((c,k)=>c.start.localeCompare(k.start)),adjusted:f.adjusted.sort((c,k)=>c.start.localeCompare(k.start)),closed:f.closed.sort((c,k)=>c.start.localeCompare(k.start))}))}));return x(i).sort((u,a)=>u.orderFormats[0].id-a.orderFormats[0].id)}module.exports=E;
|
|
@@ -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;
|