-
Notifications
You must be signed in to change notification settings - Fork 15
Description
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
EndpointOrderByshould not includeinternalNotes.- 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.