shop-client 3.14.0 → 3.15.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 +23 -22
- package/dist/ai/enrich.d.ts +24 -3
- package/dist/ai/enrich.mjs +9 -1
- package/dist/{chunk-GNIBTUEK.mjs → chunk-2W623LCW.mjs} +384 -206
- package/dist/{chunk-ZF4M6GMB.mjs → chunk-ESTBP7AD.mjs} +51 -26
- package/dist/{chunk-RLVH7LEG.mjs → chunk-OA76XD32.mjs} +143 -7
- package/dist/{chunk-554O5ED6.mjs → chunk-QCB3U4AO.mjs} +12 -1
- package/dist/collections.d.ts +3 -3
- package/dist/collections.mjs +1 -1
- package/dist/index.d.ts +20 -6
- package/dist/index.mjs +68 -10
- package/dist/products.d.ts +21 -4
- package/dist/products.mjs +1 -1
- package/dist/store.d.ts +19 -7
- package/dist/store.mjs +3 -3
- package/dist/{types-luPg5O08.d.ts → types-BRXamZMS.d.ts} +14 -1
- package/dist/utils/detect-country.d.ts +1 -1
- package/dist/utils/func.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -699,14 +699,11 @@ Determine the store’s primary verticals and target audiences using showcased p
|
|
|
699
699
|
```typescript
|
|
700
700
|
import { ShopClient } from 'shop-client';
|
|
701
701
|
|
|
702
|
-
const shop = new ShopClient('your-store-domain.com'
|
|
702
|
+
const shop = new ShopClient('your-store-domain.com', {
|
|
703
|
+
openRouter: { apiKey: 'YOUR_OPENROUTER_API_KEY', model: 'openai/gpt-4o-mini' },
|
|
704
|
+
});
|
|
703
705
|
|
|
704
706
|
const breakdown = await shop.determineStoreType({
|
|
705
|
-
// Optional: provide an OpenRouter API key for online classification
|
|
706
|
-
// Offline mode falls back to regex heuristics if no key is set
|
|
707
|
-
apiKey: process.env.OPENROUTER_API_KEY,
|
|
708
|
-
// Optional: model name when using online classification
|
|
709
|
-
model: 'openai/gpt-4o-mini',
|
|
710
707
|
// Optional: limit the number of showcased products sampled (default 10, max 50)
|
|
711
708
|
maxShowcaseProducts: 12,
|
|
712
709
|
// Note: showcased collections are not used for classification
|
|
@@ -724,34 +721,38 @@ Details:
|
|
|
724
721
|
- Uses only `product.bodyHtml` for classification (no images or external text).
|
|
725
722
|
- Samples up to `maxShowcaseProducts` from `getInfo().showcase.products`.
|
|
726
723
|
- Aggregates per-product audience/vertical into a multi-audience breakdown.
|
|
727
|
-
- If `
|
|
724
|
+
- If `openRouter.offline` is `true`, uses offline regex heuristics. Otherwise, an OpenRouter API key is required (via `ShopClient` options or `determineStoreType({ apiKey })`).
|
|
728
725
|
- Applies store-level pruning based on title/description to improve consistency.
|
|
729
726
|
|
|
730
727
|
### AI Enrichment
|
|
731
728
|
|
|
732
729
|
```typescript
|
|
733
|
-
import {
|
|
730
|
+
import { ShopClient } from 'shop-client';
|
|
731
|
+
|
|
732
|
+
const shop = new ShopClient('your-store-domain.com', {
|
|
733
|
+
openRouter: { apiKey: 'YOUR_OPENROUTER_API_KEY', model: 'openai/gpt-4o-mini' },
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
// Merge API (Ajax) + product page content into a clean description
|
|
737
|
+
const enrichedMarkdown = await shop.products.enriched('some-product-handle', {
|
|
738
|
+
outputFormat: 'markdown',
|
|
739
|
+
});
|
|
740
|
+
// enrichedMarkdown?.enriched_content → markdown
|
|
734
741
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
title: 'Organic Cotton T-Shirt',
|
|
738
|
-
bodyHtml: '<p>Soft, breathable cotton tee</p>',
|
|
739
|
-
tags: ['organic', 'cotton', 'unisex'],
|
|
742
|
+
const enrichedJson = await shop.products.enriched('some-product-handle', {
|
|
743
|
+
outputFormat: 'json',
|
|
740
744
|
});
|
|
741
|
-
//
|
|
745
|
+
// enrichedJson?.enriched_content → JSON string (validated)
|
|
742
746
|
|
|
743
|
-
//
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
description: 'Soft, breathable tee for everyday wear',
|
|
747
|
-
tags: ['organic', 'cotton', 'unisex'],
|
|
747
|
+
// Build prompts without calling the LLM (useful for debugging)
|
|
748
|
+
const { system, user } = await shop.products.enrichedPrompts('some-product-handle', {
|
|
749
|
+
outputFormat: 'markdown',
|
|
748
750
|
});
|
|
749
|
-
// seo.metaTitle, seo.metaDescription, seo.keywords
|
|
750
751
|
```
|
|
751
752
|
|
|
752
753
|
Notes:
|
|
753
|
-
- `
|
|
754
|
-
- `
|
|
754
|
+
- `enriched()` returns `enriched_content` as either markdown or a validated JSON string (based on `outputFormat`).
|
|
755
|
+
- `enrichedPrompts()` and `classifyPrompts()` return the prompt pair without making network calls.
|
|
755
756
|
|
|
756
757
|
## 🏗️ Type Definitions
|
|
757
758
|
|
package/dist/ai/enrich.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import { k as ProductClassification, l as SEOContent, a as ShopifySingleProduct } from '../types-
|
|
1
|
+
import { O as OpenRouterConfig, k as ProductClassification, l as SEOContent, m as SystemUserPrompt, a as ShopifySingleProduct } from '../types-BRXamZMS.js';
|
|
2
2
|
|
|
3
|
+
declare function buildEnrichPrompt(args: {
|
|
4
|
+
bodyInput: string;
|
|
5
|
+
pageInput: string;
|
|
6
|
+
inputType: "markdown" | "html";
|
|
7
|
+
outputFormat: "markdown" | "json";
|
|
8
|
+
}): SystemUserPrompt;
|
|
9
|
+
declare function buildClassifyPrompt(productContent: string): SystemUserPrompt;
|
|
10
|
+
declare function buildEnrichPromptForProduct(domain: string, handle: string, options?: {
|
|
11
|
+
useGfm?: boolean;
|
|
12
|
+
inputType?: "markdown" | "html";
|
|
13
|
+
outputFormat?: "markdown" | "json";
|
|
14
|
+
}): Promise<SystemUserPrompt>;
|
|
15
|
+
declare function buildClassifyPromptForProduct(domain: string, handle: string, options?: {
|
|
16
|
+
useGfm?: boolean;
|
|
17
|
+
inputType?: "markdown" | "html";
|
|
18
|
+
}): Promise<SystemUserPrompt>;
|
|
3
19
|
interface EnrichedProductResult {
|
|
4
20
|
bodyHtml: string;
|
|
5
21
|
pageHtml: string;
|
|
@@ -26,7 +42,7 @@ declare function extractMainSection(html: string): string | null;
|
|
|
26
42
|
*/
|
|
27
43
|
declare function htmlToMarkdown(html: string | null, options?: {
|
|
28
44
|
useGfm?: boolean;
|
|
29
|
-
}): string
|
|
45
|
+
}): Promise<string>;
|
|
30
46
|
/**
|
|
31
47
|
* Merge the two markdown sources using OpenAI GPT
|
|
32
48
|
*/
|
|
@@ -35,6 +51,7 @@ declare function mergeWithLLM(bodyInput: string, pageInput: string, options?: {
|
|
|
35
51
|
inputType?: "markdown" | "html";
|
|
36
52
|
model?: string;
|
|
37
53
|
outputFormat?: "markdown" | "json";
|
|
54
|
+
openRouter?: OpenRouterConfig;
|
|
38
55
|
}): Promise<string>;
|
|
39
56
|
/**
|
|
40
57
|
* MAIN WORKFLOW
|
|
@@ -45,6 +62,7 @@ declare function enrichProduct(domain: string, handle: string, options?: {
|
|
|
45
62
|
inputType?: "markdown" | "html";
|
|
46
63
|
model?: string;
|
|
47
64
|
outputFormat?: "markdown" | "json";
|
|
65
|
+
openRouter?: OpenRouterConfig;
|
|
48
66
|
}): Promise<EnrichedProductResult>;
|
|
49
67
|
/**
|
|
50
68
|
* Classify product content into a three-tier hierarchy using LLM.
|
|
@@ -53,6 +71,7 @@ declare function enrichProduct(domain: string, handle: string, options?: {
|
|
|
53
71
|
declare function classifyProduct(productContent: string, options?: {
|
|
54
72
|
apiKey?: string;
|
|
55
73
|
model?: string;
|
|
74
|
+
openRouter?: OpenRouterConfig;
|
|
56
75
|
}): Promise<ProductClassification>;
|
|
57
76
|
/**
|
|
58
77
|
* Generate SEO and marketing content for a product. Returns strictly validated JSON.
|
|
@@ -66,6 +85,7 @@ declare function generateSEOContent(product: {
|
|
|
66
85
|
}, options?: {
|
|
67
86
|
apiKey?: string;
|
|
68
87
|
model?: string;
|
|
88
|
+
openRouter?: OpenRouterConfig;
|
|
69
89
|
}): Promise<SEOContent>;
|
|
70
90
|
/**
|
|
71
91
|
* Determine store type (primary vertical and audience) from store information.
|
|
@@ -87,7 +107,8 @@ declare function determineStoreType(storeInfo: {
|
|
|
87
107
|
}, options?: {
|
|
88
108
|
apiKey?: string;
|
|
89
109
|
model?: string;
|
|
110
|
+
openRouter?: OpenRouterConfig;
|
|
90
111
|
}): Promise<Partial<Record<ProductClassification["audience"], Partial<Record<ProductClassification["vertical"], string[]>>>>>;
|
|
91
112
|
declare function pruneBreakdownForSignals(breakdown: Partial<Record<ProductClassification["audience"], Partial<Record<ProductClassification["vertical"], string[]>>>>, text: string): Partial<Record<ProductClassification["audience"], Partial<Record<ProductClassification["vertical"], string[]>>>>;
|
|
92
113
|
|
|
93
|
-
export { type EnrichedProductResult, classifyProduct, determineStoreType, enrichProduct, extractMainSection, fetchAjaxProduct, fetchProductPage, generateSEOContent, htmlToMarkdown, mergeWithLLM, pruneBreakdownForSignals };
|
|
114
|
+
export { type EnrichedProductResult, buildClassifyPrompt, buildClassifyPromptForProduct, buildEnrichPrompt, buildEnrichPromptForProduct, classifyProduct, determineStoreType, enrichProduct, extractMainSection, fetchAjaxProduct, fetchProductPage, generateSEOContent, htmlToMarkdown, mergeWithLLM, pruneBreakdownForSignals };
|
package/dist/ai/enrich.mjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
buildClassifyPrompt,
|
|
3
|
+
buildClassifyPromptForProduct,
|
|
4
|
+
buildEnrichPrompt,
|
|
5
|
+
buildEnrichPromptForProduct,
|
|
2
6
|
classifyProduct,
|
|
3
7
|
determineStoreType,
|
|
4
8
|
enrichProduct,
|
|
@@ -9,9 +13,13 @@ import {
|
|
|
9
13
|
htmlToMarkdown,
|
|
10
14
|
mergeWithLLM,
|
|
11
15
|
pruneBreakdownForSignals
|
|
12
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-2W623LCW.mjs";
|
|
13
17
|
import "../chunk-D5MTUWFO.mjs";
|
|
14
18
|
export {
|
|
19
|
+
buildClassifyPrompt,
|
|
20
|
+
buildClassifyPromptForProduct,
|
|
21
|
+
buildEnrichPrompt,
|
|
22
|
+
buildEnrichPromptForProduct,
|
|
15
23
|
classifyProduct,
|
|
16
24
|
determineStoreType,
|
|
17
25
|
enrichProduct,
|