npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ssb-graphql/profile

v9.0.1

Published

GraphQL types and resolvers for the ssb-profile plugin

Downloads

58

Readme

@ssb-graphql/profile

GraphQL types and resolvers for Secure Scuttlebutt profile plugin (ssb-profile)

Usage

Install ssb-graphql's main and profile packages:

npm i -S @ssb-graphql/main @ssb-graphql/profile

Example Usage

const ahauServer = require('ahau-graphql-server')

const ssbProfileGraphql = require('ssb-profile-graphql')
const Server = require('ssb-server')
const Config = require('ssb-config/inject')

const config = Config({})

const sbot = Server
  .use(require('ssb-backlinks'))
  .use(require('ssb-query'))
  .use(require('ssb-profile'))
  .call(null, config)

const main = require('@ssb-graphql/main')(sbot)
const profile = require('@ssb-graphql/profile')(sbot)

main.loadContext((err, context) => {
  const server = new ahauServer({
    schemas: [
      main,
      profile // { typeDefs, resolvers }
              // ... add more here
    ],
    context
  })

  // ... 
})

API

Things provided by instantiating @ssb-graphql/profile:

  • typeDefs
  • resolvers
  • gettersWithCache: an object with callback-style getters (currently for getProfile

In general, this module adds functionality:

  • ssb-profile methods
    • create profiles (person, community)
    • read profiles
    • create links: feed-profile, group-profile
    • find profiles by a name
  • resolve further profile details on the whoami query (@ssb-graphql/main)
  • get all tribes (community) profiles
  • get all peers you're within range of (profiles grouped by type)
  • get all peers you're currented connected to (profiles grouped by type)

See /src/typeDefs.js for the most up to date definition of what's offered here.

`query { findPersons(name: String!, type: String, groupId: String ): [Profile] }

  • name (required) a string of minimum length 3, a (partial) fragment of a name
  • type can be:
    • String
      • person = public + group person profiles (default)
      • person/admin = admin person profiles
      • person/source = source person profiles
      • community = public + group community profiles
      • pataka = public pataka profiles
    • null - this means "get me all matches of any type"
  • groupId String - narrows to profiles only in groupId (can be a GroupId or POBoxId)

mutation { saveProfile(input) }: String

This is a complex endpoint which does A LOT of work.

case: create profile

If no id is passed in, it is assumed that you are creating a profile. The exact type of profile is then determined by type and recps

IF you fall into the person-group type (type: person, recps: [groupId]) AND there are details that are for the person-admin fields (e.g. phone), then this method will attempt to locate an admin subgroup, and publish and link up a profile there. ONLY the admin-only fields will be saved to the profile/person/admin profile (as all the group fields are already saved to the group profile)

case: updating profile

If an id is passed in, then this method will attempt to update the given profile, and handle other assumed desired updates.

If the profile is one of "your profiles" (linked to your feedId), then a "bulk-update" of all your linked profiles is triggered (saving the appropriate details to each, e.g. phone only to admin-profiles). (The only exception to this is if you happen to be calling an update on your public profile - this does not bulk-update other profiles. The reason for this is that we want to allow people to have a different external facing name for security)

If the profile isn't "yours", then this method will update the profile as best it can, and overflow details it can't save to a "group profile" into an "admin profile" (if it can).

  • if it's a profile that anyone can edit, then you update that
    • if there are admin-only details, then those details are published to a linked admin-only profile (if you're an admin)
  • if you are not allowed to edit the profile, then all details are saved to a linked admin-only profile (assuming you're an admin)

Requirements

An ssb-server with the following plugins :

  • ssb-backlinks
  • ssb-query
  • ssb-profile

Note if running @ssb-graphql/main, that also has requirements