order3000 1.10.0 → 1.12.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.
- package/dist/client.cjs +112 -4
- package/dist/client.d.cts +61 -3500
- package/dist/client.d.mts +61 -3500
- package/dist/client.mjs +112 -4
- package/dist/index-bbg7Ev_r.d.cts +3858 -0
- package/dist/index-bbg7Ev_r.d.mts +3858 -0
- package/dist/menu.cjs +35 -0
- package/dist/menu.d.cts +51 -0
- package/dist/menu.d.mts +51 -0
- package/dist/menu.mjs +30 -0
- package/dist/schemas.cjs +522 -1
- package/dist/schemas.d.cts +419 -1
- package/dist/schemas.d.mts +419 -1
- package/dist/schemas.mjs +522 -1
- package/package.json +13 -3
package/dist/menu.cjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const MENU_WEEKDAY_ORDER = [
|
|
4
|
+
"monday",
|
|
5
|
+
"tuesday",
|
|
6
|
+
"wednesday",
|
|
7
|
+
"thursday",
|
|
8
|
+
"friday",
|
|
9
|
+
"saturday",
|
|
10
|
+
"sunday"
|
|
11
|
+
];
|
|
12
|
+
const isMenuItemAvailableInWeek = (item, isoWeek) => {
|
|
13
|
+
if (!item.availableWeeks) return true;
|
|
14
|
+
return item.availableWeeks.includes(isoWeek);
|
|
15
|
+
};
|
|
16
|
+
const isMenuItemAvailableOnWeekday = (item, weekday) => {
|
|
17
|
+
if (!item.availableDays) return true;
|
|
18
|
+
return item.availableDays.includes(weekday);
|
|
19
|
+
};
|
|
20
|
+
const groupLunchMenuByWeek = (items, isoWeek) => {
|
|
21
|
+
const weekItems = items.filter(
|
|
22
|
+
(item) => item.isActive && isMenuItemAvailableInWeek(item, isoWeek)
|
|
23
|
+
);
|
|
24
|
+
return MENU_WEEKDAY_ORDER.map((weekday) => ({
|
|
25
|
+
weekday,
|
|
26
|
+
items: weekItems.filter(
|
|
27
|
+
(item) => isMenuItemAvailableOnWeekday(item, weekday)
|
|
28
|
+
)
|
|
29
|
+
})).filter((group) => group.items.length > 0);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.MENU_WEEKDAY_ORDER = MENU_WEEKDAY_ORDER;
|
|
33
|
+
exports.groupLunchMenuByWeek = groupLunchMenuByWeek;
|
|
34
|
+
exports.isMenuItemAvailableInWeek = isMenuItemAvailableInWeek;
|
|
35
|
+
exports.isMenuItemAvailableOnWeekday = isMenuItemAvailableOnWeekday;
|
package/dist/menu.d.cts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { au as MenuItem } from './index-bbg7Ev_r.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* order3000 lunch-menu availability — the per-item rotation logic, provided by
|
|
5
|
+
* the SDK so every consumer (e.g. thamarai's `/mittagsmenü` page) filters a menu
|
|
6
|
+
* identically without re-implementing the null / `[]` / `[values]` semantics.
|
|
7
|
+
*
|
|
8
|
+
* Each menu item carries two orthogonal, optional rotation dimensions:
|
|
9
|
+
* - `availableWeeks` — ISO calendar weeks (KW 1–53)
|
|
10
|
+
* - `availableDays` — weekdays
|
|
11
|
+
* For each: `null` = no restriction (always), `[]` = never served, `[values]` =
|
|
12
|
+
* only those. An item shows on a given weekday of a given calendar week only
|
|
13
|
+
* when BOTH dimensions pass.
|
|
14
|
+
*
|
|
15
|
+
* Pure and dependency-free (no dates, no `window`) — safe to import in SSR or
|
|
16
|
+
* the browser. Calendar math (which ISO week "today" is, the dates of a week)
|
|
17
|
+
* is the caller's job via `@kolaveri/utils` / `date-fns`.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** A weekday value as carried by a menu item's `availableDays`. */
|
|
21
|
+
type MenuWeekday = NonNullable<MenuItem['availableDays']>[number];
|
|
22
|
+
/** Mon→Sun — the canonical order lunch-menu weekday groups are emitted in. */
|
|
23
|
+
declare const MENU_WEEKDAY_ORDER: readonly MenuWeekday[];
|
|
24
|
+
/**
|
|
25
|
+
* Whether an item is on the rotation for the given ISO calendar week.
|
|
26
|
+
* `null` weeks = every week; `[]` = never; otherwise only the listed weeks.
|
|
27
|
+
*/
|
|
28
|
+
declare const isMenuItemAvailableInWeek: (item: Pick<MenuItem, "availableWeeks">, isoWeek: number) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether an item is on the rotation for the given weekday.
|
|
31
|
+
* `null` days = every weekday; `[]` = never; otherwise only the listed days.
|
|
32
|
+
*/
|
|
33
|
+
declare const isMenuItemAvailableOnWeekday: (item: Pick<MenuItem, "availableDays">, weekday: MenuWeekday) => boolean;
|
|
34
|
+
/** One weekday's lunch offering within a calendar week. */
|
|
35
|
+
interface LunchMenuWeekdayGroup {
|
|
36
|
+
weekday: MenuWeekday;
|
|
37
|
+
items: MenuItem[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Group a menu's items by weekday for one ISO calendar week — the data model
|
|
41
|
+
* behind a calendar-week lunch-menu page.
|
|
42
|
+
*
|
|
43
|
+
* Keeps only active items available in `isoWeek`, buckets them into the weekday
|
|
44
|
+
* groups they're available on (Mon→Sun), and DROPS weekdays with no items.
|
|
45
|
+
* Item order within each group is preserved from the input (order3000 returns
|
|
46
|
+
* `menu.items` pre-sorted by `sortIndex`), so callers should pass them as-is.
|
|
47
|
+
*/
|
|
48
|
+
declare const groupLunchMenuByWeek: (items: MenuItem[], isoWeek: number) => LunchMenuWeekdayGroup[];
|
|
49
|
+
|
|
50
|
+
export { MENU_WEEKDAY_ORDER, groupLunchMenuByWeek, isMenuItemAvailableInWeek, isMenuItemAvailableOnWeekday };
|
|
51
|
+
export type { LunchMenuWeekdayGroup, MenuWeekday };
|
package/dist/menu.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { au as MenuItem } from './index-bbg7Ev_r.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* order3000 lunch-menu availability — the per-item rotation logic, provided by
|
|
5
|
+
* the SDK so every consumer (e.g. thamarai's `/mittagsmenü` page) filters a menu
|
|
6
|
+
* identically without re-implementing the null / `[]` / `[values]` semantics.
|
|
7
|
+
*
|
|
8
|
+
* Each menu item carries two orthogonal, optional rotation dimensions:
|
|
9
|
+
* - `availableWeeks` — ISO calendar weeks (KW 1–53)
|
|
10
|
+
* - `availableDays` — weekdays
|
|
11
|
+
* For each: `null` = no restriction (always), `[]` = never served, `[values]` =
|
|
12
|
+
* only those. An item shows on a given weekday of a given calendar week only
|
|
13
|
+
* when BOTH dimensions pass.
|
|
14
|
+
*
|
|
15
|
+
* Pure and dependency-free (no dates, no `window`) — safe to import in SSR or
|
|
16
|
+
* the browser. Calendar math (which ISO week "today" is, the dates of a week)
|
|
17
|
+
* is the caller's job via `@kolaveri/utils` / `date-fns`.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** A weekday value as carried by a menu item's `availableDays`. */
|
|
21
|
+
type MenuWeekday = NonNullable<MenuItem['availableDays']>[number];
|
|
22
|
+
/** Mon→Sun — the canonical order lunch-menu weekday groups are emitted in. */
|
|
23
|
+
declare const MENU_WEEKDAY_ORDER: readonly MenuWeekday[];
|
|
24
|
+
/**
|
|
25
|
+
* Whether an item is on the rotation for the given ISO calendar week.
|
|
26
|
+
* `null` weeks = every week; `[]` = never; otherwise only the listed weeks.
|
|
27
|
+
*/
|
|
28
|
+
declare const isMenuItemAvailableInWeek: (item: Pick<MenuItem, "availableWeeks">, isoWeek: number) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether an item is on the rotation for the given weekday.
|
|
31
|
+
* `null` days = every weekday; `[]` = never; otherwise only the listed days.
|
|
32
|
+
*/
|
|
33
|
+
declare const isMenuItemAvailableOnWeekday: (item: Pick<MenuItem, "availableDays">, weekday: MenuWeekday) => boolean;
|
|
34
|
+
/** One weekday's lunch offering within a calendar week. */
|
|
35
|
+
interface LunchMenuWeekdayGroup {
|
|
36
|
+
weekday: MenuWeekday;
|
|
37
|
+
items: MenuItem[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Group a menu's items by weekday for one ISO calendar week — the data model
|
|
41
|
+
* behind a calendar-week lunch-menu page.
|
|
42
|
+
*
|
|
43
|
+
* Keeps only active items available in `isoWeek`, buckets them into the weekday
|
|
44
|
+
* groups they're available on (Mon→Sun), and DROPS weekdays with no items.
|
|
45
|
+
* Item order within each group is preserved from the input (order3000 returns
|
|
46
|
+
* `menu.items` pre-sorted by `sortIndex`), so callers should pass them as-is.
|
|
47
|
+
*/
|
|
48
|
+
declare const groupLunchMenuByWeek: (items: MenuItem[], isoWeek: number) => LunchMenuWeekdayGroup[];
|
|
49
|
+
|
|
50
|
+
export { MENU_WEEKDAY_ORDER, groupLunchMenuByWeek, isMenuItemAvailableInWeek, isMenuItemAvailableOnWeekday };
|
|
51
|
+
export type { LunchMenuWeekdayGroup, MenuWeekday };
|
package/dist/menu.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const MENU_WEEKDAY_ORDER = [
|
|
2
|
+
"monday",
|
|
3
|
+
"tuesday",
|
|
4
|
+
"wednesday",
|
|
5
|
+
"thursday",
|
|
6
|
+
"friday",
|
|
7
|
+
"saturday",
|
|
8
|
+
"sunday"
|
|
9
|
+
];
|
|
10
|
+
const isMenuItemAvailableInWeek = (item, isoWeek) => {
|
|
11
|
+
if (!item.availableWeeks) return true;
|
|
12
|
+
return item.availableWeeks.includes(isoWeek);
|
|
13
|
+
};
|
|
14
|
+
const isMenuItemAvailableOnWeekday = (item, weekday) => {
|
|
15
|
+
if (!item.availableDays) return true;
|
|
16
|
+
return item.availableDays.includes(weekday);
|
|
17
|
+
};
|
|
18
|
+
const groupLunchMenuByWeek = (items, isoWeek) => {
|
|
19
|
+
const weekItems = items.filter(
|
|
20
|
+
(item) => item.isActive && isMenuItemAvailableInWeek(item, isoWeek)
|
|
21
|
+
);
|
|
22
|
+
return MENU_WEEKDAY_ORDER.map((weekday) => ({
|
|
23
|
+
weekday,
|
|
24
|
+
items: weekItems.filter(
|
|
25
|
+
(item) => isMenuItemAvailableOnWeekday(item, weekday)
|
|
26
|
+
)
|
|
27
|
+
})).filter((group) => group.items.length > 0);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { MENU_WEEKDAY_ORDER, groupLunchMenuByWeek, isMenuItemAvailableInWeek, isMenuItemAvailableOnWeekday };
|