diff options
| author | Andrii Mokhovyk <andrii.mokhovyk@gmail.com> | 2026-01-18 16:36:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-18 14:36:49 +0000 |
| commit | c56cf4e24f6134547fb9c5b58eb20840f5083e9e (patch) | |
| tree | ec9792cfcc6cbc6e45490d02e140b9241dca3fae /packages/shared | |
| parent | 1b98014d6cb0e3eb824d58ccbd35f39864e6ec88 (diff) | |
| download | karakeep-c56cf4e24f6134547fb9c5b58eb20840f5083e9e.tar.zst | |
feat(rules): add "Title Contains" condition to Rule Engine (#1670) (#2354)
* feat(rules): add "Title Contains" condition to Rule Engine (#1670)
* feat(rules): hide title conditions for bookmark created trigger
* fix typecheck
Diffstat (limited to 'packages/shared')
| -rw-r--r-- | packages/shared/types/rules.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/packages/shared/types/rules.ts b/packages/shared/types/rules.ts index 0daec524..fd99c266 100644 --- a/packages/shared/types/rules.ts +++ b/packages/shared/types/rules.ts @@ -59,6 +59,16 @@ const zUrlDoesNotContainCondition = z.object({ str: z.string(), }); +const zTitleContainsCondition = z.object({ + type: z.literal("titleContains"), + str: z.string(), +}); + +const zTitleDoesNotContainCondition = z.object({ + type: z.literal("titleDoesNotContain"), + str: z.string(), +}); + const zImportedFromFeedCondition = z.object({ type: z.literal("importedFromFeed"), feedId: z.string(), @@ -86,6 +96,8 @@ const nonRecursiveCondition = z.discriminatedUnion("type", [ zAlwaysTrueCondition, zUrlContainsCondition, zUrlDoesNotContainCondition, + zTitleContainsCondition, + zTitleDoesNotContainCondition, zImportedFromFeedCondition, zBookmarkTypeIsCondition, zHasTagCondition, @@ -105,6 +117,8 @@ export const zRuleEngineConditionSchema: z.ZodType<RuleEngineCondition> = zAlwaysTrueCondition, zUrlContainsCondition, zUrlDoesNotContainCondition, + zTitleContainsCondition, + zTitleDoesNotContainCondition, zImportedFromFeedCondition, zBookmarkTypeIsCondition, zHasTagCondition, @@ -244,6 +258,17 @@ const ruleValidaitorFn = ( return false; } return true; + case "titleContains": + case "titleDoesNotContain": + if (condition.str.length == 0) { + ctx.addIssue({ + code: "custom", + message: "You must specify a title for this condition type", + path: ["condition", "str"], + }); + return false; + } + return true; case "hasTag": if (condition.tagId.length == 0) { ctx.addIssue({ |
