mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Matthias Kretschmann
40754ca46a
* refactor all .order() methods to use one single method * remove `index` parameter from ocean.assets.order() * update compute test flow
97 lines
2.8 KiB
TypeScript
97 lines
2.8 KiB
TypeScript
import { MetaData } from '../../src' // @oceanprotocol/squid
|
|
import { ServiceType } from '../../src/ddo/Service'
|
|
import ddoExample from '../../test/testdata/ddo.json'
|
|
|
|
const metadata: Partial<MetaData> = {
|
|
main: {
|
|
name: undefined,
|
|
type: undefined,
|
|
dateCreated: '2012-10-10T17:00:00Z',
|
|
datePublished: '2012-10-10T17:00:00Z',
|
|
author: 'Met Office',
|
|
license: 'CC-BY',
|
|
price: '21' + '0'.repeat(18),
|
|
files: [
|
|
{
|
|
index: 0,
|
|
contentType: 'application/json',
|
|
url:
|
|
'https://raw.githubusercontent.com/oceanprotocol/squid-js/master/package.json'
|
|
},
|
|
{
|
|
index: 1,
|
|
contentType: 'text/plain',
|
|
url:
|
|
'https://raw.githubusercontent.com/oceanprotocol/squid-js/master/README.md'
|
|
}
|
|
]
|
|
},
|
|
additionalInformation: {
|
|
description: 'Weather information of UK including temperature and humidity',
|
|
copyrightHolder: 'Met Office',
|
|
workExample: '423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68',
|
|
links: [
|
|
{
|
|
name: 'Sample of Asset Data',
|
|
type: 'sample',
|
|
url: 'https://foo.com/sample.csv'
|
|
},
|
|
{
|
|
name: 'Data Format Definition',
|
|
type: 'format',
|
|
url: 'https://foo.com/sample.csv'
|
|
}
|
|
],
|
|
inLanguage: 'en',
|
|
categories: ['Economy', 'Data Science'],
|
|
tags: ['weather', 'uk', '2011', 'temperature', 'humidity']
|
|
}
|
|
}
|
|
|
|
const algorithmMeta = {
|
|
language: 'scala',
|
|
format: 'docker-image',
|
|
version: '0.1',
|
|
entrypoint: 'ocean-entrypoint.sh',
|
|
requirements: [],
|
|
container: {
|
|
entrypoint: 'node $ALGO',
|
|
image: 'node',
|
|
tag: '10'
|
|
}
|
|
}
|
|
|
|
export const generateMetadata = (
|
|
name: string,
|
|
type?: 'dataset' | 'algorithm',
|
|
price?: number
|
|
): Partial<MetaData> => ({
|
|
...metadata,
|
|
main: {
|
|
...metadata.main,
|
|
name,
|
|
type: type || 'dataset',
|
|
price: (price || 21) + '0'.repeat(18),
|
|
algorithm: type === 'algorithm' ? algorithmMeta : undefined
|
|
},
|
|
additionalInformation: {
|
|
...metadata.additionalInformation
|
|
}
|
|
})
|
|
|
|
export const getMetadata = (price?: number, type?: 'dataset' | 'algorithm') =>
|
|
generateMetadata('TestAsset', type, price)
|
|
|
|
export const getComputeServiceExample = () => {
|
|
const computeService = ddoExample.service.find(service => service.type === 'compute')
|
|
const { index, serviceEndpoint, templateId, attributes } = computeService
|
|
|
|
return {
|
|
type: 'compute' as ServiceType,
|
|
index,
|
|
serviceEndpoint,
|
|
templateId,
|
|
attributes
|
|
}
|
|
}
|