@ikas/storefront 2.0.0-alpha.21 → 2.0.0-alpha.23

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
- import{__spreadArray as t,__awaiter as e,__generator as r}from'../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import"../../data/blog/index.js";import"../../data/brand/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/customer/address/index.js";import"../../data/customer/index.js";import"../../data/customer-review/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/installment-info/index.js";import"../../data/order/index.js";import"../../data/order/line-item/index.js";import{IkasProduct as n}from"../../data/product/index.js";import"../../data/variant-type/index.js";import"../../data/product/variant/index.js";import"../../data/product/variant/price/index.js";import"../../data/product-attribute/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product-filter/index.js";import{IkasVariantValue as a}from"../../data/variant-type/variant-value/index.js";import"../../data/order-transaction/index.js";import"../../data/product-option-set/index.js";import"../../data/raffle/index.js";import"../../theme/theme.js";import"../../theme/page/index.js";import"../../theme/component/prop/index.js";import"../../theme/page/component/prop-value/link.js";import"../brand-list/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../category-list/index.js";import"../product-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import{IkasCustomerReviewList as o}from"../customer-review-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../theme/settings/index.js";import"../../theme/custom-data/index.js";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasStorefrontConfig as u}from"../../../storefront/index.js";var d=function(){function d(t,e,r){this.router=null,this.product=new n(t),this.selectedVariantValues=e.map((function(t){return new a(t)})),this.router=r,i(this)}return Object.defineProperty(d.prototype,"mainVariantValue",{get:function(){return this.selectedVariantValues.length?this.selectedVariantValues[0]:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"selectedVariant",{get:function(){if(!this.product.hasVariant)return this.product.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.product.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"href",{get:function(){var t=this,e=this.product.metaData;if(!(null==e?void 0:e.slug))return"";var r=this.product.variantTypes.map((function(e){var r=e.variantType,i=r.values.find((function(e){return t.selectedVariantValues.some((function(t){return t.id===e.id}))}));if(i)return"".concat(r.slug,"=").concat(i.slug)})).filter((function(t){return!!t})).join("&");return r?"/".concat(e.slug,"?").concat(r):"/".concat(e.slug)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasStock",{get:function(){return this.product.hasStock},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"displayedVariantTypes",{get:function(){var e=this,r=this.product.variantTypes.map((function(r,i){var n=r.variantType,a=[],o=i>0?e.product.variantTypes.slice(0,i):null,s=[];return o&&(s=e.selectedVariantValues.filter((function(t){return o.some((function(e){return e.variantType.id===t.variantTypeId}))}))),n.values.forEach((function(r){var i=t(t([],s,!0),[r],!1),n=e.product.variants.find((function(t){return t.isActive&&i.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})),o=e.selectedVariant.variantValues.some((function(t){return t.id===r.id}));n&&a.push({variant:n,variantValue:r,hasStock:n.hasStock,isSelected:o})})),{variantType:n,displayedVariantValues:a}}));return 1===r.length&&(r[0].displayedVariantValues=r[0].displayedVariantValues.filter((function(t){return t.variant.isActive}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isCustomerReviewEnabled",{get:function(){return!!u.customerReviewSettings&&!u.customerReviewSettings.customerPurchaseRequired},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isCustomerReviewLoginRequired",{get:function(){return!u.customerReviewSettings||u.customerReviewSettings.customerLoginRequired},enumerable:!1,configurable:!0}),d.prototype.getCustomerReviews=function(){return e(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return[4,(t=new o({productId:this.product.id})).getInitial()];case 1:return e.sent(),[2,t]}}))}))},d.prototype.selectVariantValue=function(e){var r,i=this,n=this.product.metaData,a=this.selectedVariantValues.map((function(t){return t.variantTypeId===e.variantTypeId?e:t})),o=this.product.variants.find((function(t){return t.isActive&&a.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(o)this.selectedVariantValues=a;else{var u=this.product.variantTypes.findIndex((function(t){return t.variantType.id===e.variantTypeId}));if(u>0){var d=this.product.variantTypes.slice(0,u),c=this.selectedVariantValues.filter((function(t){return d.some((function(e){return e.variantType.id===t.variantTypeId}))})),p=t(t([],c,!0),[e],!1);o=this.product.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var l=a.slice(0,a.length-1);(o=this.product.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(o=this.product.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===e.id}))})))}if(!o)return;this.selectedVariantValues=o.variantValues}var m=this.product.variantTypes.map((function(t){var e=t.variantType,r=e.values.find((function(t){return i.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(r)return"".concat(e.slug,"=").concat(r.slug)})).filter((function(t){return!!t})).join("&"),f="/".concat(n.slug);if(m&&(f="/".concat(n.slug,"?").concat(m)),f!==window.location.pathname){var v="production"!==process.env.NODE_ENV;null===(r=this.router)||void 0===r||r.replace(f,void 0,{shallow:v,scroll:!1}),s.productView(this)}},d}();export{d as IkasProductDetail};
1
+ import{__spreadArray as t,__awaiter as e,__generator as r}from'../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import"../../data/blog/index.js";import"../../data/brand/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/customer/address/index.js";import"../../data/customer/index.js";import"../../data/customer-review/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/installment-info/index.js";import"../../data/order/index.js";import"../../data/order/line-item/index.js";import{IkasProduct as n}from"../../data/product/index.js";import"../../data/variant-type/index.js";import"../../data/product/variant/index.js";import"../../data/product/variant/price/index.js";import"../../data/product-attribute/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product-filter/index.js";import{IkasVariantValue as a}from"../../data/variant-type/variant-value/index.js";import"../../data/order-transaction/index.js";import"../../data/product-option-set/index.js";import"../../data/raffle/index.js";import"../../theme/theme.js";import"../../theme/page/index.js";import"../../theme/component/prop/index.js";import"../../theme/page/component/prop-value/link.js";import"../brand-list/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../category-list/index.js";import"../product-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import{IkasCustomerReviewList as o}from"../customer-review-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../theme/settings/index.js";import"../../theme/custom-data/index.js";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasStorefrontConfig as u}from"../../../storefront/index.js";var d=function(){function d(t,e,r){this.router=null,this.product=new n(t),this.selectedVariantValues=e.map((function(t){return new a(t)})),this.router=r,i(this)}return Object.defineProperty(d.prototype,"mainVariantValue",{get:function(){return this.selectedVariantValues.length?this.selectedVariantValues[0]:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"selectedVariant",{get:function(){if(!this.product.hasVariant)return this.product.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.product.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"href",{get:function(){var t=this,e=this.product.metaData;if(!(null==e?void 0:e.slug))return"";var r=this.product.variantTypes.map((function(e){var r=e.variantType,i=r.values.find((function(e){return t.selectedVariantValues.some((function(t){return t.id===e.id}))}));if(i)return"".concat(r.slug,"=").concat(i.slug)})).filter((function(t){return!!t})).join("&");return r?"/".concat(e.slug,"?").concat(r):"/".concat(e.slug)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasStock",{get:function(){return this.product.hasStock},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"displayedVariantTypes",{get:function(){var e=this,r=this.product.variantTypes.map((function(r,i){var n=r.variantType,a=[],o=i>0?e.product.variantTypes.slice(0,i):null,s=[];return o&&(s=e.selectedVariantValues.filter((function(t){return o.some((function(e){return e.variantType.id===t.variantTypeId}))}))),n.values.forEach((function(r){var i=t(t([],s,!0),[r],!1),n=e.product.variants.find((function(t){return t.isActive&&i.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})),o=e.product.variants.find((function(t){return t.isActive&&t.hasStock&&i.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})),u=e.selectedVariant.variantValues.some((function(t){return t.id===r.id}));n&&a.push({variant:n,variantValue:r,hasStock:!!o,isSelected:u})})),{variantType:n,displayedVariantValues:a}}));return 1===r.length&&(r[0].displayedVariantValues=r[0].displayedVariantValues.filter((function(t){return t.variant.isActive}))),r},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isCustomerReviewEnabled",{get:function(){return!!u.customerReviewSettings&&!u.customerReviewSettings.customerPurchaseRequired},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isCustomerReviewLoginRequired",{get:function(){return!u.customerReviewSettings||u.customerReviewSettings.customerLoginRequired},enumerable:!1,configurable:!0}),d.prototype.getCustomerReviews=function(){return e(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return[4,(t=new o({productId:this.product.id})).getInitial()];case 1:return e.sent(),[2,t]}}))}))},d.prototype.selectVariantValue=function(e){var r,i=this,n=this.product.metaData,a=this.selectedVariantValues.map((function(t){return t.variantTypeId===e.variantTypeId?e:t})),o=this.product.variants.find((function(t){return t.isActive&&a.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(o)this.selectedVariantValues=a;else{var u=this.product.variantTypes.findIndex((function(t){return t.variantType.id===e.variantTypeId}));if(u>0){var d=this.product.variantTypes.slice(0,u),c=this.selectedVariantValues.filter((function(t){return d.some((function(e){return e.variantType.id===t.variantTypeId}))})),p=t(t([],c,!0),[e],!1);o=this.product.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var l=a.slice(0,a.length-1);(o=this.product.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(o=this.product.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===e.id}))})))}if(!o)return;this.selectedVariantValues=o.variantValues}var m=this.product.variantTypes.map((function(t){var e=t.variantType,r=e.values.find((function(t){return i.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(r)return"".concat(e.slug,"=").concat(r.slug)})).filter((function(t){return!!t})).join("&"),f="/".concat(n.slug);if(m&&(f="/".concat(n.slug,"?").concat(m)),f!==window.location.pathname){var v="production"!==process.env.NODE_ENV;null===(r=this.router)||void 0===r||r.replace(f,void 0,{shallow:v,scroll:!1}),s.productView(this)}},d}();export{d as IkasProductDetail};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../../ext/tslib/tslib.es6.js';import a from"path";import{createFile as o,deleteDirContent as s}from"../../../utils/fs.js";import"../../../models/data/blog/index.js";import"../../../models/data/brand/index.js";import"../../../models/data/category/index.js";import"../../../models/data/checkout/index.js";import"../../../models/data/customer/address/index.js";import"../../../models/data/customer/index.js";import"../../../models/data/customer-review/index.js";import"../../../models/data/html-meta-data/index.js";import"../../../models/data/image/index.js";import"../../../models/data/installment-info/index.js";import"../../../models/data/order/index.js";import"../../../models/data/order/line-item/index.js";import"mobx";import"../../../models/data/product/index.js";import"../../../models/data/variant-type/index.js";import"../../../models/data/product/variant/index.js";import"../../../models/data/product/variant/price/index.js";import"../../../models/data/product-attribute/index.js";import"../../../models/data/product/attribute-value/index.js";import"../../../models/data/product-filter/index.js";import"../../../models/data/variant-type/variant-value/index.js";import"../../../models/data/order-transaction/index.js";import"../../../models/data/product-option-set/index.js";import"../../../models/data/raffle/index.js";import"../../../models/theme/theme.js";import"../../../models/theme/page/index.js";import{IkasThemeComponentPropType as r}from"../../../models/theme/component/prop/index.js";import"../../../models/theme/page/component/prop-value/link.js";import"../../../models/ui/brand-list/index.js";import"../../../models/ui/blog-list/index.js";import"../../../models/ui/blog-category-list/index.js";import"../../../models/ui/category-list/index.js";import"../../../models/ui/product-detail/index.js";import"../../../models/ui/product-list/index.js";import"../../../models/ui/product-attribute-detail/index.js";import"../../../models/ui/product-attribute-list/index.js";import"../../../models/ui/customer-review-list/index.js";import"../../../models/ui/validator/index.js";import"../../../models/ui/validator/rules/index.js";import"../../../models/ui/validator/form/login.js";import"../../../models/ui/validator/form/address.js";import"../../../models/ui/validator/form/register.js";import"../../../models/ui/validator/form/contact-form.js";import"../../../models/ui/validator/form/forgot-password.js";import"../../../models/ui/validator/form/recover-password.js";import"../../../models/ui/validator/form/account-info.js";import"../../../models/ui/validator/form/raffle-form.js";import"../../../models/ui/validator/form/customer-review.js";import"../../../models/ui/raffle-list/index.js";import"../../../models/theme/settings/index.js";import"../../../models/theme/custom-data/index.js";import i from'../../../ext/lodash/uniq.js';var n=function(){function n(){}return n.generate=function(r){return e(this,void 0,void 0,(function(){var e,m,d,p,c;return t(this,(function(t){switch(t.label){case 0:return[4,s(a.join(process.cwd(),"src","components","__generated__","types"))];case 1:t.sent(),e={content:"",imports:[],internalCustomDatas:[]},t.label=2;case 2:return t.trys.push([2,4,,5]),r.customData.forEach((function(t){n.generateAllCustomDataTypes(t,e)})),e.internalCustomDatas.forEach((function(t){n.generateAllCustomDataTypes(t,e)})),m=a.join(process.cwd(),"src","components","__generated__"),e.imports=i(e.imports),d="import {\r\n",e.imports.forEach((function(e){d+="\t".concat(e,",\r\n")})),p=(d+='} from "@ikas/storefront"\r\n\r\n')+e.content,[4,o(m,"types.ts",p)];case 3:return[2,t.sent()];case 4:return c=t.sent(),console.log(c),[2,!1];case 5:return[2]}}))}))},n.generateAllCustomDataTypes=function(e,t){var a=e.type===r.ENUM,o="export ".concat(a?"enum":"type"," ").concat(n.generateTypeName(e)).concat(a?"":" = ","{ \r\n"),s="};\r\n\r\n";e.type!==r.DYNAMIC_LIST&&e.type!==r.STATIC_LIST||!e.nestedData?e.type===r.ENUM&&e.enumOptions?(t.content+=o,e.enumOptions.forEach((function(e){e.value&&e.value[0].match(/^\d/)&&(e.value="_"+e.value),t.content+='\t"'.concat(null==e?void 0:e.value,'" = "').concat(null==e?void 0:e.displayName,'",'),t.content+="\r\n"})),t.content+=s):(t.content+=o,e.nestedData&&e.nestedData.forEach((function(e){n.genenateCustomDataType(e,t),t.content+="\r\n"})),t.content+=s):n.generateAllCustomDataTypes(e.nestedData[0],t)},n.genenateCustomDataType=function(e,t){var a=n.getType(e,t);e.key&&e.key[0].match(/^\d/)&&(e.key="_"+e.key),t.content+="\t".concat(e.key).concat(e.isRequired?"":"?",": ").concat(a).concat([r.DYNAMIC_LIST,r.STATIC_LIST].includes(e.type)?"[]":"").concat(e.type===r.ENUM?",":";")},n.getType=function(e,t){var a="";switch(e.type){case r.TEXT:case r.RICH_TEXT:case r.COLOR:a="string";break;case r.BOOLEAN:a="boolean";break;case r.IMAGE:a="IkasImage",t.imports.push(a);break;case r.IMAGE_LIST:a="IkasImageList",t.imports.push(a);break;case r.LINK:a="IkasNavigationLink",t.imports.push(a);break;case r.LIST_OF_LINK:a="IkasNavigationLink[]",t.imports.push("IkasNavigationLink");break;case r.PRODUCT_DETAIL:a="IkasProductDetail",t.imports.push(a);break;case r.PRODUCT_LIST:a="IkasProductDetail[]",t.imports.push("IkasProductDetail");break;case r.PRODUCT_ATTRIBUTE:a="IkasProductAttribute",t.imports.push(a);break;case r.PRODUCT_ATTRIBUTE_LIST:a="IkasProductAttribute[]",t.imports.push("IkasProductAttribute");break;case r.BRAND:a="IkasBrand",t.imports.push(a);break;case r.BRAND_LIST:a="IkasBrandList",t.imports.push(a);break;case r.CATEGORY:a="IkasCategory",t.imports.push(a);break;case r.CATEGORY_LIST:a="IkasCategoryList",t.imports.push(a);break;case r.COMPONENT:a="IkasComponentRenderer";break;case r.COMPONENT_LIST:a="IkasComponentRenderer[]";break;case r.BLOG:a="IkasBlog",t.imports.push(a);break;case r.BLOG_LIST:a="IkasBlogList",t.imports.push(a);break;case r.BLOG_CATEGORY:a="IkasBlogCategory",t.imports.push(a);break;case r.BLOG_CATEGORY_LIST:a="IkasBlogCategoryList",t.imports.push(a);break;case r.RAFFLE:a="IkasRaffle",t.imports.push(a);break;case r.RAFFLE_LIST:a="IkasRaffleList",t.imports.push(a);break;case r.ENUM:a=n.generateTypeName(e),t.content.includes("export enum ".concat(a))||t.internalCustomDatas.push(e);break;case r.DYNAMIC_LIST:case r.STATIC_LIST:e.nestedData&&(e.nestedData[0].type===r.OBJECT||e.nestedData[0].type===r.ENUM?(a=n.generateTypeName(e),t.content.includes("export type ".concat(a))||t.internalCustomDatas.push(e)):a=n.getType(e.nestedData[0],t))}return a},n.generateTypeName=function(e){if(e.typescriptName)return e.typescriptName;var t=e.name||"";return(t=(t=t.replace(/\s/g,"")).replace(/\W/g,""))[0].match(/^\d/)&&(t="_"+t),e.type===r.ENUM&&(t+="Enum"),t},n}();export{n as CustomDataTypesGenerator};
1
+ import{__awaiter as e,__generator as t}from'../../../ext/tslib/tslib.es6.js';import a from"path";import{createFile as o,deleteDirContent as s}from"../../../utils/fs.js";import"../../../models/data/blog/index.js";import"../../../models/data/brand/index.js";import"../../../models/data/category/index.js";import"../../../models/data/checkout/index.js";import"../../../models/data/customer/address/index.js";import"../../../models/data/customer/index.js";import"../../../models/data/customer-review/index.js";import"../../../models/data/html-meta-data/index.js";import"../../../models/data/image/index.js";import"../../../models/data/installment-info/index.js";import"../../../models/data/order/index.js";import"../../../models/data/order/line-item/index.js";import"mobx";import"../../../models/data/product/index.js";import"../../../models/data/variant-type/index.js";import"../../../models/data/product/variant/index.js";import"../../../models/data/product/variant/price/index.js";import"../../../models/data/product-attribute/index.js";import"../../../models/data/product/attribute-value/index.js";import"../../../models/data/product-filter/index.js";import"../../../models/data/variant-type/variant-value/index.js";import"../../../models/data/order-transaction/index.js";import"../../../models/data/product-option-set/index.js";import"../../../models/data/raffle/index.js";import"../../../models/theme/theme.js";import"../../../models/theme/page/index.js";import{IkasThemeComponentPropType as r}from"../../../models/theme/component/prop/index.js";import"../../../models/theme/page/component/prop-value/link.js";import"../../../models/ui/brand-list/index.js";import"../../../models/ui/blog-list/index.js";import"../../../models/ui/blog-category-list/index.js";import"../../../models/ui/category-list/index.js";import"../../../models/ui/product-detail/index.js";import"../../../models/ui/product-list/index.js";import"../../../models/ui/product-attribute-detail/index.js";import"../../../models/ui/product-attribute-list/index.js";import"../../../models/ui/customer-review-list/index.js";import"../../../models/ui/validator/index.js";import"../../../models/ui/validator/rules/index.js";import"../../../models/ui/validator/form/login.js";import"../../../models/ui/validator/form/address.js";import"../../../models/ui/validator/form/register.js";import"../../../models/ui/validator/form/contact-form.js";import"../../../models/ui/validator/form/forgot-password.js";import"../../../models/ui/validator/form/recover-password.js";import"../../../models/ui/validator/form/account-info.js";import"../../../models/ui/validator/form/raffle-form.js";import"../../../models/ui/validator/form/customer-review.js";import"../../../models/ui/raffle-list/index.js";import"../../../models/theme/settings/index.js";import"../../../models/theme/custom-data/index.js";import i from'../../../ext/lodash/uniq.js';var n=function(){function n(){}return n.generate=function(r){return e(this,void 0,void 0,(function(){var e,m,d,p,c;return t(this,(function(t){switch(t.label){case 0:return[4,s(a.join(process.cwd(),"src","components","__generated__","types"))];case 1:t.sent(),e={content:"",imports:[],internalCustomDatas:[]},t.label=2;case 2:return t.trys.push([2,4,,5]),r.customData.forEach((function(t){n.generateAllCustomDataTypes(t,e)})),e.internalCustomDatas.forEach((function(t){n.generateAllCustomDataTypes(t,e)})),m=a.join(process.cwd(),"src","components","__generated__"),e.imports=i(e.imports),d="import {\r\n",e.imports.forEach((function(e){d+="\t".concat(e,",\r\n")})),p=(d+='} from "@ikas/storefront"\r\n\r\n')+e.content,[4,o(m,"types.ts",p)];case 3:return[2,t.sent()];case 4:return c=t.sent(),console.log(c),[2,!1];case 5:return[2]}}))}))},n.generateAllCustomDataTypes=function(e,t){var a=e.type===r.ENUM,o="export ".concat(a?"enum":"type"," ").concat(n.generateTypeName(e)).concat(a?"":" = ","{ \r\n"),s="};\r\n\r\n";e.type!==r.DYNAMIC_LIST&&e.type!==r.STATIC_LIST||!e.nestedData?e.type===r.ENUM&&e.enumOptions?(t.content+=o,e.enumOptions.forEach((function(e){e.value&&e.value[0].match(/^\d/)&&(e.value="_"+e.value),t.content+='\t"'.concat(null==e?void 0:e.value,'" = "').concat(null==e?void 0:e.displayName,'",'),t.content+="\r\n"})),t.content+=s):(t.content+=o,e.nestedData&&e.nestedData.forEach((function(e){n.genenateCustomDataType(e,t),t.content+="\r\n"})),t.content+=s):n.generateAllCustomDataTypes(e.nestedData[0],t)},n.genenateCustomDataType=function(e,t){var a=n.getType(e,t);e.key&&e.key[0].match(/^\d/)&&(e.key="_"+e.key),t.content+="\t".concat(e.key).concat(e.isRequired?"":"?",": ").concat(a).concat([r.DYNAMIC_LIST,r.STATIC_LIST].includes(e.type)?"[]":"").concat(e.type===r.ENUM?",":";")},n.getType=function(e,t){var a="";switch(e.type){case r.TEXT:case r.RICH_TEXT:case r.COLOR:a="string";break;case r.BOOLEAN:a="boolean";break;case r.IMAGE:a="IkasImage",t.imports.push(a);break;case r.IMAGE_LIST:a="IkasImageList",t.imports.push(a);break;case r.LINK:a="IkasNavigationLink",t.imports.push(a);break;case r.LIST_OF_LINK:a="IkasNavigationLink[]",t.imports.push("IkasNavigationLink");break;case r.PRODUCT_DETAIL:a="IkasProductDetail",t.imports.push(a);break;case r.PRODUCT_LIST:a="IkasProductDetail[]",t.imports.push("IkasProductDetail");break;case r.PRODUCT_ATTRIBUTE:a="IkasProductAttribute",t.imports.push(a);break;case r.PRODUCT_ATTRIBUTE_LIST:a="IkasProductAttribute[]",t.imports.push("IkasProductAttribute");break;case r.BRAND:a="IkasBrand",t.imports.push(a);break;case r.BRAND_LIST:a="IkasBrandList",t.imports.push(a);break;case r.CATEGORY:a="IkasCategory",t.imports.push(a);break;case r.CATEGORY_LIST:a="IkasCategoryList",t.imports.push(a);break;case r.COMPONENT:a="IkasComponentRenderer";break;case r.COMPONENT_LIST:a="IkasComponentRenderer[]";break;case r.BLOG:a="IkasBlog",t.imports.push(a);break;case r.BLOG_LIST:a="IkasBlogList",t.imports.push(a);break;case r.BLOG_CATEGORY:a="IkasBlogCategory",t.imports.push(a);break;case r.BLOG_CATEGORY_LIST:a="IkasBlogCategoryList",t.imports.push(a);break;case r.RAFFLE:a="IkasRaffle",t.imports.push(a);break;case r.RAFFLE_LIST:a="IkasRaffleList",t.imports.push(a);break;case r.ENUM:a=n.generateTypeName(e),t.content.includes("export enum ".concat(a))||t.internalCustomDatas.push(e);break;case r.DYNAMIC_LIST:case r.STATIC_LIST:e.nestedData&&(e.nestedData[0].type===r.OBJECT||e.nestedData[0].type===r.ENUM?(a=n.generateTypeName(e.nestedData[0]),t.content.includes("export type ".concat(a))||t.internalCustomDatas.push(e)):a=n.getType(e.nestedData[0],t))}return a},n.generateTypeName=function(e){if(e.typescriptName)return e.typescriptName;var t=e.name||"";return(t=(t=t.replace(/\s/g,"")).replace(/\W/g,""))[0].match(/^\d/)&&(t="_"+t),e.type===r.ENUM&&(t+="Enum"),t},n}();export{n as CustomDataTypesGenerator};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "2.0.0-alpha.21",
3
+ "version": "2.0.0-alpha.23",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.js",
6
6
  "author": "Umut Ozan Yıldırım",