ErrorsStandard library · rule
type.standard_exists
You declared a type with the same fields as a standard type, such as a start and an end, under a name of your own.
Area 19, Standard library; declinable; the next step is usually the agent's.
Why Jadpo refuses it
A standard type, such as InstantRange or Point, has one way to be
built, one shape in JSON and one in storage. A declaration with only its
fields, by their common names and built on the same types, is that type
under another name. Two declarations of one shape disagree on names and
meaning, and every package and app that meets both has to convert
between them.
Jadpo matches by shape, so it can be wrong: a type can mean something else while having the same fields. That is a judgement call, so you can decline it with a reason, which review reads.
What it looks like
main.jadpo:
/// When a room is booked, from its start to its end.type Booking = Object { starts_at: Instant ends_at: Instant}
error Booking is the standard InstantRange under another name
--> main.jadpo:2:6
|2 | type Booking = Object { | ^^^^^^^ a start and an end
- reason
Bookinghas only a start (starts_at) and an end (ends_at), each built onInstant, which is the standardInstantRange. Declarations of one shape under different names disagree on names and meaning, and every package and application has to convert between them; the standard type has one construction, one wire shape and one storage shape.- next
- Run
jadpo fix Booking swapto useInstantRangewhereBookingis used, then convert at the edge where data arrives in another shape, or writedecline type.standard_exists: "<why>"above it if this is deliberate (agent) - rule
- type.
standard_ exists - help
- https://jadpo.
dev/docs/errors/type. standard_ exists
(agent) at the end of the next: line means your coding agent can make
the fix itself.
A latitude and a longitude, by their common names, are the standard
Point, so a van's last position is refused too.
main.jadpo:
/// Where a delivery van was when its tracker last reported.type VanPosition = Object { lat: Decimal lng: Decimal}
error VanPosition is the standard Point under another name
--> main.jadpo:2:6
|2 | type VanPosition = Object { | ^^^^^^^^^^^ a latitude and a longitude
- reason
VanPositionhas only a latitude (lat) and a longitude (lng), each built onDecimalorInt, which is the standardPoint. Declarations of one shape under different names disagree on names and meaning, and every package and application has to convert between them; the standard type has one construction, one wire shape and one storage shape.- next
- Run
jadpo fix VanPosition swapto usePointwhereVanPositionis used, then convert at the edge where data arrives in another shape, or writedecline type.standard_exists: "<why>"above it if this is deliberate (agent) - rule
- type.
standard_ exists - help
- https://jadpo.
dev/docs/errors/type. standard_ exists
A list of points is either the standard LineString or a Polygon's
ring. Only your app knows which, so the error names both.
main.jadpo:
/// A van's round, stop to stop, as its tracker sends it.type VanRound = Object { coordinates: List<Point>}
error VanRound is the standard LineString or Polygon under another name
--> main.jadpo:2:6
|2 | type VanRound = Object { | ^^^^^^^^ a list of points
- reason
VanRoundhas only a list of points (coordinates), each aPoint, which is the standardLineStringorPolygon. Declarations of one shape under different names disagree on names and meaning, and every package and application has to convert between them; the standard type has one construction, one wire shape and one storage shape.- next
- Run
jadpo fix VanRound swapto useLineStringwhereVanRoundis used, or usePolygonif that is what it means, then convert at the edge where data arrives in another shape, or writedecline type.standard_exists: "<why>"above it if this is deliberate (agent) - rule
- type.
standard_ exists - help
- https://jadpo.
dev/docs/errors/type. standard_ exists
How to fix it
The question is whether your type means what the standard type means.
If it means the same thing, swap it for the standard type:
jadpo fix Booking swapThe declaration is removed, and every place that used Booking now uses
InstantRange, with its fields read by InstantRange's names, such as
start. Where data arrives in another shape, such as a provider's
starts_at, convert it at the edge where it arrives. A type that is
already stored, or in an API's record, also gets the data migration, and
the change goes through review as any API or data change does.
If it means something else, keep it, and write a decline line with the reason directly above the declaration. main.jadpo becomes:
/// A shift as the rota plans it, before anyone has worked it.decline type.standard_exists: "Planned hours on the rota, not a range anyone has worked"type PlannedShift = Object { starts_at: Instant ends_at: Instant}
The type keeps its own name and shape. jadpo approval lists every
decline with its reason, so a reviewer sees why it isn't the standard
type.
Related
Markdown for agents: /docs/errors/type.standard_exists.md.Built from Jadpo main at aee2e8f.