@jay-framework/wix-stores 0.15.0 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getCurrentCartClient, CartState } from '@jay-framework/wix-cart';
1
+ import { CartState } from '@jay-framework/wix-cart';
2
2
  export { AddToCartOptions, CartIndicatorState, CartLineItem, CartState, CartSummary, WIX_CART_CONTEXT, WIX_CART_SERVICE, WixCartContext, WixCartService, cartIndicator, cartPage, provideWixCartContext, provideWixCartService } from '@jay-framework/wix-cart';
3
3
  import * as _jay_framework_fullstack_component from '@jay-framework/fullstack-component';
4
4
  import { UrlParams, Signals, PageProps } from '@jay-framework/fullstack-component';
@@ -6,9 +6,10 @@ import * as _jay_framework_component from '@jay-framework/component';
6
6
  import * as _jay_framework_runtime from '@jay-framework/runtime';
7
7
  import { HTMLElementCollectionProxy, HTMLElementProxy } from '@jay-framework/runtime';
8
8
  import { WixClient } from '@wix/sdk';
9
+ import { BuildDescriptors } from '@wix/sdk-types';
9
10
  import { productsV3, inventoryItemsV3 } from '@wix/stores';
10
11
  import { categories } from '@wix/categories';
11
- import { BuildDescriptors } from '@wix/sdk-types';
12
+ import { currentCart } from '@wix/ecom';
12
13
  import { Getter } from '@jay-framework/reactive';
13
14
  import { OptionChoice } from '@wix/auto_sdk_stores_products-v-3';
14
15
  import { PluginSetupContext, PluginSetupResult, PluginReferencesContext, PluginReferencesResult } from '@jay-framework/stack-server-runtime';
@@ -29,7 +30,6 @@ interface ChoiceOfProductOptionsViewState {
29
30
  choiceType: ChoiceType$1,
30
31
  colorCode: string,
31
32
  inStock: boolean,
32
- variantId: string,
33
33
  isSelected: boolean
34
34
  }
35
35
 
