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;
}
}