shop-client 3.13.0 → 3.14.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 +2 -1
- package/dist/{chunk-CUL7ZM2W.mjs → chunk-RLVH7LEG.mjs} +10 -4
- package/dist/index.mjs +1 -1
- package/dist/store.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,8 +31,9 @@
|
|
|
31
31
|
|
|
32
32
|
## 🧠 Store Info Caching & Concurrency
|
|
33
33
|
|
|
34
|
-
`getInfo()` uses time-based caching and in-flight request deduping to avoid redundant network calls:
|
|
34
|
+
`getInfo()` validates the store URL and uses time-based caching and in-flight request deduping to avoid redundant network calls:
|
|
35
35
|
|
|
36
|
+
- Validation: Ensures the URL points to a valid Shopify store (checks for specific meta tags and scripts). Throws an error if invalid.
|
|
36
37
|
- Cache window: `5 minutes` (`cacheExpiry`). Fresh cached results return immediately.
|
|
37
38
|
- You can configure this TTL via the `ShopClient` constructor option `cacheTTL` (milliseconds).
|
|
38
39
|
- Cached fields: `infoCacheValue` (last `StoreInfo`) and `infoCacheTimestamp` (last fetch time).
|
|
@@ -36,6 +36,13 @@ async function getInfoForStore(args, options) {
|
|
|
36
36
|
const match = html.match(regex);
|
|
37
37
|
return match ? match[1] : null;
|
|
38
38
|
};
|
|
39
|
+
const shopifyWalletId = (_a = getMetaTag("shopify-digital-wallet")) == null ? void 0 : _a.split("/")[1];
|
|
40
|
+
const isShopifyStore = html.includes("cdn.shopify.com") || html.includes("myshopify.com") || html.includes("shopify-digital-wallet") || html.includes("Shopify.shop") || html.includes("Shopify.currency") || html.includes("shopify-section");
|
|
41
|
+
if (!isShopifyStore || !shopifyWalletId) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"The provided URL does not appear to be a valid Shopify store."
|
|
44
|
+
);
|
|
45
|
+
}
|
|
39
46
|
const getPropertyMetaTag = (property) => {
|
|
40
47
|
const regex = new RegExp(
|
|
41
48
|
`<meta[^>]*property=["']${property}["'][^>]*content=["'](.*?)["']`
|
|
@@ -43,10 +50,9 @@ async function getInfoForStore(args, options) {
|
|
|
43
50
|
const match = html.match(regex);
|
|
44
51
|
return match ? match[1] : null;
|
|
45
52
|
};
|
|
46
|
-
const name = (
|
|
47
|
-
const title = (
|
|
53
|
+
const name = (_b = getMetaTag("og:site_name")) != null ? _b : extractDomainWithoutSuffix(baseUrl);
|
|
54
|
+
const title = (_c = getMetaTag("og:title")) != null ? _c : getMetaTag("twitter:title");
|
|
48
55
|
const description = getMetaTag("description") || getPropertyMetaTag("og:description");
|
|
49
|
-
const shopifyWalletId = (_c = getMetaTag("shopify-digital-wallet")) == null ? void 0 : _c.split("/")[1];
|
|
50
56
|
const myShopifySubdomainMatch = html.match(/['"](.*?\.myshopify\.com)['"]/);
|
|
51
57
|
const myShopifySubdomain = myShopifySubdomainMatch ? myShopifySubdomainMatch[1] : null;
|
|
52
58
|
let logoUrl = getPropertyMetaTag("og:image") || getPropertyMetaTag("og:image:secure_url");
|
|
@@ -188,7 +194,7 @@ async function getInfoForStore(args, options) {
|
|
|
188
194
|
}
|
|
189
195
|
)) == null ? void 0 : _p.map((json) => json ? JSON.parse(json) : null)) || [],
|
|
190
196
|
techProvider: {
|
|
191
|
-
name: "shopify",
|
|
197
|
+
name: shopifyWalletId ? "shopify" : "",
|
|
192
198
|
walletId: shopifyWalletId,
|
|
193
199
|
subDomain: myShopifySubdomain != null ? myShopifySubdomain : null
|
|
194
200
|
},
|
package/dist/index.mjs
CHANGED
package/dist/store.mjs
CHANGED