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

@memberjunction/scheduling-engine-base

v5.11.0

Published

MemberJunction: Base Scheduling Engine Package - extended entity types and metadata caching, can be used anywhere.

Readme

@memberjunction/scheduling-engine-base

Base scheduling engine providing metadata caching for MemberJunction's scheduled jobs system. Loads and caches job types, scheduled jobs, and recent runs. Can be used on both client and server.

Architecture

graph TD
    subgraph "@memberjunction/scheduling-engine-base"
        A[SchedulingEngineBase] --> B[Job Types Cache]
        A --> C[Scheduled Jobs Cache]
        A --> D[Job Runs Cache]
        A --> E[Polling Interval<br/>Calculator]
        F[MJScheduledJobEntityExtended] --> A
    end

    subgraph "Data Sources"
        G["MJ: Scheduled Job Types"]
        H["MJ: Scheduled Jobs"]
        I["MJ: Scheduled Job Runs"]
    end

    G --> B
    H --> C
    I --> D

    J["@memberjunction/scheduling-engine<br/>(Server Execution)"] -->|extends| A

    style A fill:#2d6a9f,stroke:#1a4971,color:#fff
    style B fill:#2d8659,stroke:#1a5c3a,color:#fff
    style C fill:#2d8659,stroke:#1a5c3a,color:#fff
    style D fill:#2d8659,stroke:#1a5c3a,color:#fff
    style E fill:#7c5295,stroke:#563a6b,color:#fff
    style F fill:#b8762f,stroke:#8a5722,color:#fff
    style J fill:#7c5295,stroke:#563a6b,color:#fff

Overview

This package provides two main components:

SchedulingEngineBase

A singleton engine that extends BaseEngine to load and cache scheduling metadata:

  • Job Types: Plugin registry mapping job type names to driver classes
  • Scheduled Jobs: Active (or all) scheduled jobs with their configurations
  • Job Runs: Recent execution history (last 7 days, optional)
  • Polling Interval: Adaptive polling interval calculation based on next run times
  • Lookup Methods: Find job types by name or driver class, get jobs by type, get runs for a job

MJScheduledJobEntityExtended

An extended entity class registered via @RegisterClass that adds helper properties and methods to ScheduledJobEntity:

  • Lock Management: IsLocked, IsLockStale, CurrentLockHolder properties
  • Concurrency: AllowsConcurrent, QueuesOverlappingRuns, SkipsOverlappingRuns
  • Statistics: SuccessRate, FailureRate percentage calculations
  • Timing: GetTimeUntilNextRun() millisecond calculation
  • Auto-Notifications: Overrides Save() and Delete() to auto-refresh engine metadata and recalculate polling intervals

Installation

npm install @memberjunction/scheduling-engine-base

Usage

Loading Metadata

import { SchedulingEngineBase } from '@memberjunction/scheduling-engine-base';

const engine = SchedulingEngineBase.Instance;

// Load active jobs only (default)
await engine.Config(false, contextUser);

// Load all jobs with recent runs
await engine.Config(false, contextUser, undefined, true, true);

Accessing Cached Data

// Job types (plugin registry)
const jobTypes = engine.ScheduledJobTypes;
const agentType = engine.GetJobTypeByName('Agent');
const byDriver = engine.GetJobTypeByDriverClass('ScheduledJobAgent');

// Scheduled jobs
const activeJobs = engine.ScheduledJobs;
const agentJobs = engine.GetJobsByType(agentType.ID);

// Job runs
const runs = engine.GetRunsForJob(jobId);

// Adaptive polling
engine.UpdatePollingInterval();
const interval = engine.ActivePollingInterval; // ms, or null if no jobs

Using Extended Entity

import { MJScheduledJobEntityExtended } from '@memberjunction/scheduling-engine-base';

const job = activeJobs[0] as MJScheduledJobEntityExtended;

console.log(job.IsLocked);          // Is currently being executed?
console.log(job.IsLockStale);       // Has the lock expired?
console.log(job.SuccessRate);       // e.g., 95.5
console.log(job.AllowsConcurrent);  // Can run in parallel?
console.log(job.GetTimeUntilNextRun()); // ms until next execution

API Reference

SchedulingEngineBase

| Member | Type | Description | |--------|------|-------------| | Instance | static getter | Singleton instance | | Config() | method | Load scheduling metadata with options | | ScheduledJobTypes | getter | All job type definitions | | ScheduledJobs | getter | Active (or all) scheduled jobs | | ScheduledJobRuns | getter | Recent job runs (if loaded) | | GetJobTypeByName() | method | Find job type by name | | GetJobTypeByDriverClass() | method | Find job type by driver class | | GetJobsByType() | method | Get all jobs of a specific type | | GetRunsForJob() | method | Get runs for a specific job | | ActivePollingInterval | getter | Current polling interval (ms) or null | | UpdatePollingInterval() | method | Recalculate optimal polling interval |

Relationship to Other Scheduling Packages

graph LR
    A["base-types<br/>(Interfaces)"] --> B["base-engine<br/>(Metadata Cache)"]
    B --> C["engine<br/>(Execution)"]
    A --> D["actions<br/>(Agentic Tools)"]

    style A fill:#2d6a9f,stroke:#1a4971,color:#fff
    style B fill:#2d8659,stroke:#1a5c3a,color:#fff
    style C fill:#7c5295,stroke:#563a6b,color:#fff
    style D fill:#b8762f,stroke:#8a5722,color:#fff

Dependencies

| Package | Purpose | |---------|---------| | @memberjunction/core | BaseEngine, UserInfo, IMetadataProvider | | @memberjunction/core-entities | ScheduledJobEntity, ScheduledJobTypeEntity, ScheduledJobRunEntity | | @memberjunction/global | RegisterClass decorator | | @memberjunction/scheduling-base-types | Shared type definitions |

License

ISC