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-msg-schemas

v6.3.0

Published

validation and publishing methods for common ssb message types

Downloads

99

Readme

SSB Message Schemas

Functions to create common SSB messages.

{ type: 'post', text: String, channel: String, root: MsgLink, branch: MsgLink|MsgLinks, recps: FeedLinks, mentions: Links }
{ type: 'post-edit', text: String, root: MsgLink, revisionRoot: MsgLink, revisionBranch: MsgLink, mentions: Links }
{ type: 'about', about: Link, name: String, image: BlobLink }
{ type: 'contact', contact: FeedLink, following: Bool, blocking: Bool }
{ type: 'vote', vote: { link: Ref, value: -1|0|1, reason: String } }
{ type: 'pub', pub: { link: FeedRef, host: String, port: Number } }
var schemas = require('ssb-msg-schemas')

schemas.post(text, root (optional), branch (optional), mentions (optional), recps (optional), channel (optional))
// => { type: 'post', text: text, channel: channel, root: root, branch: branch, mentions: mentions, recps: recps }
schemas.postEdit(text, root, revisionRoot, revisionBranch, mentions (optional))
// => { type: 'post-edit', text: text, root: root, revisionRoot: revisionRoot, revisionBranch: revisionBranch, mentions: mentions }
schemas.name(id, name)
// => { type: 'about', about: id, name: name }
schemas.image(id, imgLink)
// => { type: 'about', about: id, image: imgLink }
schemas.follow(userId)
// => { type: 'contact', contact: userId, following: true, blocking: false }
schemas.unfollow(userId)
// => { type: 'contact', contact: userId, following: false }
schemas.block(userId)
// => { type: 'contact', contact: userId, following: false, blocking: true }
schemas.unblock(userId)
// => { type: 'contact', contact: userId, blocking: false }
schemas.vote(id, vote)
// => { type: 'vote', vote: { link: id, value: vote } }
schemas.vote(id, vote, reason)
// => { type: 'vote', vote: { link: id, value: vote, reason: reason } }
schemas.pub(id, host, port)
// => { type: 'pub', pub: { link: id, host: host, port: port } }

Notes

type: post

{ type: 'post', text: String, channel: String, root: MsgLink, branch: MsgLink|MsgLinks, recps: FeedLinks, mentions: Links }
  • channel is optionally used to filter posts into groups, similar to subreddits or chat channels.
  • root and branch are for replies.
    • root should point to the topmost message in the thread.
    • branch should point to the message or set of messages in the thread which is being replied to.
    • In the first reply of a thread, root === branch, and both should be included.
    • root and branch should only point to type: post messages. If the post is about another message-type, use mentions.
  • mentions is a generic reference to other feeds, entities, or blobs.
    • It is used by user mentions (you typed "@bob", so bob's link goes in mentions).
    • It is used by file-attachments (you attached a file, the reference goes in mentions).
    • It is used by message-mentions (to reference non-post messages).
  • recps is a list of user-links specifying who the message is for.
    • This is typically used for encrypted messages, to specify who the message was encrypted for.

type: postEdit

{ type: 'post-edit', text: String, root: MsgLink, revisionRoot: MsgLink, revisionBranch: MsgLink, mentions: Links }
  • text is used for posting the revised text that should take the place of some previous text.
  • root should point to the topmost message in the thread (i.e., the original thread root).
  • revisionRoot points the original 'unrevised message', i.e., the root of the revision thread.
  • revisionBranch should point to the previous revision in the revision thread. If this is the first edit to a message, revisionRoot and revisionBranch will be the same.
  • mentions is used as in post, replacing the previous mentions of the message in revisionBranch.

type: about

{ type: 'about', about: Link, name: String, image: BlobLink }
  • You should only include 1 votable piece of information at a time in an about message.
    • Of the attributes specified here, name and image are votable.
    • Therefore, name and image should not appear in the same message.
    • Reason: vote messages cant differentiate on content within a message. If name and image are grouped together, a vote on the message is a vote on both pieces of information.
  • Typically, type: about is for users, but it can also be used on msgs and blobs.