-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: support nested view groups via includes #10999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1227,6 +1227,31 @@ const folderSchema = Joi.object().keys({ | |
| ]).required(), | ||
| }).id('folderSchema'); | ||
|
|
||
| const viewGroupSchema = Joi.object().keys({ | ||
| name: Joi.string().required(), | ||
| title: Joi.string(), | ||
| description: Joi.string(), | ||
| // Legacy way of including views into a group, kept for backward compatibility. | ||
| views: Joi.alternatives([Joi.array().items(Joi.string().required()), Joi.func()]), | ||
| // Preferred way of including views (and nested view groups) into a group. | ||
| includes: Joi.alternatives([ | ||
| Joi.func(), | ||
| Joi.array().items( | ||
| Joi.alternatives([ | ||
| Joi.string().required(), | ||
| Joi.func(), | ||
| Joi.link('#viewGroupSchema'), // Can contain nested view groups | ||
| ]), | ||
| ), | ||
| ]), | ||
| fileName: Joi.string(), | ||
| }) | ||
| .oxor('views', 'includes') | ||
| .messages({ | ||
| 'object.oxor': 'View group must use either "views" or "includes", but not both' | ||
| }) | ||
| .id('viewGroupSchema'); | ||
|
Comment on lines
+1230
to
+1253
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] Because nested entries are validated through the same Side note: |
||
|
|
||
| const ViewDefaultFilterSchema = Joi.object().keys({ | ||
| member: Joi.func().required(), | ||
| operator: Joi.any().valid( | ||
|
|
@@ -1389,6 +1414,22 @@ export class CubeValidator implements CompilerInterface { | |
| return result; | ||
| } | ||
|
|
||
| public validateViewGroup(viewGroup, errorReporter: ErrorReporter) { | ||
| const options = { | ||
| nonEnumerables: true, | ||
| abortEarly: false, // This will allow all errors to be reported, not just the first one | ||
| }; | ||
| const result = viewGroupSchema.validate(viewGroup, options); | ||
|
|
||
| if (result.error != null) { | ||
| errorReporter | ||
| .inContext(`${viewGroup?.name} view group`) | ||
| .error(formatErrorMessage(result.error)); | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Validates that each cube appears only once within each root path in a view. | ||
| * This ensures that there is only one path to reach each cube within each root's join graph. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low]
{ ...group, views, includes }copies every property from the compiler-side group object into the meta response — including anything future code adds toCompiledViewGroup(e.g. internal fields). This is mostly fine today but is an easy place to leak future internal state. Consider an explicit projection:{ name, title, description, views, includes }.