Publishing
Without publishing data, applications and services a data economy could not exist. This process usually is about describing your asset in a standardized way, so that it can be displayed by catalogues or even be offered on marketplaces and sold to others.
Constructing a so called DDO (a DID document) can be challenging and time consuming, especially if you are just starting out. nautilus aims to significantly streamline this process by exposing two main builder classes that provide typed APIs to help you with this process.
The AssetBuilder
is the main class responsible for constructing the asset metadata and the ServiceBuilder
class uses the same pattern allowing to configure the services used within the asset's metadata.
AssetBuilder
Creating the builder is easy:
import { AssetBuilder } from '@deltadao/nautilus'
const assetBuilder = new AssetBuilder()
With this we can now continue to setup the metadata information for the asset:
import { AssetBuilder } from '@deltadao/nautilus'
const assetBuilder = new AssetBuilder()
assetBuilder
.setType('dataset')
.setName('My New Asset')
.setDescription('This is a publish asset building test using Nautilus')
.setAuthor('Company Ltd.')
The last step is to simply build()
the asset. This will return a correctly configured asset, ready to be published.
import { AssetBuilder } from '@deltadao/nautilus'
const assetBuilder = new AssetBuilder()
assetBuilder
.setType('dataset')
.setName('My New Asset')
.setDescription('This is a publish asset building test using Nautilus')
.setAuthor('Company Ltd.')
const asset = assetBuilder.build()
Note, that if required, there is a lot more that can be customized. To learn more about the API head over to the detailed AssetBuilder
documentation.
ServiceBuilder
Now, the asset above has some nice metadata setup, but we will not be able to really interact with it, unless we define the services it should expose.
This is where the ServiceBuilder
class comes in handy to specify the necessary information, such as the method used to access our data or application we want to publish.
We start by setting up the ServiceBuilder
we want to use:
import { UrlFile, FileTypes, ServiceTypes, ServiceBuilder } from '@deltadao/nautilus'
const serviceBuilder = new ServiceBuilder({
serviceType: ServiceTypes.ACCESS,
fileType: FileTypes.URL
})
NOTE: There are multiple supported ServiceTypes and FileTypes
Next, we declare the "file" we want to publish. This can follow multiple protocols, here we'll use a HTTP GET request:
import { UrlFile, FileTypes, ServiceTypes, ServiceBuilder } from '@deltadao/nautilus'
const serviceBuilder = new ServiceBuilder({
serviceType: ServiceTypes.ACCESS,
fileType: FileTypes.URL
})
const urlFile = {
type: 'url',
url: 'https://link.to/my/asset',
method: 'GET'
}
Finally, we add the required metadata and the file we created utilizing the builder pattern to then build the service:
import { UrlFile, FileTypes, ServiceTypes, ServiceBuilder } from '@deltadao/nautilus'
const serviceBuilder = new ServiceBuilder({
serviceType: ServiceTypes.ACCESS,
fileType: FileTypes.URL
})
const urlFile = {
type: 'url',
url: 'https://link.to/my/asset',
method: 'GET'
} satisfies UrlFile
const service = serviceBuilder
.setServiceEndpoint('https://provider.dev.pontus-x.eu')
.setTimeout(0)
.addFile(urlFile)
.setPricing({
type: 'free'
})
.build()
NOTE: The serviceEndpoint specified should point to the provider instance you want to be able to access your published data. Learn more.
If you want to learn more about the API and everything you can configure, head over to the detailed ServiceBuilder
documentation.
Publishing the Asset
Bringing everything together, in the last step we will now anchor the asset on a network of your choice using the publish function provided by nautilus:
const asset = assetBuilder.addService(service).build()
const result = await nautilus.publish(asset)
Diving Deeper
To learn about the different APIs and supported configurations follow the links below for in-detail documentations:
AssetBuilder
- API overview for building asset metadataServiceBuilder
- To build service MediaMetadata, you have access to a dedicated APIConsumerParameterBuilder
- Your service requires custom userdata to work? Head here for additional info.nautilus.publish()
- API documentation for thenautilus.publish()
call- Publish Examples - Code examples for advanced publishing processes.