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

@hiennc24/import-job

v1.0.0

Published

Reusable async import-job lifecycle: entity, repository, service and Moleculer mixin with AMQP progress publishing

Readme

@hiennc24/import-job

Reusable async import-job infrastructure for Moleculer services: persisted job lifecycle (pending → processing → completed | completed_with_errors | failed), atomic progress counters, throttled AMQP progress publishing, and query actions via a service mixin.

Each host service owns its own import_jobs collection (tenant DB routed by meta.domain through @hiennc24/mongoose).

Usage

import {
  ImportJobService,
  ImportJobRepository,
  createImportJobMixin
} from '@hiennc24/import-job';
import SERVICE_BROKER from '@hiennc24/constant';

const importJobService = new ImportJobService({
  publisher: broker, // Moleculer broker with @moleculer/channels middleware
  progressChannel: SERVICE_BROKER.CHANNEL_NAMES.SHARED.IMPORT_JOB_PROGRESS
});

broker.createService({
  name: 'svc-organization.employees',
  mixins: [
    createImportJobMixin({
      service: importJobService,
      actionNames: {
        getImportJob: SERVICE_BROKER.SVC_ORGANIZATION_EMPLOYEES.ACTION_GET_IMPORT_JOB,
        getImportJobPage: SERVICE_BROKER.SVC_ORGANIZATION_EMPLOYEES.ACTION_GET_IMPORT_JOB_PAGE
      }
    })
  ]
});

Worker side:

const job = await importJobService.create({ type: 'employee', mode, fileId, createdBy, domain }, meta);
// ... consumer:
await importJobService.start(job._id, totalRows, meta);
await importJobService.updateProgress(job._id, { processedDelta: 500, successDelta: 480, errorDelta: 20 }, meta);
await importJobService.complete(job._id, { errorReportFileId }, meta);

Guarantees

  • One active job per {domain, type} — enforced by a partial unique index (active: true); create throws ImportJobActiveError (code 409).
  • Throttled progress — non-terminal publishes at most once per throttleMs (default 1s) per job; terminal transitions always publish.
  • Publish failures never break lifecycle transitions — Mongo state is the source of truth.

Scripts

  • npm run build — tsc to lib/
  • npm test — mocha unit tests