mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-23 00:21:28 +00:00
feat(filters): JSONPath field filters, operators, AST groups, fragments, and test-match
Add a field filter type reading any payload value by JSONPath with array expansion, 12 comparison operators (eq/ne/contains/startsWith/endsWith/regex/gt/gte/lt/lte/in/exists), a visual AST builder (all/any/not) in the route editor, chip-based multi-value input, a stateless POST /admin/api/test-match dry-run, and named filter fragments stored in D1 (d1_fragments, migration 0010) inlined into route ASTs on insert.
This commit is contained in:
parent
c955db03c3
commit
c090281cb2
30 changed files with 1793 additions and 422 deletions
|
|
@ -1,14 +1,31 @@
|
|||
import * as v from "valibot";
|
||||
import type { Group, Route } from "../types";
|
||||
import type { FilterNode, Group, Route } from "../types";
|
||||
import { log } from "../lib/log";
|
||||
import { explainFilterNode } from "../events/filter-ast";
|
||||
|
||||
export const CONFIG_SCHEMA_VERSION = 1;
|
||||
|
||||
export const filterSchema = v.object({
|
||||
type: v.picklist(["event", "repo", "actor", "action", "branch", "keyword"]),
|
||||
match: v.union([v.string(), v.array(v.string())]),
|
||||
type: v.picklist(["event", "repo", "actor", "action", "branch", "keyword", "field"]),
|
||||
match: v.optional(v.union([v.string(), v.array(v.string())])),
|
||||
exclude: v.optional(v.boolean()),
|
||||
path: v.optional(v.string()),
|
||||
op: v.optional(
|
||||
v.picklist([
|
||||
"eq",
|
||||
"ne",
|
||||
"contains",
|
||||
"startsWith",
|
||||
"endsWith",
|
||||
"regex",
|
||||
"gt",
|
||||
"gte",
|
||||
"lt",
|
||||
"lte",
|
||||
"in",
|
||||
"exists",
|
||||
]),
|
||||
),
|
||||
});
|
||||
|
||||
export const routeTargetSchema = v.object({
|
||||
|
|
@ -19,7 +36,7 @@ export const routeTargetSchema = v.object({
|
|||
topicId: v.optional(v.string()),
|
||||
});
|
||||
|
||||
export const filterNodeSchema = v.lazy(() =>
|
||||
export const filterNodeSchema: v.GenericSchema<FilterNode> = v.lazy(() =>
|
||||
v.union([
|
||||
filterSchema,
|
||||
v.object({ all: v.array(filterNodeSchema) }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue