diff --git a/web/src/elements/Interface/BrandContextController.ts b/web/src/elements/Interface/BrandContextController.ts index 216d930bf0..ce47875443 100644 --- a/web/src/elements/Interface/BrandContextController.ts +++ b/web/src/elements/Interface/BrandContextController.ts @@ -1,23 +1,22 @@ import { EVENT_REFRESH } from "@goauthentik/authentik/common/constants"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { authentikBrandContext } from "@goauthentik/elements/AuthentikContexts"; +import type { ReactiveElementHost } from "@goauthentik/elements/types.js"; import { ContextProvider } from "@lit/context"; -import { ReactiveController, ReactiveControllerHost } from "lit"; +import type { ReactiveController } from "lit"; import type { CurrentBrand } from "@goauthentik/api"; import { CoreApi } from "@goauthentik/api"; import type { AkInterface } from "./Interface"; -type ReactiveElementHost = Partial & AkInterface; - export class BrandContextController implements ReactiveController { - host!: ReactiveElementHost; + host!: ReactiveElementHost; context!: ContextProvider<{ __context__: CurrentBrand | undefined }>; - constructor(host: ReactiveElementHost) { + constructor(host: ReactiveElementHost) { this.host = host; this.context = new ContextProvider(this.host, { context: authentikBrandContext, diff --git a/web/src/elements/Interface/ConfigContextController.ts b/web/src/elements/Interface/ConfigContextController.ts index 8e16d0b8dc..35e38d54ea 100644 --- a/web/src/elements/Interface/ConfigContextController.ts +++ b/web/src/elements/Interface/ConfigContextController.ts @@ -2,23 +2,22 @@ import { EVENT_REFRESH } from "@goauthentik/authentik/common/constants"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { globalAK } from "@goauthentik/common/global"; import { authentikConfigContext } from "@goauthentik/elements/AuthentikContexts"; +import type { ReactiveElementHost } from "@goauthentik/elements/types.js"; import { ContextProvider } from "@lit/context"; -import { ReactiveController, ReactiveControllerHost } from "lit"; +import type { ReactiveController } from "lit"; import type { Config } from "@goauthentik/api"; import { RootApi } from "@goauthentik/api"; import type { AkInterface } from "./Interface"; -type ReactiveElementHost = Partial & AkInterface; - export class ConfigContextController implements ReactiveController { - host!: ReactiveElementHost; + host!: ReactiveElementHost; context!: ContextProvider<{ __context__: Config | undefined }>; - constructor(host: ReactiveElementHost) { + constructor(host: ReactiveElementHost) { this.host = host; this.context = new ContextProvider(this.host, { context: authentikConfigContext, diff --git a/web/src/elements/Interface/EnterpriseContextController.ts b/web/src/elements/Interface/EnterpriseContextController.ts index 30871a75a4..faa3b4823b 100644 --- a/web/src/elements/Interface/EnterpriseContextController.ts +++ b/web/src/elements/Interface/EnterpriseContextController.ts @@ -1,23 +1,22 @@ import { EVENT_REFRESH_ENTERPRISE } from "@goauthentik/authentik/common/constants"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { authentikEnterpriseContext } from "@goauthentik/elements/AuthentikContexts"; +import type { ReactiveElementHost } from "@goauthentik/elements/types.js"; import { ContextProvider } from "@lit/context"; -import { ReactiveController, ReactiveControllerHost } from "lit"; +import type { ReactiveController } from "lit"; import type { LicenseSummary } from "@goauthentik/api"; import { EnterpriseApi } from "@goauthentik/api"; import type { AkEnterpriseInterface } from "./Interface"; -type ReactiveElementHost = Partial & AkEnterpriseInterface; - export class EnterpriseContextController implements ReactiveController { - host!: ReactiveElementHost; + host!: ReactiveElementHost; context!: ContextProvider<{ __context__: LicenseSummary | undefined }>; - constructor(host: ReactiveElementHost) { + constructor(host: ReactiveElementHost) { this.host = host; this.context = new ContextProvider(this.host, { context: authentikEnterpriseContext, diff --git a/web/src/elements/Interface/authentikConfigProvider.ts b/web/src/elements/Interface/authentikConfigProvider.ts index 3329e739b7..79f1c960bb 100644 --- a/web/src/elements/Interface/authentikConfigProvider.ts +++ b/web/src/elements/Interface/authentikConfigProvider.ts @@ -1,13 +1,11 @@ import { authentikConfigContext } from "@goauthentik/elements/AuthentikContexts"; +import type { Constructor } from "@goauthentik/elements/types.js"; import { consume } from "@lit/context"; import type { LitElement } from "lit"; import type { Config } from "@goauthentik/api"; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type Constructor = new (...args: any[]) => T; - export function WithAuthentikConfig>( superclass: T, subscribe = true, diff --git a/web/src/elements/Interface/brandProvider.ts b/web/src/elements/Interface/brandProvider.ts index 14b87d623a..912466d963 100644 --- a/web/src/elements/Interface/brandProvider.ts +++ b/web/src/elements/Interface/brandProvider.ts @@ -1,14 +1,12 @@ import { authentikBrandContext } from "@goauthentik/elements/AuthentikContexts"; +import type { AbstractConstructor } from "@goauthentik/elements/types.js"; import { consume } from "@lit/context"; import type { LitElement } from "lit"; import type { CurrentBrand } from "@goauthentik/api"; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type Constructor = abstract new (...args: any[]) => T; - -export function WithBrandConfig>( +export function WithBrandConfig>( superclass: T, subscribe = true, ) { diff --git a/web/src/elements/Interface/capabilitiesProvider.ts b/web/src/elements/Interface/capabilitiesProvider.ts index f86d480f93..c8841d880b 100644 --- a/web/src/elements/Interface/capabilitiesProvider.ts +++ b/web/src/elements/Interface/capabilitiesProvider.ts @@ -1,4 +1,5 @@ import { authentikConfigContext } from "@goauthentik/elements/AuthentikContexts"; +import type { AbstractConstructor } from "@goauthentik/elements/types.js"; import { consume } from "@lit/context"; import type { LitElement } from "lit"; @@ -6,9 +7,6 @@ import type { LitElement } from "lit"; import { CapabilitiesEnum } from "@goauthentik/api"; import { Config } from "@goauthentik/api"; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type Constructor = abstract new (...args: any[]) => T; - // Using a unique, lexically scoped, and locally static symbol as the field name for the context // means that it's inaccessible to any child class looking for it. It's one of the strongest privacy // guarantees in JavaScript. @@ -45,7 +43,7 @@ class WCC { * */ -export function WithCapabilitiesConfig>( +export function WithCapabilitiesConfig>( superclass: T, subscribe = true, ) { diff --git a/web/src/elements/Interface/licenseSummaryProvider.ts b/web/src/elements/Interface/licenseSummaryProvider.ts index 2df4289b0e..4a73ffab6d 100644 --- a/web/src/elements/Interface/licenseSummaryProvider.ts +++ b/web/src/elements/Interface/licenseSummaryProvider.ts @@ -1,13 +1,11 @@ import { authentikEnterpriseContext } from "@goauthentik/elements/AuthentikContexts"; +import { Constructor } from "@goauthentik/elements/types.js"; import { consume } from "@lit/context"; import type { LitElement } from "lit"; import type { LicenseSummary } from "@goauthentik/api"; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -type Constructor = abstract new (...args: any[]) => T; - export function WithLicenseSummary>( superclass: T, subscribe = true, diff --git a/web/src/elements/types.ts b/web/src/elements/types.ts new file mode 100644 index 0000000000..c0247b1e91 --- /dev/null +++ b/web/src/elements/types.ts @@ -0,0 +1,11 @@ +import { AKElement } from "@goauthentik/elements/Base"; + +import { ReactiveControllerHost } from "lit"; + +export type ReactiveElementHost = Partial & T; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type Constructor = new (...args: any[]) => T; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type AbstractConstructor = abstract new (...args: any[]) => T;