ng-miam 10.5.4 → 10.5.7

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.
Files changed (36) hide show
  1. package/bundles/ng-miam.umd.js +77 -32
  2. package/bundles/ng-miam.umd.js.map +1 -1
  3. package/bundles/ng-miam.umd.min.js +1 -1
  4. package/bundles/ng-miam.umd.min.js.map +1 -1
  5. package/esm2015/lib/_services/basket-utils.service.js +10 -7
  6. package/esm2015/lib/_services/baskets.service.js +6 -4
  7. package/esm2015/lib/_services/context.service.js +2 -2
  8. package/esm2015/lib/_services/http-utils.service.js +10 -2
  9. package/esm2015/lib/_services/new-recipe-details.service.js +2 -2
  10. package/esm2015/lib/_services/no-supplier-add-to-cart-cta.service.js +8 -8
  11. package/esm2015/lib/_services/replace-item.service.js +8 -8
  12. package/esm2015/lib/_services/suppliers.service.js +9 -1
  13. package/esm2015/lib/_services/user.service.js +9 -1
  14. package/esm2015/lib/_web-components/basket-preview/basket-preview-product/basket-preview-product.component.js +2 -2
  15. package/esm2015/lib/_web-components/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.component.js +15 -10
  16. package/esm2015/lib/environments/environment.js +2 -2
  17. package/esm2015/lib/environments/environment.prod.js +2 -2
  18. package/esm2015/lib/environments/version.js +2 -2
  19. package/fesm2015/ng-miam.js +66 -34
  20. package/fesm2015/ng-miam.js.map +1 -1
  21. package/lib/_services/basket-utils.service.d.ts +1 -1
  22. package/lib/_services/basket-utils.service.d.ts.map +1 -1
  23. package/lib/_services/baskets.service.d.ts +1 -1
  24. package/lib/_services/baskets.service.d.ts.map +1 -1
  25. package/lib/_services/http-utils.service.d.ts +2 -0
  26. package/lib/_services/http-utils.service.d.ts.map +1 -1
  27. package/lib/_services/no-supplier-add-to-cart-cta.service.d.ts.map +1 -1
  28. package/lib/_services/replace-item.service.d.ts.map +1 -1
  29. package/lib/_services/suppliers.service.d.ts +4 -1
  30. package/lib/_services/suppliers.service.d.ts.map +1 -1
  31. package/lib/_services/user.service.d.ts +4 -1
  32. package/lib/_services/user.service.d.ts.map +1 -1
  33. package/lib/_web-components/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.component.d.ts +6 -5
  34. package/lib/_web-components/no-supplier-add-to-cart-cta/no-supplier-add-to-cart-cta.component.d.ts.map +1 -1
  35. package/lib/environments/version.d.ts +1 -1
  36. package/package.json +1 -1
@@ -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.8/dist',
1643
+ mealzComponents: 'https://cdn.jsdelivr.net/npm/mealz-components@2.9/dist',
1644
1644
  mealzSsrApi: 'https://ssr-api.mealz.ai',
1645
1645
  lang: 'fr',
1646
1646
  analyticsEnabled: true // Only used in DEV mode
@@ -3115,10 +3115,22 @@
3115
3115
  _this.type = 'suppliers';
3116
3116
  _this.supplier$ = new rxjs.BehaviorSubject(null);
3117
3117
  _this.lastSupplierCart = []; // Stock the last retailer's cart for external purposes
3118
+ _this.token$ = new rxjs.BehaviorSubject(null);
3118
3119
  _this.url = environment$1.miamAPI + "/api/v1";
3119
3120
  _this.register();
3120
3121
  return _this;
3121
3122
  }
3123
+ Object.defineProperty(SuppliersService.prototype, "token", {
3124
+ get: function () {
3125
+ return this._token;
3126
+ },
3127
+ set: function (value) {
3128
+ this._token = value;
3129
+ this.token$.next(value);
3130
+ },
3131
+ enumerable: false,
3132
+ configurable: true
3133
+ });
3122
3134
  SuppliersService.prototype.loadSupplier = function (supplierId) {
3123
3135
  var _this = this;
3124
3136
  this.supplier$.next(null);
@@ -3440,7 +3452,7 @@
3440
3452
  EventJourney["EMPTY"] = "";
3441
3453
  })(EventJourney || (EventJourney = {}));
3442
3454
 
3443
- var VERSION = "10.5.4"; // TODO: replace by ##VERSION## and update it in the CI/CD
3455
+ var VERSION = "10.5.7"; // TODO: replace by ##VERSION## and update it in the CI/CD
3444
3456
 
3445
3457
  var ContextRegistryService = /** @class */ (function () {
3446
3458
  function ContextRegistryService() {
@@ -3917,6 +3929,7 @@
3917
3929
  this.suppliersService = suppliersService;
3918
3930
  this.toasterService = toasterService;
3919
3931
  this.ignoredBasketsService = ignoredBasketsService;
3932
+ this.language$ = new rxjs.BehaviorSubject(null);
3920
3933
  this.isLogged$ = new rxjs.BehaviorSubject(false);
3921
3934
  this.preferencesActivated$ = new rxjs.BehaviorSubject(false);
3922
3935
  this.generatingAuthlessId$ = new rxjs.BehaviorSubject(false);
@@ -3926,6 +3939,17 @@
3926
3939
  this.userProvider$ = new rxjs.BehaviorSubject(undefined);
3927
3940
  this.userSupplier$ = new rxjs.BehaviorSubject(undefined);
3928
3941
  }
3942
+ Object.defineProperty(UserService.prototype, "language", {
3943
+ get: function () {
3944
+ return this._language;
3945
+ },
3946
+ set: function (value) {
3947
+ this._language = value;
3948
+ this.language$.next(value);
3949
+ },
3950
+ enumerable: false,
3951
+ configurable: true
3952
+ });
3929
3953
  Object.defineProperty(UserService.prototype, "userProvider", {
3930
3954
  get: function () {
3931
3955
  return this.userProvider$.pipe(operators.skipWhile(function (provider) { return provider === undefined; }));
@@ -4448,6 +4472,16 @@
4448
4472
  }
4449
4473
  return headers;
4450
4474
  };
4475
+ HttpUtilsService.prototype.waitForSsrHeaders = function () {
4476
+ var _this = this;
4477
+ return rxjs.combineLatest([
4478
+ this.suppliersService.token$,
4479
+ this.userService.language$
4480
+ ]).pipe(operators.filter(function (_a) {
4481
+ var _b = __read(_a, 2), supplierToken = _b[0], languageId = _b[1];
4482
+ return !!supplierToken && !!languageId;
4483
+ }), operators.take(1), operators.map(function () { return _this.buildHeaders(); }));
4484
+ };
4451
4485
  return HttpUtilsService;
4452
4486
  }());
4453
4487
  HttpUtilsService.ɵfac = function HttpUtilsService_Factory(t) { return new (t || HttpUtilsService)(i0__namespace.ɵɵinject(SuppliersService), i0__namespace.ɵɵinject(UserService)); };
@@ -6482,11 +6516,12 @@
6482
6516
  }); });
6483
6517
  this.basketActionsQueue.next(toAdd);
6484
6518
  };
