CLI interface · 0.8.1

CLI: operation access and read rules

Expose an external API and limit the returned root records and nested collections.

On this page

For interactive work, start with the corresponding Generator UI screen. This CLI reference supports scripts and repeatable operations; UI and CLI edit the same model.

Replace ENTITY_NAME, RELATED_ENTITY_NAME and VIRTUAL_ENTITY_NAME with technical names from your model. ENTITY_ROUTE is an API route, TABLE_NAME/JOIN_TABLE_NAME are SQL tables, and RELATION_NAME/COLLECTION_NAME are relationship names. They may differ from the entity name. Commands are templates: do not execute uppercase placeholders literally.

Access has three levels: whether an operation exists, who may invoke it and which records it returns. For example, external-list permission exposes a list, while readRule limits it to published records. A client filter does not replace a mandatory server rule.

Enable the required operations

admingen-cli --path ./docs-demo entity update ENTITY_NAME \
  --admin-list=true --admin-get=true --admin-delete=false \
  --external-list anonymous --external-get anonymous \
  --external-create off --external-update off --external-delete off
Entity add/update parameters Values Purpose
--create, --read, --update, --delete true/false Available model operations. Read includes list/get.
--admin-list, --admin-get, --admin-create, --admin-update, --admin-delete true/false Administrative API calls.
--external-list, --external-get, --external-create, --external-update, --external-delete off/authenticated/anonymous External API: disabled, requires authentication, or allowed without sign-in.
--list, --form true/false Generated screen availability; not server protection.

When creating a regular entity, admin access is allowed and external access is disabled. Update preserves omitted properties. A projection supports reads only. Inspect routes in Generated routes or OpenAPI after Generate.

A permission does not enable a disabled CRUD operation. First ensure the model itself supports the action.

Return only published records

There is no separate CLI flag for readRule. Configure the condition in Entity settings → Access or add it to an existing entity in .admingen/project.yaml:

access:
  external:
    list: anonymous
    get: anonymous
    create: off
    update: off
    delete: off
    readRule:
      field: status
      op: eq
      value: published

The example assumes ENTITY_NAME has an enum status with a published variant. When editing manually, preserve other access settings, especially admin. Validate the model, run Generate and update the backend normally.

External list/get applies the rule even without a URL filter. A client cannot request a broader set; a record rejected by the rule is also unreadable by ID. This readRule does not restrict the Admin API or write operations.

Separate conditions for the root, related entity and collection

Suppose the virtual source is ENTITY_NAME, with a belongsTo RELATION_NAME relationship and a selected COLLECTION_NAME collection. Conditions for the root and its related object belong in access.external.readRule:

readRule:
  all:
    - field: isVisible
      op: eq
      value: "true"
    - field: RELATION_NAME.status
      op: eq
      value: published

Item rules are configured separately on the selected collection in virtual.select. The selection fragment below requires the referenced fields to exist in your model:

- relation: COLLECTION_NAME
  collection:
    defaultLimit: 20
    maxLimit: 100
    orderBy:
      field: position
      direction: asc
    readRule:
      all:
        - field: isVisible
          op: eq
          value: "true"
        - field: title
          op: ne
          value: ""
  select:
    - field: id
    - field: title
      searchable: true
      filterable: true
    - field: position
      sortable: true

The response contains visible root records linked to published related records. Each contains visible items with a nonempty title, sorted by position. If no items match, the root record still returns with an empty collection.

In the UI, these conditions occupy separate entity blocks so parent filtering is not mixed with nested-record filtering.

Define groups and values

all combines conditions with AND, any with OR. A group may include conditions and other groups, up to8 levels and64 nodes. A regular condition contains field/op/value.

Values are strings, including numbers and booleans. ne with "" checks for an empty string, not null. Nullable fields support isNull/isNotNull without value.

Data type Supported comparisons
Text eq/ne/contains
Enum, UUID, bool eq/ne
Numbers and dates eq/ne and additionally lt/lte/gt/gte

A rule belongs to a specific entity or projection. It is not inherited from its source or relationship targets. Conditions in this version are constant: they cannot substitute the current user or time. searchable/filterable/sortable controls client query capabilities; readRule applies independently of them.

Apply settings

admingen-cli --path ./docs-demo plan
admingen-cli --path ./docs-demo generate --dry-run
admingen-cli --path ./docs-demo generate

Generate creates code but does not restart the running backend. After updating it, check the required responses. See application API, projection CLI and sign-in and access.

Public cache

Enable it in Access → External READ access → Cache public responses. For a manually edited manifest, use the entity's access.external settings:

cache:
  enabled: true
  ttlSeconds: 30

This supplements existing permissions rather than replacing access rules. Caching requires anonymous List or Get. After Generate, release the updated backend and Nginx. Complete behavior and content-update delay are described in public caching.