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 🙏

© 2026 – Pkg Stats / Ryan Hefner

docpouch-client

v0.8.17

Published

A small class to more easily access the docPouch API

Readme

docpouch-client

A TypeScript client library for interacting with the docPouch database API.

Description

docpouch-client provides a simple and intuitive interface to access the docPouch API, allowing you to manage users, documents, data structures, and document types. It also supports real-time synchronization via WebSockets.

Installation

npm install docpouch-client

Usage

Initializing the Client

import docPouchClient from 'docpouch-client';

// Initialize the client with the server URL
const client = new docPouchClient('https://your-docpouch-server.com', 80);

// Initialize with a callback for real-time updates
const client = new docPouchClient('https://your-docpouch-server.com', 80,
    (event, data) => {
        console.log(`Received event: ${event}`, data);
    }
);

Authentication

// Login to get an authentication token
const loginResponse = await client.login({
    name: 'username',
    password: 'password'
});

if (loginResponse) {
    console.log('Login successful!');
    console.log(`Token: ${loginResponse.token}`);
} else {
    console.log('Login failed');
}

// Set an existing token
client.setToken('your-auth-token');

User Management

// List all users
const users = await client.listUsers();

// Create a new user
const newUser = await client.createUser({
    name: 'newuser',
    password: 'password',
    department: 'IT',
    group: 'Developers',
    isAdmin: false
});

// Update a user
await client.updateUser('user-id', {
    department: 'Engineering',
    group: 'Frontend'
});

// Remove a user
await client.removeUser('user-id');

Document Management

// Create a new document
const newDocument = await client.createDocument({
    _id: 'document-id',
    owner: 'user-id',
    title: 'Mission Statement',
    type: 17,
    subType: 11,
    content: '{"msg": "We strive for a world that..."}',
    shareWithGroup: false,
    shareWithDepartment: false
});

// Update a document
await client.updateDocument('document-id', {
    _id: 'document-id',
    owner: 'user-id',
    title: 'Updated Mission Statement',
    type: 17,
    subType: 11,
    content: '{"msg": "Our updated mission..."}',
    shareWithGroup: false,
    shareWithDepartment: false
});

// Delete a document
await client.removeDocument('document-id');

// List all documents
const allDocuments = await client.listDocuments();

// Fetch documents by query
const documents = await client.fetchDocuments({type: 17, subType: 11});

Data Structure Management

// Create a new data structure
const newStructure = await client.createStructure({
    name: "Data resulting from Vision-Mission-Value-Canvas",
    fields: [
        {
            name: "Mission value statement",
            type: "string"
        },
        // Add more fields as needed
    ]
});

// Update a data structure
await client.updateStructure('structure-id', {
    _id: 'structure-id',
    name: 'Updated Structure Title',
    description: 'Updated structure description',
    fields: [
        {name: 'New Field Name', type: 'number'}
    ]
});

// Delete a data structure
await client.removeStructure('structure-id');

// List all data structures
const structures = await client.getStructures();

Document Type Management

// List all document types
const docTypes = await client.getTypes();

// Create a new document type
const newDocType = await client.createType({
    name: "HR Wages",
    description: "HR Wage information Document listing wages per personnel ID",
    type: 14,
    subType: 2,
    defaultStructureID: 'structure-id'
});

// Update a document type
await client.updateType({
    _id: 'doc-type-id',
    name: 'Updated HR Wages',
    type: 14,
    subType: 2
});

// Delete a document type
await client.removeType('doc-type-id');

API Reference

Client Class

Constructor

  • new docPouchClient(host: string, port?: number, callback?: (event: I_EventString, data: I_WsMessage) => void)

Methods

  • setRealTimeSync(newRealTimeSync: boolean): void
  • login(credentials: I_UserLogin): Promise<I_LoginResponse | null>
  • listUsers(): Promise<I_UserEntry[]>
  • updateUser(userID: string, userData: I_UserUpdate): Promise<void>
  • createUser(userData: I_UserCreation): Promise<I_UserDisplay>
  • removeUser(userID: string): Promise<void>
  • createDocument(document: I_DocumentEntry): Promise<I_DocumentEntry>
  • listDocuments(): Promise<I_DocumentEntry[]>
  • fetchDocuments(queryObject: I_DocumentQuery): Promise<I_DocumentEntry[]>
  • updateDocument(documentID: string, documentData: I_DocumentEntry): Promise<void>
  • removeDocument(documentID: string): Promise<void>
  • createStructure(structure: I_StructureCreation): Promise<I_DataStructure>
  • getStructures(): Promise<I_DataStructure[]>
  • updateStructure(structureID: string, structureData: I_DataStructure): Promise<void>
  • removeStructure(structureID: string): Promise<void>
  • createType(type: I_DocumentType): Promise<I_DocumentType>
  • removeType(typeID: string): Promise<void>
  • getTypes(): Promise<I_DocumentType[]>
  • updateType(updatedType: I_DocumentType): Promise<void>
  • setToken(token: string | null): void
  • getVersion(): string
  • debugSocketConnection(): void

Types

I_UserEntry

{
    _id: string;
    name: string;
    password: string;
    email?: string;
    department: string;
    group: string;
    isAdmin: boolean;
}

I_UserLogin

{
    name: string;
    password: string;
}

I_UserDisplay

{
    _id: string;
    username: string;
    department: string;
    group: string;
    email?: string;
}

I_UserCreation

{
    name: string;
    password: string;
    email?: string;
    department: string;
    group: string;
    isAdmin: boolean;
}

I_UserUpdate

{
    _id?: string;
    name?: string;
    password?: string;
    email?: string;
    department?: string;
    group?: string;
    isAdmin?: boolean;
}

I_LoginResponse

{
    token: string;
    isAdmin: boolean;
    userName: string;
}

I_DocumentEntry

{
    _id: string;
    owner: string;
    title: string;
    description?: string;
    type: number;
    subType: number;
    content: any;
    shareWithGroup: boolean;
    shareWithDepartment: boolean;
}

I_DocumentCreation

{
    title: string;
    description?: string;
    type: number;
    subType: number;
    content: any;
    shareWithGroup: boolean;
    shareWithDepartment: boolean;
}

I_DocumentCreationOwned

{
    owner: string;
    title: string;
    description?: string;
    type: number;
    subType: number;
    content: any;
    shareWithGroup: boolean;
    shareWithDepartment: boolean;
}

I_DocumentUpdate

{
    _id?: string;
    owner?: string;
    title?: string;
    type?: number;
    subType?: number;
    shareWithGroup?: boolean;
    shareWithDepartment?: boolean;
    content?: any;
    description?: string;
}

I_DocumentQuery

{
    _id?: string;
    owner?: string;
    title?: string;
    type?: number;
    subType?: number;
    shareWithGroup?: boolean;
    shareWithDepartment?: boolean;
}

I_DataStructure

{
    _id?: string;
    name: string;
    description: string;
    fields: I_StructureField[];
}

I_StructureCreation

{
    name: string;
    description?: string;
    fields: I_StructureField[];
}

I_StructureUpdate

{
    _id?: string;
    name?: string;
    description?: string;
    fields?: I_StructureField[];
}

I_StructureField

{
    name: string;
    type: string;
    items?: string;
}

I_StructureEntry

{
    _id?: string;
    name: string;
    description: string;
    fields: I_StructureField[];
}

I_DocumentType

{
    _id?: string;
    name: string;
    description?: string;
    type: number;
    subType: number;
    defaultStructureID?: string;
}

I_EventString

'heartbeatPong' | 'heartbeatPing' | 'newDocument' | 'newStructure' |
'newUser' | 'newType' | 'removedID' | 'changedDocument' |
'changedStructure' | 'changedUser' | 'changedType' | 'removedUser' |
'removedStructure' | 'removedDocument' | 'removedType'

I_WsMessage

{
    newDocument?: I_DocumentEntry;
    newStructure?: I_StructureEntry;
    newUser?: I_UserEntry;
    removedID?: string;
    changedDocument?: I_DocumentUpdate;
    changedStructure?: I_StructureUpdate;
    changedUser?: I_UserUpdate;
    confirmSubscription?: boolean;
    confirmUnsubscription?: boolean;
    heartbeatPing?: number;
    heartbeatPong?: number;
    newType?: I_DocumentType;
}