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.24 to 1.0.25

6

index.js

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

"use strict";var p=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var F=(s,e)=>{for(var r in e)p(s,r,{get:e[r],enumerable:!0})},P=(s,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!M.call(s,n)&&n!==r&&p(s,n,{get:()=>e[n],enumerable:!(i=I(e,n))||i.enumerable});return s};var T=s=>P(p({},"__esModule",{value:!0}),s);var O={};F(O,{GraphqlClient:()=>f,MetaCms:()=>y,config:()=>v,contentQuery:()=>g,getMetaCMSConfigQuery:()=>_,getOwnerIdQuery:()=>u,setMetaCMSConfigMutation:()=>m,syncConfig:()=>k});module.exports=T(O);var m=`
"use strict";var M=Object.create;var p=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var v=(n,e)=>{for(var r in e)p(n,r,{get:e[r],enumerable:!0})},S=(n,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of P(e))!_.call(n,s)&&s!==r&&p(n,s,{get:()=>e[s],enumerable:!(i=F(e,s))||i.enumerable});return n};var k=(n,e,r)=>(r=n!=null?M(T(n)):{},S(e||!n||!n.__esModule?p(r,"default",{value:n,enumerable:!0}):r,n)),O=n=>S(p({},"__esModule",{value:!0}),n);var $={};v($,{GraphqlClient:()=>f,MetaCms:()=>y,config:()=>w,contentQuery:()=>g,getMetaCMSConfigQuery:()=>b,getOwnerIdQuery:()=>u,setMetaCMSConfigMutation:()=>m,syncConfig:()=>N});module.exports=O($);var m=`
mutation ($ownerId: ID!, $value: String!) {

@@ -13,3 +13,3 @@ metafieldsSet(

}
`,_=`
`,b=`
query {

@@ -161,2 +161,2 @@ shop {

}
`;function S(s,e,r){if(!s)return r;var i,n;if(Array.isArray(e)&&(i=e.slice(0)),typeof e=="string"&&(i=e.split(".")),typeof e=="symbol"&&(i=[e]),!Array.isArray(i))throw new Error("props arg must be an array, a string or a symbol");for(;i.length;)if(n=i.shift(),!s||(s=s[n],s===void 0))return r;return s}var f=class{constructor(e,r){this.request=async(e,r)=>(await(await fetch(this.url,{method:"POST",body:JSON.stringify({query:e,variables:r||{}}),headers:{...this.headers||{},"Content-Type":"application/json"}})).json()).data;this.url=e,this.headers=r}},y=class{constructor(e,{storefrontName:r,storefrontAccessToken:i,defaultNameSpaces:n}){this.getContentForNamespaces=async(e,r="fra")=>{let{shop:{content:i}}=await this.client.request(g,{identifiers:this.buildIdentifiers(e.concat(this.defaultNameSpaces),r)});return console.log({content:i}),i.reduce((n,t)=>{if(!t)return n;let c=t.namespace.replace(`_${r}`,"");n[c]||Object.assign(n,{[c]:{}});let o={itemID:t.id,itemType:t.type,itemProp:`${t.namespace}:${t.key}`},a;switch(t.type){case"collection_reference":{a={attributes:o,collection:{...t.collection,products:l(t.collection.products)}};break}case"file_reference":{t.image.image.alt||(t.image.image.alt=""),a={attributes:o,image:t.image.image};break}case"product_reference":{a={attributes:o,product:{...t.product,variants:l(t.product.variants)}};break}case"list.collection_reference":{a={attributes:o,collections:l(t.values).map(d=>({...d,products:l(d.products)}))};break}case"list.file_reference":{a={attributes:o,images:l(t.values).map(d=>d.image)};break}case"list.product_reference":{a={attributes:o,products:l(t.values).map(d=>({...d,variants:l(d.variants)}))};break}case"json":{a={attributes:o,[t.key]:JSON.parse(t.value)};break}case"list.multi_line_text_field":case"list.single_line_text_field":{a={attributes:o,texts:JSON.parse(t.value)};break}case"multi_line_text_field":case"single_line_text_field":{a={attributes:o,text:t.value};break}}return Object.assign(n[c],{[t.key]:a}),n},{})};this.t=(e,r="fr",i)=>{let[n,...t]=e.split("."),c=()=>S(this.config[n],t).default;return i&&i[n][t.join(".")]||c()};this.buildIdentifiers=(e,r="fra")=>e.reduce((n,t)=>{let c=this.config[t];return Object.entries(c).reduce((a,[d,h])=>(h.config?Object.keys(h.config).forEach(C=>{a.push(`${d}.${C}`)}):a.push(d),a),[]).forEach(a=>{n.push({namespace:`${t}_${r}`,key:a})}),n},[]);this.config=e,this.defaultNameSpaces=n||[],this.client=new f(`https://${r}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":i})}},l=s=>s.edges.reduce((e,{node:r})=>(e.push(r),e),[]),v=s=>s;var k=async(s,{storefrontName:e,storefrontAccessToken:r,adminAccessToken:i})=>{let n=new f(`https://${e}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":r}),t=new f(`https://${e}.myshopify.com/admin/api/2022-10/graphql.json`,{"X-Shopify-Access-Token":i}),{shop:{id:c}}=await n.request(u);return await t.request(m,{value:JSON.stringify(s),ownerId:c})};0&&(module.exports={GraphqlClient,MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig});
`;function C(n,e,r){if(!n)return r;var i,s;if(Array.isArray(e)&&(i=e.slice(0)),typeof e=="string"&&(i=e.split(".")),typeof e=="symbol"&&(i=[e]),!Array.isArray(i))throw new Error("props arg must be an array, a string or a symbol");for(;i.length;)if(s=i.shift(),!n||(n=n[s],n===void 0))return r;return n}var I=k(require("node-fetch")),f=class{constructor(e,r){this.request=async(e,r)=>(await(await(0,I.default)(this.url,{method:"POST",body:JSON.stringify({query:e,variables:r||{}}),headers:{...this.headers||{},"Content-Type":"application/json"}})).json()).data;this.url=e,this.headers=r}},y=class{constructor(e,{storefrontName:r,storefrontAccessToken:i,defaultNameSpaces:s}){this.getContentForNamespaces=async(e,r="fra")=>{let{shop:{content:i}}=await this.client.request(g,{identifiers:this.buildIdentifiers(e.concat(this.defaultNameSpaces),r)});return console.log({content:i}),i.reduce((s,t)=>{if(!t)return s;let c=t.namespace.replace(`_${r}`,"");s[c]||Object.assign(s,{[c]:{}});let o={itemID:t.id,itemType:t.type,itemProp:`${t.namespace}:${t.key}`},a;switch(t.type){case"collection_reference":{a={attributes:o,collection:{...t.collection,products:l(t.collection.products)}};break}case"file_reference":{t.image.image.alt||(t.image.image.alt=""),a={attributes:o,image:t.image.image};break}case"product_reference":{a={attributes:o,product:{...t.product,variants:l(t.product.variants)}};break}case"list.collection_reference":{a={attributes:o,collections:l(t.values).map(d=>({...d,products:l(d.products)}))};break}case"list.file_reference":{a={attributes:o,images:l(t.values).map(d=>d.image)};break}case"list.product_reference":{a={attributes:o,products:l(t.values).map(d=>({...d,variants:l(d.variants)}))};break}case"json":{a={attributes:o,[t.key]:JSON.parse(t.value)};break}case"list.multi_line_text_field":case"list.single_line_text_field":{a={attributes:o,texts:JSON.parse(t.value)};break}case"multi_line_text_field":case"single_line_text_field":{a={attributes:o,text:t.value};break}}return Object.assign(s[c],{[t.key]:a}),s},{})};this.t=(e,r="fr",i)=>{let[s,...t]=e.split("."),c=()=>C(this.config[s],t).default;return i&&i[s][t.join(".")]||c()};this.buildIdentifiers=(e,r="fra")=>e.reduce((s,t)=>{let c=this.config[t];return Object.entries(c).reduce((a,[d,h])=>(h.config?Object.keys(h.config).forEach(x=>{a.push(`${d}.${x}`)}):a.push(d),a),[]).forEach(a=>{s.push({namespace:`${t}_${r}`,key:a})}),s},[]);this.config=e,this.defaultNameSpaces=s||[],this.client=new f(`https://${r}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":i})}},l=n=>n.edges.reduce((e,{node:r})=>(e.push(r),e),[]),w=n=>n;var N=async(n,{storefrontName:e,storefrontAccessToken:r,adminAccessToken:i})=>{let s=new f(`https://${e}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":r}),t=new f(`https://${e}.myshopify.com/admin/api/2022-10/graphql.json`,{"X-Shopify-Access-Token":i}),{shop:{id:c}}=await s.request(u);return await t.request(m,{value:JSON.stringify(n),ownerId:c})};0&&(module.exports={GraphqlClient,MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig});
{
"name": "@meta-cms/core",
"version": "1.0.24",
"version": "1.0.25",
"description": "",

@@ -24,3 +24,6 @@ "main": "index.js",

},
"dependencies": {
"node-fetch": "^3.2.10"
},
"types": "index.d.ts"
}
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