import { PlausibleProps } from 'mealz-shared-analytics'; import { Observable } from 'rxjs'; import { BasketEntry, Recipe, RecipeLike } from '../../_models'; import { RecipePricing } from '../../_models/recipe-pricing'; import { EventJourney } from '../event-journey.enum'; export interface MealzInternalInterface { analytics: { /** * Sends an analytics event via mealz-shared-analytics */ sendEvent: (name: string, path: string, props: PlausibleProps, journey?: EventJourney) => void; /** * Defines the `journey` property for mealz-shared-analytics * * Set to true if we currently are in a mealz dedicated page */ setIsMealzPage: (isMealzPage: boolean) => void; }; // --------------------------------------------------------------------------------------------------- basket: { /** * Emits the list of recipe IDs when recipes are added to the basket. */ recipesAddedToBasket$: () => Observable; /** * Emits the pricing information for recipes in the basket. */ recipeDataInBasket$: () => Observable<{ id: string; price: string; guests: number }[]>; /** * Emits the list of recipes in the basket. */ waitForBasketEntries: () => Observable; }; // --------------------------------------------------------------------------------------------------- catalog: { /** * Opens preferences modal */ openPreferences: () => void; /** * Emits an observable that notifies subscribers when the preferences have changed */ preferencesModalChanged: () => Observable; /** * returns an observable with the number of preferences set */ preferencesCount: () => Observable; loadMoreRecipes: (packageId: string, page: number, pageSize: number, guests: number) => Observable; }; // --------------------------------------------------------------------------------------------------- preferences: { /** * Resets user preferences and clears cached preferences when SSR is enabled */ resetPreferences: () => void; }; // --------------------------------------------------------------------------------------------------- config: { logLevel: Observable; }; // --------------------------------------------------------------------------------------------------- recipes: { /** * Opens the recipe details by calling the `openRecipeDetails` method of the `recipesService`. */ openDetails: (recipeId: string, guests: number, initialTabIndex: number, analyticsPath?: string, categoryId?: string) => void; /** * Updates or creates a recipe like entry. * If `recipeLikeId` is provided, it updates the existing like; otherwise, it creates a new one. * It also sets the `isPast` status and tracks the update event. */ updateRecipeLike: (recipeLikeId: string, recipeId: string, isPast: boolean, path?: string) => void; /** * Gets the RecipeLike for the recipeId */ getRecipeLike: (recipeId: string) => Observable; /** * Emits an observable that notifies subscribers when a recipe like has been updated. */ recipeLikeUpdated: () => Observable<{ id: string; isPast: boolean }>; /** * Emits an observable that notifies subscribers when the number of guests of a recipe has been updated from recipe details. */ guestsUpdated: () => Observable<{ guests: number; recipeId: string }>; /** * Emits an observable that notifies subscribers when a recipe price has been updated. */ recipePriceUpdated: () => Observable<{ remaining: number; inBasket: number; recipeId: string }>; /** * Fetches the pricing information for a specific recipe based on the provided parameters. */ fetchPricing: (recipeId: string, posId: string, serves: number) => Observable; }; // --------------------------------------------------------------------------------------------------- supplier: { /** * Retrieves the token from the suppliers service */ getToken: () => string; }; // --------------------------------------------------------------------------------------------------- user: { /** * Retrieve user language as an ISO 639-1 code or custom code */ getLanguage: () => string; /** * Retrieves the current authentication status of the user. */ isAuthenticated: () => Observable; /** * Updates the SDK's session ID to ensure consistency with SSR. */ setSessionId: (sessionId: string) => void; }; planner: { getDashboardHTML: () => Observable; getCurrentMenuHTML: () => Observable; getEntryHTML: () => Observable; }; getStickyHeaderHeight: () => Observable; }