shop-client 3.16.0 → 3.18.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.
- package/README.md +74 -7
- package/dist/ai/enrich.d.ts +1 -1
- package/dist/ai/enrich.mjs +2 -2
- package/dist/{chunk-QCB3U4AO.mjs → chunk-242GBM2V.mjs} +136 -14
- package/dist/{chunk-ZX4IG4TY.mjs → chunk-5TGMDRUF.mjs} +88 -44
- package/dist/chunk-6XDBGOFZ.mjs +804 -0
- package/dist/{chunk-D5MTUWFO.mjs → chunk-O77Z6OBJ.mjs} +21 -6
- package/dist/{chunk-G7OCMGA6.mjs → chunk-SBHTEKLB.mjs} +3 -1
- package/dist/{chunk-OA76XD32.mjs → chunk-YWAW6C74.mjs} +5 -5
- package/dist/collections.d.ts +16 -2
- package/dist/collections.mjs +2 -2
- package/dist/index.d.ts +8 -4
- package/dist/index.mjs +180 -79
- package/dist/products.d.ts +65 -2
- package/dist/products.mjs +2 -2
- package/dist/store.d.ts +1 -1
- package/dist/store.mjs +3 -3
- package/dist/{types-BRXamZMS.d.ts → types-B4WDm14E.d.ts} +58 -1
- package/dist/utils/detect-country.d.ts +1 -1
- package/dist/utils/detect-country.mjs +1 -1
- package/dist/utils/func.d.ts +1 -1
- package/dist/utils/rate-limit.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-THCO3JT4.mjs +0 -593
package/dist/products.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShopInfo } from './store.js';
|
|
2
|
-
import { f as CurrencyCode, P as Product,
|
|
2
|
+
import { f as CurrencyCode, P as Product, E as EnhancedProductResponse, l as ProductClassification, m as SEOContent, M as MinimalProduct, S as ShopifyProduct, a as ShopifySingleProduct, O as OpenRouterConfig } from './types-B4WDm14E.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Interface for product operations
|
|
@@ -7,12 +7,14 @@ import { f as CurrencyCode, P as Product, k as ProductClassification, l as SEOCo
|
|
|
7
7
|
interface ProductOperations {
|
|
8
8
|
/**
|
|
9
9
|
* Fetches all products from the store across all pages.
|
|
10
|
+
* Use `shop.products.minimal.all()` for MinimalProduct returns.
|
|
10
11
|
*/
|
|
11
12
|
all(options?: {
|
|
12
13
|
currency?: CurrencyCode;
|
|
13
14
|
}): Promise<Product[] | null>;
|
|
14
15
|
/**
|
|
15
16
|
* Fetches products with pagination support.
|
|
17
|
+
* Use `shop.products.minimal.paginated()` for MinimalProduct returns.
|
|
16
18
|
*/
|
|
17
19
|
paginated(options?: {
|
|
18
20
|
page?: number;
|
|
@@ -21,10 +23,23 @@ interface ProductOperations {
|
|
|
21
23
|
}): Promise<Product[] | null>;
|
|
22
24
|
/**
|
|
23
25
|
* Finds a specific product by its handle.
|
|
26
|
+
* Use `shop.products.minimal.find()` for MinimalProduct returns.
|
|
24
27
|
*/
|
|
25
28
|
find(productHandle: string, options?: {
|
|
26
29
|
currency?: CurrencyCode;
|
|
27
30
|
}): Promise<Product | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Finds a product and enhances it with AI-generated content using an external service.
|
|
33
|
+
*
|
|
34
|
+
* @param productHandle - The handle of the product to find.
|
|
35
|
+
* @param options - Options for the request.
|
|
36
|
+
* @param options.apiKey - API key for the enhancement service.
|
|
37
|
+
* @param options.endpoint - Optional custom endpoint URL for the enhancement service. Defaults to the standard worker URL.
|
|
38
|
+
*/
|
|
39
|
+
findEnhanced(productHandle: string, options?: {
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
endpoint?: string;
|
|
42
|
+
}): Promise<EnhancedProductResponse | null>;
|
|
28
43
|
/**
|
|
29
44
|
* Finds a product by handle and enriches its content using LLM.
|
|
30
45
|
* Requires an OpenRouter API key via options.apiKey or ShopClient options.
|
|
@@ -76,12 +91,22 @@ interface ProductOperations {
|
|
|
76
91
|
* Fetches products that are showcased/featured on the store's homepage.
|
|
77
92
|
*/
|
|
78
93
|
showcased(): Promise<Product[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Showcase namespace for convenience methods related to featured items.
|
|
96
|
+
*/
|
|
97
|
+
showcase: {
|
|
98
|
+
/**
|
|
99
|
+
* Returns showcased products in MinimalProduct form.
|
|
100
|
+
*/
|
|
101
|
+
minimal(): Promise<MinimalProduct[]>;
|
|
102
|
+
};
|
|
79
103
|
/**
|
|
80
104
|
* Creates a filter map of variant options and their distinct values from all products.
|
|
81
105
|
*/
|
|
82
106
|
filter(): Promise<Record<string, string[]> | null>;
|
|
83
107
|
/**
|
|
84
108
|
* Predictive product search using Shopify Ajax API.
|
|
109
|
+
* Use `shop.products.minimal.predictiveSearch()` for MinimalProduct returns.
|
|
85
110
|
*/
|
|
86
111
|
predictiveSearch(query: string, options?: {
|
|
87
112
|
limit?: number;
|
|
@@ -91,6 +116,7 @@ interface ProductOperations {
|
|
|
91
116
|
}): Promise<Product[]>;
|
|
92
117
|
/**
|
|
93
118
|
* Product recommendations for a given product ID using Shopify Ajax API.
|
|
119
|
+
* Use `shop.products.minimal.recommendations()` for MinimalProduct returns.
|
|
94
120
|
*/
|
|
95
121
|
recommendations(productId: number, options?: {
|
|
96
122
|
limit?: number;
|
|
@@ -98,11 +124,48 @@ interface ProductOperations {
|
|
|
98
124
|
locale?: string;
|
|
99
125
|
currency?: CurrencyCode;
|
|
100
126
|
}): Promise<Product[] | null>;
|
|
127
|
+
/**
|
|
128
|
+
* Minimal namespace for convenience methods that always return MinimalProduct types.
|
|
129
|
+
*/
|
|
130
|
+
minimal: {
|
|
131
|
+
all(options?: {
|
|
132
|
+
currency?: CurrencyCode;
|
|
133
|
+
}): Promise<MinimalProduct[] | null>;
|
|
134
|
+
paginated(options?: {
|
|
135
|
+
page?: number;
|
|
136
|
+
limit?: number;
|
|
137
|
+
currency?: CurrencyCode;
|
|
138
|
+
}): Promise<MinimalProduct[] | null>;
|
|
139
|
+
find(productHandle: string, options?: {
|
|
140
|
+
currency?: CurrencyCode;
|
|
141
|
+
}): Promise<MinimalProduct | null>;
|
|
142
|
+
showcased(): Promise<MinimalProduct[]>;
|
|
143
|
+
predictiveSearch(query: string, options?: {
|
|
144
|
+
limit?: number;
|
|
145
|
+
locale?: string;
|
|
146
|
+
currency?: CurrencyCode;
|
|
147
|
+
unavailableProducts?: "show" | "hide" | "last";
|
|
148
|
+
}): Promise<MinimalProduct[]>;
|
|
149
|
+
recommendations(productId: number, options?: {
|
|
150
|
+
limit?: number;
|
|
151
|
+
intent?: "related" | "complementary";
|
|
152
|
+
locale?: string;
|
|
153
|
+
currency?: CurrencyCode;
|
|
154
|
+
}): Promise<MinimalProduct[] | null>;
|
|
155
|
+
};
|
|
101
156
|
}
|
|
102
157
|
/**
|
|
103
158
|
* Creates product operations for a store instance
|
|
104
159
|
*/
|
|
105
|
-
declare function createProductOperations(baseUrl: string, storeDomain: string, fetchProducts: (page: number, limit: number
|
|
160
|
+
declare function createProductOperations(baseUrl: string, storeDomain: string, fetchProducts: (page: number, limit: number, options?: {
|
|
161
|
+
minimal?: boolean;
|
|
162
|
+
}) => Promise<Product[] | MinimalProduct[] | null>, productsDto: (products: ShopifyProduct[], options?: {
|
|
163
|
+
minimal?: boolean;
|
|
164
|
+
}) => Product[] | MinimalProduct[] | null, productDto: (product: ShopifySingleProduct, options?: {
|
|
165
|
+
minimal?: boolean;
|
|
166
|
+
}) => Product | MinimalProduct, getStoreInfo: () => Promise<ShopInfo>, _findProduct: (handle: string, options?: {
|
|
167
|
+
minimal?: boolean;
|
|
168
|
+
}) => Promise<Product | MinimalProduct | null>, ai?: {
|
|
106
169
|
openRouter?: OpenRouterConfig;
|
|
107
170
|
}): ProductOperations;
|
|
108
171
|
|
package/dist/products.mjs
CHANGED
package/dist/store.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as JsonLdEntry, d as CountryDetectionResult, f as CurrencyCode } from './types-
|
|
1
|
+
import { J as JsonLdEntry, d as CountryDetectionResult, f as CurrencyCode } from './types-B4WDm14E.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Store operations interface for managing store-related functionality.
|
package/dist/store.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createShopOperations
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-YWAW6C74.mjs";
|
|
4
|
+
import "./chunk-O77Z6OBJ.mjs";
|
|
5
|
+
import "./chunk-SBHTEKLB.mjs";
|
|
6
6
|
import "./chunk-U3RQRBXZ.mjs";
|
|
7
7
|
export {
|
|
8
8
|
createShopOperations
|
|
@@ -116,6 +116,7 @@ type ShopifyProductVariant = ShopifyBaseVariant & {
|
|
|
116
116
|
} | null;
|
|
117
117
|
available: boolean;
|
|
118
118
|
price: string | number;
|
|
119
|
+
grams?: number | undefined;
|
|
119
120
|
weightInGrams?: number | undefined;
|
|
120
121
|
compare_at_price?: string | number | undefined;
|
|
121
122
|
};
|
|
@@ -321,6 +322,31 @@ type Product = {
|
|
|
321
322
|
variantOptionsMap: Record<string, string>;
|
|
322
323
|
enriched_content?: string;
|
|
323
324
|
};
|
|
325
|
+
/**
|
|
326
|
+
* Minimal product structure with reduced data.
|
|
327
|
+
*/
|
|
328
|
+
type MinimalProduct = {
|
|
329
|
+
title: string;
|
|
330
|
+
bodyHtml: string | null;
|
|
331
|
+
price: number;
|
|
332
|
+
compareAtPrice: number;
|
|
333
|
+
discount: number;
|
|
334
|
+
images: {
|
|
335
|
+
src: string;
|
|
336
|
+
}[];
|
|
337
|
+
featuredImage: string | null;
|
|
338
|
+
available: boolean;
|
|
339
|
+
localizedPricing: Pick<LocalizedPricing, "priceFormatted" | "compareAtPriceFormatted">;
|
|
340
|
+
options: {
|
|
341
|
+
key: string;
|
|
342
|
+
name: string;
|
|
343
|
+
values: string[];
|
|
344
|
+
}[];
|
|
345
|
+
variantOptionsMap: Record<string, string>;
|
|
346
|
+
url: string;
|
|
347
|
+
slug: string;
|
|
348
|
+
platformId: string;
|
|
349
|
+
};
|
|
324
350
|
/**
|
|
325
351
|
* Shopify collection structure from API responses.
|
|
326
352
|
*/
|
|
@@ -409,6 +435,37 @@ type SEOContent = {
|
|
|
409
435
|
tags: string[];
|
|
410
436
|
marketingCopy: string;
|
|
411
437
|
};
|
|
438
|
+
type EnhancedProductImage = {
|
|
439
|
+
textContext: string;
|
|
440
|
+
url: string;
|
|
441
|
+
alt: string;
|
|
442
|
+
};
|
|
443
|
+
type EnhancedProductCanonical = {
|
|
444
|
+
title: string;
|
|
445
|
+
summary: string;
|
|
446
|
+
highlights: string[];
|
|
447
|
+
materials: unknown;
|
|
448
|
+
fit_and_size: unknown;
|
|
449
|
+
care: unknown;
|
|
450
|
+
what_makes_it_special: unknown;
|
|
451
|
+
missing_info: unknown[];
|
|
452
|
+
images: EnhancedProductImage[];
|
|
453
|
+
};
|
|
454
|
+
type EnhancedProductEnrichment = {
|
|
455
|
+
canonical: EnhancedProductCanonical;
|
|
456
|
+
markdown: string;
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
* The response object from the enhanced product search.
|
|
460
|
+
*/
|
|
461
|
+
type EnhancedProductResponse = {
|
|
462
|
+
/** The original Shopify product data. */
|
|
463
|
+
shopify: ShopifyProduct;
|
|
464
|
+
/** The AI-enriched content. */
|
|
465
|
+
enrichment: EnhancedProductEnrichment;
|
|
466
|
+
/** Cache status of the response (e.g., 'hit', 'miss'). */
|
|
467
|
+
cache: string;
|
|
468
|
+
};
|
|
412
469
|
type StoreTypeBreakdown = Partial<Record<"adult_male" | "adult_female" | "kid_male" | "kid_female" | "generic", Partial<Record<"clothing" | "beauty" | "accessories" | "home-decor" | "food-and-beverages", string[]>>>>;
|
|
413
470
|
|
|
414
|
-
export type { Collection as C, JsonLdEntry as J, LocalizedPricing as L,
|
|
471
|
+
export type { Collection as C, EnhancedProductResponse as E, JsonLdEntry as J, LocalizedPricing as L, MinimalProduct as M, OpenRouterConfig as O, Product as P, ShopifyProduct as S, ShopifySingleProduct as a, ShopifyCollection as b, StoreTypeBreakdown as c, CountryDetectionResult as d, CountryScores as e, CurrencyCode as f, MetaTag as g, ProductImage as h, ProductOption as i, ProductVariant as j, ProductVariantImage as k, ProductClassification as l, SEOContent as m, SystemUserPrompt as n };
|
package/dist/utils/func.d.ts
CHANGED