@athenna/cron 5.4.0 → 5.6.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.
- package/package.json +10 -10
- package/src/cron/CronBuilder.d.ts +2 -1
- package/src/cron/CronBuilder.js +3 -2
- package/src/cron/CronImpl.d.ts +2 -1
- package/src/cron/CronImpl.js +2 -1
- package/src/handlers/CronExceptionHandler.js +14 -0
- package/src/kernels/CronKernel.js +2 -2
- package/src/testing/plugins/scheduler/TestScheduler.d.ts +2 -1
- package/src/testing/plugins/scheduler/TestScheduler.js +2 -1
- package/templates/scheduler.edge +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/cron",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "Athenna scheduler application. Built on top of node-cron.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "João Lenon <lenon@athenna.io>",
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"node-cron": "^3.0.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@athenna/artisan": "^5.
|
|
61
|
-
"@athenna/common": "^5.
|
|
62
|
-
"@athenna/config": "^5.
|
|
63
|
-
"@athenna/ioc": "^5.
|
|
64
|
-
"@athenna/logger": "^5.
|
|
65
|
-
"@athenna/test": "^5.
|
|
60
|
+
"@athenna/artisan": "^5.6.0",
|
|
61
|
+
"@athenna/common": "^5.7.0",
|
|
62
|
+
"@athenna/config": "^5.3.0",
|
|
63
|
+
"@athenna/ioc": "^5.1.0",
|
|
64
|
+
"@athenna/logger": "^5.3.0",
|
|
65
|
+
"@athenna/test": "^5.3.0",
|
|
66
66
|
"@athenna/tsconfig": "^5.0.0",
|
|
67
|
-
"@athenna/view": "^5.
|
|
67
|
+
"@athenna/view": "^5.3.0",
|
|
68
68
|
"@types/node-cron": "^3.0.11",
|
|
69
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
70
|
-
"@typescript-eslint/parser": "^
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
|
70
|
+
"@typescript-eslint/parser": "^8.21.0",
|
|
71
71
|
"cls-rtracer": "^2.6.3",
|
|
72
72
|
"commitizen": "^4.3.1",
|
|
73
73
|
"cz-conventional-changelog": "^3.3.0",
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import type { CronHandler } from '#src/types';
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
10
11
|
import type { CronExceptionHandler } from '#src/handlers/CronExceptionHandler';
|
|
11
|
-
export declare class CronBuilder {
|
|
12
|
+
export declare class CronBuilder extends Macroable {
|
|
12
13
|
static rTracerPlugin: any;
|
|
13
14
|
static exceptionHandler: CronExceptionHandler;
|
|
14
15
|
/**
|
package/src/cron/CronBuilder.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { schedule } from 'node-cron';
|
|
10
|
-
import { Options } from '@athenna/common';
|
|
11
|
-
export class CronBuilder {
|
|
10
|
+
import { Macroable, Options } from '@athenna/common';
|
|
11
|
+
export class CronBuilder extends Macroable {
|
|
12
12
|
constructor() {
|
|
13
|
+
super(...arguments);
|
|
13
14
|
this.cron = {};
|
|
14
15
|
}
|
|
15
16
|
/**
|
package/src/cron/CronImpl.d.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
+
import { Macroable } from '@athenna/common';
|
|
9
10
|
import type { ScheduledTask } from '#src/types';
|
|
10
11
|
import { CronBuilder } from '#src/cron/CronBuilder';
|
|
11
|
-
export declare class CronImpl {
|
|
12
|
+
export declare class CronImpl extends Macroable {
|
|
12
13
|
/**
|
|
13
14
|
* Creates a new instance of CronBuilder to register
|
|
14
15
|
* your scheduler.
|
package/src/cron/CronImpl.js
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
+
import { Macroable } from '@athenna/common';
|
|
9
10
|
import { getTasks, validate } from 'node-cron';
|
|
10
11
|
import { CronBuilder } from '#src/cron/CronBuilder';
|
|
11
12
|
import { NotFoundTaskNameException } from '#src/exceptions/NotFoundTaskNameException';
|
|
12
|
-
export class CronImpl {
|
|
13
|
+
export class CronImpl extends Macroable {
|
|
13
14
|
/**
|
|
14
15
|
* Creates a new instance of CronBuilder to register
|
|
15
16
|
* your scheduler.
|
|
@@ -42,6 +42,20 @@ export class CronExceptionHandler {
|
|
|
42
42
|
if (!this.canBeLogged(error)) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
+
const isUsingJsonFormatter = Config.is('logging.channels.exception.formatter', 'json');
|
|
46
|
+
if (isUsingJsonFormatter) {
|
|
47
|
+
Log.channelOrVanilla('exception').error({
|
|
48
|
+
name: error.name,
|
|
49
|
+
code: error.code,
|
|
50
|
+
status: error.status,
|
|
51
|
+
message: error.message,
|
|
52
|
+
help: error.help,
|
|
53
|
+
cause: error.cause,
|
|
54
|
+
details: error.details,
|
|
55
|
+
stack: error.stack
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
45
59
|
Log.channelOrVanilla('exception').error(await error.prettify());
|
|
46
60
|
}
|
|
47
61
|
/**
|
|
@@ -2,7 +2,7 @@ import { debug } from '#src/debug';
|
|
|
2
2
|
import { Cron } from '#src/facades/Cron';
|
|
3
3
|
import { CronBuilder } from '#src/cron/CronBuilder';
|
|
4
4
|
import { sep, resolve, isAbsolute } from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { File, Path, Module } from '@athenna/common';
|
|
6
6
|
import { Annotation } from '@athenna/ioc';
|
|
7
7
|
import { CronExceptionHandler } from '#src/handlers/CronExceptionHandler';
|
|
8
8
|
const rTracerPlugin = await Module.safeImport('cls-rtracer');
|
|
@@ -42,7 +42,7 @@ export class CronKernel {
|
|
|
42
42
|
*/
|
|
43
43
|
async registerSchedulers() {
|
|
44
44
|
const schedulers = Config.get('rc.schedulers', []);
|
|
45
|
-
await
|
|
45
|
+
await schedulers.athenna.concurrently(async (path) => {
|
|
46
46
|
const Scheduler = await Module.resolve(path, this.getParentURL());
|
|
47
47
|
if (Annotation.isAnnotated(Scheduler)) {
|
|
48
48
|
this.registerUsingMeta(Scheduler);
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* For the full copyright and license information, please view the LICENSE
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
import { Macroable } from '@athenna/common';
|
|
10
|
+
export declare class TestScheduler extends Macroable {
|
|
10
11
|
/**
|
|
11
12
|
* Run a specific scheduler by its name.
|
|
12
13
|
*
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* file that was distributed with this source code.
|
|
8
8
|
*/
|
|
9
9
|
import { Cron } from '@athenna/cron';
|
|
10
|
-
|
|
10
|
+
import { Macroable } from '@athenna/common';
|
|
11
|
+
export class TestScheduler extends Macroable {
|
|
11
12
|
/**
|
|
12
13
|
* Run a specific scheduler by its name.
|
|
13
14
|
*
|
package/templates/scheduler.edge
CHANGED