@ikas/storefront-providers 5.0.23 → 5.0.25

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.
@@ -9,10 +9,15 @@ export declare type IkasProductListPropValue = {
9
9
  usePageFilter?: boolean | null;
10
10
  category?: string | null;
11
11
  relatedProductsType?: IkasRelatedProductsType | null;
12
+ recommendedProductsType?: IkasRecommendedProductsType | null;
12
13
  excludedFields?: string[] | null;
13
14
  };
14
15
  declare type IkasProductVariantId = {
15
16
  productId: string;
16
17
  variantId: string;
17
18
  };
19
+ declare type IkasRecommendedProductsType = {
20
+ category?: string | null;
21
+ brand?: string | null;
22
+ };
18
23
  export {};
@@ -1,5 +1,5 @@
1
1
  import { IkasBrand, IkasCategory, IkasFilterCategory, IkasProduct, IkasProductFilter, IkasThemeJsonPageType } from "@ikas/storefront-models";
2
- import { IkasRelatedProductProps, IkasViewedTogetherProductProps } from "../../../providers/prop-value/product-list";
2
+ import { IkasRecommendedProductProps, IkasRelatedProductProps, IkasViewedTogetherProductProps } from "../../../providers/prop-value/product-list";
3
3
  import { IkasProductListPropValue } from "../../prop-value/product-list";
4
4
  export declare type IkasProductList = {
5
5
  data: IkasProduct[];
@@ -19,6 +19,7 @@ export declare type IkasProductList = {
19
19
  filterBrandId?: string | null;
20
20
  filterCategoryId?: string | null;
21
21
  relatedProductData?: IkasRelatedProductProps | null;
22
+ recommendedProductData?: IkasRecommendedProductProps | null;
22
23
  viewedTogetherProductData?: IkasViewedTogetherProductProps | null;
23
24
  pageSpecificData: IkasCategory | IkasBrand | null;
24
25
  recommendFor?: string | null;
@@ -36,7 +37,8 @@ export declare enum IkasProductListType {
36
37
  SEARCH = "SEARCH",
37
38
  LAST_VIEWED = "LAST_VIEWED",
38
39
  RELATED_PRODUCTS = "RELATED_PRODUCTS",
39
- VIEWED_TOGETHER = "VIEWED_TOGETHER"
40
+ VIEWED_TOGETHER = "VIEWED_TOGETHER",
41
+ RECOMMENDED_PRODUCTS = "RECOMMENDED_PRODUCTS"
40
42
  }
41
43
  export declare enum IkasProductListSortType {
42
44
  INCREASING_PRICE = "INCREASING_PRICE",
@@ -80,4 +82,4 @@ export declare type FacetValue = {
80
82
  id: string;
81
83
  count: number;
82
84
  };
83
- export type { IkasRelatedProductProps, IkasViewedTogetherProductProps };
85
+ export type { IkasRelatedProductProps, IkasViewedTogetherProductProps, IkasRecommendedProductProps, };
@@ -1 +1 @@
1
- var E,A,T,_,R;!function(E){E.ALL="ALL",E.STATIC="STATIC",E.DISCOUNTED="DISCOUNTED",E.RECOMMENDED="RECOMMENDED",E.CATEGORY="CATEGORY",E.SEARCH="SEARCH",E.LAST_VIEWED="LAST_VIEWED",E.RELATED_PRODUCTS="RELATED_PRODUCTS",E.VIEWED_TOGETHER="VIEWED_TOGETHER"}(E||(E={})),function(E){E.INCREASING_PRICE="INCREASING_PRICE",E.DECREASING_PRICE="DECREASING_PRICE",E.LAST_ADDED="LAST_ADDED",E.FIRST_ADDED="FIRST_ADDED",E.INCREASING_DISCOUNT="INCREASING_DISCOUNT",E.DECRASING_DISCOUNT="DECRASING_DISCOUNT",E.FEATURED="FEATURED",E.DEFAULT="DEFAULT",E.AVERAGE_RATING="AVERAGE_RATING",E.REVIEW_COUNT="REVIEW_COUNT",E.SALE_COUNT="SALE_COUNT",E.A_Z="A_Z",E.Z_A="Z_A"}(A||(A={})),function(E){E.AVERAGE_RATING="AVERAGE_RATING",E.CREATED_AT="CREATED_AT",E.DISCOUNT_RATIO="DISCOUNT_RATIO",E.MANUAL_SORT="MANUAL_SORT",E.NAME="NAME",E.PRICE="PRICE",E.REVIEW_COUNT="REVIEW_COUNT",E.SALE_COUNT="SALE_COUNT"}(T||(T={})),function(E){E.CATEGORY="CATEGORY",E.BRAND="BRAND"}(_||(_={})),function(E){E.HIDE_OUT_OF_STOCK="HIDE_OUT_OF_STOCK",E.SHOW_ALL="SHOW_ALL",E.SHOW_OUT_OF_STOCK_AT_END="SHOW_OUT_OF_STOCK_AT_END"}(R||(R={}));export{T as IkasProductListSortByTypeEnum,A as IkasProductListSortType,E as IkasProductListType,R as IkasProductSearchShowStockOption,_ as IkasRelatedProductsType};
1
+ var E,A,T,_,D;!function(E){E.ALL="ALL",E.STATIC="STATIC",E.DISCOUNTED="DISCOUNTED",E.RECOMMENDED="RECOMMENDED",E.CATEGORY="CATEGORY",E.SEARCH="SEARCH",E.LAST_VIEWED="LAST_VIEWED",E.RELATED_PRODUCTS="RELATED_PRODUCTS",E.VIEWED_TOGETHER="VIEWED_TOGETHER",E.RECOMMENDED_PRODUCTS="RECOMMENDED_PRODUCTS"}(E||(E={})),function(E){E.INCREASING_PRICE="INCREASING_PRICE",E.DECREASING_PRICE="DECREASING_PRICE",E.LAST_ADDED="LAST_ADDED",E.FIRST_ADDED="FIRST_ADDED",E.INCREASING_DISCOUNT="INCREASING_DISCOUNT",E.DECRASING_DISCOUNT="DECRASING_DISCOUNT",E.FEATURED="FEATURED",E.DEFAULT="DEFAULT",E.AVERAGE_RATING="AVERAGE_RATING",E.REVIEW_COUNT="REVIEW_COUNT",E.SALE_COUNT="SALE_COUNT",E.A_Z="A_Z",E.Z_A="Z_A"}(A||(A={})),function(E){E.AVERAGE_RATING="AVERAGE_RATING",E.CREATED_AT="CREATED_AT",E.DISCOUNT_RATIO="DISCOUNT_RATIO",E.MANUAL_SORT="MANUAL_SORT",E.NAME="NAME",E.PRICE="PRICE",E.REVIEW_COUNT="REVIEW_COUNT",E.SALE_COUNT="SALE_COUNT"}(T||(T={})),function(E){E.CATEGORY="CATEGORY",E.BRAND="BRAND"}(_||(_={})),function(E){E.HIDE_OUT_OF_STOCK="HIDE_OUT_OF_STOCK",E.SHOW_ALL="SHOW_ALL",E.SHOW_OUT_OF_STOCK_AT_END="SHOW_OUT_OF_STOCK_AT_END"}(D||(D={}));export{T as IkasProductListSortByTypeEnum,A as IkasProductListSortType,E as IkasProductListType,D as IkasProductSearchShowStockOption,_ as IkasRelatedProductsType};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i,IkasCategoryProductsOrderType as n}from"@ikas/storefront-models";import{IkasProductListType as a,IkasProductSearchShowStockOption as o,IkasProductListSortType as d}from"./index.js";import{IkasProductFilterFunctions as u}from"@ikas/storefront-model-functions";import{searchProducts as s,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as v,SortByTypeEnum as E}from"@ikas/storefront-api";import{IkasStorefrontConfig as I}from"@ikas/storefront-config";import"../blog-category-list/index.js";import"../blog-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";function p(i,o){var s,l,c,f;return e(this,void 0,void 0,(function(){var e,v,E,I,p,g,y;return t(this,(function(t){switch(t.label){case 0:!function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&[a.ALL].includes(e.type))switch(e.pageSpecificData.orderType){case n.HIGHEST_DISCOUNT_RATIO:e.sort=d.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:e.sort=d.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:e.sort=d.DECREASING_PRICE;break;case n.LOWEST_PRICE:e.sort=d.INCREASING_PRICE;break;case n.NEWEST:e.sort=d.LAST_ADDED;break;case n.OLDEST:e.sort=d.FIRST_ADDED;break;case n.MANUALLY:e.sort=d.FEATURED}}(i),i.isLoading=!0,e=Date.now(),i.fetchRequestTime=e,t.label=1;case 1:return t.trys.push([1,5,,6]),v=o?i.page:1,E=i.limit,!function(e){return e.type===a.ALL||e.type===a.CATEGORY}(i)||i.filters?[3,3]:[4,D(i)];case 2:t.sent(),t.label=3;case 3:if(S(i))return i.data=[],i.page=1,i.minPage=1,i.count=0,i.initialized=!0,[2,!0];if(void 0,C(i))v=void 0,E=200;else if(function(e){return e.type===a.DISCOUNTED}(i))v=1,E=10;else if(function(e){return e.type===a.RECOMMENDED}(i))v=1,E=10;else if(A(i))return[2];return[4,T(i,v||1,E||10,undefined)];case 4:return(I=t.sent())&&i.fetchRequestTime===e?(p=[],A(i)?[2]:(C(i)?(g=i.productListPropValue.productIds||[],p=(null==g?void 0:g.map((function(e){var t,i,n=null===(i=null===(t=I.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.productId})),a=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==a?void 0:a.isActive)||(a=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&a)return r(r({},n),{selectedVariantValues:a.variantValues})})).filter((function(e){return!!e})))||[]):p=(null===(l=null===(s=I.data)||void 0===s?void 0:s.data)||void 0===l?void 0:l.map((function(e){var t=e.variants.find((function(e){return e.isActive}));return r(r({},e),{selectedVariantValues:(t||e.variants[0]).variantValues})})))||[],function(e,t){var r,i,n=u.isCustomValueFilter;null===(r=e.filters)||void 0===r||r.forEach((function(e){var r,i,a,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=o.values.find((function(e){return e.id===t.id}));r?t.resultCount=r.count:n(e)?t.resultCount=null:t.resultCount=0})):n(e)?null===(i=e.values)||void 0===i||i.forEach((function(e){return e.resultCount=null})):null===(a=e.values)||void 0===a||a.forEach((function(e){return e.resultCount=0}))}));var a=null==t?void 0:t.find((function(e){return"category"===e.id}));a&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=a.values.find((function(t){return t.id===e.id}));e.resultCount=t?t.count:0})))}(i,null===(c=I.data)||void 0===c?void 0:c.facets),i.data=p,i.count=(null===(f=I.data)||void 0===f?void 0:f.count)||0,i.initialized=!0,i.page=v||1,i.minPage=i.page,[2,!0])):[2];case 5:return y=t.sent(),console.error(y),[3,6];case 6:return[2]}}))}))}function C(e){return e.type===a.STATIC}function A(e){return e.type===a.LAST_VIEWED}function S(e){return e.type===a.SEARCH}function T(r,n,f,p){var A,T,D;return e(this,void 0,void 0,(function(){var e,g,y,R,h,m;return t(this,(function(t){switch(t.label){case 0:return e=[],g=[],y=u.getValueList,null===(A=r.filters)||void 0===A||A.forEach((function(t){var r=y(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&g.push({id:t.id,type:t.type,displayType:t.displayType})})),R=null===(T=r.filterCategories)||void 0===T?void 0:T.filter((function(e){return e.isSelected})).map((function(e){return e.id})),h=function(e){var t,r;switch(e.sort){case d.INCREASING_PRICE:t=v.ASC,r=E.PRICE;break;case d.DECREASING_PRICE:t=v.DESC,r=E.PRICE;break;case d.FIRST_ADDED:t=v.ASC,r=E.CREATED_AT;break;case d.LAST_ADDED:t=v.DESC,r=E.CREATED_AT;break;case d.INCREASING_DISCOUNT:t=v.ASC,r=E.DISCOUNT_RATIO;break;case d.DECRASING_DISCOUNT:t=v.DESC,r=E.DISCOUNT_RATIO;break;case d.FEATURED:if(S(e))return;t=v.ASC,r=E.MANUAL_SORT;break;case d.DEFAULT:t=void 0,r=void 0;break;case d.AVERAGE_RATING:t=v.DESC,r=E.AVERAGE_RATING;break;case d.REVIEW_COUNT:t=v.DESC,r=E.REVIEW_COUNT;break;case d.SALE_COUNT:t=v.DESC,r=E.SALE_COUNT;break;case d.A_Z:t=v.ASC,r=E.NAME;break;case d.Z_A:t=v.DESC,r=E.NAME}if(t&&r)return{direction:t,type:r}}(r),function(e){return e.type===a.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:I.getPriceListId(),salesChannelId:I.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds,locale:I.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:return[2,t.sent()];case 2:return function(e){return e.type===a.VIEWED_TOGETHER}(r)&&r.viewedTogetherProductData?[4,l({priceListId:I.getPriceListId(),salesChannelId:I.getSalesChannelId(),method:c.VIEWED_TOGETHER,productIds:r.viewedTogetherProductData.productIds,locale:I.getCurrentLocale()})]:[3,4];case 4:return m={input:{page:n,perPage:f,productIdList:C(r)?null===(D=r.productListPropValue.productIds)||void 0===D?void 0:D.map((function(e){return e.productId})):p,filterList:e,facetList:g,brandId:r.pageType===i.BRAND&&r.type!==a.SEARCH?r.filterBrandId:void 0,categoryIdList:R&&R.length?R:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:I.getPriceListId(),salesChannelId:I.getSalesChannelId(),query:r.searchKeyword,order:r.type===a.SEARCH?[]:h?[h]:[],showStockOption:I.getStockPreference()||o.SHOW_ALL}},[4,s(m,r.excludedFields)]}}))}))}function D(r){var n,a,o,d,u;return e(this,void 0,void 0,(function(){var e,s;return t(this,(function(t){switch(t.label){case 0:return[4,f({categoryId:r.filterCategoryId?r.filterCategoryId:void 0,locale:I.getCurrentLocale()})];case 1:return e=t.sent(),r.filters=(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.filters)||null,r.filterCategories=(null===(o=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.categories)||void 0===o?void 0:o.map((function(e){return new g(e)})))||null,r.disabledSortTypes=null===(d=e.data)||void 0===d?void 0:d.disabledSortTypes,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(s=null===(u=r.filterCategories)||void 0===u?void 0:u.find((function(e){return e.id===r.filterCategoryId})))&&(s.isSelected=!0),r.filters&&r.filters.sort((function(e,t){return e.order>t.order?1:-1})),[2]}}))}))}var g=function(e){this.id=e.id,this.name=e.name,this.metaData=e.metaData,this.isAutomated=e.isAutomated,this.resultCount=e.resultCount,this.isSelected=e.isSelected,this.imageId=e.imageId};export{p as getInitial};
1
+ import{__awaiter as e,__generator as t,__assign as r}from'./../../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i,IkasCategoryProductsOrderType as n}from"@ikas/storefront-models";import{IkasProductListType as a,IkasProductSearchShowStockOption as o,IkasProductListSortType as d}from"./index.js";import{IkasProductFilterFunctions as s}from"@ikas/storefront-model-functions";import{searchProducts as u,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as I,SortByTypeEnum as v}from"@ikas/storefront-api";import{IkasStorefrontConfig as E}from"@ikas/storefront-config";import"../blog-category-list/index.js";import"../blog-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";function C(i,o){var u,l,c,f;return e(this,void 0,void 0,(function(){var e,I,v,E,C,g,y;return t(this,(function(t){switch(t.label){case 0:!function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&[a.ALL].includes(e.type))switch(e.pageSpecificData.orderType){case n.HIGHEST_DISCOUNT_RATIO:e.sort=d.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:e.sort=d.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:e.sort=d.DECREASING_PRICE;break;case n.LOWEST_PRICE:e.sort=d.INCREASING_PRICE;break;case n.NEWEST:e.sort=d.LAST_ADDED;break;case n.OLDEST:e.sort=d.FIRST_ADDED;break;case n.MANUALLY:e.sort=d.FEATURED}}(i),i.isLoading=!0,e=Date.now(),i.fetchRequestTime=e,t.label=1;case 1:return t.trys.push([1,5,,6]),I=o?i.page:1,v=i.limit,!function(e){return e.type===a.ALL||e.type===a.CATEGORY}(i)||i.filters?[3,3]:[4,T(i)];case 2:t.sent(),t.label=3;case 3:if(S(i))return i.data=[],i.page=1,i.minPage=1,i.count=0,i.initialized=!0,[2,!0];if(void 0,p(i))I=void 0,v=200;else if(function(e){return e.type===a.DISCOUNTED}(i))I=1,v=10;else if(function(e){return e.type===a.RECOMMENDED}(i))I=1,v=10;else if(D(i))return[2];return[4,A(i,I||1,v||10,undefined)];case 4:return(E=t.sent())&&i.fetchRequestTime===e?(C=[],D(i)?[2]:(p(i)?(g=i.productListPropValue.productIds||[],C=(null==g?void 0:g.map((function(e){var t,i,n=null===(i=null===(t=E.data)||void 0===t?void 0:t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.productId})),a=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==a?void 0:a.isActive)||(a=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&a)return r(r({},n),{selectedVariantValues:a.variantValues})})).filter((function(e){return!!e})))||[]):C=(null===(l=null===(u=E.data)||void 0===u?void 0:u.data)||void 0===l?void 0:l.map((function(e){var t=e.variants.find((function(e){return e.isActive}));return r(r({},e),{selectedVariantValues:(t||e.variants[0]).variantValues})})))||[],function(e,t){var r,i,n=s.isCustomValueFilter;null===(r=e.filters)||void 0===r||r.forEach((function(e){var r,i,a,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=o.values.find((function(e){return e.id===t.id}));r?t.resultCount=r.count:n(e)?t.resultCount=null:t.resultCount=0})):n(e)?null===(i=e.values)||void 0===i||i.forEach((function(e){return e.resultCount=null})):null===(a=e.values)||void 0===a||a.forEach((function(e){return e.resultCount=0}))}));var a=null==t?void 0:t.find((function(e){return"category"===e.id}));a&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=a.values.find((function(t){return t.id===e.id}));e.resultCount=t?t.count:0})))}(i,null===(c=E.data)||void 0===c?void 0:c.facets),i.data=C,i.count=(null===(f=E.data)||void 0===f?void 0:f.count)||0,i.initialized=!0,i.page=I||1,i.minPage=i.page,[2,!0])):[2];case 5:return y=t.sent(),console.error(y),[3,6];case 6:return[2]}}))}))}function p(e){return e.type===a.STATIC}function D(e){return e.type===a.LAST_VIEWED}function S(e){return e.type===a.SEARCH}function A(r,n,f,C){var D,A,T;return e(this,void 0,void 0,(function(){var e,g,y,R,m,h;return t(this,(function(t){switch(t.label){case 0:return e=[],g=[],y=s.getValueList,null===(D=r.filters)||void 0===D||D.forEach((function(t){var r=y(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&g.push({id:t.id,type:t.type,displayType:t.displayType})})),R=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(e){return e.isSelected})).map((function(e){return e.id})),m=function(e){var t,r;switch(e.sort){case d.INCREASING_PRICE:t=I.ASC,r=v.PRICE;break;case d.DECREASING_PRICE:t=I.DESC,r=v.PRICE;break;case d.FIRST_ADDED:t=I.ASC,r=v.CREATED_AT;break;case d.LAST_ADDED:t=I.DESC,r=v.CREATED_AT;break;case d.INCREASING_DISCOUNT:t=I.ASC,r=v.DISCOUNT_RATIO;break;case d.DECRASING_DISCOUNT:t=I.DESC,r=v.DISCOUNT_RATIO;break;case d.FEATURED:if(S(e))return;t=I.ASC,r=v.MANUAL_SORT;break;case d.DEFAULT:t=void 0,r=void 0;break;case d.AVERAGE_RATING:t=I.DESC,r=v.AVERAGE_RATING;break;case d.REVIEW_COUNT:t=I.DESC,r=v.REVIEW_COUNT;break;case d.SALE_COUNT:t=I.DESC,r=v.SALE_COUNT;break;case d.A_Z:t=I.ASC,r=v.NAME;break;case d.Z_A:t=I.DESC,r=v.NAME}if(t&&r)return{direction:t,type:r}}(r),function(e){return e.type===a.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds,locale:E.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:case 7:return[2,t.sent()];case 2:return function(e){return e.type===a.RECOMMENDED_PRODUCTS}(r)&&r.recommendedProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),brandIds:r.recommendedProductData.brandIds,categoryIds:r.recommendedProductData.categoryIds,locale:E.getCurrentLocale()})]:[3,4];case 4:return function(e){return e.type===a.VIEWED_TOGETHER}(r)&&r.viewedTogetherProductData?[4,l({priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),method:c.VIEWED_TOGETHER,productIds:r.viewedTogetherProductData.productIds,locale:E.getCurrentLocale()})]:[3,6];case 6:return h={input:{page:n,perPage:f,productIdList:p(r)?null===(T=r.productListPropValue.productIds)||void 0===T?void 0:T.map((function(e){return e.productId})):C,filterList:e,facetList:g,brandId:r.pageType===i.BRAND&&r.type!==a.SEARCH?r.filterBrandId:void 0,categoryIdList:R&&R.length?R:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:E.getPriceListId(),salesChannelId:E.getSalesChannelId(),query:r.searchKeyword,order:r.type===a.SEARCH?[]:m?[m]:[],showStockOption:E.getStockPreference()||o.SHOW_ALL}},[4,u(h,r.excludedFields)]}}))}))}function T(r){var n,a,o,d,s;return e(this,void 0,void 0,(function(){var e,u;return t(this,(function(t){switch(t.label){case 0:return[4,f({categoryId:r.filterCategoryId?r.filterCategoryId:void 0,locale:E.getCurrentLocale()})];case 1:return e=t.sent(),r.filters=(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.filters)||null,r.filterCategories=(null===(o=null===(a=null==e?void 0:e.data)||void 0===a?void 0:a.categories)||void 0===o?void 0:o.map((function(e){return new g(e)})))||null,r.disabledSortTypes=null===(d=e.data)||void 0===d?void 0:d.disabledSortTypes,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(s=r.filterCategories)||void 0===s?void 0:s.find((function(e){return e.id===r.filterCategoryId})))&&(u.isSelected=!0),r.filters&&r.filters.sort((function(e,t){return e.order>t.order?1:-1})),[2]}}))}))}var g=function(e){this.id=e.id,this.name=e.name,this.metaData=e.metaData,this.isAutomated=e.isAutomated,this.resultCount=e.resultCount,this.isSelected=e.isSelected,this.imageId=e.imageId};export{C as getInitial};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as n}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import i from"lodash/flatten";import{makeAutoObservable as a}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as s,IkasThemeJsonPageType as o,IkasStorefrontPopupPageFilterDataTypeEnum as u,IkasAmountType as c,IkasCampaignOfferProductApplicablePriceEnum as l,IkasCategoryConditionTypeEnum as d,IkasRaffleMetadataTargetType as p,IkasBlogMetaDataTargetType as g,IkasHTMLMetaDataTargetType as f,IkasThemeJsonComponentPropType as h}from"@ikas/storefront-models";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{IkasProductFunctions as m,IkasProductVariantFunctions as T}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as S}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as I}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as D}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as O}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as P}from"./prop-value/link.js";import{IkasImageListPropValueProvider as C}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as y}from"./prop-value/text.js";import{IkasColorPropValueProvider as R}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as L}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as b}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as E}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as A}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as w}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as F}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as G}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as V}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as _}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as U}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as j}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as N}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as B}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as M}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as k}from"./prop-value/raffle-list.js";import{listMerchantSettings as x,listCustomerReviewSummary as Y,searchProducts as q,listCampaignOffer as J,listCustomerReviews as H,listProductOptionSet as K,listProductBrand as X,listCategory as z,listBlog as Q,listBlogCategory as $,listStorefrontRaffle as W,listHTMLMetaData as Z,listRaffleMetaData as ee,listBlogMetaData as te}from"@ikas/storefront-api";import{populateRaffleProducts as ne}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as re}from"./prop-value/video.js";var ie=function(){function ie(e,t,n,r){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=n,this.merchantSettings=r,a(this)}return Object.defineProperty(ie.prototype,"page",{get:function(){var e=this;if(this.pageType===o.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===o.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"nextPageData",{get:function(){var e,t,r,i,a,s=[],u=[];return this.pageComponentPropValues.forEach((function(e){if(u.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:u,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||o.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(i=this.page)||void 0===i?void 0:i.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:v.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),ie.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=v.getCurrentRouting();v.getCurrentLocale(),v.getDomain();var n=v.getStorefrontId(),r=v.getStorefrontRoutingId(),i=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=v.getStorefrontPopups(),c=[];a.length&&a.forEach((function(t){var a,l,d,p,g=!1,f=!1,h=!1,v=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===s.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case s.ACCOUNT:if(i)return[o.ACCOUNT,o.ORDERS,o.ORDER_DETAIL,o.FAVORITE_PRODUCTS,o.ADDRESSES,o.RAFFLE_ACCOUNT].includes(i);case s.LOGIN:return i===o.LOGIN;case s.REGISTER:return i===o.REGISTER;case s.CART:return i===o.CART;case s.CATEGORY:return i===o.CATEGORY;case s.HOME:return i===o.INDEX;case s.PRODUCT:return i===o.PRODUCT;case s.PRODUCT_BRAND:return i===o.BRAND;case s.CUSTOM:return!0}}));if(null===(l=null==m?void 0:m.filters)||void 0===l?void 0:l.length)switch(m.pageType){case s.CATEGORY:case s.PRODUCT:case s.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===u.ID_LIST&&T&&(g=S.value.includes(T),v=!0);break;case s.CUSTOM:g=!0;break;default:v=!0,g=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(g=!0,v=!0)}else g=!0,v=!0;if(g)if(f=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===r}))),t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,D=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,O=new Date;(I&&D&&I.getTime()<=O.getTime()&&D.getTime()>=O.getTime()||I&&!D&&I.getTime()<=O.getTime()||D&&!I&&D.getTime()>=O.getTime())&&(h=!0)}}else h=!0;g&&f&&h&&(t.isFilteredOnServerSide=v,c.push(t))})),v.init({storefrontPopups:c})},Object.defineProperty(ie.prototype,"specification",{get:function(){var e,t,n=this,r=this.page;return(null==r?void 0:r.type)===o.PRODUCT?null===(e=r.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==r?void 0:r.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),ie.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,x({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},ie.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,n=this;return t(this,(function(t){switch(t.label){case 0:return this.pageSpecificData?[3,2]:[4,this.getPageSpecificData()];case 1:t.sent(),t.label=2;case 2:return this.page?[4,this.getMerchantSettings()]:[2];case 3:return t.sent(),e=this,[4,Promise.all(this.pageComponents.map((function(e){return n.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[4,this.getProductReviewSummary()];case 6:return t.sent(),[2]}}))}))},ie.prototype.getProductReviewSummary=function(){var n,r,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==o.PRODUCT?[3,2]:[4,Y({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},ie.prototype.getPageSpecificData=function(){var r,i,a,s;return e(this,void 0,void 0,(function(){var u,h,S,I,D,O,P,C,y,R,L=this;return t(this,(function(b){switch(b.label){case 0:return this.pageType&&![o.BRAND,o.PRODUCT,o.CATEGORY,o.BLOG,o.BLOG_CATEGORY,o.RAFFLE_DETAIL].includes(this.pageType)?[2]:(u=this.pageParams.slug)?(h=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(o.BLOG))||(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(o.BLOG_CATEGORY))?[4,te({slug:{eq:u}})]:[3,2]):[2];case 1:return S=b.sent(),(h=(null===(a=S.data)||void 0===a?void 0:a.data)||[]).length?[3,6]:[2];case 2:return(null===(s=this.possiblePageTypes)||void 0===s?void 0:s.includes(o.RAFFLE_DETAIL))?[4,ee({slug:{eq:u}})]:[3,4];case 3:return S=b.sent(),(h=S.data||[]).length?[3,6]:[2];case 4:return[4,Z({slug:{eq:u}})];case 5:if(S=b.sent(),!(h=S.data||[])||!h.length)return[2];b.label=6;case 6:if(!(I=h[0]).targetId)return[2];switch(D=function(){return e(L,void 0,void 0,(function(){var e,r,i,a,s,u,d,p,g,f,h,S,D,O,P,C,y,R,L,b,E,A,w,F,G,V,_,U,j,N,B,M,k,x,Y;return t(this,(function(t){switch(t.label){case 0:return[4,q({input:{productIdList:[I.targetId],priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(F=null===(w=null==e?void 0:e.data)||void 0===w?void 0:w.data)||void 0===F?void 0:F.length)?(r=e.data.data[0]).productOptionSetId?[4,K({id:{eq:r.productOptionSetId}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(G=null==i?void 0:i.data)||void 0===G?void 0:G.length)&&(r.productOptionSet=i.data[0]),t.label=3;case 3:return((null===(V=v.getDomain())||void 0===V?void 0:V.includes("thepurestsolutions"))||(null===(_=process.env.NEXT_PUBLIC_GQL_URL)||void 0===_?void 0:_.includes(".dev"))&&!v.getIsEditor())&&(a=r.variants.find((function(e){return e.isActive})))?(s=!!(null===(U=a.bundleSettings)||void 0===U?void 0:U.products.length),u=[r.id],s&&(null===(j=a.bundleSettings)||void 0===j||j.products.forEach((function(e){u.push(e.productId)}))),[4,H({productId:s?null:r.id,productIds:s?u:null,input:{salesChannelId:v.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:d=t.sent(),(null===(N=d.data)||void 0===N?void 0:N.data)&&d.isSuccess&&(p=d.data.data,g=!!(null===(B=a.bundleSettings)||void 0===B?void 0:B.products.length),f=[r.id],g&&(null===(M=a.bundleSettings)||void 0===M||M.products.forEach((function(e){f.push(e.productId)}))),r.customerReviews=n(n({data:p,count:p.length,limit:10,page:1,initialized:!0},g?{}:{productId:r.id}),g?{productIds:f}:{})),t.label=5;case 5:return(null===(k=r.campaignOffers)||void 0===k?void 0:k.length)?[4,J({id:{in:r.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(h=t.sent()).isSuccess&&(null===(x=h.data)||void 0===x?void 0:x.length)?(S=h.data[0],D=[],O=[],S.offers.forEach((function(e){return D.push(e.productId)})),[4,q({input:{productIdList:D,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})]):[3,8];case 7:(C=t.sent()).isSuccess&&C.data&&S.offers.forEach((function(e){var t,r,i=null===(r=null===(t=C.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.productId}));if(i){var a=i.variants.filter((function(t){return T.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var r=!1;return e.discountType===c.AMOUNT&&(r=!0),n(n({},t),{prices:t.prices.map((function(t){var i=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=i,s=i-(r?e.discountAmount:i*e.discountAmount/100);return e.applicablePrice===l.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(r?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&O.push({campaignOfferId:S.id,campaignOfferProductId:e.id,product:n(n({},i),{variants:a})})}P||(P={campaignOfferId:S.id,title:e.title,description:e.description})})),r.appliedCampaignOffer=P,r.offers=O,t.label=8;case 8:return r.productGroup?[4,q({input:{productGroupId:r.productGroup.id,productGroupKey:r.productGroup.groupKey,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(y=t.sent()).isSuccess&&(null===(Y=y.data)||void 0===Y?void 0:Y.data)&&(r.productGroupItems=y.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:m.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order}}))),t.label=10;case 10:return(R=r.variants.find((function(e){return e.isActive})))?(r.selectedVariantValues=R.variantValues,L=m.getDisplayedVariantTypes,this.pageSpecificData=r,(b=L(this.pageSpecificData,r.selectedVariantValues)).length&&(E=b[0]).displayedVariantValues.length&&(A=E.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=A.variant.variantValues),this.pageType=o.PRODUCT,this.setPageMetaData(I),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,X({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BRAND,this.setPageMetaData(I),[2]):[2]}}))}))},P=function(){return e(L,void 0,void 0,(function(){var e,n,r,i,a,s,u,c;return t(this,(function(t){switch(t.label){case 0:return[4,z({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(s=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?(n=e.data.data[0]).conditions&&(r=n.conditions.find((function(e){return e.conditionType===d.PRODUCT_BRAND})))?[4,X({id:{eq:r.valueList[0]}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(c=null===(u=i.data)||void 0===u?void 0:u.data)||void 0===c?void 0:c.length)&&(n.conditionValues={brand:i.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=o.CATEGORY,this.setPageMetaData(I),[2]}}))}))},C=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Q({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG,this.setPageMetaData(I),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:I.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG_CATEGORY,this.setPageMetaData(I),[2]):[2]}}))}))},R=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],[4,ne([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=o.RAFFLE_DETAIL,this.setPageMetaData(I),[2]}}))}))},I.targetType){case f.BRAND:return[3,7];case f.CATEGORY:return[3,9];case f.PRODUCT:return[3,11];case g.BLOG:return[3,13];case g.BLOG_CATEGORY:return[3,15];case p.RAFFLE:return[3,17]}return[3,19];case 7:return[4,O()];case 8:return[2,b.sent()];case 9:return[4,P()];case 10:return[2,b.sent()];case 11:return[4,D()];case 12:return[2,b.sent()];case 13:return[4,C()];case 14:return[2,b.sent()];case 15:return[4,y()];case 16:return[2,b.sent()];case 17:return[4,R()];case 18:return[2,b.sent()];case 19:return[3,20];case 20:return[2]}}))}))},ie.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var r,i,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((r=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||r.isFooter)&&(n.propValues=r.commonPropValues||n.propValues),i={pageComponent:n,component:r,propValues:{}},a=function(r){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=i.propValues,a=r.name,[4,this.getPageComponentPropValue(n,r)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(a))];case 1:return o.sent(),[2,i]}}))}))},ie.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,o,u,c,l,d,p,g,f=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[h.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case h.TEXT:return[3,1];case h.RICH_TEXT:return[3,2];case h.BOOLEAN:return[3,3];case h.IMAGE:return[3,4];case h.IMAGE_LIST:return[3,5];case h.BRAND:return[3,6];case h.BRAND_LIST:return[3,7];case h.PRODUCT_LIST:return[3,8];case h.PRODUCT_DETAIL:return[3,9];case h.PRODUCT_ATTRIBUTE:return[3,10];case h.PRODUCT_ATTRIBUTE_LIST:return[3,11];case h.CATEGORY:return[3,12];case h.CATEGORY_LIST:return[3,13];case h.LINK:case h.LIST_OF_LINK:return[3,14];case h.COLOR:return[3,15];case h.CUSTOM:return[3,16];case h.COMPONENT:case h.COMPONENT_LIST:return[3,17];case h.BLOG:return[3,19];case h.BLOG_LIST:return[3,20];case h.BLOG_CATEGORY:return[3,21];case h.BLOG_CATEGORY_LIST:return[3,22];case h.RAFFLE:return[3,23];case h.RAFFLE_LIST:return[3,24];case h.SLIDER:return[3,25];case h.VIDEO:return[3,26]}return[3,27];case 1:return e=new y(a),[3,28];case 2:return e=new G(a),[3,28];case 3:return e=new L(a),[3,28];case 4:return e=new b(a),[3,28];case 5:return e=new C(a),[3,28];case 6:return e=new O(a),[3,28];case 7:return e=new D(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===r.componentId})),u=[],o&&(d=o.props.find((function(e){return e.name===i.name})))&&(u=d.excludedFields||[]),e=new S(this.pageType,n(n({},a),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new I(a),[3,28];case 10:return e=new U(a),[3,28];case 11:return e=new j(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===r.componentId})),l=[],c&&(d=c.props.find((function(e){return e.name===i.name})))&&(l=d.excludedFieldsCategory||[]),e=new E(n(n({},a),{excludedFieldsCategory:l})),[3,28];case 13:return e=new A(a),[3,28];case 14:return e=new P(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new R(a),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new w(a,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return g=a,[4,Promise.all(g.map((function(e){return f.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new V(a),[3,28];case 20:return e=new _(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new N(a),[3,28];case 22:return e=new B(a),[3,28];case 23:return e=new M(a),[3,28];case 24:return e=new k,[3,28];case 25:return e=new F(a),[3,28];case 26:return e=new re(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},ie.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle||null,this.page.description=e.description||null,this.page.canonicals=e.canonicals||null,this.page.disableIndex=e.disableIndex||null)},ie.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},ie.prototype.getLinkSlugs=function(n,i){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=r(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],i){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,Z({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,te({targetId:{in:a}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ee({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},ie.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=i(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(n)},ie}();export{ie as IkasPageDataProvider};
1
+ import{__awaiter as e,__generator as t,__assign as n}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import i from"lodash/flatten";import{makeAutoObservable as a}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as s,IkasThemeJsonPageType as o,IkasStorefrontPopupPageFilterDataTypeEnum as u,IkasAmountType as c,IkasCampaignOfferProductApplicablePriceEnum as l,IkasCategoryConditionTypeEnum as d,IkasRaffleMetadataTargetType as p,IkasBlogMetaDataTargetType as g,IkasHTMLMetaDataTargetType as f,IkasThemeJsonComponentPropType as h}from"@ikas/storefront-models";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{IkasProductFunctions as m,IkasProductVariantFunctions as T}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as S}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as I}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as D}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as O}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as P}from"./prop-value/link.js";import{IkasImageListPropValueProvider as C}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as R}from"./prop-value/text.js";import{IkasColorPropValueProvider as y}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as L}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as b}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as E}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as A}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as w}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as F}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as G}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as V}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as _}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as U}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as j}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as N}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as B}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as M}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as k}from"./prop-value/raffle-list.js";import{listMerchantSettings as x,listCustomerReviewSummary as Y,searchProducts as q,listCampaignOffer as J,listCustomerReviews as H,listProductOptionSet as K,listProductBrand as X,listCategory as z,listBlog as Q,listBlogCategory as $,listStorefrontRaffle as W,listHTMLMetaData as Z,listRaffleMetaData as ee,listBlogMetaData as te}from"@ikas/storefront-api";import{populateRaffleProducts as ne}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as re}from"./prop-value/video.js";var ie=function(){function ie(e,t,n,r){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=n,this.merchantSettings=r,a(this)}return Object.defineProperty(ie.prototype,"page",{get:function(){var e=this;if(this.pageType===o.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===o.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"nextPageData",{get:function(){var e,t,r,i,a,s=[],u=[];return this.pageComponentPropValues.forEach((function(e){if(u.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:u,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||o.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(i=this.page)||void 0===i?void 0:i.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:v.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),ie.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=v.getCurrentRouting();v.getCurrentLocale(),v.getDomain();var n=v.getStorefrontId(),r=v.getStorefrontRoutingId(),i=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=v.getStorefrontPopups(),c=[];a.length&&a.forEach((function(t){var a,l,d,p,g=!1,f=!1,h=!1,v=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===s.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case s.ACCOUNT:if(i)return[o.ACCOUNT,o.ORDERS,o.ORDER_DETAIL,o.FAVORITE_PRODUCTS,o.ADDRESSES,o.RAFFLE_ACCOUNT].includes(i);case s.LOGIN:return i===o.LOGIN;case s.REGISTER:return i===o.REGISTER;case s.CART:return i===o.CART;case s.CATEGORY:return i===o.CATEGORY;case s.HOME:return i===o.INDEX;case s.PRODUCT:return i===o.PRODUCT;case s.PRODUCT_BRAND:return i===o.BRAND;case s.CUSTOM:return!0}}));if(null===(l=null==m?void 0:m.filters)||void 0===l?void 0:l.length)switch(m.pageType){case s.CATEGORY:case s.PRODUCT:case s.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===u.ID_LIST&&T&&(g=S.value.includes(T),v=!0);break;case s.CUSTOM:g=!0;break;default:v=!0,g=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(g=!0,v=!0)}else g=!0,v=!0;if(g)if(f=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===r}))),t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,D=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,O=new Date;(I&&D&&I.getTime()<=O.getTime()&&D.getTime()>=O.getTime()||I&&!D&&I.getTime()<=O.getTime()||D&&!I&&D.getTime()>=O.getTime())&&(h=!0)}}else h=!0;g&&f&&h&&(t.isFilteredOnServerSide=v,c.push(t))})),v.init({storefrontPopups:c})},Object.defineProperty(ie.prototype,"specification",{get:function(){var e,t,n=this,r=this.page;return(null==r?void 0:r.type)===o.PRODUCT?null===(e=r.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==r?void 0:r.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),ie.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,x({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},ie.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,n=this;return t(this,(function(t){switch(t.label){case 0:return this.pageSpecificData?[3,2]:[4,this.getPageSpecificData()];case 1:t.sent(),t.label=2;case 2:return this.page?[4,this.getMerchantSettings()]:[2];case 3:return t.sent(),e=this,[4,Promise.all(this.pageComponents.map((function(e){return n.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[4,this.getProductReviewSummary()];case 6:return t.sent(),[2]}}))}))},ie.prototype.getProductReviewSummary=function(){var n,r,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==o.PRODUCT?[3,2]:[4,Y({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},ie.prototype.getPageSpecificData=function(){var r,i,a,s;return e(this,void 0,void 0,(function(){var u,h,S,I,D,O,P,C,R,y,L=this;return t(this,(function(b){switch(b.label){case 0:return this.pageType&&![o.BRAND,o.PRODUCT,o.CATEGORY,o.BLOG,o.BLOG_CATEGORY,o.RAFFLE_DETAIL].includes(this.pageType)?[2]:(u=this.pageParams.slug)?(h=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(o.BLOG))||(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(o.BLOG_CATEGORY))?[4,te({slug:{eq:u}})]:[3,2]):[2];case 1:return S=b.sent(),(h=(null===(a=S.data)||void 0===a?void 0:a.data)||[]).length?[3,6]:[2];case 2:return(null===(s=this.possiblePageTypes)||void 0===s?void 0:s.includes(o.RAFFLE_DETAIL))?[4,ee({slug:{eq:u}})]:[3,4];case 3:return S=b.sent(),(h=S.data||[]).length?[3,6]:[2];case 4:return[4,Z({slug:{eq:u}})];case 5:if(S=b.sent(),!(h=S.data||[])||!h.length)return[2];b.label=6;case 6:if(!(I=h[0]).targetId)return[2];switch(D=function(){return e(L,void 0,void 0,(function(){var e,r,i,a,s,u,d,p,g,f,h,S,D,O,P,C,R,y,L,b,E,A,w,F,G,V,_,U,j,N,B,M,k,x,Y,X,z,Q,$,W,Z,ee;return t(this,(function(t){switch(t.label){case 0:return[4,q({input:{productIdList:[I.targetId],priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(B=null===(N=null==e?void 0:e.data)||void 0===N?void 0:N.data)||void 0===B?void 0:B.length)?(r=v.getCurrentRouting(),i=v.getRoutings(),a=i.find((function(e){return null===e.path})),s=null==r?void 0:r.path,(u=e.data.data[0]).productOptionSetId?[4,K({id:{eq:u.productOptionSetId}})]:[3,3]):[2];case 2:(d=t.sent()).isSuccess&&(null===(M=null==d?void 0:d.data)||void 0===M?void 0:M.length)&&(u.productOptionSet=d.data[0]),t.label=3;case 3:return((null===(k=v.getDomain())||void 0===k?void 0:k.includes("thepurestsolutions"))||(null===(x=process.env.NEXT_PUBLIC_GQL_URL)||void 0===x?void 0:x.includes(".dev"))&&!v.getIsEditor())&&(p=u.variants.find((function(e){return e.isActive})))?(g=!!(null===(Y=p.bundleSettings)||void 0===Y?void 0:Y.products.length),f=[u.id],g&&(null===(X=p.bundleSettings)||void 0===X||X.products.forEach((function(e){f.push(e.productId)}))),[4,H({productId:g?null:u.id,productIds:g?f:null,input:{salesChannelId:v.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:h=t.sent(),(null===(z=h.data)||void 0===z?void 0:z.data)&&h.isSuccess&&(S=h.data.data,D=!!(null===(Q=p.bundleSettings)||void 0===Q?void 0:Q.products.length),O=[u.id],D&&(null===($=p.bundleSettings)||void 0===$||$.products.forEach((function(e){O.push(e.productId)}))),u.customerReviews=n(n({data:S,count:S.length,limit:10,page:1,initialized:!0},D?{}:{productId:u.id}),D?{productIds:O}:{})),t.label=5;case 5:return(null===(W=u.campaignOffers)||void 0===W?void 0:W.length)?[4,J({id:{in:u.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(P=t.sent()).isSuccess&&(null===(Z=P.data)||void 0===Z?void 0:Z.length)?(C=P.data[0],R=[],y=[],C.offers.forEach((function(e){return R.push(e.productId)})),[4,q({input:{productIdList:R,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})]):[3,8];case 7:(b=t.sent()).isSuccess&&b.data&&C.offers.forEach((function(e){var t,r,i=null===(r=null===(t=b.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.productId}));if(i){var a=i.variants.filter((function(t){return T.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var r=!1;return e.discountType===c.AMOUNT&&(r=!0),n(n({},t),{prices:t.prices.map((function(t){var i=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=i,s=i-(r?e.discountAmount:i*e.discountAmount/100);return e.applicablePrice===l.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(r?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&y.push({campaignOfferId:C.id,campaignOfferProductId:e.id,product:n(n({},i),{variants:a})})}L||(L={campaignOfferId:C.id,title:e.title,description:e.description})})),u.appliedCampaignOffer=L,u.offers=y,t.label=8;case 8:return u.productGroup?[4,q({input:{productGroupId:u.productGroup.id,productGroupKey:u.productGroup.groupKey,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(E=t.sent()).isSuccess&&(null===(ee=E.data)||void 0===ee?void 0:ee.data)&&(u.productGroupItems=E.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:m.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order}}))),t.label=10;case 10:return(A=u.variants.find((function(e){return e.isActive})))?(u.selectedVariantValues=A.variantValues,w=m.getDisplayedVariantTypes,this.pageSpecificData=u,(F=w(this.pageSpecificData,u.selectedVariantValues)).length&&(G=F[0]).displayedVariantValues.length&&(V=G.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=V.variant.variantValues),this.pageType=o.PRODUCT,_=I,U=a&&a.locale===(null==r?void 0:r.locale),_&&(null==_?void 0:_.translations)&&!U&&(j=null==_?void 0:_.translations.find((function(e){return e.locale===s})),_.pageTitle=(null==j?void 0:j.pageTitle)||null,_.description=(null==j?void 0:j.description)||null),this.setPageMetaData(_),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,X({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BRAND,this.setPageMetaData(I),[2]):[2]}}))}))},P=function(){return e(L,void 0,void 0,(function(){var e,n,r,i,a,s,u,c;return t(this,(function(t){switch(t.label){case 0:return[4,z({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(s=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?(n=e.data.data[0]).conditions&&(r=n.conditions.find((function(e){return e.conditionType===d.PRODUCT_BRAND})))?[4,X({id:{eq:r.valueList[0]}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(c=null===(u=i.data)||void 0===u?void 0:u.data)||void 0===c?void 0:c.length)&&(n.conditionValues={brand:i.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=o.CATEGORY,this.setPageMetaData(I),[2]}}))}))},C=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Q({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG,this.setPageMetaData(I),[2]):[2]}}))}))},R=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:I.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG_CATEGORY,this.setPageMetaData(I),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],[4,ne([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=o.RAFFLE_DETAIL,this.setPageMetaData(I),[2]}}))}))},I.targetType){case f.BRAND:return[3,7];case f.CATEGORY:return[3,9];case f.PRODUCT:return[3,11];case g.BLOG:return[3,13];case g.BLOG_CATEGORY:return[3,15];case p.RAFFLE:return[3,17]}return[3,19];case 7:return[4,O()];case 8:return[2,b.sent()];case 9:return[4,P()];case 10:return[2,b.sent()];case 11:return[4,D()];case 12:return[2,b.sent()];case 13:return[4,C()];case 14:return[2,b.sent()];case 15:return[4,R()];case 16:return[2,b.sent()];case 17:return[4,y()];case 18:return[2,b.sent()];case 19:return[3,20];case 20:return[2]}}))}))},ie.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var r,i,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((r=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||r.isFooter)&&(n.propValues=r.commonPropValues||n.propValues),i={pageComponent:n,component:r,propValues:{}},a=function(r){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=i.propValues,a=r.name,[4,this.getPageComponentPropValue(n,r)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(a))];case 1:return o.sent(),[2,i]}}))}))},ie.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,o,u,c,l,d,p,g,f=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[h.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case h.TEXT:return[3,1];case h.RICH_TEXT:return[3,2];case h.BOOLEAN:return[3,3];case h.IMAGE:return[3,4];case h.IMAGE_LIST:return[3,5];case h.BRAND:return[3,6];case h.BRAND_LIST:return[3,7];case h.PRODUCT_LIST:return[3,8];case h.PRODUCT_DETAIL:return[3,9];case h.PRODUCT_ATTRIBUTE:return[3,10];case h.PRODUCT_ATTRIBUTE_LIST:return[3,11];case h.CATEGORY:return[3,12];case h.CATEGORY_LIST:return[3,13];case h.LINK:case h.LIST_OF_LINK:return[3,14];case h.COLOR:return[3,15];case h.CUSTOM:return[3,16];case h.COMPONENT:case h.COMPONENT_LIST:return[3,17];case h.BLOG:return[3,19];case h.BLOG_LIST:return[3,20];case h.BLOG_CATEGORY:return[3,21];case h.BLOG_CATEGORY_LIST:return[3,22];case h.RAFFLE:return[3,23];case h.RAFFLE_LIST:return[3,24];case h.SLIDER:return[3,25];case h.VIDEO:return[3,26]}return[3,27];case 1:return e=new R(a),[3,28];case 2:return e=new G(a),[3,28];case 3:return e=new L(a),[3,28];case 4:return e=new b(a),[3,28];case 5:return e=new C(a),[3,28];case 6:return e=new O(a),[3,28];case 7:return e=new D(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===r.componentId})),u=[],o&&(d=o.props.find((function(e){return e.name===i.name})))&&(u=d.excludedFields||[]),e=new S(this.pageType,n(n({},a),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new I(a),[3,28];case 10:return e=new U(a),[3,28];case 11:return e=new j(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===r.componentId})),l=[],c&&(d=c.props.find((function(e){return e.name===i.name})))&&(l=d.excludedFieldsCategory||[]),e=new E(n(n({},a),{excludedFieldsCategory:l})),[3,28];case 13:return e=new A(a),[3,28];case 14:return e=new P(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new y(a),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new w(a,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return g=a,[4,Promise.all(g.map((function(e){return f.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new V(a),[3,28];case 20:return e=new _(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new N(a),[3,28];case 22:return e=new B(a),[3,28];case 23:return e=new M(a),[3,28];case 24:return e=new k,[3,28];case 25:return e=new F(a),[3,28];case 26:return e=new re(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},ie.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle||null,this.page.description=e.description||null,this.page.canonicals=e.canonicals||null,this.page.disableIndex=e.disableIndex||null)},ie.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},ie.prototype.getLinkSlugs=function(n,i){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=r(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],i){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,Z({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,te({targetId:{in:a}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ee({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},ie.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=i(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(n)},ie}();export{ie as IkasPageDataProvider};
@@ -7,6 +7,10 @@ export declare type IkasRelatedProductProps = {
7
7
  categoryIds: string[] | null;
8
8
  productId: string;
9
9
  };
10
+ export declare type IkasRecommendedProductProps = {
11
+ brandIds: string[] | null;
12
+ categoryIds: string[] | null;
13
+ };
10
14
  export declare type IkasViewedTogetherProductProps = {
11
15
  productIds: string[];
12
16
  };
@@ -16,6 +20,7 @@ export declare class IkasProductListPropValueProvider implements IkasPropValuePr
16
20
  private pageSpecificData?;
17
21
  private relatedProductData?;
18
22
  private viewedTogetherProductData?;
23
+ private recommendedProductData?;
19
24
  constructor(pageType: IkasThemeJsonPageType, productListPropValue: IkasProductListPropValue, pageSpecificData?: any);
20
25
  getValue(): Promise<IkasProductList>;
21
26
  }
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'./../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as e}from"@ikas/storefront-models";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductListType as a,IkasRelatedProductsType as r,IkasProductListSortType as o}from"../../models/ui/product-list/index.js";import{getInitial as s}from"../../models/ui/product-list/init.js";var d=function(){function d(t,i,e){this.relatedProductData=null,this.viewedTogetherProductData=null,this.pageType=t,this.productListPropValue=i,this.pageSpecificData=e,this.relatedProductData=null,this.viewedTogetherProductData=null}return d.prototype.getValue=function(){var d,p;return t(this,void 0,void 0,(function(){var t,u,c,l,h;return i(this,(function(i){switch(i.label){case 0:return this.productListPropValue.productListType===a.ALL&&this.productListPropValue.usePageFilter&&(this.pageType===e.CATEGORY?(c=this.pageSpecificData,u=c.id):this.pageType===e.BRAND&&(l=this.pageSpecificData,t=l.id)),this.productListPropValue.productListType===a.CATEGORY&&this.productListPropValue.category&&(u=this.productListPropValue.category),this.pageType===e.PRODUCT&&this.productListPropValue.productListType===a.RELATED_PRODUCTS&&this.productListPropValue.relatedProductsType&&this.pageSpecificData&&(this.relatedProductData={brandIds:null,categoryIds:null,productId:""},this.productListPropValue.relatedProductsType===r.CATEGORY?this.relatedProductData.categoryIds=this.pageSpecificData.categories.map((function(t){return t.id})):this.relatedProductData.brandIds=[null===(p=null===(d=this.pageSpecificData)||void 0===d?void 0:d.brand)||void 0===p?void 0:p.id],this.relatedProductData.productId=this.pageSpecificData.id),this.pageType===e.PRODUCT&&this.productListPropValue.productListType===a.VIEWED_TOGETHER&&this.pageSpecificData&&(this.viewedTogetherProductData={productIds:[]},this.viewedTogetherProductData.productIds=[this.pageSpecificData.id]),h={data:[],count:0,page:1,limit:this.productListPropValue.initialLimit||10,type:this.productListPropValue.productListType||a.ALL,sort:this.productListPropValue.initialSort||o.LAST_ADDED,productListPropValue:this.productListPropValue,filterBrandId:t,filterCategoryId:u,pageType:this.pageType,pageSpecificData:[e.CATEGORY,e.BRAND].includes(this.pageType)?this.pageSpecificData:null,relatedProductData:this.relatedProductData,viewedTogetherProductData:this.viewedTogetherProductData,excludedFields:this.productListPropValue.excludedFields,filters:null,infiniteScrollPage:null},[4,s(h)];case 1:return i.sent(),h.pageSpecificData=null,[2,h]}}))}))},d}();export{d as IkasProductListPropValueProvider};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{IkasThemeJsonPageType as i}from"@ikas/storefront-models";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductListType as r,IkasRelatedProductsType as d,IkasProductListSortType as o}from"../../models/ui/product-list/index.js";import{getInitial as a}from"../../models/ui/product-list/init.js";var s=function(){function s(t,e,i){this.relatedProductData=null,this.viewedTogetherProductData=null,this.recommendedProductData=null,this.pageType=t,this.productListPropValue=e,this.pageSpecificData=i,this.relatedProductData=null,this.viewedTogetherProductData=null,this.recommendedProductData=null}return s.prototype.getValue=function(){var s,u;return t(this,void 0,void 0,(function(){var t,c,p,l,n;return e(this,(function(e){switch(e.label){case 0:return this.productListPropValue.productListType===r.ALL&&this.productListPropValue.usePageFilter&&(this.pageType===i.CATEGORY?(p=this.pageSpecificData,c=p.id):this.pageType===i.BRAND&&(l=this.pageSpecificData,t=l.id)),this.productListPropValue.productListType===r.CATEGORY&&this.productListPropValue.category&&(c=this.productListPropValue.category),this.pageType===i.PRODUCT&&this.productListPropValue.productListType===r.RELATED_PRODUCTS&&this.productListPropValue.relatedProductsType&&this.pageSpecificData&&(this.relatedProductData={brandIds:null,categoryIds:null,productId:""},this.productListPropValue.relatedProductsType===d.CATEGORY?this.relatedProductData.categoryIds=this.pageSpecificData.categories.map((function(t){return t.id})):this.relatedProductData.brandIds=[null===(u=null===(s=this.pageSpecificData)||void 0===s?void 0:s.brand)||void 0===u?void 0:u.id],this.relatedProductData.productId=this.pageSpecificData.id),this.pageType===i.PRODUCT&&this.productListPropValue.productListType===r.VIEWED_TOGETHER&&this.pageSpecificData&&(this.viewedTogetherProductData={productIds:[]},this.viewedTogetherProductData.productIds=[this.pageSpecificData.id]),this.productListPropValue.productListType===r.RECOMMENDED_PRODUCTS&&this.productListPropValue.recommendedProductsType&&(this.recommendedProductData={brandIds:null,categoryIds:null},this.productListPropValue.recommendedProductsType.category?this.recommendedProductData.categoryIds=[this.productListPropValue.recommendedProductsType.category]:this.productListPropValue.recommendedProductsType.brand&&(this.recommendedProductData.brandIds=[this.productListPropValue.recommendedProductsType.brand])),n={data:[],count:0,page:1,limit:this.productListPropValue.initialLimit||10,type:this.productListPropValue.productListType||r.ALL,sort:this.productListPropValue.initialSort||o.LAST_ADDED,productListPropValue:this.productListPropValue,filterBrandId:t,filterCategoryId:c,pageType:this.pageType,pageSpecificData:[i.CATEGORY,i.BRAND].includes(this.pageType)?this.pageSpecificData:null,relatedProductData:this.relatedProductData,recommendedProductData:this.recommendedProductData,viewedTogetherProductData:this.viewedTogetherProductData,excludedFields:this.productListPropValue.excludedFields,filters:null,infiniteScrollPage:null},[4,a(n)];case 1:return e.sent(),n.pageSpecificData=null,[2,n]}}))}))},s}();export{s as IkasProductListPropValueProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-providers",
3
- "version": "5.0.23",
3
+ "version": "5.0.25",
4
4
  "description": "Data providers for ikas storefront theme components.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@rollup/plugin-commonjs": "^22.0.0",
20
- "@ikas/storefront-api": "^5.0.23",
21
- "@ikas/storefront-config": "^5.0.23",
22
- "@ikas/storefront-model-functions": "^5.0.23",
23
- "@ikas/storefront-models": "^5.0.23",
20
+ "@ikas/storefront-api": "^5.0.25",
21
+ "@ikas/storefront-config": "^5.0.25",
22
+ "@ikas/storefront-model-functions": "^5.0.25",
23
+ "@ikas/storefront-models": "^5.0.25",
24
24
  "@rollup/plugin-node-resolve": "^13.3.0",
25
25
  "rollup-plugin-rename-node-modules": "^1.2.0",
26
26
  "@types/lodash": "^4.14.168",
@@ -38,10 +38,10 @@
38
38
  },
39
39
  "peerDependencies": {
40
40
  "mobx": "^6.1.3",
41
- "@ikas/storefront-api": "^5.0.23",
42
- "@ikas/storefront-config": "^5.0.23",
43
- "@ikas/storefront-model-functions": "^5.0.23",
44
- "@ikas/storefront-models": "^5.0.23",
41
+ "@ikas/storefront-api": "^5.0.25",
42
+ "@ikas/storefront-config": "^5.0.25",
43
+ "@ikas/storefront-model-functions": "^5.0.25",
44
+ "@ikas/storefront-models": "^5.0.25",
45
45
  "lodash": "^4.17.21"
46
46
  }
47
47
  }