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 🙏

© 2025 – Pkg Stats / Ryan Hefner

aiforwork-sdk-core

v0.0.1

Published

A comprehensive React Native SDK for integrating with AIforWork platform, providing socket connectivity, API management, and state management for threads/boards.

Downloads

20

Readme

AIforWork React Native Core SDK

A comprehensive React Native SDK for integrating with AIforWork platform, providing socket connectivity, API management, and state management for threads/boards.

🚀 Features

  • WebSocket Integration: Real-time communication with socket.io
  • API Client: Axios-based HTTP client with automatic device headers
  • State Management: Zustand-powered stores for threads/boards
  • Device Integration: Automatic device information headers
  • Thread Management: Fetch and rename threads/boards
  • Error Handling: Comprehensive error handling and logging
  • TypeScript Support: Full TypeScript implementation

📋 Prerequisites

  • React Native 0.77.0+
  • Node.js 18+
  • TypeScript 5.0+

📦 Installation

npm install
# or
yarn install

Dependencies

The SDK includes these key dependencies:

  • axios - HTTP client
  • zustand - State management
  • socket.io-client - WebSocket communication
  • react-native-device-info - Device information
  • immer - Immutable state updates
  • uuid - Unique identifier generation

🏗️ Architecture

Core Components

src/
├── sdk/
│   └── sdk.config.ts          # SDK configuration
├── restapi/
│   └── axios/
│       ├── axios_base.ts      # Base Axios client
│       └── api_client.ts      # API client implementation
├── socket/
│   └── socket.service.ts      # WebSocket service
├── store/
│   └── threadsStore.ts        # Threads state management
└── utils/
    └── utils.ts               # Utility functions

⚙️ Configuration

Initialize the SDK

import { initializeSDK } from './src/sdk/sdk.config';

initializeSDK({
  accessToken: 'your-access-token',
  apiUrl: 'https://work-qa.kore.ai/',
  presenceUrl: 'https://work-qa.kore.ai/',
  userId: 'your-user-id'
});

🔌 API Client

Features

  • Automatic authentication headers
  • Device information headers
  • Error handling and retry logic
  • URL parameter resolution

Device Headers

Automatically includes device information:

{
  channel: "iOS" | "Android",
  version: "1.0.0",
  deviceId: "unique-device-id",
  name: "Apple, iPhone 14",
  tz: "America/New_York",
  manufacturer: "Apple"
}

Usage

import ApiClient from './src/restapi/axios/api_client';

const apiClient = ApiClient.getInstance();

// GET request
const data = await apiClient.getCall('/api/endpoint');

// POST request
const result = await apiClient.postCall('/api/endpoint', payload);

// PUT request
const updated = await apiClient.putCall('/api/endpoint', data);

🧵 Threads Store

Zustand-based state management for threads/boards.

Store Structure

interface ThreadsState {
  boards: any[];
  loading: boolean;
  error: string | null;
  moreAvailable: boolean;
  currentBoard: any;
}

Available Actions

  • fetchThreads() - Fetch threads/boards list
  • renameThread(boardId, data) - Rename a specific thread/board
  • clearError() - Clear error state
  • resetStore() - Reset to initial state

Usage Example

See App.tsx file

🔌 WebSocket Service

Real-time communication service with connection monitoring.

Features

  • Auto-reconnection
  • Connection state management
  • Message queuing
  • Latency monitoring
  • Custom event handling

Usage

import socketService from './src/socket/socket.service';

// Connect
socketService.connectToWebSocket();

// Listen for events
socketService.on('connectionStateChange', (data) => {
  console.log('Connection state:', data.newState);
});

// Disconnect
socketService.disconnect();

🚀 Getting Started

  1. Initialize the SDK in your App component:
componentDidMount() {
  initializeSDK({
    accessToken: 'your-token',
    apiUrl: 'https://work-qa.kore.ai/',
    presenceUrl: 'https://work-qa.kore.ai/',
    userId: 'your-user-id'
  });
}
  1. Use the Threads Store:
const { fetchThreads, boards } = useThreadsStore();

useEffect(() => {
  fetchThreads();
}, []);
  1. Connect to WebSocket (optional):
socketService.connectToWebSocket();

🛠️ Development

Scripts

# Start Metro bundler
npm start

# Run on iOS
npm run ios

# Run on Android
npm run android

# Lint code
npm run lint

Project Structure

  • src/sdk/ - SDK configuration and initialization
  • src/restapi/ - HTTP client and API management
  • src/socket/ - WebSocket service
  • src/store/ - State management (Zustand stores)
  • src/utils/ - Utility functions

🔧 Error Handling

The SDK includes comprehensive error handling:

  • API errors are caught and stored in state
  • WebSocket connection errors are handled gracefully
  • Device information errors fallback to defaults
  • All errors are logged to console for debugging

📱 Platform Support

  • ✅ iOS
  • ✅ Android
  • ⚡ React Native 0.77.0+

🔗 Related


Note: This SDK is designed for internal AIforWork platform integration. Ensure proper authentication tokens and API endpoints are configured before use.