@ikas/storefront-providers 4.8.0 → 4.8.2

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,6 +9,7 @@ export declare type IkasProductListPropValue = {
9
9
  usePageFilter?: boolean | null;
10
10
  category?: string | null;
11
11
  relatedProductsType?: IkasRelatedProductsType | null;
12
+ excludedFields?: string[] | null;
12
13
  };
13
14
  declare type IkasProductVariantId = {
14
15
  productId: string;
@@ -24,6 +24,7 @@ export declare type IkasProductList = {
24
24
  recommendFor?: string | null;
25
25
  isLoading?: boolean;
26
26
  fetchRequestTime?: number;
27
+ excludedFields?: string[] | null;
27
28
  };
28
29
  export declare enum IkasProductListType {
29
30
  ALL = "ALL",
@@ -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 u}from"./index.js";import{IkasProductFilterFunctions as d}from"@ikas/storefront-model-functions";import{searchProducts as s,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as v,SortByTypeEnum as p}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 C(i,o){var s,l,c,f;return e(this,void 0,void 0,(function(){var e,v,p,I,C,A,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=u.DECRASING_DISCOUNT;break;case n.LOWEST_DISCOUNT_RATIO:e.sort=u.INCREASING_DISCOUNT;break;case n.HIGHEST_PRICE:e.sort=u.DECREASING_PRICE;break;case n.LOWEST_PRICE:e.sort=u.INCREASING_PRICE;break;case n.NEWEST:e.sort=u.LAST_ADDED;break;case n.OLDEST:e.sort=u.FIRST_ADDED;break;case n.MANUALLY:e.sort=u.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,p=i.limit,!function(e){return e.type===a.ALL||e.type===a.CATEGORY}(i)||i.filters?[3,3]:[4,g(i)];case 2:t.sent(),t.label=3;case 3:if(D(i))return i.data=[],i.page=1,i.minPage=1,i.count=0,i.initialized=!0,[2,!0];if(void 0,E(i))v=void 0,p=200;else if(function(e){return e.type===a.DISCOUNTED}(i))v=1,p=10;else if(function(e){return e.type===a.RECOMMENDED}(i))v=1,p=10;else if(T(i))return[2];return[4,S(i,v||1,p||10,undefined)];case 4:return(I=t.sent())&&i.fetchRequestTime===e?(C=[],T(i)?[2]:(E(i)?(A=i.productListPropValue.productIds||[],C=(null==A?void 0:A.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})))||[]):C=(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=d.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=C,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 E(e){return e.type===a.STATIC}function T(e){return e.type===a.LAST_VIEWED}function D(e){return e.type===a.SEARCH}function S(r,n,f,C){var T,S,g;return e(this,void 0,void 0,(function(){var e,A,y,R,h;return t(this,(function(t){switch(t.label){case 0:return e=[],A=[],y=d.getValueList,null===(T=r.filters)||void 0===T||T.forEach((function(t){var r=y(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&A.push({id:t.id,type:t.type,displayType:t.displayType})})),R=null===(S=r.filterCategories)||void 0===S?void 0:S.filter((function(e){return e.isSelected})).map((function(e){return e.id})),h=function(e){var t,r;switch(e.sort){case u.INCREASING_PRICE:t=v.ASC,r=p.PRICE;break;case u.DECREASING_PRICE:t=v.DESC,r=p.PRICE;break;case u.FIRST_ADDED:t=v.ASC,r=p.CREATED_AT;break;case u.LAST_ADDED:t=v.DESC,r=p.CREATED_AT;break;case u.INCREASING_DISCOUNT:t=v.ASC,r=p.DISCOUNT_RATIO;break;case u.DECRASING_DISCOUNT:t=v.DESC,r=p.DISCOUNT_RATIO;break;case u.FEATURED:if(D(e))return;t=v.ASC,r=p.MANUAL_SORT;break;case u.DEFAULT:t=void 0,r=void 0}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[4,s({input:{page:n,perPage:f,productIdList:E(r)?null===(g=r.productListPropValue.productIds)||void 0===g?void 0:g.map((function(e){return e.productId})):C,filterList:e,facetList:A,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}})]}}))}))}function g(r){var n,a,o;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: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===(a=null==e?void 0:e.data)||void 0===a?void 0:a.categories)||null,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(o=r.filterCategories)||void 0===o?void 0:o.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]}}))}))}export{C 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 u}from"@ikas/storefront-model-functions";import{searchProducts as s,getSuggestedProducts as l,GetSuggestedProductsMethodEnum as c,getProductFilterData as f,SortByDirectionEnum as v,SortByTypeEnum as p}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 C(i,o){var s,l,c,f;return e(this,void 0,void 0,(function(){var e,v,p,I,C,A,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,p=i.limit,!function(e){return e.type===a.ALL||e.type===a.CATEGORY}(i)||i.filters?[3,3]:[4,g(i)];case 2:t.sent(),t.label=3;case 3:if(D(i))return i.data=[],i.page=1,i.minPage=1,i.count=0,i.initialized=!0,[2,!0];if(void 0,E(i))v=void 0,p=200;else if(function(e){return e.type===a.DISCOUNTED}(i))v=1,p=10;else if(function(e){return e.type===a.RECOMMENDED}(i))v=1,p=10;else if(T(i))return[2];return[4,S(i,v||1,p||10,undefined)];case 4:return(I=t.sent())&&i.fetchRequestTime===e?(C=[],T(i)?[2]:(E(i)?(A=i.productListPropValue.productIds||[],C=(null==A?void 0:A.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})))||[]):C=(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=C,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 E(e){return e.type===a.STATIC}function T(e){return e.type===a.LAST_VIEWED}function D(e){return e.type===a.SEARCH}function S(r,n,f,C){var T,S,g;return e(this,void 0,void 0,(function(){var e,A,y,R,h,L;return t(this,(function(t){switch(t.label){case 0:return e=[],A=[],y=u.getValueList,null===(T=r.filters)||void 0===T||T.forEach((function(t){var r=y(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&A.push({id:t.id,type:t.type,displayType:t.displayType})})),R=null===(S=r.filterCategories)||void 0===S?void 0:S.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=p.PRICE;break;case d.DECREASING_PRICE:t=v.DESC,r=p.PRICE;break;case d.FIRST_ADDED:t=v.ASC,r=p.CREATED_AT;break;case d.LAST_ADDED:t=v.DESC,r=p.CREATED_AT;break;case d.INCREASING_DISCOUNT:t=v.ASC,r=p.DISCOUNT_RATIO;break;case d.DECRASING_DISCOUNT:t=v.DESC,r=p.DISCOUNT_RATIO;break;case d.FEATURED:if(D(e))return;t=v.ASC,r=p.MANUAL_SORT;break;case d.DEFAULT:t=void 0,r=void 0}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 L={input:{page:n,perPage:f,productIdList:E(r)?null===(g=r.productListPropValue.productIds)||void 0===g?void 0:g.map((function(e){return e.productId})):C,filterList:e,facetList:A,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(L,r.excludedFields)]}}))}))}function g(r){var n,a,o;return e(this,void 0,void 0,(function(){var e,d;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===(a=null==e?void 0:e.data)||void 0===a?void 0:a.categories)||null,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(d=null===(o=r.filterCategories)||void 0===o?void 0:o.find((function(e){return e.id===r.filterCategoryId})))&&(d.isSelected=!0),r.filters&&r.filters.sort((function(e,t){return e.order>t.order?1:-1})),[2]}}))}))}export{C as getInitial};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as a}from'./../ext/tslib/tslib.es6.js';import n from"lodash/uniq";import r from"lodash/flatten";import{makeAutoObservable as i}from"mobx";import{IkasThemeJsonPageType as s,IkasCategoryConditionTypeEnum as o,IkasRaffleMetadataTargetType as u,IkasBlogMetaDataTargetType as c,IkasHTMLMetaDataTargetType as p,IkasThemeJsonComponentPropType as l}from"@ikas/storefront-models";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import{IkasProductFunctions as h}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as g}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as f}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as v}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as m}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as T}from"./prop-value/link.js";import{IkasImageListPropValueProvider as S}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as D}from"./prop-value/text.js";import{IkasColorPropValueProvider as y}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as O}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as L}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as P}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as b}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as I}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as w}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as C}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as R}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as E}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as A}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as V}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as j}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as G}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as _}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as F}from"./prop-value/raffle-list.js";import{listMerchantSettings as B,listCustomerReviewSummary as M,listProductOptionSet as U,searchProducts as k,listProductBrand as N,listCategory as q,listBlog as Y,listBlogCategory as x,listStorefrontRaffle as J,listHTMLMetaData as K,listRaffleMetaData as X,listBlogMetaData as H}from"@ikas/storefront-api";import{populateRaffleProducts as $}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as z}from"./prop-value/video.js";var Q=function(){function Q(e,t,a){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=a,i(this)}return Object.defineProperty(Q.prototype,"page",{get:function(){var e=this;if(this.pageType===s.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===s.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(Q.prototype,"nextPageData",{get:function(){var e,t,n,r,i,o=[],u=[];return this.pageComponentPropValues.forEach((function(e){if(u.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!o.find((function(t){return t.id===e.component.id}))){var t=a({},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,o.push(t)}})),{props:JSON.parse(JSON.stringify({propValues:u,themeJsonComponents:o,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||s.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(n=this.page)||void 0===n?void 0:n.description)||null,canonicals:(null===(r=this.page)||void 0===r?void 0:r.canonicals)||null,disableIndex:(null===(i=this.page)||void 0===i?void 0:i.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:d.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),Object.defineProperty(Q.prototype,"specification",{get:function(){var e,t,a=this,n=this.page;return(null==n?void 0:n.type)===s.PRODUCT?null===(e=n.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=a.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==n?void 0:n.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=a.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(Q.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(Q.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),Q.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,B({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},Q.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,a=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 a.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]}}))}))},Q.prototype.getProductReviewSummary=function(){var a,n,r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==s.PRODUCT?[3,2]:[4,M({productId:{eq:null===(a=this.pageSpecificData)||void 0===a?void 0:a.id}})];case 1:(e=t.sent()).isSuccess&&(null===(r=null===(n=e.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},Q.prototype.getPageSpecificData=function(){var a,n,r,i;return e(this,void 0,void 0,(function(){var l,g,f,v,m,T,S,D,y,O,L=this;return t(this,(function(P){switch(P.label){case 0:return this.pageType&&![s.BRAND,s.PRODUCT,s.CATEGORY,s.BLOG,s.BLOG_CATEGORY,s.RAFFLE_DETAIL].includes(this.pageType)?[2]:(l=this.pageParams.slug)?(g=[],(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(s.BLOG))||(null===(n=this.possiblePageTypes)||void 0===n?void 0:n.includes(s.BLOG_CATEGORY))?[4,H({slug:{eq:l}})]:[3,2]):[2];case 1:return f=P.sent(),(g=(null===(r=f.data)||void 0===r?void 0:r.data)||[]).length?[3,6]:[2];case 2:return(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(s.RAFFLE_DETAIL))?[4,X({slug:{eq:l}})]:[3,4];case 3:return f=P.sent(),(g=f.data||[]).length?[3,6]:[2];case 4:return[4,K({slug:{eq:l}})];case 5:if(f=P.sent(),!(g=f.data||[])||!g.length)return[2];P.label=6;case 6:if(!(v=g[0]).targetId)return[2];switch(m=function(){return e(L,void 0,void 0,(function(){var e,a,n,r,i,o,u,c,p,l,g;return t(this,(function(t){switch(t.label){case 0:return[4,k({input:{productIdList:[v.targetId],priceListId:d.getPriceListId(),salesChannelId:d.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(l=null===(p=null==e?void 0:e.data)||void 0===p?void 0:p.data)||void 0===l?void 0:l.length)?(a=e.data.data[0]).productOptionSetId?[4,U({id:{eq:a.productOptionSetId}})]:[3,3]:[2];case 2:(n=t.sent()).isSuccess&&(null===(g=null==n?void 0:n.data)||void 0===g?void 0:g.length)&&(a.productOptionSet=n.data[0]),t.label=3;case 3:return(r=a.variants.find((function(e){return e.isActive})))?(a.selectedVariantValues=r.variantValues,i=h.getDisplayedVariantTypes,this.pageSpecificData=a,(o=i(this.pageSpecificData,a.selectedVariantValues)).length&&(u=o[0]).displayedVariantValues.length&&(c=u.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=c.variant.variantValues),this.pageType=s.PRODUCT,this.setPageMetaData(v),[2]):[2]}}))}))},T=function(){return e(L,void 0,void 0,(function(){var e,a,n,r;return t(this,(function(t){switch(t.label){case 0:return[4,N({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(n=e.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BRAND,this.setPageMetaData(v),[2]):[2]}}))}))},S=function(){return e(L,void 0,void 0,(function(){var e,a,n,r,i,u,c,p;return t(this,(function(t){switch(t.label){case 0:return[4,q({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(u=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===u?void 0:u.length)?(a=e.data.data[0]).conditions&&(n=a.conditions.find((function(e){return e.conditionType===o.PRODUCT_BRAND})))?[4,N({id:{eq:n.valueList[0]}})]:[3,3]:[2];case 2:if(!(r=t.sent()).isSuccess||!(null===(p=null===(c=r.data)||void 0===c?void 0:c.data)||void 0===p?void 0:p.length))return[2];a.conditionValues={brand:r.data.data[0]},t.label=3;case 3:return this.pageSpecificData=a,this.pageType=s.CATEGORY,this.setPageMetaData(v),[2]}}))}))},D=function(){return e(L,void 0,void 0,(function(){var e,a,n,r;return t(this,(function(t){switch(t.label){case 0:return[4,Y({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(n=e.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BLOG,this.setPageMetaData(v),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,a,n,r;return t(this,(function(t){switch(t.label){case 0:return[4,x({id:{eq:v.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(n=e.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BLOG_CATEGORY,this.setPageMetaData(v),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,a,n,r;return t(this,(function(t){switch(t.label){case 0:return[4,J({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(n=e.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.length)?(a=e.data.data[0],[4,$([a])]):[2];case 2:return t.sent(),this.pageSpecificData=a,this.pageType=s.RAFFLE_DETAIL,this.setPageMetaData(v),[2]}}))}))},v.targetType){case p.BRAND:return[3,7];case p.CATEGORY:return[3,9];case p.PRODUCT:return[3,11];case c.BLOG:return[3,13];case c.BLOG_CATEGORY:return[3,15];case u.RAFFLE:return[3,17]}return[3,19];case 7:return[4,T()];case 8:return[2,P.sent()];case 9:return[4,S()];case 10:return[2,P.sent()];case 11:return[4,m()];case 12:return[2,P.sent()];case 13:return[4,D()];case 14:return[2,P.sent()];case 15:return[4,y()];case 16:return[2,P.sent()];case 17:return[4,O()];case 18:return[2,P.sent()];case 19:return[3,20];case 20:return[2]}}))}))},Q.prototype.getPageComponentPropValues=function(a){return e(this,void 0,void 0,(function(){var n,r,i,s=this;return t(this,(function(o){switch(o.label){case 0:return n=this.theme.components.find((function(e){return e.id===a.componentId})),r={pageComponent:a,component:n,propValues:{}},i=function(n){return e(s,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=r.propValues,i=n.name,[4,this.getPageComponentPropValue(a,n)];case 1:return e[i]=t.sent(),[2]}}))}))},[4,Promise.all(n.props.map(i))];case 1:return o.sent(),[2,r]}}))}))},Q.prototype.getPageComponentPropValue=function(a,n){return e(this,void 0,void 0,(function(){var e,r,i,s,o,u=this;return t(this,(function(t){switch(t.label){case 0:if(r=a.propValues[n.name],i=[l.RAFFLE_LIST],null==r&&!i.includes(n.type))return[2,null];switch(n.type){case l.TEXT:return[3,1];case l.RICH_TEXT:return[3,2];case l.BOOLEAN:return[3,3];case l.IMAGE:return[3,4];case l.IMAGE_LIST:return[3,5];case l.BRAND:return[3,6];case l.BRAND_LIST:return[3,7];case l.PRODUCT_LIST:return[3,8];case l.PRODUCT_DETAIL:return[3,9];case l.PRODUCT_ATTRIBUTE:return[3,10];case l.PRODUCT_ATTRIBUTE_LIST:return[3,11];case l.CATEGORY:return[3,12];case l.CATEGORY_LIST:return[3,13];case l.LINK:case l.LIST_OF_LINK:return[3,14];case l.COLOR:return[3,15];case l.CUSTOM:return[3,16];case l.COMPONENT:case l.COMPONENT_LIST:return[3,17];case l.BLOG:return[3,19];case l.BLOG_LIST:return[3,20];case l.BLOG_CATEGORY:return[3,21];case l.BLOG_CATEGORY_LIST:return[3,22];case l.RAFFLE:return[3,23];case l.RAFFLE_LIST:return[3,24];case l.SLIDER:return[3,25];case l.VIDEO:return[3,26]}return[3,27];case 1:return e=new D(r),[3,28];case 2:return e=new C(r),[3,28];case 3:return e=new O(r),[3,28];case 4:return e=new L(r),[3,28];case 5:return e=new S(r),[3,28];case 6:return e=new m(r),[3,28];case 7:return e=new v(r),[3,28];case 8:return e=new g(this.pageType,r,this.pageSpecificData),[3,28];case 9:return e=new f(r),[3,28];case 10:return e=new A(r),[3,28];case 11:return e=new V(r),[3,28];case 12:return e=new P(r),[3,28];case 13:return e=new b(r),[3,28];case 14:return e=new T(r,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new y(r),[3,28];case 16:return(s=this.theme.customData.find((function(e){return e.id===n.customDataId})))?(e=new I(r,s,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return o=r,[4,Promise.all(o.map((function(e){return u.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new R(r),[3,28];case 20:return e=new E(this.pageType,r,this.pageSpecificData),[3,28];case 21:return e=new j(r),[3,28];case 22:return e=new G(r),[3,28];case 23:return e=new _(r),[3,28];case 24:return e=new F,[3,28];case 25:return e=new w(r),[3,28];case 26:return e=new z(r),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},Q.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)},Q.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,a,n;return t(this,(function(t){switch(t.label){case 0:return e=[],a=[],n=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":a.push(t);break;case"RAFFLE":n.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(a,"BLOG"),this.getLinkSlugs(n,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},Q.prototype.getLinkSlugs=function(a,r){return e(this,void 0,void 0,(function(){var i,s,o=this;return t(this,(function(u){switch(u.label){case 0:return i=n(a.map((function(e){return e.id}))),s=[],i.length?[4,function(){return e(o,void 0,void 0,(function(){var e,a,n,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],r){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,K({targetId:{in:i}})];case 2:return a=t.sent(),e=a.data||[],[3,8];case 3:return[4,H({targetId:{in:i}})];case 4:return n=t.sent(),e=(null===(u=n.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,X({targetId:{in:i}})];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(),a.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},Q.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var a=r(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),n=[];return n.push(e),n=n.concat(a)},Q}();export{Q as IkasPageDataProvider};
1
+ import{__awaiter as e,__generator as t,__assign as n}from'./../ext/tslib/tslib.es6.js';import a from"lodash/uniq";import r from"lodash/flatten";import{makeAutoObservable as i}from"mobx";import{IkasThemeJsonPageType as s,IkasCategoryConditionTypeEnum as o,IkasRaffleMetadataTargetType as u,IkasBlogMetaDataTargetType as c,IkasHTMLMetaDataTargetType as p,IkasThemeJsonComponentPropType as l}from"@ikas/storefront-models";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import{IkasProductFunctions as h}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as g}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as f}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as v}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as m}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as T}from"./prop-value/link.js";import{IkasImageListPropValueProvider as S}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as D}from"./prop-value/text.js";import{IkasColorPropValueProvider as y}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as O}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as L}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as P}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as b}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as I}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as w}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as C}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as R}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as E}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as A}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as V}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as j}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as F}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as G}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as _}from"./prop-value/raffle-list.js";import{listMerchantSettings as B,listCustomerReviewSummary as M,listProductOptionSet as U,searchProducts as k,listProductBrand as N,listCategory as q,listBlog as x,listBlogCategory as Y,listStorefrontRaffle as J,listHTMLMetaData as K,listRaffleMetaData as X,listBlogMetaData as H}from"@ikas/storefront-api";import{populateRaffleProducts as $}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as z}from"./prop-value/video.js";var Q=function(){function Q(e,t,n){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,i(this)}return Object.defineProperty(Q.prototype,"page",{get:function(){var e=this;if(this.pageType===s.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===s.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(Q.prototype,"nextPageData",{get:function(){var e,t,a,r,i,o=[],u=[];return this.pageComponentPropValues.forEach((function(e){if(u.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!o.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,o.push(t)}})),{props:JSON.parse(JSON.stringify({propValues:u,themeJsonComponents:o,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||s.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(a=this.page)||void 0===a?void 0:a.description)||null,canonicals:(null===(r=this.page)||void 0===r?void 0:r.canonicals)||null,disableIndex:(null===(i=this.page)||void 0===i?void 0:i.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:d.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),Object.defineProperty(Q.prototype,"specification",{get:function(){var e,t,n=this,a=this.page;return(null==a?void 0:a.type)===s.PRODUCT?null===(e=a.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==a?void 0:a.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(Q.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(Q.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),Q.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,B({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},Q.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]}}))}))},Q.prototype.getProductReviewSummary=function(){var n,a,r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==s.PRODUCT?[3,2]:[4,M({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(r=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===r?void 0:r.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},Q.prototype.getPageSpecificData=function(){var n,a,r,i;return e(this,void 0,void 0,(function(){var l,g,f,v,m,T,S,D,y,O,L=this;return t(this,(function(P){switch(P.label){case 0:return this.pageType&&![s.BRAND,s.PRODUCT,s.CATEGORY,s.BLOG,s.BLOG_CATEGORY,s.RAFFLE_DETAIL].includes(this.pageType)?[2]:(l=this.pageParams.slug)?(g=[],(null===(n=this.possiblePageTypes)||void 0===n?void 0:n.includes(s.BLOG))||(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(s.BLOG_CATEGORY))?[4,H({slug:{eq:l}})]:[3,2]):[2];case 1:return f=P.sent(),(g=(null===(r=f.data)||void 0===r?void 0:r.data)||[]).length?[3,6]:[2];case 2:return(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(s.RAFFLE_DETAIL))?[4,X({slug:{eq:l}})]:[3,4];case 3:return f=P.sent(),(g=f.data||[]).length?[3,6]:[2];case 4:return[4,K({slug:{eq:l}})];case 5:if(f=P.sent(),!(g=f.data||[])||!g.length)return[2];P.label=6;case 6:if(!(v=g[0]).targetId)return[2];switch(m=function(){return e(L,void 0,void 0,(function(){var e,n,a,r,i,o,u,c,p,l,g;return t(this,(function(t){switch(t.label){case 0:return[4,k({input:{productIdList:[v.targetId],priceListId:d.getPriceListId(),salesChannelId:d.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(l=null===(p=null==e?void 0:e.data)||void 0===p?void 0:p.data)||void 0===l?void 0:l.length)?(n=e.data.data[0]).productOptionSetId?[4,U({id:{eq:n.productOptionSetId}})]:[3,3]:[2];case 2:(a=t.sent()).isSuccess&&(null===(g=null==a?void 0:a.data)||void 0===g?void 0:g.length)&&(n.productOptionSet=a.data[0]),t.label=3;case 3:return(r=n.variants.find((function(e){return e.isActive})))?(n.selectedVariantValues=r.variantValues,i=h.getDisplayedVariantTypes,this.pageSpecificData=n,(o=i(this.pageSpecificData,n.selectedVariantValues)).length&&(u=o[0]).displayedVariantValues.length&&(c=u.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=c.variant.variantValues),this.pageType=s.PRODUCT,this.setPageMetaData(v),[2]):[2]}}))}))},T=function(){return e(L,void 0,void 0,(function(){var e,n,a,r;return t(this,(function(t){switch(t.label){case 0:return[4,N({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===r?void 0:r.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=s.BRAND,this.setPageMetaData(v),[2]):[2]}}))}))},S=function(){return e(L,void 0,void 0,(function(){var e,n,a,r,i,u,c,p;return t(this,(function(t){switch(t.label){case 0:return[4,q({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(u=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===u?void 0:u.length)?(n=e.data.data[0]).conditions&&(a=n.conditions.find((function(e){return e.conditionType===o.PRODUCT_BRAND})))?[4,N({id:{eq:a.valueList[0]}})]:[3,3]:[2];case 2:if(!(r=t.sent()).isSuccess||!(null===(p=null===(c=r.data)||void 0===c?void 0:c.data)||void 0===p?void 0:p.length))return[2];n.conditionValues={brand:r.data.data[0]},t.label=3;case 3:return this.pageSpecificData=n,this.pageType=s.CATEGORY,this.setPageMetaData(v),[2]}}))}))},D=function(){return e(L,void 0,void 0,(function(){var e,n,a,r;return t(this,(function(t){switch(t.label){case 0:return[4,x({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===r?void 0:r.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=s.BLOG,this.setPageMetaData(v),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,n,a,r;return t(this,(function(t){switch(t.label){case 0:return[4,Y({id:{eq:v.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===r?void 0:r.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=s.BLOG_CATEGORY,this.setPageMetaData(v),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,n,a,r;return t(this,(function(t){switch(t.label){case 0:return[4,J({id:{eq:v.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(r=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===r?void 0:r.length)?(n=e.data.data[0],[4,$([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=s.RAFFLE_DETAIL,this.setPageMetaData(v),[2]}}))}))},v.targetType){case p.BRAND:return[3,7];case p.CATEGORY:return[3,9];case p.PRODUCT:return[3,11];case c.BLOG:return[3,13];case c.BLOG_CATEGORY:return[3,15];case u.RAFFLE:return[3,17]}return[3,19];case 7:return[4,T()];case 8:return[2,P.sent()];case 9:return[4,S()];case 10:return[2,P.sent()];case 11:return[4,m()];case 12:return[2,P.sent()];case 13:return[4,D()];case 14:return[2,P.sent()];case 15:return[4,y()];case 16:return[2,P.sent()];case 17:return[4,O()];case 18:return[2,P.sent()];case 19:return[3,20];case 20:return[2]}}))}))},Q.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var a,r,i,s=this;return t(this,(function(o){switch(o.label){case 0:return a=this.theme.components.find((function(e){return e.id===n.componentId})),r={pageComponent:n,component:a,propValues:{}},i=function(a){return e(s,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=r.propValues,i=a.name,[4,this.getPageComponentPropValue(n,a)];case 1:return e[i]=t.sent(),[2]}}))}))},[4,Promise.all(a.props.map(i))];case 1:return o.sent(),[2,r]}}))}))},Q.prototype.getPageComponentPropValue=function(a,r){return e(this,void 0,void 0,(function(){var e,i,s,o,u,c,p,d,h=this;return t(this,(function(t){switch(t.label){case 0:if(i=a.propValues[r.name],s=[l.RAFFLE_LIST],null==i&&!s.includes(r.type))return[2,null];switch(r.type){case l.TEXT:return[3,1];case l.RICH_TEXT:return[3,2];case l.BOOLEAN:return[3,3];case l.IMAGE:return[3,4];case l.IMAGE_LIST:return[3,5];case l.BRAND:return[3,6];case l.BRAND_LIST:return[3,7];case l.PRODUCT_LIST:return[3,8];case l.PRODUCT_DETAIL:return[3,9];case l.PRODUCT_ATTRIBUTE:return[3,10];case l.PRODUCT_ATTRIBUTE_LIST:return[3,11];case l.CATEGORY:return[3,12];case l.CATEGORY_LIST:return[3,13];case l.LINK:case l.LIST_OF_LINK:return[3,14];case l.COLOR:return[3,15];case l.CUSTOM:return[3,16];case l.COMPONENT:case l.COMPONENT_LIST:return[3,17];case l.BLOG:return[3,19];case l.BLOG_LIST:return[3,20];case l.BLOG_CATEGORY:return[3,21];case l.BLOG_CATEGORY_LIST:return[3,22];case l.RAFFLE:return[3,23];case l.RAFFLE_LIST:return[3,24];case l.SLIDER:return[3,25];case l.VIDEO:return[3,26]}return[3,27];case 1:return e=new D(i),[3,28];case 2:return e=new C(i),[3,28];case 3:return e=new O(i),[3,28];case 4:return e=new L(i),[3,28];case 5:return e=new S(i),[3,28];case 6:return e=new m(i),[3,28];case 7:return e=new v(i),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===a.componentId})),u=[],o&&(c=o.props.find((function(e){return e.name===r.name})))&&(u=c.excludedFields||[]),e=new g(this.pageType,n(n({},i),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new f(i),[3,28];case 10:return e=new A(i),[3,28];case 11:return e=new V(i),[3,28];case 12:return e=new P(i),[3,28];case 13:return e=new b(i),[3,28];case 14:return e=new T(i,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new y(i),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===r.customDataId})))?(e=new I(i,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return d=i,[4,Promise.all(d.map((function(e){return h.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new R(i),[3,28];case 20:return e=new E(this.pageType,i,this.pageSpecificData),[3,28];case 21:return e=new j(i),[3,28];case 22:return e=new F(i),[3,28];case 23:return e=new G(i),[3,28];case 24:return e=new _,[3,28];case 25:return e=new w(i),[3,28];case 26:return e=new z(i),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},Q.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)},Q.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,a;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],a=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":a.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(a,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},Q.prototype.getLinkSlugs=function(n,r){return e(this,void 0,void 0,(function(){var i,s,o=this;return t(this,(function(u){switch(u.label){case 0:return i=a(n.map((function(e){return e.id}))),s=[],i.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,a,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],r){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,K({targetId:{in:i}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,H({targetId:{in:i}})];case 4:return a=t.sent(),e=(null===(u=a.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,X({targetId:{in:i}})];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]}}))}))},Q.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=r(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),a=[];return a.push(e),a=a.concat(n)},Q}();export{Q as IkasPageDataProvider};
@@ -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 r,IkasRelatedProductsType as a,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===r.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===r.CATEGORY&&this.productListPropValue.category&&(u=this.productListPropValue.category),this.pageType===e.PRODUCT&&this.productListPropValue.productListType===r.RELATED_PRODUCTS&&this.productListPropValue.relatedProductsType&&this.pageSpecificData&&(this.relatedProductData={brandIds:null,categoryIds:null,productId:""},this.productListPropValue.relatedProductsType===a.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===r.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||r.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:void 0,relatedProductData:this.relatedProductData,viewedTogetherProductData:this.viewedTogetherProductData,filters:null,infiniteScrollPage:null},[4,s(h)];case 1:return i.sent(),[2,h]}}))}))},d}();export{d as IkasProductListPropValueProvider};
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 r,IkasRelatedProductsType as a,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===r.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===r.CATEGORY&&this.productListPropValue.category&&(u=this.productListPropValue.category),this.pageType===e.PRODUCT&&this.productListPropValue.productListType===r.RELATED_PRODUCTS&&this.productListPropValue.relatedProductsType&&this.pageSpecificData&&(this.relatedProductData={brandIds:null,categoryIds:null,productId:""},this.productListPropValue.relatedProductsType===a.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===r.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||r.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:void 0,relatedProductData:this.relatedProductData,viewedTogetherProductData:this.viewedTogetherProductData,excludedFields:this.productListPropValue.excludedFields,filters:null,infiniteScrollPage:null},[4,s(h)];case 1:return i.sent(),[2,h]}}))}))},d}();export{d as IkasProductListPropValueProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-providers",
3
- "version": "4.8.0",
3
+ "version": "4.8.2",
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": "^4.8.0",
21
- "@ikas/storefront-config": "^4.8.0",
22
- "@ikas/storefront-model-functions": "^4.8.0",
23
- "@ikas/storefront-models": "^4.8.0",
20
+ "@ikas/storefront-api": "^4.8.2",
21
+ "@ikas/storefront-config": "^4.8.2",
22
+ "@ikas/storefront-model-functions": "^4.8.2",
23
+ "@ikas/storefront-models": "^4.8.2",
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": "^4.8.0",
42
- "@ikas/storefront-config": "^4.8.0",
43
- "@ikas/storefront-model-functions": "^4.8.0",
44
- "@ikas/storefront-models": "^4.8.0",
41
+ "@ikas/storefront-api": "^4.8.2",
42
+ "@ikas/storefront-config": "^4.8.2",
43
+ "@ikas/storefront-model-functions": "^4.8.2",
44
+ "@ikas/storefront-models": "^4.8.2",
45
45
  "lodash": "^4.17.21"
46
46
  }
47
47
  }