Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
163 lines (127 loc) · 3.44 KB
/
Copy pathtypes.ts
File metadata and controls
163 lines (127 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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
export interface ExternalRoute {
role: string;
url: string;
}
export type RoleRouteObject = RouteObject & {
handle?: {
/**
* Route roles identify the purpose(s) a route fulfills in the site.
*/
roles?: string[];
};
};
export type AppConfig = Record<string, unknown>;
export type AppProvider = FC<{ children?: ReactNode }>;
export interface App {
appId: string;
routes?: RoleRouteObject[];
providers?: AppProvider[];
slots?: SlotOperation[];
externalScripts?: ExternalScriptLoaderClass[];
defaultConfig?: AppConfig;
config?: AppConfig;
provides?: Record<string, unknown>;
}
// External Scripts
export interface ExternalScriptLoader {
loadScript(): void;
}
export type ExternalScriptLoaderClass = new (data: { config: AppConfig }) => ExternalScriptLoader;
// Site Config
export interface RequiredSiteConfig {
siteId: string;
siteName: string;
baseUrl: string;
// Backends
lmsBaseUrl: string;
// Frontends
loginUrl: string;
logoutUrl: string;
}
export type LocalizedMessages = Record<string, Record<string, string>>;
export type SiteMessages = LocalizedMessages[];
export type LoggingServiceClass = new (options: {
config: SiteConfig;
}) => LoggingService;
export type AnalyticsServiceClass = new (options: {
config: SiteConfig;
loggingService: LoggingService;
httpClient: unknown;
}) => AnalyticsService;
export type AuthServiceClass = new (options: {
config: SiteConfig;
loggingService: LoggingService;
middleware: unknown[];
}) => AuthService;
export interface OptionalSiteConfig {
// Site environment
environment: EnvironmentTypes;
// Backends
cmsBaseUrl: string;
// Apps, routes, and URLs
apps: App[];
basename: string;
externalRoutes: ExternalRoute[];
externalLinkUrlOverrides: string[];
runtimeConfigJsonUrl: string | null;
commonAppConfig: AppConfig;
headerLogoImageUrl: string;
// Theme
theme: Theme;
// i18n
defaultLanguage: string;
supportedLanguages: string[];
// Cookies
accessTokenCookieName: string;
languagePreferenceCookieName: string;
userInfoCookieName: string;
// Paths
csrfTokenApiPath: string;
refreshAccessTokenApiPath: string;
// Logging
ignoredErrorRegex: RegExp | null;
// Analytics
segmentKey: string | null;
// Services
loggingService: LoggingServiceClass;
analyticsService: AnalyticsServiceClass;
authService: AuthServiceClass;
}
export type SiteConfig = RequiredSiteConfig & Partial<OptionalSiteConfig>;
export interface ThemeVariant {
url: string;
}
export interface ThemeDefaults {
light?: string;
dark?: string;
}
export type ThemeVariants = Record<string, ThemeVariant>;
export interface Theme {
core?: ThemeVariant;
defaults?: ThemeDefaults;
variants?: ThemeVariants;
}
export interface User {
administrator: boolean;
email: string;
name: string;
roles: string[];
userId: number;
username: string;
avatar?: string;
}
export enum EnvironmentTypes {
PRODUCTION = 'production',
DEVELOPMENT = 'development',
TEST = 'test',
}
// Menu Items
export type MenuItemName = string | MessageDescriptor | ReactElement;