Skip to content

Commit

Permalink
feat: allow attaching meta to filter rule
Browse files Browse the repository at this point in the history
  • Loading branch information
lawvs committed Aug 10, 2024
1 parent 0ce4129 commit 744b13e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/seven-years-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fn-sphere/core": patch
---

Allow attaching meta to filter rule
6 changes: 5 additions & 1 deletion packages/core/src/filter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface SingleFilterInput {
*/
args?: unknown[];
invert?: boolean;
meta?: Record<string, unknown>;
}

export interface SingleFilter extends SingleFilterInput {
Expand All @@ -54,6 +55,7 @@ export interface FilterGroupInput {
op: "and" | "or";
conditions?: FilterRule[];
invert?: boolean;
meta?: Record<string, unknown>;
}

export interface FilterGroup extends FilterGroupInput {
Expand All @@ -68,9 +70,10 @@ export interface FilterGroup extends FilterGroupInput {
export type FilterRule = SingleFilter | FilterGroup;

export type StrictSingleFilter = Readonly<
Required<SingleFilter> & {
Required<Omit<SingleFilter, "meta">> & {
name: string;
path: FilterPath;
meta?: Record<string, unknown>;
}
>;
export type StrictFilterGroup = Readonly<{
Expand All @@ -82,6 +85,7 @@ export type StrictFilterGroup = Readonly<{
op: "and" | "or";
conditions: StrictFilterRule[];
invert: boolean;
meta?: Record<string, unknown>;
}>;

export type StrictFilterRule = StrictSingleFilter | StrictFilterGroup;

0 comments on commit 744b13e

Please sign in to comment.