mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
metadata validation updates
This commit is contained in:
parent
04e6bb0c72
commit
0c10eb5665
@ -6,7 +6,6 @@ const onChange = jest.fn()
|
|||||||
|
|
||||||
const files = [
|
const files = [
|
||||||
{
|
{
|
||||||
found: true,
|
|
||||||
url: 'https://hello.com',
|
url: 'https://hello.com',
|
||||||
checksum: 'cccccc',
|
checksum: 'cccccc',
|
||||||
checksumType: 'MD5',
|
checksumType: 'MD5',
|
||||||
@ -14,7 +13,8 @@ const files = [
|
|||||||
contentType: 'application/zip',
|
contentType: 'application/zip',
|
||||||
resourceId: 'xxx',
|
resourceId: 'xxx',
|
||||||
encoding: 'UTF-8',
|
encoding: 'UTF-8',
|
||||||
compression: 'zip'
|
compression: 'zip',
|
||||||
|
found: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -8,17 +8,18 @@ import styles from './index.module.scss'
|
|||||||
|
|
||||||
import { serviceUri } from '../../../config'
|
import { serviceUri } from '../../../config'
|
||||||
import cleanupContentType from '../../../utils/cleanupContentType'
|
import cleanupContentType from '../../../utils/cleanupContentType'
|
||||||
|
import { Logger } from '@oceanprotocol/squid'
|
||||||
|
|
||||||
interface File {
|
export interface File {
|
||||||
url: string
|
url: string
|
||||||
found: boolean
|
contentType: string
|
||||||
checksum?: string
|
checksum?: string
|
||||||
checksumType?: string
|
checksumType?: string
|
||||||
contentLength?: number
|
contentLength?: number
|
||||||
contentType?: string
|
|
||||||
resourceId?: string
|
resourceId?: string
|
||||||
encoding?: string
|
encoding?: string
|
||||||
compression?: string
|
compression?: string
|
||||||
|
found: boolean // non-standard
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FilesProps {
|
interface FilesProps {
|
||||||
@ -51,20 +52,10 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private addItem = async (value: string) => {
|
private addItem = async (value: string) => {
|
||||||
let res: {
|
|
||||||
result: {
|
|
||||||
contentLength: number
|
|
||||||
contentType: string
|
|
||||||
found: boolean
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let file: File = {
|
let file: File = {
|
||||||
url: value,
|
url: value,
|
||||||
found: false,
|
|
||||||
contentLength: 0,
|
|
||||||
contentType: '',
|
contentType: '',
|
||||||
compression: ''
|
found: false // non-standard
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -75,13 +66,16 @@ export default class Files extends PureComponent<FilesProps, FilesStates> {
|
|||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
res = await response.json()
|
|
||||||
file.contentLength = res.result.contentLength
|
const json = await response.json()
|
||||||
file.contentType = res.result.contentType
|
const { contentLength, contentType, found } = json.result
|
||||||
file.compression = await cleanupContentType(res.result.contentType)
|
|
||||||
file.found = res.result.found
|
file.contentLength = contentLength
|
||||||
|
file.contentType = contentType
|
||||||
|
file.compression = await cleanupContentType(contentType)
|
||||||
|
file.found = found
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// error
|
Logger.error(error.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.files.push(file)
|
this.props.files.push(file)
|
||||||
|
@ -11,27 +11,28 @@ import ReactGA from 'react-ga'
|
|||||||
|
|
||||||
import { steps } from '../../data/form-publish.json'
|
import { steps } from '../../data/form-publish.json'
|
||||||
import Content from '../../components/atoms/Content'
|
import Content from '../../components/atoms/Content'
|
||||||
|
import { File } from './Files'
|
||||||
|
|
||||||
type AssetType = 'dataset' | 'algorithm' | 'container' | 'workflow' | 'other'
|
type AssetType = 'dataset' | 'algorithm' | 'container' | 'workflow' | 'other'
|
||||||
|
|
||||||
interface PublishState {
|
interface PublishState {
|
||||||
name?: string
|
name?: string
|
||||||
dateCreated?: string
|
dateCreated?: string
|
||||||
description?: string
|
|
||||||
files?: string[]
|
|
||||||
price?: string
|
price?: string
|
||||||
author?: string
|
author?: string
|
||||||
type?: AssetType
|
|
||||||
license?: string
|
license?: string
|
||||||
|
description?: string
|
||||||
|
files?: File[]
|
||||||
|
type?: AssetType
|
||||||
copyrightHolder?: string
|
copyrightHolder?: string
|
||||||
categories?: string
|
categories?: string[]
|
||||||
tags?: string[]
|
|
||||||
|
currentStep?: number
|
||||||
|
publishingStep?: number
|
||||||
isPublishing?: boolean
|
isPublishing?: boolean
|
||||||
isPublished?: boolean
|
isPublished?: boolean
|
||||||
publishedDid?: string
|
publishedDid?: string
|
||||||
publishingError?: string
|
publishingError?: string
|
||||||
publishingStep?: number
|
|
||||||
currentStep?: number
|
|
||||||
validationStatus?: any
|
validationStatus?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +40,6 @@ export default class Publish extends Component<{}, PublishState> {
|
|||||||
public static contextType = User
|
public static contextType = User
|
||||||
|
|
||||||
public state = {
|
public state = {
|
||||||
currentStep: 1,
|
|
||||||
name: '',
|
name: '',
|
||||||
dateCreated: new Date().toISOString(),
|
dateCreated: new Date().toISOString(),
|
||||||
description: '',
|
description: '',
|
||||||
@ -49,7 +49,9 @@ export default class Publish extends Component<{}, PublishState> {
|
|||||||
type: 'dataset' as AssetType,
|
type: 'dataset' as AssetType,
|
||||||
license: '',
|
license: '',
|
||||||
copyrightHolder: '',
|
copyrightHolder: '',
|
||||||
categories: '',
|
categories: [],
|
||||||
|
|
||||||
|
currentStep: 1,
|
||||||
isPublishing: false,
|
isPublishing: false,
|
||||||
isPublished: false,
|
isPublished: false,
|
||||||
publishedDid: '',
|
publishedDid: '',
|
||||||
@ -127,7 +129,7 @@ export default class Publish extends Component<{}, PublishState> {
|
|||||||
type: 'dataset' as AssetType,
|
type: 'dataset' as AssetType,
|
||||||
license: '',
|
license: '',
|
||||||
copyrightHolder: '',
|
copyrightHolder: '',
|
||||||
categories: '',
|
categories: [],
|
||||||
isPublishing: false,
|
isPublishing: false,
|
||||||
isPublished: false,
|
isPublished: false,
|
||||||
publishingStep: 0,
|
publishingStep: 0,
|
||||||
@ -267,6 +269,14 @@ export default class Publish extends Component<{}, PublishState> {
|
|||||||
|
|
||||||
const { ocean } = this.context
|
const { ocean } = this.context
|
||||||
const account = await ocean.accounts.list()
|
const account = await ocean.accounts.list()
|
||||||
|
|
||||||
|
// remove `found` attribute from all objects
|
||||||
|
// and use new array for hidden input
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
// const filesStandard = this.state.files.map(
|
||||||
|
// ({ found, ...keepAttrs }) => keepAttrs // eslint-disable-line
|
||||||
|
// )
|
||||||
|
|
||||||
const newAsset = {
|
const newAsset = {
|
||||||
// OEP-08 Attributes
|
// OEP-08 Attributes
|
||||||
// https://github.com/oceanprotocol/OEPs/tree/master/8
|
// https://github.com/oceanprotocol/OEPs/tree/master/8
|
||||||
@ -280,10 +290,7 @@ export default class Publish extends Component<{}, PublishState> {
|
|||||||
files: this.state.files,
|
files: this.state.files,
|
||||||
price: this.state.price,
|
price: this.state.price,
|
||||||
type: this.state.type,
|
type: this.state.type,
|
||||||
categories: [this.state.categories],
|
categories: [this.state.categories]
|
||||||
workExample: undefined,
|
|
||||||
inLanguage: undefined,
|
|
||||||
tags: ''
|
|
||||||
}),
|
}),
|
||||||
curation: Object.assign(AssetModel.curation),
|
curation: Object.assign(AssetModel.curation),
|
||||||
additionalInformation: Object.assign(
|
additionalInformation: Object.assign(
|
||||||
|
Loading…
Reference in New Issue
Block a user