Skip to content
LogoLogo

TypeScript

Module format, type resolution and the gotchas worth knowing

nautilus is written in TypeScript and ships its own declarations — there is no @types/deltadao__nautilus to install. This page covers the setup that is not obvious.

Requirements

Node22 or later (engines.node: ">=22")
Module formatESM only
TypeScript5.x, with moduleResolution set to nodenext or bundler
Peers@oceanprotocol/lib ^9, ethers ^6

ESM only

v2 dropped the CommonJS build. The package exposes a single entry point:

package.json
{
  "type": "module",
  "exports": {
    ".": {
      "types": "./_types/index.d.ts",
      "import": "./_esm/index.js"
    }
  }
}

Two consequences:

  • Your own package needs "type": "module", or the files importing nautilus need the .mts extension. require('@deltadao/nautilus') will not work.
  • There are no deep import paths. Everything is imported from the package root; anything not re-exported from the root is not part of the public API.
import { Nautilus, AssetBuilder, getMetadata } from '@deltadao/nautilus'
import { AssetBuilder } from '@deltadao/nautilus/dist/AssetBuilder'

tsconfig

tsconfig.json
{
  "compilerOptions": {
    "module": "nodenext",
    "moduleResolution": "nodenext",
    "target": "es2022",
    "strict": true
  }
}

moduleResolution: "node" (the TypeScript 4 default) cannot read the exports map and will report that the module has no declarations.

DDO v5 types

@oceanprotocol/lib re-exports only the v4 DDO type, so the DDO v5 types come from @oceanprotocol/ddo-js. You do not install it: nautilus re-exports the v5 types its own API hands back, so they are imported from the package root like everything else:

import type { AssetV5, MetadataV5, ServiceV5,  } from '@deltadao/nautilus'

AlgorithmV5, CredentialV5, Compute, PublisherTrustedAlgorithms, VersionedDDO, IndexedMetadata, AssetDatatoken, Stats and ValidateMetadata come through the same door, alongside the v5 vocabulary nautilus declares or renames itself — License, RemoteObject, RemoteSource, LanguageValue and ConsumerParameterV5.

Type-only exports

Most configuration objects are interfaces rather than classes, so import them with import type when you only need the shape:

import type { AccessConfig, ComputeConfig, PublishResponse } from '@deltadao/nautilus'

The enums — ServiceTypes, FileTypes, CredentialListTypes, LifecycleStates, SsiMode, PolicyServerAction — are values, so they use a plain import.

Generic builders

ServiceBuilder is generic over its service type and file type. The parameters are what make addFile reject a file object the service cannot carry:

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

Two gotchas in the public surface