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

qlcodes

v1.3.3

Published

A small utility that unifies SQL error codes (SQLSTATE) from different DBMS into a single, normalized structure through a curated dataset constructed at build time.

Downloads

76

Readme

QLCodes

A small utility that unifies SQL codes describing states (SQLSTATE) from different DBMS into a single, normalized structure through a curated dataset constructed at build time.

The module is built from authoritative vendor documentation (IBM, PostgreSQL, Oracle) and generates static reference data at build time. Find references bellow.

SQLSTATES coverage

The project aims to cover sql states for most of RDBMS drivers supported by Typeorm such as Google Spanner. Find bellow the actual coverage:

🕓 MySQL | ✅ MariaDB | ✅ PostgreSQL | ✅ CockroachDB (Postgres-compatible) 🕓 Microsoft SQL Server | ✅ Oracle | 🕓 SQLite | ✅ SAP HANA | ✅ Google Spanner | ✅ IBM*

( * ) IBM defines and publishes SQLSTATE codes as part of the SQL standard, so their The codes should covere IBM products such as DB2, IBM Informix, IBM Netezza, IBM i (AS/400) .

Installation

$ npm install qlcodes

Usage

import { lens } from "qlcodes";

const state = lens("42501");

console.log(state);

Output :

{
  "code": "42501",
  "qlcs": "qlcodes_success",
  "matches": [
    {
      "code": "42501",
      "keys": [
        "insufficient_privilege",
        "authorization_id_does_not_have_privilege_to_perform_specified_operation_on_identified_object"
      ],
      "reasons": [
        "The authorization ID does not have the privilege to perform the specified operation on the identified object."
      ],
      "use": [
        "pgsql",
        "ibm"
      ],
      "class": "42 - Syntax Error or Access Rule Violation"
    }
  ]
}

Alternatively, you may need to retrive matching codes via a known key for some technologies

import { lens } from "qlcodes";

const state = lens("insufficient_privilege");

console.log(state);

Output :

{
  "key": "insufficient_privilege",
  "qlcs": "qlcodes_success",
  "matches": [
    {
      "code": "42501",
      "keys": [
        "insufficient_privilege",
        "authorization_id_does_not_have_privilege_to_perform_specified_operation_on_identified_object"
      ],
      "reasons": [
        "The authorization ID does not have the privilege to perform the specified operation on the identified object."
      ],
      "use": [
        "pgsql",
        "ibm"
      ],
      "class": "42 - Syntax Error or Access Rule Violation"
    },
    {
      "code": "258",
      "keys": [
        "insufficient_privilege"
      ],
      "reasons": [
        "Insufficient privilege"
      ],
      "use": [
        "sap_hana"
      ],
      "class": "NA - Non associable class codes"
    }
  ]
}

Mismatches

If the provided SQLSTATE code or provided key does not match any known entry, we return a normalized fallback object This guarantees that lens() always returns a predictable object shape.

There are three mismatch levels that we detect.

Format : The provided code is malformed and is not validate the expression /[0-9A-Z]{5}/

ℹ️ "SQLSTATE values are comprised of a two-character class code value, followed by a three-character subclass code value. (ISO/IEC 9075:1992)"

console.log(lens("123456"));

Output:

{
  "code": "123456",
  "qlcs": "qlcodes_malformed",
  "matches": []
}

Code : The provided code matches no code within known classes

console.log(lens("2000U"));

Output:

{
  "code": "ABCDE",
  "qlcs": "qlcodes_no_code_found",
  "matches": []
}

API

lens(code: string): QLLens

|Parameters|Returns| |-|-| |code SQLSTATE status code | A structured status description| || code — normalized SQLSTATE, or -1 if not found || keys — semantic identifiers || useDBMS where the code is applicable || reasons — human-readable explanations || qlcs — 'qlcode status', shows the lens call status

Customization & Rebuild (Contributors)

If you want to extend or adjust the reference data:

  1. Clone the repository
$ git clone https://github.com/ManuUseGitHub/QLCodes.git
$ cd qlcodes
$ npm install
  1. Adapt the column (headers) configuration.
  • .qlCodes file (root) : gives the configuration of CSVs headers/columns (with their format and aliases)
  • src/constants.mjs : gives the configuration of the options passed throught @maze014/domFetch to fetch the documentation table of codes for the matching RDBMs.
  1. Run the dev script to set everything up.
$ npm run dev

This action will generate the folowing resources folders :

  • HTML : files from which a DOM can be fetched via domFetch.
  • CSV : CSVs files generated from the build script. These files can be modified according updated info.
  1. Rebuild the module
# generate the qlCodes.json
$ npm run build -- --prod

Quality of life

By default, the build script has no flag passed but You may pass flag argument to the build script to enforce a few behaviours to help you seing through the processor...

|argument|effect| |-|-| |--debug|prevents the cleanup of middle stage file created during the data processing| |--prod|will destroy the resources folder in order to keep things clean|


Showcase

in stackblitz


References


License

MIT 2025