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

Function performRestoreTable

apps/sim/lib/table/orchestration/index.ts:25–64  ·  view source on GitHub ↗
(
  params: PerformRestoreTableParams
)

Source from the content-addressed store, hash-verified

23}
24
25export async function performRestoreTable(
26 params: PerformRestoreTableParams
27): Promise<PerformRestoreTableResult> {
28 const { tableId, userId } = params
29 const requestId = params.requestId ?? generateRequestId()
30
31 const archivedTable = await getTableById(tableId, { includeArchived: true })
32 if (!archivedTable) {
33 return { success: false, error: 'Table not found', errorCode: 'not_found' }
34 }
35
36 try {
37 await restoreTable(tableId, requestId)
38 const table = (await getTableById(tableId)) ?? archivedTable
39
40 logger.info(`[${requestId}] Restored table ${tableId}`)
41
42 recordAudit({
43 workspaceId: archivedTable.workspaceId,
44 actorId: userId,
45 action: AuditAction.TABLE_RESTORED,
46 resourceType: AuditResourceType.TABLE,
47 resourceId: tableId,
48 resourceName: table.name,
49 description: `Restored table "${table.name}"`,
50 metadata: {
51 tableName: table.name,
52 workspaceId: table.workspaceId,
53 },
54 })
55
56 return { success: true, table }
57 } catch (error) {
58 logger.error(`[${requestId}] Failed to restore table ${tableId}`, { error })
59 if (error instanceof TableConflictError) {
60 return { success: false, error: error.message, errorCode: 'conflict' }
61 }
62 return { success: false, error: toError(error).message, errorCode: 'internal' }
63 }
64}

Callers 2

performRestoreResourceFunction · 0.90
route.tsFile · 0.90

Calls 7

generateRequestIdFunction · 0.90
getTableByIdFunction · 0.90
restoreTableFunction · 0.90
recordAuditFunction · 0.90
toErrorFunction · 0.90
infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected