Skip to main content

FileMetadataStore

@forge/monorepo


@forge/monorepo / backend/src / FileMetadataStore

Interface: FileMetadataStore

Defined in: backend/src/persistence/index.ts:1187

Methods

create()

create(input): Promise<void>

Defined in: backend/src/persistence/index.ts:1188

Parameters

input

TenantScope & object

Returns

Promise<void>


get()

get(input): Promise<FileMetadata | null>

Defined in: backend/src/persistence/index.ts:1191

null for another tenant's file as well as an absent one — the two must be indistinguishable.

Parameters

input

TenantScope & object

Returns

Promise<FileMetadata | null>


listByConversation()

listByConversation(input): Promise<Page<FileMetadata>>

Defined in: backend/src/persistence/index.ts:1194

Live files only: soft-deleted rows are excluded, since this is what a user sees.

Parameters

input

TenantScope & PageRequest & object

Returns

Promise<Page<FileMetadata>>


listByExtractionState()

listByExtractionState(input): Promise<Page<FileMetadata>>

Defined in: backend/src/persistence/index.ts:1235

Files in a given extraction state, oldest first.

The reconciliation of extraction, distinct from listByState's reconciliation of bytes: a file stuck in running is a worker that died mid-parse, and nothing else would ever notice.

Parameters

input

TenantScope & PageRequest & object

Returns

Promise<Page<FileMetadata>>


listByState()

listByState(input): Promise<Page<FileMetadata>>

Defined in: backend/src/persistence/index.ts:1256

Files in a state longer than they should be — reconciliation's input.

olderThan rather than "all in this state", because a file that entered pending a second ago is an upload in progress and a file that entered it yesterday is an orphan. Without the threshold the job would report every upload happening while it ran.

Parameters

input

TenantScope & PageRequest & object

Returns

Promise<Page<FileMetadata>>


recordExtraction()

recordExtraction(input): Promise<{ recorded: boolean; }>

Defined in: backend/src/persistence/index.ts:1225

Record the outcome of extraction (#131).

Idempotent and deliberately not a compare-and-set, unlike transition. A retried extraction writing the same outcome twice is harmless, and requiring the caller to state the previous extraction state would make a retry after a crash impossible — the crash is exactly why it does not know what that state was.

recorded: false means the file is gone, which a retry after a conversation delete will legitimately hit; reported rather than thrown, because it is an ordinary race and not a fault.

Parameters

input

TenantScope & object

Returns

Promise<{ recorded: boolean; }>


scheduleConversationDeletion()

scheduleConversationDeletion(input): Promise<{ scheduled: number; }>

Defined in: backend/src/persistence/index.ts:1245

Mark every live file of a conversation for byte deletion.

One call rather than a list-then-loop, because a file uploaded between the list and the loop would be missed — and it would be missed silently, leaving bytes for a conversation that no longer exists.

Parameters

input

TenantScope & object

Returns

Promise<{ scheduled: number; }>


transition()

transition(input): Promise<{ moved: boolean; }>

Defined in: backend/src/persistence/index.ts:1205

Advance the lifecycle, with the state it must currently be in.

Compare-and-set rather than a blind write: two workers finishing the same upload, or a delete racing a completion, must not leave a file stored after its bytes were scheduled for removal. Returns whether this call was the one that moved it.

Parameters

input

TenantScope & object

Returns

Promise<{ moved: boolean; }>