Class: LifecycleTransitionRepository
Defined in: server/lifecycle/lifecycle-transition-repository.ts:49
Append-only repository over lifecycle_transitions — the immutable history
of accepted transitions. There is no update/delete path: history never
mutates. Routes every call through this.tx, so when the engine runs inside
TransactionManager.startOrUseTransaction, the append participates in that
transaction.
Extends
ReadRepository<PrismaClient,LifecycleTransition,string,Tx<PrismaClient>>
Constructors
Constructor
new LifecycleTransitionRepository(prismaClient: PrismaClient, options?: LifecycleRepositoryOptions): LifecycleTransitionRepository;Defined in: server/lifecycle/lifecycle-transition-repository.ts:57
Parameters
| Parameter | Type |
|---|---|
prismaClient | PrismaClient |
options | LifecycleRepositoryOptions |
Returns
LifecycleTransitionRepository
Overrides
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
_count()
protected _count(): Promise<number>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:86
Returns
Promise<number>
Overrides
_exists()
protected _exists(id: string): Promise<boolean>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:79
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<boolean>
Overrides
_findById()
protected _findById(id: string): Promise<
| {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}
| null>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:73
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<
| {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}
| null>
Overrides
_findMany()
protected _findMany(pagination: {
page: number;
pageSize: number;
}): Promise<{
items: {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}[];
total: number;
}>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:92
Parameters
| Parameter | Type |
|---|---|
pagination | { page: number; pageSize: number; } |
pagination.page | number |
pagination.pageSize | number |
Returns
Promise<{
items: {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}[];
total: number;
}>
Overrides
append()
append(input: AppendTransitionInput): Promise<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:116
Append a transition row, threading audit fields. The caller computes
sequence (= max + 1) inside the same transaction; a lost concurrency race
surfaces as a unique-constraint violation on (entityType, entityId, sequence), which the engine maps to TransitionConflictError.
Parameters
| Parameter | Type |
|---|---|
input | AppendTransitionInput |
Returns
Promise<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>
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
count()
count(): Promise<number>;Defined in: server/persistence/base-repository.ts:191
Returns
Promise<number>
Inherited from
exists()
exists(id: string): Promise<boolean>;Defined in: server/persistence/base-repository.ts:187
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<boolean>
Inherited from
findById()
findById(id: string): Promise<
| {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}
| null>;Defined in: server/persistence/base-repository.ts:177
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<
| {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}
| null>
Inherited from
findByIdempotencyKey()
findByIdempotencyKey(
machine: string,
entityType: string,
entityId: string,
idempotencyKey: string
): Promise<
| {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}
| null>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:164
Look up a prior transition by its idempotency key (scoped to machine +
entity). Used by send to short-circuit a replay before reading state.
Parameters
| Parameter | Type |
|---|---|
machine | string |
entityType | string |
entityId | string |
idempotencyKey | string |
Returns
Promise<
| {
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}
| null>
findByIdOrThrow()
findByIdOrThrow(id: string): Promise<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>;Defined in: server/persistence/base-repository.ts:181
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Promise<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>
Inherited from
ReadRepository.findByIdOrThrow
findMany()
findMany(pagination: {
page: number;
pageSize: number;
}): Promise<OffsetPaginatedResult<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>>;Defined in: server/persistence/base-repository.ts:195
Parameters
| Parameter | Type |
|---|---|
pagination | { page: number; pageSize: number; } |
pagination.page | number |
pagination.pageSize | number |
Returns
Promise<OffsetPaginatedResult<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>>
Inherited from
history()
history(
entityType: string,
entityId: string,
pagination?: OffsetPaginationParams
): Promise<OffsetPaginatedResult<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:182
Paginated history for an entity, ordered by sequence ascending.
Parameters
| Parameter | Type |
|---|---|
entityType | string |
entityId | string |
pagination | OffsetPaginationParams |
Returns
Promise<OffsetPaginatedResult<{
actorId: string | null;
actorType: string | null;
createdAt: Date;
createdBy: string | null;
entityId: string;
entityType: string;
event: string | null;
fromState: string;
id: string;
idempotencyFingerprint: string | null;
idempotencyKey: string | null;
machine: string;
machineVersion: string;
metadata: JsonValue;
organizationId: string | null;
reason: string | null;
sequence: number;
source: string | null;
toState: string;
updatedAt: Date;
updatedBy: string | null;
}>>
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
maxSequence()
maxSequence(entityType: string, entityId: string): Promise<number | null>;Defined in: server/lifecycle/lifecycle-transition-repository.ts:145
The highest sequence recorded for an entity, or null if the entity has
no history yet. The engine uses (max ?? 0) + 1 for the next row.
Parameters
| Parameter | Type |
|---|---|
entityType | string |
entityId | string |
Returns
Promise<number | null>
notFoundError()
protected notFoundError(id: string): Error;Defined in: server/lifecycle/lifecycle-transition-repository.ts:69
Create a not-found error. Override to provide custom error types.
Parameters
| Parameter | Type |
|---|---|
id | string |
Returns
Error