five-on-it / apps/api/src/store / Store
Interface: Store
Defined in: apps/api/src/store.ts:770
The store.
Extended by
Methods
accountEntitlement()
accountEntitlement(
account):Promise<Entitlement|undefined>
Defined in: apps/api/src/store.ts:941
The entitlement of the Steam account that signs in to an account, if one does.
Parameters
account
string
Returns
Promise<Entitlement | undefined>
addRunPlayer()
addRunPlayer(
player):Promise<boolean>
Defined in: apps/api/src/store.ts:973
Adds a seat to an open run's roster (a player placed in it under way, joinInProgress): false when the run is not open any more, the seat is taken, or the account has a seat of the run already (nothing added).
Parameters
player
Returns
Promise<boolean>
appendAudit()
appendAudit(
entry):Promise<void>
Defined in: apps/api/src/store.ts:808
Adds a decision to the audit log.
Parameters
entry
Returns
Promise<void>
applyStanding()
applyStanding(
lines,fresh):Promise<{applied:StandingLine[];standings:PlayerStanding[]; }>
Defined in: apps/api/src/store.ts:999
Applies lines to their accounts' standings, atomically each, once each (a line whose id is in the ledger already is left out): its Respect added (to its season's too), its conduct moved and kept in 0–10,000, its skill set when it carries one, its name kept; an account without a standing starts at fresh's. Answers the lines applied and the standings after.
Parameters
lines
readonly StandingLine[]
fresh
(account, name) => PlayerStanding
Returns
Promise<{ applied: StandingLine[]; standings: PlayerStanding[]; }>
auditLog()
auditLog(
limit,action?):Promise<AuditEntry[]>
Defined in: apps/api/src/store.ts:810
The audit log, newest first, at most limit entries: every one, or those of one action.
Parameters
limit
number
action?
"conduct" | "delete" | "settings" | "takedown" | "restore" | "feature" | "unfeature" | "dismiss" | "uphold" | "limits" | "erase"
Returns
Promise<AuditEntry[]>
cancelJob()
cancelJob(
id,at):Promise<Job|undefined>
Defined in: apps/api/src/store.ts:894
Cancels a job that is queued, running or waiting at a time (ISO), atomically: it is over (cancelled, no lease), so a claim never takes it and the attempt running it can renew or settle nothing. Answers the job as it was before, or undefined when there is none or it was over already.
Parameters
id
string
at
string
Returns
Promise<Job | undefined>
claimJob()
claimJob(
kind,at,leaseUntil,options?):Promise<Job|undefined>
Defined in: apps/api/src/store.ts:866
Claims the next queued job of a kind at a time (ISO), atomically, so two processes never claim the same one: the highest priority first, then the owner with the fewest jobs of that kind started that day (UTC), then the oldest (queue.ts's order). A creation (create) of an owner who has one running already waits (one at a time each, which Postgres's index holds too). It answers the job as claimed (running, its attempts counted, held until leaseUntil), or undefined when none is queued.
Parameters
kind
at
string
leaseUntil
string
options?
ClaimOptions
Returns
Promise<Job | undefined>
consents()
consents(
account):Promise<Consent[]>
Defined in: apps/api/src/store.ts:814
An account's acceptances, newest first.
Parameters
account
string
Returns
Promise<Consent[]>
countMissionRun()
countMissionRun(
run):Promise<boolean>
Defined in: apps/api/src/store.ts:1024
Counts a run in its mission version's tally, once (by the run's id): a settled run, a completion when it completed, its accounts among the distinct players. False when it was counted already.
Parameters
run
MissionRun
Returns
Promise<boolean>
deleteDraft()
deleteDraft(
id):Promise<boolean>
Defined in: apps/api/src/store.ts:776
Forgets a draft and its builds' records (their artifacts stay: they are content-addressed); false when there was none.
Parameters
id
string
Returns
Promise<boolean>
deleteLimits()
deleteLimits(
account):Promise<void>
Defined in: apps/api/src/store.ts:922
Forgets the limits an admin set an account: it has the defaults again.
Parameters
account
string
Returns
Promise<void>
deleteOAuthGrant()
deleteOAuthGrant(
id):Promise<void>
Defined in: apps/api/src/store.ts:841
Revokes a grant: forgets it and its refresh tokens.
Parameters
id
string
Returns
Promise<void>
deleteSettings()
deleteSettings():
Promise<void>
Defined in: apps/api/src/store.ts:930
Forgets the platform's settings: the configuration's defaults again.
Returns
Promise<void>
endorsements()
endorsements(
query):Promise<Endorsement[]>
Defined in: apps/api/src/store.ts:1043
The endorsements of a run, or those given or received by an account since a time.
Parameters
query
account?
string
run?
string
since?
string
Returns
Promise<Endorsement[]>
endRun()
endRun(
ended):Promise<boolean>
Defined in: apps/api/src/store.ts:988
Ends a run that is still open, atomically: the run as ended says (its state, result, end); false when it had ended already (it is left as it was).
Parameters
ended
Returns
Promise<boolean>
eraseStanding()
eraseStanding(
account):Promise<void>
Defined in: apps/api/src/store.ts:1057
Forgets an account's standing: its standing, its ledger, the endorsements it gave and got, its ratings of missions, and its account among the missions' players (each kept as an anonymous one, so the missions' counts stay).
Parameters
account
string
Returns
Promise<void>
expireJobs()
expireJobs(
kind,at,attempts):Promise<Job[]>
Defined in: apps/api/src/store.ts:887
The running jobs of a kind whose lease ran out before a time (ISO): queued again while they had fewer than attempts attempts, failed after that; answered as they are now.
Parameters
kind
at
string
attempts
number
Returns
Promise<Job[]>
findAccounts()
findAccounts(
q,limit):Promise<KnownAccount[]>
Defined in: apps/api/src/store.ts:935
The accounts the API has seen (drafts' owners, quotas' spenders, accounts with limits) whose id or name holds q (any case), by id, at most limit.
Parameters
q
string
limit
number
Returns
Promise<KnownAccount[]>
findJobs()
findJobs(
query):Promise<Job[]>
Defined in: apps/api/src/store.ts:902
The jobs a query asks for, whole, the newest first.
Parameters
query
JobQuery
Returns
Promise<Job[]>
getBuild()
getBuild(
id):Promise<Build|undefined>
Defined in: apps/api/src/store.ts:780
A build by id.
Parameters
id
string
Returns
Promise<Build | undefined>
getDraft()
getDraft(
id):Promise<Draft|undefined>
Defined in: apps/api/src/store.ts:772
A draft by id.
Parameters
id
string
Returns
Promise<Draft | undefined>
getEntitlement()
getEntitlement(
steamid):Promise<Entitlement|undefined>
Defined in: apps/api/src/store.ts:939
A Steam account's entitlement by its SteamID64.
Parameters
steamid
string
Returns
Promise<Entitlement | undefined>
getJob()
getJob(
id):Promise<Job|undefined>
Defined in: apps/api/src/store.ts:853
A job by id.
Parameters
id
string
Returns
Promise<Job | undefined>
getLimits()
getLimits(
account):Promise<AccountLimits|undefined>
Defined in: apps/api/src/store.ts:920
The limits an admin set an account, if any.
Parameters
account
string
Returns
Promise<AccountLimits | undefined>
getMissionRating()
getMissionRating(
key,account):Promise<MissionRating|undefined>
Defined in: apps/api/src/store.ts:1047
An account's rating of a mission's version.
Parameters
key
account
string
Returns
Promise<MissionRating | undefined>
getOAuthClient()
getOAuthClient(
id):Promise<OAuthClient|undefined>
Defined in: apps/api/src/store.ts:828
An OAuth client by id.
Parameters
id
string
Returns
Promise<OAuthClient | undefined>
getOAuthGrant()
getOAuthGrant(
id):Promise<OAuthGrant|undefined>
Defined in: apps/api/src/store.ts:839
A grant by id; undefined once revoked or forgotten.
Parameters
id
string
Returns
Promise<OAuthGrant | undefined>
getOAuthRefresh()
getOAuthRefresh(
hash):Promise<OAuthRefresh|undefined>
Defined in: apps/api/src/store.ts:845
A refresh token by the hash of its value.
Parameters
hash
string
Returns
Promise<OAuthRefresh | undefined>
getPlayerStanding()
getPlayerStanding(
account):Promise<PlayerStanding|undefined>
Defined in: apps/api/src/store.ts:990
An account's standing, if it has one.
Parameters
account
string
Returns
Promise<PlayerStanding | undefined>
getRating()
getRating(
game,account):Promise<Rating|undefined>
Defined in: apps/api/src/store.ts:794
An account's rating of a game.
Parameters
game
string
account
string
Returns
Promise<Rating | undefined>
getReport()
getReport(
id):Promise<Report|undefined>
Defined in: apps/api/src/store.ts:800
A report by id.
Parameters
id
string
Returns
Promise<Report | undefined>
getRun()
getRun(
id):Promise<Run|undefined>
Defined in: apps/api/src/store.ts:977
A run by its id.
Parameters
id
string
Returns
Promise<Run | undefined>
getSettings()
getSettings():
Promise<PlatformSettings|undefined>
Defined in: apps/api/src/store.ts:926
The platform's settings an admin set, if any.
Returns
Promise<PlatformSettings | undefined>
getTranscript()
getTranscript(
job):Promise<Transcript|undefined>
Defined in: apps/api/src/store.ts:963
A creation's transcript, while it is kept.
Parameters
job
string
Returns
Promise<Transcript | undefined>
jobsStarted()
jobsStarted(
kind,since):Promise<Map<string,number>>
Defined in: apps/api/src/store.ts:857
How many jobs of a kind each owner had started since a time (ISO).
Parameters
kind
since
string
Returns
Promise<Map<string, number>>
latestBuild()
latestBuild(
draft):Promise<Build|undefined>
Defined in: apps/api/src/store.ts:784
A draft's latest build.
Parameters
draft
string
Returns
Promise<Build | undefined>
latestVersions()
latestVersions():
Promise<GameVersion[]>
Defined in: apps/api/src/store.ts:790
The latest version of every game, newest first.
Returns
Promise<GameVersion[]>
leaderboard()
leaderboard(
season,limit):Promise<LeaderboardLine[]>
Defined in: apps/api/src/store.ts:1039
The leaderboard: the accounts by the Respect earned in a season (all: their Respect), the most first, at most limit (none with nothing).
Parameters
season
string
limit
number
Returns
Promise<LeaderboardLine[]>
ledgerTotals()
ledgerTotals(
since,until?):Promise<LedgerTotals>
Defined in: apps/api/src/store.ts:959
What the lines claimed from since (and before until) spent, and hold reserved.
Parameters
since
string
until?
string
Returns
Promise<LedgerTotals>
listDrafts()
listDrafts(
owner):Promise<Draft[]>
Defined in: apps/api/src/store.ts:778
An owner's drafts, newest first.
Parameters
owner
string
Returns
Promise<Draft[]>
listJobs()
listJobs(
kind,states):Promise<JobSummary[]>
Defined in: apps/api/src/store.ts:855
The jobs of a kind in the states given, without their documents, in the order they were queued.
Parameters
kind
states
readonly ("done" | "failed" | "waiting" | "running" | "queued" | "cancelled")[]
Returns
Promise<JobSummary[]>
listLimits()
listLimits():
Promise<AccountLimits[]>
Defined in: apps/api/src/store.ts:924
Every account's limits an admin set, the latest set first.
Returns
Promise<AccountLimits[]>
listReports()
listReports(
state?):Promise<Report[]>
Defined in: apps/api/src/store.ts:802
The reports, newest first: every one, or those in one state.
Parameters
state?
"open" | "actioned" | "dismissed"
Returns
Promise<Report[]>
markRunPaid()
markRunPaid(
run,at):Promise<void>
Defined in: apps/api/src/store.ts:1028
Marks a run's seats paid (once: a later mark keeps the first time).
Parameters
run
string
at
string
Returns
Promise<void>
missionRatings()
missionRatings(
key):Promise<{average:number;count:number; }>
Defined in: apps/api/src/store.ts:1049
A mission version's ratings: how many, their mean (two decimals; 0 without any).
Parameters
key
Returns
Promise<{ average: number; count: number; }>
missionRatingsBy()
missionRatingsBy(
account):Promise<MissionRating[]>
Defined in: apps/api/src/store.ts:1051
An account's ratings of missions, the newest first (its data's export).
Parameters
account
string
Returns
Promise<MissionRating[]>
missionTally()
missionTally(
key):Promise<{completions:number;players:number;runs:number; }>
Defined in: apps/api/src/store.ts:1030
A mission version's tally.
Parameters
key
Returns
Promise<{ completions: number; players: number; runs: number; }>
moveJob()
moveJob(
job,from):Promise<boolean>
Defined in: apps/api/src/store.ts:900
Saves a job as given (no lease) when it is still in the state from, atomically: a creation's conversation moved on (waiting to queued when its owner says more, waiting to done when it went quiet) never overwrites a cancel or a claim. False when it was not.
Parameters
job
from
"done" | "failed" | "waiting" | "running" | "queued" | "cancelled"
Returns
Promise<boolean>
openRuns()
openRuns():
Promise<Run[]>
Defined in: apps/api/src/store.ts:981
The runs still open, the oldest first: what the sweep looks at.
Returns
Promise<Run[]>
openRunsOf()
openRunsOf(
account):Promise<Run[]>
Defined in: apps/api/src/store.ts:983
The runs still open an account has a seat in, the oldest first.
Parameters
account
string
Returns
Promise<Run[]>
playerStandings()
playerStandings(
accounts):Promise<PlayerStanding[]>
Defined in: apps/api/src/store.ts:992
The standings of the accounts given that have one.
Parameters
accounts
readonly string[]
Returns
Promise<PlayerStanding[]>
purgeOAuth()
purgeOAuth(
before):Promise<number>
Defined in: apps/api/src/store.ts:849
Forgets the codes, refresh tokens and grants that expired before a time (ISO); returns how many.
Parameters
before
string
Returns
Promise<number>
purgeTelemetry()
purgeTelemetry(
before):Promise<number>
Defined in: apps/api/src/store.ts:824
Forgets the telemetry records older than a time (ISO); returns how many.
Parameters
before
string
Returns
Promise<number>
purgeTranscripts()
purgeTranscripts(
before):Promise<number>
Defined in: apps/api/src/store.ts:965
Forgets the transcripts kept before a time (ISO); returns how many.
Parameters
before
string
Returns
Promise<number>
putBuild()
putBuild(
build):Promise<void>
Defined in: apps/api/src/store.ts:782
Saves a build (insert or replace).
Parameters
build
Returns
Promise<void>
putConsent()
putConsent(
consent):Promise<void>
Defined in: apps/api/src/store.ts:812
Records an account's acceptance of a version of the terms (again: the latest time).
Parameters
consent
Returns
Promise<void>
putDraft()
putDraft(
draft):Promise<void>
Defined in: apps/api/src/store.ts:774
Saves a draft (insert or replace).
Parameters
draft
Returns
Promise<void>
putEndorsement()
putEndorsement(
endorsement):Promise<boolean>
Defined in: apps/api/src/store.ts:1041
Keeps an endorsement, once per run, giver and receiver: false when it was given already.
Parameters
endorsement
Endorsement
Returns
Promise<boolean>
putEntitlement()
putEntitlement(
entitlement):Promise<void>
Defined in: apps/api/src/store.ts:937
Saves a Steam account's entitlement (insert or replace; one Steam account per account).
Parameters
entitlement
Returns
Promise<void>
putJob()
putJob(
job):Promise<void>
Defined in: apps/api/src/store.ts:851
Saves a job (insert or replace).
Parameters
job
Returns
Promise<void>
putLedger()
putLedger(
entry):Promise<void>
Defined in: apps/api/src/store.ts:952
Saves a creation's line in the ledger (insert or replace).
Parameters
entry
Returns
Promise<void>
putLimits()
putLimits(
limits):Promise<void>
Defined in: apps/api/src/store.ts:918
Saves the limits an admin set an account (insert or replace).
Parameters
limits
Returns
Promise<void>
putMissionRating()
putMissionRating(
rating):Promise<void>
Defined in: apps/api/src/store.ts:1045
Keeps a player's rating of a mission's version (again: replaced).
Parameters
rating
Returns
Promise<void>
putOAuthClient()
putOAuthClient(
client):Promise<void>
Defined in: apps/api/src/store.ts:826
Saves an OAuth client.
Parameters
client
Returns
Promise<void>
putOAuthCode()
putOAuthCode(
code):Promise<void>
Defined in: apps/api/src/store.ts:830
Saves an authorization code.
Parameters
code
Returns
Promise<void>
putOAuthGrant()
putOAuthGrant(
grant):Promise<void>
Defined in: apps/api/src/store.ts:837
Saves a grant (insert or replace).
Parameters
grant
Returns
Promise<void>
putOAuthRefresh()
putOAuthRefresh(
token):Promise<void>
Defined in: apps/api/src/store.ts:843
Saves a refresh token.
Parameters
token
Returns
Promise<void>
putRating()
putRating(
rating):Promise<void>
Defined in: apps/api/src/store.ts:792
Saves a rating (one per game and account: a new one replaces the old).
Parameters
rating
Returns
Promise<void>
putReport()
putReport(
report):Promise<void>
Defined in: apps/api/src/store.ts:798
Saves a report (insert or replace; a replaced one keeps its place in the list).
Parameters
report
Returns
Promise<void>
putRun()
putRun(
run,players):Promise<void>
Defined in: apps/api/src/store.ts:967
Saves a run and its roster (insert; the roster as it is given, by seat).
Parameters
run
players
readonly RunPlayer[]
Returns
Promise<void>
putSettings()
putSettings(
settings):Promise<void>
Defined in: apps/api/src/store.ts:928
Saves the platform's settings (replacing them).
Parameters
settings
Returns
Promise<void>
putStanding()
putStanding(
standing):Promise<void>
Defined in: apps/api/src/store.ts:804
Saves a game's standing (insert or replace).
Parameters
standing
Returns
Promise<void>
putTelemetry()
putTelemetry(
record):Promise<void>
Defined in: apps/api/src/store.ts:816
Keeps a telemetry record.
Parameters
record
Returns
Promise<void>
putTranscript()
putTranscript(
transcript):Promise<void>
Defined in: apps/api/src/store.ts:961
Keeps a creation's transcript (insert or replace).
Parameters
transcript
Returns
Promise<void>
putVersion()
putVersion(
version):Promise<void>
Defined in: apps/api/src/store.ts:786
Saves a game version.
Parameters
version
Returns
Promise<void>
quotaUsage()
quotaUsage(
account,day):Promise<Partial<Record<QuotaKind,number>>>
Defined in: apps/api/src/store.ts:916
An account's uses of its quotas on a day (YYYY-MM-DD); a quota it did not use is left out.
Parameters
account
string
day
string
Returns
Promise<Partial<Record<QuotaKind, number>>>
ratingSummaries()
ratingSummaries(
games):Promise<Map<string,RatingSummary>>
Defined in: apps/api/src/store.ts:796
The ratings of the games given, summed up; a game nobody rated is left out.
Parameters
games
readonly string[]
Returns
Promise<Map<string, RatingSummary>>
refundQuota()
refundQuota(
account,what,day):Promise<number>
Defined in: apps/api/src/store.ts:914
Gives back one use of an account's quota on a day, when it used any: its uses that day now.
Parameters
account
string
what
day
string
Returns
Promise<number>
removeRunPlayer()
removeRunPlayer(
run,seat):Promise<void>
Defined in: apps/api/src/store.ts:975
Takes a seat filled under way off a run's roster again (its server refused it); nothing for a seat it has not.
Parameters
run
string
seat
number
Returns
Promise<void>
renewJob()
renewJob(
id,attempt,leaseUntil,step?):Promise<boolean>
Defined in: apps/api/src/store.ts:876
Extends the lease of a running job's attempt, and says what it is doing now when step is given; false when that attempt no longer holds it.
Parameters
id
string
attempt
number
leaseUntil
string
step?
string
Returns
Promise<boolean>
runPlayers()
runPlayers(
run):Promise<RunPlayer[]>
Defined in: apps/api/src/store.ts:979
A run's roster, by seat.
Parameters
run
string
Returns
Promise<RunPlayer[]>
runStandingLines()
runStandingLines(
run):Promise<StandingLine[]>
Defined in: apps/api/src/store.ts:1034
The lines of one run's ledger (every account's).
Parameters
run
string
Returns
Promise<StandingLine[]>
settleJob()
settleJob(
job):Promise<boolean>
Defined in: apps/api/src/store.ts:882
Ends a running job's attempt, saving it as given (done, failed or cancelled, no lease), when that attempt (job.attempts) still holds it; false otherwise (its lease ran out and another process took it, or it was cancelled).
Parameters
job
Returns
Promise<boolean>
spendLedger()
spendLedger(
job,spent,settledAt?):Promise<void>
Defined in: apps/api/src/store.ts:957
Records what a creation spent so far (never less than it had), and settles it when settledAt is given (a settled line keeps its first settling time).
Parameters
job
string
spent
number
settledAt?
string
Returns
Promise<void>
spendQuota()
spendQuota(
account,what,day,limit):Promise<number|undefined>
Defined in: apps/api/src/store.ts:907
Counts one use of an account's quota on a day (YYYY-MM-DD, UTC), atomically, when it has used fewer than limit: its uses that day now, or undefined when none are left.
Parameters
account
string
what
day
string
limit
number
Returns
Promise<number | undefined>
staleEntitlements()
staleEntitlements(
seenSince,checkedBefore,limit):Promise<Entitlement[]>
Defined in: apps/api/src/store.ts:946
The entitlements signed in with since a time and last checked before another (ISO), the longest unchecked first, at most limit: what the daily sweep asks Steam again.
Parameters
seenSince
string
checkedBefore
string
limit
number
Returns
Promise<Entitlement[]>
standingLines()
standingLines(
account,query):Promise<StandingLine[]>
Defined in: apps/api/src/store.ts:1032
An account's ledger lines a query asks for, the newest first.
Parameters
account
string
query
StandingQuery
Returns
Promise<StandingLine[]>
standings()
standings():
Promise<Map<string,GameStanding>>
Defined in: apps/api/src/store.ts:806
Every game's standing that a moderator ever set.
Returns
Promise<Map<string, GameStanding>>
telemetry()
telemetry(
kind,since,limit):Promise<TelemetryRecord[]>
Defined in: apps/api/src/store.ts:818
The telemetry records of a kind since a time (ISO), newest first, at most limit.
Parameters
kind
"crash" | "event"
since
string
limit
number
Returns
Promise<TelemetryRecord[]>
unpaidRuns()
unpaidRuns(
endedSince,limit):Promise<Run[]>
Defined in: apps/api/src/store.ts:1026
The settled runs that count (not playtests, not abandoned nor lost) ended since a time (ISO) whose seats were not paid yet, the oldest first, at most limit.
Parameters
endedSince
string
limit
number
Returns
Promise<Run[]>
useOAuthCode()
useOAuthCode(
hash,at):Promise<OAuthCode|undefined>
Defined in: apps/api/src/store.ts:835
Marks a code used at a time (ISO), once: the code as it was before (usedAt set when it had been used already), or undefined when there is none.
Parameters
hash
string
at
string
Returns
Promise<OAuthCode | undefined>
useOAuthRefresh()
useOAuthRefresh(
hash,at):Promise<OAuthRefresh|undefined>
Defined in: apps/api/src/store.ts:847
Marks a refresh token used at a time (ISO), once: the token as it was before, as useOAuthCode.
Parameters
hash
string
at
string
Returns
Promise<OAuthRefresh | undefined>
versions()
versions(
gameId):Promise<GameVersion[]>
Defined in: apps/api/src/store.ts:788
A game's versions, oldest first.
Parameters
gameId
string
Returns
Promise<GameVersion[]>
withStanding()
withStanding(
account,name,fresh,work):Promise<{applied:boolean;standing:PlayerStanding; }>
Defined in: apps/api/src/store.ts:1010
Pays one account's seat of a run atomically (respect.ts): its standing (a new one's, fresh, when it has none) held while work reads the account's ledger (lines, inside the same transaction: the day's repeat counted where nothing can change it meanwhile) and returns the line to apply; the line applied once (by its id) and the standing after. Postgres runs it in one transaction holding the account's row (SELECT … FOR UPDATE).
Parameters
account
string
name
string
fresh
(account, name) => PlayerStanding
work
(standing, lines) => Promise<StandingLine | undefined>
Returns
Promise<{ applied: boolean; standing: PlayerStanding; }>