MCPcopy
hub / github.com/anomalyco/opencode / synced

Function synced

packages/opencode/src/control-plane/workspace.ts:919–938  ·  view source on GitHub ↗
(db: Database.Interface["db"], state: Record<string, number>)

Source from the content-addressed store, hash-verified

917}
918
919function synced(db: Database.Interface["db"], state: Record<string, number>): Effect.Effect<boolean> {
920 const ids = Object.keys(state)
921 if (ids.length === 0) return Effect.succeed(true)
922
923 return db
924 .select({
925 id: EventSequenceTable.aggregate_id,
926 seq: EventSequenceTable.seq,
927 })
928 .from(EventSequenceTable)
929 .where(inArray(EventSequenceTable.aggregate_id, ids))
930 .all()
931 .pipe(
932 Effect.orDie,
933 Effect.map((rows) => {
934 const done = Object.fromEntries(rows.map((row) => [row.id, row.seq])) as Record<string, number>
935 return ids.every((id) => (done[id] ?? -1) >= state[id])
936 }),
937 )
938}
939
940function route(url: string | URL, path: string) {
941 const next = new URL(url)

Callers 2

workspace.tsFile · 0.85
waitUntilSyncedFunction · 0.85

Calls 4

allMethod · 0.45
whereMethod · 0.45
fromMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected