version_final_sans_test
This commit is contained in:
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const cors = require('cors');
|
const cors = require('cors');
|
||||||
const sql = require('mssql');
|
const sql = require('mssql');
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
@@ -6,7 +6,7 @@ require('dotenv').config();
|
|||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 3001;
|
const PORT = 3001;
|
||||||
|
|
||||||
// Configuration base de données
|
// Configuration base de données
|
||||||
const dbConfig = {
|
const dbConfig = {
|
||||||
server: process.env.DB_SERVER,
|
server: process.env.DB_SERVER,
|
||||||
database: process.env.DB_DATABASE,
|
database: process.env.DB_DATABASE,
|
||||||
@@ -26,20 +26,34 @@ app.use(cors({
|
|||||||
}));
|
}));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
// Log de toutes les requêtes
|
// Log de toutes les requêtes
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
console.log(`${new Date().toISOString()} - ${req.method} ${req.path} depuis ${req.get('origin') || 'inconnu'}`);
|
console.log(`${new Date().toISOString()} - ${req.method} ${req.path} depuis ${req.get('origin') || 'inconnu'}`);
|
||||||
|
if (req.query.user_email || req.query.email) {
|
||||||
|
console.log(` - Filtrage pour utilisateur: ${req.query.user_email || req.query.email}`);
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Variable pour stocker la connexion
|
// Variable pour stocker la connexion et l'état de la migration
|
||||||
let pool = null;
|
let pool = null;
|
||||||
|
let systemStatus = {
|
||||||
|
hasFormateurEmailColumn: false,
|
||||||
|
hasFormateurView: false,
|
||||||
|
canAccessFormateurView: false,
|
||||||
|
hasFormateurLocal: false,
|
||||||
|
operatingMode: 'unknown'
|
||||||
|
};
|
||||||
|
|
||||||
// Fonction pour se connecter à la base
|
// Fonction pour se connecter à la base
|
||||||
async function connectDatabase() {
|
async function connectDatabase() {
|
||||||
try {
|
try {
|
||||||
pool = await sql.connect(dbConfig);
|
pool = await sql.connect(dbConfig);
|
||||||
console.log('Base de données connectée');
|
console.log('Base de données connectée');
|
||||||
|
|
||||||
|
// Diagnostic automatique de la structure et permissions
|
||||||
|
await checkSystemStatus();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur de connexion :', error.message);
|
console.error('Erreur de connexion :', error.message);
|
||||||
@@ -47,116 +61,345 @@ async function connectDatabase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route de test
|
// Fonction pour vérifier l'état complet du système
|
||||||
app.get('/api/test', (req, res) => {
|
async function checkSystemStatus() {
|
||||||
res.json({
|
|
||||||
message: 'Le serveur fonctionne !',
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Route pour tester la base de données
|
|
||||||
app.get('/api/db-test', async (req, res) => {
|
|
||||||
try {
|
try {
|
||||||
if (!pool) {
|
// 1. Vérifier si la colonne formateur_email_fk existe
|
||||||
return res.status(500).json({ error: 'Base non connectée' });
|
const columnCheck = await pool.request().query(`
|
||||||
|
SELECT COUNT(*) as count
|
||||||
|
FROM INFORMATION_SCHEMA.COLUMNS
|
||||||
|
WHERE TABLE_NAME = 'declarations'
|
||||||
|
AND COLUMN_NAME = 'formateur_email_fk'
|
||||||
|
`);
|
||||||
|
systemStatus.hasFormateurEmailColumn = columnCheck.recordset[0].count > 0;
|
||||||
|
|
||||||
|
// 2. Vérifier si la vue Formateurs existe
|
||||||
|
const viewCheck = await pool.request().query(`
|
||||||
|
SELECT COUNT(*) as count
|
||||||
|
FROM INFORMATION_SCHEMA.VIEWS
|
||||||
|
WHERE TABLE_NAME = 'Formateurs'
|
||||||
|
`);
|
||||||
|
systemStatus.hasFormateurView = viewCheck.recordset[0].count > 0;
|
||||||
|
|
||||||
|
// 3. Tester l'accès à la vue Formateurs si elle existe
|
||||||
|
if (systemStatus.hasFormateurView) {
|
||||||
|
try {
|
||||||
|
await pool.request().query(`SELECT TOP 1 userPrincipalName FROM [dbo].[Formateurs]`);
|
||||||
|
systemStatus.canAccessFormateurView = true;
|
||||||
|
console.log('✅ Accès à la vue Formateurs: OK');
|
||||||
|
} catch (error) {
|
||||||
|
systemStatus.canAccessFormateurView = false;
|
||||||
|
console.log('❌ Accès à la vue Formateurs: ERREUR -', error.message);
|
||||||
|
if (error.message.includes('HP-TO-O365')) {
|
||||||
|
console.log('💡 Problème de permissions sur la base HP-TO-O365');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Vérifier si la table formateurs_local existe et est accessible
|
||||||
|
try {
|
||||||
|
await pool.request().query(`SELECT TOP 1 * FROM formateurs_local`);
|
||||||
|
systemStatus.hasFormateurLocal = true;
|
||||||
|
console.log('✅ Table formateurs_local: OK');
|
||||||
|
} catch (error) {
|
||||||
|
systemStatus.hasFormateurLocal = false;
|
||||||
|
console.log('❌ Table formateurs_local: non accessible');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. Déterminer le mode de fonctionnement optimal
|
||||||
|
if (systemStatus.hasFormateurEmailColumn && systemStatus.canAccessFormateurView) {
|
||||||
|
systemStatus.operatingMode = 'new_with_view';
|
||||||
|
} else if (systemStatus.hasFormateurEmailColumn && systemStatus.hasFormateurLocal) {
|
||||||
|
systemStatus.operatingMode = 'new_with_local';
|
||||||
|
} else if (systemStatus.hasFormateurEmailColumn) {
|
||||||
|
systemStatus.operatingMode = 'new_email_only';
|
||||||
|
} else {
|
||||||
|
systemStatus.operatingMode = 'legacy_hash';
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('📊 État du système:');
|
||||||
|
console.log(` - Colonne formateur_email_fk: ${systemStatus.hasFormateurEmailColumn ? '✅' : '❌'}`);
|
||||||
|
console.log(` - Vue Formateurs: ${systemStatus.hasFormateurView ? '✅' : '❌'}`);
|
||||||
|
console.log(` - Accès vue Formateurs: ${systemStatus.canAccessFormateurView ? '✅' : '❌'}`);
|
||||||
|
console.log(` - Table formateurs_local: ${systemStatus.hasFormateurLocal ? '✅' : '❌'}`);
|
||||||
|
console.log(` - Mode de fonctionnement: ${systemStatus.operatingMode}`);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur lors du diagnostic:', error.message);
|
||||||
|
systemStatus.operatingMode = 'legacy_hash';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Route de diagnostic complet
|
||||||
|
app.get('/api/diagnostic', async (req, res) => {
|
||||||
|
try {
|
||||||
|
await checkSystemStatus();
|
||||||
|
|
||||||
|
let recommendations = [];
|
||||||
|
|
||||||
|
switch (systemStatus.operatingMode) {
|
||||||
|
case 'new_with_view':
|
||||||
|
recommendations.push('✅ Système optimal - toutes les fonctionnalités disponibles');
|
||||||
|
break;
|
||||||
|
case 'new_with_local':
|
||||||
|
recommendations.push('⚠️ Fonctionne avec la table locale - pas d\'accès à la vue distante');
|
||||||
|
recommendations.push('💡 Vérifier les permissions sur HP-TO-O365 pour utiliser la vue');
|
||||||
|
break;
|
||||||
|
case 'new_email_only':
|
||||||
|
recommendations.push('⚠️ Mode dégradé - sauvegarde par email mais pas de détails formateurs');
|
||||||
|
recommendations.push('💡 Restaurer l\'accès à la vue Formateurs ou table formateurs_local');
|
||||||
|
break;
|
||||||
|
case 'legacy_hash':
|
||||||
|
recommendations.push('🔄 Mode compatibilité - utilise l\'ancien système de hash');
|
||||||
|
recommendations.push('💡 Appliquer la migration avec POST /api/migrate');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await pool.request().query('SELECT COUNT(*) as total FROM FormateurSqy');
|
|
||||||
res.json({
|
res.json({
|
||||||
message: 'Base OK',
|
systemStatus,
|
||||||
formateurs: result.recordset[0].total
|
recommendations,
|
||||||
|
currentMode: systemStatus.operatingMode
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route pour lister les formateurs
|
// Route pour appliquer la migration
|
||||||
app.get('/api/formateurs', async (req, res) => {
|
app.post('/api/migrate', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const result = await pool.request().query(`
|
const steps = [];
|
||||||
SELECT TOP 10
|
|
||||||
NUMERO,
|
// Étape 1: Ajouter la colonne si nécessaire
|
||||||
NOM_ENS as nom,
|
if (!systemStatus.hasFormateurEmailColumn) {
|
||||||
PRENOM_ENS as prenom,
|
try {
|
||||||
EMAIL1 as email
|
await pool.request().query(`
|
||||||
FROM FormateurSqy
|
ALTER TABLE [dbo].[declarations]
|
||||||
WHERE EMAIL1 IS NOT NULL
|
ADD [formateur_email_fk] [nvarchar](255) NULL
|
||||||
ORDER BY NOM_ENS
|
|
||||||
`);
|
`);
|
||||||
|
steps.push('✅ Colonne formateur_email_fk ajoutée');
|
||||||
|
} catch (error) {
|
||||||
|
if (!error.message.includes('already exists')) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
steps.push('ℹ️ Colonne formateur_email_fk déjà existante');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Étape 2: Créer un index
|
||||||
|
try {
|
||||||
|
await pool.request().query(`
|
||||||
|
CREATE NONCLUSTERED INDEX [IX_declarations_formateur_email_fk]
|
||||||
|
ON [dbo].[declarations] ([formateur_email_fk])
|
||||||
|
`);
|
||||||
|
steps.push('✅ Index créé');
|
||||||
|
} catch (error) {
|
||||||
|
if (error.message.includes('already exists')) {
|
||||||
|
steps.push('ℹ️ Index déjà existant');
|
||||||
|
} else {
|
||||||
|
steps.push(`⚠️ Erreur index: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vérifier à nouveau l'état
|
||||||
|
await checkSystemStatus();
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
data: result.recordset
|
steps,
|
||||||
|
newStatus: systemStatus,
|
||||||
|
message: `Migration appliquée - Mode: ${systemStatus.operatingMode}`
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
res.status(500).json({
|
||||||
|
success: false,
|
||||||
|
error: error.message,
|
||||||
|
message: 'Erreur lors de la migration'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route de test
|
||||||
|
app.get('/api/test', (req, res) => {
|
||||||
|
res.json({
|
||||||
|
message: 'Le serveur utilisateur fonctionne !',
|
||||||
|
timestamp: new Date().toISOString(),
|
||||||
|
systemStatus
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fonction pour générer un hash reproductible depuis un email (mode legacy)
|
||||||
|
function generateHashFromEmail(email) {
|
||||||
|
let hash = 0;
|
||||||
|
for (let i = 0; i < email.length; i++) {
|
||||||
|
const char = email.charCodeAt(i);
|
||||||
|
hash = ((hash << 5) - hash) + char;
|
||||||
|
hash = hash & hash; // Convert to 32-bit integer
|
||||||
|
}
|
||||||
|
return Math.abs(hash) % 10000 + 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Route pour les formateurs (adaptée au mode de fonctionnement)
|
||||||
|
app.get('/api/formateurs', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { email, search } = req.query;
|
||||||
|
|
||||||
|
switch (systemStatus.operatingMode) {
|
||||||
|
case 'new_with_view':
|
||||||
|
// Utiliser la vue Formateurs
|
||||||
|
let query = `
|
||||||
|
SELECT
|
||||||
|
userPrincipalName as email,
|
||||||
|
displayName as nom_complet,
|
||||||
|
givenname as prenom,
|
||||||
|
surname as nom,
|
||||||
|
Campus,
|
||||||
|
departement,
|
||||||
|
Jobtitle
|
||||||
|
FROM [dbo].[Formateurs]
|
||||||
|
`;
|
||||||
|
|
||||||
|
const request = pool.request();
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
query += ` WHERE userPrincipalName = @email`;
|
||||||
|
request.input('email', sql.NVarChar, email);
|
||||||
|
} else if (search) {
|
||||||
|
query += ` WHERE displayName LIKE @search OR userPrincipalName LIKE @search`;
|
||||||
|
request.input('search', sql.NVarChar, `%${search}%`);
|
||||||
|
}
|
||||||
|
|
||||||
|
query += ` ORDER BY displayName`;
|
||||||
|
|
||||||
|
const result = await request.query(query);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
data: result.recordset,
|
||||||
|
source: 'vue_formateurs'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'new_with_local':
|
||||||
|
// Utiliser la table formateurs_local
|
||||||
|
let localQuery = `
|
||||||
|
SELECT
|
||||||
|
userPrincipalName as email,
|
||||||
|
displayName as nom_complet,
|
||||||
|
givenname as prenom,
|
||||||
|
surname as nom,
|
||||||
|
Campus,
|
||||||
|
departement,
|
||||||
|
Jobtitle
|
||||||
|
FROM formateurs_local
|
||||||
|
`;
|
||||||
|
|
||||||
|
const localRequest = pool.request();
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
localQuery += ` WHERE userPrincipalName = @email`;
|
||||||
|
localRequest.input('email', sql.NVarChar, email);
|
||||||
|
} else if (search) {
|
||||||
|
localQuery += ` WHERE displayName LIKE @search OR userPrincipalName LIKE @search`;
|
||||||
|
localRequest.input('search', sql.NVarChar, `%${search}%`);
|
||||||
|
}
|
||||||
|
|
||||||
|
localQuery += ` ORDER BY displayName`;
|
||||||
|
|
||||||
|
const localResult = await localRequest.query(localQuery);
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
data: localResult.recordset,
|
||||||
|
source: 'table_locale'
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'new_email_only':
|
||||||
|
case 'legacy_hash':
|
||||||
|
default:
|
||||||
|
// Mode dégradé - réponse basique
|
||||||
|
if (email) {
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
data: [{
|
||||||
|
email: email,
|
||||||
|
nom_complet: email.split('@')[0] || 'Utilisateur',
|
||||||
|
prenom: 'Utilisateur',
|
||||||
|
nom: email.split('@')[0] || 'Inconnu',
|
||||||
|
source: 'fallback'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
data: [],
|
||||||
|
source: 'fallback'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur recherche formateurs:', error);
|
||||||
|
// Fallback en cas d'erreur
|
||||||
|
if (email) {
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
data: [{
|
||||||
|
email: email,
|
||||||
|
nom_complet: email.split('@')[0] || 'Utilisateur',
|
||||||
|
prenom: 'Utilisateur',
|
||||||
|
nom: email.split('@')[0] || 'Inconnu',
|
||||||
|
source: 'error_fallback'
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
} else {
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
success: false,
|
success: false,
|
||||||
error: error.message
|
error: error.message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route pour sauvegarder une déclaration
|
// Conversion simple en string "HH:mm:ss"
|
||||||
|
const toSQLTime = (timeStr) => {
|
||||||
|
if (!timeStr) return null;
|
||||||
|
const [hours, minutes] = timeStr.split(':').map(Number);
|
||||||
|
const d = new Date(Date.UTC(2000, 0, 1, hours, minutes, 0));
|
||||||
|
return d;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Route pour sauvegarder une déclaration (ADAPTÉE AU MODE)
|
||||||
app.post('/api/save_declaration', async (req, res) => {
|
app.post('/api/save_declaration', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { date, activityType, hours, description, user } = req.body;
|
const { date, activityType, hours, description, user, startTime, endTime } = req.body;
|
||||||
|
console.log('Données reçues:', { date, activityType, hours, description, user, startTime, endTime });
|
||||||
|
|
||||||
console.log('Données reçues:', { date, activityType, hours, description, user });
|
const heureDebutSQL = toSQLTime(startTime);
|
||||||
|
const heureFinSQL = toSQLTime(endTime);
|
||||||
|
|
||||||
// Validation simple
|
// Validation
|
||||||
if (!date || !activityType || !hours) {
|
if (!date || !activityType || !hours || !startTime || !endTime) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
success: false,
|
success: false,
|
||||||
error: 'Données manquantes'
|
error: 'Données manquantes'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let formateurNumero;
|
if (!user || !user.email) {
|
||||||
|
return res.status(400).json({
|
||||||
if (user && user.email) {
|
success: false,
|
||||||
// Chercher le formateur par email
|
error: 'Email utilisateur requis'
|
||||||
const formateurResult = await pool.request()
|
});
|
||||||
.input('email', sql.VarChar, user.email)
|
|
||||||
.query('SELECT NUMERO FROM FormateurSqy WHERE EMAIL1 = @email');
|
|
||||||
|
|
||||||
if (formateurResult.recordset.length > 0) {
|
|
||||||
// Formateur trouvé
|
|
||||||
formateurNumero = formateurResult.recordset[0].NUMERO;
|
|
||||||
console.log('Formateur trouvé par email:', formateurNumero);
|
|
||||||
} else {
|
|
||||||
// Créer un nouveau formateur
|
|
||||||
const maxNumeroResult = await pool.request()
|
|
||||||
.query('SELECT ISNULL(MAX(NUMERO), 0) + 1 as nextNumero FROM FormateurSqy');
|
|
||||||
|
|
||||||
const nextNumero = maxNumeroResult.recordset[0].nextNumero;
|
|
||||||
|
|
||||||
await pool.request()
|
|
||||||
.input('numero', sql.Int, nextNumero)
|
|
||||||
.input('nom', sql.VarChar, user.nom || 'Inconnu')
|
|
||||||
.input('prenom', sql.VarChar, user.prenom || 'Inconnu')
|
|
||||||
.input('email', sql.VarChar, user.email)
|
|
||||||
.input('department', sql.VarChar, user.department || 'Non défini')
|
|
||||||
.input('role', sql.VarChar, user.role || 'Employé')
|
|
||||||
.query(`
|
|
||||||
INSERT INTO FormateurSqy (
|
|
||||||
NUMERO, NOM_ENS, PRENOM_ENS, EMAIL1, [Ecole - Pole], Contrat
|
|
||||||
) VALUES (
|
|
||||||
@numero, @nom, @prenom, @email, @department, @role
|
|
||||||
)
|
|
||||||
`);
|
|
||||||
|
|
||||||
formateurNumero = nextNumero;
|
|
||||||
console.log('Nouveau formateur créé:', formateurNumero);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Fallback : utiliser un formateur par défaut
|
|
||||||
formateurNumero = 999;
|
|
||||||
console.log('Utilisation du formateur par défaut:', formateurNumero);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupérer l'ID du type de demande
|
const userEmail = user.email;
|
||||||
|
|
||||||
|
// Récupération du type de demande
|
||||||
const typeResult = await pool.request()
|
const typeResult = await pool.request()
|
||||||
.input('activityType', sql.VarChar, activityType)
|
.input('activityType', sql.VarChar, activityType)
|
||||||
.query('SELECT id FROM types_demandes WHERE libelle = @activityType');
|
.query('SELECT id FROM types_demandes WHERE libelle = @activityType');
|
||||||
@@ -164,20 +407,89 @@ app.post('/api/save_declaration', async (req, res) => {
|
|||||||
if (typeResult.recordset.length === 0) {
|
if (typeResult.recordset.length === 0) {
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
success: false,
|
success: false,
|
||||||
error: `Type d'activité invalide: ${activityType}`
|
error: `Type d'activité invalide: ${activityType}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeDemandeId = typeResult.recordset[0].id;
|
const typeDemandeId = typeResult.recordset[0].id;
|
||||||
|
|
||||||
// Vérifier si une déclaration existe déjà pour cette date
|
// Logique selon le mode de fonctionnement
|
||||||
|
if (systemStatus.operatingMode.startsWith('new_')) {
|
||||||
|
// NOUVEAU SYSTÈME - par email
|
||||||
|
console.log(`💾 Sauvegarde avec nouveau système (email) - Mode: ${systemStatus.operatingMode}`);
|
||||||
|
|
||||||
|
// Vérifier si une déclaration existe déjà
|
||||||
|
const existingResult = await pool.request()
|
||||||
|
.input('formateurEmail', sql.NVarChar, userEmail)
|
||||||
|
.input('date', sql.Date, date)
|
||||||
|
.query('SELECT id FROM declarations WHERE formateur_email_fk = @formateurEmail AND date = @date');
|
||||||
|
|
||||||
|
const utilisateurId = 1; // À adapter selon votre logique
|
||||||
|
|
||||||
|
if (existingResult.recordset.length > 0) {
|
||||||
|
// UPDATE
|
||||||
|
await pool.request()
|
||||||
|
.input('formateurEmail', sql.NVarChar, userEmail)
|
||||||
|
.input('typeDemandeId', sql.Int, typeDemandeId)
|
||||||
|
.input('hours', sql.Float, hours)
|
||||||
|
.input('description', sql.NVarChar, description || null)
|
||||||
|
.input('date', sql.Date, date)
|
||||||
|
.input('heure_debut', sql.Time, heureDebutSQL)
|
||||||
|
.input('heure_fin', sql.Time, heureFinSQL)
|
||||||
|
.query(`
|
||||||
|
UPDATE declarations
|
||||||
|
SET type_demande_id = @typeDemandeId,
|
||||||
|
duree = @hours,
|
||||||
|
description = @description,
|
||||||
|
heure_debut = @heure_debut,
|
||||||
|
heure_fin = @heure_fin
|
||||||
|
WHERE formateur_email_fk = @formateurEmail AND date = @date
|
||||||
|
`);
|
||||||
|
console.log('✅ Déclaration mise à jour');
|
||||||
|
} else {
|
||||||
|
// INSERT
|
||||||
|
await pool.request()
|
||||||
|
.input('utilisateurId', sql.Int, utilisateurId)
|
||||||
|
.input('formateurEmail', sql.NVarChar, userEmail)
|
||||||
|
.input('typeDemandeId', sql.Int, typeDemandeId)
|
||||||
|
.input('date', sql.Date, date)
|
||||||
|
.input('hours', sql.Float, hours)
|
||||||
|
.input('description', sql.NVarChar, description || null)
|
||||||
|
.input('heure_debut', sql.Time, heureDebutSQL)
|
||||||
|
.input('heure_fin', sql.Time, heureFinSQL)
|
||||||
|
.query(`
|
||||||
|
INSERT INTO declarations (
|
||||||
|
utilisateur_id, formateur_email_fk, type_demande_id,
|
||||||
|
date, duree, description, heure_debut, heure_fin
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
@utilisateurId, @formateurEmail, @typeDemandeId,
|
||||||
|
@date, @hours, @description, @heure_debut, @heure_fin
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
console.log('✅ Nouvelle déclaration créée');
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: `Déclaration sauvegardée avec succès (${systemStatus.operatingMode})`,
|
||||||
|
formateurEmail: userEmail
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// ANCIEN SYSTÈME - par hash
|
||||||
|
console.log('💾 Sauvegarde avec ancien système (hash)');
|
||||||
|
|
||||||
|
const formateurNumero = generateHashFromEmail(userEmail);
|
||||||
|
|
||||||
|
// Vérifier si une déclaration existe déjà
|
||||||
const existingResult = await pool.request()
|
const existingResult = await pool.request()
|
||||||
.input('formateurNumero', sql.Int, formateurNumero)
|
.input('formateurNumero', sql.Int, formateurNumero)
|
||||||
.input('date', sql.Date, date)
|
.input('date', sql.Date, date)
|
||||||
.query('SELECT id FROM declarations WHERE formateur_numero = @formateurNumero AND date = @date');
|
.query('SELECT id FROM declarations WHERE formateur_numero = @formateurNumero AND date = @date');
|
||||||
|
|
||||||
if (existingResult.recordset.length > 0) {
|
if (existingResult.recordset.length > 0) {
|
||||||
// Mise à jour
|
// UPDATE
|
||||||
await pool.request()
|
await pool.request()
|
||||||
.input('utilisateurId', sql.Int, formateurNumero)
|
.input('utilisateurId', sql.Int, formateurNumero)
|
||||||
.input('typeDemandeId', sql.Int, typeDemandeId)
|
.input('typeDemandeId', sql.Int, typeDemandeId)
|
||||||
@@ -185,15 +497,21 @@ app.post('/api/save_declaration', async (req, res) => {
|
|||||||
.input('description', sql.NVarChar, description || null)
|
.input('description', sql.NVarChar, description || null)
|
||||||
.input('formateurNumero', sql.Int, formateurNumero)
|
.input('formateurNumero', sql.Int, formateurNumero)
|
||||||
.input('date', sql.Date, date)
|
.input('date', sql.Date, date)
|
||||||
|
.input('heure_debut', sql.Time, heureDebutSQL)
|
||||||
|
.input('heure_fin', sql.Time, heureFinSQL)
|
||||||
.query(`
|
.query(`
|
||||||
UPDATE declarations
|
UPDATE declarations
|
||||||
SET utilisateur_id = @utilisateurId, type_demande_id = @typeDemandeId, duree = @hours, description = @description
|
SET utilisateur_id = @utilisateurId,
|
||||||
|
type_demande_id = @typeDemandeId,
|
||||||
|
duree = @hours,
|
||||||
|
description = @description,
|
||||||
|
heure_debut = @heure_debut,
|
||||||
|
heure_fin = @heure_fin
|
||||||
WHERE formateur_numero = @formateurNumero AND date = @date
|
WHERE formateur_numero = @formateurNumero AND date = @date
|
||||||
`);
|
`);
|
||||||
|
console.log('✅ Déclaration mise à jour (legacy)');
|
||||||
console.log('Déclaration mise à jour');
|
|
||||||
} else {
|
} else {
|
||||||
// Création
|
// INSERT
|
||||||
await pool.request()
|
await pool.request()
|
||||||
.input('utilisateurId', sql.Int, formateurNumero)
|
.input('utilisateurId', sql.Int, formateurNumero)
|
||||||
.input('formateurNumero', sql.Int, formateurNumero)
|
.input('formateurNumero', sql.Int, formateurNumero)
|
||||||
@@ -201,18 +519,27 @@ app.post('/api/save_declaration', async (req, res) => {
|
|||||||
.input('date', sql.Date, date)
|
.input('date', sql.Date, date)
|
||||||
.input('hours', sql.Float, hours)
|
.input('hours', sql.Float, hours)
|
||||||
.input('description', sql.NVarChar, description || null)
|
.input('description', sql.NVarChar, description || null)
|
||||||
|
.input('heure_debut', sql.Time, heureDebutSQL)
|
||||||
|
.input('heure_fin', sql.Time, heureFinSQL)
|
||||||
.query(`
|
.query(`
|
||||||
INSERT INTO declarations (utilisateur_id, formateur_numero, type_demande_id, date, duree, description)
|
INSERT INTO declarations (
|
||||||
VALUES (@utilisateurId, @formateurNumero, @typeDemandeId, @date, @hours, @description)
|
utilisateur_id, formateur_numero, type_demande_id,
|
||||||
|
date, duree, description, heure_debut, heure_fin
|
||||||
|
)
|
||||||
|
VALUES (
|
||||||
|
@utilisateurId, @formateurNumero, @typeDemandeId,
|
||||||
|
@date, @hours, @description, @heure_debut, @heure_fin
|
||||||
|
)
|
||||||
`);
|
`);
|
||||||
|
console.log('✅ Nouvelle déclaration créée (legacy)');
|
||||||
console.log('Nouvelle déclaration créée');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
message: 'Déclaration sauvegardée avec succès'
|
message: 'Déclaration sauvegardée avec succès (legacy)',
|
||||||
|
formateurNumero: formateurNumero
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la sauvegarde:', error);
|
console.error('Erreur lors de la sauvegarde:', error);
|
||||||
@@ -223,60 +550,307 @@ app.post('/api/save_declaration', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route pour récupérer les déclarations
|
// Route pour récupérer par email (ADAPTÉE AU MODE)
|
||||||
app.get('/api/get_declarations', async (req, res) => {
|
app.get('/api/get_declarations_by_email', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const result = await pool.request().query(`
|
const { email } = req.query;
|
||||||
|
console.log('DEBUG - Email reçu:', email);
|
||||||
|
|
||||||
|
if (!email) {
|
||||||
|
return res.status(400).json({ error: 'Email requis' });
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (systemStatus.operatingMode) {
|
||||||
|
case 'new_with_view':
|
||||||
|
// Avec vue Formateurs
|
||||||
|
const resultWithView = await pool.request()
|
||||||
|
.input('email', sql.NVarChar, email)
|
||||||
|
.query(`
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
d.utilisateur_id,
|
||||||
|
d.formateur_email_fk as formateur_email,
|
||||||
|
f.displayName as formateur_nom,
|
||||||
|
f.Campus,
|
||||||
|
f.departement,
|
||||||
|
td.id as type_demande_id,
|
||||||
|
td.libelle as activityType,
|
||||||
|
d.date,
|
||||||
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
|
d.description,
|
||||||
|
d.status
|
||||||
|
FROM declarations d
|
||||||
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
LEFT JOIN [dbo].[Formateurs] f ON d.formateur_email_fk = f.userPrincipalName
|
||||||
|
WHERE d.formateur_email_fk = @email
|
||||||
|
ORDER BY d.date DESC
|
||||||
|
`);
|
||||||
|
res.json(resultWithView.recordset);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'new_with_local':
|
||||||
|
// Avec table formateurs_local
|
||||||
|
const resultWithLocal = await pool.request()
|
||||||
|
.input('email', sql.NVarChar, email)
|
||||||
|
.query(`
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
d.utilisateur_id,
|
||||||
|
d.formateur_email_fk as formateur_email,
|
||||||
|
f.displayName as formateur_nom,
|
||||||
|
f.Campus,
|
||||||
|
f.departement,
|
||||||
|
td.id as type_demande_id,
|
||||||
|
td.libelle as activityType,
|
||||||
|
d.date,
|
||||||
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
|
d.description,
|
||||||
|
d.status
|
||||||
|
FROM declarations d
|
||||||
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
LEFT JOIN formateurs_local f ON d.formateur_email_fk = f.userPrincipalName
|
||||||
|
WHERE d.formateur_email_fk = @email
|
||||||
|
ORDER BY d.date DESC
|
||||||
|
`);
|
||||||
|
res.json(resultWithLocal.recordset);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'new_email_only':
|
||||||
|
// Sans jointure formateur
|
||||||
|
const resultEmailOnly = await pool.request()
|
||||||
|
.input('email', sql.NVarChar, email)
|
||||||
|
.query(`
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
d.utilisateur_id,
|
||||||
|
d.formateur_email_fk as formateur_email,
|
||||||
|
td.id as type_demande_id,
|
||||||
|
td.libelle as activityType,
|
||||||
|
d.date,
|
||||||
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
|
d.description,
|
||||||
|
d.status
|
||||||
|
FROM declarations d
|
||||||
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
WHERE d.formateur_email_fk = @email
|
||||||
|
ORDER BY d.date DESC
|
||||||
|
`);
|
||||||
|
res.json(resultEmailOnly.recordset);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'legacy_hash':
|
||||||
|
default:
|
||||||
|
// Ancien système avec hash
|
||||||
|
const formateurNumero = generateHashFromEmail(email);
|
||||||
|
console.log(`Email ${email} -> Numéro ${formateurNumero}`);
|
||||||
|
|
||||||
|
const resultLegacy = await pool.request()
|
||||||
|
.input('formateur_numero', sql.Int, formateurNumero)
|
||||||
|
.query(`
|
||||||
SELECT
|
SELECT
|
||||||
d.id,
|
d.id,
|
||||||
d.formateur_numero as utilisateur_id,
|
d.formateur_numero as utilisateur_id,
|
||||||
td.id as type_demande_id,
|
td.id as type_demande_id,
|
||||||
d.date,
|
d.date,
|
||||||
d.duree,
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
d.description,
|
d.description,
|
||||||
d.formateur_numero,
|
td.libelle as activityType,
|
||||||
td.libelle as activityType
|
d.status
|
||||||
FROM declarations d
|
FROM declarations d
|
||||||
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
WHERE d.formateur_numero = @formateur_numero
|
||||||
ORDER BY d.date DESC
|
ORDER BY d.date DESC
|
||||||
`);
|
`);
|
||||||
|
res.json(resultLegacy.recordset);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
res.json(result.recordset);
|
console.log(`✅ Déclarations récupérées pour ${email} (mode: ${systemStatus.operatingMode})`);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors de la récupération:', error);
|
console.error('Erreur lors de la récupération par email:', error.message);
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Démarrage du serveur
|
// Route pour récupérer toutes les déclarations
|
||||||
|
app.get('/api/get_declarations', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { user_email, admin } = req.query;
|
||||||
|
|
||||||
|
// Utiliser la même logique que pour get_declarations_by_email
|
||||||
|
if (user_email && !admin) {
|
||||||
|
// Rediriger vers get_declarations_by_email
|
||||||
|
req.query = { email: user_email };
|
||||||
|
return app._router.handle(req, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mode admin - récupérer toutes les déclarations
|
||||||
|
let result;
|
||||||
|
switch (systemStatus.operatingMode) {
|
||||||
|
case 'new_with_view':
|
||||||
|
result = await pool.request().query(`
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
d.utilisateur_id,
|
||||||
|
d.formateur_email_fk as formateur_email,
|
||||||
|
f.displayName as formateur_nom,
|
||||||
|
f.Campus,
|
||||||
|
f.departement,
|
||||||
|
td.id as type_demande_id,
|
||||||
|
td.libelle as activityType,
|
||||||
|
d.date,
|
||||||
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
|
d.description,
|
||||||
|
d.status
|
||||||
|
FROM declarations d
|
||||||
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
LEFT JOIN [dbo].[Formateurs] f ON d.formateur_email_fk = f.userPrincipalName
|
||||||
|
ORDER BY d.date DESC
|
||||||
|
`);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'new_with_local':
|
||||||
|
result = await pool.request().query(`
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
d.utilisateur_id,
|
||||||
|
d.formateur_email_fk as formateur_email,
|
||||||
|
f.displayName as formateur_nom,
|
||||||
|
f.Campus,
|
||||||
|
f.departement,
|
||||||
|
td.id as type_demande_id,
|
||||||
|
td.libelle as activityType,
|
||||||
|
d.date,
|
||||||
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
|
d.description,
|
||||||
|
d.status
|
||||||
|
FROM declarations d
|
||||||
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
LEFT JOIN formateurs_local f ON d.formateur_email_fk = f.userPrincipalName
|
||||||
|
ORDER BY d.date DESC
|
||||||
|
`);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'new_email_only':
|
||||||
|
result = await pool.request().query(`
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
d.utilisateur_id,
|
||||||
|
d.formateur_email_fk as formateur_email,
|
||||||
|
td.id as type_demande_id,
|
||||||
|
td.libelle as activityType,
|
||||||
|
d.date,
|
||||||
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
|
d.description,
|
||||||
|
d.status
|
||||||
|
FROM declarations d
|
||||||
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
ORDER BY d.date DESC
|
||||||
|
`);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
result = await pool.request().query(`
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
d.formateur_numero as utilisateur_id,
|
||||||
|
td.id as type_demande_id,
|
||||||
|
d.date,
|
||||||
|
d.duree,
|
||||||
|
d.heure_debut,
|
||||||
|
d.heure_fin,
|
||||||
|
d.description,
|
||||||
|
d.formateur_numero,
|
||||||
|
td.libelle as activityType,
|
||||||
|
d.status
|
||||||
|
FROM declarations d
|
||||||
|
INNER JOIN types_demandes td ON d.type_demande_id = td.id
|
||||||
|
ORDER BY d.date DESC
|
||||||
|
`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
res.json(result.recordset);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur lors de la récupération:', error);
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route de création de formateur (pour compatibilité)
|
||||||
|
app.post('/api/create_formateur', (req, res) => {
|
||||||
|
res.json({
|
||||||
|
success: true,
|
||||||
|
message: 'Route de compatibilité - utilisez /api/formateurs'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Démarrage du serveur
|
||||||
async function startServer() {
|
async function startServer() {
|
||||||
const dbConnected = await connectDatabase();
|
const dbConnected = await connectDatabase();
|
||||||
|
|
||||||
if (!dbConnected) {
|
if (!dbConnected) {
|
||||||
console.log('Impossible de démarrer sans base de données');
|
console.log('Impossible de démarrer sans base de données');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`Serveur démarré sur http://localhost:${PORT}`);
|
console.log(`🚀 Serveur UTILISATEUR démarré sur http://localhost:${PORT}`);
|
||||||
|
console.log(`📊 Mode de fonctionnement: ${systemStatus.operatingMode}`);
|
||||||
|
console.log('');
|
||||||
console.log('Routes disponibles :');
|
console.log('Routes disponibles :');
|
||||||
|
console.log('- GET /api/diagnostic (vérifier l\'état)');
|
||||||
|
console.log('- POST /api/migrate (appliquer la migration)');
|
||||||
console.log('- GET /api/test');
|
console.log('- GET /api/test');
|
||||||
console.log('- GET /api/db-test');
|
console.log('- GET /api/formateurs?email=test@example.com');
|
||||||
console.log('- GET /api/formateurs');
|
|
||||||
console.log('- POST /api/save_declaration');
|
console.log('- POST /api/save_declaration');
|
||||||
console.log('- GET /api/get_declarations');
|
console.log('- GET /api/get_declarations');
|
||||||
|
console.log('- GET /api/get_declarations_by_email?email=test@example.com');
|
||||||
|
console.log('');
|
||||||
|
|
||||||
|
switch (systemStatus.operatingMode) {
|
||||||
|
case 'new_with_view':
|
||||||
|
console.log('✅ Système optimal - utilise la vue Formateurs');
|
||||||
|
break;
|
||||||
|
case 'new_with_local':
|
||||||
|
console.log('⚠️ Mode dégradé - utilise la table formateurs_local');
|
||||||
|
console.log('💡 Conseil: Vérifier les permissions sur HP-TO-O365');
|
||||||
|
break;
|
||||||
|
case 'new_email_only':
|
||||||
|
console.log('⚠️ Mode minimal - sauvegarde par email sans détails formateurs');
|
||||||
|
break;
|
||||||
|
case 'legacy_hash':
|
||||||
|
console.log('🔄 Mode compatibilité - utilise l\'ancien système de hash');
|
||||||
|
console.log('💡 Conseil: Appliquer la migration avec POST /api/migrate');
|
||||||
|
break;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arrêt propre
|
// Arrêt propre
|
||||||
process.on('SIGINT', async () => {
|
process.on('SIGINT', async () => {
|
||||||
console.log('Arrêt du serveur...');
|
console.log('Arrêt du serveur utilisateur...');
|
||||||
if (pool) {
|
if (pool) {
|
||||||
await pool.close();
|
await pool.close();
|
||||||
}
|
}
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Démarrer
|
// Démarrer
|
||||||
startServer();
|
startServer()
|
||||||
18
GTF/project/node_modules/.vite/deps/_metadata.json
generated
vendored
18
GTF/project/node_modules/.vite/deps/_metadata.json
generated
vendored
@@ -1,43 +1,43 @@
|
|||||||
{
|
{
|
||||||
"hash": "1e9c2bee",
|
"hash": "5aba48b5",
|
||||||
"configHash": "451161ff",
|
"configHash": "2088881b",
|
||||||
"lockfileHash": "b1ec30a4",
|
"lockfileHash": "b1ec30a4",
|
||||||
"browserHash": "57e609ed",
|
"browserHash": "ac0e96b1",
|
||||||
"optimized": {
|
"optimized": {
|
||||||
"react": {
|
"react": {
|
||||||
"src": "../../react/index.js",
|
"src": "../../react/index.js",
|
||||||
"file": "react.js",
|
"file": "react.js",
|
||||||
"fileHash": "4348729b",
|
"fileHash": "9a2d9b21",
|
||||||
"needsInterop": true
|
"needsInterop": true
|
||||||
},
|
},
|
||||||
"react/jsx-dev-runtime": {
|
"react/jsx-dev-runtime": {
|
||||||
"src": "../../react/jsx-dev-runtime.js",
|
"src": "../../react/jsx-dev-runtime.js",
|
||||||
"file": "react_jsx-dev-runtime.js",
|
"file": "react_jsx-dev-runtime.js",
|
||||||
"fileHash": "9694e297",
|
"fileHash": "d21e6b25",
|
||||||
"needsInterop": true
|
"needsInterop": true
|
||||||
},
|
},
|
||||||
"react/jsx-runtime": {
|
"react/jsx-runtime": {
|
||||||
"src": "../../react/jsx-runtime.js",
|
"src": "../../react/jsx-runtime.js",
|
||||||
"file": "react_jsx-runtime.js",
|
"file": "react_jsx-runtime.js",
|
||||||
"fileHash": "4fa96245",
|
"fileHash": "286c86a9",
|
||||||
"needsInterop": true
|
"needsInterop": true
|
||||||
},
|
},
|
||||||
"@azure/msal-browser": {
|
"@azure/msal-browser": {
|
||||||
"src": "../../@azure/msal-browser/dist/index.mjs",
|
"src": "../../@azure/msal-browser/dist/index.mjs",
|
||||||
"file": "@azure_msal-browser.js",
|
"file": "@azure_msal-browser.js",
|
||||||
"fileHash": "8be31f82",
|
"fileHash": "90396c8f",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
},
|
},
|
||||||
"react-dom/client": {
|
"react-dom/client": {
|
||||||
"src": "../../react-dom/client.js",
|
"src": "../../react-dom/client.js",
|
||||||
"file": "react-dom_client.js",
|
"file": "react-dom_client.js",
|
||||||
"fileHash": "8aa9b52d",
|
"fileHash": "a16fb88b",
|
||||||
"needsInterop": true
|
"needsInterop": true
|
||||||
},
|
},
|
||||||
"react-router-dom": {
|
"react-router-dom": {
|
||||||
"src": "../../../../node_modules/react-router-dom/dist/index.mjs",
|
"src": "../../../../node_modules/react-router-dom/dist/index.mjs",
|
||||||
"file": "react-router-dom.js",
|
"file": "react-router-dom.js",
|
||||||
"fileHash": "f4ac1124",
|
"fileHash": "a93f0753",
|
||||||
"needsInterop": false
|
"needsInterop": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -13,18 +13,28 @@ function App() {
|
|||||||
const [showProfile, setShowProfile] = useState(false);
|
const [showProfile, setShowProfile] = useState(false);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
// Fonction pour charger les déclarations depuis la base
|
// Fonction pour charger les déclarations filtrées par utilisateur
|
||||||
const loadDeclarations = async () => {
|
const loadDeclarations = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('Chargement des déclarations...');
|
console.log('Chargement des déclarations...');
|
||||||
const response = await fetch('http://localhost:3001/api/get_declarations');
|
|
||||||
|
// Vérifier si l'utilisateur est connecté
|
||||||
|
if (!user?.email) {
|
||||||
|
console.log('Aucun utilisateur connecté');
|
||||||
|
setTimeEntries([]);
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// CORRECTION : Utiliser l'email au lieu de l'ID
|
||||||
|
const response = await fetch(`http://localhost:3001/api/get_declarations_by_email?email=${encodeURIComponent(user.email)}`);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log('Déclarations reçues:', data);
|
console.log('Déclarations reçues pour l\'email', user.email, ':', data);
|
||||||
|
|
||||||
// Convertir les données du serveur au format TimeEntry
|
// Convertir les données du serveur au format TimeEntry
|
||||||
const entries: TimeEntry[] = data.map((d: any) => ({
|
const entries: TimeEntry[] = data.map((d: any) => ({
|
||||||
@@ -36,18 +46,24 @@ function App() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
setTimeEntries(entries);
|
setTimeEntries(entries);
|
||||||
console.log('Déclarations converties:', entries);
|
console.log('Déclarations converties pour l\'utilisateur:', entries);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur lors du chargement des déclarations:', error);
|
console.error('Erreur lors du chargement des déclarations:', error);
|
||||||
|
setTimeEntries([]);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Charger les déclarations au démarrage
|
// Recharger quand l'utilisateur change
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (user?.email) {
|
||||||
loadDeclarations();
|
loadDeclarations();
|
||||||
}, []);
|
} else {
|
||||||
|
setTimeEntries([]);
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [user?.email]);
|
||||||
|
|
||||||
const handleDateClick = (date: string) => setSelectedDate(date);
|
const handleDateClick = (date: string) => setSelectedDate(date);
|
||||||
const handleCloseModal = () => setSelectedDate(null);
|
const handleCloseModal = () => setSelectedDate(null);
|
||||||
@@ -82,6 +98,17 @@ function App() {
|
|||||||
.slice(0, 3);
|
.slice(0, 3);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Vérification si utilisateur connecté
|
||||||
|
if (!user) {
|
||||||
|
return (
|
||||||
|
<div className="min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center">
|
||||||
|
<div className="bg-white rounded-2xl shadow-xl border border-gray-100 p-8 text-center">
|
||||||
|
<div className="text-gray-600">Chargement de la session...</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50">
|
<div className="min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -94,7 +121,9 @@ function App() {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-xl sm:text-2xl font-bold text-gray-800">GTF</h1>
|
<h1 className="text-xl sm:text-2xl font-bold text-gray-800">GTF</h1>
|
||||||
<p className="text-sm text-gray-600">Formateurs - Suivi mensuel</p>
|
<p className="text-sm text-gray-600">
|
||||||
|
Formateurs - Suivi mensuel • {user.nom} {user.prenom}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -136,15 +165,11 @@ function App() {
|
|||||||
{/* Mobile Profile */}
|
{/* Mobile Profile */}
|
||||||
{showProfile && (
|
{showProfile && (
|
||||||
<div className="mb-6 sm:hidden">
|
<div className="mb-6 sm:hidden">
|
||||||
{user ? (
|
|
||||||
<UserProfile
|
<UserProfile
|
||||||
user={user}
|
user={user}
|
||||||
totalHours={getTotalCurrentMonthHours()}
|
totalHours={getTotalCurrentMonthHours()}
|
||||||
totalEntries={timeEntries.length}
|
totalEntries={timeEntries.length}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<div>Chargement du profil...</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -161,6 +186,7 @@ function App() {
|
|||||||
<Calendar
|
<Calendar
|
||||||
onDateClick={handleDateClick}
|
onDateClick={handleDateClick}
|
||||||
getEntryForDate={getEntryForDate}
|
getEntryForDate={getEntryForDate}
|
||||||
|
currentUserId={user.id}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -169,15 +195,11 @@ function App() {
|
|||||||
<div className="space-y-6 xl:col-span-1">
|
<div className="space-y-6 xl:col-span-1">
|
||||||
{/* Desktop Profile */}
|
{/* Desktop Profile */}
|
||||||
<div className="hidden sm:block">
|
<div className="hidden sm:block">
|
||||||
{user ? (
|
|
||||||
<UserProfile
|
<UserProfile
|
||||||
user={user}
|
user={user}
|
||||||
totalHours={getTotalCurrentMonthHours()}
|
totalHours={getTotalCurrentMonthHours()}
|
||||||
totalEntries={timeEntries.length}
|
totalEntries={timeEntries.length}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<div>Chargement du profil...</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Quick Actions */}
|
{/* Quick Actions */}
|
||||||
@@ -201,6 +223,7 @@ function App() {
|
|||||||
<ul className="space-y-1 text-xs">
|
<ul className="space-y-1 text-xs">
|
||||||
<li>• Lundi à vendredi uniquement</li>
|
<li>• Lundi à vendredi uniquement</li>
|
||||||
<li>• Description optionnelle</li>
|
<li>• Description optionnelle</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -249,7 +272,9 @@ function App() {
|
|||||||
{!loading && timeEntries.length === 0 && (
|
{!loading && timeEntries.length === 0 && (
|
||||||
<div className="bg-white rounded-2xl shadow-lg p-4 sm:p-6 border border-gray-100 text-center">
|
<div className="bg-white rounded-2xl shadow-lg p-4 sm:p-6 border border-gray-100 text-center">
|
||||||
<h3 className="text-lg font-semibold text-gray-800 mb-2">Aucune déclaration</h3>
|
<h3 className="text-lg font-semibold text-gray-800 mb-2">Aucune déclaration</h3>
|
||||||
<p className="text-sm text-gray-600 mb-4">Commencez par déclarer vos premières heures</p>
|
<p className="text-sm text-gray-600 mb-4">
|
||||||
|
Commencez par déclarer vos premières heures pour {user.prenom}
|
||||||
|
</p>
|
||||||
<button
|
<button
|
||||||
onClick={() => handleDateClick(new Date().toISOString().split('T')[0])}
|
onClick={() => handleDateClick(new Date().toISOString().split('T')[0])}
|
||||||
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
|
||||||
@@ -268,6 +293,7 @@ function App() {
|
|||||||
<p>• Cliquez sur une date pour déclarer vos heures</p>
|
<p>• Cliquez sur une date pour déclarer vos heures</p>
|
||||||
<p>• Choisissez entre préparation ou correction</p>
|
<p>• Choisissez entre préparation ou correction</p>
|
||||||
<p>• Description optionnelle mais recommandée</p>
|
<p>• Description optionnelle mais recommandée</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { ChevronLeft, ChevronRight, Clock, Plus } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, Clock } from 'lucide-react';
|
||||||
import { TimeEntry } from '../types/TimeEntry';
|
import { TimeEntry } from '../types/TimeEntry';
|
||||||
|
|
||||||
interface Declaration {
|
interface Declaration {
|
||||||
@@ -14,6 +14,7 @@ interface Declaration {
|
|||||||
interface CalendarProps {
|
interface CalendarProps {
|
||||||
onDateClick: (date: string) => void;
|
onDateClick: (date: string) => void;
|
||||||
getEntryForDate: (date: string) => TimeEntry | undefined;
|
getEntryForDate: (date: string) => TimeEntry | undefined;
|
||||||
|
currentUserId?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const activityTypeColors = {
|
const activityTypeColors = {
|
||||||
@@ -45,14 +46,14 @@ const Calendar: React.FC<CalendarProps> = ({ onDateClick, getEntryForDate }) =>
|
|||||||
.catch((err) => console.error("Erreur fetch:", err));
|
.catch((err) => console.error("Erreur fetch:", err));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Fonction de sauvegarde d'une déclaration (à utiliser selon besoin)
|
// Fonction de sauvegarde d'une déclaration
|
||||||
const saveDeclaration = async (newDeclaration: Declaration) => {
|
const saveDeclaration = async (newDeclaration: Declaration) => {
|
||||||
const res = await fetch("http://localhost:3001/api/get_declarations", {
|
const res = await fetch("http://localhost:3001/api/get_declarations", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(newDeclaration),
|
body: JSON.stringify(newDeclaration),
|
||||||
});
|
});
|
||||||
// Traiter le retour selon besoin
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMonthData = () => {
|
const getMonthData = () => {
|
||||||
@@ -174,22 +175,20 @@ const Calendar: React.FC<CalendarProps> = ({ onDateClick, getEntryForDate }) =>
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
key={di}
|
key={di}
|
||||||
onClick={() => !day.isPastDate && day.isCurrentMonth && onDateClick(day.dateString)}
|
onClick={() => day.isCurrentMonth && onDateClick(day.dateString)}
|
||||||
className={`
|
className={`
|
||||||
relative rounded-lg sm:rounded-xl border-2 transition-all duration-200 p-2 sm:p-3 h-16 sm:h-20
|
relative rounded-lg sm:rounded-xl border-2 transition-all duration-200 p-2 sm:p-3 h-16 sm:h-20
|
||||||
${day.isCurrentMonth
|
${day.isCurrentMonth
|
||||||
? day.isPastDate
|
? `${borderClass} ${bgClass} hover:border-blue-300 hover:shadow-md cursor-pointer`
|
||||||
? 'border-gray-200 bg-gray-100 text-gray-400 cursor-not-allowed'
|
|
||||||
: `${borderClass} ${bgClass} hover:border-blue-300 hover:shadow-md cursor-pointer`
|
|
||||||
: 'border-gray-100 bg-gray-50 cursor-not-allowed opacity-40'
|
: 'border-gray-100 bg-gray-50 cursor-not-allowed opacity-40'
|
||||||
}
|
}
|
||||||
${day.isToday ? 'ring-2 ring-blue-500 bg-blue-50' : ''}
|
${day.isToday ? 'ring-2 ring-blue-500 bg-blue-50' : ''}
|
||||||
`}
|
`}
|
||||||
disabled={day.isPastDate || !day.isCurrentMonth}
|
disabled={!day.isCurrentMonth}
|
||||||
>
|
>
|
||||||
{day.isCurrentMonth && day.date && (
|
{day.isCurrentMonth && day.date && (
|
||||||
<div className="flex flex-col h-full justify-between items-center">
|
<div className="flex flex-col h-full justify-between items-center">
|
||||||
<div className={`text-xs sm:text-sm font-medium ${day.isToday ? 'text-blue-600' : day.isPastDate ? 'text-gray-400' : 'text-gray-700'}`}>
|
<div className={`text-xs sm:text-sm font-medium ${day.isToday ? 'text-blue-600' : 'text-gray-700'}`}>
|
||||||
{day.date.getDate()}
|
{day.date.getDate()}
|
||||||
</div>
|
</div>
|
||||||
{day.hasEntry && (
|
{day.hasEntry && (
|
||||||
|
|||||||
@@ -19,18 +19,19 @@ const TimeEntryModal: React.FC<TimeEntryModalProps> = ({
|
|||||||
const [activityType, setActivityType] = useState<'preparation' | 'correction'>('preparation');
|
const [activityType, setActivityType] = useState<'preparation' | 'correction'>('preparation');
|
||||||
const [hours, setHours] = useState<number>(0);
|
const [hours, setHours] = useState<number>(0);
|
||||||
const [description, setDescription] = useState('');
|
const [description, setDescription] = useState('');
|
||||||
|
const [startTime, setStartTime] = useState('');
|
||||||
|
const [endTime, setEndTime] = useState('');
|
||||||
const [errors, setErrors] = useState<string[]>([]);
|
const [errors, setErrors] = useState<string[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const { user, isAuthorized } = useAuth();
|
const { user, isAuthorized } = useAuth();
|
||||||
|
|
||||||
console.log('DEBUG AUTH:', { user, isAuthorized });
|
|
||||||
console.log('user est:', typeof user, user);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (existingEntry) {
|
if (existingEntry) {
|
||||||
setActivityType(existingEntry.activityType);
|
setActivityType(existingEntry.activityType);
|
||||||
setHours(existingEntry.hours);
|
setHours(existingEntry.hours);
|
||||||
setDescription(existingEntry.description);
|
setDescription(existingEntry.description);
|
||||||
|
setStartTime(existingEntry.startTime ?? '');
|
||||||
|
setEndTime(existingEntry.endTime ?? '');
|
||||||
}
|
}
|
||||||
}, [existingEntry]);
|
}, [existingEntry]);
|
||||||
|
|
||||||
@@ -43,6 +44,34 @@ const TimeEntryModal: React.FC<TimeEntryModalProps> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Calcule la différence en heures entre start et end (format "HH:mm")
|
||||||
|
const calculateHours = (start: string, end: string): number => {
|
||||||
|
if (!start || !end) return 0;
|
||||||
|
const dateRef = '2000-01-01T';
|
||||||
|
let startDate = new Date(dateRef + start);
|
||||||
|
let endDate = new Date(dateRef + end);
|
||||||
|
// Si fin avant début, on considère passage au lendemain
|
||||||
|
if (endDate <= startDate) {
|
||||||
|
endDate.setDate(endDate.getDate() + 1);
|
||||||
|
}
|
||||||
|
const diffMs = endDate.getTime() - startDate.getTime();
|
||||||
|
return Math.round((diffMs / (1000 * 60 * 60)) * 10) / 10; // arrondi au 0.1 h près
|
||||||
|
};
|
||||||
|
|
||||||
|
// Gère changement heure début
|
||||||
|
const handleStartTimeChange = (value: string) => {
|
||||||
|
setStartTime(value);
|
||||||
|
const newHours = calculateHours(value, endTime);
|
||||||
|
setHours(newHours);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Gère changement heure fin
|
||||||
|
const handleEndTimeChange = (value: string) => {
|
||||||
|
setEndTime(value);
|
||||||
|
const newHours = calculateHours(startTime, value);
|
||||||
|
setHours(newHours);
|
||||||
|
};
|
||||||
|
|
||||||
const validateForm = (): boolean => {
|
const validateForm = (): boolean => {
|
||||||
const newErrors: string[] = [];
|
const newErrors: string[] = [];
|
||||||
if (hours < 0.5 || hours > 8) {
|
if (hours < 0.5 || hours > 8) {
|
||||||
@@ -51,6 +80,20 @@ const TimeEntryModal: React.FC<TimeEntryModalProps> = ({
|
|||||||
if (description.trim() && description.trim().length < 10) {
|
if (description.trim() && description.trim().length < 10) {
|
||||||
newErrors.push('Si fournie, la description doit contenir au moins 10 caractères');
|
newErrors.push('Si fournie, la description doit contenir au moins 10 caractères');
|
||||||
}
|
}
|
||||||
|
if (!startTime) {
|
||||||
|
newErrors.push("L'heure de début est obligatoire");
|
||||||
|
}
|
||||||
|
if (!endTime) {
|
||||||
|
newErrors.push("L'heure de fin est obligatoire");
|
||||||
|
}
|
||||||
|
if (startTime && endTime && startTime >= endTime) {
|
||||||
|
// Permet à endTime d'être le lendemain, donc ce contrôle est à adapter,
|
||||||
|
// mais thème validation simple ici:
|
||||||
|
const diff = calculateHours(startTime, endTime);
|
||||||
|
if (diff <= 0) {
|
||||||
|
newErrors.push("L'heure de fin doit être après l'heure de début");
|
||||||
|
}
|
||||||
|
}
|
||||||
setErrors(newErrors);
|
setErrors(newErrors);
|
||||||
return newErrors.length === 0;
|
return newErrors.length === 0;
|
||||||
};
|
};
|
||||||
@@ -58,7 +101,6 @@ const TimeEntryModal: React.FC<TimeEntryModalProps> = ({
|
|||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!validateForm()) return;
|
if (!validateForm()) return;
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setErrors([]);
|
setErrors([]);
|
||||||
const entry: TimeEntry = {
|
const entry: TimeEntry = {
|
||||||
@@ -66,26 +108,22 @@ const TimeEntryModal: React.FC<TimeEntryModalProps> = ({
|
|||||||
activityType,
|
activityType,
|
||||||
hours,
|
hours,
|
||||||
description: description.trim(),
|
description: description.trim(),
|
||||||
createdAt: new Date()
|
startTime,
|
||||||
|
endTime,
|
||||||
|
createdAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('Utilisateur connecté:', user);
|
|
||||||
console.log('Données à envoyer:', {
|
|
||||||
...entry,
|
|
||||||
user: user
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const response = await fetch("http://localhost:3001/api/save_declaration", {
|
const response = await fetch("http://localhost:3001/api/save_declaration", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
date: date,
|
date,
|
||||||
activityType: activityType,
|
activityType,
|
||||||
hours: hours,
|
hours,
|
||||||
description: description.trim(),
|
description: description.trim(),
|
||||||
user: user
|
startTime,
|
||||||
|
endTime,
|
||||||
|
user,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -192,30 +230,47 @@ const TimeEntryModal: React.FC<TimeEntryModalProps> = ({
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* Nombre d'heures */}
|
{/* Heure de début */}
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||||
Nombre d'heures <span className="text-red-500">*</span>
|
Heure de début <span className="text-red-500">*</span>
|
||||||
</label>
|
</label>
|
||||||
<div className="relative">
|
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="time"
|
||||||
min="0.5"
|
value={startTime}
|
||||||
max="8"
|
onChange={e => handleStartTimeChange(e.target.value)}
|
||||||
step="0.5"
|
|
||||||
value={hours || ''}
|
|
||||||
onChange={(e) => setHours(parseFloat(e.target.value) || 0)}
|
|
||||||
className="w-full pl-4 pr-20 py-3 border-2 border-gray-300 rounded-xl focus:border-blue-500 focus:ring-0 transition-colors text-base"
|
|
||||||
placeholder="0"
|
|
||||||
required
|
required
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
|
className="w-full p-3 border-2 border-gray-300 rounded-xl focus:border-blue-500"
|
||||||
/>
|
/>
|
||||||
<div className="absolute right-3 top-3 text-gray-500 text-sm">
|
|
||||||
heures
|
|
||||||
</div>
|
</div>
|
||||||
|
{/* Heure de fin */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||||
|
Heure de fin <span className="text-red-500">*</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="time"
|
||||||
|
value={endTime}
|
||||||
|
onChange={e => handleEndTimeChange(e.target.value)}
|
||||||
|
required
|
||||||
|
disabled={loading}
|
||||||
|
className="w-full p-3 border-2 border-gray-300 rounded-xl focus:border-blue-500"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{/* Nombre d'heures calculé */}
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||||
|
Nombre d'heures
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={hours}
|
||||||
|
readOnly
|
||||||
|
className="w-full p-3 border-2 border-gray-300 rounded-xl bg-gray-100 cursor-not-allowed"
|
||||||
|
/>
|
||||||
<p className="text-xs text-gray-500 mt-2">
|
<p className="text-xs text-gray-500 mt-2">
|
||||||
Maximum 8 heures par jour (par tranches de 0.5h)
|
Calculé automatiquement à partir de l'heure de début et de fin
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{/* Description */}
|
{/* Description */}
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { User, Mail, Calendar, Clock, Award } from 'lucide-react';
|
import { User, Mail, Calendar, Clock, Award,AlertTriangle } from 'lucide-react';
|
||||||
|
|
||||||
interface UserProfileProps {
|
interface UserProfileProps {
|
||||||
user: {
|
user: {
|
||||||
name: string;
|
id?: number;
|
||||||
|
nom: string;
|
||||||
|
prenom: string;
|
||||||
email: string;
|
email: string;
|
||||||
department: string;
|
department?: string;
|
||||||
role: string;
|
role?: string;
|
||||||
joinDate: string;
|
joinDate?: string;
|
||||||
};
|
};
|
||||||
totalHours: number;
|
totalHours: number;
|
||||||
totalEntries: number;
|
totalEntries: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const UserProfile: React.FC<UserProfileProps> = ({ user, totalHours, totalEntries }) => {
|
||||||
|
// Valeurs par défaut si les données manquent
|
||||||
|
|
||||||
|
const role ='Formateur';
|
||||||
|
const joinDate = user.joinDate || new Date().getFullYear().toString();
|
||||||
|
|
||||||
const UserProfile: React.FC<UserProfileProps> = ({ user, totalHours, totalEntries }) => {
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white rounded-2xl shadow-lg border border-gray-100 overflow-hidden">
|
<div className="bg-white rounded-2xl shadow-lg border border-gray-100 overflow-hidden">
|
||||||
<div className="bg-[#198ab4] p-4 sm:p-6">
|
<div className="bg-[#198ab4] p-4 sm:p-6">
|
||||||
@@ -27,8 +32,8 @@ interface UserProfileProps {
|
|||||||
<h2 className="text-xl sm:text-2xl font-bold text-white">
|
<h2 className="text-xl sm:text-2xl font-bold text-white">
|
||||||
{user.prenom} {user.nom}
|
{user.prenom} {user.nom}
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-blue-100 text-sm sm:text-base">{user.role}</p>
|
<p className="text-blue-100 text-sm sm:text-base">{role}</p>
|
||||||
<p className="text-blue-200 text-xs sm:text-sm">{user.department}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,14 +48,15 @@ interface UserProfileProps {
|
|||||||
<p className="text-sm font-medium text-gray-800 truncate">{user.email}</p>
|
<p className="text-sm font-medium text-gray-800 truncate">{user.email}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-3 p-3 bg-gray-50 rounded-lg">
|
<div className="flex items-center gap-3 p-3 bg-gray-50 rounded-lg">
|
||||||
<Calendar className="h-5 w-5 text-gray-600 flex-shrink-0" />
|
<Calendar className="h-5 w-5 text-gray-600 flex-shrink-0" />
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="text-xs text-gray-500">Depuis</p>
|
<p className="text-xs text-gray-500">Depuis</p>
|
||||||
<p className="text-sm font-medium text-gray-800">{user.joinDate}</p>
|
<p className="text-sm font-medium text-gray-800">{joinDate}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Statistiques */}
|
{/* Statistiques */}
|
||||||
@@ -67,6 +73,9 @@ interface UserProfileProps {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { loginRequest } from "../Authconfig";
|
|||||||
|
|
||||||
// Type utilisateur
|
// Type utilisateur
|
||||||
type UserType = {
|
type UserType = {
|
||||||
|
id?: number;
|
||||||
prenom: string;
|
prenom: string;
|
||||||
nom: string;
|
nom: string;
|
||||||
email: string;
|
email: string;
|
||||||
@@ -71,13 +72,11 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
|||||||
// -----------------------------
|
// -----------------------------
|
||||||
const loginWithO365 = async () => {
|
const loginWithO365 = async () => {
|
||||||
try {
|
try {
|
||||||
// Popup login pour Microsoft
|
|
||||||
const loginResponse = await msalInstance.loginPopup(loginRequest);
|
const loginResponse = await msalInstance.loginPopup(loginRequest);
|
||||||
const account = loginResponse.account;
|
const account = loginResponse.account;
|
||||||
|
|
||||||
if (!account) throw new Error("Aucun compte récupéré");
|
if (!account) throw new Error("Aucun compte récupéré");
|
||||||
|
|
||||||
// Récupérer le token via acquireTokenSilent
|
|
||||||
const tokenResponse = await msalInstance.acquireTokenSilent({
|
const tokenResponse = await msalInstance.acquireTokenSilent({
|
||||||
...loginRequest,
|
...loginRequest,
|
||||||
account
|
account
|
||||||
@@ -85,16 +84,43 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
|||||||
|
|
||||||
const accessToken = tokenResponse.accessToken;
|
const accessToken = tokenResponse.accessToken;
|
||||||
|
|
||||||
// Récupérer profil Microsoft Graph
|
|
||||||
const graphRes = await fetch("https://graph.microsoft.com/v1.0/me", {
|
const graphRes = await fetch("https://graph.microsoft.com/v1.0/me", {
|
||||||
headers: { Authorization: `Bearer ${accessToken}` }
|
headers: { Authorization: `Bearer ${accessToken}` }
|
||||||
});
|
});
|
||||||
const graphData = await graphRes.json();
|
const graphData = await graphRes.json();
|
||||||
|
|
||||||
|
// NOUVEAU : Récupérer ou créer l'utilisateur dans la base
|
||||||
|
const userEmail = graphData.mail || account.username;
|
||||||
|
|
||||||
|
const formateurResponse = await fetch(`http://localhost:3001/api/formateurs?email=${userEmail}`);
|
||||||
|
const formateurData = await formateurResponse.json();
|
||||||
|
|
||||||
|
let formateurId;
|
||||||
|
if (formateurData.success && formateurData.data.length > 0) {
|
||||||
|
// Utilisateur existe
|
||||||
|
formateurId = formateurData.data[0].NUMERO;
|
||||||
|
} else {
|
||||||
|
// Créer l'utilisateur (vous devrez ajouter cette route)
|
||||||
|
const createResponse = await fetch("http://localhost:3001/api/create_formateur", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
nom: graphData.surname || account.name?.split(" ")[1] || "",
|
||||||
|
prenom: graphData.givenName || account.name?.split(" ")[0] || "",
|
||||||
|
email: userEmail,
|
||||||
|
department: graphData.department,
|
||||||
|
role: "Employe"
|
||||||
|
})
|
||||||
|
});
|
||||||
|
const createData = await createResponse.json();
|
||||||
|
formateurId = createData.formateurId;
|
||||||
|
}
|
||||||
|
|
||||||
const o365User: UserType = {
|
const o365User: UserType = {
|
||||||
|
id: formateurId, // AJOUT IMPORTANT
|
||||||
prenom: graphData.givenName || account.name?.split(" ")[0] || "",
|
prenom: graphData.givenName || account.name?.split(" ")[0] || "",
|
||||||
nom: graphData.surname || account.name?.split(" ")[1] || "",
|
nom: graphData.surname || account.name?.split(" ")[1] || "",
|
||||||
email: graphData.mail || account.username,
|
email: userEmail,
|
||||||
jobTitle: graphData.jobTitle,
|
jobTitle: graphData.jobTitle,
|
||||||
department: graphData.department,
|
department: graphData.department,
|
||||||
officeLocation: graphData.officeLocation,
|
officeLocation: graphData.officeLocation,
|
||||||
@@ -109,9 +135,9 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
|
|||||||
return true;
|
return true;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("Erreur login O365:", error);
|
console.error("Erreur login O365:", error);
|
||||||
return false; // le composant Login affichera l'erreur
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// LOGOUT
|
// LOGOUT
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export interface TimeEntry {
|
export interface TimeEntry {
|
||||||
|
startTime: string;
|
||||||
|
endTime: string;
|
||||||
date: string;
|
date: string;
|
||||||
activityType: 'preparation' | 'correction';
|
activityType: 'preparation' | 'correction';
|
||||||
hours: number;
|
hours: number;
|
||||||
|
|||||||
25
node_modules/.package-lock.json
generated
vendored
Normal file
25
node_modules/.package-lock.json
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "GTF_GIT",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"node_modules/node-cron": {
|
||||||
|
"version": "4.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.2.1.tgz",
|
||||||
|
"integrity": "sha512-lgimEHPE/QDgFlywTd8yTR61ptugX3Qer29efeyWw2rv259HtGBNn1vZVmp8lB9uo9wC0t/AT4iGqXxia+CJFg==",
|
||||||
|
"license": "ISC",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/nodemailer": {
|
||||||
|
"version": "7.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-7.0.6.tgz",
|
||||||
|
"integrity": "sha512-F44uVzgwo49xboqbFgBGkRaiMgtoBrBEWCVincJPK9+S9Adkzt/wXCLKbf7dxucmxfTI5gHGB+bEmdyzN6QKjw==",
|
||||||
|
"license": "MIT-0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
node_modules/node-cron/LICENSE.md
generated
vendored
Normal file
7
node_modules/node-cron/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
## ISC License
|
||||||
|
|
||||||
|
Copyright (c) 2016, Lucas Merencia \<lucas.merencia@gmail.com\>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
117
node_modules/node-cron/README.md
generated
vendored
Normal file
117
node_modules/node-cron/README.md
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
# Node Cron
|
||||||
|
|
||||||
|
[](https://github.com/merencia/node-cron/blob/master/LICENSE.md)
|
||||||
|
[](https://img.shields.io/npm/v/node-cron.svg)
|
||||||
|

|
||||||
|
[](https://coveralls.io/github/node-cron/node-cron?branch=main)
|
||||||
|
|
||||||
|
The node-cron module is tiny task scheduler in pure JavaScript for node.js based on [GNU crontab](https://www.gnu.org/software/mcron/manual/html_node/Crontab-file.html). This module allows you to schedule task in node.js using full crontab syntax.
|
||||||
|
|
||||||
|
### [Node-Cron Documentation](http://nodecron.com)
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Install node-cron using npm:
|
||||||
|
|
||||||
|
```console
|
||||||
|
npm install --save node-cron
|
||||||
|
```
|
||||||
|
|
||||||
|
Import node-cron and schedule a task:
|
||||||
|
|
||||||
|
- commonjs
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const cron = require('node-cron');
|
||||||
|
|
||||||
|
cron.schedule('* * * * *', () => {
|
||||||
|
console.log('running a task every minute');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
- es6 (module)
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import cron from 'node-cron';
|
||||||
|
|
||||||
|
cron.schedule('* * * * *', () => {
|
||||||
|
console.log('running a task every minute');
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cron Syntax
|
||||||
|
|
||||||
|
This is a quick reference to cron syntax and also shows the options supported by node-cron.
|
||||||
|
|
||||||
|
### Allowed fields
|
||||||
|
|
||||||
|
```
|
||||||
|
# ┌────────────── second (optional)
|
||||||
|
# │ ┌──────────── minute
|
||||||
|
# │ │ ┌────────── hour
|
||||||
|
# │ │ │ ┌──────── day of month
|
||||||
|
# │ │ │ │ ┌────── month
|
||||||
|
# │ │ │ │ │ ┌──── day of week
|
||||||
|
# │ │ │ │ │ │
|
||||||
|
# │ │ │ │ │ │
|
||||||
|
# * * * * * *
|
||||||
|
```
|
||||||
|
|
||||||
|
### Allowed values
|
||||||
|
|
||||||
|
| field | value |
|
||||||
|
| ------------ | --------------------------------- |
|
||||||
|
| second | 0-59 |
|
||||||
|
| minute | 0-59 |
|
||||||
|
| hour | 0-23 |
|
||||||
|
| day of month | 1-31 |
|
||||||
|
| month | 1-12 (or names) |
|
||||||
|
| day of week | 0-7 (or names, 0 or 7 are sunday) |
|
||||||
|
|
||||||
|
|
||||||
|
## Issues
|
||||||
|
|
||||||
|
Feel free to submit issues and enhancement requests [here](https://github.com/merencia/node-cron/issues).
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
In general, we follow the "fork-and-pull" Git workflow.
|
||||||
|
|
||||||
|
- Fork the repo on GitHub;
|
||||||
|
- Commit changes to a branch in your fork;
|
||||||
|
- Pull request "upstream" with your changes;
|
||||||
|
|
||||||
|
NOTE: Be sure to merge the latest from "upstream" before making a pull request!
|
||||||
|
|
||||||
|
Please do not contribute code you did not write yourself, unless you are certain you have the legal ability to do so. Also ensure all contributed code can be distributed under the ISC License.
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
This project exists thanks to all the people who contribute.
|
||||||
|
<a href="https://github.com/node-cron/node-cron/graphs/contributors"><img src="https://opencollective.com/node-cron/contributors.svg?width=890&button=false" /></a>
|
||||||
|
|
||||||
|
|
||||||
|
## Backers
|
||||||
|
|
||||||
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/node-cron#backer)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/node-cron#backers" target="_blank"><img src="https://opencollective.com/node-cron/backers.svg?width=890"></a>
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
|
||||||
|
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/node-cron#sponsor)]
|
||||||
|
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/0/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/0/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/1/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/1/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/2/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/2/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/3/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/3/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/4/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/4/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/5/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/5/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/6/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/6/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/7/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/7/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/8/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/8/avatar.svg"></a>
|
||||||
|
<a href="https://opencollective.com/node-cron/sponsor/9/website" target="_blank"><img src="https://opencollective.com/node-cron/sponsor/9/avatar.svg"></a>
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
node-cron is under [ISC License](https://github.com/merencia/node-cron/blob/master/LICENSE.md).
|
||||||
1
node_modules/node-cron/dist/cjs/create-id.d.ts
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/create-id.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export declare function createID(prefix?: string, length?: number): string;
|
||||||
14
node_modules/node-cron/dist/cjs/create-id.js
generated
vendored
Normal file
14
node_modules/node-cron/dist/cjs/create-id.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.createID = createID;
|
||||||
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
||||||
|
function createID(prefix = '', length = 16) {
|
||||||
|
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const values = node_crypto_1.default.randomBytes(length);
|
||||||
|
const id = Array.from(values, v => charset[v % charset.length]).join('');
|
||||||
|
return prefix ? `${prefix}-${id}` : id;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=create-id.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/create-id.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/create-id.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"create-id.js","sourceRoot":"","sources":["../../src/create-id.ts"],"names":[],"mappings":";;;;;AAEA,4BAKC;AAPD,8DAAiC;AAEjC,SAAgB,QAAQ,CAAC,SAAiB,EAAE,EAAE,SAAiB,EAAE;IAC/D,MAAM,OAAO,GAAG,gEAAgE,CAAC;IACjF,MAAM,MAAM,GAAG,qBAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC"}
|
||||||
7
node_modules/node-cron/dist/cjs/logger.d.ts
generated
vendored
Normal file
7
node_modules/node-cron/dist/cjs/logger.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
declare const logger: {
|
||||||
|
info(message: string): void;
|
||||||
|
warn(message: string): void;
|
||||||
|
error(message: string | Error, err?: Error): void;
|
||||||
|
debug(message: string | Error, err?: Error): void;
|
||||||
|
};
|
||||||
|
export default logger;
|
||||||
57
node_modules/node-cron/dist/cjs/logger.js
generated
vendored
Normal file
57
node_modules/node-cron/dist/cjs/logger.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const levelColors = {
|
||||||
|
INFO: '\x1b[36m',
|
||||||
|
WARN: '\x1b[33m',
|
||||||
|
ERROR: '\x1b[31m',
|
||||||
|
DEBUG: '\x1b[35m',
|
||||||
|
};
|
||||||
|
const GREEN = '\x1b[32m';
|
||||||
|
const RESET = '\x1b[0m';
|
||||||
|
function log(level, message, extra) {
|
||||||
|
const timestamp = new Date().toISOString();
|
||||||
|
const color = levelColors[level] ?? '';
|
||||||
|
const prefix = `[${timestamp}] [PID: ${process.pid}] ${GREEN}[NODE-CRON]${GREEN} ${color}[${level}]${RESET}`;
|
||||||
|
const output = `${prefix} ${message}`;
|
||||||
|
switch (level) {
|
||||||
|
case 'ERROR':
|
||||||
|
console.error(output, extra ?? '');
|
||||||
|
break;
|
||||||
|
case 'DEBUG':
|
||||||
|
console.debug(output, extra ?? '');
|
||||||
|
break;
|
||||||
|
case 'WARN':
|
||||||
|
console.warn(output);
|
||||||
|
break;
|
||||||
|
case 'INFO':
|
||||||
|
default:
|
||||||
|
console.info(output);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const logger = {
|
||||||
|
info(message) {
|
||||||
|
log('INFO', message);
|
||||||
|
},
|
||||||
|
warn(message) {
|
||||||
|
log('WARN', message);
|
||||||
|
},
|
||||||
|
error(message, err) {
|
||||||
|
if (message instanceof Error) {
|
||||||
|
log('ERROR', message.message, message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log('ERROR', message, err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
debug(message, err) {
|
||||||
|
if (message instanceof Error) {
|
||||||
|
log('DEBUG', message.message, message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log('DEBUG', message, err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = logger;
|
||||||
|
//# sourceMappingURL=logger.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/logger.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/logger.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;AAEA,MAAM,WAAW,GAA6B;IAC5C,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,KAAK,GAAG,SAAS,CAAC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AAC;IACH,CAAC;IACD,KAAK,CAAC,OAAuB,EAAE,GAAW;QACxC,IAAI,OAAO,YAAY,KAAK,EAAE,CAAC;YAC7B,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
||||||
18
node_modules/node-cron/dist/cjs/node-cron.d.ts
generated
vendored
Normal file
18
node_modules/node-cron/dist/cjs/node-cron.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { ScheduledTask, TaskFn, TaskOptions } from "./tasks/scheduled-task";
|
||||||
|
export declare function schedule(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
|
||||||
|
export declare function createTask(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
|
||||||
|
export declare function solvePath(filePath: string): string;
|
||||||
|
export declare function validate(expression: string): boolean;
|
||||||
|
export declare const getTasks: () => Map<string, ScheduledTask>;
|
||||||
|
export declare const getTask: (taskId: string) => ScheduledTask | undefined;
|
||||||
|
export { ScheduledTask } from './tasks/scheduled-task';
|
||||||
|
export type { TaskFn, TaskContext, TaskOptions } from './tasks/scheduled-task';
|
||||||
|
export interface NodeCron {
|
||||||
|
schedule: typeof schedule;
|
||||||
|
createTask: typeof createTask;
|
||||||
|
validate: typeof validate;
|
||||||
|
getTasks: typeof getTasks;
|
||||||
|
getTask: typeof getTask;
|
||||||
|
}
|
||||||
|
export declare const nodeCron: NodeCron;
|
||||||
|
export default nodeCron;
|
||||||
71
node_modules/node-cron/dist/cjs/node-cron.js
generated
vendored
Normal file
71
node_modules/node-cron/dist/cjs/node-cron.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.nodeCron = exports.getTask = exports.getTasks = void 0;
|
||||||
|
exports.schedule = schedule;
|
||||||
|
exports.createTask = createTask;
|
||||||
|
exports.solvePath = solvePath;
|
||||||
|
exports.validate = validate;
|
||||||
|
const inline_scheduled_task_1 = require("./tasks/inline-scheduled-task");
|
||||||
|
const task_registry_1 = require("./task-registry");
|
||||||
|
const pattern_validation_1 = __importDefault(require("./pattern/validation/pattern-validation"));
|
||||||
|
const background_scheduled_task_1 = __importDefault(require("./tasks/background-scheduled-task/background-scheduled-task"));
|
||||||
|
const path_1 = __importDefault(require("path"));
|
||||||
|
const url_1 = require("url");
|
||||||
|
const registry = new task_registry_1.TaskRegistry();
|
||||||
|
function schedule(expression, func, options) {
|
||||||
|
const task = createTask(expression, func, options);
|
||||||
|
task.start();
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
function createTask(expression, func, options) {
|
||||||
|
let task;
|
||||||
|
if (func instanceof Function) {
|
||||||
|
task = new inline_scheduled_task_1.InlineScheduledTask(expression, func, options);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const taskPath = solvePath(func);
|
||||||
|
task = new background_scheduled_task_1.default(expression, taskPath, options);
|
||||||
|
}
|
||||||
|
registry.add(task);
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
function solvePath(filePath) {
|
||||||
|
if (path_1.default.isAbsolute(filePath))
|
||||||
|
return (0, url_1.pathToFileURL)(filePath).href;
|
||||||
|
if (filePath.startsWith('file://'))
|
||||||
|
return filePath;
|
||||||
|
const stackLines = new Error().stack?.split('\n');
|
||||||
|
if (stackLines) {
|
||||||
|
stackLines?.shift();
|
||||||
|
const callerLine = stackLines?.find((line) => { return line.indexOf(__filename) === -1; });
|
||||||
|
const match = callerLine?.match(/(file:\/\/)?(((\/?)(\w:))?([/\\].+)):\d+:\d+/);
|
||||||
|
if (match) {
|
||||||
|
const dir = `${match[5] ?? ""}${path_1.default.dirname(match[6])}`;
|
||||||
|
return (0, url_1.pathToFileURL)(path_1.default.resolve(dir, filePath)).href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(`Could not locate task file ${filePath}`);
|
||||||
|
}
|
||||||
|
function validate(expression) {
|
||||||
|
try {
|
||||||
|
(0, pattern_validation_1.default)(expression);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.getTasks = registry.all;
|
||||||
|
exports.getTask = registry.get;
|
||||||
|
exports.nodeCron = {
|
||||||
|
schedule,
|
||||||
|
createTask,
|
||||||
|
validate,
|
||||||
|
getTasks: exports.getTasks,
|
||||||
|
getTask: exports.getTask,
|
||||||
|
};
|
||||||
|
exports.default = exports.nodeCron;
|
||||||
|
//# sourceMappingURL=node-cron.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/node-cron.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/node-cron.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"node-cron.js","sourceRoot":"","sources":["../../src/node-cron.ts"],"names":[],"mappings":";;;;;;AA2CA,4BAIC;AAWD,gCAWC;AAUD,8BAoBC;AAQD,4BASC;AA1GD,yEAAoE;AAEpE,mDAA+C;AAE/C,iGAAiE;AACjE,4HAAkG;AAElG,gDAAwB;AACxB,6BAAoC;AAMpC,MAAM,QAAQ,GAAG,IAAI,4BAAY,EAAE,CAAC;AAmBpC,SAAgB,QAAQ,CAAC,UAAiB,EAAE,IAAqB,EAAE,OAAqB;IACpF,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,OAAO,IAAI,CAAC;AAChB,CAAC;AAWD,SAAgB,UAAU,CAAC,UAAkB,EAAE,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AAa,EAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;QACzD,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,EAAE,CAAC,CAAC;AAC5D,CAAC;AAQD,SAAgB,QAAQ,CAAC,UAAkB;IACzC,IAAI,CAAC;QACD,IAAA,4BAAU,EAAC,UAAU,CAAC,CAAC;QAEvB,OAAO,IAAI,CAAC;IAEhB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC;AAOY,QAAA,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC;AAQxB,QAAA,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC;AAavB,QAAA,QAAQ,GAAa;IAChC,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,QAAQ,EAAR,gBAAQ;IACR,OAAO,EAAP,eAAO;CACR,CAAC;AAKF,kBAAe,gBAAQ,CAAC"}
|
||||||
2
node_modules/node-cron/dist/cjs/pattern/convertion/asterisk-to-range-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/pattern/convertion/asterisk-to-range-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expressions: any) => any;
|
||||||
|
export default _default;
|
||||||
21
node_modules/node-cron/dist/cjs/pattern/convertion/asterisk-to-range-conversion.js
generated
vendored
Normal file
21
node_modules/node-cron/dist/cjs/pattern/convertion/asterisk-to-range-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
function convertAsterisk(expression, replecement) {
|
||||||
|
if (expression.indexOf('*') !== -1) {
|
||||||
|
return expression.replace('*', replecement);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function convertAsterisksToRanges(expressions) {
|
||||||
|
expressions[0] = convertAsterisk(expressions[0], '0-59');
|
||||||
|
expressions[1] = convertAsterisk(expressions[1], '0-59');
|
||||||
|
expressions[2] = convertAsterisk(expressions[2], '0-23');
|
||||||
|
expressions[3] = convertAsterisk(expressions[3], '1-31');
|
||||||
|
expressions[4] = convertAsterisk(expressions[4], '1-12');
|
||||||
|
expressions[5] = convertAsterisk(expressions[5], '0-6');
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
return convertAsterisksToRanges;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=asterisk-to-range-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/pattern/convertion/asterisk-to-range-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/pattern/convertion/asterisk-to-range-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"asterisk-to-range-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/asterisk-to-range-conversion.ts"],"names":[],"mappings":";;AACA,kBAAe,CAAC,GAAG,EAAE;IACjB,SAAS,eAAe,CAAC,UAAU,EAAE,WAAW;QAC5C,IAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAC,CAAC;YAC/B,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,SAAS,wBAAwB,CAAC,WAAW;QACzC,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,OAAO,wBAAwB,CAAC;AACpC,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/cjs/pattern/convertion/index.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/pattern/convertion/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expression: any) => any;
|
||||||
|
export default _default;
|
||||||
42
node_modules/node-cron/dist/cjs/pattern/convertion/index.js
generated
vendored
Normal file
42
node_modules/node-cron/dist/cjs/pattern/convertion/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const month_names_conversion_1 = __importDefault(require("./month-names-conversion"));
|
||||||
|
const week_day_names_conversion_1 = __importDefault(require("./week-day-names-conversion"));
|
||||||
|
const asterisk_to_range_conversion_1 = __importDefault(require("./asterisk-to-range-conversion"));
|
||||||
|
const range_conversion_1 = __importDefault(require("./range-conversion"));
|
||||||
|
exports.default = (() => {
|
||||||
|
function appendSeccondExpression(expressions) {
|
||||||
|
if (expressions.length === 5) {
|
||||||
|
return ['0'].concat(expressions);
|
||||||
|
}
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
function removeSpaces(str) {
|
||||||
|
return str.replace(/\s{2,}/g, ' ').trim();
|
||||||
|
}
|
||||||
|
function normalizeIntegers(expressions) {
|
||||||
|
for (let i = 0; i < expressions.length; i++) {
|
||||||
|
const numbers = expressions[i].split(',');
|
||||||
|
for (let j = 0; j < numbers.length; j++) {
|
||||||
|
numbers[j] = parseInt(numbers[j]);
|
||||||
|
}
|
||||||
|
expressions[i] = numbers;
|
||||||
|
}
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
function interprete(expression) {
|
||||||
|
let expressions = removeSpaces(`${expression}`).split(' ');
|
||||||
|
expressions = appendSeccondExpression(expressions);
|
||||||
|
expressions[4] = (0, month_names_conversion_1.default)(expressions[4]);
|
||||||
|
expressions[5] = (0, week_day_names_conversion_1.default)(expressions[5]);
|
||||||
|
expressions = (0, asterisk_to_range_conversion_1.default)(expressions);
|
||||||
|
expressions = (0, range_conversion_1.default)(expressions);
|
||||||
|
expressions = normalizeIntegers(expressions);
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
return interprete;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/pattern/convertion/index.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/pattern/convertion/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/index.ts"],"names":[],"mappings":";;;;;AAAA,sFAA4D;AAC5D,4FAAiE;AACjE,kGAAsE;AACtE,0EAA+C;AAE/C,kBAAe,CAAC,GAAG,EAAE;IAEjB,SAAS,uBAAuB,CAAC,WAAW;QACxC,IAAG,WAAW,CAAC,MAAM,KAAK,CAAC,EAAC,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,SAAS,YAAY,CAAC,GAAG;QACrB,OAAO,GAAG,CAA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cron/dist/cjs/pattern/convertion/month-names-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/pattern/convertion/month-names-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (monthExpression: any) => any;
|
||||||
|
export default _default;
|
||||||
21
node_modules/node-cron/dist/cjs/pattern/convertion/month-names-conversion.js
generated
vendored
Normal file
21
node_modules/node-cron/dist/cjs/pattern/convertion/month-names-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
const months = ['january', 'february', 'march', 'april', 'may', 'june', 'july',
|
||||||
|
'august', 'september', 'october', 'november', 'december'];
|
||||||
|
const shortMonths = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
|
||||||
|
'sep', 'oct', 'nov', 'dec'];
|
||||||
|
function convertMonthName(expression, items) {
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
expression = expression.replace(new RegExp(items[i], 'gi'), i + 1);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function interprete(monthExpression) {
|
||||||
|
monthExpression = convertMonthName(monthExpression, months);
|
||||||
|
monthExpression = convertMonthName(monthExpression, shortMonths);
|
||||||
|
return monthExpression;
|
||||||
|
}
|
||||||
|
return interprete;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=month-names-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/pattern/convertion/month-names-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/pattern/convertion/month-names-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"month-names-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/month-names-conversion.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,GAAG,EAAE;IACjB,MAAM,MAAM,GAAG,CAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,MAAM,EAAC,MAAM;QACpE,QAAQ,EAAC,WAAW,EAAC,SAAS,EAAC,UAAU,EAAC,UAAU,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QACvE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAEhC,SAAS,gBAAgB,CAAC,UAAU,EAAE,KAAK;QACvC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;YAClC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,SAAS,UAAU,CAAC,eAAe;QAC/B,eAAe,GAAG,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC5D,eAAe,GAAG,gBAAgB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QACjE,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/cjs/pattern/convertion/range-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/pattern/convertion/range-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expressions: any) => any;
|
||||||
|
export default _default;
|
||||||
35
node_modules/node-cron/dist/cjs/pattern/convertion/range-conversion.js
generated
vendored
Normal file
35
node_modules/node-cron/dist/cjs/pattern/convertion/range-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
function replaceWithRange(expression, text, init, end, stepTxt) {
|
||||||
|
const step = parseInt(stepTxt);
|
||||||
|
const numbers = [];
|
||||||
|
let last = parseInt(end);
|
||||||
|
let first = parseInt(init);
|
||||||
|
if (first > last) {
|
||||||
|
last = parseInt(init);
|
||||||
|
first = parseInt(end);
|
||||||
|
}
|
||||||
|
for (let i = first; i <= last; i += step) {
|
||||||
|
numbers.push(i);
|
||||||
|
}
|
||||||
|
return expression.replace(new RegExp(text, 'i'), numbers.join());
|
||||||
|
}
|
||||||
|
function convertRange(expression) {
|
||||||
|
const rangeRegEx = /(\d+)-(\d+)(\/(\d+)|)/;
|
||||||
|
let match = rangeRegEx.exec(expression);
|
||||||
|
while (match !== null && match.length > 0) {
|
||||||
|
expression = replaceWithRange(expression, match[0], match[1], match[2], match[4] || '1');
|
||||||
|
match = rangeRegEx.exec(expression);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function convertAllRanges(expressions) {
|
||||||
|
for (let i = 0; i < expressions.length; i++) {
|
||||||
|
expressions[i] = convertRange(expressions[i]);
|
||||||
|
}
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
return convertAllRanges;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=range-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/pattern/convertion/range-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/pattern/convertion/range-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"range-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/range-conversion.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAE,GAAG,EAAE;IAClB,SAAS,gBAAgB,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAA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CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;YACxC,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC5B,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/cjs/pattern/convertion/week-day-names-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/pattern/convertion/week-day-names-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expression: any) => any;
|
||||||
|
export default _default;
|
||||||
20
node_modules/node-cron/dist/cjs/pattern/convertion/week-day-names-conversion.js
generated
vendored
Normal file
20
node_modules/node-cron/dist/cjs/pattern/convertion/week-day-names-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
const weekDays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
|
||||||
|
'friday', 'saturday'];
|
||||||
|
const shortWeekDays = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
|
||||||
|
function convertWeekDayName(expression, items) {
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
expression = expression.replace(new RegExp(items[i], 'gi'), i);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function convertWeekDays(expression) {
|
||||||
|
expression = expression.replace('7', '0');
|
||||||
|
expression = convertWeekDayName(expression, weekDays);
|
||||||
|
return convertWeekDayName(expression, shortWeekDays);
|
||||||
|
}
|
||||||
|
return convertWeekDays;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=week-day-names-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/pattern/convertion/week-day-names-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/pattern/convertion/week-day-names-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"week-day-names-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/week-day-names-conversion.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,GAAG,EAAE;IACjB,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU;QACpE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC1B,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAExE,SAAS,kBAAkB,CAAC,UAAU,EAAE,KAAK;QACzC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;YAClC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,SAAS,eAAe,CAAC,UAAU;QAC/B,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,UAAU,GAAG,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACtD,OAAO,kBAAkB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/cjs/pattern/validation/pattern-validation.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/pattern/validation/pattern-validation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare function validate(pattern: any): void;
|
||||||
|
export default validate;
|
||||||
61
node_modules/node-cron/dist/cjs/pattern/validation/pattern-validation.js
generated
vendored
Normal file
61
node_modules/node-cron/dist/cjs/pattern/validation/pattern-validation.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const index_1 = __importDefault(require("../convertion/index"));
|
||||||
|
const validationRegex = /^(?:\d+|\*|\*\/\d+)$/;
|
||||||
|
function isValidExpression(expression, min, max) {
|
||||||
|
const options = expression;
|
||||||
|
for (const option of options) {
|
||||||
|
const optionAsInt = parseInt(option, 10);
|
||||||
|
if ((!Number.isNaN(optionAsInt) &&
|
||||||
|
(optionAsInt < min || optionAsInt > max)) ||
|
||||||
|
!validationRegex.test(option))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
function isInvalidSecond(expression) {
|
||||||
|
return !isValidExpression(expression, 0, 59);
|
||||||
|
}
|
||||||
|
function isInvalidMinute(expression) {
|
||||||
|
return !isValidExpression(expression, 0, 59);
|
||||||
|
}
|
||||||
|
function isInvalidHour(expression) {
|
||||||
|
return !isValidExpression(expression, 0, 23);
|
||||||
|
}
|
||||||
|
function isInvalidDayOfMonth(expression) {
|
||||||
|
return !isValidExpression(expression, 1, 31);
|
||||||
|
}
|
||||||
|
function isInvalidMonth(expression) {
|
||||||
|
return !isValidExpression(expression, 1, 12);
|
||||||
|
}
|
||||||
|
function isInvalidWeekDay(expression) {
|
||||||
|
return !isValidExpression(expression, 0, 7);
|
||||||
|
}
|
||||||
|
function validateFields(patterns, executablePatterns) {
|
||||||
|
if (isInvalidSecond(executablePatterns[0]))
|
||||||
|
throw new Error(`${patterns[0]} is a invalid expression for second`);
|
||||||
|
if (isInvalidMinute(executablePatterns[1]))
|
||||||
|
throw new Error(`${patterns[1]} is a invalid expression for minute`);
|
||||||
|
if (isInvalidHour(executablePatterns[2]))
|
||||||
|
throw new Error(`${patterns[2]} is a invalid expression for hour`);
|
||||||
|
if (isInvalidDayOfMonth(executablePatterns[3]))
|
||||||
|
throw new Error(`${patterns[3]} is a invalid expression for day of month`);
|
||||||
|
if (isInvalidMonth(executablePatterns[4]))
|
||||||
|
throw new Error(`${patterns[4]} is a invalid expression for month`);
|
||||||
|
if (isInvalidWeekDay(executablePatterns[5]))
|
||||||
|
throw new Error(`${patterns[5]} is a invalid expression for week day`);
|
||||||
|
}
|
||||||
|
function validate(pattern) {
|
||||||
|
if (typeof pattern !== 'string')
|
||||||
|
throw new TypeError('pattern must be a string!');
|
||||||
|
const patterns = pattern.split(' ');
|
||||||
|
const executablePatterns = (0, index_1.default)(pattern);
|
||||||
|
if (patterns.length === 5)
|
||||||
|
patterns.unshift('0');
|
||||||
|
validateFields(patterns, executablePatterns);
|
||||||
|
}
|
||||||
|
exports.default = validate;
|
||||||
|
//# sourceMappingURL=pattern-validation.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/pattern/validation/pattern-validation.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/pattern/validation/pattern-validation.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"pattern-validation.js","sourceRoot":"","sources":["../../../../src/pattern/validation/pattern-validation.ts"],"names":[],"mappings":";;;;;AAAA,gEAAoD;AAEpD,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAQ/C,SAAS,iBAAiB,CAAC,UAAU,EAAE,GAAG,EAAE,GAAG;IAC3C,MAAM,OAAO,GAAG,UAAU,CAAC;IAE3B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEzC,IACI,CAAC,CAA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,CAAC,qCAAqC,CAAC,CAAC;IAEzE,IAAI,aAAa,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC;IAEvE,IAAI,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,IAAI,KAAK,CACX,GAAG,QAAQ,CAAC,CAAC,CAAC,2CAA2C,CAC5D,CAAC;IAEN,IAAI,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC;IAExE,IAAI,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC;AAC/E,CAAC;AAQD,SAAS,QAAQ,CAAC,OAAO;IACrB,IAAI,OAAO,OAAO,KAAK,QAAQ;QAC3B,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAErD,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,kBAAkB,GAAG,IAAA,eAAiB,EAAC,OAAO,CAAC,CAAC;IAEtD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAEjD,cAAc,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AACjD,CAAC;AAED,kBAAe,QAAQ,CAAC"}
|
||||||
19
node_modules/node-cron/dist/cjs/promise/tracked-promise.d.ts
generated
vendored
Normal file
19
node_modules/node-cron/dist/cjs/promise/tracked-promise.d.ts
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
type PromiseState = 'pending' | 'fulfilled' | 'rejected';
|
||||||
|
export declare class TrackedPromise<T> {
|
||||||
|
promise: Promise<T>;
|
||||||
|
error: any;
|
||||||
|
state: PromiseState;
|
||||||
|
value?: T;
|
||||||
|
constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void) => void);
|
||||||
|
getPromise(): Promise<T>;
|
||||||
|
getState(): PromiseState;
|
||||||
|
isPending(): boolean;
|
||||||
|
isFulfilled(): boolean;
|
||||||
|
isRejected(): boolean;
|
||||||
|
getValue(): T | undefined;
|
||||||
|
getError(): any;
|
||||||
|
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
||||||
|
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
|
||||||
|
finally(onfinally?: (() => void) | undefined | null): Promise<T>;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
55
node_modules/node-cron/dist/cjs/promise/tracked-promise.js
generated
vendored
Normal file
55
node_modules/node-cron/dist/cjs/promise/tracked-promise.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.TrackedPromise = void 0;
|
||||||
|
class TrackedPromise {
|
||||||
|
promise;
|
||||||
|
error;
|
||||||
|
state;
|
||||||
|
value;
|
||||||
|
constructor(executor) {
|
||||||
|
this.state = 'pending';
|
||||||
|
this.promise = new Promise((resolve, reject) => {
|
||||||
|
executor((value) => {
|
||||||
|
this.state = 'fulfilled';
|
||||||
|
this.value = value;
|
||||||
|
resolve(value);
|
||||||
|
}, (error) => {
|
||||||
|
this.state = 'rejected';
|
||||||
|
this.error = error;
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getPromise() {
|
||||||
|
return this.promise;
|
||||||
|
}
|
||||||
|
getState() {
|
||||||
|
return this.state;
|
||||||
|
}
|
||||||
|
isPending() {
|
||||||
|
return this.state === 'pending';
|
||||||
|
}
|
||||||
|
isFulfilled() {
|
||||||
|
return this.state === 'fulfilled';
|
||||||
|
}
|
||||||
|
isRejected() {
|
||||||
|
return this.state === 'rejected';
|
||||||
|
}
|
||||||
|
getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
getError() {
|
||||||
|
return this.error;
|
||||||
|
}
|
||||||
|
then(onfulfilled, onrejected) {
|
||||||
|
return this.promise.then(onfulfilled, onrejected);
|
||||||
|
}
|
||||||
|
catch(onrejected) {
|
||||||
|
return this.promise.catch(onrejected);
|
||||||
|
}
|
||||||
|
finally(onfinally) {
|
||||||
|
return this.promise.finally(onfinally);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.TrackedPromise = TrackedPromise;
|
||||||
|
//# sourceMappingURL=tracked-promise.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/promise/tracked-promise.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/promise/tracked-promise.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"tracked-promise.js","sourceRoot":"","sources":["../../../src/promise/tracked-promise.ts"],"names":[],"mappings":";;;AAEA,MAAa,cAAc;IACzB,OAAO,CAAa;IACpB,KAAK,CAAM;IACX,KAAK,CAAe;IACpB,KAAK,CAAK;IAEV,YAAY,QAA+E;QACzF,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QAEvB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAChD,QAAQ,CACN,CAAC,KAAK,EAAE,EAAE;gBACR,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;gBACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;gBACnB,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,EACD,CAAC,KAAK,EAAE,EAAE;gBACR,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;gBACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;gBACnB,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;IAClC,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC;IACpC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC;IACnC,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,CACF,WAAiF,EACjF,UAAmF;QAEnF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CACH,UAAiF;QAEjF,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,CAAC,SAA2C;QACjD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CACF;AArED,wCAqEC"}
|
||||||
42
node_modules/node-cron/dist/cjs/scheduler/runner.d.ts
generated
vendored
Normal file
42
node_modules/node-cron/dist/cjs/scheduler/runner.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { Execution } from "../tasks/scheduled-task";
|
||||||
|
import { TimeMatcher } from "../time/time-matcher";
|
||||||
|
type OnFn = (date: Date) => void | Promise<void>;
|
||||||
|
type OnErrorHookFn = (date: Date, error: Error, execution: Execution) => void | Promise<void>;
|
||||||
|
type OnHookFn = (date: Date, execution: Execution) => boolean | Promise<boolean>;
|
||||||
|
type OnMatch = (date: Date, execution: Execution) => any | Promise<any>;
|
||||||
|
export type RunnerOptions = {
|
||||||
|
noOverlap?: boolean;
|
||||||
|
timezone?: string;
|
||||||
|
maxExecutions?: number;
|
||||||
|
maxRandomDelay?: number;
|
||||||
|
onMissedExecution?: OnFn;
|
||||||
|
onOverlap?: OnFn;
|
||||||
|
onError?: OnErrorHookFn;
|
||||||
|
onFinished?: OnHookFn;
|
||||||
|
beforeRun?: OnHookFn;
|
||||||
|
onMaxExecutions?: OnFn;
|
||||||
|
};
|
||||||
|
export declare class Runner {
|
||||||
|
timeMatcher: TimeMatcher;
|
||||||
|
onMatch: OnMatch;
|
||||||
|
noOverlap: boolean;
|
||||||
|
maxExecutions?: number;
|
||||||
|
maxRandomDelay: number;
|
||||||
|
runCount: number;
|
||||||
|
running: boolean;
|
||||||
|
heartBeatTimeout?: NodeJS.Timeout;
|
||||||
|
onMissedExecution: OnFn;
|
||||||
|
onOverlap: OnFn;
|
||||||
|
onError: OnErrorHookFn;
|
||||||
|
beforeRun: OnHookFn;
|
||||||
|
onFinished: OnHookFn;
|
||||||
|
onMaxExecutions: OnFn;
|
||||||
|
constructor(timeMatcher: TimeMatcher, onMatch: OnMatch, options?: RunnerOptions);
|
||||||
|
start(): void;
|
||||||
|
nextRun(): Date;
|
||||||
|
stop(): void;
|
||||||
|
isStarted(): boolean;
|
||||||
|
isStopped(): boolean;
|
||||||
|
execute(): Promise<void>;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
192
node_modules/node-cron/dist/cjs/scheduler/runner.js
generated
vendored
Normal file
192
node_modules/node-cron/dist/cjs/scheduler/runner.js
generated
vendored
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Runner = void 0;
|
||||||
|
const create_id_1 = require("../create-id");
|
||||||
|
const logger_1 = __importDefault(require("../logger"));
|
||||||
|
const tracked_promise_1 = require("../promise/tracked-promise");
|
||||||
|
function emptyOnFn() { }
|
||||||
|
;
|
||||||
|
function emptyHookFn() { return true; }
|
||||||
|
;
|
||||||
|
function defaultOnError(date, error) {
|
||||||
|
logger_1.default.error('Task failed with error!', error);
|
||||||
|
}
|
||||||
|
class Runner {
|
||||||
|
timeMatcher;
|
||||||
|
onMatch;
|
||||||
|
noOverlap;
|
||||||
|
maxExecutions;
|
||||||
|
maxRandomDelay;
|
||||||
|
runCount;
|
||||||
|
running;
|
||||||
|
heartBeatTimeout;
|
||||||
|
onMissedExecution;
|
||||||
|
onOverlap;
|
||||||
|
onError;
|
||||||
|
beforeRun;
|
||||||
|
onFinished;
|
||||||
|
onMaxExecutions;
|
||||||
|
constructor(timeMatcher, onMatch, options) {
|
||||||
|
this.timeMatcher = timeMatcher;
|
||||||
|
this.onMatch = onMatch;
|
||||||
|
this.noOverlap = options == undefined || options.noOverlap === undefined ? false : options.noOverlap;
|
||||||
|
this.maxExecutions = options?.maxExecutions;
|
||||||
|
this.maxRandomDelay = options?.maxRandomDelay || 0;
|
||||||
|
this.onMissedExecution = options?.onMissedExecution || emptyOnFn;
|
||||||
|
this.onOverlap = options?.onOverlap || emptyOnFn;
|
||||||
|
this.onError = options?.onError || defaultOnError;
|
||||||
|
this.onFinished = options?.onFinished || emptyHookFn;
|
||||||
|
this.beforeRun = options?.beforeRun || emptyHookFn;
|
||||||
|
this.onMaxExecutions = options?.onMaxExecutions || emptyOnFn;
|
||||||
|
this.runCount = 0;
|
||||||
|
this.running = false;
|
||||||
|
}
|
||||||
|
start() {
|
||||||
|
this.running = true;
|
||||||
|
let lastExecution;
|
||||||
|
let expectedNextExecution;
|
||||||
|
const scheduleNextHeartBeat = (currentDate) => {
|
||||||
|
if (this.running) {
|
||||||
|
clearTimeout(this.heartBeatTimeout);
|
||||||
|
this.heartBeatTimeout = setTimeout(heartBeat, getDelay(this.timeMatcher, currentDate));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const runTask = (date) => {
|
||||||
|
return new Promise(async (resolve) => {
|
||||||
|
const execution = {
|
||||||
|
id: (0, create_id_1.createID)('exec'),
|
||||||
|
reason: 'scheduled'
|
||||||
|
};
|
||||||
|
const shouldExecute = await this.beforeRun(date, execution);
|
||||||
|
const randomDelay = Math.floor(Math.random() * this.maxRandomDelay);
|
||||||
|
if (shouldExecute) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
try {
|
||||||
|
this.runCount++;
|
||||||
|
execution.startedAt = new Date();
|
||||||
|
const result = await this.onMatch(date, execution);
|
||||||
|
execution.finishedAt = new Date();
|
||||||
|
execution.result = result;
|
||||||
|
this.onFinished(date, execution);
|
||||||
|
if (this.maxExecutions && this.runCount >= this.maxExecutions) {
|
||||||
|
this.onMaxExecutions(date);
|
||||||
|
this.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
execution.finishedAt = new Date();
|
||||||
|
execution.error = error;
|
||||||
|
this.onError(date, error, execution);
|
||||||
|
}
|
||||||
|
resolve(true);
|
||||||
|
}, randomDelay);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const checkAndRun = (date) => {
|
||||||
|
return new tracked_promise_1.TrackedPromise(async (resolve, reject) => {
|
||||||
|
try {
|
||||||
|
if (this.timeMatcher.match(date)) {
|
||||||
|
await runTask(date);
|
||||||
|
}
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const heartBeat = async () => {
|
||||||
|
const currentDate = nowWithoutMs();
|
||||||
|
if (expectedNextExecution && expectedNextExecution.getTime() < currentDate.getTime()) {
|
||||||
|
while (expectedNextExecution.getTime() < currentDate.getTime()) {
|
||||||
|
logger_1.default.warn(`missed execution at ${expectedNextExecution}! Possible blocking IO or high CPU user at the same process used by node-cron.`);
|
||||||
|
expectedNextExecution = this.timeMatcher.getNextMatch(expectedNextExecution);
|
||||||
|
runAsync(this.onMissedExecution, expectedNextExecution, defaultOnError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (lastExecution && lastExecution.getState() === 'pending') {
|
||||||
|
runAsync(this.onOverlap, currentDate, defaultOnError);
|
||||||
|
if (this.noOverlap) {
|
||||||
|
logger_1.default.warn('task still running, new execution blocked by overlap prevention!');
|
||||||
|
expectedNextExecution = this.timeMatcher.getNextMatch(currentDate);
|
||||||
|
scheduleNextHeartBeat(currentDate);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastExecution = checkAndRun(currentDate);
|
||||||
|
expectedNextExecution = this.timeMatcher.getNextMatch(currentDate);
|
||||||
|
scheduleNextHeartBeat(currentDate);
|
||||||
|
};
|
||||||
|
this.heartBeatTimeout = setTimeout(() => {
|
||||||
|
heartBeat();
|
||||||
|
}, getDelay(this.timeMatcher, nowWithoutMs()));
|
||||||
|
}
|
||||||
|
nextRun() {
|
||||||
|
return this.timeMatcher.getNextMatch(new Date());
|
||||||
|
}
|
||||||
|
stop() {
|
||||||
|
this.running = false;
|
||||||
|
if (this.heartBeatTimeout) {
|
||||||
|
clearTimeout(this.heartBeatTimeout);
|
||||||
|
this.heartBeatTimeout = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isStarted() {
|
||||||
|
return !!this.heartBeatTimeout && this.running;
|
||||||
|
}
|
||||||
|
isStopped() {
|
||||||
|
return !this.isStarted();
|
||||||
|
}
|
||||||
|
async execute() {
|
||||||
|
const date = new Date();
|
||||||
|
const execution = {
|
||||||
|
id: (0, create_id_1.createID)('exec'),
|
||||||
|
reason: 'invoked'
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const shouldExecute = await this.beforeRun(date, execution);
|
||||||
|
if (shouldExecute) {
|
||||||
|
this.runCount++;
|
||||||
|
execution.startedAt = new Date();
|
||||||
|
const result = await this.onMatch(date, execution);
|
||||||
|
execution.finishedAt = new Date();
|
||||||
|
execution.result = result;
|
||||||
|
this.onFinished(date, execution);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
execution.finishedAt = new Date();
|
||||||
|
execution.error = error;
|
||||||
|
this.onError(date, error, execution);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Runner = Runner;
|
||||||
|
async function runAsync(fn, date, onError) {
|
||||||
|
try {
|
||||||
|
await fn(date);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
onError(date, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function getDelay(timeMatcher, currentDate) {
|
||||||
|
const maxDelay = 86400000;
|
||||||
|
const nextRun = timeMatcher.getNextMatch(currentDate);
|
||||||
|
const now = new Date();
|
||||||
|
const delay = nextRun.getTime() - now.getTime();
|
||||||
|
if (delay > maxDelay) {
|
||||||
|
return maxDelay;
|
||||||
|
}
|
||||||
|
return Math.max(0, delay);
|
||||||
|
}
|
||||||
|
function nowWithoutMs() {
|
||||||
|
const date = new Date();
|
||||||
|
date.setMilliseconds(0);
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=runner.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/scheduler/runner.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/scheduler/runner.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
11
node_modules/node-cron/dist/cjs/task-registry.d.ts
generated
vendored
Normal file
11
node_modules/node-cron/dist/cjs/task-registry.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { ScheduledTask } from "./tasks/scheduled-task";
|
||||||
|
declare const tasks: Map<string, ScheduledTask>;
|
||||||
|
export declare class TaskRegistry {
|
||||||
|
add(task: ScheduledTask): void;
|
||||||
|
get(taskId: string): ScheduledTask | undefined;
|
||||||
|
remove(task: ScheduledTask): void;
|
||||||
|
all(): typeof tasks;
|
||||||
|
has(taskId: string): boolean;
|
||||||
|
killAll(): void;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
35
node_modules/node-cron/dist/cjs/task-registry.js
generated
vendored
Normal file
35
node_modules/node-cron/dist/cjs/task-registry.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.TaskRegistry = void 0;
|
||||||
|
const tasks = new Map();
|
||||||
|
class TaskRegistry {
|
||||||
|
add(task) {
|
||||||
|
if (this.has(task.id)) {
|
||||||
|
throw Error(`task ${task.id} already registred!`);
|
||||||
|
}
|
||||||
|
tasks.set(task.id, task);
|
||||||
|
task.on('task:destroyed', () => {
|
||||||
|
this.remove(task);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
get(taskId) {
|
||||||
|
return tasks.get(taskId);
|
||||||
|
}
|
||||||
|
remove(task) {
|
||||||
|
if (this.has(task.id)) {
|
||||||
|
task?.destroy();
|
||||||
|
tasks.delete(task.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
all() {
|
||||||
|
return tasks;
|
||||||
|
}
|
||||||
|
has(taskId) {
|
||||||
|
return tasks.has(taskId);
|
||||||
|
}
|
||||||
|
killAll() {
|
||||||
|
tasks.forEach(id => this.remove(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.TaskRegistry = TaskRegistry;
|
||||||
|
//# sourceMappingURL=task-registry.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/task-registry.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/task-registry.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"task-registry.js","sourceRoot":"","sources":["../../src/task-registry.ts"],"names":[],"mappings":";;;AAEA,MAAM,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEhD,MAAa,YAAY;IACvB,GAAG,CAAC,IAAmB;QACrB,IAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAC,CAAC;YACpB,MAAM,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,qBAAqB,CAAC,CAAA;QACnD,CAAC;QAED,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAEzB,IAAI,CAAC,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;YAC7B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,IAAmB;QACxB,IAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAC,CAAC;YACpB,IAAI,EAAE,OAAO,EAAE,CAAC;YAChB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,GAAG;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO;QACN,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;CACF;AAnCD,oCAmCC"}
|
||||||
28
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/background-scheduled-task.d.ts
generated
vendored
Normal file
28
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/background-scheduled-task.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { ChildProcess } from 'child_process';
|
||||||
|
import { ScheduledTask, TaskContext, TaskEvent, TaskOptions } from '../scheduled-task';
|
||||||
|
import { EventEmitter } from 'stream';
|
||||||
|
import { StateMachine } from '../state-machine';
|
||||||
|
declare class TaskEmitter extends EventEmitter {
|
||||||
|
}
|
||||||
|
declare class BackgroundScheduledTask implements ScheduledTask {
|
||||||
|
emitter: TaskEmitter;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
cronExpression: any;
|
||||||
|
taskPath: any;
|
||||||
|
options?: any;
|
||||||
|
forkProcess?: ChildProcess;
|
||||||
|
stateMachine: StateMachine;
|
||||||
|
constructor(cronExpression: string, taskPath: string, options?: TaskOptions);
|
||||||
|
getNextRun(): Date | null;
|
||||||
|
start(): Promise<void>;
|
||||||
|
stop(): Promise<void>;
|
||||||
|
getStatus(): string;
|
||||||
|
destroy(): Promise<void>;
|
||||||
|
execute(): Promise<any>;
|
||||||
|
on(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
off(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
once(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
private createContext;
|
||||||
|
}
|
||||||
|
export default BackgroundScheduledTask;
|
||||||
220
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/background-scheduled-task.js
generated
vendored
Normal file
220
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/background-scheduled-task.js
generated
vendored
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const path_1 = require("path");
|
||||||
|
const child_process_1 = require("child_process");
|
||||||
|
const create_id_1 = require("../../create-id");
|
||||||
|
const stream_1 = require("stream");
|
||||||
|
const state_machine_1 = require("../state-machine");
|
||||||
|
const localized_time_1 = require("../../time/localized-time");
|
||||||
|
const logger_1 = __importDefault(require("../../logger"));
|
||||||
|
const time_matcher_1 = require("../../time/time-matcher");
|
||||||
|
const daemonPath = (0, path_1.resolve)(__dirname, 'daemon.js');
|
||||||
|
class TaskEmitter extends stream_1.EventEmitter {
|
||||||
|
}
|
||||||
|
class BackgroundScheduledTask {
|
||||||
|
emitter;
|
||||||
|
id;
|
||||||
|
name;
|
||||||
|
cronExpression;
|
||||||
|
taskPath;
|
||||||
|
options;
|
||||||
|
forkProcess;
|
||||||
|
stateMachine;
|
||||||
|
constructor(cronExpression, taskPath, options) {
|
||||||
|
this.cronExpression = cronExpression;
|
||||||
|
this.taskPath = taskPath;
|
||||||
|
this.options = options;
|
||||||
|
this.id = (0, create_id_1.createID)('task');
|
||||||
|
this.name = options?.name || this.id;
|
||||||
|
this.emitter = new TaskEmitter();
|
||||||
|
this.stateMachine = new state_machine_1.StateMachine('stopped');
|
||||||
|
this.on('task:stopped', () => {
|
||||||
|
this.forkProcess?.kill();
|
||||||
|
this.forkProcess = undefined;
|
||||||
|
this.stateMachine.changeState('stopped');
|
||||||
|
});
|
||||||
|
this.on('task:destroyed', () => {
|
||||||
|
this.forkProcess?.kill();
|
||||||
|
this.forkProcess = undefined;
|
||||||
|
this.stateMachine.changeState('destroyed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getNextRun() {
|
||||||
|
if (this.stateMachine.state !== 'stopped') {
|
||||||
|
const timeMatcher = new time_matcher_1.TimeMatcher(this.cronExpression, this.options?.timezone);
|
||||||
|
return timeMatcher.getNextMatch(new Date());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
start() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (this.forkProcess) {
|
||||||
|
return resolve(undefined);
|
||||||
|
}
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
reject(new Error('Start operation timed out'));
|
||||||
|
}, 5000);
|
||||||
|
try {
|
||||||
|
this.forkProcess = (0, child_process_1.fork)(daemonPath);
|
||||||
|
this.forkProcess.on('error', (err) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
reject(new Error(`Error on daemon: ${err.message}`));
|
||||||
|
});
|
||||||
|
this.forkProcess.on('exit', (code, signal) => {
|
||||||
|
if (code !== 0 && signal !== 'SIGTERM') {
|
||||||
|
const erro = new Error(`node-cron daemon exited with code ${code || signal}`);
|
||||||
|
logger_1.default.error(erro);
|
||||||
|
clearTimeout(timeout);
|
||||||
|
reject(erro);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.forkProcess.on('message', (message) => {
|
||||||
|
if (message.jsonError) {
|
||||||
|
if (message.context?.execution) {
|
||||||
|
message.context.execution.error = deserializeError(message.jsonError);
|
||||||
|
delete message.jsonError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (message.context?.task?.state) {
|
||||||
|
this.stateMachine.changeState(message.context?.task?.state);
|
||||||
|
}
|
||||||
|
if (message.context) {
|
||||||
|
const execution = message.context?.execution;
|
||||||
|
delete execution?.hasError;
|
||||||
|
const context = this.createContext(new Date(message.context.date), execution);
|
||||||
|
this.emitter.emit(message.event, context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.once('task:started', () => {
|
||||||
|
this.stateMachine.changeState('idle');
|
||||||
|
clearTimeout(timeout);
|
||||||
|
resolve(undefined);
|
||||||
|
});
|
||||||
|
this.forkProcess.send({
|
||||||
|
command: 'task:start',
|
||||||
|
path: this.taskPath,
|
||||||
|
cron: this.cronExpression,
|
||||||
|
options: this.options
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
stop() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!this.forkProcess) {
|
||||||
|
return resolve(undefined);
|
||||||
|
}
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
reject(new Error('Stop operation timed out'));
|
||||||
|
}, 5000);
|
||||||
|
const cleanupAndResolve = () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
this.off('task:stopped', onStopped);
|
||||||
|
this.forkProcess = undefined;
|
||||||
|
resolve(undefined);
|
||||||
|
};
|
||||||
|
const onStopped = () => {
|
||||||
|
cleanupAndResolve();
|
||||||
|
};
|
||||||
|
this.once('task:stopped', onStopped);
|
||||||
|
this.forkProcess.send({
|
||||||
|
command: 'task:stop'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getStatus() {
|
||||||
|
return this.stateMachine.state;
|
||||||
|
}
|
||||||
|
destroy() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!this.forkProcess) {
|
||||||
|
return resolve(undefined);
|
||||||
|
}
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
reject(new Error('Destroy operation timed out'));
|
||||||
|
}, 5000);
|
||||||
|
const onDestroy = () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
this.off('task:destroyed', onDestroy);
|
||||||
|
resolve(undefined);
|
||||||
|
};
|
||||||
|
this.once('task:destroyed', onDestroy);
|
||||||
|
this.forkProcess.send({
|
||||||
|
command: 'task:destroy'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
execute() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!this.forkProcess) {
|
||||||
|
return reject(new Error('Cannot execute background task because it hasn\'t been started yet. Please initialize the task using the start() method before attempting to execute it.'));
|
||||||
|
}
|
||||||
|
const timeoutId = setTimeout(() => {
|
||||||
|
cleanupListeners();
|
||||||
|
reject(new Error('Execution timeout exceeded'));
|
||||||
|
}, 5000);
|
||||||
|
const cleanupListeners = () => {
|
||||||
|
clearTimeout(timeoutId);
|
||||||
|
this.off('execution:finished', onFinished);
|
||||||
|
this.off('execution:failed', onFail);
|
||||||
|
};
|
||||||
|
const onFinished = (context) => {
|
||||||
|
cleanupListeners();
|
||||||
|
resolve(context.execution?.result);
|
||||||
|
};
|
||||||
|
const onFail = (context) => {
|
||||||
|
cleanupListeners();
|
||||||
|
reject(context.execution?.error || new Error('Execution failed without specific error'));
|
||||||
|
};
|
||||||
|
this.once('execution:finished', onFinished);
|
||||||
|
this.once('execution:failed', onFail);
|
||||||
|
this.forkProcess.send({
|
||||||
|
command: 'task:execute'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
on(event, fun) {
|
||||||
|
this.emitter.on(event, fun);
|
||||||
|
}
|
||||||
|
off(event, fun) {
|
||||||
|
this.emitter.off(event, fun);
|
||||||
|
}
|
||||||
|
once(event, fun) {
|
||||||
|
this.emitter.once(event, fun);
|
||||||
|
}
|
||||||
|
createContext(executionDate, execution) {
|
||||||
|
const localTime = new localized_time_1.LocalizedTime(executionDate, this.options?.timezone);
|
||||||
|
const ctx = {
|
||||||
|
date: localTime.toDate(),
|
||||||
|
dateLocalIso: localTime.toISO(),
|
||||||
|
triggeredAt: new Date(),
|
||||||
|
task: this,
|
||||||
|
execution: execution
|
||||||
|
};
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function deserializeError(str) {
|
||||||
|
const data = JSON.parse(str);
|
||||||
|
const Err = globalThis[data.name] || Error;
|
||||||
|
const err = new Err(data.message);
|
||||||
|
if (data.stack) {
|
||||||
|
err.stack = data.stack;
|
||||||
|
}
|
||||||
|
Object.keys(data).forEach(key => {
|
||||||
|
if (!['name', 'message', 'stack'].includes(key)) {
|
||||||
|
err[key] = data[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
exports.default = BackgroundScheduledTask;
|
||||||
|
//# sourceMappingURL=background-scheduled-task.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/background-scheduled-task.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/background-scheduled-task.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/daemon.d.ts
generated
vendored
Normal file
3
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/daemon.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import { ScheduledTask } from "../scheduled-task";
|
||||||
|
export declare function startDaemon(message: any): Promise<ScheduledTask>;
|
||||||
|
export declare function bind(): void;
|
||||||
142
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/daemon.js
generated
vendored
Normal file
142
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/daemon.js
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || (function () {
|
||||||
|
var ownKeys = function(o) {
|
||||||
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||||
|
var ar = [];
|
||||||
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||||
|
return ar;
|
||||||
|
};
|
||||||
|
return ownKeys(o);
|
||||||
|
};
|
||||||
|
return function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.startDaemon = startDaemon;
|
||||||
|
exports.bind = bind;
|
||||||
|
const url_1 = require("url");
|
||||||
|
const logger_1 = __importDefault(require("../../logger"));
|
||||||
|
const inline_scheduled_task_1 = require("../inline-scheduled-task");
|
||||||
|
async function startDaemon(message) {
|
||||||
|
let script;
|
||||||
|
try {
|
||||||
|
script = await Promise.resolve(`${message.path}`).then(s => __importStar(require(s)));
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
script = await Promise.resolve(`${(0, url_1.fileURLToPath)(message.path)}`).then(s => __importStar(require(s)));
|
||||||
|
}
|
||||||
|
const task = new inline_scheduled_task_1.InlineScheduledTask(message.cron, script.task, message.options);
|
||||||
|
task.on('task:started', (context => sendEvent('task:started', context)));
|
||||||
|
task.on('task:stopped', (context => sendEvent('task:stopped', context)));
|
||||||
|
task.on('task:destroyed', (context => sendEvent('task:destroyed', context)));
|
||||||
|
task.on('execution:started', (context => sendEvent('execution:started', context)));
|
||||||
|
task.on('execution:finished', (context => sendEvent('execution:finished', context)));
|
||||||
|
task.on('execution:failed', (context => sendEvent('execution:failed', context)));
|
||||||
|
task.on('execution:missed', (context => sendEvent('execution:missed', context)));
|
||||||
|
task.on('execution:overlap', (context => sendEvent('execution:overlap', context)));
|
||||||
|
task.on('execution:maxReached', (context => sendEvent('execution:maxReached', context)));
|
||||||
|
if (process.send)
|
||||||
|
process.send({ event: 'daemon:started' });
|
||||||
|
task.start();
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
function sendEvent(event, context) {
|
||||||
|
const message = { event: event, context: safelySerializeContext(context) };
|
||||||
|
if (context.execution?.error) {
|
||||||
|
message.jsonError = serializeError(context.execution?.error);
|
||||||
|
}
|
||||||
|
if (process.send)
|
||||||
|
process.send(message);
|
||||||
|
}
|
||||||
|
function serializeError(err) {
|
||||||
|
const plain = {
|
||||||
|
name: err.name,
|
||||||
|
message: err.message,
|
||||||
|
stack: err.stack,
|
||||||
|
...Object.getOwnPropertyNames(err)
|
||||||
|
.filter(k => !['name', 'message', 'stack'].includes(k))
|
||||||
|
.reduce((acc, k) => {
|
||||||
|
acc[k] = err[k];
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
};
|
||||||
|
return JSON.stringify(plain);
|
||||||
|
}
|
||||||
|
function safelySerializeContext(context) {
|
||||||
|
const safeContext = {
|
||||||
|
date: context.date,
|
||||||
|
dateLocalIso: context.dateLocalIso,
|
||||||
|
triggeredAt: context.triggeredAt
|
||||||
|
};
|
||||||
|
if (context.task) {
|
||||||
|
safeContext.task = {
|
||||||
|
id: context.task.id,
|
||||||
|
name: context.task.name,
|
||||||
|
status: context.task.getStatus()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (context.execution) {
|
||||||
|
safeContext.execution = {
|
||||||
|
id: context.execution.id,
|
||||||
|
reason: context.execution.reason,
|
||||||
|
startedAt: context.execution.startedAt,
|
||||||
|
finishedAt: context.execution.finishedAt,
|
||||||
|
hasError: !!context.execution.error,
|
||||||
|
result: context.execution.result
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return safeContext;
|
||||||
|
}
|
||||||
|
function bind() {
|
||||||
|
let task;
|
||||||
|
process.on('message', async (message) => {
|
||||||
|
switch (message.command) {
|
||||||
|
case 'task:start':
|
||||||
|
task = await startDaemon(message);
|
||||||
|
return task;
|
||||||
|
case 'task:stop':
|
||||||
|
if (task)
|
||||||
|
task.stop();
|
||||||
|
return task;
|
||||||
|
case 'task:destroy':
|
||||||
|
if (task)
|
||||||
|
task.destroy();
|
||||||
|
return task;
|
||||||
|
case 'task:execute':
|
||||||
|
try {
|
||||||
|
if (task)
|
||||||
|
await task.execute();
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
logger_1.default.debug('Daemon task:execute falied:', error);
|
||||||
|
}
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
bind();
|
||||||
|
//# sourceMappingURL=daemon.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/daemon.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/daemon.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"daemon.js","sourceRoot":"","sources":["../../../../src/tasks/background-scheduled-task/daemon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,kCA4CC;AAyDD,oBAuBC;AAjID,6BAAoC;AACpC,0DAAkC;AAClC,oEAA+D;AAGxD,KAAK,UAAU,WAAW,CAAC,OAAY;IAC1C,IAAI,MAAM,CAAC;IAaX,IAAI,CAAC;QACH,MAAM,GAAG,yBAAa,OAAO,CAAC,IAAI,uCAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,yBAAa,IAAA,mBAAa,EAAC,OAAO,CAAC,IAAI,CAAC,uCAAC,CAAA;IACpD,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,2CAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEjF,IAAI,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAEzE,IAAI,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CA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C;AACL,CAAC;AAED,IAAI,EAAE,CAAC"}
|
||||||
0
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/index.d.ts
generated
vendored
Normal file
0
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/index.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/index.js
generated
vendored
Normal file
2
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
"use strict";
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/index.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/tasks/background-scheduled-task/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tasks/background-scheduled-task/index.ts"],"names":[],"mappings":""}
|
||||||
30
node_modules/node-cron/dist/cjs/tasks/inline-scheduled-task.d.ts
generated
vendored
Normal file
30
node_modules/node-cron/dist/cjs/tasks/inline-scheduled-task.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import EventEmitter from "events";
|
||||||
|
import { ScheduledTask, TaskContext, TaskEvent, TaskFn, TaskOptions } from "./scheduled-task";
|
||||||
|
import { Runner } from "../scheduler/runner";
|
||||||
|
import { TimeMatcher } from "../time/time-matcher";
|
||||||
|
import { StateMachine } from "./state-machine";
|
||||||
|
declare class TaskEmitter extends EventEmitter {
|
||||||
|
}
|
||||||
|
export declare class InlineScheduledTask implements ScheduledTask {
|
||||||
|
emitter: TaskEmitter;
|
||||||
|
cronExpression: string;
|
||||||
|
timeMatcher: TimeMatcher;
|
||||||
|
runner: Runner;
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
stateMachine: StateMachine;
|
||||||
|
timezone?: string;
|
||||||
|
constructor(cronExpression: string, taskFn: TaskFn, options?: TaskOptions);
|
||||||
|
getNextRun(): Date | null;
|
||||||
|
private changeState;
|
||||||
|
start(): void;
|
||||||
|
stop(): void;
|
||||||
|
getStatus(): string;
|
||||||
|
destroy(): void;
|
||||||
|
execute(): Promise<any>;
|
||||||
|
on(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
off(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
once(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
private createContext;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
144
node_modules/node-cron/dist/cjs/tasks/inline-scheduled-task.js
generated
vendored
Normal file
144
node_modules/node-cron/dist/cjs/tasks/inline-scheduled-task.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.InlineScheduledTask = void 0;
|
||||||
|
const events_1 = __importDefault(require("events"));
|
||||||
|
const runner_1 = require("../scheduler/runner");
|
||||||
|
const time_matcher_1 = require("../time/time-matcher");
|
||||||
|
const create_id_1 = require("../create-id");
|
||||||
|
const state_machine_1 = require("./state-machine");
|
||||||
|
const logger_1 = __importDefault(require("../logger"));
|
||||||
|
const localized_time_1 = require("../time/localized-time");
|
||||||
|
class TaskEmitter extends events_1.default {
|
||||||
|
}
|
||||||
|
class InlineScheduledTask {
|
||||||
|
emitter;
|
||||||
|
cronExpression;
|
||||||
|
timeMatcher;
|
||||||
|
runner;
|
||||||
|
id;
|
||||||
|
name;
|
||||||
|
stateMachine;
|
||||||
|
timezone;
|
||||||
|
constructor(cronExpression, taskFn, options) {
|
||||||
|
this.emitter = new TaskEmitter();
|
||||||
|
this.cronExpression = cronExpression;
|
||||||
|
this.id = (0, create_id_1.createID)('task', 12);
|
||||||
|
this.name = options?.name || this.id;
|
||||||
|
this.timezone = options?.timezone;
|
||||||
|
this.timeMatcher = new time_matcher_1.TimeMatcher(cronExpression, options?.timezone);
|
||||||
|
this.stateMachine = new state_machine_1.StateMachine();
|
||||||
|
const runnerOptions = {
|
||||||
|
timezone: options?.timezone,
|
||||||
|
noOverlap: options?.noOverlap,
|
||||||
|
maxExecutions: options?.maxExecutions,
|
||||||
|
maxRandomDelay: options?.maxRandomDelay,
|
||||||
|
beforeRun: (date, execution) => {
|
||||||
|
if (execution.reason === 'scheduled') {
|
||||||
|
this.changeState('running');
|
||||||
|
}
|
||||||
|
this.emitter.emit('execution:started', this.createContext(date, execution));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
onFinished: (date, execution) => {
|
||||||
|
if (execution.reason === 'scheduled') {
|
||||||
|
this.changeState('idle');
|
||||||
|
}
|
||||||
|
this.emitter.emit('execution:finished', this.createContext(date, execution));
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
onError: (date, error, execution) => {
|
||||||
|
logger_1.default.error(error);
|
||||||
|
this.emitter.emit('execution:failed', this.createContext(date, execution));
|
||||||
|
this.changeState('idle');
|
||||||
|
},
|
||||||
|
onOverlap: (date) => {
|
||||||
|
this.emitter.emit('execution:overlap', this.createContext(date));
|
||||||
|
},
|
||||||
|
onMissedExecution: (date) => {
|
||||||
|
this.emitter.emit('execution:missed', this.createContext(date));
|
||||||
|
},
|
||||||
|
onMaxExecutions: (date) => {
|
||||||
|
this.emitter.emit('execution:maxReached', this.createContext(date));
|
||||||
|
this.destroy();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.runner = new runner_1.Runner(this.timeMatcher, (date, execution) => {
|
||||||
|
return taskFn(this.createContext(date, execution));
|
||||||
|
}, runnerOptions);
|
||||||
|
}
|
||||||
|
getNextRun() {
|
||||||
|
if (this.stateMachine.state !== 'stopped') {
|
||||||
|
return this.runner.nextRun();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
changeState(state) {
|
||||||
|
if (this.runner.isStarted()) {
|
||||||
|
this.stateMachine.changeState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
start() {
|
||||||
|
if (this.runner.isStopped()) {
|
||||||
|
this.runner.start();
|
||||||
|
this.stateMachine.changeState('idle');
|
||||||
|
this.emitter.emit('task:started', this.createContext(new Date()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stop() {
|
||||||
|
if (this.runner.isStarted()) {
|
||||||
|
this.runner.stop();
|
||||||
|
this.stateMachine.changeState('stopped');
|
||||||
|
this.emitter.emit('task:stopped', this.createContext(new Date()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getStatus() {
|
||||||
|
return this.stateMachine.state;
|
||||||
|
}
|
||||||
|
destroy() {
|
||||||
|
if (this.stateMachine.state === 'destroyed')
|
||||||
|
return;
|
||||||
|
this.stop();
|
||||||
|
this.stateMachine.changeState('destroyed');
|
||||||
|
this.emitter.emit('task:destroyed', this.createContext(new Date()));
|
||||||
|
}
|
||||||
|
execute() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const onFail = (context) => {
|
||||||
|
this.off('execution:finished', onFail);
|
||||||
|
reject(context.execution?.error);
|
||||||
|
};
|
||||||
|
const onFinished = (context) => {
|
||||||
|
this.off('execution:failed', onFail);
|
||||||
|
resolve(context.execution?.result);
|
||||||
|
};
|
||||||
|
this.once('execution:finished', onFinished);
|
||||||
|
this.once('execution:failed', onFail);
|
||||||
|
this.runner.execute();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
on(event, fun) {
|
||||||
|
this.emitter.on(event, fun);
|
||||||
|
}
|
||||||
|
off(event, fun) {
|
||||||
|
this.emitter.off(event, fun);
|
||||||
|
}
|
||||||
|
once(event, fun) {
|
||||||
|
this.emitter.once(event, fun);
|
||||||
|
}
|
||||||
|
createContext(executionDate, execution) {
|
||||||
|
const localTime = new localized_time_1.LocalizedTime(executionDate, this.timezone);
|
||||||
|
const ctx = {
|
||||||
|
date: localTime.toDate(),
|
||||||
|
dateLocalIso: localTime.toISO(),
|
||||||
|
triggeredAt: new Date(),
|
||||||
|
task: this,
|
||||||
|
execution: execution
|
||||||
|
};
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.InlineScheduledTask = InlineScheduledTask;
|
||||||
|
//# sourceMappingURL=inline-scheduled-task.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/tasks/inline-scheduled-task.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/tasks/inline-scheduled-task.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"inline-scheduled-task.js","sourceRoot":"","sources":["../../../src/tasks/inline-scheduled-task.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAkC;AAElC,gDAA4D;AAC5D,uDAAmD;AACnD,4CAAwC;AACxC,mDAA+C;AAC/C,uDAA+B;AAC/B,2DAAuD;AAEvD,MAAM,WAAY,SAAQ,gBAAY;CAAE;AAExC,MAAa,mBAAmB;IAC9B,OAAO,CAAc;IACrB,cAAc,CAAS;IACvB,WAAW,CAAc;IACzB,MAAM,CAAS;IACf,EAAE,CAAS;IACX,IAAI,CAAS;IACb,YAAY,CAAe;IAC3B,QAAQ,CAAU;IAElB,YAAY,cAAsB,EAAE,MAAc,EAAE,OAAqB;QACvE,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,EAAE,GAAG,IAAA,oBAAQ,EAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAElC,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,cAAc,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QACrE,IAAI,CAAC,YAAY,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AAC,SAAS,EAAE,MAAM,CAAC,CAAA;YACpC,CAAC,CAAA;YAED,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;YAEtC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,EAAE,CAAC,KAAgB,EAAE,GAAmD;QACtE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,GAAG,CAAC,KAAgB,EAAE,GAAmD;QACvE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,KAAgB,EAAE,GAAmD;QACxE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChC,CAAC;IAEO,aAAa,CAAC,aAAmB,EAAE,SAAqB;QAC9D,MAAM,SAAS,GAAG,IAAI,8BAAa,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QACjE,MAAM,GAAG,GAAgB;YACvB,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE;YACxB,YAAY,EAAE,SAAS,CAAC,KAAK,EAAE;YAC/B,WAAW,EAAE,IAAI,IAAI,EAAE;YACvB,IAAI,EAAE,IAAI;YACV,SAAS,EAAE,SAAS;SACrB,CAAA;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAlJD,kDAkJC"}
|
||||||
37
node_modules/node-cron/dist/cjs/tasks/scheduled-task.d.ts
generated
vendored
Normal file
37
node_modules/node-cron/dist/cjs/tasks/scheduled-task.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
export type TaskContext = {
|
||||||
|
date: Date;
|
||||||
|
dateLocalIso: string;
|
||||||
|
task?: ScheduledTask;
|
||||||
|
execution?: Execution;
|
||||||
|
triggeredAt: Date;
|
||||||
|
};
|
||||||
|
export type TaskEvent = 'task:started' | 'task:stopped' | 'task:destroyed' | 'execution:started' | 'execution:finished' | 'execution:failed' | 'execution:missed' | 'execution:overlap' | 'execution:maxReached';
|
||||||
|
export type TaskOptions = {
|
||||||
|
timezone?: string;
|
||||||
|
name?: string;
|
||||||
|
noOverlap?: boolean;
|
||||||
|
maxExecutions?: number;
|
||||||
|
maxRandomDelay?: number;
|
||||||
|
};
|
||||||
|
export type Execution = {
|
||||||
|
id: string;
|
||||||
|
reason: 'invoked' | 'scheduled';
|
||||||
|
startedAt?: Date;
|
||||||
|
finishedAt?: Date;
|
||||||
|
error?: Error;
|
||||||
|
result?: any;
|
||||||
|
};
|
||||||
|
export type TaskFn = (context: TaskContext) => any | Promise<any>;
|
||||||
|
export interface ScheduledTask {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
start(): void | Promise<void>;
|
||||||
|
stop(): void | Promise<void>;
|
||||||
|
getStatus(): string | Promise<string>;
|
||||||
|
destroy(): void | Promise<void>;
|
||||||
|
execute(): Promise<any>;
|
||||||
|
getNextRun(): Date | null;
|
||||||
|
on(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
off(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
once(event: TaskEvent, fun: (context: TaskContext) => Promise<void> | void): void;
|
||||||
|
}
|
||||||
3
node_modules/node-cron/dist/cjs/tasks/scheduled-task.js
generated
vendored
Normal file
3
node_modules/node-cron/dist/cjs/tasks/scheduled-task.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
//# sourceMappingURL=scheduled-task.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/tasks/scheduled-task.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/tasks/scheduled-task.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"scheduled-task.js","sourceRoot":"","sources":["../../../src/tasks/scheduled-task.ts"],"names":[],"mappings":""}
|
||||||
6
node_modules/node-cron/dist/cjs/tasks/state-machine.d.ts
generated
vendored
Normal file
6
node_modules/node-cron/dist/cjs/tasks/state-machine.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export type TaskState = 'stopped' | 'idle' | 'running' | 'destroyed';
|
||||||
|
export declare class StateMachine {
|
||||||
|
state: TaskState;
|
||||||
|
constructor(initial?: TaskState);
|
||||||
|
changeState(state: TaskState): void;
|
||||||
|
}
|
||||||
25
node_modules/node-cron/dist/cjs/tasks/state-machine.js
generated
vendored
Normal file
25
node_modules/node-cron/dist/cjs/tasks/state-machine.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.StateMachine = void 0;
|
||||||
|
const allowedTransitions = {
|
||||||
|
'stopped': ['stopped', 'idle', 'destroyed'],
|
||||||
|
'idle': ['idle', 'running', 'stopped', 'destroyed'],
|
||||||
|
'running': ['running', 'idle', 'stopped', 'destroyed'],
|
||||||
|
'destroyed': ['destroyed']
|
||||||
|
};
|
||||||
|
class StateMachine {
|
||||||
|
state;
|
||||||
|
constructor(initial = 'stopped') {
|
||||||
|
this.state = initial;
|
||||||
|
}
|
||||||
|
changeState(state) {
|
||||||
|
if (allowedTransitions[this.state].includes(state)) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error(`invalid transition from ${this.state} to ${state}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.StateMachine = StateMachine;
|
||||||
|
//# sourceMappingURL=state-machine.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/tasks/state-machine.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/tasks/state-machine.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"state-machine.js","sourceRoot":"","sources":["../../../src/tasks/state-machine.ts"],"names":[],"mappings":";;;AAEA,MAAM,kBAAkB,GAAmC;IACzD,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC;IAC3C,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,CAAC;IACnD,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC;IACtD,WAAW,EAAE,CAAC,WAAW,CAAC;CAC3B,CAAA;AAED,MAAa,YAAY;IACvB,KAAK,CAAY;IAEjB,YAAY,UAAqB,SAAS;QACxC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;IACvB,CAAC;IAED,WAAW,CAAC,KAAgB;QAC1B,IAAG,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAC,CAAC;YACjD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,KAAK,OAAO,KAAK,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;CAEF;AAfD,oCAeC"}
|
||||||
22
node_modules/node-cron/dist/cjs/time/localized-time.d.ts
generated
vendored
Normal file
22
node_modules/node-cron/dist/cjs/time/localized-time.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
type DateParts = {
|
||||||
|
day: number;
|
||||||
|
month: number;
|
||||||
|
year: number;
|
||||||
|
hour: number;
|
||||||
|
minute: number;
|
||||||
|
second: number;
|
||||||
|
milisecond: number;
|
||||||
|
weekday: string;
|
||||||
|
gmt: string;
|
||||||
|
};
|
||||||
|
export declare class LocalizedTime {
|
||||||
|
timestamp: number;
|
||||||
|
parts: DateParts;
|
||||||
|
timezone?: string | undefined;
|
||||||
|
constructor(date: Date, timezone?: string);
|
||||||
|
toDate(): Date;
|
||||||
|
toISO(): string;
|
||||||
|
getParts(): DateParts;
|
||||||
|
set(field: string, value: number): void;
|
||||||
|
}
|
||||||
|
export {};
|
||||||
81
node_modules/node-cron/dist/cjs/time/localized-time.js
generated
vendored
Normal file
81
node_modules/node-cron/dist/cjs/time/localized-time.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.LocalizedTime = void 0;
|
||||||
|
class LocalizedTime {
|
||||||
|
timestamp;
|
||||||
|
parts;
|
||||||
|
timezone;
|
||||||
|
constructor(date, timezone) {
|
||||||
|
this.timestamp = date.getTime();
|
||||||
|
this.timezone = timezone;
|
||||||
|
this.parts = buildDateParts(date, timezone);
|
||||||
|
}
|
||||||
|
toDate() {
|
||||||
|
return new Date(this.timestamp);
|
||||||
|
}
|
||||||
|
toISO() {
|
||||||
|
const gmt = this.parts.gmt.replace(/^GMT/, '');
|
||||||
|
const offset = gmt ? gmt : 'Z';
|
||||||
|
const pad = (n) => String(n).padStart(2, '0');
|
||||||
|
return `${this.parts.year}-${pad(this.parts.month)}-${pad(this.parts.day)}`
|
||||||
|
+ `T${pad(this.parts.hour)}:${pad(this.parts.minute)}:${pad(this.parts.second)}`
|
||||||
|
+ `.${String(this.parts.milisecond).padStart(3, '0')}`
|
||||||
|
+ offset;
|
||||||
|
}
|
||||||
|
getParts() {
|
||||||
|
return this.parts;
|
||||||
|
}
|
||||||
|
set(field, value) {
|
||||||
|
this.parts[field] = value;
|
||||||
|
const newDate = new Date(this.toISO());
|
||||||
|
this.timestamp = newDate.getTime();
|
||||||
|
this.parts = buildDateParts(newDate, this.timezone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.LocalizedTime = LocalizedTime;
|
||||||
|
function buildDateParts(date, timezone) {
|
||||||
|
const dftOptions = {
|
||||||
|
year: 'numeric',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
second: '2-digit',
|
||||||
|
weekday: 'short',
|
||||||
|
hour12: false
|
||||||
|
};
|
||||||
|
if (timezone) {
|
||||||
|
dftOptions.timeZone = timezone;
|
||||||
|
}
|
||||||
|
const dateFormat = new Intl.DateTimeFormat('en-US', dftOptions);
|
||||||
|
const parts = dateFormat.formatToParts(date).filter(part => {
|
||||||
|
return part.type !== 'literal';
|
||||||
|
}).reduce((acc, part) => {
|
||||||
|
acc[part.type] = part.value;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
return {
|
||||||
|
day: parseInt(parts.day),
|
||||||
|
month: parseInt(parts.month),
|
||||||
|
year: parseInt(parts.year),
|
||||||
|
hour: parts.hour === '24' ? 0 : parseInt(parts.hour),
|
||||||
|
minute: parseInt(parts.minute),
|
||||||
|
second: parseInt(parts.second),
|
||||||
|
milisecond: date.getMilliseconds(),
|
||||||
|
weekday: parts.weekday,
|
||||||
|
gmt: getTimezoneGMT(date, timezone)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function getTimezoneGMT(date, timezone) {
|
||||||
|
const utcDate = new Date(date.toLocaleString('en-US', { timeZone: 'UTC' }));
|
||||||
|
const tzDate = new Date(date.toLocaleString('en-US', { timeZone: timezone }));
|
||||||
|
let offsetInMinutes = (utcDate.getTime() - tzDate.getTime()) / 60000;
|
||||||
|
const sign = offsetInMinutes <= 0 ? '+' : '-';
|
||||||
|
offsetInMinutes = Math.abs(offsetInMinutes);
|
||||||
|
if (offsetInMinutes === 0)
|
||||||
|
return 'Z';
|
||||||
|
const hours = Math.floor(offsetInMinutes / 60).toString().padStart(2, '0');
|
||||||
|
const minutes = Math.floor(offsetInMinutes % 60).toString().padStart(2, '0');
|
||||||
|
return `GMT${sign}${hours}:${minutes}`;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=localized-time.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/time/localized-time.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/time/localized-time.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"localized-time.js","sourceRoot":"","sources":["../../../src/time/localized-time.ts"],"names":[],"mappings":";;;AAYA,MAAa,aAAa;IACxB,SAAS,CAAQ;IACjB,KAAK,CAAW;IAChB,QAAQ,CAAqB;IAE7B,YAAY,IAAU,EAAE,QAAiB;QACvC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAED,KAAK;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAE/B,MAAM,GAAG,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACtD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;cACpE,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAA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AI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC5C,IAAG,eAAe,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAE7E,OAAO,MAAM,IAAI,GAAG,KAAK,IAAI,OAAO,EAAE,CAAC;AACzC,CAAC"}
|
||||||
13
node_modules/node-cron/dist/cjs/time/matcher-walker.d.ts
generated
vendored
Normal file
13
node_modules/node-cron/dist/cjs/time/matcher-walker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { LocalizedTime } from './localized-time';
|
||||||
|
import { TimeMatcher } from './time-matcher';
|
||||||
|
export declare class MatcherWalker {
|
||||||
|
cronExpression: string;
|
||||||
|
baseDate: Date;
|
||||||
|
pattern: any;
|
||||||
|
expressions: number[][];
|
||||||
|
timeMatcher: TimeMatcher;
|
||||||
|
timezone?: string;
|
||||||
|
constructor(cronExpression: string, baseDate: Date, timezone?: string);
|
||||||
|
isMatching(): boolean;
|
||||||
|
matchNext(): LocalizedTime;
|
||||||
|
}
|
||||||
100
node_modules/node-cron/dist/cjs/time/matcher-walker.js
generated
vendored
Normal file
100
node_modules/node-cron/dist/cjs/time/matcher-walker.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.MatcherWalker = void 0;
|
||||||
|
const convertion_1 = __importDefault(require("../pattern/convertion"));
|
||||||
|
const localized_time_1 = require("./localized-time");
|
||||||
|
const time_matcher_1 = require("./time-matcher");
|
||||||
|
const week_day_names_conversion_1 = __importDefault(require("../pattern/convertion/week-day-names-conversion"));
|
||||||
|
class MatcherWalker {
|
||||||
|
cronExpression;
|
||||||
|
baseDate;
|
||||||
|
pattern;
|
||||||
|
expressions;
|
||||||
|
timeMatcher;
|
||||||
|
timezone;
|
||||||
|
constructor(cronExpression, baseDate, timezone) {
|
||||||
|
this.cronExpression = cronExpression;
|
||||||
|
this.baseDate = baseDate;
|
||||||
|
this.timeMatcher = new time_matcher_1.TimeMatcher(cronExpression, timezone);
|
||||||
|
this.timezone = timezone;
|
||||||
|
this.expressions = (0, convertion_1.default)(cronExpression);
|
||||||
|
}
|
||||||
|
isMatching() {
|
||||||
|
return this.timeMatcher.match(this.baseDate);
|
||||||
|
}
|
||||||
|
matchNext() {
|
||||||
|
const findNextDateIgnoringWeekday = () => {
|
||||||
|
const baseDate = new Date(this.baseDate.getTime());
|
||||||
|
baseDate.setMilliseconds(0);
|
||||||
|
const localTime = new localized_time_1.LocalizedTime(baseDate, this.timezone);
|
||||||
|
const dateParts = localTime.getParts();
|
||||||
|
const date = new localized_time_1.LocalizedTime(localTime.toDate(), this.timezone);
|
||||||
|
const seconds = this.expressions[0];
|
||||||
|
const nextSecond = availableValue(seconds, dateParts.second);
|
||||||
|
if (nextSecond) {
|
||||||
|
date.set('second', nextSecond);
|
||||||
|
if (this.timeMatcher.match(date.toDate())) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
date.set('second', seconds[0]);
|
||||||
|
const minutes = this.expressions[1];
|
||||||
|
const nextMinute = availableValue(minutes, dateParts.minute);
|
||||||
|
if (nextMinute) {
|
||||||
|
date.set('minute', nextMinute);
|
||||||
|
if (this.timeMatcher.match(date.toDate())) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
date.set('minute', minutes[0]);
|
||||||
|
const hours = this.expressions[2];
|
||||||
|
const nextHour = availableValue(hours, dateParts.hour);
|
||||||
|
if (nextHour) {
|
||||||
|
date.set('hour', nextHour);
|
||||||
|
if (this.timeMatcher.match(date.toDate())) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
date.set('hour', hours[0]);
|
||||||
|
const days = this.expressions[3];
|
||||||
|
const nextDay = availableValue(days, dateParts.day);
|
||||||
|
if (nextDay) {
|
||||||
|
date.set('day', nextDay);
|
||||||
|
if (this.timeMatcher.match(date.toDate())) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
date.set('day', days[0]);
|
||||||
|
const months = this.expressions[4];
|
||||||
|
const nextMonth = availableValue(months, dateParts.month);
|
||||||
|
if (nextMonth) {
|
||||||
|
date.set('month', nextMonth);
|
||||||
|
if (this.timeMatcher.match(date.toDate())) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
date.set('year', date.getParts().year + 1);
|
||||||
|
date.set('month', months[0]);
|
||||||
|
return date;
|
||||||
|
};
|
||||||
|
const date = findNextDateIgnoringWeekday();
|
||||||
|
const weekdays = this.expressions[5];
|
||||||
|
let currentWeekday = parseInt((0, week_day_names_conversion_1.default)(date.getParts().weekday));
|
||||||
|
while (!(weekdays.indexOf(currentWeekday) > -1)) {
|
||||||
|
date.set('year', date.getParts().year + 1);
|
||||||
|
currentWeekday = parseInt((0, week_day_names_conversion_1.default)(date.getParts().weekday));
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.MatcherWalker = MatcherWalker;
|
||||||
|
function availableValue(values, currentValue) {
|
||||||
|
const availableValues = values.sort((a, b) => a - b).filter(s => s > currentValue);
|
||||||
|
if (availableValues.length > 0)
|
||||||
|
return availableValues[0];
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=matcher-walker.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/time/matcher-walker.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/time/matcher-walker.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"matcher-walker.js","sourceRoot":"","sources":["../../../src/time/matcher-walker.ts"],"names":[],"mappings":";;;;;;AACA,uEAAsD;AACtD,qDAAiD;AACjD,iDAA6C;AAE7C,gHAAqF;AAErF,MAAa,aAAa;IACxB,cAAc,CAAS;IACvB,QAAQ,CAAO;IACf,OAAO,CAAM;IACb,WAAW,CAAa;IACxB,WAAW,CAAc;IACzB,QAAQ,CAAU;IAElB,YAAY,cAAsB,EAAE,QAAc,EAAE,QAAgB;QAClE,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QAC7D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,CAAC,WAAW,GAAG,IAAA,oBAAiB,EAAC,cAAc,CAAC,CAAA;IACtD,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS;QACP,MAAM,2BAA2B,GAAG,GAAG,EAAE;YACvC,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;YACnD,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,SAAS,GAAG,IAAI,8BAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC7D,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,8BAAa,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,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AAG,2BAA2B,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAErC,IAAI,cAAc,GAAG,QAAQ,CAAC,IAAA,mCAAsB,EAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAE/E,OAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAC,CAAC;YAC9C,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YAC3C,cAAc,GAAG,QAAQ,CAAC,IAAA,mCAAsB,EAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAjGD,sCAiGC;AAED,SAAS,cAAc,CAAC,MAAgB,EAAE,YAAoB;IAC5D,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;IAClF,IAAG,eAAe,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;IACzD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
||||||
8
node_modules/node-cron/dist/cjs/time/time-matcher.d.ts
generated
vendored
Normal file
8
node_modules/node-cron/dist/cjs/time/time-matcher.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export declare class TimeMatcher {
|
||||||
|
timezone?: string;
|
||||||
|
pattern: string;
|
||||||
|
expressions: any[];
|
||||||
|
constructor(pattern: string, timezone?: string);
|
||||||
|
match(date: Date): boolean;
|
||||||
|
getNextMatch(date: Date): Date;
|
||||||
|
}
|
||||||
41
node_modules/node-cron/dist/cjs/time/time-matcher.js
generated
vendored
Normal file
41
node_modules/node-cron/dist/cjs/time/time-matcher.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.TimeMatcher = void 0;
|
||||||
|
const index_1 = __importDefault(require("../pattern/convertion/index"));
|
||||||
|
const week_day_names_conversion_1 = __importDefault(require("../pattern/convertion/week-day-names-conversion"));
|
||||||
|
const localized_time_1 = require("./localized-time");
|
||||||
|
const matcher_walker_1 = require("./matcher-walker");
|
||||||
|
function matchValue(allowedValues, value) {
|
||||||
|
return allowedValues.indexOf(value) !== -1;
|
||||||
|
}
|
||||||
|
class TimeMatcher {
|
||||||
|
timezone;
|
||||||
|
pattern;
|
||||||
|
expressions;
|
||||||
|
constructor(pattern, timezone) {
|
||||||
|
this.timezone = timezone;
|
||||||
|
this.pattern = pattern;
|
||||||
|
this.expressions = (0, index_1.default)(pattern);
|
||||||
|
}
|
||||||
|
match(date) {
|
||||||
|
const localizedTime = new localized_time_1.LocalizedTime(date, this.timezone);
|
||||||
|
const parts = localizedTime.getParts();
|
||||||
|
const runOnSecond = matchValue(this.expressions[0], parts.second);
|
||||||
|
const runOnMinute = matchValue(this.expressions[1], parts.minute);
|
||||||
|
const runOnHour = matchValue(this.expressions[2], parts.hour);
|
||||||
|
const runOnDay = matchValue(this.expressions[3], parts.day);
|
||||||
|
const runOnMonth = matchValue(this.expressions[4], parts.month);
|
||||||
|
const runOnWeekDay = matchValue(this.expressions[5], parseInt((0, week_day_names_conversion_1.default)(parts.weekday)));
|
||||||
|
return runOnSecond && runOnMinute && runOnHour && runOnDay && runOnMonth && runOnWeekDay;
|
||||||
|
}
|
||||||
|
getNextMatch(date) {
|
||||||
|
const walker = new matcher_walker_1.MatcherWalker(this.pattern, date, this.timezone);
|
||||||
|
const next = walker.matchNext();
|
||||||
|
return next.toDate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.TimeMatcher = TimeMatcher;
|
||||||
|
//# sourceMappingURL=time-matcher.js.map
|
||||||
1
node_modules/node-cron/dist/cjs/time/time-matcher.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/cjs/time/time-matcher.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"time-matcher.js","sourceRoot":"","sources":["../../../src/time/time-matcher.ts"],"names":[],"mappings":";;;;;;AACA,wEAA4D;AAC5D,gHAAqF;AACrF,qDAAiD;AACjD,qDAAiD;AAEjD,SAAS,UAAU,CAAC,aAAuB,EAAE,KAAa;IACxD,OAAO,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAa,WAAW;IACpB,QAAQ,CAAU;IAClB,OAAO,CAAS;IAChB,WAAW,CAAQ;IAEnB,YAAY,OAAc,EAAE,QAAgB;QACxC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAA,eAAiB,EAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,IAAU;QACZ,MAAM,aAAa,GAAG,IAAI,8BAAa,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC5D,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC;QACvC,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAClE,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9D,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAChE,MAAM,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAA,mCAAsB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEtG,OAAO,WAAW,IAAI,WAAW,IAAI,SAAS,IAAI,QAAQ,IAAI,UAAU,IAAI,YAAY,CAAC;IAC7F,CAAC;IAED,YAAY,CAAC,IAAU;QACrB,MAAM,MAAM,GAAG,IAAI,8BAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpE,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACJ;AA7BD,kCA6BC"}
|
||||||
1
node_modules/node-cron/dist/esm/create-id.d.ts
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/create-id.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export declare function createID(prefix?: string, length?: number): string;
|
||||||
14
node_modules/node-cron/dist/esm/create-id.js
generated
vendored
Normal file
14
node_modules/node-cron/dist/esm/create-id.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.createID = createID;
|
||||||
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
||||||
|
function createID(prefix = '', length = 16) {
|
||||||
|
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const values = node_crypto_1.default.randomBytes(length);
|
||||||
|
const id = Array.from(values, v => charset[v % charset.length]).join('');
|
||||||
|
return prefix ? `${prefix}-${id}` : id;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=create-id.js.map
|
||||||
1
node_modules/node-cron/dist/esm/create-id.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/create-id.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"create-id.js","sourceRoot":"","sources":["../../src/create-id.ts"],"names":[],"mappings":";;;;;AAEA,4BAKC;AAPD,8DAAiC;AAEjC,SAAgB,QAAQ,CAAC,SAAiB,EAAE,EAAE,SAAiB,EAAE;IAC/D,MAAM,OAAO,GAAG,gEAAgE,CAAC;IACjF,MAAM,MAAM,GAAG,qBAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACzC,CAAC"}
|
||||||
7
node_modules/node-cron/dist/esm/logger.d.ts
generated
vendored
Normal file
7
node_modules/node-cron/dist/esm/logger.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
declare const logger: {
|
||||||
|
info(message: string): void;
|
||||||
|
warn(message: string): void;
|
||||||
|
error(message: string | Error, err?: Error): void;
|
||||||
|
debug(message: string | Error, err?: Error): void;
|
||||||
|
};
|
||||||
|
export default logger;
|
||||||
57
node_modules/node-cron/dist/esm/logger.js
generated
vendored
Normal file
57
node_modules/node-cron/dist/esm/logger.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const levelColors = {
|
||||||
|
INFO: '\x1b[36m',
|
||||||
|
WARN: '\x1b[33m',
|
||||||
|
ERROR: '\x1b[31m',
|
||||||
|
DEBUG: '\x1b[35m',
|
||||||
|
};
|
||||||
|
const GREEN = '\x1b[32m';
|
||||||
|
const RESET = '\x1b[0m';
|
||||||
|
function log(level, message, extra) {
|
||||||
|
const timestamp = new Date().toISOString();
|
||||||
|
const color = levelColors[level] ?? '';
|
||||||
|
const prefix = `[${timestamp}] [PID: ${process.pid}] ${GREEN}[NODE-CRON]${GREEN} ${color}[${level}]${RESET}`;
|
||||||
|
const output = `${prefix} ${message}`;
|
||||||
|
switch (level) {
|
||||||
|
case 'ERROR':
|
||||||
|
console.error(output, extra ?? '');
|
||||||
|
break;
|
||||||
|
case 'DEBUG':
|
||||||
|
console.debug(output, extra ?? '');
|
||||||
|
break;
|
||||||
|
case 'WARN':
|
||||||
|
console.warn(output);
|
||||||
|
break;
|
||||||
|
case 'INFO':
|
||||||
|
default:
|
||||||
|
console.info(output);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const logger = {
|
||||||
|
info(message) {
|
||||||
|
log('INFO', message);
|
||||||
|
},
|
||||||
|
warn(message) {
|
||||||
|
log('WARN', message);
|
||||||
|
},
|
||||||
|
error(message, err) {
|
||||||
|
if (message instanceof Error) {
|
||||||
|
log('ERROR', message.message, message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log('ERROR', message, err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
debug(message, err) {
|
||||||
|
if (message instanceof Error) {
|
||||||
|
log('DEBUG', message.message, message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log('DEBUG', message, err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
exports.default = logger;
|
||||||
|
//# sourceMappingURL=logger.js.map
|
||||||
1
node_modules/node-cron/dist/esm/logger.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/logger.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":";;AAEA,MAAM,WAAW,GAA6B;IAC5C,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,KAAK,GAAG,SAAS,CAAC;AAExB,SAAS,GAAG,CAAC,KAAe,EAAE,OAAe,EAAE,KAAW;IACxD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,SAAS,WAAW,OAAO,CAAC,GAAG,KAAK,KAAK,cAAc,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;IAC7G,MAAM,MAAM,GAAG,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC;IAEtC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,OAAO;YACV,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YACnC,MAAM;QACR,KAAK,OAAO;YACR,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YACnC,MAAM;QACV,KAAK,MAAM;YACT,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,MAAM;QACR,KAAK,MAAM,CAAC;QACZ;YACE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrB,MAAM;IACV,CAAC;AACH,CAAC;AAED,MAAM,MAAM,GAAG;IACb,IAAI,CAAC,OAAe;QAClB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,IAAI,CAAC,OAAe;QAClB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvB,CAAC;IACD,KAAK,CAAC,OAAuB,EAAE,GAAW;QACxC,IAAI,OAAO,YAAY,KAAK,EAAE,CAAC;YAC7B,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,KAAK,CAAC,OAAuB,EAAE,GAAW;QACxC,IAAI,OAAO,YAAY,KAAK,EAAE,CAAC;YAC7B,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
||||||
18
node_modules/node-cron/dist/esm/node-cron.d.ts
generated
vendored
Normal file
18
node_modules/node-cron/dist/esm/node-cron.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { ScheduledTask, TaskFn, TaskOptions } from "./tasks/scheduled-task";
|
||||||
|
export declare function schedule(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
|
||||||
|
export declare function createTask(expression: string, func: TaskFn | string, options?: TaskOptions): ScheduledTask;
|
||||||
|
export declare function solvePath(filePath: string): string;
|
||||||
|
export declare function validate(expression: string): boolean;
|
||||||
|
export declare const getTasks: () => Map<string, ScheduledTask>;
|
||||||
|
export declare const getTask: (taskId: string) => ScheduledTask | undefined;
|
||||||
|
export { ScheduledTask } from './tasks/scheduled-task';
|
||||||
|
export type { TaskFn, TaskContext, TaskOptions } from './tasks/scheduled-task';
|
||||||
|
export interface NodeCron {
|
||||||
|
schedule: typeof schedule;
|
||||||
|
createTask: typeof createTask;
|
||||||
|
validate: typeof validate;
|
||||||
|
getTasks: typeof getTasks;
|
||||||
|
getTask: typeof getTask;
|
||||||
|
}
|
||||||
|
export declare const nodeCron: NodeCron;
|
||||||
|
export default nodeCron;
|
||||||
71
node_modules/node-cron/dist/esm/node-cron.js
generated
vendored
Normal file
71
node_modules/node-cron/dist/esm/node-cron.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.nodeCron = exports.getTask = exports.getTasks = void 0;
|
||||||
|
exports.schedule = schedule;
|
||||||
|
exports.createTask = createTask;
|
||||||
|
exports.solvePath = solvePath;
|
||||||
|
exports.validate = validate;
|
||||||
|
const inline_scheduled_task_1 = require("./tasks/inline-scheduled-task");
|
||||||
|
const task_registry_1 = require("./task-registry");
|
||||||
|
const pattern_validation_1 = __importDefault(require("./pattern/validation/pattern-validation"));
|
||||||
|
const background_scheduled_task_1 = __importDefault(require("./tasks/background-scheduled-task/background-scheduled-task"));
|
||||||
|
const path_1 = __importDefault(require("path"));
|
||||||
|
const url_1 = require("url");
|
||||||
|
const registry = new task_registry_1.TaskRegistry();
|
||||||
|
function schedule(expression, func, options) {
|
||||||
|
const task = createTask(expression, func, options);
|
||||||
|
task.start();
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
function createTask(expression, func, options) {
|
||||||
|
let task;
|
||||||
|
if (func instanceof Function) {
|
||||||
|
task = new inline_scheduled_task_1.InlineScheduledTask(expression, func, options);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const taskPath = solvePath(func);
|
||||||
|
task = new background_scheduled_task_1.default(expression, taskPath, options);
|
||||||
|
}
|
||||||
|
registry.add(task);
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
function solvePath(filePath) {
|
||||||
|
if (path_1.default.isAbsolute(filePath))
|
||||||
|
return (0, url_1.pathToFileURL)(filePath).href;
|
||||||
|
if (filePath.startsWith('file://'))
|
||||||
|
return filePath;
|
||||||
|
const stackLines = new Error().stack?.split('\n');
|
||||||
|
if (stackLines) {
|
||||||
|
stackLines?.shift();
|
||||||
|
const callerLine = stackLines?.find((line) => { return line.indexOf(__filename) === -1; });
|
||||||
|
const match = callerLine?.match(/(file:\/\/)?(((\/?)(\w:))?([/\\].+)):\d+:\d+/);
|
||||||
|
if (match) {
|
||||||
|
const dir = `${match[5] ?? ""}${path_1.default.dirname(match[6])}`;
|
||||||
|
return (0, url_1.pathToFileURL)(path_1.default.resolve(dir, filePath)).href;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error(`Could not locate task file ${filePath}`);
|
||||||
|
}
|
||||||
|
function validate(expression) {
|
||||||
|
try {
|
||||||
|
(0, pattern_validation_1.default)(expression);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.getTasks = registry.all;
|
||||||
|
exports.getTask = registry.get;
|
||||||
|
exports.nodeCron = {
|
||||||
|
schedule,
|
||||||
|
createTask,
|
||||||
|
validate,
|
||||||
|
getTasks: exports.getTasks,
|
||||||
|
getTask: exports.getTask,
|
||||||
|
};
|
||||||
|
exports.default = exports.nodeCron;
|
||||||
|
//# sourceMappingURL=node-cron.js.map
|
||||||
1
node_modules/node-cron/dist/esm/node-cron.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/node-cron.js.map
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pattern/convertion/asterisk-to-range-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/esm/pattern/convertion/asterisk-to-range-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expressions: any) => any;
|
||||||
|
export default _default;
|
||||||
21
node_modules/node-cron/dist/esm/pattern/convertion/asterisk-to-range-conversion.js
generated
vendored
Normal file
21
node_modules/node-cron/dist/esm/pattern/convertion/asterisk-to-range-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
function convertAsterisk(expression, replecement) {
|
||||||
|
if (expression.indexOf('*') !== -1) {
|
||||||
|
return expression.replace('*', replecement);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function convertAsterisksToRanges(expressions) {
|
||||||
|
expressions[0] = convertAsterisk(expressions[0], '0-59');
|
||||||
|
expressions[1] = convertAsterisk(expressions[1], '0-59');
|
||||||
|
expressions[2] = convertAsterisk(expressions[2], '0-23');
|
||||||
|
expressions[3] = convertAsterisk(expressions[3], '1-31');
|
||||||
|
expressions[4] = convertAsterisk(expressions[4], '1-12');
|
||||||
|
expressions[5] = convertAsterisk(expressions[5], '0-6');
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
return convertAsterisksToRanges;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=asterisk-to-range-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/esm/pattern/convertion/asterisk-to-range-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/pattern/convertion/asterisk-to-range-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"asterisk-to-range-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/asterisk-to-range-conversion.ts"],"names":[],"mappings":";;AACA,kBAAe,CAAC,GAAG,EAAE;IACjB,SAAS,eAAe,CAAC,UAAU,EAAE,WAAW;QAC5C,IAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAC,CAAC;YAC/B,OAAO,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,SAAS,wBAAwB,CAAC,WAAW;QACzC,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACzD,WAAW,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QACxD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,OAAO,wBAAwB,CAAC;AACpC,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/esm/pattern/convertion/index.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/esm/pattern/convertion/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expression: any) => any;
|
||||||
|
export default _default;
|
||||||
42
node_modules/node-cron/dist/esm/pattern/convertion/index.js
generated
vendored
Normal file
42
node_modules/node-cron/dist/esm/pattern/convertion/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const month_names_conversion_1 = __importDefault(require("./month-names-conversion"));
|
||||||
|
const week_day_names_conversion_1 = __importDefault(require("./week-day-names-conversion"));
|
||||||
|
const asterisk_to_range_conversion_1 = __importDefault(require("./asterisk-to-range-conversion"));
|
||||||
|
const range_conversion_1 = __importDefault(require("./range-conversion"));
|
||||||
|
exports.default = (() => {
|
||||||
|
function appendSeccondExpression(expressions) {
|
||||||
|
if (expressions.length === 5) {
|
||||||
|
return ['0'].concat(expressions);
|
||||||
|
}
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
function removeSpaces(str) {
|
||||||
|
return str.replace(/\s{2,}/g, ' ').trim();
|
||||||
|
}
|
||||||
|
function normalizeIntegers(expressions) {
|
||||||
|
for (let i = 0; i < expressions.length; i++) {
|
||||||
|
const numbers = expressions[i].split(',');
|
||||||
|
for (let j = 0; j < numbers.length; j++) {
|
||||||
|
numbers[j] = parseInt(numbers[j]);
|
||||||
|
}
|
||||||
|
expressions[i] = numbers;
|
||||||
|
}
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
function interprete(expression) {
|
||||||
|
let expressions = removeSpaces(`${expression}`).split(' ');
|
||||||
|
expressions = appendSeccondExpression(expressions);
|
||||||
|
expressions[4] = (0, month_names_conversion_1.default)(expressions[4]);
|
||||||
|
expressions[5] = (0, week_day_names_conversion_1.default)(expressions[5]);
|
||||||
|
expressions = (0, asterisk_to_range_conversion_1.default)(expressions);
|
||||||
|
expressions = (0, range_conversion_1.default)(expressions);
|
||||||
|
expressions = normalizeIntegers(expressions);
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
return interprete;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
1
node_modules/node-cron/dist/esm/pattern/convertion/index.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/pattern/convertion/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/index.ts"],"names":[],"mappings":";;;;;AAAA,sFAA4D;AAC5D,4FAAiE;AACjE,kGAAsE;AACtE,0EAA+C;AAE/C,kBAAe,CAAC,GAAG,EAAE;IAEjB,SAAS,uBAAuB,CAAC,WAAW;QACxC,IAAG,WAAW,CAAC,MAAM,KAAK,CAAC,EAAC,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,SAAS,YAAY,CAAC,GAAG;QACrB,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IAGD,SAAS,iBAAiB,CAAC,WAAW;QAClC,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;YACvC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1C,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;gBACjC,OAAO,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;YACD,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;QAC7B,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAmBD,SAAS,UAAU,CAAC,UAAU;QAC1B,IAAI,WAAW,GAAG,YAAY,CAAC,GAAG,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3D,WAAW,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACnD,WAAW,CAAC,CAAC,CAAC,GAAG,IAAA,gCAAoB,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QACtD,WAAW,CAAC,CAAC,CAAC,GAAG,IAAA,mCAAsB,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QACxD,WAAW,GAAG,IAAA,sCAAwB,EAAC,WAAW,CAAC,CAAC;QACpD,WAAW,GAAG,IAAA,0BAAa,EAAC,WAAW,CAAC,CAAC;QAEzC,WAAW,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAE7C,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/esm/pattern/convertion/month-names-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/esm/pattern/convertion/month-names-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (monthExpression: any) => any;
|
||||||
|
export default _default;
|
||||||
21
node_modules/node-cron/dist/esm/pattern/convertion/month-names-conversion.js
generated
vendored
Normal file
21
node_modules/node-cron/dist/esm/pattern/convertion/month-names-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
const months = ['january', 'february', 'march', 'april', 'may', 'june', 'july',
|
||||||
|
'august', 'september', 'october', 'november', 'december'];
|
||||||
|
const shortMonths = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug',
|
||||||
|
'sep', 'oct', 'nov', 'dec'];
|
||||||
|
function convertMonthName(expression, items) {
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
expression = expression.replace(new RegExp(items[i], 'gi'), i + 1);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function interprete(monthExpression) {
|
||||||
|
monthExpression = convertMonthName(monthExpression, months);
|
||||||
|
monthExpression = convertMonthName(monthExpression, shortMonths);
|
||||||
|
return monthExpression;
|
||||||
|
}
|
||||||
|
return interprete;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=month-names-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/esm/pattern/convertion/month-names-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/pattern/convertion/month-names-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"month-names-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/month-names-conversion.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,GAAG,EAAE;IACjB,MAAM,MAAM,GAAG,CAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAC,OAAO,EAAC,KAAK,EAAC,MAAM,EAAC,MAAM;QACpE,QAAQ,EAAC,WAAW,EAAC,SAAS,EAAC,UAAU,EAAC,UAAU,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;QACvE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAEhC,SAAS,gBAAgB,CAAC,UAAU,EAAE,KAAK;QACvC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;YAClC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,SAAS,UAAU,CAAC,eAAe;QAC/B,eAAe,GAAG,gBAAgB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;QAC5D,eAAe,GAAG,gBAAgB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QACjE,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/esm/pattern/convertion/range-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/esm/pattern/convertion/range-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expressions: any) => any;
|
||||||
|
export default _default;
|
||||||
35
node_modules/node-cron/dist/esm/pattern/convertion/range-conversion.js
generated
vendored
Normal file
35
node_modules/node-cron/dist/esm/pattern/convertion/range-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
function replaceWithRange(expression, text, init, end, stepTxt) {
|
||||||
|
const step = parseInt(stepTxt);
|
||||||
|
const numbers = [];
|
||||||
|
let last = parseInt(end);
|
||||||
|
let first = parseInt(init);
|
||||||
|
if (first > last) {
|
||||||
|
last = parseInt(init);
|
||||||
|
first = parseInt(end);
|
||||||
|
}
|
||||||
|
for (let i = first; i <= last; i += step) {
|
||||||
|
numbers.push(i);
|
||||||
|
}
|
||||||
|
return expression.replace(new RegExp(text, 'i'), numbers.join());
|
||||||
|
}
|
||||||
|
function convertRange(expression) {
|
||||||
|
const rangeRegEx = /(\d+)-(\d+)(\/(\d+)|)/;
|
||||||
|
let match = rangeRegEx.exec(expression);
|
||||||
|
while (match !== null && match.length > 0) {
|
||||||
|
expression = replaceWithRange(expression, match[0], match[1], match[2], match[4] || '1');
|
||||||
|
match = rangeRegEx.exec(expression);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function convertAllRanges(expressions) {
|
||||||
|
for (let i = 0; i < expressions.length; i++) {
|
||||||
|
expressions[i] = convertRange(expressions[i]);
|
||||||
|
}
|
||||||
|
return expressions;
|
||||||
|
}
|
||||||
|
return convertAllRanges;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=range-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/esm/pattern/convertion/range-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/pattern/convertion/range-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"range-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/range-conversion.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAE,GAAG,EAAE;IAClB,SAAS,gBAAgB,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO;QAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/B,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAE3B,IAAG,KAAK,GAAG,IAAI,EAAC,CAAC;YACb,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YACtB,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QAED,KAAI,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;YACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;QAED,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,SAAS,YAAY,CAAC,UAAU;QAC5B,MAAM,UAAU,GAAG,uBAAuB,CAAC;QAC3C,IAAI,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACxC,OAAM,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAC,CAAC;YACtC,UAAU,GAAG,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;YACzF,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,SAAS,gBAAgB,CAAC,WAAW;QACjC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;YACxC,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC5B,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/esm/pattern/convertion/week-day-names-conversion.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/esm/pattern/convertion/week-day-names-conversion.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare const _default: (expression: any) => any;
|
||||||
|
export default _default;
|
||||||
20
node_modules/node-cron/dist/esm/pattern/convertion/week-day-names-conversion.js
generated
vendored
Normal file
20
node_modules/node-cron/dist/esm/pattern/convertion/week-day-names-conversion.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.default = (() => {
|
||||||
|
const weekDays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday',
|
||||||
|
'friday', 'saturday'];
|
||||||
|
const shortWeekDays = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
|
||||||
|
function convertWeekDayName(expression, items) {
|
||||||
|
for (let i = 0; i < items.length; i++) {
|
||||||
|
expression = expression.replace(new RegExp(items[i], 'gi'), i);
|
||||||
|
}
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
function convertWeekDays(expression) {
|
||||||
|
expression = expression.replace('7', '0');
|
||||||
|
expression = convertWeekDayName(expression, weekDays);
|
||||||
|
return convertWeekDayName(expression, shortWeekDays);
|
||||||
|
}
|
||||||
|
return convertWeekDays;
|
||||||
|
})();
|
||||||
|
//# sourceMappingURL=week-day-names-conversion.js.map
|
||||||
1
node_modules/node-cron/dist/esm/pattern/convertion/week-day-names-conversion.js.map
generated
vendored
Normal file
1
node_modules/node-cron/dist/esm/pattern/convertion/week-day-names-conversion.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"week-day-names-conversion.js","sourceRoot":"","sources":["../../../../src/pattern/convertion/week-day-names-conversion.ts"],"names":[],"mappings":";;AAAA,kBAAe,CAAC,GAAG,EAAE;IACjB,MAAM,QAAQ,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU;QACpE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC1B,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAExE,SAAS,kBAAkB,CAAC,UAAU,EAAE,KAAK;QACzC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC,CAAC;YAClC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,SAAS,eAAe,CAAC,UAAU;QAC/B,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC1C,UAAU,GAAG,kBAAkB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACtD,OAAO,kBAAkB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,eAAe,CAAC;AAC3B,CAAC,CAAC,EAAE,CAAC"}
|
||||||
2
node_modules/node-cron/dist/esm/pattern/validation/pattern-validation.d.ts
generated
vendored
Normal file
2
node_modules/node-cron/dist/esm/pattern/validation/pattern-validation.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
declare function validate(pattern: any): void;
|
||||||
|
export default validate;
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user