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

@vulog/aima-document

v1.2.15

Published

Document management module for the AIMA platform. This module provides functionality to manage user documents, including creation, updates, and status management.

Readme

@vulog/aima-document

Document management module for the AIMA platform. This module provides functionality to manage user documents, including creation, updates, and status management.

Installation

npm install @vulog/aima-client @vulog/aima-core @vulog/aima-document

Usage

Initialize Client

import { getClient } from '@vulog/aima-client';
import { createOrUpdateDocument, getUserDocuments, updateDocumentStatus } from '@vulog/aima-document';

const client = getClient({
    apiKey: 'your-api-key',
    baseUrl: 'https://your-api-base-url',
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
    fleetId: 'your-fleet-id',
});

API Reference

createOrUpdateDocument

Create a new document or update an existing one for a user.

const document = await createOrUpdateDocument(client, {
    entityId: 'user-uuid-here',
    documentType: 'DRIVER_LICENSE',
    fileData: 'base64-encoded-file-data',
    fileName: 'license.pdf',
    mimeType: 'application/pdf'
});

Parameters:

  • client: AIMA client instance
  • payload: Document configuration object
    • entityId: User UUID
    • documentType: Type of document (e.g., 'DRIVER_LICENSE', 'ID_CARD', 'PASSPORT')
    • fileData: Base64 encoded file data
    • fileName: Name of the file
    • mimeType: MIME type of the file

getUserDocuments

Retrieve all documents for a specific user.

const documents = await getUserDocuments(client, 'user-uuid-here');

Parameters:

  • client: AIMA client instance
  • entityId: User UUID

Returns: Array of user documents

updateDocumentStatus

Update the status of a document.

const updatedDocument = await updateDocumentStatus(client, {
    documentId: 'document-id-here',
    status: 'APPROVED',
    notes: 'Document verified successfully'
});

Parameters:

  • client: AIMA client instance
  • payload: Status update configuration
    • documentId: Document identifier
    • status: New status ('PENDING', 'APPROVED', 'REJECTED')
    • notes: Optional notes about the status change

Types

Document

interface Document {
    id: string;
    entityId: string;
    documentType: string;
    fileName: string;
    mimeType: string;
    fileSize: number;
    status: 'PENDING' | 'APPROVED' | 'REJECTED';
    uploadDate: string;
    lastModified: string;
    notes?: string;
}

DocumentType

Common document types include:

  • DRIVER_LICENSE: Driver's license
  • ID_CARD: National ID card
  • PASSPORT: Passport
  • INSURANCE: Insurance document
  • REGISTRATION: Vehicle registration

Error Handling

All functions include validation and will throw appropriate errors if:

  • Required parameters are missing
  • Invalid document types are provided
  • File data is invalid
  • User or document not found

Examples

Complete Document Management Workflow

import { getClient } from '@vulog/aima-client';
import { createOrUpdateDocument, getUserDocuments, updateDocumentStatus } from '@vulog/aima-document';
import fs from 'fs';

const client = getClient({
    apiKey: 'your-api-key',
    baseUrl: 'https://your-api-base-url',
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
    fleetId: 'your-fleet-id',
});

async function documentWorkflow() {
    try {
        // Read and encode a file
        const fileBuffer = fs.readFileSync('path/to/license.pdf');
        const base64Data = fileBuffer.toString('base64');
        
        // Create a new document
        const document = await createOrUpdateDocument(client, {
            entityId: 'user-uuid-here',
            documentType: 'DRIVER_LICENSE',
            fileData: base64Data,
            fileName: 'license.pdf',
            mimeType: 'application/pdf'
        });
        
        console.log('Document created:', document);
        
        // Get all user documents
        const documents = await getUserDocuments(client, 'user-uuid-here');
        console.log('User documents:', documents);
        
        // Update document status
        const updatedDocument = await updateDocumentStatus(client, {
            documentId: document.id,
            status: 'APPROVED',
            notes: 'License verified and approved'
        });
        
        console.log('Document status updated:', updatedDocument);
        
    } catch (error) {
        console.error('Document management error:', error);
    }
}

File Upload Helper

import { createOrUpdateDocument } from '@vulog/aima-document';
import fs from 'fs';

async function uploadDocument(client, filePath, documentType, entityId) {
    try {
        // Read file
        const fileBuffer = fs.readFileSync(filePath);
        const base64Data = fileBuffer.toString('base64');
        
        // Get file info
        const stats = fs.statSync(filePath);
        const fileName = filePath.split('/').pop();
        const mimeType = getMimeType(fileName);
        
        // Upload document
        return await createOrUpdateDocument(client, {
            entityId,
            documentType,
            fileData: base64Data,
            fileName,
            mimeType
        });
    } catch (error) {
        console.error('File upload error:', error);
        throw error;
    }
}

function getMimeType(fileName) {
    const ext = fileName.split('.').pop().toLowerCase();
    const mimeTypes = {
        'pdf': 'application/pdf',
        'jpg': 'image/jpeg',
        'jpeg': 'image/jpeg',
        'png': 'image/png',
        'doc': 'application/msword',
        'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
    };
    return mimeTypes[ext] || 'application/octet-stream';
}