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

@quicore/resource-id

v1.0.0

Published

Deterministic and compact ID generation for API resources using pluggable hashing.

Readme

@quicore/resource-id

A lightweight, pluggable utility for generating compact, deterministic, and integration-scoped resource identifiers using flexible components. Ideal for APIs, FHIR systems, and cross-service data referencing.


✨ Features

  • 🔐 Compact deterministic ID generation using Blake2b + Base62
  • 🧩 Component-based customization (resourceType, resourceId, integrationId)
  • 📦 Works with any API data (not just FHIR)
  • ⚙️ Chainable and extensible class structure
  • 💾 MongoDB-friendly (22-character Base62 IDs by default)

📦 Installation

npm install @quicore/resource-id

🚀 Quick Start

import { ResourceIDGenerator } from '@quicore/resource-id';

const id = new ResourceIDGenerator()
  .setIntegrationId('my-app')
  .setResourceType('Invoice')
  .setResourceId('INV-12345')
  .generate();

console.log(id); // Compact, consistent ID (e.g., "004f83akdT3mJLhFtVNckT")

🔄 Use Case

While originally designed for FHIR resources, ResourceIDGenerator is generic and can be used for any API data:

  • resourceId = the unique identifier of your data object
  • resourceType = the type/category of your object ("User", "Invoice", "Post", etc.)
  • integrationId = a scoping prefix to prevent ID collisions across systems

📘 API Reference

class ResourceIDGenerator

Extends IDGenerator and is ready to use out of the box.

.setIntegrationId(id: string)

Sets a prefix to scope the generated ID by system/environment.

.setResourceType(type: string)

Sets the type/category of the data object (e.g., 'User', 'Appointment').

.setResourceId(id: string)

Sets the primary unique identifier (e.g., a database or API ID).

.setIdLength(length: number)

(Optional) Set the output ID length (minimum 10, default 22).

.generate() → string

Returns a compact, Base62-encoded ID derived from all components.


class IDGenerator

The base abstract class for deterministic ID generation. To extend:

class MyCustomGenerator extends IDGenerator {
  createCanonicalString() {
    return `${this.components.a}-${this.components.b}`;
  }

  validateComponents() {
    if (!this.components.a || !this.components.b) {
      throw new Error('Missing required components');
    }
  }
}

🧬 Output Format

Internally, IDs are created by hashing this structure:

<integrationId>::<resourceType>::<resourceId>

Then encoded into a compact Base62 string using blake2b.


🔐 Why Deterministic IDs?

  • Guarantees the same input always gives the same ID
  • Useful for deduplication, data sync, upserts, or ID federation
  • Scope-aware via integrationId to prevent overlap

🔧 FHIR Support (Optional)

For FHIR-specific use, the package includes:

class FHIRIDGenerator

import { FHIRIDGenerator } from '@quicore/resource-id';

const resource = {
  id: 'abc123',
  resourceType: 'Patient'
};

const id = new FHIRIDGenerator(resource)
  .setIntegrationId('epic')
  .generate();

console.log(id); // e.g., "A81dskf9e3rKW2ThjL9bc3"

📄 License

MIT