6485
- BasketsService.prototype.addItemToBasket = function (item, eventTrace, previousItem) {
6519
+ BasketsService.prototype.addItemToBasket = function (item, eventTrace, previousItem, forcedQuantity) {
6520
+ if (forcedQuantity === void 0) { forcedQuantity = 1; }
6486
6521
  var toAdd = this.basketActionsQueue.value;
6487
6522
  toAdd.push({
6488
6523
  type: BasketActionType.ADD_ITEM,
6489
- params: { item: item, eventTrace: eventTrace, previousItem: previousItem }
6524
+ params: { item: item, eventTrace: eventTrace, previousItem: previousItem, forcedQuantity: forcedQuantity }
6490
6525
  });
6491
6526
  this.basketActionsQueue.next(toAdd);
6492
6527
  };
@@ -6775,9 +6810,11 @@
6775
6810
  var _this = this;
6776
6811
  return this.waitForBasket.pipe(operators.switchMap(function (basket) {
6777
6812
  var requests = itemsToAdd.map(function (action) {
6813
+ var forcedQuantity = action.params.forcedQuantity || 1;
6778
6814
  var postUrl = environment$1.miamAPI + "/api/v1/baskets/" + basket.id + "/basket-entries/from-item" +
6779
6815
  ("?include=selected-item&selected_item_id=" + action.params.item.id) +
6780
- ("&name=" + action.params.item.attributes.name);
6816
+ ("&name=" + action.params.item.attributes.name) +
6817
+ ("&forced_quantity=" + forcedQuantity);
6781
6818
  return _this.http.post(encodeURI(postUrl.trim()), {});
6782
6819
  });
6783
6820
  // NOT WORKING AS ITEM AND NOT BASKET ENTRY
@@ -8420,13 +8457,16 @@
8420
8457
  var recipe = _a.recipe, basketEntries = _a.basketEntries;
8421
8458
  var filteredProducts = _this.buildRemoveProducts(recipe, basketEntries);
8422
8459
  var recipeRemoveActions = _this.buildRemoveActions(filteredProducts);
8423
- if (recipeRemoveActions.length !== 0) {
8424
- _this.basketSynchroService.addToActionList(recipeRemoveActions);
8425
- return recipeRemoveActions[recipeRemoveActions.length - 1].onSuccess.pipe(operators.take(1), operators.switchMap(function () { return _this.removeRecipeFromBasket(filteredProducts, recipeId, analyticsPath); }));
8426
- }
8427
- else {
8460
+ if (recipeRemoveActions.length === 0) {
8428
8461
  return _this.basketsService.removeRecipeById(recipeId, analyticsPath);
8429
8462
  }
8463
+ return new rxjs.Observable(function (observer) {
8464
+ var onSuccesses = rxjs.forkJoin(recipeRemoveActions.map(function (action) { return action.onSuccess.pipe(operators.take(1)); })).pipe(operators.switchMap(function () { return _this.removeRecipeFromBasket(filteredProducts, recipeId, analyticsPath); }));
8465
+ var onFailures = rxjs.merge.apply(void 0, __spread(recipeRemoveActions.map(function (action) { return action.onTimeout; }), recipeRemoveActions.map(function (action) { return action.onError; }))).pipe(operators.take(1), operators.switchMap(function () { return rxjs.throwError('Basket sync remove recipe failed'); }));
8466
+ var subscription = rxjs.merge(onSuccesses, onFailures).pipe(operators.take(1)).subscribe(observer);
8467
+ _this.basketSynchroService.addToActionList(recipeRemoveActions);
8468
+ return function () { return subscription.unsubscribe(); };
8469
+ });
8430
8470
  }));
8431
8471
  };
8432
8472
  BasketUtilsService.prototype.removeProduct = function (basketEntry, eventTrace) {
@@ -9736,7 +9776,7 @@
9736
9776
  .subscribe(function (action) {
9737
9777
  action.onSuccess.pipe(operators.take(1)).subscribe(function () {
9738
9778
  _this.recipeDetailsService.hasReplaced = true;
9739
- if (eventTrace && fromRecipeDetails) {
9779
+ if (eventTrace && fromRecipeDetails && !_this.addProductMode) {
9740
9780
  _this.sendReplaceEvent(searchString, eventTrace);
9741
9781
  }
9742
9782
  if (_this.addProductMode || !fromRecipeDetails) {
@@ -9754,6 +9794,7 @@
9754
9794
  });
9755
9795
  }
9756
9796
  });
9797
+ _this.basketSynchroService.addToActionList([action]);
9757
9798
  });
9758
9799
  };
