webc-miam 10.5.9 → 10.5.10

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,17 +1,8 @@
1
1
  import { PlausibleProps } from 'mealz-shared-analytics';
2
- import { DocumentCollection } from 'miam-jsonapi';
3
- import { BehaviorSubject, Observable, ReplaySubject } from 'rxjs';
4
- import { Basket, BasketEntry, Ingredient, Item, Menu, MenuRecipe, PointOfSale, Recipe, RecipeLike, SponsorBlock, Supplier } from '../../_models';
2
+ import { Observable } from 'rxjs';
3
+ import { BasketEntry, Recipe, RecipeLike } from '../../_models';
5
4
  import { RecipePricing } from '../../_models/recipe-pricing';
6
- import { Tag } from '../../_models/tag';
7
- import { ProductCategory, ProductPrice, RecipeDisplay } from '../../_services';
8
- import { RecipeInBasketPreview } from '../../_services/basket-utils.service';
9
- import { Product } from '../../_services/new-recipe-details.service';
10
- import { BasicPreference } from '../../_services/preferences.service';
11
- import { ProductPlanner, ProductPlannerCategory } from '../../_services/recipe-details-products-planner.service';
12
- import { BasketEntryToReplace } from '../../_services/replace-item.service';
13
5
  import { EventJourney } from '../event-journey.enum';
14
- import { EventTrace } from '../event-trace';
15
6
 
16
7
  export interface MealzInternalInterface {
17
8
 
@@ -42,83 +33,32 @@ export interface MealzInternalInterface {
42
33
  /**
43
34
  * Emits the pricing information for recipes in the basket.
44
35
  */
45
- recipePricesInBasket$: () => Observable<{ id: string; price: string }[]>;
46
-
47
- /**
48
- * Gets the guests count for a recipe
49
- * @param recipeId
50
- */
51
- guestsForRecipe: (recipeId: string) => number;
52
-
53
- /**
54
- * Removes a recipe from the basket.
55
- */
56
- removeRecipe: (recipeId: string, analyticsPath: string) => void;
57
-
58
- /**
59
- * Emits the preview of recipes in the basket.
60
- */
61
- buildPreview: () => Observable<RecipeInBasketPreview[]>;
62
-
63
-
64
- /**
65
- * Observable that emits the full state of the basket preview including open state and active tab
66
- */
67
- basketPreviewState$: Observable<{ isOpen: boolean; activeTabIndex?: number }>;
36
+ recipeDataInBasket$: () => Observable<{ id: string; price: string, guests: number }[]>;
68
37
 
69
38
  /**
70
39
  * Emits the list of recipes in the basket.
71
40
  */
72
41
  waitForBasketEntries: () => Observable<BasketEntry[]>;
73
-
74
- /**
75
- * Emits the list of basket-entries in the basket each time it changes.
76
- */
77
- entries$: () => Observable<BasketEntry[]>;
78
-
79
- /**
80
- * Refresh the current basket state and emit updated basket
81
- */
82
- refreshCurrentBasket: () => Observable<Basket>;
83
-
84
- /**
85
- * if false, don't show the product section in the basket preview
86
- */
87
-
88
- displayProductsInBasket: () => boolean;
89
-
90
- /**
91
- * Emits the list of basket-entries to add to retailer cart
92
- */
93
- updateRetailerBasketFromPlanner: () => void;
94
42
  };
95
43
 
96
- basketTransfer: {
97
- /**
98
- * Exposes the transfer-in-progress state
99
- */
100
- basketIsBeingTransferred: BehaviorSubject<boolean>;
44
+ // ---------------------------------------------------------------------------------------------------
45
+
46
+ catalog: {
101
47
 
102
48
  /**
103
- * Abort the transfer (reloads basket)
49
+ * Opens preferences modal
104
50
  */
105
- abortTransfer: () => Observable<void>;
51
+ openPreferences: () => void;
106
52
 
107
53
  /**
108
- * Navigate to the transfer URL stored in session
54
+ * Emits an observable that notifies subscribers when the preferences have changed
109
55
  */
110
- navigateToTransferUrl: () => void;
56
+ preferencesModalChanged: () => Observable<void>;
111
57
 
112
58
  /**
113
- * transfer basket to supplier
59
+ * returns an observable with the number of preferences set
114
60
  */
115
-
116
- transfer: () => void;
117
- };
118
-
119
- // ---------------------------------------------------------------------------------------------------
120
-
121
- catalog: {
61
+ preferencesCount: () => Observable<number>;
122
62
 
123
63
  loadMoreRecipes: (packageId: string, page: number, pageSize: number, guests: number) => Observable<Recipe[]>;
124
64
  };
@@ -126,151 +66,7 @@ export interface MealzInternalInterface {
126
66
  // ---------------------------------------------------------------------------------------------------
127
67
 
128
68
  config: {
129
- logLevel: Observable<string>;
130
- };
131
-
132
- // ---------------------------------------------------------------------------------------------------
133
-
134
- planner: {
135
- /**
136
- * Emits the item to replace from recipe details view
137
- */
138
- itemToReplace$: BehaviorSubject<{ ingredient: Ingredient; item: Item }>;
139
-
140
-
141
- /**
142
- * Emits the list of items with prices
143
- */
144
- itemsWithPricesList$: BehaviorSubject<ProductPlanner[]>;
145
-
146
-
147
- /**
148
- * Emits if items are getting fetched
149
- */
150
- fetchingItemLoading$: BehaviorSubject<boolean>;
151
-
152
- /**
153
- * Emits an observable with the total price of the menu in the planner
154
- */
155
- menuPrice$: BehaviorSubject<number>;
156
-
157
- /**
158
- * Emits an observable with the price of the recipe currently displayed in the planner
159
- */
160
- plannerRecipePrice$: BehaviorSubject<number>;
161
-
162
- /**
163
- * creates a menu
164
- */
165
- createMenu: () => Observable<any>;
166
-
167
- /**
168
- * Deletes a menu from its id
169
- * @param menuId
170
- */
171
- deleteMenu: (menuId: string) => Observable<void>;
172
-
173
- /**
174
- * Updates a menu with its id
175
- * @param menuId
176
- * @param toUpdate
177
- */
178
- updateMenu: (menuId: string, toUpdate: Partial<Menu>) => Observable<any>;
179
-
180
- /**
181
- * Add a recipe to a menu with its id
182
- * @param recipeId
183
- * @param guests
184
- * @param autocomplete
185
- */
186
- addRecipeToMenu: (recipeId: string, guests: number, hasPos?: boolean, toPickProducts?: ProductPlanner[]) => Observable<MenuRecipe>;
187
-
188
- /**
189
- * Removes a recipe from a menu with its id
190
- * @param recipeId
191
- */
192
- removeRecipeFromMenu: (recipeId: string) => Observable<void>;
193
-
194
- /**
195
- * Fetches the title of the menu
196
- */
197
- fetchMenuTitle: () => Observable<string>;
198
-
199
- /**
200
- * Transfers the menu to the basket
201
- * @param basketId
202
- */
203
- menuToBasket: (basketId: string) => Observable<Menu>;
204
-
205
- /**
206
- * Gets the menu recipe id for a recipe
207
- * @param recipeId
208
- */
209
- getMenuRecipeId: (recipeId: string) => Observable<string | undefined>;
210
-
211
- /**
212
- * Checks if a recipe is in the menu
213
- * @param recipeId
214
- */
215
- isRecipeInMenu$: (recipeId: string) => Observable<boolean>;
216
-
217
- /**
218
- * Rejects a recipe suggestion to prevent it to be suggested again
219
- * @param recipeId
220
- */
221
- rejectRecipe: (recipeId: string) => Observable<any>;
222
-
223
- /**
224
- * Selects a product in the planner
225
- * @param itemId
226
- * @param ingredientsDefinitionId
227
- */
228
- selectProduct: (itemId: number, ingredientsDefinitionId: string) => void;
229
-
230
- /**
231
- * Unselects a product in the planner
232
- * @param itemId
233
- * @param ingredientsDefinitionId
234
- */
235
- unselectProduct: (itemId: number, ingredientsDefinitionId: string) => void;
236
-
237
- /**
238
- * Replaces a product in the planner from the replace item modal
239
- * @param product
240
- */
241
- replaceProduct: (product: ProductPlanner) => void;
242
-
243
- /**
244
- * Opens replace item view
245
- * @param product
246
- */
247
- openReplaceItemView: (product: ProductPlanner) => void;
248
-
249
- /**
250
- * Searches for an item from replace item modal
251
- * @param searchString
252
- * @param ingredient
253
- * @param item
254
- */
255
- searchItem(searchString: string, ingredient: Ingredient, item: Item): Observable<void>;
256
-
257
- /**
258
- * Gets suggested recipes
259
- */
260
- getSuggestedRecipes: () => Observable<Recipe[]>;
261
-
262
- /**
263
- * Updates the guests count
264
- * @param guests
265
- * @param eventTrace
266
- */
267
- updateGuests: (guests: number, eventTrace: EventTrace) => void;
268
-
269
- /**
270
- * Gets the guests count for a recipe
271
- * @param recipeId
272
- */
273
- getGuestsForRecipe: (recipeId: string) => Observable<number>;
69
+ logLevel: Observable<string>
274
70
  };
275
71
 
276
72
  // ---------------------------------------------------------------------------------------------------
@@ -282,117 +78,12 @@ export interface MealzInternalInterface {
282
78
  openDetails: (
283
79
  recipeId: string,
284
80
  guests: number,
285
- initialTabIndex?: number,
81
+ initialTabIndex: number,
286
82
  analyticsPath?: string,
287
83
  plannerOrCategoryId?: boolean | string,
288
84
  categoryId?: string
289
85
  ) => void;
290
86
 
291
- /**
292
- * Loads and setups a recipe
293
- */
294
- loadAndSetupRecipe: (recipeId: string, guests?: number) => Observable<void>;
295
-
296
- /**
297
- * Method to open replace item view
298
- */
299
- replaceBasketEntry: (basketEntry: BasketEntry, ignoreSelected: boolean) => void;
300
-
301
- /**
302
- * Method to update guest number
303
- */
304
- updateGuests: (eventTrace: EventTrace, guests?: number) => void;
305
-
306
- /**
307
- * Method to add all ingredients from recipe to basket
308
- */
309
- addAllIngredientsToBasket: (eventTrace: EventTrace) => void;
310
-
311
- /**
312
- * Method to add a product to the basket
313
- */
314
- addToBasket: (product: Product, eventTrace: EventTrace) => void;
315
-
316
- /**
317
- * Method to remove an ingredient
318
- */
319
- ingredientRemoved: (ingredient: Ingredient, eventTrace: EventTrace) => void;
320
-
321
- /**
322
- * Method to update the quantity of a product
323
- */
324
- updateProductQuantity: (basketEntry: BasketEntry, newQuantity: number, eventTrace: EventTrace) => void;
325
-
326
- /**
327
- * Method to ignore a product
328
- */
329
- ignoreProduct: (product: Product) => void;
330
-
331
- /**
332
- * Method to check if a product is being added
333
- */
334
- productIsBeingAdded: (basketEntry: BasketEntry) => Observable<boolean>;
335
-
336
- /**
337
- * Emits the loading state of the `addAllIngredientsToBasket` method
338
- */
339
- allIngredientsToBasketLoading$: BehaviorSubject<boolean>;
340
-
341
- /**
342
- * Emits the loading state of the `addToBasket` method
343
- */
344
- ingredientToBasketLoading$: BehaviorSubject<boolean>;
345
-
346
- /**
347
- * Emits the loading state of the `ingredientRemoved` or `updateIngredientFromBasket` method
348
- */
349
- updateIngredientFromBasketLoading$: BehaviorSubject<boolean>;
350
-
351
- /**
352
- * Emits the loading state of products
353
- */
354
- productsLoading$: BehaviorSubject<boolean>;
355
-
356
- /**
357
- * Emits the currently displayed recipe
358
- */
359
- displayedRecipe$: BehaviorSubject<RecipeDisplay>;
360
-
361
- /**
362
- * Emits the products by category
363
- */
364
- productsByCategory$: BehaviorSubject<ProductCategory>;
365
-
366
- /**
367
- * Emits the products by category in planner view
368
- */
369
- productsPlannerByCategory$: BehaviorSubject<ProductPlannerCategory>;
370
-
371
- /**
372
- * Emits if recipeDetails should display the noPos view
373
- */
374
- noPosDisplay$: BehaviorSubject<boolean>;
375
-
376
- /**
377
- * Emits if recipeDetails should display the invalidPos view
378
- */
379
- invalidPosDisplay$: BehaviorSubject<boolean>;
380
-
381
- /**
382
- * Emits an observable containing the recipe's basket entries that have not yet been added to the basket.
383
- */
384
- remainingBasketEntries$: BehaviorSubject<BasketEntry[]>;
385
-
386
- /**
387
- * Emits an observable with the price of a recipe displayed, from what is already in the basket and what is remaining
388
- */
389
- recipePrice$: BehaviorSubject<{ remaining: number; inBasket: number }>;
390
-
391
- /**
392
- * Emits an observable with the date of the last order
393
- */
394
- orderHistoryDate$: BehaviorSubject<string>;
395
-
396
87
  /**
397
88
  * Updates or creates a recipe like entry.
398
89
  * If `recipeLikeId` is provided, it updates the existing like; otherwise, it creates a new one.
@@ -400,6 +91,11 @@ export interface MealzInternalInterface {
400
91
  */
401
92
  updateRecipeLike: (recipeLikeId: string, recipeId: string, isPast: boolean, path?: string, categoryId?: string) => void;
402
93
 
94
+ /**
95
+ * Gets the RecipeLike for the recipeId
96
+ */
97
+ getRecipeLike: (recipeId: string) => Observable<RecipeLike>;
98
+
403
99
  /**
404
100
  * Emits an observable that notifies subscribers when a recipe like has been updated.
405
101
  */
@@ -419,142 +115,6 @@ export interface MealzInternalInterface {
419
115
  * Fetches the pricing information for a specific recipe based on the provided parameters.
420
116
  */
421
117
  fetchPricing: (recipeId: string, posId: string, serves: number) => Observable<RecipePricing>;
422
-
423
- /**
424
- * Updates the state to indicate whether the recipe details is being accessed from planner.
425
- */
426
- setIsRecipeDetailsFromPlanner: (isSSR: boolean) => void;
427
-
428
- /**
429
- * Checks if a recipe is in the basket
430
- * @param recipeId
431
- */
432
- isRecipeInBasket: (recipeId: string) => Observable<boolean>;
433
-
434
- /**
435
- * Gets the recipe like for a specific recipe
436
- * @param recipeId
437
- */
438
- getRecipeLike: (recipeId: string) => Observable<RecipeLike>;
439
- };
440
-
441
- // ---------------------------------------------------------------------------------------------------
442
-
443
- replaceItem: {
444
- /**
445
- * Emits the basket entry to replace from recipe details view
446
- */
447
- basketEntryToReplace$: BehaviorSubject<BasketEntryToReplace>;
448
-
449
- /**
450
- * Emits if the replace item modal should be displayed from basket preview
451
- */
452
- replaceProductFromPreviewOpen$: BehaviorSubject<BasketEntry>;
453
-
454
- /**
455
- * Emits if the replace item modal should be displayed from the product addition
456
- */
457
- additionModalOpen$: BehaviorSubject<boolean>;
458
-
459
- /**
460
- * Method to call when adding an item from the replace item modal
461
- */
462
- onSelectItem: (item: Item, searchString: string, onComplete?: (itemId?: string) => void, eventTrace?: EventTrace) => void;
463
-
464
- /**
465
- * Variable with the list of items with prices
466
- */
467
- itemsWithPricesList$: BehaviorSubject<{ item: Item; price: ProductPrice }[]>;
468
-
469
- /**
470
- * Emits if items are getting fetched
471
- */
472
- fetchingItemLoading$: BehaviorSubject<boolean>;
473
-
474
- /**
475
- * Emits the item that is being replaced
476
- */
477
- replaceItemLoading$: BehaviorSubject<Item>;
478
-
479
- /**
480
- * method to call to retrieve item from query
481
- */
482
- searchItem: (searchString: string) => Observable<void>;
483
- };
484
-
485
- // ---------------------------------------------------------------------------------------------------
486
-
487
- router: {
488
-
489
- /**
490
- * Retrieve retailer cart url
491
- */
492
- getRetailerCartUrl: () => string;
493
-
494
- /**
495
- * Retrieve catalog url
496
- */
497
- getCatalogUrl: () => string;
498
- };
499
-
500
-
501
- // ---------------------------------------------------------------------------------------------------
502
-
503
- products: {
504
- /**
505
- * Changes the quantity of a product or removes it from the basket if quantity is equal to 0
506
- */
507
- changeQuantity: (basketEntry: BasketEntry, quantity: number, path: string) => void;
508
-
509
- /**
510
- * Removes a product from the basket
511
- */
512
- removeProduct: (basketEntry: BasketEntry, path: string) => void;
513
-
514
- /**
515
- * Checks if a product is being updated
516
- */
517
- entryIsBeingUpdated: (entryId: string) => Observable<boolean>;
518
- };
519
-
520
- // ---------------------------------------------------------------------------------------------------
521
-
522
- pos: {
523
-
524
- /**
525
- * Fetches the current point of sale
526
- */
527
- currentPos: () => Observable<PointOfSale>;
528
-
529
- /**
530
- * Checks if the point of sale has been initialized
531
- */
532
- posWasInitialized: () => Observable<boolean>;
533
-
534
- /**
535
- * Loads the point of sale data for the given pos id
536
- */
537
- loadPos: (posId: string) => Observable<PointOfSale>;
538
-
539
- /**
540
- * Retrieves the updated basket after a new POS has been selected
541
- */
542
- basketLoadedForNewPos: () => Observable<Basket>;
543
- };
544
-
545
- // ---------------------------------------------------------------------------------------------------
546
-
547
- sponsor: {
548
-
549
- /**
550
- * Checks if a sponsor has storytelling content available
551
- */
552
- hasStorytelling: (sponsorId: string) => Observable<boolean>;
553
-
554
- /**
555
- * Retrieves all sponsor blocks associated with a given sponsor, sorted by position
556
- */
557
- getSponsorBlocks: (sponsorId: string) => Observable<SponsorBlock[]>;
558
118
  };
559
119
 
560
120
  // ---------------------------------------------------------------------------------------------------
@@ -565,21 +125,6 @@ export interface MealzInternalInterface {
565
125
  * Retrieves the token from the suppliers service
566
126
  */
567
127
  getToken: () => string;
568
-
569
- /**
570
- * Fetches the current supplier
571
- */
572
- currentSupplier: () => Observable<Supplier>;
573
-
574
- /**
575
- * Retrieves if the retailer is not a supplier
576
- */
577
- isNoSupplier: () => boolean;
578
-
579
- /**
580
- * Emits once the no-supplier mode has been resolved from `setupWithToken`.
581
- */
582
- noSupplier$: ReplaySubject<boolean>;
583
128
  };
584
129
 
585
130
  // ---------------------------------------------------------------------------------------------------
@@ -596,182 +141,11 @@ export interface MealzInternalInterface {
596
141
  */
597
142
  isAuthenticated: () => Observable<boolean>;
598
143
 
599
- /**
600
- * BehaviorSubject containing the user's geolocation coordinates
601
- */
602
- userCoordinates$: BehaviorSubject<GeolocationPosition>;
603
-
604
144
  /**
605
145
  * Updates the SDK's session ID to ensure consistency with SSR.
606
146
  */
607
147
  setSessionId: (sessionId: string) => void;
608
148
  };
609
149
 
610
- // ---------------------------------------------------------------------------------------------------
611
-
612
- storeLocator: {
613
-
614
- /**
615
- * Opens the store locator
616
- */
617
- open: () => void;
618
-
619
- /**
620
- * Opens the store locator / indicator warning modal
621
- */
622
- openWarning: () => void;
623
-
624
- /**
625
- * Closes the store locator
626
- */
627
- close: () => void;
628
-
629
- /**
630
- * Method to call to configure new pos and supplier
631
- */
632
- changePosAndSupplier: (e: CustomEvent, eventTrace: EventTrace) => void;
633
-
634
- /**
635
- * Notifies subscribers that a new store has been selected
636
- */
637
- newStoreSelected: () => void;
638
- };
639
-
640
- // ---------------------------------------------------------------------------------------------------
641
-
642
- productAddition: {
643
-
644
- /**
645
- * Opens the product addition modal
646
- */
647
- open: () => void;
648
-
649
- /**
650
- * Closes the product addition modal
651
- */
652
- close: () => void;
653
-
654
- /**
655
- * Emits an observable that notifies subscribers when a product has been added.
656
- */
657
- productAdded$: Observable<string>;
658
- };
659
-
660
- productReplacement: {
661
-
662
- /**
663
- * Opens the product replacement modal
664
- * @param product the product to replace
665
- */
666
- open: (product: BasketEntry) => void;
667
- };
668
-
669
- html: {
670
-
671
- /**
672
- * method that returns Like button HTML from SSR
673
- */
674
- like: (recipeId: string, path?: string, categoryId?: string) => Observable<string>;
675
- };
676
-
677
150
  getStickyHeaderHeight: () => Observable<number>;
678
-
679
- preferences: {
680
-
681
- /**
682
- * Returns the current number of preferences
683
- */
684
- preferencesCount: () => Observable<number>;
685
-
686
- /**
687
- * BehaviorSubject containing the current number of guests
688
- */
689
- guests$: BehaviorSubject<number>;
690
-
691
- /**
692
- * Resets the tags actions
693
- */
694
- resetTagsActions: () => void;
695
-
696
- /**
697
- * Checks if a tag should be checked based on its state
698
- */
699
- tagShouldBeChecked: (tag: Tag, isWithout: boolean) => boolean;
700
-
701
- /**
702
- * Resets all preferences to default values
703
- */
704
- resetPreferences: () => void;
705
-
706
- /**
707
- * Sends a cache request to the server
708
- */
709
- sendCacheRequest: (action: 'set' | 'remove', key: string, value?: any) => Observable<void>;
710
-
711
- /**
712
- * Current preferences stored in local storage
713
- */
714
- preferencesInStorage: () => { with: BasicPreference[]; without: BasicPreference[] };
715
-
716
- /**
717
- * Array of tags to be added
718
- */
719
- tagsToAdd: { tag: Tag; checked: boolean; without: boolean }[];
720
-
721
- /**
722
- * Adds a tag to preferences
723
- */
724
- addTag: (tag: { tag: Tag; checked: boolean; without: boolean }) => void;
725
-
726
- /**
727
- * Removes a tag from preferences
728
- */
729
- removeTag: (tag: { tag: Tag; checked: boolean; without: boolean }) => void;
730
-
731
- /**
732
- * Updates the preferences
733
- */
734
- updatePreferences: () => void;
735
-
736
- /**
737
- * Notifies that preferences have changed
738
- */
739
- preferencesChanged$: () => Observable<void>;
740
-
741
- /**
742
- * Emits an observable that notifies subscribers when the preferences have changed
743
- */
744
- preferencesChanged: () => void;
745
-
746
- /**
747
- * Adds preferences to remote filters
748
- */
749
- addPreferencesToRemoteFilters: (filters: object, includeGuests: boolean) => { include_tags?: string; exclude_tags?: string };
750
-
751
- /**
752
- * Adds a new tag from search to preferences
753
- */
754
- newTagFromSearch: (tag: Tag) => void;
755
- };
756
-
757
- tags: {
758
- all: (params: { remotefilter: { tag_type: string; for_supplier: string } }) => Observable<DocumentCollection<Tag>>;
759
- autocomplete: (query: string) => Observable<DocumentCollection<Tag>>;
760
- };
761
-
762
- /**
763
- * Set up a callback which Mealz will call before adding a recipe to the user's cart
764
- *
765
- * @param needLogin if true, Mealz will ask for login
766
- * @param needPos if true, Mealz will ask for a pos
767
- * @returns Observable<boolean> true if the operation can continue, false otherwise
768
- */
769
- hook: {
770
- hookCallback: (needLogin?: boolean, needPos?: boolean) => Observable<boolean>;
771
- };
772
-
773
- noSupplier: {
774
- addRecipeToBasketFromIdAndOpenPreview: (recipeId: string) => Observable<void>;
775
- displaySupplierSelector$: BehaviorSubject<boolean>;
776
- };
777
151
  }