@@ -100,6 +100,7 @@ declare enum ProductType$1 {
100
100
  declare enum QuickAddType {
101
101
  SIMPLE,
102
102
  SINGLE_OPTION,
103
+ COLOR_AND_TEXT_OPTIONS,
103
104
  NEEDS_CONFIGURATION
104
105
  }
105
106
 
@@ -121,7 +122,8 @@ interface ProductCardViewState {
121
122
  productType: ProductType$1,
122
123
  isAddingToCart: boolean,
123
124
  quickAddType: QuickAddType,
124
- quickOption: ProductOptionsViewState
125
+ quickOption: ProductOptionsViewState,
126
+ secondQuickOption: ProductOptionsViewState
125
127
  }
126
128
 
127
129
 
@@ -129,7 +131,8 @@ interface ProductCardRepeatedRefs {
129
131
  productLink: HTMLElementCollectionProxy<ProductCardViewState, HTMLAnchorElement>,
130
132
  addToCartButton: HTMLElementCollectionProxy<ProductCardViewState, HTMLButtonElement>,
131
133
  viewOptionsButton: HTMLElementCollectionProxy<ProductCardViewState, HTMLButtonElement>,
132
- quickOption: ProductOptionsRepeatedRefs
134
+ quickOption: ProductOptionsRepeatedRefs,
135
+ secondQuickOption: ProductOptionsRepeatedRefs
133
136
  }
134
137
 
135
138
  interface RangeOfPriceRangeOfFilterOfProductSearchViewState {
@@ -153,7 +156,8 @@ interface CategoryOfCategoryFilterOfFilterOfProductSearchViewState {
153
156
  categoryId: string,
154
157
  categoryName: string,
155
158
  categorySlug: string,
156
- isSelected: boolean
159
+ isSelected: boolean,
160
+ categoryUrl: string
157
161
  }
158
162
 
159
163
  interface CategoryFilterOfFilterOfProductSearchViewState {
@@ -184,6 +188,57 @@ interface SuggestionOfProductSearchViewState {
184
188
  suggestionText: string
185
189
  }
186
190
 
191
+ interface BreadcrumbOfCategoryHeaderOfProductSearchViewState {
192
+ categoryId: string,
193
+ name: string,
194
+ slug: string,
195
+ url: string
196
+ }
197
+
198
+ interface PropOfTagOfSeoDatumOfCategoryHeaderOfProductSearchViewState {
199
+ key: string,
200
+ value: string
201
+ }
202
+
203
+ interface MetaOfTagOfSeoDatumOfCategoryHeaderOfProductSearchViewState {
204
+ key: string,
205
+ value: string
206
+ }
207
+
208
+ interface TagOfSeoDatumOfCategoryHeaderOfProductSearchViewState {
209
+ position: string,
210
+ type: string,
211
+ props: Array<PropOfTagOfSeoDatumOfCategoryHeaderOfProductSearchViewState>,
212
+ meta: Array<MetaOfTagOfSeoDatumOfCategoryHeaderOfProductSearchViewState>,
213
+ children: string
214
+ }
215
+
216
+ interface KeywordOfSettingOfSeoDatumOfCategoryHeaderOfProductSearchViewState {
217
+ term: string,
218
+ isMain: boolean,
219
+ origin: string
220
+ }
221
+
222
+ interface SettingOfSeoDatumOfCategoryHeaderOfProductSearchViewState {
223
+ preventAutoRedirect: boolean,
224
+ keywords: Array<KeywordOfSettingOfSeoDatumOfCategoryHeaderOfProductSearchViewState>
225
+ }
226
+
227
+ interface SeoDatumOfCategoryHeaderOfProductSearchViewState {
228
+ tags: Array<TagOfSeoDatumOfCategoryHeaderOfProductSearchViewState>,
229
+ settings: SettingOfSeoDatumOfCategoryHeaderOfProductSearchViewState
230
+ }
231
+
232
+ interface CategoryHeaderOfProductSearchViewState {
233
+ name: string,
234
+ description: string,
235
+ imageUrl: string,
236
+ hasImage: boolean,
237
+ productCount: number,
238
+ breadcrumbs: Array<BreadcrumbOfCategoryHeaderOfProductSearchViewState>,
239
+ seoData: SeoDatumOfCategoryHeaderOfProductSearchViewState
240
+ }
241
+
187
242
  interface ProductSearchViewState {
188
243
  searchExpression: string,
189
244
  searchFields: string,
@@ -200,15 +255,17 @@ interface ProductSearchViewState {
200
255
  loadedCount: number,
201
256
  totalCount: number,
202
257
  hasSuggestions: boolean,
203
- suggestions: Array<SuggestionOfProductSearchViewState>
258
+ suggestions: Array<SuggestionOfProductSearchViewState>,
259
+ categoryHeader: CategoryHeaderOfProductSearchViewState
204
260
  }
205
261
 
206
262
  type ProductSearchSlowViewState = Pick<ProductSearchViewState, 'searchFields' | 'fuzzySearch' | 'emptyStateMessage'> & {
207
263
  filters: {
208
264
  categoryFilter: {
209
- categories: Array<Pick<ProductSearchViewState['filters']['categoryFilter']['categories'][number], 'categoryId' | 'categoryName' | 'categorySlug'>>;
265
+ categories: Array<Pick<ProductSearchViewState['filters']['categoryFilter']['categories'][number], 'categoryId' | 'categoryName' | 'categorySlug' | 'categoryUrl'>>;
210
266
  };
211
267
  };
268
+ categoryHeader: ProductSearchViewState['categoryHeader'];
212
269
  };
213
270
 
214
271
  type ProductSearchFastViewState = Pick<ProductSearchViewState, 'searchExpression' | 'isSearching' | 'hasSearched' | 'resultCount' | 'hasResults' | 'hasMore' | 'loadedCount' | 'totalCount' | 'hasSuggestions'> & {
@@ -267,79 +324,94 @@ interface ProductSearchRefs {
267
324
  }
268
325
 
269
326
  /**
270
- * Wix Store API Client Factories
271
- *
272
- * These functions create singleton instances of Wix API clients.
273
- * Used by both the server service and client context.
327
+ * Configuration loader for wix-stores plugin.
274
328
  *
275
- * Note: Cart client is provided by @jay-framework/wix-cart package.
329
+ * Reads optional config from config/.wix-stores.yaml.
330
+ * When the file doesn't exist, returns defaults.
276
331
  */
332
+ /**
333
+ * URL templates for building canonical product and category links.
334
+ * Placeholders: {slug}, {category}, {prefix}
335
+ */
336
+ interface UrlTemplates {
337
+ /** URL template for product pages. Default: "/products/{slug}" */
338
+ product: string;
339
+ /** URL template for category pages. Not set = no category deep-linking */
340
+ category: string | null;
341
+ }
277
342
 
278
343
  /**
279
- * Get a configured Wix Stores Products V3 client (singleton)
344
+ * Shared Product Mapping Utilities
280
345
  *
281
- * The Products V3 API is part of the new Catalog V3 system that provides
282
- * advanced product management capabilities for sophisticated e-commerce applications.
283
- *
284
- * @returns Products V3 client instance from @wix/stores
285
- * @see https://dev.wix.com/docs/sdk/backend-modules/stores/catalog-v3/introduction
346
+ * Maps Wix Stores Catalog V3 product responses to view state contracts.
286
347
  */
287
- declare function getProductsV3Client(wixClient: WixClient): BuildDescriptors<typeof productsV3, {}>;
348
+
288
349
  /**
289
- * Get a configured Wix Stores Categories client (singleton)
290
- *
291
- * The Categories API allows you to manage product Categories in your Wix store.
292
- *
293
- * @returns Categories client instance from @wix/stores
294
- * @see https://dev.wix.com/docs/sdk/backend-modules/categories/categories/introduction
350
+ * Cached category hierarchy data, used for resolving category slugs and parent chains.
351
+ * Built lazily from the Wix Categories API and cached on the service.
295
352
  */
296
- declare function getCategoriesClient(wixClient: WixClient): BuildDescriptors<typeof categories, {}>;
353
+ interface CategoryTree {
354
+ /** Map of categoryId → slug */
355
+ slugMap: Map<string, string>;
356
+ /** Map of categoryId → parent categoryId */
357
+ parentMap: Map<string, string>;
358
+ /** Set of root category IDs (categories with no parent) */
359
+ rootIds: Set<string>;
360
+ /** Map of categoryId → image URL (only for categories that have an image) */
361
+ imageMap: Map<string, string>;
362
+ }
297
363
  /**
298
- * Get a configured Wix Stores Inventory V3 client (singleton)
299
- *
300
- * The Inventory API allows you to manage product inventory in your Wix store.
301
- *
302
- * @returns Inventory client instance from @wix/stores
303
- * @see https://dev.wix.com/docs/sdk/backend-modules/stores/inventory/introduction
364
+ * Find the root category ID for a given category by walking up the parent chain.
304
365
  */
305
- declare function getInventoryClient(wixClient: WixClient): BuildDescriptors<typeof inventoryItemsV3, {}>;
306
-
366
+ declare function findRootCategoryId(categoryId: string, tree: CategoryTree): string;
307
367
  /**
308
- * Maps a Wix root category to a URL prefix slug.
309
- * Products belonging to any child of this category get URLs like /products/{prefix}/{slug}.
368
+ * Get the slug of the root category for a given category.
310
369
  */
311
- interface CategoryPrefixConfig {
312
- /** Root category ID in Wix */
313
- categoryId: string;
314
- /** URL prefix slug (e.g., 'polgat', 'kitan') */
315
- prefix: string;
316
- /** Display name for the category (e.g., 'פולגת', 'כיתן') */
317
- name: string;
318
- }
370
+ declare function findRootCategorySlug(categoryId: string, tree: CategoryTree): string;
371
+ /**
372
+ * Find the image URL for a category, walking up the parent chain if the category has no image.
373
+ * Returns the first image found in the ancestry, or empty string.
374
+ */
375
+ declare function findCategoryImage(categoryId: string, tree: CategoryTree): string;
376
+ /**
377
+ * Build a product URL from the template, resolving {slug}, {category}, {prefix}.
378
+ * Defaults to placeholders if values are not provided
379
+ */
380
+ declare function buildProductUrl(urls: UrlTemplates, tree: CategoryTree, slug: string, mainCategoryId: string): string | null;
381
+ /**
382
+ * Build a category URL from the template, resolving {category} and {prefix}.
383
+ * Returns null if template is null or a required placeholder can't be resolved.
384
+ */
385
+ declare function buildCategoryUrl(urls: UrlTemplates, tree: CategoryTree, categorySlug: string, categoryId: string): string | null;
386
+ /** Variant stock map: colorChoiceId -> textChoiceId -> inStock */
387
+ type VariantStockMap = Record<string, Record<string, boolean>>;
388
+
319
389
  interface WixStoresService {
320
- products: ReturnType<typeof getProductsV3Client>;
321
- categories: ReturnType<typeof getCategoriesClient>;
322
- inventory: ReturnType<typeof getInventoryClient>;
390
+ products: BuildDescriptors<typeof productsV3, {}>;
391
+ categories: BuildDescriptors<typeof categories, {}>;
392
+ inventory: BuildDescriptors<typeof inventoryItemsV3, {}>;
323
393
  /** @deprecated Use WIX_CART_SERVICE from @jay-framework/wix-cart instead */
324
- cart: ReturnType<typeof getCurrentCartClient>;
325
- /** Category-to-URL-prefix mappings. Empty array when not configured. */
326
- categoryPrefixes: CategoryPrefixConfig[];
394
+ cart: BuildDescriptors<typeof currentCart, {}>;
395
+ /** URL templates for building canonical links */
396
+ urls: UrlTemplates;
397
+ /** Slug of the fallback category for pages without category context */
398
+ defaultCategory: string | null;
399
+ /** Get the cached category tree. Lazily built on first call. */
400
+ getCategoryTree(): Promise<CategoryTree>;
327
401
  }
328
402
  /**
329
403
  * Server service marker for Wix Stores.
330
- * Use with `.withServices(WIX_STORES_SERVICE_MARKER)` in component definitions.
331
404
  */
332
405
  declare const WIX_STORES_SERVICE_MARKER: _jay_framework_fullstack_component.ServiceMarker<WixStoresService>;
333
406
  /**
334
407
  * Options for initializing the Wix Stores service.
335
408
  */
336
409
  interface WixStoresServiceOptions {
337
- /** Category-to-URL-prefix mappings for category-prefixed product routes */
338
- categoryPrefixes?: CategoryPrefixConfig[];
410
+ urls?: UrlTemplates;
411
+ defaultCategory?: string | null;
339
412
  }
340
413
  /**
341
414
  * Creates, registers, and returns a Wix Stores service instance.
342
- * Called during server initialization.
343
415
  */
344
416
  declare function provideWixStoresService(wixClient: WixClient, options?: WixStoresServiceOptions): WixStoresService;
345
417
 
@@ -403,11 +475,13 @@ declare const WIX_STORES_CONTEXT: _jay_framework_runtime.ContextMarker<WixStores
403
475
 
404
476
  /**
405
477
  * URL parameters for product search routes.
406
- * When used as a category listing, `category` is the prefix slug (e.g., 'polgat').
478
+ * Supports: category (prefix slug), subcategory (sub-category slug).
407
479
  */
408
480
  interface ProductSearchParams extends UrlParams {
409
- /** Category prefix slug. When present, scopes search to this category hierarchy. */
481
+ /** Top-level category slug (e.g., 'polgat'). Scopes search to this category. */
410
482
  category?: string;
483
+ /** Sub-category slug (e.g., 'shirts'). Further scopes within the category. */
484
+ subcategory?: string;
411
485
  }
412
486
  /**
413
487
  * Search sort options
@@ -437,23 +511,7 @@ interface SearchFastCarryForward {
437
511
  /** Root category ID when scoped to a category prefix (always applied, hidden from UI) */
438
512
  baseCategoryId: string | null;
439
513
  }
440
- /**
441
- * Product Search Full-Stack Component
442
- *
443
- * A complete headless product search component with server-side rendering,
444
- * filtering, sorting, and "load more" functionality.
445
- *
446
- * Rendering phases:
447
- * - Slow: Categories for filtering (relatively static)
448
- * - Fast: Products, search results, load more state (dynamic per request)
449
- * - Interactive: Search input, filter selections, sorting, load more (client-side)
450
- *
451
- * Usage:
452
- * ```typescript
453
- * import { productSearch } from '@jay-framework/wix-stores';
454
- * ```
455
- */
456
- declare const productSearch: _jay_framework_fullstack_component.JayStackComponentDefinition<ProductSearchRefs, ProductSearchSlowViewState, ProductSearchFastViewState, ProductSearchInteractiveViewState, [SearchSlowCarryForward, WixStoresService], [Signals<ProductSearchFastViewState>, SearchFastCarryForward, WixStoresContext], PageProps & ProductSearchParams, {}, _jay_framework_component.JayComponentCore<PageProps & ProductSearchParams, ProductSearchInteractiveViewState>>;
514
+ declare const productSearch: _jay_framework_fullstack_component.JayStackComponentDefinition<ProductSearchRefs, ProductSearchSlowViewState, ProductSearchFastViewState, ProductSearchInteractiveViewState, [SearchSlowCarryForward, WixStoresService], [Signals<ProductSearchFastViewState>, SearchFastCarryForward, WixStoresContext], PageProps & ProductSearchParams, ProductSearchParams, _jay_framework_component.JayComponentCore<PageProps & ProductSearchParams, ProductSearchInteractiveViewState>>;
457
515
 
458
516
  declare enum MediaType {
459
517
  IMAGE,
@@ -907,6 +965,15 @@ declare const searchProducts: _jay_framework_fullstack_component.JayAction<Searc
907
965
  * ```
908
966
  */
909
967
  declare const getProductBySlug: _jay_framework_fullstack_component.JayAction<GetProductBySlugInput, ProductCardViewState> & _jay_framework_fullstack_component.JayActionDefinition<GetProductBySlugInput, ProductCardViewState, [WixStoresService]>;
968
+ /**
969
+ * Get variant stock availability for a COLOR_AND_TEXT_OPTIONS product.
970
+ * Fetches full product data and builds a stock map: colorChoiceId -> textChoiceId -> inStock.
971
+ */
972
+ declare const getVariantStock: _jay_framework_fullstack_component.JayAction<{
973
+ productId: string;
974
+ }, VariantStockMap> & _jay_framework_fullstack_component.JayActionDefinition<{
975
+ productId: string;
976
+ }, VariantStockMap, [WixStoresService]>;
910
977
  /**
911
978
  * Get available categories for filtering.
912
979
  *
@@ -940,4 +1007,4 @@ declare function setupWixStores(ctx: PluginSetupContext): Promise<PluginSetupRes
940
1007
  */
941
1008
  declare function generateWixStoresReferences(ctx: PluginReferencesContext): Promise<PluginReferencesResult>;
942
1009
 
943
- export { type CategoryPrefixConfig, type GetProductBySlugInput, type PriceAggregationData, type PriceRangeBucket, type ProductPageParams, type ProductSearchFilters, type ProductSearchParams, type ProductSortField, type SearchProductsInput, type SearchProductsOutput, type SearchSortOption, WIX_STORES_CONTEXT, WIX_STORES_SERVICE_MARKER, type WixStoresContext, type WixStoresInitData, type WixStoresService, type WixStoresServiceOptions, categoryList, generateWixStoresReferences, getCategories, getProductBySlug, init, productPage, productSearch, provideWixStoresService, searchProducts, setupWixStores };
1010
+ export { type CategoryTree, type GetProductBySlugInput, type PriceAggregationData, type PriceRangeBucket, type ProductPageParams, type ProductSearchFilters, type ProductSearchParams, type ProductSortField, type SearchProductsInput, type SearchProductsOutput, type SearchSortOption, WIX_STORES_CONTEXT, WIX_STORES_SERVICE_MARKER, type WixStoresContext, type WixStoresInitData, type WixStoresService, type WixStoresServiceOptions, buildCategoryUrl, buildProductUrl, categoryList, findCategoryImage, findRootCategoryId, findRootCategorySlug, generateWixStoresReferences, getCategories, getProductBySlug, getVariantStock, init, productPage, productSearch, provideWixStoresService, searchProducts, setupWixStores };