Skip to content

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.

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
manifest/queries.ts
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 package reference in a document must name a declared dependency.
  • Parameter labels follow the RyotQL parameter label rules.

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
  • defineRecipe omits a query whose value is undefined from the document and maps it as undefined. Use that for disabled comparisons instead of always-false predicates.
  • Read projection status from eventStream rows 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/schema and take the ResolvedReportingSelection that 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.

@ryot-app/plugin-kit/operations provides an Effect-based typed operation invoker.

  • defineOperationRecipe pins the package ID, operation slug, and input/output Effect Schemas.
  • invokeOperationRecipe encodes the input, calls the supplied transport, and decodes the output.
shared/note-operations.ts
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.

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.
manifest/plugin.ts
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 use defineEntityPresentation({ prepare, component, entity? }) from the client SDK.

  • The optional entity pair 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.