@wix/headless-stores 0.0.57 → 0.0.59

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 (37) hide show
  1. package/cjs/dist/react/ProductList.d.ts +0 -2
  2. package/cjs/dist/react/ProductList.js +3 -2
  3. package/cjs/dist/react/ProductListSort.d.ts +14 -0
  4. package/cjs/dist/react/ProductListSort.js +14 -0
  5. package/cjs/dist/react/core/ProductList.d.ts +3 -3
  6. package/cjs/dist/react/core/ProductList.js +3 -3
  7. package/cjs/dist/react/core/ProductListFilters.d.ts +8 -180
  8. package/cjs/dist/react/core/ProductListFilters.js +137 -171
  9. package/cjs/dist/react/core/ProductListPagination.d.ts +0 -192
  10. package/cjs/dist/react/core/ProductListPagination.js +2 -160
  11. package/cjs/dist/react/core/ProductListSort.d.ts +9 -57
  12. package/cjs/dist/react/core/ProductListSort.js +32 -52
  13. package/cjs/dist/services/index.d.ts +1 -2
  14. package/cjs/dist/services/index.js +1 -2
  15. package/cjs/dist/services/products-list-search-service.d.ts +1 -287
  16. package/cjs/dist/services/products-list-search-service.js +1 -900
  17. package/cjs/dist/services/products-list-service.d.ts +150 -4
  18. package/cjs/dist/services/products-list-service.js +537 -4
  19. package/dist/react/ProductList.d.ts +0 -2
  20. package/dist/react/ProductList.js +3 -2
  21. package/dist/react/ProductListSort.d.ts +14 -0
  22. package/dist/react/ProductListSort.js +14 -0
  23. package/dist/react/core/ProductList.d.ts +3 -3
  24. package/dist/react/core/ProductList.js +3 -3
  25. package/dist/react/core/ProductListFilters.d.ts +8 -180
  26. package/dist/react/core/ProductListFilters.js +137 -171
  27. package/dist/react/core/ProductListPagination.d.ts +0 -192
  28. package/dist/react/core/ProductListPagination.js +2 -160
  29. package/dist/react/core/ProductListSort.d.ts +9 -57
  30. package/dist/react/core/ProductListSort.js +32 -52
  31. package/dist/services/index.d.ts +1 -2
  32. package/dist/services/index.js +1 -2
  33. package/dist/services/products-list-search-service.d.ts +0 -287
  34. package/dist/services/products-list-search-service.js +1 -900
  35. package/dist/services/products-list-service.d.ts +150 -4
  36. package/dist/services/products-list-service.js +537 -4
  37. package/package.json +5 -4
@@ -1,7 +1,36 @@
1
- import { type Signal } from '@wix/services-definitions/core-services/signals';
2
- import { productsV3 } from '@wix/stores';
3
- import { type InitialSearchState } from './products-list-search-service.js';
1
+ import { type Signal, type ReadOnlySignal } from '@wix/services-definitions/core-services/signals';
2
+ import { customizationsV3, productsV3 } from '@wix/stores';
3
+ import { type Category } from './category-service.js';
4
4
  export declare const DEFAULT_QUERY_LIMIT = 100;
5
+ import { SortType } from './../enums/sort-enums.js';
6
+ export { SortType } from './../enums/sort-enums.js';
7
+ /**
8
+ * Enumeration of inventory status types available for filtering.
9
+ * Re-exports the Wix inventory availability status enum values.
10
+ */
11
+ export declare const InventoryStatusType: typeof productsV3.InventoryAvailabilityStatus;
12
+ /**
13
+ * Type for inventory status values.
14
+ * Re-exports the Wix inventory availability status enum type.
15
+ */
16
+ export type InventoryStatusType = productsV3.InventoryAvailabilityStatus;
17
+ /**
18
+ * Interface representing a product option (like Size, Color, etc.).
19
+ */
20
+ export interface ProductOption {
21
+ id: string;
22
+ name: string;
23
+ choices: ProductChoice[];
24
+ optionRenderType?: string;
25
+ }
26
+ /**
27
+ * Interface representing a choice within a product option.
28
+ */
29
+ export interface ProductChoice {
30
+ id: string;
31
+ name: string;
32
+ colorCode?: string;
33
+ }
5
34
  /**
6
35
  * Configuration interface for the Products List service.
7
36
  * Contains the initial products data, search options, and metadata.
@@ -17,6 +46,8 @@ export type ProductsListServiceConfig = {
17
46
  pagingMetadata: productsV3.CommonCursorPagingMetadata;
18
47
  /** Aggregation data containing filters, facets, and counts */
