@wix/headless-stores 0.0.12 → 0.0.14
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/cjs/dist/astro/actions/custom-checkout.d.ts +4 -2
- package/cjs/dist/astro/actions/custom-checkout.js +4 -8
- package/cjs/dist/astro/actions/index.d.ts +1 -1
- package/cjs/dist/astro/actions/index.js +1 -17
- package/cjs/dist/enums/index.d.ts +2 -2
- package/cjs/dist/enums/index.js +2 -18
- package/cjs/dist/enums/social-platform-enums.js +4 -7
- package/cjs/dist/enums/sort-enums.js +3 -6
- package/cjs/dist/react/BuyNow.js +6 -11
- package/cjs/dist/react/Category.d.ts +2 -2
- package/cjs/dist/react/Category.js +6 -10
- package/cjs/dist/react/Collection.d.ts +1 -1
- package/cjs/dist/react/Collection.js +31 -39
- package/cjs/dist/react/FilteredCollection.d.ts +6 -20
- package/cjs/dist/react/FilteredCollection.js +29 -57
- package/cjs/dist/react/PayNow.js +4 -9
- package/cjs/dist/react/Product.d.ts +3 -3
- package/cjs/dist/react/Product.js +6 -11
- package/cjs/dist/react/ProductActions.js +12 -17
- package/cjs/dist/react/ProductModifiers.d.ts +3 -1
- package/cjs/dist/react/ProductModifiers.js +23 -29
- package/cjs/dist/react/ProductVariantSelector.d.ts +1 -1
- package/cjs/dist/react/ProductVariantSelector.js +18 -28
- package/cjs/dist/react/RelatedProducts.d.ts +2 -2
- package/cjs/dist/react/RelatedProducts.js +35 -33
- package/cjs/dist/react/SelectedVariant.js +8 -14
- package/cjs/dist/react/SocialSharing.d.ts +2 -3
- package/cjs/dist/react/SocialSharing.js +35 -33
- package/cjs/dist/react/Sort.d.ts +4 -3
- package/cjs/dist/react/Sort.js +6 -10
- package/cjs/dist/react/index.d.ts +13 -13
- package/cjs/dist/react/index.js +13 -52
- package/cjs/dist/server-actions/custom-checkout-action.js +8 -11
- package/cjs/dist/server-actions/index.d.ts +1 -1
- package/cjs/dist/server-actions/index.js +1 -17
- package/cjs/dist/services/buy-now-service.d.ts +44 -3
- package/cjs/dist/services/buy-now-service.js +20 -22
- package/cjs/dist/services/catalog-options-service.d.ts +3 -3
- package/cjs/dist/services/catalog-options-service.js +45 -46
- package/cjs/dist/services/catalog-price-range-service.d.ts +3 -3
- package/cjs/dist/services/catalog-price-range-service.js +21 -25
- package/cjs/dist/services/category-service.d.ts +7 -7
- package/cjs/dist/services/category-service.js +20 -22
- package/cjs/dist/services/collection-service.d.ts +8 -8
- package/cjs/dist/services/collection-service.js +102 -133
- package/cjs/dist/services/filter-service.d.ts +4 -4
- package/cjs/dist/services/filter-service.js +47 -61
- package/cjs/dist/services/index.d.ts +13 -2
- package/cjs/dist/services/index.js +13 -9
- package/cjs/dist/services/pay-now-service.d.ts +4 -3
- package/cjs/dist/services/pay-now-service.js +11 -16
- package/cjs/dist/services/product-modifiers-service.d.ts +6 -6
- package/cjs/dist/services/product-modifiers-service.js +17 -21
- package/cjs/dist/services/product-service.d.ts +8 -8
- package/cjs/dist/services/product-service.js +22 -26
- package/cjs/dist/services/related-products-service.d.ts +5 -5
- package/cjs/dist/services/related-products-service.js +9 -13
- package/cjs/dist/services/selected-variant-service.d.ts +11 -8
- package/cjs/dist/services/selected-variant-service.js +73 -90
- package/cjs/dist/services/social-sharing-service.d.ts +2 -9
- package/cjs/dist/services/social-sharing-service.js +48 -60
- package/cjs/dist/services/sort-service.d.ts +3 -3
- package/cjs/dist/services/sort-service.js +14 -19
- package/cjs/dist/utils/index.js +6 -9
- package/cjs/dist/utils/url-params.js +5 -9
- package/dist/astro/actions/custom-checkout.d.ts +1 -1
- package/dist/astro/actions/custom-checkout.js +1 -1
- package/dist/astro/actions/index.d.ts +1 -1
- package/dist/astro/actions/index.js +1 -1
- package/dist/enums/index.d.ts +2 -2
- package/dist/enums/index.js +2 -2
- package/dist/react/BuyNow.js +4 -6
- package/dist/react/Category.d.ts +2 -2
- package/dist/react/Category.js +2 -2
- package/dist/react/Collection.d.ts +1 -1
- package/dist/react/Collection.js +20 -20
- package/dist/react/FilteredCollection.d.ts +6 -20
- package/dist/react/FilteredCollection.js +17 -35
- package/dist/react/PayNow.js +2 -4
- package/dist/react/Product.d.ts +3 -3
- package/dist/react/Product.js +2 -2
- package/dist/react/ProductActions.js +9 -10
- package/dist/react/ProductModifiers.d.ts +3 -1
- package/dist/react/ProductModifiers.js +14 -12
- package/dist/react/ProductVariantSelector.d.ts +1 -1
- package/dist/react/ProductVariantSelector.js +6 -8
- package/dist/react/RelatedProducts.d.ts +2 -2
- package/dist/react/RelatedProducts.js +25 -15
- package/dist/react/SelectedVariant.js +2 -2
- package/dist/react/SocialSharing.d.ts +2 -3
- package/dist/react/SocialSharing.js +24 -13
- package/dist/react/Sort.d.ts +4 -3
- package/dist/react/Sort.js +3 -4
- package/dist/react/index.d.ts +13 -13
- package/dist/react/index.js +13 -13
- package/dist/server-actions/index.d.ts +1 -1
- package/dist/server-actions/index.js +1 -1
- package/dist/services/buy-now-service.d.ts +44 -3
- package/dist/services/buy-now-service.js +7 -4
- package/dist/services/catalog-options-service.d.ts +3 -3
- package/dist/services/catalog-options-service.js +33 -30
- package/dist/services/catalog-price-range-service.d.ts +3 -3
- package/dist/services/catalog-price-range-service.js +18 -18
- package/dist/services/category-service.d.ts +7 -7
- package/dist/services/category-service.js +17 -15
- package/dist/services/collection-service.d.ts +8 -8
- package/dist/services/collection-service.js +80 -74
- package/dist/services/filter-service.d.ts +4 -4
- package/dist/services/filter-service.js +37 -48
- package/dist/services/index.d.ts +13 -2
- package/dist/services/index.js +13 -2
- package/dist/services/pay-now-service.d.ts +4 -3
- package/dist/services/pay-now-service.js +1 -1
- package/dist/services/product-modifiers-service.d.ts +6 -6
- package/dist/services/product-modifiers-service.js +13 -13
- package/dist/services/product-service.d.ts +8 -8
- package/dist/services/product-service.js +19 -19
- package/dist/services/related-products-service.d.ts +5 -5
- package/dist/services/related-products-service.js +6 -6
- package/dist/services/selected-variant-service.d.ts +11 -8
- package/dist/services/selected-variant-service.js +71 -85
- package/dist/services/social-sharing-service.d.ts +2 -9
- package/dist/services/social-sharing-service.js +29 -37
- package/dist/services/sort-service.d.ts +3 -3
- package/dist/services/sort-service.js +8 -10
- package/dist/utils/url-params.js +4 -4
- package/package.json +5 -5
- package/cjs/dist/services/product-media-gallery-service.d.ts +0 -25
- package/cjs/dist/services/product-media-gallery-service.js +0 -105
- package/dist/services/product-media-gallery-service.d.ts +0 -25
- package/dist/services/product-media-gallery-service.js +0 -101
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineService, implementService } from
|
|
2
|
-
import { SignalsServiceDefinition } from
|
|
3
|
-
import { URLParamsUtils } from
|
|
4
|
-
import { CatalogPriceRangeServiceDefinition } from
|
|
5
|
-
import { CatalogOptionsServiceDefinition } from
|
|
6
|
-
export const FilterServiceDefinition = defineService(
|
|
1
|
+
import { defineService, implementService } from "@wix/services-definitions";
|
|
2
|
+
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
import { URLParamsUtils } from "../utils/url-params.js";
|
|
4
|
+
import { CatalogPriceRangeServiceDefinition } from "./catalog-price-range-service.js";
|
|
5
|
+
import { CatalogOptionsServiceDefinition } from "./catalog-options-service.js";
|
|
6
|
+
export const FilterServiceDefinition = defineService("filtered-collection");
|
|
7
7
|
export const defaultFilter = {
|
|
8
8
|
priceRange: { min: 0, max: 0 },
|
|
9
9
|
selectedOptions: {},
|
|
@@ -12,35 +12,39 @@ export const FilterService = implementService.withConfig()(FilterServiceDefiniti
|
|
|
12
12
|
const signalsService = getService(SignalsServiceDefinition);
|
|
13
13
|
const catalogPriceRangeService = getService(CatalogPriceRangeServiceDefinition);
|
|
14
14
|
const catalogOptionsService = getService(CatalogOptionsServiceDefinition);
|
|
15
|
-
const currentFilters = signalsService.signal((config
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const currentFilters = signalsService.signal((config?.initialFilters || defaultFilter));
|
|
16
|
+
// Use computed signal for availableOptions to automatically track dependencies
|
|
17
|
+
const availableOptions = signalsService.computed(() => {
|
|
18
|
+
const catalogPriceRange = catalogPriceRangeService.catalogPriceRange.get();
|
|
19
|
+
const catalogOptions = catalogOptionsService.catalogOptions.get();
|
|
20
|
+
const priceRange = catalogPriceRange &&
|
|
21
|
+
catalogPriceRange.minPrice < catalogPriceRange.maxPrice
|
|
22
|
+
? { min: catalogPriceRange.minPrice, max: catalogPriceRange.maxPrice }
|
|
23
|
+
: { min: 0, max: 0 };
|
|
24
|
+
const productOptions = catalogOptions && catalogOptions.length > 0 ? catalogOptions : [];
|
|
25
|
+
return {
|
|
26
|
+
productOptions,
|
|
27
|
+
priceRange,
|
|
28
|
+
};
|
|
19
29
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const checkIfFullyLoaded = () => {
|
|
30
|
+
// Use computed signal for isFullyLoaded to automatically track dependencies
|
|
31
|
+
const isFullyLoaded = signalsService.computed(() => {
|
|
23
32
|
const catalogPriceRange = catalogPriceRangeService.catalogPriceRange.get();
|
|
24
33
|
const catalogOptions = catalogOptionsService.catalogOptions.get();
|
|
25
34
|
// Price range data is considered loaded whether it's null (no prices) or has valid data
|
|
26
35
|
const hasPriceRangeData = catalogPriceRange !== undefined; // includes null case
|
|
27
36
|
const hasOptionsData = !!(catalogOptions && catalogOptions.length >= 0); // Even 0 options is valid
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
//
|
|
31
|
-
|
|
37
|
+
return hasPriceRangeData && hasOptionsData;
|
|
38
|
+
});
|
|
39
|
+
// Effect to update currentFilters when catalog data loads (only if filters are at defaults)
|
|
40
|
+
signalsService.effect(() => {
|
|
41
|
+
const catalogPriceRange = catalogPriceRangeService.catalogPriceRange.get();
|
|
32
42
|
if (catalogPriceRange &&
|
|
33
43
|
catalogPriceRange.minPrice < catalogPriceRange.maxPrice) {
|
|
34
44
|
const priceRange = {
|
|
35
45
|
min: catalogPriceRange.minPrice,
|
|
36
46
|
max: catalogPriceRange.maxPrice,
|
|
37
47
|
};
|
|
38
|
-
// Update available options with catalog price range
|
|
39
|
-
const currentAvailableOptions = availableOptions.get();
|
|
40
|
-
availableOptions.set({
|
|
41
|
-
...currentAvailableOptions,
|
|
42
|
-
priceRange,
|
|
43
|
-
});
|
|
44
48
|
// Update current filters to use catalog price range
|
|
45
49
|
const currentFiltersValue = currentFilters.get();
|
|
46
50
|
// Only update if current filter range is at defaults (either 0-0 or 0-1000)
|
|
@@ -55,21 +59,6 @@ export const FilterService = implementService.withConfig()(FilterServiceDefiniti
|
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
|
-
// Check if fully loaded after price range update
|
|
59
|
-
checkIfFullyLoaded();
|
|
60
|
-
});
|
|
61
|
-
// Subscribe to catalog options changes and automatically update our signals
|
|
62
|
-
catalogOptionsService.catalogOptions.subscribe(catalogOptions => {
|
|
63
|
-
if (catalogOptions && catalogOptions.length > 0) {
|
|
64
|
-
// Update available options with catalog options
|
|
65
|
-
const currentAvailableOptions = availableOptions.get();
|
|
66
|
-
availableOptions.set({
|
|
67
|
-
...currentAvailableOptions,
|
|
68
|
-
productOptions: catalogOptions,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// Check if fully loaded after options update
|
|
72
|
-
checkIfFullyLoaded();
|
|
73
62
|
});
|
|
74
63
|
// Apply filters by delegating to the collection service
|
|
75
64
|
const applyFilters = async (filters) => {
|
|
@@ -80,30 +69,30 @@ export const FilterService = implementService.withConfig()(FilterServiceDefiniti
|
|
|
80
69
|
// Add price filters if different from defaults
|
|
81
70
|
if (availableOpts?.priceRange) {
|
|
82
71
|
if (filters.priceRange.min > availableOpts.priceRange.min) {
|
|
83
|
-
urlParams[
|
|
72
|
+
urlParams["minPrice"] = filters.priceRange.min.toString();
|
|
84
73
|
}
|
|
85
74
|
if (filters.priceRange.max < availableOpts.priceRange.max) {
|
|
86
|
-
urlParams[
|
|
75
|
+
urlParams["maxPrice"] = filters.priceRange.max.toString();
|
|
87
76
|
}
|
|
88
77
|
}
|
|
89
78
|
// Add option filters using option names as keys
|
|
90
79
|
if (availableOpts?.productOptions) {
|
|
91
80
|
Object.entries(filters.selectedOptions).forEach(([optionId, choiceIds]) => {
|
|
92
|
-
const option = availableOpts.productOptions.find(opt => opt.id === optionId);
|
|
81
|
+
const option = availableOpts.productOptions.find((opt) => opt.id === optionId);
|
|
93
82
|
if (option && choiceIds.length > 0) {
|
|
94
|
-
const selectedChoices = option.choices.filter(choice => choiceIds.includes(choice.id));
|
|
83
|
+
const selectedChoices = option.choices.filter((choice) => choiceIds.includes(choice.id));
|
|
95
84
|
if (selectedChoices.length > 0) {
|
|
96
85
|
// Use 'availability' as URL param for inventory filter
|
|
97
|
-
const paramName = optionId ===
|
|
98
|
-
urlParams[paramName] = selectedChoices.map(choice => choice.name);
|
|
86
|
+
const paramName = optionId === "inventory-filter" ? "availability" : option.name;
|
|
87
|
+
urlParams[paramName] = selectedChoices.map((choice) => choice.name);
|
|
99
88
|
}
|
|
100
89
|
}
|
|
101
90
|
});
|
|
102
91
|
}
|
|
103
92
|
// Preserve existing sort parameter
|
|
104
93
|
const currentParams = URLParamsUtils.getURLParams();
|
|
105
|
-
if (currentParams[
|
|
106
|
-
urlParams[
|
|
94
|
+
if (currentParams["sort"]) {
|
|
95
|
+
urlParams["sort"] = currentParams["sort"];
|
|
107
96
|
}
|
|
108
97
|
URLParamsUtils.updateURL(urlParams);
|
|
109
98
|
};
|
|
@@ -117,8 +106,8 @@ export const FilterService = implementService.withConfig()(FilterServiceDefiniti
|
|
|
117
106
|
// Clear filter parameters from URL, keeping only sort parameter
|
|
118
107
|
const currentParams = URLParamsUtils.getURLParams();
|
|
119
108
|
const urlParams = {};
|
|
120
|
-
if (currentParams[
|
|
121
|
-
urlParams[
|
|
109
|
+
if (currentParams["sort"]) {
|
|
110
|
+
urlParams["sort"] = currentParams["sort"];
|
|
122
111
|
}
|
|
123
112
|
URLParamsUtils.updateURL(urlParams);
|
|
124
113
|
};
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
export { buyNowServiceBinding, loadBuyNowServiceInitialData, } from "./buy-now-service";
|
|
2
|
-
export { payNowServiceBinding, loadPayNowServiceInitialData, } from "./pay-now-service";
|
|
1
|
+
export { buyNowServiceBinding, loadBuyNowServiceInitialData, } from "./buy-now-service.js";
|
|
2
|
+
export { payNowServiceBinding, loadPayNowServiceInitialData, } from "./pay-now-service.js";
|
|
3
|
+
export { CatalogOptionsService, CatalogOptionsServiceDefinition, loadCatalogOptionsServiceConfig, } from "./catalog-options-service.js";
|
|
4
|
+
export { CategoryService, CategoryServiceDefinition, loadCategoriesConfig, } from "./category-service.js";
|
|
5
|
+
export { CollectionService, CollectionServiceDefinition, loadCollectionServiceConfig, } from "./collection-service.js";
|
|
6
|
+
export { CatalogPriceRangeService, CatalogPriceRangeServiceDefinition, loadCatalogPriceRangeServiceConfig, } from "./catalog-price-range-service.js";
|
|
7
|
+
export { FilterService, FilterServiceDefinition } from "./filter-service.js";
|
|
8
|
+
export { ProductModifiersService, ProductModifiersServiceDefinition, } from "./product-modifiers-service.js";
|
|
9
|
+
export { ProductService, ProductServiceDefinition, loadProductServiceConfig, } from "./product-service.js";
|
|
10
|
+
export { RelatedProductsService, RelatedProductsServiceDefinition, loadRelatedProductsServiceConfig, } from "./related-products-service.js";
|
|
11
|
+
export { SelectedVariantService, SelectedVariantServiceDefinition, } from "./selected-variant-service.js";
|
|
12
|
+
export { SocialSharingService, SocialSharingServiceDefinition, } from "./social-sharing-service.js";
|
|
13
|
+
export { SortService, SortServiceDefinition } from "./sort-service.js";
|
package/dist/services/index.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
export { buyNowServiceBinding, loadBuyNowServiceInitialData, } from "./buy-now-service";
|
|
2
|
-
export { payNowServiceBinding, loadPayNowServiceInitialData, } from "./pay-now-service";
|
|
1
|
+
export { buyNowServiceBinding, loadBuyNowServiceInitialData, } from "./buy-now-service.js";
|
|
2
|
+
export { payNowServiceBinding, loadPayNowServiceInitialData, } from "./pay-now-service.js";
|
|
3
|
+
export { CatalogOptionsService, CatalogOptionsServiceDefinition, loadCatalogOptionsServiceConfig, } from "./catalog-options-service.js";
|
|
4
|
+
export { CategoryService, CategoryServiceDefinition, loadCategoriesConfig, } from "./category-service.js";
|
|
5
|
+
export { CollectionService, CollectionServiceDefinition, loadCollectionServiceConfig, } from "./collection-service.js";
|
|
6
|
+
export { CatalogPriceRangeService, CatalogPriceRangeServiceDefinition, loadCatalogPriceRangeServiceConfig, } from "./catalog-price-range-service.js";
|
|
7
|
+
export { FilterService, FilterServiceDefinition } from "./filter-service.js";
|
|
8
|
+
export { ProductModifiersService, ProductModifiersServiceDefinition, } from "./product-modifiers-service.js";
|
|
9
|
+
export { ProductService, ProductServiceDefinition, loadProductServiceConfig, } from "./product-service.js";
|
|
10
|
+
export { RelatedProductsService, RelatedProductsServiceDefinition, loadRelatedProductsServiceConfig, } from "./related-products-service.js";
|
|
11
|
+
export { SelectedVariantService, SelectedVariantServiceDefinition, } from "./selected-variant-service.js";
|
|
12
|
+
export { SocialSharingService, SocialSharingServiceDefinition, } from "./social-sharing-service.js";
|
|
13
|
+
export { SortService, SortServiceDefinition } from "./sort-service.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ServiceFactoryConfig
|
|
1
|
+
import { ServiceFactoryConfig } from "@wix/services-definitions";
|
|
2
|
+
import { type Signal } from "@wix/services-definitions/core-services/signals";
|
|
2
3
|
export declare const PayNowServiceDefinition: string & {
|
|
3
4
|
__api: {
|
|
4
5
|
redirectToCheckout: () => Promise<void>;
|
|
@@ -29,7 +30,7 @@ export declare const PayNowServiceImplementation: import("@wix/services-definiti
|
|
|
29
30
|
data: string | undefined;
|
|
30
31
|
error: unknown;
|
|
31
32
|
}>;
|
|
32
|
-
}
|
|
33
|
+
}>;
|
|
33
34
|
export declare const loadPayNowServiceInitialData: () => Promise<{
|
|
34
35
|
[PayNowServiceDefinition]: {};
|
|
35
36
|
}>;
|
|
@@ -64,7 +65,7 @@ export declare const payNowServiceBinding: <T extends {
|
|
|
64
65
|
data: string | undefined;
|
|
65
66
|
error: unknown;
|
|
66
67
|
}>;
|
|
67
|
-
}
|
|
68
|
+
}>, {
|
|
68
69
|
customCheckoutAction?: () => Promise<{
|
|
69
70
|
data: string | undefined;
|
|
70
71
|
error: unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineService, implementService, } from "@wix/services-definitions";
|
|
2
|
-
import { SignalsServiceDefinition } from "@wix/services-definitions/core-services/signals";
|
|
2
|
+
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
3
|
export const PayNowServiceDefinition = defineService("PayNow");
|
|
4
4
|
export const PayNowServiceImplementation = implementService.withConfig()(PayNowServiceDefinition, ({ getService, config }) => {
|
|
5
5
|
const signalsService = getService(SignalsServiceDefinition);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type ServiceFactoryConfig } from
|
|
2
|
-
import type
|
|
3
|
-
import
|
|
1
|
+
import { type ServiceFactoryConfig } from "@wix/services-definitions";
|
|
2
|
+
import { type Signal, type ReadOnlySignal } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
import * as productsV3 from "@wix/auto_sdk_stores_products-v-3";
|
|
4
4
|
export interface ModifierValue {
|
|
5
5
|
modifierName: string;
|
|
6
6
|
choiceValue?: string;
|
|
7
7
|
freeTextValue?: string;
|
|
8
8
|
}
|
|
9
9
|
export interface ProductModifiersServiceAPI {
|
|
10
|
-
modifiers: ReadOnlySignal<ConnectedModifier[]>;
|
|
10
|
+
modifiers: ReadOnlySignal<productsV3.ConnectedModifier[]>;
|
|
11
11
|
selectedModifiers: Signal<Record<string, ModifierValue>>;
|
|
12
12
|
hasModifiers: ReadOnlySignal<boolean>;
|
|
13
13
|
isLoading: Signal<boolean>;
|
|
@@ -30,5 +30,5 @@ export declare const ProductModifiersService: import("@wix/services-definitions"
|
|
|
30
30
|
__api: ProductModifiersServiceAPI;
|
|
31
31
|
__config: {};
|
|
32
32
|
isServiceDefinition?: boolean;
|
|
33
|
-
} & ProductModifiersServiceAPI, unknown
|
|
34
|
-
export declare function createProductModifiersServiceConfig(product: V3Product): ServiceFactoryConfig<typeof ProductModifiersService>;
|
|
33
|
+
} & ProductModifiersServiceAPI, unknown>;
|
|
34
|
+
export declare function createProductModifiersServiceConfig(product: productsV3.V3Product): ServiceFactoryConfig<typeof ProductModifiersService>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineService, implementService, } from
|
|
2
|
-
import { SignalsServiceDefinition } from
|
|
3
|
-
import
|
|
4
|
-
import { ProductServiceDefinition } from
|
|
5
|
-
export const ProductModifiersServiceDefinition = defineService(
|
|
1
|
+
import { defineService, implementService, } from "@wix/services-definitions";
|
|
2
|
+
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
import * as productsV3 from "@wix/auto_sdk_stores_products-v-3";
|
|
4
|
+
import { ProductServiceDefinition } from "./product-service.js";
|
|
5
|
+
export const ProductModifiersServiceDefinition = defineService("productModifiers");
|
|
6
6
|
export const ProductModifiersService = implementService.withConfig()(ProductModifiersServiceDefinition, ({ getService }) => {
|
|
7
7
|
const signalsService = getService(SignalsServiceDefinition);
|
|
8
8
|
const productService = getService(ProductServiceDefinition);
|
|
@@ -53,33 +53,33 @@ export const ProductModifiersService = implementService.withConfig()(ProductModi
|
|
|
53
53
|
};
|
|
54
54
|
const isModifierRequired = (modifierName) => {
|
|
55
55
|
const mods = modifiers.get();
|
|
56
|
-
const modifier = mods.find(m => m.name === modifierName);
|
|
56
|
+
const modifier = mods.find((m) => m.name === modifierName);
|
|
57
57
|
return modifier?.mandatory || false;
|
|
58
58
|
};
|
|
59
59
|
const hasRequiredModifiers = () => {
|
|
60
60
|
const mods = modifiers.get();
|
|
61
|
-
return mods.some(m => m.mandatory);
|
|
61
|
+
return mods.some((m) => m.mandatory);
|
|
62
62
|
};
|
|
63
63
|
const areAllRequiredModifiersFilled = () => {
|
|
64
64
|
const mods = modifiers.get();
|
|
65
65
|
const current = selectedModifiers.get();
|
|
66
|
-
return mods.every(modifier => {
|
|
66
|
+
return mods.every((modifier) => {
|
|
67
67
|
if (!modifier.mandatory)
|
|
68
68
|
return true;
|
|
69
|
-
const selectedValue = current[modifier.name ||
|
|
69
|
+
const selectedValue = current[modifier.name || ""];
|
|
70
70
|
if (!selectedValue)
|
|
71
71
|
return false;
|
|
72
72
|
// Check based on modifier type
|
|
73
73
|
const renderType = modifier.modifierRenderType;
|
|
74
74
|
if (!renderType)
|
|
75
75
|
return false;
|
|
76
|
-
if (renderType === ModifierRenderType.SWATCH_CHOICES ||
|
|
77
|
-
renderType === ModifierRenderType.TEXT_CHOICES) {
|
|
76
|
+
if (renderType === productsV3.ModifierRenderType.SWATCH_CHOICES ||
|
|
77
|
+
renderType === productsV3.ModifierRenderType.TEXT_CHOICES) {
|
|
78
78
|
return !!selectedValue.choiceValue;
|
|
79
79
|
}
|
|
80
|
-
else if (renderType === ModifierRenderType.FREE_TEXT) {
|
|
80
|
+
else if (renderType === productsV3.ModifierRenderType.FREE_TEXT) {
|
|
81
81
|
return (!!selectedValue.freeTextValue &&
|
|
82
|
-
selectedValue.freeTextValue.trim() !==
|
|
82
|
+
selectedValue.freeTextValue.trim() !== "");
|
|
83
83
|
}
|
|
84
84
|
return false;
|
|
85
85
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type ServiceFactoryConfig } from
|
|
2
|
-
import type
|
|
3
|
-
import
|
|
1
|
+
import { type ServiceFactoryConfig } from "@wix/services-definitions";
|
|
2
|
+
import { type Signal } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
import * as productsV3 from "@wix/auto_sdk_stores_products-v-3";
|
|
4
4
|
export interface ProductServiceAPI {
|
|
5
|
-
product: Signal<V3Product>;
|
|
5
|
+
product: Signal<productsV3.V3Product>;
|
|
6
6
|
isLoading: Signal<boolean>;
|
|
7
7
|
error: Signal<string | null>;
|
|
8
8
|
loadProduct: (slug: string) => Promise<void>;
|
|
@@ -17,12 +17,12 @@ export declare const ProductService: import("@wix/services-definitions").Service
|
|
|
17
17
|
__config: {};
|
|
18
18
|
isServiceDefinition?: boolean;
|
|
19
19
|
} & ProductServiceAPI, {
|
|
20
|
-
product: V3Product;
|
|
21
|
-
}
|
|
20
|
+
product: productsV3.V3Product;
|
|
21
|
+
}>;
|
|
22
22
|
export type ProductServiceConfigResult = {
|
|
23
|
-
type:
|
|
23
|
+
type: "success";
|
|
24
24
|
config: ServiceFactoryConfig<typeof ProductService>;
|
|
25
25
|
} | {
|
|
26
|
-
type:
|
|
26
|
+
type: "notFound";
|
|
27
27
|
};
|
|
28
28
|
export declare function loadProductServiceConfig(productSlug: string): Promise<ProductServiceConfigResult>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineService, implementService, } from
|
|
2
|
-
import { SignalsServiceDefinition } from
|
|
3
|
-
import
|
|
4
|
-
export const ProductServiceDefinition = defineService(
|
|
1
|
+
import { defineService, implementService, } from "@wix/services-definitions";
|
|
2
|
+
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
import * as productsV3 from "@wix/auto_sdk_stores_products-v-3";
|
|
4
|
+
export const ProductServiceDefinition = defineService("product");
|
|
5
5
|
export const ProductService = implementService.withConfig()(ProductServiceDefinition, ({ getService, config }) => {
|
|
6
6
|
const signalsService = getService(SignalsServiceDefinition);
|
|
7
7
|
const product = signalsService.signal(config.product);
|
|
@@ -11,7 +11,7 @@ export const ProductService = implementService.withConfig()(ProductServiceDefini
|
|
|
11
11
|
isLoading.set(true);
|
|
12
12
|
const productResponse = await loadProductBySlug(slug);
|
|
13
13
|
if (!productResponse.product) {
|
|
14
|
-
error.set(
|
|
14
|
+
error.set("Product not found");
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
17
|
product.set(productResponse.product);
|
|
@@ -27,18 +27,18 @@ export const ProductService = implementService.withConfig()(ProductServiceDefini
|
|
|
27
27
|
};
|
|
28
28
|
});
|
|
29
29
|
const loadProductBySlug = async (slug) => {
|
|
30
|
-
const productResponse = await getProductBySlug(slug, {
|
|
30
|
+
const productResponse = await productsV3.getProductBySlug(slug, {
|
|
31
31
|
fields: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
"DESCRIPTION",
|
|
33
|
+
"DIRECT_CATEGORIES_INFO",
|
|
34
|
+
"BREADCRUMBS_INFO",
|
|
35
|
+
"INFO_SECTION",
|
|
36
|
+
"MEDIA_ITEMS_INFO",
|
|
37
|
+
"PLAIN_DESCRIPTION",
|
|
38
|
+
"THUMBNAIL",
|
|
39
|
+
"URL",
|
|
40
|
+
"VARIANT_OPTION_CHOICE_NAMES",
|
|
41
|
+
"WEIGHT_MEASUREMENT_UNIT_INFO",
|
|
42
42
|
],
|
|
43
43
|
});
|
|
44
44
|
return productResponse;
|
|
@@ -48,10 +48,10 @@ export async function loadProductServiceConfig(productSlug) {
|
|
|
48
48
|
// Use getProductBySlug directly - single API call with comprehensive fields
|
|
49
49
|
const productResponse = await loadProductBySlug(productSlug);
|
|
50
50
|
if (!productResponse.product) {
|
|
51
|
-
return { type:
|
|
51
|
+
return { type: "notFound" };
|
|
52
52
|
}
|
|
53
53
|
return {
|
|
54
|
-
type:
|
|
54
|
+
type: "success",
|
|
55
55
|
config: {
|
|
56
56
|
product: productResponse.product,
|
|
57
57
|
},
|
|
@@ -59,6 +59,6 @@ export async function loadProductServiceConfig(productSlug) {
|
|
|
59
59
|
}
|
|
60
60
|
catch (error) {
|
|
61
61
|
console.error(`Failed to load product for slug "${productSlug}":`, error);
|
|
62
|
-
return { type:
|
|
62
|
+
return { type: "notFound" };
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { type ServiceFactoryConfig } from
|
|
2
|
-
import type
|
|
3
|
-
import
|
|
1
|
+
import { type ServiceFactoryConfig } from "@wix/services-definitions";
|
|
2
|
+
import { type Signal } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
import * as productsV3 from "@wix/auto_sdk_stores_products-v-3";
|
|
4
4
|
export interface RelatedProductsServiceAPI {
|
|
5
|
-
relatedProducts: Signal<V3Product[]>;
|
|
5
|
+
relatedProducts: Signal<productsV3.V3Product[]>;
|
|
6
6
|
isLoading: Signal<boolean>;
|
|
7
7
|
error: Signal<string | null>;
|
|
8
8
|
hasRelatedProducts: Signal<boolean>;
|
|
@@ -21,5 +21,5 @@ export declare const RelatedProductsService: import("@wix/services-definitions")
|
|
|
21
21
|
} & RelatedProductsServiceAPI, {
|
|
22
22
|
productId: string;
|
|
23
23
|
limit?: number;
|
|
24
|
-
}
|
|
24
|
+
}>;
|
|
25
25
|
export declare function loadRelatedProductsServiceConfig(productId: string, limit?: number): Promise<ServiceFactoryConfig<typeof RelatedProductsService>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineService, implementService, } from
|
|
2
|
-
import { SignalsServiceDefinition } from
|
|
3
|
-
import
|
|
4
|
-
export const RelatedProductsServiceDefinition = defineService(
|
|
1
|
+
import { defineService, implementService, } from "@wix/services-definitions";
|
|
2
|
+
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
import * as productsV3 from "@wix/auto_sdk_stores_products-v-3";
|
|
4
|
+
export const RelatedProductsServiceDefinition = defineService("relatedProducts");
|
|
5
5
|
export const RelatedProductsService = implementService.withConfig()(RelatedProductsServiceDefinition, ({ getService, config }) => {
|
|
6
6
|
const signalsService = getService(SignalsServiceDefinition);
|
|
7
7
|
const relatedProducts = signalsService.signal([]);
|
|
@@ -12,13 +12,13 @@ export const RelatedProductsService = implementService.withConfig()(RelatedProdu
|
|
|
12
12
|
isLoading.set(true);
|
|
13
13
|
error.set(null);
|
|
14
14
|
try {
|
|
15
|
-
let relatedQuery = queryProducts().ne(
|
|
15
|
+
let relatedQuery = productsV3.queryProducts().ne("_id", productId);
|
|
16
16
|
const relatedResult = await relatedQuery.limit(limit).find();
|
|
17
17
|
relatedProducts.set(relatedResult.items || []);
|
|
18
18
|
hasRelatedProducts.set((relatedResult.items || []).length > 0);
|
|
19
19
|
}
|
|
20
20
|
catch (err) {
|
|
21
|
-
const errorMessage = err instanceof Error ? err.message :
|
|
21
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to load related products";
|
|
22
22
|
error.set(errorMessage);
|
|
23
23
|
relatedProducts.set([]);
|
|
24
24
|
hasRelatedProducts.set(false);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
1
|
+
import { type Signal, type ReadOnlySignal } from "@wix/services-definitions/core-services/signals";
|
|
2
|
+
import * as productsV3 from "@wix/auto_sdk_stores_products-v-3";
|
|
3
3
|
export interface SelectedVariantServiceAPI {
|
|
4
4
|
selectedQuantity: Signal<number>;
|
|
5
5
|
selectedChoices: Signal<Record<string, string>>;
|
|
6
6
|
selectedVariantId: ReadOnlySignal<string | null>;
|
|
7
|
-
currentVariant: ReadOnlySignal<Variant | null>;
|
|
7
|
+
currentVariant: ReadOnlySignal<productsV3.Variant | null>;
|
|
8
8
|
currentPrice: ReadOnlySignal<string>;
|
|
9
9
|
currentCompareAtPrice: ReadOnlySignal<string | null>;
|
|
10
10
|
isInStock: ReadOnlySignal<boolean>;
|
|
@@ -12,7 +12,7 @@ export interface SelectedVariantServiceAPI {
|
|
|
12
12
|
preOrderMessage: ReadOnlySignal<string | null>;
|
|
13
13
|
isLoading: Signal<boolean>;
|
|
14
14
|
error: Signal<string | null>;
|
|
15
|
-
variants: Signal<Variant[]>;
|
|
15
|
+
variants: Signal<productsV3.Variant[]>;
|
|
16
16
|
options: Signal<Record<string, string[]>>;
|
|
17
17
|
basePrice: Signal<number>;
|
|
18
18
|
discountPrice: Signal<number | null>;
|
|
@@ -21,10 +21,10 @@ export interface SelectedVariantServiceAPI {
|
|
|
21
21
|
trackQuantity: Signal<boolean>;
|
|
22
22
|
productId: Signal<string>;
|
|
23
23
|
ribbonLabel: Signal<string | null>;
|
|
24
|
-
product: ReadOnlySignal<V3Product | null>;
|
|
25
|
-
productOptions: ReadOnlySignal<ConnectedOption[]>;
|
|
24
|
+
product: ReadOnlySignal<productsV3.V3Product | null>;
|
|
25
|
+
productOptions: ReadOnlySignal<productsV3.ConnectedOption[]>;
|
|
26
26
|
currency: ReadOnlySignal<string>;
|
|
27
|
-
selectedVariant: () => Variant | null;
|
|
27
|
+
selectedVariant: () => productsV3.Variant | null;
|
|
28
28
|
finalPrice: () => number;
|
|
29
29
|
isLowStock: () => boolean;
|
|
30
30
|
setSelectedChoices: (choices: Record<string, string>) => void;
|
|
@@ -47,6 +47,9 @@ export interface SelectedVariantServiceAPI {
|
|
|
47
47
|
hasAnySelections: () => boolean;
|
|
48
48
|
IsAllVariantsAreOutOfStock: () => boolean;
|
|
49
49
|
}
|
|
50
|
+
export interface SelectedVariantServiceConfig {
|
|
51
|
+
fetchInventoryData?: boolean;
|
|
52
|
+
}
|
|
50
53
|
export declare const SelectedVariantServiceDefinition: string & {
|
|
51
54
|
__api: SelectedVariantServiceAPI;
|
|
52
55
|
__config: {};
|
|
@@ -56,4 +59,4 @@ export declare const SelectedVariantService: import("@wix/services-definitions")
|
|
|
56
59
|
__api: SelectedVariantServiceAPI;
|
|
57
60
|
__config: {};
|
|
58
61
|
isServiceDefinition?: boolean;
|
|
59
|
-
} & SelectedVariantServiceAPI,
|
|
62
|
+
} & SelectedVariantServiceAPI, SelectedVariantServiceConfig>;
|