forked from openedx/frontend-base
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypes.ts
More file actions
129 lines (103 loc) · 3.02 KB
/
types.ts
File metadata and controls
129 lines (103 loc) · 3.02 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
import { ReactElement } from 'react';
import { MessageDescriptor } from 'react-intl';
import { RouteObject } from 'react-router';
import { SlotOperation } from './runtime/slots/types';
// Apps
export interface ExternalRoute {
role: string,
url: string,
}
export type RoleRouteObject = RouteObject & {
handle?: {
/**
* A route role is used to identify a route that fulfills a particular role in the site, such as "login", "learnerHome", or "profile".
*/
role?: string,
},
};
export interface App {
messages?: LocalizedMessages,
routes?: RoleRouteObject[],
slots?: SlotOperation[],
remotes?: Remote[],
config?: AppConfig,
}
export type AppConfig = {
// An AppConfig must contain an appId if it exists, which allows us to differentiate between app configs.
appId,
} & Record<string, unknown>;
export interface FederatedApp {
remoteId: string,
moduleId: string,
// rolePaths are used to find out the paths to certain roles before loading the app via module federation. This means we can form links without needing to load the whole thing.
rolePaths?: Record<string, string>,
hints?: {
// The path hints are used by our react-router patchRoutesOnNavigation handler to load the
// federated app when one of its paths has been requested. This can happen, for instance, when
// a path is loaded via the rolePaths above.
paths?: string[],
},
}
export interface Remote {
id: string,
url: string,
}
// Site Config
export interface RequiredSiteConfig {
appId: string,
siteName: string,
baseUrl: string,
// Backends
lmsBaseUrl: string,
// Frontends
loginUrl: string,
logoutUrl: string,
}
export type LocalizedMessages = Record<string, Record<string, string>>;
export type ProjectSiteConfig = RequiredSiteConfig & Partial<OptionalSiteConfig>;
export interface OptionalSiteConfig {
apps: App[],
federatedApps: FederatedApp[],
remotes: Remote[],
externalRoutes: ExternalRoute[],
// Cookies
accessTokenCookieName: string,
languagePreferenceCookieName: string,
userInfoCookieName: string,
// Paths
csrfTokenApiPath: string,
refreshAccessTokenApiPath: string,
// Logging
ignoredErrorRegex: RegExp | null,
// Analytics
segmentKey: string | null,
environment: EnvironmentTypes,
mfeConfigApiUrl: string | null,
publicPath: string,
custom: AppConfig,
}
export type SiteConfig = RequiredSiteConfig & OptionalSiteConfig;
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;
// Learning
// TODO: Make this interface match the shape of course info coming back from the server.
// Check what additional data frontend-app-learning or frontend-app-authoring has and model it here.
export interface CourseInfo {
title: string,
number: string,
org: string,
}