@ikas/storefront 3.0.0-alpha.2 → 3.0.0-alpha.21
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.
- package/build/__api/models/AddItemToCartInput.d.ts +0 -3
- package/build/__api/models/CartV2.d.ts +2 -1
- package/build/__api/models/CreateCustomerEmailSubscriptionInput.d.ts +2 -0
- package/build/__api/models/OrderAdjustmentAppliedOrderLine.d.ts +1 -0
- package/build/__api/models/OrderAdjustmentAppliedOrderLine.js +1 -1
- package/build/__api/models/OrderCustomer.d.ts +0 -6
- package/build/__api/models/OrderShippingLine.d.ts +2 -0
- package/build/__api/models/OrderShippingLine.js +1 -1
- package/build/__api/models/PaymentGateway.d.ts +1 -1
- package/build/__api/models/PaymentGateway.js +1 -1
- package/build/__api/models/SaveMyCustomerInput.d.ts +2 -0
- package/build/__api/models/SaveMyCustomerInput.js +1 -1
- package/build/__api/models/SearchProductAttributeValue.d.ts +1 -0
- package/build/__api/models/StockLocation.js +1 -0
- package/build/__api/models/StockLocationAddress.js +1 -0
- package/build/__api/models/StockLocationAddressCity.js +1 -0
- package/build/__api/models/StockLocationAddressCountry.js +1 -0
- package/build/__api/models/StockLocationAddressDistrict.js +1 -0
- package/build/__api/models/StockLocationAddressState.js +1 -0
- package/build/__api/models/_base.js +1 -1
- package/build/__api/mutations/addCouponCodeToCheckout.d.ts +2 -0
- package/build/__api/mutations/addItemToCart.d.ts +4 -6
- package/build/__api/mutations/addItemToCart.js +1 -1
- package/build/__api/mutations/createCustomerEmailSubscription.d.ts +1 -1
- package/build/__api/mutations/createCustomerReview.d.ts +1 -1
- package/build/__api/mutations/createOrderRefundRequest.d.ts +3 -6
- package/build/__api/mutations/createOrderRefundRequest.js +1 -1
- package/build/__api/mutations/createSaleTransactionWithCart.d.ts +1 -1
- package/build/__api/mutations/customerLogin.d.ts +1 -1
- package/build/__api/mutations/customerRefreshToken.d.ts +1 -1
- package/build/__api/mutations/getOrderLineFile.d.ts +1 -1
- package/build/__api/mutations/registerCustomer.d.ts +1 -1
- package/build/__api/mutations/retrieveInstallmentInfo.d.ts +1 -1
- package/build/__api/mutations/saveCart.d.ts +4 -6
- package/build/__api/mutations/saveCart.js +1 -1
- package/build/__api/mutations/saveCartCouponCode.d.ts +4 -6
- package/build/__api/mutations/saveCartCouponCode.js +1 -1
- package/build/__api/mutations/saveCheckout.d.ts +2 -0
- package/build/__api/mutations/saveLastViewedProducts.d.ts +1 -1
- package/build/__api/mutations/saveMyCustomer.d.ts +1 -1
- package/build/__api/mutations/saveProductBackInStockRemind.d.ts +1 -1
- package/build/__api/mutations/saveRaffleParticipant.d.ts +1 -1
- package/build/__api/queries/checkCustomerEmail.d.ts +1 -1
- package/build/__api/queries/checkStocks.d.ts +1 -1
- package/build/__api/queries/customerSocialLogin.d.ts +1 -1
- package/build/__api/queries/getAvailableShippingCountries.d.ts +1 -1
- package/build/__api/queries/getCartById.d.ts +5 -8
- package/build/__api/queries/getCartById.js +1 -1
- package/build/__api/queries/getCheckoutByCartId.d.ts +2 -0
- package/build/__api/queries/getCheckoutById.d.ts +2 -0
- package/build/__api/queries/getCustomerOrders.d.ts +3 -6
- package/build/__api/queries/getCustomerOrders.js +1 -1
- package/build/__api/queries/getLastViewedProducts.d.ts +1 -1
- package/build/__api/queries/getMyCountry.d.ts +1 -1
- package/build/__api/queries/getMyCustomer.d.ts +1 -1
- package/build/__api/queries/getOrder.d.ts +2 -5
- package/build/__api/queries/getOrderByEmail.d.ts +3 -6
- package/build/__api/queries/getOrderByEmail.js +1 -1
- package/build/__api/queries/getProductCampaigns.d.ts +1 -1
- package/build/__api/queries/getProductFilterData.d.ts +1 -1
- package/build/__api/queries/getRafflesByCustomerId.d.ts +1 -1
- package/build/__api/queries/getStorefront.d.ts +1 -1
- package/build/__api/queries/listBlog.d.ts +1 -1
- package/build/__api/queries/listBlogCategory.d.ts +1 -1
- package/build/__api/queries/listBlogMetadata.d.ts +1 -1
- package/build/__api/queries/listCategory.d.ts +1 -1
- package/build/__api/queries/listCheckoutSettings.d.ts +1 -1
- package/build/__api/queries/listCity.d.ts +1 -1
- package/build/__api/queries/listCountry.d.ts +1 -1
- package/build/__api/queries/listCustomerAttribute.d.ts +1 -1
- package/build/__api/queries/listCustomerReviewSummary.d.ts +1 -1
- package/build/__api/queries/listCustomerReviews.d.ts +1 -1
- package/build/__api/queries/listDistrict.d.ts +1 -1
- package/build/__api/queries/listFavoriteProducts.d.ts +1 -1
- package/build/__api/queries/listHTMLMetaData.d.ts +1 -1
- package/build/__api/queries/listMerchantSettings.d.ts +1 -1
- package/build/__api/queries/listOrderRefundSettings.d.ts +1 -1
- package/build/__api/queries/listOrderTransactions.d.ts +1 -1
- package/build/__api/queries/listPaymentGateway.d.ts +2 -2
- package/build/__api/queries/listPaymentGateway.js +1 -1
- package/build/__api/queries/listProductAttribute.d.ts +1 -1
- package/build/__api/queries/listProductBackInStockRemind.d.ts +1 -1
- package/build/__api/queries/listProductBrand.d.ts +1 -1
- package/build/__api/queries/listProductOptionSet.d.ts +1 -1
- package/build/__api/queries/listRaffle.d.ts +1 -1
- package/build/__api/queries/listRaffleMetadata.d.ts +1 -1
- package/build/__api/queries/listState.d.ts +1 -1
- package/build/__api/queries/listStockLocation.js +1 -0
- package/build/__api/queries/searchProducts.d.ts +3 -1
- package/build/__api/queries/searchProducts.js +1 -1
- package/build/__api/types/index.d.ts +10 -49
- package/build/__api/types/index.js +1 -1
- package/build/analytics/analytics.d.ts +1 -1
- package/build/analytics/facebookPixel.d.ts +1 -1
- package/build/analytics/googleAnalytics.d.ts +1 -1
- package/build/analytics/googleTagManager.d.ts +1 -1
- package/build/analytics/googleUniversal.d.ts +1 -1
- package/build/analytics/ikas.d.ts +1 -1
- package/build/analytics/ikas.js +1 -1
- package/build/assets/translations/checkout/en.js +1 -1
- package/build/assets/translations/checkout/tr.js +1 -1
- package/build/components/checkout/components/address-form/index.js +1 -1
- package/build/components/checkout/components/address-form/model.d.ts +1 -0
- package/build/components/checkout/components/customer-addresses/index.d.ts +4 -0
- package/build/components/checkout/components/customer-addresses/index.js +1 -1
- package/build/components/checkout/components/customer-addresses/style.module.scss.js +1 -1
- package/build/components/checkout/components/delivery-methods/icon-button/index.d.ts +10 -0
- package/build/components/checkout/components/delivery-methods/icon-button/index.js +1 -0
- package/build/components/checkout/components/delivery-methods/icon-button/style.module.scss.js +1 -0
- package/build/components/checkout/components/delivery-methods/icons/box.d.ts +6 -0
- package/build/components/checkout/components/delivery-methods/icons/box.js +1 -0
- package/build/components/checkout/components/delivery-methods/icons/store.d.ts +6 -0
- package/build/components/checkout/components/delivery-methods/icons/store.js +1 -0
- package/build/components/checkout/components/delivery-methods/index.d.ts +7 -0
- package/build/components/checkout/components/delivery-methods/index.js +1 -0
- package/build/components/checkout/components/delivery-methods/style.module.scss.js +1 -0
- package/build/components/checkout/index.d.ts +1 -1
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +13 -3
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/steps/step-info/index.js +1 -1
- package/build/components/checkout/steps/step-payment/billing-address/index.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/components/checkout/style.module.scss.js +1 -1
- package/build/components/index.d.ts +0 -1
- package/build/components/page-editor/model.js +1 -1
- package/build/ext/@ikas/fe-api-client/build/_virtual/_commonjsHelpers.js +1 -1
- package/build/ext/@ikas/fe-api-client/build/_virtual/axios-error-format.js_commonjs-exports.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/_virtual/core.js_commonjs-exports.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/_virtual/index.js_commonjs-exports.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/ext/@redtea/format-axios-error/axios-error-format.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/ext/@redtea/format-axios-error/core.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/ext/@redtea/format-axios-error/index.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/ext/@redtea/format-axios-error/index.mjs.js +1 -0
- package/build/ext/@ikas/fe-api-client/build/utils/api.js +1 -1
- package/build/ext/@ikas/fe-api-client/build/utils/fetch-query.js +1 -1
- package/build/ext/uuid/dist/{esm-browser → esm-node}/regex.js +0 -0
- package/build/ext/uuid/dist/esm-node/rng.js +1 -0
- package/build/ext/uuid/dist/esm-node/stringify.js +1 -0
- package/build/ext/uuid/dist/esm-node/v4.js +1 -0
- package/build/ext/uuid/dist/{esm-browser → esm-node}/validate.js +0 -0
- package/build/ikas.cjs +2 -0
- package/build/index.js +1 -1
- package/build/models/data/blog/enums.d.ts +1 -1
- package/build/models/data/blog/index.d.ts +6 -6
- package/build/models/data/brand/enums.d.ts +1 -1
- package/build/models/data/brand/index.d.ts +2 -2
- package/build/models/data/cart/campaign-offer/enums.d.ts +1 -1
- package/build/models/data/cart/campaign-offer/index.d.ts +1 -1
- package/build/models/data/cart/enums.d.ts +1 -1
- package/build/models/data/cart/index.d.ts +4 -3
- package/build/models/data/cart/index.js +1 -1
- package/build/models/data/category/enums.d.ts +1 -1
- package/build/models/data/category/index.d.ts +3 -3
- package/build/models/data/checkout/index.d.ts +3 -3
- package/build/models/data/checkout/index.js +1 -1
- package/build/models/data/checkout-settings/enums.d.ts +1 -1
- package/build/models/data/checkout-settings/index.d.ts +2 -2
- package/build/models/data/city/index.d.ts +1 -1
- package/build/models/data/country/index.d.ts +1 -1
- package/build/models/data/customer/address/index.d.ts +6 -6
- package/build/models/data/customer/address/index.js +1 -1
- package/build/models/data/customer/attribute-value/index.d.ts +1 -1
- package/build/models/data/customer/enums.d.ts +1 -1
- package/build/models/data/customer/index.d.ts +2 -2
- package/build/models/data/customer-attribute/customer-attribute-option/index.d.ts +1 -1
- package/build/models/data/customer-attribute/customer-attribute-sales-channel/enums.d.ts +1 -1
- package/build/models/data/customer-attribute/customer-attribute-sales-channel/index.d.ts +1 -1
- package/build/models/data/customer-attribute/enums.d.ts +1 -1
- package/build/models/data/customer-attribute/index.d.ts +3 -3
- package/build/models/data/customer-review/enums.d.ts +1 -1
- package/build/models/data/customer-review/index.d.ts +1 -1
- package/build/models/data/customer-review-summary/index.d.ts +2 -2
- package/build/models/data/district/index.d.ts +1 -1
- package/build/models/data/favorite-product/index.d.ts +1 -1
- package/build/models/data/html-meta-data/enums.d.ts +1 -1
- package/build/models/data/html-meta-data/index.d.ts +2 -2
- package/build/models/data/index.d.ts +0 -1
- package/build/models/data/merchant-settings/index.d.ts +1 -1
- package/build/models/data/order/address/index.d.ts +5 -5
- package/build/models/data/order/address/index.js +1 -1
- package/build/models/data/order/adjustment/enums.d.ts +1 -1
- package/build/models/data/order/adjustment/index.d.ts +1 -1
- package/build/models/data/order/customer/index.d.ts +0 -6
- package/build/models/data/order/customer/index.js +1 -1
- package/build/models/data/order/enums.d.ts +1 -1
- package/build/models/data/order/gift-line/index.d.ts +1 -1
- package/build/models/data/order/index.d.ts +3 -3
- package/build/models/data/order/invoice/enums.d.ts +1 -1
- package/build/models/data/order/invoice/index.d.ts +1 -1
- package/build/models/data/order/line-item/discount/index.d.ts +1 -1
- package/build/models/data/order/line-item/enums.d.ts +1 -1
- package/build/models/data/order/line-item/index.d.ts +1 -1
- package/build/models/data/order/line-item/option/index.d.ts +1 -1
- package/build/models/data/order/line-item/option/value/index.d.ts +1 -1
- package/build/models/data/order/line-item/variant/index.d.ts +2 -2
- package/build/models/data/order/package/enums.d.ts +1 -1
- package/build/models/data/order/package/index.d.ts +1 -1
- package/build/models/data/order/package/tracking-info/index.d.ts +1 -1
- package/build/models/data/order/payment-method/enums.d.ts +1 -1
- package/build/models/data/order/payment-method/index.d.ts +1 -1
- package/build/models/data/order/refund/line-item/index.d.ts +1 -1
- package/build/models/data/order/shipping-line/index.d.ts +1 -1
- package/build/models/data/order/tax-line/index.d.ts +1 -1
- package/build/models/data/order/transaction/enums.d.ts +1 -1
- package/build/models/data/order/transaction/index.d.ts +4 -3
- package/build/models/data/order/transaction/index.js +1 -1
- package/build/models/data/payment-gateway/additional-price/index.d.ts +1 -1
- package/build/models/data/payment-gateway/enums.d.ts +1 -1
- package/build/models/data/payment-gateway/index.d.ts +1 -1
- package/build/models/data/payment-gateway/index.js +1 -1
- package/build/models/data/product/attribute-value/index.d.ts +1 -1
- package/build/models/data/product/variant/price/index.d.ts +1 -1
- package/build/models/data/product-filter/index.d.ts +1 -1
- package/build/models/data/product-option-set/enums.d.ts +1 -1
- package/build/models/data/state/index.d.ts +1 -1
- package/build/models/data/storefront/index.d.ts +1 -0
- package/build/models/data/storefront/index.js +1 -1
- package/build/models/theme/custom-data/index.js +1 -1
- package/build/models/theme/settings/color/index.js +1 -1
- package/build/models/ui/customer-review-summary-list/index.d.ts +1 -1
- package/build/models/ui/product-list/index.d.ts +2 -2
- package/build/models/ui/validator/form/register.d.ts +1 -1
- package/build/pages/404.js +1 -1
- package/build/pages/_slug_/index.js +1 -1
- package/build/pages/account/addresses.js +1 -1
- package/build/pages/account/favorite-products.js +1 -1
- package/build/pages/account/forgot-password.js +1 -1
- package/build/pages/account/index.js +1 -1
- package/build/pages/account/login.js +1 -1
- package/build/pages/account/orders/_id_.js +1 -1
- package/build/pages/account/orders/index.js +1 -1
- package/build/pages/account/raffles.js +1 -1
- package/build/pages/account/recover-password.js +1 -1
- package/build/pages/account/register.js +1 -1
- package/build/pages/blog/_slug_.js +1 -1
- package/build/pages/blog/index.js +1 -1
- package/build/pages/cart.js +1 -1
- package/build/pages/checkout.js +1 -1
- package/build/pages/editor.d.ts +1 -1
- package/build/pages/home.js +1 -1
- package/build/pages/pages/_slug_.js +1 -1
- package/build/pages/raffle/_slug_.js +1 -1
- package/build/pages/raffle/index.js +1 -1
- package/build/pages/search.js +1 -1
- package/build/providers/page-data-get.d.ts +1 -0
- package/build/providers/page-data-get.js +1 -1
- package/build/providers/page-data-next.d.ts +6 -0
- package/build/providers/page-data-next.js +1 -1
- package/build/providers/prop-value/slider.d.ts +1 -1
- package/build/scripts/generators/config/content.d.ts +5 -0
- package/build/scripts/generators/config/content.js +1 -1
- package/build/scripts/generators/config/index.js +1 -1
- package/build/scripts/generators/types/index.d.ts +2 -1
- package/build/scripts/generators/types/index.js +1 -1
- package/build/store/base.d.ts +1 -0
- package/build/store/base.js +1 -1
- package/build/store/cart/index.js +1 -1
- package/build/store/checkout/index.d.ts +4 -1
- package/build/store/checkout/index.js +1 -1
- package/build/store/customer/api.d.ts +13 -6
- package/build/store/customer/api.js +1 -1
- package/build/store/customer/index.js +1 -1
- package/build/store/location/index.d.ts +1 -1
- package/build/store/product/index.d.ts +7 -2
- package/build/store/product/index.js +1 -1
- package/build/storefront/index.d.ts +3 -0
- package/build/storefront/index.js +1 -1
- package/build/utils/currency.js +1 -1
- package/build/utils/helper.d.ts +1 -0
- package/build/utils/helper.js +1 -1
- package/package.json +3 -3
- package/build/__api/models/CustomerAddressInput.d.ts +0 -29
- package/build/__api/models/CustomerInput.d.ts +0 -23
- package/build/__api/mutations/updateCustomer.d.ts +0 -69
- package/build/ext/uuid/dist/esm-browser/rng.js +0 -1
- package/build/ext/uuid/dist/esm-browser/stringify.js +0 -1
- package/build/ext/uuid/dist/esm-browser/v4.js +0 -1
- package/build/ikas.js +0 -98
- package/build/models/data/simple-product/index.d.ts +0 -137
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as o,__spreadArray as r}from'../ext/tslib/tslib.es6.js';import i from"fs";import n from"next/config.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/index.js";import"../models/data/city/index.js";import"mobx";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute-value/index.js";import"../models/data/customer/index.js";import"../models/data/customer-attribute/customer-attribute-option/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-review/index.js";import"../models/data/customer-review-summary/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/address/index.js";import"../models/data/order/adjustment/index.js";import"../models/data/order/gift-line/index.js";import"../models/data/order/invoice/index.js";import"../models/data/order/line-item/discount/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/option/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/tracking-info/index.js";import"../models/data/order/package/index.js";import"../models/data/order/payment-method/index.js";import"../models/data/order/refund/line-item/index.js";import"../models/data/order/shipping-line/index.js";import"../models/data/order/tax-line/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product-filter/index.js";import"../models/data/product-campaign/campaign/index.js";import"../models/data/product-campaign/filter/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/variant-type/variant-value/index.js";import{IkasTheme as s}from"../models/theme/theme.js";import{IkasThemePageType as a}from"../models/theme/page/index.js";import"../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/customer-review-summary-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{IkasStorefront as d}from"../models/data/storefront/index.js";import{IkasSalesChannel as l}from"../models/data/sales-channel/index.js";import{IkasStorefrontRouting as m}from"../models/data/storefront/routing/index.js";import{IkasStorefrontConfig as c}from"../storefront/index.js";import{IkasPageDataProvider as u}from"./page-data-get.js";import{IkasStorefrontThemeLocalization as p}from"../models/data/storefront/theme-localization/index.js";import{I18NFileReader as f}from"../utils/i18n.js";import{getGoogleFontHref as g}from"../utils/google-fonts.js";import v from"../store/storefront/index.js";import j from"../store/checkout/index.js";var h=function(){function h(){}return h.readLocalTheme=function(){return new Promise((function(e,t){i.readFile("./src/theme.json",{flag:"a+"},(function(o,r){if(o)return t(o);var i=r.length?JSON.parse(r.toString()):{};e(new s(i))}))}))},h.readSettingsFile=function(){return new Promise((function(e){var t=n().serverRuntimeConfig.SETTINGS;i.readFile(t,{flag:"a+"},(function(t,o){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var r=o.length?JSON.parse(o.toString()):{};e(r)}))}))},h.getLocalSettings=function(o){return e(this,void 0,void 0,(function(){var e,r,i,n,s,a;return t(this,(function(t){switch(t.label){case 0:return c.storefrontId?[4,v.getStorefront({id:c.storefrontId})]:(console.error("Missing storefrontId in the config.json file!"),[2,null]);case 1:return(e=t.sent()).isSuccess&&e.data?(r=e.data,[4,h.readLocalTheme()]):[2,null];case 2:return i=t.sent(),n=h.createColorScript(i.settings),s=h.createFontScript(i.settings),a=[],n&&a.push(n),s&&a.push(s),[2,{storefront:r,themeLocalization:new p({themeJson:i}),salesChannel:new l({id:r.salesChannelId}),routing:r.routings.length?r.routings.find((function(e){return e.locale===o||e.id===o}))||r.routings[0]:new m({}),favicon:i.settings.favicon,stockPreference:i.settings.stockPreference,storefrontJSScripts:a,domain:"",productBackInStockSettings:{customerLoginRequired:!0},customerReviewSettings:{customerLoginRequired:!0,customerPurchaseRequired:!1}}]}}))}))},h.getProdSettings=function(o){return e(this,void 0,void 0,(function(){var r=this;return t(this,(function(n){return[2,new Promise((function(n){return e(r,void 0,void 0,(function(){var e,r,s,a,m,c,u,f,g,v;return t(this,(function(t){switch(t.label){case 0:return[4,h.readSettingsFile()];case 1:return(e=t.sent())&&e.localizationMap?(r=new d(e.storefront),s=new l(e.salesChannel),a=e.localizationMap,m=e.storefrontJSScripts||[],c=e.domain,u=e.productBackInStockSettings?{customerLoginRequired:e.productBackInStockSettings.customerLoginRequired}:null,f=e.customerReviewSettings?{customerLoginRequired:e.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:e.customerReviewSettings.customerPurchaseRequired||!1}:null,g=a[o],v=r.routings.find((function(e){return e.id===o||e.path===o})),g&&v?(i.readFile(g,{flag:"a+"},(function(e,t){if(e)return console.error("THEME LOCALZIATION FILE READ ERROR!!!"),console.error(e),n(null);var o=t.length?JSON.parse(t.toString()):{},i=new p(o),a=i.themeJson.settings.favicon,d=i.themeJson.settings.stockPreference;if(i.themeJson.settings){var l=h.createColorScript(i.themeJson.settings),g=h.createFontScript(i.themeJson.settings);l&&m.push(l),g&&m.push(g)}n({storefront:r,themeLocalization:i,salesChannel:s,routing:v,favicon:a,stockPreference:d,storefrontJSScripts:m,domain:c,productBackInStockSettings:u,customerReviewSettings:f})})),[2]):(console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,n(null)])):[2,n(null)]}}))}))}))]}))}))},h.getSettings=function(o){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?[4,this.getLocalSettings(o)]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,this.getProdSettings(o)]}}))}))},h.getPageData=function(i,s,d,l,m){var p,g,v;return e(this,void 0,void 0,(function(){var e,x,S,C,y,b,I,w,P,k,L,R,T,B,E,V,J,F,O,N,D,A,q,z,M,G;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,x=!e&&m,S=n().serverRuntimeConfig,x?[3,7]:(C=i.locale)?[4,h.getSettings(C)]:[2,{props:{},notFound:!0}];case 1:return(y=t.sent())&&y.storefront.mainStorefrontThemeId&&y.storefront.salesChannelId?(b=y.storefront,I=y.themeLocalization,w=y.salesChannel,P=y.routing,k=y.favicon,L=y.stockPreference,R=y.storefrontJSScripts,T=y.domain,B=y.productBackInStockSettings,E=y.customerReviewSettings,c.storefrontId=b.id,c.storefrontRoutingId=P.id,c.storefrontThemeId=b.mainStorefrontThemeId,c.salesChannelId=b.salesChannelId,c.priceListId=P.priceListId||void 0,c.stockLocationIds=null===(p=w.stockLocations)||void 0===p?void 0:p.map((function(e){return e.id})),c.routings=b.routings,c.paymentGateways=w.paymentGateways||[],c.gtmId=b.gtmId||void 0,c.fbpId=b.fbpId||void 0,c.analytics4Id=b.analytics4Id||void 0,c.universalAnalyticsId=b.universalAnalyticsId||void 0,c.favicon=k||null,c.stockPreference=L||null,c.storefrontJSScripts=R||[],c.domain=T,c.productBackInStockSettings=B,c.customerReviewSettings=E,(V=new u(I.themeJson,i.params,d)).possiblePageTypes=l||(d?[d]:[]),m?[3,3]:[4,V.getPageData()]):[2,{props:{},notFound:!0}];case 2:if(t.sent(),!V.page)return[2,{props:{},notFound:!0}];t.label=3;case 3:return J=m?V.theme.components.map((function(e){return e.id})):V.page.components.map((function(e){return e.componentId})),F=I.themeJson.components.filter((function(e){return m||J.includes(e.id)})),O=r(["common"],F.map((function(e){return e.dir})),!0),(d===a.CHECKOUT||m)&&O.push("checkout-page"),N=S.nextI18nConf,D=P.locale,[4,new f(D,O,e?void 0:N.localePath).read()];case 4:return A=t.sent(),c.translations=A,q={},d!==a.CHECKOUT?[3,6]:(z=null===(g=V.page)||void 0===g?void 0:g.components[0])?[4,j.listCheckoutSettings({})]:[3,6];case 5:M=t.sent(),G={buttonBgColor:z.propValues.buttonBgColor,buttonTextColor:z.propValues.buttonTextColor,buttonDisabledBgColor:z.propValues.buttonDisabledBgColor,buttonDisabledTextColor:z.propValues.buttonDisabledTextColor,primaryTextColor:z.propValues.primaryTextColor,secondaryTextColor:z.propValues.secondaryTextColor,primaryBgColor:z.propValues.primaryBgColor,secondaryBgColor:z.propValues.secondaryBgColor,borderColor:z.propValues.borderColor,cardBgColor:z.propValues.cardBgColor,errorColor:z.propValues.errorColor,errorLightColor:z.propValues.errorLightColor,warningColor:z.propValues.warningColor,warningLightColor:z.propValues.warningLightColor,successColor:z.propValues.successColor,successLightColor:z.propValues.successLightColor},q.customizationProps=G,q.returnPolicy=I.returnPolicy,q.privacyPolicy=I.privacyPolicy,q.termsOfService=I.termsOfService,q.checkoutSettingsStr=(null===(v=null==M?void 0:M.data)||void 0===v?void 0:v.length)?JSON.stringify(M.data[0]):null,t.label=6;case 6:return s?[2,{props:o(o({},V.nextPageData.props),q)}]:[2,{props:o(o({},V.nextPageData.props),q),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},h.getStaticProps=function(o,r,i,n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!1,r,i,n)];case 1:return[2,e.sent()]}}))}))},h.getServerSideProps=function(o,r){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!0,r)];case 1:return[2,e.sent()]}}))}))},h.createColorScript=function(e){if(e.colors)return"<script>".concat(e.colors.map((function(e){return'document.documentElement.style.setProperty("'.concat(e.key,'","').concat(e.color,'");')})).join("\r\n"),"<\/script> \n ")},h.createFontScript=function(e){var t=g(e.fontFamily);if(t)return'<link id="ikas-font" rel="stylesheet" href="'.concat(t,"\"> \n <style>\n body { \n font-family: '").concat(e.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n </style>')},h}();export{h as IkasNextPageDataProvider};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as o,__spreadArray as r}from'../ext/tslib/tslib.es6.js';import i from"fs";import n from"next/config.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/index.js";import"../models/data/city/index.js";import"mobx";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute-value/index.js";import"../models/data/customer/index.js";import"../models/data/customer-attribute/customer-attribute-option/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-review/index.js";import"../models/data/customer-review-summary/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/address/index.js";import"../models/data/order/adjustment/index.js";import"../models/data/order/gift-line/index.js";import"../models/data/order/invoice/index.js";import"../models/data/order/line-item/discount/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/option/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/tracking-info/index.js";import"../models/data/order/package/index.js";import"../models/data/order/payment-method/index.js";import"../models/data/order/refund/line-item/index.js";import"../models/data/order/shipping-line/index.js";import"../models/data/order/tax-line/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product-filter/index.js";import"../models/data/product-campaign/campaign/index.js";import"../models/data/product-campaign/filter/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/variant-type/variant-value/index.js";import{IkasTheme as s}from"../models/theme/theme.js";import{IkasThemePageType as a}from"../models/theme/page/index.js";import"../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/customer-review-summary-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{IkasStorefront as d}from"../models/data/storefront/index.js";import{IkasSalesChannel as l}from"../models/data/sales-channel/index.js";import{IkasStorefrontRouting as m}from"../models/data/storefront/routing/index.js";import{IkasStorefrontConfig as c}from"../storefront/index.js";import{IkasPageDataProvider as u}from"./page-data-get.js";import{IkasStorefrontThemeLocalization as p}from"../models/data/storefront/theme-localization/index.js";import{I18NFileReader as f}from"../utils/i18n.js";import{getGoogleFontHref as g}from"../utils/google-fonts.js";import v from"../store/storefront/index.js";import j from"../store/checkout/index.js";var h=function(){function h(){}return h.readLocalTheme=function(){return new Promise((function(e,t){i.readFile("./src/theme.json",{flag:"a+"},(function(o,r){if(o)return t(o);var i=r.length?JSON.parse(r.toString()):{};e(new s(i))}))}))},h.readSettingsFile=function(){return new Promise((function(e){var t=n().serverRuntimeConfig.SETTINGS;i.readFile(t,{flag:"a+"},(function(t,o){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var r=o.length?JSON.parse(o.toString()):{};e(r)}))}))},h.getLocalSettings=function(o){return e(this,void 0,void 0,(function(){var e,r,i,n,s,a;return t(this,(function(t){switch(t.label){case 0:return c.storefrontId?[4,v.getStorefront({id:c.storefrontId})]:(console.error("Missing storefrontId in the config.json file!"),[2,null]);case 1:return(e=t.sent()).isSuccess&&e.data?(r=e.data,[4,h.readLocalTheme()]):[2,null];case 2:return i=t.sent(),n=h.createColorScript(i.settings),s=h.createFontScript(i.settings),a=[],n&&a.push(n),s&&a.push(s),[2,{storefront:r,themeLocalization:new p({themeJson:i}),salesChannel:new l({id:r.salesChannelId}),routing:r.routings.length?r.routings.find((function(e){return e.locale===o||e.id===o}))||r.routings[0]:new m({}),favicon:i.settings.favicon,stockPreference:i.settings.stockPreference,storefrontJSScripts:a,domain:"",productBackInStockSettings:{customerLoginRequired:!0},customerReviewSettings:{customerLoginRequired:!0,customerPurchaseRequired:!1}}]}}))}))},h.getProdSettings=function(o){return e(this,void 0,void 0,(function(){var r=this;return t(this,(function(n){return[2,new Promise((function(n){return e(r,void 0,void 0,(function(){var e,r,s,a,m,c,u,f,g,v;return t(this,(function(t){switch(t.label){case 0:return[4,h.readSettingsFile()];case 1:return(e=t.sent())&&e.localizationMap?(r=new d(e.storefront),s=new l(e.salesChannel),a=e.localizationMap,m=e.storefrontJSScripts||[],c=e.domain,u=e.productBackInStockSettings?{customerLoginRequired:e.productBackInStockSettings.customerLoginRequired}:null,f=e.customerReviewSettings?{customerLoginRequired:e.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:e.customerReviewSettings.customerPurchaseRequired||!1}:null,g=a[o],v=r.routings.find((function(e){return e.id===o||e.path===o})),g&&v?(i.readFile(g,{flag:"a+"},(function(e,t){if(e)return console.error("THEME LOCALZIATION FILE READ ERROR!!!"),console.error(e),n(null);var o=t.length?JSON.parse(t.toString()):{},i=new p(o),a=i.themeJson.settings.favicon,d=i.themeJson.settings.stockPreference;if(i.themeJson.settings){var l=h.createColorScript(i.themeJson.settings),g=h.createFontScript(i.themeJson.settings);l&&m.push(l),g&&m.push(g)}n({storefront:r,themeLocalization:i,salesChannel:s,routing:v,favicon:a,stockPreference:d,storefrontJSScripts:m,domain:c,productBackInStockSettings:u,customerReviewSettings:f})})),[2]):(console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,n(null)])):[2,n(null)]}}))}))}))]}))}))},h.getSettings=function(o){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?[4,this.getLocalSettings(o)]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,this.getProdSettings(o)]}}))}))},h.getPageData=function(i,s,d,l,m){var p,g,v;return e(this,void 0,void 0,(function(){var e,x,S,C,I,y,b,k,w,L,P,R,T,B,E,V,J,F,O,N,D,A,U,q,z,M;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,x=!e&&m,S=n().serverRuntimeConfig,x?[3,7]:(C=i.locale)?[4,h.getSettings(C)]:[2,{props:{},notFound:!0}];case 1:return(I=t.sent())&&I.storefront.mainStorefrontThemeId&&I.storefront.salesChannelId?(y=I.storefront,b=I.themeLocalization,k=I.salesChannel,w=I.routing,L=I.favicon,P=I.stockPreference,R=I.storefrontJSScripts,T=I.domain,B=I.productBackInStockSettings,E=I.customerReviewSettings,c.storefrontId=y.id,c.storefrontRoutingId=w.id,c.storefrontThemeId=y.mainStorefrontThemeId,c.salesChannelId=y.salesChannelId,c.priceListId=w.priceListId||void 0,c.stockLocationIds=null===(p=k.stockLocations)||void 0===p?void 0:p.map((function(e){return e.id})),c.routings=y.routings,c.paymentGateways=k.paymentGateways||[],c.gtmId=y.gtmId||void 0,c.fbpId=y.fbpId||void 0,c.analytics4Id=y.analytics4Id||void 0,c.universalAnalyticsId=y.universalAnalyticsId||void 0,c.favicon=L||null,c.pickUpStockLocationIds=y.pickUpStockLocationIds&&y.pickUpStockLocationIds.length?y.pickUpStockLocationIds:null,c.stockPreference=P||null,c.storefrontJSScripts=R||[],c.domain=T,c.productBackInStockSettings=B,c.customerReviewSettings=E,(V=new u(b.themeJson,i.params,d)).possiblePageTypes=l||(d?[d]:[]),m?[3,3]:[4,V.getPageData()]):[2,{props:{},notFound:!0}];case 2:if(t.sent(),!V.page)return[2,{props:{},notFound:!0}];t.label=3;case 3:return J=m?V.theme.components.map((function(e){return e.id})):V.page.components.map((function(e){return e.componentId})),F=b.themeJson.components.filter((function(e){return m||J.includes(e.id)})),O=r(["common"],F.map((function(e){return e.dir})),!0),(d===a.CHECKOUT||m)&&O.push("checkout-page"),N=S.nextI18nConf,D=w.locale,[4,new f(D,O,e?void 0:N.localePath).read()];case 4:return A=t.sent(),c.translations=A,U={},d!==a.CHECKOUT?[3,6]:(q=null===(g=V.page)||void 0===g?void 0:g.components[0])?[4,j.listCheckoutSettings({})]:[3,6];case 5:z=t.sent(),M={buttonBgColor:q.propValues.buttonBgColor,buttonTextColor:q.propValues.buttonTextColor,buttonDisabledBgColor:q.propValues.buttonDisabledBgColor,buttonDisabledTextColor:q.propValues.buttonDisabledTextColor,primaryTextColor:q.propValues.primaryTextColor,secondaryTextColor:q.propValues.secondaryTextColor,primaryBgColor:q.propValues.primaryBgColor,secondaryBgColor:q.propValues.secondaryBgColor,borderColor:q.propValues.borderColor,cardBgColor:q.propValues.cardBgColor,errorColor:q.propValues.errorColor,errorLightColor:q.propValues.errorLightColor,warningColor:q.propValues.warningColor,warningLightColor:q.propValues.warningLightColor,successColor:q.propValues.successColor,successLightColor:q.propValues.successLightColor},U.customizationProps=M,U.returnPolicy=b.returnPolicy,U.privacyPolicy=b.privacyPolicy,U.termsOfService=b.termsOfService,U.checkoutSettingsStr=(null===(v=null==z?void 0:z.data)||void 0===v?void 0:v.length)?JSON.stringify(z.data[0]):null,t.label=6;case 6:return s?[2,{props:o(o({},V.nextPageData.props),U)}]:[2,{props:o(o({},V.nextPageData.props),U),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},h.getStaticProps=function(o,r,i,n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!1,r,i,n)];case 1:return[2,e.sent()]}}))}))},h.getServerSideProps=function(o,r){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!0,r)];case 1:return[2,e.sent()]}}))}))},h.createColorScript=function(e){if(e.colors)return"<script>".concat(e.colors.map((function(e){return'document.documentElement.style.setProperty("'.concat(e.key,'","').concat(e.color,'");')})).join("\r\n"),"<\/script> \n ")},h.createFontScript=function(e){var t=g(e.fontFamily);if(t)return'<link id="ikas-font" rel="stylesheet" href="'.concat(t,"\"> \n <style>\n body { \n font-family: '").concat(e.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n </style>')},h}();export{h as IkasNextPageDataProvider};
|
|
@@ -10,6 +10,7 @@ export declare const DEPENDENCIES: {
|
|
|
10
10
|
export declare const DEV_DEPENDENCIES: {
|
|
11
11
|
"@types/node": string;
|
|
12
12
|
"@types/react": string;
|
|
13
|
+
"@types/react-dom": string;
|
|
13
14
|
"@typescript-eslint/eslint-plugin": string;
|
|
14
15
|
"@typescript-eslint/parser": string;
|
|
15
16
|
eslint: string;
|
|
@@ -23,6 +24,10 @@ export declare const DEV_DEPENDENCIES: {
|
|
|
23
24
|
sass: string;
|
|
24
25
|
typescript: string;
|
|
25
26
|
};
|
|
27
|
+
export declare const RESOLUTIONS: {
|
|
28
|
+
"@types/react": string;
|
|
29
|
+
"@types/react-dom": string;
|
|
30
|
+
};
|
|
26
31
|
export declare const SCRIPTS: {
|
|
27
32
|
upgradeDependencies: string;
|
|
28
33
|
dev: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e={next:"12.0.7",react:"17.0.2","react-dom":"17.0.2",mobx:"^6.1.3","mobx-react-lite":"^3.1.5","next-transpile-modules":"^9.0.0","@ikas/storefront-utils":"^3.0.0-alpha.20"},n={"@types/node":"^14.14.6","@types/react":"^17.0.2","@types/react-dom":"^17.0.2","@typescript-eslint/eslint-plugin":"^2.10.0","@typescript-eslint/parser":"^2.10.0",eslint:"^6.6.0","eslint-config-react-app":"^5.2.1","eslint-loader":"3.0.3","eslint-plugin-flowtype":"4.6.0","eslint-plugin-import":"2.20.1","eslint-plugin-jsx-a11y":"6.2.3","eslint-plugin-react":"7.19.0","eslint-plugin-react-hooks":"^1.6.1",sass:"^1.43.4",typescript:"^4.5.2"},t={"@types/react":"17.0.2","@types/react-dom":"17.0.2"},s={upgradeDependencies:"yarn upgrade @ikas/storefront @ikas/storefront-utils",dev:"next dev -p 3333",build:"next build",start:"next start",generate:"ikas --generate","prettier:all":"npx prettier@^2.1 './**/src/**/*.(ts|tsx|css|scss)' --write"},i='{\n "compilerOptions": {\n "target": "esnext",\n "lib": [\n "dom",\n "dom.iterable",\n "esnext"\n ],\n "allowJs": true,\n "skipLibCheck": true,\n "strict": true,\n "forceConsistentCasingInFileNames": true,\n "experimentalDecorators": true,\n "noEmit": true,\n "esModuleInterop": true,\n "module": "esnext",\n "moduleResolution": "node",\n "resolveJsonModule": true,\n "isolatedModules": true,\n "jsx": "preserve",\n "baseUrl": ".",\n "useUnknownInCatchVariables": false,\n "incremental": true\n },\n "typeRoots": [\n "./node_modules/@types"\n ],\n "include": [\n "next-env.d.ts",\n "**/*.ts",\n "**/*.tsx",\n "**/typings/global.d.ts",\n ],\n "exclude": [\n "node_modules",\n "./src/pages/api",\n ]\n}',a='const withTM = require("next-transpile-modules")(["@ikas/storefront"]);\n\nconst config = {\n i18n: {\n defaultLocale: "en",\n locales: ["en"],\n localeDetection: false,\n },\n basePath: process.env.NEXTJS_BASE_PATH || "",\n\n images: {\n deviceSizes: [\n 180,\n 360,\n 540,\n 720,\n 900,\n 1080,\n 1296,\n 1512,\n 1728,\n 1950,\n 2560,\n 3840,\n ],\n },\n\n webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {\n if (!isServer) {\n config.resolve.fallback.fs = false;\n }\n return config;\n },\n};\n\nmodule.exports = withTM(config);',r="NEXT_PUBLIC_ENV=local\nNEXT_PUBLIC_BASE_URL=https://api.myikas.dev/api/sf\nNEXT_PUBLIC_IMG_BASE_URL=https://cdn.myikas.dev/\nNEXT_PUBLIC_UPLOAD_GQL_URL=https://api.myikas.dev/api/admin/graphql\nNEXT_PUBLIC_GQL_URL=https://api.myikas.dev/api/sf/graphql\n",l="NEXT_PUBLIC_ENV=local\nNEXT_PUBLIC_BASE_URL=https://api.myikas.com/api/sf\nNEXT_PUBLIC_IMG_BASE_URL=https://cdn.myikas.com/\nNEXT_PUBLIC_UPLOAD_GQL_URL=https://api.myikas.com/api/admin/graphql\nNEXT_PUBLIC_GQL_URL=https://api.myikas.com/api/sf/graphql\n";export{e as DEPENDENCIES,n as DEV_DEPENDENCIES,r as DEV_ENV,a as NEXT_CONFIG,l as PROD_ENV,t as RESOLUTIONS,s as SCRIPTS,i as TS_CONFIG};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as n,__assign as t}from'../../../ext/tslib/tslib.es6.js';import r from"path";import s from"fs";import{sortObject as o}from"../../../utils/helper.js";import"../../../storefront/index.js";import"../../../utils/i18n.js";import{createFile as i}from"../../../utils/fs.js";import{TS_CONFIG as c,NEXT_CONFIG as a,SCRIPTS as u,
|
|
1
|
+
import{__awaiter as e,__generator as n,__assign as t}from'../../../ext/tslib/tslib.es6.js';import r from"path";import s from"fs";import{sortObject as o}from"../../../utils/helper.js";import"../../../storefront/index.js";import"../../../utils/i18n.js";import{createFile as i}from"../../../utils/fs.js";import{TS_CONFIG as c,NEXT_CONFIG as a,SCRIPTS as u,RESOLUTIONS as f,DEV_ENV as p,PROD_ENV as l,DEV_DEPENDENCIES as g,DEPENDENCIES as d}from"./content.js";var v=function(){function v(){}return v.generate=function(t){return e(this,void 0,void 0,(function(){var e,r,s;return n(this,(function(n){switch(n.label){case 0:return[4,v.generateTsConfig()];case 1:return(s=n.sent())?[4,v.generateNextConfig()]:[3,3];case 2:s=n.sent(),n.label=3;case 3:return(r=s)?[4,v.generatePackageJson()]:[3,5];case 4:r=n.sent(),n.label=5;case 5:return(e=r)?[4,v.generateEnv(t)]:[3,7];case 6:e=n.sent(),n.label=7;case 7:return[2,e]}}))}))},v.generateTsConfig=function(){return i(process.cwd(),"tsconfig.json",c)},v.generateNextConfig=function(){return i(process.cwd(),"next.config.js",a)},v.generatePackageJson=function(){return e(this,void 0,void 0,(function(){var e,c,a,p,l;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),e=r.join(process.cwd(),"package.json"),(c=s.readFileSync(e)).length?(a=JSON.parse(c.toString()),(p=function(e){var n="dev"===e?g:d,r="dev"===e?"devDependencies":"dependencies";a[r]&&"object"==typeof a[r]?a[r]=t(t({},a[r]),n):a[r]=n;var s=o(a[r]);a[r]=s})("dev"),p("normal"),a.scripts&&"object"==typeof a.scripts?a.scripts=t(t({},a.scripts),u):a.scripts=u,a.resolutions=t(t({},a.resolutions),f),[4,i(e,"",JSON.stringify(a,null,2))]):[3,2];case 1:return[2,n.sent()];case 2:return[3,4];case 3:return l=n.sent(),console.error(l),[2,!1];case 4:return[2]}}))}))},v.generateEnv=function(e){var n="dev"===e?p:l;return i(process.cwd(),".env",n)},v}();export{v as ConfigGenerator};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IkasTheme } from "../../../models/theme/theme";
|
|
2
|
-
import { IkasThemeComponent
|
|
2
|
+
import { IkasThemeComponent } from "../../../models/theme/component";
|
|
3
|
+
import { IkasThemeComponentProp } from "../../../models/theme/component/prop";
|
|
3
4
|
import { IkasThemeCustomData } from "../../../models/theme/custom-data";
|
|
4
5
|
declare type File = {
|
|
5
6
|
content: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'../../../ext/tslib/tslib.es6.js';import a from"path";import{createFile as s,deleteDirContent as r}from"../../../utils/fs.js";import"../../../models/data/blog/index.js";import"../../../models/data/brand/index.js";import"../../../models/data/cart/campaign-offer/index.js";import"../../../models/data/cart/index.js";import"../../../models/data/category/index.js";import"../../../models/data/city/index.js";import"mobx";import"../../../models/data/country/index.js";import"../../../models/data/customer/address/index.js";import"../../../models/data/customer/attribute-value/index.js";import"../../../models/data/customer/index.js";import"../../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../../models/data/customer-attribute/index.js";import"../../../models/data/customer-review/index.js";import"../../../models/data/customer-review-summary/index.js";import"../../../models/data/district/index.js";import"../../../models/data/favorite-product/index.js";import"../../../models/data/html-meta-data/index.js";import"../../../models/data/image/index.js";import"../../../models/data/merchant-settings/index.js";import"../../../models/data/order/address/index.js";import"../../../models/data/order/adjustment/index.js";import"../../../models/data/order/gift-line/index.js";import"../../../models/data/order/invoice/index.js";import"../../../models/data/order/line-item/discount/index.js";import"../../../models/data/order/line-item/option/value/index.js";import"../../../models/data/order/line-item/option/index.js";import"../../../models/data/order/line-item/variant/index.js";import"../../../models/data/order/line-item/index.js";import"../../../models/data/order/package/tracking-info/index.js";import"../../../models/data/order/package/index.js";import"../../../models/data/order/payment-method/index.js";import"../../../models/data/order/refund/line-item/index.js";import"../../../models/data/order/shipping-line/index.js";import"../../../models/data/order/tax-line/index.js";import"../../../models/data/order/transaction/index.js";import"../../../models/data/order/index.js";import"../../../models/data/product/attribute-value/index.js";import"../../../models/data/product/variant/price/index.js";import"../../../models/data/product/variant/index.js";import"../../../models/data/variant-type/index.js";import"../../../models/data/product/index.js";import"../../../models/data/product-attribute/index.js";import"../../../models/data/product-filter/index.js";import"../../../models/data/product-campaign/campaign/index.js";import"../../../models/data/product-campaign/filter/index.js";import"../../../models/data/product-option-set/index.js";import"../../../models/data/raffle/index.js";import"../../../models/data/state/index.js";import"../../../models/data/variant-type/variant-value/index.js";import"../../../models/theme/theme.js";import"../../../models/theme/page/index.js";import{IkasThemeComponentPropType as o}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/customer-review-summary-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(o){return e(this,void 0,void 0,(function(){var e,d,p,c,u,l,k;return t(this,(function(t){switch(t.label){case 0:return[4,r(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,5,,6]),o.customData.forEach((function(t){n.generateAllCustomDataTypes(t,e,o)})),d=0,p=0;do{d=e.internalCustomDatas.length,e.internalCustomDatas.forEach((function(t){n.generateAllCustomDataTypes(t,e,o)})),(p=e.internalCustomDatas.length)!==d&&(e.internalCustomDatas=e.internalCustomDatas.splice(d,p))}while(d!==p);return[4,m.generate(o,e)];case 3:return t.sent(),c=a.join(process.cwd(),"src","components","__generated__"),e.imports=i(e.imports),u="import {\r\n",e.imports.forEach((function(e){u+="\t".concat(e,",\r\n")})),l=(u+='} from "@ikas/storefront"\r\n\r\n')+e.content,[4,s(c,"types.ts",l)];case 4:return[2,t.sent()];case 5:return k=t.sent(),console.log(k),[2,!1];case 6:return[2]}}))}))},n.generateAllCustomDataTypes=function(e,t,a){var s=e.type===o.ENUM,r="export ".concat(s?"enum":"type"," ").concat(n.generateTypeName(e)).concat(s?"":" = ","{ \r\n"),i="};\r\n\r\n";e.type!==o.DYNAMIC_LIST&&e.type!==o.STATIC_LIST||!e.nestedData?e.type===o.ENUM&&e.enumOptions?(t.content+=r,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+=r,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([o.DYNAMIC_LIST,o.STATIC_LIST].includes(e.type)?"[]":"").concat(e.type===o.ENUM?",":";")},n.getType=function(e,t,a){var s="";switch(e.type){case o.TEXT:case o.RICH_TEXT:case o.COLOR:s="string";break;case o.BOOLEAN:s="boolean";break;case o.IMAGE:s="IkasImage",t.imports.push(s);break;case o.IMAGE_LIST:s="IkasImage[]",t.imports.push("IkasImage");break;case o.LINK:s="IkasNavigationLink",t.imports.push(s);break;case o.LIST_OF_LINK:s="IkasNavigationLink[]",t.imports.push("IkasNavigationLink");break;case o.PRODUCT_DETAIL:s="IkasProductDetail",t.imports.push(s);break;case o.PRODUCT_LIST:s="IkasProductList",t.imports.push("IkasProductList");break;case o.PRODUCT_ATTRIBUTE:s="IkasProductAttribute",t.imports.push(s);break;case o.PRODUCT_ATTRIBUTE_LIST:s="IkasProductAttribute[]",t.imports.push("IkasProductAttribute");break;case o.BRAND:s="IkasBrand",t.imports.push(s);break;case o.BRAND_LIST:s="IkasBrandList",t.imports.push(s);break;case o.CATEGORY:s="IkasCategory",t.imports.push(s);break;case o.CATEGORY_LIST:s="IkasCategoryList",t.imports.push(s);break;case o.CUSTOM:var r=a.customData.find((function(t){return t.id===e.customDataId}));r&&(s=n.generateTypeName(r));break;case o.COMPONENT:s="IkasComponentRenderer",t.imports.push(s);break;case o.COMPONENT_LIST:s="IkasComponentRenderer[]",t.imports.push("IkasComponentRenderer");break;case o.BLOG:s="IkasBlog",t.imports.push(s);break;case o.BLOG_LIST:s="IkasBlogList",t.imports.push(s);break;case o.BLOG_CATEGORY:s="IkasBlogCategory",t.imports.push(s);break;case o.BLOG_CATEGORY_LIST:s="IkasBlogCategoryList",t.imports.push(s);break;case o.RAFFLE:s="IkasRaffle",t.imports.push(s);break;case o.RAFFLE_LIST:s="IkasRaffleList",t.imports.push(s);break;case o.SLIDER:s="IkasSlider",t.imports.push(s);break;case o.ENUM:s=n.generateTypeName(e),t.content.includes("export enum ".concat(s))||t.internalCustomDatas.push(e);break;case o.OBJECT:s=n.generateTypeName(e);break;case o.DYNAMIC_LIST:case o.STATIC_LIST:e.nestedData&&(e.nestedData[0].type===o.OBJECT||e.nestedData[0].type===o.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===o.ENUM&&(t+="Enum"),t},n}(),m=function(){function a(){}return a.generate=function(s,r){return e(this,void 0,void 0,(function(){return t(this,(function(e){return s.components.forEach((function(e){e.props.length>0&&"checkout"!==e.id&&(r.content+="export type ".concat(a.generatePropTypeName(e),"Props = {\n"),e.props.forEach((function(e){r.content+="\t".concat(e.name,": ").concat(a.getType(e,s,r),";\n")})),r.content+="};\r\n\r\n")})),[2]}))}))},a.getType=function(e,t,a){var s="";switch(e.type){case o.TEXT:case o.RICH_TEXT:case o.COLOR:s="string";break;case o.BOOLEAN:s="boolean";break;case o.IMAGE:s="IkasImage",a.imports.push(s);break;case o.IMAGE_LIST:s="IkasImage[]",a.imports.push("IkasImage");break;case o.LINK:s="IkasNavigationLink",a.imports.push(s);break;case o.LIST_OF_LINK:s="IkasNavigationLink[]",a.imports.push("IkasNavigationLink");break;case o.PRODUCT_DETAIL:s="IkasProductDetail",a.imports.push(s);break;case o.PRODUCT_LIST:s="IkasProductList",a.imports.push("IkasProductList");break;case o.PRODUCT_ATTRIBUTE:s="IkasProductAttribute",a.imports.push(s);break;case o.PRODUCT_ATTRIBUTE_LIST:s="IkasProductAttribute[]",a.imports.push("IkasProductAttribute");break;case o.BRAND:s="IkasBrand",a.imports.push(s);break;case o.BRAND_LIST:s="IkasBrandList",a.imports.push(s);break;case o.CATEGORY:s="IkasCategory",a.imports.push(s);break;case o.CATEGORY_LIST:s="IkasCategoryList",a.imports.push(s);break;case o.CUSTOM:var r=t.customData.find((function(t){return t.id===e.customDataId}));r&&(s=n.getType(r,a,t),r.type!==o.DYNAMIC_LIST&&r.type!==o.STATIC_LIST||(s+="[]"));break;case o.COMPONENT:s="IkasComponentRenderer",a.imports.push(s);break;case o.COMPONENT_LIST:s="IkasComponentRenderer[]",a.imports.push("IkasComponentRenderer");break;case o.BLOG:s="IkasBlog",a.imports.push(s);break;case o.BLOG_LIST:s="IkasBlogList",a.imports.push(s);break;case o.BLOG_CATEGORY:s="IkasBlogCategory",a.imports.push(s);break;case o.BLOG_CATEGORY_LIST:s="IkasBlogCategoryList",a.imports.push(s);break;case o.RAFFLE:s="IkasRaffle",a.imports.push(s);break;case o.RAFFLE_LIST:s="IkasRaffleList",a.imports.push(s);break;case o.SLIDER:s="IkasSlider",a.imports.push(s)}return s},a.generatePropTypeName=function(e){if(""!==e.displayName){var t=(e.dir||"").split("-"),a="";return t.forEach((function(e,t){return a+=e.charAt(0).toUpperCase()+e.slice(1)})),a[0].match(/^\d/)&&(a="_"+a),a}},a}();export{n as CustomDataTypesGenerator,m as PropTypeGenarator};
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../../../ext/tslib/tslib.es6.js';import a from"path";import{createFile as s,deleteDirContent as r}from"../../../utils/fs.js";import{IkasThemeComponentPropType as n}from"../../../models/theme/component/prop/index.js";import o from'../../../ext/lodash/uniq.js';var c=function(){function c(){}return c.generate=function(n){return e(this,void 0,void 0,(function(){var e,i,u,m,I,k,T;return t(this,(function(t){switch(t.label){case 0:return[4,r(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,5,,6]),n.customData.forEach((function(t){c.generateAllCustomDataTypes(t,e,n)})),i=0,u=0;do{i=e.internalCustomDatas.length,e.internalCustomDatas.forEach((function(t){c.generateAllCustomDataTypes(t,e,n)})),(u=e.internalCustomDatas.length)!==i&&(e.internalCustomDatas=e.internalCustomDatas.splice(i,u))}while(i!==u);return[4,p.generate(n,e)];case 3:return t.sent(),m=a.join(process.cwd(),"src","components","__generated__"),e.imports=o(e.imports),I="import {\r\n",e.imports.forEach((function(e){I+="\t".concat(e,",\r\n")})),k=(I+='} from "@ikas/storefront"\r\n\r\n')+e.content,[4,s(m,"types.ts",k)];case 4:return[2,t.sent()];case 5:return T=t.sent(),console.log(T),[2,!1];case 6:return[2]}}))}))},c.generateAllCustomDataTypes=function(e,t,a){var s=e.type===n.ENUM,r="export ".concat(s?"enum":"type"," ").concat(c.generateTypeName(e)).concat(s?"":" = ","{ \r\n"),o="};\r\n\r\n";e.type!==n.DYNAMIC_LIST&&e.type!==n.STATIC_LIST||!e.nestedData?e.type===n.ENUM&&e.enumOptions?(t.content+=r,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+=o):(t.content+=r,e.nestedData&&e.nestedData.forEach((function(e){c.genenateCustomDataType(e,t,a),t.content+="\r\n"})),t.content+=o):c.generateAllCustomDataTypes(e.nestedData[0],t,a)},c.genenateCustomDataType=function(e,t,a){var s=c.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([n.DYNAMIC_LIST,n.STATIC_LIST].includes(e.type)?"[]":"").concat(e.type===n.ENUM?",":";")},c.getType=function(e,t,a){var s="";switch(e.type){case n.TEXT:case n.RICH_TEXT:case n.COLOR:s="string";break;case n.BOOLEAN:s="boolean";break;case n.IMAGE:s="IkasImage",t.imports.push(s);break;case n.IMAGE_LIST:s="IkasImage[]",t.imports.push("IkasImage");break;case n.LINK:s="IkasNavigationLink",t.imports.push(s);break;case n.LIST_OF_LINK:s="IkasNavigationLink[]",t.imports.push("IkasNavigationLink");break;case n.PRODUCT_DETAIL:s="IkasProductDetail",t.imports.push(s);break;case n.PRODUCT_LIST:s="IkasProductList",t.imports.push("IkasProductList");break;case n.PRODUCT_ATTRIBUTE:s="IkasProductAttribute",t.imports.push(s);break;case n.PRODUCT_ATTRIBUTE_LIST:s="IkasProductAttribute[]",t.imports.push("IkasProductAttribute");break;case n.BRAND:s="IkasBrand",t.imports.push(s);break;case n.BRAND_LIST:s="IkasBrandList",t.imports.push(s);break;case n.CATEGORY:s="IkasCategory",t.imports.push(s);break;case n.CATEGORY_LIST:s="IkasCategoryList",t.imports.push(s);break;case n.CUSTOM:var r=a.customData.find((function(t){return t.id===e.customDataId}));r&&(s=c.generateTypeName(r));break;case n.COMPONENT:s="IkasComponentRenderer",t.imports.push(s);break;case n.COMPONENT_LIST:s="IkasComponentRenderer[]",t.imports.push("IkasComponentRenderer");break;case n.BLOG:s="IkasBlog",t.imports.push(s);break;case n.BLOG_LIST:s="IkasBlogList",t.imports.push(s);break;case n.BLOG_CATEGORY:s="IkasBlogCategory",t.imports.push(s);break;case n.BLOG_CATEGORY_LIST:s="IkasBlogCategoryList",t.imports.push(s);break;case n.RAFFLE:s="IkasRaffle",t.imports.push(s);break;case n.RAFFLE_LIST:s="IkasRaffleList",t.imports.push(s);break;case n.SLIDER:s="IkasSlider",t.imports.push(s);break;case n.ENUM:s=c.generateTypeName(e),t.content.includes("export enum ".concat(s))||t.internalCustomDatas.push(e);break;case n.OBJECT:s=c.generateTypeName(e);break;case n.DYNAMIC_LIST:case n.STATIC_LIST:e.nestedData&&(e.nestedData[0].type===n.OBJECT||e.nestedData[0].type===n.ENUM?(s=c.generateTypeName(e.nestedData[0]),t.content.includes("export type ".concat(s))||t.internalCustomDatas.push(e.nestedData[0])):s=c.getType(e.nestedData[0],t,a))}return s},c.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===n.ENUM&&(t+="Enum"),t},c}(),p=function(){function a(){}return a.generate=function(s,r){return e(this,void 0,void 0,(function(){return t(this,(function(e){return s.components.forEach((function(e){e.props.length>0&&"checkout"!==e.id&&(r.content+="export type ".concat(a.generatePropTypeName(e),"Props = {\n"),e.props.forEach((function(e){r.content+="\t".concat(e.name,": ").concat(a.getType(e,s,r),";\n")})),r.content+="};\r\n\r\n")})),[2]}))}))},a.getType=function(e,t,a){var s="";switch(e.type){case n.TEXT:case n.RICH_TEXT:case n.COLOR:s="string";break;case n.BOOLEAN:s="boolean";break;case n.IMAGE:s="IkasImage",a.imports.push(s);break;case n.IMAGE_LIST:s="IkasImage[]",a.imports.push("IkasImage");break;case n.LINK:s="IkasNavigationLink",a.imports.push(s);break;case n.LIST_OF_LINK:s="IkasNavigationLink[]",a.imports.push("IkasNavigationLink");break;case n.PRODUCT_DETAIL:s="IkasProductDetail",a.imports.push(s);break;case n.PRODUCT_LIST:s="IkasProductList",a.imports.push("IkasProductList");break;case n.PRODUCT_ATTRIBUTE:s="IkasProductAttribute",a.imports.push(s);break;case n.PRODUCT_ATTRIBUTE_LIST:s="IkasProductAttribute[]",a.imports.push("IkasProductAttribute");break;case n.BRAND:s="IkasBrand",a.imports.push(s);break;case n.BRAND_LIST:s="IkasBrandList",a.imports.push(s);break;case n.CATEGORY:s="IkasCategory",a.imports.push(s);break;case n.CATEGORY_LIST:s="IkasCategoryList",a.imports.push(s);break;case n.CUSTOM:var r=t.customData.find((function(t){return t.id===e.customDataId}));r&&(s=c.getType(r,a,t),r.type!==n.DYNAMIC_LIST&&r.type!==n.STATIC_LIST||(s+="[]"));break;case n.COMPONENT:s="IkasComponentRenderer",a.imports.push(s);break;case n.COMPONENT_LIST:s="IkasComponentRenderer[]",a.imports.push("IkasComponentRenderer");break;case n.BLOG:s="IkasBlog",a.imports.push(s);break;case n.BLOG_LIST:s="IkasBlogList",a.imports.push(s);break;case n.BLOG_CATEGORY:s="IkasBlogCategory",a.imports.push(s);break;case n.BLOG_CATEGORY_LIST:s="IkasBlogCategoryList",a.imports.push(s);break;case n.RAFFLE:s="IkasRaffle",a.imports.push(s);break;case n.RAFFLE_LIST:s="IkasRaffleList",a.imports.push(s);break;case n.SLIDER:s="IkasSlider",a.imports.push(s)}return s},a.generatePropTypeName=function(e){if(""!==e.displayName){var t=(e.dir||"").split("-"),a="";return t.forEach((function(e,t){return a+=e.charAt(0).toUpperCase()+e.slice(1)})),a[0].match(/^\d/)&&(a="_"+a),a}},a}();export{c as CustomDataTypesGenerator,p as PropTypeGenarator};
|
package/build/store/base.d.ts
CHANGED
package/build/store/base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as o,__generator as t}from'../ext/tslib/tslib.es6.js';import{configure as e,makeObservable as i,observable as r}from"mobx";import d from'../ext/lodash/sortBy.js';import s from'../ext/lodash/flatten.js';import{IkasCartStore as n}from"./cart/index.js";import{IkasCustomerStore as a}from"./customer/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute-value/index.js";import"../models/data/customer/index.js";import"../models/data/customer-attribute/customer-attribute-option/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-review/index.js";import"../models/data/customer-review-summary/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/address/index.js";import"../models/data/order/adjustment/index.js";import"../models/data/order/gift-line/index.js";import"../models/data/order/invoice/index.js";import"../models/data/order/line-item/discount/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/option/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/tracking-info/index.js";import"../models/data/order/package/index.js";import"../models/data/order/payment-method/index.js";import"../models/data/order/refund/line-item/index.js";import"../models/data/order/shipping-line/index.js";import"../models/data/order/tax-line/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product-filter/index.js";import"../models/data/product-campaign/campaign/index.js";import"../models/data/product-campaign/filter/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../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/customer-review-summary-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{IkasThemeSettings as m}from"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import{IkasStorefrontConfig as l}from"../storefront/index.js";import u from"./location/index.js";import p from'../ext/uuid/dist/esm-
|
|
1
|
+
import{__awaiter as o,__generator as t}from'../ext/tslib/tslib.es6.js';import{configure as e,makeObservable as i,observable as r}from"mobx";import d from'../ext/lodash/sortBy.js';import s from'../ext/lodash/flatten.js';import{IkasCartStore as n}from"./cart/index.js";import{IkasCustomerStore as a}from"./customer/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute-value/index.js";import"../models/data/customer/index.js";import"../models/data/customer-attribute/customer-attribute-option/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-review/index.js";import"../models/data/customer-review-summary/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/address/index.js";import"../models/data/order/adjustment/index.js";import"../models/data/order/gift-line/index.js";import"../models/data/order/invoice/index.js";import"../models/data/order/line-item/discount/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/option/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/tracking-info/index.js";import"../models/data/order/package/index.js";import"../models/data/order/payment-method/index.js";import"../models/data/order/refund/line-item/index.js";import"../models/data/order/shipping-line/index.js";import"../models/data/order/tax-line/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product-filter/index.js";import"../models/data/product-campaign/campaign/index.js";import"../models/data/product-campaign/filter/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../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/customer-review-summary-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{IkasThemeSettings as m}from"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import{IkasStorefrontConfig as l}from"../storefront/index.js";import u from"./location/index.js";import p from'../ext/uuid/dist/esm-node/v4.js';e({enforceActions:"never"});var c=function(){function e(){this.currentPageType=null,this.localeOptions=[],this.showLocaleOptions=!1,this.currentCountryCode=null,this.localeChecked=!1,this.settingsSet=!1,this.customerStore=new a(this),this.cartStore=new n(this),i(this,{currentPageType:r,localeOptions:r,showLocaleOptions:r,currentCountryCode:r})}return e.prototype.checkLocalization=function(){return o(this,void 0,void 0,(function(){var o,e,i,r,n,a,m,c,j,x;return t(this,(function(t){switch(t.label){case 0:return this.localeChecked?[2]:void 0===typeof window?(console.warn("checkLocalization should be called on the client side!"),[2]):[4,u.getMyCountry()];case 1:return(o=t.sent()).isSuccess?(e=o.data,i=l.routings.find((function(o){return o.id===l.storefrontRoutingId})),this.currentCountryCode=e,i&&e?(r=!0,n=l.routings.find((function(o){var t;return null===(t=o.countryCodes)||void 0===t?void 0:t.includes(e)})),a=l.routings.find((function(o){var t;return!(null===(t=o.countryCodes)||void 0===t?void 0:t.length)})),n?i.id!==n.id&&(r=!1):a&&i.id!==a.id&&(r=!1),m=[],c=s(l.routings.map((function(o){return o.countryCodes||[]}))),[4,u.listCountry({iso2:{in:c}})]):[3,3]):[2];case 2:if(!(j=t.sent()).isSuccess)return[2];x=j.data||[],l.routings.map((function(o){var t;(null===(t=o.countryCodes)||void 0===t?void 0:t.length)?o.countryCodes.forEach((function(t){var i=x.find((function(o){return o.iso2===t}));m.push({id:p(),countryName:(null==i?void 0:i.native)||(null==i?void 0:i.name)||"",iso2:(null==i?void 0:i.iso2)||void 0,iso3:(null==i?void 0:i.iso3)||void 0,routing:o,isRecommended:t===e})})):m.push({id:p(),routing:o,isRecommended:!l.routings.some((function(o){var t;return null===(t=o.countryCodes)||void 0===t?void 0:t.includes(e)}))})})),this.localeOptions=d(m,"countryName"),r||(this.showLocaleOptions=!0),this.localeChecked=!0,t.label=3;case 3:return[2]}}))}))},e.prototype.setLocalization=function(o){o.routing.domain?window.location.replace("https://"+o.routing.domain):window.location.replace(window.location.origin+(o.routing.path?"/"+o.routing.path:""))},e.prototype.setSettings=function(o){this.settingsSet||new m(JSON.parse(o)).colors.map((function(o){return document.documentElement.style.setProperty(o.key,o.color)}))},e.prototype.init=function(){this.customerStore.init()},e}();export{c as IkasBaseStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as
|
|
1
|
+
import{__awaiter as t,__generator as e}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import{Analytics as n}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as r}from"../../storefront/index.js";import a from"./api.js";var o="cartId",s=function(){function o(o){var s=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(i,o,u){return void 0===u&&(u=1),t(s,void 0,void 0,(function(){var t,s,c,d,l,h,v,f,p,m;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),o.canAddToCart?[4,this.beforeCartOperationCheck()]:[2,!1];case 1:return e.sent(),this.cart&&(t=this.findExistingItem(i,o))?(null===(f=o.productOptionSet)||void 0===f||f.initOptionValues(),[2,this.changeItemQuantity(t,t.quantity+1)]):(s=this.getOptionValues(o),c=(null===(p=this.cart)||void 0===p?void 0:p.id)||localStorage.getItem("cartId"),[4,a.addItemToCart({input:{cartId:c,item:{id:null,quantity:u,variant:{id:i.id,name:o.name}},options:s.length?s:null,priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId}})]);case 2:return(d=e.sent()).isSuccess&&d.data?[4,this.setCart(d.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(l="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(h=this.cart.orderLineItems.find((function(t){return t.variant.id})))&&n.addToCart(h,u,l,this.cart)),null===(m=o.productOptionSet)||void 0===m||m.initOptionValues(),[2,!0];case 5:return v=e.sent(),console.log(v),[2,!1];case 6:return[2]}}))}))},this.changeItemQuantity=function(i,o){return t(s,void 0,void 0,(function(){var t,s,u,c,d;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),[4,a.addItemToCart({input:{cartId:(null===(d=this.cart)||void 0===d?void 0:d.id)||null,item:{id:i.id,quantity:o,variant:{id:i.variant.id,name:i.variant.name}},options:this.createCartLineOptions(i),priceListId:r.priceListId||null,salesChannelId:r.salesChannelId,storefrontThemeId:r.storefrontThemeId}})];case 2:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.removeCardIfEmpty(),this.cart&&(s="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(u=i.quantity)>o?n.removeFromCart(i,u-o,this.cart):n.addToCart(i,o-u,s,this.cart)),[2,!0];case 5:return c=e.sent(),console.log(c),[2,!1];case 6:return[2]}}))}))},this.removeItem=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return t.sent(),[2]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),s.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){s.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.findExistingItem=function(t,e){var i,n,r,a,o;if(!e.productOptionSetId)return null===(i=s.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));for(var u=s.getOptionValues(e),c=(null===(n=s.cart)||void 0===n?void 0:n.orderLineItems.filter((function(e){var i;return e.variant.id===t.id&&(null===(i=e.options)||void 0===i?void 0:i.length)===u.length})))||[],d=0,l=c;d<l.length;d++){var h=l[d];if(h.options){for(var v=!0,f=function(t){var i=t.values.map((function(t){return t.value})),n=null===(o=null===(a=null===(r=e.productOptionSet)||void 0===r?void 0:r.options)||void 0===a?void 0:a.find((function(e){return e.id===t.productOptionId})))||void 0===o?void 0:o.values;if(!(v=v&&i.length===(null==n?void 0:n.length)&&i.every((function(t){return null==n?void 0:n.includes(t)}))))return"break"},p=0,m=h.options;p<m.length;p++){if("break"===f(m[p]))break}if(v)return h}}},this.saveCouponCode=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,a.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,!1];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,t.isSuccess]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=s.cart)||void 0===t?void 0:t.itemCount)&&s.removeCart()},this.getCart=function(){return t(s,void 0,void 0,(function(){var t,i,n,r,o,s;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(o=this.baseStore.customerStore.customer)||void 0===o?void 0:o.id,(i=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,a.getCartById({id:i})]:[2];case 2:return(n=e.sent()).isSuccess&&n.data?[4,this.setCart(n.data)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return r=e.sent(),console.log(r),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){return localStorage.setItem("cartId",i.id),this.cart=i,[2]}))}))},this.beforeCartOperationCheck=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,n=t.options;i<n.length;i++){var r=n[i],a={productOptionId:r.productOptionId,productOptionsSetId:r.productOptionsSetId,values:r.values.map((function(t){return t.value}))};e.push(a)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),i},this.baseStore=o,i(this)}return Object.defineProperty(o.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout?id=".concat(this.checkoutId,"&step=info")},enumerable:!1,configurable:!0}),o}();export{o as CART_LS_KEY,s as IkasCartStore};
|
|
@@ -4,14 +4,17 @@ import { QueryParams as RetrieveInstallmentInfoQueryParams } from "src/__api/mut
|
|
|
4
4
|
import { QueryParams as CheckStocksQueryParams } from "src/__api/queries/checkStocks";
|
|
5
5
|
import { QueryParams as ListCheckoutSettingsQueryParams } from "src/__api/queries/listCheckoutSettings";
|
|
6
6
|
import { QueryParams as GetAvailableShippingCountriesQueryParams } from "src/__api/queries/getAvailableShippingCountries";
|
|
7
|
+
import { QueryParams as ListStockLocationQueryParams } from "src/__api/queries/listStockLocation";
|
|
7
8
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
8
9
|
import { IkasCheckoutSettings } from "src/models/data/checkout-settings";
|
|
9
10
|
import { IkasPaymentGateway } from "src/models/data/payment-gateway";
|
|
11
|
+
import { StockLocation } from "../../__api/models/StockLocation";
|
|
10
12
|
export default class CheckoutStore {
|
|
11
|
-
static createSaleTransactionWithCart(params: CreateSaleTransaction): Promise<APIResponse<import("../../__api/types").TransactionResponse
|
|
13
|
+
static createSaleTransactionWithCart(params: CreateSaleTransaction): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").TransactionResponse>>;
|
|
12
14
|
static listPaymentGateway(params: ListPaymentGatewayQueryParams): Promise<APIResponse<IkasPaymentGateway[]>>;
|
|
13
15
|
static retrieveInstallmentInfo(params: RetrieveInstallmentInfoQueryParams): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").RetrieveInstallmentInfoResponse>>;
|
|
14
16
|
static checkStocks(params: CheckStocksQueryParams): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").CheckStocksResponse>>;
|
|
15
17
|
static listCheckoutSettings(params: ListCheckoutSettingsQueryParams): Promise<APIResponse<IkasCheckoutSettings[]>>;
|
|
16
18
|
static getAvailableShippingCountries(params: GetAvailableShippingCountriesQueryParams): Promise<APIResponse<undefined> | APIResponse<string[]>>;
|
|
19
|
+
static listStockLocation(params: ListStockLocationQueryParams): Promise<APIResponse<StockLocation[]>>;
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as
|
|
1
|
+
import{__awaiter as t,__generator as i}from'../../ext/tslib/tslib.es6.js';import e from"../../__api/mutations/createSaleTransactionWithCart.js";import n from"../../__api/queries/listPaymentGateway.js";import r from"../../__api/mutations/retrieveInstallmentInfo.js";import o from"../../__api/queries/checkStocks.js";import s from"../../__api/queries/listCheckoutSettings.js";import a from"../../__api/queries/getAvailableShippingCountries.js";import u from"../../__api/queries/listStockLocation.js";import{APIResponse as c}from'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import{IkasCheckoutSettings as l}from"../../models/data/checkout-settings/index.js";import{IkasPaymentGateway as d}from"../../models/data/payment-gateway/index.js";import{StockLocation as m}from"../../__api/models/StockLocation.js";var f=function(){function f(){}return f.createSaleTransactionWithCart=function(n){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,e(n)];case 1:return[2,t.sent()]}}))}))},f.listPaymentGateway=function(e){var r;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,n(e)];case 1:return t=i.sent(),[2,new c(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new d(t)})),t.graphQLErrors)]}}))}))},f.retrieveInstallmentInfo=function(e){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,r(e)];case 1:return[2,t.sent()]}}))}))},f.checkStocks=function(e){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,o(e)];case 1:return[2,t.sent()]}}))}))},f.listCheckoutSettings=function(e){var n;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,s(e)];case 1:return t=i.sent(),[2,new c(null===(n=t.data)||void 0===n?void 0:n.map((function(t){return new l(t)})),t.graphQLErrors)]}}))}))},f.getAvailableShippingCountries=function(e){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,a(e)];case 1:return[2,t.sent()]}}))}))},f.listStockLocation=function(e){var n;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,u(e)];case 1:return t=i.sent(),[2,new c(null===(n=t.data)||void 0===n?void 0:n.map((function(t){return new m(t)})),t.graphQLErrors)]}}))}))},f}();export{f as default};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
2
|
-
import { IkasCustomer, IkasCustomerAttribute, IkasCustomerReview, IkasCustomerReviewSummary, IkasFavoriteProduct, IkasOrder, IkasOrderRefundSettings, IkasOrderTransaction } from "src";
|
|
3
2
|
import { QueryParams as CustomerLoginQueryParams } from "src/__api/mutations/customerLogin";
|
|
4
3
|
import { QueryParams as CustomerSocialLoginQueryParams } from "src/__api/queries/customerSocialLogin";
|
|
5
4
|
import { QueryParams as RegisterCustomerQueryParams } from "src/__api/mutations/registerCustomer";
|
|
@@ -22,6 +21,14 @@ import { QueryParams as IsFavoriteProductQueryParams } from "src/__api/queries/i
|
|
|
22
21
|
import { QueryParams as CreateCustomerReviewQueryParams } from "src/__api/mutations/createCustomerReview";
|
|
23
22
|
import { QueryParams as ListCustomerReviewsQueryParams } from "src/__api/queries/listCustomerReviews";
|
|
24
23
|
import { QueryParams as ListCustomerReviewSummaryQueryParams } from "src/__api/queries/listCustomerReviewSummary";
|
|
24
|
+
import { IkasCustomer } from "src/models/data/customer";
|
|
25
|
+
import { IkasOrder } from "src/models/data/order";
|
|
26
|
+
import { IkasOrderTransaction } from "src/models/data/order/transaction";
|
|
27
|
+
import { IkasOrderRefundSettings } from "src/models/data/order/refund/settings";
|
|
28
|
+
import { IkasFavoriteProduct } from "src/models/data/favorite-product";
|
|
29
|
+
import { IkasCustomerReview } from "src/models/data/customer-review";
|
|
30
|
+
import { IkasCustomerReviewSummary } from "src/models/data/customer-review-summary";
|
|
31
|
+
import { IkasCustomerAttribute } from "src/models/data/customer-attribute";
|
|
25
32
|
export default class CustomerStoreAPI {
|
|
26
33
|
static login(params: CustomerLoginQueryParams): Promise<APIResponse<{
|
|
27
34
|
customer: IkasCustomer | null;
|
|
@@ -39,8 +46,8 @@ export default class CustomerStoreAPI {
|
|
|
39
46
|
tokenExpiry: number;
|
|
40
47
|
} | null>>;
|
|
41
48
|
static refreshToken(params: CustomerRefreshTokenQueryParams): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").CustomerRefreshTokenResponse>>;
|
|
42
|
-
static forgotPassword(params: CustomerForgotPasswordQueryParams): Promise<APIResponse<
|
|
43
|
-
static recoverPassword(params: CustomerRecoverPasswordQueryParams): Promise<APIResponse<
|
|
49
|
+
static forgotPassword(params: CustomerForgotPasswordQueryParams): Promise<APIResponse<boolean> | APIResponse<undefined>>;
|
|
50
|
+
static recoverPassword(params: CustomerRecoverPasswordQueryParams): Promise<APIResponse<boolean> | APIResponse<undefined>>;
|
|
44
51
|
static checkEmail(params: CheckCustomerEmailQueryParams): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").CustomerCheckResponse>>;
|
|
45
52
|
static getCustomer(): Promise<APIResponse<IkasCustomer | null>>;
|
|
46
53
|
static saveCustomer(params: SaveMyCustomerQueryParams): Promise<APIResponse<IkasCustomer | null>>;
|
|
@@ -52,10 +59,10 @@ export default class CustomerStoreAPI {
|
|
|
52
59
|
static getLastViewedProducts(params: GetLastViewedProductsQueryParams): Promise<APIResponse<import("../../__api/types").ProductItem[]>>;
|
|
53
60
|
static saveLastViewedProducts(params: SaveLastViewedProductsQueryParams): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").ProductLastViewed>>;
|
|
54
61
|
static listOrderRefundSettings(params: ListOrderRefundSettingsQueryParams): Promise<APIResponse<IkasOrderRefundSettings[]>>;
|
|
55
|
-
static sendContactFormToMerchant(params: SendContactFormToMerchantQueryParams): Promise<APIResponse<
|
|
62
|
+
static sendContactFormToMerchant(params: SendContactFormToMerchantQueryParams): Promise<APIResponse<boolean> | APIResponse<undefined>>;
|
|
56
63
|
static listFavoriteProducts(): Promise<APIResponse<IkasFavoriteProduct[]>>;
|
|
57
|
-
static saveFavoriteProduct(params: SaveFavoriteProductQueryParams): Promise<APIResponse<
|
|
58
|
-
static isFavoriteProduct(params: IsFavoriteProductQueryParams): Promise<APIResponse<
|
|
64
|
+
static saveFavoriteProduct(params: SaveFavoriteProductQueryParams): Promise<APIResponse<boolean> | APIResponse<undefined>>;
|
|
65
|
+
static isFavoriteProduct(params: IsFavoriteProductQueryParams): Promise<APIResponse<boolean> | APIResponse<undefined>>;
|
|
59
66
|
static createCustomerReview(params: CreateCustomerReviewQueryParams): Promise<APIResponse<IkasCustomerReview | null>>;
|
|
60
67
|
static listCustomerReviews(params: ListCustomerReviewsQueryParams): Promise<APIResponse<{
|
|
61
68
|
data: IkasCustomerReview[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as r,__assign as e}from'../../ext/tslib/tslib.es6.js';import{APIResponse as n}from'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import i from"../../__api/mutations/customerLogin.js";import o from"../../__api/queries/customerSocialLogin.js";import s from"../../__api/mutations/registerCustomer.js";import a from"../../__api/mutations/customerRefreshToken.js";import u from"../../__api/mutations/customerForgotPassword.js";import c from"../../__api/mutations/customerRecoverPassword.js";import d from"../../__api/queries/checkCustomerEmail.js";import m from"../../__api/queries/getMyCustomer.js";import l from"../../__api/mutations/saveMyCustomer.js";import f from"../../__api/queries/getCustomerOrders.js";import v from"../../__api/queries/getOrderByEmail.js";import p from"../../__api/queries/listOrderTransactions.js";import h from"../../__api/mutations/createOrderRefundRequest.js";import w from"../../__api/mutations/createCustomerEmailSubscription.js";import _ from"../../__api/queries/getLastViewedProducts.js";import b from"../../__api/mutations/saveLastViewedProducts.js";import j from"../../__api/queries/listOrderRefundSettings.js";import g from"../../__api/mutations/sendContactFormToMerchant.js";import L from"../../__api/queries/listFavoriteProducts.js";import E from"../../__api/mutations/saveFavoriteProduct.js";import C from"../../__api/queries/isFavoriteProduct.js";import P from"../../__api/mutations/createCustomerReview.js";import Q from"../../__api/queries/listCustomerReviews.js";import q from"../../__api/queries/listCustomerReviewSummary.js";import x from"../../__api/queries/listCustomerAttribute.js";import{IkasCustomer as R}from"../../models/data/customer/index.js";import{
|
|
1
|
+
import{__awaiter as t,__generator as r,__assign as e}from'../../ext/tslib/tslib.es6.js';import{APIResponse as n}from'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import i from"../../__api/mutations/customerLogin.js";import o from"../../__api/queries/customerSocialLogin.js";import s from"../../__api/mutations/registerCustomer.js";import a from"../../__api/mutations/customerRefreshToken.js";import u from"../../__api/mutations/customerForgotPassword.js";import c from"../../__api/mutations/customerRecoverPassword.js";import d from"../../__api/queries/checkCustomerEmail.js";import m from"../../__api/queries/getMyCustomer.js";import l from"../../__api/mutations/saveMyCustomer.js";import f from"../../__api/queries/getCustomerOrders.js";import v from"../../__api/queries/getOrderByEmail.js";import p from"../../__api/queries/listOrderTransactions.js";import h from"../../__api/mutations/createOrderRefundRequest.js";import w from"../../__api/mutations/createCustomerEmailSubscription.js";import _ from"../../__api/queries/getLastViewedProducts.js";import b from"../../__api/mutations/saveLastViewedProducts.js";import j from"../../__api/queries/listOrderRefundSettings.js";import g from"../../__api/mutations/sendContactFormToMerchant.js";import L from"../../__api/queries/listFavoriteProducts.js";import E from"../../__api/mutations/saveFavoriteProduct.js";import C from"../../__api/queries/isFavoriteProduct.js";import P from"../../__api/mutations/createCustomerReview.js";import Q from"../../__api/queries/listCustomerReviews.js";import q from"../../__api/queries/listCustomerReviewSummary.js";import x from"../../__api/queries/listCustomerAttribute.js";import{IkasCustomer as R}from"../../models/data/customer/index.js";import{IkasOrder as O}from"../../models/data/order/index.js";import{IkasOrderTransaction as k}from"../../models/data/order/transaction/index.js";import{IkasOrderRefundSettings as F}from"../../models/data/order/refund/settings/index.js";import{IkasFavoriteProduct as T}from"../../models/data/favorite-product/index.js";import{IkasCustomerReview as y}from"../../models/data/customer-review/index.js";import{IkasCustomerReviewSummary as S}from"../../models/data/customer-review-summary/index.js";import{IkasCustomerAttribute as M}from"../../models/data/customer-attribute/index.js";var V=function(){function V(){}return V.login=function(o){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,i(o)];case 1:return t=r.sent(),[2,new n(t.data?e(e({},t.data),{customer:t.data.customer?new R(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,o(i)];case 1:return t=r.sent(),[2,new n(t.data?e(e({},t.data),{customer:t.data.customer?new R(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.register=function(i){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,s(i)];case 1:return t=r.sent(),[2,new n(t.data?e(e({},t.data),{customer:t.data.customer?new R(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.refreshToken=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,a(e)];case 1:return[2,t.sent()]}}))}))},V.forgotPassword=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,u(e)];case 1:return[2,t.sent()]}}))}))},V.recoverPassword=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,c(e)];case 1:return[2,t.sent()]}}))}))},V.checkEmail=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,d(e)];case 1:return[2,t.sent()]}}))}))},V.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,m()];case 1:return t=r.sent(),[2,new n(t.data?new R(t.data):null,t.graphQLErrors)]}}))}))},V.saveCustomer=function(e){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,l(e)];case 1:return t=r.sent(),[2,new n(t.data?new R(t.data):null,t.graphQLErrors)]}}))}))},V.getOrders=function(e){var i;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,f(e)];case 1:return t=r.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new O(t)})),t.graphQLErrors)]}}))}))},V.getOrderByEmail=function(e){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,v(e)];case 1:return t=r.sent(),[2,new n(t.data?new O(t.data):null,t.graphQLErrors)]}}))}))},V.listOrderTransactions=function(e){var i;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,p(e)];case 1:return t=r.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new k(t)})),t.graphQLErrors)]}}))}))},V.createOrderRefundRequest=function(e){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,h(e)];case 1:return t=r.sent(),[2,new n(t.data?new O(t.data):null,t.graphQLErrors)]}}))}))},V.createCustomerEmailSubscription=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,w(e)];case 1:return[2,t.sent()]}}))}))},V.getLastViewedProducts=function(e){var i;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,_(e)];case 1:return t=r.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.products,t.graphQLErrors)]}}))}))},V.saveLastViewedProducts=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,b(e)];case 1:return[2,t.sent()]}}))}))},V.listOrderRefundSettings=function(e){var i;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,j(e)];case 1:return t=r.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new F(t)})),t.graphQLErrors)]}}))}))},V.sendContactFormToMerchant=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,g(e)];case 1:return[2,t.sent()]}}))}))},V.listFavoriteProducts=function(){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,L()];case 1:return t=r.sent(),[2,new n(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new T(t)})),t.graphQLErrors)]}}))}))},V.saveFavoriteProduct=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,E(e)];case 1:return[2,t.sent()]}}))}))},V.isFavoriteProduct=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,C({productId:e.productId})];case 1:return[2,t.sent()]}}))}))},V.createCustomerReview=function(e){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,P(e)];case 1:return t=r.sent(),[2,new n(t.data?new y(t.data):null,t.graphQLErrors)]}}))}))},V.listCustomerReviews=function(i){return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,Q(i)];case 1:return t=r.sent(),[2,new n(t.data?e(e({},t.data),{data:t.data.data.map((function(t){return new y(t)}))}):null,t.graphQLErrors)]}}))}))},V.listCustomerReviewSummary=function(i){var o;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,q(i)];case 1:return t=r.sent(),[2,new n(e(e({},t.data),{data:null===(o=t.data)||void 0===o?void 0:o.data.map((function(t){return new S(t)}))}),t.graphQLErrors)]}}))}))},V.listCustomerAttribute=function(){var e;return t(this,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,x()];case 1:return t=r.sent(),[2,new n(null===(e=t.data)||void 0===e?void 0:e.map((function(t){return new M(t)}),t.graphQLErrors))]}}))}))},V}();export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import o from'../../ext/lodash/uniqBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import{IkasCustomer as s}from"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../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/customer-review-summary-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{Analytics as n}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import{populateRaffleProducts as d}from"../../providers/helpers/raffles.js";import u from"./api.js";import{SaveMyCustomerInput as c}from"../../__api/models/SaveMyCustomerInput.js";import l from"../raffle/index.js";import'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.js';import m from'../../ext/@ikas/fe-api-client/build/config/index.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import p from"../product/index.js";import{CustomerEmailSubscriptionStatusesEnum as h}from"../../__api/types/index.js";var f="undefined"==typeof localStorage,v=function(){function v(o){var s=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this.login=function(i,r){return t(s,void 0,void 0,(function(){var t,o,s,a;return e(this,(function(e){switch(e.label){case 0:return[4,u.login({email:i,password:r})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&n.customerLogin(),(s=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(s.orderLineItems[0],s.orderLineItems[0].quantity)]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:return this.saveLocalLastViewedProducts(),[2,!0];case 4:return[2,!1]}}))}))},this.register=function(i,r,o,n,a,d){return t(s,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,u.register({email:o,password:n,firstName:i,lastName:r,isAcceptMarketing:a,attributes:d})];case 1:return(t=e.sent())&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return n.contactForm(i),[4,u.sendContactFormToMerchant(i)];case 1:return[2,t.sent().isSuccess]}}))}))},this.checkEmail=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.checkEmail({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.forgotPassword=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.forgotPassword({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.recoverPassword({password:i,passwordAgain:r,token:o})];case 1:return[2,t.sent().isSuccess]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),n.customerLogout()},this.saveCustomer=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.saveCustomer({input:new c(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(s,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.getOrders({orderId:i})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?((r=t.data[0])._refundSettings=this._refundSettings,[2,r]):[2,null]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.listOrderTransactions({checkoutId:{eq:i.checkoutId},id:{eq:i.checkoutId},orderId:{eq:i.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess||!(null===(r=t.data)||void 0===r?void 0:r.length)?[2,[]]:[4,p.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:a.priceListId,salesChannelId:a.salesChannelId}})];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,u.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,u.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,u.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.createCustomerEmailSubscription({input:{email:i}})];case 1:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,h.SUBSCRIBED):this._visitorSubscribedEmail=!0),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(s,void 0,void 0,(function(){var t,o,s,n;return e(this,(function(e){switch(e.label){case 0:if(t=a.customerReviewSettings,o=a.salesChannelId,!t)return[2];if(!(s=null===(n=this.customer)||void 0===n?void 0:n.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){s.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){s.initialized&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(s,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,l.getRafflesByCustomerId({winnerFilter:!1})];case 1:return t=e.sent(),[4,l.getRafflesByCustomerId({winnerFilter:!0})];case 2:return i=e.sent(),r=t.data,o=i.data,null==r||r.forEach((function(t){(null==o?void 0:o.find((function(e){return e.id===t.id})))&&(t.isCustomerWinner=!0)})),r?[4,d(r)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2,r||[]]}}))}))},this.getCustomerAttributes=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,u.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,u.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,this.init(),r(this)}return Object.defineProperty(v.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||f||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),v.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":a.config.apiKey||"","x-sfid":a.storefrontId||"","x-sfrid":a.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),a.router?a.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},v.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.socialLogin({code:i})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(r=t.data)||void 0===r?void 0:r.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&n.customerLogin(),[2,!0]):[2,!1]}}))}))},v.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),[4,this.getOrderRefundSettings()];case 3:return t.sent(),this._initialized=!0,this.customer&&n.customerVisit(),[2]}}))}))},v.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},v.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return f||!this.token?[2]:[4,u.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},v.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,u.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},v.prototype.setCustomer=function(t){this.customer=new s(t)},v.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,u.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},v.prototype.saveLastViewedProducts=function(){f||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},v.prototype.loadLastViewedProducts=function(){if(!f)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},v.prototype.removeLastViewedProducts=function(){f||window.localStorage.removeItem("lastViewedProducts")},v.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},v.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(f)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},v.prototype.saveCustomerConsent=function(){f||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},v.prototype.loadCustomerConsent=function(){f||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},v.prototype.removeCustomerConsent=function(){f||window.localStorage.removeItem("customerConsent")},v.prototype.setToken=function(t,e){f||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.TOKEN=t)},v.prototype.loadToken=function(){if(!f){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},v.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},v.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.TOKEN=""},v}();export{v as IkasCustomerStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import o from'../../ext/lodash/uniqBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import{IkasCustomer as s}from"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../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/customer-review-summary-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{Analytics as n}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import{populateRaffleProducts as d}from"../../providers/helpers/raffles.js";import u from"./api.js";import{SaveMyCustomerInput as c}from"../../__api/models/SaveMyCustomerInput.js";import l from"../raffle/index.js";import'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.js';import m from'../../ext/@ikas/fe-api-client/build/config/index.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import p from"../product/index.js";import{CustomerEmailSubscriptionStatusesEnum as h}from"../../__api/types/index.js";var f="undefined"==typeof localStorage,v=function(){function v(o){var s=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this.login=function(i,r){return t(s,void 0,void 0,(function(){var t,o,s,a;return e(this,(function(e){switch(e.label){case 0:return[4,u.login({email:i,password:r})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&n.customerLogin(),(s=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(s.orderLineItems[0],s.orderLineItems[0].quantity)]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:return this.saveLocalLastViewedProducts(),[2,!0];case 4:return[2,!1]}}))}))},this.register=function(i,r,o,n,a,d){return t(s,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,u.register({email:o,password:n,firstName:i,lastName:r,isAcceptMarketing:a,attributes:d})];case 1:return(t=e.sent())&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return n.contactForm(i),[4,u.sendContactFormToMerchant(i)];case 1:return[2,t.sent().isSuccess]}}))}))},this.checkEmail=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.checkEmail({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.forgotPassword=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.forgotPassword({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.recoverPassword({password:i,passwordAgain:r,token:o})];case 1:return[2,t.sent().isSuccess]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),n.customerLogout()},this.saveCustomer=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.saveCustomer({input:new c(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(s,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.getOrders({orderId:i})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?((r=t.data[0])._refundSettings=this._refundSettings,[2,r]):[2,null]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.listOrderTransactions({checkoutId:{eq:i.checkoutId},id:{eq:i.checkoutId},orderId:{eq:i.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess||!(null===(r=t.data)||void 0===r?void 0:r.length)?[2,[]]:[4,p.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:a.priceListId,salesChannelId:a.salesChannelId}})];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,u.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,u.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,u.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.createCustomerEmailSubscription({input:{email:i}})];case 1:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,h.SUBSCRIBED):this._visitorSubscribedEmail=!0),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(s,void 0,void 0,(function(){var t,o,s,n;return e(this,(function(e){switch(e.label){case 0:if(t=a.customerReviewSettings,o=a.salesChannelId,!t)return[2];if(!(s=null===(n=this.customer)||void 0===n?void 0:n.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){s.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){s.initialized&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(s,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,l.getRafflesByCustomerId({winnerFilter:!1})];case 1:return t=e.sent(),[4,l.getRafflesByCustomerId({winnerFilter:!0})];case 2:return i=e.sent(),r=t.data,o=i.data,null==r||r.forEach((function(t){(null==o?void 0:o.find((function(e){return e.id===t.id})))&&(t.isCustomerWinner=!0)})),r?[4,d(r)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2,r||[]]}}))}))},this.getCustomerAttributes=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,u.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,u.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,r(this)}return Object.defineProperty(v.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||f||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),v.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":a.config.apiKey||"","x-sfid":a.storefrontId||"","x-sfrid":a.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),a.router?a.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},v.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.socialLogin({code:i})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(r=t.data)||void 0===r?void 0:r.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&n.customerLogin(),[2,!0]):[2,!1]}}))}))},v.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),[4,this.getOrderRefundSettings()];case 3:return t.sent(),this._initialized=!0,this.customer&&n.customerVisit(),[2]}}))}))},v.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},v.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return f||!this.token?[2]:[4,u.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},v.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,u.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},v.prototype.setCustomer=function(t){this.customer=new s(t)},v.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,u.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},v.prototype.saveLastViewedProducts=function(){f||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},v.prototype.loadLastViewedProducts=function(){if(!f)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},v.prototype.removeLastViewedProducts=function(){f||window.localStorage.removeItem("lastViewedProducts")},v.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},v.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(f)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},v.prototype.saveCustomerConsent=function(){f||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},v.prototype.loadCustomerConsent=function(){f||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},v.prototype.removeCustomerConsent=function(){f||window.localStorage.removeItem("customerConsent")},v.prototype.setToken=function(t,e){f||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.TOKEN=t)},v.prototype.loadToken=function(){if(!f){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},v.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},v.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.TOKEN=""},v}();export{v as IkasCustomerStore};
|
|
@@ -5,7 +5,7 @@ import { QueryParams as ListStateQueryParams } from "src/__api/queries/listState
|
|
|
5
5
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
6
6
|
import { IkasCity, IkasCountry, IkasDistrict, IkasState } from "src/models";
|
|
7
7
|
export default class LocationStore {
|
|
8
|
-
static getMyCountry(): Promise<APIResponse<
|
|
8
|
+
static getMyCountry(): Promise<APIResponse<undefined> | APIResponse<string>>;
|
|
9
9
|
static listCountry(params: ListCountryQueryParams): Promise<APIResponse<IkasCountry[]>>;
|
|
10
10
|
static listCity(params: ListCityQueryParams): Promise<APIResponse<IkasCity[]>>;
|
|
11
11
|
static listDistrict(params: ListDistrictQueryParams): Promise<APIResponse<IkasDistrict[]>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
2
|
-
import { IkasProduct, IkasProductAttribute, IkasProductFilter, IkasFilterCategory, IkasProductCampaign, IkasProductOptionSet } from "src/models";
|
|
3
2
|
import { QueryParams as ListProductBackInStockRemind } from "src/__api/queries/listProductBackInStockRemind";
|
|
4
3
|
import { QueryParams as SearchProductsQueryParams } from "src/__api/queries/searchProducts";
|
|
5
4
|
import { QueryParams as GetProductFilterDataQueryParams } from "src/__api/queries/getProductFilterData";
|
|
@@ -9,8 +8,14 @@ import { QueryParams as GetProductCampaignsQueryParams } from "src/__api/queries
|
|
|
9
8
|
import { QueryParams as GetOrderLineFile } from "src/__api/mutations/getOrderLineFile";
|
|
10
9
|
import { QueryParams as ListProductOptionSetQueryParams } from "src/__api/queries/listProductOptionSet";
|
|
11
10
|
import { QueryParams as SaveProductBackInStockRemindQueryParams } from "src/__api/mutations/saveProductBackInStockRemind";
|
|
11
|
+
import { IkasProductFilter } from "src/models/data/product-filter";
|
|
12
|
+
import { IkasFilterCategory } from "src/models/data/category";
|
|
13
|
+
import { IkasProduct } from "src/models/data/product";
|
|
14
|
+
import { IkasProductAttribute } from "src/models/data/product-attribute";
|
|
15
|
+
import { IkasProductCampaign } from "src/models/data/product-campaign";
|
|
16
|
+
import { IkasProductOptionSet } from "src/models/data/product-option-set";
|
|
12
17
|
export default class ProductStore {
|
|
13
|
-
static listProductBackInStockRemind(params: ListProductBackInStockRemind): Promise<APIResponse<import("../../__api/types").ProductBackInStockRemind[]
|
|
18
|
+
static listProductBackInStockRemind(params: ListProductBackInStockRemind): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").ProductBackInStockRemind[]>>;
|
|
14
19
|
static saveProductBackInStockRemind(params: SaveProductBackInStockRemindQueryParams): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").ProductBackInStockRemind>>;
|
|
15
20
|
static searchProducts(params: SearchProductsQueryParams): Promise<APIResponse<{
|
|
16
21
|
data: IkasProduct[] | undefined;
|