Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 27 additions & 24 deletions src/platform/packages/shared/kbn-es-query-server/src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,33 @@ const filterStateStoreSchema = schema.oneOf(
}
);

export const filterMetaSchema = schema.object({
alias: schema.maybe(schema.nullable(schema.string())),
disabled: schema.maybe(schema.boolean()),
negate: schema.maybe(schema.boolean()),
controlledBy: schema.maybe(
schema.string({ meta: { description: 'Identifies the owner the filter.' } })
),
group: schema.maybe(
schema.string({ meta: { description: 'The group to which this filter belongs.' } })
),
// field is missing from the Filter type, but is stored in SerializedSearchSourceFields
// see the todo in src/platform/packages/shared/kbn-es-query/src/filters/helpers/update_filter.ts
field: schema.maybe(schema.string()),
index: schema.maybe(schema.string()),
isMultiIndex: schema.maybe(schema.boolean()),
type: schema.maybe(schema.string()),
key: schema.maybe(schema.string()),
// We could consider creating FilterMetaParams as a schema to match the concrete Filter type.
// However, this is difficult because FilterMetaParams can be a `filterSchema` which is defined below.
// This would require a more complex schema definition that can handle recursive types.
// For now, we use `schema.any()` to allow flexibility in the params field.
params: schema.maybe(schema.any()),
value: schema.maybe(schema.string()),
});
export const filterMetaSchema = schema.object(
{
alias: schema.maybe(schema.nullable(schema.string())),
disabled: schema.maybe(schema.boolean()),
negate: schema.maybe(schema.boolean()),
controlledBy: schema.maybe(
schema.string({ meta: { description: 'Identifies the owner the filter.' } })
),
group: schema.maybe(
schema.string({ meta: { description: 'The group to which this filter belongs.' } })
),
// field is missing from the Filter type, but is stored in SerializedSearchSourceFields
// see the todo in src/platform/packages/shared/kbn-es-query/src/filters/helpers/update_filter.ts
field: schema.maybe(schema.string()),
index: schema.maybe(schema.string()),
isMultiIndex: schema.maybe(schema.boolean()),
type: schema.maybe(schema.string()),
key: schema.maybe(schema.string()),
// We could consider creating FilterMetaParams as a schema to match the concrete Filter type.
// However, this is difficult because FilterMetaParams can be a `filterSchema` which is defined below.
// This would require a more complex schema definition that can handle recursive types.
// For now, we use `schema.any()` to allow flexibility in the params field.
params: schema.maybe(schema.any()),
value: schema.maybe(schema.string()),
},
{ unknowns: 'allow' }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key change. These rest of the diff is formatting.

);

export const filterSchema = schema.object(
{
Expand Down