Queries and recipes
Plugins read data with RyotQL documents built from shared recipes. This page covers the queries a plugin declares for assistants and other callers, the neutral recipe helpers available in shared code, typed operation recipes, and the field selections that feed entity cards and rows. For the query language itself, see the RyotQL API.
Declared queries
Section titled “Declared queries”Optional queries maps names to { title, description, document, entitlement? }.
| Field | Meaning |
|---|---|
title |
A short capitalized phrase, such as “Read journal”, that assistants and approval screens show to people |
description |
What the query reads and how to call it |
document |
A static PluginRyotQLDocument built from shared recipes |
entitlement |
Optional entitlement required to run it |
const reference = { kind: "self" } as const;
export const declaredQueries = { "workout-detail": { title: "Read workout", document: workoutDetailRecipe({ reference }).document, description: "Read one workout by entityId, including its recorded start and end times, notes, energy, and linked workout template.", },};- Build each static authored document from shared recipes. Declare runtime inputs as parameters and
send paging through request
pages. - Ingestion validates all authored branches and control targets against effective definitions.
- Runtime execution reads the persisted revision’s query section and resolves parameter values and source authority on the server.
- User calls identify the scoped package and declaration name. Pinned system scripts resolve their own declarations at their retained revision.
- Every
packagereference in a document must name a declared dependency. - Parameter labels follow the RyotQL parameter label rules.
Recipe helpers
Section titled “Recipe helpers”Shared recipes import their builders from @ryot-app/plugin-kit/ryotql. The shim exports query
builders and helpers, not application recipes.
| Helper | Purpose |
|---|---|
Query builders, defineRecipe |
Everything @ryot-app/ryotql exports |
IsoDateString |
Date codec |
| Event expressions | eventIsAfter, latestEventField, eventOrderAscending, eventOrderDescending |
withinPeriod |
A half-open reporting-period predicate that is empty for all time |
countAll, sumOf, countIf, NullableNumber |
Common aggregate measures and their codec |
projectionStatusMeasures, projectionProcessingState |
Derive one ProjectionProcessing ("ready" | "pending" | "failed") from an aggregate over event or eventStream rows |
projectionProcessing |
The same value as a correlated expression for row selections |
foldSubjectEventPredicate, foldEventImageSelection |
Read fold history; see Folds |
| Reporting helpers | reportingParameterFields, reportingPeriodPredicate and related builders |
Recipe rules
Section titled “Recipe rules”defineRecipeomits a query whose value isundefinedfrom the document and maps it asundefined. Use that for disabled comparisons instead of always-false predicates.- Read projection status from
eventStreamrows when a stream key covers the scope, since one stream row stands for all of its events. - Shared reporting recipes import the neutral helpers from
@ryot-app/plugin-kit/schemaand take theResolvedReportingSelectionthat the client query resolved with the supplied clock during execution. - Colocate result schemas, decoders and types with their recipes. Consumers never parse generic row values.
Operation recipes
Section titled “Operation recipes”@ryot-app/plugin-kit/operations provides an Effect-based typed operation invoker.
defineOperationRecipepins the package ID, operation slug, and input/output Effect Schemas.invokeOperationRecipeencodes the input, calls the supplied transport, and decodes the output.
import { defineOperationRecipe } from "@ryot-app/plugin-kit/operations";
export const deleteNoteRecipe = defineOperationRecipe({ packageId: PLUGIN_PACKAGE_ID, operationSlug: "exercise-note-delete", input: ExerciseNoteDeleteInput, output: ExerciseNoteOutput,});The same module provides operationJsonSchema for operation declarations; see
Operations.
Entity presentation sources
Section titled “Entity presentation sources”Each client.entities[slug] registration with a grid or list presentation declares
presentation: { entity, owner, ownerIncludes?, settings? }.
| Field | Rule |
|---|---|
entity |
RyotQL field selections rooted at table("entity", "entity"). Reads only public subject columns, without correlated queries, parameters, relationships or events. |
owner |
Field selections rooted at the same table. May use owner-scoped reads and nested includes. |
ownerIncludes |
Optional nested includes for the owner source |
settings |
true captures normalized plugin user settings, for owner scope only. Requires a userSettingsSchema. |
entities: { exercise: { detailPage: "exercise-detail", listPresentation: "entity-row", gridPresentation: "entity-card", presentation: { owner: presentationSource("exercise").fields, entity: entityPresentationSource("exercise").fields, }, },},- Reuse a shared selected source for its fields and client decoder.
- Definition-set validation checks complete projections during build and ingestion; no fields are silently removed.
Presentation exports
Section titled “Presentation exports”Presentation exports use defineEntityPresentation({ prepare, component, entity? }) from the client
SDK.
- The optional
entitypair renders the public source when it differs from the owner source. - Preparation is pure. It receives references, selected data and captured context.
- Share UI components between variants.
- Saved views declare table fields and selection controls; they do not embed card projections.