2020-01-31 00:15:55 +01:00
|
|
|
import { MetaData, MetaDataAlgorithm } from '../../../src' // @oceanprotocol/squid
|
|
|
|
import { ServiceType } from '../../../src/ddo/Service'
|
|
|
|
import ddoExample from '../../unit/__fixtures__/ddo.json'
|
2019-03-15 15:23:28 +01:00
|
|
|
|
|
|
|
const metadata: Partial<MetaData> = {
|
2019-08-15 13:23:56 +02:00
|
|
|
main: {
|
2019-03-15 15:23:28 +01:00
|
|
|
name: undefined,
|
2020-01-21 22:09:32 +01:00
|
|
|
type: undefined,
|
2019-06-20 00:20:09 +02:00
|
|
|
dateCreated: '2012-10-10T17:00:00Z',
|
|
|
|
datePublished: '2012-10-10T17:00:00Z',
|
|
|
|
author: 'Met Office',
|
|
|
|
license: 'CC-BY',
|
2019-08-15 13:23:56 +02:00
|
|
|
price: '21' + '0'.repeat(18),
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
index: 0,
|
2019-08-16 16:12:42 +02:00
|
|
|
contentType: 'application/json',
|
2019-11-15 00:00:10 +01:00
|
|
|
url:
|
|
|
|
'https://raw.githubusercontent.com/oceanprotocol/squid-js/master/package.json'
|
2019-08-15 13:23:56 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
index: 1,
|
2019-08-16 16:12:42 +02:00
|
|
|
contentType: 'text/plain',
|
2019-11-15 00:00:10 +01:00
|
|
|
url:
|
|
|
|
'https://raw.githubusercontent.com/oceanprotocol/squid-js/master/README.md'
|
2019-08-15 13:23:56 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
additionalInformation: {
|
2019-09-09 12:18:54 +02:00
|
|
|
description: 'Weather information of UK including temperature and humidity',
|
2019-06-20 00:20:09 +02:00
|
|
|
copyrightHolder: 'Met Office',
|
2019-09-09 12:18:54 +02:00
|
|
|
workExample: '423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68',
|
2019-04-29 14:35:42 +02:00
|
|
|
links: [
|
2019-03-15 15:23:28 +01:00
|
|
|
{
|
2019-06-20 00:20:09 +02:00
|
|
|
name: 'Sample of Asset Data',
|
|
|
|
type: 'sample',
|
|
|
|
url: 'https://foo.com/sample.csv'
|
2019-03-15 15:23:28 +01:00
|
|
|
},
|
|
|
|
{
|
2019-06-20 00:20:09 +02:00
|
|
|
name: 'Data Format Definition',
|
|
|
|
type: 'format',
|
|
|
|
url: 'https://foo.com/sample.csv'
|
|
|
|
}
|
2019-03-15 15:23:28 +01:00
|
|
|
],
|
2019-06-20 00:20:09 +02:00
|
|
|
inLanguage: 'en',
|
|
|
|
categories: ['Economy', 'Data Science'],
|
2019-08-15 13:23:56 +02:00
|
|
|
tags: ['weather', 'uk', '2011', 'temperature', 'humidity']
|
2019-06-20 00:20:09 +02:00
|
|
|
}
|
2019-03-15 15:23:28 +01:00
|
|
|
}
|
|
|
|
|
2020-01-28 18:59:06 +01:00
|
|
|
const algorithmMeta: MetaDataAlgorithm = {
|
2020-01-24 15:23:50 +01:00
|
|
|
language: 'scala',
|
|
|
|
format: 'docker-image',
|
|
|
|
version: '0.1',
|
|
|
|
container: {
|
2020-01-28 18:59:06 +01:00
|
|
|
entrypoint: 'ocean-entrypoint.sh',
|
2020-01-27 15:59:26 +01:00
|
|
|
image: 'node',
|
|
|
|
tag: '10'
|
2020-01-24 15:23:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-21 22:09:32 +01:00
|
|
|
export const generateMetadata = (
|
|
|
|
name: string,
|
|
|
|
type?: 'dataset' | 'algorithm',
|
|
|
|
price?: number
|
|
|
|
): Partial<MetaData> => ({
|
2019-08-15 13:23:56 +02:00
|
|
|
main: {
|
|
|
|
...metadata.main,
|
2019-06-26 20:57:50 +02:00
|
|
|
name,
|
2020-01-21 22:09:32 +01:00
|
|
|
type: type || 'dataset',
|
2020-01-24 15:23:50 +01:00
|
|
|
price: (price || 21) + '0'.repeat(18),
|
2020-01-27 15:59:26 +01:00
|
|
|
algorithm: type === 'algorithm' ? algorithmMeta : undefined
|
2019-08-15 13:23:56 +02:00
|
|
|
},
|
|
|
|
additionalInformation: {
|
|
|
|
...metadata.additionalInformation
|
2019-06-20 00:20:09 +02:00
|
|
|
}
|
2019-03-15 15:23:28 +01:00
|
|
|
})
|
|
|
|
|
2020-01-21 22:09:32 +01:00
|
|
|
export const getMetadata = (price?: number, type?: 'dataset' | 'algorithm') =>
|
|
|
|
generateMetadata('TestAsset', type, price)
|
2020-01-27 15:59:26 +01:00
|
|
|
|
2020-01-27 16:50:33 +01:00
|
|
|
export const getComputeServiceExample = () => {
|
2020-01-27 19:14:12 +01:00
|
|
|
const computeService = ddoExample.service.find(service => service.type === 'compute')
|
2020-01-27 16:50:33 +01:00
|
|
|
const { index, serviceEndpoint, templateId, attributes } = computeService
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: 'compute' as ServiceType,
|
|
|
|
index,
|
|
|
|
serviceEndpoint,
|
|
|
|
templateId,
|
|
|
|
attributes
|
2020-01-27 15:59:26 +01:00
|
|
|
}
|
|
|
|
}
|