@luigi-project/container 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,71 @@
1
+ declare module 'EventPayloads' {
2
+ type ModalSettings = {
3
+ height?: 'px' | '%' | 'rem' | 'em' | 'vh' | 'vw';
4
+ size?: 'fullscreen' | 'l' | 'm' | 's';
5
+ title?: string;
6
+ width?: 'px' | '%' | 'rem' | 'em' | 'vh' | 'vw';
7
+ };
8
+
9
+ export interface AlertRequestPayload {
10
+ closeAfter?: number;
11
+ links?: {
12
+ [key: string]: {
13
+ dismissKey?: string;
14
+ text: string;
15
+ url?: string;
16
+ };
17
+ };
18
+ text?: string;
19
+ type: 'info' | 'success' | 'warning' | 'error';
20
+ }
21
+
22
+ export interface ConfirmationModalRequestPayload {
23
+ body?: string;
24
+ buttonConfirm?: string | boolean;
25
+ buttonDismiss?: string;
26
+ header?: string;
27
+ type?: 'confirmation' | 'info' | 'success' | 'warning' | 'error' | 'information';
28
+ }
29
+
30
+ export interface ModalSettingsRequestPayload {
31
+ addHistoryEntry: boolean;
32
+ updatedModalSettings: ModalSettings;
33
+ }
34
+
35
+ export interface CurrentRouteRequestPayload {
36
+ fromClosestContext?: boolean;
37
+ fromContext?: string | null;
38
+ fromParent?: boolean;
39
+ fromVirtualTreeRoot?: boolean;
40
+ nodeParams?: {
41
+ [key: string]: string;
42
+ };
43
+ }
44
+
45
+ export interface CurrentRoutePostMessageData {
46
+ correlationId: number;
47
+ route: string;
48
+ }
49
+
50
+ export interface CheckPathPostMessageData {
51
+ correlationId: number;
52
+ pathExists: boolean;
53
+ }
54
+
55
+ export interface NavigationRequestPayload extends CurrentRouteRequestPayload {
56
+ link?: string;
57
+ }
58
+
59
+ export interface ModalPathDataRequestPayload extends CurrentRouteRequestPayload {
60
+ history?: boolean;
61
+ link?: string;
62
+ modal?: ModalSettings;
63
+ }
64
+
65
+ export interface ParamsRequestPayload {
66
+ data?: {
67
+ [key: string]: any;
68
+ };
69
+ keepBrowserHistory?: boolean;
70
+ }
71
+ }
@@ -1,176 +1,404 @@
1
+ /* eslint-disable @typescript-eslint/triple-slash-reference */
2
+ /// <reference path="../../typings/constants/event-payloads.ts" />
3
+ import type {
4
+ AlertRequestPayload,
5
+ ConfirmationModalRequestPayload,
6
+ CurrentRouteRequestPayload,
7
+ ModalPathDataRequestPayload,
8
+ ModalSettingsRequestPayload,
9
+ NavigationRequestPayload,
10
+ ParamsRequestPayload
11
+ } from 'EventPayloads';
12
+
1
13
  /* eslint-disable @typescript-eslint/no-unsafe-function-type */
