Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.4 to 0.0.5

2

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

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

const {
// getId,
getAbout,
// getBlob,
publish,
message,
getMessagesByType,
get,
} = require('ssb-helpers')

@@ -41,3 +37,4 @@

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

@@ -56,4 +53,4 @@ }

const getUserBalance = async(username, sbot) => {
const transactions = await getUserTransactions(username, sbot)
const getUserBalance = async(username, scope, sbot) => {
const transactions = await getUserTransactions(username, scope, sbot)
const userReceived = transactions

@@ -94,6 +91,7 @@ .filter(transaction => transaction.value.content.receiver === username)

const getPublishedResources = async (sbot) => {
const getPublishedResources = async (scope, sbot) => {
try {
const events = await getMessagesByType({ type: economicEventType }, sbot)
const unpublished = events
const communityEvents = events.filter(e => e.value.content.scope === scope)
const unpublished = communityEvents
.filter(msg => msg.value.content.action === unpublishAction)

@@ -125,2 +123,3 @@ .map(msg => msg.value.content.affects[0])

user: msg.value.content.currentOwner,
scope,
}

@@ -135,16 +134,19 @@ })

const getUserPublications = async(username, sbot) => {
const resources = await getPublishedResources(sbot)
const getUserPublications = async(username, scope, sbot) => {
const resources = await getPublishedResources(scope, sbot)
return resources.filter(r => r.user === username)
}
const getUserTransactions = async(username, sbot) => {
const getUserTransactions = async(username, scope, sbot) => {
const transactions = await getTransactions(sbot)
return transactions.filter(transaction => (transaction.value.content.receiver === username || transaction.value.content.provider === username))
return transactions
.filter(transaction => transaction.value.content.scope === scope)
.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 getUser = async(username, scope, sbot) => {
const balance = await getUserBalance(username, scope, sbot)
const rawTransactions = await getUserTransactions(username, scope, sbot)
const transactions = rawTransactions.map(t => Object.assign(t.value.content, { key: t.key }))
const publishedResources = await getUserPublications(username, scope, sbot)
const res = {

@@ -155,2 +157,3 @@ username,

publishedResources,
scope,
}

@@ -161,11 +164,13 @@ return res

const Query = {
publishedResources: async (_, {}, { sbot }) => {
return await getPublishedResources(sbot)
publishedResources: async (_, {}, { sbot, opts }) => {
return await getPublishedResources(opts.scope, sbot)
},
user: async(_, { username }, { sbot }) => {
return getUser(username, sbot)
user: async(_, { username }, { sbot, opts }) => {
return getUser(username, opts.scope, sbot)
},
transactions: async(_, {}, {sbot}) => {
transactions: async(_, {}, { sbot, opts }) => {
const events = await getMessagesByType({ type: economicEventType }, sbot)
const transactions = events.filter(event => event.value.content.action === transactionAction)
const transactions = events
.filter(event => event.value.content.scope === opts.scope)
.filter(event => event.value.content.action === transactionAction)
return transactions.map(tx => Object.assign(tx.value.content, { key: tx.key }))

@@ -176,3 +181,3 @@ }

const Mutation = {
publishResource: async (_, { input }, { sbot }) => {
publishResource: async (_, { input }, { sbot, opts }) => {
const classification = await publish(Object.assign({ type: resourceClassficationType }, {

@@ -186,3 +191,4 @@ category: input.category

prices: input.prices,
resourceClassifiedAs: classification.key
resourceClassifiedAs: classification.key,
scope: opts.scope,
}), sbot)

@@ -195,2 +201,3 @@ .then(msg => {

user: msg.value.content.currentOwner,
scope: msg.value.content.scope
}

@@ -212,3 +219,3 @@ })

},
transaction: async(_, { input: { provider, receiver, currency, value, affects }}, { sbot }) => {
transaction: async(_, { input: { provider, receiver, currency, value, affects }}, { sbot, opts }) => {
return publish({

@@ -220,3 +227,4 @@ type: economicEventType,

receiver,
affectedQuantity: [`${value},${currency}`]
affectedQuantity: [`${value},${currency}`],
scope: opts.scope,
}, sbot)

@@ -229,2 +237,3 @@ .then(msg => {

affectedQuantity: [ { currency, value }],
scope: msg.value.content.scope,
}

@@ -231,0 +240,0 @@ })

@@ -14,2 +14,3 @@ const Price = `

affectedQuantity: Price!
scope: String!
affects: [Resource]

@@ -25,2 +26,3 @@ }

transactions: [Transaction]
scope: String!
}

@@ -35,2 +37,3 @@ `

user: String!
scope: String!
}

@@ -37,0 +40,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