@wix/headless-stores 0.0.12 → 0.0.15

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.
Files changed (131) hide show
  1. package/cjs/dist/astro/actions/custom-checkout.d.ts +4 -2
  2. package/cjs/dist/astro/actions/custom-checkout.js +4 -8
  3. package/cjs/dist/astro/actions/index.d.ts +1 -1
  4. package/cjs/dist/astro/actions/index.js +1 -17
  5. package/cjs/dist/enums/index.d.ts +2 -2
  6. package/cjs/dist/enums/index.js +2 -18
  7. package/cjs/dist/enums/social-platform-enums.js +4 -7
  8. package/cjs/dist/enums/sort-enums.js +3 -6
  9. package/cjs/dist/react/BuyNow.js +6 -11
  10. package/cjs/dist/react/Category.d.ts +2 -2
  11. package/cjs/dist/react/Category.js +6 -10
  12. package/cjs/dist/react/Collection.d.ts +1 -1
  13. package/cjs/dist/react/Collection.js +31 -39
  14. package/cjs/dist/react/FilteredCollection.d.ts +6 -20
  15. package/cjs/dist/react/FilteredCollection.js +29 -57
  16. package/cjs/dist/react/PayNow.js +4 -9
  17. package/cjs/dist/react/Product.d.ts +3 -3
  18. package/cjs/dist/react/Product.js +6 -11
  19. package/cjs/dist/react/ProductActions.js +12 -17
  20. package/cjs/dist/react/ProductModifiers.d.ts +3 -1
  21. package/cjs/dist/react/ProductModifiers.js +23 -29
  22. package/cjs/dist/react/ProductVariantSelector.d.ts +1 -1
  23. package/cjs/dist/react/ProductVariantSelector.js +18 -28
  24. package/cjs/dist/react/RelatedProducts.d.ts +2 -2
  25. package/cjs/dist/react/RelatedProducts.js +35 -33
  26. package/cjs/dist/react/SelectedVariant.js +8 -14
  27. package/cjs/dist/react/SocialSharing.d.ts +2 -3
  28. package/cjs/dist/react/SocialSharing.js +35 -33
  29. package/cjs/dist/react/Sort.d.ts +4 -3
  30. package/cjs/dist/react/Sort.js +6 -10
  31. package/cjs/dist/react/index.d.ts +13 -13
  32. package/cjs/dist/react/index.js +13 -52
  33. package/cjs/dist/server-actions/custom-checkout-action.js +8 -11
  34. package/cjs/dist/server-actions/index.d.ts +1 -1
  35. package/cjs/dist/server-actions/index.js +1 -17
  36. package/cjs/dist/services/buy-now-service.d.ts +44 -3
  37. package/cjs/dist/services/buy-now-service.js +20 -22
  38. package/cjs/dist/services/catalog-options-service.d.ts +3 -3
  39. package/cjs/dist/services/catalog-options-service.js +45 -46
  40. package/cjs/dist/services/catalog-price-range-service.d.ts +3 -3
  41. package/cjs/dist/services/catalog-price-range-service.js +21 -25
  42. package/cjs/dist/services/category-service.d.ts +7 -7
  43. package/cjs/dist/services/category-service.js +20 -22
  44. package/cjs/dist/services/collection-service.d.ts +8 -8
  45. package/cjs/dist/services/collection-service.js +102 -133
  46. package/cjs/dist/services/filter-service.d.ts +4 -4
  47. package/cjs/dist/services/filter-service.js +47 -61
  48. package/cjs/dist/services/index.d.ts +13 -2
  49. package/cjs/dist/services/index.js +13 -9
  50. package/cjs/dist/services/pay-now-service.d.ts +4 -3
  51. package/cjs/dist/services/pay-now-service.js +11 -16
  52. package/cjs/dist/services/product-modifiers-service.d.ts +6 -6
  53. package/cjs/dist/services/product-modifiers-service.js +17 -21
  54. package/cjs/dist/services/product-service.d.ts +8 -8
  55. package/cjs/dist/services/product-service.js +22 -26
  56. package/cjs/dist/services/related-products-service.d.ts +5 -5
  57. package/cjs/dist/services/related-products-service.js +9 -13
  58. package/cjs/dist/services/selected-variant-service.d.ts +11 -8
  59. package/cjs/dist/services/selected-variant-service.js +73 -90
  60. package/cjs/dist/services/social-sharing-service.d.ts +2 -9
  61. package/cjs/dist/services/social-sharing-service.js +48 -60
  62. package/cjs/dist/services/sort-service.d.ts +3 -3
  63. package/cjs/dist/services/sort-service.js +14 -19
  64. package/cjs/dist/utils/index.js +6 -9
  65. package/cjs/dist/utils/url-params.js +5 -9
  66. package/dist/astro/actions/custom-checkout.d.ts +1 -1
  67. package/dist/astro/actions/custom-checkout.js +1 -1
  68. package/dist/astro/actions/index.d.ts +1 -1
  69. package/dist/astro/actions/index.js +1 -1
  70. package/dist/enums/index.d.ts +2 -2
  71. package/dist/enums/index.js +2 -2
  72. package/dist/react/BuyNow.js +4 -6
  73. package/dist/react/Category.d.ts +2 -2
  74. package/dist/react/Category.js +2 -2
  75. package/dist/react/Collection.d.ts +1 -1
  76. package/dist/react/Collection.js +20 -20
  77. package/dist/react/FilteredCollection.d.ts +6 -20
  78. package/dist/react/FilteredCollection.js +17 -35
  79. package/dist/react/PayNow.js +2 -4
  80. package/dist/react/Product.d.ts +3 -3
  81. package/dist/react/Product.js +2 -2
  82. package/dist/react/ProductActions.js +9 -10
  83. package/dist/react/ProductModifiers.d.ts +3 -1
  84. package/dist/react/ProductModifiers.js +14 -12
  85. package/dist/react/ProductVariantSelector.d.ts +1 -1
  86. package/dist/react/ProductVariantSelector.js +6 -8
  87. package/dist/react/RelatedProducts.d.ts +2 -2
  88. package/dist/react/RelatedProducts.js +25 -15
  89. package/dist/react/SelectedVariant.js +2 -2
  90. package/dist/react/SocialSharing.d.ts +2 -3
  91. package/dist/react/SocialSharing.js +24 -13
  92. package/dist/react/Sort.d.ts +4 -3
  93. package/dist/react/Sort.js +3 -4
  94. package/dist/react/index.d.ts +13 -13
  95. package/dist/react/index.js +13 -13
  96. package/dist/server-actions/index.d.ts +1 -1
  97. package/dist/server-actions/index.js +1 -1
  98. package/dist/services/buy-now-service.d.ts +44 -3
  99. package/dist/services/buy-now-service.js +7 -4
  100. package/dist/services/catalog-options-service.d.ts +3 -3
  101. package/dist/services/catalog-options-service.js +33 -30
  102. package/dist/services/catalog-price-range-service.d.ts +3 -3
  103. package/dist/services/catalog-price-range-service.js +18 -18
  104. package/dist/services/category-service.d.ts +7 -7
  105. package/dist/services/category-service.js +17 -15
  106. package/dist/services/collection-service.d.ts +8 -8
  107. package/dist/services/collection-service.js +80 -74
  108. package/dist/services/filter-service.d.ts +4 -4
  109. package/dist/services/filter-service.js +37 -48
  110. package/dist/services/index.d.ts +13 -2
  111. package/dist/services/index.js +13 -2
  112. package/dist/services/pay-now-service.d.ts +4 -3
  113. package/dist/services/pay-now-service.js +1 -1
  114. package/dist/services/product-modifiers-service.d.ts +6 -6
  115. package/dist/services/product-modifiers-service.js +13 -13
  116. package/dist/services/product-service.d.ts +8 -8
  117. package/dist/services/product-service.js +19 -19
  118. package/dist/services/related-products-service.d.ts +5 -5
  119. package/dist/services/related-products-service.js +6 -6
  120. package/dist/services/selected-variant-service.d.ts +11 -8
  121. package/dist/services/selected-variant-service.js +71 -85
  122. package/dist/services/social-sharing-service.d.ts +2 -9
  123. package/dist/services/social-sharing-service.js +29 -37
  124. package/dist/services/sort-service.d.ts +3 -3
  125. package/dist/services/sort-service.js +8 -10
  126. package/dist/utils/url-params.js +4 -4
  127. package/package.json +6 -5
  128. package/cjs/dist/services/product-media-gallery-service.d.ts +0 -25
  129. package/cjs/dist/services/product-media-gallery-service.js +0 -105
  130. package/dist/services/product-media-gallery-service.d.ts +0 -25
  131. package/dist/services/product-media-gallery-service.js +0 -101
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatalogOptionsService = exports.CatalogOptionsServiceDefinition = void 0;
4
- exports.loadCatalogOptionsServiceConfig = loadCatalogOptionsServiceConfig;
5
- const services_definitions_1 = require("@wix/services-definitions");
6
- const signals_1 = require("@wix/services-definitions/core-services/signals");
7
- const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
8
- const auto_sdk_stores_customizations_v_3_1 = require("@wix/auto_sdk_stores_customizations-v-3");
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 * as customizationsV3 from "@wix/auto_sdk_stores_customizations-v-3";
5
+ const { SortDirection, SortType: SDKSortType } = productsV3;
9
6
  // Helper functions
10
7
  const extractAggregationValues = (aggregationResponse, name) => {
11
8
  const aggregation = aggregationResponse.aggregations?.[name] ||
@@ -13,7 +10,7 @@ const extractAggregationValues = (aggregationResponse, name) => {
13
10
  return aggregation?.values?.results?.map((item) => item.value) || [];
14
11
  };
15
12
  const matchesAggregationName = (name, aggregationNames) => {
16
- return aggregationNames.some(aggName => aggName.toLowerCase() === name.toLowerCase());
13
+ return aggregationNames.some((aggName) => aggName.toLowerCase() === name.toLowerCase());
17
14
  };
18
15
  const sortChoicesIntelligently = (choices) => {
19
16
  return [...choices].sort((a, b) => {
@@ -35,14 +32,14 @@ const buildCategoryFilter = (categoryId) => {
35
32
  }
36
33
  return {
37
34
  visible: true,
38
- 'allCategoriesInfo.categories': {
35
+ "allCategoriesInfo.categories": {
39
36
  $matchItems: [{ _id: { $in: [categoryId] } }],
40
37
  },
41
38
  };
42
39
  };
43
- exports.CatalogOptionsServiceDefinition = (0, services_definitions_1.defineService)('catalogOptions');
44
- exports.CatalogOptionsService = services_definitions_1.implementService.withConfig()(exports.CatalogOptionsServiceDefinition, ({ getService }) => {
45
- const signalsService = getService(signals_1.SignalsServiceDefinition);
40
+ export const CatalogOptionsServiceDefinition = defineService("catalogOptions");
41
+ export const CatalogOptionsService = implementService.withConfig()(CatalogOptionsServiceDefinition, ({ getService }) => {
42
+ const signalsService = getService(SignalsServiceDefinition);
46
43
  const catalogOptions = signalsService.signal(null);
47
44
  const isLoading = signalsService.signal(false);
48
45
  const error = signalsService.signal(null);
@@ -54,33 +51,33 @@ exports.CatalogOptionsService = services_definitions_1.implementService.withConf
54
51
  const aggregationRequest = {
55
52
  aggregations: [
56
53
  {
57
- name: 'optionNames',
58
- fieldPath: 'options.name',
59
- type: auto_sdk_stores_products_v_3_1.SortType.VALUE,
54
+ name: "optionNames",
55
+ fieldPath: "options.name",
56
+ type: SDKSortType.VALUE,
60
57
  value: {
61
58
  limit: 20,
62
- sortType: auto_sdk_stores_products_v_3_1.SortType.VALUE,
63
- sortDirection: auto_sdk_stores_products_v_3_1.SortDirection.ASC,
59
+ sortType: SDKSortType.VALUE,
60
+ sortDirection: SortDirection.ASC,
64
61
  },
65
62
  },
66
63
  {
67
- name: 'choiceNames',
68
- fieldPath: 'options.choicesSettings.choices.name',
69
- type: auto_sdk_stores_products_v_3_1.SortType.VALUE,
64
+ name: "choiceNames",
65
+ fieldPath: "options.choicesSettings.choices.name",
66
+ type: SDKSortType.VALUE,
70
67
  value: {
71
68
  limit: 50,
72
- sortType: auto_sdk_stores_products_v_3_1.SortType.VALUE,
73
- sortDirection: auto_sdk_stores_products_v_3_1.SortDirection.ASC,
69
+ sortType: SDKSortType.VALUE,
70
+ sortDirection: SortDirection.ASC,
74
71
  },
75
72
  },
76
73
  {
77
- name: 'inventoryStatus',
78
- fieldPath: 'inventory.availabilityStatus',
79
- type: auto_sdk_stores_products_v_3_1.SortType.VALUE,
74
+ name: "inventoryStatus",
75
+ fieldPath: "inventory.availabilityStatus",
76
+ type: SDKSortType.VALUE,
80
77
  value: {
81
78
  limit: 10,
82
- sortType: auto_sdk_stores_products_v_3_1.SortType.VALUE,
83
- sortDirection: auto_sdk_stores_products_v_3_1.SortDirection.ASC,
79
+ sortType: SDKSortType.VALUE,
80
+ sortDirection: SortDirection.ASC,
84
81
  },
85
82
  },
86
83
  ],
@@ -88,26 +85,28 @@ exports.CatalogOptionsService = services_definitions_1.implementService.withConf
88
85
  includeProducts: false,
89
86
  cursorPaging: { limit: 0 },
90
87
  };
91
- const aggregationResponse = await (0, auto_sdk_stores_products_v_3_1.searchProducts)(aggregationRequest);
92
- const optionNames = extractAggregationValues(aggregationResponse, 'optionNames');
93
- const choiceNames = extractAggregationValues(aggregationResponse, 'choiceNames');
94
- const inventoryStatuses = extractAggregationValues(aggregationResponse, 'inventoryStatus');
88
+ const aggregationResponse = await productsV3.searchProducts(aggregationRequest);
89
+ const optionNames = extractAggregationValues(aggregationResponse, "optionNames");
90
+ const choiceNames = extractAggregationValues(aggregationResponse, "choiceNames");
91
+ const inventoryStatuses = extractAggregationValues(aggregationResponse, "inventoryStatus");
95
92
  // Step 2: Get option structure from customizations API
96
- const customizationsResponse = await (0, auto_sdk_stores_customizations_v_3_1.queryCustomizations)().find();
93
+ const customizationsResponse = await customizationsV3
94
+ .queryCustomizations()
95
+ .find();
97
96
  const customizations = customizationsResponse.items || [];
98
97
  // Step 3: Build options by matching customizations with aggregation data
99
98
  const options = customizations
100
- .filter(customization => customization.name &&
99
+ .filter((customization) => customization.name &&
101
100
  customization._id &&
102
101
  customization.customizationType ===
103
- auto_sdk_stores_customizations_v_3_1.CustomizationType.PRODUCT_OPTION &&
102
+ customizationsV3.CustomizationType.PRODUCT_OPTION &&
104
103
  matchesAggregationName(customization.name, optionNames))
105
- .map(customization => {
104
+ .map((customization) => {
106
105
  const choices = (customization.choicesSettings?.choices || [])
107
- .filter(choice => choice._id &&
106
+ .filter((choice) => choice._id &&
108
107
  choice.name &&
109
108
  matchesAggregationName(choice.name, choiceNames))
110
- .map(choice => ({
109
+ .map((choice) => ({
111
110
  id: choice._id,
112
111
  name: choice.name,
113
112
  colorCode: choice.colorCode,
@@ -119,25 +118,25 @@ exports.CatalogOptionsService = services_definitions_1.implementService.withConf
119
118
  optionRenderType: customization.customizationRenderType,
120
119
  };
121
120
  })
122
- .filter(option => option.choices.length > 0);
121
+ .filter((option) => option.choices.length > 0);
123
122
  // Step 4: Add inventory filter if there are multiple inventory statuses
124
123
  if (inventoryStatuses.length > 1) {
125
- const inventoryChoices = inventoryStatuses.map(status => ({
124
+ const inventoryChoices = inventoryStatuses.map((status) => ({
126
125
  id: status.toUpperCase(), // Use uppercase to match actual availabilityStatus values
127
126
  name: status.toUpperCase(), // Use raw status value - UI components will handle display conversion
128
127
  }));
129
128
  options.push({
130
- id: 'inventory-filter',
131
- name: 'Availability',
129
+ id: "inventory-filter",
130
+ name: "Availability",
132
131
  choices: inventoryChoices,
133
- optionRenderType: auto_sdk_stores_products_v_3_1.ModifierRenderType.TEXT_CHOICES,
132
+ optionRenderType: productsV3.ModifierRenderType.TEXT_CHOICES,
134
133
  });
135
134
  }
136
135
  catalogOptions.set(options);
137
136
  }
138
137
  catch (err) {
139
- console.error('Failed to load catalog options:', err);
140
- error.set(err instanceof Error ? err.message : 'Failed to load catalog options');
138
+ console.error("Failed to load catalog options:", err);
139
+ error.set(err instanceof Error ? err.message : "Failed to load catalog options");
141
140
  catalogOptions.set([]);
142
141
  }
143
142
  finally {
@@ -151,6 +150,6 @@ exports.CatalogOptionsService = services_definitions_1.implementService.withConf
151
150
  loadCatalogOptions,
152
151
  };
153
152
  });
154
- async function loadCatalogOptionsServiceConfig() {
153
+ export async function loadCatalogOptionsServiceConfig() {
155
154
  return {};
156
155
  }
@@ -1,5 +1,5 @@
1
- import { type ServiceFactoryConfig } from '@wix/services-definitions';
2
- import type { Signal } from '../../Signal';
1
+ import { type ServiceFactoryConfig } from "@wix/services-definitions";
2
+ import { type Signal } from "@wix/services-definitions/core-services/signals";
3
3
  export interface CatalogPriceRange {
4
4
  minPrice: number;
5
5
  maxPrice: number;
@@ -19,5 +19,5 @@ export declare const CatalogPriceRangeService: import("@wix/services-definitions
19
19
  __api: CatalogPriceRangeServiceAPI;
20
20
  __config: {};
21
21
  isServiceDefinition?: boolean;
22
- } & CatalogPriceRangeServiceAPI, {}, import("@wix/services-definitions").ThreadMode.MAIN>;
22
+ } & CatalogPriceRangeServiceAPI, {}>;
23
23
  export declare function loadCatalogPriceRangeServiceConfig(): Promise<ServiceFactoryConfig<typeof CatalogPriceRangeService>>;
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CatalogPriceRangeService = exports.CatalogPriceRangeServiceDefinition = void 0;
4
- exports.loadCatalogPriceRangeServiceConfig = loadCatalogPriceRangeServiceConfig;
5
- const services_definitions_1 = require("@wix/services-definitions");
6
- const signals_1 = require("@wix/services-definitions/core-services/signals");
7
- const auto_sdk_stores_products_v_3_1 = require("@wix/auto_sdk_stores_products-v-3");
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";
8
4
  // Helper function to extract scalar aggregation values
9
5
  const extractScalarAggregationValue = (aggregationResponse, name) => {
10
6
  const aggregation = aggregationResponse.aggregations?.[name] ||
@@ -18,14 +14,14 @@ const buildCategoryFilter = (categoryId) => {
18
14
  }
19
15
  return {
20
16
  visible: true,
21
- 'allCategoriesInfo.categories': {
17
+ "allCategoriesInfo.categories": {
22
18
  $matchItems: [{ _id: { $in: [categoryId] } }],
23
19
  },
24
20
  };
25
21
  };
26
- exports.CatalogPriceRangeServiceDefinition = (0, services_definitions_1.defineService)('catalogPriceRange');
27
- exports.CatalogPriceRangeService = services_definitions_1.implementService.withConfig()(exports.CatalogPriceRangeServiceDefinition, ({ getService }) => {
28
- const signalsService = getService(signals_1.SignalsServiceDefinition);
22
+ export const CatalogPriceRangeServiceDefinition = defineService("catalogPriceRange");
23
+ export const CatalogPriceRangeService = implementService.withConfig()(CatalogPriceRangeServiceDefinition, ({ getService }) => {
24
+ const signalsService = getService(SignalsServiceDefinition);
29
25
  // Signal declarations
30
26
  const catalogPriceRange = signalsService.signal(null);
31
27
  const isLoading = signalsService.signal(false);
@@ -42,25 +38,25 @@ exports.CatalogPriceRangeService = services_definitions_1.implementService.withC
42
38
  const aggregationRequest = {
43
39
  aggregations: [
44
40
  {
45
- name: 'minPrice',
46
- fieldPath: 'actualPriceRange.minValue.amount',
47
- type: 'SCALAR',
48
- scalar: { type: 'MIN' },
41
+ name: "minPrice",
42
+ fieldPath: "actualPriceRange.minValue.amount",
43
+ type: "SCALAR",
44
+ scalar: { type: "MIN" },
49
45
  },
50
46
  {
51
- name: 'maxPrice',
52
- fieldPath: 'actualPriceRange.maxValue.amount',
53
- type: 'SCALAR',
54
- scalar: { type: 'MAX' },
47
+ name: "maxPrice",
48
+ fieldPath: "actualPriceRange.maxValue.amount",
49
+ type: "SCALAR",
50
+ scalar: { type: "MAX" },
55
51
  },
56
52
  ],
57
53
  filter: buildCategoryFilter(categoryId),
58
54
  includeProducts: false,
59
55
  cursorPaging: { limit: 0 },
60
56
  };
61
- const aggregationResponse = await (0, auto_sdk_stores_products_v_3_1.searchProducts)(aggregationRequest);
62
- const minPrice = extractScalarAggregationValue(aggregationResponse, 'minPrice');
63
- const maxPrice = extractScalarAggregationValue(aggregationResponse, 'maxPrice');
57
+ const aggregationResponse = await productsV3.searchProducts(aggregationRequest);
58
+ const minPrice = extractScalarAggregationValue(aggregationResponse, "minPrice");
59
+ const maxPrice = extractScalarAggregationValue(aggregationResponse, "maxPrice");
64
60
  // Only set price range if we found valid prices
65
61
  if (minPrice !== null &&
66
62
  maxPrice !== null &&
@@ -76,8 +72,8 @@ exports.CatalogPriceRangeService = services_definitions_1.implementService.withC
76
72
  }
77
73
  }
78
74
  catch (err) {
79
- console.error('Failed to load catalog price range:', err);
80
- error.set(err instanceof Error ? err.message : 'Failed to load price range');
75
+ console.error("Failed to load catalog price range:", err);
76
+ error.set(err instanceof Error ? err.message : "Failed to load price range");
81
77
  // Don't set fallback values - let the component handle the error state
82
78
  catalogPriceRange.set(null);
83
79
  }
@@ -92,6 +88,6 @@ exports.CatalogPriceRangeService = services_definitions_1.implementService.withC
92
88
  loadCatalogPriceRange,
93
89
  };
94
90
  });
95
- async function loadCatalogPriceRangeServiceConfig() {
91
+ export async function loadCatalogPriceRangeServiceConfig() {
96
92
  return {};
97
93
  }
@@ -1,8 +1,8 @@
1
- import type { Signal } from '../../Signal';
2
- import { type Category } from '@wix/auto_sdk_categories_categories';
1
+ import { type Signal } from "@wix/services-definitions/core-services/signals";
2
+ import * as categories from "@wix/auto_sdk_categories_categories";
3
3
  export interface CategoryServiceAPI {
4
4
  selectedCategory: Signal<string | null>;
5
- categories: Signal<Category[]>;
5
+ categories: Signal<categories.Category[]>;
6
6
  setSelectedCategory: (categoryId: string | null) => void;
7
7
  loadCategories: () => Promise<void>;
8
8
  }
@@ -12,15 +12,15 @@ export declare const CategoryServiceDefinition: string & {
12
12
  isServiceDefinition?: boolean;
13
13
  } & CategoryServiceAPI;
14
14
  export interface CategoryServiceConfig {
15
- categories: Category[];
15
+ categories: categories.Category[];
16
16
  initialCategoryId?: string | null;
17
- onCategoryChange?: (categoryId: string | null, category: Category | null) => void;
17
+ onCategoryChange?: (categoryId: string | null, category: categories.Category | null) => void;
18
18
  }
19
19
  export declare const CategoryService: import("@wix/services-definitions").ServiceFactory<string & {
20
20
  __api: CategoryServiceAPI;
21
21
  __config: {};
22
22
  isServiceDefinition?: boolean;
23
- } & CategoryServiceAPI, CategoryServiceConfig, import("@wix/services-definitions").ThreadMode.MAIN>;
23
+ } & CategoryServiceAPI, CategoryServiceConfig>;
24
24
  export declare function loadCategoriesConfig(): Promise<{
25
- categories: Category[];
25
+ categories: categories.Category[];
26
26
  }>;
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CategoryService = exports.CategoryServiceDefinition = void 0;
4
- exports.loadCategoriesConfig = loadCategoriesConfig;
5
- const services_definitions_1 = require("@wix/services-definitions");
6
- const signals_1 = require("@wix/services-definitions/core-services/signals");
7
- const auto_sdk_categories_categories_1 = require("@wix/auto_sdk_categories_categories");
8
- exports.CategoryServiceDefinition = (0, services_definitions_1.defineService)('category-service');
9
- exports.CategoryService = services_definitions_1.implementService.withConfig()(exports.CategoryServiceDefinition, ({ getService, config }) => {
10
- const signalsService = getService(signals_1.SignalsServiceDefinition);
11
- const selectedCategory = signalsService.signal((config.initialCategoryId || null));
12
- const categories = signalsService.signal(config.categories);
1
+ import { defineService, implementService } from "@wix/services-definitions";
2
+ import { SignalsServiceDefinition, } from "@wix/services-definitions/core-services/signals";
3
+ import * as categories from "@wix/auto_sdk_categories_categories";
4
+ export const CategoryServiceDefinition = defineService("category-service");
5
+ export const CategoryService = implementService.withConfig()(CategoryServiceDefinition, ({ getService, config }) => {
6
+ const signalsService = getService(SignalsServiceDefinition);
7
+ const selectedCategory = signalsService.signal((config?.initialCategoryId || null));
8
+ const categories = signalsService.signal(config?.categories);
13
9
  const loadCategories = async () => {
14
10
  const { categories: loadedCategories } = await loadCategoriesConfig();
15
11
  categories.set(loadedCategories);
@@ -20,16 +16,17 @@ exports.CategoryService = services_definitions_1.implementService.withConfig()(e
20
16
  selectedCategory.set(categoryId);
21
17
  };
22
18
  // Subscribe to category changes and handle navigation as a side effect
23
- selectedCategory.subscribe(categoryId => {
19
+ signalsService.effect(() => {
20
+ const categoryId = selectedCategory.get();
24
21
  // Skip navigation on initial load (when service is first created)
25
22
  if (isInitialLoad) {
26
23
  isInitialLoad = false;
27
24
  return;
28
25
  }
29
26
  // If a navigation handler is provided, use it
30
- if (config.onCategoryChange) {
27
+ if (config?.onCategoryChange) {
31
28
  const category = categoryId
32
- ? config.categories.find(cat => cat._id === categoryId) || null
29
+ ? config?.categories.find((cat) => cat._id === categoryId) || null
33
30
  : null;
34
31
  config.onCategoryChange(categoryId, category);
35
32
  }
@@ -41,20 +38,21 @@ exports.CategoryService = services_definitions_1.implementService.withConfig()(e
41
38
  loadCategories,
42
39
  };
43
40
  });
44
- async function loadCategoriesConfig() {
41
+ export async function loadCategoriesConfig() {
45
42
  try {
46
- const categoriesResponse = await (0, auto_sdk_categories_categories_1.queryCategories)({
43
+ const categoriesResponse = await categories
44
+ .queryCategories({
47
45
  treeReference: {
48
- appNamespace: '@wix/stores',
46
+ appNamespace: "@wix/stores",
49
47
  treeKey: null,
50
48
  },
51
49
  })
52
- .eq('visible', true)
50
+ .eq("visible", true)
53
51
  .find();
54
52
  const fetchedCategories = categoriesResponse.items || [];
55
53
  // Sort categories to put "all-products" first, keep the rest in original order
56
- const allProductsCategory = fetchedCategories.find(cat => cat.slug === 'all-products');
57
- const otherCategories = fetchedCategories.filter(cat => cat.slug !== 'all-products');
54
+ const allProductsCategory = fetchedCategories.find((cat) => cat.slug === "all-products");
55
+ const otherCategories = fetchedCategories.filter((cat) => cat.slug !== "all-products");
58
56
  const allCategories = allProductsCategory
59
57
  ? [allProductsCategory, ...otherCategories]
60
58
  : fetchedCategories;
@@ -63,7 +61,7 @@ async function loadCategoriesConfig() {
63
61
  };
64
62
  }
65
63
  catch (error) {
66
- console.warn('Failed to load categories:', error);
64
+ console.warn("Failed to load categories:", error);
67
65
  return {
68
66
  categories: [],
69
67
  };
@@ -1,10 +1,10 @@
1
- import { type ServiceFactoryConfig } from '@wix/services-definitions';
2
- import type { Signal } from '../../Signal';
3
- import { type V3Product } from '@wix/auto_sdk_stores_products-v-3';
4
- import { type Filter } from './filter-service';
5
- import { type SortBy } from './sort-service';
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
+ import { type Filter } from "./filter-service.js";
5
+ import { type SortBy } from "./sort-service.js";
6
6
  export interface CollectionServiceAPI {
7
- products: Signal<V3Product[]>;
7
+ products: Signal<productsV3.V3Product[]>;
8
8
  isLoading: Signal<boolean>;
9
9
  error: Signal<string | null>;
10
10
  totalProducts: Signal<number>;
@@ -23,12 +23,12 @@ export declare const CollectionService: import("@wix/services-definitions").Serv
23
23
  __config: {};
24
24
  isServiceDefinition?: boolean;
25
25
  } & CollectionServiceAPI, {
26
- initialProducts?: V3Product[];
26
+ initialProducts?: productsV3.V3Product[];
27
27
  pageSize?: number;
28
28
  initialCursor?: string;
29
29
  initialHasMore?: boolean;
30
30
  categories?: any[];
31
- }, import("@wix/services-definitions").ThreadMode.MAIN>;
31
+ }>;
32
32
  export declare function loadCollectionServiceConfig(categoryId?: string, searchParams?: URLSearchParams, preloadedCategories?: any[]): Promise<ServiceFactoryConfig<typeof CollectionService> & {
33
33
  initialCursor?: string;
34
34
  initialHasMore?: boolean;