ng-miam 10.6.0 → 10.6.1
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/bundles/ng-miam.umd.js +91 -28
- package/bundles/ng-miam.umd.js.map +1 -1
- package/bundles/ng-miam.umd.min.js +1 -1
- package/bundles/ng-miam.umd.min.js.map +1 -1
- package/esm2015/lib/_services/basket-utils.service.js +17 -3
- package/esm2015/lib/_services/baskets.service.js +66 -26
- package/esm2015/lib/_services/recipes.service.js +5 -2
- package/esm2015/lib/environments/environment.js +2 -2
- package/esm2015/lib/environments/environment.prod.js +2 -2
- package/esm2015/lib/environments/version.js +2 -2
- package/fesm2015/ng-miam.js +87 -30
- package/fesm2015/ng-miam.js.map +1 -1
- package/lib/_services/basket-utils.service.d.ts +2 -0
- package/lib/_services/basket-utils.service.d.ts.map +1 -1
- package/lib/_services/baskets.service.d.ts +8 -0
- package/lib/_services/baskets.service.d.ts.map +1 -1
- package/lib/_services/recipes.service.d.ts.map +1 -1
- package/lib/environments/version.d.ts +1 -1
- package/package.json +1 -1
package/bundles/ng-miam.umd.js
CHANGED
|
@@ -1640,7 +1640,7 @@
|
|
|
1640
1640
|
env: 'prod',
|
|
1641
1641
|
miamAPI: 'https://api.miam.tech',
|
|
1642
1642
|
miamWeb: 'https://miam.tech',
|
|
1643
|
-
mealzComponents: 'https://cdn.jsdelivr.net/npm/mealz-components@2.
|
|
1643
|
+
mealzComponents: 'https://cdn.jsdelivr.net/npm/mealz-components@2.11/dist',
|
|
1644
1644
|
mealzSsrApi: 'https://ssr-api.mealz.ai',
|
|
1645
1645
|
lang: 'fr',
|
|
1646
1646
|
analyticsEnabled: true // Only used in DEV mode
|
|
@@ -3648,7 +3648,7 @@
|
|
|
3648
3648
|
EventJourney["EMPTY"] = "";
|
|
3649
3649
|
})(EventJourney || (EventJourney = {}));
|
|
3650
3650
|
|
|
3651
|
-
var VERSION = "10.6.
|
|
3651
|
+
var VERSION = "10.6.1"; // TODO: replace by ##VERSION## and update it in the CI/CD
|
|
3652
3652
|
|
|
3653
3653
|
var ContextRegistryService = /** @class */ (function () {
|
|
3654
3654
|
function ContextRegistryService() {
|
|
@@ -5773,7 +5773,10 @@
|
|
|
5773
5773
|
RecipesService.prototype.getSuggestedRecipes = function () {
|
|
5774
5774
|
var _this = this;
|
|
5775
5775
|
var pref = this.buildfilterUrlFromPreferences();
|
|
5776
|
-
var
|
|
5776
|
+
var params = new URLSearchParams(pref ? pref.slice(1) : '');
|
|
5777
|
+
params.append('include', 'sponsors');
|
|
5778
|
+
params.append('fields[sponsors]', 'logo-url');
|
|
5779
|
+
var url = MIAM_API_HOST$2 + "recipes/suggest?" + params.toString();
|
|
5777
5780
|
return this.http.get(url, {
|
|
5778
5781
|
headers: {
|
|
5779
5782
|
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
@@ -6208,6 +6211,7 @@
|
|
|
6208
6211
|
_this.basketPreviewIsCalculating$ = new rxjs.BehaviorSubject(true);
|
|
6209
6212
|
_this.basketInitCalled = false;
|
|
6210
6213
|
_this.recipesAdded = new i0.EventEmitter();
|
|
6214
|
+
_this.recipesAddFailed = new i0.EventEmitter();
|
|
6211
6215
|
_this.confirming = new rxjs.BehaviorSubject(false);
|
|
6212
6216
|
_this.currentlyAddingRecipes = [];
|
|
6213
6217
|
_this.basketActionsQueue = new rxjs.BehaviorSubject([]);
|
|
@@ -6392,8 +6396,30 @@
|
|
|
6392
6396
|
return this.basket$.pipe(operators.skipWhile(function (b) { return !b; }), operators.map(function (basket) { return basket.hasRecipe(recipeId); }));
|
|
6393
6397
|
};
|
|
6394
6398
|
BasketsService.prototype.guestsForRecipe = function (recipeId) {
|
|
6399
|
+
return this.resolveGuestsForRecipe(recipeId);
|
|
6400
|
+
};
|
|
6401
|
+
BasketsService.prototype.resolveGuestsForRecipe = function (recipeId) {
|
|
6402
|
+
var _a;
|
|
6403
|
+
var guestsFromBasket = (_a = this.basket$.value) === null || _a === void 0 ? void 0 : _a.guestsForRecipe(recipeId);
|
|
6404
|
+
if (Number.isFinite(guestsFromBasket)) {
|
|
6405
|
+
return guestsFromBasket;
|
|
6406
|
+
}
|
|
6407
|
+
var pendingRecipeAction = __spread(this.actionsBeingProcessed.value, this.basketActionsQueue.value).find(function (action) { return (action.type === BasketActionType.ADD_RECIPE || action.type === BasketActionType.ADD_RECIPE_LIGHT) &&
|
|
6408
|
+
action.params.recipeId === recipeId &&
|
|
6409
|
+
Number.isFinite(action.params.guests); });
|
|
6410
|
+
return pendingRecipeAction === null || pendingRecipeAction === void 0 ? void 0 : pendingRecipeAction.params.guests;
|
|
6411
|
+
};
|
|
6412
|
+
/**
|
|
6413
|
+
* Waits until the given recipe is in the basket before resolving.
|
|
6414
|
+
* Emits `true` when the recipe is confirmed in the basket, `false` when its addition failed,
|
|
6415
|
+
* so callers can avoid firing dependent requests (e.g. add-ingredient) against a recipe that was never created.
|
|
6416
|
+
*/
|
|
6417
|
+
BasketsService.prototype.waitUntilRecipeInBasket = function (recipeId) {
|
|
6395
6418
|
var _a;
|
|
6396
|
-
|
|
6419
|
+
if (!recipeId || ((_a = this.basket$.value) === null || _a === void 0 ? void 0 : _a.hasRecipe(recipeId))) {
|
|
6420
|
+
return rxjs.of(true);
|
|
6421
|
+
}
|
|
6422
|
+
return rxjs.merge(this.basket$.pipe(operators.skipWhile(function (basket) { return !(basket === null || basket === void 0 ? void 0 : basket.hasRecipe(recipeId)); }), operators.take(1), operators.map(function () { return true; })), this.recipesAdded.pipe(operators.skipWhile(function (recipeIds) { return !recipeIds.includes(recipeId); }), operators.take(1), operators.map(function () { return true; })), this.recipesAddFailed.pipe(operators.skipWhile(function (recipeIds) { return !recipeIds.includes(recipeId); }), operators.take(1), operators.map(function () { return false; }))).pipe(operators.take(1));
|
|
6397
6423
|
};
|
|
6398
6424
|
BasketsService.prototype.showRecipeAddedToaster = function () {
|
|
6399
6425
|
var _this = this;
|
|
@@ -6774,8 +6800,11 @@
|
|
|
6774
6800
|
/** *************************************************** PROCESS THE ACTIONS QUEUE *************************************************** **/
|
|
6775
6801
|
BasketsService.prototype.emptyActionsQueue = function () {
|
|
6776
6802
|
var _this = this;
|
|
6777
|
-
if (this.basketActionsQueue.value.length > 0) {
|
|
6803
|
+
if (this.basketActionsQueue.value.length > 0 && this.actionsBeingProcessed.value.length === 0) {
|
|
6778
6804
|
var actionsToProcess_1 = this.nextActionsBatch();
|
|
6805
|
+
if (actionsToProcess_1.length === 0) {
|
|
6806
|
+
return;
|
|
6807
|
+
}
|
|
6779
6808
|
this.actionsBeingProcessed.next(__spread(actionsToProcess_1));
|
|
6780
6809
|
if (actionsToProcess_1.length > 0) {
|
|
6781
6810
|
this.processActionsBatch(actionsToProcess_1).subscribe(function () {
|
|
@@ -6791,14 +6820,16 @@
|
|
|
6791
6820
|
* @returns the next batch of actions to process
|
|
6792
6821
|
*/
|
|
6793
6822
|
BasketsService.prototype.nextActionsBatch = function () {
|
|
6823
|
+
var _this = this;
|
|
6824
|
+
var pendingActions = this.basketActionsQueue.value.filter(function (action) { return !_this.actionsBeingProcessed.value.includes(action); });
|
|
6794
6825
|
var batch = [];
|
|
6795
|
-
var
|
|
6796
|
-
var currentAction =
|
|
6826
|
+
var index = 0;
|
|
6827
|
+
var currentAction = pendingActions[index];
|
|
6797
6828
|
var shouldForceStop = false;
|
|
6798
|
-
while (
|
|
6799
|
-
currentAction =
|
|
6829
|
+
while (pendingActions[index] && pendingActions[index].type === currentAction.type && !shouldForceStop) {
|
|
6830
|
+
currentAction = pendingActions[index];
|
|
6800
6831
|
shouldForceStop = this.addActionToBatchOrStopProcessingBatch(batch, currentAction);
|
|
6801
|
-
|
|
6832
|
+
index++;
|
|
6802
6833
|
}
|
|
6803
6834
|
return batch;
|
|
6804
6835
|
};
|
|
@@ -6923,6 +6954,10 @@
|
|
|
6923
6954
|
return _this.http.post(postUrl, body).pipe(operators.switchMap(function (b) { var _a; return ((_a = b.data) === null || _a === void 0 ? void 0 : _a.id) ? _this.fillBasket(b) : rxjs.of(null); }), operators.tap(function () {
|
|
6924
6955
|
_this.recipesAdded.emit(recipeIds.map(function (r) { return r.recipe_id; }));
|
|
6925
6956
|
_this.currentlyAddingRecipes = _this.currentlyAddingRecipes.filter(function (id) { return !(_this.basket$.value.recipeInfos.find(function (i) { return i.id === id; })); });
|
|
6957
|
+
}), operators.catchError(function () {
|
|
6958
|
+
_this.currentlyAddingRecipes = _this.currentlyAddingRecipes.filter(function (recipeId) { return !recipeIds.some(function (candidate) { return candidate.recipe_id === recipeId; }); });
|
|
6959
|
+
_this.recipesAddFailed.emit(recipeIds.map(function (r) { return r.recipe_id; }));
|
|
6960
|
+
return rxjs.of(null);
|
|
6926
6961
|
}));
|
|
6927
6962
|
}), operators.catchError(function () { return rxjs.of(null); }));
|
|
6928
6963
|
};
|
|
@@ -6982,23 +7017,32 @@
|
|
|
6982
7017
|
*/
|
|
6983
7018
|
BasketsService.prototype.addItemsForIngredients = function (ingredientsToAdd) {
|
|
6984
7019
|
var _this = this;
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
return
|
|
6992
|
-
}
|
|
6993
|
-
return
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7020
|
+
var _a;
|
|
7021
|
+
var recipeId = (_a = ingredientsToAdd[0]) === null || _a === void 0 ? void 0 : _a.params.recipeId;
|
|
7022
|
+
return this.waitUntilRecipeInBasket(recipeId).pipe(operators.switchMap(function (recipeIsInBasket) {
|
|
7023
|
+
// The parent recipe add failed: skip add-ingredient to avoid a request against a recipe that was never created
|
|
7024
|
+
// (which would leave the retailer basket updated while Mealz stays out of sync).
|
|
7025
|
+
if (!recipeIsInBasket) {
|
|
7026
|
+
return rxjs.of(null);
|
|
7027
|
+
}
|
|
7028
|
+
return _this.waitForBasket.pipe(operators.switchMap(function (basket) {
|
|
7029
|
+
var requests = ingredientsToAdd.map(function (action) {
|
|
7030
|
+
var modifiedGuests = _this.resolveGuestsForRecipe(action.params.recipeId);
|
|
7031
|
+
var patchUrl = environment$1.miamAPI + "/api/v1/baskets/" + basket.id + "/basket-entries/" + action.params.basketEntry.id + "/add-ingredient" +
|
|
7032
|
+
("?ingredient_id=" + action.params.ingredientId + "&selected_item_id=" + action.params.basketEntry.selectedItem.id) +
|
|
7033
|
+
("&guests=" + modifiedGuests + "&forced_quantity=" + action.params.basketEntry.quantity);
|
|
7034
|
+
return _this.http.patch(patchUrl, {});
|
|
7035
|
+
});
|
|
7036
|
+
return rxjs.forkJoin(requests);
|
|
7037
|
+
}), operators.tap(function () {
|
|
7038
|
+
// Determine journey: item-replacement if previousItem exists (indicates replacement), otherwise meals-space-recipe-details
|
|
7039
|
+
var journey = ingredientsToAdd.some(function (action) { return action.params.previousItem; })
|
|
7040
|
+
? 'item-replacement'
|
|
7041
|
+
: 'meals-space-recipe-details';
|
|
7042
|
+
_this.analyticsService.sendAddProductsEvents(ingredientsToAdd, journey);
|
|
7043
|
+
}), operators.switchMap(function () { return _this.reloadBasket(); }), operators.switchMap(function () { return rxjs.of(null); }) // Just to keep the return type as Observable<void> to match with the other methods
|
|
7044
|
+
);
|
|
7045
|
+
}), operators.catchError(function () { return rxjs.of(null); }));
|
|
7002
7046
|
};
|
|
7003
7047
|
/**
|
|
7004
7048
|
* Add items to the basket HTTP request.
|
|
@@ -8616,17 +8660,27 @@
|
|
|
8616
8660
|
|
|
8617
8661
|
var BasketUtilsService = /** @class */ (function () {
|
|
8618
8662
|
function BasketUtilsService(basketsService, recipesService, priceService, basketSynchroService, analyticsService, loadLitDrawerService) {
|
|
8663
|
+
var _this = this;
|
|
8619
8664
|
this.basketsService = basketsService;
|
|
8620
8665
|
this.recipesService = recipesService;
|
|
8621
8666
|
this.priceService = priceService;
|
|
8622
8667
|
this.basketSynchroService = basketSynchroService;
|
|
8623
8668
|
this.analyticsService = analyticsService;
|
|
8624
8669
|
this.loadLitDrawerService = loadLitDrawerService;
|
|
8670
|
+
this.removeRecipeJobs$ = new rxjs.Subject();
|
|
8625
8671
|
this.recipesWithEntries = [];
|
|
8626
8672
|
this.basketPreviewState$ = new rxjs.BehaviorSubject({
|
|
8627
8673
|
isOpen: false,
|
|
8628
8674
|
activeTabIndex: 0 // Default to the first tab (recipes)
|
|
8629
8675
|
});
|
|
8676
|
+
this.removeRecipeJobs$.pipe(operators.concatMap(function (_a) {
|
|
8677
|
+
var recipeId = _a.recipeId, analyticsPath = _a.analyticsPath, result$ = _a.result$;
|
|
8678
|
+
return _this.removeRecipeInternal(recipeId, analyticsPath).pipe(operators.tap({
|
|
8679
|
+
next: function (value) { return result$.next(value); },
|
|
8680
|
+
error: function (error) { return result$.error(error); },
|
|
8681
|
+
complete: function () { return result$.complete(); }
|
|
8682
|
+
}), operators.catchError(function () { return rxjs.EMPTY; }));
|
|
8683
|
+
})).subscribe();
|
|
8630
8684
|
}
|
|
8631
8685
|
/**
|
|
8632
8686
|
* Builds a preview of recipes in the basket, including their total price and total number of products per recipe.
|
|
@@ -8652,6 +8706,15 @@
|
|
|
8652
8706
|
});
|
|
8653
8707
|
};
|
|
8654
8708
|
BasketUtilsService.prototype.removeRecipe = function (recipeId, analyticsPath) {
|
|
8709
|
+
var _this = this;
|
|
8710
|
+
return new rxjs.Observable(function (subscriber) {
|
|
8711
|
+
var result$ = new rxjs.Subject();
|
|
8712
|
+
var resultSubscription = result$.subscribe(subscriber);
|
|
8713
|
+
_this.removeRecipeJobs$.next({ recipeId: recipeId, analyticsPath: analyticsPath, result$: result$ });
|
|
8714
|
+
return function () { return resultSubscription.unsubscribe(); };
|
|
8715
|
+
});
|
|
8716
|
+
};
|
|
8717
|
+
BasketUtilsService.prototype.removeRecipeInternal = function (recipeId, analyticsPath) {
|
|
8655
8718
|
var _this = this;
|
|
8656
8719
|
return this.fetchDataToRemoveRecipe(recipeId).pipe(operators.switchMap(function (_a) {
|
|
8657
8720
|
var recipe = _a.recipe, basketEntries = _a.basketEntries;
|
|
@@ -13391,7 +13454,7 @@
|
|
|
13391
13454
|
env: 'prod',
|
|
13392
13455
|
miamAPI: 'https://api.miam.tech',
|
|
13393
13456
|
miamWeb: 'https://miam.tech',
|
|
13394
|
-
mealzComponents: 'https://cdn.jsdelivr.net/npm/mealz-components@2.
|
|
13457
|
+
mealzComponents: 'https://cdn.jsdelivr.net/npm/mealz-components@2.11/dist',
|
|
13395
13458
|
mealzSsrApi: 'https://ssr-api.mealz.ai',
|
|
13396
13459
|
lang: 'fr',
|
|
13397
13460
|
analyticsEnabled: true // Only used in DEV mode
|