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.7 to 1.0.8

18

client.ts

@@ -17,3 +17,4 @@ import {

GetType,
TParams
TParams,
ConfigElement
} from "./types";

@@ -113,5 +114,10 @@ import { GraphQLClient } from "graphql-request";

const defaultValue = () => get(this.config[ns as keyof C], path).default as GetType<C, P>;
// if (!content) {
// return defaultValue() as GetType<C, P>;
// }
if (!content) {
// @ts-ignore
return defaultValue() as GetType<C, P>;
}
if (params?.toString === true) {
// @ts-ignore
return String(content[ns as keyof Cont][path.join(".")] || defaultValue());
}
// @ts-ignore

@@ -153,1 +159,5 @@ return (content[ns as keyof Cont][path.join(".")] || defaultValue()) as GetType<C, P>;

};
export const config = <C extends ConfigElement>(c: C) => {
return c;
};

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

}
declare const config: <C extends ConfigElement>(c: C) => C;
export { ArrayKeys, ArrayToUnion, CollectionContent, Config, ConfigElement, ConfigType, Content, GetConfigType, GetType, Identifier, ImageContent, Last, MetaCMSConfig, MetaCms, MetafieldCollection, MetafieldContent, MetafieldImage, MetafieldProduct, MetafieldVariant, Namespaces, Nodes, PathForNamespace, Paths, Price, PriceContent, PriceVariation, PriceVariationContent, ProductContent, Simplify, Split, TParams, TextContent, VariantContent, WithEdge, isList, toList };
export { ArrayKeys, ArrayToUnion, CollectionContent, Config, ConfigElement, ConfigType, Content, GetConfigType, GetType, Identifier, ImageContent, Last, MetaCMSConfig, MetaCms, MetafieldCollection, MetafieldContent, MetafieldImage, MetafieldProduct, MetafieldVariant, Namespaces, Nodes, PathForNamespace, Paths, Price, PriceContent, PriceVariation, PriceVariationContent, ProductContent, Simplify, Split, TParams, TextContent, VariantContent, WithEdge, config, isList, toList };

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

