MCPcopy Index your code
hub / github.com/anomalyco/opencode / hydrate

Function hydrate

packages/opencode/src/session/message-v2.ts:98–123  ·  view source on GitHub ↗
(db: Database.Interface["db"], rows: (typeof MessageTable.$inferSelect)[])

Source from the content-addressed store, hash-verified

96 or(lt(MessageTable.time_created, row.time), and(eq(MessageTable.time_created, row.time), lt(MessageTable.id, row.id)))
97
98function hydrate(db: Database.Interface["db"], rows: (typeof MessageTable.$inferSelect)[]) {
99 const ids = rows.map((row) => row.id)
100 const partByMessage = new Map<string, Part[]>()
101 return Effect.gen(function* () {
102 if (ids.length > 0) {
103 const partRows = yield* db
104 .select()
105 .from(PartTable)
106 .where(inArray(PartTable.message_id, ids))
107 .orderBy(PartTable.message_id, PartTable.id)
108 .all()
109 .pipe(Effect.orDie)
110 for (const row of partRows) {
111 const next = part(row)
112 const list = partByMessage.get(row.message_id)
113 if (list) list.push(next)
114 else partByMessage.set(row.message_id, [next])
115 }
116 }
117
118 return rows.map((row) => ({
119 info: info(row),
120 parts: partByMessage.get(row.id) ?? [],
121 }))
122 })
123}
124
125function providerMeta(metadata: Record<string, any> | undefined) {
126 if (!metadata) return undefined

Callers 1

message-v2.tsFile · 0.85

Calls 10

pushMethod · 0.80
partFunction · 0.70
infoFunction · 0.70
getMethod · 0.65
allMethod · 0.45
orderByMethod · 0.45
whereMethod · 0.45
fromMethod · 0.45
selectMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected