Skip to content

Feature request: /// @prismabox.orderby.hide to restrict generated ModelOrderBy schemas #53

@tsegreto

Description

@tsegreto

Prismabox generates ModelOrderBy schemas (e.g. PostOrderBy). In real APIs, we often want to expose a restricted set of sortable fields (e.g. public sortBy) and avoid exposing internal-only fields.

Today, we end up hand-maintaining a whitelist TypeBox schema (often a verbose Type.Union([...Type.Literal(...)])), which is:

  • repetitive
  • easy to get out of sync with model changes
  • hard to standardize across many models

Feature request (preferred): /// @prismabox.orderby.hide

Add a new annotation that hides fields only from generated ModelOrderBy schemas:

model Endpoint {
  id        String   @id @default(cuid())
  name      String
  type      String

  /// @prismabox.orderby.hide
  internalNotes String?

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}

Expected behavior

  • EndpointOrderBy should not include internalNotes.
  • Other generated schemas (e.g. EndpointPlain) remain unchanged.

This follows the same ergonomics as existing Prismabox annotations like @prismabox.hide, @prismabox.input.hide, etc., but scoped specifically to order-by generation.

Optional extensions (nice-to-have)

If you think it fits the project, this could also drive generation of a “public” scalar-field schema used in query params (e.g. sortBy, distinct), derived from the same rules:

  • EndpointScalarFieldEnumPublic (or similar)

But the core request is simply: support hiding fields from ModelOrderBy output.

Alternatives considered

  • Manual Type.Union([Type.Literal(...) ...]) allowlists in application code.
  • Deriving allowed fields from generated model schemas (e.g. Type.KeyOf(Type.Pick(...))).

Both work, but neither keeps the policy in schema.prisma nor matches the annotation-based workflow Prismabox already uses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions