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.6 to 1.0.7

increment.js

13

client.ts

@@ -103,9 +103,14 @@ import {

t = <P extends Paths<C>, Cont extends Content<C>>(p: P, locale: "fr" = "fr", params: TParams, content: Cont) => {
t = <P extends Paths<C>, Cont extends Content<C>, O extends TParams>(
p: P,
locale: "fr" = "fr",
content: Cont,
params?: O
): O["toString"] extends true ? string : GetType<C, P> => {
console.log({ params, locale });
const [ns, ...path] = p.split(".");
const defaultValue = () => get(this.config[ns as keyof C], path).default as GetType<C, P>;
if (!content) {
return defaultValue();
}
// if (!content) {
// return defaultValue() as GetType<C, P>;
// }
// @ts-ignore

@@ -112,0 +117,0 @@ return (content[ns as keyof Cont][path.join(".")] || defaultValue()) as GetType<C, P>;

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

toString?: boolean;
plural: boolean;
plural?: boolean;
} & Record<string, any>;

@@ -233,3 +233,3 @@

getContentForNamespaces: (namespaces: Namespaces<C>[], locale?: "fra") => Promise<Content<C>>;
t: <P extends Paths<C>, Cont extends Content<C>>(p: P, locale: "fr" | undefined, params: TParams, content: Cont) => GetType<C, P>;
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>;
buildIdentifiers: (namespaces: Namespaces<C>[], locale?: "fra") => Identifier[];

@@ -236,0 +236,0 @@ }

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

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

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

}
`;var M=j(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:r,locale:s});let[e,...i]=n.split("."),c=()=>(0,M.default)(this.config[e],i).default;return t&&t[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=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});
{
"name": "@meta-cms/core",
"version": "1.0.6",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"pub": "pnpm run build && npm publish --access public",
"build": "tsup index.ts --minify --dts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "beynar",
"license": "MIT",
"devDependencies": {
"tsup": "^6.2.3",
"type-fest": "^3.0.0",
"typescript": "^4.8.4"
},
"dependencies": {
"graphql-request": "^5.0.0",
"just-safe-get": "^4.1.1"
},
"peerDependencies": {
"type-fest": "^3.0.0"
}
}
"name": "@meta-cms/core",
"version": "1.0.7",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup index.ts --minify --dts",
"pub": "pnpm run build && node increment && npm publish --access public",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "beynar",
"license": "MIT",
"devDependencies": {
"semver": "^7.3.8",
"tsup": "^6.2.3",
"type-fest": "^3.0.0",
"typescript": "^4.8.4"
},
"dependencies": {
"graphql-request": "^5.0.0",
"just-safe-get": "^4.1.1"
},
"peerDependencies": {
"type-fest": "^3.0.0"
}
}

@@ -323,3 +323,3 @@ import { Get } from "type-fest";

toString?: boolean;
plural: boolean;
plural?: boolean;
} & Record<string, any>;
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