@meta-cms/core
Advanced tools
Comparing version 1.0.9 to 1.0.11
@@ -28,3 +28,3 @@ import { | ||
defaultNameSpaces: Namespaces<C>[]; | ||
constructor(config: C, { storefrontName, storefrontAcessToken, defaultNameSpaces }: MetaCMSConfig<C>) { | ||
constructor(config: C, { storefrontName, storefrontAccessToken, defaultNameSpaces }: MetaCMSConfig<C>) { | ||
this.config = config; | ||
@@ -34,3 +34,3 @@ this.defaultNameSpaces = defaultNameSpaces || []; | ||
headers: { | ||
"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN": storefrontAcessToken | ||
"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN": storefrontAccessToken | ||
} | ||
@@ -37,0 +37,0 @@ }); |
@@ -137,3 +137,3 @@ import { Get } from 'type-fest'; | ||
storefrontName: string; | ||
storefrontAcessToken: string; | ||
storefrontAccessToken: string; | ||
defaultNameSpaces: Namespaces<C>[]; | ||
@@ -231,3 +231,3 @@ }; | ||
defaultNameSpaces: Namespaces<C>[]; | ||
constructor(config: C, { storefrontName, storefrontAcessToken, defaultNameSpaces }: MetaCMSConfig<C>); | ||
constructor(config: C, { storefrontName, storefrontAccessToken, defaultNameSpaces }: MetaCMSConfig<C>); | ||
getContentForNamespaces: (namespaces: Namespaces<C>[], locale?: "fra") => Promise<Content<C>>; | ||
@@ -246,5 +246,5 @@ t: <P extends Paths<C>, Cont extends Content<C>, O extends TParams>(p: P, locale: "fr" | undefined, content: Cont, params?: O | undefined) => O["toString"] extends true ? string : GetType<C, P>; | ||
declare const syncConfig: (config: Config, { storefrontName, storefrontAcessToken, adminAccessToken }: { | ||
declare const syncConfig: (config: Config, { storefrontName, storefrontAccessToken, adminAccessToken }: { | ||
storefrontName: string; | ||
storefrontAcessToken: string; | ||
storefrontAccessToken: string; | ||
adminAccessToken: string; | ||
@@ -251,0 +251,0 @@ }) => Promise<any>; |
@@ -160,2 +160,2 @@ "use strict";var O=Object.create;var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var v=(s,n)=>{for(var o in n)m(s,o,{get:n[o],enumerable:!0})},P=(s,n,o,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of T(n))!k.call(s,t)&&t!==o&&m(s,t,{get:()=>n[t],enumerable:!(a=S(n,t))||a.enumerable});return s};var _=(s,n,o)=>(o=s!=null?O(j(s)):{},P(n||!s||!s.__esModule?m(o,"default",{value:s,enumerable:!0}):o,s)),N=s=>P(m({},"__esModule",{value:!0}),s);var E={};v(E,{MetaCms:()=>M,config:()=>$,contentQuery:()=>h,getMetaCMSConfigQuery:()=>b,getOwnerIdQuery:()=>y,setMetaCMSConfigMutation:()=>C,syncConfig:()=>w});module.exports=N(E);var F=require("graphql-request");var C=` | ||
} | ||
`;var x=_(require("just-safe-get")),M=class{constructor(n,{storefrontName:o,storefrontAcessToken:a,defaultNameSpaces:t}){this.getContentForNamespaces=async(n,o="fra")=>{let{shop:{content:a}}=await this.client.request(h,{identifiers:this.buildIdentifiers(n.concat(this.defaultNameSpaces),o)});return a.reduce((t,e)=>{var d,c,f,g;if(!e)return t;let i=e.namespace.replace(`_${o}`,"");if(t[i]||Object.assign(t,{[i]:{}}),(d=e.image)!=null&&d.image)Object.assign(t[i],{[e.key]:e.image.image});else if((c=e.product)!=null&&c.descriptionHtml)Object.assign(t[i],{[e.key]:{...e.product,variants:p(e.product.variants)}});else if((f=e.collection)!=null&&f.products)Object.assign(t[i],{[e.key]:{...e.collection,products:p(e.collection.products)}});else if((g=e.values)!=null&&g.edges.length){let r=p(e.values),[u]=r;u.__typename==="Collection"?Object.assign(t[i],{[e.key]:r.map(l=>({...l,products:p(l.products)}))}):u.__typename==="MediaImage"?Object.assign(t[i],{[e.key]:r.map(l=>l.image)}):Object.assign(t[i],{[e.key]:r.map(l=>({...l,variants:p(l.variants)}))})}else if(e.type==="list.single_line_text_field"){let r=JSON.parse(e.value).map((u,l)=>({id:`${e.id}#${l}`,dangerouslySetInnerHTML:{__html:u}}));Object.assign(t[i],{[e.key]:r})}else{let r={id:e.id,dangerouslySetInnerHTML:{__html:e.value}};Object.assign(t[i],{[e.key]:r})}return t},{})};this.t=(n,o="fr",a,t)=>{console.log({params:t,locale:o});let[e,...i]=n.split("."),d=()=>(0,x.default)(this.config[e],i).default;return a?(t==null?void 0:t.toString)===!0?String(a[e][i.join(".")]||d()):a[e][i.join(".")]||d():d()};this.buildIdentifiers=(n,o="fra")=>n.reduce((t,e)=>{let i=this.config[e];return Object.entries(i).reduce((c,[f,g])=>(g.config?Object.keys(g.config).forEach(r=>{c.push(`${f}.${r}`)}):c.push(f),c),[]).forEach(c=>{t.push({namespace:`${e}_${o}`,key:c})}),t},[]);this.config=n,this.defaultNameSpaces=t||[],this.client=new F.GraphQLClient(`https://${o}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":a}})}},p=s=>s.edges.reduce((n,{node:o})=>(n.push(o),n),[]),$=s=>s;var I=require("graphql-request");var w=async(s,{storefrontName:n,storefrontAcessToken:o,adminAccessToken:a})=>{let t=new I.GraphQLClient(`https://${n}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":o}}),e=new I.GraphQLClient(`https://${n}.myshopify.com/admin/api/2022-10/graphql.json`,{headers:{"X-Shopify-Access-Token":a}}),{data:{shop:{id:i}}}=await t.request(y);console.log({id:i});let{data:d}=await e.request(C,{value:JSON.stringify(s),ownerId:i});return d};0&&(module.exports={MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig}); | ||
`;var x=_(require("just-safe-get")),M=class{constructor(n,{storefrontName:o,storefrontAccessToken:a,defaultNameSpaces:t}){this.getContentForNamespaces=async(n,o="fra")=>{let{shop:{content:a}}=await this.client.request(h,{identifiers:this.buildIdentifiers(n.concat(this.defaultNameSpaces),o)});return a.reduce((t,e)=>{var l,c,f,g;if(!e)return t;let i=e.namespace.replace(`_${o}`,"");if(t[i]||Object.assign(t,{[i]:{}}),(l=e.image)!=null&&l.image)Object.assign(t[i],{[e.key]:e.image.image});else if((c=e.product)!=null&&c.descriptionHtml)Object.assign(t[i],{[e.key]:{...e.product,variants:p(e.product.variants)}});else if((f=e.collection)!=null&&f.products)Object.assign(t[i],{[e.key]:{...e.collection,products:p(e.collection.products)}});else if((g=e.values)!=null&&g.edges.length){let r=p(e.values),[u]=r;u.__typename==="Collection"?Object.assign(t[i],{[e.key]:r.map(d=>({...d,products:p(d.products)}))}):u.__typename==="MediaImage"?Object.assign(t[i],{[e.key]:r.map(d=>d.image)}):Object.assign(t[i],{[e.key]:r.map(d=>({...d,variants:p(d.variants)}))})}else if(e.type==="list.single_line_text_field"){let r=JSON.parse(e.value).map((u,d)=>({id:`${e.id}#${d}`,dangerouslySetInnerHTML:{__html:u}}));Object.assign(t[i],{[e.key]:r})}else{let r={id:e.id,dangerouslySetInnerHTML:{__html:e.value}};Object.assign(t[i],{[e.key]:r})}return t},{})};this.t=(n,o="fr",a,t)=>{console.log({params:t,locale:o});let[e,...i]=n.split("."),l=()=>(0,x.default)(this.config[e],i).default;return a?(t==null?void 0:t.toString)===!0?String(a[e][i.join(".")]||l()):a[e][i.join(".")]||l():l()};this.buildIdentifiers=(n,o="fra")=>n.reduce((t,e)=>{let i=this.config[e];return Object.entries(i).reduce((c,[f,g])=>(g.config?Object.keys(g.config).forEach(r=>{c.push(`${f}.${r}`)}):c.push(f),c),[]).forEach(c=>{t.push({namespace:`${e}_${o}`,key:c})}),t},[]);this.config=n,this.defaultNameSpaces=t||[],this.client=new F.GraphQLClient(`https://${o}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":a}})}},p=s=>s.edges.reduce((n,{node:o})=>(n.push(o),n),[]),$=s=>s;var I=require("graphql-request");var w=async(s,{storefrontName:n,storefrontAccessToken:o,adminAccessToken:a})=>{let t=new I.GraphQLClient(`https://${n}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":o}}),e=new I.GraphQLClient(`https://${n}.myshopify.com/admin/api/2022-10/graphql.json`,{headers:{"X-Shopify-Access-Token":a}}),{shop:{id:i}}=await t.request(y);return await e.request(C,{value:JSON.stringify(s),ownerId:i})};0&&(module.exports={MetaCms,config,contentQuery,getMetaCMSConfigQuery,getOwnerIdQuery,setMetaCMSConfigMutation,syncConfig}); |
{ | ||
"name": "@meta-cms/core", | ||
"version": "1.0.9", | ||
"version": "1.0.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
13
sync.ts
@@ -10,7 +10,7 @@ import { Config } from "./types"; | ||
storefrontName, | ||
storefrontAcessToken, | ||
storefrontAccessToken, | ||
adminAccessToken | ||
}: { | ||
storefrontName: string; | ||
storefrontAcessToken: string; | ||
storefrontAccessToken: string; | ||
adminAccessToken: string; | ||
@@ -21,3 +21,3 @@ } | ||
headers: { | ||
"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN": storefrontAcessToken | ||
"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN": storefrontAccessToken | ||
} | ||
@@ -32,9 +32,6 @@ }); | ||
const { | ||
data: { | ||
shop: { id } | ||
} | ||
shop: { id } | ||
} = await storefrontClient.request(getOwnerIdQuery); | ||
console.log({ id }); | ||
const { data } = await adminClient.request(setMetaCMSConfigMutation, { | ||
const data = await adminClient.request(setMetaCMSConfigMutation, { | ||
value: JSON.stringify(config), | ||
@@ -41,0 +38,0 @@ ownerId: id |
@@ -213,3 +213,3 @@ import { Get } from "type-fest"; | ||
storefrontName: string; | ||
storefrontAcessToken: string; | ||
storefrontAccessToken: string; | ||
defaultNameSpaces: Namespaces<C>[]; | ||
@@ -216,0 +216,0 @@ }; |
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
41355
1117