Manta Developers
GitHub
Menu

Generate schemas

Read a datastore's SHACL shapes and write LDKit schemas.

What it is

@manta-eu/codegen reads the SHACL shapes in a datastore and writes LDKit schemas into your project. The reading hooks take those schemas. How to use them is on Schemas and LDKit.

Import

The package provides the manta-codegen command:

pnpm add @manta-eu/codegen

Example

Sign in once. The login is stored for all Manta CLIs. Then generate the schemas for your datastore:

pnpm manta-codegen login
pnpm manta-codegen generate --datastore your-datastore --out ./.ldkit

Request

login, status, and logout take --keycloak-url, --keycloak-realm, and --client-id. login also takes --use-device-code, which asks for a one-time code when a browser redirect is unavailable. With no flags the commands target hiremanta.com production: Keycloak at https://auth.hiremanta.com, realm hiremanta-com. The client defaults to <realm>-cli.

generate reads the shapes and writes the schemas.

  • --datastore <id> is required.
  • --out <dir> defaults to ./.ldkit.
  • --api-url <url> defaults to https://app.hiremanta.com.
  • --keycloak-url <url> defaults to https://auth.hiremanta.com.
  • --keycloak-realm <realm> defaults to hiremanta-com.
  • --client-id <id> defaults to <realm>-cli.
  • --scope <scope> sets the scope of a service account token.
  • --use-device-code uses a one-time code when a login is needed.

generate signs in on its own when nothing is stored and a terminal is attached. With no terminal and no stored login, it fails and names the login command.

In CI, set MANTA_CLIENT_SECRET to the secret of the realm’s manta-codegen client. The CLI then asks for a service account token, and --client-id defaults to manta-codegen. The secret is an environment variable. --scope narrows that token.

Response

The output directory holds one .ts file per namespace, plus namespaces.ts and an index.ts that re-exports them. A run deletes the .ts files already in --out and writes the new set, and leaves every other file in the directory alone. Re-run it when the shapes change.

On stderr the CLI prints the vocabulary base and the class count for each namespace.