@volontariapp/workers 0.1.0-snap-ee35df4 → 0.1.0-snap-c4aad21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/base.worker.d.ts +6 -0
- package/dist/core/base.worker.d.ts.map +1 -1
- package/dist/core/base.worker.js +79 -0
- package/dist/core/base.worker.js.map +1 -1
- package/dist/data/entities/job-audit.entity.d.ts +15 -0
- package/dist/data/entities/job-audit.entity.d.ts.map +1 -0
- package/dist/data/entities/job-audit.entity.js +14 -0
- package/dist/data/entities/job-audit.entity.js.map +1 -0
- package/dist/data/index.d.ts +5 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +5 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/models/job-audit.model.d.ts +15 -0
- package/dist/data/models/job-audit.model.d.ts.map +1 -0
- package/dist/data/models/job-audit.model.js +73 -0
- package/dist/data/models/job-audit.model.js.map +1 -0
- package/dist/data/repositories/job-audit.repository.d.ts +8 -0
- package/dist/data/repositories/job-audit.repository.d.ts.map +1 -0
- package/dist/data/repositories/job-audit.repository.js +30 -0
- package/dist/data/repositories/job-audit.repository.js.map +1 -0
- package/dist/data/types/job-audit.status.d.ts +7 -0
- package/dist/data/types/job-audit.status.d.ts.map +1 -0
- package/dist/data/types/job-audit.status.js +8 -0
- package/dist/data/types/job-audit.status.js.map +1 -0
- package/package.json +2 -1
|
@@ -2,10 +2,16 @@ import { WorkerHost } from '@nestjs/bullmq';
|
|
|
2
2
|
import { Logger } from '@volontariapp/logger';
|
|
3
3
|
import type { Job } from 'bullmq';
|
|
4
4
|
import type { JobMessagingType, JobRegistry } from '@volontariapp/messaging';
|
|
5
|
+
import type { JobAuditRepository } from '../data/index.js';
|
|
5
6
|
export declare abstract class BaseWorker<K extends JobMessagingType> extends WorkerHost {
|
|
7
|
+
protected readonly auditRepo?: JobAuditRepository | undefined;
|
|
6
8
|
protected readonly logger: Logger;
|
|
7
9
|
protected readonly workerId: string;
|
|
10
|
+
constructor(auditRepo?: JobAuditRepository | undefined);
|
|
8
11
|
process(job: Job<JobRegistry[K], void, K>, _token?: string): Promise<void>;
|
|
9
12
|
protected abstract processJob(job: Job<JobRegistry[K], void, K>): Promise<void>;
|
|
13
|
+
private recordAuditStart;
|
|
14
|
+
private recordAuditSuccess;
|
|
15
|
+
private recordAuditFailure;
|
|
10
16
|
}
|
|
11
17
|
//# sourceMappingURL=base.worker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.worker.d.ts","sourceRoot":"","sources":["../../src/core/base.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"base.worker.d.ts","sourceRoot":"","sources":["../../src/core/base.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,8BAAsB,UAAU,CAAC,CAAC,SAAS,gBAAgB,CAAE,SAAQ,UAAU;IAIjE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,kBAAkB;IAH7D,SAAS,CAAC,QAAQ,CAAC,MAAM,SAAkD;IAC3E,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAc;gBAElB,SAAS,CAAC,EAAE,kBAAkB,YAAA;IAIvD,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA+BhF,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAEjE,gBAAgB;YA0BhB,kBAAkB;YAuBlB,kBAAkB;CA+BjC"}
|
package/dist/core/base.worker.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { WorkerHost } from '@nestjs/bullmq';
|
|
2
2
|
import { Logger } from '@volontariapp/logger';
|
|
3
3
|
import { hostname } from 'node:os';
|
|
4
|
+
import { JobAuditStatus } from '../data/index.js';
|
|
4
5
|
export class BaseWorker extends WorkerHost {
|
|
6
|
+
auditRepo;
|
|
5
7
|
logger = new Logger({ context: this.constructor.name });
|
|
6
8
|
workerId = hostname();
|
|
9
|
+
constructor(auditRepo) {
|
|
10
|
+
super();
|
|
11
|
+
this.auditRepo = auditRepo;
|
|
12
|
+
}
|
|
7
13
|
async process(job, _token) {
|
|
8
14
|
this.logger.info('Processing job', {
|
|
9
15
|
jobId: job.id,
|
|
10
16
|
type: job.name,
|
|
11
17
|
workerId: this.workerId,
|
|
12
18
|
});
|
|
19
|
+
const startedAt = new Date();
|
|
20
|
+
await this.recordAuditStart(job, startedAt);
|
|
13
21
|
try {
|
|
14
22
|
await this.processJob(job);
|
|
15
23
|
this.logger.info('Job completed', {
|
|
@@ -17,6 +25,7 @@ export class BaseWorker extends WorkerHost {
|
|
|
17
25
|
type: job.name,
|
|
18
26
|
workerId: this.workerId,
|
|
19
27
|
});
|
|
28
|
+
await this.recordAuditSuccess(job);
|
|
20
29
|
}
|
|
21
30
|
catch (error) {
|
|
22
31
|
this.logger.error('Job failed', {
|
|
@@ -25,8 +34,78 @@ export class BaseWorker extends WorkerHost {
|
|
|
25
34
|
workerId: this.workerId,
|
|
26
35
|
error,
|
|
27
36
|
});
|
|
37
|
+
await this.recordAuditFailure(job, error);
|
|
28
38
|
throw error;
|
|
29
39
|
}
|
|
30
40
|
}
|
|
41
|
+
async recordAuditStart(job, startedAt) {
|
|
42
|
+
if (!this.auditRepo || !job.id)
|
|
43
|
+
return;
|
|
44
|
+
try {
|
|
45
|
+
await this.auditRepo.upsert({
|
|
46
|
+
jobId: job.id,
|
|
47
|
+
jobType: job.name,
|
|
48
|
+
status: JobAuditStatus.PROCESSING,
|
|
49
|
+
workerId: this.workerId,
|
|
50
|
+
currentAttempt: job.attemptsMade + 1,
|
|
51
|
+
startedAt,
|
|
52
|
+
}, ['jobId']);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.logger.error('Failed to record audit start', {
|
|
56
|
+
jobId: job.id,
|
|
57
|
+
error,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async recordAuditSuccess(job) {
|
|
62
|
+
if (!this.auditRepo || !job.id) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
await this.auditRepo
|
|
67
|
+
.createQueryBuilder()
|
|
68
|
+
.update()
|
|
69
|
+
.set({
|
|
70
|
+
status: JobAuditStatus.COMPLETED,
|
|
71
|
+
finishedAt: new Date(),
|
|
72
|
+
})
|
|
73
|
+
.where('jobId = :jobId', { jobId: job.id })
|
|
74
|
+
.execute();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.logger.error('Failed to record audit success', {
|
|
78
|
+
jobId: job.id,
|
|
79
|
+
error,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async recordAuditFailure(job, error) {
|
|
84
|
+
if (!this.auditRepo || !job.id) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
89
|
+
const errorStack = error instanceof Error ? error.stack : undefined;
|
|
90
|
+
await this.auditRepo
|
|
91
|
+
.createQueryBuilder()
|
|
92
|
+
.update()
|
|
93
|
+
.set({
|
|
94
|
+
status: JobAuditStatus.FAILED,
|
|
95
|
+
errorMessage,
|
|
96
|
+
errorStack,
|
|
97
|
+
finishedAt: new Date(),
|
|
98
|
+
currentAttempt: job.attemptsMade + 1,
|
|
99
|
+
})
|
|
100
|
+
.where('jobId = :jobId', { jobId: job.id })
|
|
101
|
+
.execute();
|
|
102
|
+
}
|
|
103
|
+
catch (auditError) {
|
|
104
|
+
this.logger.error('Failed to record audit failure', {
|
|
105
|
+
jobId: job.id,
|
|
106
|
+
error: auditError,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
31
110
|
}
|
|
32
111
|
//# sourceMappingURL=base.worker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.worker.js","sourceRoot":"","sources":["../../src/core/base.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,MAAM,OAAgB,UAAuC,SAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"base.worker.js","sourceRoot":"","sources":["../../src/core/base.worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,OAAgB,UAAuC,SAAQ,UAAU;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;gBACb,KAAK;aACN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAC9B,GAAiC,EACjC,KAAc;QAEd,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YAC/B,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC5E,MAAM,UAAU,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;YAEpE,MAAM,IAAI,CAAC,SAAS;iBACjB,kBAAkB,EAAE;iBACpB,MAAM,EAAE;iBACR,GAAG,CAAC;gBACH,MAAM,EAAE,cAAc,CAAC,MAAM;gBAC7B,YAAY;gBACZ,UAAU;gBACV,UAAU,EAAE,IAAI,IAAI,EAAE;gBACtB,cAAc,EAAE,GAAG,CAAC,YAAY,GAAG,CAAC;aACrC,CAAC;iBACD,KAAK,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;iBAC1C,OAAO,EAAE,CAAC;QACf,CAAC;QAAC,OAAO,UAAmB,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE;gBAClD,KAAK,EAAE,GAAG,CAAC,EAAE;gBACb,KAAK,EAAE,UAAU;aAClB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseEntity } from '@volontariapp/database';
|
|
2
|
+
import type { JobAuditStatus } from '../types/job-audit.status.js';
|
|
3
|
+
export declare class JobAuditEntity extends BaseEntity {
|
|
4
|
+
jobId: string;
|
|
5
|
+
jobType: string;
|
|
6
|
+
status: JobAuditStatus;
|
|
7
|
+
workerId: string;
|
|
8
|
+
currentAttempt: number;
|
|
9
|
+
startedAt?: Date;
|
|
10
|
+
finishedAt?: Date;
|
|
11
|
+
resultPayload?: Record<string, unknown>;
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
errorStack?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=job-audit.entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.entity.d.ts","sourceRoot":"","sources":["../../../src/data/entities/job-audit.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,qBAAa,cAAe,SAAQ,UAAU;IAC5C,KAAK,EAAG,MAAM,CAAC;IAEf,OAAO,EAAG,MAAM,CAAC;IAEjB,MAAM,EAAG,cAAc,CAAC;IAExB,QAAQ,EAAG,MAAM,CAAC;IAElB,cAAc,EAAG,MAAM,CAAC;IAExB,SAAS,CAAC,EAAE,IAAI,CAAC;IAEjB,UAAU,CAAC,EAAE,IAAI,CAAC;IAElB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAExC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseEntity } from '@volontariapp/database';
|
|
2
|
+
export class JobAuditEntity extends BaseEntity {
|
|
3
|
+
jobId;
|
|
4
|
+
jobType;
|
|
5
|
+
status;
|
|
6
|
+
workerId;
|
|
7
|
+
currentAttempt;
|
|
8
|
+
startedAt;
|
|
9
|
+
finishedAt;
|
|
10
|
+
resultPayload;
|
|
11
|
+
errorMessage;
|
|
12
|
+
errorStack;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=job-audit.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.entity.js","sourceRoot":"","sources":["../../../src/data/entities/job-audit.entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,KAAK,CAAU;IAEf,OAAO,CAAU;IAEjB,MAAM,CAAkB;IAExB,QAAQ,CAAU;IAElB,cAAc,CAAU;IAExB,SAAS,CAAQ;IAEjB,UAAU,CAAQ;IAElB,aAAa,CAA2B;IAExC,YAAY,CAAU;IAEtB,UAAU,CAAU;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseModel } from '@volontariapp/database';
|
|
2
|
+
import { JobAuditStatus } from '../types/job-audit.status.js';
|
|
3
|
+
export declare class JobAuditModel extends BaseModel {
|
|
4
|
+
jobId: string;
|
|
5
|
+
jobType: string;
|
|
6
|
+
status: JobAuditStatus;
|
|
7
|
+
workerId: string;
|
|
8
|
+
currentAttempt: number;
|
|
9
|
+
startedAt?: Date;
|
|
10
|
+
finishedAt?: Date;
|
|
11
|
+
resultPayload?: Record<string, unknown>;
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
errorStack?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=job-audit.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.model.d.ts","sourceRoot":"","sources":["../../../src/data/models/job-audit.model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,qBAKa,aAAc,SAAQ,SAAS;IAE1C,KAAK,EAAG,MAAM,CAAC;IAGf,OAAO,EAAG,MAAM,CAAC;IAGjB,MAAM,EAAE,cAAc,CAA0B;IAGhD,QAAQ,EAAG,MAAM,CAAC;IAGlB,cAAc,EAAE,MAAM,CAAK;IAG3B,SAAS,CAAC,EAAE,IAAI,CAAC;IAGjB,UAAU,CAAC,EAAE,IAAI,CAAC;IAGlB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGxC,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Column, Entity, Index } from 'typeorm';
|
|
11
|
+
import { BaseModel } from '@volontariapp/database';
|
|
12
|
+
import { JobAuditStatus } from '../types/job-audit.status.js';
|
|
13
|
+
let JobAuditModel = class JobAuditModel extends BaseModel {
|
|
14
|
+
jobId;
|
|
15
|
+
jobType;
|
|
16
|
+
status = JobAuditStatus.PENDING;
|
|
17
|
+
workerId;
|
|
18
|
+
currentAttempt = 1;
|
|
19
|
+
startedAt;
|
|
20
|
+
finishedAt;
|
|
21
|
+
resultPayload;
|
|
22
|
+
errorMessage;
|
|
23
|
+
errorStack;
|
|
24
|
+
};
|
|
25
|
+
__decorate([
|
|
26
|
+
Column({ type: 'varchar', length: 100 }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], JobAuditModel.prototype, "jobId", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
Column({ type: 'varchar', length: 255 }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], JobAuditModel.prototype, "jobType", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
Column({ type: 'varchar', length: 20, default: JobAuditStatus.PENDING }),
|
|
35
|
+
__metadata("design:type", String)
|
|
36
|
+
], JobAuditModel.prototype, "status", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
Column({ type: 'varchar', length: 255 }),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], JobAuditModel.prototype, "workerId", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
Column({ name: 'current_attempt', type: 'int', default: 1 }),
|
|
43
|
+
__metadata("design:type", Number)
|
|
44
|
+
], JobAuditModel.prototype, "currentAttempt", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
Column({ name: 'started_at', type: 'timestamp', nullable: true }),
|
|
47
|
+
__metadata("design:type", Date)
|
|
48
|
+
], JobAuditModel.prototype, "startedAt", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
Column({ name: 'finished_at', type: 'timestamp', nullable: true }),
|
|
51
|
+
__metadata("design:type", Date)
|
|
52
|
+
], JobAuditModel.prototype, "finishedAt", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
Column({ name: 'result_payload', type: 'jsonb', nullable: true }),
|
|
55
|
+
__metadata("design:type", Object)
|
|
56
|
+
], JobAuditModel.prototype, "resultPayload", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
Column({ name: 'error_message', type: 'text', nullable: true }),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], JobAuditModel.prototype, "errorMessage", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
Column({ name: 'error_stack', type: 'text', nullable: true }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], JobAuditModel.prototype, "errorStack", void 0);
|
|
65
|
+
JobAuditModel = __decorate([
|
|
66
|
+
Entity('job_audit'),
|
|
67
|
+
Index(['jobId']),
|
|
68
|
+
Index(['jobType']),
|
|
69
|
+
Index(['workerId']),
|
|
70
|
+
Index(['status'])
|
|
71
|
+
], JobAuditModel);
|
|
72
|
+
export { JobAuditModel };
|
|
73
|
+
//# sourceMappingURL=job-audit.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.model.js","sourceRoot":"","sources":["../../../src/data/models/job-audit.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAOvD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,SAAS;IAE1C,KAAK,CAAU;IAGf,OAAO,CAAU;IAGjB,MAAM,GAAmB,cAAc,CAAC,OAAO,CAAC;IAGhD,QAAQ,CAAU;IAGlB,cAAc,GAAW,CAAC,CAAC;IAG3B,SAAS,CAAQ;IAGjB,UAAU,CAAQ;IAGlB,aAAa,CAA2B;IAGxC,YAAY,CAAU;IAGtB,UAAU,CAAU;CACrB,CAAA;AA5BC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AAK,CAAC,CAAC,SAAS,CAAC,CAAC;IAClB,KAAK,CAAC,CAAC,UAAU,CAAC,CAAC;IACnB,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC;GACL,aAAa,CA8BzB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { BaseRepository } from '@volontariapp/database';
|
|
3
|
+
import { JobAuditEntity } from '../entities/job-audit.entity.js';
|
|
4
|
+
import { JobAuditModel } from '../models/job-audit.model.js';
|
|
5
|
+
export declare class JobAuditRepository extends BaseRepository<JobAuditModel, JobAuditEntity> {
|
|
6
|
+
constructor(repository: Repository<JobAuditModel>);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=job-audit.repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.repository.d.ts","sourceRoot":"","sources":["../../../src/data/repositories/job-audit.repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,qBACa,kBAAmB,SAAQ,cAAc,CAAC,aAAa,EAAE,cAAc,CAAC;gBAGjF,UAAU,EAAE,UAAU,CAAC,aAAa,CAAC;CAIxC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Injectable } from '@nestjs/common';
|
|
14
|
+
import { InjectRepository } from '@nestjs/typeorm';
|
|
15
|
+
import { Repository } from 'typeorm';
|
|
16
|
+
import { BaseRepository } from '@volontariapp/database';
|
|
17
|
+
import { JobAuditEntity } from '../entities/job-audit.entity.js';
|
|
18
|
+
import { JobAuditModel } from '../models/job-audit.model.js';
|
|
19
|
+
let JobAuditRepository = class JobAuditRepository extends BaseRepository {
|
|
20
|
+
constructor(repository) {
|
|
21
|
+
super(repository, JobAuditEntity, JobAuditModel);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
JobAuditRepository = __decorate([
|
|
25
|
+
Injectable(),
|
|
26
|
+
__param(0, InjectRepository(JobAuditModel)),
|
|
27
|
+
__metadata("design:paramtypes", [Repository])
|
|
28
|
+
], JobAuditRepository);
|
|
29
|
+
export { JobAuditRepository };
|
|
30
|
+
//# sourceMappingURL=job-audit.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.repository.js","sourceRoot":"","sources":["../../../src/data/repositories/job-audit.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGtD,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,cAA6C;IACnF,YAEE,UAAqC;QAErC,KAAK,CAAC,UAAU,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;IACnD,CAAC;CACF,CAAA;AAPY,kBAAkB;IAD9B,UAAU,EAAE;IAGR,WAAA,gBAAgB,CAAC,aAAa,CAAC,CAAA;qCACpB,UAAU;GAHb,kBAAkB,CAO9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.status.d.ts","sourceRoot":"","sources":["../../../src/data/types/job-audit.status.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,MAAM,WAAW;CAClB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var JobAuditStatus;
|
|
2
|
+
(function (JobAuditStatus) {
|
|
3
|
+
JobAuditStatus["PENDING"] = "PENDING";
|
|
4
|
+
JobAuditStatus["PROCESSING"] = "PROCESSING";
|
|
5
|
+
JobAuditStatus["COMPLETED"] = "COMPLETED";
|
|
6
|
+
JobAuditStatus["FAILED"] = "FAILED";
|
|
7
|
+
})(JobAuditStatus || (JobAuditStatus = {}));
|
|
8
|
+
//# sourceMappingURL=job-audit.status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-audit.status.js","sourceRoot":"","sources":["../../../src/data/types/job-audit.status.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,2CAAyB,CAAA;IACzB,yCAAuB,CAAA;IACvB,mCAAiB,CAAA;AACnB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volontariapp/workers",
|
|
3
|
-
"version": "0.1.0-snap-
|
|
3
|
+
"version": "0.1.0-snap-c4aad21",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@nestjs/common": "^11.0.0",
|
|
51
51
|
"@types/jest": "^30.0.0",
|
|
52
52
|
"@types/node": "^24.0.0",
|
|
53
|
+
"@volontariapp/testing": "1.0.0",
|
|
53
54
|
"bullmq": "^5.76.5",
|
|
54
55
|
"jest": "^30.3.0",
|
|
55
56
|
"ts-jest": "^29.4.6",
|