@meta-cms/core
Advanced tools
Comparing version 1.0.19 to 1.0.20
@@ -1,2 +0,2 @@ | ||
"use strict";var F=Object.create;var p=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var k=(n,t)=>{for(var s in t)p(n,s,{get:t[s],enumerable:!0})},S=(n,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P(t))!T.call(n,r)&&r!==s&&p(n,r,{get:()=>t[r],enumerable:!(o=x(t,r))||o.enumerable});return n};var v=(n,t,s)=>(s=n!=null?F(_(n)):{},S(t||!n||!n.__esModule?p(s,"default",{value:n,enumerable:!0}):s,n)),b=n=>S(p({},"__esModule",{value:!0}),n);var w={};k(w,{MetaCms:()=>g,config:()=>O,contentQuery:()=>u,getMetaCMSConfigQuery:()=>N,getOwnerIdQuery:()=>m,setMetaCMSConfigMutation:()=>f,syncConfig:()=>$});module.exports=b(w);var C=require("graphql-request");var f=` | ||
"use strict";var F=Object.create;var p=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var k=(n,t)=>{for(var s in t)p(n,s,{get:t[s],enumerable:!0})},S=(n,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P(t))!T.call(n,r)&&r!==s&&p(n,r,{get:()=>t[r],enumerable:!(a=x(t,r))||a.enumerable});return n};var v=(n,t,s)=>(s=n!=null?F(_(n)):{},S(t||!n||!n.__esModule?p(s,"default",{value:n,enumerable:!0}):s,n)),b=n=>S(p({},"__esModule",{value:!0}),n);var w={};k(w,{MetaCms:()=>g,config:()=>O,contentQuery:()=>u,getMetaCMSConfigQuery:()=>N,getOwnerIdQuery:()=>m,setMetaCMSConfigMutation:()=>f,syncConfig:()=>$});module.exports=b(w);var C=require("graphql-request");var f=` | ||
mutation ($ownerId: ID!, $value: String!) { | ||
@@ -160,2 +160,2 @@ metafieldsSet( | ||
} | ||
`;var I=v(require("just-safe-get")),g=class{constructor(t,{storefrontName:s,storefrontAccessToken:o,defaultNameSpaces:r}){this.getContentForNamespaces=async(t,s="fra")=>{let{shop:{content:o}}=await this.client.request(u,{identifiers:this.buildIdentifiers(t.concat(this.defaultNameSpaces),s)});return console.log({content:o}),o.reduce((r,e)=>{if(!e)return r;let a=e.namespace.replace(`_${s}`,"");r[a]||Object.assign(r,{[a]:{}});let c={itemID:e.id,itemType:e.type,itemProp:`${e.namespace}:${e.key}`},i;switch(e.type){case"collection_reference":{i={attributes:c,collection:{...e.collection,products:l(e.collection.products)}};break}case"file_reference":{i={attributes:c,image:e.image.image};break}case"product_reference":{i={attributes:c,product:{...e.product,variants:l(e.product.variants)}};break}case"list.collection_reference":{i={attributes:c,collections:l(e.values).map(d=>({...d,products:l(d.products)}))};break}case"list.file_reference":{i={attributes:c,images:l(e.values).map(d=>d.image)};break}case"list.product_reference":{i={attributes:c,items:l(e.values).map(d=>({...d,variants:l(d.variants)}))};break}case"list.multi_line_text_field":case"list.single_line_text_field":{i={attributes:c,texts:JSON.parse(e.value)};break}case"multi_line_text_field":case"single_line_text_field":{i={attributes:c,text:e.value};break}}return Object.assign(r[a],{[e.key]:i}),r},{})};this.t=(t,s="fr",o)=>{let[r,...e]=t.split("."),a=()=>(0,I.default)(this.config[r],e).default;return o&&o[r][e.join(".")]||a()};this.buildIdentifiers=(t,s="fra")=>t.reduce((r,e)=>{let a=this.config[e];return Object.entries(a).reduce((i,[d,y])=>(y.config?Object.keys(y.config).forEach(M=>{i.push(`${d}.${M}`)}):i.push(d),i),[]).forEach(i=>{r.push({namespace:`${e}_${s}`,key:i})}),r},[]);this.config=t,this.defaultNameSpaces=r||[],this.client=new C.GraphQLClient(`https://${s}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":o}})}},l=n=>n.edges.reduce((t,{node:s})=>(t.push(s),t),[]),O=n=>n;var h=require("graphql-request");var $=async(n,{storefrontName:t,storefrontAccessToken:s,adminAccessToken:o})=>{let r=new h.GraphQLClient(`https://${t}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":s}}),e=new h.GraphQLClient(`https://${t}.myshopify.com/admin/api/2022-10/graphql.json`,{headers:{"X-Shopify-Access-Token":o}}),{shop:{id:a}}=await r.request(m);return await e.request(f,{value:JSON.stringify(n),ownerId:a})};0&&(module.exports={MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig}); | ||
`;var I=v(require("just-safe-get")),g=class{constructor(t,{storefrontName:s,storefrontAccessToken:a,defaultNameSpaces:r}){this.getContentForNamespaces=async(t,s="fra")=>{let{shop:{content:a}}=await this.client.request(u,{identifiers:this.buildIdentifiers(t.concat(this.defaultNameSpaces),s)});return a.reduce((r,e)=>{if(!e)return r;let o=e.namespace.replace(`_${s}`,"");r[o]||Object.assign(r,{[o]:{}});let c={itemID:e.id,itemType:e.type,itemProp:`${e.namespace}:${e.key}`},i;switch(e.type){case"collection_reference":{i={attributes:c,collection:{...e.collection,products:l(e.collection.products)}};break}case"file_reference":{i={attributes:c,image:e.image.image};break}case"product_reference":{i={attributes:c,product:{...e.product,variants:l(e.product.variants)}};break}case"list.collection_reference":{i={attributes:c,collections:l(e.values).map(d=>({...d,products:l(d.products)}))};break}case"list.file_reference":{i={attributes:c,images:l(e.values).map(d=>d.image)};break}case"list.product_reference":{i={attributes:c,items:l(e.values).map(d=>({...d,variants:l(d.variants)}))};break}case"list.multi_line_text_field":case"list.single_line_text_field":{i={attributes:c,texts:JSON.parse(e.value)};break}case"multi_line_text_field":case"single_line_text_field":{i={attributes:c,text:e.value};break}}return Object.assign(r[o],{[e.key]:i}),r},{})};this.t=(t,s="fr",a)=>{let[r,...e]=t.split("."),o=()=>(0,I.default)(this.config[r],e).default;return a&&a[r][e.join(".")]||o()};this.buildIdentifiers=(t,s="fra")=>t.reduce((r,e)=>{let o=this.config[e];return Object.entries(o).reduce((i,[d,y])=>(y.config?Object.keys(y.config).forEach(M=>{i.push(`${d}.${M}`)}):i.push(d),i),[]).forEach(i=>{r.push({namespace:`${e}_${s}`,key:i})}),r},[]);this.config=t,this.defaultNameSpaces=r||[],this.client=new C.GraphQLClient(`https://${s}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":a}})}},l=n=>n.edges.reduce((t,{node:s})=>(t.push(s),t),[]),O=n=>n;var h=require("graphql-request");var $=async(n,{storefrontName:t,storefrontAccessToken:s,adminAccessToken:a})=>{let r=new h.GraphQLClient(`https://${t}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":s}}),e=new h.GraphQLClient(`https://${t}.myshopify.com/admin/api/2022-10/graphql.json`,{headers:{"X-Shopify-Access-Token":a}}),{shop:{id:o}}=await r.request(m);return await e.request(f,{value:JSON.stringify(n),ownerId:o})};0&&(module.exports={MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig}); |
{ | ||
"name": "@meta-cms/core", | ||
"version": "1.0.19", | ||
"version": "1.0.20", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
20986
494