@gem-sdk/core 5.0.0 → 5.0.7

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 +1 @@
1
- "use strict";var useSWR=require("swr"),getCollection=require("./queries/get-collection.js"),getProduct=require("./queries/get-product.js"),getProducts=require("./queries/get-products.js"),query=require("./query.js");const prefetchQueries=(e,t)=>{let r=[];return Object.keys(e).forEach(s=>{let u;let o=e[s];switch(o.tag){case"Product":{if(o.settings?.isAuto)break;let e={id:o.settings?.productSetting?.productId??"latest",isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductQueryKey(e)),func:getProduct.getProduct,variables:e};break}case"ProductList":{let e=o.settings?.productSetting;if(e?.productSrc==="Collection"){let r={id:e?.collectionId??"latest",numberOfProducts:o.settings?.numberOfProducts??4,orderBy:o.settings?.orderBy,isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateCollectionQueryKey(r)),func:getCollection.getCollection,variables:r}}else{let r={ids:[...e?.productIds??[]].sort(),isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductsQueryKey(r)),func:getProducts.getProducts,variables:r}}}}u&&r.push(u)}),r.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};exports.prefetchQueries=prefetchQueries;
1
+ "use strict";var useSWR=require("swr"),getCollection=require("./queries/get-collection.js"),getProduct=require("./queries/get-product.js"),getProducts=require("./queries/get-products.js"),query=require("./query.js");const prefetchQueries=(e,t)=>{let r=[];return Object.keys(e).forEach(s=>{let u;let o=e[s];switch(o.tag){case"Product":{if(o.settings?.isAuto)break;let e={id:o.settings?.productSetting?.productId??"latest",isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductQueryKey(e)),func:getProduct.getProduct,variables:e};break}case"ProductList":case"ProductListV3":{let e=o.settings?.productSetting;if(e?.productSrc==="Collection"){let r={id:e?.collectionId??"latest",numberOfProducts:o.settings?.numberOfProducts??4,orderBy:o.settings?.orderBy,isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateCollectionQueryKey(r)),func:getCollection.getCollection,variables:r}}else{let r={ids:[...e?.productIds??[]].sort(),isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductsQueryKey(r)),func:getProducts.getProducts,variables:r}}}}u&&r.push(u)}),r.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};exports.prefetchQueries=prefetchQueries;
@@ -1 +1 @@
1
- import{unstable_serialize as e}from"swr";import{getCollection as t}from"./queries/get-collection.js";import{getProduct as r}from"./queries/get-product.js";import{getProducts as s}from"./queries/get-products.js";import{generateCollectionQueryKey as o,generateProductsQueryKey as i,generateProductQueryKey as c}from"./query.js";let prefetchQueries=(u,l)=>{let n=[];return Object.keys(u).forEach(p=>{let f;let d=u[p];switch(d.tag){case"Product":{if(d.settings?.isAuto)break;let t={id:d.settings?.productSetting?.productId??"latest",isSample:l?.isSample,isStorefront:l?.isStorefront};f={key:e(c(t)),func:r,variables:t};break}case"ProductList":{let r=d.settings?.productSetting;if(r?.productSrc==="Collection"){let s={id:r?.collectionId??"latest",numberOfProducts:d.settings?.numberOfProducts??4,orderBy:d.settings?.orderBy,isSample:l?.isSample,isStorefront:l?.isStorefront};f={key:e(o(s)),func:t,variables:s}}else{let t={ids:[...r?.productIds??[]].sort(),isSample:l?.isSample,isStorefront:l?.isStorefront};f={key:e(i(t)),func:s,variables:t}}}}f&&n.push(f)}),n.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};export{prefetchQueries};
1
+ import{unstable_serialize as e}from"swr";import{getCollection as t}from"./queries/get-collection.js";import{getProduct as r}from"./queries/get-product.js";import{getProducts as s}from"./queries/get-products.js";import{generateCollectionQueryKey as o,generateProductsQueryKey as i,generateProductQueryKey as c}from"./query.js";let prefetchQueries=(u,l)=>{let n=[];return Object.keys(u).forEach(p=>{let d;let f=u[p];switch(f.tag){case"Product":{if(f.settings?.isAuto)break;let t={id:f.settings?.productSetting?.productId??"latest",isSample:l?.isSample,isStorefront:l?.isStorefront};d={key:e(c(t)),func:r,variables:t};break}case"ProductList":case"ProductListV3":{let r=f.settings?.productSetting;if(r?.productSrc==="Collection"){let s={id:r?.collectionId??"latest",numberOfProducts:f.settings?.numberOfProducts??4,orderBy:f.settings?.orderBy,isSample:l?.isSample,isStorefront:l?.isStorefront};d={key:e(o(s)),func:t,variables:s}}else{let t={ids:[...r?.productIds??[]].sort(),isSample:l?.isSample,isStorefront:l?.isStorefront};d={key:e(i(t)),func:s,variables:t}}}}d&&n.push(d)}),n.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};export{prefetchQueries};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "5.0.0",
3
+ "version": "5.0.7",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",