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

av6-core

v1.6.5

Published

All utility function for av6 node js projects.

Readme

AV6 Core

A comprehensive utility library for AV6 Node.js projects, providing common functionality for data operations, caching, and Excel handling.

Features

  • Dynamic Data Operations: Flexible search, fetch, and CRUD operations with support for dynamic models
  • Caching Support: Built-in Redis caching for improved performance
  • Excel Import/Export: Seamless Excel file handling for data import and export
  • Pagination: Built-in pagination for search results
  • DTO Mapping: Support for Data Transfer Object mapping
  • Type Safety: Written in TypeScript with comprehensive type definitions
  • UIN Config Management: Unique Identification Number generation with configurable segments and automatic reset policies

Installation

npm install av6-core

Usage

Basic Setup

To use the library, you need to provide the necessary dependencies:

import { commonService, Deps } from 'av6-core';
import { PrismaClient } from '@prisma/client';
import winston from 'winston';
import { AsyncLocalStorage } from 'async_hooks';

// Initialize dependencies
const deps: Deps = {
  config: {
    REDIS_PREFIX: 'your-prefix:',
    CACHE_KEY_NAME: 'your-cache-key'
  },
  mapper: {
    dtoMapping: {}, // Your DTO mapping functions
    mappingExport: {}, // Your export mapping functions
    mappingImport: {}, // Your import mapping functions
  },
  helpers: {
    generateErrorMessage: (type, ...variables) => {
      // Your error message generation logic
    },
    ErrorHandler: class ErrorHandler extends Error {
      // Your error handler implementation
    }
  },
  logger: winston.createLogger({
    // Your logger configuration
  }),
  cacheAdapter: {
    // Your cache adapter implementation
  },
  requestStorage: new AsyncLocalStorage(),
  db: new PrismaClient()
};

// Initialize the service
const service = commonService(deps);

Search Operations

// Perform a search operation
const searchResult = await service.search({
  pageNo: 1,
  pageSize: 10,
  shortCode: 'USER',
  searchColumns: ['name', 'email'],
  searchText: 'john',
  sortBy: 'createdAt',
  sortDir: 'DESC',
  shortCodeData: {
    shortCode: 'USER',
    tableName: 'user',
    isDTO: true,
    isCacheable: true
  }
});

Fetch Record

// Fetch a specific record
const record = await service.fetch({
  shortCode: 'USER',
  id: 123,
  shortCodeData: {
    shortCode: 'USER',
    tableName: 'user',
    isDTO: true,
    isCacheable: true
  }
});

Excel Operations

// Import data from Excel
const importResult = await service.commonExcelImport({
  shortCode: 'USER',
  file: excelFile, // File object from upload
  shortCodeData: {
    shortCode: 'USER',
    tableName: 'user'
  }
});

// Export data to Excel
const workbook = await service.commonExcelExport({
  shortCode: 'USER',
  isSample: false,
  shortCodeData: {
    shortCode: 'USER',
    tableName: 'user'
  }
});

UIN Config Operations

import { uinConfigService, UinDeps, UIN_RESET_POLICY, UinShortCode } from 'av6-core';

// Initialize UIN Config dependencies
const uinDeps: UinDeps = {
  config: {
    REDIS_PREFIX: 'your-prefix:',
    CACHE_KEY_NAME: 'your-cache-key'
  },
  helpers: {
    generateErrorMessage: (type, ...variables) => {
      // Your error message generation logic
    },
    ErrorHandler: class ErrorHandler extends Error {
      // Your error handler implementation
    }
  },
  logger: winston.createLogger({
    // Your logger configuration
  }),
  cacheAdapter: {
    // Your cache adapter implementation
  },
  requestStorage: new AsyncLocalStorage(),
  db: new PrismaClient(),
  prisma: PrismaNamespace,
  shortCode: 'UIN_CONFIG',
  cacheKey: 'uin-config'
};

// Initialize the UIN Config service
const uinService = uinConfigService(uinDeps);

// Create a new UIN Config
const newUinConfig = await uinService.createUINConfig({
  shortCode: UinShortCode.INVOICE,
  seqResetPolicy: UIN_RESET_POLICY.monthly,
  description: 'Invoice number generator',
  uinSegments: [
    { order: 1, type: 'text', value: 'INV-' },
    { order: 2, type: 'dateFormat', value: 'YYYYMM' },
    { order: 3, type: 'separator', value: '-' },
    { order: 4, type: 'sequenceNo', minSeqLength: 5 }
  ]
});

// Generate a UIN preview
const uinPreview = await uinService.previewUIN({
  uinSegments: [
    { order: 1, type: 'text', value: 'INV-' },
    { order: 2, type: 'dateFormat', value: 'YYYYMM' },
    { order: 3, type: 'separator', value: '-' },
    { order: 4, type: 'sequenceNo', minSeqLength: 5 }
  ]
});

// Get a UIN Config by ID
const uinConfig = await uinService.getUINConfigById(1);

// Generate a new UIN
const generatedUin = await uinService.generateUIN(UinShortCode.INVOICE);

API Reference

Common Service

The library provides a comprehensive service for common operations:

  • search: Search records with pagination and filtering
  • dropdownSearch: Search records for dropdown components
  • fixedSearch: Search with fixed criteria
  • fixedSearchWoPaginationService: Search with fixed criteria without pagination
  • commonExcelService: Generate Excel workbooks
  • fetch: Fetch a specific record by ID
  • commonExcelImport: Import data from Excel files
  • commonExcelExport: Export data to Excel files
  • delete: Delete a record
  • updateStatus: Update the status of a record
  • fetchImageStream: Fetch an image as a stream

UIN Config Service

The library provides a service for managing Unique Identification Numbers:

  • createUINConfig: Create a new UIN configuration
  • updateUINConfig: Update an existing UIN configuration
  • getUINConfigById: Retrieve a UIN configuration by ID
  • getAllUINConfig: Retrieve all UIN configurations
  • deleteUINConfig: Delete a UIN configuration
  • generateUIN: Generate a new UIN based on a shortcode
  • previewUIN: Preview a UIN based on segment configuration

Utility Functions

The library also provides utility functions:

  • customOmit: Omit specific keys from an object
  • objectTo2DArray: Convert an object to a 2D array
  • toRelativeImageUrl: Convert an absolute path to a relative image URL

License

ISC