Craticula IR Document reference
Generated from spec/ir.schema.json ($id https://schemas.pluries.dev/craticula/v1/ir.schema.json). Every member of the schema is listed with its type and description.
The canonical, vendor-neutral intermediate representation (IR) of a grid query: a filter tree, sort, group, aggregation and page spec. It describes structure only, so resource limits (maximum depth, leaves, in-values and page size) are left to the runtime validator, which must check them before or while it descends into the document. The $id path is versioned (/v1/), and a breaking revision is published at /v2/ next to this one, never over it.
Members #
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
filter | filterNode | The root of the filter tree. When absent, no filtering is applied. | ||
sort | array of sortItem (minItems 1) | The ordered sort spec, applied in array order with the first element as the primary sort key. Absent is the only way to say there is no sort, and an empty array is rejected (minItems: 1), so the document has one canonical form for cache-key hashing and byte-comparable fixtures. | ||
group | groupSpec | Which group columns are active and which groups the user has expanded. When absent, the query is not grouped. | ||
aggregations | array of aggregation (minItems 1) | The aggregation spec: pairs of a field and a function, computed for grouped rows. Absent is the only way to say there are no aggregations, and an empty array is rejected (minItems: 1) for the same canonical-form reason as sort. | ||
page | pageSpec | yes | The page spec: either a bounded row range or none, which means unpaginated output for export or streaming. |
Definitions #
filterNode #
A node of the filter tree. It is recursive by construction, so a runtime validator can walk it and count depth and leaves against the host's configurable limits (by default a maximum depth of 8 and 64 leaves). The schema sets no depth or item limit here because a fixed bound cannot vary per host.
Type: one of andNode, orNode, notNode, comparisonNode
andNode #
A logical AND of child nodes: every child must match.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "and" | yes | ||
nodes | array of filterNode (minItems 1) | yes | The child filter nodes, all of which must match. There is no maxItems here, because the maximum-leaves limit is a budget for the whole tree that the runtime validator enforces, and a per-node bound on this array could not express it. |
orNode #
A logical OR of child nodes: at least one child must match.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "or" | yes | ||
nodes | array of filterNode (minItems 1) | yes | Child filter nodes, at least one of which must match. See andNode.nodes for why there is no maxItems here. |
notNode #
A logical negation of a single child node.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "not" | yes | ||
node | filterNode | yes |
comparisonNode #
A leaf comparison against a single field, made of the field, an operator and a value or values. It is split into subschemas by operator category because the value shape differs: no value, one typed value, an array of typed values, or a typed from and to pair with inclusivity flags.
Type: one of unaryComparisonNode, binaryComparisonNode, setComparisonNode, rangeComparisonNode
unaryComparisonNode #
Comparisons that take no value: blank and notBlank (is or is not null or empty), and true and false (the field is true or false).
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "comparison" | yes | ||
field | fieldName | yes | ||
op | unaryOperator | yes |
binaryComparisonNode #
Comparison operators that take exactly one typed value.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "comparison" | yes | ||
field | fieldName | yes | ||
op | binaryOperator | yes | ||
value | typedValue | yes |
setComparisonNode #
The set-membership operators in and notIn, which take an array of typed values that may be empty. An empty in list matches no row, and an empty notIn list matches every row. There is no maxItems here, because the maximum number of in-values is a limit the host configures and the runtime validator is the only place that enforces it.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "comparison" | yes | ||
field | fieldName | yes | ||
op | setOperator | yes | ||
values | array of typedValue | yes |
rangeComparisonNode #
The inRange operator, with an explicit inclusivity flag for each boundary. The flags are never left implicit, because the defaults differ between filter types.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "comparison" | yes | ||
field | fieldName | yes | ||
op | const "inRange" | yes | ||
from | typedValue | yes | ||
to | typedValue | yes | ||
fromInclusive | boolean | yes | Whether the from boundary is inclusive. | |
toInclusive | boolean | yes | Whether the to boundary is inclusive. |
fieldName #
The logical field name (column id) as declared in the host's GridSchema allowlist. It is never a physical column or path, because the compiler resolves that mapping from the schema configuration. maxLength is only a size cap, and the allowlist check itself happens at runtime, because this schema cannot express it.
Type: string (minLength 1, maxLength 256)
unaryOperator #
Comparisons that take no value: blank and notBlank (is or is not null or empty), and true and false (the field is true or false).
Type: one of "blank", "notBlank", "true", "false"
binaryOperator #
The single-value part of the closed operator set.
Type: one of "eq", "neq", "gt", "gte", "lt", "lte", "contains", "notContains", "startsWith", "endsWith"
setOperator #
The value-array part of the closed operator set.
Type: one of "in", "notIn"
operator #
The full closed operator set of 17 operators and no others, which is the union of every category. It is provided for consumers that want one flat enum instead of the per-category subschemas that comparisonNode uses.
Type: one of "eq", "neq", "gt", "gte", "lt", "lte", "contains", "notContains", "startsWith", "endsWith", "blank", "notBlank", "in", "notIn", "inRange", "true", "false"
typedValue #
A fully typed IR value. Every value is tagged with its declared type, and compilers never guess a type from JSON's native number or string distinction. Frontend adapters turn AG Grid's string-typed wire values into one of these, using the field's declared type, before the IR is built.
Type: one of stringValue, int64Value, decimalValue, doubleValue, booleanValue, dateValue, datetimeValue, nullValue
stringValue #
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "string" | yes | ||
value | string (maxLength 8192) | yes | The string content. It is limited to 8192 characters, a structural size cap rather than one of the host-configurable limits (those cover tree shape and page size, not string length). Do not send longer text through a filter comparison. |
int64Value #
A 64-bit integer, kept separate from decimal and double and bounded to the signed 64-bit range so every port can round-trip it in a native int64 or long. The TypeScript port must read values beyond +/-2^53 as a bigint or a string, because JSON.parse loses precision there.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "int64" | yes | ||
value | integer (minimum -9223372036854775808, maximum 9223372036854775807) | yes |
decimalValue #
An arbitrary-precision decimal. It is carried as a numeric string, not a JSON number, to avoid floating-point round-trip loss.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "decimal" | yes | ||
value | string (maxLength 128, pattern "^-?[0-9]+(\\.[0-9]+)?$") | yes |
doubleValue #
An IEEE 754 double-precision floating-point number.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "double" | yes | ||
value | number | yes |
booleanValue #
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "boolean" | yes | ||
value | boolean | yes |
dateValue #
A local date with no time-of-day or zone part. format: date is only an annotation in the default draft 2020-12 meta-schema, and not every port's validator asserts it, so the pattern carries the real guarantee across languages. The format stays as a hint for tooling that does assert it.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "date" | yes | ||
value | string (format "date", pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}$") | yes |
datetimeValue #
An instant together with the time zone used to interpret it. The value is an ISO 8601 timestamp with an explicit offset or Z, and zone is an IANA time zone id that records the zone used to resolve the instant. See dateValue for why a pattern accompanies format here too.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "datetime" | yes | ||
value | string (format "date-time", pattern "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$") | yes | ||
zone | string (minLength 1, maxLength 64, pattern "^[A-Za-z0-9_+-]+(/[A-Za-z0-9_+-]+)*$") | yes | An IANA time zone id (e.g. 'Europe/Paris', 'UTC') — not allowlisted anywhere (unlike 'field'), so this shape constraint is the only structural guard against a malformed value reaching a dialect-specific zone clause (AT TIME ZONE / $dateTrunc.timezone / ES time_zone). |
nullValue #
The null value. It is different from the blank and notBlank operators, which handle nulls at the comparison-node level and are not a value.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
type | const "null" | yes |
groupSpec #
Describes how far the user has drilled into a grouped grid. groupCols lists the row-group columns and groupKeys the values already chosen, one per expanded level and in the same order, so it can never be longer than groupCols. If groupKeys is shorter, the query returns the next group level (the next group column plus aggregations) for rows matching those keys; if both have the same length, it returns the actual rows of that group.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
groupCols | array of fieldName (minItems 1, maxItems 64) | yes | The ordered list of row-group column field names, as configured on the grid. maxItems is only a size cap of 64, the default maximum number of leaves, because a groupSpec is as client-controlled as the filter tree and may reach a compiler without the runtime validator. A host that configures a smaller maximum still gets the tighter answer from the runtime validator. | |
groupKeys | array of typedValue (maxItems 64) | yes | The group key values already consumed by the drill-down so far, one per expanded group level, in groupCols order. Each key is a typed value, because it compiles into an equality predicate against its group column, and a drilled-into null group bucket is nullValue, not JSON null. maxItems repeats the cap of groupCols, because JSON Schema cannot express that this array is no longer than groupCols. |
setValuesSpec #
A request for the distinct values of one column, to fill an AG Grid set filter. It is a separate definition because the main query document requires page, while this request has no page, no sort and no aggregation; its limit is only a maximum. The request format is Craticula's own, because AG Grid Community defines none and leaves this to a host-supplied values callback.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
colId | fieldName | yes | The column whose distinct values are wanted. The result is the distinct values of this column, ordered by it, and any conditions the filter has on this same column are ignored. Because the client chooses it, it must be in the field allowlist in every mode, Lenient included. | |
searchPrefix | string (minLength 1, maxLength 8192) | The text typed into the set filter's own search box. It becomes an ordinary starts-with condition on colId, with the same case and escaping rules as a user's own prefix filter, and it stays even when every other condition on colId is dropped. Leave the property out for an empty search box (an empty string is rejected because it would match every row); the text is capped at the same length as a string value, and a prefix on a column not declared as a string is rejected at runtime, which this schema cannot express. | ||
limit | integer (minimum 1) | A client-requested cap on how many distinct values come back. It is never authoritative: the host's configured maximum always wins, and an absent value falls back to the host's default, so the compiled cap is the smaller of the requested limit (or the default) and the maximum. Exceeding the maximum is not a rejection, because the server clamps the value, and minimum: 1 is structural because a non-positive cap could never return a value. |
aggregation #
A single aggregation pair of a field and a function. In version 1 func is limited to sum, min, max, avg and count, and first and last are deliberately excluded and planned for version 2.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
field | fieldName | yes | ||
func | aggregationFunc | yes | ||
alias | string (minLength 1, maxLength 64, pattern "^[A-Za-z_][A-Za-z0-9_]*$") | An optional output key for the aggregated value, which defaults to a compiler-chosen name derived from the field and function when absent. Unlike field, the alias is not checked against the GridSchema allowlist, yet it lands in the generated query text as an identifier (such as SUM(x) AS <alias>, a $group output key or an Elasticsearch aggregation name). An identifier cannot be parameterized, so the identifier-safe pattern (a letter or underscore followed by letters, digits and underscores) is the only guard against injection through the alias in all four compilers. |
aggregationFunc #
The closed set of aggregation functions in version 1. first and last are deliberately excluded and planned for version 2.
Type: one of "sum", "min", "max", "avg", "count"
sortItem #
A single sort key. The position of nulls is always explicit in the IR and is never left to a backend's default ordering.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
field | fieldName | yes | ||
direction | sortDirection | yes | ||
nullsPosition | nullsPosition | yes |
sortDirection #
Type: one of "asc", "desc"
nullsPosition #
The explicit position of nulls, first or last. It is never inferred from the sort direction.
Type: one of "first", "last"
pageSpec #
Either a startRow and endRow row range, or the unpaginated none mode needed to compile a full export.
Type: one of rangePage, nonePage
rangePage #
A bounded row range that mirrors AG Grid's server-side row model startRow and endRow. endRow is exclusive, as in that model.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
mode | const "range" | yes | ||
startRow | integer (minimum 0) | yes | Zero-based inclusive start offset. | |
endRow | integer (minimum 0) | yes | The zero-based, exclusive end offset, so endRow - startRow is the requested page size. This schema cannot express the maximum page size (a host-configurable limit, so no fixed maximum belongs here) or the rule that endRow is at least startRow (a comparison between two properties, which JSON Schema cannot express). Both are left to the runtime validator, so do not assume structural validation enforces either one. |
nonePage #
Unpaginated mode: compile the full filtered and sorted result with no row-range clause. It is meant for streaming and export scopes, such as an export with exportScope: 'all'.
Type: object
| Member | Type | Required | Default | Description |
|---|---|---|---|---|
mode | const "none" | yes |