feat: Add banner api calls and evaluate banner display rule sets locally (#7087)

* scaffold banner api calls

* feat: add basic json rules local evaludation

* use another way to fetch ide name and version

* refine rules as well as rules evaluations in BannerService

* refactor: refactor BannerService so it is unit testable

* feat: add tests to banner service

* refactor: use separate initialize and get for banner service

* refactor: use Logger.error to log errors

* refactor: rename personal to personal only

* fix: move import to the top

* fix: remove unnecessary  wrapper

* move banner initialization to common.ts

* fix test

* fix: move import statement to the top in common.ts

* fix: remove feature targeting from rulesets

* fix: remove this._controller check in BannerService

* fix: add getProviderName in AuthService

* fix: include the owner role, treat it same as admin in applying banner rules
This commit is contained in:
Zhongying Qiao authored and GitHub committed 2025-10-29 14:03:33 -07:00
1 parent f12b5a1573
commit ac81aeaf4e
5 files changed
+1167

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
/**
* Banner message types for Cline extension
*/
export type BannerSeverity = "info" | "success" | "warning"
export type BannerPlacement = "top" | "bottom"
export interface Banner {
id: string
titleMd: string
bodyMd: string
severity: BannerSeverity
placement: BannerPlacement
rulesJson: string
activeFrom?: string
activeTo?: string
}
export interface BannersResponse {
data: {
banners: Banner[]
}
}
/**
* Audience targeting options
*/
export type BannerAudience = "all" | "team admin only" | "team members" | "personal only"
/**
* Rules that can be evaluated for banner targeting
*/
export interface BannerRules {
/** Target specific IDEs (e.g., "vscode", "jetbrains") */
ide?: string[]
/** Target specific auth providers (e.g., "firebase", "workos") */
auth?: string[]
/** Target employees only */
employee_only?: boolean
/** Target users with specific API providers (e.g., "anthropic", "openai") */
providers?: string[]
/** Target specific audience segment */
audience?: BannerAudience
}