MCPcopy Index your code
hub / github.com/simstudioai/sim / queryAuditLogs

Function queryAuditLogs

apps/sim/app/api/v1/audit-logs/query.ts:147–179  ·  view source on GitHub ↗
(
  conditions: SQL<unknown>[],
  limit: number,
  cursor?: string
)

Source from the content-addressed store, hash-verified

145}
146
147export async function queryAuditLogs(
148 conditions: SQL<unknown>[],
149 limit: number,
150 cursor?: string
151): Promise<CursorPaginatedResult> {
152 const allConditions = [...conditions]
153
154 if (cursor) {
155 const cursorCondition = buildCursorCondition(cursor)
156 if (cursorCondition) allConditions.push(cursorCondition)
157 }
158
159 const rows = await dbReplica
160 .select()
161 .from(auditLog)
162 .where(allConditions.length > 0 ? and(...allConditions) : undefined)
163 .orderBy(desc(auditLog.createdAt), desc(auditLog.id))
164 .limit(limit + 1)
165
166 const hasMore = rows.length > limit
167 const data = rows.slice(0, limit)
168
169 let nextCursor: string | undefined
170 if (hasMore && data.length > 0) {
171 const last = data[data.length - 1]
172 nextCursor = encodeCursor({
173 createdAt: last.createdAt.toISOString(),
174 id: last.id,
175 })
176 }
177
178 return { data, nextCursor }
179}

Callers 2

route.tsFile · 0.90
route.tsFile · 0.90

Calls 3

buildCursorConditionFunction · 0.70
encodeCursorFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected