@bernierllc/job-scheduler 1.2.5 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,8 +17,11 @@ const types_1 = require("./types");
17
17
  * Job scheduler for cron-based recurring tasks and one-time scheduled jobs
18
18
  */
19
19
  class JobScheduler {
20
+ jobs;
21
+ logger;
22
+ config;
23
+ nextJobId = 1;
20
24
  constructor(config = {}) {
21
- this.nextJobId = 1;
22
25
  this.jobs = new Map();
23
26
  this.logger = (0, logger_1.createLogger)();
24
27
  this.config = {
@@ -14,8 +14,13 @@ const types_1 = require("./types");
14
14
  * Represents a scheduled job with execution tracking
15
15
  */
16
16
  class ScheduledJob {
17
+ config;
18
+ status;
19
+ executions;
20
+ timer;
21
+ logger;
22
+ currentRetries = 0;
17
23
  constructor(config, logger) {
18
- this.currentRetries = 0;
19
24
  this.config = config;
20
25
  this.status = types_1.JobStatus.SCHEDULED;
21
26
  this.executions = [];
@@ -0,0 +1,11 @@
1
+ export type JobSchedulerErrorCode = 'JOB_SCHEDULER_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
2
+ export interface JobSchedulerErrorOptions {
3
+ cause?: Error;
4
+ code?: JobSchedulerErrorCode;
5
+ context?: Record<string, unknown>;
6
+ }
7
+ export declare class JobSchedulerError extends Error {
8
+ readonly code: JobSchedulerErrorCode;
9
+ readonly context?: Record<string, unknown>;
10
+ constructor(message: string, options?: JobSchedulerErrorOptions);
11
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code only within the scope of the project it was delivered for.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.JobSchedulerError = void 0;
11
+ class JobSchedulerError extends Error {
12
+ code;
13
+ context;
14
+ constructor(message, options) {
15
+ super(message, options?.cause ? { cause: options.cause } : undefined);
16
+ this.name = 'JobSchedulerError';
17
+ this.code = options?.code ?? 'JOB_SCHEDULER_ERROR';
18
+ if (options?.context !== undefined) {
19
+ this.context = options.context;
20
+ }
21
+ Error.captureStackTrace?.(this, this.constructor);
22
+ }
23
+ }
24
+ exports.JobSchedulerError = JobSchedulerError;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { JobSchedulerError, type JobSchedulerErrorCode, type JobSchedulerErrorOptions, } from './errors';
1
2
  export { JobScheduler, createJobScheduler } from './JobScheduler';
2
3
  export { ScheduledJob } from './ScheduledJob';
3
4
  export { JobStatus, JobType, JobHandler, JobExecution, ScheduledJobConfig, JobSchedulerConfig, JobSchedulerResult, JobStatistics } from './types';
package/dist/index.js CHANGED
@@ -7,7 +7,9 @@ The client may use and modify this code *only within the scope of the project it
7
7
  Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.JobType = exports.JobStatus = exports.ScheduledJob = exports.createJobScheduler = exports.JobScheduler = void 0;
10
+ exports.JobType = exports.JobStatus = exports.ScheduledJob = exports.createJobScheduler = exports.JobScheduler = exports.JobSchedulerError = void 0;
11
+ var errors_1 = require("./errors");
12
+ Object.defineProperty(exports, "JobSchedulerError", { enumerable: true, get: function () { return errors_1.JobSchedulerError; } });
11
13
  var JobScheduler_1 = require("./JobScheduler");
12
14
  Object.defineProperty(exports, "JobScheduler", { enumerable: true, get: function () { return JobScheduler_1.JobScheduler; } });
13
15
  Object.defineProperty(exports, "createJobScheduler", { enumerable: true, get: function () { return JobScheduler_1.createJobScheduler; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/job-scheduler",
3
- "version": "1.2.5",
3
+ "version": "1.4.0",
4
4
  "description": "Cron-based job scheduling for recurring tasks with execution tracking",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "license": "SEE LICENSE IN LICENSE",
23
23
  "dependencies": {
24
24
  "cron-parser": "^4.9.0",
25
- "@bernierllc/logger": "1.4.3"
25
+ "@bernierllc/logger": "1.6.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/jest": "^29.0.0",