Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@meta-cms/core

Package Overview
Dependencies
Maintainers
2
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meta-cms/core - npm Package Compare versions

Comparing version 1.0.41 to 1.0.42

2

index.d.ts

@@ -351,3 +351,3 @@ import { Get } from 'type-fest';

params?: GetContentParams<any, any>;
constructor(config: S, { storefrontName, storefrontAccessToken, defaultNameSpaces }: MetaCMSConfig<S>, adapter: Adapter);
constructor(config: S, { storefrontName, storefrontAccessToken, defaultNameSpaces }: MetaCMSConfig<S>, adapter?: Adapter);
getMetafieldsByIds: (ids: string[]) => Promise<[Record<string, MetafieldContent>, MetafieldContent[]]>;

@@ -354,0 +354,0 @@ getMetafieldsForProductsAndCollection: <P extends GetContentParams<S, P>>({ collection, product }: P, locale?: 'fra') => Promise<[

@@ -1,2 +0,2 @@

"use strict";var _=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var X=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},Y=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of B(e))!K.call(n,i)&&i!==t&&_(n,i,{get:()=>e[i],enumerable:!(r=U(e,i))||r.enumerable});return n};var Z=n=>Y(_({},"__esModule",{value:!0}),n);var ie={};X(ie,{GraphqlClient:()=>y,MetaCms:()=>j,buildQuery:()=>P,collectionFragment:()=>E,config:()=>te,contentQuery:()=>w,getMetaCMSConfigQuery:()=>ee,getOwnerIdQuery:()=>N,imageFragment:()=>$,isId:()=>C,mediaImageFragment:()=>A,metafieldFragment:()=>M,metafieldsForNodes:()=>q,metafieldsQuery:()=>R,normalizeEdges:()=>m,productFragment:()=>S,randomId:()=>g,setInNamespace:()=>T,setMetaCMSConfigMutation:()=>F,syncConfig:()=>re});module.exports=Z(ie);var k=(n,e,t)=>{if(!n)return t?t():void 0;var r,i;if(Array.isArray(e)&&(r=e.slice(0)),typeof e=="string"&&(r=e.split(".")),typeof e=="symbol"&&(r=[e]),!Array.isArray(r))throw new Error("props arg must be an array, a string or a symbol");for(;r.length;)if(i=r.shift(),!n||(n=n[i],n===void 0))return t?t():void 0;return n};var Q=n=>{let e=[];return n.forEach(t=>{!t||(t.type==="product_reference"&&t.product.content&&t.product.content.map(r=>{e.push(r.id)}),t.type==="list.product_reference"&&t.values.edges.map(({node:r})=>{r.content&&r.content.map(i=>{e.push(i.id)})}),t.type==="collection_reference"&&t.collection.content&&t.collection.content.map(r=>{e.push(r.id)}),t.type==="list.collection_reference"&&t.values.edges.map(({node:r})=>{r.content&&r.content.map(i=>{e.push(i.id)})}))}),e};var F=`
"use strict";var _=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var X=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},Y=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of B(e))!K.call(n,i)&&i!==t&&_(n,i,{get:()=>e[i],enumerable:!(r=U(e,i))||r.enumerable});return n};var Z=n=>Y(_({},"__esModule",{value:!0}),n);var ie={};X(ie,{GraphqlClient:()=>y,MetaCms:()=>J,buildQuery:()=>P,collectionFragment:()=>E,config:()=>te,contentQuery:()=>w,getMetaCMSConfigQuery:()=>ee,getOwnerIdQuery:()=>N,imageFragment:()=>$,isId:()=>C,mediaImageFragment:()=>A,metafieldFragment:()=>M,metafieldsForNodes:()=>q,metafieldsQuery:()=>R,normalizeEdges:()=>p,productFragment:()=>S,randomId:()=>g,setInNamespace:()=>T,setMetaCMSConfigMutation:()=>F,syncConfig:()=>re});module.exports=Z(ie);var k=(n,e,t)=>{if(!n)return t?t():void 0;var r,i;if(Array.isArray(e)&&(r=e.slice(0)),typeof e=="string"&&(r=e.split(".")),typeof e=="symbol"&&(r=[e]),!Array.isArray(r))throw new Error("props arg must be an array, a string or a symbol");for(;r.length;)if(i=r.shift(),!n||(n=n[i],n===void 0))return t?t():void 0;return n};var Q=n=>{let e=[];return n.forEach(t=>{!t||(t.type==="product_reference"&&t.product.content&&t.product.content.map(r=>{e.push(r.id)}),t.type==="list.product_reference"&&t.values.edges.map(({node:r})=>{r.content&&r.content.map(i=>{e.push(i.id)})}),t.type==="collection_reference"&&t.collection.content&&t.collection.content.map(r=>{e.push(r.id)}),t.type==="list.collection_reference"&&t.values.edges.map(({node:r})=>{r.content&&r.content.map(i=>{e.push(i.id)})}))}),e};var F=`
mutation ($ownerId: ID!, $value: String!, $key: String!) {

@@ -210,3 +210,3 @@ metafieldsSet(metafields: [{ key: $key, namespace: "meta-cms", ownerId: $ownerId, value: $value, type: "json" }]) {

}`;var m=n=>n.edges.reduce((e,{node:t})=>(e.push(t),e),[]),te=n=>n,g=()=>{let n="meta-cms-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",e="",t=10;for(;t--;)e+=n[Math.random()*n.length|0];return`meta-cms-${e}`},C=n=>typeof n=="string"?n.startsWith("gid://shopify/Metafield/"):!1,T=({content:n,namespace:e,key:t,id:r,value:i})=>{let s=r?`${t}@${r}`:t;n[e]||Object.assign(n,{[e]:{}}),Object.assign(n[e],{[s]:i})},P=({handles:n,ids:e})=>{let t=r=>r.replace("gid://shopify/Product/","");return(n==null?void 0:n.length)||(e==null?void 0:e.length)?`${(e||[]).map((r,i,s)=>`id:${t(r)}${s.length-1>i?" or ":n!=null&&n.length?" or":""}`).join("")} ${(n||[]).map((r,i,s)=>`handle:${r}${s.length-1>i?" or ":""}`).join("")}`.trim():void 0};var O=({field:n,acc:e,item:t,locale:r,jsonMetafields:i,nestedContent:s})=>{var p;let a={itemID:t.id,itemType:t.type,itemProp:`${t.namespace}:${t.key}`},d,c=({id:o,key:l,namespace:f,objectId:u})=>{s&&e&&r&&T({content:e,key:l,id:u,namespace:f.replace(`_${r}`,""),value:s[o]})};switch(t.type){case"collection_reference":{d={attributes:a,value:{...t.collection,products:m(t.collection.products).map(({content:o,...l})=>(o==null||o.forEach(f=>c({...f,objectId:l.id})),{...l,variants:m(l.variants)}))}};break}case"file_reference":{(!t.image.image.alt||!t.image.image.alt.length)&&(t.image.image.alt="image"),d={attributes:a,value:t.image.image};break}case"product_reference":{let{product:o}=t;(p=o.content)==null||p.forEach(l=>c({...l,objectId:o.id})),d={attributes:a,value:{...o,variants:m(t.product.variants)}};break}case"list.collection_reference":{d={attributes:a,value:m(t.values).map(o=>{var l;return(l=o.content)==null||l.forEach(f=>c({...f,objectId:o.id})),{...o,products:m(o.products).map(f=>{var u;return(u=f.content)==null||u.forEach(h=>c({...h,objectId:f.id})),{...f,variants:m(f.variants)}})}})};break}case"list.file_reference":{d={attributes:a,value:m(t.values).map(o=>o.image)};break}case"list.product_reference":{d={attributes:a,value:m(t.values).map(o=>{var l;return(l=o.content)==null||l.forEach(f=>c({...f,objectId:o.id})),{...o,variants:m(o.variants)}})};break}case"json":{d={attributes:a,value:H(t.value,i)};break}case"list.multi_line_text_field":case"list.single_line_text_field":{d={attributes:a,value:JSON.parse(t.value)};break}case"multi_line_text_field":case"single_line_text_field":{d={attributes:a,value:t.value};break}}return d},L=({client:n,id:e,initalizer:t,content:r,jsonMetafields:i,nestedContent:s})=>{let a=t||{};for(let d=0;d<r.length;d++){let c=r[d];if(c){let p=n.config[c.namespace.replace(`_${n.locale}`,"")].schema[c.key],o=O({client:n,field:p,acc:a,item:c,jsonMetafields:i,nestedContent:s});T({content:a,key:c.key,namespace:c.namespace.replace(`_${n.locale}`,""),value:n.adapter(o)})}}return a};var ne=n=>{let e=[];return n&&JSON.parse(n,(t,r)=>(Array.isArray(r)?r.forEach(i=>{C(i)&&e.push(i)}):C(r)&&e.push(r),r)),e},J=n=>{let e=[];return n.forEach(t=>{!t||t.type==="json"&&(e=e.concat(ne(t.value)))}),e},b=(n,e)=>n.reduce((t,r)=>{if(r){console.log(r.namespace,e.locale,r.key,e.config[r.namespace.replace(`_${e.locale}`,"")]);let i=e.config[r.namespace.replace(`_${e.locale}`,"")].schema[r.key],s=O({field:i,item:r,client:e});t[r.id]=e.adapter(s)}return t},{}),H=(n,e)=>e?JSON.parse(n,(t,r)=>Array.isArray(r)?r.map(i=>C(i)?e[i]:i):C(r)?e[r]:r):JSON.parse(n);var W=n=>{let t={text:"single_line_text_field",richtext:"multi_line_text_field",image:"file_reference",product:"product_reference",collection:"collection_reference",object:"json"}[n.type];return n.isList?`list.${t}`:t},v=(n=400,e=300)=>({alt:"image",src:`https://picsum.photos/${n}/${e}`,width:n,height:e}),x=()=>({id:g(),descriptionHtml:"Lorem ipsum",title:"Lorem ipsum",handle:"",featuredImage:v(),compareAtPriceRange:{maxVariantPrice:{amount:"0",currencyCode:"EUR"},minVariantPrice:{amount:"0",currencyCode:"EUR"}},priceRange:{maxVariantPrice:{amount:"0",currencyCode:"EUR"},minVariantPrice:{amount:"0",currencyCode:"EUR"}},variants:[]}),V=()=>({id:g(),title:"Lorem ipsum",descriptionHtml:"Lorem ipsum",handle:"",image:v(),products:[x(),x(),x()]}),D=(n,e=3)=>{let t=[];for(let r=0;r<4;r++)t.push(n());return t},z=(n,e)=>{switch(n.type){case"collection":return{attributes:e,value:n.isList?D(V):V()};case"image":return{value:n.isList?D(v):{id:g(),...v()},attributes:e};case"product":return{attributes:e,value:n.isList?D(x):x()};case"richtext":return{attributes:e,value:n.isList?["Lorem ipsum","Lorem ipsum","Lorem ipsum"]:`<i>Lorem ipsum dolor sit amet consectetur adipisicing elit</i>.
Officia quisquam, vero eius nam, reiciendis fugiat dolore, sit aspernatur numquam a vitae quae laborum? Rem quidem, neque dignissimos delectus vel quasi!`};default:case"text":return{attributes:e,value:n.isList?["Lorem ipsum","Lorem ipsum","Lorem ipsum"]:"Lorem ipsum dolor sit amet consectetur adipisicing elit."}}};var y=class{constructor(e,t){this.request=async(e,t)=>{let{data:r}=await(await fetch(this.url,{method:"POST",body:JSON.stringify({query:e,variables:t||{}}),headers:{...this.headers||{},"Content-Type":"application/json"}})).json();return r};this.url=e,this.headers=t}},j=class{constructor(e,{storefrontName:t,storefrontAccessToken:r,defaultNameSpaces:i},s){this.getMetafieldsByIds=async e=>{var i,s;if(!e.length)return[{},[]];let t=await this.client.request(R(!1,{customProductMetafields:(s=(i=this.params)==null?void 0:i.product)==null?void 0:s.customMetafieldsIdentifiers}),{ids:e});if(console.log({res:t}),!t)return[{},[]];let{metafields:r}=t;return[b(r,this),r]};this.getMetafieldsForProductsAndCollection=async({collection:e,product:t},r="fra")=>{var u,h;if(!(e!=null&&e.ids)&&!(e!=null&&e.handles)&&!(e!=null&&e.namespaces)&&!(t!=null&&t.ids)&&!(t!=null&&t.handles)&&!(t!=null&&t.namespaces))return[{},[],[]];let i=await this.client.request(q({collectionQuery:P({ids:e==null?void 0:e.ids,handles:e==null?void 0:e.handles}),productQuery:P({ids:t==null?void 0:t.ids,handles:t==null?void 0:t.handles})},{customProductMetafields:(h=(u=this.params)==null?void 0:u.product)==null?void 0:h.customMetafieldsIdentifiers}),{productIdentifiers:this.buildIdentifiers((t==null?void 0:t.namespaces)||[],r),collectionIdentifiers:this.buildIdentifiers((e==null?void 0:e.namespaces)||[],r)});if(console.log({res:i}),!i)return[{},[],[]];let{products:s,collections:a}=i,d=s?m(s):[],c=a?m(a):[],p=d.map(I=>I.content).flat(),o=c.map(I=>I.content).flat(),l=b(p,this),f=b(o,this);return[{...l,...f},p.concat(o),d.concat(c)]};this.getContentForNamespaces=async(e,t="fra")=>{var l,f,u;if(this.locale=t,!e.global)return{content:{},params:e};this.params=e;let{shop:{content:r}}=await this.client.request(w(!0,{customProductMetafields:(l=e.product)==null?void 0:l.customMetafieldsIdentifiers}),{productIdentifiers:this.buildIdentifiers(((f=e.product)==null?void 0:f.namespaces)||[],t),collectionIdentifiers:this.buildIdentifiers(((u=e.collection)==null?void 0:u.namespaces)||[],t),identifiers:this.buildIdentifiers(e.global.concat(this.defaultNameSpaces),t)}),[[i,s],[a,d,c]]=await Promise.all([this.getMetafieldsByIds(Q(r)),this.getMetafieldsForProductsAndCollection(e)]),[p]=await this.getMetafieldsByIds(J(r.concat(s).concat(d))),o=L({client:this,content:r,jsonMetafields:p,nestedContent:{...i,...a}});return c.forEach(({id:h,content:I})=>{L({client:this,initalizer:o,id:h,content:I,jsonMetafields:p,nestedContent:{...i,...a}})}),{params:{...e,global:e.global.concat(this.defaultNameSpaces)},content:o}};this.t=(e,t,{productId:r,collectionId:i})=>{let[s,a]=e.split("."),{kind:d,schema:c}=this.config[s];r&&d==="product"&&(a=`${a}@${r}`),i&&d==="collection"&&(a=`${a}@${i}`);let p=c[a],o=()=>k(this.config[s],`${a}.default`,()=>{let l=W(p),f={itemID:g(),itemType:l,itemProp:`${s}:${a}`};return z(p,f)});return k(t,`${s}.${a}`,o)};this.buildIdentifiers=(e,t="fra")=>e?e.reduce((r,i)=>{let s=this.config[i];return s&&Object.keys(s.schema).forEach(a=>{r.push({namespace:`${i}_${t}`,key:a})}),r},[]):[];this.locale="en",this.adapter=s,this.config=e,this.defaultNameSpaces=i||[],this.client=new y(`https://${t}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":r})}};var re=async(n,{storefrontName:e,storefrontAccessToken:t,adminAccessToken:r},i)=>{console.log(i);let s=new y(`https://${e}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":t}),a=new y(`https://${e}.myshopify.com/admin/api/2022-10/graphql.json`,{"X-Shopify-Access-Token":r}),{shop:{id:d}}=await s.request(N);return await a.request(F,{value:JSON.stringify(n),key:i,ownerId:d})};0&&(module.exports={GraphqlClient,MetaCms,buildQuery,collectionFragment,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,imageFragment,isId,mediaImageFragment,metafieldFragment,metafieldsForNodes,metafieldsQuery,normalizeEdges,productFragment,randomId,setInNamespace,setMetaCMSConfigMutation,syncConfig});
}`;var p=n=>n.edges.reduce((e,{node:t})=>(e.push(t),e),[]),te=n=>n,g=()=>{let n="meta-cms-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",e="",t=10;for(;t--;)e+=n[Math.random()*n.length|0];return`meta-cms-${e}`},C=n=>typeof n=="string"?n.startsWith("gid://shopify/Metafield/"):!1,T=({content:n,namespace:e,key:t,id:r,value:i})=>{let o=r?`${t}@${r}`:t;n[e]||Object.assign(n,{[e]:{}}),Object.assign(n[e],{[o]:i})},P=({handles:n,ids:e})=>{let t=r=>r.replace("gid://shopify/Product/","");return(n==null?void 0:n.length)||(e==null?void 0:e.length)?`${(e||[]).map((r,i,o)=>`id:${t(r)}${o.length-1>i?" or ":n!=null&&n.length?" or":""}`).join("")} ${(n||[]).map((r,i,o)=>`handle:${r}${o.length-1>i?" or ":""}`).join("")}`.trim():void 0};var O=({field:n,acc:e,item:t,locale:r,jsonMetafields:i,nestedContent:o})=>{var m;let s={itemID:t.id,itemType:t.type,itemProp:`${t.namespace}:${t.key}`},d,c=({id:a,key:l,namespace:f,objectId:u})=>{o&&e&&r&&T({content:e,key:l,id:u,namespace:f.replace(`_${r}`,""),value:o[a]})};switch(t.type){case"collection_reference":{d={attributes:s,value:{...t.collection,products:p(t.collection.products).map(({content:a,...l})=>(a==null||a.forEach(f=>c({...f,objectId:l.id})),{...l,variants:p(l.variants)}))}};break}case"file_reference":{(!t.image.image.alt||!t.image.image.alt.length)&&(t.image.image.alt="image"),d={attributes:s,value:t.image.image};break}case"product_reference":{let{product:a}=t;(m=a.content)==null||m.forEach(l=>c({...l,objectId:a.id})),d={attributes:s,value:{...a,variants:p(t.product.variants)}};break}case"list.collection_reference":{d={attributes:s,value:p(t.values).map(a=>{var l;return(l=a.content)==null||l.forEach(f=>c({...f,objectId:a.id})),{...a,products:p(a.products).map(f=>{var u;return(u=f.content)==null||u.forEach(h=>c({...h,objectId:f.id})),{...f,variants:p(f.variants)}})}})};break}case"list.file_reference":{d={attributes:s,value:p(t.values).map(a=>a.image)};break}case"list.product_reference":{d={attributes:s,value:p(t.values).map(a=>{var l;return(l=a.content)==null||l.forEach(f=>c({...f,objectId:a.id})),{...a,variants:p(a.variants)}})};break}case"json":{let a=H(t.value,i);d={attributes:s,value:a.value||a};break}case"list.multi_line_text_field":case"list.single_line_text_field":{d={attributes:s,value:JSON.parse(t.value)};break}case"multi_line_text_field":case"single_line_text_field":{d={attributes:s,value:t.value};break}}return d},L=({client:n,id:e,initalizer:t,content:r,jsonMetafields:i,nestedContent:o})=>{let s=t||{};for(let d=0;d<r.length;d++){let c=r[d];if(c){let m=n.config[c.namespace.replace(`_${n.locale}`,"")].schema[c.key],a=O({client:n,field:m,acc:s,item:c,jsonMetafields:i,nestedContent:o});T({content:s,key:c.key,namespace:c.namespace.replace(`_${n.locale}`,""),value:n.adapter(a)})}}return s};var ne=n=>{let e=[];return n&&JSON.parse(n,(t,r)=>(Array.isArray(r)?r.forEach(i=>{C(i)&&e.push(i)}):C(r)&&e.push(r),r)),e},D=n=>{let e=[];return n.forEach(t=>{!t||t.type==="json"&&(e=e.concat(ne(t.value)))}),e},b=(n,e)=>n.reduce((t,r)=>{if(r){console.log(r.namespace,e.locale,r.key,e.config[r.namespace.replace(`_${e.locale}`,"")]);let i=e.config[r.namespace.replace(`_${e.locale}`,"")].schema[r.key],o=O({field:i,item:r,client:e});t[r.id]=e.adapter(o)}return t},{}),H=(n,e)=>e?JSON.parse(n,(t,r)=>Array.isArray(r)?r.map(i=>C(i)?e[i]:i):C(r)?e[r]:r):JSON.parse(n);var W=n=>{let t={text:"single_line_text_field",richtext:"multi_line_text_field",image:"file_reference",product:"product_reference",collection:"collection_reference",object:"json"}[n.type];return n.isList?`list.${t}`:t},v=(n=400,e=300)=>({alt:"image",src:`https://picsum.photos/${n}/${e}`,width:n,height:e}),x=()=>({id:g(),descriptionHtml:"Lorem ipsum",title:"Lorem ipsum",handle:"",featuredImage:v(),compareAtPriceRange:{maxVariantPrice:{amount:"0",currencyCode:"EUR"},minVariantPrice:{amount:"0",currencyCode:"EUR"}},priceRange:{maxVariantPrice:{amount:"0",currencyCode:"EUR"},minVariantPrice:{amount:"0",currencyCode:"EUR"}},variants:[]}),V=()=>({id:g(),title:"Lorem ipsum",descriptionHtml:"Lorem ipsum",handle:"",image:v(),products:[x(),x(),x()]}),j=(n,e=3)=>{let t=[];for(let r=0;r<4;r++)t.push(n());return t},z=(n,e)=>{switch(n.type){case"collection":return{attributes:e,value:n.isList?j(V):V()};case"image":return{value:n.isList?j(v):{id:g(),...v()},attributes:e};case"product":return{attributes:e,value:n.isList?j(x):x()};case"richtext":return{attributes:e,value:n.isList?["Lorem ipsum","Lorem ipsum","Lorem ipsum"]:`<i>Lorem ipsum dolor sit amet consectetur adipisicing elit</i>.
Officia quisquam, vero eius nam, reiciendis fugiat dolore, sit aspernatur numquam a vitae quae laborum? Rem quidem, neque dignissimos delectus vel quasi!`};default:case"text":return{attributes:e,value:n.isList?["Lorem ipsum","Lorem ipsum","Lorem ipsum"]:"Lorem ipsum dolor sit amet consectetur adipisicing elit."}}};var y=class{constructor(e,t){this.request=async(e,t)=>{let{data:r}=await(await fetch(this.url,{method:"POST",body:JSON.stringify({query:e,variables:t||{}}),headers:{...this.headers||{},"Content-Type":"application/json"}})).json();return r};this.url=e,this.headers=t}},J=class{constructor(e,{storefrontName:t,storefrontAccessToken:r,defaultNameSpaces:i},o){this.getMetafieldsByIds=async e=>{var i,o;if(!e.length)return[{},[]];let t=await this.client.request(R(!1,{customProductMetafields:(o=(i=this.params)==null?void 0:i.product)==null?void 0:o.customMetafieldsIdentifiers}),{ids:e});if(console.log({res:t}),!t)return[{},[]];let{metafields:r}=t;return[b(r,this),r]};this.getMetafieldsForProductsAndCollection=async({collection:e,product:t},r="fra")=>{var u,h;if(!(e!=null&&e.ids)&&!(e!=null&&e.handles)&&!(e!=null&&e.namespaces)&&!(t!=null&&t.ids)&&!(t!=null&&t.handles)&&!(t!=null&&t.namespaces))return[{},[],[]];let i=await this.client.request(q({collectionQuery:P({ids:e==null?void 0:e.ids,handles:e==null?void 0:e.handles}),productQuery:P({ids:t==null?void 0:t.ids,handles:t==null?void 0:t.handles})},{customProductMetafields:(h=(u=this.params)==null?void 0:u.product)==null?void 0:h.customMetafieldsIdentifiers}),{productIdentifiers:this.buildIdentifiers((t==null?void 0:t.namespaces)||[],r),collectionIdentifiers:this.buildIdentifiers((e==null?void 0:e.namespaces)||[],r)});if(console.log({res:i}),!i)return[{},[],[]];let{products:o,collections:s}=i,d=o?p(o):[],c=s?p(s):[],m=d.map(I=>I.content).flat(),a=c.map(I=>I.content).flat(),l=b(m,this),f=b(a,this);return[{...l,...f},m.concat(a),d.concat(c)]};this.getContentForNamespaces=async(e,t="fra")=>{var l,f,u;if(this.locale=t,!e.global)return{content:{},params:e};this.params=e;let{shop:{content:r}}=await this.client.request(w(!0,{customProductMetafields:(l=e.product)==null?void 0:l.customMetafieldsIdentifiers}),{productIdentifiers:this.buildIdentifiers(((f=e.product)==null?void 0:f.namespaces)||[],t),collectionIdentifiers:this.buildIdentifiers(((u=e.collection)==null?void 0:u.namespaces)||[],t),identifiers:this.buildIdentifiers(e.global.concat(this.defaultNameSpaces),t)}),[[i,o],[s,d,c]]=await Promise.all([this.getMetafieldsByIds(Q(r)),this.getMetafieldsForProductsAndCollection(e)]),[m]=await this.getMetafieldsByIds(D(r.concat(o).concat(d))),a=L({client:this,content:r,jsonMetafields:m,nestedContent:{...i,...s}});return console.log("content",r,"jsonMetafields",m,"getJsonNstedIds",D(r)),c.forEach(({id:h,content:I})=>{L({client:this,initalizer:a,id:h,content:I,jsonMetafields:m,nestedContent:{...i,...s}})}),{params:{...e,global:e.global.concat(this.defaultNameSpaces)},content:a}};this.t=(e,t,{productId:r,collectionId:i})=>{let[o,s]=e.split("."),{kind:d,schema:c}=this.config[o];r&&d==="product"&&(s=`${s}@${r}`),i&&d==="collection"&&(s=`${s}@${i}`);let m=c[s],a=()=>k(this.config[o],`${s}.default`,()=>{let l=W(m),f={itemID:g(),itemType:l,itemProp:`${o}:${s}`};return z(m,f)});return k(t,`${o}.${s}`,a)};this.buildIdentifiers=(e,t="fra")=>e?e.reduce((r,i)=>{let o=this.config[i];return o&&Object.keys(o.schema).forEach(s=>{r.push({namespace:`${i}_${t}`,key:s})}),r},[]):[];this.locale="en",this.adapter=o||(s=>s),this.config=e,this.defaultNameSpaces=i||[],this.client=new y(`https://${t}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":r})}};var re=async(n,{storefrontName:e,storefrontAccessToken:t,adminAccessToken:r},i)=>{console.log(i);let o=new y(`https://${e}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":t}),s=new y(`https://${e}.myshopify.com/admin/api/2022-10/graphql.json`,{"X-Shopify-Access-Token":r}),{shop:{id:d}}=await o.request(N);return await s.request(F,{value:JSON.stringify(n),key:i,ownerId:d})};0&&(module.exports={GraphqlClient,MetaCms,buildQuery,collectionFragment,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,imageFragment,isId,mediaImageFragment,metafieldFragment,metafieldsForNodes,metafieldsQuery,normalizeEdges,productFragment,randomId,setInNamespace,setMetaCMSConfigMutation,syncConfig});
{
"name": "@meta-cms/core",
"version": "1.0.41",
"version": "1.0.42",
"description": "",

@@ -27,2 +27,4 @@ "main": "index.js",

"dependencies": {
"just-extend": "^6.1.1",
"just-safe-set": "^4.1.1",
"node-fetch": "^3.2.10"

@@ -29,0 +31,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc