mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge pull request #78 from oceanprotocol/feature/datatoken
Full flow for Phase-2 [Part-1]
This commit is contained in:
commit
5df40cef81
@ -1,7 +1,7 @@
|
|||||||
import { URL } from 'whatwg-url'
|
import { URL } from 'whatwg-url'
|
||||||
import { DDO } from '../ddo/DDO'
|
import { DDO } from '../ddo/DDO'
|
||||||
import DID from '../ocean/DID'
|
import DID from '../ocean/DID'
|
||||||
import { EditableMetaData } from '../ddo/MetaData'
|
import { EditableMetadata } from '../ddo/interfaces/EditableMetadata'
|
||||||
import { Logger } from '../utils'
|
import { Logger } from '../utils'
|
||||||
import { WebServiceConnector } from '../ocean/utils/WebServiceConnector'
|
import { WebServiceConnector } from '../ocean/utils/WebServiceConnector'
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ export class Aquarius {
|
|||||||
this.logger.error('Success accessing consume endpoint: ', consumptionUrl)
|
this.logger.error('Success accessing consume endpoint: ', consumptionUrl)
|
||||||
return consumptionUrl
|
return consumptionUrl
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error(
|
this.logger.error(
|
||||||
'Error fetching the data asset consumption url: ',
|
'Error fetching the data asset consumption url: ',
|
||||||
error
|
error
|
||||||
@ -94,10 +94,10 @@ export class Aquarius {
|
|||||||
)
|
)
|
||||||
return this.transformResult()
|
return this.transformResult()
|
||||||
})
|
})
|
||||||
.then(results => {
|
.then((results) => {
|
||||||
return this.transformResult(results)
|
return this.transformResult(results)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error fetching querying metadata: ', error)
|
this.logger.error('Error fetching querying metadata: ', error)
|
||||||
return this.transformResult()
|
return this.transformResult()
|
||||||
})
|
})
|
||||||
@ -133,10 +133,10 @@ export class Aquarius {
|
|||||||
)
|
)
|
||||||
return this.transformResult()
|
return this.transformResult()
|
||||||
})
|
})
|
||||||
.then(results => {
|
.then((results) => {
|
||||||
return this.transformResult(results)
|
return this.transformResult(results)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error fetching querying metadata by text: ', error)
|
this.logger.error('Error fetching querying metadata by text: ', error)
|
||||||
return this.transformResult()
|
return this.transformResult()
|
||||||
})
|
})
|
||||||
@ -168,7 +168,7 @@ export class Aquarius {
|
|||||||
.then((response: DDO) => {
|
.then((response: DDO) => {
|
||||||
return new DDO(response) as DDO
|
return new DDO(response) as DDO
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error fetching querying metadata: ', error)
|
this.logger.error('Error fetching querying metadata: ', error)
|
||||||
return null as DDO
|
return null as DDO
|
||||||
})
|
})
|
||||||
@ -204,7 +204,7 @@ export class Aquarius {
|
|||||||
.then((response: DDO) => {
|
.then((response: DDO) => {
|
||||||
return new DDO(response) as DDO
|
return new DDO(response) as DDO
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error fetching querying metadata: ', error)
|
this.logger.error('Error fetching querying metadata: ', error)
|
||||||
return null as DDO
|
return null as DDO
|
||||||
})
|
})
|
||||||
@ -253,7 +253,7 @@ export class Aquarius {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error transfering ownership metadata: ', error)
|
this.logger.error('Error transfering ownership metadata: ', error)
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
@ -307,7 +307,7 @@ export class Aquarius {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error updating compute privacy: ', error)
|
this.logger.error('Error updating compute privacy: ', error)
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
@ -318,14 +318,14 @@ export class Aquarius {
|
|||||||
/**
|
/**
|
||||||
* Edit Metadata for a DDO.
|
* Edit Metadata for a DDO.
|
||||||
* @param {did} string DID.
|
* @param {did} string DID.
|
||||||
* @param {newMetadata} EditableMetaData Metadata fields & new values.
|
* @param {newMetadata} EditableMetadata Metadata fields & new values.
|
||||||
* @param {String} updated Updated field of the DDO
|
* @param {String} updated Updated field of the DDO
|
||||||
* @param {String} signature Signature using updated field to verify that the consumer has rights
|
* @param {String} signature Signature using updated field to verify that the consumer has rights
|
||||||
* @return {Promise<String>} Result.
|
* @return {Promise<String>} Result.
|
||||||
*/
|
*/
|
||||||
public async editMetadata(
|
public async editMetadata(
|
||||||
did: DID | string,
|
did: DID | string,
|
||||||
newMetadata: EditableMetaData,
|
newMetadata: EditableMetadata,
|
||||||
updated: string,
|
updated: string,
|
||||||
signature: string
|
signature: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
@ -353,7 +353,7 @@ export class Aquarius {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error transfering ownership metadata: ', error)
|
this.logger.error('Error transfering ownership metadata: ', error)
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
@ -391,7 +391,7 @@ export class Aquarius {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
this.logger.error('Error transfering ownership metadata: ', error)
|
this.logger.error('Error transfering ownership metadata: ', error)
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
@ -416,7 +416,7 @@ export class Aquarius {
|
|||||||
}
|
}
|
||||||
): QueryResult {
|
): QueryResult {
|
||||||
return {
|
return {
|
||||||
results: (results || []).map(ddo => new DDO(ddo as DDO)),
|
results: (results || []).map((ddo) => new DDO(ddo as DDO)),
|
||||||
page,
|
page,
|
||||||
totalPages,
|
totalPages,
|
||||||
totalResults
|
totalResults
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
import { File, MetaDataAlgorithm } from '../ddo/MetaData'
|
|
||||||
import Account from '../ocean/Account'
|
import Account from '../ocean/Account'
|
||||||
import { noZeroX, noDidPrefixed } from '../utils'
|
import { noZeroX } from '../utils'
|
||||||
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
||||||
import { DDO } from '../ddo/DDO'
|
|
||||||
import { ServiceType } from '../ddo/Service'
|
|
||||||
|
|
||||||
const apiPath = '/api/v1/brizo/services'
|
const apiPath = '/api/v1/brizo/services'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a interface with Brizo.
|
* Provides an interface for provider service.
|
||||||
* Brizo is the technical component executed by the Publishers allowing to them to provide extended data services.
|
* Provider service is the technical component executed
|
||||||
|
* by the Publishers allowing to them to provide extended
|
||||||
|
* data services.
|
||||||
*/
|
*/
|
||||||
export class Brizo extends Instantiable {
|
export class Brizo extends Instantiable {
|
||||||
private get url() {
|
private get url() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import Account from '../ocean/Account'
|
import Account from '../ocean/Account'
|
||||||
const defaultFactoryABI = require('@oceanprotocol/artifacts/development/Factory.json')
|
|
||||||
const defaultDatatokensABI = require('@oceanprotocol/artifacts/development/DatatokenTemplate.json')
|
import * as defaultFactoryABI from '@oceanprotocol/contracts/artifacts/development/Factory.json'
|
||||||
|
import * as defaultDatatokensABI from '@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a interface to DataTokens
|
* Provides a interface to DataTokens
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Ocean } from '../ocean/Ocean'
|
import { Ocean } from '../ocean/Ocean'
|
||||||
import { Authentication } from './Authentication'
|
import { Authentication } from './interfaces/Authentication'
|
||||||
import { Proof } from './Proof'
|
import { Proof } from './interfaces/Proof'
|
||||||
import { PublicKey } from './PublicKey'
|
import { PublicKey } from './interfaces/PublicKey'
|
||||||
import { Service, ServiceType } from './Service'
|
import { Service, ServiceType } from './interfaces/Service'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DID Descriptor Object.
|
* DID Descriptor Object.
|
||||||
@ -72,7 +72,7 @@ export class DDO {
|
|||||||
throw new Error('index is not set')
|
throw new Error('index is not set')
|
||||||
}
|
}
|
||||||
|
|
||||||
const service = this.service.find(s => s.index === index)
|
const service = this.service.find((s) => s.index === index)
|
||||||
|
|
||||||
return service as Service<T>
|
return service as Service<T>
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ export class DDO {
|
|||||||
throw new Error('serviceType not set')
|
throw new Error('serviceType not set')
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.service.find(s => s.type === serviceType) as Service<T>
|
return this.service.find((s) => s.type === serviceType) as Service<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +100,7 @@ export class DDO {
|
|||||||
const { files, name, author, license } = attributes.main
|
const { files, name, author, license } = attributes.main
|
||||||
|
|
||||||
const values = [
|
const values = [
|
||||||
...(files || []).map(({ checksum }) => checksum).filter(_ => !!_),
|
...(files || []).map(({ checksum }) => checksum).filter((_) => !!_),
|
||||||
name,
|
name,
|
||||||
author,
|
author,
|
||||||
license,
|
license,
|
||||||
|
@ -1,303 +0,0 @@
|
|||||||
export interface File {
|
|
||||||
/**
|
|
||||||
* File name.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
name?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File URL.
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
url: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File index.
|
|
||||||
* @type {number}
|
|
||||||
*/
|
|
||||||
index?: number
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File format, if applicable.
|
|
||||||
* @type {string}
|
|
||||||
* @example "text/csv"
|
|
||||||
*/
|
|
||||||
contentType: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File checksum.
|
|
||||||
* @type {[type]}
|
|
||||||
*/
|
|
||||||
checksum?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checksum hash algorithm.
|
|
||||||
* @type {[type]}
|
|
||||||
*/
|
|
||||||
checksumType?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File content length.
|
|
||||||
* @type {[type]}
|
|
||||||
*/
|
|
||||||
contentLength?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resource ID (depending on the source).
|
|
||||||
* @type {[type]}
|
|
||||||
*/
|
|
||||||
resourceId?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File encoding.
|
|
||||||
* @type {string}
|
|
||||||
* @example "UTF-8"
|
|
||||||
*/
|
|
||||||
encoding?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* File compression (e.g. no, gzip, bzip2, etc).
|
|
||||||
* @type {string}
|
|
||||||
* @example "zip"
|
|
||||||
*/
|
|
||||||
compression?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MetaDataAlgorithm {
|
|
||||||
url?: string
|
|
||||||
rawcode?: string
|
|
||||||
language?: string
|
|
||||||
format?: string
|
|
||||||
version?: string
|
|
||||||
container: {
|
|
||||||
entrypoint: string
|
|
||||||
image: string
|
|
||||||
tag: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main attributes of assets metadata.
|
|
||||||
* @see https://github.com/oceanprotocol/OEPs/tree/master/8
|
|
||||||
*/
|
|
||||||
export interface MetaDataMain {
|
|
||||||
/**
|
|
||||||
* Descriptive name of the Asset.
|
|
||||||
* @type {string}
|
|
||||||
* @example "UK Weather information 2011"
|
|
||||||
*/
|
|
||||||
name: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of the Asset. Helps to filter by the type of asset ("dataset" or "algorithm").
|
|
||||||
* @type {string}
|
|
||||||
* @example "dataset"
|
|
||||||
*/
|
|
||||||
type: 'dataset' | 'algorithm'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The date on which the asset was created by the originator in
|
|
||||||
* ISO 8601 format, Coordinated Universal Time.
|
|
||||||
* @type {string}
|
|
||||||
* @example "2019-01-31T08:38:32Z"
|
|
||||||
*/
|
|
||||||
dateCreated: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The date on which the asset DDO was registered into the metadata store.
|
|
||||||
* This value is created automatically by Aquarius upon registering,
|
|
||||||
* so this value can't be set.
|
|
||||||
* @type {string}
|
|
||||||
* @example "2019-01-31T08:38:32Z"
|
|
||||||
*/
|
|
||||||
datePublished?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Name of the entity generating this data (e.g. Tfl, Disney Corp, etc.).
|
|
||||||
* @type {string}
|
|
||||||
* @example "Met Office"
|
|
||||||
*/
|
|
||||||
author: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Short name referencing the license of the asset (e.g. Public Domain, CC-0, CC-BY, No License Specified, etc. ).
|
|
||||||
* If it's not specified, the following value will be added: "No License Specified".
|
|
||||||
* @type {string}
|
|
||||||
* @example "CC-BY"
|
|
||||||
*/
|
|
||||||
license: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Price of the asset in vodka (attoOCEAN). It must be an integer encoded as a string.
|
|
||||||
* @type {string}
|
|
||||||
* @example "1000000000000000000"
|
|
||||||
*/
|
|
||||||
price: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Array of File objects including the encrypted file urls and some additional information.
|
|
||||||
* @type {File[]}
|
|
||||||
*/
|
|
||||||
files: File[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Metadata used only for assets with type `algorithm`.
|
|
||||||
* @type {MetaDataAlgorithm}
|
|
||||||
*/
|
|
||||||
algorithm?: MetaDataAlgorithm
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Curation attributes of Assets Metadata.
|
|
||||||
* @see https://github.com/oceanprotocol/OEPs/tree/master/8
|
|
||||||
*/
|
|
||||||
export interface Curation {
|
|
||||||
/**
|
|
||||||
* Decimal value between 0 and 1. 0 is the default value.
|
|
||||||
* @type {number}
|
|
||||||
* @example 0.93
|
|
||||||
*/
|
|
||||||
rating: number
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Number of votes. 0 is the default value.
|
|
||||||
* @type {number}
|
|
||||||
* @example 123
|
|
||||||
*/
|
|
||||||
numVotes: number
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Schema applied to calculate the rating.
|
|
||||||
* @type {string}
|
|
||||||
* @example "Binary Voting"
|
|
||||||
*/
|
|
||||||
schema?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flag unsuitable content.
|
|
||||||
* @type {boolean}
|
|
||||||
* @example true
|
|
||||||
*/
|
|
||||||
isListed?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Additional Information of Assets Metadata.
|
|
||||||
* @see https://github.com/oceanprotocol/OEPs/tree/master/8#additional-information
|
|
||||||
*/
|
|
||||||
export interface AdditionalInformation {
|
|
||||||
/**
|
|
||||||
* Details of what the resource is. For a dataset, this attribute
|
|
||||||
* explains what the data represents and what it can be used for.
|
|
||||||
* @type {string}
|
|
||||||
* @example "Weather information of UK including temperature and humidity"
|
|
||||||
*/
|
|
||||||
description?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The party holding the legal copyright. Empty by default.
|
|
||||||
* @type {string}
|
|
||||||
* @example "Met Office"
|
|
||||||
*/
|
|
||||||
copyrightHolder?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Example of the concept of this asset. This example is part
|
|
||||||
* of the metadata, not an external link.
|
|
||||||
* @type {string}
|
|
||||||
* @example "423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68"
|
|
||||||
*/
|
|
||||||
workExample?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mapping of links for data samples, or links to find out more information.
|
|
||||||
* Links may be to either a URL or another Asset. We expect marketplaces to
|
|
||||||
* converge on agreements of typical formats for linked data: The Ocean Protocol
|
|
||||||
* itself does not mandate any specific formats as these requirements are likely
|
|
||||||
* to be domain-specific.
|
|
||||||
* @type {any[]}
|
|
||||||
* @example
|
|
||||||
* [
|
|
||||||
* {
|
|
||||||
* anotherSample: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/",
|
|
||||||
* },
|
|
||||||
* {
|
|
||||||
* fieldsDescription: "http://data.ceda.ac.uk/badc/ukcp09/",
|
|
||||||
* },
|
|
||||||
* ]
|
|
||||||
*/
|
|
||||||
links?: { [name: string]: string }[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The language of the content. Please use one of the language
|
|
||||||
* codes from the {@link https://tools.ietf.org/html/bcp47 IETF BCP 47 standard}.
|
|
||||||
* @type {String}
|
|
||||||
* @example "en"
|
|
||||||
*/
|
|
||||||
inLanguage?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Categories used to describe this content. Empty by default.
|
|
||||||
* @type {string[]}
|
|
||||||
* @example ["Economy", "Data Science"]
|
|
||||||
*/
|
|
||||||
categories?: string[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Keywords or tags used to describe this content. Empty by default.
|
|
||||||
* @type {string[]}
|
|
||||||
* @example ["weather", "uk", "2011", "temperature", "humidity"]
|
|
||||||
*/
|
|
||||||
tags?: string[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An indication of update latency - i.e. How often are updates expected (seldom,
|
|
||||||
* annually, quarterly, etc.), or is the resource static that is never expected
|
|
||||||
* to get updated.
|
|
||||||
* @type {string}
|
|
||||||
* @example "yearly"
|
|
||||||
*/
|
|
||||||
updateFrequency?: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A link to machine-readable structured markup (such as ttl/json-ld/rdf)
|
|
||||||
* describing the dataset.
|
|
||||||
* @type {StructuredMarkup[]}
|
|
||||||
*/
|
|
||||||
structuredMarkup?: {
|
|
||||||
uri: string
|
|
||||||
mediaType: string
|
|
||||||
}[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MetaData {
|
|
||||||
main: MetaDataMain
|
|
||||||
encryptedFiles?: string
|
|
||||||
additionalInformation?: AdditionalInformation
|
|
||||||
curation?: Curation
|
|
||||||
}
|
|
||||||
/** Warning. serviceIndex is the index of a services in Services array, and not service.index attribute.
|
|
||||||
Let's assume that you have the following services array:
|
|
||||||
[
|
|
||||||
{"index":1,"type":"access","main":{"price":3}},
|
|
||||||
{"index":0,"type":"compute","main":{"price":1}}
|
|
||||||
]
|
|
||||||
then calling update with { serviceIndex:1,price:2} will update the 'compute' service, and not the access one
|
|
||||||
**/
|
|
||||||
export interface ServicePrices {
|
|
||||||
serviceIndex: number
|
|
||||||
price: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EditableMetaDataLinks {
|
|
||||||
name: string
|
|
||||||
url: string
|
|
||||||
type: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface EditableMetaData {
|
|
||||||
description?: string
|
|
||||||
title?: string
|
|
||||||
links?: EditableMetaDataLinks[]
|
|
||||||
servicePrices?: ServicePrices[]
|
|
||||||
}
|
|
88
src/ddo/interfaces/AdditionalInformation.ts
Normal file
88
src/ddo/interfaces/AdditionalInformation.ts
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
* Additional Information of Assets Metadata.
|
||||||
|
* @see https://github.com/oceanprotocol/OEPs/tree/master/8#additional-information
|
||||||
|
*/
|
||||||
|
export interface AdditionalInformation {
|
||||||
|
/**
|
||||||
|
* Details of what the resource is. For a dataset, this attribute
|
||||||
|
* explains what the data represents and what it can be used for.
|
||||||
|
* @type {string}
|
||||||
|
* @example "Weather information of UK including temperature and humidity"
|
||||||
|
*/
|
||||||
|
description?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The party holding the legal copyright. Empty by default.
|
||||||
|
* @type {string}
|
||||||
|
* @example "Met Office"
|
||||||
|
*/
|
||||||
|
copyrightHolder?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example of the concept of this asset. This example is part
|
||||||
|
* of the metadata, not an external link.
|
||||||
|
* @type {string}
|
||||||
|
* @example "423432fsd,51.509865,-0.118092,2011-01-01T10:55:11+00:00,7.2,68"
|
||||||
|
*/
|
||||||
|
workExample?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping of links for data samples, or links to find out more information.
|
||||||
|
* Links may be to either a URL or another Asset. We expect marketplaces to
|
||||||
|
* converge on agreements of typical formats for linked data: The Ocean Protocol
|
||||||
|
* itself does not mandate any specific formats as these requirements are likely
|
||||||
|
* to be domain-specific.
|
||||||
|
* @type {any[]}
|
||||||
|
* @example
|
||||||
|
* [
|
||||||
|
* {
|
||||||
|
* anotherSample: "http://data.ceda.ac.uk/badc/ukcp09/data/gridded-land-obs/gridded-land-obs-daily/",
|
||||||
|
* },
|
||||||
|
* {
|
||||||
|
* fieldsDescription: "http://data.ceda.ac.uk/badc/ukcp09/",
|
||||||
|
* },
|
||||||
|
* ]
|
||||||
|
*/
|
||||||
|
links?: { [name: string]: string }[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The language of the content. Please use one of the language
|
||||||
|
* codes from the {@link https://tools.ietf.org/html/bcp47 IETF BCP 47 standard}.
|
||||||
|
* @type {String}
|
||||||
|
* @example "en"
|
||||||
|
*/
|
||||||
|
inLanguage?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Categories used to describe this content. Empty by default.
|
||||||
|
* @type {string[]}
|
||||||
|
* @example ["Economy", "Data Science"]
|
||||||
|
*/
|
||||||
|
categories?: string[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keywords or tags used to describe this content. Empty by default.
|
||||||
|
* @type {string[]}
|
||||||
|
* @example ["weather", "uk", "2011", "temperature", "humidity"]
|
||||||
|
*/
|
||||||
|
tags?: string[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An indication of update latency - i.e. How often are updates expected (seldom,
|
||||||
|
* annually, quarterly, etc.), or is the resource static that is never expected
|
||||||
|
* to get updated.
|
||||||
|
* @type {string}
|
||||||
|
* @example "yearly"
|
||||||
|
*/
|
||||||
|
updateFrequency?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A link to machine-readable structured markup (such as ttl/json-ld/rdf)
|
||||||
|
* describing the dataset.
|
||||||
|
* @type {StructuredMarkup[]}
|
||||||
|
*/
|
||||||
|
structuredMarkup?: {
|
||||||
|
uri: string
|
||||||
|
mediaType: string
|
||||||
|
}[]
|
||||||
|
}
|
33
src/ddo/interfaces/Curation.ts
Normal file
33
src/ddo/interfaces/Curation.ts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Curation attributes of Assets Metadata.
|
||||||
|
* @see https://github.com/oceanprotocol/OEPs/tree/master/8
|
||||||
|
*/
|
||||||
|
export interface Curation {
|
||||||
|
/**
|
||||||
|
* Decimal value between 0 and 1. 0 is the default value.
|
||||||
|
* @type {number}
|
||||||
|
* @example 0.93
|
||||||
|
*/
|
||||||
|
rating: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of votes. 0 is the default value.
|
||||||
|
* @type {number}
|
||||||
|
* @example 123
|
||||||
|
*/
|
||||||
|
numVotes: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schema applied to calculate the rating.
|
||||||
|
* @type {string}
|
||||||
|
* @example "Binary Voting"
|
||||||
|
*/
|
||||||
|
schema?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag unsuitable content.
|
||||||
|
* @type {boolean}
|
||||||
|
* @example true
|
||||||
|
*/
|
||||||
|
isListed?: boolean
|
||||||
|
}
|
9
src/ddo/interfaces/EditableMetadata.ts
Normal file
9
src/ddo/interfaces/EditableMetadata.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { EditableMetadataLinks } from './EditableMetadataLinks'
|
||||||
|
import { ServicePrices } from './ServicePrices'
|
||||||
|
|
||||||
|
export interface EditableMetadata {
|
||||||
|
description?: string
|
||||||
|
title?: string
|
||||||
|
links?: EditableMetadataLinks[]
|
||||||
|
servicePrices?: ServicePrices[]
|
||||||
|
}
|
5
src/ddo/interfaces/EditableMetadataLinks.ts
Normal file
5
src/ddo/interfaces/EditableMetadataLinks.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface EditableMetadataLinks {
|
||||||
|
name: string
|
||||||
|
url: string
|
||||||
|
type: string
|
||||||
|
}
|
64
src/ddo/interfaces/File.ts
Normal file
64
src/ddo/interfaces/File.ts
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
export interface File {
|
||||||
|
/**
|
||||||
|
* File name.
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
name?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File URL.
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
url: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File index.
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
index?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File format, if applicable.
|
||||||
|
* @type {string}
|
||||||
|
* @example "text/csv"
|
||||||
|
*/
|
||||||
|
contentType: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File checksum.
|
||||||
|
* @type {[type]}
|
||||||
|
*/
|
||||||
|
checksum?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checksum hash algorithm.
|
||||||
|
* @type {[type]}
|
||||||
|
*/
|
||||||
|
checksumType?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File content length.
|
||||||
|
* @type {[type]}
|
||||||
|
*/
|
||||||
|
contentLength?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resource ID (depending on the source).
|
||||||
|
* @type {[type]}
|
||||||
|
*/
|
||||||
|
resourceId?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File encoding.
|
||||||
|
* @type {string}
|
||||||
|
* @example "UTF-8"
|
||||||
|
*/
|
||||||
|
encoding?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File compression (e.g. no, gzip, bzip2, etc).
|
||||||
|
* @type {string}
|
||||||
|
* @example "zip"
|
||||||
|
*/
|
||||||
|
compression?: string
|
||||||
|
}
|
10
src/ddo/interfaces/Metadata.ts
Normal file
10
src/ddo/interfaces/Metadata.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { MetadataMain } from './MetadataMain'
|
||||||
|
import { AdditionalInformation } from './AdditionalInformation'
|
||||||
|
import { Curation } from './Curation'
|
||||||
|
|
||||||
|
export interface Metadata {
|
||||||
|
main: MetadataMain
|
||||||
|
encryptedFiles?: string
|
||||||
|
additionalInformation?: AdditionalInformation
|
||||||
|
curation?: Curation
|
||||||
|
}
|
12
src/ddo/interfaces/MetadataAlgorithm.ts
Normal file
12
src/ddo/interfaces/MetadataAlgorithm.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
export interface MetadataAlgorithm {
|
||||||
|
url?: string
|
||||||
|
rawcode?: string
|
||||||
|
language?: string
|
||||||
|
format?: string
|
||||||
|
version?: string
|
||||||
|
container: {
|
||||||
|
entrypoint: string
|
||||||
|
image: string
|
||||||
|
tag: string
|
||||||
|
}
|
||||||
|
}
|
73
src/ddo/interfaces/MetadataMain.ts
Normal file
73
src/ddo/interfaces/MetadataMain.ts
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import { MetadataAlgorithm } from './MetadataAlgorithm'
|
||||||
|
import { File } from './File'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main attributes of assets metadata.
|
||||||
|
* @see https://github.com/oceanprotocol/OEPs/tree/master/8
|
||||||
|
*/
|
||||||
|
export interface MetadataMain {
|
||||||
|
/**
|
||||||
|
* Descriptive name of the Asset.
|
||||||
|
* @type {string}
|
||||||
|
* @example "UK Weather information 2011"
|
||||||
|
*/
|
||||||
|
name: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the Asset. Helps to filter by the type of asset ("dataset" or "algorithm").
|
||||||
|
* @type {string}
|
||||||
|
* @example "dataset"
|
||||||
|
*/
|
||||||
|
type: 'dataset' | 'algorithm'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date on which the asset was created by the originator in
|
||||||
|
* ISO 8601 format, Coordinated Universal Time.
|
||||||
|
* @type {string}
|
||||||
|
* @example "2019-01-31T08:38:32Z"
|
||||||
|
*/
|
||||||
|
dateCreated: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The date on which the asset DDO was registered into the metadata store.
|
||||||
|
* This value is created automatically by Aquarius upon registering,
|
||||||
|
* so this value can't be set.
|
||||||
|
* @type {string}
|
||||||
|
* @example "2019-01-31T08:38:32Z"
|
||||||
|
*/
|
||||||
|
datePublished?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the entity generating this data (e.g. Tfl, Disney Corp, etc.).
|
||||||
|
* @type {string}
|
||||||
|
* @example "Met Office"
|
||||||
|
*/
|
||||||
|
author: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Short name referencing the license of the asset (e.g. Public Domain, CC-0, CC-BY, No License Specified, etc. ).
|
||||||
|
* If it's not specified, the following value will be added: "No License Specified".
|
||||||
|
* @type {string}
|
||||||
|
* @example "CC-BY"
|
||||||
|
*/
|
||||||
|
license: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Price of the asset in vodka (attoOCEAN). It must be an integer encoded as a string.
|
||||||
|
* @type {string}
|
||||||
|
* @example "1000000000000000000"
|
||||||
|
*/
|
||||||
|
price: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of File objects including the encrypted file urls and some additional information.
|
||||||
|
* @type {File[]}
|
||||||
|
*/
|
||||||
|
files: File[]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metadata used only for assets with type `algorithm`.
|
||||||
|
* @type {MetaDataAlgorithm}
|
||||||
|
*/
|
||||||
|
algorithm?: MetadataAlgorithm
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { MetaData } from './MetaData'
|
import { Metadata } from './Metadata'
|
||||||
|
|
||||||
export type ServiceType = 'authorization' | 'metadata' | 'access' | 'compute'
|
export type ServiceType = 'authorization' | 'metadata' | 'access' | 'compute'
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ export interface ServiceComputeProvider {
|
|||||||
|
|
||||||
export interface ServiceMetadata extends ServiceCommon {
|
export interface ServiceMetadata extends ServiceCommon {
|
||||||
type: 'metadata'
|
type: 'metadata'
|
||||||
attributes: MetaData
|
attributes: Metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServiceAccess extends ServiceCommon {
|
export interface ServiceAccess extends ServiceCommon {
|
4
src/ddo/interfaces/ServicePrices.ts
Normal file
4
src/ddo/interfaces/ServicePrices.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export interface ServicePrices {
|
||||||
|
serviceIndex: number
|
||||||
|
price: string
|
||||||
|
}
|
@ -11,7 +11,7 @@ import * as utils from './utils'
|
|||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
export * from './ddo/DDO'
|
export * from './ddo/DDO'
|
||||||
export * from './ddo/MetaData'
|
export * from './ddo/interfaces/Metadata'
|
||||||
|
|
||||||
export { CreateProgressStep, OrderProgressStep } from './ocean/Assets'
|
export { CreateProgressStep, OrderProgressStep } from './ocean/Assets'
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ export class Accounts extends Instantiable {
|
|||||||
const ethAccounts: string[] = await this.web3.eth.getAccounts()
|
const ethAccounts: string[] = await this.web3.eth.getAccounts()
|
||||||
|
|
||||||
const accountPromises = ethAccounts.map(
|
const accountPromises = ethAccounts.map(
|
||||||
address => new Account(address, this.instanceConfig)
|
(address) => new Account(address, this.instanceConfig)
|
||||||
)
|
)
|
||||||
return Promise.all(accountPromises)
|
return Promise.all(accountPromises)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { TransactionReceipt } from 'web3-core'
|
import { TransactionReceipt } from 'web3-core'
|
||||||
import { SearchQuery } from '../aquarius/Aquarius'
|
import { SearchQuery } from '../aquarius/Aquarius'
|
||||||
import { DDO } from '../ddo/DDO'
|
import { DDO } from '../ddo/DDO'
|
||||||
import { MetaData, EditableMetaData } from '../ddo/MetaData'
|
import { Metadata } from '../ddo/interfaces/Metadata'
|
||||||
import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/Service'
|
import { Service } from '../ddo/interfaces/Service'
|
||||||
import Account from './Account'
|
import Account from './Account'
|
||||||
import DID from './DID'
|
import DID from './DID'
|
||||||
import { SubscribablePromise, didZeroX } from '../utils'
|
import { SubscribablePromise, didZeroX } from '../utils'
|
||||||
@ -63,13 +63,13 @@ export class Assets extends Instantiable {
|
|||||||
* @return {Promise<DDO>}
|
* @return {Promise<DDO>}
|
||||||
*/
|
*/
|
||||||
public create(
|
public create(
|
||||||
metadata: MetaData,
|
metadata: Metadata,
|
||||||
publisher: Account,
|
publisher: Account,
|
||||||
services: Service[] = [],
|
services: Service[] = [],
|
||||||
dtAddress?: string
|
dtAddress?: string
|
||||||
): SubscribablePromise<CreateProgressStep, DDO> {
|
): SubscribablePromise<CreateProgressStep, DDO> {
|
||||||
this.logger.log('Creating asset')
|
this.logger.log('Creating asset')
|
||||||
return new SubscribablePromise(async observer => {
|
return new SubscribablePromise(async (observer) => {
|
||||||
if (services.length === 0) {
|
if (services.length === 0) {
|
||||||
this.logger.log('You have no services. Are you sure about this?')
|
this.logger.log('You have no services. Are you sure about this?')
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ export class Assets extends Instantiable {
|
|||||||
)
|
)
|
||||||
.reverse()
|
.reverse()
|
||||||
// Adding index
|
// Adding index
|
||||||
.map(_ => ({
|
.map((_) => ({
|
||||||
..._,
|
..._,
|
||||||
index: indexCount++
|
index: indexCount++
|
||||||
})) as Service[]
|
})) as Service[]
|
||||||
|
@ -25,7 +25,7 @@ export class ConfigHelper {
|
|||||||
confighelp.factoryAddress = null
|
confighelp.factoryAddress = null
|
||||||
confighelp.url = null
|
confighelp.url = null
|
||||||
confighelp.network = network
|
confighelp.network = network
|
||||||
const knownconfig = configs.find(c => c.network === network)
|
const knownconfig = configs.find((c) => c.network === network)
|
||||||
if (knownconfig) {
|
if (knownconfig) {
|
||||||
confighelp.factoryAddress = knownconfig.factoryAddress
|
confighelp.factoryAddress = knownconfig.factoryAddress
|
||||||
confighelp.url = knownconfig.url
|
confighelp.url = knownconfig.url
|
||||||
|
@ -39,7 +39,7 @@ export class SubscribableObserver<T, P> {
|
|||||||
|
|
||||||
private emit(type: 'onNext' | 'onComplete' | 'onError', value: any) {
|
private emit(type: 'onNext' | 'onComplete' | 'onError', value: any) {
|
||||||
Array.from(this.subscriptions)
|
Array.from(this.subscriptions)
|
||||||
.map(subscription => subscription[type])
|
.map((subscription) => subscription[type])
|
||||||
.filter((callback: any) => callback && typeof callback === 'function')
|
.filter((callback: any) => callback && typeof callback === 'function')
|
||||||
.forEach((callback: any) => callback(value))
|
.forEach((callback: any) => callback(value))
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@ export class SubscribablePromise<T extends any, P extends any> {
|
|||||||
const execution = executor(this.observer)
|
const execution = executor(this.observer)
|
||||||
|
|
||||||
Promise.resolve(execution as any)
|
Promise.resolve(execution as any)
|
||||||
.then(result => {
|
.then((result) => {
|
||||||
if (typeof (execution as any).then === 'function') {
|
if (typeof (execution as any).then === 'function') {
|
||||||
this.observer.complete(result)
|
this.observer.complete(result)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(result => {
|
.catch((result) => {
|
||||||
if (typeof (execution as any).then === 'function') {
|
if (typeof (execution as any).then === 'function') {
|
||||||
this.observer.error(result)
|
this.observer.error(result)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user