"use strict";var F=Object.create;var C=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var b=(a,n)=>{for(var s in n)C(a,s,{get:n[s],enumerable:!0})},h=(a,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of O(n))!_.call(a,t)&&t!==s&&C(a,t,{get:()=>n[t],enumerable:!(r=I(n,t))||r.enumerable});return a};var x=(a,n,s)=>(s=a!=null?F(T(a)):{},h(n||!a||!a.__esModule?C(s,"default",{value:a,enumerable:!0}):s,a)),j=a=>h(C({},"__esModule",{value:!0}),a);var N={};b(N,{MetaCms:()=>m});module.exports=j(N);var P=require("graphql-request");var y=`
"use strict";var F=Object.create;var C=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var _=(s,n)=>{for(var i in n)C(s,i,{get:n[i],enumerable:!0})},h=(s,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of T(n))!x.call(s,t)&&t!==i&&C(s,t,{get:()=>n[t],enumerable:!(o=I(n,t))||o.enumerable});return s};var b=(s,n,i)=>(i=s!=null?F(O(s)):{},h(n||!s||!s.__esModule?C(i,"default",{value:s,enumerable:!0}):i,s)),j=s=>h(C({},"__esModule",{value:!0}),s);var N={};_(N,{MetaCms:()=>m,config:()=>S});module.exports=j(N);var P=require("graphql-request");var y=`
query getContentF($identifiers: [HasMetafieldsIdentifier!]!) {

@@ -133,2 +133,2 @@ shop {

}
`;var M=x(require("just-safe-get")),m=class{constructor(n,{storefrontName:s,storefrontAcessToken:r,defaultNameSpaces:t}){this.getContentForNamespaces=async(n,s="fra")=>{let{shop:{content:r}}=await this.client.request(y,{identifiers:this.buildIdentifiers(n.concat(this.defaultNameSpaces),s)});return r.reduce((t,e)=>{var c,l,f,g;if(!e)return t;let i=e.namespace.replace(`_${s}`,"");if(t[i]||Object.assign(t,{[i]:{}}),(c=e.image)!=null&&c.image)Object.assign(t[i],{[e.key]:e.image.image});else if((l=e.product)!=null&&l.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 o=p(e.values),[u]=o;u.__typename==="Collection"?Object.assign(t[i],{[e.key]:o.map(d=>({...d,products:p(d.products)}))}):u.__typename==="MediaImage"?Object.assign(t[i],{[e.key]:o.map(d=>d.image)}):Object.assign(t[i],{[e.key]:o.map(d=>({...d,variants:p(d.variants)}))})}else if(e.type==="list.single_line_text_field"){let o=JSON.parse(e.value).map((u,d)=>({id:`${e.id}#${d}`,dangerouslySetInnerHTML:{__html:u}}));Object.assign(t[i],{[e.key]:o})}else{let o={id:e.id,dangerouslySetInnerHTML:{__html:e.value}};Object.assign(t[i],{[e.key]:o})}return t},{})};this.t=(n,s="fr",r,t)=>{console.log({params:t,locale:s});let[e,...i]=n.split("."),c=()=>(0,M.default)(this.config[e],i).default;return r[e][i.join(".")]||c()};this.buildIdentifiers=(n,s="fra")=>n.reduce((t,e)=>{let i=this.config[e];return Object.entries(i).reduce((l,[f,g])=>(g.config?Object.keys(g.config).forEach(o=>{l.push(`${f}.${o}`)}):l.push(f),l),[]).forEach(l=>{t.push({namespace:`${e}_${s}`,key:l})}),t},[]);this.config=n,this.defaultNameSpaces=t||[],this.client=new P.GraphQLClient(`https://${s}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":r}})}},p=a=>a.edges.reduce((n,{node:s})=>(n.push(s),n),[]);0&&(module.exports={MetaCms});
`;var M=b(require("just-safe-get")),m=class{constructor(n,{storefrontName:i,storefrontAcessToken:o,defaultNameSpaces:t}){this.getContentForNamespaces=async(n,i="fra")=>{let{shop:{content:o}}=await this.client.request(y,{identifiers:this.buildIdentifiers(n.concat(this.defaultNameSpaces),i)});return o.reduce((t,e)=>{var c,l,f,g;if(!e)return t;let a=e.namespace.replace(`_${i}`,"");if(t[a]||Object.assign(t,{[a]:{}}),(c=e.image)!=null&&c.image)Object.assign(t[a],{[e.key]:e.image.image});else if((l=e.product)!=null&&l.descriptionHtml)Object.assign(t[a],{[e.key]:{...e.product,variants:u(e.product.variants)}});else if((f=e.collection)!=null&&f.products)Object.assign(t[a],{[e.key]:{...e.collection,products:u(e.collection.products)}});else if((g=e.values)!=null&&g.edges.length){let r=u(e.values),[p]=r;p.__typename==="Collection"?Object.assign(t[a],{[e.key]:r.map(d=>({...d,products:u(d.products)}))}):p.__typename==="MediaImage"?Object.assign(t[a],{[e.key]:r.map(d=>d.image)}):Object.assign(t[a],{[e.key]:r.map(d=>({...d,variants:u(d.variants)}))})}else if(e.type==="list.single_line_text_field"){let r=JSON.parse(e.value).map((p,d)=>({id:`${e.id}#${d}`,dangerouslySetInnerHTML:{__html:p}}));Object.assign(t[a],{[e.key]:r})}else{let r={id:e.id,dangerouslySetInnerHTML:{__html:e.value}};Object.assign(t[a],{[e.key]:r})}return t},{})};this.t=(n,i="fr",o,t)=>{console.log({params:t,locale:i});let[e,...a]=n.split("."),c=()=>(0,M.default)(this.config[e],a).default;return o?(t==null?void 0:t.toString)===!0?String(o[e][a.join(".")]||c()):o[e][a.join(".")]||c():c()};this.buildIdentifiers=(n,i="fra")=>n.reduce((t,e)=>{let a=this.config[e];return Object.entries(a).reduce((l,[f,g])=>(g.config?Object.keys(g.config).forEach(r=>{l.push(`${f}.${r}`)}):l.push(f),l),[]).forEach(l=>{t.push({namespace:`${e}_${i}`,key:l})}),t},[]);this.config=n,this.defaultNameSpaces=t||[],this.client=new P.GraphQLClient(`https://${i}.myshopify.com/api/2022-10/graphql.json`,{headers:{"X-SHOPIFY-STOREFRONT-ACCESS-TOKEN":o}})}},u=s=>s.edges.reduce((n,{node:i})=>(n.push(i),n),[]),S=s=>s;0&&(module.exports={MetaCms,config});
{
"name": "@meta-cms/core",
"version": "1.0.7",
"version": "1.0.8",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/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