webc-miam 8.7.0 → 9.0.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.
@@ -253,6 +253,9 @@ licenses; we recommend you read them, as their terms may differ from the
253
253
  terms above.
254
254
 
255
255
 
256
+ mealz-shared-analytics
257
+ GNU GPLv3
258
+
256
259
  miam-jsonapi
257
260
 
258
261
  regenerator-runtime
@@ -1,24 +1,24 @@
1
1
  /**
2
- * An interface used to represent a product when Miam synchronizes the client's cart with
3
- * Miam's basket, and need to compare products present in each one.
2
+ * An interface used to represent a product when Mealz synchronizes the client's cart with
3
+ * Mealz's basket, and need to compare products present in each one.
4
4
  */
5
5
  export interface ComparableProduct {
6
6
  /**
7
- * Id of the product in the client's database (called ext-id on Miam's end).
7
+ * Id of the product in the client's database (called ext-id on Mealz's end).
8
8
  */
9
9
  id: string;
10
10
  /**
11
- * When client side sends an array of ComparableProduct to Miam, the SDK expects quantities
11
+ * When client side sends an array of ComparableProduct to Mealz, the SDK expects quantities
12
12
  * to match the quantity of each product in the cart of the client.
13
13
  *
14
- * When Miam sends an array of ComparableProducts to the client, quantities represent the quantity
14
+ * When Mealz sends an array of ComparableProducts to the client, quantities represent the quantity
15
15
  * of products to add to the client's cart, and as such can be negatives if products need to be
16
16
  * removed from the cart.
17
17
  */
18
18
  quantity: number;
19
19
  /**
20
20
  * The client can add attributes if they need when sending ComparableProducts to the SDK.
21
- * Miam will send the attributes back if changes are to be made about those products.
21
+ * Mealz will send the attributes back if changes are to be made about those products.
22
22
  */
23
23
  additionalInfos?: any;
24
24
  }
@@ -1,10 +1,10 @@
1
1
  import { EventEmitter } from '@angular/core';
2
- import { Observable } from 'rxjs';
3
- import { ComparableProduct } from './comparable-product';
4
2
  import { DocumentCollection } from 'miam-jsonapi';
3
+ import { Observable } from 'rxjs';
5
4
  import { PointOfSale, Supplier } from '../../_models';
5
+ import { ComparableProduct } from './comparable-product';
6
6
 
