@fayz-ai/storefront 0.47.0 → 0.49.0
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/dist/catalog.d.ts +2 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +1 -1
- package/dist/{chunk-DK3KK373.js → chunk-PU7DSP2T.js} +43 -12
- package/dist/chunk-PU7DSP2T.js.map +1 -0
- package/dist/data/auth.d.ts +9 -1
- package/dist/data/auth.d.ts.map +1 -1
- package/dist/document/store-policy.d.ts +7 -1
- package/dist/document/store-policy.d.ts.map +1 -1
- package/dist/hooks/use-known-customer.d.ts.map +1 -1
- package/dist/index.d.ts +27 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/render.js +1 -1
- package/dist/shop.d.ts +2 -1
- package/dist/shop.d.ts.map +1 -1
- package/dist/shop.js +1 -1
- package/dist/ui.d.ts +2 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +1 -1
- package/package.json +6 -7
- package/dist/chunk-DK3KK373.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -28
- package/dist/hooks/index.d.ts.map +0 -1
package/dist/catalog.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { MOCK_CATEGORIES, MOCK_DISCOUNTS, MOCK_PRODUCTS, buildMockCatalog, svgPlaceholder, } from '@fayz-ai/shop/catalog';
|
|
2
|
+
export type { CatalogCategoryInput, CatalogInput, CatalogProductInput } from '@fayz-ai/shop/catalog';
|
|
2
3
|
//# sourceMappingURL=catalog.d.ts.map
|
package/dist/catalog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAEA,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,oBAAoB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA"}
|
package/dist/catalog.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { persist } from 'zustand/middleware';
|
|
3
|
-
import {
|
|
3
|
+
import { createMockAuthAdapter } from '@fayz-ai/auth';
|
|
4
|
+
import { createAuthRuntime } from '@fayz-ai/auth/lib/runtime';
|
|
4
5
|
import { getShopProvider, setShopProvider } from '@fayz-ai/shop/runtime';
|
|
5
6
|
import { setShopCarrierQuotesResolver, setShopAccessTokenResolver, setShopShippingItemsResolver } from '@fayz-ai/sdk/shop';
|
|
6
7
|
import { normalizePostalCode, getCountrySchema, lookupPostalCode, defaultRouterAdapter, defineLoader, staticRouterAdapter, isLoaderParamRef, isLoaderPropRef, resolveLoader, errorMessage, dataNeedKey, getBlockMeta, defaultPropsFromSettings, getBlockErrorVisibility, isBlockEnabledOn, checkBlockConstraints, checkBlockContext, repairBlockTree, renderBlocks, clearExtensionPoints, defineExtensionPoint, runExtensionPoint, runEscapeValve, breadcrumbJsonLd, hasEntityDeclaration, resolveEntityDeclaration, defineBlock, formatPostalCode, countryName, defineEntity, listEntityDeclarations, resolveHandle, seoOrigin, describeError, RESERVED_ENTITY_FIELDS, ENTITY_FIELD_TYPES, handleNameFor, registerHandle, validateAddress, hasHandle, listHandles, blockRegistry, loaderRegistry, listLoaders } from '@fayz-ai/core';
|
|
@@ -76,10 +77,8 @@ function initCustomerAuth(adapter) {
|
|
|
76
77
|
_accessToken = existing?.session.accessToken ?? null;
|
|
77
78
|
if (!existing) return;
|
|
78
79
|
_hadAuthUser = true;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
void linkCustomer(existing.user);
|
|
82
|
-
}
|
|
80
|
+
void linkCustomer(existing.user).catch(() => {
|
|
81
|
+
});
|
|
83
82
|
}).catch(() => {
|
|
84
83
|
});
|
|
85
84
|
adapter.onAuthStateChange((user) => {
|
|
@@ -92,9 +91,26 @@ function initCustomerAuth(adapter) {
|
|
|
92
91
|
return;
|
|
93
92
|
}
|
|
94
93
|
_hadAuthUser = true;
|
|
95
|
-
|
|
94
|
+
const linked = useSessionStore.getState();
|
|
95
|
+
const needsLink = !linked.customerId || (linked.email ?? "").toLowerCase() !== (user.email ?? "").toLowerCase();
|
|
96
|
+
void syncAccessToken(adapter).then(() => {
|
|
97
|
+
if (needsLink && user.email) return linkCustomer(user).then(() => void 0);
|
|
98
|
+
}).catch(() => {
|
|
99
|
+
});
|
|
96
100
|
});
|
|
97
101
|
}
|
|
102
|
+
function hasCustomerAuth() {
|
|
103
|
+
return _hadAuthUser;
|
|
104
|
+
}
|
|
105
|
+
async function relinkCustomer() {
|
|
106
|
+
if (!_hadAuthUser) return null;
|
|
107
|
+
const existing = await getCustomerAuthAdapter().getSession().catch(() => null);
|
|
108
|
+
if (!existing?.user.email) return null;
|
|
109
|
+
const customer = await resolveShopCustomer(existing.user.email.trim().toLowerCase(), existing.user.fullName ?? "");
|
|
110
|
+
const store = useSessionStore.getState();
|
|
111
|
+
store.setSession({ customerId: customer.id, email: existing.user.email.trim().toLowerCase(), name: store.name });
|
|
112
|
+
return { customerId: customer.id, phone: customer.phone ?? null, document: customer.document ?? null };
|
|
113
|
+
}
|
|
98
114
|
function getCustomerAuthAdapter() {
|
|
99
115
|
if (!_adapter) _adapter = createMockAuthAdapter();
|
|
100
116
|
return _adapter;
|
|
@@ -6773,6 +6789,10 @@ function applyStoreSettings(config, settings) {
|
|
|
6773
6789
|
}
|
|
6774
6790
|
return next;
|
|
6775
6791
|
}
|
|
6792
|
+
function applyShippingSettings(config, shipping) {
|
|
6793
|
+
if (!shipping) return config;
|
|
6794
|
+
return { ...config, shipping: { flatRate: shipping.flatRate, freeAbove: shipping.freeAbove ?? void 0 } };
|
|
6795
|
+
}
|
|
6776
6796
|
function applyBuyer(config, buyer) {
|
|
6777
6797
|
if (!buyer) return config;
|
|
6778
6798
|
const language = normalizeLanguage(buyer.language) ?? config.language;
|
|
@@ -6787,6 +6807,7 @@ function StorefrontConfigHost({
|
|
|
6787
6807
|
children
|
|
6788
6808
|
}) {
|
|
6789
6809
|
const [policy, setPolicy] = React38.useState(null);
|
|
6810
|
+
const [shipping, setShipping] = React38.useState(null);
|
|
6790
6811
|
React38.useEffect(() => {
|
|
6791
6812
|
let cancelled = false;
|
|
6792
6813
|
let provider;
|
|
@@ -6795,6 +6816,12 @@ function StorefrontConfigHost({
|
|
|
6795
6816
|
} catch {
|
|
6796
6817
|
return;
|
|
6797
6818
|
}
|
|
6819
|
+
if (typeof provider.getShippingSettings === "function") {
|
|
6820
|
+
void provider.getShippingSettings().then((saved) => {
|
|
6821
|
+
if (!cancelled) setShipping(saved);
|
|
6822
|
+
}).catch(() => {
|
|
6823
|
+
});
|
|
6824
|
+
}
|
|
6798
6825
|
if (typeof provider.getPublicStoreSettings !== "function") return;
|
|
6799
6826
|
void provider.getPublicStoreSettings().then((settings) => {
|
|
6800
6827
|
if (cancelled) return;
|
|
@@ -6813,8 +6840,8 @@ function StorefrontConfigHost({
|
|
|
6813
6840
|
};
|
|
6814
6841
|
}, [config]);
|
|
6815
6842
|
const resolved = React38.useMemo(
|
|
6816
|
-
() => applyBuyer(applyStoreSettings(config, policy), buyer),
|
|
6817
|
-
[config, policy, buyer?.language, buyer?.country]
|
|
6843
|
+
() => applyBuyer(applyShippingSettings(applyStoreSettings(config, policy), shipping), buyer),
|
|
6844
|
+
[config, policy, shipping, buyer?.language, buyer?.country]
|
|
6818
6845
|
);
|
|
6819
6846
|
return /* @__PURE__ */ jsx(StorefrontConfigProvider, { value: resolved, children: /* @__PURE__ */ jsx(MarketScope, { children }) });
|
|
6820
6847
|
}
|
|
@@ -9343,9 +9370,13 @@ function useKnownCustomer() {
|
|
|
9343
9370
|
}
|
|
9344
9371
|
let cancelled = false;
|
|
9345
9372
|
const shop = getShopProvider();
|
|
9346
|
-
Promise.resolve(shop.getCustomer?.(customerId)).then((customer) => {
|
|
9373
|
+
Promise.resolve(shop.getCustomer?.(customerId)).then(async (customer) => {
|
|
9374
|
+
if (customer || !hasCustomerAuth()) return customer ? { phone: customer.phone ?? null, document: customer.document ?? null } : null;
|
|
9375
|
+
const relinked = await relinkCustomer();
|
|
9376
|
+
return relinked ? { phone: relinked.phone, document: relinked.document } : null;
|
|
9377
|
+
}).then((found) => {
|
|
9347
9378
|
if (cancelled) return;
|
|
9348
|
-
setContact(
|
|
9379
|
+
setContact(found);
|
|
9349
9380
|
}).catch(() => {
|
|
9350
9381
|
if (!cancelled) setContact(null);
|
|
9351
9382
|
}).finally(() => {
|
|
@@ -14102,5 +14133,5 @@ ${formatErrors(report.errors)}`;
|
|
|
14102
14133
|
}
|
|
14103
14134
|
|
|
14104
14135
|
export { AddressForm, AddressSheet, AddressStrip, BEFORE_PLACE_ORDER_VALVE, BLOCK_STRUCTURAL_KEYS, BUYER_COUNTRY_COOKIE, BenefitsRow, BlockDataError, CART_LINE_ANNOTATION_POINT, CATALOG_BODY_BLOCK, CHECKOUT_FIELD_POINT, CartDrawer, CatalogPage, CategoryShowcase, CheckoutPage, ClosedStoreDialog, CollectionCta, CollectionHero, ContentPage, CountdownBand, CountrySelect, DeliverToPicker, EmailConfirmationRequiredError, EntityListBlock, FaqSection, FiltersPanel, FormBlock, HeroSection, ImageTiles, ItemSheet, Link, MESSAGES, ManifestoBlock, MediaCarousel, MenuItemRow, MenuPage, MenuToolbar, MotifStrip, MyPurchasesPage, NewsletterBand, ORDER_METADATA_POINT, OrderConfirmationPage, OrderTrackingTimeline, PAGE_DATA_SCRIPT_ID, PLACEHOLDER_ASPECTS, PRODUCT_BODY_BLOCK, PRODUCT_CARD_BADGE_POINT, PageDataScope, PaymentTerms, Price, ProductCard, ProductDetailPage, ProductEnquiryForm, ProductGallery, ProductGrid, ProductOptionSelector, ProductRail, ProductReviews, ProductSlider, ProductSpecs, ProductSpotlight, PromoBanner, QuantityInput, Reveal, STOREFRONT_COMPONENT_KEYS, STOREFRONT_PAGE_KINDS, STOREFRONT_SLOTS, STORE_BACKEND_PROVIDERS, STORE_COMMERCE_MODES, STORE_DOCUMENT_KIND, STORE_PAYMENT_METHOD_KINDS, STORE_PAYMENT_MODES, STORE_ROUTE_CHROMES, STORE_ROUTE_KINDS, STORE_SECTIONS, STORE_SECTION_NAMES, ScheduleSheet, SealsBand, SearchOverlay, ServiceHoursModal, Slot, SmoothImage, StepsSection, StoreCover, StorefrontConfigHost, StorefrontConfigProvider, StorefrontFooter, StorefrontHeader, StorefrontPage, StorefrontRouterProvider, StorefrontShell, StorefrontThemeStyle, StoryQuote, THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX, TID, Testimonials, TierCards, applyStoreSettings, bannerPlaceholder, blockInstanceId, buildEnquiryFromForm, checkPageBlocks, collectDataNeeds, collectOrderMetadata, contentPagePath, createStorefront, createStorefrontApp, currentStaticRenderPass, defaultPageBlocks, entityListBlockMeta, establishCustomerSession, exportStore, formatMoney, formatProductOptionSelection, getCartLineAnnotations, getCheckoutFieldContributions, getCustomerAuthAdapter, getProductCardBadges, getProductOptionGroups, hydrateStoreDocument, hydratedEntriesFor, initStorefrontRuntime, isJsonValue, isKnownPath, isNestedBlockRef, isPublicPath, isRecord, listSlots, marketForCountry, marketUnitPrice, matchContentPage, matchPath, matchesFacets, mergeCollectionFacet, mergePageTheme, navigateTo, nextMilestone, normalizeLanguage, normalizeProductOptionSelection, orderGalleryImages, overrideComponent, overrideProps, pageSeo, pageThemeSelector, pickProductCardImage, placeStorefrontOrder, prefersReducedMotion, primaryImageUrl, productCardComponentContract, productJsonLd, productOptionSelectionKey, productPlaceholder, productSeo, readHydratedPageData, registerStorefrontBlocks, registerStorefrontEntities, registerStorefrontExtensionPoints, registerStorefrontLoaders, resetPageDiagnostics, resetProductOptionsDeprecationWarnings, resetStorefrontExtensionPoints, resolveAuthAdapter, resolveConfig, resolveDataParams, resolveOverride, resolvePageData, resolvePageDataNeed, resolvePaymentTerms, resolveStorefrontProvider, resolveStorefrontRoute, resolveVariantForSelection, roundCents, routePathParams, runBeforePlaceOrderValve, sectionToJsonSchema, sectionsToBlocks, selectCount, selectDiscountTotal, selectIsOpen, selectRequiresShipping, selectShipping, selectShowsHours, selectSubtotal, selectTotal, selectionPrice, serializePageData, shellRouterAdapter, signInByEmail, signOutCustomer, signUpCustomer, slugifyStoreName, storefrontComponentContracts, storefrontPaths, themeToCss, toBlockNodes, toFacetMap, translate, useBlockData, useBuyerCountry, useBuyerStore, useCartStore, useCatalogStore, useCategories, useDeliveryStore, useDiscountValidator, useEnquiry, useHashPath, useInView, useLoader, useMarketProduct, useMarketStore, useMyOrders, useNavigate, usePopOnChange, useProduct, useProducts, useRoutePath, useRouterAdapter, useScrollToTopOnNavigate, useScrolled, useServiceStore, useSessionStore, useSlotContext, useStorefrontActions, useStorefrontConfig, useStorefrontConfigOptional, useStorefrontHead, useStorefrontPage, useStorefrontPageOptional, useT, usedSlots, validateStore, withFacet, withMarketPrice, withStaticRenderPass };
|
|
14105
|
-
//# sourceMappingURL=chunk-
|
|
14106
|
-
//# sourceMappingURL=chunk-
|
|
14136
|
+
//# sourceMappingURL=chunk-PU7DSP2T.js.map
|
|
14137
|
+
//# sourceMappingURL=chunk-PU7DSP2T.js.map
|