@ikas/storefront-providers 5.0.24 → 5.0.26
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=function(){return n=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},n.apply(this,arguments)};function t(n,t,e,r){return new(e||(e=Promise))((function(o,a){function
|
|
1
|
+
var n=function(){return n=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var o in t=arguments[e])Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o]);return n},n.apply(this,arguments)};function t(n,t,e,r){return new(e||(e=Promise))((function(o,a){function l(n){try{i(r.next(n))}catch(n){a(n)}}function c(n){try{i(r.throw(n))}catch(n){a(n)}}function i(n){var t;n.done?o(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(l,c)}i((r=r.apply(n,t||[])).next())}))}function e(n,t){var e,r,o,a,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;l;)try{if(e=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return l.label++,{value:a[1],done:!1};case 5:l.label++,r=a[1],a=[0];continue;case 7:a=l.ops.pop(),l.trys.pop();continue;default:if(!(o=l.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){l=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){l.label=a[1];break}if(6===a[0]&&l.label<o[1]){l.label=o[1],o=a;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(a);break}o[2]&&l.ops.pop(),l.trys.pop();continue}a=t.call(n,l)}catch(n){a=[6,n],r=0}finally{e=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function r(n,t,e){if(e||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return n.concat(r||Array.prototype.slice.call(t))}export{n as __assign,t as __awaiter,e as __generator,r as __spreadArray};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as n}from'./../ext/tslib/tslib.es6.js';import r from"lodash/uniq";import i from"lodash/flatten";import{makeAutoObservable as a}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as s,IkasThemeJsonPageType as o,IkasStorefrontPopupPageFilterDataTypeEnum as u,IkasAmountType as c,IkasCampaignOfferProductApplicablePriceEnum as l,IkasCategoryConditionTypeEnum as d,IkasRaffleMetadataTargetType as p,IkasBlogMetaDataTargetType as g,IkasHTMLMetaDataTargetType as f,IkasThemeJsonComponentPropType as h}from"@ikas/storefront-models";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{IkasProductFunctions as m,IkasProductVariantFunctions as T}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as S}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as I}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as D}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as O}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as P}from"./prop-value/link.js";import{IkasImageListPropValueProvider as C}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as y}from"./prop-value/text.js";import{IkasColorPropValueProvider as R}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as L}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as b}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as E}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as A}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as w}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as F}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as G}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as V}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as _}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as U}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as j}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as N}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as B}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as M}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as k}from"./prop-value/raffle-list.js";import{listMerchantSettings as x,listCustomerReviewSummary as Y,searchProducts as q,listCampaignOffer as J,listCustomerReviews as H,listProductOptionSet as K,listProductBrand as X,listCategory as z,listBlog as Q,listBlogCategory as $,listStorefrontRaffle as W,listHTMLMetaData as Z,listRaffleMetaData as ee,listBlogMetaData as te}from"@ikas/storefront-api";import{populateRaffleProducts as ne}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as re}from"./prop-value/video.js";var ie=function(){function ie(e,t,n,r){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=n,this.merchantSettings=r,a(this)}return Object.defineProperty(ie.prototype,"page",{get:function(){var e=this;if(this.pageType===o.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===o.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"nextPageData",{get:function(){var e,t,r,i,a,s=[],u=[];return this.pageComponentPropValues.forEach((function(e){if(u.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:u,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||o.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(i=this.page)||void 0===i?void 0:i.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:v.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),ie.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=v.getCurrentRouting();v.getCurrentLocale(),v.getDomain();var n=v.getStorefrontId(),r=v.getStorefrontRoutingId(),i=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=v.getStorefrontPopups(),c=[];a.length&&a.forEach((function(t){var a,l,d,p,g=!1,f=!1,h=!1,v=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===s.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case s.ACCOUNT:if(i)return[o.ACCOUNT,o.ORDERS,o.ORDER_DETAIL,o.FAVORITE_PRODUCTS,o.ADDRESSES,o.RAFFLE_ACCOUNT].includes(i);case s.LOGIN:return i===o.LOGIN;case s.REGISTER:return i===o.REGISTER;case s.CART:return i===o.CART;case s.CATEGORY:return i===o.CATEGORY;case s.HOME:return i===o.INDEX;case s.PRODUCT:return i===o.PRODUCT;case s.PRODUCT_BRAND:return i===o.BRAND;case s.CUSTOM:return!0}}));if(null===(l=null==m?void 0:m.filters)||void 0===l?void 0:l.length)switch(m.pageType){case s.CATEGORY:case s.PRODUCT:case s.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===u.ID_LIST&&T&&(g=S.value.includes(T),v=!0);break;case s.CUSTOM:g=!0;break;default:v=!0,g=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(g=!0,v=!0)}else g=!0,v=!0;if(g)if(f=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===r}))),t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,D=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,O=new Date;(I&&D&&I.getTime()<=O.getTime()&&D.getTime()>=O.getTime()||I&&!D&&I.getTime()<=O.getTime()||D&&!I&&D.getTime()>=O.getTime())&&(h=!0)}}else h=!0;g&&f&&h&&(t.isFilteredOnServerSide=v,c.push(t))})),v.init({storefrontPopups:c})},Object.defineProperty(ie.prototype,"specification",{get:function(){var e,t,n=this,r=this.page;return(null==r?void 0:r.type)===o.PRODUCT?null===(e=r.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==r?void 0:r.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(ie.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),ie.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,x({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},ie.prototype.getPageData=function(){return e(this,void 0,void 0,(function(){var e,n=this;return t(this,(function(t){switch(t.label){case 0:return this.pageSpecificData?[3,2]:[4,this.getPageSpecificData()];case 1:t.sent(),t.label=2;case 2:return this.page?[4,this.getMerchantSettings()]:[2];case 3:return t.sent(),e=this,[4,Promise.all(this.pageComponents.map((function(e){return n.getPageComponentPropValues(e)})))];case 4:return e.pageComponentPropValues=t.sent(),[4,this.setLinkSlugs()];case 5:return t.sent(),[4,this.getProductReviewSummary()];case 6:return t.sent(),[2]}}))}))},ie.prototype.getProductReviewSummary=function(){var n,r,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==o.PRODUCT?[3,2]:[4,Y({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},ie.prototype.getPageSpecificData=function(){var r,i,a,s;return e(this,void 0,void 0,(function(){var u,h,S,I,D,O,P,C,y,R,L=this;return t(this,(function(b){switch(b.label){case 0:return this.pageType&&![o.BRAND,o.PRODUCT,o.CATEGORY,o.BLOG,o.BLOG_CATEGORY,o.RAFFLE_DETAIL].includes(this.pageType)?[2]:(u=this.pageParams.slug)?(h=[],(null===(r=this.possiblePageTypes)||void 0===r?void 0:r.includes(o.BLOG))||(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(o.BLOG_CATEGORY))?[4,te({slug:{eq:u}})]:[3,2]):[2];case 1:return S=b.sent(),(h=(null===(a=S.data)||void 0===a?void 0:a.data)||[]).length?[3,6]:[2];case 2:return(null===(s=this.possiblePageTypes)||void 0===s?void 0:s.includes(o.RAFFLE_DETAIL))?[4,ee({slug:{eq:u}})]:[3,4];case 3:return S=b.sent(),(h=S.data||[]).length?[3,6]:[2];case 4:return[4,Z({slug:{eq:u}})];case 5:if(S=b.sent(),!(h=S.data||[])||!h.length)return[2];b.label=6;case 6:if(!(I=h[0]).targetId)return[2];switch(D=function(){return e(L,void 0,void 0,(function(){var e,r,i,a,s,u,d,p,g,f,h,S,D,O,P,C,y,R,L,b,E,A,w,F,G,V,_,U,j,N,B,M,k,x,Y;return t(this,(function(t){switch(t.label){case 0:return[4,q({input:{productIdList:[I.targetId],priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})];case 1:return e=t.sent(),(null===(F=null===(w=null==e?void 0:e.data)||void 0===w?void 0:w.data)||void 0===F?void 0:F.length)?(r=e.data.data[0]).productOptionSetId?[4,K({id:{eq:r.productOptionSetId}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(G=null==i?void 0:i.data)||void 0===G?void 0:G.length)&&(r.productOptionSet=i.data[0]),t.label=3;case 3:return((null===(V=v.getDomain())||void 0===V?void 0:V.includes("thepurestsolutions"))||(null===(_=process.env.NEXT_PUBLIC_GQL_URL)||void 0===_?void 0:_.includes(".dev"))&&!v.getIsEditor())&&(a=r.variants.find((function(e){return e.isActive})))?(s=!!(null===(U=a.bundleSettings)||void 0===U?void 0:U.products.length),u=[r.id],s&&(null===(j=a.bundleSettings)||void 0===j||j.products.forEach((function(e){u.push(e.productId)}))),[4,H({productId:s?null:r.id,productIds:s?u:null,input:{salesChannelId:v.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:d=t.sent(),(null===(N=d.data)||void 0===N?void 0:N.data)&&d.isSuccess&&(p=d.data.data,g=!!(null===(B=a.bundleSettings)||void 0===B?void 0:B.products.length),f=[r.id],g&&(null===(M=a.bundleSettings)||void 0===M||M.products.forEach((function(e){f.push(e.productId)}))),r.customerReviews=n(n({data:p,count:p.length,limit:10,page:1,initialized:!0},g?{}:{productId:r.id}),g?{productIds:f}:{})),t.label=5;case 5:return(null===(k=r.campaignOffers)||void 0===k?void 0:k.length)?[4,J({id:{in:r.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(h=t.sent()).isSuccess&&(null===(x=h.data)||void 0===x?void 0:x.length)?(S=h.data[0],D=[],O=[],S.offers.forEach((function(e){return D.push(e.productId)})),[4,q({input:{productIdList:D,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId()}})]):[3,8];case 7:(C=t.sent()).isSuccess&&C.data&&S.offers.forEach((function(e){var t,r,i=null===(r=null===(t=C.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.productId}));if(i){var a=i.variants.filter((function(t){return T.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var r=!1;return e.discountType===c.AMOUNT&&(r=!0),n(n({},t),{prices:t.prices.map((function(t){var i=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=i,s=i-(r?e.discountAmount:i*e.discountAmount/100);return e.applicablePrice===l.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(r?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&O.push({campaignOfferId:S.id,campaignOfferProductId:e.id,product:n(n({},i),{variants:a})})}P||(P={campaignOfferId:S.id,title:e.title,description:e.description})})),r.appliedCampaignOffer=P,r.offers=O,t.label=8;case 8:return r.productGroup?[4,q({input:{productGroupId:r.productGroup.id,productGroupKey:r.productGroup.groupKey,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(y=t.sent()).isSuccess&&(null===(Y=y.data)||void 0===Y?void 0:Y.data)&&(r.productGroupItems=y.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:m.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order}}))),t.label=10;case 10:return(R=r.variants.find((function(e){return e.isActive})))?(r.selectedVariantValues=R.variantValues,L=m.getDisplayedVariantTypes,this.pageSpecificData=r,(b=L(this.pageSpecificData,r.selectedVariantValues)).length&&(E=b[0]).displayedVariantValues.length&&(A=E.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=A.variant.variantValues),this.pageType=o.PRODUCT,this.setPageMetaData(I),[2]):[2]}}))}))},O=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,X({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BRAND,this.setPageMetaData(I),[2]):[2]}}))}))},P=function(){return e(L,void 0,void 0,(function(){var e,n,r,i,a,s,u,c;return t(this,(function(t){switch(t.label){case 0:return[4,z({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(s=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?(n=e.data.data[0]).conditions&&(r=n.conditions.find((function(e){return e.conditionType===d.PRODUCT_BRAND})))?[4,X({id:{eq:r.valueList[0]}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(c=null===(u=i.data)||void 0===u?void 0:u.data)||void 0===c?void 0:c.length)&&(n.conditionValues={brand:i.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=o.CATEGORY,this.setPageMetaData(I),[2]}}))}))},C=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Q({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG,this.setPageMetaData(I),[2]):[2]}}))}))},y=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:I.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=o.BLOG_CATEGORY,this.setPageMetaData(I),[2]):[2]}}))}))},R=function(){return e(L,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:I.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],[4,ne([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=o.RAFFLE_DETAIL,this.setPageMetaData(I),[2]}}))}))},I.targetType){case f.BRAND:return[3,7];case f.CATEGORY:return[3,9];case f.PRODUCT:return[3,11];case g.BLOG:return[3,13];case g.BLOG_CATEGORY:return[3,15];case p.RAFFLE:return[3,17]}return[3,19];case 7:return[4,O()];case 8:return[2,b.sent()];case 9:return[4,P()];case 10:return[2,b.sent()];case 11:return[4,D()];case 12:return[2,b.sent()];case 13:return[4,C()];case 14:return[2,b.sent()];case 15:return[4,y()];case 16:return[2,b.sent()];case 17:return[4,R()];case 18:return[2,b.sent()];case 19:return[3,20];case 20:return[2]}}))}))},ie.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var r,i,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((r=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||r.isFooter)&&(n.propValues=r.commonPropValues||n.propValues),i={pageComponent:n,component:r,propValues:{}},a=function(r){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=i.propValues,a=r.name,[4,this.getPageComponentPropValue(n,r)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(a))];case 1:return o.sent(),[2,i]}}))}))},ie.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,o,u,c,l,d,p,g,f=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[h.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case h.TEXT:return[3,1];case h.RICH_TEXT:return[3,2];case h.BOOLEAN:return[3,3];case h.IMAGE:return[3,4];case h.IMAGE_LIST:return[3,5];case h.BRAND:return[3,6];case h.BRAND_LIST:return[3,7];case h.PRODUCT_LIST:return[3,8];case h.PRODUCT_DETAIL:return[3,9];case h.PRODUCT_ATTRIBUTE:return[3,10];case h.PRODUCT_ATTRIBUTE_LIST:return[3,11];case h.CATEGORY:return[3,12];case h.CATEGORY_LIST:return[3,13];case h.LINK:case h.LIST_OF_LINK:return[3,14];case h.COLOR:return[3,15];case h.CUSTOM:return[3,16];case h.COMPONENT:case h.COMPONENT_LIST:return[3,17];case h.BLOG:return[3,19];case h.BLOG_LIST:return[3,20];case h.BLOG_CATEGORY:return[3,21];case h.BLOG_CATEGORY_LIST:return[3,22];case h.RAFFLE:return[3,23];case h.RAFFLE_LIST:return[3,24];case h.SLIDER:return[3,25];case h.VIDEO:return[3,26]}return[3,27];case 1:return e=new y(a),[3,28];case 2:return e=new G(a),[3,28];case 3:return e=new L(a),[3,28];case 4:return e=new b(a),[3,28];case 5:return e=new C(a),[3,28];case 6:return e=new O(a),[3,28];case 7:return e=new D(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===r.componentId})),u=[],o&&(d=o.props.find((function(e){return e.name===i.name})))&&(u=d.excludedFields||[]),e=new S(this.pageType,n(n({},a),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new I(a),[3,28];case 10:return e=new U(a),[3,28];case 11:return e=new j(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===r.componentId})),l=[],c&&(d=c.props.find((function(e){return e.name===i.name})))&&(l=d.excludedFieldsCategory||[]),e=new E(n(n({},a),{excludedFieldsCategory:l})),[3,28];case 13:return e=new A(a),[3,28];case 14:return e=new P(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new R(a),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new w(a,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return g=a,[4,Promise.all(g.map((function(e){return f.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new V(a),[3,28];case 20:return e=new _(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new N(a),[3,28];case 22:return e=new B(a),[3,28];case 23:return e=new M(a),[3,28];case 24:return e=new k,[3,28];case 25:return e=new F(a),[3,28];case 26:return e=new re(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},ie.prototype.setPageMetaData=function(e){this.page&&(this.page.pageTitle=e.pageTitle||null,this.page.description=e.description||null,this.page.canonicals=e.canonicals||null,this.page.disableIndex=e.disableIndex||null)},ie.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},ie.prototype.getLinkSlugs=function(n,i){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=r(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,r,o,u;return t(this,(function(t){switch(t.label){case 0:switch(e=[],i){case"DEFAULT":return[3,1];case"BLOG":return[3,3];case"RAFFLE":return[3,5]}return[3,7];case 1:return[4,Z({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,te({targetId:{in:a}})];case 4:return r=t.sent(),e=(null===(u=r.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ee({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},ie.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=i(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(n)},ie}();export{ie as IkasPageDataProvider};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as n,__spreadArray as r}from'./../ext/tslib/tslib.es6.js';import i from"lodash/uniq";import a from"lodash/flatten";import{makeAutoObservable as s}from"mobx";import{IkasStorefrontPopupPageFilterTypeEnum as o,IkasThemeJsonPageType as u,IkasStorefrontPopupPageFilterDataTypeEnum as c,IkasProductAttributeType as l,IkasAmountType as d,IkasCampaignOfferProductApplicablePriceEnum as p,IkasCategoryConditionTypeEnum as g,IkasRaffleMetadataTargetType as f,IkasBlogMetaDataTargetType as v,IkasHTMLMetaDataTargetType as h,IkasThemeJsonComponentPropType as m}from"@ikas/storefront-models";import{IkasStorefrontConfig as T}from"@ikas/storefront-config";import{IkasProductFunctions as S,IkasProductVariantFunctions as I}from"@ikas/storefront-model-functions";import{IkasProductListPropValueProvider as D}from"./prop-value/product-list.js";import{IkasProductPropValueProvider as O}from"./prop-value/product-detail.js";import{IkasBrandListPropValueProvider as P}from"./prop-value/brand-list.js";import{IkasBrandPropValueProvider as C}from"./prop-value/brand.js";import{IkasLinkPropValueProvider as R}from"./prop-value/link.js";import{IkasImageListPropValueProvider as y}from"./prop-value/image-list.js";import{IkasTextPropValueProvider as L}from"./prop-value/text.js";import{IkasColorPropValueProvider as b}from"./prop-value/color.js";import{IkasBooleanPropValueProvider as E}from"./prop-value/boolean.js";import{IkasImagePropValueProvider as A}from"./prop-value/image.js";import{IkasCategoryPropValueProvider as w}from"./prop-value/category.js";import{IkasCategoryListPropValueProvider as F}from"./prop-value/category-list.js";import{IkasCustomPropValueProvider as G}from"./prop-value/custom.js";import{IkasSliderPropValueProvider as V}from"./prop-value/slider.js";import{IkasRichTextPropValueProvider as _}from"./prop-value/rich-text.js";import{IkasBlogPropValueProvider as U}from"./prop-value/blog.js";import{IkasBlogListPropValueProvider as j}from"./prop-value/blog-list.js";import{IkasAttributePropValueProvider as N}from"./prop-value/attribute.js";import{IkasAttributeListPropValueProvider as B}from"./prop-value/attribute-list.js";import{IkasBlogCategoryPropValueProvider as M}from"./prop-value/blog-category.js";import{IkasBlogCategoryListPropValueProvider as k}from"./prop-value/blog-category-list.js";import{IkasRafflePropValueProvider as x}from"./prop-value/raffle.js";import{IkasRaffleListPropValueProvider as Y}from"./prop-value/raffle-list.js";import{listMerchantSettings as q,listCustomerReviewSummary as J,searchProducts as H,listCampaignOffer as K,listCustomerReviews as X,listProductOptionSet as z,listProductBrand as Q,listCategory as $,listBlog as W,listBlogCategory as Z,listStorefrontRaffle as ee,listHTMLMetaData as te,listRaffleMetaData as ne,listBlogMetaData as re}from"@ikas/storefront-api";import{populateRaffleProducts as ie}from"./helpers/raffle.js";import{IkasVideoPropValueProvider as ae}from"./prop-value/video.js";var se=function(){function se(e,t,n,r){this.pageType=null,this.pageParams={},this.pageComponentPropValues=[],this.pageSpecificData=null,this.merchantSettings=null,this.possiblePageTypes=[],this.linkMetaDataTargetIds=[],this.productReviewSummary=null,this.theme=e,this.pageParams=t||{},this.pageType=n,this.merchantSettings=r,s(this)}return Object.defineProperty(se.prototype,"page",{get:function(){var e=this;if(this.pageType===u.CUSTOM){var t=this.pageParams.slug;return this.theme.pages.find((function(e){return e.type===u.CUSTOM&&e.slug===t}))}return this.theme.pages.find((function(t){return t.type===e.pageType}))},enumerable:!1,configurable:!0}),Object.defineProperty(se.prototype,"nextPageData",{get:function(){var e,t,r,i,a,s=[],o=[];return this.pageComponentPropValues.forEach((function(e){if(o.push({pageComponent:{id:e.pageComponent.id,componentId:e.pageComponent.componentId},propValues:e.propValues}),!s.find((function(t){return t.id===e.component.id}))){var t=n({},e.component);t.props.forEach((function(e){delete e.description,delete e.displayName,delete e.translations,delete e.groupId})),delete t.translations,delete t.defaultPropValues,delete t.displayName,delete t.description,delete t.dir,delete t.commonPropValues,s.push(t)}})),this.filterPopupList(),{props:JSON.parse(JSON.stringify({propValues:o,themeJsonComponents:s,customDataList:this.theme.customData,pageSpecificData:this.pageSpecificData||null,pageType:(null===(e=this.page)||void 0===e?void 0:e.type)||u.CUSTOM,pageTitle:(null===(t=this.page)||void 0===t?void 0:t.pageTitle)||null,pageDescription:(null===(r=this.page)||void 0===r?void 0:r.description)||null,canonicals:(null===(i=this.page)||void 0===i?void 0:i.canonicals)||null,disableIndex:(null===(a=this.page)||void 0===a?void 0:a.disableIndex)||null,settings:this.theme.settings||{},productReviewSummary:this.productReviewSummary,configJson:T.toJSON(),merchantSettings:this.getMerchantSettings()}))}},enumerable:!1,configurable:!0}),se.prototype.filterPopupList=function(){var e=this;this.pageParams.slug;var t=T.getCurrentRouting();T.getCurrentLocale(),T.getDomain();var n=T.getStorefrontId(),r=T.getStorefrontRoutingId(),i=this.pageType;(null==t?void 0:t.path)&&"/".concat(null==t?void 0:t.path);var a=T.getStorefrontPopups(),s=[];a.length&&a.forEach((function(t){var a,l,d,p,g=!1,f=!1,v=!1,h=!1;if(null===(a=t.pageFilters)||void 0===a?void 0:a.length){var m=t.pageFilters.sort((function(e,t){return e.pageType===o.CUSTOM?1:-1})).find((function(e){switch(e.pageType){case o.ACCOUNT:if(i)return[u.ACCOUNT,u.ORDERS,u.ORDER_DETAIL,u.FAVORITE_PRODUCTS,u.ADDRESSES,u.RAFFLE_ACCOUNT].includes(i);case o.LOGIN:return i===u.LOGIN;case o.REGISTER:return i===u.REGISTER;case o.CART:return i===u.CART;case o.CATEGORY:return i===u.CATEGORY;case o.HOME:return i===u.INDEX;case o.PRODUCT:return i===u.PRODUCT;case o.PRODUCT_BRAND:return i===u.BRAND;case o.CUSTOM:return!0}}));if(null===(l=null==m?void 0:m.filters)||void 0===l?void 0:l.length)switch(m.pageType){case o.CATEGORY:case o.PRODUCT:case o.PRODUCT_BRAND:var T=null===(d=e.pageSpecificData)||void 0===d?void 0:d.id,S=m.filters[0];S.type===c.ID_LIST&&T&&(g=S.value.includes(T),h=!0);break;case o.CUSTOM:g=!0;break;default:h=!0,g=!0}else t.pageFilters.find((function(e){return e.pageType===(null==m?void 0:m.pageType)}))&&(g=!0,h=!0)}else g=!0,h=!0;if(g)if(f=!!(null===(p=t.storefrontRoutings)||void 0===p?void 0:p.find((function(e){return e.storefrontId===n&&e.storefrontRoutingId===r}))),t.dateFilter){if(t.dateFilter){var I=t.dateFilter.startDate?new Date(t.dateFilter.startDate):null,D=t.dateFilter.endDate?new Date(t.dateFilter.endDate):null,O=new Date;(I&&D&&I.getTime()<=O.getTime()&&D.getTime()>=O.getTime()||I&&!D&&I.getTime()<=O.getTime()||D&&!I&&D.getTime()>=O.getTime())&&(v=!0)}}else v=!0;g&&f&&v&&(t.isFilteredOnServerSide=h,s.push(t))})),T.init({storefrontPopups:s})},Object.defineProperty(se.prototype,"specification",{get:function(){var e,t,n=this,r=this.page;return(null==r?void 0:r.type)===u.PRODUCT?null===(e=r.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)})):null===(t=null==r?void 0:r.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=n.pageSpecificData)||void 0===t?void 0:t.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(se.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(se.prototype,"$pageComponentPropValues",{get:function(){return this.pageComponentPropValues},enumerable:!1,configurable:!0}),se.prototype.getMerchantSettings=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.merchantSettings?[2,this.merchantSettings]:[4,q({})];case 1:return(e=t.sent()).isSuccess&&e.data&&(this.merchantSettings=e.data),[2]}}))}))},se.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]}}))}))},se.prototype.getProductReviewSummary=function(){var n,r,i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageType!==u.PRODUCT?[3,2]:[4,J({productId:{eq:null===(n=this.pageSpecificData)||void 0===n?void 0:n.id}})];case 1:(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)&&(this.productReviewSummary=e.data.data[0]),t.label=2;case 2:return[2]}}))}))},se.prototype.getPageSpecificData=function(){var i,a,s,o;return e(this,void 0,void 0,(function(){var c,m,D,O,P,C,R,y,L,b,E=this;return t(this,(function(A){switch(A.label){case 0:return this.pageType&&![u.BRAND,u.PRODUCT,u.CATEGORY,u.BLOG,u.BLOG_CATEGORY,u.RAFFLE_DETAIL].includes(this.pageType)?[2]:(c=this.pageParams.slug)?(m=[],(null===(i=this.possiblePageTypes)||void 0===i?void 0:i.includes(u.BLOG))||(null===(a=this.possiblePageTypes)||void 0===a?void 0:a.includes(u.BLOG_CATEGORY))?[4,re({slug:{eq:c}})]:[3,2]):[2];case 1:return D=A.sent(),(m=(null===(s=D.data)||void 0===s?void 0:s.data)||[]).length?[3,6]:[2];case 2:return(null===(o=this.possiblePageTypes)||void 0===o?void 0:o.includes(u.RAFFLE_DETAIL))?[4,ne({slug:{eq:c}})]:[3,4];case 3:return D=A.sent(),(m=D.data||[]).length?[3,6]:[2];case 4:return[4,te({slug:{eq:c}})];case 5:if(D=A.sent(),!(m=D.data||[])||!m.length)return[2];A.label=6;case 6:if(!(O=m[0]).targetId)return[2];switch(P=function(){return e(E,void 0,void 0,(function(){var i,a,s,o,c,g,f,v,h,m,D,P,C,R,y,L,b,E,A,w,F,G,V,_,U,j,N,B,M,k,x,Y,q,J,Q,$,W,Z,ee,te,ne,re,ie,ae,se=this;return t(this,(function(oe){switch(oe.label){case 0:return[4,H({input:{productIdList:[O.targetId],priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})];case 1:return i=oe.sent(),(null===(q=null===(Y=null==i?void 0:i.data)||void 0===Y?void 0:Y.data)||void 0===q?void 0:q.length)?(a=T.getCurrentRouting(),s=T.getRoutings(),o=s.find((function(e){return null===e.path})),c=null==a?void 0:a.path,(g=i.data.data[0]).productOptionSetId?[4,z({id:{eq:g.productOptionSetId}})]:[3,3]):[2];case 2:(f=oe.sent()).isSuccess&&(null===(J=null==f?void 0:f.data)||void 0===J?void 0:J.length)&&(g.productOptionSet=f.data[0]),oe.label=3;case 3:return((null===(Q=T.getDomain())||void 0===Q?void 0:Q.includes("thepurestsolutions"))||(null===($=process.env.NEXT_PUBLIC_GQL_URL)||void 0===$?void 0:$.includes(".dev"))&&!T.getIsEditor())&&(v=g.variants.find((function(e){return e.isActive})))?(h=!!(null===(W=v.bundleSettings)||void 0===W?void 0:W.products.length),m=[g.id],h&&(null===(Z=v.bundleSettings)||void 0===Z||Z.products.forEach((function(e){m.push(e.productId)}))),[4,X({productId:h?null:g.id,productIds:h?m:null,input:{salesChannelId:T.getSalesChannelId()||""},pagination:{page:1,limit:10}})]):[3,5];case 4:D=oe.sent(),(null===(ee=D.data)||void 0===ee?void 0:ee.data)&&D.isSuccess&&(P=D.data.data,C=!!(null===(te=v.bundleSettings)||void 0===te?void 0:te.products.length),R=[g.id],C&&(null===(ne=v.bundleSettings)||void 0===ne||ne.products.forEach((function(e){R.push(e.productId)}))),g.customerReviews=n(n({data:P,count:P.length,limit:10,page:1,initialized:!0},C?{}:{productId:g.id}),C?{productIds:R}:{})),oe.label=5;case 5:return(null===(re=g.campaignOffers)||void 0===re?void 0:re.length)?[4,K({id:{in:g.campaignOffers.map((function(e){return e.id}))}})]:[3,8];case 6:return(y=oe.sent()).isSuccess&&(null===(ie=y.data)||void 0===ie?void 0:ie.length)?(L=y.data[0],b=[],E=[],L.offers.forEach((function(e){return b.push(e.productId)})),[4,H({input:{productIdList:b,priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})]):[3,8];case 7:(w=oe.sent()).isSuccess&&w.data&&L.offers.forEach((function(e){var t,r,i=null===(r=null===(t=w.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.productId}));if(i){var a=i.variants.filter((function(t){return I.hasStock(t)&&!(e.excludedVariantIdList||[]).some((function(e){return e===t.id}))})).map((function(t){if(!e.discountAmount)return t;var r=!1;return e.discountType===d.AMOUNT&&(r=!0),n(n({},t),{prices:t.prices.map((function(t){var i=null!==t.discountPrice?t.discountPrice:t.sellPrice,a=i,s=i-(r?e.discountAmount:i*e.discountAmount/100);return e.applicablePrice===p.SELL_PRICE&&(a=t.sellPrice,s=t.sellPrice-(r?e.discountAmount:t.sellPrice*e.discountAmount/100)),n(n({},t),{sellPrice:a,discountPrice:s})}))})}));a.length&&E.push({campaignOfferId:L.id,campaignOfferProductId:e.id,product:n(n({},i),{variants:a})})}A||(A={campaignOfferId:L.id,title:e.title,description:e.description})})),g.appliedCampaignOffer=A,g.offers=E,oe.label=8;case 8:return g.productGroup?[4,H({input:{productGroupId:g.productGroup.id,productGroupKey:g.productGroup.groupKey,priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId(),perPage:200}})]:[3,10];case 9:(F=oe.sent()).isSuccess&&(null===(ae=F.data)||void 0===ae?void 0:ae.data)&&(g.productGroupItems=F.data.data.map((function(e){var t,n;return{productId:e.id,image:e.variants[0].images&&e.variants[0].images.length?e.variants[0].images[0].image:null,href:S.getProductHref(e),groupValues:null===(t=e.productGroup)||void 0===t?void 0:t.values,order:null===(n=e.productGroup)||void 0===n?void 0:n.order}}))),oe.label=10;case 10:return g.attributes.length?(G=g.attributes.filter((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)===l.PRODUCT})).map((function(r){return e(se,void 0,void 0,(function(){var e,i,a,s;return t(this,(function(t){switch(t.label){case 0:return r.value?[4,H({input:{productIdList:JSON.parse(r.value),priceListId:T.getPriceListId(),salesChannelId:T.getSalesChannelId()}})]:[2,n(n({},r),{products:[]})];case 1:return e=t.sent(),null===(a=null===(i=e.data)||void 0===i?void 0:i.data)||void 0===a||a.forEach((function(e){e.selectedVariantValues=e.variants[0].variantValues})),[2,n(n({},r),{products:(null===(s=e.data)||void 0===s?void 0:s.data)||[]})]}}))}))})),[4,Promise.allSettled(G)]):[3,12];case 11:(V=oe.sent().filter((function(e){return"fulfilled"===e.status&&e.value})).map((function(e){return e.value}))).length&&(g.attributes=r(r([],g.attributes.filter((function(e){var t;return(null===(t=e.productAttribute)||void 0===t?void 0:t.type)!==l.PRODUCT})),!0),V,!0)),oe.label=12;case 12:return(_=g.variants.find((function(e){return e.isActive})))?(g.selectedVariantValues=_.variantValues,U=S.getDisplayedVariantTypes,this.pageSpecificData=g,(j=U(this.pageSpecificData,g.selectedVariantValues)).length&&(N=j[0]).displayedVariantValues.length&&(B=N.displayedVariantValues.find((function(e){return e.hasStock})))&&(this.pageSpecificData.selectedVariantValues=B.variant.variantValues),this.pageType=u.PRODUCT,M=O,k=o&&o.locale===(null==a?void 0:a.locale),M&&(null==M?void 0:M.translations)&&!k&&(x=null==M?void 0:M.translations.find((function(e){return e.locale===c})),M.pageTitle=(null==x?void 0:x.pageTitle)||null,M.description=(null==x?void 0:x.description)||null),this.setPageMetaData(M),[2]):[2]}}))}))},C=function(){return e(E,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Q({id:{eq:O.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BRAND,this.setPageMetaData(O),[2]):[2]}}))}))},R=function(){return e(E,void 0,void 0,(function(){var e,n,r,i,a,s,o,c;return t(this,(function(t){switch(t.label){case 0:return[4,$({id:{eq:O.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(s=null===(a=e.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?(n=e.data.data[0]).conditions&&(r=n.conditions.find((function(e){return e.conditionType===g.PRODUCT_BRAND})))?[4,Q({id:{eq:r.valueList[0]}})]:[3,3]:[2];case 2:(i=t.sent()).isSuccess&&(null===(c=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===c?void 0:c.length)&&(n.conditionValues={brand:i.data.data[0]}),t.label=3;case 3:return this.pageSpecificData=n,this.pageType=u.CATEGORY,this.setPageMetaData(O),[2]}}))}))},y=function(){return e(E,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,W({id:{eq:O.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BLOG,this.setPageMetaData(O),[2]):[2]}}))}))},L=function(){return e(E,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,Z({id:{eq:O.targetId},pagination:{page:1,limit:1}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],this.pageSpecificData=n,this.pageType=u.BLOG_CATEGORY,this.setPageMetaData(O),[2]):[2]}}))}))},b=function(){return e(E,void 0,void 0,(function(){var e,n,r,i;return t(this,(function(t){switch(t.label){case 0:return[4,ee({id:{eq:O.targetId}})];case 1:return(e=t.sent()).isSuccess&&(null===(i=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===i?void 0:i.length)?(n=e.data.data[0],[4,ie([n])]):[2];case 2:return t.sent(),this.pageSpecificData=n,this.pageType=u.RAFFLE_DETAIL,this.setPageMetaData(O),[2]}}))}))},O.targetType){case h.BRAND:return[3,7];case h.CATEGORY:return[3,9];case h.PRODUCT:return[3,11];case v.BLOG:return[3,13];case v.BLOG_CATEGORY:return[3,15];case f.RAFFLE:return[3,17]}return[3,19];case 7:return[4,C()];case 8:return[2,A.sent()];case 9:return[4,R()];case 10:return[2,A.sent()];case 11:return[4,P()];case 12:return[2,A.sent()];case 13:return[4,y()];case 14:return[2,A.sent()];case 15:return[4,L()];case 16:return[2,A.sent()];case 17:return[4,b()];case 18:return[2,A.sent()];case 19:return[3,20];case 20:return[2]}}))}))},se.prototype.getPageComponentPropValues=function(n){return e(this,void 0,void 0,(function(){var r,i,a,s=this;return t(this,(function(o){switch(o.label){case 0:return((r=this.theme.components.find((function(e){return e.id===n.componentId}))).isHeader||r.isFooter)&&(n.propValues=r.commonPropValues||n.propValues),i={pageComponent:n,component:r,propValues:{}},a=function(r){return e(s,void 0,void 0,(function(){var e,a;return t(this,(function(t){switch(t.label){case 0:return e=i.propValues,a=r.name,[4,this.getPageComponentPropValue(n,r)];case 1:return e[a]=t.sent(),[2]}}))}))},[4,Promise.all(r.props.map(a))];case 1:return o.sent(),[2,i]}}))}))},se.prototype.getPageComponentPropValue=function(r,i){return e(this,void 0,void 0,(function(){var e,a,s,o,u,c,l,d,p,g,f=this;return t(this,(function(t){switch(t.label){case 0:if(a=r.propValues[i.name],s=[m.RAFFLE_LIST],null==a&&!s.includes(i.type))return[2,null];switch(i.type){case m.TEXT:return[3,1];case m.RICH_TEXT:return[3,2];case m.BOOLEAN:return[3,3];case m.IMAGE:return[3,4];case m.IMAGE_LIST:return[3,5];case m.BRAND:return[3,6];case m.BRAND_LIST:return[3,7];case m.PRODUCT_LIST:return[3,8];case m.PRODUCT_DETAIL:return[3,9];case m.PRODUCT_ATTRIBUTE:return[3,10];case m.PRODUCT_ATTRIBUTE_LIST:return[3,11];case m.CATEGORY:return[3,12];case m.CATEGORY_LIST:return[3,13];case m.LINK:case m.LIST_OF_LINK:return[3,14];case m.COLOR:return[3,15];case m.CUSTOM:return[3,16];case m.COMPONENT:case m.COMPONENT_LIST:return[3,17];case m.BLOG:return[3,19];case m.BLOG_LIST:return[3,20];case m.BLOG_CATEGORY:return[3,21];case m.BLOG_CATEGORY_LIST:return[3,22];case m.RAFFLE:return[3,23];case m.RAFFLE_LIST:return[3,24];case m.SLIDER:return[3,25];case m.VIDEO:return[3,26]}return[3,27];case 1:return e=new L(a),[3,28];case 2:return e=new _(a),[3,28];case 3:return e=new E(a),[3,28];case 4:return e=new A(a),[3,28];case 5:return e=new y(a),[3,28];case 6:return e=new C(a),[3,28];case 7:return e=new P(a),[3,28];case 8:return o=this.theme.components.find((function(e){return e.id===r.componentId})),u=[],o&&(d=o.props.find((function(e){return e.name===i.name})))&&(u=d.excludedFields||[]),e=new D(this.pageType,n(n({},a),{excludedFields:u}),this.pageSpecificData),[3,28];case 9:return e=new O(a),[3,28];case 10:return e=new N(a),[3,28];case 11:return e=new B(a),[3,28];case 12:return c=this.theme.components.find((function(e){return e.id===r.componentId})),l=[],c&&(d=c.props.find((function(e){return e.name===i.name})))&&(l=d.excludedFieldsCategory||[]),e=new w(n(n({},a),{excludedFieldsCategory:l})),[3,28];case 13:return e=new F(a),[3,28];case 14:return e=new R(a,this.theme,this.linkMetaDataTargetIds),[3,28];case 15:return e=new b(a),[3,28];case 16:return(p=this.theme.customData.find((function(e){return e.id===i.customDataId})))?(e=new G(a,p,this.theme,this.pageType,this,this.pageSpecificData,this.pageParams),[3,28]):[2];case 17:return g=a,[4,Promise.all(g.map((function(e){return f.getPageComponentPropValues(e)})))];case 18:case 29:return[2,t.sent()];case 19:return e=new U(a),[3,28];case 20:return e=new j(this.pageType,a,this.pageSpecificData),[3,28];case 21:return e=new M(a),[3,28];case 22:return e=new k(a),[3,28];case 23:return e=new x(a),[3,28];case 24:return e=new Y,[3,28];case 25:return e=new V(a),[3,28];case 26:return e=new ae(a),[3,28];case 27:return[3,28];case 28:return[4,null==e?void 0:e.getValue()]}}))}))},se.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)},se.prototype.setLinkSlugs=function(){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return e=[],n=[],r=[],this.linkMetaDataTargetIds.forEach((function(t){switch(t.type){case"DEFAULT":e.push(t);break;case"BLOG":n.push(t);break;case"RAFFLE":r.push(t)}})),[4,Promise.all([this.getLinkSlugs(e,"DEFAULT"),this.getLinkSlugs(n,"BLOG"),this.getLinkSlugs(r,"RAFFLE")])];case 1:return[2,t.sent()]}}))}))},se.prototype.getLinkSlugs=function(n,r){return e(this,void 0,void 0,(function(){var a,s,o=this;return t(this,(function(u){switch(u.label){case 0:return a=i(n.map((function(e){return e.id}))),s=[],a.length?[4,function(){return e(o,void 0,void 0,(function(){var e,n,i,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,te({targetId:{in:a}})];case 2:return n=t.sent(),e=n.data||[],[3,8];case 3:return[4,re({targetId:{in:a}})];case 4:return i=t.sent(),e=(null===(u=i.data)||void 0===u?void 0:u.data)||[],[3,8];case 5:return[4,ne({targetId:{in:a}})];case 6:return o=t.sent(),e=o.data||[],[3,8];case 7:return[3,8];case 8:return e.length&&(s=e),[2]}}))}))}()]:[2];case 1:return u.sent(),n.forEach((function(e){var t=s.find((function(t){return t.targetId===e.id}));t&&(e.navigationLink.href+=t.slug)})),[2]}}))}))},se.prototype.getFlatCustomData=function(e){var t=this;if(!e.nestedData||!e.nestedData.length)return[e];var n=a(e.nestedData.map((function(e){return t.getFlatCustomData(e)}))),r=[];return r.push(e),r=r.concat(n)},se}();export{se as IkasPageDataProvider};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront-providers",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.26",
|
|
4
4
|
"description": "Data providers for ikas storefront theme components.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
20
|
-
"@ikas/storefront-api": "^5.0.
|
|
21
|
-
"@ikas/storefront-config": "^5.0.
|
|
22
|
-
"@ikas/storefront-model-functions": "^5.0.
|
|
23
|
-
"@ikas/storefront-models": "^5.0.
|
|
20
|
+
"@ikas/storefront-api": "^5.0.26",
|
|
21
|
+
"@ikas/storefront-config": "^5.0.26",
|
|
22
|
+
"@ikas/storefront-model-functions": "^5.0.26",
|
|
23
|
+
"@ikas/storefront-models": "^5.0.26",
|
|
24
24
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
25
25
|
"rollup-plugin-rename-node-modules": "^1.2.0",
|
|
26
26
|
"@types/lodash": "^4.14.168",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"mobx": "^6.1.3",
|
|
41
|
-
"@ikas/storefront-api": "^5.0.
|
|
42
|
-
"@ikas/storefront-config": "^5.0.
|
|
43
|
-
"@ikas/storefront-model-functions": "^5.0.
|
|
44
|
-
"@ikas/storefront-models": "^5.0.
|
|
41
|
+
"@ikas/storefront-api": "^5.0.26",
|
|
42
|
+
"@ikas/storefront-config": "^5.0.26",
|
|
43
|
+
"@ikas/storefront-model-functions": "^5.0.26",
|
|
44
|
+
"@ikas/storefront-models": "^5.0.26",
|
|
45
45
|
"lodash": "^4.17.21"
|
|
46
46
|
}
|
|
47
47
|
}
|