diff --git a/src/ddo/Asset.ts b/src/ddo/Asset.ts new file mode 100644 index 00000000..fa4deb23 --- /dev/null +++ b/src/ddo/Asset.ts @@ -0,0 +1,109 @@ +import { DDO } from './DDO' + +export interface AssetNft { + /** + * Contract address of the deployed ERC721 NFT contract. + * @type {string} + */ + address: string + + /** + * Name of NFT set in contract. + * @type {string} + */ + name: string + + /** + * Symbol of NFT set in contract. + * @type {string} + */ + symbol: string + + /** + * ETH account address of the NFT owner. + * @type {string} + */ + owner: string + + /** + * State of the asset reflecting the NFT contract value. + * 0 Active. + * 1 End-of-life. + * 2 Deprecated (by another asset). + * 3 Revoked by publisher. + * 4 Ordering is temporary disabled. + * @type {number} + */ + state: 0 | 1 | 2 | 3 | 4 +} + +export interface AssetDatatoken { + /** + * Name of NFT set in contract. + * @type {string} + */ + name: string + + /** + * Symbol of NFT set in contract. + * @type {string} + */ + symbol: string + + /** + * Contract address of the deployed ERC20 contract. + * @type {string} + */ + address: string + + /** + * ID of the service the datatoken is attached to. + * @type {string} + */ + serviceId: string +} + +export interface AssetLastEvent { + tx: string + block: number + from: string + contract: string +} + +export class Asset extends DDO { + /** + * Contains information about the ERC721 NFT contract which represents the intellectual property of the publisher. + * @type {string} + */ + nft: AssetNft + + /** + * Contains information about the ERC20 datatokens attached to asset services. + * @type {string} + */ + datatokens: AssetDatatoken[] + + /** + * Contains information about the last transaction that created or updated the DDO. + * @type {string} + */ + event: AssetLastEvent + + /** + * The stats section contains different statistics fields. + * @type {string} + */ + stats: { consume: number } + + /** + * If asset is listed in purgatory and reason. + * @type {string} + */ + isInPurgatory: string + + /** + * Name of NFT set in contract. + * @type {AssetDatatoken} + */ + dataTokenInfo: AssetDatatoken // To be removed +} diff --git a/src/ddo/Metadata.ts b/src/ddo/Metadata.ts index 90b48326..425592b8 100644 --- a/src/ddo/Metadata.ts +++ b/src/ddo/Metadata.ts @@ -1,26 +1,127 @@ export interface MetadataAlgorithm { + /** + * Language used to implement the software. + * @type {string} + */ language?: string + + /** + * Version of the software preferably in SemVer notation. + * @type {string} + */ version?: string + + /** + * Object describing the Docker container image. + * @type {Object} + */ container: { + /** + * The command to execute, or script to run inside the Docker image. + * @type {string} + */ entrypoint: string + + /** + * Name of the Docker image. + * @type {string} + */ image: string + + /** + * Tag of the Docker image. + * @type {string} + */ tag: string + + /** + * Checksum of the Docker image. + * @type {string} + */ checksum: string } } export interface Metadata { + /** + * Contains the date of publishing in ISO Date Time + * @type {string} + */ created: string + + /** + * Contains the the date of last update in ISO Date Time + * @type {string} + */ updated: string + + /** + * Descriptive name or title of the asset. + * @type {string} + */ name: string + + /** + * Details of what the resource is. + * @type {string} + */ description: string + + /** + * Asset type. Includes "dataset" (e.g. csv file), "algorithm" (e.g. Python script). + * Each type needs a different subset of metadata attributes. + * @type {'dataset' | 'algorithm'} + */ type: 'dataset' | 'algorithm' + + /** + * Name of the entity generating this data (e.g. Tfl, Disney Corp, etc.). + * @type {string} + */ author: string + + /** + * Short name referencing the license of the asset. + * If it’s not specified, the following value will be added: “No License Specified”. + * @type {string} + */ license: string + + /** + * Mapping of URL strings for data samples, or links to find out more information. + * Links may be to either a URL or another asset. + * @type {string[]} + */ links?: string[] + + /** + * Mapping of URL strings for data samples, or links to find out more information. + * Links may be to either a URL or another asset. + * @type {string[]} + */ tags?: string[] + + /** + * The party holding the legal copyright. Empty by default. + * @type {string} + */ copyrightHolder?: string + + /** + *The language of the content. Use one of the language codes from the IETF BCP 47 standard + * @type {string} + */ contentLanguage?: string + + /** + * Information about asset of typealgorithm + * @type {MetadataAlgorithm} + */ algorithm?: MetadataAlgorithm + + /** + * Stores additional information, this is customizable by publisher + * @type {any} + */ additionalInformation?: any } diff --git a/src/ddo/Service.ts b/src/ddo/Service.ts index 0ba45317..12922209 100644 --- a/src/ddo/Service.ts +++ b/src/ddo/Service.ts @@ -1,29 +1,139 @@ export interface PublisherTrustedAlgorithm { + /** + * The DID of the algorithm which is trusted by the publisher. + * @type {string} + */ did: string + + /** + * Hash of algorithm’s files section. + * @type {string} + */ filesChecksum: string + + /** + * Hash of algorithm’s metadata.algorithm.container section. + * @type {string} + */ containerSectionChecksum: string } export interface ServiceComputeOptions { + /** + * Namespaced used for the compute job. + * @type {string} + */ namespace: string + + /** + * Maximum number of CPUs allocated for a job + * @type {number} + */ cpu?: number + + /** + * Maximum number of GPUs allocated for a job + * @type {number} + */ gpu?: number + + /** + * Type of GPU (if any) + * @type {string} + */ gpuType?: string + + /** + * Maximum amount of memory allocated for a job. + * You can express memory as a plain integer or as a fixed-point number using one of these suffixes: E, P, T, G, M, k. + * You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki. + * For example, the following represent roughly the same value: 128974848, 129e6, 129M, 123Mi + * @type {string} + */ memory?: string + + /** + * Amount of disk space allocated. + * You can express it as a plain integer or as a fixed-point number using one of these suffixes: E, P, T, G, M, k. + * You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki. + * @type {string} + */ volumeSize?: string + + /** + * If true, any passed raw text will be allowed to run. + * Useful for an algorithm drag & drop use case, but increases risk of data escape through malicious user input. + * Should be false by default in all implementations. + * @type {boolean} + */ allowRawAlgorithm: boolean + + /** + * If true, the algorithm job will have network access. + * @type {boolean} + */ allowNetworkAccess: boolean + + /** + * If empty, then any published algorithm is allowed. + * Otherwise, only published algorithms by some publishers are allowed + * @type {string[]} + */ publisherTrustedAlgorithmPublishers: string[] + + /** + * If empty, then any published algorithm is allowed. (see below) + * @type {PublisherTrustedAlgorithm[]} + */ publisherTrustedAlgorithms: PublisherTrustedAlgorithm[] } export interface Service { + /** + * Type of service (access, compute, wss. + * @type {string} + */ type: 'access' | 'compute' | string + + /** + * Encrypted file URLs. + * @type {string} + */ files: string + + /** + * Datatoken address + * @type {string} + */ datatokenAddress: string + + /** + * Provider URL (schema + host). + * @type {string} + */ serviceEndpoint: string + + /** + * Describing how long the service can be used after consumption is initiated. + * @type {string} + */ timeout: string + + /** + * Service friendly name + * @type {string} + */ name?: string + + /** + * Service description + * @type {string} + */ description?: string + + /** + * If service is of typecompute, holds information about the compute-related privacy settings & resources. + * @type {string} + */ compute?: ServiceComputeOptions } diff --git a/src/ddo/index.ts b/src/ddo/index.ts index 4bd3a54b..06eb4fc6 100644 --- a/src/ddo/index.ts +++ b/src/ddo/index.ts @@ -1 +1,5 @@ export * from './DDO' +export * from './Asset' +export * from './Service' +export * from './Credentials' +export * from './Metadata'