-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.ts
304 lines (245 loc) · 6.69 KB
/
types.ts
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
import { ElementType, ReactElement } from 'react';
import { MessageDescriptor } from 'react-intl';
import { IndexRouteObject, NonIndexRouteObject } from 'react-router';
export type AppConfig = ExternalAppConfig | InternalAppConfig | FederatedAppConfig | HydratedFederatedAppConfig;
export type ConfigurableAppConfig = InternalAppConfig | HydratedFederatedAppConfig;
export enum AppConfigTypes {
EXTERNAL = 'external',
INTERNAL = 'internal',
FEDERATED = 'federated',
}
export interface AppModuleHandle {
appId: string,
[key: string]: any,
}
// We extend the react-router RouteObject to make path required. `path` is not required for
// 'layout' routes, which for now we won't support as the route of a module.
// Documentation of this here: https://reactrouter.com/en/main/route/route#layout-routes
export interface AppModuleIndexRouteObject extends IndexRouteObject {
path: string,
}
export interface AppModuleNonIndexRouteObject extends NonIndexRouteObject {
path: string,
}
export type AppModuleRouteObject = AppModuleIndexRouteObject | AppModuleNonIndexRouteObject;
export interface ApplicationModuleConfig {
route: AppModuleRouteObject,
header?: HeaderConfig,
}
export interface InternalAppConfig {
type: AppConfigTypes.INTERNAL,
config: ApplicationModuleConfig,
path?: string,
}
export interface FederatedAppConfig {
type: AppConfigTypes.FEDERATED,
libraryId: string,
remoteUrl: string,
moduleId: string,
path: string,
}
export interface HydratedFederatedAppConfig extends FederatedAppConfig {
config: ApplicationModuleConfig,
}
export interface ExternalAppConfig {
type: AppConfigTypes.EXTERNAL,
url: string,
}
export type ProjectSiteConfig = RequiredSiteConfig & Partial<OptionalSiteConfig>;
export interface OptionalSiteConfig {
pluginSlots: {
[slotName: string]: {
keepDefault: boolean,
plugins: Array<Plugin>,
},
},
header?: HeaderConfig,
// Cookies
ACCESS_TOKEN_COOKIE_NAME: string,
LANGUAGE_PREFERENCE_COOKIE_NAME: string,
USER_INFO_COOKIE_NAME: string,
// Paths
CSRF_TOKEN_API_PATH: string,
REFRESH_ACCESS_TOKEN_API_PATH: string,
// Logging
IGNORED_ERROR_REGEX: RegExp | null,
// Analytics
SEGMENT_KEY: string | null,
ENVIRONMENT: EnvironmentTypes,
MFE_CONFIG_API_URL: string | null,
PUBLIC_PATH: string,
// Backends
CREDENTIALS_BASE_URL: string | null,
DISCOVERY_API_BASE_URL: string | null,
ECOMMERCE_BASE_URL: string | null,
PUBLISHER_BASE_URL: string | null,
// Frontends
ORDER_HISTORY_URL: string | null,
SUPPORT_URL: string | null,
SUPPORT_EMAIL: string | null,
TERMS_OF_SERVICE_URL: string | null,
PRIVACY_POLICY_URL: string | null,
ACCESSIBILITY_URL: string | null,
custom: {
[key: string]: any,
}
}
export interface AppsConfig {
[appId: string]: AppConfig,
}
export interface RequiredSiteConfig {
apps: AppsConfig,
APP_ID: string,
BASE_URL: string,
SITE_NAME: string,
// Frontends
ACCOUNT_PROFILE_URL: string,
ACCOUNT_SETTINGS_URL: string,
LEARNER_DASHBOARD_URL: string,
LEARNING_BASE_URL: string,
LOGIN_URL: string,
LOGOUT_URL: string,
MARKETING_SITE_BASE_URL: string,
// Backends
LMS_BASE_URL: string,
STUDIO_BASE_URL: string,
// Branding
FAVICON_URL: string,
LOGO_TRADEMARK_URL: string,
LOGO_URL: string,
LOGO_WHITE_URL: string,
}
export type SiteConfig = RequiredSiteConfig & OptionalSiteConfig;
export interface ProjectModuleConfig {
modules?: Array<string>,
name?: string,
plugins?: any,
custom?: {
[key: string]: any,
}
}
export interface User {
administrator: boolean,
email: string,
name: string,
roles: Array<string>,
userId: number,
username: string,
avatar: string,
}
export enum FooterTypes {
DEFAULT = 'default',
STUDIO = 'studio',
NONE = 'none',
}
export enum EnvironmentTypes {
PRODUCTION = 'production',
DEVELOPMENT = 'development',
TEST = 'test',
}
// Header Types
export interface HeaderConfig {
logoUrl?: string,
logoDestinationUrl?: string | null,
primaryLinks?: Array<MenuItem>,
secondaryLinks?: Array<MenuItem>,
anonymousLinks?: Array<MenuItem>,
authenticatedLinks?: Array<ChildMenuItem>,
}
export interface ResolvedHeaderConfig {
logoUrl: string,
logoDestinationUrl: string | null,
primaryLinks: Array<MenuItem>,
secondaryLinks: Array<MenuItem>,
anonymousLinks: Array<MenuItem>,
authenticatedLinks: Array<ChildMenuItem>,
}
export type MenuItemName = string | MessageDescriptor | ReactElement;
export interface BaseLinkMenuItem {
label: MenuItemName,
}
export interface AppMenuItem extends BaseLinkMenuItem {
appId: string,
}
export interface DropdownMenuItem {
label: MessageDescriptor | string,
items: Array<ChildMenuItem>,
}
export interface UrlMenuItem extends BaseLinkMenuItem {
url: string,
}
/**
* A menu item that displays as a link.
*
* There are two sub-types based on how the link is configured.
*
* * **AppMenuItem**: Uses an app ID to resolve the link URL. Used to link directly to another app module.
* * **UrlMenuItem**: Includes a fully-qualified URL. Used for external links.
*/
export type LinkMenuItem = AppMenuItem | UrlMenuItem;
export type MenuItem = LinkMenuItem | DropdownMenuItem | ReactElement;
export type ChildMenuItem = LinkMenuItem | ReactElement;
// Plugin Types
/**
* Defines the changes to be made to either the default widget(s) or to any
* that are inserted.
*/
export enum PluginOperations {
/**
* Inserts a new widget into the DirectPluginSlot.
*/
INSERT = 'insert',
/**
* Used to hide a default widget based on the widgetId.
*/
HIDE = 'hide',
/**
* Used to modify/replace a widget's content.
*/
MODIFY = 'modify',
/**
* Wraps a widget with a React element or fragment.
*/
WRAP = 'wrap',
}
export enum PluginTypes {
IFRAME = 'iframe',
DIRECT = 'direct',
}
export interface InsertDirectPluginWidget {
id: string,
type: PluginTypes.DIRECT,
priority: number,
RenderWidget: ElementType,
content?: {
[propName: string]: any,
}
}
export interface InsertIframePluginWidget {
id: string,
type: PluginTypes.IFRAME,
priority: number,
url: string,
title: string,
}
export type InsertPluginWidget = InsertDirectPluginWidget | InsertIframePluginWidget;
export type PluginWidget = InsertPluginWidget;
export interface ModifyPlugin {
op: PluginOperations.MODIFY,
widgetId: string,
fn: (InsertDirectPluginWidget) => InsertDirectPluginWidget,
}
export interface InsertPlugin {
op: PluginOperations.INSERT,
widget: PluginWidget,
}
export interface WrapPlugin {
op: PluginOperations.WRAP,
widgetId: string,
wrapper: ElementType
}
export interface HidePlugin {
op: PluginOperations.HIDE,
widgetId: string
}
export type Plugin = HidePlugin | InsertPlugin | ModifyPlugin | WrapPlugin;