From f1962f710371679ca1fe9c65e5ddd1d4a80a348b Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Thu, 11 Nov 2021 17:12:24 +0200 Subject: [PATCH] initial commit for the DDO typings --- src/ddo/Credentials.ts | 9 +++++++ src/ddo/DDO.ts | 54 ++++++++++++++++++++++++++++++++++++++++++ src/ddo/Metadata.ts | 26 ++++++++++++++++++++ src/ddo/Service.ts | 29 +++++++++++++++++++++++ src/ddo/index.ts | 1 + 5 files changed, 119 insertions(+) create mode 100644 src/ddo/Credentials.ts create mode 100644 src/ddo/DDO.ts create mode 100644 src/ddo/Metadata.ts create mode 100644 src/ddo/Service.ts create mode 100644 src/ddo/index.ts diff --git a/src/ddo/Credentials.ts b/src/ddo/Credentials.ts new file mode 100644 index 00000000..9133f74e --- /dev/null +++ b/src/ddo/Credentials.ts @@ -0,0 +1,9 @@ +export interface Credential { + type: string + values: string[] +} + +export interface Credentials { + allow: Credential[] + deny: Credential[] +} diff --git a/src/ddo/DDO.ts b/src/ddo/DDO.ts new file mode 100644 index 00000000..465e4aab --- /dev/null +++ b/src/ddo/DDO.ts @@ -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 +} diff --git a/src/ddo/Metadata.ts b/src/ddo/Metadata.ts new file mode 100644 index 00000000..90b48326 --- /dev/null +++ b/src/ddo/Metadata.ts @@ -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 +} diff --git a/src/ddo/Service.ts b/src/ddo/Service.ts new file mode 100644 index 00000000..0ba45317 --- /dev/null +++ b/src/ddo/Service.ts @@ -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 +} diff --git a/src/ddo/index.ts b/src/ddo/index.ts new file mode 100644 index 00000000..4bd3a54b --- /dev/null +++ b/src/ddo/index.ts @@ -0,0 +1 @@ +export * from './DDO'