@ancon/wildcat-utils 1.9.1 → 1.10.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.
Files changed (80) hide show
  1. package/api/getEndpointWithVersion.js +1 -6
  2. package/api/getEndpointWithVersion.mjs +6 -0
  3. package/api/getUrlAndParams.js +1 -23
  4. package/api/getUrlAndParams.mjs +23 -0
  5. package/api/index.js +1 -6
  6. package/api/index.mjs +6 -0
  7. package/color/brighten.js +1 -7
  8. package/color/brighten.mjs +7 -0
  9. package/color/darken.js +1 -7
  10. package/color/darken.mjs +7 -0
  11. package/color/index.js +1 -9
  12. package/color/index.mjs +9 -0
  13. package/color/lighten.js +1 -7
  14. package/color/lighten.mjs +7 -0
  15. package/index.d.ts +1 -0
  16. package/index.js +1 -36
  17. package/index.mjs +40 -0
  18. package/logger/Logger.d.ts +12 -0
  19. package/logger/Logger.js +1 -0
  20. package/logger/Logger.mjs +30 -0
  21. package/logger/index.d.ts +4 -0
  22. package/logger/index.js +1 -0
  23. package/logger/index.mjs +6 -0
  24. package/logger/types.d.ts +12 -0
  25. package/logger/types.js +1 -0
  26. package/logger/types.mjs +4 -0
  27. package/outlet/getListOutletOpeningHoursTable.js +1 -172
  28. package/outlet/getListOutletOpeningHoursTable.mjs +172 -0
  29. package/outlet/index.js +1 -8
  30. package/outlet/index.mjs +8 -0
  31. package/outlet/types.js +1 -1
  32. package/outlet/types.mjs +1 -0
  33. package/package.json +13 -2
  34. package/shared/enums.js +1 -7
  35. package/shared/enums.mjs +7 -0
  36. package/shared/generateId.js +1 -7
  37. package/shared/generateId.mjs +7 -0
  38. package/shared/index.js +1 -11
  39. package/shared/index.mjs +11 -0
  40. package/shared/isWithinFlag.js +1 -6
  41. package/shared/isWithinFlag.mjs +6 -0
  42. package/string/index.js +1 -4
  43. package/string/index.mjs +4 -0
  44. package/string/slugify.js +1 -6
  45. package/string/slugify.mjs +6 -0
  46. package/user/getFullAddressString.js +1 -6
  47. package/user/getFullAddressString.mjs +6 -0
  48. package/user/getFullName.js +1 -13
  49. package/user/getFullName.mjs +13 -0
  50. package/user/index.js +1 -6
  51. package/user/index.mjs +6 -0
  52. package/versioning/cleanVersionString.js +1 -7
  53. package/versioning/cleanVersionString.mjs +7 -0
  54. package/versioning/index.js +1 -7
  55. package/versioning/index.mjs +7 -0
  56. package/versioning/isVersionALessThanB.js +1 -9
  57. package/versioning/isVersionALessThanB.mjs +9 -0
  58. package/api/getEndpointWithVersion.cjs +0 -1
  59. package/api/getUrlAndParams.cjs +0 -1
  60. package/api/index.cjs +0 -1
  61. package/color/brighten.cjs +0 -1
  62. package/color/darken.cjs +0 -1
  63. package/color/index.cjs +0 -1
  64. package/color/lighten.cjs +0 -1
  65. package/index.cjs +0 -1
  66. package/outlet/getListOutletOpeningHoursTable.cjs +0 -1
  67. package/outlet/index.cjs +0 -1
  68. package/outlet/types.cjs +0 -1
  69. package/shared/enums.cjs +0 -1
  70. package/shared/generateId.cjs +0 -1
  71. package/shared/index.cjs +0 -1
  72. package/shared/isWithinFlag.cjs +0 -1
  73. package/string/index.cjs +0 -1
  74. package/string/slugify.cjs +0 -1
  75. package/user/getFullAddressString.cjs +0 -1
  76. package/user/getFullName.cjs +0 -1
  77. package/user/index.cjs +0 -1
  78. package/versioning/cleanVersionString.cjs +0 -1
  79. package/versioning/index.cjs +0 -1
  80. package/versioning/isVersionALessThanB.cjs +0 -1
@@ -1,6 +1 @@
1
- function n(t, e = 1) {
2
- return `v${e.toFixed(1)}/${t}`;
3
- }
4
- export {
5
- n as default
6
- };
1
+ "use strict";function i(t,e=1){return`v${e.toFixed(1)}/${t}`}module.exports=i;
@@ -0,0 +1,6 @@
1
+ function n(t, e = 1) {
2
+ return `v${e.toFixed(1)}/${t}`;
3
+ }
4
+ export {
5
+ n as default
6
+ };
@@ -1,23 +1 @@
1
- const f = /(\/{.+?})/g, g = /[/{}]/g;
2
- function a(o, e) {
3
- const s = { url: o, params: e ?? {} };
4
- if (!e)
5
- return s;
6
- const t = o.match(f);
7
- return t != null && t.length ? t.reduce(
8
- (n, l) => {
9
- const r = l.replace(g, ""), p = e[r];
10
- return p ? (delete n.params[r], n.url = n.url.replace(
11
- new RegExp(l, "g"),
12
- `/${p}`
13
- )) : n.params[r] = e[r], n;
14
- },
15
- {
16
- url: o,
17
- params: { ...e }
18
- }
19
- ) : s;
20
- }
21
- export {
22
- a as default
23
- };
1
+ "use strict";const l=/(\/{.+?})/g,c=/[/{}]/g;function f(s,t){const o={url:s,params:t??{}};if(!t)return o;const n=s.match(l);return n!=null&&n.length?n.reduce((e,p)=>{const r=p.replace(c,""),g=t[r];return g?(delete e.params[r],e.url=e.url.replace(new RegExp(p,"g"),`/${g}`)):e.params[r]=t[r],e},{url:s,params:{...t}}):o}module.exports=f;
@@ -0,0 +1,23 @@
1
+ const f = /(\/{.+?})/g, g = /[/{}]/g;
2
+ function a(o, e) {
3
+ const s = { url: o, params: e ?? {} };
4
+ if (!e)
5
+ return s;
6
+ const t = o.match(f);
7
+ return t != null && t.length ? t.reduce(
8
+ (n, l) => {
9
+ const r = l.replace(g, ""), p = e[r];
10
+ return p ? (delete n.params[r], n.url = n.url.replace(
11
+ new RegExp(l, "g"),
12
+ `/${p}`
13
+ )) : n.params[r] = e[r], n;
14
+ },
15
+ {
16
+ url: o,
17
+ params: { ...e }
18
+ }
19
+ ) : s;
20
+ }
21
+ export {
22
+ a as default
23
+ };
package/api/index.js CHANGED
@@ -1,6 +1 @@
1
- import { default as r } from "./getUrlAndParams.js";
2
- import { default as o } from "./getEndpointWithVersion.js";
3
- export {
4
- o as getEndpointWithVersion,
5
- r as getUrlAndParams
6
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getUrlAndParams.js"),t=require("./getEndpointWithVersion.js");exports.getUrlAndParams=e;exports.getEndpointWithVersion=t;
package/api/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import { default as r } from "./getUrlAndParams.mjs";
2
+ import { default as o } from "./getEndpointWithVersion.mjs";
3
+ export {
4
+ o as getEndpointWithVersion,
5
+ r as getUrlAndParams
6
+ };
package/color/brighten.js CHANGED
@@ -1,7 +1 @@
1
- import n from "tinycolor2";
2
- function i(t, r) {
3
- return n(t).brighten(r).toString();
4
- }
5
- export {
6
- i as default
7
- };
1
+ "use strict";const n=require("tinycolor2");function e(t,r){return n(t).brighten(r).toString()}module.exports=e;
@@ -0,0 +1,7 @@
1
+ import n from "tinycolor2";
2
+ function i(t, r) {
3
+ return n(t).brighten(r).toString();
4
+ }
5
+ export {
6
+ i as default
7
+ };
package/color/darken.js CHANGED
@@ -1,7 +1 @@
1
- import n from "tinycolor2";
2
- function e(r, t) {
3
- return n(r).darken(t).toString();
4
- }
5
- export {
6
- e as default
7
- };
1
+ "use strict";const n=require("tinycolor2");function e(r,t){return n(r).darken(t).toString()}module.exports=e;
@@ -0,0 +1,7 @@
1
+ import n from "tinycolor2";
2
+ function e(r, t) {
3
+ return n(r).darken(t).toString();
4
+ }
5
+ export {
6
+ e as default
7
+ };
package/color/index.js CHANGED
@@ -1,9 +1 @@
1
- import { default as a } from "./lighten.js";
2
- import { default as f } from "./brighten.js";
3
- import { default as l } from "./darken.js";
4
- import "tinycolor2";
5
- export {
6
- f as brighten,
7
- l as darken,
8
- a as lighten
9
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./lighten.js"),r=require("./brighten.js"),o=require("./darken.js");require("tinycolor2");exports.lighten=e;exports.brighten=r;exports.darken=o;
@@ -0,0 +1,9 @@
1
+ import { default as a } from "./lighten.mjs";
2
+ import { default as f } from "./brighten.mjs";
3
+ import { default as l } from "./darken.mjs";
4
+ import "tinycolor2";
5
+ export {
6
+ f as brighten,
7
+ l as darken,
8
+ a as lighten
9
+ };
package/color/lighten.js CHANGED
@@ -1,7 +1 @@
1
- import o from "tinycolor2";
2
- function i(t, n) {
3
- return o(t).lighten(n).toString();
4
- }
5
- export {
6
- i as default
7
- };
1
+ "use strict";const r=require("tinycolor2");function e(t,n){return r(t).lighten(n).toString()}module.exports=e;
@@ -0,0 +1,7 @@
1
+ import o from "tinycolor2";
2
+ function i(t, n) {
3
+ return o(t).lighten(n).toString();
4
+ }
5
+ export {
6
+ i as default
7
+ };
package/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from './api';
5
5
  export * from './string';
6
6
  export * from './color';
7
7
  export * from './user';
8
+ export * from './logger';
package/index.js CHANGED
@@ -1,36 +1 @@
1
- import { DayOfWeek as f, IntervalState as l, IntervalType as s, OrderFormat as m } from "./shared/enums.js";
2
- import { default as i } from "./shared/isWithinFlag.js";
3
- import { default as d } from "./shared/generateId.js";
4
- import { default as x } from "./outlet/getListOutletOpeningHoursTable.js";
5
- import { default as h } from "./versioning/isVersionALessThanB.js";
6
- import { default as O } from "./versioning/cleanVersionString.js";
7
- import { default as A } from "./api/getUrlAndParams.js";
8
- import { default as S } from "./api/getEndpointWithVersion.js";
9
- import { default as V } from "./string/slugify.js";
10
- import { default as b } from "./color/lighten.js";
11
- import { default as v } from "./color/brighten.js";
12
- import { default as c } from "./color/darken.js";
13
- import { getFullName as D } from "./user/getFullName.js";
14
- import { getFullAddressString as H } from "./user/getFullAddressString.js";
15
- import "moment";
16
- import "compare-versions";
17
- import "tinycolor2";
18
- export {
19
- f as DayOfWeek,
20
- l as IntervalState,
21
- s as IntervalType,
22
- m as OrderFormat,
23
- v as brighten,
24
- O as cleanVersionString,
25
- c as darken,
26
- d as generateId,
27
- S as getEndpointWithVersion,
28
- H as getFullAddressString,
29
- D as getFullName,
30
- x as getListOutletOpeningHoursTable,
31
- A as getUrlAndParams,
32
- h as isVersionALessThanB,
33
- i as isWithinFlag,
34
- b as lighten,
35
- V as slugify
36
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.js"),r=require("./shared/isWithinFlag.js"),t=require("./shared/generateId.js"),n=require("./outlet/getListOutletOpeningHoursTable.js"),i=require("./versioning/isVersionALessThanB.js"),s=require("./versioning/cleanVersionString.js"),o=require("./api/getUrlAndParams.js"),g=require("./api/getEndpointWithVersion.js"),l=require("./string/slugify.js"),u=require("./color/lighten.js"),a=require("./color/brighten.js"),c=require("./color/darken.js"),d=require("./user/getFullName.js"),q=require("./user/getFullAddressString.js"),_=require("./logger/Logger.js"),h=require("./logger/types.js");require("moment");require("compare-versions");require("tinycolor2");exports.DayOfWeek=e.DayOfWeek;exports.IntervalState=e.IntervalState;exports.IntervalType=e.IntervalType;exports.OrderFormat=e.OrderFormat;exports.isWithinFlag=r;exports.generateId=t;exports.getListOutletOpeningHoursTable=n;exports.isVersionALessThanB=i;exports.cleanVersionString=s;exports.getUrlAndParams=o;exports.getEndpointWithVersion=g;exports.slugify=l;exports.lighten=u;exports.brighten=a;exports.darken=c;exports.getFullName=d.getFullName;exports.getFullAddressString=q.getFullAddressString;exports.Logger=_;exports.LogLevel=h.LogLevel;
package/index.mjs ADDED
@@ -0,0 +1,40 @@
1
+ import { DayOfWeek as f, IntervalState as l, IntervalType as s, OrderFormat as m } from "./shared/enums.mjs";
2
+ import { default as d } from "./shared/isWithinFlag.mjs";
3
+ import { default as n } from "./shared/generateId.mjs";
4
+ import { default as g } from "./outlet/getListOutletOpeningHoursTable.mjs";
5
+ import { default as h } from "./versioning/isVersionALessThanB.mjs";
6
+ import { default as F } from "./versioning/cleanVersionString.mjs";
7
+ import { default as v } from "./api/getUrlAndParams.mjs";
8
+ import { default as A } from "./api/getEndpointWithVersion.mjs";
9
+ import { default as S } from "./string/slugify.mjs";
10
+ import { default as V } from "./color/lighten.mjs";
11
+ import { default as b } from "./color/brighten.mjs";
12
+ import { default as c } from "./color/darken.mjs";
13
+ import { getFullName as D } from "./user/getFullName.mjs";
14
+ import { getFullAddressString as H } from "./user/getFullAddressString.mjs";
15
+ import { default as P } from "./logger/Logger.mjs";
16
+ import { LogLevel as j } from "./logger/types.mjs";
17
+ import "moment";
18
+ import "compare-versions";
19
+ import "tinycolor2";
20
+ export {
21
+ f as DayOfWeek,
22
+ l as IntervalState,
23
+ s as IntervalType,
24
+ j as LogLevel,
25
+ P as Logger,
26
+ m as OrderFormat,
27
+ b as brighten,
28
+ F as cleanVersionString,
29
+ c as darken,
30
+ n as generateId,
31
+ A as getEndpointWithVersion,
32
+ H as getFullAddressString,
33
+ D as getFullName,
34
+ g as getListOutletOpeningHoursTable,
35
+ v as getUrlAndParams,
36
+ h as isVersionALessThanB,
37
+ d as isWithinFlag,
38
+ V as lighten,
39
+ S as slugify
40
+ };
@@ -0,0 +1,12 @@
1
+ import { LogProperties, LogStrategy } from './types';
2
+ export default class Logger {
3
+ private logStrategy;
4
+ constructor(logStrategy: LogStrategy);
5
+ setLogStrategy(logStrategy: LogStrategy): void;
6
+ verbose(message: string, properties?: LogProperties): void;
7
+ debug(message: string, properties?: LogProperties): void;
8
+ info(message: string, properties?: LogProperties): void;
9
+ warn(message: string, properties?: LogProperties): void;
10
+ error(message: string, properties?: LogProperties): void;
11
+ fatal(message: string, properties?: LogProperties): void;
12
+ }
@@ -0,0 +1 @@
1
+ "use strict";const g=require("./types.js");class o{constructor(e){this.logStrategy=e}setLogStrategy(e){this.logStrategy=e}verbose(e,t){this.logStrategy.execute(g.LogLevel.Verbose,e,t)}debug(e,t){this.logStrategy.execute(g.LogLevel.Debug,e,t)}info(e,t){this.logStrategy.execute(g.LogLevel.Information,e,t)}warn(e,t){this.logStrategy.execute(g.LogLevel.Warning,e,t)}error(e,t){this.logStrategy.execute(g.LogLevel.Error,e,t)}fatal(e,t){this.logStrategy.execute(g.LogLevel.Fatal,e,t)}}module.exports=o;
@@ -0,0 +1,30 @@
1
+ import { LogLevel as r } from "./types.mjs";
2
+ class a {
3
+ constructor(t) {
4
+ this.logStrategy = t;
5
+ }
6
+ setLogStrategy(t) {
7
+ this.logStrategy = t;
8
+ }
9
+ verbose(t, e) {
10
+ this.logStrategy.execute(r.Verbose, t, e);
11
+ }
12
+ debug(t, e) {
13
+ this.logStrategy.execute(r.Debug, t, e);
14
+ }
15
+ info(t, e) {
16
+ this.logStrategy.execute(r.Information, t, e);
17
+ }
18
+ warn(t, e) {
19
+ this.logStrategy.execute(r.Warning, t, e);
20
+ }
21
+ error(t, e) {
22
+ this.logStrategy.execute(r.Error, t, e);
23
+ }
24
+ fatal(t, e) {
25
+ this.logStrategy.execute(r.Fatal, t, e);
26
+ }
27
+ }
28
+ export {
29
+ a as default
30
+ };
@@ -0,0 +1,4 @@
1
+ import Logger from './Logger';
2
+ import type { LogProperties, LogStrategy } from './types';
3
+ import { LogLevel } from './types';
4
+ export { Logger, LogLevel, LogProperties, LogStrategy };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Logger.js"),g=require("./types.js");exports.Logger=e;exports.LogLevel=g.LogLevel;
@@ -0,0 +1,6 @@
1
+ import { default as r } from "./Logger.mjs";
2
+ import { LogLevel as g } from "./types.mjs";
3
+ export {
4
+ g as LogLevel,
5
+ r as Logger
6
+ };
@@ -0,0 +1,12 @@
1
+ export declare enum LogLevel {
2
+ Verbose = 0,
3
+ Debug = 1,
4
+ Information = 2,
5
+ Warning = 3,
6
+ Error = 4,
7
+ Fatal = 5
8
+ }
9
+ export declare type LogProperties = Record<string, unknown>;
10
+ export interface LogStrategy {
11
+ execute: <T extends LogProperties>(logLevel: LogLevel, message: string, properties?: T) => void;
12
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var a=(r=>(r[r.Verbose=0]="Verbose",r[r.Debug=1]="Debug",r[r.Information=2]="Information",r[r.Warning=3]="Warning",r[r.Error=4]="Error",r[r.Fatal=5]="Fatal",r))(a||{});exports.LogLevel=a;
@@ -0,0 +1,4 @@
1
+ var a = /* @__PURE__ */ ((r) => (r[r.Verbose = 0] = "Verbose", r[r.Debug = 1] = "Debug", r[r.Information = 2] = "Information", r[r.Warning = 3] = "Warning", r[r.Error = 4] = "Error", r[r.Fatal = 5] = "Fatal", r))(a || {});
2
+ export {
3
+ a as LogLevel
4
+ };
@@ -1,172 +1 @@
1
- import F from "moment";
2
- import { OrderFormat as p, DayOfWeek as m, IntervalType as y, IntervalState as O } from "../shared/enums.js";
3
- import h from "../shared/isWithinFlag.js";
4
- import W from "../shared/generateId.js";
5
- const k = [
6
- { id: p.EatIn, name: "eatIn" },
7
- { id: p.Takeaway, name: "takeaway" },
8
- { id: p.TableOrder, name: "tableOrder" },
9
- { id: p.Delivery, name: "delivery" }
10
- ];
11
- function M(e) {
12
- const r = F.utc(e).subtract(1, "day").startOf("day"), t = [];
13
- for (let a = 0, o = r; a < 7; a += 1)
14
- o = o.clone().add(1, "day").startOf("day"), t.push(o.clone());
15
- return t;
16
- }
17
- function v(e) {
18
- return [...e].sort((r, t) => r.isoWeekday() - t.isoWeekday());
19
- }
20
- function S(e) {
21
- return e.split(":").map(Number);
22
- }
23
- function H(e, r) {
24
- const [t, a] = S(e.start), [o, s] = S(
25
- e.duration
26
- );
27
- if (e.type === y.Interval) {
28
- const n = r.clone().add(t, "hour").add(a, "minute"), i = n.clone().add(o, "hour").add(s, "minute");
29
- return {
30
- id: e.id,
31
- start: n.toISOString(),
32
- end: i.toISOString()
33
- };
34
- }
35
- if (e.type === y.Exception) {
36
- const n = F(e.fromDate), i = F(e.toDate);
37
- if (r.isBetween(n, i, void 0, "[]")) {
38
- const I = r.clone().add(t, "hour").add(a, "minute"), u = I.clone().add(o, "hour").add(s, "minute");
39
- return {
40
- id: e.id,
41
- start: I.toISOString(),
42
- end: u.toISOString(),
43
- reason: e.reason
44
- };
45
- }
46
- return null;
47
- }
48
- throw new Error("Invalid interval type");
49
- }
50
- function E(e, r, t) {
51
- const a = {
52
- [m.Monday]: 1,
53
- [m.Tuesday]: 2,
54
- [m.Wednesday]: 3,
55
- [m.Thursday]: 4,
56
- [m.Friday]: 5,
57
- [m.Saturday]: 6,
58
- [m.Sunday]: 7
59
- };
60
- for (let o = 0; o < r.length; o += 1) {
61
- const s = r[o], n = s.isoWeekday(), i = e.dayOfWeek, u = (a[i] ?? null) === n || i === m.Everyday;
62
- if (t[n] || (t[n] = {
63
- isoWeekday: n,
64
- key: "",
65
- open: [],
66
- adjusted: [],
67
- closed: []
68
- }), u) {
69
- const d = H(e, s);
70
- d && (t[n].key += d.id, e.type === y.Interval && e.state === O.Open ? t[n].open.push(d) : e.type === y.Interval && e.state === O.Closed ? t[n].closed.push(d) : e.type === y.Exception && e.state === O.Open ? t[n].adjusted.push(d) : e.type === y.Exception && e.state === O.Closed && t[n].closed.push(d));
71
- }
72
- }
73
- }
74
- function T(e) {
75
- switch (e.type) {
76
- case y.Exception:
77
- return W("interval-exception");
78
- case y.Interval:
79
- return W("interval-normal");
80
- default:
81
- return W("interval-unknown");
82
- }
83
- }
84
- function x(e) {
85
- const r = e.reduce(
86
- (t, a) => (k.forEach((o) => {
87
- h(o.id, a.orderFormats) && (t[o.id] || (t[o.id] = {
88
- orderFormat: o,
89
- intervals: []
90
- }), t[o.id].intervals.push(
91
- ...a.intervals.sort(
92
- (s, n) => s.dayOfWeek - n.dayOfWeek
93
- )
94
- ));
95
- }), t),
96
- {}
97
- );
98
- return Object.values(r);
99
- }
100
- function j(e) {
101
- return e.reduce(
102
- (r, t, a) => {
103
- const o = r.findIndex(
104
- (s) => s !== t && !s.orderFormats.some(
105
- (n) => t.orderFormats.some(
106
- (i) => i.id === n.id
107
- )
108
- ) && s.openingHours.every(
109
- (n) => t.openingHours.some((i) => i.key === n.key)
110
- ) && t.openingHours.every(
111
- (n) => s.openingHours.some((i) => i.key === n.key)
112
- )
113
- );
114
- if (o >= 0) {
115
- const s = r[o];
116
- return r.splice(o, 1, {
117
- ...s,
118
- orderFormats: [...t.orderFormats, ...s.orderFormats]
119
- }), r.splice(a, 1), r;
120
- }
121
- return r;
122
- },
123
- [...e]
124
- );
125
- }
126
- function w(e) {
127
- return e.map((r) => ({
128
- ...r,
129
- intervals: r.intervals.map((t) => ({
130
- ...t,
131
- id: T(t)
132
- }))
133
- }));
134
- }
135
- function A(e, r) {
136
- const t = x(
137
- w(e.serviceDateTimes)
138
- ), a = M(r), o = v(a), s = t.reduce(
139
- (u, d) => (u[d.orderFormat.id] || (u[d.orderFormat.id] = {}), d.intervals.reduce((g, f) => (E(f, o, g), g), u[d.orderFormat.id]), u),
140
- {}
141
- ), n = {
142
- [p.EatIn]: k[0],
143
- [p.Takeaway]: k[1],
144
- [p.TableOrder]: k[2],
145
- [p.Delivery]: k[3]
146
- }, i = Object.entries(
147
- s
148
- ).map(([u, d]) => ({
149
- orderFormats: [n[Number(u)]],
150
- openingHours: Object.entries(d).map(
151
- ([g, f]) => ({
152
- isoWeekday: Number(g),
153
- key: f.key,
154
- open: f.open.sort(
155
- (c, l) => c.start.localeCompare(l.start)
156
- ),
157
- adjusted: f.adjusted.sort(
158
- (c, l) => c.start.localeCompare(l.start)
159
- ),
160
- closed: f.closed.sort(
161
- (c, l) => c.start.localeCompare(l.start)
162
- )
163
- })
164
- )
165
- }));
166
- return j(i).sort(
167
- (u, d) => u.orderFormats[0].id - d.orderFormats[0].id
168
- );
169
- }
170
- export {
171
- A as default
172
- };
1
+ "use strict";const k=require("moment"),r=require("../shared/enums.js"),g=require("../shared/isWithinFlag.js"),I=require("../shared/generateId.js"),l=[{id:r.OrderFormat.EatIn,name:"eatIn"},{id:r.OrderFormat.Takeaway,name:"takeaway"},{id:r.OrderFormat.TableOrder,name:"tableOrder"},{id:r.OrderFormat.Delivery,name:"delivery"}];function F(e){const n=k.utc(e).subtract(1,"day").startOf("day"),t=[];for(let i=0,s=n;i<7;i+=1)s=s.clone().add(1,"day").startOf("day"),t.push(s.clone());return t}function v(e){return[...e].sort((n,t)=>n.isoWeekday()-t.isoWeekday())}function W(e){return e.split(":").map(Number)}function S(e,n){const[t,i]=W(e.start),[s,a]=W(e.duration);if(e.type===r.IntervalType.Interval){const o=n.clone().add(t,"hour").add(i,"minute"),u=o.clone().add(s,"hour").add(a,"minute");return{id:e.id,start:o.toISOString(),end:u.toISOString()}}if(e.type===r.IntervalType.Exception){const o=k(e.fromDate),u=k(e.toDate);if(n.isBetween(o,u,void 0,"[]")){const c=n.clone().add(t,"hour").add(i,"minute"),y=c.clone().add(s,"hour").add(a,"minute");return{id:e.id,start:c.toISOString(),end:y.toISOString(),reason:e.reason}}return null}throw new Error("Invalid interval type")}function h(e,n,t){const i={[r.DayOfWeek.Monday]:1,[r.DayOfWeek.Tuesday]:2,[r.DayOfWeek.Wednesday]:3,[r.DayOfWeek.Thursday]:4,[r.DayOfWeek.Friday]:5,[r.DayOfWeek.Saturday]:6,[r.DayOfWeek.Sunday]:7};for(let s=0;s<n.length;s+=1){const a=n[s],o=a.isoWeekday(),u=e.dayOfWeek,y=(i[u]??null)===o||u===r.DayOfWeek.Everyday;if(t[o]||(t[o]={isoWeekday:o,key:"",open:[],adjusted:[],closed:[]}),y){const d=S(e,a);d&&(t[o].key+=d.id,e.type===r.IntervalType.Interval&&e.state===r.IntervalState.Open?t[o].open.push(d):e.type===r.IntervalType.Interval&&e.state===r.IntervalState.Closed?t[o].closed.push(d):e.type===r.IntervalType.Exception&&e.state===r.IntervalState.Open?t[o].adjusted.push(d):e.type===r.IntervalType.Exception&&e.state===r.IntervalState.Closed&&t[o].closed.push(d))}}}function T(e){switch(e.type){case r.IntervalType.Exception:return I("interval-exception");case r.IntervalType.Interval:return I("interval-normal");default:return I("interval-unknown")}}function D(e){const n=e.reduce((t,i)=>(l.forEach(s=>{g(s.id,i.orderFormats)&&(t[s.id]||(t[s.id]={orderFormat:s,intervals:[]}),t[s.id].intervals.push(...i.intervals.sort((a,o)=>a.dayOfWeek-o.dayOfWeek)))}),t),{});return Object.values(n)}function M(e){return e.reduce((n,t,i)=>{const s=n.findIndex(a=>a!==t&&!a.orderFormats.some(o=>t.orderFormats.some(u=>u.id===o.id))&&a.openingHours.every(o=>t.openingHours.some(u=>u.key===o.key))&&t.openingHours.every(o=>a.openingHours.some(u=>u.key===o.key)));if(s>=0){const a=n[s];return n.splice(s,1,{...a,orderFormats:[...t.orderFormats,...a.orderFormats]}),n.splice(i,1),n}return n},[...e])}function H(e){return e.map(n=>({...n,intervals:n.intervals.map(t=>({...t,id:T(t)}))}))}function E(e,n){const t=D(H(e.serviceDateTimes)),i=F(n),s=v(i),a=t.reduce((y,d)=>(y[d.orderFormat.id]||(y[d.orderFormat.id]={}),d.intervals.reduce((O,p)=>(h(p,s,O),O),y[d.orderFormat.id]),y),{}),o={[r.OrderFormat.EatIn]:l[0],[r.OrderFormat.Takeaway]:l[1],[r.OrderFormat.TableOrder]:l[2],[r.OrderFormat.Delivery]:l[3]},u=Object.entries(a).map(([y,d])=>({orderFormats:[o[Number(y)]],openingHours:Object.entries(d).map(([O,p])=>({isoWeekday:Number(O),key:p.key,open:p.open.sort((m,f)=>m.start.localeCompare(f.start)),adjusted:p.adjusted.sort((m,f)=>m.start.localeCompare(f.start)),closed:p.closed.sort((m,f)=>m.start.localeCompare(f.start))}))}));return M(u).sort((y,d)=>y.orderFormats[0].id-d.orderFormats[0].id)}module.exports=E;
@@ -0,0 +1,172 @@
1
+ import F from "moment";
2
+ import { OrderFormat as p, DayOfWeek as m, IntervalType as y, IntervalState as O } from "../shared/enums.mjs";
3
+ import h from "../shared/isWithinFlag.mjs";
4
+ import W from "../shared/generateId.mjs";
5
+ const k = [
6
+ { id: p.EatIn, name: "eatIn" },
7
+ { id: p.Takeaway, name: "takeaway" },
8
+ { id: p.TableOrder, name: "tableOrder" },
9
+ { id: p.Delivery, name: "delivery" }
10
+ ];
11
+ function M(e) {
12
+ const r = F.utc(e).subtract(1, "day").startOf("day"), t = [];
13
+ for (let a = 0, o = r; a < 7; a += 1)
14
+ o = o.clone().add(1, "day").startOf("day"), t.push(o.clone());
15
+ return t;
16
+ }
17
+ function v(e) {
18
+ return [...e].sort((r, t) => r.isoWeekday() - t.isoWeekday());
19
+ }
20
+ function S(e) {
21
+ return e.split(":").map(Number);
22
+ }
23
+ function H(e, r) {
24
+ const [t, a] = S(e.start), [o, s] = S(
25
+ e.duration
26
+ );
27
+ if (e.type === y.Interval) {
28
+ const n = r.clone().add(t, "hour").add(a, "minute"), i = n.clone().add(o, "hour").add(s, "minute");
29
+ return {
30
+ id: e.id,
31
+ start: n.toISOString(),
32
+ end: i.toISOString()
33
+ };
34
+ }
35
+ if (e.type === y.Exception) {
36
+ const n = F(e.fromDate), i = F(e.toDate);
37
+ if (r.isBetween(n, i, void 0, "[]")) {
38
+ const I = r.clone().add(t, "hour").add(a, "minute"), u = I.clone().add(o, "hour").add(s, "minute");
39
+ return {
40
+ id: e.id,
41
+ start: I.toISOString(),
42
+ end: u.toISOString(),
43
+ reason: e.reason
44
+ };
45
+ }
46
+ return null;
47
+ }
48
+ throw new Error("Invalid interval type");
49
+ }
50
+ function E(e, r, t) {
51
+ const a = {
52
+ [m.Monday]: 1,
53
+ [m.Tuesday]: 2,
54
+ [m.Wednesday]: 3,
55
+ [m.Thursday]: 4,
56
+ [m.Friday]: 5,
57
+ [m.Saturday]: 6,
58
+ [m.Sunday]: 7
59
+ };
60
+ for (let o = 0; o < r.length; o += 1) {
61
+ const s = r[o], n = s.isoWeekday(), i = e.dayOfWeek, u = (a[i] ?? null) === n || i === m.Everyday;
62
+ if (t[n] || (t[n] = {
63
+ isoWeekday: n,
64
+ key: "",
65
+ open: [],
66
+ adjusted: [],
67
+ closed: []
68
+ }), u) {
69
+ const d = H(e, s);
70
+ d && (t[n].key += d.id, e.type === y.Interval && e.state === O.Open ? t[n].open.push(d) : e.type === y.Interval && e.state === O.Closed ? t[n].closed.push(d) : e.type === y.Exception && e.state === O.Open ? t[n].adjusted.push(d) : e.type === y.Exception && e.state === O.Closed && t[n].closed.push(d));
71
+ }
72
+ }
73
+ }
74
+ function T(e) {
75
+ switch (e.type) {
76
+ case y.Exception:
77
+ return W("interval-exception");
78
+ case y.Interval:
79
+ return W("interval-normal");
80
+ default:
81
+ return W("interval-unknown");
82
+ }
83
+ }
84
+ function x(e) {
85
+ const r = e.reduce(
86
+ (t, a) => (k.forEach((o) => {
87
+ h(o.id, a.orderFormats) && (t[o.id] || (t[o.id] = {
88
+ orderFormat: o,
89
+ intervals: []
90
+ }), t[o.id].intervals.push(
91
+ ...a.intervals.sort(
92
+ (s, n) => s.dayOfWeek - n.dayOfWeek
93
+ )
94
+ ));
95
+ }), t),
96
+ {}
97
+ );
98
+ return Object.values(r);
99
+ }
100
+ function j(e) {
101
+ return e.reduce(
102
+ (r, t, a) => {
103
+ const o = r.findIndex(
104
+ (s) => s !== t && !s.orderFormats.some(
105
+ (n) => t.orderFormats.some(
106
+ (i) => i.id === n.id
107
+ )
108
+ ) && s.openingHours.every(
109
+ (n) => t.openingHours.some((i) => i.key === n.key)
110
+ ) && t.openingHours.every(
111
+ (n) => s.openingHours.some((i) => i.key === n.key)
112
+ )
113
+ );
114
+ if (o >= 0) {
115
+ const s = r[o];
116
+ return r.splice(o, 1, {
117
+ ...s,
118
+ orderFormats: [...t.orderFormats, ...s.orderFormats]
119
+ }), r.splice(a, 1), r;
120
+ }
121
+ return r;
122
+ },
123
+ [...e]
124
+ );
125
+ }
126
+ function w(e) {
127
+ return e.map((r) => ({
128
+ ...r,
129
+ intervals: r.intervals.map((t) => ({
130
+ ...t,
131
+ id: T(t)
132
+ }))
133
+ }));
134
+ }
135
+ function A(e, r) {
136
+ const t = x(
137
+ w(e.serviceDateTimes)
138
+ ), a = M(r), o = v(a), s = t.reduce(
139
+ (u, d) => (u[d.orderFormat.id] || (u[d.orderFormat.id] = {}), d.intervals.reduce((g, f) => (E(f, o, g), g), u[d.orderFormat.id]), u),
140
+ {}
141
+ ), n = {
142
+ [p.EatIn]: k[0],
143
+ [p.Takeaway]: k[1],
144
+ [p.TableOrder]: k[2],
145
+ [p.Delivery]: k[3]
146
+ }, i = Object.entries(
147
+ s
148
+ ).map(([u, d]) => ({
149
+ orderFormats: [n[Number(u)]],
150
+ openingHours: Object.entries(d).map(
151
+ ([g, f]) => ({
152
+ isoWeekday: Number(g),
153
+ key: f.key,
154
+ open: f.open.sort(
155
+ (c, l) => c.start.localeCompare(l.start)
156
+ ),
157
+ adjusted: f.adjusted.sort(
158
+ (c, l) => c.start.localeCompare(l.start)
159
+ ),
160
+ closed: f.closed.sort(
161
+ (c, l) => c.start.localeCompare(l.start)
162
+ )
163
+ })
164
+ )
165
+ }));
166
+ return j(i).sort(
167
+ (u, d) => u.orderFormats[0].id - d.orderFormats[0].id
168
+ );
169
+ }
170
+ export {
171
+ A as default
172
+ };
package/outlet/index.js CHANGED
@@ -1,8 +1 @@
1
- import { default as m } from "./getListOutletOpeningHoursTable.js";
2
- import "moment";
3
- import "../shared/enums.js";
4
- import "../shared/isWithinFlag.js";
5
- import "../shared/generateId.js";
6
- export {
7
- m as getListOutletOpeningHoursTable
8
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getListOutletOpeningHoursTable.js");require("moment");require("../shared/enums.js");require("../shared/isWithinFlag.js");require("../shared/generateId.js");exports.getListOutletOpeningHoursTable=e;
@@ -0,0 +1,8 @@
1
+ import { default as m } from "./getListOutletOpeningHoursTable.mjs";
2
+ import "moment";
3
+ import "../shared/enums.mjs";
4
+ import "../shared/isWithinFlag.mjs";
5
+ import "../shared/generateId.mjs";
6
+ export {
7
+ m as getListOutletOpeningHoursTable
8
+ };
package/outlet/types.js CHANGED
@@ -1 +1 @@
1
-
1
+ "use strict";
@@ -0,0 +1 @@
1
+
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.9.1",
3
+ "version": "1.10.1",
4
4
  "private": false,
5
- "type": "module",
6
5
  "main": "index.cjs",
7
6
  "module": "index.js",
8
7
  "types": "index.d.ts",
@@ -39,6 +38,18 @@
39
38
  "import": "./index.js",
40
39
  "require": "./index.cjs"
41
40
  },
41
+ "./logger/Logger": {
42
+ "import": "./logger/Logger.js",
43
+ "require": "./logger/Logger.cjs"
44
+ },
45
+ "./logger": {
46
+ "import": "./logger/index.js",
47
+ "require": "./logger/index.cjs"
48
+ },
49
+ "./logger/types": {
50
+ "import": "./logger/types.js",
51
+ "require": "./logger/types.cjs"
52
+ },
42
53
  "./outlet/getListOutletOpeningHoursTable": {
43
54
  "import": "./outlet/getListOutletOpeningHoursTable.js",
44
55
  "require": "./outlet/getListOutletOpeningHoursTable.cjs"
package/shared/enums.js CHANGED
@@ -1,7 +1 @@
1
- var n = /* @__PURE__ */ ((d) => (d[d.EatIn = 1] = "EatIn", d[d.Takeaway = 2] = "Takeaway", d[d.TableOrder = 4] = "TableOrder", d[d.Delivery = 8] = "Delivery", d))(n || {}), u = /* @__PURE__ */ ((d) => (d[d.Monday = 1] = "Monday", d[d.Tuesday = 2] = "Tuesday", d[d.Wednesday = 4] = "Wednesday", d[d.Thursday = 8] = "Thursday", d[d.Friday = 16] = "Friday", d[d.Saturday = 32] = "Saturday", d[d.Sunday = 64] = "Sunday", d[d.Everyday = 127] = "Everyday", d))(u || {}), s = /* @__PURE__ */ ((d) => (d[d.Open = 0] = "Open", d[d.Closed = 1] = "Closed", d))(s || {}), i = /* @__PURE__ */ ((d) => (d[d.Interval = 0] = "Interval", d[d.Exception = 1] = "Exception", d))(i || {});
2
- export {
3
- u as DayOfWeek,
4
- s as IntervalState,
5
- i as IntervalType,
6
- n as OrderFormat
7
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var n=(d=>(d[d.EatIn=1]="EatIn",d[d.Takeaway=2]="Takeaway",d[d.TableOrder=4]="TableOrder",d[d.Delivery=8]="Delivery",d))(n||{}),u=(d=>(d[d.Monday=1]="Monday",d[d.Tuesday=2]="Tuesday",d[d.Wednesday=4]="Wednesday",d[d.Thursday=8]="Thursday",d[d.Friday=16]="Friday",d[d.Saturday=32]="Saturday",d[d.Sunday=64]="Sunday",d[d.Everyday=127]="Everyday",d))(u||{}),a=(d=>(d[d.Open=0]="Open",d[d.Closed=1]="Closed",d))(a||{}),r=(d=>(d[d.Interval=0]="Interval",d[d.Exception=1]="Exception",d))(r||{});exports.DayOfWeek=u;exports.IntervalState=a;exports.IntervalType=r;exports.OrderFormat=n;
@@ -0,0 +1,7 @@
1
+ var n = /* @__PURE__ */ ((d) => (d[d.EatIn = 1] = "EatIn", d[d.Takeaway = 2] = "Takeaway", d[d.TableOrder = 4] = "TableOrder", d[d.Delivery = 8] = "Delivery", d))(n || {}), u = /* @__PURE__ */ ((d) => (d[d.Monday = 1] = "Monday", d[d.Tuesday = 2] = "Tuesday", d[d.Wednesday = 4] = "Wednesday", d[d.Thursday = 8] = "Thursday", d[d.Friday = 16] = "Friday", d[d.Saturday = 32] = "Saturday", d[d.Sunday = 64] = "Sunday", d[d.Everyday = 127] = "Everyday", d))(u || {}), s = /* @__PURE__ */ ((d) => (d[d.Open = 0] = "Open", d[d.Closed = 1] = "Closed", d))(s || {}), i = /* @__PURE__ */ ((d) => (d[d.Interval = 0] = "Interval", d[d.Exception = 1] = "Exception", d))(i || {});
2
+ export {
3
+ u as DayOfWeek,
4
+ s as IntervalState,
5
+ i as IntervalType,
6
+ n as OrderFormat
7
+ };
@@ -1,7 +1 @@
1
- function r(t) {
2
- const n = Math.random().toString();
3
- return `${t ? `${t}-` : ""}${n.substring(2)}`;
4
- }
5
- export {
6
- r as default
7
- };
1
+ "use strict";function n(t){const r=Math.random().toString();return`${t?`${t}-`:""}${r.substring(2)}`}module.exports=n;
@@ -0,0 +1,7 @@
1
+ function r(t) {
2
+ const n = Math.random().toString();
3
+ return `${t ? `${t}-` : ""}${n.substring(2)}`;
4
+ }
5
+ export {
6
+ r as default
7
+ };
package/shared/index.js CHANGED
@@ -1,11 +1 @@
1
- import { DayOfWeek as t, IntervalState as a, IntervalType as o, OrderFormat as f } from "./enums.js";
2
- import { default as d } from "./isWithinFlag.js";
3
- import { default as n } from "./generateId.js";
4
- export {
5
- t as DayOfWeek,
6
- a as IntervalState,
7
- o as IntervalType,
8
- f as OrderFormat,
9
- n as generateId,
10
- d as isWithinFlag
11
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./enums.js"),r=require("./isWithinFlag.js"),t=require("./generateId.js");exports.DayOfWeek=e.DayOfWeek;exports.IntervalState=e.IntervalState;exports.IntervalType=e.IntervalType;exports.OrderFormat=e.OrderFormat;exports.isWithinFlag=r;exports.generateId=t;
@@ -0,0 +1,11 @@
1
+ import { DayOfWeek as t, IntervalState as a, IntervalType as o, OrderFormat as f } from "./enums.mjs";
2
+ import { default as d } from "./isWithinFlag.mjs";
3
+ import { default as n } from "./generateId.mjs";
4
+ export {
5
+ t as DayOfWeek,
6
+ a as IntervalState,
7
+ o as IntervalType,
8
+ f as OrderFormat,
9
+ n as generateId,
10
+ d as isWithinFlag
11
+ };
@@ -1,6 +1 @@
1
- function a(t, i) {
2
- return (i & t) === t;
3
- }
4
- export {
5
- a as default
6
- };
1
+ "use strict";function r(t,i){return(i&t)===t}module.exports=r;
@@ -0,0 +1,6 @@
1
+ function a(t, i) {
2
+ return (i & t) === t;
3
+ }
4
+ export {
5
+ a as default
6
+ };
package/string/index.js CHANGED
@@ -1,4 +1 @@
1
- import { default as e } from "./slugify.js";
2
- export {
3
- e as slugify
4
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./slugify.js");exports.slugify=e;
@@ -0,0 +1,4 @@
1
+ import { default as e } from "./slugify.mjs";
2
+ export {
3
+ e as slugify
4
+ };
package/string/slugify.js CHANGED
@@ -1,6 +1 @@
1
- function r(e, a) {
2
- return e.toLocaleLowerCase(a).replace(/[åäæ]/g, "a").replace(/[öø]/g, "o").replace(/[é]/g, "e").replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
3
- }
4
- export {
5
- r as default
6
- };
1
+ "use strict";function a(e,r){return e.toLocaleLowerCase(r).replace(/[åäæ]/g,"a").replace(/[öø]/g,"o").replace(/[é]/g,"e").replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}module.exports=a;
@@ -0,0 +1,6 @@
1
+ function r(e, a) {
2
+ return e.toLocaleLowerCase(a).replace(/[åäæ]/g, "a").replace(/[öø]/g, "o").replace(/[é]/g, "e").replace(/\s+/g, "-").replace(/[^\w-]+/g, "").replace(/--+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
3
+ }
4
+ export {
5
+ r as default
6
+ };
@@ -1,6 +1 @@
1
- function e(t) {
2
- return t && [t.street, t.city, t.state, t.zipCode].filter(Boolean).join(", ") || "";
3
- }
4
- export {
5
- e as getFullAddressString
6
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(t){return t&&[t.street,t.city,t.state,t.zipCode].filter(Boolean).join(", ")||""}exports.getFullAddressString=e;
@@ -0,0 +1,6 @@
1
+ function e(t) {
2
+ return t && [t.street, t.city, t.state, t.zipCode].filter(Boolean).join(", ") || "";
3
+ }
4
+ export {
5
+ e as getFullAddressString
6
+ };
@@ -1,13 +1 @@
1
- function n(t, r = "N/A") {
2
- try {
3
- if (Array.isArray(t))
4
- return t.filter(Boolean).join(" ") || r;
5
- const e = t;
6
- return e && [e.firstName, e.lastName].filter(Boolean).join(" ") || r;
7
- } catch {
8
- return r;
9
- }
10
- }
11
- export {
12
- n as getFullName
13
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t,e="N/A"){try{if(Array.isArray(t))return t.filter(Boolean).join(" ")||e;const r=t;return r&&[r.firstName,r.lastName].filter(Boolean).join(" ")||e}catch{return e}}exports.getFullName=n;
@@ -0,0 +1,13 @@
1
+ function n(t, r = "N/A") {
2
+ try {
3
+ if (Array.isArray(t))
4
+ return t.filter(Boolean).join(" ") || r;
5
+ const e = t;
6
+ return e && [e.firstName, e.lastName].filter(Boolean).join(" ") || r;
7
+ } catch {
8
+ return r;
9
+ }
10
+ }
11
+ export {
12
+ n as getFullName
13
+ };
package/user/index.js CHANGED
@@ -1,6 +1 @@
1
- import { getFullName as t } from "./getFullName.js";
2
- import { getFullAddressString as o } from "./getFullAddressString.js";
3
- export {
4
- o as getFullAddressString,
5
- t as getFullName
6
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getFullName.js"),t=require("./getFullAddressString.js");exports.getFullName=e.getFullName;exports.getFullAddressString=t.getFullAddressString;
package/user/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import { getFullName as t } from "./getFullName.mjs";
2
+ import { getFullAddressString as o } from "./getFullAddressString.mjs";
3
+ export {
4
+ o as getFullAddressString,
5
+ t as getFullName
6
+ };
@@ -1,7 +1 @@
1
- function s(r) {
2
- const e = r.toLowerCase().split("-")[0];
3
- return e.charAt(0) === "v" ? e.substring(1) : e;
4
- }
5
- export {
6
- s as default
7
- };
1
+ "use strict";function s(r){const e=r.toLowerCase().split("-")[0];return e.charAt(0)==="v"?e.substring(1):e}module.exports=s;
@@ -0,0 +1,7 @@
1
+ function s(r) {
2
+ const e = r.toLowerCase().split("-")[0];
3
+ return e.charAt(0) === "v" ? e.substring(1) : e;
4
+ }
5
+ export {
6
+ s as default
7
+ };
@@ -1,7 +1 @@
1
- import { default as s } from "./isVersionALessThanB.js";
2
- import { default as t } from "./cleanVersionString.js";
3
- import "compare-versions";
4
- export {
5
- t as cleanVersionString,
6
- s as isVersionALessThanB
7
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./isVersionALessThanB.js"),i=require("./cleanVersionString.js");require("compare-versions");exports.isVersionALessThanB=e;exports.cleanVersionString=i;
@@ -0,0 +1,7 @@
1
+ import { default as s } from "./isVersionALessThanB.mjs";
2
+ import { default as t } from "./cleanVersionString.mjs";
3
+ import "compare-versions";
4
+ export {
5
+ t as cleanVersionString,
6
+ s as isVersionALessThanB
7
+ };
@@ -1,9 +1 @@
1
- import i from "compare-versions";
2
- import e from "./cleanVersionString.js";
3
- function c(n, o) {
4
- const r = e(n), s = e(o);
5
- return i.compare(r, s, "<");
6
- }
7
- export {
8
- c as default
9
- };
1
+ "use strict";const i=require("compare-versions"),e=require("./cleanVersionString.js");function c(n,r){const s=e(n),o=e(r);return i.compare(s,o,"<")}module.exports=c;
@@ -0,0 +1,9 @@
1
+ import i from "compare-versions";
2
+ import e from "./cleanVersionString.mjs";
3
+ function c(n, o) {
4
+ const r = e(n), s = e(o);
5
+ return i.compare(r, s, "<");
6
+ }
7
+ export {
8
+ c as default
9
+ };
@@ -1 +0,0 @@
1
- "use strict";function i(t,e=1){return`v${e.toFixed(1)}/${t}`}module.exports=i;
@@ -1 +0,0 @@
1
- "use strict";const l=/(\/{.+?})/g,c=/[/{}]/g;function f(s,t){const o={url:s,params:t??{}};if(!t)return o;const n=s.match(l);return n!=null&&n.length?n.reduce((e,p)=>{const r=p.replace(c,""),g=t[r];return g?(delete e.params[r],e.url=e.url.replace(new RegExp(p,"g"),`/${g}`)):e.params[r]=t[r],e},{url:s,params:{...t}}):o}module.exports=f;
package/api/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getUrlAndParams.cjs"),t=require("./getEndpointWithVersion.cjs");exports.getUrlAndParams=e;exports.getEndpointWithVersion=t;
@@ -1 +0,0 @@
1
- "use strict";const n=require("tinycolor2");function e(t,r){return n(t).brighten(r).toString()}module.exports=e;
package/color/darken.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";const n=require("tinycolor2");function e(r,t){return n(r).darken(t).toString()}module.exports=e;
package/color/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./lighten.cjs"),r=require("./brighten.cjs"),o=require("./darken.cjs");require("tinycolor2");exports.lighten=e;exports.brighten=r;exports.darken=o;
package/color/lighten.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";const r=require("tinycolor2");function e(t,n){return r(t).lighten(n).toString()}module.exports=e;
package/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.cjs"),r=require("./shared/isWithinFlag.cjs"),t=require("./shared/generateId.cjs"),n=require("./outlet/getListOutletOpeningHoursTable.cjs"),i=require("./versioning/isVersionALessThanB.cjs"),s=require("./versioning/cleanVersionString.cjs"),o=require("./api/getUrlAndParams.cjs"),l=require("./api/getEndpointWithVersion.cjs"),a=require("./string/slugify.cjs"),u=require("./color/lighten.cjs"),g=require("./color/brighten.cjs"),c=require("./color/darken.cjs"),d=require("./user/getFullName.cjs"),q=require("./user/getFullAddressString.cjs");require("moment");require("compare-versions");require("tinycolor2");exports.DayOfWeek=e.DayOfWeek;exports.IntervalState=e.IntervalState;exports.IntervalType=e.IntervalType;exports.OrderFormat=e.OrderFormat;exports.isWithinFlag=r;exports.generateId=t;exports.getListOutletOpeningHoursTable=n;exports.isVersionALessThanB=i;exports.cleanVersionString=s;exports.getUrlAndParams=o;exports.getEndpointWithVersion=l;exports.slugify=a;exports.lighten=u;exports.brighten=g;exports.darken=c;exports.getFullName=d.getFullName;exports.getFullAddressString=q.getFullAddressString;
@@ -1 +0,0 @@
1
- "use strict";const k=require("moment"),r=require("../shared/enums.cjs"),g=require("../shared/isWithinFlag.cjs"),I=require("../shared/generateId.cjs"),l=[{id:r.OrderFormat.EatIn,name:"eatIn"},{id:r.OrderFormat.Takeaway,name:"takeaway"},{id:r.OrderFormat.TableOrder,name:"tableOrder"},{id:r.OrderFormat.Delivery,name:"delivery"}];function F(e){const n=k.utc(e).subtract(1,"day").startOf("day"),t=[];for(let i=0,s=n;i<7;i+=1)s=s.clone().add(1,"day").startOf("day"),t.push(s.clone());return t}function v(e){return[...e].sort((n,t)=>n.isoWeekday()-t.isoWeekday())}function W(e){return e.split(":").map(Number)}function S(e,n){const[t,i]=W(e.start),[s,a]=W(e.duration);if(e.type===r.IntervalType.Interval){const o=n.clone().add(t,"hour").add(i,"minute"),u=o.clone().add(s,"hour").add(a,"minute");return{id:e.id,start:o.toISOString(),end:u.toISOString()}}if(e.type===r.IntervalType.Exception){const o=k(e.fromDate),u=k(e.toDate);if(n.isBetween(o,u,void 0,"[]")){const c=n.clone().add(t,"hour").add(i,"minute"),y=c.clone().add(s,"hour").add(a,"minute");return{id:e.id,start:c.toISOString(),end:y.toISOString(),reason:e.reason}}return null}throw new Error("Invalid interval type")}function h(e,n,t){const i={[r.DayOfWeek.Monday]:1,[r.DayOfWeek.Tuesday]:2,[r.DayOfWeek.Wednesday]:3,[r.DayOfWeek.Thursday]:4,[r.DayOfWeek.Friday]:5,[r.DayOfWeek.Saturday]:6,[r.DayOfWeek.Sunday]:7};for(let s=0;s<n.length;s+=1){const a=n[s],o=a.isoWeekday(),u=e.dayOfWeek,y=(i[u]??null)===o||u===r.DayOfWeek.Everyday;if(t[o]||(t[o]={isoWeekday:o,key:"",open:[],adjusted:[],closed:[]}),y){const d=S(e,a);d&&(t[o].key+=d.id,e.type===r.IntervalType.Interval&&e.state===r.IntervalState.Open?t[o].open.push(d):e.type===r.IntervalType.Interval&&e.state===r.IntervalState.Closed?t[o].closed.push(d):e.type===r.IntervalType.Exception&&e.state===r.IntervalState.Open?t[o].adjusted.push(d):e.type===r.IntervalType.Exception&&e.state===r.IntervalState.Closed&&t[o].closed.push(d))}}}function T(e){switch(e.type){case r.IntervalType.Exception:return I("interval-exception");case r.IntervalType.Interval:return I("interval-normal");default:return I("interval-unknown")}}function D(e){const n=e.reduce((t,i)=>(l.forEach(s=>{g(s.id,i.orderFormats)&&(t[s.id]||(t[s.id]={orderFormat:s,intervals:[]}),t[s.id].intervals.push(...i.intervals.sort((a,o)=>a.dayOfWeek-o.dayOfWeek)))}),t),{});return Object.values(n)}function M(e){return e.reduce((n,t,i)=>{const s=n.findIndex(a=>a!==t&&!a.orderFormats.some(o=>t.orderFormats.some(u=>u.id===o.id))&&a.openingHours.every(o=>t.openingHours.some(u=>u.key===o.key))&&t.openingHours.every(o=>a.openingHours.some(u=>u.key===o.key)));if(s>=0){const a=n[s];return n.splice(s,1,{...a,orderFormats:[...t.orderFormats,...a.orderFormats]}),n.splice(i,1),n}return n},[...e])}function H(e){return e.map(n=>({...n,intervals:n.intervals.map(t=>({...t,id:T(t)}))}))}function E(e,n){const t=D(H(e.serviceDateTimes)),i=F(n),s=v(i),a=t.reduce((y,d)=>(y[d.orderFormat.id]||(y[d.orderFormat.id]={}),d.intervals.reduce((O,p)=>(h(p,s,O),O),y[d.orderFormat.id]),y),{}),o={[r.OrderFormat.EatIn]:l[0],[r.OrderFormat.Takeaway]:l[1],[r.OrderFormat.TableOrder]:l[2],[r.OrderFormat.Delivery]:l[3]},u=Object.entries(a).map(([y,d])=>({orderFormats:[o[Number(y)]],openingHours:Object.entries(d).map(([O,p])=>({isoWeekday:Number(O),key:p.key,open:p.open.sort((m,f)=>m.start.localeCompare(f.start)),adjusted:p.adjusted.sort((m,f)=>m.start.localeCompare(f.start)),closed:p.closed.sort((m,f)=>m.start.localeCompare(f.start))}))}));return M(u).sort((y,d)=>y.orderFormats[0].id-d.orderFormats[0].id)}module.exports=E;
package/outlet/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getListOutletOpeningHoursTable.cjs");require("moment");require("../shared/enums.cjs");require("../shared/isWithinFlag.cjs");require("../shared/generateId.cjs");exports.getListOutletOpeningHoursTable=e;
package/outlet/types.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";
package/shared/enums.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var n=(d=>(d[d.EatIn=1]="EatIn",d[d.Takeaway=2]="Takeaway",d[d.TableOrder=4]="TableOrder",d[d.Delivery=8]="Delivery",d))(n||{}),u=(d=>(d[d.Monday=1]="Monday",d[d.Tuesday=2]="Tuesday",d[d.Wednesday=4]="Wednesday",d[d.Thursday=8]="Thursday",d[d.Friday=16]="Friday",d[d.Saturday=32]="Saturday",d[d.Sunday=64]="Sunday",d[d.Everyday=127]="Everyday",d))(u||{}),a=(d=>(d[d.Open=0]="Open",d[d.Closed=1]="Closed",d))(a||{}),r=(d=>(d[d.Interval=0]="Interval",d[d.Exception=1]="Exception",d))(r||{});exports.DayOfWeek=u;exports.IntervalState=a;exports.IntervalType=r;exports.OrderFormat=n;
@@ -1 +0,0 @@
1
- "use strict";function n(t){const r=Math.random().toString();return`${t?`${t}-`:""}${r.substring(2)}`}module.exports=n;
package/shared/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./enums.cjs"),r=require("./isWithinFlag.cjs"),t=require("./generateId.cjs");exports.DayOfWeek=e.DayOfWeek;exports.IntervalState=e.IntervalState;exports.IntervalType=e.IntervalType;exports.OrderFormat=e.OrderFormat;exports.isWithinFlag=r;exports.generateId=t;
@@ -1 +0,0 @@
1
- "use strict";function r(t,i){return(i&t)===t}module.exports=r;
package/string/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./slugify.cjs");exports.slugify=e;
@@ -1 +0,0 @@
1
- "use strict";function a(e,r){return e.toLocaleLowerCase(r).replace(/[åäæ]/g,"a").replace(/[öø]/g,"o").replace(/[é]/g,"e").replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}module.exports=a;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(t){return t&&[t.street,t.city,t.state,t.zipCode].filter(Boolean).join(", ")||""}exports.getFullAddressString=e;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t,e="N/A"){try{if(Array.isArray(t))return t.filter(Boolean).join(" ")||e;const r=t;return r&&[r.firstName,r.lastName].filter(Boolean).join(" ")||e}catch{return e}}exports.getFullName=n;
package/user/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getFullName.cjs"),t=require("./getFullAddressString.cjs");exports.getFullName=e.getFullName;exports.getFullAddressString=t.getFullAddressString;
@@ -1 +0,0 @@
1
- "use strict";function s(r){const e=r.toLowerCase().split("-")[0];return e.charAt(0)==="v"?e.substring(1):e}module.exports=s;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./isVersionALessThanB.cjs"),i=require("./cleanVersionString.cjs");require("compare-versions");exports.isVersionALessThanB=e;exports.cleanVersionString=i;
@@ -1 +0,0 @@
1
- "use strict";const i=require("compare-versions"),e=require("./cleanVersionString.cjs");function c(n,r){const s=e(n),o=e(r);return i.compare(s,o,"<")}module.exports=c;