@ancon/wildcat-utils 1.40.28 → 1.40.29

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.
@@ -1 +1 @@
1
- "use strict";const a=require("moment");function u(r,i,n,c=6e5,s){const l=r.valueOf(),f=i.valueOf(),m=[];for(let e=l;e<=f;e+=c){const t=s?a(e).locale(s):a(e),o=t.valueOf();n.some(d=>d.timestamp===o)||m.push({timestamp:o,timeLabel:t.format("HH:mm"),dayLabel:t.format("dddd")})}return m}module.exports=u;
1
+ "use strict";const r=require("moment");function f(i,n,c,s=6e5,m){const l=i.valueOf(),d=n.valueOf()-s,o=[];for(let e=l;e<=d;e+=s){const t=m?r(e).locale(m):r(e),a=t.valueOf();c.some(u=>u.timestamp===a)||o.push({timestamp:a,timeLabel:t.format("HH:mm"),dayLabel:t.format("dddd")})}return o}module.exports=f;
@@ -1,15 +1,15 @@
1
- import a from "moment";
2
- function u(r, i, n, f = 6e5, m) {
3
- const l = r.valueOf(), c = i.valueOf(), s = [];
4
- for (let e = l; e <= c; e += f) {
5
- const t = m ? a(e).locale(m) : a(e), o = t.valueOf();
6
- n.some((d) => d.timestamp === o) || s.push({
7
- timestamp: o,
1
+ import r from "moment";
2
+ function u(i, n, l, m = 6e5, s) {
3
+ const c = i.valueOf(), d = n.valueOf() - m, o = [];
4
+ for (let e = c; e <= d; e += m) {
5
+ const t = s ? r(e).locale(s) : r(e), a = t.valueOf();
6
+ l.some((f) => f.timestamp === a) || o.push({
7
+ timestamp: a,
8
8
  timeLabel: t.format("HH:mm"),
9
9
  dayLabel: t.format("dddd")
10
10
  });
11
11
  }
12
- return s;
12
+ return o;
13
13
  }
14
14
  export {
15
15
  u as default
@@ -1 +1 @@
1
- "use strict";const f=require("@ancon/wildcat-types"),O=require("moment"),S=require("./getPickerIntervalsForDay.js"),h=require("./getSettingsForOrderFormat.js"),k=require("./getServiceIntervalStart.js"),l=require("./generatePickerTimesForDay.js"),T=require("./getServiceIntervalEnd.js"),_=require("./getOutletNextReadyToOrderTime.js");require("../shared/constants.js");require("./getServiceIntervalsForOrderFormat.js");require("./getNextTenthMinute.js");require("./hoursAndMinutesToMinutes.js");require("./isOutletAcceptingPreOrders.js");require("./getOutletTagInformation.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getMomentFromDateAndTimeString.js");require("./searchNextOpeningMoment.js");function D(e,o,p,y){const{preparationTime:m="00:00:00"}=h(o,e==null?void 0:e.orderFormatSettings)??{},n=_(e,o);let s=n.clone();const a=O(p);a>n&&(s=n.clone().set({year:a.year(),month:a.month(),date:a.date()}));let r=[];const g=S(s.isoWeekday(),e==null?void 0:e.serviceDateTimes,o);let q;return g.forEach(t=>{!q&&t.type&&(r=[]);const c=k(s,t,m,e==null?void 0:e.timeZoneOffset),u=T(s,t,m,e==null?void 0:e.timeZoneOffset);c<n&&c.add(n.valueOf()-c.valueOf(),"millisecond");const i=l(c,u,r,void 0,y);i.length>0&&t.state===f.IntervalState.Closed?r=r.filter(d=>d.timestamp<i[0].timestamp||d.timestamp>i[i.length-1].timestamp):i.length>0&&t.state===f.IntervalState.Open&&(r=r.concat(i)),q=t.type}),r}module.exports=D;
1
+ "use strict";const f=require("@ancon/wildcat-types"),O=require("moment"),S=require("./getPickerIntervalsForDay.js"),h=require("./getSettingsForOrderFormat.js"),l=require("./getServiceIntervalStart.js"),T=require("./generatePickerTimesForDay.js"),_=require("./getServiceIntervalEnd.js"),k=require("./getOutletNextReadyToOrderTime.js");require("../shared/constants.js");require("./getServiceIntervalsForOrderFormat.js");require("./getNextTenthMinute.js");require("./hoursAndMinutesToMinutes.js");require("./isOutletAcceptingPreOrders.js");require("./getOutletTagInformation.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getMomentFromDateAndTimeString.js");require("./searchNextOpeningMoment.js");function D(e,o,p,y){const{preparationTime:m="00:00:00"}=h(o,e==null?void 0:e.orderFormatSettings)??{},n=k(e,o);let s=n.clone();const a=O(p);a>n&&(s=n.clone().set({year:a.year(),month:a.month(),date:a.date()}));let r=[];const g=S(s,e==null?void 0:e.serviceDateTimes,o);let q;return g.forEach(t=>{!q&&t.type&&(r=[]);const c=l(s,t,m,e==null?void 0:e.timeZoneOffset),u=_(s,t,m,e==null?void 0:e.timeZoneOffset);c<n&&c.add(n.valueOf()-c.valueOf(),"millisecond");const i=T(c,u,r,void 0,y);i.length>0&&t.state===f.IntervalState.Closed?r=r.filter(d=>d.timestamp<i[0].timestamp||d.timestamp>i[i.length-1].timestamp):i.length>0&&t.state===f.IntervalState.Open&&(r=r.concat(i)),q=t.type}),r}module.exports=D;
@@ -1,6 +1,6 @@
1
1
  import { IntervalState as d } from "@ancon/wildcat-types";
2
- import k from "moment";
3
- import S from "./getPickerIntervalsForDay.mjs";
2
+ import S from "moment";
3
+ import k from "./getPickerIntervalsForDay.mjs";
4
4
  import T from "./getSettingsForOrderFormat.mjs";
5
5
  import D from "./getServiceIntervalStart.mjs";
6
6
  import F from "./generatePickerTimesForDay.mjs";
@@ -16,51 +16,51 @@ import "./constants.mjs";
16
16
  import "./getOutletCurrentActiveOperatingHour.mjs";
17
17
  import "./getMomentFromDateAndTimeString.mjs";
18
18
  import "./searchNextOpeningMoment.mjs";
19
- function J(e, p, y, g) {
20
- const { preparationTime: s = "00:00:00" } = T(p, e == null ? void 0 : e.orderFormatSettings) ?? {}, m = P(e, p);
21
- let o = m.clone();
22
- const n = k(y);
23
- n > m && (o = m.clone().set({
24
- year: n.year(),
25
- month: n.month(),
26
- date: n.date()
19
+ function K(r, a, g, y) {
20
+ const { preparationTime: s = "00:00:00" } = T(a, r == null ? void 0 : r.orderFormatSettings) ?? {}, m = P(r, a);
21
+ let n = m.clone();
22
+ const o = S(g);
23
+ o > m && (n = m.clone().set({
24
+ year: o.year(),
25
+ month: o.month(),
26
+ date: o.date()
27
27
  }));
28
- let r = [];
29
- const O = S(
30
- o.isoWeekday(),
31
- e == null ? void 0 : e.serviceDateTimes,
32
- p
28
+ let e = [];
29
+ const O = k(
30
+ n,
31
+ r == null ? void 0 : r.serviceDateTimes,
32
+ a
33
33
  );
34
34
  let f;
35
35
  return O.forEach((i) => {
36
- !f && i.type && (r = []);
37
- const a = D(
38
- o,
36
+ !f && i.type && (e = []);
37
+ const p = D(
38
+ n,
39
39
  i,
40
40
  s,
41
- e == null ? void 0 : e.timeZoneOffset
41
+ r == null ? void 0 : r.timeZoneOffset
42
42
  ), h = x(
43
- o,
43
+ n,
44
44
  i,
45
45
  s,
46
- e == null ? void 0 : e.timeZoneOffset
46
+ r == null ? void 0 : r.timeZoneOffset
47
47
  );
48
- a < m && a.add(
49
- m.valueOf() - a.valueOf(),
48
+ p < m && p.add(
49
+ m.valueOf() - p.valueOf(),
50
50
  "millisecond"
51
51
  );
52
52
  const t = F(
53
- a,
53
+ p,
54
54
  h,
55
- r,
55
+ e,
56
56
  void 0,
57
- g
57
+ y
58
58
  );
59
- t.length > 0 && i.state === d.Closed ? r = r.filter(
59
+ t.length > 0 && i.state === d.Closed ? e = e.filter(
60
60
  (c) => c.timestamp < t[0].timestamp || c.timestamp > t[t.length - 1].timestamp
61
- ) : t.length > 0 && i.state === d.Open && (r = r.concat(t)), f = i.type;
62
- }), r;
61
+ ) : t.length > 0 && i.state === d.Open && (e = e.concat(t)), f = i.type;
62
+ }), e;
63
63
  }
64
64
  export {
65
- J as default
65
+ K as default
66
66
  };
@@ -1,4 +1,5 @@
1
1
  import { OrderFormat, ServiceDateTime, ServiceDateTimeInterval } from '@ancon/wildcat-types';
2
+ import { Moment } from 'moment';
2
3
  /**
3
4
  * Returns the intervals for the specified weekday index (0-6) and order format (optional)
4
5
  *
@@ -7,4 +8,4 @@ import { OrderFormat, ServiceDateTime, ServiceDateTimeInterval } from '@ancon/wi
7
8
  * @param orderFormat
8
9
  * @returns
9
10
  */
10
- export default function getPickerIntervalsForDay(weekdayIndex: number, serviceDateTimes: ServiceDateTime[], orderFormat?: OrderFormat): ServiceDateTimeInterval[];
11
+ export default function getPickerIntervalsForDay(date: Moment, serviceDateTimes: ServiceDateTime[], orderFormat?: OrderFormat): ServiceDateTimeInterval[];
@@ -1 +1 @@
1
- "use strict";const f=require("@ancon/wildcat-types"),o=require("moment"),d=require("../shared/constants.js"),m=require("./getServiceIntervalsForOrderFormat.js");function p(t,i,n){return m(n,i).reduce((e,r)=>{const u=r.dayOfWeek===f.DayOfWeek.Everyday,a=!!r.type;if(u){if(a){const s=o(r.fromDate),y=o().isoWeekday(t);return s.isSame(y,"isoWeek")&&t===s.isoWeekday()&&e.push(r),e}return e.push(r),e}return r.dayOfWeek===d.DaysOfWeekMap[t]&&e.push(r),e},[])}module.exports=p;
1
+ "use strict";const f=require("@ancon/wildcat-types"),s=require("moment"),D=require("../shared/constants.js"),c=require("./getServiceIntervalsForOrderFormat.js");function p(r,o,n){return c(n,o).reduce((t,e)=>{const a=e.dayOfWeek===f.DayOfWeek.Everyday,i=!!e.type,u=r.isoWeekday();if(a){if(i){const y=s(e.fromDate),d=s(e.toDate);return r.isBetween(y,d,"day","[]")&&t.push(e),t}return t.push(e),t}return e.dayOfWeek===D.DaysOfWeekMap[u]&&t.push(e),t},[])}module.exports=p;
@@ -1,26 +1,26 @@
1
- import { DayOfWeek as p } from "@ancon/wildcat-types";
2
- import s from "moment";
3
- import { DaysOfWeekMap as u } from "../shared/constants.mjs";
4
- import y from "./getServiceIntervalsForOrderFormat.mjs";
5
- function D(o, f, m) {
6
- return y(
7
- m,
8
- f
1
+ import { DayOfWeek as d } from "@ancon/wildcat-types";
2
+ import o from "moment";
3
+ import { DaysOfWeekMap as p } from "../shared/constants.mjs";
4
+ import u from "./getServiceIntervalsForOrderFormat.mjs";
5
+ function w(t, s, n) {
6
+ return u(
7
+ n,
8
+ s
9
9
  ).reduce(
10
10
  (r, e) => {
11
- const i = e.dayOfWeek === p.Everyday, a = !!e.type;
12
- if (i) {
13
- if (a) {
14
- const t = s(e.fromDate), n = s().isoWeekday(o);
15
- return t.isSame(n, "isoWeek") && o === t.isoWeekday() && r.push(e), r;
11
+ const a = e.dayOfWeek === d.Everyday, f = !!e.type, m = t.isoWeekday();
12
+ if (a) {
13
+ if (f) {
14
+ const i = o(e.fromDate), y = o(e.toDate);
15
+ return t.isBetween(i, y, "day", "[]") && r.push(e), r;
16
16
  }
17
17
  return r.push(e), r;
18
18
  }
19
- return e.dayOfWeek === u[o] && r.push(e), r;
19
+ return e.dayOfWeek === p[m] && r.push(e), r;
20
20
  },
21
21
  []
22
22
  );
23
23
  }
24
24
  export {
25
- D as default
25
+ w as default
26
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.40.28",
3
+ "version": "1.40.29",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",