Skip to content
LogoLogo

ServiceBuilder

Builds one service on an asset. A service is what consumers actually order: it names an ocean-node, the files it serves, how long an order stays valid, and how it is paid for.

Instantiating

Two modes, chosen by the config you pass.

import { , ,  } from '@deltadao/nautilus'
 
const  = new <., .>({ 
  : .
}) 

In edit mode the builder loads the published service — its id, endpoint, timeout, compute options, consumer parameters, credentials, and the datatoken's name and symbol (recovered from the indexer's datatoken list, since they are not on the DDO's service object).

reset() returns to whichever state the constructor produced — including a loaded service. v1 discarded the loaded state, which made reset() unusable while editing.

The two type parameters

new <., .>({
  : .
})

ServiceTypes is ACCESS (download) or COMPUTE (run algorithms on the data without exposing it).

FileTypes picks which storage object addFile accepts:

. // { type: 'url', url, method, headers? }
. // { type: 'ipfs', hash }
. // { type: 'arweave', transactionId }
. // { type: 's3', s3Access: { ... } }
. // { type: 'ftp', url }
. // { type: 'nodePersistentStorage', bucketId, fileName }

A minimal service

const  = new <., .>({
  : .
})
  .('https://ocean-node.dev.pontus-x.eu') // required
  .('Access Service')
  .(86400)
  .({ : 'url', : 'https://data.example/x.csv', : 'GET' })
  .({ : 'free' }) // required for a new service
  .()

build() checks only what cannot be checked later: a new service needs pricing, and every service needs an endpoint. The name is defaulted rather than required, even though DDO v5 requires it.

Pricing

Required for a new service, because it needs its own datatoken. Blocked for a published one — a new pricing config mints a new datatoken, which changes the service id. Use nautilus.setServicePrice instead.

See setPricing.

Compute services

A COMPUTE service controls which algorithms may run against the data. The compute-only methods throw on an access service, naming the operation.

const  = new <., .>({
  : .
})
  .('https://ocean-node.dev.pontus-x.eu')
  .({ : 'url', : 'https://data.example/x.csv', : 'GET' })
  .({ : 'free' })
  .(false) 
  .(false) 
  .([{ : 'did:ope:926098d069b017dcf...' }]) 
  .()

Trusted algorithms are staged here and resolved to container and file checksums at publish time, so a publisher cannot swap the container afterwards. DDO v5 requires a serviceId per trusted algorithm, so serviceIds is finally honoured — see addTrustedAlgorithms.

Per-service gating

New in DDO v5: credentials sit on services as well as assets, so one service can be restricted while another stays open.

const  = new <., .>({
  : .
})
  .('https://ocean-node.dev.pontus-x.eu')
  .({ : 'url', : 'https://data.example/x.csv', : 'GET' })
  .({ : 'free' })
  .(., [ 
    { : 'VerifiableId', : 'jwt_vc_json' } 
  ]) 
  .()

See Credential-gated assets.

Attaching it to an asset

const  = new ()
  .('dataset')
  .('My Dataset')
  .('My Organisation')
  .() 
  .()

Method reference

Identity

setName · setDisplayName · setDescription · setState

Endpoint and files

setServiceEndpoint · addFile · setTimeout

Consumer parameters and schemas

addConsumerParameter · setDataSchema · setInputSchema · setOutputSchema · addAdditionalInformation

Pricing and datatoken

setPricing · setDatatokenData · setDatatokenNameAndSymbol

Compute — trusted algorithms

Compute services only; these throw on an access service.

addTrustedAlgorithms · removeTrustedAlgorithm · setAllAlgorithmsTrusted · setAllAlgorithmsUntrusted · addTrustedAlgorithmPublisher · removeTrustedAlgorithmPublisher · setAllAlgorithmPublishersTrusted · setAllAlgorithmPublishersUntrusted

Compute — job permissions

allowRawAlgorithms · allowAlgorithmNetworkAccess

Gating

addCredentialAddresses · addRequestCredentials

Building

build · reset