Merge branch 'main' into chore/Upgrade-LC-version

# Conflicts:
#	packages/components/package.json
This commit is contained in:
Henry
2024-02-07 02:01:32 +08:00
54 changed files with 5331 additions and 139 deletions
+22
View File
@@ -662,6 +662,28 @@ export const convertSchemaToZod = (schema: string | object): ICommonObject => {
}
}
/**
* Flatten nested object
* @param {ICommonObject} obj
* @param {string} parentKey
* @returns {ICommonObject}
*/
export const flattenObject = (obj: ICommonObject, parentKey?: string) => {
let result: any = {}
Object.keys(obj).forEach((key) => {
const value = obj[key]
const _key = parentKey ? parentKey + '.' + key : key
if (typeof value === 'object') {
result = { ...result, ...flattenObject(value, _key) }
} else {
result[_key] = value
}
})
return result
}
/**
* Convert BaseMessage to IMessage
* @param {BaseMessage[]} messages