@atlantjs/arch 14.0.4 → 15.0.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/@tool-box/utils/validators/is-schedule.d.ts +1 -1
- package/@tool-box/utils/validators/is-schedule.js +2 -2
- package/index.d.ts +2 -3
- package/index.js +5 -8
- package/objects/{schedule/schedule.edge.d.ts → scheduling/scheduling.edge.d.ts} +34 -83
- package/objects/{schedule/schedule.edge.failure.d.ts → scheduling/scheduling.edge.failure.d.ts} +1 -1
- package/objects/{schedule/schedule.edge.failure.js → scheduling/scheduling.edge.failure.js} +4 -4
- package/objects/{schedule/schedule.edge.js → scheduling/scheduling.edge.js} +94 -139
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/objects/@common/edges/cron-expression.edge.d.ts +0 -34
- package/objects/@common/edges/cron-expression.edge.js +0 -96
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { StringEdgeSketch } from "../../primitives/string.edge.sketch";
|
|
2
|
-
export declare class CronExpressionEdge extends StringEdgeSketch {
|
|
3
|
-
constructor(expression: string);
|
|
4
|
-
protected validateCronExpression(): void;
|
|
5
|
-
/**
|
|
6
|
-
* Retorna a expressão cron.
|
|
7
|
-
*/
|
|
8
|
-
toString(): string;
|
|
9
|
-
/**
|
|
10
|
-
* Retorna os campos da expressão cron.
|
|
11
|
-
*/
|
|
12
|
-
getFields(): string[];
|
|
13
|
-
/**
|
|
14
|
-
* Compara com outra expressão cron (string ou edge).
|
|
15
|
-
*/
|
|
16
|
-
isEqual(other: string | CronExpressionEdge): boolean;
|
|
17
|
-
isDifferent(other: string | CronExpressionEdge): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Retorna a próxima execução a partir de uma data base.
|
|
20
|
-
*/
|
|
21
|
-
nextDate(fromDate?: Date): Date;
|
|
22
|
-
/**
|
|
23
|
-
* Retorna a execução anterior a partir de uma data base.
|
|
24
|
-
*/
|
|
25
|
-
previousDate(fromDate?: Date): Date;
|
|
26
|
-
/**
|
|
27
|
-
* Retorna as próximas N execuções.
|
|
28
|
-
*/
|
|
29
|
-
nextDates(count: number, fromDate?: Date): Date[];
|
|
30
|
-
/**
|
|
31
|
-
* Valida expressão cron sem lançar exceção.
|
|
32
|
-
*/
|
|
33
|
-
static isValid(expression: string): boolean;
|
|
34
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CronExpressionEdge = void 0;
|
|
7
|
-
const cron_parser_1 = __importDefault(require("cron-parser"));
|
|
8
|
-
const string_edge_sketch_1 = require("../../primitives/string.edge.sketch");
|
|
9
|
-
class CronExpressionEdge extends string_edge_sketch_1.StringEdgeSketch {
|
|
10
|
-
constructor(expression) {
|
|
11
|
-
// normaliza espaços múltiplos para evitar inconsistência de validação
|
|
12
|
-
super(expression.replace(/\s+/g, " "));
|
|
13
|
-
this.validateCronExpression();
|
|
14
|
-
}
|
|
15
|
-
validateCronExpression() {
|
|
16
|
-
try {
|
|
17
|
-
// usa valor sanitizado do StringEdgeSketch
|
|
18
|
-
cron_parser_1.default.parse(this.toString());
|
|
19
|
-
}
|
|
20
|
-
catch {
|
|
21
|
-
throw new Error(`${this.toString()} should be a valid Cron Expression.`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// ==================== Getters ====================
|
|
25
|
-
/**
|
|
26
|
-
* Retorna a expressão cron.
|
|
27
|
-
*/
|
|
28
|
-
toString() {
|
|
29
|
-
return super.toString();
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Retorna os campos da expressão cron.
|
|
33
|
-
*/
|
|
34
|
-
getFields() {
|
|
35
|
-
return this.toString().split(/\s+/);
|
|
36
|
-
}
|
|
37
|
-
// ==================== Comparações ====================
|
|
38
|
-
/**
|
|
39
|
-
* Compara com outra expressão cron (string ou edge).
|
|
40
|
-
*/
|
|
41
|
-
isEqual(other) {
|
|
42
|
-
const comparand = other instanceof CronExpressionEdge ? other.toString() : other;
|
|
43
|
-
return this.toString() === comparand.trim().replace(/\s+/g, " ");
|
|
44
|
-
}
|
|
45
|
-
isDifferent(other) {
|
|
46
|
-
return !this.isEqual(other);
|
|
47
|
-
}
|
|
48
|
-
// ==================== Cálculo de Execução ====================
|
|
49
|
-
/**
|
|
50
|
-
* Retorna a próxima execução a partir de uma data base.
|
|
51
|
-
*/
|
|
52
|
-
nextDate(fromDate = new Date()) {
|
|
53
|
-
const interval = cron_parser_1.default.parse(this.toString(), {
|
|
54
|
-
currentDate: fromDate,
|
|
55
|
-
});
|
|
56
|
-
return interval.next().toDate();
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Retorna a execução anterior a partir de uma data base.
|
|
60
|
-
*/
|
|
61
|
-
previousDate(fromDate = new Date()) {
|
|
62
|
-
const interval = cron_parser_1.default.parse(this.toString(), {
|
|
63
|
-
currentDate: fromDate,
|
|
64
|
-
});
|
|
65
|
-
return interval.prev().toDate();
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Retorna as próximas N execuções.
|
|
69
|
-
*/
|
|
70
|
-
nextDates(count, fromDate = new Date()) {
|
|
71
|
-
if (count <= 0)
|
|
72
|
-
return [];
|
|
73
|
-
const interval = cron_parser_1.default.parse(this.toString(), {
|
|
74
|
-
currentDate: fromDate,
|
|
75
|
-
});
|
|
76
|
-
const dates = [];
|
|
77
|
-
for (let i = 0; i < count; i++) {
|
|
78
|
-
dates.push(interval.next().toDate());
|
|
79
|
-
}
|
|
80
|
-
return dates;
|
|
81
|
-
}
|
|
82
|
-
// ==================== Métodos Estáticos ====================
|
|
83
|
-
/**
|
|
84
|
-
* Valida expressão cron sem lançar exceção.
|
|
85
|
-
*/
|
|
86
|
-
static isValid(expression) {
|
|
87
|
-
try {
|
|
88
|
-
cron_parser_1.default.parse(expression.trim().replace(/\s+/g, " "));
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.CronExpressionEdge = CronExpressionEdge;
|