@ancon/wildcat-utils 1.44.0-r13-2-tz.28 → 1.44.0-r13-2-tz.30
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/outlet/getOutletNextReadyToOrderTime.js +1 -1
- package/outlet/getOutletNextReadyToOrderTime.mjs +22 -18
- package/outlet/getOutletTagInformation.js +1 -1
- package/outlet/getOutletTagInformation.mjs +36 -37
- package/outlet/searchNextOpeningMoment.js +1 -1
- package/outlet/searchNextOpeningMoment.mjs +38 -43
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const p=require("@ancon/wildcat-types"),r=require("moment"),q=require("./getSettingsForOrderFormat.js"),u=require("./isOutletAcceptingPreOrders.js"),x=require("./getOutletTagInformation.js"),v=require("./getNextTenthMinute.js"),_=require("./getServiceIntervalsForOrderFormat.js"),I=require("./getOutletNextServiceTimeOffset.js");require("../date/createLocalTimezoneMoment.js");require("../time/getTimeSpanParts.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getServiceIntervalTimeSpanMoment.js");require("./searchNextOpeningMoment.js");function N(e,i){const c=(e==null?void 0:e.state)===p.OutletState.Opened,t=q(i,e==null?void 0:e.orderFormatSettings),g=(t==null?void 0:t.preparationTime)??"00:00:00",O=u((e==null?void 0:e.orderFormatSettings)||[]),f=_(i,(e==null?void 0:e.serviceDateTimes)||[]),o=x.default(f,c,r(),r()),T=!c&&O&&o.openingTime?o.openingTime:void 0,a=r(),s=r(T);console.log("Next Order Time",s.format());const n=(a>s?a:s).second(0).millisecond(0);console.log("Next Order Time",n.format());const m=I(i,g,e==null?void 0:e.deliveryIntegrationEnabled);m>0&&n.add(m,"minute");const d=v(n)-n.minutes();return d&&n.add(d,"minutes"),n}module.exports=N;
|
|
@@ -1,39 +1,43 @@
|
|
|
1
1
|
import { OutletState as T } from "@ancon/wildcat-types";
|
|
2
2
|
import i from "moment";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import x from "./getSettingsForOrderFormat.mjs";
|
|
4
|
+
import v from "./isOutletAcceptingPreOrders.mjs";
|
|
5
5
|
import I from "./getOutletTagInformation.mjs";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import N from "./getNextTenthMinute.mjs";
|
|
7
|
+
import S from "./getServiceIntervalsForOrderFormat.mjs";
|
|
8
|
+
import y from "./getOutletNextServiceTimeOffset.mjs";
|
|
9
9
|
import "../date/createLocalTimezoneMoment.mjs";
|
|
10
10
|
import "../time/getTimeSpanParts.mjs";
|
|
11
11
|
import "./constants.mjs";
|
|
12
12
|
import "./getOutletCurrentActiveOperatingHour.mjs";
|
|
13
13
|
import "./getServiceIntervalTimeSpanMoment.mjs";
|
|
14
14
|
import "./searchNextOpeningMoment.mjs";
|
|
15
|
-
function z(
|
|
16
|
-
const
|
|
15
|
+
function z(e, r) {
|
|
16
|
+
const o = (e == null ? void 0 : e.state) === T.Opened, t = x(
|
|
17
17
|
r,
|
|
18
|
-
|
|
19
|
-
), f = (t == null ? void 0 : t.preparationTime) ?? "00:00:00", d =
|
|
20
|
-
(
|
|
21
|
-
), g =
|
|
18
|
+
e == null ? void 0 : e.orderFormatSettings
|
|
19
|
+
), f = (t == null ? void 0 : t.preparationTime) ?? "00:00:00", d = v(
|
|
20
|
+
(e == null ? void 0 : e.orderFormatSettings) || []
|
|
21
|
+
), g = S(
|
|
22
22
|
r,
|
|
23
|
-
(
|
|
23
|
+
(e == null ? void 0 : e.serviceDateTimes) || []
|
|
24
24
|
), s = I(
|
|
25
25
|
g,
|
|
26
|
-
|
|
26
|
+
o,
|
|
27
27
|
i(),
|
|
28
28
|
i()
|
|
29
|
-
), O = !
|
|
29
|
+
), O = !o && d && s.openingTime ? s.openingTime : void 0, p = i(), m = i(O);
|
|
30
|
+
console.log("Next Order Time", m.format());
|
|
31
|
+
const n = (p > m ? p : m).second(0).millisecond(0);
|
|
32
|
+
console.log("Next Order Time", n.format());
|
|
33
|
+
const a = y(
|
|
30
34
|
r,
|
|
31
35
|
f,
|
|
32
|
-
|
|
36
|
+
e == null ? void 0 : e.deliveryIntegrationEnabled
|
|
33
37
|
);
|
|
34
|
-
a > 0 &&
|
|
35
|
-
const c =
|
|
36
|
-
return c &&
|
|
38
|
+
a > 0 && n.add(a, "minute");
|
|
39
|
+
const c = N(n) - n.minutes();
|
|
40
|
+
return c && n.add(c, "minutes"), n;
|
|
37
41
|
}
|
|
38
42
|
export {
|
|
39
43
|
z as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@ancon/wildcat-types"),v=require("moment"),u=require("../date/createLocalTimezoneMoment.js"),k=require("../time/getTimeSpanParts.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),D=require("./getServiceIntervalTimeSpanMoment.js"),S=require("./searchNextOpeningMoment.js"),O={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function T(n,e){const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("@ancon/wildcat-types"),v=require("moment"),u=require("../date/createLocalTimezoneMoment.js"),k=require("../time/getTimeSpanParts.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),D=require("./getServiceIntervalTimeSpanMoment.js"),S=require("./searchNextOpeningMoment.js"),O={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function T(n,e){const o=n.isSame(e,"d"),a={[e.format(d.OutletMapKeyFormatter)]:{intervals:[],exception:null,metadata:{dayOfWeek:O[e.isoWeekday()]}}};for(let s=o?1:0;s<d.OutletTimelineDayCount;s+=1){const i=v(n).add(s,"d");a[i.format(d.OutletMapKeyFormatter)]={intervals:[],exception:null,metadata:{dayOfWeek:O[i.isoWeekday()]}}}return a}function W(n,e){const o=u(e.periodFrom),t=u(e.periodTo);if(!o.isSame(t,"d"))Object.keys(n).forEach(s=>{const i=v(s);if(i.isSame(o,"d")||i.isSame(t,"d")||i.isBetween(o,t)){const c=n[s],r=c.exception?c.exception.position:0;e.position>r&&(c.exception=e)}});else{const s=o.format(d.OutletMapKeyFormatter),i=n[s];if(i){const m=i.exception?i.exception.position:0;e.position>m&&(i.exception=e)}}}function I(n,e){Object.keys(n).forEach(o=>{const t=n[o],{dayOfWeek:a}=t.metadata,{dayOfWeek:s}=e;(a&s)===a&&t.intervals.push(e)})}function q(n,e,o){const t=T(e,o);return n.forEach(a=>{a.type===g.IntervalType.Exception?W(t,a):I(t,a)}),t}function x(n,e,o,t){const a=q(n,o,t),s=t.format(d.OutletMapKeyFormatter),i=M(s,a[s],t)!==null,m=e;let c=null,r=null;if(e){const f=o.format(d.OutletMapKeyFormatter),l=M(f,a[f],o);if(l){const{hours:p,minutes:y}=k(l.duration);r=D(f,l.from),c=r.clone().add(p,"hours").add(y,"minutes")}}else r=S(a,o);if(!e&&!r){const f=n.filter(p=>p.state&&u(p.periodTo).isAfter(o)),[l]=f.sort((p,y)=>t.valueOf()-(u(p.periodTo).valueOf()-u(y.periodTo).valueOf()));if(l)return x(n,e,u(l.periodTo),t)}return{closingTime:c,openingTime:r,openDuringSpecifiedTime:m,openNow:i}}exports.DaysOfWeekMap=O;exports.default=x;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntervalType as g } from "@ancon/wildcat-types";
|
|
2
2
|
import v from "moment";
|
|
3
|
-
import
|
|
3
|
+
import m from "../date/createLocalTimezoneMoment.mjs";
|
|
4
4
|
import M from "../time/getTimeSpanParts.mjs";
|
|
5
5
|
import { OutletMapKeyFormatter as d, OutletTimelineDayCount as k } from "./constants.mjs";
|
|
6
6
|
import O from "./getOutletCurrentActiveOperatingHour.mjs";
|
|
@@ -19,14 +19,14 @@ const x = {
|
|
|
19
19
|
// WEEKENDS: 96,
|
|
20
20
|
};
|
|
21
21
|
function I(n, e) {
|
|
22
|
-
const
|
|
22
|
+
const o = n.isSame(e, "d"), a = {
|
|
23
23
|
[e.format(d)]: {
|
|
24
24
|
intervals: [],
|
|
25
25
|
exception: null,
|
|
26
26
|
metadata: { dayOfWeek: x[e.isoWeekday()] }
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
for (let s =
|
|
29
|
+
for (let s = o ? 1 : 0; s < k; s += 1) {
|
|
30
30
|
const i = v(n).add(s, "d");
|
|
31
31
|
a[i.format(d)] = {
|
|
32
32
|
intervals: [],
|
|
@@ -36,80 +36,79 @@ function I(n, e) {
|
|
|
36
36
|
}
|
|
37
37
|
return a;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
|
|
39
|
+
function T(n, e) {
|
|
40
|
+
const o = m(e.periodFrom), t = m(e.periodTo);
|
|
41
|
+
if (!o.isSame(
|
|
42
|
+
t,
|
|
43
43
|
"d"
|
|
44
44
|
))
|
|
45
45
|
Object.keys(n).forEach((s) => {
|
|
46
46
|
const i = v(s);
|
|
47
|
-
if (i.isSame(
|
|
47
|
+
if (i.isSame(o, "d") || i.isSame(t, "d") || i.isBetween(o, t)) {
|
|
48
48
|
const p = n[s], r = p.exception ? p.exception.position : 0;
|
|
49
49
|
e.position > r && (p.exception = e);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
else {
|
|
53
|
-
const s =
|
|
53
|
+
const s = o.format(d), i = n[s];
|
|
54
54
|
if (i) {
|
|
55
55
|
const u = i.exception ? i.exception.position : 0;
|
|
56
56
|
e.position > u && (i.exception = e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
Object.keys(n).forEach((
|
|
62
|
-
const
|
|
63
|
-
(a & s) === a &&
|
|
60
|
+
function W(n, e) {
|
|
61
|
+
Object.keys(n).forEach((o) => {
|
|
62
|
+
const t = n[o], { dayOfWeek: a } = t.metadata, { dayOfWeek: s } = e;
|
|
63
|
+
(a & s) === a && t.intervals.push(e);
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const
|
|
66
|
+
function E(n, e, o) {
|
|
67
|
+
const t = I(e, o);
|
|
68
68
|
return n.forEach((a) => {
|
|
69
|
-
a.type === g.Exception ?
|
|
70
|
-
}),
|
|
69
|
+
a.type === g.Exception ? T(t, a) : W(t, a);
|
|
70
|
+
}), t;
|
|
71
71
|
}
|
|
72
|
-
function h(n, e,
|
|
73
|
-
const a =
|
|
72
|
+
function h(n, e, o, t) {
|
|
73
|
+
const a = E(
|
|
74
74
|
n,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
), s =
|
|
75
|
+
o,
|
|
76
|
+
t
|
|
77
|
+
), s = t.format(d), i = O(
|
|
78
78
|
s,
|
|
79
79
|
a[s],
|
|
80
|
-
|
|
80
|
+
t
|
|
81
81
|
) !== null, u = e;
|
|
82
82
|
let p = null, r = null;
|
|
83
83
|
if (e) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
a[
|
|
87
|
-
|
|
84
|
+
const f = o.format(d), c = O(
|
|
85
|
+
f,
|
|
86
|
+
a[f],
|
|
87
|
+
o
|
|
88
88
|
);
|
|
89
89
|
if (c) {
|
|
90
90
|
const { hours: l, minutes: y } = M(
|
|
91
91
|
c.duration
|
|
92
92
|
);
|
|
93
93
|
r = D(
|
|
94
|
-
|
|
95
|
-
c.from
|
|
96
|
-
t.utcOffset()
|
|
94
|
+
f,
|
|
95
|
+
c.from
|
|
97
96
|
), p = r.clone().add(l, "hours").add(y, "minutes");
|
|
98
97
|
}
|
|
99
98
|
} else
|
|
100
|
-
r = S(a,
|
|
99
|
+
r = S(a, o);
|
|
101
100
|
if (!e && !r) {
|
|
102
|
-
const
|
|
103
|
-
(l) => l.state &&
|
|
104
|
-
), [c] =
|
|
105
|
-
(l, y) =>
|
|
101
|
+
const f = n.filter(
|
|
102
|
+
(l) => l.state && m(l.periodTo).isAfter(o)
|
|
103
|
+
), [c] = f.sort(
|
|
104
|
+
(l, y) => t.valueOf() - (m(l.periodTo).valueOf() - m(y.periodTo).valueOf())
|
|
106
105
|
);
|
|
107
106
|
if (c)
|
|
108
107
|
return h(
|
|
109
108
|
n,
|
|
110
109
|
e,
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
m(c.periodTo),
|
|
111
|
+
t
|
|
113
112
|
);
|
|
114
113
|
}
|
|
115
114
|
return { closingTime: p, openingTime: r, openDuringSpecifiedTime: u, openNow: i };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const m=require("moment"),
|
|
1
|
+
"use strict";const m=require("moment"),y=require("@ancon/wildcat-types"),O=require("../time/getTimeSpanParts.js"),f=require("./constants.js"),u=require("./getServiceIntervalTimeSpanMoment.js");function p(l){let e=null;const{intervals:t,exception:n}=l;if(n){const{state:i}=n;i||(e=n)}else{const i=t.sort((o,r)=>O(o.from).hours-O(r.from).hours),[s]=i;return s}return e}function g(l,e,t){var i,s;const n=[];if(e.exception){if(e.exception.state===y.IntervalState.Opened){const o=u(l,e.exception.from,t.utcOffset());t.isBefore(o)&&n.push({interval:e.exception,moment:o})}}else for(let o=0;o<e.intervals.length;o+=1){const r=e.intervals[o],c=u(l,r.from,t.utcOffset());console.log("relevantMoment",t.format()),console.log("openingMoment",c.format()),t.isBefore(c)&&n.push({interval:r,moment:c})}return n.length<2?((i=n[0])==null?void 0:i.interval)??null:((s=n.sort((o,r)=>o.moment-t-(r.moment-t))[0])==null?void 0:s.interval)??null}function x(l,e){let t=null;const n=m(e).format(f.OutletMapKeyFormatter),i=g(n,l[n],e);if(i&&(t=u(n,i.from)),!t)for(let s=1;s<f.OutletTimelineDayCount;s+=1){const r=m(e).add(s,"d").format(f.OutletMapKeyFormatter),c=l[r],a=p(c);if(a){t=u(r,a.from);break}}return t}module.exports=x;
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IntervalState as
|
|
3
|
-
import
|
|
4
|
-
import { OutletMapKeyFormatter as
|
|
5
|
-
import
|
|
6
|
-
function y(
|
|
7
|
-
return i.clone().date() - e.date(), i;
|
|
8
|
-
}
|
|
9
|
-
function h(i) {
|
|
1
|
+
import c from "moment";
|
|
2
|
+
import { IntervalState as O } from "@ancon/wildcat-types";
|
|
3
|
+
import u from "../time/getTimeSpanParts.mjs";
|
|
4
|
+
import { OutletMapKeyFormatter as p, OutletTimelineDayCount as g } from "./constants.mjs";
|
|
5
|
+
import m from "./getServiceIntervalTimeSpanMoment.mjs";
|
|
6
|
+
function y(s) {
|
|
10
7
|
let e = null;
|
|
11
|
-
const { intervals: t, exception: o } =
|
|
8
|
+
const { intervals: t, exception: o } = s;
|
|
12
9
|
if (o) {
|
|
13
|
-
const { state:
|
|
14
|
-
|
|
10
|
+
const { state: i } = o;
|
|
11
|
+
i || (e = o);
|
|
15
12
|
} else {
|
|
16
|
-
const
|
|
17
|
-
(n,
|
|
18
|
-
), [
|
|
19
|
-
return
|
|
13
|
+
const i = t.sort(
|
|
14
|
+
(n, r) => u(n.from).hours - u(r.from).hours
|
|
15
|
+
), [l] = i;
|
|
16
|
+
return l;
|
|
20
17
|
}
|
|
21
18
|
return e;
|
|
22
19
|
}
|
|
23
|
-
function x(
|
|
24
|
-
var
|
|
20
|
+
function x(s, e, t) {
|
|
21
|
+
var i, l;
|
|
25
22
|
const o = [];
|
|
26
23
|
if (e.exception) {
|
|
27
|
-
if (e.exception.state ===
|
|
28
|
-
const n =
|
|
29
|
-
|
|
24
|
+
if (e.exception.state === O.Opened) {
|
|
25
|
+
const n = m(
|
|
26
|
+
s,
|
|
30
27
|
e.exception.from,
|
|
31
28
|
t.utcOffset()
|
|
32
29
|
);
|
|
@@ -37,43 +34,41 @@ function x(i, e, t) {
|
|
|
37
34
|
}
|
|
38
35
|
} else
|
|
39
36
|
for (let n = 0; n < e.intervals.length; n += 1) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const r = e.intervals[n], f = m(
|
|
38
|
+
s,
|
|
39
|
+
r.from,
|
|
43
40
|
t.utcOffset()
|
|
44
41
|
);
|
|
45
|
-
console.log("relevantMoment", t.format()), console.log("openingMoment",
|
|
42
|
+
console.log("relevantMoment", t.format()), console.log("openingMoment", f.format()), t.isBefore(f) && o.push({ interval: r, moment: f });
|
|
46
43
|
}
|
|
47
|
-
return o.length < 2 ? ((
|
|
44
|
+
return o.length < 2 ? ((i = o[0]) == null ? void 0 : i.interval) ?? null : ((l = o.sort(
|
|
48
45
|
// @ts-ignore TODO
|
|
49
|
-
(n,
|
|
50
|
-
)[0]) == null ? void 0 :
|
|
46
|
+
(n, r) => n.moment - t - (r.moment - t)
|
|
47
|
+
)[0]) == null ? void 0 : l.interval) ?? null;
|
|
51
48
|
}
|
|
52
|
-
function
|
|
49
|
+
function K(s, e) {
|
|
53
50
|
let t = null;
|
|
54
|
-
const o =
|
|
51
|
+
const o = c(e).format(p), i = x(
|
|
55
52
|
o,
|
|
56
|
-
|
|
53
|
+
s[o],
|
|
57
54
|
e
|
|
58
55
|
);
|
|
59
|
-
if (
|
|
56
|
+
if (i && (t = m(
|
|
60
57
|
o,
|
|
61
|
-
|
|
62
|
-
e.utcOffset()
|
|
58
|
+
i.from
|
|
63
59
|
)), !t)
|
|
64
|
-
for (let
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
t =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
), t = y(t, n);
|
|
60
|
+
for (let l = 1; l < g; l += 1) {
|
|
61
|
+
const r = c(e).add(l, "d").format(p), f = s[r], a = y(f);
|
|
62
|
+
if (a) {
|
|
63
|
+
t = m(
|
|
64
|
+
r,
|
|
65
|
+
a.from
|
|
66
|
+
);
|
|
72
67
|
break;
|
|
73
68
|
}
|
|
74
69
|
}
|
|
75
70
|
return t;
|
|
76
71
|
}
|
|
77
72
|
export {
|
|
78
|
-
|
|
73
|
+
K as default
|
|
79
74
|
};
|