-
Notifications
You must be signed in to change notification settings - Fork 12
fix: add missing SiteConfig service override typings and definitions #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ module.exports = tseslint.config( | |
| 'test-site/*', | ||
| 'config/*', | ||
| 'docs/*', | ||
| 'test-types/*', | ||
| ], | ||
| }, | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| export interface AnalyticsService { | ||
| sendTrackingLogEvent(eventName: string, properties: object): Promise<void>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should return
|
||
| identifyAuthenticatedUser(userId: string | number, traits?: Record<string, unknown>): void, | ||
| identifyAnonymousUser(traits?: Record<string, unknown>): void, | ||
| sendTrackEvent(eventName?: string, properties?: Record<string, unknown>): void, | ||
| sendPageEvent(category: string, name: string, properties?: Record<string, unknown>): void, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| export interface AuthService { | ||
| getAuthenticatedHttpClient(options?: Record<string, unknown>): unknown, | ||
| getHttpClient(options?: Record<string, unknown>): unknown, | ||
| getLoginRedirectUrl(redirectUrl?: string): string, | ||
| redirectToLogin(redirectUrl?: string): void, | ||
| getLogoutRedirectUrl(redirectUrl?: string): string, | ||
| redirectToLogout(redirectUrl?: string): void, | ||
| getAuthenticatedUser(): Record<string, unknown> | null, | ||
| setAuthenticatedUser(authUser: Record<string, unknown>): void, | ||
| fetchAuthenticatedUser(options?: Record<string, unknown>): Promise<Record<string, unknown> | null>, | ||
| ensureAuthenticatedUser(redirectUrl?: string): Promise<Record<string, unknown>>, | ||
|
Comment on lines
+8
to
+11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| hydrateAuthenticatedUser(): Promise<null>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should return Neither implementation resolves to |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { SiteConfig } from '../types'; | ||
| import NewRelicLoggingService from '../runtime/logging/NewRelicLoggingService'; | ||
| import SegmentAnalyticsService from '../runtime/analytics/SegmentAnalyticsService'; | ||
| import AxiosJwtAuthService from '../runtime/auth/AxiosJwtAuthService'; | ||
|
|
||
| const config: SiteConfig = { | ||
| loggingService: NewRelicLoggingService, | ||
| analyticsService: SegmentAnalyticsService, | ||
| authService: AxiosJwtAuthService, | ||
| siteId: '', | ||
| siteName: '', | ||
| baseUrl: '', | ||
| lmsBaseUrl: '', | ||
| loginUrl: '', | ||
| logoutUrl: '', | ||
| } | ||
|
|
||
| export default config; | ||
|
Comment on lines
+1
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove The real fix is typing |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,9 @@ import { FC, ReactElement, ReactNode } from 'react'; | |
| import { MessageDescriptor } from 'react-intl'; | ||
| import { RouteObject } from 'react-router'; | ||
| import { SlotOperation } from './runtime/slots/types'; | ||
| import { LoggingService } from './runtime/logging/types'; | ||
| import { AnalyticsService } from './runtime/analytics/types'; | ||
| import { AuthService } from './runtime/auth/types'; | ||
|
|
||
| // Apps | ||
|
|
||
|
|
@@ -59,6 +62,35 @@ export interface RequiredSiteConfig { | |
| export type LocalizedMessages = Record<string, Record<string, string>>; | ||
| export type SiteMessages = LocalizedMessages[]; | ||
|
|
||
| export type { LoggingService, AnalyticsService, AuthService }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Export the new types from their barrels with |
||
|
|
||
| // Logging instantiated | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drop the |
||
| export type LoggingServiceClass = new (options: { | ||
| config: SiteConfig, | ||
| }) => LoggingService; | ||
|
|
||
| // Analytics instantiated | ||
| export type AnalyticsServiceClass = new (options: { | ||
| config: SiteConfig, | ||
| loggingService: LoggingService, | ||
| httpClient: unknown, | ||
| }) => AnalyticsService; | ||
|
|
||
| // Auth instantiated | ||
| export type AuthServiceClass = new (options: { | ||
| config: { | ||
| baseUrl: string, | ||
| lmsBaseUrl: string, | ||
| loginUrl: string, | ||
| logoutUrl: string, | ||
| refreshAccessTokenApiPath: string, | ||
| accessTokenCookieName: string, | ||
| csrfTokenApiPath: string, | ||
| }, | ||
| loggingService: object, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| middleware?: unknown[], | ||
|
Comment on lines
+81
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| }) => AuthService; | ||
|
|
||
| export interface OptionalSiteConfig { | ||
| // Site environment | ||
| environment: EnvironmentTypes, | ||
|
|
@@ -92,6 +124,11 @@ export interface OptionalSiteConfig { | |
|
|
||
| // Analytics | ||
| segmentKey: string | null, | ||
|
|
||
| // Services | ||
| loggingService: LoggingServiceClass, | ||
| analyticsService: AnalyticsServiceClass, | ||
| authService: AuthServiceClass, | ||
| } | ||
|
|
||
| export type SiteConfig = RequiredSiteConfig & Partial<OptionalSiteConfig>; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ignore comes back out along with
test-types/- see the comment on the fixture file.