mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-21 04:48:00 -05:00
fix types
This commit is contained in:
@@ -372,7 +372,6 @@ async function handleExternalUrl(
|
||||
|
||||
logger.info(`Downloaded file from URL: ${url}, size: ${buffer.length} bytes`)
|
||||
|
||||
// Store file in execution storage if execution context is provided
|
||||
let userFile: UserFile | undefined
|
||||
const mimeType = response.headers.get('content-type') || getMimeTypeFromExtension(extension)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useRef, useState } from 'react'
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { isUserFile } from '@/lib/core/utils/user-file'
|
||||
import { isUserFileWithMetadata } from '@/lib/core/utils/user-file'
|
||||
import type { ChatFile, ChatMessage } from '@/app/chat/components/message/message'
|
||||
import { CHAT_ERROR_MESSAGES } from '@/app/chat/constants'
|
||||
|
||||
@@ -17,7 +17,7 @@ function extractFilesFromData(
|
||||
return files
|
||||
}
|
||||
|
||||
if (isUserFile(data)) {
|
||||
if (isUserFileWithMetadata(data)) {
|
||||
if (!seenIds.has(data.id)) {
|
||||
seenIds.add(data.id)
|
||||
files.push({
|
||||
@@ -232,7 +232,7 @@ export function useChatStreaming() {
|
||||
return null
|
||||
}
|
||||
|
||||
if (isUserFile(value)) {
|
||||
if (isUserFileWithMetadata(value)) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ export function useChatStreaming() {
|
||||
|
||||
const value = getOutputValue(blockOutputs, config.path)
|
||||
|
||||
if (isUserFile(value)) {
|
||||
if (isUserFileWithMetadata(value)) {
|
||||
extractedFiles.push({
|
||||
id: value.id,
|
||||
name: value.name,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isUserFile } from '@/lib/core/utils/user-file'
|
||||
import { isUserFileWithMetadata } from '@/lib/core/utils/user-file'
|
||||
import {
|
||||
classifyStartBlockType,
|
||||
getLegacyStarterMode,
|
||||
@@ -234,7 +234,7 @@ function getFilesFromWorkflowInput(workflowInput: unknown): UserFile[] | undefin
|
||||
return undefined
|
||||
}
|
||||
const files = workflowInput.files
|
||||
if (Array.isArray(files) && files.every(isUserFile)) {
|
||||
if (Array.isArray(files) && files.every(isUserFileWithMetadata)) {
|
||||
return files
|
||||
}
|
||||
return undefined
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createLogger } from '@sim/logger'
|
||||
import { isUserFile } from '@/lib/core/utils/user-file'
|
||||
import { isUserFileWithMetadata } from '@/lib/core/utils/user-file'
|
||||
import type { ExecutionContext } from '@/lib/uploads/contexts/execution/utils'
|
||||
import { generateExecutionFileKey, generateFileId } from '@/lib/uploads/contexts/execution/utils'
|
||||
import type { UserFile } from '@/executor/types'
|
||||
@@ -169,7 +169,7 @@ export async function uploadFileFromRawData(
|
||||
context: ExecutionContext,
|
||||
userId?: string
|
||||
): Promise<UserFile> {
|
||||
if (isUserFile(rawData)) {
|
||||
if (isUserFileWithMetadata(rawData)) {
|
||||
return rawData
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ interface HydrationState {
|
||||
}
|
||||
|
||||
export interface Base64HydrationOptions {
|
||||
requestId: string
|
||||
requestId?: string
|
||||
executionId?: string
|
||||
logger?: Logger
|
||||
maxBytes?: number
|
||||
@@ -148,13 +148,14 @@ async function resolveBase64(
|
||||
}
|
||||
|
||||
let buffer: Buffer | null = null
|
||||
const requestId = options.requestId ?? 'unknown'
|
||||
|
||||
if (file.key) {
|
||||
try {
|
||||
buffer = await downloadFileFromStorage(file, options.requestId, logger)
|
||||
buffer = await downloadFileFromStorage(file, requestId, logger)
|
||||
} catch (error) {
|
||||
logger.warn(
|
||||
`[${options.requestId}] Failed to download ${file.name} from storage, trying URL fallback`,
|
||||
`[${requestId}] Failed to download ${file.name} from storage, trying URL fallback`,
|
||||
error
|
||||
)
|
||||
}
|
||||
@@ -164,7 +165,7 @@ async function resolveBase64(
|
||||
try {
|
||||
buffer = await downloadFileFromUrl(file.url, timeoutMs)
|
||||
} catch (error) {
|
||||
logger.warn(`[${options.requestId}] Failed to download ${file.name} from URL`, error)
|
||||
logger.warn(`[${requestId}] Failed to download ${file.name} from URL`, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user