19
48
  aggregations: productsV3.AggregationData;
49
+ /** Customizations used to fetch the products */
50
+ customizations: customizationsV3.Customization[];
20
51
  };
21
52
  /**
22
53
  * Loads products list service configuration from the Wix Stores API for SSR initialization.
@@ -132,7 +163,6 @@ export type ProductsListServiceConfig = {
132
163
  */
133
164
  export declare function loadProductsListServiceConfig(input: string | {
134
165
  searchOptions: productsV3.V3ProductSearch;
135
- initialSearchState: InitialSearchState;
136
166
  }): Promise<ProductsListServiceConfig>;
137
167
  /**
138
168
  * Service definition for the Products List service.
@@ -154,12 +184,28 @@ export declare const ProductsListServiceDefinition: string & {
154
184
  isLoading: Signal<boolean>;
155
185
  /** Reactive signal containing any error message, or null if no error */
156
186
  error: Signal<string | null>;
187
+ /** Reactive signal containing the minimum price of the products */
188
+ minPrice: Signal<number>;
189
+ /** Reactive signal containing the maximum price of the products */
190
+ maxPrice: Signal<number>;
191
+ /** Reactive signal containing the available inventory statuses */
192
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
193
+ /** Reactive signal containing the available product options */
194
+ availableProductOptions: Signal<ProductOption[]>;
157
195
  /** Function to update search options and trigger a new search */
158
196
  setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
159
197
  /** Function to update only the sort part of search options */
160
198
  setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
161
199
  /** Function to update only the filter part of search options */
162
200
  setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
201
+ /** Function to reset the filter part of search options */
202
+ resetFilter: () => void;
203
+ /** Reactive signal indicating if any filters are currently applied */
204
+ isFiltered: () => ReadOnlySignal<boolean>;
205
+ /** Function to load more products */
206
+ loadMore: (count: number) => void;
207
+ /** Reactive signal indicating if there are more products to load */
208
+ hasMoreProducts: ReadOnlySignal<boolean>;
163
209
  };
164
210
  __config: ProductsListServiceConfig;
165
211
  isServiceDefinition?: boolean;
@@ -176,12 +222,28 @@ export declare const ProductsListServiceDefinition: string & {
176
222
  isLoading: Signal<boolean>;
177
223
  /** Reactive signal containing any error message, or null if no error */
178
224
  error: Signal<string | null>;
225
+ /** Reactive signal containing the minimum price of the products */
226
+ minPrice: Signal<number>;
227
+ /** Reactive signal containing the maximum price of the products */
228
+ maxPrice: Signal<number>;
229
+ /** Reactive signal containing the available inventory statuses */
230
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
231
+ /** Reactive signal containing the available product options */
232
+ availableProductOptions: Signal<ProductOption[]>;
179
233
  /** Function to update search options and trigger a new search */
180
234
  setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
181
235
  /** Function to update only the sort part of search options */
182
236
  setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
183
237
  /** Function to update only the filter part of search options */
184
238
  setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
239
+ /** Function to reset the filter part of search options */
240
+ resetFilter: () => void;
241
+ /** Reactive signal indicating if any filters are currently applied */
242
+ isFiltered: () => ReadOnlySignal<boolean>;
243
+ /** Function to load more products */
244
+ loadMore: (count: number) => void;
245
+ /** Reactive signal indicating if there are more products to load */
246
+ hasMoreProducts: ReadOnlySignal<boolean>;
185
247
  };
186
248
  /**
187
249
  * Implementation of the Products List service that manages reactive products data.
@@ -251,12 +313,28 @@ export declare const ProductListService: import("@wix/services-definitions").Ser
251
313
  isLoading: Signal<boolean>;
252
314
  /** Reactive signal containing any error message, or null if no error */
253
315
  error: Signal<string | null>;
316
+ /** Reactive signal containing the minimum price of the products */
317
+ minPrice: Signal<number>;
318
+ /** Reactive signal containing the maximum price of the products */
319
+ maxPrice: Signal<number>;
320
+ /** Reactive signal containing the available inventory statuses */
321
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
322
+ /** Reactive signal containing the available product options */
323
+ availableProductOptions: Signal<ProductOption[]>;
254
324
  /** Function to update search options and trigger a new search */
255
325
  setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
256
326
  /** Function to update only the sort part of search options */
257
327
  setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
258
328
  /** Function to update only the filter part of search options */
259
329
  setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
330
+ /** Function to reset the filter part of search options */
331
+ resetFilter: () => void;
332
+ /** Reactive signal indicating if any filters are currently applied */
333
+ isFiltered: () => ReadOnlySignal<boolean>;
334
+ /** Function to load more products */
335
+ loadMore: (count: number) => void;
336
+ /** Reactive signal indicating if there are more products to load */
337
+ hasMoreProducts: ReadOnlySignal<boolean>;
260
338
  };
261
339
  __config: ProductsListServiceConfig;
262
340
  isServiceDefinition?: boolean;
@@ -273,10 +351,78 @@ export declare const ProductListService: import("@wix/services-definitions").Ser
273
351
  isLoading: Signal<boolean>;
274
352
  /** Reactive signal containing any error message, or null if no error */
275
353
  error: Signal<string | null>;
354
+ /** Reactive signal containing the minimum price of the products */
355
+ minPrice: Signal<number>;
356
+ /** Reactive signal containing the maximum price of the products */
357
+ maxPrice: Signal<number>;
358
+ /** Reactive signal containing the available inventory statuses */
359
+ availableInventoryStatuses: Signal<InventoryStatusType[]>;
360
+ /** Reactive signal containing the available product options */
361
+ availableProductOptions: Signal<ProductOption[]>;
276
362
  /** Function to update search options and trigger a new search */
277
363
  setSearchOptions: (searchOptions: productsV3.V3ProductSearch) => void;
278
364
  /** Function to update only the sort part of search options */
279
365
  setSort: (sort: productsV3.V3ProductSearch["sort"]) => void;
280
366
  /** Function to update only the filter part of search options */
281
367
  setFilter: (filter: productsV3.V3ProductSearch["filter"]) => void;
368
+ /** Function to reset the filter part of search options */
369
+ resetFilter: () => void;
370
+ /** Reactive signal indicating if any filters are currently applied */
371
+ isFiltered: () => ReadOnlySignal<boolean>;
372
+ /** Function to load more products */
373
+ loadMore: (count: number) => void;
374
+ /** Reactive signal indicating if there are more products to load */
375
+ hasMoreProducts: ReadOnlySignal<boolean>;
282
376
  }, ProductsListServiceConfig>;
377
+ /**
378
+ * Initial search state that can be loaded from URL parameters.
379
+ */
380
+ export type InitialSearchState = {
381
+ sort?: SortType;
382
+ limit?: number;
383
+ cursor?: string | null;
384
+ priceRange?: {
385
+ min?: number;
386
+ max?: number;
387
+ };
388
+ inventoryStatuses?: InventoryStatusType[];
389
+ productOptions?: Record<string, string[]>;
390
+ category?: Category;
391
+ visible?: boolean;
392
+ productType?: string;
393
+ };
394
+ /**
395
+ * Parse URL and build complete search options with all filters, sort, and pagination.
396
+ * This function extracts search parameters, filters, sorting, and pagination from a URL
397
+ * and converts them into the format expected by the Wix Stores API.
398
+ *
399
+ * @param {string} url - The URL to parse search parameters from
400
+ * @param {Category[]} categoriesList - List of available categories for category slug resolution
401
+ * @param {productsV3.V3ProductSearch} [defaultSearchOptions] - Default search options to merge with parsed URL parameters
402
+ * @returns {Promise<{searchOptions: productsV3.V3ProductSearch, initialSearchState: InitialSearchState}>}
403
+ * Object containing both API-ready search options and UI-ready initial state
404
+ *
405
+ * @example
406
+ * ```tsx
407
+ * // Parse URL with filters, sort, and pagination
408
+ * const categories = await loadCategoriesListServiceConfig();
409
+ * const { searchOptions, initialSearchState } = await parseUrlToSearchOptions(
410
+ * 'https://example.com/products?sort=price:desc&Color=red,blue&minPrice=50',
411
+ * categories.categories
412
+ * );
413
+ *
414
+ * // Use searchOptions for API calls
415
+ * const products = await productsV3.searchProducts(searchOptions);
416
+ *
417
+ * // Use initialSearchState for UI initialization
418
+ * const filterState = initialSearchState.productOptions; // { colorId: ['red-id', 'blue-id'] }
419
+ * ```
420
+ */
421
+ export declare function parseUrlToSearchOptions(url: string, categoriesList: Category[], customizations: customizationsV3.Customization[], defaultSearchOptions?: productsV3.V3ProductSearch): Promise<{
422
+ searchOptions: productsV3.V3ProductSearch;
423
+ initialSearchState: InitialSearchState;
424
+ }>;
425
+ /**
426
+ * Convert URL sort format to SortType enum
427
+ */
428
+ export declare function convertUrlSortToSortType(urlSort: string): SortType | null;