Something went wrong. Try again.
An ATProto Powered Reputation Network
Something went wrong. Try again.
53 kB · 2014 lines
Go
at master
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015// Code generated by sqlc. DO NOT EDIT.// versions:// sqlc v1.31.1// source: queries.sql
package db
import ( "context" "database/sql")
const addSecret = `-- name: AddSecret :execINSERT INTO secrets(kind, id, value, expires) VALUES (?, ?, ?, ?)`
type AddSecretParams struct { Kind string ID string Value []byte Expires int64}
func (q *Queries) AddSecret(ctx context.Context, arg AddSecretParams) error { _, err := q.exec(ctx, q.addSecretStmt, addSecret, arg.Kind, arg.ID, arg.Value, arg.Expires, ) return err}
const advanceCursor = `-- name: AdvanceCursor :execINSERT INTO stream_cursors(source, time_us) VALUES (?, ?)ON CONFLICT(source) DO UPDATE SET time_us = max(stream_cursors.time_us, excluded.time_us)`
type AdvanceCursorParams struct { Source string TimeUs int64}
func (q *Queries) AdvanceCursor(ctx context.Context, arg AdvanceCursorParams) error { _, err := q.exec(ctx, q.advanceCursorStmt, advanceCursor, arg.Source, arg.TimeUs) return err}
const advanceReplayAccount = `-- name: AdvanceReplayAccount :execINSERT INTO replay_accounts(source, author, sequence) VALUES (?1, ?2, ?3)ON CONFLICT(source, author) DO UPDATE SET sequence = excluded.sequence`
type AdvanceReplayAccountParams struct { Source string Author int64 Sequence int64}
func (q *Queries) AdvanceReplayAccount(ctx context.Context, arg AdvanceReplayAccountParams) error { _, err := q.exec(ctx, q.advanceReplayAccountStmt, advanceReplayAccount, arg.Source, arg.Author, arg.Sequence) return err}
const authorRecords = `-- name: AuthorRecords :manySELECT author, subject, tag, score, created_at, record_key, comment, source FROM vouches WHERE author = ?`
func (q *Queries) AuthorRecords(ctx context.Context, author string) ([]Vouch, error) { rows, err := q.query(ctx, q.authorRecordsStmt, authorRecords, author) if err != nil { return nil, err } defer rows.Close() items := []Vouch{} for rows.Next() { var i Vouch if err := rows.Scan( &i.Author, &i.Subject, &i.Tag, &i.Score, &i.CreatedAt, &i.RecordKey, &i.Comment, &i.Source, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const bumpGraphRevision = `-- name: BumpGraphRevision :execUPDATE graph_revision SET revision = revision + 1 WHERE singleton = 1`
func (q *Queries) BumpGraphRevision(ctx context.Context) error { _, err := q.exec(ctx, q.bumpGraphRevisionStmt, bumpGraphRevision) return err}
const cachedTrust = `-- name: CachedTrust :oneSELECT status, score FROM trust_cache WHERE cache_key = ? AND expires_us > ?`
type CachedTrustParams struct { CacheKey string ExpiresUs int64}
type CachedTrustRow struct { Status string Score sql.NullFloat64}
func (q *Queries) CachedTrust(ctx context.Context, arg CachedTrustParams) (CachedTrustRow, error) { row := q.queryRow(ctx, q.cachedTrustStmt, cachedTrust, arg.CacheKey, arg.ExpiresUs) var i CachedTrustRow err := row.Scan(&i.Status, &i.Score) return i, err}
const clearListAuthor = `-- name: ClearListAuthor :execDELETE FROM list_records WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))`
func (q *Queries) ClearListAuthor(ctx context.Context, author string) error { _, err := q.exec(ctx, q.clearListAuthorStmt, clearListAuthor, author) return err}
const clearListVersions = `-- name: ClearListVersions :execDELETE FROM list_versions WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))`
func (q *Queries) ClearListVersions(ctx context.Context, author string) error { _, err := q.exec(ctx, q.clearListVersionsStmt, clearListVersions, author) return err}
const clearSoft = `-- name: ClearSoft :execDELETE FROM soft_vouches WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))`
func (q *Queries) ClearSoft(ctx context.Context, author string) error { _, err := q.exec(ctx, q.clearSoftStmt, clearSoft, author) return err}
const clearSoftVersions = `-- name: ClearSoftVersions :execDELETE FROM soft_versions WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))`
func (q *Queries) ClearSoftVersions(ctx context.Context, author string) error { _, err := q.exec(ctx, q.clearSoftVersionsStmt, clearSoftVersions, author) return err}
const clearTrust = `-- name: ClearTrust :execDELETE FROM trust_cache`
func (q *Queries) ClearTrust(ctx context.Context) error { _, err := q.exec(ctx, q.clearTrustStmt, clearTrust) return err}
const clearVersions = `-- name: ClearVersions :execDELETE FROM record_versions WHERE author = ?`
func (q *Queries) ClearVersions(ctx context.Context, author string) error { _, err := q.exec(ctx, q.clearVersionsStmt, clearVersions, author) return err}
const clearVouches = `-- name: ClearVouches :execDELETE FROM vouches WHERE author = ?`
func (q *Queries) ClearVouches(ctx context.Context, author string) error { _, err := q.exec(ctx, q.clearVouchesStmt, clearVouches, author) return err}
const consumeSecret = `-- name: ConsumeSecret :oneDELETE FROM secrets WHERE kind = ? AND id = ? AND expires > ? RETURNING value`
type ConsumeSecretParams struct { Kind string ID string Expires int64}
func (q *Queries) ConsumeSecret(ctx context.Context, arg ConsumeSecretParams) ([]byte, error) { row := q.queryRow(ctx, q.consumeSecretStmt, consumeSecret, arg.Kind, arg.ID, arg.Expires) var value []byte err := row.Scan(&value) return value, err}
const cursor = `-- name: Cursor :oneSELECT time_us FROM stream_cursors WHERE source = ?`
func (q *Queries) Cursor(ctx context.Context, source string) (int64, error) { row := q.queryRow(ctx, q.cursorStmt, cursor, source) var time_us int64 err := row.Scan(&time_us) return time_us, err}
const deferReplayIndexes = `-- name: DeferReplayIndexes :execUPDATE replay_indexes SET source = ?, deferred = 1 WHERE singleton = 1`
func (q *Queries) DeferReplayIndexes(ctx context.Context, source string) error { _, err := q.exec(ctx, q.deferReplayIndexesStmt, deferReplayIndexes, source) return err}
const deferTrustInvalidation = `-- name: DeferTrustInvalidation :execUPDATE cache_policy SET deferred = 1 WHERE singleton = 1`
func (q *Queries) DeferTrustInvalidation(ctx context.Context) error { _, err := q.exec(ctx, q.deferTrustInvalidationStmt, deferTrustInvalidation) return err}
const deleteListRecord = `-- name: DeleteListRecord :execDELETE FROM list_records WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)) AND source = ?2 AND record_key = ?3`
type DeleteListRecordParams struct { Author string Source string RecordKey string}
func (q *Queries) DeleteListRecord(ctx context.Context, arg DeleteListRecordParams) error { _, err := q.exec(ctx, q.deleteListRecordStmt, deleteListRecord, arg.Author, arg.Source, arg.RecordKey) return err}
const deleteRecord = `-- name: DeleteRecord :execDELETE FROM vouches WHERE author = ? AND record_key = ?`
type DeleteRecordParams struct { Author string RecordKey string}
func (q *Queries) DeleteRecord(ctx context.Context, arg DeleteRecordParams) error { _, err := q.exec(ctx, q.deleteRecordStmt, deleteRecord, arg.Author, arg.RecordKey) return err}
const deleteReplaySoft = `-- name: DeleteReplaySoft :execDELETE FROM soft_vouches WHERE author = ?1 AND source = ?2 AND record_key = ?3`
type DeleteReplaySoftParams struct { Author int64 Source string RecordKey string}
func (q *Queries) DeleteReplaySoft(ctx context.Context, arg DeleteReplaySoftParams) error { _, err := q.exec(ctx, q.deleteReplaySoftStmt, deleteReplaySoft, arg.Author, arg.Source, arg.RecordKey) return err}
const deleteSoft = `-- name: DeleteSoft :execDELETE FROM soft_vouches WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)) AND source = ?2 AND record_key = ?3`
type DeleteSoftParams struct { Author string Source string RecordKey string}
func (q *Queries) DeleteSoft(ctx context.Context, arg DeleteSoftParams) error { _, err := q.exec(ctx, q.deleteSoftStmt, deleteSoft, arg.Author, arg.Source, arg.RecordKey) return err}
const deleteTrust = `-- name: DeleteTrust :execDELETE FROM trust_cache WHERE cache_key = ?`
func (q *Queries) DeleteTrust(ctx context.Context, cacheKey string) error { _, err := q.exec(ctx, q.deleteTrustStmt, deleteTrust, cacheKey) return err}
const finishReplayIndexes = `-- name: FinishReplayIndexes :execUPDATE replay_indexes SET deferred = 0 WHERE singleton = 1`
func (q *Queries) FinishReplayIndexes(ctx context.Context) error { _, err := q.exec(ctx, q.finishReplayIndexesStmt, finishReplayIndexes) return err}
const getSecret = `-- name: GetSecret :oneSELECT value FROM secrets WHERE kind = ? AND id = ? AND expires > ?`
type GetSecretParams struct { Kind string ID string Expires int64}
func (q *Queries) GetSecret(ctx context.Context, arg GetSecretParams) ([]byte, error) { row := q.queryRow(ctx, q.getSecretStmt, getSecret, arg.Kind, arg.ID, arg.Expires) var value []byte err := row.Scan(&value) return value, err}
const graph = `-- name: Graph :manySELECT vouches.author, vouches.subject, vouches.tag, vouches.score, vouches.created_at, vouches.record_key, vouches.comment, vouches.source FROM vouches JOIN participants ON participants.did = vouches.authorWHERE participants.active = 1AND NOT EXISTS (SELECT 1 FROM participants target WHERE target.did = vouches.subject AND target.active = 0)AND (tag = ?1 OR (CAST(?2 AS INTEGER) = 1 AND tag = ''))ORDER BY author, subject, tag LIMIT ?3`
type GraphParams struct { Tag string Fallback int64 MaxRows int64}
func (q *Queries) Graph(ctx context.Context, arg GraphParams) ([]Vouch, error) { rows, err := q.query(ctx, q.graphStmt, graph, arg.Tag, arg.Fallback, arg.MaxRows) if err != nil { return nil, err } defer rows.Close() items := []Vouch{} for rows.Next() { var i Vouch if err := rows.Scan( &i.Author, &i.Subject, &i.Tag, &i.Score, &i.CreatedAt, &i.RecordKey, &i.Comment, &i.Source, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const graphRevision = `-- name: GraphRevision :oneSELECT revision FROM graph_revision WHERE singleton = 1`
func (q *Queries) GraphRevision(ctx context.Context) (int64, error) { row := q.queryRow(ctx, q.graphRevisionStmt, graphRevision) var revision int64 err := row.Scan(&revision) return revision, err}
const incoming = `-- name: Incoming :manySELECT vouches.author, vouches.subject, vouches.tag, vouches.score, vouches.created_at, vouches.record_key, vouches.comment, vouches.source FROM vouches JOIN participants ON participants.did = vouches.authorWHERE subject = ?1 AND participants.active = 1AND NOT EXISTS (SELECT 1 FROM participants target WHERE target.did = vouches.subject AND target.active = 0)AND (tag = ?2 OR (CAST(?3 AS INTEGER) = 1 AND tag = ''))ORDER BY author, tag LIMIT ?4`
type IncomingParams struct { Subject string Tag string Column3 int64 Limit int64}
func (q *Queries) Incoming(ctx context.Context, arg IncomingParams) ([]Vouch, error) { rows, err := q.query(ctx, q.incomingStmt, incoming, arg.Subject, arg.Tag, arg.Column3, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() items := []Vouch{} for rows.Next() { var i Vouch if err := rows.Scan( &i.Author, &i.Subject, &i.Tag, &i.Score, &i.CreatedAt, &i.RecordKey, &i.Comment, &i.Source, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const initCursor = `-- name: InitCursor :execINSERT INTO stream_cursors(source, time_us) VALUES (?, ?) ON CONFLICT(source) DO NOTHING`
type InitCursorParams struct { Source string TimeUs int64}
func (q *Queries) InitCursor(ctx context.Context, arg InitCursorParams) error { _, err := q.exec(ctx, q.initCursorStmt, initCursor, arg.Source, arg.TimeUs) return err}
const insertVouch = `-- name: InsertVouch :execINSERT INTO vouches(author, subject, tag, score, created_at, record_key, comment) VALUES (?, ?, ?, ?, ?, ?, ?)`
type InsertVouchParams struct { Author string Subject string Tag string Score int64 CreatedAt string RecordKey string Comment string}
func (q *Queries) InsertVouch(ctx context.Context, arg InsertVouchParams) error { _, err := q.exec(ctx, q.insertVouchStmt, insertVouch, arg.Author, arg.Subject, arg.Tag, arg.Score, arg.CreatedAt, arg.RecordKey, arg.Comment, ) return err}
const join = `-- name: Join :execINSERT INTO participants(did) VALUES (?) ON CONFLICT(did) DO NOTHING`
func (q *Queries) Join(ctx context.Context, did string) error { _, err := q.exec(ctx, q.joinStmt, join, did) return err}
const joinReplaySoft = `-- name: JoinReplaySoft :execINSERT INTO soft_accounts(did) VALUES (?) ON CONFLICT(did) DO NOTHING`
func (q *Queries) JoinReplaySoft(ctx context.Context, did int64) error { _, err := q.exec(ctx, q.joinReplaySoftStmt, joinReplaySoft, did) return err}
const joinSoft = `-- name: JoinSoft :execINSERT INTO soft_accounts(did) SELECT id FROM identities WHERE did = CAST(?1 AS TEXT) ON CONFLICT(did) DO NOTHING`
func (q *Queries) JoinSoft(ctx context.Context, did string) error { _, err := q.exec(ctx, q.joinSoftStmt, joinSoft, did) return err}
const legacyKeys = `-- name: LegacyKeys :manySELECT author, subject, tag FROM vouches WHERE record_key = ''`
type LegacyKeysRow struct { Author string Subject string Tag string}
func (q *Queries) LegacyKeys(ctx context.Context) ([]LegacyKeysRow, error) { rows, err := q.query(ctx, q.legacyKeysStmt, legacyKeys) if err != nil { return nil, err } defer rows.Close() items := []LegacyKeysRow{} for rows.Next() { var i LegacyKeysRow if err := rows.Scan(&i.Author, &i.Subject, &i.Tag); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const listAuthorRecords = `-- name: ListAuthorRecords :manySELECT a.did AS author, r.source, r.record_key, r.list_uri, COALESCE(s.did, '') AS subject, r.purpose, r.created_atFROM list_records r JOIN identities a ON a.id = r.author LEFT JOIN identities s ON s.id = r.subjectWHERE a.did = CAST(?1 AS TEXT) AND r.source = ?2`
type ListAuthorRecordsParams struct { Author string Source string}
type ListAuthorRecordsRow struct { Author string Source string RecordKey string ListUri string Subject string Purpose string CreatedAt string}
func (q *Queries) ListAuthorRecords(ctx context.Context, arg ListAuthorRecordsParams) ([]ListAuthorRecordsRow, error) { rows, err := q.query(ctx, q.listAuthorRecordsStmt, listAuthorRecords, arg.Author, arg.Source) if err != nil { return nil, err } defer rows.Close() items := []ListAuthorRecordsRow{} for rows.Next() { var i ListAuthorRecordsRow if err := rows.Scan( &i.Author, &i.Source, &i.RecordKey, &i.ListUri, &i.Subject, &i.Purpose, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const listBootstrap = `-- name: ListBootstrap :oneSELECT bootstrap_us FROM list_bootstraps WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))`
func (q *Queries) ListBootstrap(ctx context.Context, author string) (int64, error) { row := q.queryRow(ctx, q.listBootstrapStmt, listBootstrap, author) var bootstrap_us int64 err := row.Scan(&bootstrap_us) return bootstrap_us, err}
const listGraph = `-- name: ListGraph :manySELECT e.author, e.subject, e.source, e.record_key, e.created_at, e.list_uri, e.list_author, e.list_key, e.item_key FROM list_edges eWHERE (CAST(?1 AS INTEGER) = 1 OR EXISTS (SELECT 1 FROM participants p WHERE p.did = e.author AND p.active = 1))AND NOT EXISTS (SELECT 1 FROM vouches v WHERE v.author = e.author AND v.subject = e.subject AND (v.tag = ?2 OR (CAST(?3 AS INTEGER) = 1 AND v.tag = '')))LIMIT ?4`
type ListGraphParams struct { AllAuthors int64 Tag string Fallback int64 MaxRows int64}
func (q *Queries) ListGraph(ctx context.Context, arg ListGraphParams) ([]ListEdge, error) { rows, err := q.query(ctx, q.listGraphStmt, listGraph, arg.AllAuthors, arg.Tag, arg.Fallback, arg.MaxRows, ) if err != nil { return nil, err } defer rows.Close() items := []ListEdge{} for rows.Next() { var i ListEdge if err := rows.Scan( &i.Author, &i.Subject, &i.Source, &i.RecordKey, &i.CreatedAt, &i.ListUri, &i.ListAuthor, &i.ListKey, &i.ItemKey, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const listIncoming = `-- name: ListIncoming :manySELECT e.author, e.subject, e.source, e.record_key, e.created_at, e.list_uri, e.list_author, e.list_key, e.item_key FROM list_edges eWHERE e.subject = ?1AND (CAST(?2 AS INTEGER) = 1 OR EXISTS (SELECT 1 FROM participants p WHERE p.did = e.author AND p.active = 1))AND NOT EXISTS (SELECT 1 FROM vouches v WHERE v.author = e.author AND v.subject = e.subject AND (v.tag = ?3 OR (CAST(?4 AS INTEGER) = 1 AND v.tag = '')))ORDER BY e.author, e.list_uri LIMIT ?5`
type ListIncomingParams struct { Subject string AllAuthors int64 Tag string Fallback int64 MaxRows int64}
func (q *Queries) ListIncoming(ctx context.Context, arg ListIncomingParams) ([]ListEdge, error) { rows, err := q.query(ctx, q.listIncomingStmt, listIncoming, arg.Subject, arg.AllAuthors, arg.Tag, arg.Fallback, arg.MaxRows, ) if err != nil { return nil, err } defer rows.Close() items := []ListEdge{} for rows.Next() { var i ListEdge if err := rows.Scan( &i.Author, &i.Subject, &i.Source, &i.RecordKey, &i.CreatedAt, &i.ListUri, &i.ListAuthor, &i.ListKey, &i.ItemKey, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const listOutgoing = `-- name: ListOutgoing :manySELECT e.author, e.subject, e.source, e.record_key, e.created_at, e.list_uri, e.list_author, e.list_key, e.item_key FROM list_edges eWHERE e.author = ?1AND (CAST(?2 AS INTEGER) = 1 OR EXISTS (SELECT 1 FROM participants p WHERE p.did = e.author AND p.active = 1))AND NOT EXISTS (SELECT 1 FROM vouches v WHERE v.author = e.author AND v.subject = e.subject AND (v.tag = ?3 OR (CAST(?4 AS INTEGER) = 1 AND v.tag = '')))LIMIT ?5`
type ListOutgoingParams struct { Author string AllAuthors int64 Tag string Fallback int64 MaxRows int64}
func (q *Queries) ListOutgoing(ctx context.Context, arg ListOutgoingParams) ([]ListEdge, error) { rows, err := q.query(ctx, q.listOutgoingStmt, listOutgoing, arg.Author, arg.AllAuthors, arg.Tag, arg.Fallback, arg.MaxRows, ) if err != nil { return nil, err } defer rows.Close() items := []ListEdge{} for rows.Next() { var i ListEdge if err := rows.Scan( &i.Author, &i.Subject, &i.Source, &i.RecordKey, &i.CreatedAt, &i.ListUri, &i.ListAuthor, &i.ListKey, &i.ItemKey, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const listRecord = `-- name: ListRecord :oneSELECT a.did AS author, r.source, r.record_key, r.list_uri, COALESCE(s.did, '') AS subject, r.purpose, r.created_atFROM list_records r JOIN identities a ON a.id = r.author LEFT JOIN identities s ON s.id = r.subjectWHERE a.did = CAST(?1 AS TEXT) AND r.source = ?2 AND r.record_key = ?3`
type ListRecordParams struct { Author string Source string RecordKey string}
type ListRecordRow struct { Author string Source string RecordKey string ListUri string Subject string Purpose string CreatedAt string}
func (q *Queries) ListRecord(ctx context.Context, arg ListRecordParams) (ListRecordRow, error) { row := q.queryRow(ctx, q.listRecordStmt, listRecord, arg.Author, arg.Source, arg.RecordKey) var i ListRecordRow err := row.Scan( &i.Author, &i.Source, &i.RecordKey, &i.ListUri, &i.Subject, &i.Purpose, &i.CreatedAt, ) return i, err}
const listURIRecords = `-- name: ListURIRecords :manySELECT a.did AS author, r.source, r.record_key, r.list_uri, COALESCE(s.did, '') AS subject, r.purpose, r.created_atFROM list_records r JOIN identities a ON a.id = r.author LEFT JOIN identities s ON s.id = r.subjectWHERE r.list_uri = ? AND r.source != 'app.bsky.graph.listblock'`
type ListURIRecordsRow struct { Author string Source string RecordKey string ListUri string Subject string Purpose string CreatedAt string}
func (q *Queries) ListURIRecords(ctx context.Context, listUri string) ([]ListURIRecordsRow, error) { rows, err := q.query(ctx, q.listURIRecordsStmt, listURIRecords, listUri) if err != nil { return nil, err } defer rows.Close() items := []ListURIRecordsRow{} for rows.Next() { var i ListURIRecordsRow if err := rows.Scan( &i.Author, &i.Source, &i.RecordKey, &i.ListUri, &i.Subject, &i.Purpose, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const listVersion = `-- name: ListVersion :oneSELECT time_us FROM list_versions WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)) AND source = ?2 AND record_key = ?3`
type ListVersionParams struct { Author string Source string RecordKey string}
func (q *Queries) ListVersion(ctx context.Context, arg ListVersionParams) (int64, error) { row := q.queryRow(ctx, q.listVersionStmt, listVersion, arg.Author, arg.Source, arg.RecordKey) var time_us int64 err := row.Scan(&time_us) return time_us, err}
const listWatermark = `-- name: ListWatermark :oneSELECT bootstrap_us FROM list_snapshots WHERE list_uri = ?`
func (q *Queries) ListWatermark(ctx context.Context, listUri string) (int64, error) { row := q.queryRow(ctx, q.listWatermarkStmt, listWatermark, listUri) var bootstrap_us int64 err := row.Scan(&bootstrap_us) return bootstrap_us, err}
const outgoing = `-- name: Outgoing :manySELECT v.author, v.subject, v.tag, v.score, v.created_at, v.record_key, v.comment, v.source FROM vouches v JOIN participants p ON p.did = v.authorWHERE v.author = ?1 AND p.active = 1AND NOT EXISTS (SELECT 1 FROM participants target WHERE target.did = v.subject AND target.active = 0)AND (v.tag = ?2 OR (CAST(?3 AS INTEGER) = 1 AND v.tag = ''))ORDER BY v.subject, v.tag LIMIT ?4`
type OutgoingParams struct { Author string Tag string Fallback int64 MaxRows int64}
// Outgoing reads preserve per-pair selection and use author indexes rather than a global graph scan.func (q *Queries) Outgoing(ctx context.Context, arg OutgoingParams) ([]Vouch, error) { rows, err := q.query(ctx, q.outgoingStmt, outgoing, arg.Author, arg.Tag, arg.Fallback, arg.MaxRows, ) if err != nil { return nil, err } defer rows.Close() items := []Vouch{} for rows.Next() { var i Vouch if err := rows.Scan( &i.Author, &i.Subject, &i.Tag, &i.Score, &i.CreatedAt, &i.RecordKey, &i.Comment, &i.Source, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const ownVouches = `-- name: OwnVouches :manySELECT vouches.author, vouches.subject, vouches.tag, vouches.score, vouches.created_at, vouches.record_key, vouches.comment, vouches.source FROM vouches JOIN participants ON participants.did = vouches.authorWHERE participants.active = 1 AND author = ? ORDER BY subject, tag LIMIT ? OFFSET ?`
type OwnVouchesParams struct { Author string Limit int64 Offset int64}
func (q *Queries) OwnVouches(ctx context.Context, arg OwnVouchesParams) ([]Vouch, error) { rows, err := q.query(ctx, q.ownVouchesStmt, ownVouches, arg.Author, arg.Limit, arg.Offset) if err != nil { return nil, err } defer rows.Close() items := []Vouch{} for rows.Next() { var i Vouch if err := rows.Scan( &i.Author, &i.Subject, &i.Tag, &i.Score, &i.CreatedAt, &i.RecordKey, &i.Comment, &i.Source, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const participant = `-- name: Participant :oneSELECT did, threshold, synced_at, bootstrap_us, active, account_us FROM participants WHERE did = ?`
func (q *Queries) Participant(ctx context.Context, did string) (Participant, error) { row := q.queryRow(ctx, q.participantStmt, participant, did) var i Participant err := row.Scan( &i.Did, &i.Threshold, &i.SyncedAt, &i.BootstrapUs, &i.Active, &i.AccountUs, ) return i, err}
const participants = `-- name: Participants :manySELECT did, threshold, synced_at, bootstrap_us, active, account_us FROM participants ORDER BY synced_at, did LIMIT ?`
func (q *Queries) Participants(ctx context.Context, limit int64) ([]Participant, error) { rows, err := q.query(ctx, q.participantsStmt, participants, limit) if err != nil { return nil, err } defer rows.Close() items := []Participant{} for rows.Next() { var i Participant if err := rows.Scan( &i.Did, &i.Threshold, &i.SyncedAt, &i.BootstrapUs, &i.Active, &i.AccountUs, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const pruneSecrets = `-- name: PruneSecrets :execDELETE FROM secrets WHERE expires <= ?`
func (q *Queries) PruneSecrets(ctx context.Context, expires int64) error { _, err := q.exec(ctx, q.pruneSecretsStmt, pruneSecrets, expires) return err}
const putIdentity = `-- name: PutIdentity :execINSERT INTO identities(did) VALUES (?) ON CONFLICT(did) DO NOTHING`
func (q *Queries) PutIdentity(ctx context.Context, did string) error { _, err := q.exec(ctx, q.putIdentityStmt, putIdentity, did) return err}
const putListBootstrap = `-- name: PutListBootstrap :execINSERT INTO list_bootstraps(author, bootstrap_us) VALUES ((SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)), ?2)ON CONFLICT(author) DO UPDATE SET bootstrap_us = excluded.bootstrap_us`
type PutListBootstrapParams struct { Author string BootstrapUs int64}
func (q *Queries) PutListBootstrap(ctx context.Context, arg PutListBootstrapParams) error { _, err := q.exec(ctx, q.putListBootstrapStmt, putListBootstrap, arg.Author, arg.BootstrapUs) return err}
const putListRecord = `-- name: PutListRecord :execINSERT INTO list_records(author, source, record_key, list_uri, subject, purpose, created_at)VALUES ((SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)), ?2, ?3, ?4, (SELECT id FROM identities WHERE did = NULLIF(CAST(?5 AS TEXT), '')), ?6, ?7)ON CONFLICT(author, source, record_key) DO UPDATE SET list_uri = excluded.list_uri, subject = excluded.subject, purpose = excluded.purpose, created_at = excluded.created_atWHERE list_uri != excluded.list_uri OR subject IS NOT excluded.subject OR purpose != excluded.purpose OR created_at != excluded.created_at`
type PutListRecordParams struct { Author string Source string RecordKey string ListUri string Subject string Purpose string CreatedAt string}
func (q *Queries) PutListRecord(ctx context.Context, arg PutListRecordParams) error { _, err := q.exec(ctx, q.putListRecordStmt, putListRecord, arg.Author, arg.Source, arg.RecordKey, arg.ListUri, arg.Subject, arg.Purpose, arg.CreatedAt, ) return err}
const putListVersion = `-- name: PutListVersion :execINSERT INTO list_versions(author, source, record_key, time_us) VALUES ((SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)), ?2, ?3, ?4)ON CONFLICT(author, source, record_key) DO UPDATE SET time_us = excluded.time_us`
type PutListVersionParams struct { Author string Source string RecordKey string TimeUs int64}
func (q *Queries) PutListVersion(ctx context.Context, arg PutListVersionParams) error { _, err := q.exec(ctx, q.putListVersionStmt, putListVersion, arg.Author, arg.Source, arg.RecordKey, arg.TimeUs, ) return err}
const putListWatermark = `-- name: PutListWatermark :execINSERT INTO list_snapshots(list_uri, owner, bootstrap_us) VALUES (?1, (SELECT id FROM identities WHERE did = CAST(?2 AS TEXT)), ?3)ON CONFLICT(list_uri) DO UPDATE SET bootstrap_us = excluded.bootstrap_us`
type PutListWatermarkParams struct { ListUri string Owner string BootstrapUs int64}
func (q *Queries) PutListWatermark(ctx context.Context, arg PutListWatermarkParams) error { _, err := q.exec(ctx, q.putListWatermarkStmt, putListWatermark, arg.ListUri, arg.Owner, arg.BootstrapUs) return err}
const putSecret = `-- name: PutSecret :execINSERT INTO secrets(kind, id, value, expires) VALUES (?, ?, ?, ?)ON CONFLICT(kind, id) DO UPDATE SET value = excluded.value, expires = excluded.expires`
type PutSecretParams struct { Kind string ID string Value []byte Expires int64}
func (q *Queries) PutSecret(ctx context.Context, arg PutSecretParams) error { _, err := q.exec(ctx, q.putSecretStmt, putSecret, arg.Kind, arg.ID, arg.Value, arg.Expires, ) return err}
const recordVersion = `-- name: RecordVersion :oneSELECT time_us FROM record_versions WHERE author = ? AND record_key = ?`
type RecordVersionParams struct { Author string RecordKey string}
func (q *Queries) RecordVersion(ctx context.Context, arg RecordVersionParams) (int64, error) { row := q.queryRow(ctx, q.recordVersionStmt, recordVersion, arg.Author, arg.RecordKey) var time_us int64 err := row.Scan(&time_us) return time_us, err}
const removeSecret = `-- name: RemoveSecret :execDELETE FROM secrets WHERE kind = ? AND id = ?`
type RemoveSecretParams struct { Kind string ID string}
func (q *Queries) RemoveSecret(ctx context.Context, arg RemoveSecretParams) error { _, err := q.exec(ctx, q.removeSecretStmt, removeSecret, arg.Kind, arg.ID) return err}
const replaceReplaySoft = `-- name: ReplaceReplaySoft :execINSERT INTO soft_vouches(author, subject, source, record_key, score, created_at)VALUES (?1, (SELECT id FROM identities WHERE did = CAST(?2 AS TEXT)), ?3, ?4, ?5, ?6)ON CONFLICT(author, source, record_key) DO UPDATE SET subject = excluded.subject, score = excluded.score, created_at = excluded.created_atWHERE subject != excluded.subject OR score != excluded.score OR created_at != excluded.created_at`
type ReplaceReplaySoftParams struct { Author int64 Subject string Source string RecordKey string Score float64 CreatedAt string}
func (q *Queries) ReplaceReplaySoft(ctx context.Context, arg ReplaceReplaySoftParams) error { _, err := q.exec(ctx, q.replaceReplaySoftStmt, replaceReplaySoft, arg.Author, arg.Subject, arg.Source, arg.RecordKey, arg.Score, arg.CreatedAt, ) return err}
const replaceSoft = `-- name: ReplaceSoft :execINSERT INTO soft_vouches(author, subject, source, record_key, score, created_at)VALUES ((SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)), (SELECT id FROM identities WHERE did = CAST(?2 AS TEXT)), ?3, ?4, ?5, ?6)ON CONFLICT(author, source, record_key) DO UPDATE SET subject = excluded.subject, score = excluded.score, created_at = excluded.created_atWHERE subject != excluded.subject OR score != excluded.score OR created_at != excluded.created_at`
type ReplaceSoftParams struct { Author string Subject string Source string RecordKey string Score float64 CreatedAt string}
func (q *Queries) ReplaceSoft(ctx context.Context, arg ReplaceSoftParams) error { _, err := q.exec(ctx, q.replaceSoftStmt, replaceSoft, arg.Author, arg.Subject, arg.Source, arg.RecordKey, arg.Score, arg.CreatedAt, ) return err}
const replaceVouch = `-- name: ReplaceVouch :execINSERT INTO vouches(author, subject, tag, score, created_at, record_key, comment) VALUES (?, ?, ?, ?, ?, ?, ?)ON CONFLICT(author, subject, tag) DO UPDATE SET score = excluded.score, created_at = excluded.created_at, record_key = excluded.record_key, comment = excluded.commentWHERE score != excluded.score OR created_at != excluded.created_at OR record_key != excluded.record_key OR comment != excluded.comment`
type ReplaceVouchParams struct { Author string Subject string Tag string Score int64 CreatedAt string RecordKey string Comment string}
func (q *Queries) ReplaceVouch(ctx context.Context, arg ReplaceVouchParams) error { _, err := q.exec(ctx, q.replaceVouchStmt, replaceVouch, arg.Author, arg.Subject, arg.Tag, arg.Score, arg.CreatedAt, arg.RecordKey, arg.Comment, ) return err}
const replayClearLists = `-- name: ReplayClearLists :execDELETE FROM list_records WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))AND NOT EXISTS (SELECT 1 FROM list_snapshots s WHERE s.list_uri = list_records.list_uri AND s.bootstrap_us >= ?2)AND (source != 'app.bsky.graph.listblock' OR NOT EXISTS (SELECT 1 FROM list_bootstraps b WHERE b.author = list_records.author AND b.bootstrap_us >= ?2))`
type ReplayClearListsParams struct { Author string TimeUs int64}
func (q *Queries) ReplayClearLists(ctx context.Context, arg ReplayClearListsParams) error { _, err := q.exec(ctx, q.replayClearListsStmt, replayClearLists, arg.Author, arg.TimeUs) return err}
const replayIndexState = `-- name: ReplayIndexState :oneSELECT source, deferred FROM replay_indexes WHERE singleton = 1`
type ReplayIndexStateRow struct { Source string Deferred int64}
func (q *Queries) ReplayIndexState(ctx context.Context) (ReplayIndexStateRow, error) { row := q.queryRow(ctx, q.replayIndexStateStmt, replayIndexState) var i ReplayIndexStateRow err := row.Scan(&i.Source, &i.Deferred) return i, err}
const replaySequence = `-- name: ReplaySequence :oneSELECT i.id, CAST(COALESCE(r.sequence, 0) AS INTEGER) AS sequence FROM identities iLEFT JOIN replay_accounts r ON r.author = i.id AND r.source = ?1WHERE i.did = CAST(?2 AS TEXT)`
type ReplaySequenceParams struct { Source string Author string}
type ReplaySequenceRow struct { ID int64 Sequence int64}
func (q *Queries) ReplaySequence(ctx context.Context, arg ReplaySequenceParams) (ReplaySequenceRow, error) { row := q.queryRow(ctx, q.replaySequenceStmt, replaySequence, arg.Source, arg.Author) var i ReplaySequenceRow err := row.Scan(&i.ID, &i.Sequence) return i, err}
const resumeTrustInvalidation = `-- name: ResumeTrustInvalidation :execUPDATE cache_policy SET deferred = 0 WHERE singleton = 1`
func (q *Queries) ResumeTrustInvalidation(ctx context.Context) error { _, err := q.exec(ctx, q.resumeTrustInvalidationStmt, resumeTrustInvalidation) return err}
const saveDependency = `-- name: SaveDependency :execINSERT OR IGNORE INTO trust_dependencies(cache_key, author, source, record_key)VALUES (?1, (SELECT id FROM identities WHERE did = CAST(?2 AS TEXT)), ?3, ?4)`
type SaveDependencyParams struct { CacheKey string Author string Source string RecordKey string}
func (q *Queries) SaveDependency(ctx context.Context, arg SaveDependencyParams) error { _, err := q.exec(ctx, q.saveDependencyStmt, saveDependency, arg.CacheKey, arg.Author, arg.Source, arg.RecordKey, ) return err}
const saveTrust = `-- name: SaveTrust :execINSERT INTO trust_cache(cache_key, status, score, expires_us) VALUES (?, ?, ?, ?)`
type SaveTrustParams struct { CacheKey string Status string Score sql.NullFloat64 ExpiresUs int64}
func (q *Queries) SaveTrust(ctx context.Context, arg SaveTrustParams) error { _, err := q.exec(ctx, q.saveTrustStmt, saveTrust, arg.CacheKey, arg.Status, arg.Score, arg.ExpiresUs, ) return err}
const saveTrustPath = `-- name: SaveTrustPath :execINSERT INTO trust_cache_paths(cache_key, position, did) VALUES (?, ?, ?)`
type SaveTrustPathParams struct { CacheKey string Position int64 Did string}
func (q *Queries) SaveTrustPath(ctx context.Context, arg SaveTrustPathParams) error { _, err := q.exec(ctx, q.saveTrustPathStmt, saveTrustPath, arg.CacheKey, arg.Position, arg.Did) return err}
const saveTrustScore = `-- name: SaveTrustScore :execINSERT INTO trust_cache_scores(cache_key, position, did, assertion, source, list_uri, score, comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?)`
type SaveTrustScoreParams struct { CacheKey string Position int64 Did string Assertion sql.NullFloat64 Source string ListUri string Score float64 Comment string}
func (q *Queries) SaveTrustScore(ctx context.Context, arg SaveTrustScoreParams) error { _, err := q.exec(ctx, q.saveTrustScoreStmt, saveTrustScore, arg.CacheKey, arg.Position, arg.Did, arg.Assertion, arg.Source, arg.ListUri, arg.Score, arg.Comment, ) return err}
const setAccount = `-- name: SetAccount :execUPDATE participants SET active = ?, account_us = ?, synced_at = ? WHERE did = ?`
type SetAccountParams struct { Active int64 AccountUs int64 SyncedAt string Did string}
func (q *Queries) SetAccount(ctx context.Context, arg SetAccountParams) error { _, err := q.exec(ctx, q.setAccountStmt, setAccount, arg.Active, arg.AccountUs, arg.SyncedAt, arg.Did, ) return err}
const setBootstrap = `-- name: SetBootstrap :execUPDATE participants SET bootstrap_us = ?, account_us = ?, active = 1, synced_at = ? WHERE did = ?`
type SetBootstrapParams struct { BootstrapUs int64 AccountUs int64 SyncedAt string Did string}
func (q *Queries) SetBootstrap(ctx context.Context, arg SetBootstrapParams) error { _, err := q.exec(ctx, q.setBootstrapStmt, setBootstrap, arg.BootstrapUs, arg.AccountUs, arg.SyncedAt, arg.Did, ) return err}
const setDeleted = `-- name: SetDeleted :execUPDATE participants SET active = 0, account_us = ?, bootstrap_us = ?, synced_at = ? WHERE did = ?`
type SetDeletedParams struct { AccountUs int64 BootstrapUs int64 SyncedAt string Did string}
func (q *Queries) SetDeleted(ctx context.Context, arg SetDeletedParams) error { _, err := q.exec(ctx, q.setDeletedStmt, setDeleted, arg.AccountUs, arg.BootstrapUs, arg.SyncedAt, arg.Did, ) return err}
const setLegacyKey = `-- name: SetLegacyKey :execUPDATE vouches SET record_key = ? WHERE author = ? AND subject = ? AND tag = ?`
type SetLegacyKeyParams struct { RecordKey string Author string Subject string Tag string}
func (q *Queries) SetLegacyKey(ctx context.Context, arg SetLegacyKeyParams) error { _, err := q.exec(ctx, q.setLegacyKeyStmt, setLegacyKey, arg.RecordKey, arg.Author, arg.Subject, arg.Tag, ) return err}
const setRecordVersion = `-- name: SetRecordVersion :execINSERT INTO record_versions(author, record_key, time_us) VALUES (?, ?, ?)ON CONFLICT(author, record_key) DO UPDATE SET time_us = excluded.time_us`
type SetRecordVersionParams struct { Author string RecordKey string TimeUs int64}
func (q *Queries) SetRecordVersion(ctx context.Context, arg SetRecordVersionParams) error { _, err := q.exec(ctx, q.setRecordVersionStmt, setRecordVersion, arg.Author, arg.RecordKey, arg.TimeUs) return err}
const setReplaySoftVersion = `-- name: SetReplaySoftVersion :execINSERT INTO soft_versions(author, source, record_key, time_us) VALUES (?1, ?2, ?3, ?4)ON CONFLICT(author, source, record_key) DO UPDATE SET time_us = excluded.time_us`
type SetReplaySoftVersionParams struct { Author int64 Source string RecordKey string TimeUs int64}
func (q *Queries) SetReplaySoftVersion(ctx context.Context, arg SetReplaySoftVersionParams) error { _, err := q.exec(ctx, q.setReplaySoftVersionStmt, setReplaySoftVersion, arg.Author, arg.Source, arg.RecordKey, arg.TimeUs, ) return err}
const setSoftVersion = `-- name: SetSoftVersion :execINSERT INTO soft_versions(author, source, record_key, time_us) VALUES ((SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)), ?2, ?3, ?4)ON CONFLICT(author, source, record_key) DO UPDATE SET time_us = excluded.time_us`
type SetSoftVersionParams struct { Author string Source string RecordKey string TimeUs int64}
func (q *Queries) SetSoftVersion(ctx context.Context, arg SetSoftVersionParams) error { _, err := q.exec(ctx, q.setSoftVersionStmt, setSoftVersion, arg.Author, arg.Source, arg.RecordKey, arg.TimeUs, ) return err}
const setSynced = `-- name: SetSynced :execUPDATE participants SET synced_at = ? WHERE did = ?`
type SetSyncedParams struct { SyncedAt string Did string}
func (q *Queries) SetSynced(ctx context.Context, arg SetSyncedParams) error { _, err := q.exec(ctx, q.setSyncedStmt, setSynced, arg.SyncedAt, arg.Did) return err}
const setThreshold = `-- name: SetThreshold :execrowsUPDATE participants SET threshold = ? WHERE did = ?`
type SetThresholdParams struct { Threshold float64 Did string}
func (q *Queries) SetThreshold(ctx context.Context, arg SetThresholdParams) (int64, error) { result, err := q.exec(ctx, q.setThresholdStmt, setThreshold, arg.Threshold, arg.Did) if err != nil { return 0, err } return result.RowsAffected()}
const softAccount = `-- name: SoftAccount :oneSELECT i.did, a.active, a.account_us, a.bootstrap_us FROM soft_accounts a JOIN identities i ON i.id = a.did WHERE i.did = ?`
type SoftAccountRow struct { Did string Active int64 AccountUs int64 BootstrapUs int64}
func (q *Queries) SoftAccount(ctx context.Context, did string) (SoftAccountRow, error) { row := q.queryRow(ctx, q.softAccountStmt, softAccount, did) var i SoftAccountRow err := row.Scan( &i.Did, &i.Active, &i.AccountUs, &i.BootstrapUs, ) return i, err}
const softAccountState = `-- name: SoftAccountState :execUPDATE soft_accounts SET active = ?1, account_us = ?2 WHERE did = (SELECT id FROM identities WHERE did = CAST(?3 AS TEXT))`
type SoftAccountStateParams struct { Active int64 AccountUs int64 Did string}
func (q *Queries) SoftAccountState(ctx context.Context, arg SoftAccountStateParams) error { _, err := q.exec(ctx, q.softAccountStateStmt, softAccountState, arg.Active, arg.AccountUs, arg.Did) return err}
const softBootstrap = `-- name: SoftBootstrap :execUPDATE soft_accounts SET active = 1, account_us = ?1, bootstrap_us = ?2 WHERE did = (SELECT id FROM identities WHERE did = CAST(?3 AS TEXT))`
type SoftBootstrapParams struct { AccountUs int64 BootstrapUs int64 Did string}
func (q *Queries) SoftBootstrap(ctx context.Context, arg SoftBootstrapParams) error { _, err := q.exec(ctx, q.softBootstrapStmt, softBootstrap, arg.AccountUs, arg.BootstrapUs, arg.Did) return err}
const softDeleted = `-- name: SoftDeleted :execUPDATE soft_accounts SET active = 0, account_us = ?1, bootstrap_us = ?2 WHERE did = (SELECT id FROM identities WHERE did = CAST(?3 AS TEXT))`
type SoftDeletedParams struct { AccountUs int64 BootstrapUs int64 Did string}
func (q *Queries) SoftDeleted(ctx context.Context, arg SoftDeletedParams) error { _, err := q.exec(ctx, q.softDeletedStmt, softDeleted, arg.AccountUs, arg.BootstrapUs, arg.Did) return err}
const softGraph = `-- name: SoftGraph :manySELECT s.author, s.subject, s.source, s.record_key, s.score, s.created_at FROM soft_edges sWHERE (CAST(?1 AS INTEGER) = 1 OR EXISTS (SELECT 1 FROM participants p WHERE p.did = s.author AND p.active = 1))AND NOT EXISTS (SELECT 1 FROM vouches v WHERE v.author = s.author AND v.subject = s.subject AND (v.tag = ?2 OR (CAST(?3 AS INTEGER) = 1 AND v.tag = '')))LIMIT ?4`
type SoftGraphParams struct { AllAuthors int64 Tag string Fallback int64 MaxRows int64}
// The caller sorts complete results. Avoid a global DID sort before the edge limit.func (q *Queries) SoftGraph(ctx context.Context, arg SoftGraphParams) ([]SoftEdge, error) { rows, err := q.query(ctx, q.softGraphStmt, softGraph, arg.AllAuthors, arg.Tag, arg.Fallback, arg.MaxRows, ) if err != nil { return nil, err } defer rows.Close() items := []SoftEdge{} for rows.Next() { var i SoftEdge if err := rows.Scan( &i.Author, &i.Subject, &i.Source, &i.RecordKey, &i.Score, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const softIncoming = `-- name: SoftIncoming :manySELECT s.author, s.subject, s.source, s.record_key, s.score, s.created_at FROM soft_edges sWHERE s.subject = ?1AND (CAST(?2 AS INTEGER) = 1 OR EXISTS (SELECT 1 FROM participants p WHERE p.did = s.author AND p.active = 1))AND NOT EXISTS (SELECT 1 FROM vouches v WHERE v.author = s.author AND v.subject = s.subject AND (v.tag = ?3 OR (CAST(?4 AS INTEGER) = 1 AND v.tag = '')))ORDER BY s.author LIMIT ?5`
type SoftIncomingParams struct { Subject string AllAuthors int64 Tag string Fallback int64 MaxRows int64}
func (q *Queries) SoftIncoming(ctx context.Context, arg SoftIncomingParams) ([]SoftEdge, error) { rows, err := q.query(ctx, q.softIncomingStmt, softIncoming, arg.Subject, arg.AllAuthors, arg.Tag, arg.Fallback, arg.MaxRows, ) if err != nil { return nil, err } defer rows.Close() items := []SoftEdge{} for rows.Next() { var i SoftEdge if err := rows.Scan( &i.Author, &i.Subject, &i.Source, &i.RecordKey, &i.Score, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const softOutgoing = `-- name: SoftOutgoing :manySELECT s.author, s.subject, s.source, s.record_key, s.score, s.created_at FROM soft_edges sWHERE s.author = ?1AND (CAST(?2 AS INTEGER) = 1 OR EXISTS (SELECT 1 FROM participants p WHERE p.did = s.author AND p.active = 1))AND NOT EXISTS (SELECT 1 FROM vouches v WHERE v.author = s.author AND v.subject = s.subject AND (v.tag = ?3 OR (CAST(?4 AS INTEGER) = 1 AND v.tag = '')))LIMIT ?5`
type SoftOutgoingParams struct { Author string AllAuthors int64 Tag string Fallback int64 MaxRows int64}
func (q *Queries) SoftOutgoing(ctx context.Context, arg SoftOutgoingParams) ([]SoftEdge, error) { rows, err := q.query(ctx, q.softOutgoingStmt, softOutgoing, arg.Author, arg.AllAuthors, arg.Tag, arg.Fallback, arg.MaxRows, ) if err != nil { return nil, err } defer rows.Close() items := []SoftEdge{} for rows.Next() { var i SoftEdge if err := rows.Scan( &i.Author, &i.Subject, &i.Source, &i.RecordKey, &i.Score, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const softRecords = `-- name: SoftRecords :manySELECT author, subject, source, record_key, score, created_at FROM soft_vouches WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))`
func (q *Queries) SoftRecords(ctx context.Context, author string) ([]SoftVouch, error) { rows, err := q.query(ctx, q.softRecordsStmt, softRecords, author) if err != nil { return nil, err } defer rows.Close() items := []SoftVouch{} for rows.Next() { var i SoftVouch if err := rows.Scan( &i.Author, &i.Subject, &i.Source, &i.RecordKey, &i.Score, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const softReplayState = `-- name: SoftReplayState :oneSELECT a.bootstrap_us, v.time_us FROM (SELECT CAST(?1 AS INTEGER) AS id) iLEFT JOIN soft_accounts a ON a.did = i.idLEFT JOIN soft_versions v ON v.author = i.id AND v.source = ?2 AND v.record_key = ?3`
type SoftReplayStateParams struct { Author int64 Source string RecordKey string}
type SoftReplayStateRow struct { BootstrapUs sql.NullInt64 TimeUs sql.NullInt64}
func (q *Queries) SoftReplayState(ctx context.Context, arg SoftReplayStateParams) (SoftReplayStateRow, error) { row := q.queryRow(ctx, q.softReplayStateStmt, softReplayState, arg.Author, arg.Source, arg.RecordKey) var i SoftReplayStateRow err := row.Scan(&i.BootstrapUs, &i.TimeUs) return i, err}
const softVersion = `-- name: SoftVersion :oneSELECT time_us FROM soft_versions WHERE author = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT)) AND source = ?2 AND record_key = ?3`
type SoftVersionParams struct { Author string Source string RecordKey string}
func (q *Queries) SoftVersion(ctx context.Context, arg SoftVersionParams) (int64, error) { row := q.queryRow(ctx, q.softVersionStmt, softVersion, arg.Author, arg.Source, arg.RecordKey) var time_us int64 err := row.Scan(&time_us) return time_us, err}
const tags = `-- name: Tags :manySELECT DISTINCT tag FROM vouches JOIN participants ON participants.did = vouches.authorWHERE participants.active = 1 AND tag != '' AND substr(tag, 1, length(CAST(?1 AS TEXT))) = CAST(?1 AS TEXT)ORDER BY tag LIMIT ?2`
type TagsParams struct { Prefix string MaxRows int64}
func (q *Queries) Tags(ctx context.Context, arg TagsParams) ([]string, error) { rows, err := q.query(ctx, q.tagsStmt, tags, arg.Prefix, arg.MaxRows) if err != nil { return nil, err } defer rows.Close() items := []string{} for rows.Next() { var tag string if err := rows.Scan(&tag); err != nil { return nil, err } items = append(items, tag) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const trustCachePath = `-- name: TrustCachePath :manySELECT did FROM trust_cache_paths WHERE cache_key = ? ORDER BY position`
func (q *Queries) TrustCachePath(ctx context.Context, cacheKey string) ([]string, error) { rows, err := q.query(ctx, q.trustCachePathStmt, trustCachePath, cacheKey) if err != nil { return nil, err } defer rows.Close() items := []string{} for rows.Next() { var did string if err := rows.Scan(&did); err != nil { return nil, err } items = append(items, did) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const trustCacheScores = `-- name: TrustCacheScores :manySELECT did, assertion, source, list_uri, score, comment FROM trust_cache_scores WHERE cache_key = ? ORDER BY position`
type TrustCacheScoresRow struct { Did string Assertion sql.NullFloat64 Source string ListUri string Score float64 Comment string}
func (q *Queries) TrustCacheScores(ctx context.Context, cacheKey string) ([]TrustCacheScoresRow, error) { rows, err := q.query(ctx, q.trustCacheScoresStmt, trustCacheScores, cacheKey) if err != nil { return nil, err } defer rows.Close() items := []TrustCacheScoresRow{} for rows.Next() { var i TrustCacheScoresRow if err := rows.Scan( &i.Did, &i.Assertion, &i.Source, &i.ListUri, &i.Score, &i.Comment, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil}
const wantsListOwner = `-- name: WantsListOwner :oneSELECT EXISTS(SELECT 1 FROM list_snapshots WHERE owner = (SELECT id FROM identities WHERE did = CAST(?1 AS TEXT))) AS wanted`
func (q *Queries) WantsListOwner(ctx context.Context, owner string) (bool, error) { row := q.queryRow(ctx, q.wantsListOwnerStmt, wantsListOwner, owner) var wanted bool err := row.Scan(&wanted) return wanted, err}
const wantsListURI = `-- name: WantsListURI :oneSELECT EXISTS(SELECT 1 FROM list_snapshots WHERE list_uri = ?) AS wanted`
func (q *Queries) WantsListURI(ctx context.Context, listUri string) (bool, error) { row := q.queryRow(ctx, q.wantsListURIStmt, wantsListURI, listUri) var wanted bool err := row.Scan(&wanted) return wanted, err}