2021-04-21 15:43:31 +08:00
|
|
|
import { ExtensionAttribute } from '../types'
|
2021-01-29 16:33:42 +08:00
|
|
|
|
|
|
|
export default function getSplittedAttributes(
|
|
|
|
extensionAttributes: ExtensionAttribute[],
|
|
|
|
typeName: string,
|
2021-04-21 15:43:31 +08:00
|
|
|
attributes: Record<string, any>,
|
|
|
|
): Record<string, any> {
|
2021-01-29 16:33:42 +08:00
|
|
|
return Object.fromEntries(Object
|
|
|
|
.entries(attributes)
|
|
|
|
.filter(([name]) => {
|
|
|
|
const extensionAttribute = extensionAttributes.find(item => {
|
|
|
|
return item.type === typeName && item.name === name
|
|
|
|
})
|
|
|
|
|
|
|
|
if (!extensionAttribute) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return extensionAttribute.attribute.keepOnSplit
|
|
|
|
}))
|
|
|
|
}
|