@ancon/wildcat-utils 1.17.5 → 1.18.0

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,4 +1,4 @@
1
- import { ListOutlet } from './types';
1
+ import { ServiceDateTime } from './types';
2
2
  declare type ReadableOrderFormat = {
3
3
  id: number;
4
4
  name: string;
@@ -27,5 +27,7 @@ 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: ListOutlet, nowISOString?: string): OpeningHoursTable[];
30
+ export default function getListOutletOpeningHoursTable(outlet: {
31
+ serviceDateTimes: ServiceDateTime[];
32
+ }, nowISOString?: string): OpeningHoursTable[];
31
33
  export {};
@@ -0,0 +1,19 @@
1
+ import { ServiceDateTime } from '@ancon/wildcat-types';
2
+ export declare type OutletDetailsOpeningHour = {
3
+ type: 0;
4
+ state: 0;
5
+ orderFormat: 8;
6
+ dayOfWeek: 8;
7
+ unformattedPeriodFrom: '1900-01-01T00:00:00Z';
8
+ periodFrom: '1900-01-01T00:00:00';
9
+ unformattedPeriodTo: '2200-01-01T00:00:00Z';
10
+ periodTo: '2200-01-01T00:00:00';
11
+ from: '23:00:00';
12
+ duration: '06:00:00';
13
+ reason: '';
14
+ isDefault: false;
15
+ position: 0;
16
+ };
17
+ export default function serviceDateTimesFromOpeningHours({ openingHours, }: {
18
+ openingHours: OutletDetailsOpeningHour[];
19
+ }): ServiceDateTime[];
@@ -0,0 +1 @@
1
+ "use strict";const n=require("moment");function u({openingHours:s}){const e=s.reduce((o,r)=>{o[r.orderFormat]||(o[r.orderFormat]={orderFormats:r.orderFormat,intervals:[],isDefault:r.isDefault});const[t,a]=r.duration.split(":");return o[r.orderFormat].intervals.push({start:r.from,duration:r.duration,end:n(r.from,"HH:mm:ss").add(t,"hours").add(a,"minutes").format("HH:mm:ss"),fromDate:r.unformattedPeriodFrom,toDate:r.unformattedPeriodTo,type:r.type,position:r.position,state:r.state,dayOfWeek:r.dayOfWeek,isDefault:r.isDefault,reason:r.reason}),o},{});return Object.values(e)}module.exports=u;
@@ -0,0 +1,33 @@
1
+ import n from "moment";
2
+ function u({
3
+ openingHours: s
4
+ }) {
5
+ const t = s.reduce(
6
+ (o, r) => {
7
+ o[r.orderFormat] || (o[r.orderFormat] = {
8
+ orderFormats: r.orderFormat,
9
+ intervals: [],
10
+ isDefault: r.isDefault
11
+ });
12
+ const [a, e] = r.duration.split(":");
13
+ return o[r.orderFormat].intervals.push({
14
+ start: r.from,
15
+ duration: r.duration,
16
+ end: n(r.from, "HH:mm:ss").add(a, "hours").add(e, "minutes").format("HH:mm:ss"),
17
+ fromDate: r.unformattedPeriodFrom,
18
+ toDate: r.unformattedPeriodTo,
19
+ type: r.type,
20
+ position: r.position,
21
+ state: r.state,
22
+ dayOfWeek: r.dayOfWeek,
23
+ isDefault: r.isDefault,
24
+ reason: r.reason
25
+ }), o;
26
+ },
27
+ {}
28
+ );
29
+ return Object.values(t);
30
+ }
31
+ export {
32
+ u as default
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.17.5",
3
+ "version": "1.18.0",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -161,6 +161,11 @@
161
161
  "require": "./outlet/searchNextOpeningMoment.js",
162
162
  "types": "./outlet/searchNextOpeningMoment.d.ts"
163
163
  },
164
+ "./outlet/serviceDateTimesFromOpeningHours": {
165
+ "import": "./outlet/serviceDateTimesFromOpeningHours.mjs",
166
+ "require": "./outlet/serviceDateTimesFromOpeningHours.js",
167
+ "types": "./outlet/serviceDateTimesFromOpeningHours.d.ts"
168
+ },
164
169
  "./outlet/types": {
165
170
  "import": "./outlet/types.mjs",
166
171
  "require": "./outlet/types.js",