mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-22 08:40:08 +08:00
fix(agents): convert null values to undefined in database responses
Ensure type consistency by converting null values from database to undefined as specified in type definitions
This commit is contained in:
parent
ae9c78e643
commit
eb3ff6f570
@ -1,5 +1,6 @@
|
|||||||
import { type Client, createClient } from '@libsql/client'
|
import { type Client, createClient } from '@libsql/client'
|
||||||
import { loggerService } from '@logger'
|
import { loggerService } from '@logger'
|
||||||
|
import { objectKeys } from '@types'
|
||||||
import { drizzle, type LibSQLDatabase } from 'drizzle-orm/libsql'
|
import { drizzle, type LibSQLDatabase } from 'drizzle-orm/libsql'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
@ -150,6 +151,13 @@ export abstract class BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert null from db to undefined to satisfy type definition
|
||||||
|
for (const key of objectKeys(data)) {
|
||||||
|
if (deserialized[key] === null) {
|
||||||
|
deserialized[key] = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return deserialized
|
return deserialized
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Database entity types for Agent, Session, and SessionMessage
|
* Database entity types for Agent, Session, and SessionMessage
|
||||||
* Shared between main and renderer processes
|
* Shared between main and renderer processes
|
||||||
|
*
|
||||||
|
* WARNING: Any null value will be converted to undefined from api.
|
||||||
*/
|
*/
|
||||||
import { ModelMessage, modelMessageSchema, TextStreamPart } from 'ai'
|
import { ModelMessage, modelMessageSchema, TextStreamPart } from 'ai'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user