Replies: 3 comments 12 replies
-
if you call operands operands you should call operators operators (or operations, that also works) |
Beta Was this translation helpful? Give feedback.
-
The "type" fields currently denote different things. I would suggest to rename the different "types" to, e.g. "operator" and "filter". |
Beta Was this translation helpful? Give feedback.
-
In an in-person meeting @timakro, @enola-dkfz, and I discussed the proposal especially w.r.t. consumers of the AST. We have a slighly modified proposal, as stated below. We did not discuss empty queries, yet. We did not discuss naming of things (e.g., should it be "operands" or "children"...), but only focused on the structure of the AST. High level discussion points:
Please correct me if I missed something or messed something up :) // The @discriminator annotation tells ts-json-schema-generator to represent
// this type as a discriminated union in the generated JSON schema.
/** @discriminator type */
export type AstNode = AndOperator | OrOperator | NotOperator | NumericRangeFilter | DateRangeFilter | AnyFilter;
export type AndOperator = {
type: "AndOperator";
/** @minItems 1 */
operands: AstNode[];
}
export type OrOperator = {
type: "OrOperator";
/** @minItems 1 */
operands: AstNode[];
}
export type NotOperator = {
type: "NotOperator";
operand: AstNode;
}
export type NumericRangeFilter = {
type: "NumericRangeFilter";
key: string;
// The system could be used to include units of measurement, LOINC codes and so on.
system?: string;
// Using optionals for half open intervals is fine, however, at least one entry must be set
// Ranges are always specified to be inclusive
min?: number;
max?: number;
}
export type DateRangeFilter = {
type: "DateRangeFilter";
key: string;
// Note: System was removed here
// Note: The dates are now specified as "date-time"s as in RFC 3339 sec. 5.6.
// For querying, Lens should deduce the local timezone from the browser of the user
// Ranges are always specified to be inclusive
/** The earliest accepted date in YYYY-MM-DDTHH:MM:SSZ±OO format. @format date-time */
min?: string;
/**The latest accepted date in YYYY-MM-DDTHH:MM:SSZ±OO format. @format date-time */
max?: string;
}
// This Filter is used for checking set membership. Equality of conditions is a special case with
// only one entry in the "values" array.
export type AnyFilter = {
type: "AnyFilter";
key: string;
system?: string;
values: string[];
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey Lens Community,
we are proposing changes to the structure of the AST with the goal of making the TypeScript definitions in lens stricter and documenting the AST better. Consumers of the AST in strictly typed languages like Rust will benefit as well because they can parse the AST into the stricter typed and more fine-grained data structures, which reduces the need for manual validation in the codebase and benefits readability.
The TypeScript definition of the AST currently looks like this:
@patrickskowronekdkfz and I came up with the following in a call today:
An example in JSON as it would be sent over the wire:
Note that nothing here should be seen as set in stone and the final shape of the AST is still very much up for discussion. Features that the proposed representation has and we would like to keep include:
type
and variants are in CamelCase. This makes it very ergonomic to work with in TypeScript and also Rust's serde.AstBottomLayerValue
has been split into multiple types, meaning that nonsensical ASTs like{"type": "BETWEEN", "value": "a rock"}
can no longer be represented.We plan to add JSDoc to each node type to document its semantics. Personally I would hope to see the JSDoc converted to HTML at some point to provide as documentation to our users. Optionally we could automatically generate a JSON schema definition from TypeScript using ts-json-schema-generator like we will be doing for the catalogue soon. I've already added appropriate annotations (e.g.
@format date
) where constraints cannot be expressed in TypeScript.If you have other suggestions feel free to bring them into the discussion. We would introduce the AST Structure with the next major update of lens with milestone v0.5.
Beta Was this translation helpful? Give feedback.
All reactions