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

@wezard/halo-core

v0.12.0

Published

test

Downloads

23

Readme

Halo Core

javascript NPM version

Table of Content

  1. Installation
    1. Firebase
  2. Usage
    1. Initialization
    2. Authentication and user creation
  3. Overview
    1. User
    2. Agent
    3. Room
  4. Create an Halo Module

Installation

Firebase

Add Halo dependencies:

yarn add @wezard/halo-core @wezard/react-native-halo-firebase

Add Firebase dependencies:

yarn add @react-native-firebase/app @react-native-firebase/auth @react-native-firebase/firestore @react-native-firebase/storage

Setup Firebase following official guide.

Usage

Initialization

import { halo } from '@wezard/halo-core'

// ...

const initChat = () => {
    halo.initialize('firebase')
}

Authentication and user creation

Halo Firebase needs to authenticate the user before they perform any action.

import { halo } from '@wezard/halo-core'
import auth from '@react-native-firebase/app'

// ...
const signUp = async () => {
    try {
        await auth().createUserWithEmailAndPassword(email, password)
        const user = await halo.createUser({
            firstName: 'Matteo',
            lastName: 'Bianchi',
            nickname: 'mattyb98',
            image: 'https://avatar.com'
        })
        // save user data
    } catch (error) {
        // handle error
    }
}

const signIn = async () => {
    try {
        const userCredentials = await auth().signInWithEmailAndPassword(email, password)
        const user = await halo.getUser(userCredentials.user.uid)
        // save user data
    } catch (error) {
        // handle error
    }
}

Overview

User

method | return | description ---|---|--- getUser | UserDetails | get user info by user id createUser | UserDetails | create chat user reference updateUser | UserDetails | update chat user updateUserDeviceToken | void | update device token in order to receive notifications fetchUsers | void | register a callback triggered when a user is added o updated

Agent

method | return | description ---|---|--- getAgent | AgentDetails | get agent info by agent id createUser | AgentDetails | create chat agent reference updateAgent | AgentDetails | update chat agent updateAgentDeviceToken | void | update device token in order to receive notifications

Room

method | return | description ---|---|--- getRooms | RoomDetails[] | get rooms details collection with pagination getRoomDetails | RoomDetails | get room details createRoomWithUsers | RoomDetails | create private or group room object createRoomForAgents | RoomDetails | create an agent room based on a specific tag joinUser | RoomDetails | add a user to a group room joinAgent | RoomDetails | add an agent to an agent room, an agent must be added to the room in order to have write permissions removeUser | RoomDetails | remove a user from a group room sendTextMessage | MessageType.Any | send a message sendFileMessage | MessageType.Any | send a message with an attachement, it handles file upload sendFileMessageFromUrl | MessageType.Any | send a message with an attachement, it uses file url passed as argument to store file readMessage | void | mark message read for one user deleteMessage | void | delete message for all room users getRoomMedia | MessageType.MediaInfo[] | get room media filtered by content type fetchRooms | void | register a callback triggered when a room is added or updated fetchRoomsByAgent | void | register a callback triggered when a room with one or more tags is added or updated fetchMessages | void | register a callback triggered when messages are added to a room

Create an Halo Module

In order to create an Halo Module, init a React Native library, you can use create-react-native-library.

Then add Halo dependency:

yarn add @wezard/halo-core

Now you have to implements IUser, IAgent and IRoom interfaces:

  • user.ts
import { IUser } from '@wezard/halo-core'

export class User implements IUser {
    // implements IUser methods
}
  • agent.ts
import { IAgent } from '@wezard/halo-core'

export class Agent implements IAgent {
    // implements IAgent methods
}
  • room.ts
import { IRoom } from '@wezard/halo-core'

export class Room implements IRoom {
    // implements IRoom methods
}

And create an index.ts file that exports classes

export * from './agent'
export * from './room'
export * from './user'