[data-reveal]{opacity:1!important;transform:none!important}
DocumentationInterface registry

Interface registry

List interfaces and their implementations in the interface registry so the AntelopeJS CLI can find them.

What the interface registry is

The interface registry is a git repository that lists the available interfaces and the modules that implement them. The AntelopeJS CLI reads it to help developers find and install modules.

Listing an interface is optional. Modules and interfaces work without a registry entry. The registry adds two CLI features:

  • ajs project modules install finds the interface dependencies in your project that no module implements, and adds an implementation listed in the registry.
  • ajs module init offers the registry's featured interfaces when it creates a module, and adds the ones you pick to the module's dependencies.
Note

The registry does not host code. It stores only metadata, such as descriptions and source locations. The interface packages and the implementing modules live on npm, in git repositories, or on local paths.

Registry structure

The registry has a manifest.json at its root and one directory per interface under interfaces/. Each interface directory holds a manifest.json that describes the interface and lists its implementations.

text
manifest.json
interfaces/
├── auth/
│   └── manifest.json
├── database/
│   └── manifest.json
└── api/
    └── manifest.json

The root manifest.json maps each interface package name to its directory under interfaces/. Its starredInterfaces list names the directories that ajs module init offers. The same file also lists the templates for ajs module init and ajs project init.

manifest.json (root) json
{
  "interfaces": {
    "@antelopejs/interface-api": "api",
    "@antelopejs/interface-auth": "auth",
    "@antelopejs/interface-database": "database"
  },
  "starredInterfaces": ["api", "auth", "database"]
}

AntelopeJS maintains the official registry at https://github.com/AntelopeJS/interfaces.git. Organizations can also host private registries for internal interfaces.

Interface manifest format

Each interface's manifest.json describes the interface and lists the modules that implement it.

interfaces/users/manifest.json json
{
  "description": "User management interface",
  "package": "@your-org/interface-users",
  "modules": [
    {
      "name": "user-module-mongodb",
      "source": {
        "type": "package",
        "package": "@your-org/user-mongodb",
        "version": "1.0.0"
      }
    }
  ]
}
FieldDescription
descriptionShort summary of what the interface provides
packagenpm package of the interface, which ajs module init adds as a dependency
modulesList of modules that implement this interface
modules[].nameName of the implementing module, shown when the CLI asks you to choose
modules[].sourceModule source, with the same fields as a source in antelope.config.ts

The modules array can list several implementations. If it lists one, ajs project modules install selects it without asking. If it lists more than one, the CLI asks you to choose, and --yes selects the first.

Add an interface to the registry

To list an interface or add an implementation, open a pull request against the registry repository.

Create or update the manifests

If the registry has no entry for your interface yet, add a directory under interfaces/ with a manifest.json, and map the interface package name to that directory in the root manifest.json. If the interface already has a manifest, add your module to its modules array.

interfaces/payment/manifest.json json
{
  "description": "Payment processing interface",
  "package": "@your-org/interface-payment",
  "modules": [
    {
      "name": "payment-stripe",
      "source": {
        "type": "package",
        "package": "@your-org/payment-stripe",
        "version": "1.0.0"
      }
    }
  ]
}

Make your module available

Publish the implementing module to npm, or make it available in a git repository. The registry points to your module's source, and developers download the module from there.

Submit a pull request

Open a pull request against the registry repository with your manifest changes. The repository maintainers review the manifests before they merge.

Use a custom registry

An organization can host a private registry for internal interfaces that do not belong in the official catalog.

terminal
ajs config set git https://github.com/your-org/your-interfaces.git

The CLI then reads your repository for interface discovery. The repository must have the same layout: a root manifest.json and one directory per interface, each with its own manifest.json. To use another registry for a single command, pass --git <url> or set ANTELOPEJS_GIT.

Tip

A private registry can live on any git host. For a repository that requires authentication, use an SSH URL or an access token.

How the CLI uses the registry

The registry drives the ajs project modules install command. The command finds the interfaces your project needs but no module implements, and adds a module for each.

terminal
ajs project modules install

The command runs these steps:

  1. It reads the project configuration for each environment, or for the one that --env names.
  2. It lists the interface packages in your modules' dependencies and optionalDependencies that no loaded module implements. A standalone interface is not on this list.
  3. It looks up each package name in the registry's root manifest.json and reads the implementations from that interface's manifest.
  4. It selects an implementation for each interface, and asks you to choose when there are several.
  5. It downloads each selected module and adds it to your project's antelope.config.ts.

The next time you start the project, the core loads the new modules, and the interface calls in your existing modules reach the new implementations. When the registry lists no implementation for an interface, the command prints a warning and leaves that import unresolved.