9759
9800
  /**
@@ -9767,7 +9808,7 @@
9767
9808
  */
9768
9809
  ReplaceItemService.prototype.onSelectItem = function (item, searchString, eventTrace) {
9769
9810
  if (this.addProductMode) {
9770
- return this.handleAddProductMode(item, this.basketEntry, eventTrace);
9811
+ return this.handleAddProductMode(item, eventTrace);
9771
9812
  }
9772
9813
  return this.handleReplaceProductMode(item, this.basketEntry, this.ingredient, searchString, eventTrace, this.ignoreSelected);
9773
9814
  };
@@ -9820,10 +9861,12 @@
9820
9861
  * Handles any errors by rolling back the operation.
9821
9862
  * Adds the action to the synchronization service's action list for processing.
9822
9863
  */
9823
- ReplaceItemService.prototype.handleAddProductMode = function (item, basketEntry, eventTrace) {
9864
+ ReplaceItemService.prototype.handleAddProductMode = function (item, eventTrace) {
9824
9865
  var _this = this;
9825
9866
  this.replaceItemLoading$.next(item);
9826
- var newBasketEntry = deepCloneWithClass(basketEntry);
9867
+ var newBasketEntry = new BasketEntry();
9868
+ newBasketEntry.quantity = 1;
9869
+ newBasketEntry.quantityToAdd = 0;
9827
9870
  this.replaceRelationship(newBasketEntry, item);
9828
9871
  var addIngredientWithoutRecipe = new AddIngredientAction(newBasketEntry, { eventTrace: eventTrace, item: item }, this.basketsService, this.basketEntriesService);
9829
9872
  rxjs.merge(addIngredientWithoutRecipe.onTimeout, addIngredientWithoutRecipe.onError)
@@ -9831,7 +9874,6 @@
9831
9874
  .subscribe(function () {
9832
9875
  _this.rollbackReplace();
9833
9876
  });
9834
- this.basketSynchroService.addToActionList([addIngredientWithoutRecipe]);
9835
9877
  return rxjs.of(addIngredientWithoutRecipe);
9836
9878
  };
9837
9879
  /**
@@ -9888,7 +9930,6 @@
9888
9930
  rxjs.merge(addIngredientFromReplace.onTimeout, addIngredientFromReplace.onError).pipe(operators.take(1)).subscribe(function () {
9889
9931
  _this.rollbackReplace();
9890
9932
  });
9891
- _this.basketSynchroService.addToActionList([addIngredientFromReplace]);
9892
9933
  addIngredientFromReplace.onSuccess.pipe(operators.take(1)).subscribe(function () {
9893
9934
  _this.recipeDetailsService.updateIngredientFromBasketLoading = false;
9894
9935
  });
@@ -9964,7 +10005,6 @@
9964
10005
  searchString: searchString
9965
10006
  }, this.basketsService);
9966
10007
  this.handleAddIngredientActionErrors(addIngredient);
9967
- this.basketSynchroService.addToActionList([addIngredient]);
9968
10008
  // No need to send entry.added event, because it is done in the action
9969
10009
  return rxjs.of(addIngredient);
9970
10010
  };
@@ -10935,7 +10975,6 @@
10935
10975
  ingredientId: re.ingredientId,
10936
10976
  eventTrace: eventTrace
10937
10977
  }, _this.basketsService); });
10938
- _this.basketSynchroService.addToActionList(addRecipes);
10939
10978
  var onTimeouts = addRecipes.map(function (action) { return action.onTimeout; });
10940
10979
  var onErrors = addRecipes.map(function (action) { return action.onError; });
10941
10980
  var onSuccesses = addRecipes.map(function (action) { return action.onSuccess; });
@@ -10944,6 +10983,7 @@
10944
10983
  .subscribe({
10945
10984
  complete: function () { return _this.allIngredientsToBasketLoading$.next(false); }
10946
10985
  });
10986
+ _this.basketSynchroService.addToActionList(addRecipes);
10947
10987
  }
10948
10988
  else {
10949
10989
  _this.allIngredientsToBasketLoading$.next(false);
@@ -11774,11 +11814,11 @@
11774
11814
  _this.basketsService.resetBasket().subscribe();
11775
11815
  }
11776
11816
  var resetBasket = clonedEntriesToRemove.map(function (entry) { return new ResetBasketAction(entry, {}, _this.basketsService); });
11777
- _this.basketHandler.addToActionList(resetBasket);
11778
11817
  if (resetBasket.length > 0) {
11779
11818
  resetBasket[resetBasket.length - 1].onSuccess.pipe(operators.take(1)).subscribe(function () {
11780
11819
  _this.basketsService.resetBasket().subscribe();
11781
11820
  });
11821
+ _this.basketHandler.addToActionList(resetBasket);
11782
11822
  }
11783
11823
  });
11784
11824
  };
@@ -13110,7 +13150,7 @@
13110
13150
  env: 'prod',
13111
13151
  miamAPI: 'https://api.miam.tech',
13112
13152
  miamWeb: 'https://miam.tech',
13113
- mealzComponents: 'https://cdn.jsdelivr.net/npm/mealz-components@2.8/dist',
13153
+ mealzComponents: 'https://cdn.jsdelivr.net/npm/mealz-components@2.9/dist',
13114
13154
  mealzSsrApi: 'https://ssr-api.mealz.ai',
13115
13155
  lang: 'fr',
13116
13156
  analyticsEnabled: true // Only used in DEV mode
@@ -16700,11 +16740,11 @@
16700
16740
  _this.basketEntry.quantity = previousValue;
16701
16741
  _this.cdr.detectChanges();
16702
16742
  });
16703
- this.basketSynchroService.addToActionList([updateQuantity]);
16704
16743
  updateQuantity.onSuccess.pipe(operators.take(1)).subscribe(function () {
16705
16744
  _this.basketEntry.quantity = newBasketEntry_1.quantity;
16706
16745
  _this.subscriptions.push(_this.basketsService.reloadBasket().subscribe(function () { return _this.cdr.detectChanges(); }));
16707
16746
  });
16747
+ this.basketSynchroService.addToActionList([updateQuantity]);
16708
16748
  this.analyticsService.sendEvent('entry.change-quantity', this.path, {
16709
16749
  entry_name: this.basketEntry.name,
16710
16750
  item_id: this.basketEntry.selectedItem.id,
@@ -22077,11 +22117,11 @@
22077
22117
  }
22078
22118
  NoSupplierAddToCartCtaService.prototype.displayNoSupplierAddToCartCta = function (recipeId, guests) {
22079
22119
  var _this = this;
22080
- var headers = this.httpUtils.buildHeaders();
22081
- this.loadStyles();
22082
- this.loadComponentScripts();
22083
- this.fetchingHTMLLoader$.next(true);
22084
- return this.posService.posWasInitialized().pipe(operators.take(1), operators.map(function (wasInitialized) { return wasInitialized ? _this.posService.pos$.value : null; }), operators.switchMap(function (pos) {
22120
+ return this.httpUtils.waitForSsrHeaders().pipe(operators.tap(function () {
22121
+ _this.loadStyles();
22122
+ _this.loadComponentScripts();
22123
+ _this.fetchingHTMLLoader$.next(true);
22124
+ }), operators.switchMap(function (headers) { return _this.posService.posWasInitialized().pipe(operators.take(1), operators.map(function (wasInitialized) { return wasInitialized ? _this.posService.pos$.value : null; }), operators.switchMap(function (pos) {
22085
22125
  var url = _this.MEALZ_SSR_API + "/no-supplier-add-to-cart-cta?recipe_id=" + recipeId;
22086
22126
  if (pos === null || pos === void 0 ? void 0 : pos.id) {
22087
22127
  url += "&store_id=" + pos.id;
@@ -22090,7 +22130,7 @@
22090
22130
  url += "&guests=" + guests;
22091
22131
  }
22092
22132
  return _this.http.get(url, { headers: headers, responseType: 'text' });
22093
- }), operators.tap(function () { return _this.fetchingHTMLLoader$.next(false); }));
22133
+ })); }), operators.finalize(function () { return _this.fetchingHTMLLoader$.next(false); }));
22094
22134
  };
22095
22135
  return NoSupplierAddToCartCtaService;
22096
22136
  }(LoadSsrScriptsAndLinksService));
@@ -22113,12 +22153,17 @@
22113
22153
  this.clicked = new i0.EventEmitter();
22114
22154
  this.ctaHTML = null;
22115
22155
  }
22116
- NoSupplierAddToCartCtaComponent.prototype.ngOnInit = function () {
22117
- this.loadComponent();
22156
+ NoSupplierAddToCartCtaComponent.prototype.ngOnChanges = function (changes) {
22157
+ var recipeId = String(this.recipeId);
22158
+ if (!changes.recipeId || !this.recipeId || recipeId === this.loadedRecipeId) {
22159
+ return;
22160
+ }
22161
+ this.loadComponent(recipeId);
22118
22162
  };
22119
- NoSupplierAddToCartCtaComponent.prototype.loadComponent = function () {
22163
+ NoSupplierAddToCartCtaComponent.prototype.loadComponent = function (recipeId) {
22120
22164
  var _this = this;
22121
- this.noSupplierAddToCartCtaService.displayNoSupplierAddToCartCta(this.recipeId, this.guests).pipe(operators.take(1)).subscribe({
22165
+ this.loadedRecipeId = recipeId;
22166
+ this.noSupplierAddToCartCtaService.displayNoSupplierAddToCartCta(recipeId, this.guests).pipe(operators.take(1)).subscribe({
22122
22167
  next: function (html) {
22123
22168
  _this.ctaHTML = _this.sanitizer.bypassSecurityTrustHtml(html);
22124
22169
  _this.clicked.emit();
@@ -22132,7 +22177,7 @@
22132
22177
  return NoSupplierAddToCartCtaComponent;
22133
22178
  }());
22134
22179
  NoSupplierAddToCartCtaComponent.ɵfac = function NoSupplierAddToCartCtaComponent_Factory(t) { return new (t || NoSupplierAddToCartCtaComponent)(i0__namespace.ɵɵdirectiveInject(NoSupplierAddToCartCtaService), i0__namespace.ɵɵdirectiveInject(i2__namespace.DomSanitizer), i0__namespace.ɵɵdirectiveInject(i0__namespace.ChangeDetectorRef)); };
22135
- NoSupplierAddToCartCtaComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: NoSupplierAddToCartCtaComponent, selectors: [["ng-miam-no-supplier-add-to-cart-cta"]], inputs: { recipeId: "recipeId", guests: "guests" }, outputs: { clicked: "clicked" }, decls: 1, vars: 1, consts: [[3, "innerHTML"]], template: function NoSupplierAddToCartCtaComponent_Template(rf, ctx) {
22180
+ NoSupplierAddToCartCtaComponent.ɵcmp = i0__namespace.ɵɵdefineComponent({ type: NoSupplierAddToCartCtaComponent, selectors: [["ng-miam-no-supplier-add-to-cart-cta"]], inputs: { recipeId: "recipeId", guests: "guests" }, outputs: { clicked: "clicked" }, features: [i0__namespace.ɵɵNgOnChangesFeature], decls: 1, vars: 1, consts: [[3, "innerHTML"]], template: function NoSupplierAddToCartCtaComponent_Template(rf, ctx) {
22136
22181
  if (rf & 1) {
22137
22182
  i0__namespace.ɵɵelement(0, "div", 0);
22138
22183
  }