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.32 to 1.0.33

2

index.d.ts

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

declare const setMetaCMSConfigMutation: (key: string) => string;
declare const setMetaCMSConfigMutation = "\n mutation ($ownerId: ID!, $value: String!) {\n metafieldsSet(metafields: [{ key: $key, namespace: \"meta-cms\", ownerId: $ownerId, value: $value, type: \"json\" }]) {\n userErrors {\n code\n }\n }\n }\n";
declare const getMetaCMSConfigQuery = "\n query {\n shop {\n config: metafield(key: \"config\", namespace: \"meta-cms\") {\n value\n id\n }\n }\n }\n";

@@ -329,0 +329,0 @@

@@ -1,13 +0,9 @@

"use strict";var m=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var F=(r,e)=>{for(var s in e)m(r,s,{get:e[s],enumerable:!0})},P=(r,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!M.call(r,n)&&n!==s&&m(r,n,{get:()=>e[n],enumerable:!(i=I(e,n))||i.enumerable});return r};var T=r=>P(m({},"__esModule",{value:!0}),r);var b={};F(b,{GraphqlClient:()=>f,MetaCms:()=>y,config:()=>v,contentQuery:()=>g,getMetaCMSConfigQuery:()=>_,getOwnerIdQuery:()=>u,setMetaCMSConfigMutation:()=>p,syncConfig:()=>O});module.exports=T(b);var p=r=>`
mutation ($ownerId: ID!, $value: String!) {
metafieldsSet(
metafields: [
{ key: ${r}, namespace: "meta-cms", ownerId: $ownerId, value: $value, type: "json" }
]
) {
userErrors {
code
}
}
}
"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=`
mutation ($ownerId: ID!, $value: String!) {
metafieldsSet(metafields: [{ key: $key, namespace: "meta-cms", ownerId: $ownerId, value: $value, type: "json" }]) {
userErrors {
code
}
}
}
`,_=`

@@ -160,2 +156,2 @@ query {

}
`;function S(r,e,s){if(!r)return s;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(),!r||(r=r[n],r===void 0))return s;return r}var f=class{constructor(e,s){this.request=async(e,s)=>(await(await fetch(this.url,{method:"POST",body:JSON.stringify({query:e,variables:s||{}}),headers:{...this.headers||{},"Content-Type":"application/json"}})).json()).data;this.url=e,this.headers=s}},y=class{constructor(e,{storefrontName:s,storefrontAccessToken:i,defaultNameSpaces:n}){this.getContentForNamespaces=async(e,s="fra")=>{let{shop:{content:i}}=await this.client.request(g,{identifiers:this.buildIdentifiers(e.concat(this.defaultNameSpaces),s)});return console.log({content:i}),i.reduce((n,t)=>{if(!t)return n;let c=t.namespace.replace(`_${s}`,"");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:d(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:d(t.product.variants)}};break}case"list.collection_reference":{a={attributes:o,collections:d(t.values).map(l=>({...l,products:d(l.products)}))};break}case"list.file_reference":{a={attributes:o,images:d(t.values).map(l=>l.image)};break}case"list.product_reference":{a={attributes:o,products:d(t.values).map(l=>({...l,variants:d(l.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,s="fr",i)=>{let[n,...t]=e.split("."),c=()=>S(this.config[n],t).default;return i&&i[n][t.join(".")]||c()};this.buildIdentifiers=(e,s="fra")=>e.reduce((n,t)=>{let c=this.config[t];return Object.entries(c).reduce((a,[l,h])=>(h.config?Object.keys(h.config).forEach(C=>{a.push(`${l}.${C}`)}):a.push(l),a),[]).forEach(a=>{n.push({namespace:`${t}_${s}`,key:a})}),n},[]);this.config=e,this.defaultNameSpaces=n||[],this.client=new f(`https://${s}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":i})}},d=r=>r.edges.reduce((e,{node:s})=>(e.push(s),e),[]),v=r=>r;var O=async(r,{storefrontName:e,storefrontAccessToken:s,adminAccessToken:i},n)=>{console.log(n);let t=new f(`https://${e}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":s}),c=new f(`https://${e}.myshopify.com/admin/api/2022-10/graphql.json`,{"X-Shopify-Access-Token":i}),{shop:{id:o}}=await t.request(u);return console.log(p(n)),await c.request(p(n),{value:JSON.stringify(r),ownerId:o})};0&&(module.exports={GraphqlClient,MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig});
`;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:d(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:d(t.product.variants)}};break}case"list.collection_reference":{a={attributes:o,collections:d(t.values).map(l=>({...l,products:d(l.products)}))};break}case"list.file_reference":{a={attributes:o,images:d(t.values).map(l=>l.image)};break}case"list.product_reference":{a={attributes:o,products:d(t.values).map(l=>({...l,variants:d(l.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,[l,h])=>(h.config?Object.keys(h.config).forEach(C=>{a.push(`${l}.${C}`)}):a.push(l),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})}},d=s=>s.edges.reduce((e,{node:r})=>(e.push(r),e),[]),v=s=>s;var k=async(s,{storefrontName:e,storefrontAccessToken:r,adminAccessToken:i},n)=>{console.log(n);let t=new f(`https://${e}.myshopify.com/api/2022-10/graphql.json`,{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":r}),c=new f(`https://${e}.myshopify.com/admin/api/2022-10/graphql.json`,{"X-Shopify-Access-Token":i}),{shop:{id:o}}=await t.request(u);return console.log({key:n}),await c.request(m,{value:JSON.stringify(s),key:n,ownerId:o})};0&&(module.exports={GraphqlClient,MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig});
{
"name": "@meta-cms/core",
"version": "1.0.32",
"version": "1.0.33",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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