7
- export interface MiamInterface {
7
+ export interface MealzInterface {
8
8
  /**
9
9
  * Method to call when the user begins the payment procedure (typically when they click
10
10
  * on a "Confirm my cart" button)
@@ -19,9 +19,8 @@ export interface MiamInterface {
19
19
  * Initialize Analytics
20
20
  *
21
21
  * @param domain Plausible domain
22
- * @param optimizeKey Google Optimize key
23
22
  */
24
- init: (domain: string, _optimizeKey: string) => void;
23
+ init: (domain: string) => void;
25
24
 
26
25
  /**
27
26
  * Observable on events as a string sent from Analytics
@@ -38,28 +37,28 @@ export interface MiamInterface {
38
37
 
39
38
  basket: {
40
39
  /**
41
- * Emits true when Miam's basket has succesfully loaded for the first time.
40
+ * Emits true when Mealz's basket has succesfully loaded for the first time.
42
41
  * Does not emit anything before or after that.
43
42
  */
44
43
  basketIsReady$: Observable<boolean>;
45
44
  /**
46
- * Fetch the first Basket early (before any action requires it on Miam's
45
+ * Fetch the first Basket early (before any action requires it on Mealz's
47
46
  * side), so you can start the basket-sync earlier
48
47
  */
49
48
  initialize: () => void;
50
49
  /**
51
- * Resets Miam's basket : empties all products & recipes added by the user
50
+ * Resets Mealz's basket : empties all products & recipes added by the user
52
51
  * /!\ We heavily recommend not to use this method except in the console for testing purposes /!\
53
52
  */
54
53
  reset: () => void;
55
54
  /**
56
55
  * If you have different price tables (or pricebooks) for the same point of sale, you can call this
57
- * method to make Miam know on which pricebook you are using
56
+ * method to make Mealz know on which pricebook you are using
58
57
  * For example, prices can be different depending on if the user chose home delivery or drive-in
59
58
  */
60
59
  updatePricebook: (pricebookName: string) => Observable<void>;
61
60
  /**
62
- * @returns A BehaviorSubject that emits the current number of recipes in Miam's Basket
61
+ * @returns A BehaviorSubject that emits the current number of recipes in Mealz's Basket
63
62
  */
64
63
  recipeCount: () => Observable<number>;
65
64
  /**
@@ -77,28 +76,28 @@ export interface MiamInterface {
77
76
 
78
77
  basketSync: {
79
78
  /**
80
- * The callback parameter is called when Miam's basket changes to update the user's cart accordingly
79
+ * The callback parameter is called when Mealz's basket changes to update the user's cart accordingly
81
80
  *
82
- * @param pushProductsToBasket a method that updates the user's cart with the pruducts passed in parameter, by adding
81
+ * @param pushProductsToCart a method that updates the user's cart with the pruducts passed in parameter, by adding
83
82
  * products if their quantity is positive, and removing them if their quantity is negative
84
83
  */
85
- definePushProductsToBasket: (pushProductsToBasket: (products: ComparableProduct[]) => void) => void;
84
+ definePushProductsToCart: (pushProductsToCart: (products: ComparableProduct[]) => void) => void;
86
85
  /**
87
- * The callback parameter is called when Miam's basket changes to update the user's cart accordingly
86
+ * The callback parameter is called when Mealz's basket changes to update the user's cart accordingly
88
87
  *
89
- * @param pushProductsToBasket a method that updates the user's cart with the pruducts passed in parameter, by adding
88
+ * @param pushProductsToCart a method that updates the user's cart with the pruducts passed in parameter, by adding
90
89
  * products if their quantity is positive, and removing them if their quantity is negative
91
90
  */
92
- definePushBasketEntriesToBasket: (pushProductsToBasket: (products: ComparableProduct[]) => void) => void;
91
+ definePushBasketEntriesToBasket: (pushProductsToCart: (products: ComparableProduct[]) => void) => void;
93
92
  /**
94
- * Call to notify Miam that the user's cart has been updated
93
+ * Call to notify Mealz that the user's cart has been updated
95
94
  *
96
95
  * @param comparableProducts The products in the user's cart
97
96
  */
98
97
  retailerBasketChanged: (comparableProducts: ComparableProduct[]) => void;
99
98
  /**
100
- * Call to notify Miam that the user's cart was paid
101
- * Miam then refreshes the basket for the next user's cart
99
+ * Call to notify Mealz that the user's cart was paid
100
+ * Mealz then refreshes the basket for the next user's cart
102
101
  *
103
102
  * @param total The total price of the cart paid
104
103
  */
@@ -117,7 +116,7 @@ export interface MiamInterface {
117
116
  */
118
117
  enableArticlesInCatalog: () => void;
119
118
  /**
120
- * Call to authorize Miam to ask for user preferences the first time users view the recipe catalog
119
+ * Call to authorize Mealz to ask for user preferences the first time users view the recipe catalog
121
120
  */
122
121
  enableUserPreferences: () => void;
123
122
  /**
@@ -155,17 +154,17 @@ export interface MiamInterface {
155
154
 
156
155
  hook: {
157
156
  /**
158
- * Set up a callback which Miam will call before adding a recipe to the user's cart
157
+ * Set up a callback which Mealz will call before adding a recipe to the user's cart
159
158
  *
160
159
  * @param callback a method that will be called passing two parameters :
161
- * - isLogged, true if the user is logged (according to Miam, see user.loadWithExtId for more)
162
- * - isPosValid true if the PointOfSale is recognized by Miam
160
+ * - isLogged, true if the user is logged (according to Mealz, see user.loadWithExtId for more)
161
+ * - isPosValid true if the PointOfSale is recognized by Mealz
163
162
  * Typically you might want to use this to show your connexion page if the user tries to add a recipe while logged out
164
163
  * or to show your point of sale picker if the user has not chosen one
165
164
  */
166
165
  setHookCallback: (callback: (isLogged, isPosValid) => boolean) => void;
167
166
  /**
168
- * Set up a callback which Miam will call when it needs to force the POS
167
+ * Set up a callback which Mealz will call when it needs to force the POS
169
168
  * (only used when tranfering a basket from an affiliated website)
170
169
  *
171
170
  * @param callback a method that will be called passing :
@@ -178,7 +177,7 @@ export interface MiamInterface {
178
177
 
179
178
  pos: {
180
179
  /**
181
- * Call to inform Miam of the point of sale the user is currently on. Do not forget to call the method
180
+ * Call to inform Mealz of the point of sale the user is currently on. Do not forget to call the method
182
181
  * if it changes after user loads the page
183
182
  *
184
183
  * @param externalId the id of the PointOfSale in client's database
@@ -247,19 +246,19 @@ export interface MiamInterface {
247
246
 
248
247
  router: {
249
248
  /**
250
- * Inform Miam of the url where the catalog is for the redirection link of recipe-details
249
+ * Inform Mealz of the url where the catalog is for the redirection link of recipe-details
251
250
  */
252
251
  setRecipeCatalogUrl: (url?: string) => void;
253
252
  /**
254
- * Inform Miam of the url where the onboarding section of the catalog should redirect
253
+ * Inform Mealz of the url where the onboarding section of the catalog should redirect
255
254
  */
256
255
  setRecipeInfoLink: (url?: string) => void;
257
256
  /**
258
- * Inform Miam of the url of the retailer's if Miam needs to redirect there
257
+ * Inform Mealz of the url of the retailer's if Mealz needs to redirect there
259
258
  */
260
259
  setRetailerCartUrl: (url?: string) => void;
261
260
  /**
262
- * Inform Miam of the url where the promotions are
261
+ * Inform Mealz of the url where the promotions are
263
262
  */
264
263
  setPromotionsUrl: (url?: string) => void;
265
264
  };
@@ -269,15 +268,15 @@ export interface MiamInterface {
269
268
  supplier: {
270
269
  /**
271
270
  * /!\ This needs to be the first method called, because nothing will work if the origin isn't set
272
- * @param origin an identifier string that Miam passes to the API with each request to keep track of the origin
271
+ * @param origin an identifier string that Mealz passes to the API with each request to keep track of the origin
273
272
  * of the request
274
273
  */
275
274
  setOrigin: (origin: string) => void;
276
275
  /**
277
- * Call to inform Miam of the supplier the user is currently on. Do not forget to call the method
276
+ * Call to inform Mealz of the supplier the user is currently on. Do not forget to call the method
278
277
  * if it changes after user loads the page (should not happen escept in very specific cases)
279
278
  *
280
- * @param supplierId the Supplier id in Miam's database
279
+ * @param supplierId the Supplier id in Mealz's database
281
280
  */
282
281
  load: (supplierId: number | string) => void;
283
282
  /**
@@ -293,7 +292,7 @@ export interface MiamInterface {
293
292
 
294
293
  user: {
295
294
  /**
296
- * Call to inform Miam of the id of the user.
295
+ * Call to inform Mealz of the id of the user.
297
296
  *
298
297
  * @param id a string unique identifier to the user
299
298
  * @param forbidProfiling if set to true, desactivate personalized content (personalized recipes & products)
@@ -302,9 +301,16 @@ export interface MiamInterface {
302
301
  */
303
302
  loadWithExternalId: (id: string, forbidProfiling?: boolean, initBasket?: boolean) => Observable<object>;
304
303
  /**
305
- * Call to inform Miam that the user has logged out
304
+ * Call to inform Mealz that the user has logged out
306
305
  */
307
306
  reset: () => void;
307
+
308
+ /**
309
+ * Set user language with a ISO 639-1 code or custom language name
310
+ * @param lang
311
+ */
312
+ setLanguage: (lang: string) => void;
313
+
308
314
  /**
309
315
  * If your website has a "favorite products" feature, you can pass the ids of all products
310
316
  * which the user has marked as favorites, so they can be prioritized when adding a recipe
@@ -0,0 +1,105 @@
1
+ import { Observable } from 'rxjs';
2
+ import { BasketEntry, Recipe } from '../../_models';
3
+ import { RecipePricing } from '../../_models/recipe-pricing';
4
+
5
+ export interface MealzInternalInterface {
6
+
7
+ // ---------------------------------------------------------------------------------------------------
8
+
9
+ basket: {
10
+
11
+ /**
12
+ * Emits the list of recipe IDs when recipes are added to the basket.
13
+ */
14
+ recipesAddedToBasket$: () => Observable<string[]>;
15
+
16
+ /**
17
+ * Emits the pricing information for recipes in the basket.
18
+ */
19
+ recipePricesInBasket$: () => Observable<{ id: string; price: string }[]>;
20
+
21
+ /**
22
+ * Emits the list of recipes in the basket.
23
+ */
24
+ waitForBasketEntries: () => Observable<BasketEntry[]>;
25
+ };
26
+
27
+ // ---------------------------------------------------------------------------------------------------
28
+
29
+ catalog: {
30
+ /**
31
+ * Opens filter modal
32
+ */
33
+ openFilters: () => void;
34
+
35
+ /**
36
+ * Opens preferences modal
37
+ */
38
+ openPreferences: () => void;
39
+
40
+ loadMoreRecipes: (packageId: string, page: number, pageSize: number, guests: number) => Observable<Recipe[]>;
41
+ };
42
+
43
+ // ---------------------------------------------------------------------------------------------------
44
+
45
+ recipes: {
46
+ /**
47
+ * Opens the recipe details by calling the `openRecipeDetails` method of the `recipesService`.
48
+ */
49
+ openDetails: (recipeId: string, guests: number) => void;
50
+
51
+ /**
52
+ * Updates or creates a recipe like entry.
53
+ * If `recipeLikeId` is provided, it updates the existing like; otherwise, it creates a new one.
54
+ * It also sets the `isPast` status and tracks the update event.
55
+ */
56
+ updateRecipeLike: (recipeLikeId: string, recipeId: string, isPast: boolean, recipe: any) => void;
57
+
58
+ /**
59
+ * Emits an observable that notifies subscribers when a recipe like has been updated.
60
+ */
61
+ recipeLikeUpdated: () => Observable<{ id: string; isPast: boolean }>;
62
+
63
+ /**
64
+ * Emits an observable that notifies subscribers when the number of guests of a recipe has been updated from recipe details.
65
+ */
66
+ guestsUpdated: () => Observable<{ guests: number; recipeId: string }>;
67
+
68
+ /**
69
+ * Emits an observable that notifies subscribers when a recipe price has been updated.
70
+ */
71
+ recipePriceUpdated: () => Observable<{ remaining: number; inBasket: number; recipeId: string }>;
72
+
73
+ /**
74
+ * Fetches the pricing information for a specific recipe based on the provided parameters.
75
+ */
76
+ fetchPricing: (recipeId: string, posId: string, pricebookKey: string, serves: number) => Observable<RecipePricing>;
77
+ };
78
+
79
+ // ---------------------------------------------------------------------------------------------------
80
+
81
+ supplier: {
82
+
83
+ /**
84
+ * Retrieves the token from the suppliers service
85
+ */
86
+ getToken: () => string;
87
+ };
88
+
89
+ // ---------------------------------------------------------------------------------------------------
90
+
91
+ user: {
92
+
93
+ /**
94
+ * Retrieve user language as an ISO 639-1 code or custom code
95
+ */
96
+ getLanguage: () => string;
97
+
98
+ /**
99
+ * Retrieves the current authentication status of the user.
100
+ */
101
+ isAuthenticated: () => Observable<boolean>;
102
+ };
103
+
104
+ getStickyHeaderHeight: () => Observable<number>;
105
+ }