mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
46 lines
1002 B
TypeScript
46 lines
1002 B
TypeScript
import { MetadataMarket, MetadataPublishForm } from '../../../@types/MetaData'
|
|
import { toStringNoMS } from '../../../utils'
|
|
import AssetModel from '../../../models/Asset'
|
|
|
|
export function transformPublishFormToMetadata(
|
|
data: Partial<MetadataPublishForm>
|
|
): MetadataMarket {
|
|
const currentTime = toStringNoMS(new Date())
|
|
|
|
const {
|
|
name,
|
|
author,
|
|
license,
|
|
description,
|
|
copyrightHolder,
|
|
tags,
|
|
links,
|
|
termsAndConditions,
|
|
files,
|
|
price
|
|
} = data
|
|
|
|
const metadata: MetadataMarket = {
|
|
main: {
|
|
...AssetModel.main,
|
|
name,
|
|
author,
|
|
dateCreated: currentTime,
|
|
datePublished: currentTime,
|
|
files: typeof files !== 'string' && files,
|
|
license
|
|
},
|
|
additionalInformation: {
|
|
...AssetModel.additionalInformation,
|
|
description,
|
|
copyrightHolder,
|
|
tags: tags?.split(','),
|
|
links: typeof links !== 'string' && links,
|
|
termsAndConditions,
|
|
priceType: price.type
|
|
}
|
|
}
|
|
|
|
return metadata
|
|
}
|