Skip to content

Commit 767006b

Browse files
fix(mothership): lint (#3517)
* fix(mothership): lint * fix typing
1 parent 69820a4 commit 767006b

File tree

29 files changed

+165
-83
lines changed

29 files changed

+165
-83
lines changed

apps/sim/app/api/schedules/[id]/route.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ async function fetchAndAuthorize(
7575
return { schedule, workspaceId: schedule.sourceWorkspaceId }
7676
}
7777

78+
if (!schedule.workflowId) {
79+
logger.warn(`[${requestId}] Schedule has no workflow: ${scheduleId}`)
80+
return NextResponse.json({ error: 'Schedule has no associated workflow' }, { status: 400 })
81+
}
82+
7883
const authorization = await authorizeWorkflowByWorkspacePermission({
7984
workflowId: schedule.workflowId,
8085
userId,

apps/sim/app/api/schedules/execute/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function GET(request: NextRequest) {
9393

9494
try {
9595
const jobId = await jobQueue.enqueue('schedule-execution', payload, {
96-
metadata: { workflowId: schedule.workflowId },
96+
metadata: { workflowId: schedule.workflowId ?? undefined },
9797
})
9898
logger.info(
9999
`[${requestId}] Queued schedule execution task ${jobId} for workflow ${schedule.workflowId}`

apps/sim/app/api/table/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ export function serverErrorResponse(message = 'Internal server error') {
155155
return errorResponse(message, 500)
156156
}
157157

158-
const columnTypeEnum = z.enum(COLUMN_TYPES as unknown as [string, ...string[]])
158+
const columnTypeEnum = z.enum(
159+
COLUMN_TYPES as unknown as [(typeof COLUMN_TYPES)[number], ...(typeof COLUMN_TYPES)[number][]]
160+
)
159161

160162
export const CreateColumnSchema = z.object({
161163
workspaceId: z.string().min(1, 'Workspace ID is required'),

apps/sim/app/api/v1/knowledge/[id]/documents/[documentId]/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { db } from '@sim/db'
2-
import { document } from '@sim/db/schema'
2+
import { document, knowledgeConnector } from '@sim/db/schema'
33
import { and, eq, isNull } from 'drizzle-orm'
44
import { type NextRequest, NextResponse } from 'next/server'
55
import { z } from 'zod'
@@ -64,10 +64,11 @@ export async function GET(request: NextRequest, { params }: DocumentDetailRouteP
6464
enabled: document.enabled,
6565
uploadedAt: document.uploadedAt,
6666
connectorId: document.connectorId,
67-
connectorType: document.connectorType,
67+
connectorType: knowledgeConnector.connectorType,
6868
sourceUrl: document.sourceUrl,
6969
})
7070
.from(document)
71+
.leftJoin(knowledgeConnector, eq(document.connectorId, knowledgeConnector.id))
7172
.where(
7273
and(
7374
eq(document.id, documentId),

apps/sim/app/api/v1/knowledge/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function POST(request: NextRequest) {
9393
userId,
9494
embeddingModel: 'text-embedding-3-small',
9595
embeddingDimension: 1536,
96-
chunkingConfig,
96+
chunkingConfig: chunkingConfig ?? { maxSize: 1024, minSize: 100, overlap: 200 },
9797
},
9898
requestId
9999
)

apps/sim/app/api/v1/knowledge/search/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export async function POST(request: NextRequest) {
240240
const tags: Record<string, string | number | boolean | Date | null> = {}
241241

242242
ALL_TAG_SLOTS.forEach((slot) => {
243-
const tagValue = (result as Record<string, unknown>)[slot]
243+
const tagValue = result[slot as keyof SearchResult]
244244
if (tagValue !== null && tagValue !== undefined) {
245245
const displayName = kbTagMap[slot] || slot
246246
tags[displayName] = tagValue as string | number | boolean | Date | null

apps/sim/app/api/v1/knowledge/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ export async function resolveKnowledgeBase(
9191
/**
9292
* Validates data against a Zod schema with consistent error response.
9393
*/
94-
export function validateSchema<T>(
95-
schema: z.ZodSchema<T>,
94+
export function validateSchema<S extends z.ZodType>(
95+
schema: S,
9696
data: unknown
97-
): { success: true; data: T } | { success: false; response: NextResponse } {
97+
): { success: true; data: z.output<S> } | { success: false; response: NextResponse } {
9898
const result = schema.safeParse(data)
9999
if (!result.success) {
100100
return {

apps/sim/app/chat/components/input/input.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ export const ChatInput: React.FC<{
4444
const isDragOver = dragCounter > 0
4545

4646
// Check if speech-to-text is available in the browser
47-
const isSttAvailable =
48-
typeof window !== 'undefined' && !!(window.SpeechRecognition || window.webkitSpeechRecognition)
47+
const isSttAvailable = (() => {
48+
if (typeof window === 'undefined') return false
49+
const w = window as Window & { SpeechRecognition?: unknown; webkitSpeechRecognition?: unknown }
50+
return !!(w.SpeechRecognition || w.webkitSpeechRecognition)
51+
})()
4952

5053
// Function to adjust textarea height
5154
const adjustTextareaHeight = () => {

apps/sim/app/chat/components/input/voice-input.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ interface SpeechRecognitionStatic {
3131
new (): SpeechRecognition
3232
}
3333

34-
declare global {
35-
interface Window {
36-
SpeechRecognition?: SpeechRecognitionStatic
37-
webkitSpeechRecognition?: SpeechRecognitionStatic
38-
}
34+
type WindowWithSpeech = Window & {
35+
SpeechRecognition?: SpeechRecognitionStatic
36+
webkitSpeechRecognition?: SpeechRecognitionStatic
3937
}
4038

4139
interface VoiceInputProps {
@@ -57,8 +55,9 @@ export function VoiceInput({
5755

5856
// Check if speech recognition is supported
5957
useEffect(() => {
60-
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition
61-
setIsSupported(!!SpeechRecognition)
58+
const w = window as WindowWithSpeech
59+
const SpeechRecognitionCtor = w.SpeechRecognition || w.webkitSpeechRecognition
60+
setIsSupported(!!SpeechRecognitionCtor)
6261
}, [])
6362

6463
const handleVoiceClick = useCallback(() => {

apps/sim/app/chat/components/voice-interface/voice-interface.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ interface SpeechRecognitionStatic {
3636
new (): SpeechRecognition
3737
}
3838

39-
declare global {
40-
interface Window {
41-
SpeechRecognition?: SpeechRecognitionStatic
42-
webkitSpeechRecognition?: SpeechRecognitionStatic
43-
}
39+
type WindowWithSpeech = Window & {
40+
SpeechRecognition?: SpeechRecognitionStatic
41+
webkitSpeechRecognition?: SpeechRecognitionStatic
4442
}
4543

4644
interface VoiceInterfaceProps {
@@ -93,7 +91,11 @@ export function VoiceInterface({
9391
const responseTimeoutRef = useRef<NodeJS.Timeout | null>(null)
9492

9593
const isSupported =
96-
typeof window !== 'undefined' && !!(window.SpeechRecognition || window.webkitSpeechRecognition)
94+
typeof window !== 'undefined' &&
95+
!!(
96+
(window as WindowWithSpeech).SpeechRecognition ||
97+
(window as WindowWithSpeech).webkitSpeechRecognition
98+
)
9799

98100
useEffect(() => {
99101
isMutedRef.current = isMuted
@@ -214,7 +216,8 @@ export function VoiceInterface({
214216
const setupSpeechRecognition = useCallback(() => {
215217
if (!isSupported) return
216218

217-
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition
219+
const w = window as WindowWithSpeech
220+
const SpeechRecognition = w.SpeechRecognition || w.webkitSpeechRecognition
218221
if (!SpeechRecognition) return
219222

220223
const recognition = new SpeechRecognition()

0 commit comments

Comments
 (0)