mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
chore: auto-fix lint & formatting [skip ci]
This commit is contained in:
parent
a77ac8ad91
commit
df16dc94f7
17 changed files with 142 additions and 125 deletions
|
|
@ -241,7 +241,7 @@ export function evaluateFilterNode(
|
|||
export function explainFilter(filter: Filter): string {
|
||||
const patterns = toPatterns(filter);
|
||||
const value = patterns.map((m) => JSON.stringify(m)).join(" or ");
|
||||
const label = filter.type === "field" ? filter.path ?? "field" : filter.type;
|
||||
const label = filter.type === "field" ? (filter.path ?? "field") : filter.type;
|
||||
const op = filter.op ?? "eq";
|
||||
let base: string;
|
||||
if (filter.type === "keyword") {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ interface D1FragmentRow {
|
|||
|
||||
export async function loadFragments(db: D1Database): Promise<NamedFragment[]> {
|
||||
try {
|
||||
const stmt = db.prepare(
|
||||
"SELECT id, group_id, name, node FROM d1_fragments ORDER BY id",
|
||||
);
|
||||
const stmt = db.prepare("SELECT id, group_id, name, node FROM d1_fragments ORDER BY id");
|
||||
if (typeof stmt.all !== "function") return [];
|
||||
const { results } = await stmt.all<D1FragmentRow>();
|
||||
if (!results || results.length === 0) return [];
|
||||
|
|
@ -35,10 +33,7 @@ export async function loadFragments(db: D1Database): Promise<NamedFragment[]> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function saveFragments(
|
||||
db: D1Database,
|
||||
fragments: NamedFragment[],
|
||||
): Promise<void> {
|
||||
export async function saveFragments(db: D1Database, fragments: NamedFragment[]): Promise<void> {
|
||||
const now = Date.now();
|
||||
const statements: D1PreparedStatement[] = [
|
||||
db.prepare("DELETE FROM d1_fragments"),
|
||||
|
|
|
|||
|
|
@ -151,14 +151,7 @@ export interface Group {
|
|||
logTarget?: RouteTarget;
|
||||
}
|
||||
|
||||
export type FilterType =
|
||||
| "event"
|
||||
| "repo"
|
||||
| "actor"
|
||||
| "action"
|
||||
| "branch"
|
||||
| "keyword"
|
||||
| "field";
|
||||
export type FilterType = "event" | "repo" | "actor" | "action" | "branch" | "keyword" | "field";
|
||||
|
||||
export type FilterOp =
|
||||
| "eq"
|
||||
|
|
|
|||
|
|
@ -37,8 +37,29 @@ import { getTenantSecret, setTenantSecret, deleteTenantSecret } from "./tenants"
|
|||
import { cfEnv } from "../cf";
|
||||
import { log } from "../lib/log";
|
||||
|
||||
const VALID_FILTER_TYPES = new Set(["event", "repo", "actor", "action", "branch", "keyword", "field"]);
|
||||
const VALID_OPS = new Set(["eq", "ne", "contains", "startsWith", "endsWith", "regex", "gt", "gte", "lt", "lte", "in", "exists"]);
|
||||
const VALID_FILTER_TYPES = new Set([
|
||||
"event",
|
||||
"repo",
|
||||
"actor",
|
||||
"action",
|
||||
"branch",
|
||||
"keyword",
|
||||
"field",
|
||||
]);
|
||||
const VALID_OPS = new Set([
|
||||
"eq",
|
||||
"ne",
|
||||
"contains",
|
||||
"startsWith",
|
||||
"endsWith",
|
||||
"regex",
|
||||
"gt",
|
||||
"gte",
|
||||
"lt",
|
||||
"lte",
|
||||
"in",
|
||||
"exists",
|
||||
]);
|
||||
const ID_RE = /^[a-z0-9][a-z0-9-]*$/;
|
||||
const HOST_RE =
|
||||
/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/;
|
||||
|
|
@ -1175,9 +1196,7 @@ export async function adminGroupFragmentsPut(
|
|||
}
|
||||
|
||||
/** POST /admin/api/test-match */
|
||||
export async function adminApiTestMatch(
|
||||
event: H3Event,
|
||||
): Promise<Record<string, unknown>> {
|
||||
export async function adminApiTestMatch(event: H3Event): Promise<Record<string, unknown>> {
|
||||
await requireAnyAccess(event);
|
||||
const body = await readJsonBody(event);
|
||||
if (!body) return respondError(event, 400, "Invalid JSON body");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue