shop-client 3.14.1 → 3.16.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.
@@ -1,5 +1,5 @@
1
1
  import { ShopInfo } from './store.js';
2
- import { C as Collection, f as CurrencyCode, P as Product, b as ShopifyCollection } from './types-luPg5O08.js';
2
+ import { C as Collection, f as CurrencyCode, P as Product, b as ShopifyCollection } from './types-BRXamZMS.js';
3
3
 
4
4
  /**
5
5
  * Interface for collection operations
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createCollectionOperations
3
- } from "./chunk-554O5ED6.mjs";
3
+ } from "./chunk-QCB3U4AO.mjs";
4
4
  import "./chunk-D5MTUWFO.mjs";
5
5
  import "./chunk-U3RQRBXZ.mjs";
6
6
  export {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ShopifyProduct, P as Product, a as ShopifySingleProduct, b as ShopifyCollection, C as Collection, J as JsonLdEntry, c as StoreTypeBreakdown } from './types-luPg5O08.js';
2
- export { d as CountryDetectionResult, e as CountryScores, f as CurrencyCode, L as LocalizedPricing, M as MetaTag, g as ProductImage, h as ProductOption, i as ProductVariant, j as ProductVariantImage } from './types-luPg5O08.js';
1
+ import { O as OpenRouterConfig, S as ShopifyProduct, P as Product, a as ShopifySingleProduct, b as ShopifyCollection, C as Collection, J as JsonLdEntry, c as StoreTypeBreakdown } from './types-BRXamZMS.js';
2
+ export { d as CountryDetectionResult, e as CountryScores, f as CurrencyCode, L as LocalizedPricing, M as MetaTag, g as ProductImage, h as ProductOption, i as ProductVariant, j as ProductVariantImage } from './types-BRXamZMS.js';
3
3
  import { CheckoutOperations } from './checkout.js';
4
4
  import { CollectionOperations } from './collections.js';
5
5
  import { ProductOperations } from './products.js';
@@ -27,11 +27,13 @@ export { configureRateLimit } from './utils/rate-limit.js';
27
27
  */
28
28
  type ShopClientOptions = {
29
29
  cacheTTL?: number;
30
+ openRouter?: OpenRouterConfig;
30
31
  };
31
32
  declare class ShopClient {
32
33
  private storeDomain;
33
34
  private baseUrl;
34
35
  private storeSlug;
36
+ private openRouter?;
35
37
  private validationCache;
36
38
  private cacheExpiry;
37
39
  private cacheTimestamps;
@@ -186,4 +188,4 @@ declare class ShopClient {
186
188
  }): Promise<StoreTypeBreakdown>;
187
189
  }
188
190
 
189
- export { CheckoutOperations, Collection, CollectionOperations, OpenGraphMeta, Product, ProductOperations, ShopClient, type ShopClientOptions, ShopInfo, ShopOperations, StoreTypeBreakdown };
191
+ export { CheckoutOperations, Collection, CollectionOperations, OpenGraphMeta, OpenRouterConfig, Product, ProductOperations, ShopClient, type ShopClientOptions, ShopInfo, ShopOperations, StoreTypeBreakdown };
package/dist/index.mjs CHANGED
@@ -3,19 +3,19 @@ import {
3
3
  } from "./chunk-W4SF6W2P.mjs";
4
4
  import {
5
5
  createCollectionOperations
6
- } from "./chunk-554O5ED6.mjs";
6
+ } from "./chunk-QCB3U4AO.mjs";
7
7
  import {
8
8
  createProductOperations
9
- } from "./chunk-ZF4M6GMB.mjs";
9
+ } from "./chunk-THCO3JT4.mjs";
10
10
  import {
11
11
  createShopOperations,
12
12
  getInfoForShop
13
- } from "./chunk-7IMI76JZ.mjs";
13
+ } from "./chunk-OA76XD32.mjs";
14
14
  import {
15
15
  classifyProduct,
16
16
  determineStoreType,
17
17
  generateSEOContent
18
- } from "./chunk-GNIBTUEK.mjs";
18
+ } from "./chunk-ZX4IG4TY.mjs";
19
19
  import {
20
20
  configureRateLimit,
21
21
  rateLimitedFetch
@@ -55,7 +55,7 @@ async function determineStoreTypeForStore(args) {
55
55
  collections: collectionsSample
56
56
  }
57
57
  },
58
- { apiKey: args.apiKey, model: args.model }
58
+ { apiKey: args.apiKey, model: args.model, openRouter: args.openRouter }
59
59
  );
60
60
  return breakdown;
61
61
  }
@@ -353,6 +353,7 @@ var ShopClient = class {
353
353
  if (typeof (options == null ? void 0 : options.cacheTTL) === "number" && options.cacheTTL > 0) {
354
354
  this.cacheExpiry = options.cacheTTL;
355
355
  }
356
+ this.openRouter = options == null ? void 0 : options.openRouter;
356
357
  this.shopOperations = createShopOperations({
357
358
  baseUrl: this.baseUrl,
358
359
  storeDomain: this.storeDomain,
@@ -368,7 +369,8 @@ var ShopClient = class {
368
369
  this.productsDto.bind(this),
369
370
  this.productDto.bind(this),
370
371
  () => this.getInfo(),
371
- (handle) => this.products.find(handle)
372
+ (handle) => this.products.find(handle),
373
+ { openRouter: this.openRouter }
372
374
  );
373
375
  this.collections = createCollectionOperations(
374
376
  this.baseUrl,
@@ -786,12 +788,14 @@ var ShopClient = class {
786
788
  */
787
789
  async determineStoreType(options) {
788
790
  try {
791
+ const openRouter = this.openRouter;
789
792
  const breakdown = await determineStoreTypeForStore({
790
793
  baseUrl: this.baseUrl,
791
794
  getInfo: () => this.getInfo(),
792
795
  findProduct: (handle) => this.products.find(handle),
793
796
  apiKey: options == null ? void 0 : options.apiKey,
794
797
  model: options == null ? void 0 : options.model,
798
+ openRouter,
795
799
  maxShowcaseProducts: options == null ? void 0 : options.maxShowcaseProducts,
796
800
  maxShowcaseCollections: options == null ? void 0 : options.maxShowcaseCollections
797
801
  });
@@ -1,5 +1,5 @@
1
1
  import { ShopInfo } from './store.js';
2
- import { f as CurrencyCode, P as Product, k as ProductClassification, l as SEOContent, S as ShopifyProduct, a as ShopifySingleProduct } from './types-luPg5O08.js';
2
+ import { f as CurrencyCode, P as Product, k as ProductClassification, l as SEOContent, S as ShopifyProduct, a as ShopifySingleProduct, O as OpenRouterConfig } from './types-BRXamZMS.js';
3
3
 
4
4
  /**
5
5
  * Interface for product operations
@@ -27,7 +27,7 @@ interface ProductOperations {
27
27
  }): Promise<Product | null>;
28
28
  /**
29
29
  * Finds a product by handle and enriches its content using LLM.
30
- * Requires an OpenAI API key via options.apiKey or process.env.OPENAI_API_KEY.
30
+ * Requires an OpenRouter API key via options.apiKey or ShopClient options.
31
31
  */
32
32
  enriched(productHandle: string, options?: {
33
33
  apiKey?: string;
@@ -35,11 +35,30 @@ interface ProductOperations {
35
35
  inputType?: "markdown" | "html";
36
36
  model?: string;
37
37
  outputFormat?: "markdown" | "json";
38
+ content?: string;
38
39
  }): Promise<Product | null>;
40
+ enrichedPrompts(productHandle: string, options?: {
41
+ useGfm?: boolean;
42
+ inputType?: "markdown" | "html";
43
+ outputFormat?: "markdown" | "json";
44
+ content?: string;
45
+ }): Promise<{
46
+ system: string;
47
+ user: string;
48
+ }>;
39
49
  classify(productHandle: string, options?: {
40
50
  apiKey?: string;
41
51
  model?: string;
52
+ content?: string;
42
53
  }): Promise<ProductClassification | null>;
54
+ classifyPrompts(productHandle: string, options?: {
55
+ useGfm?: boolean;
56
+ inputType?: "markdown" | "html";
57
+ content?: string;
58
+ }): Promise<{
59
+ system: string;
60
+ user: string;
61
+ }>;
43
62
  /**
44
63
  * Generate SEO and marketing content for a product.
45
64
  */
@@ -47,6 +66,12 @@ interface ProductOperations {
47
66
  apiKey?: string;
48
67
  model?: string;
49
68
  }): Promise<SEOContent | null>;
69
+ /**
70
+ * Fetches the extracted HTML content from the product page.
71
+ * This is useful for getting the main product description and content directly from the page HTML.
72
+ * If content is provided, it is used directly to extract the main section.
73
+ */
74
+ infoHtml(productHandle: string, content?: string): Promise<string | null>;
50
75
  /**
51
76
  * Fetches products that are showcased/featured on the store's homepage.
52
77
  */
@@ -77,6 +102,8 @@ interface ProductOperations {
77
102
  /**
78
103
  * Creates product operations for a store instance
79
104
  */
80
- declare function createProductOperations(baseUrl: string, storeDomain: string, fetchProducts: (page: number, limit: number) => Promise<Product[] | null>, productsDto: (products: ShopifyProduct[]) => Product[] | null, productDto: (product: ShopifySingleProduct) => Product, getStoreInfo: () => Promise<ShopInfo>, findProduct: (handle: string) => Promise<Product | null>): ProductOperations;
105
+ declare function createProductOperations(baseUrl: string, storeDomain: string, fetchProducts: (page: number, limit: number) => Promise<Product[] | null>, productsDto: (products: ShopifyProduct[]) => Product[] | null, productDto: (product: ShopifySingleProduct) => Product, getStoreInfo: () => Promise<ShopInfo>, findProduct: (handle: string) => Promise<Product | null>, ai?: {
106
+ openRouter?: OpenRouterConfig;
107
+ }): ProductOperations;
81
108
 
82
109
  export { type ProductOperations, createProductOperations };
package/dist/products.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createProductOperations
3
- } from "./chunk-ZF4M6GMB.mjs";
3
+ } from "./chunk-THCO3JT4.mjs";
4
4
  import "./chunk-D5MTUWFO.mjs";
5
5
  import "./chunk-U3RQRBXZ.mjs";
6
6
  export {
package/dist/store.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { J as JsonLdEntry, d as CountryDetectionResult, f as CurrencyCode } from './types-luPg5O08.js';
1
+ import { J as JsonLdEntry, d as CountryDetectionResult, f as CurrencyCode } from './types-BRXamZMS.js';
2
2
 
3
3
  /**
4
4
  * Store operations interface for managing store-related functionality.
package/dist/store.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createShopOperations
3
- } from "./chunk-7IMI76JZ.mjs";
3
+ } from "./chunk-OA76XD32.mjs";
4
4
  import "./chunk-D5MTUWFO.mjs";
5
5
  import "./chunk-G7OCMGA6.mjs";
6
6
  import "./chunk-U3RQRBXZ.mjs";
@@ -1,3 +1,16 @@
1
+ type OpenRouterConfig = {
2
+ apiKey?: string;
3
+ model?: string;
4
+ fallbackModels?: string[];
5
+ baseUrl?: string;
6
+ siteUrl?: string;
7
+ appTitle?: string;
8
+ offline?: boolean;
9
+ };
10
+ type SystemUserPrompt = {
11
+ system: string;
12
+ user: string;
13
+ };
1
14
  /**
2
15
  * Base timestamp fields used across Shopify entities.
3
16
  */
@@ -398,4 +411,4 @@ type SEOContent = {
398
411
  };
399
412
  type StoreTypeBreakdown = Partial<Record<"adult_male" | "adult_female" | "kid_male" | "kid_female" | "generic", Partial<Record<"clothing" | "beauty" | "accessories" | "home-decor" | "food-and-beverages", string[]>>>>;
400
413
 
401
- export type { Collection as C, JsonLdEntry as J, LocalizedPricing as L, MetaTag as M, Product as P, ShopifyProduct as S, ShopifySingleProduct as a, ShopifyCollection as b, StoreTypeBreakdown as c, CountryDetectionResult as d, CountryScores as e, CurrencyCode as f, ProductImage as g, ProductOption as h, ProductVariant as i, ProductVariantImage as j, ProductClassification as k, SEOContent as l };
414
+ export type { Collection as C, JsonLdEntry as J, LocalizedPricing as L, MetaTag 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, ProductImage as g, ProductOption as h, ProductVariant as i, ProductVariantImage as j, ProductClassification as k, SEOContent as l, SystemUserPrompt as m };
@@ -1,4 +1,4 @@
1
- import { d as CountryDetectionResult } from '../types-luPg5O08.js';
1
+ import { d as CountryDetectionResult } from '../types-BRXamZMS.js';
2
2
 
3
3
  /**
4
4
  * Detects the country of a Shopify store by analyzing various signals in the HTML content.
@@ -1,4 +1,4 @@
1
- import { f as CurrencyCode } from '../types-luPg5O08.js';
1
+ import { f as CurrencyCode } from '../types-BRXamZMS.js';
2
2
 
3
3
  declare function extractDomainWithoutSuffix(domain: string): string | null;
4
4
  declare function generateStoreSlug(domain: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shop-client",
3
- "version": "3.14.1",
3
+ "version": "3.16.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",