@ikas/storefront 2.0.17 → 2.0.19
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{__awaiter as e,__generator as t}from'../../../ext/tslib/tslib.es6.js';import a from"path";import{createFile as
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../../../ext/tslib/tslib.es6.js';import a from"path";import{createFile as s,deleteDirContent as o}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"../../../api/product-option-file/index.js";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/data/product-campaing/campaign/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,u,l;return t(this,(function(t){switch(t.label){case 0:return[4,o(a.join(process.cwd(),"src","components","__generated__","types"))];case 1:t.sent(),e={content:"",imports:[],internalCustomDatas:[]},t.label=2;case 2:t.trys.push([2,4,,5]),r.customData.forEach((function(t){n.generateAllCustomDataTypes(t,e,r)})),m=0,d=0;do{m=e.internalCustomDatas.length,e.internalCustomDatas.forEach((function(t){n.generateAllCustomDataTypes(t,e,r)})),(d=e.internalCustomDatas.length)!==m&&(e.internalCustomDatas=e.internalCustomDatas.splice(m,d))}while(m!==d);return p=a.join(process.cwd(),"src","components","__generated__"),e.imports=i(e.imports),c="import {\r\n",e.imports.forEach((function(e){c+="\t".concat(e,",\r\n")})),u=(c+='} from "@ikas/storefront"\r\n\r\n')+e.content,[4,s(p,"types.ts",u)];case 3:return[2,t.sent()];case 4:return l=t.sent(),console.log(l),[2,!1];case 5:return[2]}}))}))},n.generateAllCustomDataTypes=function(e,t,a){var s=e.type===r.ENUM,o="export ".concat(s?"enum":"type"," ").concat(n.generateTypeName(e)).concat(s?"":" = ","{ \r\n"),i="};\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){var a=e.value;e.value&&!isNaN(parseInt(e.value))&&(a="_"+e.value),t.content+='\t"'.concat(a,'" = "').concat(null==e?void 0:e.value,'",'),t.content+="\r\n"})),t.content+=i):(t.content+=o,e.nestedData&&e.nestedData.forEach((function(e){n.genenateCustomDataType(e,t,a),t.content+="\r\n"})),t.content+=i):n.generateAllCustomDataTypes(e.nestedData[0],t,a)},n.genenateCustomDataType=function(e,t,a){var s=n.getType(e,t,a);e.key&&e.key[0].match(/^\d/)&&(e.key="_"+e.key),t.content+="\t".concat(e.key).concat(e.isRequired?"":"?",": ").concat(s).concat([r.DYNAMIC_LIST,r.STATIC_LIST].includes(e.type)?"[]":"").concat(e.type===r.ENUM?",":";")},n.getType=function(e,t,a){var s="";switch(e.type){case r.TEXT:case r.RICH_TEXT:case r.COLOR:s="string";break;case r.BOOLEAN:s="boolean";break;case r.IMAGE:s="IkasImage",t.imports.push(s);break;case r.IMAGE_LIST:s="IkasImage[]",t.imports.push("IkasImage");break;case r.LINK:s="IkasNavigationLink",t.imports.push(s);break;case r.LIST_OF_LINK:s="IkasNavigationLink[]",t.imports.push("IkasNavigationLink");break;case r.PRODUCT_DETAIL:s="IkasProductDetail",t.imports.push(s);break;case r.PRODUCT_LIST:s="IkasProductList",t.imports.push("IkasProductList");break;case r.PRODUCT_ATTRIBUTE:s="IkasProductAttribute",t.imports.push(s);break;case r.PRODUCT_ATTRIBUTE_LIST:s="IkasProductAttribute[]",t.imports.push("IkasProductAttribute");break;case r.BRAND:s="IkasBrand",t.imports.push(s);break;case r.BRAND_LIST:s="IkasBrandList",t.imports.push(s);break;case r.CATEGORY:s="IkasCategory",t.imports.push(s);break;case r.CATEGORY_LIST:s="IkasCategoryList",t.imports.push(s);break;case r.CUSTOM:var o=a.customData.find((function(t){return t.id===e.customDataId}));o&&(s=n.generateTypeName(o));break;case r.COMPONENT:s="IkasComponentRenderer",t.imports.push(s);break;case r.COMPONENT_LIST:s="IkasComponentRenderer[]",t.imports.push("IkasComponentRenderer");break;case r.BLOG:s="IkasBlog",t.imports.push(s);break;case r.BLOG_LIST:s="IkasBlogList",t.imports.push(s);break;case r.BLOG_CATEGORY:s="IkasBlogCategory",t.imports.push(s);break;case r.BLOG_CATEGORY_LIST:s="IkasBlogCategoryList",t.imports.push(s);break;case r.RAFFLE:s="IkasRaffle",t.imports.push(s);break;case r.RAFFLE_LIST:s="IkasRaffleList",t.imports.push(s);break;case r.ENUM:s=n.generateTypeName(e),t.content.includes("export enum ".concat(s))||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?(s=n.generateTypeName(e.nestedData[0]),t.content.includes("export type ".concat(s))||t.internalCustomDatas.push(e.nestedData[0])):s=n.getType(e.nestedData[0],t,a))}return s},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};
|