Socket
Socket
Sign inDemoInstall

bazaar-graphql

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bazaar-graphql - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

package.json
{
"name": "bazaar-graphql",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

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

@@ -11,5 +11,5 @@ const {

const resourceClassficationType = 'resourceClassificationTest3'
const economicResourceType = 'economicResourceTest3'
const economicEventType = 'economicEventTest3'
const resourceClassficationType = 'vf:resourceClassificationAlpha'
const economicResourceType = 'vf:economicResourceAlpha'
const economicEventType = 'vf:economicEventAlpha'
const unpublishAction = "unpublish resource"

@@ -40,2 +40,8 @@ const transactionAction = "transaction"

const getTransactions = async (sbot) => {
const events = await getMessagesByType({ type: economicEventType }, sbot)
return events.filter(event => event.value.content.action === transactionAction)
}
const getEconomicResource = async (id, sbot) => {

@@ -52,4 +58,3 @@ const economicResource = await message({ id }, sbot)

const getUserBalance = async(username, sbot) => {
const events = await getMessagesByType({ type: economicEventType }, sbot)
const transactions = events.filter(event => event.value.content.action === transactionAction)
const transactions = await getUserTransactions(username, sbot)
const userReceived = transactions

@@ -90,20 +95,4 @@ .filter(transaction => transaction.value.content.receiver === username)

const getUserPublications = async(username, sbot) => {
}
const getUserTransactions = async(username, sbot) => {
}
const getUser = async(username, sbot) => {
const balance = getUserBalance(username, sbot)
return {
username,
balance,
}
}
const Query = {
publishedResources: async (_, {}, { sbot }) => {
const getPublishedResources = async (sbot) => {
try {
const events = await getMessagesByType({ type: economicEventType }, sbot)

@@ -113,4 +102,6 @@ const unpublished = events

.map(msg => msg.value.content.affects[0])
// console.log('unpublished', unpublished)
const msgs = await getMessagesByType({ type: economicResourceType }, sbot)
return msgs
// console.log('MSGS', msgs)
const filtered = msgs
.filter(msg => msg.value.content.prices.length > 0)

@@ -125,5 +116,8 @@ .filter(msg => {

})
.map(async msg => {
const res = await filtered
.map(async (msg) => {
// console.log('MSG', Object.keys(msg).length)
const resourceClassifiedAs = await getResourceClassfication(msg.value.content.resourceClassifiedAs, sbot)
const prices = getPrices(msg.value.content.prices)
// console.log('ASYNC')
return {

@@ -136,2 +130,35 @@ key: msg.key,

})
// console.log('ASONC')
return res
} catch(err) {
console.log('ERROR!!', err)
}
}
const getUserPublications = async(username, sbot) => {
const resources = await getPublishedResources(sbot)
return resources.filter(r => r.user === username)
}
const getUserTransactions = async(username, sbot) => {
const transactions = await getTransactions(sbot)
return transactions.filter(transaction => (transaction.value.content.receiver === username || transaction.value.content.provider === username))
}
const getUser = async(username, sbot) => {
const balance = await getUserBalance(username, sbot)
const transactions = await getUserTransactions(username, sbot)
const publishedResources = await getUserPublications(username, sbot)
const res = {
username,
balance,
transactions,
publishedResources,
}
return res
}
const Query = {
publishedResources: async (_, {}, { sbot }) => {
return await getPublishedResources(sbot)
},

@@ -138,0 +165,0 @@ user: async(_, { username }, { sbot }) => {

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