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.5 to 1.0.6

6

client.ts

@@ -26,4 +26,6 @@ import {

client: GraphQLClient;
constructor(config: C, { storefrontName, storefrontAcessToken }: MetaCMSConfig) {
defaultNameSpaces: Namespaces<C>[];
constructor(config: C, { storefrontName, storefrontAcessToken, defaultNameSpaces }: MetaCMSConfig<C>) {
this.config = config;
this.defaultNameSpaces = defaultNameSpaces || [];
this.client = new GraphQLClient(`https://${storefrontName}.myshopify.com/api/2022-10/graphql.json`, {

@@ -40,3 +42,3 @@ headers: {

} = await this.client.request<{ shop: { content: MetafieldContent[] } }>(contentQuery, {
identifiers: this.buildIdentifiers(namespaces, locale)
identifiers: this.buildIdentifiers(namespaces.concat(this.defaultNameSpaces), locale)
});

@@ -43,0 +45,0 @@

@@ -135,5 +135,6 @@ import { Get } from 'type-fest';

};
declare type MetaCMSConfig = {
declare type MetaCMSConfig<C extends Config> = {
storefrontName: string;
storefrontAcessToken: string;
defaultNameSpaces: Namespaces<C>[];
};

@@ -229,3 +230,4 @@ interface MetafieldContent {

client: GraphQLClient;
constructor(config: C, { storefrontName, storefrontAcessToken }: MetaCMSConfig);
defaultNameSpaces: Namespaces<C>[];
constructor(config: C, { storefrontName, storefrontAcessToken, defaultNameSpaces }: MetaCMSConfig<C>);
getContentForNamespaces: (namespaces: Namespaces<C>[], locale?: "fra") => Promise<Content<C>>;

@@ -236,2 +238,2 @@ t: <P extends Paths<C>, Cont extends Content<C>>(p: P, locale: "fr" | undefined, params: TParams, content: Cont) => GetType<C, P>;

export { ArrayKeys, 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, 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, isList, toList };

@@ -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=(i,n)=>{for(var s in n)C(i,s,{get:n[s],enumerable:!0})},h=(i,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of T(n))!b.call(i,t)&&t!==s&&C(i,t,{get:()=>n[t],enumerable:!(r=I(n,t))||r.enumerable});return i};var j=(i,n,s)=>(s=i!=null?F(_(i)):{},h(n||!i||!i.__esModule?C(s,"default",{value:i,enumerable:!0}):s,i)),x=i=>h(C({},"__esModule",{value:!0}),i);var v={};O(v,{MetaCms:()=>m});module.exports=x(v);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 _=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=`
query getContentF($identifiers: [HasMetafieldsIdentifier!]!) {

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

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

@@ -5,0 +5,0 @@ "main": "dist/index.js",

import { Get } from "type-fest";
type Simplify<C extends ConfigElement | Config> = {
export type Simplify<C extends ConfigElement | Config> = {
[K in keyof C]: Get<C[K], "config"> extends ConfigElement ? keyof Get<C[K], "config"> : never;
};
type ArrayToUnion<Base> = NonNullable<
export type ArrayToUnion<Base> = NonNullable<
{

@@ -211,5 +211,6 @@ [Key in keyof Base]: Base[Key] extends never

export type Identifier = { namespace: string; key: string };
export type MetaCMSConfig = {
export type MetaCMSConfig<C extends Config> = {
storefrontName: string;
storefrontAcessToken: string;
defaultNameSpaces: Namespaces<C>[];
};

@@ -216,0 +217,0 @@

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