@ikas/storefront-providers 4.2.0-beta.1 → 4.2.0-beta.10

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.
@@ -0,0 +1,4 @@
1
+ export declare type IkasImagePropValue = {
2
+ id: string;
3
+ altText: string | null;
4
+ };
@@ -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 o,IkasProductSearchShowStockOption as a,IkasProductListSortType as u}from"./index.js";import{IkasProductFilterFunctions as d}from"@ikas/storefront-model-functions";import{searchProducts as s,getRelatedProducts as l,getProductFilterData as c,SortByDirectionEnum as f,SortByTypeEnum as v}from"@ikas/storefront-api";import{IkasStorefrontConfig as p}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 I(i,a){var s,l,c,f;return e(this,void 0,void 0,(function(){var e,v,p,I,T,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)&&[o.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=a?i.page:1,p=i.limit,!function(e){return e.type===o.ALL||e.type===o.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,p=200;else if(function(e){return e.type===o.DISCOUNTED}(i))v=1,p=10;else if(function(e){return e.type===o.RECOMMENDED}(i))v=1,p=10;else if(E(i))return[2];return[4,A(i,v||1,p||10,undefined)];case 4:return(I=t.sent())&&i.fetchRequestTime===e?(T=[],E(i)?[2]:(C(i)?(g=i.productListPropValue.productIds||[],T=(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})),o=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==o?void 0:o.isActive)||(o=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&o)return r(r({},n),{selectedVariantValues:o.variantValues})})).filter((function(e){return!!e})))||[]):T=(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,o,a=null==t?void 0:t.find((function(t){return t.id===e.id}));a?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=a.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===(o=e.values)||void 0===o||o.forEach((function(e){return e.resultCount=0}))}));var o=null==t?void 0:t.find((function(e){return"category"===e.id}));o&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=o.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=T,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===o.STATIC}function E(e){return e.type===o.LAST_VIEWED}function S(e){return e.type===o.SEARCH}function A(r,n,c,I){var E,A,D;return e(this,void 0,void 0,(function(){var e,T,g,y,R;return t(this,(function(t){switch(t.label){case 0:return e=[],T=[],g=d.getValueList,null===(E=r.filters)||void 0===E||E.forEach((function(t){var r=g(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&T.push({id:t.id,type:t.type,displayType:t.displayType})})),y=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(e){return e.isSelected})).map((function(e){return e.id})),R=function(e){var t,r;switch(e.sort){case u.INCREASING_PRICE:t=f.ASC,r=v.PRICE;break;case u.DECREASING_PRICE:t=f.DESC,r=v.PRICE;break;case u.FIRST_ADDED:t=f.ASC,r=v.CREATED_AT;break;case u.LAST_ADDED:t=f.DESC,r=v.CREATED_AT;break;case u.INCREASING_DISCOUNT:t=f.ASC,r=v.DISCOUNT_RATIO;break;case u.DECRASING_DISCOUNT:t=f.DESC,r=v.DISCOUNT_RATIO;break;case u.FEATURED:if(S(e))return;t=f.ASC,r=v.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===o.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds,locale:p.getCurrentLocale()})]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,s({input:{page:n,perPage:c,productIdList:C(r)?null===(D=r.productListPropValue.productIds)||void 0===D?void 0:D.map((function(e){return e.productId})):I,filterList:e,facetList:T,brandId:r.pageType===i.BRAND&&r.type!==o.SEARCH?r.filterBrandId:void 0,categoryIdList:y&&y.length?y:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),query:r.searchKeyword,order:r.type===o.SEARCH?[]:R?[R]:[],showStockOption:p.getStockPreference()||a.SHOW_ALL}})]}}))}))}function D(r){var n,o,a;return e(this,void 0,void 0,(function(){var e,u;return t(this,(function(t){switch(t.label){case 0:return[4,c({categoryId:r.filterCategoryId?r.filterCategoryId:void 0,locale:p.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==e?void 0:e.data)||void 0===o?void 0:o.categories)||null,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(a=r.filterCategories)||void 0===a?void 0:a.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{I 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 o,IkasProductSearchShowStockOption as a,IkasProductListSortType as u}from"./index.js";import{IkasProductFilterFunctions as d}from"@ikas/storefront-model-functions";import{searchProducts as s,getSuggestedProducts as l,getProductFilterData as c,SortByDirectionEnum as f,SortByTypeEnum as v}from"@ikas/storefront-api";import{IkasStorefrontConfig as p}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 I(i,a){var s,l,c,f;return e(this,void 0,void 0,(function(){var e,v,p,I,T,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)&&[o.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=a?i.page:1,p=i.limit,!function(e){return e.type===o.ALL||e.type===o.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,p=200;else if(function(e){return e.type===o.DISCOUNTED}(i))v=1,p=10;else if(function(e){return e.type===o.RECOMMENDED}(i))v=1,p=10;else if(E(i))return[2];return[4,A(i,v||1,p||10,undefined)];case 4:return(I=t.sent())&&i.fetchRequestTime===e?(T=[],E(i)?[2]:(C(i)?(g=i.productListPropValue.productIds||[],T=(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})),o=null==n?void 0:n.variants.find((function(t){return t.id===e.variantId}));if((null==o?void 0:o.isActive)||(o=null==n?void 0:n.variants.find((function(e){return e.isActive}))),n&&o)return r(r({},n),{selectedVariantValues:o.variantValues})})).filter((function(e){return!!e})))||[]):T=(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,o,a=null==t?void 0:t.find((function(t){return t.id===e.id}));a?null===(r=e.values)||void 0===r||r.forEach((function(t){var r=a.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===(o=e.values)||void 0===o||o.forEach((function(e){return e.resultCount=0}))}));var o=null==t?void 0:t.find((function(e){return"category"===e.id}));o&&(null===(i=e.filterCategories)||void 0===i||i.forEach((function(e){var t=o.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=T,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===o.STATIC}function E(e){return e.type===o.LAST_VIEWED}function S(e){return e.type===o.SEARCH}function A(r,n,c,I){var E,A,D;return e(this,void 0,void 0,(function(){var e,T,g,y,R;return t(this,(function(t){switch(t.label){case 0:return e=[],T=[],g=d.getValueList,null===(E=r.filters)||void 0===E||E.forEach((function(t){var r=g(t);r.length&&e.push({id:t.id,type:t.type,displayType:t.displayType,valueList:r}),t.isFacetFilter&&T.push({id:t.id,type:t.type,displayType:t.displayType})})),y=null===(A=r.filterCategories)||void 0===A?void 0:A.filter((function(e){return e.isSelected})).map((function(e){return e.id})),R=function(e){var t,r;switch(e.sort){case u.INCREASING_PRICE:t=f.ASC,r=v.PRICE;break;case u.DECREASING_PRICE:t=f.DESC,r=v.PRICE;break;case u.FIRST_ADDED:t=f.ASC,r=v.CREATED_AT;break;case u.LAST_ADDED:t=f.DESC,r=v.CREATED_AT;break;case u.INCREASING_DISCOUNT:t=f.ASC,r=v.DISCOUNT_RATIO;break;case u.DECRASING_DISCOUNT:t=f.DESC,r=v.DISCOUNT_RATIO;break;case u.FEATURED:if(S(e))return;t=f.ASC,r=v.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===o.RELATED_PRODUCTS}(r)&&r.relatedProductData?[4,l({priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),productId:r.relatedProductData.productId,brandIds:r.relatedProductData.brandIds,categoryIds:r.relatedProductData.categoryIds,locale:p.getCurrentLocale()})]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,s({input:{page:n,perPage:c,productIdList:C(r)?null===(D=r.productListPropValue.productIds)||void 0===D?void 0:D.map((function(e){return e.productId})):I,filterList:e,facetList:T,brandId:r.pageType===i.BRAND&&r.type!==o.SEARCH?r.filterBrandId:void 0,categoryIdList:y&&y.length?y:r.filterCategoryId?[r.filterCategoryId]:void 0,priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),query:r.searchKeyword,order:r.type===o.SEARCH?[]:R?[R]:[],showStockOption:p.getStockPreference()||a.SHOW_ALL}})]}}))}))}function D(r){var n,o,a;return e(this,void 0,void 0,(function(){var e,u;return t(this,(function(t){switch(t.label){case 0:return[4,c({categoryId:r.filterCategoryId?r.filterCategoryId:void 0,locale:p.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==e?void 0:e.data)||void 0===o?void 0:o.categories)||null,r.pageType!==i.CATEGORY&&r.filterCategoryId&&(u=null===(a=r.filterCategories)||void 0===a?void 0:a.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{I as getInitial};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as a}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import n from"lodash/flatten";import{makeAutoObservable as i}from"mobx";import{IkasThemeJsonPageType as s,IkasRaffleMetadataTargetType as o,IkasBlogMetaDataTargetType as u,IkasHTMLMetaDataTargetType as c,IkasThemeJsonComponentPropType as p}from"@ikas/storefront-models";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{IkasProductFunctions as d}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as h}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as g}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as f}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as v}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as m}from"./prop-value/link.js";import{IkasImageListPropValueProvider as T}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as S}from"./prop-value/text.js";import{IkasColorPropValueProvider as y}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as D}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as L}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as O}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as P}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as b}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as I}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as w}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as C}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as R}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as E}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as A}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as V}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as j}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as G}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as F}from"./prop-value/raffle-list.js";import{listMerchantSettings as _,listCustomerReviewSummary as B,listProductOptionSet as M,searchProducts as k,listProductBrand as U,listCategory as N,listBlog as q,listBlogCategory as Y,listStorefrontRaffle as x,listHTMLMetaData as J,listRaffleMetaData as K,listBlogMetaData as X}from"@ikas/storefront-api";import{populateRaffleProducts as H}from"./helpers/raffle.js";var $=function(){function $(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($.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($.prototype,"nextPageData",{get:function(){var e,t,r,n,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===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(n=this.page)||void 0===n?void 0:n.canonicals)||null,disableIndex:(null===(i=this.page)||void 0===i?void 0:i.disableIndex)||null,themeSettings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:l.toJSON()}))}},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"specification",{get:function(){var e,t,a=this,r=this.page;return(null==r?void 0:r.type)===s.PRODUCT?null===(e=r.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==r?void 0:r.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($.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($.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),$.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,_({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},$.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]}}))}))},$.prototype.getProductReviewSummary=function(){var a,r,n;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,B({productId:{eq:null===(a=this.pageSpecificData)||void 0===a?void 0:a.id}})];case 1:(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},$.prototype.getPageSpecificData=function(){var a,r,n,i;return e(this,void 0,void 0,(function(){var p,h,g,f,v,m,T,S,y,D,L=this;return t(this,(function(O){switch(O.label){case 0:return this.pageType&&![s.BRAND,s.PRODUCT,s.CATEGORY,s.BLOG,s.BLOG_CATEGORY,s.RAFFLE_DETAIL].includes(this.pageType)?[2]:(p=this.pageParams.slug)?(h=[],(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(s.BLOG))||(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(s.BLOG_CATEGORY))?[4,X({slug:{eq:p}})]:[3,2]):[2];case 1:return g=O.sent(),(h=(null===(n=g.data)||void 0===n?void 0:n.data)||[]).length?[3,6]:[2];case 2:return(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(s.RAFFLE_DETAIL))?[4,K({slug:{eq:p}})]:[3,4];case 3:return g=O.sent(),(h=g.data||[]).length?[3,6]:[2];case 4:return[4,J({slug:{eq:p}})];case 5:if(g=O.sent(),!(h=g.data||[])||!h.length)return[2];O.label=6;case 6:if(!(f=h[0]).targetId)return[2];switch(v=function(){return e(L,void 0,void 0,(function(){var e,a,r,n,i,o,u,c,p,h,g;return t(this,(function(t){switch(t.label){case 0:return[4,k({input:{productIdList:[f.targetId],priceListId:l.getPriceListId(),salesChannelId:l.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(h=null===(p=null==e?void 0:e.data)||void 0===p?void 0:p.data)||void 0===h?void 0:h.length)?(a=e.data.data[0]).productOptionSetId?[4,M({id:{eq:a.productOptionSetId}})]:[3,3]:[2];case 2:(r=t.sent()).isSuccess&&(null===(g=null==r?void 0:r.data)||void 0===g?void 0:g.length)&&(a.productOptionSet=r.data[0]),t.label=3;case 3:return(n=a.variants.find((function(e){return e.isActive})))?(a.selectedVariantValues=n.variantValues,i=d.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(f),[2]):[2]}}))}))},m=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,U({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BRAND,this.setPageMetaData(f),[2]):[2]}}))}))},T=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,N({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},S=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,q({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BLOG,this.setPageMetaData(f),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,Y({id:{eq:f.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BLOG_CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},D=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,x({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],[4,H([a])]):[2];case 2:return t.sent(),this.pageSpecificData=a,this.pageType=s.RAFFLE_DETAIL,this.setPageMetaData(f),[2]}}))}))},f.targetType){case c.BRAND:return[3,7];case c.CATEGORY:return[3,9];case c.PRODUCT:return[3,11];case u.BLOG:return[3,13];case u.BLOG_CATEGORY:return[3,15];case o.RAFFLE:return[3,17]}return[3,19];case 7:return[4,m()];case 8:return[2,O.sent()];case 9:return[4,T()];case 10:return[2,O.sent()];case 11:return[4,v()];case 12:return[2,O.sent()];case 13:return[4,S()];case 14:return[2,O.sent()];case 15:return[4,y()];case 16:return[2,O.sent()];case 17:return[4,D()];case 18:return[2,O.sent()];case 19:return[3,20];case 20:return[2]}}))}))},$.prototype.getPageComponentPropValues=function(a){return e(this,void 0,void 0,(function(){var r,n,i,s=this;return t(this,(function(o){switch(o.label){case 0:return r=this.theme.components.find((function(e){return e.id===a.componentId})),n={pageComponent:a,component:r,propValues:{}},i=function(r){return e(s,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=n.propValues,i=r.name,[4,this.getPageComponentPropValue(a,r)];case 1:return e[i]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(i))];case 1:return o.sent(),[2,n]}}))}))},$.prototype.getPageComponentPropValue=function(a,r){return e(this,void 0,void 0,(function(){var e,n,i,s,o,u=this;return t(this,(function(t){switch(t.label){case 0:if(n=a.propValues[r.name],i=[p.RAFFLE_LIST],null==n&&!i.includes(r.type))return[2,null];switch(r.type){case p.TEXT:return[3,1];case p.RICH_TEXT:return[3,2];case p.BOOLEAN:return[3,3];case p.IMAGE:return[3,4];case p.IMAGE_LIST:return[3,5];case p.BRAND:return[3,6];case p.BRAND_LIST:return[3,7];case p.PRODUCT_LIST:return[3,8];case p.PRODUCT_DETAIL:return[3,9];case p.PRODUCT_ATTRIBUTE:return[3,10];case p.PRODUCT_ATTRIBUTE_LIST:return[3,11];case p.CATEGORY:return[3,12];case p.CATEGORY_LIST:return[3,13];case p.LINK:case p.LIST_OF_LINK:return[3,14];case p.COLOR:return[3,15];case p.CUSTOM:return[3,16];case p.COMPONENT:case p.COMPONENT_LIST:return[3,17];case p.BLOG:return[3,19];case p.BLOG_LIST:return[3,20];case p.BLOG_CATEGORY:return[3,21];case p.BLOG_CATEGORY_LIST:return[3,22];case p.RAFFLE:return[3,23];case p.RAFFLE_LIST:return[3,24];case p.SLIDER:return[3,25]}return[3,26];case 1:return e=new S(n),[3,27];case 2:return e=new w(n),[3,27];case 3:return e=new D(n),[3,27];case 4:return e=new L(n),[3,27];case 5:return e=new T(n),[3,27];case 6:return e=new v(n),[3,27];case 7:return e=new f(n),[3,27];case 8:return e=new h(this.pageType,n,this.pageSpecificData),[3,27];case 9:return e=new g(n),[3,27];case 10:return e=new E(n),[3,27];case 11:return e=new A(n),[3,27];case 12:return e=new O(n),[3,27];case 13:return e=new P(n),[3,27];case 14:return e=new m(n,this.theme,this.linkMetaDataTargetIds),[3,27];case 15:return e=new y(n),[3,27];case 16:return(s=this.theme.customData.find((function(e){return e.id===r.customDataId})))?(e=new b(n,s,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,27]):[2];case 17:return o=n,[4,Promise.all(o.map((function(e){return u.getPageComponentPropValues(e)})))];case 18:case 28:return[2,t.sent()];case 19:return e=new C(n),[3,27];case 20:return e=new R(this.pageType,n,this.pageSpecificData),[3,27];case 21:return e=new V(n),[3,27];case 22:return e=new j(n),[3,27];case 23:return e=new G(n),[3,27];case 24:return e=new F,[3,27];case 25:return e=new I(n),[3,27];case 26:return[3,27];case 27:return[4,null==e?void 0:e.getValue()]}}))}))},$.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)},$.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,a,r;return t(this,(function(t){switch(t.label){case 0:return e=[],a=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":a.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(a,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},$.prototype.getLinkSlugs=function(a,n){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=r(a.map((function(e){return e.id}))),s=[],i.length?[4,function(){return e(o,void 0,void 0,(function(){var e,a,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],n){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,J({targetId:{in:i}})];case 2:return a=t.sent(),e=a.data||[],[3,8];case 3:return[4,X({targetId:{in:i}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,K({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]}}))}))},$.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var a=n(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(a)},$}();export{$ as IkasPageDataProvider};
1
+ import{__awaiter as e,__generator as t,__assign as a}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import n from"lodash/flatten";import{makeAutoObservable as i}from"mobx";import{IkasThemeJsonPageType as s,IkasRaffleMetadataTargetType as o,IkasBlogMetaDataTargetType as u,IkasHTMLMetaDataTargetType as c,IkasThemeJsonComponentPropType as p}from"@ikas/storefront-models";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{IkasProductFunctions as d}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as h}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as g}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as f}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as v}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as m}from"./prop-value/link.js";import{IkasImageListPropValueProvider as T}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as S}from"./prop-value/text.js";import{IkasColorPropValueProvider as y}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as D}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as L}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as O}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as P}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as b}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as I}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as w}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as C}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as R}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as E}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as A}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as V}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as j}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as G}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as F}from"./prop-value/raffle-list.js";import{listMerchantSettings as _,listCustomerReviewSummary as B,listProductOptionSet as M,searchProducts as k,listProductBrand as U,listCategory as N,listBlog as q,listBlogCategory as Y,listStorefrontRaffle as x,listHTMLMetaData as J,listRaffleMetaData as K,listBlogMetaData as X}from"@ikas/storefront-api";import{populateRaffleProducts as H}from"./helpers/raffle.js";var $=function(){function $(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($.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($.prototype,"nextPageData",{get:function(){var e,t,r,n,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===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(n=this.page)||void 0===n?void 0:n.canonicals)||null,disableIndex:(null===(i=this.page)||void 0===i?void 0:i.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:l.toJSON()}))}},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"specification",{get:function(){var e,t,a=this,r=this.page;return(null==r?void 0:r.type)===s.PRODUCT?null===(e=r.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==r?void 0:r.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($.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($.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),$.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,_({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},$.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]}}))}))},$.prototype.getProductReviewSummary=function(){var a,r,n;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,B({productId:{eq:null===(a=this.pageSpecificData)||void 0===a?void 0:a.id}})];case 1:(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},$.prototype.getPageSpecificData=function(){var a,r,n,i;return e(this,void 0,void 0,(function(){var p,h,g,f,v,m,T,S,y,D,L=this;return t(this,(function(O){switch(O.label){case 0:return this.pageType&&![s.BRAND,s.PRODUCT,s.CATEGORY,s.BLOG,s.BLOG_CATEGORY,s.RAFFLE_DETAIL].includes(this.pageType)?[2]:(p=this.pageParams.slug)?(h=[],(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(s.BLOG))||(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(s.BLOG_CATEGORY))?[4,X({slug:{eq:p}})]:[3,2]):[2];case 1:return g=O.sent(),(h=(null===(n=g.data)||void 0===n?void 0:n.data)||[]).length?[3,6]:[2];case 2:return(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(s.RAFFLE_DETAIL))?[4,K({slug:{eq:p}})]:[3,4];case 3:return g=O.sent(),(h=g.data||[]).length?[3,6]:[2];case 4:return[4,J({slug:{eq:p}})];case 5:if(g=O.sent(),!(h=g.data||[])||!h.length)return[2];O.label=6;case 6:if(!(f=h[0]).targetId)return[2];switch(v=function(){return e(L,void 0,void 0,(function(){var e,a,r,n,i,o,u,c,p,h,g;return t(this,(function(t){switch(t.label){case 0:return[4,k({input:{productIdList:[f.targetId],priceListId:l.getPriceListId(),salesChannelId:l.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(h=null===(p=null==e?void 0:e.data)||void 0===p?void 0:p.data)||void 0===h?void 0:h.length)?(a=e.data.data[0]).productOptionSetId?[4,M({id:{eq:a.productOptionSetId}})]:[3,3]:[2];case 2:(r=t.sent()).isSuccess&&(null===(g=null==r?void 0:r.data)||void 0===g?void 0:g.length)&&(a.productOptionSet=r.data[0]),t.label=3;case 3:return(n=a.variants.find((function(e){return e.isActive})))?(a.selectedVariantValues=n.variantValues,i=d.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(f),[2]):[2]}}))}))},m=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,U({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BRAND,this.setPageMetaData(f),[2]):[2]}}))}))},T=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,N({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},S=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,q({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BLOG,this.setPageMetaData(f),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,Y({id:{eq:f.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],this.pageSpecificData=a,this.pageType=s.BLOG_CATEGORY,this.setPageMetaData(f),[2]):[2]}}))}))},D=function(){return e(L,void 0,void 0,(function(){var e,a,r,n;return t(this,(function(t){switch(t.label){case 0:return[4,x({id:{eq:f.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.length)?(a=e.data.data[0],[4,H([a])]):[2];case 2:return t.sent(),this.pageSpecificData=a,this.pageType=s.RAFFLE_DETAIL,this.setPageMetaData(f),[2]}}))}))},f.targetType){case c.BRAND:return[3,7];case c.CATEGORY:return[3,9];case c.PRODUCT:return[3,11];case u.BLOG:return[3,13];case u.BLOG_CATEGORY:return[3,15];case o.RAFFLE:return[3,17]}return[3,19];case 7:return[4,m()];case 8:return[2,O.sent()];case 9:return[4,T()];case 10:return[2,O.sent()];case 11:return[4,v()];case 12:return[2,O.sent()];case 13:return[4,S()];case 14:return[2,O.sent()];case 15:return[4,y()];case 16:return[2,O.sent()];case 17:return[4,D()];case 18:return[2,O.sent()];case 19:return[3,20];case 20:return[2]}}))}))},$.prototype.getPageComponentPropValues=function(a){return e(this,void 0,void 0,(function(){var r,n,i,s=this;return t(this,(function(o){switch(o.label){case 0:return r=this.theme.components.find((function(e){return e.id===a.componentId})),n={pageComponent:a,component:r,propValues:{}},i=function(r){return e(s,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return e=n.propValues,i=r.name,[4,this.getPageComponentPropValue(a,r)];case 1:return e[i]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(i))];case 1:return o.sent(),[2,n]}}))}))},$.prototype.getPageComponentPropValue=function(a,r){return e(this,void 0,void 0,(function(){var e,n,i,s,o,u=this;return t(this,(function(t){switch(t.label){case 0:if(n=a.propValues[r.name],i=[p.RAFFLE_LIST],null==n&&!i.includes(r.type))return[2,null];switch(r.type){case p.TEXT:return[3,1];case p.RICH_TEXT:return[3,2];case p.BOOLEAN:return[3,3];case p.IMAGE:return[3,4];case p.IMAGE_LIST:return[3,5];case p.BRAND:return[3,6];case p.BRAND_LIST:return[3,7];case p.PRODUCT_LIST:return[3,8];case p.PRODUCT_DETAIL:return[3,9];case p.PRODUCT_ATTRIBUTE:return[3,10];case p.PRODUCT_ATTRIBUTE_LIST:return[3,11];case p.CATEGORY:return[3,12];case p.CATEGORY_LIST:return[3,13];case p.LINK:case p.LIST_OF_LINK:return[3,14];case p.COLOR:return[3,15];case p.CUSTOM:return[3,16];case p.COMPONENT:case p.COMPONENT_LIST:return[3,17];case p.BLOG:return[3,19];case p.BLOG_LIST:return[3,20];case p.BLOG_CATEGORY:return[3,21];case p.BLOG_CATEGORY_LIST:return[3,22];case p.RAFFLE:return[3,23];case p.RAFFLE_LIST:return[3,24];case p.SLIDER:return[3,25]}return[3,26];case 1:return e=new S(n),[3,27];case 2:return e=new w(n),[3,27];case 3:return e=new D(n),[3,27];case 4:return e=new L(n),[3,27];case 5:return e=new T(n),[3,27];case 6:return e=new v(n),[3,27];case 7:return e=new f(n),[3,27];case 8:return e=new h(this.pageType,n,this.pageSpecificData),[3,27];case 9:return e=new g(n),[3,27];case 10:return e=new E(n),[3,27];case 11:return e=new A(n),[3,27];case 12:return e=new O(n),[3,27];case 13:return e=new P(n),[3,27];case 14:return e=new m(n,this.theme,this.linkMetaDataTargetIds),[3,27];case 15:return e=new y(n),[3,27];case 16:return(s=this.theme.customData.find((function(e){return e.id===r.customDataId})))?(e=new b(n,s,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,27]):[2];case 17:return o=n,[4,Promise.all(o.map((function(e){return u.getPageComponentPropValues(e)})))];case 18:case 28:return[2,t.sent()];case 19:return e=new C(n),[3,27];case 20:return e=new R(this.pageType,n,this.pageSpecificData),[3,27];case 21:return e=new V(n),[3,27];case 22:return e=new j(n),[3,27];case 23:return e=new G(n),[3,27];case 24:return e=new F,[3,27];case 25:return e=new I(n),[3,27];case 26:return[3,27];case 27:return[4,null==e?void 0:e.getValue()]}}))}))},$.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)},$.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,a,r;return t(this,(function(t){switch(t.label){case 0:return e=[],a=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":a.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(a,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},$.prototype.getLinkSlugs=function(a,n){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=r(a.map((function(e){return e.id}))),s=[],i.length?[4,function(){return e(o,void 0,void 0,(function(){var e,a,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],n){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,J({targetId:{in:i}})];case 2:return a=t.sent(),e=a.data||[],[3,8];case 3:return[4,X({targetId:{in:i}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,K({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]}}))}))},$.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var a=n(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(a)},$}();export{$ as IkasPageDataProvider};
@@ -1 +1 @@
1
- import{IkasProductType as t,IkasRaffleVerificationType as e}from"@ikas/storefront-models";function a(){return{id:"",name:"",type:t.PHYSICAL,description:"",shortDescription:"",metaData:null,brand:null,categories:[],tags:[],variants:[],attributes:[],variantTypes:[],productOptionSetId:null,baseUnit:null,averageRating:null,reviewCount:null}}function n(){return{categoryPath:[],description:null,imageId:null,name:"",parentId:null,metaData:null,categoryPathItems:[],orderType:null,id:"",createdAt:0,updatedAt:0}}function d(){return{description:null,imageId:null,metaData:null,orderType:null,name:"",id:"",createdAt:0,updatedAt:0}}function l(){return{createdAt:0,id:"",updatedAt:0,blogContent:{content:"",createdAt:0,id:"",updatedAt:0},categoryId:"",imageId:"",isPublished:!1,locale:null,metadata:{canonicals:[],description:"",disableIndex:!1,pageTitle:null,slug:"",targetId:null,targetType:null,createdAt:0,id:"",updatedAt:0},publishedAt:null,shortDescription:"",storefrontId:"",tagIds:[],tags:[],title:"",writer:{firstName:"",lastName:""},category:r()}}function r(){return{createdAt:0,id:"",updatedAt:0,imageId:"",metadata:{canonicals:[],description:"",disableIndex:!1,pageTitle:null,slug:"",targetId:null,targetType:null,createdAt:0,id:"",updatedAt:0},name:""}}function i(){return{createdAt:0,id:"",updatedAt:0,deleted:!1,dateRange:null,metadata:null,name:"",requiredCustomerAccount:!1,status:!1,variants:[],products:[],verificationType:e.EMAIL}}export{l as getPlaceholderBlog,r as getPlaceholderBlogCategory,d as getPlaceholderBrand,n as getPlaceholderCategory,a as getPlaceholderProduct,i as getPlaceholderRaffle};
1
+ import{IkasProductType as t,IkasRaffleVerificationType as e}from"@ikas/storefront-models";function a(){return{id:"",name:"",type:t.PHYSICAL,description:"",shortDescription:"",metaData:null,brand:null,categories:[],tags:[],variants:[],attributes:[],variantTypes:[],productOptionSetId:null,baseUnit:null,averageRating:null,reviewCount:null,groupVariantsByVariantTypeId:null}}function n(){return{categoryPath:[],description:null,imageId:null,name:"",parentId:null,metaData:null,categoryPathItems:[],orderType:null,id:"",createdAt:0,updatedAt:0}}function d(){return{description:null,imageId:null,metaData:null,orderType:null,name:"",id:"",createdAt:0,updatedAt:0}}function l(){return{createdAt:0,id:"",updatedAt:0,blogContent:{content:"",createdAt:0,id:"",updatedAt:0},categoryId:"",imageId:"",isPublished:!1,locale:null,metadata:{canonicals:[],description:"",disableIndex:!1,pageTitle:null,slug:"",targetId:null,targetType:null,createdAt:0,id:"",updatedAt:0},publishedAt:null,shortDescription:"",storefrontId:"",tagIds:[],tags:[],title:"",writer:{firstName:"",lastName:""},category:r()}}function r(){return{createdAt:0,id:"",updatedAt:0,imageId:"",metadata:{canonicals:[],description:"",disableIndex:!1,pageTitle:null,slug:"",targetId:null,targetType:null,createdAt:0,id:"",updatedAt:0},name:""}}function i(){return{createdAt:0,id:"",updatedAt:0,deleted:!1,dateRange:null,metadata:null,name:"",requiredCustomerAccount:!1,status:!1,variants:[],products:[],verificationType:e.EMAIL}}export{l as getPlaceholderBlog,r as getPlaceholderBlogCategory,d as getPlaceholderBrand,n as getPlaceholderCategory,a as getPlaceholderProduct,i as getPlaceholderRaffle};
@@ -1,7 +1,8 @@
1
1
  import { IkasImage } from "@ikas/storefront-models";
2
2
  import IkasPropValueProvider from ".";
3
+ import { IkasImagePropValue } from "../../models/prop-value/image";
3
4
  export declare class IkasImageListPropValueProvider implements IkasPropValueProvider<IkasImage[]> {
4
5
  private imageListPropValue;
5
- constructor(imageListPropValue: string[]);
6
+ constructor(imageListPropValue: (string | IkasImagePropValue)[]);
6
7
  getValue(): Promise<IkasImage[]>;
7
8
  }
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'./../../ext/tslib/tslib.es6.js';var n=function(){function n(t){this.imageListPropValue=t}return n.prototype.getValue=function(){return t(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.imageListPropValue.map((function(t){return{id:t,isVideo:!1}}))]}))}))},n}();export{n as IkasImageListPropValueProvider};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';var i=function(){function i(t){this.imageListPropValue=t}return i.prototype.getValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,this.imageListPropValue.map((function(t){return{id:"object"==typeof t?t.id:t,isVideo:!1,altText:"object"==typeof t?t.altText:null}}))]}))}))},i}();export{i as IkasImageListPropValueProvider};
@@ -1,7 +1,9 @@
1
1
  import { IkasImage } from "@ikas/storefront-models";
2
2
  import IkasPropValueProvider from ".";
3
+ import { IkasImagePropValue } from "../../models/prop-value/image";
3
4
  export declare class IkasImagePropValueProvider implements IkasPropValueProvider<IkasImage> {
4
5
  private imagePropValue;
5
- constructor(imagePropValue: string);
6
+ private isObject;
7
+ constructor(imagePropValue: string | IkasImagePropValue);
6
8
  getValue(): Promise<IkasImage>;
7
9
  }
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'./../../ext/tslib/tslib.es6.js';var o=function(){function o(t){this.imagePropValue=t}return o.prototype.getValue=function(){return t(this,void 0,void 0,(function(){return i(this,(function(t){return[2,{id:this.imagePropValue,isVideo:!1}]}))}))},o}();export{o as IkasImagePropValueProvider};
1
+ import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';var i=function(){function i(t){this.isObject="object"==typeof t,this.isObject,this.imagePropValue=t}return i.prototype.getValue=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){return[2,{id:"object"==typeof this.imagePropValue?this.imagePropValue.id:this.imagePropValue,isVideo:!1,altText:"object"==typeof this.imagePropValue?this.imagePropValue.altText:null}]}))}))},i}();export{i as IkasImagePropValueProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-providers",
3
- "version": "4.2.0-beta.1",
3
+ "version": "4.2.0-beta.10",
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.2.0-beta.1",
21
- "@ikas/storefront-config": "^4.2.0-beta.1",
22
- "@ikas/storefront-model-functions": "^4.2.0-beta.1",
23
- "@ikas/storefront-models": "^4.2.0-beta.1",
20
+ "@ikas/storefront-api": "^4.2.0-beta.10",
21
+ "@ikas/storefront-config": "^4.2.0-beta.10",
22
+ "@ikas/storefront-model-functions": "^4.2.0-beta.10",
23
+ "@ikas/storefront-models": "^4.2.0-beta.10",
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.2.0-beta.1",
42
- "@ikas/storefront-config": "^4.2.0-beta.1",
43
- "@ikas/storefront-model-functions": "^4.2.0-beta.1",
44
- "@ikas/storefront-models": "^4.2.0-beta.1",
41
+ "@ikas/storefront-api": "^4.2.0-beta.10",
42
+ "@ikas/storefront-config": "^4.2.0-beta.10",
43
+ "@ikas/storefront-model-functions": "^4.2.0-beta.10",
44
+ "@ikas/storefront-models": "^4.2.0-beta.10",
45
45
  "lodash": "^4.17.21"
46
46
  }
47
47
  }