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

@ecency/ns-query

v1.2.6-next

Published

React-query based Nostr protocol SDK for Ecency vision and mobile

Downloads

385

Readme

Nostr protocol react-query based client SDK for Ecency

NPM JavaScript Style Guide

Overview

This repository contains react-query based SDK for Ececny vision and mobile projects

Installation

yarn add @ecency/ns-query

npm install @ecency/ns-query

Setup

  1. Add ChatContextProvider to your App.tsx as root element
  2. Pass there current user information via props
<ChatContextProvider activeUsername={} activeUserData={} />
  1. Use!

Queries

High-level queries

  1. Channels query – use this query for fetching user joined and created channels
    • Requirements – current user and its credentials
  2. Community channel query – use this query for fetching the community channel from its posting json metadata
    • Requirements – nothing
  3. Direct contacts query – use this query for fetching direct contacts of active user
    • Requirements – current user and its credentials
  4. Left community channels query – use this query for fetching community channels from where active user had been left
    • Requirements – current user and its credentials
  5. Messages query – use this query for fetching channel or contact messages based on their username
    • Requirements – current user and its credentials
    • ~~Note – this query are invalidating each N seconds periodically to keep messages fresh~~
  6. ~~Joined community team query – use this query for fetching community team member which joined to chats and assigned to moderation team~~ ~~* Requirements – current user and its credentials~~
  7. Created channels query – use this query for fetching created channels by current Nostr account
    • Requirements – current user and its credentials
  8. Joined channels query – use this query for fetching all channels where current Nostr account was joined
    • Requirements – current user and its credentials
  9. Last message query – fetch last message for specific contact or channel
    • Requirements – current user and its credentials

Low-level queries

Low-level queries builds the high-level queries above

  1. Direct messages query – fetches direct messages by given direct contacts
  2. Public messages query – fetches public messages by given channels
    • Both of them builds messages query and shouldn't be used for messages management.
  3. Get user profile query – fetching user metadata from Nostr by given public key

Mutations

High-level mutations

All mutations marked as override channel metadata means that mutation could by run only by channel owner

  1. Add community channel – adds community channel to community list(only locally w/o saving in Nostr or Ecency)
  2. Add direct contact – adding direct contact to contacts list
  3. Create community chat – creates community channel and make current user as owner
  4. Fetch previous messages – fetches channel's previous messages and appends to messages query
  5. Hide messages in channel – hides message in a channel by owner(it overrides community channel metadata)
  6. Import chats by keys – imports existing chat account and saves encrypted chat keys to accounts posting metadata
  7. Join chat – creates chatting account and saves encrypted chat keys to account metadata
  8. Leave community channel – leaves community channel
  9. Logout from chats – clears current active user chatting session
  10. Resend message – resends failed messages which already exists in queries with status 2
  11. Restore chat by PIN – restores logged out account session by PIN
  12. Send message – sends message to specific direct contact or channel
  13. Update channel's blocked users – updates channel's blocked users(overrides channel metadata)
  14. ~~Update channel's moderator – add, remove or update channel's moderator~~
  15. Update community channel – updates community channel's information(overrides channel metadata)

Low-level mutations

  1. Find healthy relay – finds healthy Nostr relay and return its host(uses by library itself – no need to re-use it)
  2. Send direct message – sends message to direct contact(uses in Send message)
  3. Send public message – sends message to channel(uses in Send message)
  4. Update left channels – updates left channels list(uses in add community channel and Leave community channel)

Misc

~~useActiveUserSwitching – invalidates all Nostr queries each time when active user changes(no need to call, library use it itself).~~

useAutoScrollInChatBox – uses for auto-scrolling to the end of chatbox(available in Web only)