SnapshotModel
Defined in: packages/core/src/models/snapshot.ts:17
Data operations for snapshot records.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SnapshotModel(
db,tables?):SnapshotModel
Defined in: packages/core/src/models/snapshot.ts:25
Parameters
Section titled “Parameters”Database adapter.
tables?
Section titled “tables?”SnapshotTables
Table handles.
Returns
Section titled “Returns”SnapshotModel
Methods
Section titled “Methods”create()
Section titled “create()”create(
projectId,buildId,input):Promise<Snapshot>
Defined in: packages/core/src/models/snapshot.ts:38
Create a snapshot for a story within a build.
Parameters
Section titled “Parameters”projectId
Section titled “projectId”string
Project ID.
buildId
Section titled “buildId”string
Build ID.
Snapshot creation input.
Returns
Section titled “Returns”Promise<Snapshot>
The created snapshot.
durationsByStory()
Section titled “durationsByStory()”durationsByStory(
buildId):Promise<Map<string,number>>
Defined in: packages/core/src/models/snapshot.ts:109
Milliseconds each story cost on one build, summed over its viewports and engines. Stories the renderer did not time are left out, so an empty map means this build carries no timings.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<Map<string, number>>
get(
id):Promise<Snapshot|null>
Defined in: packages/core/src/models/snapshot.ts:141
Fetch a snapshot by id, or null if not found.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Promise<Snapshot | null>
listByBuild()
Section titled “listByBuild()”listByBuild(
buildId):Promise<Snapshot[]>
Defined in: packages/core/src/models/snapshot.ts:120
List all snapshots belonging to a build.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<Snapshot[]>
listByImportPath()
Section titled “listByImportPath()”listByImportPath(
projectId,importPath):Promise<Snapshot[]>
Defined in: packages/core/src/models/snapshot.ts:130
Every snapshot of a story file across the project’s builds. Index paths are
stored raw (./src/A.stories.tsx), so both spellings of importPath match.
Parameters
Section titled “Parameters”projectId
Section titled “projectId”string
importPath
Section titled “importPath”string
Returns
Section titled “Returns”Promise<Snapshot[]>
removeForBuild()
Section titled “removeForBuild()”removeForBuild(
buildId):Promise<number>
Defined in: packages/core/src/models/snapshot.ts:91
Delete every snapshot of a build: a new plan of it starts clean.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
Returns
Section titled “Returns”Promise<number>
removeRendered()
Section titled “removeRendered()”removeRendered(
buildId,work):Promise<number>
Defined in: packages/core/src/models/snapshot.ts:74
Delete the rendered snapshots a shard is about to write again: rows of (story, engine) pairs
in work, so a rerun starts from a clean slate instead of colliding with rows an earlier,
interrupted run left behind. Inherited rows are kept: the plan wrote them, for engines or
viewports this shard does not render.
Parameters
Section titled “Parameters”buildId
Section titled “buildId”string
readonly object[]
Returns
Section titled “Returns”Promise<number>
review()
Section titled “review()”review(
id,status,userId):Promise<Snapshot>
Defined in: packages/core/src/models/snapshot.ts:159
Record a reviewer’s decision on a snapshot.
Parameters
Section titled “Parameters”string
status
Section titled “status”"pending" | "approved" | "rejected" | "new" | "unchanged" | "changed"
userId
Section titled “userId”string | null
Returns
Section titled “Returns”Promise<Snapshot>
setStatus()
Section titled “setStatus()”setStatus(
id,status):Promise<Snapshot>
Defined in: packages/core/src/models/snapshot.ts:154
Set the status of a snapshot.
Parameters
Section titled “Parameters”string
status
Section titled “status”"pending" | "approved" | "rejected" | "new" | "unchanged" | "changed"
Returns
Section titled “Returns”Promise<Snapshot>
update()
Section titled “update()”update(
id,patch):Promise<Snapshot>
Defined in: packages/core/src/models/snapshot.ts:146
Update mutable fields of a snapshot.
Parameters
Section titled “Parameters”string
Partial<Snapshot>
Returns
Section titled “Returns”Promise<Snapshot>