Socket
Socket
Sign inDemoInstall

@nestjs/schedule

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/schedule - npm Package Compare versions

Comparing version 3.0.4 to 4.0.0

19

dist/decorators/cron.decorator.d.ts

@@ -0,5 +1,6 @@

import { CronJobParams } from 'cron';
/**
* @ref https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/cron/index.d.ts
*/
export interface CronOptions {
export type CronOptions = {
/**

@@ -12,7 +13,7 @@ * Specify the name of your cron job. This will allow to inject your cron job reference through `@InjectCronRef`.

*/
timeZone?: string;
timeZone?: unknown;
/**
* This allows you to specify the offset of your timezone rather than using the ```timeZone``` param. Probably don't use both ```timeZone``` and ```utcOffset``` together or weird things may happen.
*/
utcOffset?: string | number;
utcOffset?: unknown;
/**

@@ -27,8 +28,14 @@ * If you have code that keeps the event loop running and want to stop the node process when that finishes regardless of the state of your cronjob, you can do so making use of this parameter. This is off by default and cron will run as if it needs to control the event loop. For more information take a look at [timers#timers_timeout_unref](https://nodejs.org/api/timers.html#timers_timeout_unref) from the NodeJS docs.

disabled?: boolean;
}
} & ({
timeZone?: string;
utcOffset?: never;
} | {
timeZone?: never;
utcOffset?: number;
});
/**
* Creates a scheduled job.
* @param cronTime The time to fire off your job. This can be in the form of cron syntax or a JS ```Date``` object.
* @param cronTime The time to fire off your job. This can be in the form of cron syntax, a JS ```Date``` object or a Luxon ```DateTime``` object.
* @param options Job execution options.
*/
export declare function Cron(cronTime: string | Date, options?: CronOptions): MethodDecorator;
export declare function Cron(cronTime: CronJobParams['cronTime'], options?: CronOptions): MethodDecorator;

@@ -9,7 +9,7 @@ "use strict";

* Creates a scheduled job.
* @param cronTime The time to fire off your job. This can be in the form of cron syntax or a JS ```Date``` object.
* @param cronTime The time to fire off your job. This can be in the form of cron syntax, a JS ```Date``` object or a Luxon ```DateTime``` object.
* @param options Job execution options.
*/
function Cron(cronTime, options = {}) {
const name = options && options.name;
const name = options?.name;
return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(schedule_constants_1.SCHEDULE_CRON_OPTIONS, {

@@ -16,0 +16,0 @@ ...options,

@@ -89,2 +89,2 @@ "use strict";

CronExpression["MONDAY_TO_FRIDAY_AT_11PM"] = "0 0 23 * * 1-5";
})(CronExpression = exports.CronExpression || (exports.CronExpression = {}));
})(CronExpression || (exports.CronExpression = CronExpression = {}));

@@ -9,2 +9,2 @@ "use strict";

SchedulerType[SchedulerType["INTERVAL"] = 3] = "INTERVAL";
})(SchedulerType = exports.SchedulerType || (exports.SchedulerType = {}));
})(SchedulerType || (exports.SchedulerType = SchedulerType = {}));

@@ -42,6 +42,6 @@ "use strict";

};
SchedulerMetadataAccessor = __decorate([
exports.SchedulerMetadataAccessor = SchedulerMetadataAccessor;
exports.SchedulerMetadataAccessor = SchedulerMetadataAccessor = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [core_1.Reflector])
], SchedulerMetadataAccessor);
exports.SchedulerMetadataAccessor = SchedulerMetadataAccessor;

@@ -39,5 +39,13 @@ "use strict";

}
this.metadataScanner.scanFromPrototype(instance, Object.getPrototypeOf(instance), (key) => wrapper.isDependencyTreeStatic()
? this.lookupSchedulers(instance, key)
: this.warnForNonStaticProviders(wrapper, instance, key));
const processMethod = (name) => wrapper.isDependencyTreeStatic()
? this.lookupSchedulers(instance, name)
: this.warnForNonStaticProviders(wrapper, instance, name);
// TODO(v4): remove this after dropping support for nestjs v9.3.2
if (!Reflect.has(this.metadataScanner, 'getAllMethodNames')) {
this.metadataScanner.scanFromPrototype(instance, Object.getPrototypeOf(instance), processMethod);
return;
}
this.metadataScanner
.getAllMethodNames(Object.getPrototypeOf(instance))
.forEach(processMethod);
});

@@ -97,3 +105,4 @@ }

};
ScheduleExplorer = __decorate([
exports.ScheduleExplorer = ScheduleExplorer;
exports.ScheduleExplorer = ScheduleExplorer = __decorate([
(0, common_1.Injectable)(),

@@ -105,2 +114,1 @@ __metadata("design:paramtypes", [scheduler_orchestrator_1.SchedulerOrchestrator,

], ScheduleExplorer);
exports.ScheduleExplorer = ScheduleExplorer;

@@ -1,2 +0,2 @@

export declare const NO_SCHEDULER_FOUND: (schedulerName: string, name?: string | undefined) => string;
export declare const NO_SCHEDULER_FOUND: (schedulerName: string, name?: string) => string;
export declare const DUPLICATE_SCHEDULER: (schedulerName: string, name: string) => string;

@@ -27,3 +27,4 @@ "use strict";

};
ScheduleModule = ScheduleModule_1 = __decorate([
exports.ScheduleModule = ScheduleModule;
exports.ScheduleModule = ScheduleModule = ScheduleModule_1 = __decorate([
(0, common_1.Module)({

@@ -34,2 +35,1 @@ imports: [core_1.DiscoveryModule],

], ScheduleModule);
exports.ScheduleModule = ScheduleModule;
import { OnApplicationBootstrap, OnApplicationShutdown } from '@nestjs/common';
import { CronJobParams } from 'cron';
import { CronOptions } from './decorators/cron.decorator';

@@ -20,3 +21,3 @@ import { SchedulerRegistry } from './scheduler.registry';

addInterval(methodRef: Function, timeout: number, name?: string): void;
addCron(methodRef: Function, options: CronOptions & Record<'cronTime', string | Date | any>): void;
addCron(methodRef: Function, options: CronOptions & Record<'cronTime', CronJobParams['cronTime']>): void;
}

@@ -56,9 +56,7 @@ "use strict";

const { options, target } = this.cronJobs[key];
const cronJob = new cron_1.CronJob(options.cronTime, target, undefined, false, options.timeZone, undefined, false, options.utcOffset, options.unrefTimeout);
if (options.disabled) {
cronJob.stop();
}
else {
cronJob.start();
}
const cronJob = cron_1.CronJob.from({
...options,
onTick: target,
start: !options.disabled
});
this.cronJobs[key].ref = cronJob;

@@ -97,6 +95,6 @@ this.schedulerRegistry.addCronJob(key, cronJob);

};
SchedulerOrchestrator = __decorate([
exports.SchedulerOrchestrator = SchedulerOrchestrator;
exports.SchedulerOrchestrator = SchedulerOrchestrator = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [scheduler_registry_1.SchedulerRegistry])
], SchedulerOrchestrator);
exports.SchedulerOrchestrator = SchedulerOrchestrator;

@@ -8,3 +8,3 @@ import { CronJob } from 'cron';

doesExist(type: 'cron' | 'timeout' | 'interval', name: string): boolean;
getCronJob(name: string): CronJob;
getCronJob(name: string): CronJob<null, null>;
getInterval(name: string): any;

@@ -11,0 +11,0 @@ getTimeout(name: string): any;

@@ -110,5 +110,5 @@ "use strict";

};
SchedulerRegistry = SchedulerRegistry_1 = __decorate([
exports.SchedulerRegistry = SchedulerRegistry;
exports.SchedulerRegistry = SchedulerRegistry = SchedulerRegistry_1 = __decorate([
(0, common_1.Injectable)()
], SchedulerRegistry);
exports.SchedulerRegistry = SchedulerRegistry;
{
"name": "@nestjs/schedule",
"version": "3.0.4",
"version": "4.0.0",
"description": "Nest - modern, fast, powerful node.js web framework (@schedule)",

@@ -21,30 +21,30 @@ "author": "Kamil Mysliwiec",

"dependencies": {
"cron": "2.4.3",
"cron": "3.1.3",
"uuid": "9.0.1"
},
"devDependencies": {
"@commitlint/cli": "17.7.1",
"@commitlint/config-angular": "17.7.0",
"@nestjs/common": "10.2.5",
"@nestjs/core": "10.2.5",
"@nestjs/platform-express": "10.2.5",
"@nestjs/testing": "10.2.5",
"@types/jest": "29.5.5",
"@types/node": "18.17.18",
"@types/sinon": "10.0.16",
"@types/uuid": "9.0.4",
"@typescript-eslint/eslint-plugin": "6.7.2",
"@typescript-eslint/parser": "6.7.2",
"eslint": "8.49.0",
"@commitlint/cli": "18.0.0",
"@commitlint/config-angular": "18.0.0",
"@nestjs/common": "10.2.7",
"@nestjs/core": "10.2.7",
"@nestjs/platform-express": "10.2.7",
"@nestjs/testing": "10.2.7",
"@types/jest": "29.5.6",
"@types/node": "18.18.6",
"@types/sinon": "10.0.20",
"@types/uuid": "9.0.6",
"@typescript-eslint/eslint-plugin": "6.8.0",
"@typescript-eslint/parser": "6.8.0",
"eslint": "8.52.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-import": "2.29.0",
"husky": "8.0.3",
"jest": "29.7.0",
"lint-staged": "14.0.1",
"lint-staged": "15.0.2",
"prettier": "3.0.3",
"reflect-metadata": "0.1.13",
"release-it": "16.1.5",
"rimraf": "5.0.1",
"release-it": "16.2.1",
"rimraf": "5.0.5",
"rxjs": "7.8.1",
"sinon": "16.0.0",
"sinon": "17.0.0",
"ts-jest": "29.1.1",

@@ -51,0 +51,0 @@ "typescript": "5.2.2"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc