feat: ajout de la gestion des jobs avec création, récupération, suppression et filtrage via l'API, incluant des entités, des composants Vue.js et des mises à jour de la documentation API

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-03-30 16:14:17 +02:00
parent 4d1d5b9f21
commit fd2d3cd640
21 changed files with 1538 additions and 184 deletions

View File

@@ -0,0 +1,50 @@
export class Job {
constructor({
id,
type,
status,
progress = 0,
payload = {},
result = null,
error = null,
createdAt = new Date().toISOString(),
updatedAt = new Date().toISOString()
}) {
this.id = id;
this.type = type;
this.status = status;
this.progress = progress;
this.payload = payload;
this.result = result;
this.error = error;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
}
static create(data) {
return new Job(data);
}
isActive() {
return ['PENDING', 'IN_PROGRESS'].includes(this.status);
}
hasError() {
return this.status === 'ERROR';
}
isCompleted() {
return this.status === 'COMPLETED';
}
}
export class JobCollection {
constructor(items, total, page, limit, hasNextPage, hasPreviousPage) {
this.items = items.map(item => Job.create(item));
this.total = total;
this.page = page;
this.limit = limit;
this.hasNextPage = hasNextPage;
this.hasPreviousPage = hasPreviousPage;
}
}

View File

@@ -0,0 +1,42 @@
export class JobRepositoryInterface {
/**
* Récupère la liste des jobs
* @param {Object} options Les options de filtrage et pagination
* @param {number} options.page Numéro de la page
* @param {number} options.limit Nombre d'éléments par page
* @param {string} options.sortBy Champ pour le tri
* @param {string} options.sortOrder Direction du tri ('ASC' ou 'DESC')
* @param {Array<string>} options.status Liste des statuts à filtrer
* @returns {Promise<JobCollection>} Collection de jobs
*/
async getJobs(options) {
throw new Error('Not implemented');
}
/**
* Récupère un job par son ID
* @param {string} id Identifiant du job
* @returns {Promise<Job>} Job
*/
async getJobById(id) {
throw new Error('Not implemented');
}
/**
* Supprime un job
* @param {string} id Identifiant du job
* @returns {Promise<boolean>} Succès de l'opération
*/
async deleteJob(id) {
throw new Error('Not implemented');
}
/**
* Supprime tous les jobs correspondant aux critères
* @param {Object} criteria Critères de suppression
* @returns {Promise<number>} Nombre de jobs supprimés
*/
async deleteJobs(criteria) {
throw new Error('Not implemented');
}
}