Class: BackgroundJobRunRepository
Defined in: server/background-jobs/background-job-run-repository.ts:29
Repository for background_job_runs rows — the opt-in job-runs audit table.
Extends BaseRepository<PrismaClient, Tx<PrismaClient>> so this.tx
resolves to the active transaction handle when called inside a
TransactionManager scope, and falls back to the raw client otherwise.
Audit columns are populated via the inherited auditCreate / auditUpdate
getters (sourced from the constructor-time actor), not direct actorId
access.
Extends BaseRepository directly rather than CrudRepository /
WriteRepository: this is a status-tracking audit log written from the
lifecycle subscriber (upsert-on-queue, then monotonic status updates by
jobId). One row per (queueName, jobId) represents the latest run — a
reused custom jobId (BullMQ's dedup pattern) resets the row to a fresh run
rather than accumulating duplicates. It has no read/ownership/soft-delete
lifecycle, so the CRUD template machinery would be unused.
NOTE: this repo requires the consumer's Prisma client to expose the
backgroundJobRun model (run taproot db:setup). Audit writes are
best-effort — the lifecycle subscriber catches and logs failures rather than
throwing — so a misconfigured consumer surfaces as a per-job
console.error rather than failing fast. Pass repo only when the model is
present.
Extends
BaseRepository<PrismaClient,Tx<PrismaClient>>
Constructors
Constructor
new BackgroundJobRunRepository(prismaClient: PrismaClientLike<Tx<PrismaClient<PrismaClientOptions, never, DefaultArgs>>> & PrismaClient<PrismaClientOptions, never, DefaultArgs>, options?: RepositoryOptions): BackgroundJobRunRepository;Defined in: server/persistence/base-repository.ts:68
Parameters
| Parameter | Type |
|---|---|
prismaClient | PrismaClientLike<Tx<PrismaClient<PrismaClientOptions, never, DefaultArgs>>> & PrismaClient<PrismaClientOptions, never, DefaultArgs> |
options | RepositoryOptions |
Returns
BackgroundJobRunRepository
Inherited from
Properties
ENTITY_TYPE?
protected readonly optional ENTITY_TYPE?: string;Defined in: server/persistence/base-repository.ts:61
Set ENTITY_TYPE in child repositories to enable automatic activity
logging. When set, create/update/delete operations auto-log unless
silenced with .silent. Requires an activity model on the consumer's
Prisma schema.
Inherited from
logger?
protected readonly optional logger?: Logger;Defined in: server/persistence/base-repository.ts:64
Inherited from
prismaClient
protected prismaClient: PrismaClientLike<Tx<PrismaClient<PrismaClientOptions, never, DefaultArgs>>> & PrismaClient<PrismaClientOptions, never, DefaultArgs>;Defined in: server/persistence/base-repository.ts:69
Inherited from
Accessors
actorId
Get Signature
get protected actorId(): string | null | undefined;Defined in: server/persistence/base-repository.ts:76
Returns
string | null | undefined
Inherited from
auditCreate
Get Signature
get protected auditCreate(): {
createdBy: string | null | undefined;
updatedBy: string | null | undefined;
};Defined in: server/persistence/base-repository.ts:90
Returns
{
createdBy: string | null | undefined;
updatedBy: string | null | undefined;
}createdBy
createdBy: string | null | undefined = actorId;updatedBy
updatedBy: string | null | undefined = actorId;Inherited from
auditDelete
Get Signature
get protected auditDelete(): {
deletedAt: Date;
deletedBy: string | null | undefined;
};Defined in: server/persistence/base-repository.ts:99
Returns
{
deletedAt: Date;
deletedBy: string | null | undefined;
}deletedAt
deletedAt: Date;deletedBy
deletedBy: string | null | undefined;Inherited from
auditUpdate
Get Signature
get protected auditUpdate(): {
updatedBy: string | null | undefined;
};Defined in: server/persistence/base-repository.ts:95
Returns
{
updatedBy: string | null | undefined;
}updatedBy
updatedBy: string | null | undefined;Inherited from
silent
Get Signature
get silent(): this;Defined in: server/persistence/base-repository.ts:115
Suppress activity logging for the next mutation call. One-shot: the flag is consumed by the next create/update/delete.
Example
await repo.silent.update(id, data); // no activity logged
await repo.update(id, data); // activity logged normallyReturns
this
Inherited from
tx
Get Signature
get protected tx(): TTx;Defined in: server/persistence/base-repository.ts:86
The current Prisma handle: the active transaction if one is running on this async context, otherwise the raw client.
Returns
TTx
Inherited from
Methods
consumeSilent()
protected consumeSilent(): boolean;Defined in: server/persistence/base-repository.ts:128
Consume and reset the silent flag. Called by template methods.
Returns
boolean
Inherited from
logActivity()
protected logActivity(
_entityId: string,
_action: string,
_metadata?: Record<string, unknown>
): Promise<void>;Defined in: server/persistence/base-repository.ts:140
Log an activity entry.
NOTE: This is not implemented because there's no activity model implemented in taproot yet! https://linear.app/kaizenlabs/issue/ENG-7846/add-activity-log-tables
Parameters
| Parameter | Type |
|---|---|
_entityId | string |
_action | string |
_metadata? | Record<string, unknown> |
Returns
Promise<void>
Inherited from
recordCompletion()
recordCompletion(queueName: string, jobId: string): Promise<void>;Defined in: server/background-jobs/background-job-run-repository.ts:64
Parameters
| Parameter | Type |
|---|---|
queueName | string |
jobId | string |
Returns
Promise<void>
recordFailure()
recordFailure(
queueName: string,
jobId: string,
error: string
): Promise<void>;Defined in: server/background-jobs/background-job-run-repository.ts:76
Parameters
| Parameter | Type |
|---|---|
queueName | string |
jobId | string |
error | string |
Returns
Promise<void>
recordQueued()
recordQueued(params: {
jobId: string;
jobName: string;
organizationId?: string;
queueName: string;
}): Promise<void>;Defined in: server/background-jobs/background-job-run-repository.ts:33
Parameters
| Parameter | Type |
|---|---|
params | { jobId: string; jobName: string; organizationId?: string; queueName: string; } |
params.jobId | string |
params.jobName | string |
params.organizationId? | string |
params.queueName | string |
Returns
Promise<void>
recordStalled()
recordStalled(queueName: string, jobId: string): Promise<void>;Defined in: server/background-jobs/background-job-run-repository.ts:93
Parameters
| Parameter | Type |
|---|---|
queueName | string |
jobId | string |
Returns
Promise<void>