Skip to content

Conversation

yurynix
Copy link
Collaborator

@yurynix yurynix commented Jul 31, 2025

Align Products List Service APIs

Summary

This PR aligns the APIs of loadProductsListServiceConfig and loadProductsListSearchServiceConfig to provide a consistent developer experience.

Changes Made

API Alignment

  • Updated both functions to accept string | productsV3.V3ProductSearch (previously inconsistent)
  • Unified usage pattern: Both services now support URL parsing and custom search options
  • Better developer experience: No more manual URL parsing required

🔧 Function Rename

  • Renamed parseUrlForProductsListSearchparseUrlToSearchOptions
  • Clearer name: Better reflects what the function actually returns (search options + initial state)
  • More general: Used by both services, not just the search-specific one

📚 Documentation Improvements

  • Enhanced JSDoc with comprehensive examples for all usage patterns
  • Added as const assertions in examples for better TypeScript type safety
  • Performance optimization examples showing how to parse URL once for both services

Before/After

Before:

// Inconsistent APIs
const { searchOptions } = await parseUrlForProductsListSearch(url, categories);
const [productsConfig, searchConfig] = await Promise.all([
  loadProductsListServiceConfig(searchOptions),    // Takes searchOptions
  loadProductsListSearchServiceConfig(url),        // Takes URL
]);

After:

// Consistent APIs
const [productsConfig, searchConfig] = await Promise.all([
  loadProductsListServiceConfig(url),           // Both take URL
  loadProductsListSearchServiceConfig(url),
]);

// Or both take searchOptions
const [productsConfig, searchConfig] = await Promise.all([
  loadProductsListServiceConfig(searchOptions),
  loadProductsListSearchServiceConfig(searchOptions),
]);

Impact

  • No breaking changes - all existing usage patterns continue to work
  • Improved consistency - APIs now work the same way
  • Better performance - option to parse URL once and reuse
  • Enhanced type safety - JSDoc examples use proper TypeScript patterns

@yurynix yurynix merged commit 2f7b984 into main Jul 31, 2025
1 check passed
@yurynix yurynix deleted the align-loaders-api branch July 31, 2025 11:20
Paveltarno pushed a commit that referenced this pull request Aug 13, 2025
…ServiceConfig (#118)

* Align API of loadProductsListSearchServiceConfig and loadProductsListServiceConfig

* Align the API more

* Bump stores version
ttsahi pushed a commit that referenced this pull request Aug 17, 2025
…ServiceConfig (#118)

* Align API of loadProductsListSearchServiceConfig and loadProductsListServiceConfig

* Align the API more

* Bump stores version
valeriihorsharik-wix pushed a commit that referenced this pull request Sep 17, 2025
…ServiceConfig (#118)

* Align API of loadProductsListSearchServiceConfig and loadProductsListServiceConfig

* Align the API more

* Bump stores version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant