Skip to main content

createArtifactService

@retinue/monorepo


@retinue/monorepo / backend/src / createArtifactService

Function: createArtifactService()

createArtifactService(deps): object

Defined in: backend/src/artifacts/index.ts:79

Parameters​

deps​

ArtifactServiceDeps

Returns​

create()​

create(context, input): Promise<Artifact>

Create an artifact at version 1.

Parameters​

context​

ExecutionContext

input​
content​

ArtifactContent

conversationId​

ConversationId

name​

string

provenance​

ArtifactProvenance

Returns​

Promise<Artifact>

history()​

history(context, input): Promise<Page<ArtifactVersion>>

The version history, for a restore or an audit. Metadata only — no content is loaded.

Parameters​

context​

ExecutionContext

input​
cursor?​

string

id​

ArtifactId

limit​

number

Returns​

Promise<Page<ArtifactVersion>>

listForConversation()​

listForConversation(context, input): Promise<Page<Artifact>>

Parameters​

context​

ExecutionContext

input​
conversationId​

ConversationId

cursor?​

string

limit​

number

Returns​

Promise<Page<Artifact>>

read()​

read(context, input): Promise<{ artifact: Artifact; content: unknown; version: ArtifactVersion; }>

A version's row and its content together. The latest when no version is asked for.

Parameters​

context​

ExecutionContext

input​
id​

ArtifactId

version?​

number

Returns​

Promise<{ artifact: Artifact; content: unknown; version: ArtifactVersion; }>

regenerate()​

regenerate(context, input): Promise<{ version: number; }>

Regenerate: a new version, never an overwrite — AC-2.

expectedLatestVersion is read here rather than taken from the caller, and then passed through as the compare. That is not redundant: the read establishes what the caller is regenerating from, and the compare makes a concurrent regeneration lose loudly instead of silently replacing this one.

Parameters​

context​

ExecutionContext

input​
content​

ArtifactContent

id​

ArtifactId

provenance​

ArtifactProvenance

Returns​

Promise<{ version: number; }>

restore()​

restore(context, input): Promise<{ version: number; }>

Restore an earlier version by making it the newest one.

A new version whose content is the old one's, not a pointer moved backwards. Moving a pointer would make the history lie about what happened — and "the version that was current on Tuesday" is exactly the question a shared link asks.

Parameters​

context​

ExecutionContext

input​
id​

ArtifactId

producedBy?​

string

version​

number

Returns​

Promise<{ version: number; }>

softDelete()​

softDelete(context, id): Promise<{ deleted: boolean; }>

Parameters​

context​

ExecutionContext

id​

ArtifactId

Returns​

Promise<{ deleted: boolean; }>