1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

initial commit for the DDO typings

This commit is contained in:
Bogdan Fazakas 2021-11-11 17:12:24 +02:00
parent 5938939847
commit f1962f7103
5 changed files with 119 additions and 0 deletions

9
src/ddo/Credentials.ts Normal file
View File

@ -0,0 +1,9 @@
export interface Credential {
type: string
values: string[]
}
export interface Credentials {
allow: Credential[]
deny: Credential[]
}

54
src/ddo/DDO.ts Normal file
View File

@ -0,0 +1,54 @@
import { Service } from './Service'
import { Metadata } from './Metadata'
import { Credentials } from './Credentials'
/**
* DID Descriptor Object.
* Contains metadata about the asset, and define access in at least one service.
*/
export class DDO {
/**
* Contexts used for validation..
* @type {string[]}
*/
public '@context': string[]
/**
* DID, descentralized ID.
* Computed as sha256(address of ERC721 contract + chainId)
* @type {string}
*/
public id: string
/**
* Version information in SemVer notation
* referring to the DDO spec version
* @type {string}
*/
public version: string
/**
* ChainId of the network the DDO was published to.
* @type {number}
*/
public chainId: number
/**
* Stores an object describing the asset.
* @type {Metadata}
*/
public metadata: Metadata
/**
* Stores an array of services defining access to the asset.
* @type {Service[]}
*/
public services: Service[]
/**
* Describes the credentials needed to access a dataset
* in addition to the services definition.
* @type {Credentials}
*/
public credentials?: Credentials
}

26
src/ddo/Metadata.ts Normal file
View File

@ -0,0 +1,26 @@
export interface MetadataAlgorithm {
language?: string
version?: string
container: {
entrypoint: string
image: string
tag: string
checksum: string
}
}
export interface Metadata {
created: string
updated: string
name: string
description: string
type: 'dataset' | 'algorithm'
author: string
license: string
links?: string[]
tags?: string[]
copyrightHolder?: string
contentLanguage?: string
algorithm?: MetadataAlgorithm
additionalInformation?: any
}

29
src/ddo/Service.ts Normal file
View File

@ -0,0 +1,29 @@
export interface PublisherTrustedAlgorithm {
did: string
filesChecksum: string
containerSectionChecksum: string
}
export interface ServiceComputeOptions {
namespace: string
cpu?: number
gpu?: number
gpuType?: string
memory?: string
volumeSize?: string
allowRawAlgorithm: boolean
allowNetworkAccess: boolean
publisherTrustedAlgorithmPublishers: string[]
publisherTrustedAlgorithms: PublisherTrustedAlgorithm[]
}
export interface Service {
type: 'access' | 'compute' | string
files: string
datatokenAddress: string
serviceEndpoint: string
timeout: string
name?: string
description?: string
compute?: ServiceComputeOptions
}

1
src/ddo/index.ts Normal file
View File

@ -0,0 +1 @@
export * from './DDO'