Skip to content

BuildModel

Defined in: packages/core/src/models/build.ts:19

Data operations for build records.

new BuildModel(db, tables?, logger?): BuildModel

Defined in: packages/core/src/models/build.ts:25

logger only reports a status write refused by a cancelled build, at debug.

DatabaseAdapter

BuildTables

Logger

BuildModel

create(projectId, input): Promise<Build>

Defined in: packages/core/src/models/build.ts:35

string

BuildCreateInput

Promise<Build>


get(id): Promise<Build | null>

Defined in: packages/core/src/models/build.ts:57

string

Promise<Build | null>


latestApprovedDefault(project): Promise<Build | null>

Defined in: packages/core/src/models/build.ts:97

Return the build a project-slug Storybook link resolves to: the most recent approved build on the project’s default branch. Approved builds on other branches never qualify (their PR can still be dismissed), and neither do pending, failed, or unreviewed default-branch builds. Visibility (public or authenticated) is checked separately by the caller.

string

string

Promise<Build | null>


list(projectId, filter?): Promise<Build[]>

Defined in: packages/core/src/models/build.ts:61

string

BuildListFilter = {}

Promise<Build[]>


remove(id): Promise<void>

Defined in: packages/core/src/models/build.ts:199

string

Promise<void>


resetStatus(id, status): Promise<Build>

Defined in: packages/core/src/models/build.ts:142

Put a finished build back to status for a retry. The one write that leaves cancelled (a user chose it), so it skips the terminal guard of BuildModel.update.

string

"failed" | "cancelled" | "pending" | "capturing" | "comparing" | "reviewing" | "approved" | "rejected"

Promise<Build>


setAffected(id, input): Promise<Build>

Defined in: packages/core/src/models/build.ts:150

Record the affected-capture computation for a build. Idempotent: the CLI posts this once after creating the build and before uploading the bundle.

string

AffectedComputation

Promise<Build>


setStatus(id, status): Promise<Build>

Defined in: packages/core/src/models/build.ts:134

string

"failed" | "cancelled" | "pending" | "capturing" | "comparing" | "reviewing" | "approved" | "rejected"

Promise<Build>


setTestResults(id, results): Promise<Build>

Defined in: packages/core/src/models/build.ts:163

Store the results of the build’s .test() entries (TestResult[], as JSON), or clear them with null. Written once per capture run, by the run that ran the tests.

string

readonly unknown[] | null

Promise<Build>


update(id, patch, options?): Promise<Build>

Defined in: packages/core/src/models/build.ts:113

Patch a build. A cancelled build is terminal (ADR 0006): a patch that carries another status is refused, the row is returned as it is, so a capture that ends after a cancel cannot move the build. Only BuildModel.resetStatus leaves cancelled.

string

Partial<Pick<Build, "status" | "public" | "message" | "authorEmail" | "authorName">>

boolean

Promise<Build>


updateCounts(id): Promise<Build>

Defined in: packages/core/src/models/build.ts:178

string

Promise<Build>


static affectedPaths(build): string[] | null

Defined in: packages/core/src/models/build.ts:174

Parse a build’s affected import paths. Returns null for full capture (no computation, or an unreadable payload) — callers render everything.

Pick<Build, "affectedImportPaths">

string[] | null