2
14
  export namespace Events {
3
15
  /**
4
16
  * Event fired when the micro frontend sends a custom message.
17
+ * @type {Object}
18
+ * @property {object} data - event data
19
+ * @property {string} id - event ID
20
+ * @example
21
+ * {
22
+ * data: {},
23
+ * id: 'some-id'
24
+ * }
25
+ * @returns {void}
26
+ *
27
+ * <br>
5
28
  */
6
29
  export const CUSTOM_MESSAGE = 'custom-message';
7
30
 
8
31
  /**
9
- * Event fired when the micro frontend requests the context data.
32
+ * Event left due to historical reasons - do not use.
33
+ * @deprecated
34
+ * @ignore
10
35
  */
11
36
  export const GET_CONTEXT_REQUEST = 'get-context-request';
12
37
 
13
38
  /**
14
- * Event fired when a navigation has been requested by the micro frontend.
39
+ * Event fired when a navigation has been requested by the micro frontend. <br><br>
40
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|NavigationRequestPayload}
41
+ * @type {NavigationRequestPayload}
42
+ * @example
43
+ * {
44
+ * fromClosestContext: false,
45
+ * fromContext: null,
46
+ * fromParent: true,
47
+ * fromVirtualTreeRoot: false,
48
+ * link: '/test/route',
49
+ * nodeParams: {}
50
+ * }
51
+ * @returns {void}
52
+ *
53
+ * <br>
15
54
  */
16
55
  export const NAVIGATION_REQUEST = 'navigation-request';
17
56
 
18
57
  /**
19
- * Event fired when the micro frontend requests to show an alert.
58
+ * Event fired when the micro frontend requests to show an alert. <br>
59
+ * Read more about `showAlert` params [here](https://docs.luigi-project.io/docs/luigi-core-api?section=showalert). <br><br>
60
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|AlertRequestPayload}
61
+ * @type {AlertRequestPayload}
62
+ * @example
63
+ * {
64
+ * text: 'Custom alert message',
65
+ * type: 'info',
66
+ * links: {
67
+ * goToHome: { text: 'Homepage', url: '/overview' },
68
+ * goToOtherProject: { text: 'Other project', url: '/projects/pr2' },
69
+ * relativePath: { text: 'Hide side nav', url: 'hideSideNav' },
70
+ * neverShowItAgain: { text: 'Never show it again', dismissKey: 'neverShowItAgain' }
71
+ * },
72
+ * closeAfter: 3000
73
+ * }
74
+ * @returns {void}
75
+ *
76
+ * <br>
20
77
  */
21
78
  export const ALERT_REQUEST = 'show-alert-request';
22
79
 
23
80
  /**
24
81
  * Event left due to historical reasons - do not use.
25
82
  * @deprecated
83
+ * @ignore
26
84
  */
27
85
  export const ALERT_CLOSED = 'close-alert-request';
28
86
 
29
87
  /**
30
88
  * Event fired when the micro frontend has been initialized.
89
+ * @type {unspecified} (type is not relevant in this case)
90
+ * @returns {void}
91
+ *
92
+ * <br>
31
93
  */
32
94
  export const INITIALIZED = 'initialized';
33
95
 
34
96
  /**
35
- * Event fired when the micro frontend requests the addition of search parameters to the URL.
97
+ * Event fired when the micro frontend requests the addition of search parameters to the URL. <br><br>
98
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|ParamsRequestPayload}
99
+ * @type {ParamsRequestPayload}
100
+ * @example
101
+ * {
102
+ * data: {},
103
+ * keepBrowserHistory: false
104
+ * }
105
+ * @returns {void}
106
+ *
107
+ * <br>
36
108
  */
37
109
  export const ADD_SEARCH_PARAMS_REQUEST = 'add-search-params-request';
38
110
 
39
111
  /**
40
- * Event fired when the micro frontend requests the addition of node parameters to the URL.
112
+ * Event fired when the micro frontend requests the addition of node parameters to the URL. <br><br>
113
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|ParamsRequestPayload}
114
+ * @type {ParamsRequestPayload}
115
+ * @example
116
+ * {
117
+ * data: {},
118
+ * keepBrowserHistory: false
119
+ * }
120
+ * @returns {void}
121
+ *
122
+ * <br>
41
123
  */
42
124
  export const ADD_NODE_PARAMS_REQUEST = 'add-node-params-request';
43
125
 
44
126
  /**
45
- * Event fired when the micro frontend requests to show a confirmation modal.
127
+ * Event fired when the micro frontend requests to show a confirmation modal. <br>
128
+ * Read more about `showConfirmationModal` params [here](https://docs.luigi-project.io/docs/luigi-core-api?section=showconfirmationmodal). <br><br>
129
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|ConfirmationModalRequestPayload}
130
+ * @type {ConfirmationModalRequestPayload}
131
+ * @example
132
+ * {
133
+ * header: 'Confirmation',
134
+ * body: 'Are you sure you want to do this?',
135
+ * buttonConfirm: 'Yes',
136
+ * buttonDismiss: 'No'
137
+ * }
138
+ * @returns {void}
139
+ *
140
+ * <br>
46
141
  */
47
142
  export const SHOW_CONFIRMATION_MODAL_REQUEST = 'show-confirmation-modal-request';
48
143
 
49
144
  /**
50
145
  * Event fired when the micro frontend requests to show a loading indicator.
146
+ * @type {unspecified} (type is not relevant in this case)
147
+ * @returns {void}
148
+ *
149
+ * <br>
51
150
  */
52
151
  export const SHOW_LOADING_INDICATOR_REQUEST = 'show-loading-indicator-request';
53
152
 
54
153
  /**
55
154
  * Event fired when the micro frontend requests to hide the loading indicator.
155
+ * @type {unspecified} (type is not relevant in this case)
156
+ * @returns {void}
157
+ *
158
+ * <br>
56
159
  */
57
160
  export const HIDE_LOADING_INDICATOR_REQUEST = 'hide-loading-indicator-request';
58
161
 
59
162
  /**
60
163
  * Event fired when the micro frontend requests to set the current locale.
164
+ * @type {Object.<string, string>}
165
+ * @example
166
+ * {
167
+ * currentLocale: 'en'
168
+ * }
169
+ * @returns {void}
170
+ *
171
+ * <br>
61
172
  */
62
173
  export const SET_CURRENT_LOCALE_REQUEST = 'set-current-locale-request';
63
174
 
64
175
  /**
65
176
  * Event fired when the micro frontend requests to modify the local storage.
177
+ * @type {Object.<string, string>}
178
+ * @example
179
+ * {
180
+ * key: 'luigi-version',
181
+ * value: '2.21.0'
182
+ * }
183
+ * @returns {void}
184
+ *
185
+ * <br>
66
186
  */
67
187
  export const LOCAL_STORAGE_SET_REQUEST = 'set-storage-request';
68
188
 
69
189
  /**
70
190
  * Event fired when the micro frontend requests to handle errors that might happen during the runtime of the micro frontend.
191
+ * @type {unspecified} (type is not relevant in this case)
192
+ * @returns {void}
193
+ *
194
+ * <br>
71
195
  */
72
196
  export const RUNTIME_ERROR_HANDLING_REQUEST = 'runtime-error-handling-request';
73
197
 
74
198
  /**
75
199
  * Event fired when the micro frontend requests to set the anchor of the URL.
200
+ * @type {string}
201
+ * @example 'some-anchor'
202
+ * @returns {void}
203
+ *
204
+ * <br>
76
205
  */
77
206
  export const SET_ANCHOR_LINK_REQUEST = 'set-anchor-request';
78
207
 
79
208
  /**
80
209
  * Event fired when the micro frontend requests to set third-party cookies.
210
+ * @type {unspecified} (type is not relevant in this case)
211
+ * @returns {void}
212
+ *
213
+ * <br>
81
214
  */
82
215
  export const SET_THIRD_PARTY_COOKIES_REQUEST = 'set-third-party-cookies-request';
83
216
 
84
217
  /**
85
- * Event fired when the micro frontend requests to navigate back.
86
- * @deprecated use GO_BACK_REQUEST
218
+ * Event left due to historical reasons - use 'GO_BACK_REQUEST' instead.
219
+ * @deprecated
220
+ * @ignore
87
221
  */
88
222
  export const BACK_NAVIGATION_REQUEST = 'navigate-back-request';
89
223
 
90
224
  /**
91
- * Event fired when the micro frontend requests the current app route.
225
+ * Event fired when the micro frontend requests the current app route. <br><br>
226
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|CurrentRouteRequestPayload}
227
+ * @type {CurrentRouteRequestPayload}
228
+ * @example
229
+ * {
230
+ * fromClosestContext: false,
231
+ * fromContext: null,
232
+ * fromParent: true,
233
+ * fromVirtualTreeRoot: false,
234
+ * nodeParams: {}
235
+ * }
236
+ * @returns {void}
237
+ *
238
+ * <br>
92
239
  */
93
240
  export const GET_CURRENT_ROUTE_REQUEST = 'get-current-route-request';
94
241
 
95
242
  /**
96
243
  * Event fired to report that the micro frontend's navigation has completed.
244
+ * @type {unspecified} (type is not relevant in this case)
245
+ * @returns {void}
246
+ *
247
+ * <br>
97
248
  */
98
249
  export const NAVIGATION_COMPLETED_REPORT = 'report-navigation-completed-request';
99
250
 
100
251
  /**
101
- * Event fired when the micro frontend requests to update the modal path parameters.
252
+ * Event fired when the micro frontend requests to update the modal path parameters. <br><br>
253
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|ModalPathDataRequestPayload}
254
+ * @type {ModalPathDataRequestPayload}
255
+ * @example
256
+ * {
257
+ * fromClosestContext: false,
258
+ * fromContext: null,
259
+ * fromParent: true,
260
+ * fromVirtualTreeRoot: false,
261
+ * history: true,
262
+ * link: '/test/route',
263
+ * modal: { title: 'Some modal' },
264
+ * nodeParams: {}
265
+ * }
266
+ * @returns {void}
267
+ *
268
+ * <br>
102
269
  */
103
270
  export const UPDATE_MODAL_PATH_DATA_REQUEST = 'update-modal-path-data-request';
104
271
 
105
272
  /**
106
- * Event fired when the micro frontend requests to update the modal settings.
273
+ * Event fired when the micro frontend requests to update the modal settings. <br>
274
+ * Read more about `updateModalSettings` params [here](https://docs.luigi-project.io/docs/luigi-client-api?section=updatemodalsettings). <br><br>
275
+ * Payload: {@link https://github.com/luigi-project/luigi/blob/main/container/typings/constants/event-payloads.ts|ModalSettingsRequestPayload}
276
+ * @type {ModalSettingsRequestPayload}
277
+ * @example
278
+ * {
279
+ * addHistoryEntry: true,
280
+ * updatedModalSettings: {}
281
+ * }
282
+ * @returns {void}
283
+ *
284
+ * <br>
107
285
  */
108
286
  export const UPDATE_MODAL_SETTINGS_REQUEST = 'update-modal-settings-request';
109
287
 
110
288
  /**
111
289
  * Event fired when the micro frontend requests to check the validity of a path.
290
+ * @type {Object.<string, string>}
291
+ * @example
292
+ * {
293
+ * link: '/test/route'
294
+ * }
295
+ * @returns {void}
296
+ *
297
+ * <br>
112
298
  */
113
299
  export const CHECK_PATH_EXISTS_REQUEST = 'check-path-exists-request';
114
300
 
115
301
  /**
116
302
  * Event fired when the micro frontend requests to set the 'dirty status' which, for example, avoids closing when there are any unsaved changes.
303
+ * @type {Object.<string, boolean>}
304
+ * @example
305
+ * {
306
+ * dirty: true
307
+ * }
308
+ * @returns {void}
309
+ *
310
+ * <br>
117
311
  */
118
312
  export const SET_DIRTY_STATUS_REQUEST = 'set-dirty-status-request';
119
313
 
120
314
  /**
121
315
  * Event fired when the micro frontend requests to set the view group data.
316
+ * @type {Object.<string, unknown>}
317
+ * @example
318
+ * {
319
+ * vg: 'some data'
320
+ * }
321
+ * @returns {void}
322
+ *
323
+ * <br>
122
324
  */
123
325
  export const SET_VIEW_GROUP_DATA_REQUEST = 'set-viewgroup-data-request';
124
326
 
125
327
  /**
126
- * Event fired when the micro frontend requests to set the document title.
328
+ * Event left due to historical reasons - do not use.
127
329
  * @deprecated
330
+ * @ignore
128
331
  */
129
332
  export const SET_DOCUMENT_TITLE_REQUEST = 'set-document-title-request';
130
333
 
131
334
  /**
132
- * Event fired when the micro frontend requests to open the user settings.
335
+ * Event left due to historical reasons - do not use.
336
+ * @deprecated
337
+ * @ignore
133
338
  */
134
339
  export const OPEN_USER_SETTINGS_REQUEST = 'open-user-settings-request';
135
340
 
136
341
  /**
137
- * Event fired when the micro frontend requests to close the user settings.
342
+ * Event left due to historical reasons - do not use.
343
+ * @deprecated
344
+ * @ignore
138
345
  */
139
346
  export const CLOSE_USER_SETTINGS_REQUEST = 'close-user-settings-request';
140
347
 
141
348
  /**
142
- * Event fired when the micro frontend requests to collapse left side navigation.
349
+ * Event left due to historical reasons - do not use.
350
+ * @deprecated
351
+ * @ignore
143
352
  */
144
353
  export const COLLAPSE_LEFT_NAV_REQUEST = 'collapse-leftnav-request';
145
354
 
146
355
  /**
147
- * Event fired when the micro frontend requests to update the top navigation.
356
+ * Event left due to historical reasons - do not use.
357
+ * @deprecated
358
+ * @ignore
148
359
  */
149
360
  export const UPDATE_TOP_NAVIGATION_REQUEST = 'update-top-navigation-request';
150
361
 
151
362
  /**
152
- * Event fired when the micro frontend requests to check if the path exists.
153
- * @deprecated use CHECK_PATH_EXISTS_REQUEST
363
+ * Event left due to historical reasons - use 'CHECK_PATH_EXISTS_REQUEST' instead.
364
+ * @deprecated
365
+ * @ignore
154
366
  */
155
367
  export const PATH_EXISTS_REQUEST = 'path-exists-request';
156
368
 
157
369
  /**
158
370
  * Event fired when the micro frontend requests to navigate back.
371
+ * @type {Object.<string, unknown>}
372
+ * @example
373
+ * {
374
+ * ctx: 'some context'
375
+ * }
376
+ * @returns {void}
377
+ *
378
+ * <br>
159
379
  */
160
380
  export const GO_BACK_REQUEST = 'go-back-request';
161
381
 
162
382
  /**
163
- * Event fired when the micro frontend requests to check if there are any preserved views.
383
+ * Event left due to historical reasons - do not use.
384
+ * @deprecated
385
+ * @ignore
164
386
  */
165
387
  export const HAS_BACK_REQUEST = 'has-back-request';
166
388
 
167
389
  /**
168
390
  * Event fired when the micro frontend requests to display the backdrop.
391
+ * @type {unspecified} (type is not relevant in this case)
392
+ * @returns {void}
393
+ *
394
+ * <br>
169
395
  */
170
396
  export const ADD_BACKDROP_REQUEST = 'add-backdrop-request';
171
397
 
172
398
  /**
173
399
  * Event fired when the micro frontend requests to remove the backdrop.
400
+ * @type {unspecified} (type is not relevant in this case)
401
+ * @returns {void}
174
402
  */
175
403
  export const REMOVE_BACKDROP_REQUEST = 'remove-backdrop-request';
176
404
  }
@@ -178,7 +406,7 @@ export namespace Events {
178
406
  export class LuigiEvent extends Event {
179
407
  payload?: unknown;
180
408
  detail: unknown;
181
- private callbackFn: Function;
409
+ private callbackFn: Function | undefined;
182
410
 
183
411
  constructor(type: string, data: unknown, payload?: unknown, callback?: Function) {
184
412
  super(type);