Skip to content

Commit 6540453

Browse files
waleedlatif1claude
andcommitted
improvement(processing): replace remaining as any casts with proper types
- preprocessing.ts: use exported `HighestPrioritySubscription` type instead of redeclaring via `Awaited<ReturnType<...>>` - deploy/route.ts, status/route.ts: cast `hasWorkflowChanged` args to `WorkflowState` instead of `any` (JSONB + object literal narrowing) - state/route.ts: type block sanitization and save with `BlockState` and `WorkflowState` instead of `any` - search-suggestions.ts: remove 8 unnecessary `as any` casts on `'date'` literal that already satisfies the `Suggestion['category']` union Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 007d137 commit 6540453

File tree

5 files changed

+28
-14
lines changed

5 files changed

+28
-14
lines changed

apps/sim/app/api/workflows/[id]/deploy/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
} from '@/lib/workflows/schedules'
2323
import { validateWorkflowPermissions } from '@/lib/workflows/utils'
2424
import { createErrorResponse, createSuccessResponse } from '@/app/api/workflows/utils'
25+
import type { WorkflowState } from '@/stores/workflows/workflow/types'
2526

2627
const logger = createLogger('WorkflowDeployAPI')
2728

@@ -86,7 +87,10 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
8687
variables: workflowRecord?.variables || {},
8788
}
8889
const { hasWorkflowChanged } = await import('@/lib/workflows/comparison')
89-
needsRedeployment = hasWorkflowChanged(currentState as any, active.state as any)
90+
needsRedeployment = hasWorkflowChanged(
91+
currentState as WorkflowState,
92+
active.state as WorkflowState
93+
)
9094
}
9195
}
9296

apps/sim/app/api/workflows/[id]/state/route.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { extractAndPersistCustomTools } from '@/lib/workflows/persistence/custom
1111
import { saveWorkflowToNormalizedTables } from '@/lib/workflows/persistence/utils'
1212
import { sanitizeAgentToolsInBlocks } from '@/lib/workflows/sanitization/validation'
1313
import { authorizeWorkflowByWorkspacePermission } from '@/lib/workflows/utils'
14-
import type { BlockState } from '@/stores/workflows/workflow/types'
14+
import type { BlockState, WorkflowState } from '@/stores/workflows/workflow/types'
1515
import { generateLoopBlocks, generateParallelBlocks } from '@/stores/workflows/workflow/utils'
1616

1717
const logger = createLogger('WorkflowStateAPI')
@@ -153,13 +153,15 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
153153
}
154154

155155
// Sanitize custom tools in agent blocks before saving
156-
const { blocks: sanitizedBlocks, warnings } = sanitizeAgentToolsInBlocks(state.blocks as any)
156+
const { blocks: sanitizedBlocks, warnings } = sanitizeAgentToolsInBlocks(
157+
state.blocks as Record<string, BlockState>
158+
)
157159

158160
// Save to normalized tables
159161
// Ensure all required fields are present for WorkflowState type
160162
// Filter out blocks without type or name before saving
161163
const filteredBlocks = Object.entries(sanitizedBlocks).reduce(
162-
(acc, [blockId, block]: [string, any]) => {
164+
(acc, [blockId, block]: [string, BlockState]) => {
163165
if (block.type && block.name) {
164166
// Ensure all required fields are present
165167
acc[blockId] = {
@@ -191,7 +193,10 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
191193
deployedAt: state.deployedAt,
192194
}
193195

194-
const saveResult = await saveWorkflowToNormalizedTables(workflowId, workflowState as any)
196+
const saveResult = await saveWorkflowToNormalizedTables(
197+
workflowId,
198+
workflowState as WorkflowState
199+
)
195200

196201
if (!saveResult.success) {
197202
logger.error(`[${requestId}] Failed to save workflow ${workflowId} state:`, saveResult.error)

apps/sim/app/api/workflows/[id]/status/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { hasWorkflowChanged } from '@/lib/workflows/comparison'
77
import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/persistence/utils'
88
import { validateWorkflowAccess } from '@/app/api/workflows/middleware'
99
import { createErrorResponse, createSuccessResponse } from '@/app/api/workflows/utils'
10+
import type { WorkflowState } from '@/stores/workflows/workflow/types'
1011

1112
const logger = createLogger('WorkflowStatusAPI')
1213

@@ -64,7 +65,10 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
6465
.limit(1)
6566

6667
if (active?.state) {
67-
needsRedeployment = hasWorkflowChanged(currentState as any, active.state as any)
68+
needsRedeployment = hasWorkflowChanged(
69+
currentState as WorkflowState,
70+
active.state as WorkflowState
71+
)
6872
}
6973
}
7074

apps/sim/lib/execution/preprocessing.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { workflow } from '@sim/db/schema'
33
import { createLogger } from '@sim/logger'
44
import { eq } from 'drizzle-orm'
55
import { checkServerSideUsageLimits } from '@/lib/billing/calculations/usage-monitor'
6+
import type { HighestPrioritySubscription } from '@/lib/billing/core/plan'
67
import { getHighestPrioritySubscription } from '@/lib/billing/core/subscription'
78
import { getExecutionTimeout } from '@/lib/core/execution-limits'
89
import { RateLimiter } from '@/lib/core/rate-limiter/rate-limiter'
@@ -68,7 +69,7 @@ export interface PreprocessExecutionResult {
6869
}
6970

7071
type WorkflowRecord = typeof workflow.$inferSelect
71-
type SubscriptionInfo = Awaited<ReturnType<typeof getHighestPrioritySubscription>>
72+
type SubscriptionInfo = HighestPrioritySubscription
7273

7374
export async function preprocessExecution(
7475
options: PreprocessExecutionOptions

apps/sim/lib/logs/search-suggestions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ export class SearchSuggestions {
433433
value: `date:${partial}`,
434434
label: `${this.formatDateLabel(startDate)} to ${this.formatDateLabel(endDate)}`,
435435
description: 'Custom date range',
436-
category: 'date' as any,
436+
category: 'date',
437437
})
438438
return suggestions
439439
}
@@ -446,7 +446,7 @@ export class SearchSuggestions {
446446
value: `date:${startDate}..`,
447447
label: `${this.formatDateLabel(startDate)} to ...`,
448448
description: 'Type end date (YYYY-MM-DD)',
449-
category: 'date' as any,
449+
category: 'date',
450450
})
451451
return suggestions
452452
}
@@ -458,7 +458,7 @@ export class SearchSuggestions {
458458
value: `date:${partial}`,
459459
label: `Year ${partial}`,
460460
description: 'All logs from this year',
461-
category: 'date' as any,
461+
category: 'date',
462462
})
463463
return suggestions
464464
}
@@ -486,7 +486,7 @@ export class SearchSuggestions {
486486
value: `date:${partial}`,
487487
label: `${monthName} ${year}`,
488488
description: 'All logs from this month',
489-
category: 'date' as any,
489+
category: 'date',
490490
})
491491
return suggestions
492492
}
@@ -500,15 +500,15 @@ export class SearchSuggestions {
500500
value: `date:${partial}`,
501501
label: this.formatDateLabel(partial),
502502
description: 'Single date',
503-
category: 'date' as any,
503+
category: 'date',
504504
})
505505
// Also suggest starting a range
506506
suggestions.push({
507507
id: `date-range-start-${partial}`,
508508
value: `date:${partial}..`,
509509
label: `${this.formatDateLabel(partial)} to ...`,
510510
description: 'Start a date range',
511-
category: 'date' as any,
511+
category: 'date',
512512
})
513513
}
514514
return suggestions
@@ -521,7 +521,7 @@ export class SearchSuggestions {
521521
value: `date:${partial}`,
522522
label: partial,
523523
description: 'Continue typing: YYYY, YYYY-MM, or YYYY-MM-DD',
524-
category: 'date' as any,
524+
category: 'date',
525525
})
526526
}
527527

0 commit comments

Comments
 (0)