@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,49 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const catalog_options_service_1 = require("./catalog-options-service");
|
|
9
|
-
exports.FilterServiceDefinition = (0, services_definitions_1.defineService)('filtered-collection');
|
|
10
|
-
exports.defaultFilter = {
|
|
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
|
+
export const defaultFilter = {
|
|
11
8
|
priceRange: { min: 0, max: 0 },
|
|
12
9
|
selectedOptions: {},
|
|
13
10
|
};
|
|
14
|
-
|
|
15
|
-
const signalsService = getService(
|
|
16
|
-
const catalogPriceRangeService = getService(
|
|
17
|
-
const catalogOptionsService = getService(
|
|
18
|
-
const currentFilters = signalsService.signal((config
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
export const FilterService = implementService.withConfig()(FilterServiceDefinition, ({ getService, config }) => {
|
|
12
|
+
const signalsService = getService(SignalsServiceDefinition);
|
|
13
|
+
const catalogPriceRangeService = getService(CatalogPriceRangeServiceDefinition);
|
|
14
|
+
const catalogOptionsService = getService(CatalogOptionsServiceDefinition);
|
|
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
|
+
};
|
|
22
29
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const checkIfFullyLoaded = () => {
|
|
30
|
+
// Use computed signal for isFullyLoaded to automatically track dependencies
|
|
31
|
+
const isFullyLoaded = signalsService.computed(() => {
|
|
26
32
|
const catalogPriceRange = catalogPriceRangeService.catalogPriceRange.get();
|
|
27
33
|
const catalogOptions = catalogOptionsService.catalogOptions.get();
|
|
28
34
|
// Price range data is considered loaded whether it's null (no prices) or has valid data
|
|
29
35
|
const hasPriceRangeData = catalogPriceRange !== undefined; // includes null case
|
|
30
36
|
const hasOptionsData = !!(catalogOptions && catalogOptions.length >= 0); // Even 0 options is valid
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
//
|
|
34
|
-
|
|
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();
|
|
35
42
|
if (catalogPriceRange &&
|
|
36
43
|
catalogPriceRange.minPrice < catalogPriceRange.maxPrice) {
|
|
37
44
|
const priceRange = {
|
|
38
45
|
min: catalogPriceRange.minPrice,
|
|
39
46
|
max: catalogPriceRange.maxPrice,
|
|
40
47
|
};
|
|
41
|
-
// Update available options with catalog price range
|
|
42
|
-
const currentAvailableOptions = availableOptions.get();
|
|
43
|
-
availableOptions.set({
|
|
44
|
-
...currentAvailableOptions,
|
|
45
|
-
priceRange,
|
|
46
|
-
});
|
|
47
48
|
// Update current filters to use catalog price range
|
|
48
49
|
const currentFiltersValue = currentFilters.get();
|
|
49
50
|
// Only update if current filter range is at defaults (either 0-0 or 0-1000)
|
|
@@ -58,21 +59,6 @@ exports.FilterService = services_definitions_1.implementService.withConfig()(exp
|
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
// Check if fully loaded after price range update
|
|
62
|
-
checkIfFullyLoaded();
|
|
63
|
-
});
|
|
64
|
-
// Subscribe to catalog options changes and automatically update our signals
|
|
65
|
-
catalogOptionsService.catalogOptions.subscribe(catalogOptions => {
|
|
66
|
-
if (catalogOptions && catalogOptions.length > 0) {
|
|
67
|
-
// Update available options with catalog options
|
|
68
|
-
const currentAvailableOptions = availableOptions.get();
|
|
69
|
-
availableOptions.set({
|
|
70
|
-
...currentAvailableOptions,
|
|
71
|
-
productOptions: catalogOptions,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
// Check if fully loaded after options update
|
|
75
|
-
checkIfFullyLoaded();
|
|
76
62
|
});
|
|
77
63
|
// Apply filters by delegating to the collection service
|
|
78
64
|
const applyFilters = async (filters) => {
|
|
@@ -83,47 +69,47 @@ exports.FilterService = services_definitions_1.implementService.withConfig()(exp
|
|
|
83
69
|
// Add price filters if different from defaults
|
|
84
70
|
if (availableOpts?.priceRange) {
|
|
85
71
|
if (filters.priceRange.min > availableOpts.priceRange.min) {
|
|
86
|
-
urlParams[
|
|
72
|
+
urlParams["minPrice"] = filters.priceRange.min.toString();
|
|
87
73
|
}
|
|
88
74
|
if (filters.priceRange.max < availableOpts.priceRange.max) {
|
|
89
|
-
urlParams[
|
|
75
|
+
urlParams["maxPrice"] = filters.priceRange.max.toString();
|
|
90
76
|
}
|
|
91
77
|
}
|
|
92
78
|
// Add option filters using option names as keys
|
|
93
79
|
if (availableOpts?.productOptions) {
|
|
94
80
|
Object.entries(filters.selectedOptions).forEach(([optionId, choiceIds]) => {
|
|
95
|
-
const option = availableOpts.productOptions.find(opt => opt.id === optionId);
|
|
81
|
+
const option = availableOpts.productOptions.find((opt) => opt.id === optionId);
|
|
96
82
|
if (option && choiceIds.length > 0) {
|
|
97
|
-
const selectedChoices = option.choices.filter(choice => choiceIds.includes(choice.id));
|
|
83
|
+
const selectedChoices = option.choices.filter((choice) => choiceIds.includes(choice.id));
|
|
98
84
|
if (selectedChoices.length > 0) {
|
|
99
85
|
// Use 'availability' as URL param for inventory filter
|
|
100
|
-
const paramName = optionId ===
|
|
101
|
-
urlParams[paramName] = selectedChoices.map(choice => choice.name);
|
|
86
|
+
const paramName = optionId === "inventory-filter" ? "availability" : option.name;
|
|
87
|
+
urlParams[paramName] = selectedChoices.map((choice) => choice.name);
|
|
102
88
|
}
|
|
103
89
|
}
|
|
104
90
|
});
|
|
105
91
|
}
|
|
106
92
|
// Preserve existing sort parameter
|
|
107
|
-
const currentParams =
|
|
108
|
-
if (currentParams[
|
|
109
|
-
urlParams[
|
|
93
|
+
const currentParams = URLParamsUtils.getURLParams();
|
|
94
|
+
if (currentParams["sort"]) {
|
|
95
|
+
urlParams["sort"] = currentParams["sort"];
|
|
110
96
|
}
|
|
111
|
-
|
|
97
|
+
URLParamsUtils.updateURL(urlParams);
|
|
112
98
|
};
|
|
113
99
|
// Clear all filters by applying default filter state
|
|
114
100
|
const clearFilters = async () => {
|
|
115
101
|
const availablePriceRange = availableOptions.get()?.priceRange;
|
|
116
102
|
currentFilters.set({
|
|
117
|
-
...
|
|
103
|
+
...defaultFilter,
|
|
118
104
|
priceRange: availablePriceRange || { min: 0, max: 0 },
|
|
119
105
|
});
|
|
120
106
|
// Clear filter parameters from URL, keeping only sort parameter
|
|
121
|
-
const currentParams =
|
|
107
|
+
const currentParams = URLParamsUtils.getURLParams();
|
|
122
108
|
const urlParams = {};
|
|
123
|
-
if (currentParams[
|
|
124
|
-
urlParams[
|
|
109
|
+
if (currentParams["sort"]) {
|
|
110
|
+
urlParams["sort"] = currentParams["sort"];
|
|
125
111
|
}
|
|
126
|
-
|
|
112
|
+
URLParamsUtils.updateURL(urlParams);
|
|
127
113
|
};
|
|
128
114
|
// Note: calculateAvailableOptions was removed as it's no longer needed
|
|
129
115
|
// Options are now loaded from the catalog-wide service via loadCatalogOptions
|
|
@@ -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,9 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
exports.PayNowServiceDefinition = (0, services_definitions_1.defineService)("PayNow");
|
|
7
|
-
exports.PayNowServiceImplementation = services_definitions_1.implementService.withConfig()(exports.PayNowServiceDefinition, ({ getService, config }) => {
|
|
8
|
-
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
1
|
+
import { defineService, implementService, } from "@wix/services-definitions";
|
|
2
|
+
import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
|
|
3
|
+
export const PayNowServiceDefinition = defineService("PayNow");
|
|
4
|
+
export const PayNowServiceImplementation = implementService.withConfig()(PayNowServiceDefinition, ({ getService, config }) => {
|
|
5
|
+
const signalsService = getService(SignalsServiceDefinition);
|
|
9
6
|
const loadingSignal = signalsService.signal(false);
|
|
10
7
|
const errorSignal = signalsService.signal(null);
|
|
11
8
|
return {
|
|
@@ -31,20 +28,18 @@ exports.PayNowServiceImplementation = services_definitions_1.implementService.wi
|
|
|
31
28
|
errorSignal,
|
|
32
29
|
};
|
|
33
30
|
});
|
|
34
|
-
const loadPayNowServiceInitialData = async () => {
|
|
31
|
+
export const loadPayNowServiceInitialData = async () => {
|
|
35
32
|
return {
|
|
36
|
-
[
|
|
33
|
+
[PayNowServiceDefinition]: {},
|
|
37
34
|
};
|
|
38
35
|
};
|
|
39
|
-
|
|
40
|
-
const payNowServiceBinding = (servicesConfigs, additionalConfig = {}) => {
|
|
36
|
+
export const payNowServiceBinding = (servicesConfigs, additionalConfig = {}) => {
|
|
41
37
|
return [
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
PayNowServiceDefinition,
|
|
39
|
+
PayNowServiceImplementation,
|
|
44
40
|
{
|
|
45
|
-
...servicesConfigs[
|
|
41
|
+
...servicesConfigs[PayNowServiceDefinition],
|
|
46
42
|
...additionalConfig,
|
|
47
43
|
},
|
|
48
44
|
];
|
|
49
45
|
};
|
|
50
|
-
exports.payNowServiceBinding = payNowServiceBinding;
|
|
@@ -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,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
exports.ProductModifiersServiceDefinition = (0, services_definitions_1.defineService)('productModifiers');
|
|
10
|
-
exports.ProductModifiersService = services_definitions_1.implementService.withConfig()(exports.ProductModifiersServiceDefinition, ({ getService }) => {
|
|
11
|
-
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
12
|
-
const productService = getService(product_service_1.ProductServiceDefinition);
|
|
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
|
+
export const ProductModifiersService = implementService.withConfig()(ProductModifiersServiceDefinition, ({ getService }) => {
|
|
7
|
+
const signalsService = getService(SignalsServiceDefinition);
|
|
8
|
+
const productService = getService(ProductServiceDefinition);
|
|
13
9
|
const selectedModifiers = signalsService.signal({});
|
|
14
10
|
const isLoading = signalsService.signal(false);
|
|
15
11
|
const error = signalsService.signal(null);
|
|
@@ -57,33 +53,33 @@ exports.ProductModifiersService = services_definitions_1.implementService.withCo
|
|
|
57
53
|
};
|
|
58
54
|
const isModifierRequired = (modifierName) => {
|
|
59
55
|
const mods = modifiers.get();
|
|
60
|
-
const modifier = mods.find(m => m.name === modifierName);
|
|
56
|
+
const modifier = mods.find((m) => m.name === modifierName);
|
|
61
57
|
return modifier?.mandatory || false;
|
|
62
58
|
};
|
|
63
59
|
const hasRequiredModifiers = () => {
|
|
64
60
|
const mods = modifiers.get();
|
|
65
|
-
return mods.some(m => m.mandatory);
|
|
61
|
+
return mods.some((m) => m.mandatory);
|
|
66
62
|
};
|
|
67
63
|
const areAllRequiredModifiersFilled = () => {
|
|
68
64
|
const mods = modifiers.get();
|
|
69
65
|
const current = selectedModifiers.get();
|
|
70
|
-
return mods.every(modifier => {
|
|
66
|
+
return mods.every((modifier) => {
|
|
71
67
|
if (!modifier.mandatory)
|
|
72
68
|
return true;
|
|
73
|
-
const selectedValue = current[modifier.name ||
|
|
69
|
+
const selectedValue = current[modifier.name || ""];
|
|
74
70
|
if (!selectedValue)
|
|
75
71
|
return false;
|
|
76
72
|
// Check based on modifier type
|
|
77
73
|
const renderType = modifier.modifierRenderType;
|
|
78
74
|
if (!renderType)
|
|
79
75
|
return false;
|
|
80
|
-
if (renderType ===
|
|
81
|
-
renderType ===
|
|
76
|
+
if (renderType === productsV3.ModifierRenderType.SWATCH_CHOICES ||
|
|
77
|
+
renderType === productsV3.ModifierRenderType.TEXT_CHOICES) {
|
|
82
78
|
return !!selectedValue.choiceValue;
|
|
83
79
|
}
|
|
84
|
-
else if (renderType ===
|
|
80
|
+
else if (renderType === productsV3.ModifierRenderType.FREE_TEXT) {
|
|
85
81
|
return (!!selectedValue.freeTextValue &&
|
|
86
|
-
selectedValue.freeTextValue.trim() !==
|
|
82
|
+
selectedValue.freeTextValue.trim() !== "");
|
|
87
83
|
}
|
|
88
84
|
return false;
|
|
89
85
|
});
|
|
@@ -104,7 +100,7 @@ exports.ProductModifiersService = services_definitions_1.implementService.withCo
|
|
|
104
100
|
areAllRequiredModifiersFilled,
|
|
105
101
|
};
|
|
106
102
|
});
|
|
107
|
-
function createProductModifiersServiceConfig(product) {
|
|
103
|
+
export function createProductModifiersServiceConfig(product) {
|
|
108
104
|
return {
|
|
109
105
|
product,
|
|
110
106
|
};
|
|
@@ -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,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
8
|
-
exports.ProductServiceDefinition = (0, services_definitions_1.defineService)('product');
|
|
9
|
-
exports.ProductService = services_definitions_1.implementService.withConfig()(exports.ProductServiceDefinition, ({ getService, config }) => {
|
|
10
|
-
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
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
|
+
export const ProductService = implementService.withConfig()(ProductServiceDefinition, ({ getService, config }) => {
|
|
6
|
+
const signalsService = getService(SignalsServiceDefinition);
|
|
11
7
|
const product = signalsService.signal(config.product);
|
|
12
8
|
const isLoading = signalsService.signal(false);
|
|
13
9
|
const error = signalsService.signal(null);
|
|
@@ -15,7 +11,7 @@ exports.ProductService = services_definitions_1.implementService.withConfig()(ex
|
|
|
15
11
|
isLoading.set(true);
|
|
16
12
|
const productResponse = await loadProductBySlug(slug);
|
|
17
13
|
if (!productResponse.product) {
|
|
18
|
-
error.set(
|
|
14
|
+
error.set("Product not found");
|
|
19
15
|
}
|
|
20
16
|
else {
|
|
21
17
|
product.set(productResponse.product);
|
|
@@ -31,31 +27,31 @@ exports.ProductService = services_definitions_1.implementService.withConfig()(ex
|
|
|
31
27
|
};
|
|
32
28
|
});
|
|
33
29
|
const loadProductBySlug = async (slug) => {
|
|
34
|
-
const productResponse = await
|
|
30
|
+
const productResponse = await productsV3.getProductBySlug(slug, {
|
|
35
31
|
fields: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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",
|
|
46
42
|
],
|
|
47
43
|
});
|
|
48
44
|
return productResponse;
|
|
49
45
|
};
|
|
50
|
-
async function loadProductServiceConfig(productSlug) {
|
|
46
|
+
export async function loadProductServiceConfig(productSlug) {
|
|
51
47
|
try {
|
|
52
48
|
// Use getProductBySlug directly - single API call with comprehensive fields
|
|
53
49
|
const productResponse = await loadProductBySlug(productSlug);
|
|
54
50
|
if (!productResponse.product) {
|
|
55
|
-
return { type:
|
|
51
|
+
return { type: "notFound" };
|
|
56
52
|
}
|
|
57
53
|
return {
|
|
58
|
-
type:
|
|
54
|
+
type: "success",
|
|
59
55
|
config: {
|
|
60
56
|
product: productResponse.product,
|
|
61
57
|
},
|
|
@@ -63,6 +59,6 @@ async function loadProductServiceConfig(productSlug) {
|
|
|
63
59
|
}
|
|
64
60
|
catch (error) {
|
|
65
61
|
console.error(`Failed to load product for slug "${productSlug}":`, error);
|
|
66
|
-
return { type:
|
|
62
|
+
return { type: "notFound" };
|
|
67
63
|
}
|
|
68
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,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
|
|
8
|
-
exports.RelatedProductsServiceDefinition = (0, services_definitions_1.defineService)('relatedProducts');
|
|
9
|
-
exports.RelatedProductsService = services_definitions_1.implementService.withConfig()(exports.RelatedProductsServiceDefinition, ({ getService, config }) => {
|
|
10
|
-
const signalsService = getService(signals_1.SignalsServiceDefinition);
|
|
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
|
+
export const RelatedProductsService = implementService.withConfig()(RelatedProductsServiceDefinition, ({ getService, config }) => {
|
|
6
|
+
const signalsService = getService(SignalsServiceDefinition);
|
|
11
7
|
const relatedProducts = signalsService.signal([]);
|
|
12
8
|
const isLoading = signalsService.signal(false);
|
|
13
9
|
const error = signalsService.signal(null);
|
|
@@ -16,13 +12,13 @@ exports.RelatedProductsService = services_definitions_1.implementService.withCon
|
|
|
16
12
|
isLoading.set(true);
|
|
17
13
|
error.set(null);
|
|
18
14
|
try {
|
|
19
|
-
let relatedQuery =
|
|
15
|
+
let relatedQuery = productsV3.queryProducts().ne("_id", productId);
|
|
20
16
|
const relatedResult = await relatedQuery.limit(limit).find();
|
|
21
17
|
relatedProducts.set(relatedResult.items || []);
|
|
22
18
|
hasRelatedProducts.set((relatedResult.items || []).length > 0);
|
|
23
19
|
}
|
|
24
20
|
catch (err) {
|
|
25
|
-
const errorMessage = err instanceof Error ? err.message :
|
|
21
|
+
const errorMessage = err instanceof Error ? err.message : "Failed to load related products";
|
|
26
22
|
error.set(errorMessage);
|
|
27
23
|
relatedProducts.set([]);
|
|
28
24
|
hasRelatedProducts.set(false);
|
|
@@ -46,7 +42,7 @@ exports.RelatedProductsService = services_definitions_1.implementService.withCon
|
|
|
46
42
|
refreshRelatedProducts,
|
|
47
43
|
};
|
|
48
44
|
});
|
|
49
|
-
async function loadRelatedProductsServiceConfig(productId, limit = 4) {
|
|
45
|
+
export async function loadRelatedProductsServiceConfig(productId, limit = 4) {
|
|
50
46
|
return {
|
|
51
47
|
productId,
|
|
52
48
|
limit,
|
|
@@ -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>;
|