@managesome/eposmatic-toolkit 0.2.694 → 0.2.695
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,10 +1,10 @@
|
|
|
1
1
|
import { PLATFORMS_ENUM } from '../../constants';
|
|
2
2
|
import { IItem, IItemSpecialHour, IModifier, IModifierOption } from '../../schemas';
|
|
3
3
|
import { IPrice } from '../../schemas/types/common';
|
|
4
|
-
import { ICatalog, ISimplifiedCatalog, ISimplifiedCatalogItem } from '../types';
|
|
4
|
+
import { ICatalog, IMinifiedItemSpecialHour, ISimplifiedCatalog, ISimplifiedCatalogItem } from '../types';
|
|
5
5
|
export declare function getPriceEnum(price: IPrice | null | undefined, platform: PLATFORMS_ENUM | null | undefined): number;
|
|
6
6
|
export declare function areAllSchedulesExpired(special_hours: IItemSpecialHour[] | null | undefined): boolean;
|
|
7
|
-
export declare function findApplicableSchedule(special_hours:
|
|
7
|
+
export declare function findApplicableSchedule<T extends IItemSpecialHour | IMinifiedItemSpecialHour>(special_hours: T[] | null | undefined, platform: PLATFORMS_ENUM): T | boolean;
|
|
8
8
|
/**
|
|
9
9
|
* Pure mapping: converts a list of platforms an entity is INCLUDED in into the
|
|
10
10
|
* list of platforms it is EXCLUDED from (complement over all platforms).
|
|
@@ -32,6 +32,19 @@ type ISetupWithAvailability = {
|
|
|
32
32
|
item_special_hours: IItemSpecialHour[] | null | undefined;
|
|
33
33
|
};
|
|
34
34
|
export declare function isSetupApplicable(setup: ISetupWithAvailability, { tenant_id, platform }: ISetupApplicabilityContext): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Availability predicate for the display-only simplified setups
|
|
37
|
+
* (ISimplifiedSpecial / ISimplifiedHalfHalfSetup):
|
|
38
|
+
* - no tenant check — simplified payloads are already scoped to the requesting
|
|
39
|
+
* tenant by the endpoint (they carry no tenants field),
|
|
40
|
+
* - minified special-hours type accepted directly (no casting).
|
|
41
|
+
*/
|
|
42
|
+
type ISimplifiedSetupWithAvailability = {
|
|
43
|
+
active: boolean;
|
|
44
|
+
included_platforms: PLATFORMS_ENUM[];
|
|
45
|
+
item_special_hours?: IMinifiedItemSpecialHour[] | null | undefined;
|
|
46
|
+
};
|
|
47
|
+
export declare function isSimplifiedSetupApplicable(setup: ISimplifiedSetupWithAvailability, platform: PLATFORMS_ENUM): boolean;
|
|
35
48
|
export declare function getPlatformModifierOptions(options: IModifierOption[], platform: PLATFORMS_ENUM, excludeIds?: string[]): IModifierOption[];
|
|
36
49
|
export declare function getPlatformModifiers(modifiers: IModifier[] | null | undefined, platform: PLATFORMS_ENUM | undefined, excludeIds?: string[]): IModifier[] | null;
|
|
37
50
|
export declare function convertItemToWorkableItem<T extends IItem | ISimplifiedCatalogItem>(item: T, platform: PLATFORMS_ENUM, tenantId: string | undefined, omitSchedule?: boolean, omitSchedulePricing?: boolean): T | null;
|
|
@@ -5,6 +5,7 @@ exports.areAllSchedulesExpired = areAllSchedulesExpired;
|
|
|
5
5
|
exports.findApplicableSchedule = findApplicableSchedule;
|
|
6
6
|
exports.getExcludedPlatformsFromIncludedPlatforms = getExcludedPlatformsFromIncludedPlatforms;
|
|
7
7
|
exports.isSetupApplicable = isSetupApplicable;
|
|
8
|
+
exports.isSimplifiedSetupApplicable = isSimplifiedSetupApplicable;
|
|
8
9
|
exports.getPlatformModifierOptions = getPlatformModifierOptions;
|
|
9
10
|
exports.getPlatformModifiers = getPlatformModifiers;
|
|
10
11
|
exports.convertItemToWorkableItem = convertItemToWorkableItem;
|
|
@@ -53,7 +54,7 @@ function findApplicableSchedule(special_hours, platform) {
|
|
|
53
54
|
if (!special_hours || special_hours.length === 0)
|
|
54
55
|
return true;
|
|
55
56
|
// step 1: we filter out excluded special hours
|
|
56
|
-
const availableSchedules = special_hours.filter((specialHour) => !specialHour.excluded_platforms.includes(platform));
|
|
57
|
+
const availableSchedules = special_hours.filter((specialHour) => !(specialHour.excluded_platforms ?? []).includes(platform));
|
|
57
58
|
// if there are no special hours left after filtering, it means that item is available
|
|
58
59
|
if (availableSchedules.length === 0)
|
|
59
60
|
return true;
|
|
@@ -121,6 +122,13 @@ function isSetupApplicable(setup, { tenant_id, platform }) {
|
|
|
121
122
|
const applicableSchedule = findApplicableSchedule(setup.item_special_hours, platform);
|
|
122
123
|
return applicableSchedule !== false;
|
|
123
124
|
}
|
|
125
|
+
function isSimplifiedSetupApplicable(setup, platform) {
|
|
126
|
+
if (!setup.active || !setup.included_platforms.includes(platform)) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const applicableSchedule = findApplicableSchedule(setup.item_special_hours, platform);
|
|
130
|
+
return applicableSchedule !== false;
|
|
131
|
+
}
|
|
124
132
|
// ==========================================================><====================================================
|
|
125
133
|
function getPlatformModifierOptions(options, platform, excludeIds = []) {
|
|
126
134
|
const platformOptions = [];
|