Skip to content

Commit f4692ec

Browse files
committed
refactor(orchestration): remove seven unreferenced perform* entry points
Each had exactly one declaration, a barrel re-export, and no caller anywhere in the repo — no route, no application use case, no tool handler, no test. Their Params/Result interfaces went with them where nothing else consumed them; PerformCredentialResult, PerformUpdateWorkflowParams and PerformUpdateWorkflowResult stay, since live functions still use them. Removed: performDeleteCredential, performGetWorkspaceFileShare, performUpsertWorkspaceFileShare, performMoveRenameWorkspaceFile, performUpdateTableDescription, performUpdateWorkflow, performUpdateWorkspaceFileContent.
1 parent ef42424 commit f4692ec

10 files changed

Lines changed: 3 additions & 555 deletions

File tree

‎apps/sim/lib/copilot/tools/handlers/vfs-mutate.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const mocks = vi.hoisted(() => ({
2020
updateWorkspaceFileFolder: vi.fn(),
2121
deleteWorkspaceFile: vi.fn(),
2222
renameWorkspaceFile: vi.fn(),
23-
performMoveRenameWorkspaceFile: vi.fn(),
2423
performUpdateWorkspaceFileFolder: vi.fn(),
2524
performCreateFolder: vi.fn(),
2625
performUpdateFolder: vi.fn(),

‎apps/sim/lib/credentials/orchestration/index.ts‎

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createLogger } from '@sim/logger'
1111
import { generateId } from '@sim/utils/id'
1212
import { and, eq, sql } from 'drizzle-orm'
1313
import type { NextRequest } from 'next/server'
14-
import { asOrchestrationError, OrchestrationError } from '@/lib/core/orchestration/types'
14+
import { OrchestrationError } from '@/lib/core/orchestration/types'
1515
import { decryptSecret } from '@/lib/core/security/encryption'
1616
import { listSlackCredentialGroupConfigurationsForBot } from '@/lib/credential-groups/provider-configuration'
1717
import {
@@ -45,7 +45,6 @@ import {
4545
SLACK_CUSTOM_BOT_PROVIDER_ID,
4646
SLACK_CUSTOM_BOT_SECRET_TYPE,
4747
} from '@/lib/oauth/types'
48-
import { captureServerEvent } from '@/lib/posthog/server'
4948

5049
const logger = createLogger('CredentialOrchestration')
5150
type CredentialRow = typeof credential.$inferSelect
@@ -618,89 +617,3 @@ export async function deleteCredentialRecord(
618617
reason: params.reason,
619618
})
620619
}
621-
622-
/** Preserves the legacy callers while application adapters migrate to the manager above. */
623-
export async function performDeleteCredential(
624-
params: CredentialActorParams
625-
): Promise<PerformCredentialResult> {
626-
try {
627-
const access = await getCredentialActorContext(params.credentialId, params.userId)
628-
if (!access.credential) {
629-
return { success: false, error: 'Credential not found', errorCode: 'not_found' }
630-
}
631-
if (access.credential.type === 'managed_oauth') {
632-
return { success: false, error: 'Credential not found', errorCode: 'not_found' }
633-
}
634-
if (!access.hasWorkspaceAccess || !access.isAdmin) {
635-
return {
636-
success: false,
637-
error: 'Credential admin permission required',
638-
errorCode: 'forbidden',
639-
}
640-
}
641-
if (params.allowedTypes && !params.allowedTypes.includes(access.credential.type)) {
642-
return {
643-
success: false,
644-
error: `Only ${params.allowedTypes.join(', ')} credentials can be managed with this tool.`,
645-
errorCode: 'validation',
646-
}
647-
}
648-
649-
const reason = params.reason ?? 'user_delete'
650-
await deleteCredentialRecord({ credential: access.credential, reason })
651-
652-
captureServerEvent(
653-
params.userId,
654-
'credential_deleted',
655-
{
656-
credential_type: access.credential.type,
657-
provider_id:
658-
access.credential.providerId ?? access.credential.envKey ?? params.credentialId,
659-
workspace_id: access.credential.workspaceId,
660-
},
661-
{ groups: { workspace: access.credential.workspaceId } }
662-
)
663-
664-
const envDescription =
665-
access.credential.type === 'env_personal'
666-
? `Deleted personal env credential "${access.credential.envKey}"`
667-
: access.credential.type === 'env_workspace'
668-
? `Deleted workspace env credential "${access.credential.envKey}"`
669-
: `Deleted ${access.credential.type} credential "${access.credential.displayName}" (${reason})`
670-
recordAudit({
671-
workspaceId: access.credential.workspaceId,
672-
actorId: params.userId,
673-
actorName: params.actorName ?? undefined,
674-
actorEmail: params.actorEmail ?? undefined,
675-
action: AuditAction.CREDENTIAL_DELETED,
676-
resourceType: AuditResourceType.CREDENTIAL,
677-
resourceId: params.credentialId,
678-
resourceName: access.credential.displayName,
679-
description: envDescription,
680-
metadata: {
681-
reason,
682-
credentialType: access.credential.type,
683-
providerId: access.credential.providerId,
684-
accountId: access.credential.accountId,
685-
envKey: access.credential.envKey,
686-
},
687-
request: params.request,
688-
})
689-
690-
return { success: true, workspaceId: access.credential.workspaceId }
691-
} catch (error) {
692-
const orchestrationError = asOrchestrationError(error)
693-
if (orchestrationError) {
694-
if (orchestrationError.code !== 'not_found' && orchestrationError.code !== 'conflict') {
695-
throw orchestrationError
696-
}
697-
return {
698-
success: false,
699-
error: orchestrationError.message,
700-
errorCode: orchestrationError.code,
701-
}
702-
}
703-
logger.error('Failed to delete credential', { error })
704-
return { success: false, error: 'Internal server error', errorCode: 'internal' }
705-
}
706-
}

‎apps/sim/lib/table/orchestration/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ export {
66
performDeleteTableRow,
77
performMoveTableToFolder,
88
performRenameTable,
9-
performUpdateTableDescription,
109
performUpdateTableLocks,
1110
} from './tables'

‎apps/sim/lib/table/orchestration/tables.ts‎

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ import { generateRequestId } from '@/lib/core/utils/request'
1010
import { captureServerEvent } from '@/lib/posthog/server'
1111
import { TableLockedError } from '@/lib/table/mutation-locks'
1212
import { deleteRow } from '@/lib/table/rows/service'
13-
import {
14-
deleteTable,
15-
moveTableToFolder,
16-
renameTable,
17-
updateTableDescription,
18-
updateTableLocks,
19-
} from '@/lib/table/service'
13+
import { deleteTable, moveTableToFolder, renameTable, updateTableLocks } from '@/lib/table/service'
2014
import {
2115
TABLE_LOCK_FLAGS,
2216
TABLE_LOCK_KINDS,
@@ -204,48 +198,6 @@ export async function performRenameTable(
204198
}
205199
}
206200

207-
export interface PerformUpdateTableDescriptionParams {
208-
table: TableDefinition
209-
description: string | null
210-
userId: string
211-
requestId?: string
212-
request?: OrchestrationRequestContext
213-
}
214-
215-
/** Updates a table description and records the metadata change. */
216-
export async function performUpdateTableDescription(
217-
params: PerformUpdateTableDescriptionParams
218-
): Promise<PerformTableMutationResult> {
219-
const { table, description, userId, request } = params
220-
const requestId = params.requestId ?? generateRequestId()
221-
if (!table.workspaceId) {
222-
return { success: false, error: 'Table is not in a workspace', errorCode: 'validation' }
223-
}
224-
225-
try {
226-
const updated = await updateTableDescription(
227-
table.id,
228-
table.workspaceId,
229-
description,
230-
requestId
231-
)
232-
recordAudit({
233-
workspaceId: table.workspaceId,
234-
actorId: userId,
235-
action: AuditAction.TABLE_UPDATED,
236-
resourceType: AuditResourceType.TABLE,
237-
resourceId: table.id,
238-
resourceName: updated.name,
239-
description: `Updated description for table "${updated.name}"`,
240-
metadata: { op: 'description' },
241-
...(request ? { request } : {}),
242-
})
243-
return { success: true }
244-
} catch (error) {
245-
return classifyTableMutation(error, requestId, table.id)
246-
}
247-
}
248-
249201
export interface PerformMoveTableParams {
250202
table: TableDefinition
251203
folderId: string | null

‎apps/sim/lib/workflows/orchestration/index.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ export {
1717
performCreateWorkflowTransition,
1818
performDeleteWorkflow,
1919
performRestoreWorkflow,
20-
performUpdateWorkflow,
2120
updateWorkflowRecord,
2221
} from './workflow-lifecycle'

‎apps/sim/lib/workflows/orchestration/workflow-lifecycle.ts‎

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { and, eq, isNull, min, ne } from 'drizzle-orm'
99
import type { OrchestrationErrorCode } from '@/lib/core/orchestration/types'
1010
import { generateRequestId } from '@/lib/core/utils/request'
1111
import type { DbOrTx } from '@/lib/db/types'
12-
import { captureServerEvent } from '@/lib/posthog/server'
1312
import { buildDefaultWorkflowArtifacts } from '@/lib/workflows/defaults'
1413
import { archiveWorkflow, restoreWorkflow } from '@/lib/workflows/lifecycle'
1514
import { saveWorkflowToNormalizedTables } from '@/lib/workflows/persistence/utils'
@@ -443,78 +442,6 @@ export async function updateWorkflowRecord(
443442
return { success: true, workflow: updatedWorkflow }
444443
}
445444

446-
export async function performUpdateWorkflow(
447-
params: PerformUpdateWorkflowParams
448-
): Promise<PerformUpdateWorkflowResult> {
449-
const requestId = params.requestId ?? generateRequestId()
450-
451-
try {
452-
const result = await updateWorkflowRecord({ ...params, requestId })
453-
const updatedWorkflow = result.workflow
454-
if (!result.success || !updatedWorkflow) return result
455-
456-
if (params.locked !== undefined && params.locked !== (params.currentLocked ?? false)) {
457-
const workspaceId = updatedWorkflow.workspaceId
458-
recordAudit({
459-
workspaceId: workspaceId ?? null,
460-
actorId: params.userId,
461-
action: params.locked ? AuditAction.WORKFLOW_LOCKED : AuditAction.WORKFLOW_UNLOCKED,
462-
resourceType: AuditResourceType.WORKFLOW,
463-
resourceId: params.workflowId,
464-
resourceName: updatedWorkflow.name,
465-
description: `${params.locked ? 'Locked' : 'Unlocked'} workflow "${updatedWorkflow.name}"`,
466-
metadata: { locked: params.locked },
467-
})
468-
469-
captureServerEvent(
470-
params.userId,
471-
'workflow_lock_toggled',
472-
{
473-
workflow_id: params.workflowId,
474-
...(workspaceId ? { workspace_id: workspaceId } : {}),
475-
locked: params.locked,
476-
},
477-
workspaceId ? { groups: { workspace: workspaceId } } : undefined
478-
)
479-
}
480-
481-
if (
482-
params.forkSyncExcluded !== undefined &&
483-
params.forkSyncExcluded !== (params.currentForkSyncExcluded ?? false)
484-
) {
485-
const workspaceId = updatedWorkflow.workspaceId
486-
recordAudit({
487-
workspaceId: workspaceId ?? null,
488-
actorId: params.userId,
489-
action: params.forkSyncExcluded
490-
? AuditAction.WORKFLOW_FORK_SYNC_EXCLUDED
491-
: AuditAction.WORKFLOW_FORK_SYNC_INCLUDED,
492-
resourceType: AuditResourceType.WORKFLOW,
493-
resourceId: params.workflowId,
494-
resourceName: updatedWorkflow.name,
495-
description: `${params.forkSyncExcluded ? 'Excluded' : 'Included'} workflow "${updatedWorkflow.name}" ${params.forkSyncExcluded ? 'from' : 'in'} fork sync`,
496-
metadata: { forkSyncExcluded: params.forkSyncExcluded },
497-
})
498-
499-
captureServerEvent(
500-
params.userId,
501-
'workflow_fork_sync_exclusion_toggled',
502-
{
503-
workflow_id: params.workflowId,
504-
...(workspaceId ? { workspace_id: workspaceId } : {}),
505-
fork_sync_excluded: params.forkSyncExcluded,
506-
},
507-
workspaceId ? { groups: { workspace: workspaceId } } : undefined
508-
)
509-
}
510-
511-
return result
512-
} catch (error) {
513-
logger.error(`[${requestId}] Failed to update workflow ${params.workflowId}`, { error })
514-
return { success: false, error: toError(error).message, errorCode: 'internal' }
515-
}
516-
}
517-
518445
export async function deleteWorkflowRecord(
519446
params: PerformDeleteWorkflowParams
520447
): Promise<PerformDeleteWorkflowResult> {
Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
import { AuditAction, AuditResourceType, recordAudit } from '@sim/audit'
21
import { createLogger } from '@sim/logger'
3-
import { toError } from '@sim/utils/errors'
4-
import {
5-
asOrchestrationError,
6-
type OrchestrationErrorCode,
7-
type OrchestrationRequestContext,
8-
} from '@/lib/core/orchestration/types'
9-
import {
10-
ContentVersionConflictError,
11-
updateWorkspaceFileContent,
12-
type WorkspaceFileRecord,
13-
} from '@/lib/uploads/contexts/workspace'
14-
import { EXACT_EMPTY_WORKSPACE_FILE_SECRET_PROVENANCE } from '@/lib/uploads/contexts/workspace/workspace-file-secret-provenance'
152

163
const logger = createLogger('WorkspaceFileContentOrchestration')
174

@@ -20,88 +7,3 @@ export const MAX_WORKSPACE_FILE_CONTENT_BYTES = 50 * 1024 * 1024
207

218
/** JSON-body ceiling with room for a 50 MiB file's base64 expansion and envelope. */
229
export const MAX_WORKSPACE_FILE_INLINE_BODY_BYTES = 70 * 1024 * 1024
23-
24-
export interface PerformUpdateWorkspaceFileContentParams {
25-
workspaceId: string
26-
fileId: string
27-
userId: string
28-
content: string
29-
encoding: 'utf-8' | 'base64'
30-
actorName?: string
31-
actorEmail?: string
32-
request?: OrchestrationRequestContext
33-
}
34-
35-
export interface PerformUpdateWorkspaceFileContentResult {
36-
success: boolean
37-
error?: string
38-
errorCode?: OrchestrationErrorCode
39-
file?: WorkspaceFileRecord
40-
}
41-
42-
/**
43-
* Replaces a workspace file's bytes.
44-
*
45-
* Failures are classified rather than message-matched: the manager throws a
46-
* classified `not_found`, the storage ledger throws `StorageLimitExceededError`
47-
* (a `payload_too_large` {@link OrchestrationError}), and both reach here through
48-
* `asOrchestrationError`, which walks the `cause` chain past drizzle's
49-
* transaction wrapper.
50-
*/
51-
export async function performUpdateWorkspaceFileContent(
52-
params: PerformUpdateWorkspaceFileContentParams
53-
): Promise<PerformUpdateWorkspaceFileContentResult> {
54-
const { workspaceId, fileId, userId, content, encoding, actorName, actorEmail, request } = params
55-
56-
const buffer = Buffer.from(content, encoding === 'base64' ? 'base64' : 'utf-8')
57-
58-
if (buffer.length > MAX_WORKSPACE_FILE_CONTENT_BYTES) {
59-
return {
60-
success: false,
61-
error: `File size exceeds ${MAX_WORKSPACE_FILE_CONTENT_BYTES / 1024 / 1024}MB limit`,
62-
errorCode: 'payload_too_large',
63-
}
64-
}
65-
66-
try {
67-
const file = await updateWorkspaceFileContent(workspaceId, fileId, userId, buffer, undefined, {
68-
secretProvenancePolicy: {
69-
mode: 'replace',
70-
provenance: EXACT_EMPTY_WORKSPACE_FILE_SECRET_PROVENANCE,
71-
},
72-
})
73-
74-
logger.info('Updated workspace file content', { workspaceId, fileId, size: buffer.length })
75-
76-
recordAudit({
77-
workspaceId,
78-
actorId: userId,
79-
actorName,
80-
actorEmail,
81-
action: AuditAction.FILE_UPDATED,
82-
resourceType: AuditResourceType.FILE,
83-
resourceId: fileId,
84-
resourceName: file.name,
85-
description: `Updated content of file "${file.name}"`,
86-
metadata: { contentSize: buffer.length },
87-
request,
88-
})
89-
90-
return { success: true, file }
91-
} catch (error) {
92-
const classified = asOrchestrationError(error)
93-
if (classified) {
94-
logger.warn('Workspace file content update rejected', {
95-
workspaceId,
96-
fileId,
97-
errorCode: classified.code,
98-
})
99-
return { success: false, error: classified.message, errorCode: classified.code }
100-
}
101-
if (error instanceof ContentVersionConflictError) {
102-
return { success: false, error: error.message, errorCode: 'conflict' }
103-
}
104-
logger.error('Failed to update workspace file content', { error })
105-
return { success: false, error: toError(error).message, errorCode: 'internal' }
106-
}
107-
}

0 commit comments

Comments
 (0)