1.2.11-next • Published 9 months ago

@ecency/ns-query v1.2.11-next

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

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.
  1. 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)

1.2.11-next

9 months ago

1.2.7-next

10 months ago

1.2.10-next

9 months ago

1.2.9-next

10 months ago

1.2.6-next

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.3-app

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.2-rc0

1 year ago

1.2.0

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.1

1 year ago

1.1.2

1 year ago

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

2 years ago