@meta-cms/core
Advanced tools
Comparing version 1.0.35 to 1.0.36
@@ -326,3 +326,3 @@ import { Get } from 'type-fest'; | ||
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 setMetaCMSConfigMutation = "\n mutation ($ownerId: ID!, $value: String!, $key: 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,3 +0,3 @@ | ||
"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 N={};F(N,{GraphqlClient:()=>f,MetaCms:()=>y,config:()=>v,contentQuery:()=>m,getMetaCMSConfigQuery:()=>_,getOwnerIdQuery:()=>u,setMetaCMSConfigMutation:()=>g,syncConfig:()=>O});module.exports=T(N);var g=` | ||
mutation ($ownerId: ID!, $value: String!) { | ||
"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:()=>k,contentQuery:()=>g,getMetaCMSConfigQuery:()=>_,getOwnerIdQuery:()=>u,setMetaCMSConfigMutation:()=>m,syncConfig:()=>v});module.exports=T(O);var m=` | ||
mutation ($ownerId: ID!, $value: String!, $key: String!) { | ||
metafieldsSet(metafields: [{ key: $key, namespace: "meta-cms", ownerId: $ownerId, value: $value, type: "json" }]) { | ||
@@ -24,3 +24,3 @@ userErrors { | ||
} | ||
`;var m=` | ||
`;var g=` | ||
query getContentF($identifiers: [HasMetafieldsIdentifier!]!) { | ||
@@ -157,2 +157,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)=>{let i=await fetch(this.url,{method:"POST",body:JSON.stringify({query:e,variables:r||{}}),headers:{...this.headers||{},"Content-Type":"application/json"}});return console.log(i),(await i.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(m,{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 O=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);console.log({key:n,id:o}),console.log(JSON.stringify(s));let a=await c.request(g,{value:JSON.stringify(s),key:n,ownerId:o});return console.log({data:a}),console.log({key:n}),a};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: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),[]),k=s=>s;var v=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 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.35", | ||
"version": "1.0.36", | ||
"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
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
22538