shop-client 3.8.2 → 3.9.0

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 (60) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +93 -1
  3. package/dist/checkout.mjs +1 -7
  4. package/dist/chunk-6GPWNCDO.mjs +130 -0
  5. package/dist/chunk-EJO5U4BT.mjs +2 -0
  6. package/dist/chunk-FFKWCNLU.mjs +1 -0
  7. package/dist/chunk-KYLPIEU3.mjs +2 -0
  8. package/dist/chunk-MB2INNNP.mjs +1 -0
  9. package/dist/chunk-MI7754VX.mjs +2 -0
  10. package/dist/chunk-SZQPMLZG.mjs +1 -0
  11. package/dist/collections.d.ts +1 -1
  12. package/dist/collections.mjs +1 -9
  13. package/dist/enrich-OZHBXKK6.mjs +1 -0
  14. package/dist/index.d.ts +24 -6
  15. package/dist/index.mjs +2 -702
  16. package/dist/products.d.ts +1 -1
  17. package/dist/products.mjs +1 -9
  18. package/dist/{store-CJVUz2Yb.d.mts → store-iQARl6J3.d.ts} +3 -3
  19. package/dist/store.d.ts +1 -1
  20. package/dist/store.mjs +1 -9
  21. package/dist/utils/rate-limit.d.ts +5 -0
  22. package/dist/utils/rate-limit.mjs +1 -11
  23. package/package.json +8 -10
  24. package/dist/checkout.d.mts +0 -31
  25. package/dist/checkout.js +0 -115
  26. package/dist/checkout.js.map +0 -1
  27. package/dist/checkout.mjs.map +0 -1
  28. package/dist/chunk-2KBOKOAD.mjs +0 -177
  29. package/dist/chunk-2KBOKOAD.mjs.map +0 -1
  30. package/dist/chunk-BWKBRM2Z.mjs +0 -136
  31. package/dist/chunk-BWKBRM2Z.mjs.map +0 -1
  32. package/dist/chunk-O4BPIIQ6.mjs +0 -503
  33. package/dist/chunk-O4BPIIQ6.mjs.map +0 -1
  34. package/dist/chunk-QCTICSBE.mjs +0 -398
  35. package/dist/chunk-QCTICSBE.mjs.map +0 -1
  36. package/dist/chunk-QL5OUZGP.mjs +0 -91
  37. package/dist/chunk-QL5OUZGP.mjs.map +0 -1
  38. package/dist/chunk-WTK5HUFI.mjs +0 -1287
  39. package/dist/chunk-WTK5HUFI.mjs.map +0 -1
  40. package/dist/collections.d.mts +0 -64
  41. package/dist/collections.js +0 -540
  42. package/dist/collections.js.map +0 -1
  43. package/dist/collections.mjs.map +0 -1
  44. package/dist/index.d.mts +0 -233
  45. package/dist/index.js +0 -3241
  46. package/dist/index.js.map +0 -1
  47. package/dist/index.mjs.map +0 -1
  48. package/dist/products.d.mts +0 -63
  49. package/dist/products.js +0 -1206
  50. package/dist/products.js.map +0 -1
  51. package/dist/products.mjs.map +0 -1
  52. package/dist/store-CJVUz2Yb.d.ts +0 -608
  53. package/dist/store.d.mts +0 -1
  54. package/dist/store.js +0 -698
  55. package/dist/store.js.map +0 -1
  56. package/dist/store.mjs.map +0 -1
  57. package/dist/utils/rate-limit.d.mts +0 -25
  58. package/dist/utils/rate-limit.js +0 -203
  59. package/dist/utils/rate-limit.js.map +0 -1
  60. package/dist/utils/rate-limit.mjs.map +0 -1
package/dist/index.d.mts DELETED
@@ -1,233 +0,0 @@
1
- import { CheckoutOperations } from './checkout.mjs';
2
- import { CollectionOperations } from './collections.mjs';
3
- import { ProductOperations } from './products.mjs';
4
- import { P as ProductClassification, S as SEOContent, C as CountryDetectionResult, a as StoreOperations, b as ShopifyProduct, c as Product, d as ShopifySingleProduct, e as ShopifyCollection, f as Collection, g as StoreInfo, h as StoreTypeBreakdown } from './store-CJVUz2Yb.mjs';
5
- export { H as Address, F as CatalogCategory, I as ContactUrls, K as CountryScore, N as CountryScores, J as Coupon, y as CurrencyCode, G as Demographics, Q as JsonLdEntry, L as LocalizedPricing, M as MetaTag, D as ProductImage, z as ProductOption, x as ProductPricing, B as ProductVariant, A as ProductVariantImage, E as ShopifyApiProduct, u as ShopifyBaseProduct, r as ShopifyBaseVariant, k as ShopifyBasicInfo, o as ShopifyFeaturedMedia, O as ShopifyFeaturesData, m as ShopifyImage, l as ShopifyImageDimensions, p as ShopifyMedia, q as ShopifyOption, w as ShopifyPredictiveProductSearch, v as ShopifyProductAndStore, s as ShopifyProductVariant, t as ShopifySingleProductVariant, j as ShopifyTimestamps, n as ShopifyVariantImage, i as StoreCatalog, R as StoreTypeResult, V as ValidStoreCatalog } from './store-CJVUz2Yb.mjs';
6
- export { configureRateLimit } from './utils/rate-limit.mjs';
7
-
8
- /**
9
- * Classify product content into a three-tier hierarchy using LLM.
10
- * Returns strictly validated JSON with audience, vertical, and optional category/subCategory.
11
- */
12
- declare function classifyProduct(productContent: string, options?: {
13
- apiKey?: string;
14
- model?: string;
15
- }): Promise<ProductClassification>;
16
- /**
17
- * Generate SEO and marketing content for a product. Returns strictly validated JSON.
18
- */
19
- declare function generateSEOContent(product: {
20
- title: string;
21
- description?: string;
22
- vendor?: string;
23
- price?: number;
24
- tags?: string[];
25
- }, options?: {
26
- apiKey?: string;
27
- model?: string;
28
- }): Promise<SEOContent>;
29
-
30
- /**
31
- * Detects the country of a Shopify store by analyzing various signals in the HTML content.
32
- *
33
- * This function examines multiple data sources within the HTML to determine the store's country:
34
- * - Shopify features JSON data (country, locale, money format)
35
- * - Phone number prefixes in contact information
36
- * - JSON-LD structured data with address information
37
- * - Footer mentions of country names
38
- * - Currency symbols in money formatting
39
- *
40
- * @param html - The HTML content of the Shopify store's homepage
41
- * @returns Promise resolving to country detection results containing:
42
- * - `country` - The detected country ISO 3166-1 alpha-2 code (e.g., "US", "GB") or "Unknown" if no reliable detection
43
- * - `confidence` - Confidence score between 0 and 1 (higher = more confident)
44
- * - `signals` - Array of detection signals that contributed to the result
45
- *
46
- * @example
47
- * ```typescript
48
- * const response = await fetch('https://exampleshop.com');
49
- * const html = await response.text();
50
- * const result = await detectShopifyCountry(html);
51
- *
52
- * console.log(result.country); // "US" (ISO code for United States)
53
- * console.log(result.confidence); // 0.85
54
- * console.log(result.signals); // ["shopify-features.country", "phone prefix +1"]
55
- * ```
56
- */
57
- declare function detectShopifyCountry(html: string): Promise<CountryDetectionResult>;
58
-
59
- declare function extractDomainWithoutSuffix(domain: string): string | null;
60
- declare function generateStoreSlug(domain: string): string;
61
- declare const genProductSlug: ({ handle, storeDomain, }: {
62
- handle: string;
63
- storeDomain: string;
64
- }) => string;
65
- declare const calculateDiscount: (price: number, compareAtPrice?: number) => number;
66
- /**
67
- * Normalize and sanitize a domain string.
68
- *
69
- * Accepts inputs like full URLs, protocol-relative URLs, bare hostnames,
70
- * or strings with paths/query/fragment, and returns a normalized domain.
71
- *
72
- * Examples:
73
- * - "https://WWW.Example.com/path" -> "example.com"
74
- * - "//sub.example.co.uk" -> "example.co.uk"
75
- * - "www.example.com:8080" -> "example.com"
76
- * - "example" -> "example"
77
- */
78
- declare function sanitizeDomain(input: string, opts?: {
79
- stripWWW?: boolean;
80
- }): string;
81
- /**
82
- * Safely parse a date string into a Date object.
83
- *
84
- * Returns `undefined` when input is falsy or cannot be parsed into a valid date.
85
- * Use `|| null` at call sites that expect `null` instead of `undefined`.
86
- */
87
- declare function safeParseDate(input?: string | null): Date | undefined;
88
-
89
- /**
90
- * A comprehensive Shopify store client for fetching products, collections, and store information.
91
- *
92
- * @example
93
- * ```typescript
94
- * import { ShopClient } from 'shop-search';
95
- *
96
- * const shop = new ShopClient('https://exampleshop.com');
97
- *
98
- * // Fetch all products
99
- * const products = await shop.products.all();
100
- *
101
- * // Get store information
102
- * const storeInfo = await shop.getInfo();
103
- * ```
104
- */
105
- declare class ShopClient {
106
- private storeDomain;
107
- private baseUrl;
108
- private storeSlug;
109
- private validationCache;
110
- private cacheExpiry;
111
- private cacheTimestamps;
112
- private normalizeImageUrlCache;
113
- private storeCurrency?;
114
- products: ProductOperations;
115
- collections: CollectionOperations;
116
- checkout: CheckoutOperations;
117
- storeOperations: StoreOperations;
118
- /**
119
- * Creates a new ShopClient instance for interacting with a Shopify store.
120
- *
121
- * @param urlPath - The Shopify store URL (e.g., 'https://exampleshop.com' or 'exampleshop.com')
122
- *
123
- * @throws {Error} When the URL is invalid or contains malicious patterns
124
- *
125
- * @example
126
- * ```typescript
127
- * // With full URL
128
- * const shop = new ShopClient('https://exampleshop.com');
129
- *
130
- * // Without protocol (automatically adds https://)
131
- * const shop = new ShopClient('exampleshop.com');
132
- *
133
- * // Works with any Shopify store domain
134
- * const shop1 = new ShopClient('https://example.myshopify.com');
135
- * const shop2 = new ShopClient('https://boutique.fashion');
136
- * ```
137
- */
138
- constructor(urlPath: string);
139
- /**
140
- * Optimized image URL normalization with caching
141
- */
142
- private normalizeImageUrl;
143
- /**
144
- * Format a price amount (in cents) using the store currency.
145
- */
146
- private formatPrice;
147
- /**
148
- * Transform Shopify products to our Product format
149
- */
150
- productsDto(products: ShopifyProduct[]): Product[] | null;
151
- productDto(product: ShopifySingleProduct): Product;
152
- collectionsDto(collections: ShopifyCollection[]): Collection[];
153
- /**
154
- * Enhanced error handling with context
155
- */
156
- private handleFetchError;
157
- /**
158
- * Fetch products with pagination
159
- */
160
- private fetchProducts;
161
- /**
162
- * Fetch collections with pagination
163
- */
164
- private fetchCollections;
165
- /**
166
- * Fetch paginated products from a specific collection
167
- */
168
- private fetchPaginatedProductsFromCollection;
169
- /**
170
- * Validate if a product exists (with caching)
171
- */
172
- private validateProductExists;
173
- /**
174
- * Validate if a collection exists (with caching)
175
- */
176
- private validateCollectionExists;
177
- /**
178
- * Check if cache entry is still valid
179
- */
180
- private isCacheValid;
181
- /**
182
- * Set cache value with timestamp
183
- */
184
- private setCacheValue;
185
- /**
186
- * Validate links in batches to avoid overwhelming the server
187
- */
188
- private validateLinksInBatches;
189
- /**
190
- * Fetches comprehensive store information including metadata, social links, and showcase content.
191
- *
192
- * @returns {Promise<StoreInfo>} Store information object containing:
193
- * - `name` - Store name from meta tags or domain
194
- * - `domain` - Store domain URL
195
- * - `slug` - Generated store slug
196
- * - `title` - Store title from meta tags
197
- * - `description` - Store description from meta tags
198
- * - `logoUrl` - Store logo URL from Open Graph or CDN
199
- * - `socialLinks` - Object with social media links (facebook, twitter, instagram, etc.)
200
- * - `contactLinks` - Object with contact information (tel, email, contactPage)
201
- * - `headerLinks` - Array of navigation links from header
202
- * - `showcase` - Object with featured products and collections from homepage
203
- * - `jsonLdData` - Structured data from JSON-LD scripts
204
- * - `techProvider` - Shopify-specific information (walletId, subDomain)
205
- * - `country` - Country detection results with ISO 3166-1 alpha-2 codes (e.g., "US", "GB")
206
- *
207
- * @throws {Error} When the store URL is unreachable or returns an error
208
- *
209
- * @example
210
- * ```typescript
211
- * const shop = new ShopClient('https://exampleshop.com');
212
- * const storeInfo = await shop.getInfo();
213
- *
214
- * console.log(storeInfo.name); // "Example Store"
215
- * console.log(storeInfo.socialLinks.instagram); // "https://instagram.com/example"
216
- * console.log(storeInfo.showcase.products); // ["product-handle-1", "product-handle-2"]
217
- * console.log(storeInfo.country); // "US"
218
- * ```
219
- */
220
- getInfo(): Promise<StoreInfo>;
221
- /**
222
- * Determine the store's primary vertical and target audience.
223
- * Uses `getInfo()` internally; no input required.
224
- */
225
- determineStoreType(options?: {
226
- apiKey?: string;
227
- model?: string;
228
- maxShowcaseProducts?: number;
229
- maxShowcaseCollections?: number;
230
- }): Promise<StoreTypeBreakdown>;
231
- }
232
-
233
- export { CheckoutOperations, Collection, CollectionOperations, CountryDetectionResult, Product, ProductClassification, ProductOperations, SEOContent, ShopClient, ShopifyCollection, ShopifyProduct, ShopifySingleProduct, StoreInfo, StoreOperations, StoreTypeBreakdown, calculateDiscount, classifyProduct, detectShopifyCountry, extractDomainWithoutSuffix, genProductSlug, generateSEOContent, generateStoreSlug, safeParseDate, sanitizeDomain };