Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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 1.0.1 to 1.0.2

2

dist/decorators/cron.decorator.js

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

const name = options && options.name;
return common_1.applyDecorators(common_1.SetMetadata(schedule_constants_1.SCHEDULE_CRON_OPTIONS, Object.assign(Object.assign({}, options), { cronTime })), common_1.SetMetadata(schedule_constants_1.SCHEDULER_NAME, name), common_1.SetMetadata(schedule_constants_1.SCHEDULER_TYPE, scheduler_type_enum_1.SchedulerType.CRON));
return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(schedule_constants_1.SCHEDULE_CRON_OPTIONS, Object.assign(Object.assign({}, options), { cronTime })), (0, common_1.SetMetadata)(schedule_constants_1.SCHEDULER_NAME, name), (0, common_1.SetMetadata)(schedule_constants_1.SCHEDULER_TYPE, scheduler_type_enum_1.SchedulerType.CRON));
}
exports.Cron = Cron;

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

function Interval(nameOrTimeout, timeout) {
const [name, intervalTimeout] = util_1.isString(nameOrTimeout)
const [name, intervalTimeout] = (0, util_1.isString)(nameOrTimeout)
? [nameOrTimeout, timeout]
: [undefined, nameOrTimeout];
return common_1.applyDecorators(common_1.SetMetadata(schedule_constants_1.SCHEDULE_INTERVAL_OPTIONS, { timeout: intervalTimeout }), common_1.SetMetadata(schedule_constants_1.SCHEDULER_NAME, name), common_1.SetMetadata(schedule_constants_1.SCHEDULER_TYPE, scheduler_type_enum_1.SchedulerType.INTERVAL));
return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(schedule_constants_1.SCHEDULE_INTERVAL_OPTIONS, { timeout: intervalTimeout }), (0, common_1.SetMetadata)(schedule_constants_1.SCHEDULER_NAME, name), (0, common_1.SetMetadata)(schedule_constants_1.SCHEDULER_TYPE, scheduler_type_enum_1.SchedulerType.INTERVAL));
}
exports.Interval = Interval;

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

function Timeout(nameOrTimeout, timeout) {
const [name, timeoutValue] = util_1.isString(nameOrTimeout)
const [name, timeoutValue] = (0, util_1.isString)(nameOrTimeout)
? [nameOrTimeout, timeout]
: [undefined, nameOrTimeout];
return common_1.applyDecorators(common_1.SetMetadata(schedule_constants_1.SCHEDULE_TIMEOUT_OPTIONS, { timeout: timeoutValue }), common_1.SetMetadata(schedule_constants_1.SCHEDULER_NAME, name), common_1.SetMetadata(schedule_constants_1.SCHEDULER_TYPE, scheduler_type_enum_1.SchedulerType.TIMEOUT));
return (0, common_1.applyDecorators)((0, common_1.SetMetadata)(schedule_constants_1.SCHEDULE_TIMEOUT_OPTIONS, { timeout: timeoutValue }), (0, common_1.SetMetadata)(schedule_constants_1.SCHEDULER_NAME, name), (0, common_1.SetMetadata)(schedule_constants_1.SCHEDULER_TYPE, scheduler_type_enum_1.SchedulerType.TIMEOUT));
}
exports.Timeout = Timeout;

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

SchedulerMetadataAccessor = __decorate([
common_1.Injectable(),
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [core_1.Reflector])
], SchedulerMetadataAccessor);
exports.SchedulerMetadataAccessor = SchedulerMetadataAccessor;
import { OnModuleInit } from '@nestjs/common';
import { DiscoveryService } from '@nestjs/core';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';

@@ -16,3 +17,4 @@ import { SchedulerMetadataAccessor } from './schedule-metadata.accessor';

lookupSchedulers(instance: Record<string, Function>, key: string): void;
warnForNonStaticProviders(wrapper: InstanceWrapper<any>, instance: Record<string, Function>, key: string): void;
private wrapFunctionInTryCatchBlocks;
}

@@ -44,5 +44,3 @@ "use strict";

];
instanceWrappers
.filter((wrapper) => wrapper.isDependencyTreeStatic())
.forEach((wrapper) => {
instanceWrappers.forEach((wrapper) => {
const { instance } = wrapper;

@@ -52,3 +50,5 @@ if (!instance || !Object.getPrototypeOf(instance)) {

}
this.metadataScanner.scanFromPrototype(instance, Object.getPrototypeOf(instance), (key) => this.lookupSchedulers(instance, key));
this.metadataScanner.scanFromPrototype(instance, Object.getPrototypeOf(instance), (key) => wrapper.isDependencyTreeStatic()
? this.lookupSchedulers(instance, key)
: this.warnForNonStaticProviders(wrapper, instance, key));
});

@@ -79,2 +79,20 @@ }

}
warnForNonStaticProviders(wrapper, instance, key) {
const methodRef = instance[key];
const metadata = this.metadataAccessor.getSchedulerType(methodRef);
switch (metadata) {
case scheduler_type_enum_1.SchedulerType.CRON: {
this.logger.warn(`Cannot register cron job "${wrapper.name}@${key}" because it is defined in a non static provider.`);
break;
}
case scheduler_type_enum_1.SchedulerType.TIMEOUT: {
this.logger.warn(`Cannot register timeout "${wrapper.name}@${key}" because it is defined in a non static provider.`);
break;
}
case scheduler_type_enum_1.SchedulerType.INTERVAL: {
this.logger.warn(`Cannot register interval "${wrapper.name}@${key}" because it is defined in a non static provider.`);
break;
}
}
}
wrapFunctionInTryCatchBlocks(methodRef, instance) {

@@ -92,3 +110,3 @@ return (...args) => __awaiter(this, void 0, void 0, function* () {

ScheduleExplorer = __decorate([
common_1.Injectable(),
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [scheduler_orchestrator_1.SchedulerOrchestrator,

@@ -95,0 +113,0 @@ core_1.DiscoveryService,

@@ -28,3 +28,3 @@ "use strict";

ScheduleModule = ScheduleModule_1 = __decorate([
common_1.Module({
(0, common_1.Module)({
imports: [core_1.DiscoveryModule],

@@ -31,0 +31,0 @@ providers: [schedule_metadata_accessor_1.SchedulerMetadataAccessor, scheduler_orchestrator_1.SchedulerOrchestrator],

@@ -71,3 +71,3 @@ "use strict";

}
addTimeout(methodRef, timeout, name = uuid_1.v4()) {
addTimeout(methodRef, timeout, name = (0, uuid_1.v4)()) {
this.timeouts[name] = {

@@ -78,3 +78,3 @@ target: methodRef,

}
addInterval(methodRef, timeout, name = uuid_1.v4()) {
addInterval(methodRef, timeout, name = (0, uuid_1.v4)()) {
this.intervals[name] = {

@@ -86,3 +86,3 @@ target: methodRef,

addCron(methodRef, options) {
const name = options.name || uuid_1.v4();
const name = options.name || (0, uuid_1.v4)();
this.cronJobs[name] = {

@@ -95,5 +95,5 @@ target: methodRef,

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

@@ -33,3 +33,3 @@ "use strict";

if (!ref) {
throw new Error(schedule_messages_1.NO_SCHEDULER_FOUND('Cron Job', name));
throw new Error((0, schedule_messages_1.NO_SCHEDULER_FOUND)('Cron Job', name));
}

@@ -41,3 +41,3 @@ return ref;

if (typeof ref === 'undefined') {
throw new Error(schedule_messages_1.NO_SCHEDULER_FOUND('Interval', name));
throw new Error((0, schedule_messages_1.NO_SCHEDULER_FOUND)('Interval', name));
}

@@ -49,3 +49,3 @@ return ref;

if (typeof ref === 'undefined') {
throw new Error(schedule_messages_1.NO_SCHEDULER_FOUND('Timeout', name));
throw new Error((0, schedule_messages_1.NO_SCHEDULER_FOUND)('Timeout', name));
}

@@ -57,3 +57,3 @@ return ref;

if (ref) {
throw new Error(schedule_messages_1.DUPLICATE_SCHEDULER('Cron Job', name));
throw new Error((0, schedule_messages_1.DUPLICATE_SCHEDULER)('Cron Job', name));
}

@@ -65,3 +65,3 @@ this.cronJobs.set(name, job);

if (ref) {
throw new Error(schedule_messages_1.DUPLICATE_SCHEDULER('Interval', name));
throw new Error((0, schedule_messages_1.DUPLICATE_SCHEDULER)('Interval', name));
}

@@ -73,3 +73,3 @@ this.intervals.set(name, intervalId);

if (ref) {
throw new Error(schedule_messages_1.DUPLICATE_SCHEDULER('Timeout', name));
throw new Error((0, schedule_messages_1.DUPLICATE_SCHEDULER)('Timeout', name));
}

@@ -104,4 +104,4 @@ this.timeouts.set(name, timeoutId);

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

@@ -25,29 +25,29 @@ "author": "Kamil Mysliwiec",

"devDependencies": {
"@commitlint/cli": "13.1.0",
"@commitlint/config-angular": "13.1.0",
"@nestjs/common": "8.0.5",
"@nestjs/core": "8.0.5",
"@nestjs/platform-express": "8.0.5",
"@nestjs/testing": "8.0.5",
"@commitlint/cli": "14.1.0",
"@commitlint/config-angular": "14.1.0",
"@nestjs/common": "8.2.0",
"@nestjs/core": "8.2.0",
"@nestjs/platform-express": "8.2.0",
"@nestjs/testing": "8.2.0",
"@types/cron": "1.7.2",
"@types/jest": "26.0.24",
"@types/node": "14.17.6",
"@types/sinon": "10.0.2",
"@types/jest": "27.0.2",
"@types/node": "16.11.7",
"@types/sinon": "10.0.6",
"@types/uuid": "8.3.1",
"@typescript-eslint/eslint-plugin": "4.28.5",
"@typescript-eslint/parser": "4.28.5",
"eslint": "7.31.0",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
"eslint": "8.2.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.23.4",
"husky": "7.0.1",
"jest": "27.0.6",
"lint-staged": "11.1.1",
"prettier": "2.3.2",
"eslint-plugin-import": "2.25.3",
"husky": "7.0.4",
"jest": "27.3.1",
"lint-staged": "12.0.2",
"prettier": "2.4.1",
"reflect-metadata": "0.1.13",
"release-it": "14.10.1",
"release-it": "14.11.7",
"rimraf": "3.0.2",
"rxjs": "7.2.0",
"sinon": "11.1.2",
"ts-jest": "27.0.4",
"typescript": "4.3.5"
"rxjs": "7.4.0",
"sinon": "12.0.1",
"ts-jest": "27.0.7",
"typescript": "4.4.4"
},

@@ -54,0 +54,0 @@ "peerDependencies": {

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