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

@vulog/aima-ticket

v1.2.14

Published

Ticket management module for the AIMA platform. This module provides functionality to create, retrieve, and manage support tickets and user groups.

Readme

@vulog/aima-ticket

Ticket management module for the AIMA platform. This module provides functionality to create, retrieve, and manage support tickets and user groups.

Installation

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

Usage

Initialize Client

import { getClient } from '@vulog/aima-client';
import { getTickets, getUserGroupById, createTicket } from '@vulog/aima-ticket';

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

getTickets

Retrieve tickets with optional filtering.

const tickets = await getTickets(client, {
    status: 'OPEN',
    priority: 'HIGH',
    assignedTo: 'agent-id-here'
});

Parameters:

  • client: AIMA client instance
  • filters: Optional filter object
    • status: Ticket status ('OPEN', 'IN_PROGRESS', 'CLOSED', 'RESOLVED')
    • priority: Priority level ('LOW', 'MEDIUM', 'HIGH', 'URGENT')
    • assignedTo: Agent ID
    • createdBy: User ID who created the ticket
    • category: Ticket category

Returns: Array of tickets matching the filters

getUserGroupById

Retrieve user group information by ID.

const userGroup = await getUserGroupById(client, 'group-id-here');

Parameters:

  • client: AIMA client instance
  • groupId: User group identifier

Returns: User group object with details

createTicket

Create a new support ticket.

const ticket = await createTicket(client, {
    title: 'Vehicle not starting',
    description: 'The vehicle with ID xyz is not responding to unlock commands',
    priority: 'HIGH',
    category: 'TECHNICAL',
    entityId: 'user-uuid-here',
    relatedEntityType: 'VEHICLE',
    relatedEntityId: 'vehicle-id-here'
});

Parameters:

  • client: AIMA client instance
  • ticketData: Ticket creation data
    • title: Ticket title
    • description: Detailed description
    • priority: Priority level ('LOW', 'MEDIUM', 'HIGH', 'URGENT')
    • category: Ticket category ('TECHNICAL', 'BILLING', 'GENERAL', 'VEHICLE')
    • entityId: User ID creating the ticket
    • relatedEntityType: Type of related entity ('VEHICLE', 'TRIP', 'BOOKING')
    • relatedEntityId: ID of related entity

Returns: Created ticket object

Types

Ticket

interface Ticket {
    id: string;
    title: string;
    description: string;
    status: 'OPEN' | 'IN_PROGRESS' | 'CLOSED' | 'RESOLVED';
    priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'URGENT';
    category: 'TECHNICAL' | 'BILLING' | 'GENERAL' | 'VEHICLE';
    entityId: string;
    assignedTo?: string;
    createdBy: string;
    createdAt: string;
    updatedAt: string;
    resolvedAt?: string;
    relatedEntityType?: string;
    relatedEntityId?: string;
    comments: TicketComment[];
}

TicketComment

interface TicketComment {
    id: string;
    ticketId: string;
    authorId: string;
    content: string;
    isInternal: boolean;
    createdAt: string;
    updatedAt: string;
}

UserGroup

interface UserGroup {
    id: string;
    name: string;
    description: string;
    memberCount: number;
    permissions: string[];
    createdAt: string;
    updatedAt: string;
}

Error Handling

All functions include validation and will throw appropriate errors if:

  • Required parameters are missing
  • Invalid ticket or group IDs are provided
  • Invalid priority or category values are used
  • Network errors occur

Examples

Basic Ticket Operations

import { getClient } from '@vulog/aima-client';
import { getTickets, createTicket, getUserGroupById } from '@vulog/aima-ticket';

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 ticketOperations() {
    try {
        // Get all open tickets
        const openTickets = await getTickets(client, { status: 'OPEN' });
        console.log(`Found ${openTickets.length} open tickets`);
        
        // Create a new ticket
        const newTicket = await createTicket(client, {
            title: 'Vehicle Issue',
            description: 'Vehicle not responding to commands',
            priority: 'HIGH',
            category: 'TECHNICAL',
            entityId: 'user-uuid-here',
            relatedEntityType: 'VEHICLE',
            relatedEntityId: 'vehicle-id-here'
        });
        
        console.log('Created ticket:', newTicket);
        
        // Get user group
        const userGroup = await getUserGroupById(client, 'group-id-here');
        console.log('User group:', userGroup);
        
        return { openTickets, newTicket, userGroup };
    } catch (error) {
        console.error('Ticket operation error:', error);
        throw error;
    }
}

Ticket Management Dashboard

async function getTicketDashboard(client) {
    try {
        // Get tickets by status
        const [openTickets, inProgressTickets, closedTickets] = await Promise.all([
            getTickets(client, { status: 'OPEN' }),
            getTickets(client, { status: 'IN_PROGRESS' }),
            getTickets(client, { status: 'CLOSED' })
        ]);
        
        // Get tickets by priority
        const highPriorityTickets = await getTickets(client, { priority: 'HIGH' });
        const urgentTickets = await getTickets(client, { priority: 'URGENT' });
        
        const dashboard = {
            summary: {
                total: openTickets.length + inProgressTickets.length + closedTickets.length,
                open: openTickets.length,
                inProgress: inProgressTickets.length,
                closed: closedTickets.length,
                highPriority: highPriorityTickets.length,
                urgent: urgentTickets.length
            },
            tickets: {
                open: openTickets,
                inProgress: inProgressTickets,
                closed: closedTickets,
                highPriority: highPriorityTickets,
                urgent: urgentTickets
            }
        };
        
        console.log('Ticket Dashboard:');
        console.log(`Total Tickets: ${dashboard.summary.total}`);
        console.log(`Open: ${dashboard.summary.open}`);
        console.log(`In Progress: ${dashboard.summary.inProgress}`);
        console.log(`Closed: ${dashboard.summary.closed}`);
        console.log(`High Priority: ${dashboard.summary.highPriority}`);
        console.log(`Urgent: ${dashboard.summary.urgent}`);
        
        return dashboard;
    } catch (error) {
        console.error('Dashboard error:', error);
        throw error;
    }
}

Ticket Analytics

async function analyzeTickets(client, dateRange) {
    try {
        const allTickets = await getTickets(client);
        
        // Filter by date range
        const filteredTickets = allTickets.filter(ticket => {
            const ticketDate = new Date(ticket.createdAt);
            return ticketDate >= dateRange.start && ticketDate <= dateRange.end;
        });
        
        // Analyze by category
        const categoryAnalysis = filteredTickets.reduce((acc, ticket) => {
            const category = ticket.category || 'UNCATEGORIZED';
            if (!acc[category]) {
                acc[category] = { count: 0, tickets: [] };
            }
            acc[category].count++;
            acc[category].tickets.push(ticket);
            return acc;
        }, {});
        
        // Analyze by priority
        const priorityAnalysis = filteredTickets.reduce((acc, ticket) => {
            const priority = ticket.priority || 'UNKNOWN';
            if (!acc[priority]) {
                acc[priority] = { count: 0, tickets: [] };
            }
            acc[priority].count++;
            acc[priority].tickets.push(ticket);
            return acc;
        }, {});
        
        // Calculate resolution time for closed tickets
        const closedTickets = filteredTickets.filter(t => t.status === 'CLOSED' && t.resolvedAt);
        const resolutionTimes = closedTickets.map(ticket => {
            const created = new Date(ticket.createdAt);
            const resolved = new Date(ticket.resolvedAt);
            return resolved.getTime() - created.getTime();
        });
        
        const avgResolutionTime = resolutionTimes.length > 0 
            ? resolutionTimes.reduce((sum, time) => sum + time, 0) / resolutionTimes.length
            : 0;
        
        const analysis = {
            totalTickets: filteredTickets.length,
            categoryBreakdown: categoryAnalysis,
            priorityBreakdown: priorityAnalysis,
            resolutionStats: {
                closedTickets: closedTickets.length,
                averageResolutionTimeMs: avgResolutionTime,
                averageResolutionTimeHours: avgResolutionTime / (1000 * 60 * 60)
            }
        };
        
        console.log('Ticket Analysis:');
        console.log(`Total Tickets: ${analysis.totalTickets}`);
        console.log('Category Breakdown:', analysis.categoryBreakdown);
        console.log('Priority Breakdown:', analysis.priorityBreakdown);
        console.log('Resolution Stats:', analysis.resolutionStats);
        
        return analysis;
    } catch (error) {
        console.error('Ticket analysis error:', error);
        throw error;
    }
}

Automated Ticket Creation

async function createVehicleIssueTicket(client, vehicleId, issueType, description, userId) {
    try {
        const ticketCategories = {
            'NOT_STARTING': 'TECHNICAL',
            'UNLOCK_ISSUE': 'TECHNICAL',
            'BATTERY_LOW': 'TECHNICAL',
            'DAMAGE': 'VEHICLE',
            'CLEANLINESS': 'GENERAL'
        };
        
        const ticketPriorities = {
            'NOT_STARTING': 'HIGH',
            'UNLOCK_ISSUE': 'HIGH',
            'BATTERY_LOW': 'MEDIUM',
            'DAMAGE': 'MEDIUM',
            'CLEANLINESS': 'LOW'
        };
        
        const category = ticketCategories[issueType] || 'TECHNICAL';
        const priority = ticketPriorities[issueType] || 'MEDIUM';
        
        const ticket = await createTicket(client, {
            title: `Vehicle ${issueType}: ${vehicleId}`,
            description: `Vehicle ID: ${vehicleId}\nIssue Type: ${issueType}\nDescription: ${description}`,
            priority: priority,
            category: category,
            entityId: userId,
            relatedEntityType: 'VEHICLE',
            relatedEntityId: vehicleId
        });
        
        console.log(`Created ${priority} priority ticket for vehicle ${vehicleId}:`, ticket.id);
        return ticket;
    } catch (error) {
        console.error('Automated ticket creation error:', error);
        throw error;
    }
}