@axinom/mosaic-portal 0.14.0 → 0.14.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.
- package/app/index.d.ts +1097 -1343
- package/app/{index.8d01a1.js → index.d70d68.js} +84842 -92987
- package/app/index.d70d68.js.map +1 -0
- package/app/index.html +16 -16
- package/app/index.js +1 -1
- package/files.tar +0 -0
- package/files_once.tar +0 -0
- package/package.json +37 -34
- package/app/index.8d01a1.js.map +0 -1
package/app/index.d.ts
CHANGED
|
@@ -1,1458 +1,1212 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import * as ReactRouter from 'react-router';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Gets the metadata of the current pilet.
|
|
12
|
-
*/
|
|
13
|
-
meta: PiletMetadata;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The emitter for Piral app shell events.
|
|
18
|
-
*/
|
|
19
|
-
export interface EventEmitter {
|
|
20
|
-
/**
|
|
21
|
-
* Attaches a new event listener.
|
|
22
|
-
* @param type The type of the event to listen for.
|
|
23
|
-
* @param callback The callback to trigger.
|
|
24
|
-
*/
|
|
25
|
-
on<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
26
|
-
/**
|
|
27
|
-
* Detaches an existing event listener.
|
|
28
|
-
* @param type The type of the event to listen for.
|
|
29
|
-
* @param callback The callback to trigger.
|
|
30
|
-
*/
|
|
31
|
-
off<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
32
|
-
/**
|
|
33
|
-
* Emits a new event with the given type.
|
|
34
|
-
* @param type The type of the event to emit.
|
|
35
|
-
* @param arg The payload of the event.
|
|
36
|
-
*/
|
|
37
|
-
emit<K extends keyof PiralEventMap>(type: K, arg: PiralEventMap[K]): EventEmitter;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Custom Pilet API parts defined outside of piral-core.
|
|
42
|
-
*/
|
|
43
|
-
export interface PiletCustomApi extends AuthApi, EnvironmentApi, HomeApi, RegistrationInfoApi, NavigationApi, NotificationApi, ProviderApi, NavigationResolverApi {}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Defines the Pilet API from piral-core.
|
|
47
|
-
* This interface will be consumed by pilet developers so that their pilet can interact with the piral instance.
|
|
48
|
-
*/
|
|
49
|
-
export interface PiletCoreApi {
|
|
50
|
-
/**
|
|
51
|
-
* Gets a shared data value.
|
|
52
|
-
* @param name The name of the data to retrieve.
|
|
53
|
-
*/
|
|
54
|
-
getData<TKey extends string>(name: TKey): SharedData[TKey];
|
|
55
|
-
/**
|
|
56
|
-
* Sets the data using a given name. The name needs to be used exclusively by the current pilet.
|
|
57
|
-
* Using the name occupied by another pilet will result in no change.
|
|
58
|
-
* @param name The name of the data to store.
|
|
59
|
-
* @param value The value of the data to store.
|
|
60
|
-
* @param options The optional configuration for storing this piece of data.
|
|
61
|
-
* @returns True if the data could be set, otherwise false.
|
|
62
|
-
*/
|
|
63
|
-
setData<TKey extends string>(name: TKey, value: SharedData[TKey], options?: DataStoreOptions): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Registers a route for predefined page component.
|
|
66
|
-
* The route needs to be unique and can contain params.
|
|
67
|
-
* Params are following the path-to-regexp notation, e.g., :id for an id parameter.
|
|
68
|
-
* @param route The route to register.
|
|
69
|
-
* @param Component The component to render the page.
|
|
70
|
-
* @param meta The optional metadata to use.
|
|
71
|
-
*/
|
|
72
|
-
registerPage(route: string, Component: AnyComponent<PageComponentProps>, meta?: PiralPageMeta): RegistrationDisposer;
|
|
73
|
-
/**
|
|
74
|
-
* Unregisters the page identified by the given route.
|
|
75
|
-
* @param route The route that was previously registered.
|
|
76
|
-
*/
|
|
77
|
-
unregisterPage(route: string): void;
|
|
78
|
-
/**
|
|
79
|
-
* Registers an extension component with a predefined extension component.
|
|
80
|
-
* The name must refer to the extension slot.
|
|
81
|
-
* @param name The global name of the extension slot.
|
|
82
|
-
* @param Component The component to be rendered.
|
|
83
|
-
* @param defaults Optionally, sets the default values for the expected data.
|
|
84
|
-
*/
|
|
85
|
-
registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>, defaults?: TName): RegistrationDisposer;
|
|
86
|
-
/**
|
|
87
|
-
* Unregisters a global extension component.
|
|
88
|
-
* Only previously registered extension components can be unregistered.
|
|
89
|
-
* @param name The name of the extension slot to unregister from.
|
|
90
|
-
* @param Component The registered extension component to unregister.
|
|
91
|
-
*/
|
|
92
|
-
unregisterExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>): void;
|
|
93
|
-
/**
|
|
94
|
-
* React component for displaying extensions for a given name.
|
|
95
|
-
* @param props The extension's rendering props.
|
|
96
|
-
* @return The created React element.
|
|
97
|
-
*/
|
|
98
|
-
Extension<TName>(props: ExtensionSlotProps<TName>): React.ReactElement | null;
|
|
99
|
-
/**
|
|
100
|
-
* Renders an extension in a plain DOM component.
|
|
101
|
-
* @param element The DOM element or shadow root as a container for rendering the extension.
|
|
102
|
-
* @param props The extension's rendering props.
|
|
103
|
-
* @return The disposer to clear the extension.
|
|
104
|
-
*/
|
|
105
|
-
renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Describes the metadata transported by a pilet.
|
|
110
|
-
*/
|
|
111
|
-
export type PiletMetadata = SinglePiletMetadata | MultiPiletMetadata;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Listener for Piral app shell events.
|
|
115
|
-
*/
|
|
116
|
-
export interface Listener<T> {
|
|
117
|
-
(arg: T): void;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* The map of known Piral app shell events.
|
|
122
|
-
*/
|
|
123
|
-
export interface PiralEventMap extends PiralCustomEventMap {
|
|
124
|
-
"unload-pilet": PiralUnloadPiletEvent;
|
|
125
|
-
[custom: string]: any;
|
|
126
|
-
"store-data": PiralStoreDataEvent;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface AuthApi {
|
|
130
|
-
/**
|
|
131
|
-
* Gets the currently authenticated user, if any.
|
|
132
|
-
*/
|
|
133
|
-
getToken(): Promise<User | undefined>;
|
|
134
|
-
/**
|
|
135
|
-
* Checks if the user has one of the `requiredPermissions`.
|
|
136
|
-
*/
|
|
137
|
-
checkPermission(requiredPermissions: UserPermissions): Promise<boolean>;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface EnvironmentApi {
|
|
141
|
-
/**
|
|
142
|
-
* Returns current portal environment
|
|
143
|
-
*/
|
|
144
|
-
getEnvironment(): PortalConfiguration;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export interface HomeApi {
|
|
148
|
-
/**
|
|
149
|
-
* Registers a tile with preferences.
|
|
150
|
-
* The name has to be unique within the Current pilet.
|
|
151
|
-
* @param data HomeTileData or AdminTileData object with the details of the tile.
|
|
152
|
-
* @param registerNavItem if item needs to be added to navigation registry, defaults to true
|
|
153
|
-
* @example
|
|
154
|
-
* app.registerTile({
|
|
155
|
-
* kind: 'home',
|
|
156
|
-
* name: 'service',
|
|
157
|
-
* path: '/service-packages',
|
|
158
|
-
* label: 'Service Packages',
|
|
159
|
-
* icon: require('./images/service-packages.svg'),
|
|
160
|
-
* type: 'large',
|
|
161
|
-
* });
|
|
162
|
-
* @example
|
|
163
|
-
* app.registerTile({
|
|
164
|
-
* kind: 'settings',
|
|
165
|
-
* name: 'service',
|
|
166
|
-
* groupName: 'Users',
|
|
167
|
-
* path: '/users/roles',
|
|
168
|
-
* label: 'Roles',
|
|
169
|
-
* icon: require('./images/roles.svg'),
|
|
170
|
-
* })
|
|
171
|
-
*/
|
|
172
|
-
registerTile(data: AnyTile, registerNavItem?: boolean): RegistrationDisposer;
|
|
173
|
-
/**
|
|
174
|
-
* Unregisters a tile known by the given name.
|
|
175
|
-
* Only previously registered tiles can be unregistered.
|
|
176
|
-
* @param name The name of the tile to unregister.
|
|
177
|
-
*/
|
|
178
|
-
unregisterTile(name: string): void;
|
|
179
|
-
/**
|
|
180
|
-
* Use this to set a function that will be called to determine the order of the tiles on the home station.
|
|
181
|
-
* @param sorter Sorter function.
|
|
182
|
-
*/
|
|
183
|
-
setHomeTileSorter(sorter: TileSorter<HomeTileData>): void;
|
|
184
|
-
/**
|
|
185
|
-
* Creates a connector for wrapping home with data relations.
|
|
186
|
-
*/
|
|
187
|
-
createHomeConnector(): HomeStateContainer;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface RegistrationInfoApi {
|
|
191
|
-
/**
|
|
192
|
-
* Registered page components for the router
|
|
193
|
-
* @return Key value pair with registered route as key and it's page component as value
|
|
194
|
-
*/
|
|
195
|
-
getRegisteredPages: GetRegisteredPages;
|
|
196
|
-
/**
|
|
197
|
-
* Registered extension components for extension slots
|
|
198
|
-
* @return Key value pair with extension slot name as key and array of it's components as a value
|
|
199
|
-
*/
|
|
200
|
-
getRegisteredExtensions: GetRegisteredExtensions;
|
|
201
|
-
/**
|
|
202
|
-
* @return metadata for currently loaded pilets
|
|
203
|
-
*/
|
|
204
|
-
getRegisteredPilets: GetRegisteredPilets;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export interface NavigationApi {
|
|
208
|
-
/**
|
|
209
|
-
* Registers navigation panel item
|
|
210
|
-
* @param item Contains all details for createing navigation item
|
|
211
|
-
* @example
|
|
212
|
-
* app.registerNavigationItem({
|
|
213
|
-
* name: 'service-management',
|
|
214
|
-
* categoryName: 'Settings',
|
|
215
|
-
* path: '/settings/service-management',
|
|
216
|
-
* label: 'Service Management',
|
|
217
|
-
* });
|
|
218
|
-
* app.registerNavigationItem({
|
|
219
|
-
* name: 'service-management-feature',
|
|
220
|
-
* parentName: 'service-management',
|
|
221
|
-
* categoryName: 'Settings',
|
|
222
|
-
* path: '/settings/service-management/service-feature',
|
|
223
|
-
* label: 'Service Management',
|
|
224
|
-
* });
|
|
225
|
-
*/
|
|
226
|
-
registerNavigationItem(item: RegisterNavigationItem): () => void;
|
|
227
|
-
/**
|
|
228
|
-
* Removes registered navigation item
|
|
229
|
-
* @param name Unique name of the navigation item, that was provided on route registration
|
|
230
|
-
*/
|
|
231
|
-
unregisterNavigationItem(name: string): void;
|
|
232
|
-
/**
|
|
233
|
-
* Creates connector for wrapping component with navigation state data relations
|
|
234
|
-
*/
|
|
235
|
-
createNavigationConnector(): NavigationConnector;
|
|
236
|
-
/**
|
|
237
|
-
* Registers provided navigation item transformation function
|
|
238
|
-
* `transformer` function receives flat array of registered navigation items
|
|
239
|
-
* Use this to alter or re-order registered navigation items
|
|
240
|
-
* @param transformer function that alters navigation registry items
|
|
241
|
-
* @example
|
|
242
|
-
* app.setNavigationItemsTransformer(
|
|
243
|
-
* (navItems: NavigationItem[]): NavigationItem[] => {
|
|
244
|
-
* return navItems.map((item) => {
|
|
245
|
-
* if (item.name.includes('playground')) {
|
|
246
|
-
* item.categoryName = 'Playground';
|
|
247
|
-
* item.label = item.name.replace(/playground|-/g, ' ');
|
|
248
|
-
* item.parentName = undefined;
|
|
249
|
-
* }
|
|
250
|
-
* return item;
|
|
251
|
-
* });
|
|
252
|
-
* },
|
|
253
|
-
* );
|
|
254
|
-
*/
|
|
255
|
-
setNavigationItemsTransformer(transformer: NavigationTransformer<NavigationItem>): void;
|
|
256
|
-
/**
|
|
257
|
-
* Registers provided navigation tree transformation function
|
|
258
|
-
* `transformer` function receives navigation item tree created from registered navigation items
|
|
259
|
-
* Use this to alter or re-order navigation panel categories or their items
|
|
260
|
-
* @param transformer Function that alters navigation panel item order
|
|
261
|
-
* @example
|
|
262
|
-
* app.setNavigationTreeTransformer(
|
|
263
|
-
* (navTree: NavigationPanelCategory[]): NavigationPanelCategory[] => {
|
|
264
|
-
* return navTree.sort((a, b) =>
|
|
265
|
-
* a.categoryName.localeCompare(b.categoryName),
|
|
266
|
-
* );
|
|
267
|
-
* },
|
|
268
|
-
* );
|
|
269
|
-
*/
|
|
270
|
-
setNavigationTreeTransformer(transformer: NavigationTransformer<NavigationPanelCategory>): void;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export interface NotificationApi {
|
|
274
|
-
/**
|
|
275
|
-
* Displays a toast notification
|
|
276
|
-
* @param notification Notification to be shown
|
|
277
|
-
* @returns Id of the toast, used for updating or dismissing the notification
|
|
278
|
-
* @example
|
|
279
|
-
* const toastId = app.notifications.show({ title: 'Notification shown', body: 'Hello world', options: { type: 'error', autoClose: false } });
|
|
280
|
-
*/
|
|
281
|
-
showNotification: ShowNotification;
|
|
282
|
-
/**
|
|
283
|
-
* Updates a toast notification
|
|
284
|
-
* @param id toastId to be updated (returned from 'show' method call)
|
|
285
|
-
* @param notification Updated notification
|
|
286
|
-
* @example
|
|
287
|
-
* app.notifications.update(toastId, { title: 'Notification updated', body: 'Hello world' });
|
|
288
|
-
*/
|
|
289
|
-
updateNotification: UpdateNotification;
|
|
290
|
-
/**
|
|
291
|
-
* Dismisses a toast notification
|
|
292
|
-
* @param id toastId to be dismissed (returned from 'show' method call)
|
|
293
|
-
* @example
|
|
294
|
-
* app.notifications.dismiss(toastId);
|
|
295
|
-
*/
|
|
296
|
-
dismissNotification: DismissNotification;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
export interface ProviderApi {
|
|
300
|
-
/**
|
|
301
|
-
* Creates a provider object using the 'type' property. Assigns data and converter args to an array of objects as its value. If the 'type' already exists, the data will be appended to the array.
|
|
302
|
-
* @param type provider name
|
|
303
|
-
* @param data provider data
|
|
304
|
-
* @param converter function used to transformation
|
|
305
|
-
* @example
|
|
306
|
-
* // new provider
|
|
307
|
-
* app.addProvider<Example>(
|
|
308
|
-
* 'fast-provider',
|
|
309
|
-
* data: { type: 'movie' });
|
|
310
|
-
* // appends object to 'fast-provider'array
|
|
311
|
-
* app.addProvider(
|
|
312
|
-
* 'fast-provider',,
|
|
313
|
-
* data: { type: 'episode' });
|
|
314
|
-
*/
|
|
315
|
-
addProvider: ProviderRegistration;
|
|
316
|
-
/**
|
|
317
|
-
* Returns an array of data associated with a specific provider
|
|
318
|
-
* @param type Unique value of the provider 'type'
|
|
319
|
-
* @example
|
|
320
|
-
* app.getProviders('fast-provider');
|
|
321
|
-
*/
|
|
322
|
-
getProviders: GetProviders;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
export interface NavigationResolverApi {
|
|
326
|
-
/**
|
|
327
|
-
* Register a resolver function for a station
|
|
328
|
-
* @param data
|
|
329
|
-
* @example
|
|
330
|
-
* ```ts
|
|
331
|
-
* app.registerRouteResolver({
|
|
332
|
-
* station: 'movie-details',
|
|
333
|
-
* resolver: (dynamicRouteSegments?: string[]) => {
|
|
334
|
-
* return dynamicRouteSegments?.length
|
|
335
|
-
* ? `/movies/${dynamicRouteSegments[0]}`
|
|
336
|
-
* : undefined;
|
|
337
|
-
* },
|
|
338
|
-
* });
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
registerRouteResolver(data: ResolverData): void;
|
|
342
|
-
/**
|
|
343
|
-
* Resolves a route for a given station
|
|
344
|
-
* @param station Name of the station
|
|
345
|
-
* @param dynamicRouteSegments Dynamic route segments
|
|
346
|
-
* @returns Resolved route
|
|
347
|
-
* @example
|
|
348
|
-
* ```ts
|
|
349
|
-
* const entityId = '123'
|
|
350
|
-
* const route = await app.resolveRoute('movie-details', [entityId]);
|
|
351
|
-
* ```
|
|
352
|
-
*/
|
|
353
|
-
resolveRoute: ResolverFunction;
|
|
354
|
-
/**
|
|
355
|
-
* Returns resolvers from navigation registry
|
|
356
|
-
* @returns All registered route resolvers
|
|
357
|
-
*/
|
|
358
|
-
getAllRouteResolvers(): NavigationResolverRegistryState["navigationResolvers"];
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* Defines the shape of the data store for storing shared data.
|
|
363
|
-
*/
|
|
364
|
-
export interface SharedData<TValue = any> {
|
|
365
|
-
[key: string]: TValue;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Defines the options to be used for storing data.
|
|
370
|
-
*/
|
|
371
|
-
export type DataStoreOptions = DataStoreTarget | CustomDataStoreOptions;
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Possible shapes for a component.
|
|
375
|
-
*/
|
|
376
|
-
export type AnyComponent<T> = React.ComponentType<T> | FirstParametersOf<ComponentConverters<T>>;
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* The props used by a page component.
|
|
380
|
-
*/
|
|
381
|
-
export interface PageComponentProps<T = any, S = any> extends RouteBaseProps<T, S> {}
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* The meta data registered for a page.
|
|
385
|
-
*/
|
|
386
|
-
export interface PiralPageMeta extends PiralCustomPageMeta {}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* The shape of an implicit unregister function.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Defines the API accessible from pilets.
|
|
6
|
+
*/
|
|
7
|
+
export interface PiletApi extends EventEmitter, PiletCustomApi, PiletCoreApi {
|
|
8
|
+
/**
|
|
9
|
+
* Gets the metadata of the current pilet.
|
|
390
10
|
*/
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
11
|
+
meta: PiletMetadata;
|
|
12
|
+
}
|
|
394
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The emitter for Piral app shell events.
|
|
16
|
+
*/
|
|
17
|
+
export interface EventEmitter {
|
|
18
|
+
/**
|
|
19
|
+
* Attaches a new event listener.
|
|
20
|
+
* @param type The type of the event to listen for.
|
|
21
|
+
* @param callback The callback to trigger.
|
|
22
|
+
*/
|
|
23
|
+
on<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
395
24
|
/**
|
|
396
|
-
*
|
|
25
|
+
* Detaches an existing event listener.
|
|
26
|
+
* @param type The type of the event to listen for.
|
|
27
|
+
* @param callback The callback to trigger.
|
|
397
28
|
*/
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
29
|
+
off<K extends keyof PiralEventMap>(type: K, callback: Listener<PiralEventMap[K]>): EventEmitter;
|
|
30
|
+
/**
|
|
31
|
+
* Emits a new event with the given type.
|
|
32
|
+
* @param type The type of the event to emit.
|
|
33
|
+
* @param arg The payload of the event.
|
|
34
|
+
*/
|
|
35
|
+
emit<K extends keyof PiralEventMap>(type: K, arg: PiralEventMap[K]): EventEmitter;
|
|
36
|
+
}
|
|
404
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Custom Pilet API parts defined outside of piral-core.
|
|
40
|
+
*/
|
|
41
|
+
export interface PiletCustomApi extends AuthApi, EnvironmentApi, HomeApi, RegistrationInfoApi, NavigationApi, NotificationApi, ProviderApi, NavigationResolverApi {}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Defines the Pilet API from piral-core.
|
|
45
|
+
* This interface will be consumed by pilet developers so that their pilet can interact with the piral instance.
|
|
46
|
+
*/
|
|
47
|
+
export interface PiletCoreApi {
|
|
48
|
+
/**
|
|
49
|
+
* Gets a shared data value.
|
|
50
|
+
* @param name The name of the data to retrieve.
|
|
51
|
+
*/
|
|
52
|
+
getData<TKey extends string>(name: TKey): SharedData[TKey];
|
|
53
|
+
/**
|
|
54
|
+
* Sets the data using a given name. The name needs to be used exclusively by the current pilet.
|
|
55
|
+
* Using the name occupied by another pilet will result in no change.
|
|
56
|
+
* @param name The name of the data to store.
|
|
57
|
+
* @param value The value of the data to store.
|
|
58
|
+
* @param options The optional configuration for storing this piece of data.
|
|
59
|
+
* @returns True if the data could be set, otherwise false.
|
|
60
|
+
*/
|
|
61
|
+
setData<TKey extends string>(name: TKey, value: SharedData[TKey], options?: DataStoreOptions): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Registers a route for predefined page component.
|
|
64
|
+
* The route needs to be unique and can contain params.
|
|
65
|
+
* Params are following the path-to-regexp notation, e.g., :id for an id parameter.
|
|
66
|
+
* @param route The route to register.
|
|
67
|
+
* @param Component The component to render the page.
|
|
68
|
+
* @param meta The optional metadata to use.
|
|
69
|
+
*/
|
|
70
|
+
registerPage(route: string, Component: AnyComponent<PageComponentProps>, meta?: PiralPageMeta): RegistrationDisposer;
|
|
71
|
+
/**
|
|
72
|
+
* Unregisters the page identified by the given route.
|
|
73
|
+
* @param route The route that was previously registered.
|
|
74
|
+
*/
|
|
75
|
+
unregisterPage(route: string): void;
|
|
405
76
|
/**
|
|
406
|
-
*
|
|
77
|
+
* Registers an extension component with a predefined extension component.
|
|
78
|
+
* The name must refer to the extension slot.
|
|
79
|
+
* @param name The global name of the extension slot.
|
|
80
|
+
* @param Component The component to be rendered.
|
|
81
|
+
* @param defaults Optionally, sets the default values for the expected data.
|
|
407
82
|
*/
|
|
408
|
-
|
|
83
|
+
registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>, defaults?: Partial<ExtensionParams<TName>>): RegistrationDisposer;
|
|
84
|
+
/**
|
|
85
|
+
* Unregisters a global extension component.
|
|
86
|
+
* Only previously registered extension components can be unregistered.
|
|
87
|
+
* @param name The name of the extension slot to unregister from.
|
|
88
|
+
* @param Component The registered extension component to unregister.
|
|
89
|
+
*/
|
|
90
|
+
unregisterExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>): void;
|
|
91
|
+
/**
|
|
92
|
+
* React component for displaying extensions for a given name.
|
|
93
|
+
* @param props The extension's rendering props.
|
|
94
|
+
* @return The created React element.
|
|
95
|
+
*/
|
|
96
|
+
Extension<TName>(props: ExtensionSlotProps<TName>): React.ReactElement | null;
|
|
97
|
+
/**
|
|
98
|
+
* Renders an extension in a plain DOM component.
|
|
99
|
+
* @param element The DOM element or shadow root as a container for rendering the extension.
|
|
100
|
+
* @param props The extension's rendering props.
|
|
101
|
+
* @return The disposer to clear the extension.
|
|
102
|
+
*/
|
|
103
|
+
renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
|
|
104
|
+
}
|
|
409
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Describes the metadata of a pilet available in its API.
|
|
108
|
+
*/
|
|
109
|
+
export interface PiletMetadata {
|
|
110
|
+
/**
|
|
111
|
+
* The name of the pilet, i.e., the package id.
|
|
112
|
+
*/
|
|
113
|
+
name: string;
|
|
114
|
+
/**
|
|
115
|
+
* The version of the pilet. Should be semantically versioned.
|
|
116
|
+
*/
|
|
117
|
+
version: string;
|
|
118
|
+
/**
|
|
119
|
+
* Provides the version of the specification for this pilet.
|
|
120
|
+
*/
|
|
121
|
+
spec: string;
|
|
122
|
+
/**
|
|
123
|
+
* Provides some custom metadata for the pilet.
|
|
124
|
+
*/
|
|
125
|
+
custom?: any;
|
|
126
|
+
/**
|
|
127
|
+
* Optionally indicates the global require reference, if any.
|
|
128
|
+
*/
|
|
129
|
+
requireRef?: string;
|
|
410
130
|
/**
|
|
411
|
-
*
|
|
131
|
+
* Additional shared dependencies from the pilet.
|
|
412
132
|
*/
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
133
|
+
dependencies: Record<string, string>;
|
|
134
|
+
/**
|
|
135
|
+
* Provides some configuration to be used in the pilet.
|
|
136
|
+
*/
|
|
137
|
+
config: Record<string, any>;
|
|
138
|
+
/**
|
|
139
|
+
* The URL of the main script of the pilet.
|
|
140
|
+
*/
|
|
141
|
+
link: string;
|
|
142
|
+
/**
|
|
143
|
+
* The base path to the pilet. Can be used to make resource requests
|
|
144
|
+
* and override the public path.
|
|
145
|
+
*/
|
|
146
|
+
basePath: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Listener for Piral app shell events.
|
|
151
|
+
*/
|
|
152
|
+
export interface Listener<T> {
|
|
153
|
+
/**
|
|
154
|
+
* Receives an event of type T.
|
|
155
|
+
*/
|
|
156
|
+
(arg: T): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The map of known Piral app shell events.
|
|
161
|
+
*/
|
|
162
|
+
export interface PiralEventMap extends PiralCustomEventMap {
|
|
163
|
+
"unload-pilet": PiralUnloadPiletEvent;
|
|
164
|
+
[custom: string]: any;
|
|
165
|
+
"store-data": PiralStoreDataEvent;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface AuthApi {
|
|
169
|
+
/**
|
|
170
|
+
* Gets the currently authenticated user, if any.
|
|
171
|
+
*/
|
|
172
|
+
getToken(): Promise<User | undefined>;
|
|
173
|
+
/**
|
|
174
|
+
* Checks if the user has one of the `requiredPermissions`.
|
|
175
|
+
*/
|
|
176
|
+
checkPermission(requiredPermissions: UserPermissions): Promise<boolean>;
|
|
177
|
+
}
|
|
416
178
|
|
|
179
|
+
export interface EnvironmentApi {
|
|
417
180
|
/**
|
|
418
|
-
*
|
|
181
|
+
* Returns current portal environment
|
|
419
182
|
*/
|
|
420
|
-
|
|
183
|
+
getEnvironment(): PortalConfiguration;
|
|
184
|
+
}
|
|
421
185
|
|
|
186
|
+
export interface HomeApi {
|
|
422
187
|
/**
|
|
423
|
-
*
|
|
188
|
+
* Registers a tile with preferences.
|
|
189
|
+
* The name has to be unique within the Current pilet.
|
|
190
|
+
* @param data HomeTileData or AdminTileData object with the details of the tile.
|
|
191
|
+
* @param registerNavItem if item needs to be added to navigation registry, defaults to true
|
|
192
|
+
* @example
|
|
193
|
+
* app.registerTile({
|
|
194
|
+
* kind: 'home',
|
|
195
|
+
* name: 'service',
|
|
196
|
+
* path: '/service-packages',
|
|
197
|
+
* label: 'Service Packages',
|
|
198
|
+
* icon: require('./images/service-packages.svg'),
|
|
199
|
+
* type: 'large',
|
|
200
|
+
* });
|
|
201
|
+
* @example
|
|
202
|
+
* app.registerTile({
|
|
203
|
+
* kind: 'settings',
|
|
204
|
+
* name: 'service',
|
|
205
|
+
* groupName: 'Users',
|
|
206
|
+
* path: '/users/roles',
|
|
207
|
+
* label: 'Roles',
|
|
208
|
+
* icon: require('./images/roles.svg'),
|
|
209
|
+
* })
|
|
424
210
|
*/
|
|
425
|
-
|
|
211
|
+
registerTile(data: AnyTile, registerNavItem?: boolean): RegistrationDisposer;
|
|
212
|
+
/**
|
|
213
|
+
* Unregisters a tile known by the given name.
|
|
214
|
+
* Only previously registered tiles can be unregistered.
|
|
215
|
+
* @param name The name of the tile to unregister.
|
|
216
|
+
*/
|
|
217
|
+
unregisterTile(name: string): void;
|
|
218
|
+
/**
|
|
219
|
+
* Use this to set a function that will be called to determine the order of the tiles on the home station.
|
|
220
|
+
* @param sorter Sorter function.
|
|
221
|
+
*/
|
|
222
|
+
setHomeTileSorter(sorter: TileSorter<HomeTileData>): void;
|
|
223
|
+
/**
|
|
224
|
+
* Creates a connector for wrapping home with data relations.
|
|
225
|
+
*/
|
|
226
|
+
createHomeConnector(): HomeStateContainer;
|
|
227
|
+
}
|
|
426
228
|
|
|
229
|
+
export interface RegistrationInfoApi {
|
|
230
|
+
/**
|
|
231
|
+
* Registered page components for the router
|
|
232
|
+
* @return Key value pair with registered route as key and it's page component as value
|
|
233
|
+
*/
|
|
234
|
+
getRegisteredPages: GetRegisteredPages;
|
|
427
235
|
/**
|
|
428
|
-
*
|
|
236
|
+
* Registered extension components for extension slots
|
|
237
|
+
* @return Key value pair with extension slot name as key and array of it's components as a value
|
|
429
238
|
*/
|
|
430
|
-
|
|
239
|
+
getRegisteredExtensions: GetRegisteredExtensions;
|
|
240
|
+
/**
|
|
241
|
+
* @return metadata for currently loaded pilets
|
|
242
|
+
*/
|
|
243
|
+
getRegisteredPilets: GetRegisteredPilets;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface NavigationApi {
|
|
247
|
+
/**
|
|
248
|
+
* Registers navigation panel item
|
|
249
|
+
* @param item Contains all details for createing navigation item
|
|
250
|
+
* @example
|
|
251
|
+
* app.registerNavigationItem({
|
|
252
|
+
* name: 'service-management',
|
|
253
|
+
* categoryName: 'Settings',
|
|
254
|
+
* path: '/settings/service-management',
|
|
255
|
+
* label: 'Service Management',
|
|
256
|
+
* });
|
|
257
|
+
* app.registerNavigationItem({
|
|
258
|
+
* name: 'service-management-feature',
|
|
259
|
+
* parentName: 'service-management',
|
|
260
|
+
* categoryName: 'Settings',
|
|
261
|
+
* path: '/settings/service-management/service-feature',
|
|
262
|
+
* label: 'Service Management',
|
|
263
|
+
* });
|
|
264
|
+
*/
|
|
265
|
+
registerNavigationItem(item: RegisterNavigationItem): () => void;
|
|
266
|
+
/**
|
|
267
|
+
* Removes registered navigation item
|
|
268
|
+
* @param name Unique name of the navigation item, that was provided on route registration
|
|
269
|
+
*/
|
|
270
|
+
unregisterNavigationItem(name: string): void;
|
|
271
|
+
/**
|
|
272
|
+
* Creates connector for wrapping component with navigation state data relations
|
|
273
|
+
*/
|
|
274
|
+
createNavigationConnector(): NavigationConnector;
|
|
275
|
+
/**
|
|
276
|
+
* Registers provided navigation item transformation function
|
|
277
|
+
* `transformer` function receives flat array of registered navigation items
|
|
278
|
+
* Use this to alter or re-order registered navigation items
|
|
279
|
+
* @param transformer function that alters navigation registry items
|
|
280
|
+
* @example
|
|
281
|
+
* app.setNavigationItemsTransformer(
|
|
282
|
+
* (navItems: NavigationItem[]): NavigationItem[] => {
|
|
283
|
+
* return navItems.map((item) => {
|
|
284
|
+
* if (item.name.includes('playground')) {
|
|
285
|
+
* item.categoryName = 'Playground';
|
|
286
|
+
* item.label = item.name.replace(/playground|-/g, ' ');
|
|
287
|
+
* item.parentName = undefined;
|
|
288
|
+
* }
|
|
289
|
+
* return item;
|
|
290
|
+
* });
|
|
291
|
+
* },
|
|
292
|
+
* );
|
|
293
|
+
*/
|
|
294
|
+
setNavigationItemsTransformer(transformer: NavigationTransformer<NavigationItem>): void;
|
|
295
|
+
/**
|
|
296
|
+
* Registers provided navigation tree transformation function
|
|
297
|
+
* `transformer` function receives navigation item tree created from registered navigation items
|
|
298
|
+
* Use this to alter or re-order navigation panel categories or their items
|
|
299
|
+
* @param transformer Function that alters navigation panel item order
|
|
300
|
+
* @example
|
|
301
|
+
* app.setNavigationTreeTransformer(
|
|
302
|
+
* (navTree: NavigationPanelCategory[]): NavigationPanelCategory[] => {
|
|
303
|
+
* return navTree.sort((a, b) =>
|
|
304
|
+
* a.categoryName.localeCompare(b.categoryName),
|
|
305
|
+
* );
|
|
306
|
+
* },
|
|
307
|
+
* );
|
|
308
|
+
*/
|
|
309
|
+
setNavigationTreeTransformer(transformer: NavigationTransformer<NavigationPanelCategory>): void;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface NotificationApi {
|
|
313
|
+
/**
|
|
314
|
+
* Displays a toast notification
|
|
315
|
+
* @param notification Notification to be shown
|
|
316
|
+
* @returns Id of the toast, used for updating or dismissing the notification
|
|
317
|
+
* @example
|
|
318
|
+
* const toastId = app.notifications.show({ title: 'Notification shown', body: 'Hello world', options: { type: 'error', autoClose: false } });
|
|
319
|
+
*/
|
|
320
|
+
showNotification: ShowNotification;
|
|
321
|
+
/**
|
|
322
|
+
* Updates a toast notification
|
|
323
|
+
* @param id toastId to be updated (returned from 'show' method call)
|
|
324
|
+
* @param notification Updated notification
|
|
325
|
+
* @example
|
|
326
|
+
* app.notifications.update(toastId, { title: 'Notification updated', body: 'Hello world' });
|
|
327
|
+
*/
|
|
328
|
+
updateNotification: UpdateNotification;
|
|
329
|
+
/**
|
|
330
|
+
* Dismisses a toast notification
|
|
331
|
+
* @param id toastId to be dismissed (returned from 'show' method call)
|
|
332
|
+
* @example
|
|
333
|
+
* app.notifications.dismiss(toastId);
|
|
334
|
+
*/
|
|
335
|
+
dismissNotification: DismissNotification;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export interface ProviderApi {
|
|
339
|
+
/**
|
|
340
|
+
* Creates a provider object using the 'type' property. Assigns data and converter args to an array of objects as its value. If the 'type' already exists, the data will be appended to the array.
|
|
341
|
+
* @param type provider name
|
|
342
|
+
* @param data provider data
|
|
343
|
+
* @param converter function used to transformation
|
|
344
|
+
* @example
|
|
345
|
+
* // new provider
|
|
346
|
+
* app.addProvider<Example>(
|
|
347
|
+
* 'fast-provider',
|
|
348
|
+
* data: { type: 'movie' });
|
|
349
|
+
* // appends object to 'fast-provider'array
|
|
350
|
+
* app.addProvider(
|
|
351
|
+
* 'fast-provider',,
|
|
352
|
+
* data: { type: 'episode' });
|
|
353
|
+
*/
|
|
354
|
+
addProvider: ProviderRegistration;
|
|
355
|
+
/**
|
|
356
|
+
* Returns an array of data associated with a specific provider
|
|
357
|
+
* @param type Unique value of the provider 'type'
|
|
358
|
+
* @example
|
|
359
|
+
* app.getProviders('fast-provider');
|
|
360
|
+
*/
|
|
361
|
+
getProviders: GetProviders;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export interface NavigationResolverApi {
|
|
365
|
+
/**
|
|
366
|
+
* Register a resolver function for a station
|
|
367
|
+
* @param data
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* app.registerRouteResolver({
|
|
371
|
+
* station: 'movie-details',
|
|
372
|
+
* resolver: (dynamicRouteSegments?: string[]) => {
|
|
373
|
+
* return dynamicRouteSegments?.length
|
|
374
|
+
* ? `/movies/${dynamicRouteSegments[0]}`
|
|
375
|
+
* : undefined;
|
|
376
|
+
* },
|
|
377
|
+
* });
|
|
378
|
+
* ```
|
|
379
|
+
*/
|
|
380
|
+
registerRouteResolver(data: ResolverData): void;
|
|
381
|
+
/**
|
|
382
|
+
* Resolves a route for a given station
|
|
383
|
+
* @param station Name of the station
|
|
384
|
+
* @param dynamicRouteSegments Dynamic route segments
|
|
385
|
+
* @returns Resolved route
|
|
386
|
+
* @example
|
|
387
|
+
* ```ts
|
|
388
|
+
* const entityId = '123'
|
|
389
|
+
* const route = app.resolveRoute('movie-details', [entityId]);
|
|
390
|
+
* ```
|
|
391
|
+
*/
|
|
392
|
+
resolveRoute: ResolverFunction;
|
|
393
|
+
/**
|
|
394
|
+
* Returns resolvers from navigation registry
|
|
395
|
+
* @returns All registered route resolvers
|
|
396
|
+
*/
|
|
397
|
+
getAllRouteResolvers(): NavigationResolverRegistryState["navigationResolvers"];
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Defines the shape of the data store for storing shared data.
|
|
402
|
+
*/
|
|
403
|
+
export interface SharedData<TValue = any> {
|
|
404
|
+
[key: string]: TValue;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Defines the options to be used for storing data.
|
|
409
|
+
*/
|
|
410
|
+
export type DataStoreOptions = DataStoreTarget | CustomDataStoreOptions;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Possible shapes for a component.
|
|
414
|
+
*/
|
|
415
|
+
export type AnyComponent<T> = React.ComponentType<T> | FirstParametersOf<ComponentConverters<T>>;
|
|
431
416
|
|
|
417
|
+
/**
|
|
418
|
+
* The props used by a page component.
|
|
419
|
+
*/
|
|
420
|
+
export interface PageComponentProps<T extends {
|
|
421
|
+
[K in keyof T]?: string;
|
|
422
|
+
} = {}, S = any> extends RouteBaseProps<T, S> {
|
|
432
423
|
/**
|
|
433
|
-
*
|
|
424
|
+
* The meta data registered with the page.
|
|
434
425
|
*/
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
426
|
+
meta: PiralPageMeta;
|
|
427
|
+
/**
|
|
428
|
+
* The children of the page.
|
|
429
|
+
*/
|
|
430
|
+
children: React.ReactNode;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* The meta data registered for a page.
|
|
435
|
+
*/
|
|
436
|
+
export interface PiralPageMeta extends PiralCustomPageMeta, PiralCustomPageMeta {}
|
|
441
437
|
|
|
438
|
+
/**
|
|
439
|
+
* The shape of an implicit unregister function.
|
|
440
|
+
*/
|
|
441
|
+
export interface RegistrationDisposer {
|
|
442
442
|
/**
|
|
443
|
-
*
|
|
443
|
+
* Cleans up the previous registration.
|
|
444
444
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
* The name of the item that was stored.
|
|
448
|
-
*/
|
|
449
|
-
name: string;
|
|
450
|
-
/**
|
|
451
|
-
* The storage target of the item.
|
|
452
|
-
*/
|
|
453
|
-
target: string;
|
|
454
|
-
/**
|
|
455
|
-
* The value that was stored.
|
|
456
|
-
*/
|
|
457
|
-
value: TValue;
|
|
458
|
-
/**
|
|
459
|
-
* The owner of the item.
|
|
460
|
-
*/
|
|
461
|
-
owner: string;
|
|
462
|
-
/**
|
|
463
|
-
* The expiration of the item.
|
|
464
|
-
*/
|
|
465
|
-
expires: number;
|
|
466
|
-
}
|
|
445
|
+
(): void;
|
|
446
|
+
}
|
|
467
447
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
profilePictureUrl: string;
|
|
473
|
-
token: UserToken;
|
|
474
|
-
}
|
|
448
|
+
/**
|
|
449
|
+
* Shorthand for the definition of an extension component.
|
|
450
|
+
*/
|
|
451
|
+
export type AnyExtensionComponent<TName> = TName extends keyof PiralExtensionSlotMap ? AnyComponent<ExtensionComponentProps<TName>> : TName extends string ? AnyComponent<ExtensionComponentProps<any>> : AnyComponent<ExtensionComponentProps<TName>>;
|
|
475
452
|
|
|
476
|
-
|
|
453
|
+
/**
|
|
454
|
+
* Gives the extension params shape for the given extension slot name.
|
|
455
|
+
*/
|
|
456
|
+
export type ExtensionParams<TName> = TName extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[TName] : TName extends string ? any : TName;
|
|
477
457
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
idServiceAuthEndpoint: string;
|
|
483
|
-
}
|
|
458
|
+
/**
|
|
459
|
+
* The props for defining an extension slot.
|
|
460
|
+
*/
|
|
461
|
+
export type ExtensionSlotProps<TName = string> = BaseExtensionSlotProps<TName extends string ? TName : string, ExtensionParams<TName>>;
|
|
484
462
|
|
|
485
|
-
|
|
463
|
+
/**
|
|
464
|
+
* Can be implemented by functions to be used for disposal purposes.
|
|
465
|
+
*/
|
|
466
|
+
export interface Disposable {
|
|
467
|
+
/**
|
|
468
|
+
* Disposes the created resource.
|
|
469
|
+
*/
|
|
470
|
+
(): void;
|
|
471
|
+
}
|
|
486
472
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
473
|
+
/**
|
|
474
|
+
* Custom events defined outside of piral-core.
|
|
475
|
+
*/
|
|
476
|
+
export interface PiralCustomEventMap {}
|
|
490
477
|
|
|
478
|
+
/**
|
|
479
|
+
* Gets fired when a pilet gets unloaded.
|
|
480
|
+
*/
|
|
481
|
+
export interface PiralUnloadPiletEvent {
|
|
491
482
|
/**
|
|
492
|
-
*
|
|
483
|
+
* The name of the pilet to be unloaded.
|
|
493
484
|
*/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
* Type Tag
|
|
497
|
-
*/
|
|
498
|
-
kind: "home";
|
|
499
|
-
/**
|
|
500
|
-
* Unique name of the Home Tile. This value needs to be unique for the Pilet.
|
|
501
|
-
*/
|
|
502
|
-
name?: string;
|
|
503
|
-
}
|
|
485
|
+
name: string;
|
|
486
|
+
}
|
|
504
487
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
export interface NavigationConnector {
|
|
531
|
-
<TProps>(component: React.ComponentType<TProps & NavigationConnectorProps>): React.FC<TProps>;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
export interface NavigationTransformer<T> {
|
|
535
|
-
(items: Array<T>): Array<T>;
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
export interface NavigationItem extends RegisterNavigationItem {
|
|
539
|
-
/**
|
|
540
|
-
* Unique name of the navigation item provided on registration (auto generated in case not provided)
|
|
541
|
-
*/
|
|
542
|
-
readonly name: string;
|
|
543
|
-
/**
|
|
544
|
-
* Name of the pilet registering navigation item
|
|
545
|
-
*/
|
|
546
|
-
pilet: string;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
export interface NavigationPanelCategory {
|
|
550
|
-
/**
|
|
551
|
-
* Name of the category under which navigation items will be listed
|
|
552
|
-
*/
|
|
553
|
-
categoryName: string;
|
|
554
|
-
/**
|
|
555
|
-
* Navigation items
|
|
556
|
-
*/
|
|
557
|
-
items: Array<NavigationPanelItem>;
|
|
558
|
-
}
|
|
488
|
+
/**
|
|
489
|
+
* Gets fired when a data item gets stored in piral.
|
|
490
|
+
*/
|
|
491
|
+
export interface PiralStoreDataEvent<TValue = any> {
|
|
492
|
+
/**
|
|
493
|
+
* The name of the item that was stored.
|
|
494
|
+
*/
|
|
495
|
+
name: string;
|
|
496
|
+
/**
|
|
497
|
+
* The storage target of the item.
|
|
498
|
+
*/
|
|
499
|
+
target: string;
|
|
500
|
+
/**
|
|
501
|
+
* The value that was stored.
|
|
502
|
+
*/
|
|
503
|
+
value: TValue;
|
|
504
|
+
/**
|
|
505
|
+
* The owner of the item.
|
|
506
|
+
*/
|
|
507
|
+
owner: string;
|
|
508
|
+
/**
|
|
509
|
+
* The expiration of the item.
|
|
510
|
+
*/
|
|
511
|
+
expires: number;
|
|
512
|
+
}
|
|
559
513
|
|
|
560
|
-
|
|
514
|
+
export interface User {
|
|
515
|
+
id: string;
|
|
516
|
+
name: string;
|
|
517
|
+
email: string;
|
|
518
|
+
profilePictureUrl: string;
|
|
519
|
+
token: UserToken;
|
|
520
|
+
}
|
|
561
521
|
|
|
562
|
-
|
|
522
|
+
export type UserPermissions = UserToken["permissions"];
|
|
563
523
|
|
|
564
|
-
|
|
524
|
+
export interface PortalConfiguration {
|
|
525
|
+
tenantId: string;
|
|
526
|
+
environmentId: string;
|
|
527
|
+
microFrontendServiceEndpoint: string;
|
|
528
|
+
idServiceAuthEndpoint: string;
|
|
529
|
+
}
|
|
565
530
|
|
|
566
|
-
|
|
567
|
-
(type: never, data: object): void;
|
|
568
|
-
}
|
|
531
|
+
export type AnyTile = HomeTileData | SettingsTileData;
|
|
569
532
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
533
|
+
export interface TileSorter<T extends AnyTile> {
|
|
534
|
+
(tiles: Array<T>): Array<T>;
|
|
535
|
+
}
|
|
573
536
|
|
|
537
|
+
/**
|
|
538
|
+
* Data item for Dashboard Tile
|
|
539
|
+
*/
|
|
540
|
+
export interface HomeTileData extends LandingPageItem {
|
|
574
541
|
/**
|
|
575
|
-
*
|
|
542
|
+
* Type Tag
|
|
576
543
|
*/
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
* Route resolver function
|
|
584
|
-
*/
|
|
585
|
-
resolver: NavigationResolver;
|
|
586
|
-
}
|
|
544
|
+
kind: "home";
|
|
545
|
+
/**
|
|
546
|
+
* Unique name of the Home Tile. This value needs to be unique for the Pilet.
|
|
547
|
+
*/
|
|
548
|
+
name?: string;
|
|
549
|
+
}
|
|
587
550
|
|
|
551
|
+
export interface HomeStateContainer {
|
|
588
552
|
/**
|
|
589
|
-
*
|
|
553
|
+
* State container connector function for wrapping a component. TProps generic can be used to define custom props for the component.
|
|
554
|
+
* @param component The component to connect by providing a state.
|
|
590
555
|
*/
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* The registered navigation resolvers
|
|
599
|
-
* @example
|
|
600
|
-
* ```ts
|
|
601
|
-
* {
|
|
602
|
-
* 'movie-details': (dynamicRouteSegments?: string[]) => dynamicRouteSegments?.length
|
|
603
|
-
* ? `/movies/${dynamicRouteSegments[0]}`
|
|
604
|
-
* : undefined
|
|
605
|
-
* },
|
|
606
|
-
* ```
|
|
607
|
-
*/
|
|
608
|
-
navigationResolvers: {
|
|
609
|
-
[key: string]: NavigationResolver;
|
|
610
|
-
};
|
|
611
|
-
}
|
|
556
|
+
<TProps>(component: React.ComponentType<TProps & HomeStateConnectorProps>): React.FC<TProps>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export type GetRegisteredPages = () => Dict<PageRegistration>;
|
|
560
|
+
|
|
561
|
+
export type GetRegisteredExtensions = () => Dict<Array<ExtensionRegistration>>;
|
|
612
562
|
|
|
563
|
+
export type GetRegisteredPilets = () => Array<PiletMetadata>;
|
|
564
|
+
|
|
565
|
+
export interface RegisterNavigationItem extends Omit<NavigationPanelItem, "items" | "name"> {
|
|
566
|
+
/**
|
|
567
|
+
* Title of category under which navigation item will be displayed
|
|
568
|
+
*/
|
|
569
|
+
categoryName: string;
|
|
570
|
+
/**
|
|
571
|
+
* Unique name of the navigation item.
|
|
572
|
+
*/
|
|
573
|
+
name?: string;
|
|
613
574
|
/**
|
|
614
|
-
*
|
|
615
|
-
*/
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
/**
|
|
619
|
-
* Defines the custom options for storing data.
|
|
620
|
-
*/
|
|
621
|
-
export interface CustomDataStoreOptions {
|
|
622
|
-
/**
|
|
623
|
-
* The target data store. By default the data is only stored in memory.
|
|
624
|
-
*/
|
|
625
|
-
target?: DataStoreTarget;
|
|
626
|
-
/**
|
|
627
|
-
* Optionally determines when the data expires.
|
|
628
|
-
*/
|
|
629
|
-
expires?: "never" | Date | number;
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
export type FirstParametersOf<T> = {
|
|
633
|
-
[K in keyof T]: T[K] extends (arg: any) => any ? FirstParameter<T[K]> : never;
|
|
634
|
-
}[keyof T];
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Mapping of available component converters.
|
|
638
|
-
*/
|
|
639
|
-
export interface ComponentConverters<TProps> extends PiralCustomComponentConverters<TProps> {
|
|
640
|
-
/**
|
|
641
|
-
* Converts the HTML component to a framework-independent component.
|
|
642
|
-
* @param component The vanilla JavaScript component to be converted.
|
|
643
|
-
*/
|
|
644
|
-
html(component: HtmlComponent<TProps>): ForeignComponent<TProps>;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* The props that every registered page component obtains.
|
|
649
|
-
*/
|
|
650
|
-
export interface RouteBaseProps<UrlParams = any, UrlState = any> extends ReactRouter.RouteComponentProps<UrlParams, {}, UrlState>, BaseComponentProps {}
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* Custom meta data to include for pages.
|
|
654
|
-
*/
|
|
655
|
-
export interface PiralCustomPageMeta extends BreadCrumbMeta, PermissionMeta {}
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* The props that every registered component obtains.
|
|
659
|
-
*/
|
|
660
|
-
export interface BaseComponentProps {
|
|
661
|
-
/**
|
|
662
|
-
* The currently used pilet API.
|
|
663
|
-
*/
|
|
664
|
-
piral: PiletApi;
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
* The mapping of the existing (known) extension slots.
|
|
669
|
-
*/
|
|
670
|
-
export interface PiralExtensionSlotMap extends PiralCustomExtensionSlotMap {}
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* The basic props for defining an extension slot.
|
|
674
|
-
*/
|
|
675
|
-
export interface BaseExtensionSlotProps<TName, TParams> {
|
|
676
|
-
/**
|
|
677
|
-
* Defines what should be rendered when no components are available
|
|
678
|
-
* for the specified extension.
|
|
679
|
-
*/
|
|
680
|
-
empty?(): React.ReactNode;
|
|
681
|
-
/**
|
|
682
|
-
* Defines how the provided nodes should be rendered.
|
|
683
|
-
* @param nodes The rendered extension nodes.
|
|
684
|
-
*/
|
|
685
|
-
render?(nodes: Array<React.ReactNode>): React.ReactElement<any, any> | null;
|
|
686
|
-
/**
|
|
687
|
-
* The custom parameters for the given extension.
|
|
688
|
-
*/
|
|
689
|
-
params?: TParams;
|
|
690
|
-
/**
|
|
691
|
-
* The name of the extension to render.
|
|
692
|
-
*/
|
|
693
|
-
name: TName;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
/**
|
|
697
|
-
* Metadata for pilets using the v0 schema.
|
|
698
|
-
*/
|
|
699
|
-
export type PiletMetadataV0 = PiletMetadataV0Content | PiletMetadataV0Link;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Metadata for pilets using the v1 schema.
|
|
703
|
-
*/
|
|
704
|
-
export interface PiletMetadataV1 {
|
|
705
|
-
/**
|
|
706
|
-
* The name of the pilet, i.e., the package id.
|
|
707
|
-
*/
|
|
708
|
-
name: string;
|
|
709
|
-
/**
|
|
710
|
-
* The version of the pilet. Should be semantically versioned.
|
|
711
|
-
*/
|
|
712
|
-
version: string;
|
|
713
|
-
/**
|
|
714
|
-
* Optionally provides the version of the specification for this pilet.
|
|
715
|
-
*/
|
|
716
|
-
spec?: "v1";
|
|
717
|
-
/**
|
|
718
|
-
* The link for retrieving the content of the pilet.
|
|
719
|
-
*/
|
|
720
|
-
link: string;
|
|
721
|
-
/**
|
|
722
|
-
* The reference name for the global require.
|
|
723
|
-
*/
|
|
724
|
-
requireRef: string;
|
|
725
|
-
/**
|
|
726
|
-
* The computed integrity of the pilet. Will be used to set the
|
|
727
|
-
* integrity value of the script.
|
|
728
|
-
*/
|
|
729
|
-
integrity?: string;
|
|
730
|
-
/**
|
|
731
|
-
* Optionally provides some custom metadata for the pilet.
|
|
732
|
-
*/
|
|
733
|
-
custom?: any;
|
|
734
|
-
/**
|
|
735
|
-
* Optionally provides some configuration to be used in the pilet.
|
|
736
|
-
*/
|
|
737
|
-
config?: Record<string, any>;
|
|
738
|
-
/**
|
|
739
|
-
* Additional shared dependency script files.
|
|
740
|
-
*/
|
|
741
|
-
dependencies?: Record<string, string>;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
export interface PiletMetadataVx {
|
|
745
|
-
/**
|
|
746
|
-
* The name of the pilet, i.e., the package id.
|
|
747
|
-
*/
|
|
748
|
-
name: string;
|
|
749
|
-
/**
|
|
750
|
-
* The version of the pilet. Should be semantically versioned.
|
|
751
|
-
*/
|
|
752
|
-
version: string;
|
|
753
|
-
/**
|
|
754
|
-
* Provides an identifier for the custom specification.
|
|
755
|
-
*/
|
|
756
|
-
spec: string;
|
|
757
|
-
/**
|
|
758
|
-
* Optionally provides some custom metadata for the pilet.
|
|
759
|
-
*/
|
|
760
|
-
custom?: any;
|
|
761
|
-
/**
|
|
762
|
-
* Optionally provides some configuration to be used in the pilet.
|
|
763
|
-
*/
|
|
764
|
-
config?: Record<string, any>;
|
|
765
|
-
/**
|
|
766
|
-
* Additional shared dependency script files.
|
|
767
|
-
*/
|
|
768
|
-
dependencies?: Record<string, string>;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* Metadata for pilets using the bundle schema.
|
|
773
|
-
*/
|
|
774
|
-
export interface PiletMetadataBundle {
|
|
775
|
-
/**
|
|
776
|
-
* The name of the bundle pilet, i.e., the package id.
|
|
777
|
-
*/
|
|
778
|
-
name?: string;
|
|
779
|
-
/**
|
|
780
|
-
* Optionally provides the version of the specification for this pilet.
|
|
781
|
-
*/
|
|
782
|
-
spec?: "v1";
|
|
783
|
-
/**
|
|
784
|
-
* The link for retrieving the bundle content of the pilet.
|
|
785
|
-
*/
|
|
786
|
-
link: string;
|
|
787
|
-
/**
|
|
788
|
-
* The reference name for the global bundle-shared require.
|
|
789
|
-
*/
|
|
790
|
-
bundle: string;
|
|
791
|
-
/**
|
|
792
|
-
* The computed integrity of the pilet. Will be used to set the
|
|
793
|
-
* integrity value of the script.
|
|
794
|
-
*/
|
|
795
|
-
integrity?: string;
|
|
796
|
-
/**
|
|
797
|
-
* Optionally provides some custom metadata for the pilet.
|
|
798
|
-
*/
|
|
799
|
-
custom?: any;
|
|
800
|
-
/**
|
|
801
|
-
* Additional shared dependency script files.
|
|
802
|
-
*/
|
|
803
|
-
dependencies?: Record<string, string>;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
export interface UserToken {
|
|
807
|
-
accessToken: string;
|
|
808
|
-
expiresInSeconds: number;
|
|
809
|
-
permissions: {
|
|
810
|
-
[serviceId: string]: Array<string>;
|
|
811
|
-
};
|
|
812
|
-
tags: Array<string>;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
/**
|
|
816
|
-
* Data item for Settings page
|
|
817
|
-
*/
|
|
818
|
-
export interface SettingsTileData extends HubItem {
|
|
819
|
-
/**
|
|
820
|
-
* Type Tag
|
|
821
|
-
*/
|
|
822
|
-
kind: "settings";
|
|
823
|
-
/**
|
|
824
|
-
* Unique name of the Home Tile. This value needs to be unique for the Pilet.
|
|
825
|
-
*/
|
|
826
|
-
name?: string;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
export interface LandingPageItem {
|
|
830
|
-
/**
|
|
831
|
-
* url path
|
|
832
|
-
*/
|
|
833
|
-
path: string;
|
|
834
|
-
/**
|
|
835
|
-
* Tile label
|
|
836
|
-
*/
|
|
837
|
-
label: string;
|
|
838
|
-
/**
|
|
839
|
-
* Icon location or an react element of svg icon.
|
|
840
|
-
* if an react element of svg is passed, the correct style for two types ("small" and "large") will be applied accordingly
|
|
841
|
-
* The styles which don't want to be affected based on the tile type can be passed as inline styles.
|
|
842
|
-
*/
|
|
843
|
-
icon: string | React.ReactNode;
|
|
844
|
-
/**
|
|
845
|
-
* Tile type
|
|
846
|
-
*/
|
|
847
|
-
type: "small" | "large";
|
|
848
|
-
/**
|
|
849
|
-
* Tile is disabled or enabled, default is false
|
|
850
|
-
*/
|
|
851
|
-
disabled?: boolean;
|
|
852
|
-
/**
|
|
853
|
-
* Subtitle resolver
|
|
854
|
-
*/
|
|
855
|
-
subtitle?: ValueOrOnDemand;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
export interface HomeStateConnectorProps {
|
|
859
|
-
/**
|
|
860
|
-
* Home Tile data currently available in the state.
|
|
861
|
-
*/
|
|
862
|
-
homeTileData: Array<HomeTileData>;
|
|
863
|
-
/**
|
|
864
|
-
* Settings Tile data currently available in the state.
|
|
865
|
-
*/
|
|
866
|
-
settingsTileData: Array<SettingsTileData>;
|
|
867
|
-
tileSorter?: TileSorter<HomeTileData>;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
export type Dict<T> = Record<string, T>;
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* The interface modeling the registration of a pilet page component.
|
|
874
|
-
*/
|
|
875
|
-
export interface PageRegistration extends BaseRegistration {
|
|
876
|
-
component: WrappedComponent<PageComponentProps>;
|
|
877
|
-
meta: PiralPageMeta;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
/**
|
|
881
|
-
* The interface modeling the registration of a pilet extension component.
|
|
882
|
-
*/
|
|
883
|
-
export interface ExtensionRegistration extends BaseRegistration {
|
|
884
|
-
component: WrappedComponent<ExtensionComponentProps<string>>;
|
|
885
|
-
reference: any;
|
|
886
|
-
defaults: any;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
export interface NavigationPanelItem {
|
|
890
|
-
/**
|
|
891
|
-
* Unique name of the navigation item provided on registration (auto generated in case not provided)
|
|
892
|
-
*/
|
|
893
|
-
readonly name: string;
|
|
894
|
-
/**
|
|
895
|
-
* Menu item label text
|
|
896
|
-
*/
|
|
897
|
-
label: string;
|
|
898
|
-
/**
|
|
899
|
-
* Icon displayed with label
|
|
900
|
-
*/
|
|
901
|
-
icon?: string | React.ReactNode;
|
|
902
|
-
/**
|
|
903
|
-
* URL path
|
|
904
|
-
*/
|
|
905
|
-
path?: string;
|
|
906
|
-
/**
|
|
907
|
-
* Child navigation items, nested beneath drop down
|
|
908
|
-
*/
|
|
909
|
-
items?: Array<NavigationPanelItem>;
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
export interface NavigationConnectorProps {
|
|
913
|
-
/**
|
|
914
|
-
* Registered navigation items
|
|
915
|
-
*/
|
|
916
|
-
items: Array<NavigationItem>;
|
|
917
|
-
/**
|
|
918
|
-
* registered navigation registry item transformer
|
|
919
|
-
*/
|
|
920
|
-
itemsTransformer?: NavigationTransformer<NavigationItem>;
|
|
921
|
-
/**
|
|
922
|
-
* Registered navigation tree transformer
|
|
923
|
-
*/
|
|
924
|
-
treeTransformer?: NavigationTransformer<NavigationPanelCategory>;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
export interface Notification {
|
|
928
|
-
/**
|
|
929
|
-
* Title shown in toast messages header
|
|
930
|
-
*/
|
|
931
|
-
title: string;
|
|
932
|
-
/**
|
|
933
|
-
* Optional body of the notification
|
|
934
|
-
*/
|
|
935
|
-
body?: NotificationBody;
|
|
936
|
-
/**
|
|
937
|
-
* Additional options for the notification
|
|
938
|
-
*/
|
|
939
|
-
options?: NotificationOptions;
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
export type NotificationId = string | number;
|
|
943
|
-
|
|
944
|
-
/**
|
|
945
|
-
* Navigation resolver function for resolver registration
|
|
946
|
-
*/
|
|
947
|
-
export type NavigationResolver = (dynamicRouteSegments?: Array<string>) => string | undefined;
|
|
948
|
-
|
|
949
|
-
export type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
|
|
950
|
-
|
|
951
|
-
/**
|
|
952
|
-
* Custom component converters defined outside of piral-core.
|
|
953
|
-
*/
|
|
954
|
-
export interface PiralCustomComponentConverters<TProps> {}
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Definition of a vanilla JavaScript component.
|
|
958
|
-
*/
|
|
959
|
-
export interface HtmlComponent<TProps> {
|
|
960
|
-
/**
|
|
961
|
-
* Renders a component into the provided element using the given props and context.
|
|
962
|
-
*/
|
|
963
|
-
component: ForeignComponent<TProps>;
|
|
964
|
-
/**
|
|
965
|
-
* The type of the HTML component.
|
|
966
|
-
*/
|
|
967
|
-
type: "html";
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
/**
|
|
971
|
-
* Generic definition of a framework-independent component.
|
|
972
|
-
*/
|
|
973
|
-
export interface ForeignComponent<TProps> {
|
|
974
|
-
/**
|
|
975
|
-
* Called when the component is mounted.
|
|
976
|
-
* @param element The container hosting the element.
|
|
977
|
-
* @param props The props to transport.
|
|
978
|
-
* @param ctx The associated context.
|
|
979
|
-
*/
|
|
980
|
-
mount(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
|
|
981
|
-
/**
|
|
982
|
-
* Called when the component should be updated.
|
|
983
|
-
* @param element The container hosting the element.
|
|
984
|
-
* @param props The props to transport.
|
|
985
|
-
* @param ctx The associated context.
|
|
986
|
-
*/
|
|
987
|
-
update?(element: HTMLElement, props: TProps, ctx: ComponentContext): void;
|
|
988
|
-
/**
|
|
989
|
-
* Called when a component is unmounted.
|
|
990
|
-
* @param element The container that was hosting the element.
|
|
991
|
-
*/
|
|
992
|
-
unmount?(element: HTMLElement): void;
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
export interface BreadCrumbMeta {
|
|
996
|
-
/**
|
|
997
|
-
* A function that provides the value that should be used in the breadcrumb.
|
|
998
|
-
*/
|
|
999
|
-
breadcrumb?: BreadcrumbResolver;
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
export interface PermissionMeta {
|
|
1003
|
-
permissions?: {
|
|
1004
|
-
[key: string]: Array<string>;
|
|
1005
|
-
};
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
/**
|
|
1009
|
-
* Custom extension slots outside of piral-core.
|
|
1010
|
-
*/
|
|
1011
|
-
export interface PiralCustomExtensionSlotMap {}
|
|
1012
|
-
|
|
1013
|
-
/**
|
|
1014
|
-
* Metadata for pilets using the v0 schema with a content.
|
|
1015
|
-
*/
|
|
1016
|
-
export interface PiletMetadataV0Content extends PiletMetadataV0Base {
|
|
1017
|
-
/**
|
|
1018
|
-
* The content of the pilet. If the content is not available
|
|
1019
|
-
* the link will be used (unless caching has been activated).
|
|
1020
|
-
*/
|
|
1021
|
-
content: string;
|
|
1022
|
-
/**
|
|
1023
|
-
* If available indicates that the pilet should not be cached.
|
|
1024
|
-
* In case of a string this is interpreted as the expiration time
|
|
1025
|
-
* of the cache. In case of an accurate hash this should not be
|
|
1026
|
-
* required or set.
|
|
1027
|
-
*/
|
|
1028
|
-
noCache?: boolean | string;
|
|
1029
|
-
}
|
|
575
|
+
* Name of parent navigation item for adding navigation item as nested child menu item (2nd navigation level)
|
|
576
|
+
*/
|
|
577
|
+
parentName?: string;
|
|
578
|
+
}
|
|
1030
579
|
|
|
580
|
+
export interface NavigationConnector {
|
|
1031
581
|
/**
|
|
1032
|
-
*
|
|
582
|
+
* Connector function for wraping a component
|
|
583
|
+
* @param component The component to connet by providing navigation state properties
|
|
1033
584
|
*/
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
* The link for retrieving the content of the pilet.
|
|
1037
|
-
*/
|
|
1038
|
-
link: string;
|
|
1039
|
-
}
|
|
585
|
+
<TProps>(component: React.ComponentType<TProps & NavigationConnectorProps>): React.FC<TProps>;
|
|
586
|
+
}
|
|
1040
587
|
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
*/
|
|
1045
|
-
groupName: string;
|
|
1046
|
-
}
|
|
588
|
+
export interface NavigationTransformer<T> {
|
|
589
|
+
(items: Array<T>): Array<T>;
|
|
590
|
+
}
|
|
1047
591
|
|
|
1048
|
-
|
|
592
|
+
export interface NavigationItem extends RegisterNavigationItem {
|
|
593
|
+
/**
|
|
594
|
+
* Unique name of the navigation item provided on registration (auto generated in case not provided)
|
|
595
|
+
*/
|
|
596
|
+
readonly name: string;
|
|
597
|
+
/**
|
|
598
|
+
* Name of the pilet registering navigation item
|
|
599
|
+
*/
|
|
600
|
+
pilet: string;
|
|
601
|
+
}
|
|
1049
602
|
|
|
603
|
+
export interface NavigationPanelCategory {
|
|
604
|
+
/**
|
|
605
|
+
* Name of the category under which navigation items will be listed
|
|
606
|
+
*/
|
|
607
|
+
categoryName: string;
|
|
1050
608
|
/**
|
|
1051
|
-
*
|
|
609
|
+
* Navigation items
|
|
1052
610
|
*/
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
611
|
+
items: Array<NavigationPanelItem>;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export type ShowNotification = (notification: Notification) => NotificationId;
|
|
615
|
+
|
|
616
|
+
export type UpdateNotification = (id: NotificationId, notification: Notification) => void;
|
|
617
|
+
|
|
618
|
+
export type DismissNotification = (id: NotificationId) => void;
|
|
1056
619
|
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
export interface NotificationOptions {
|
|
1062
|
-
type?: NotificationType;
|
|
1063
|
-
autoClose?: number | false;
|
|
1064
|
-
}
|
|
620
|
+
export interface ProviderRegistration {
|
|
621
|
+
(type: never, data: object): void;
|
|
622
|
+
}
|
|
1065
623
|
|
|
624
|
+
export interface GetProviders<T = object> {
|
|
625
|
+
(type: string): Array<T>;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Data item for registering a resolver
|
|
630
|
+
*/
|
|
631
|
+
export interface ResolverData {
|
|
632
|
+
/**
|
|
633
|
+
* Name of the station, has to be unique among the workflows
|
|
634
|
+
*/
|
|
635
|
+
station: string;
|
|
1066
636
|
/**
|
|
1067
|
-
*
|
|
637
|
+
* Route resolver function
|
|
1068
638
|
*/
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
639
|
+
resolver: NavigationResolver;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Resolver function for resolving a route
|
|
644
|
+
*/
|
|
645
|
+
export type ResolverFunction = (station: string, dynamicRouteSegments?: Array<string>) => string | undefined;
|
|
1073
646
|
|
|
647
|
+
/**
|
|
648
|
+
* Represents the state of the navigation resolver registry
|
|
649
|
+
*/
|
|
650
|
+
export interface NavigationResolverRegistryState {
|
|
1074
651
|
/**
|
|
1075
|
-
*
|
|
652
|
+
* The registered navigation resolvers
|
|
653
|
+
* @example
|
|
654
|
+
* ```ts
|
|
655
|
+
* {
|
|
656
|
+
* 'movie-details': (dynamicRouteSegments?: string[]) => dynamicRouteSegments?.length
|
|
657
|
+
* ? `/movies/${dynamicRouteSegments[0]}`
|
|
658
|
+
* : undefined
|
|
659
|
+
* },
|
|
660
|
+
* ```
|
|
1076
661
|
*/
|
|
1077
|
-
|
|
1078
|
-
[key: string]:
|
|
1079
|
-
}) => Breadcrumb["label"];
|
|
1080
|
-
|
|
1081
|
-
/**
|
|
1082
|
-
* Basic metadata for pilets using the v0 schema.
|
|
1083
|
-
*/
|
|
1084
|
-
export interface PiletMetadataV0Base {
|
|
1085
|
-
/**
|
|
1086
|
-
* The name of the pilet, i.e., the package id.
|
|
1087
|
-
*/
|
|
1088
|
-
name: string;
|
|
1089
|
-
/**
|
|
1090
|
-
* The version of the pilet. Should be semantically versioned.
|
|
1091
|
-
*/
|
|
1092
|
-
version: string;
|
|
1093
|
-
/**
|
|
1094
|
-
* Optionally provides the version of the specification for this pilet.
|
|
1095
|
-
*/
|
|
1096
|
-
spec?: "v0";
|
|
1097
|
-
/**
|
|
1098
|
-
* The computed hash value of the pilet's content. Should be
|
|
1099
|
-
* accurate to allow caching.
|
|
1100
|
-
*/
|
|
1101
|
-
hash: string;
|
|
1102
|
-
/**
|
|
1103
|
-
* Optionally provides some custom metadata for the pilet.
|
|
1104
|
-
*/
|
|
1105
|
-
custom?: any;
|
|
1106
|
-
/**
|
|
1107
|
-
* Optionally provides some configuration to be used in the pilet.
|
|
1108
|
-
*/
|
|
1109
|
-
config?: Record<string, any>;
|
|
1110
|
-
/**
|
|
1111
|
-
* Additional shared dependency script files.
|
|
1112
|
-
*/
|
|
1113
|
-
dependencies?: Record<string, string>;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
export interface TileProps {
|
|
1117
|
-
/**
|
|
1118
|
-
* url path
|
|
1119
|
-
*/
|
|
1120
|
-
path: string;
|
|
1121
|
-
/**
|
|
1122
|
-
* Tile label
|
|
1123
|
-
*/
|
|
1124
|
-
label: string;
|
|
1125
|
-
/**
|
|
1126
|
-
* Icon location or an react element of svg icon.
|
|
1127
|
-
* if an react element of svg is passed, the correct style for two types ("small" and "large") will be applied accordingly
|
|
1128
|
-
* The styles which don't want to be affected based on the tile type can be passed as inline styles.
|
|
1129
|
-
*/
|
|
1130
|
-
icon: string | React.ReactNode;
|
|
1131
|
-
/**
|
|
1132
|
-
* Tile is disabled or enabled, default is false
|
|
1133
|
-
*/
|
|
1134
|
-
disabled?: boolean;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
1138
|
-
|
|
1139
|
-
export type NotificationType = "success" | "error" | "info" | "warning";
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
* The Piral global app state container.
|
|
1143
|
-
*/
|
|
1144
|
-
export interface GlobalState extends PiralCustomState {
|
|
1145
|
-
/**
|
|
1146
|
-
* The relevant state for the app itself.
|
|
1147
|
-
*/
|
|
1148
|
-
app: AppState;
|
|
1149
|
-
/**
|
|
1150
|
-
* The relevant state for rendering errors of the app.
|
|
1151
|
-
*/
|
|
1152
|
-
errorComponents: ErrorComponentsState;
|
|
1153
|
-
/**
|
|
1154
|
-
* The relevant state for rendering parts of the app.
|
|
1155
|
-
*/
|
|
1156
|
-
components: ComponentsState;
|
|
1157
|
-
/**
|
|
1158
|
-
* The relevant state for the registered components.
|
|
1159
|
-
*/
|
|
1160
|
-
registry: RegistryState;
|
|
1161
|
-
/**
|
|
1162
|
-
* Gets the loaded modules.
|
|
1163
|
-
*/
|
|
1164
|
-
modules: Array<PiletMetadata>;
|
|
1165
|
-
/**
|
|
1166
|
-
* The foreign component portals to render.
|
|
1167
|
-
*/
|
|
1168
|
-
portals: Record<string, Array<React.ReactPortal>>;
|
|
1169
|
-
/**
|
|
1170
|
-
* The application's shared data.
|
|
1171
|
-
*/
|
|
1172
|
-
data: Dict<SharedDataItem>;
|
|
1173
|
-
/**
|
|
1174
|
-
* The used (exact) application routes.
|
|
1175
|
-
*/
|
|
1176
|
-
routes: Dict<React.ComponentType<ReactRouter.RouteComponentProps<any>>>;
|
|
1177
|
-
/**
|
|
1178
|
-
* The current provider.
|
|
1179
|
-
*/
|
|
1180
|
-
provider?: React.ComponentType;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
/**
|
|
1184
|
-
* Breadcrumb
|
|
1185
|
-
*/
|
|
1186
|
-
export interface Breadcrumb {
|
|
1187
|
-
/**
|
|
1188
|
-
* Text to be displayed in breadcrumb
|
|
1189
|
-
*/
|
|
1190
|
-
label: ValueOrOnDemand;
|
|
1191
|
-
/**
|
|
1192
|
-
* The link it leads to, must be absolute path
|
|
1193
|
-
*/
|
|
1194
|
-
url: string;
|
|
1195
|
-
/**
|
|
1196
|
-
* Collection of route parameters
|
|
1197
|
-
*/
|
|
1198
|
-
params: [];
|
|
1199
|
-
}
|
|
1200
|
-
|
|
1201
|
-
/**
|
|
1202
|
-
* Custom state extensions defined outside of piral-core.
|
|
1203
|
-
*/
|
|
1204
|
-
export interface PiralCustomState {}
|
|
1205
|
-
|
|
1206
|
-
/**
|
|
1207
|
-
* The Piral global app sub-state container for app information.
|
|
1208
|
-
*/
|
|
1209
|
-
export interface AppState {
|
|
1210
|
-
/**
|
|
1211
|
-
* Information for the layout computation.
|
|
1212
|
-
*/
|
|
1213
|
-
layout: LayoutType;
|
|
1214
|
-
/**
|
|
1215
|
-
* Gets if the application is currently performing a background loading
|
|
1216
|
-
* activity, e.g., for loading modules asynchronously or fetching
|
|
1217
|
-
* translations.
|
|
1218
|
-
*/
|
|
1219
|
-
loading: boolean;
|
|
1220
|
-
/**
|
|
1221
|
-
* Gets an unrecoverable application error, if any.
|
|
1222
|
-
*/
|
|
1223
|
-
error: Error | undefined;
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
export type ErrorComponentsState = {
|
|
1227
|
-
[P in keyof Errors]?: React.ComponentType<Errors[P]>;
|
|
662
|
+
navigationResolvers: {
|
|
663
|
+
[key: string]: NavigationResolver;
|
|
1228
664
|
};
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Defines the potential targets when storing data.
|
|
669
|
+
*/
|
|
670
|
+
export type DataStoreTarget = "memory" | "local" | "remote";
|
|
1229
671
|
|
|
672
|
+
/**
|
|
673
|
+
* Defines the custom options for storing data.
|
|
674
|
+
*/
|
|
675
|
+
export interface CustomDataStoreOptions {
|
|
676
|
+
/**
|
|
677
|
+
* The target data store. By default the data is only stored in memory.
|
|
678
|
+
*/
|
|
679
|
+
target?: DataStoreTarget;
|
|
1230
680
|
/**
|
|
1231
|
-
*
|
|
1232
|
-
*/
|
|
1233
|
-
export interface ComponentsState extends PiralCustomComponentsState {
|
|
1234
|
-
/**
|
|
1235
|
-
* The loading indicator renderer.
|
|
1236
|
-
*/
|
|
1237
|
-
LoadingIndicator: React.ComponentType<LoadingIndicatorProps>;
|
|
1238
|
-
/**
|
|
1239
|
-
* The error renderer.
|
|
1240
|
-
*/
|
|
1241
|
-
ErrorInfo: React.ComponentType<ErrorInfoProps>;
|
|
1242
|
-
/**
|
|
1243
|
-
* The router context.
|
|
1244
|
-
*/
|
|
1245
|
-
Router: React.ComponentType<RouterProps>;
|
|
1246
|
-
/**
|
|
1247
|
-
* The layout used for pages.
|
|
1248
|
-
*/
|
|
1249
|
-
Layout: React.ComponentType<LayoutProps>;
|
|
1250
|
-
/**
|
|
1251
|
-
* A component that can be used for debugging purposes.
|
|
1252
|
-
*/
|
|
1253
|
-
Debug?: React.ComponentType;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
/**
|
|
1257
|
-
* The Piral global app sub-state container for component registrations.
|
|
681
|
+
* Optionally determines when the data expires.
|
|
1258
682
|
*/
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
* The registered page components for the router.
|
|
1262
|
-
*/
|
|
1263
|
-
pages: Dict<PageRegistration>;
|
|
1264
|
-
/**
|
|
1265
|
-
* The registered extension components for extension slots.
|
|
1266
|
-
*/
|
|
1267
|
-
extensions: Dict<Array<ExtensionRegistration>>;
|
|
1268
|
-
/**
|
|
1269
|
-
* The registered wrappers for any component.
|
|
1270
|
-
*/
|
|
1271
|
-
wrappers: Dict<React.ComponentType<any>>;
|
|
1272
|
-
}
|
|
683
|
+
expires?: "never" | Date | number;
|
|
684
|
+
}
|
|
1273
685
|
|
|
686
|
+
export type FirstParametersOf<T> = {
|
|
687
|
+
[K in keyof T]: T[K] extends (arg: any) => any ? FirstParameter<T[K]> : never;
|
|
688
|
+
}[keyof T];
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Mapping of available component converters.
|
|
692
|
+
*/
|
|
693
|
+
export interface ComponentConverters<TProps> extends PiralCustomComponentConverters<TProps> {
|
|
1274
694
|
/**
|
|
1275
|
-
*
|
|
695
|
+
* Converts the HTML component to a framework-independent component.
|
|
696
|
+
* @param component The vanilla JavaScript component to be converted.
|
|
1276
697
|
*/
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
/**
|
|
1287
|
-
* Gets the storage location.
|
|
1288
|
-
*/
|
|
1289
|
-
target: DataStoreTarget;
|
|
1290
|
-
/**
|
|
1291
|
-
* Gets the expiration of the item.
|
|
1292
|
-
*/
|
|
1293
|
-
expires: number;
|
|
1294
|
-
}
|
|
698
|
+
html(component: HtmlComponent<TProps>): ForeignComponent<TProps>;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* The props that every registered page component obtains.
|
|
703
|
+
*/
|
|
704
|
+
export interface RouteBaseProps<UrlParams extends {
|
|
705
|
+
[K in keyof UrlParams]?: string;
|
|
706
|
+
} = {}, UrlState = any> extends ReactRouter.RouteComponentProps<UrlParams, {}, UrlState>, BaseComponentProps {}
|
|
1295
707
|
|
|
708
|
+
/**
|
|
709
|
+
* Custom meta data to include for pages.
|
|
710
|
+
*/
|
|
711
|
+
export interface PiralCustomPageMeta extends BreadCrumbMeta, PermissionMeta {}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* The props of an extension component.
|
|
715
|
+
*/
|
|
716
|
+
export interface ExtensionComponentProps<T> extends BaseComponentProps {
|
|
1296
717
|
/**
|
|
1297
|
-
* The
|
|
718
|
+
* The provided parameters for showing the extension.
|
|
1298
719
|
*/
|
|
1299
|
-
|
|
720
|
+
params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
|
|
721
|
+
/**
|
|
722
|
+
* The optional children to receive, if any.
|
|
723
|
+
*/
|
|
724
|
+
children?: React.ReactNode;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* The mapping of the existing (known) extension slots.
|
|
729
|
+
*/
|
|
730
|
+
export interface PiralExtensionSlotMap extends PiralCustomExtensionSlotMap {}
|
|
1300
731
|
|
|
732
|
+
/**
|
|
733
|
+
* The basic props for defining an extension slot.
|
|
734
|
+
*/
|
|
735
|
+
export interface BaseExtensionSlotProps<TName, TParams> {
|
|
736
|
+
/**
|
|
737
|
+
* The children to transport, if any.
|
|
738
|
+
*/
|
|
739
|
+
children?: React.ReactNode;
|
|
740
|
+
/**
|
|
741
|
+
* Defines what should be rendered when no components are available
|
|
742
|
+
* for the specified extension.
|
|
743
|
+
*/
|
|
744
|
+
empty?(): React.ReactNode;
|
|
745
|
+
/**
|
|
746
|
+
* Determines if the `render` function should be called in case no
|
|
747
|
+
* components are available for the specified extension.
|
|
748
|
+
*
|
|
749
|
+
* If true, `empty` will be called and returned from the slot.
|
|
750
|
+
* If false, `render` will be called with the result of calling `empty`.
|
|
751
|
+
* The result of calling `render` will then be returned from the slot.
|
|
752
|
+
*/
|
|
753
|
+
emptySkipsRender?: boolean;
|
|
754
|
+
/**
|
|
755
|
+
* Defines the order of the components to render.
|
|
756
|
+
* May be more convient than using `render` w.r.t. ordering extensions
|
|
757
|
+
* by their supplied metadata.
|
|
758
|
+
* @param extensions The registered extensions.
|
|
759
|
+
* @returns The ordered extensions.
|
|
760
|
+
*/
|
|
761
|
+
order?(extensions: Array<ExtensionRegistration>): Array<ExtensionRegistration>;
|
|
1301
762
|
/**
|
|
1302
|
-
*
|
|
763
|
+
* Defines how the provided nodes should be rendered.
|
|
764
|
+
* @param nodes The rendered extension nodes.
|
|
765
|
+
* @returns The rendered nodes, i.e., an ReactElement.
|
|
1303
766
|
*/
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
* The props type for a page error.
|
|
1315
|
-
*/
|
|
1316
|
-
page: PageErrorInfoProps;
|
|
1317
|
-
/**
|
|
1318
|
-
* The props type for a not found error.
|
|
1319
|
-
*/
|
|
1320
|
-
not_found: NotFoundErrorInfoProps;
|
|
1321
|
-
/**
|
|
1322
|
-
* The props type for an unknown error.
|
|
1323
|
-
*/
|
|
1324
|
-
unknown: UnknownErrorInfoProps;
|
|
1325
|
-
}
|
|
767
|
+
render?(nodes: Array<React.ReactNode>): React.ReactElement<any, any> | null;
|
|
768
|
+
/**
|
|
769
|
+
* The custom parameters for the given extension.
|
|
770
|
+
*/
|
|
771
|
+
params?: TParams;
|
|
772
|
+
/**
|
|
773
|
+
* The name of the extension to render.
|
|
774
|
+
*/
|
|
775
|
+
name: TName;
|
|
776
|
+
}
|
|
1326
777
|
|
|
778
|
+
export interface UserToken {
|
|
779
|
+
accessToken: string;
|
|
780
|
+
expiresInSeconds: number;
|
|
781
|
+
permissions: {
|
|
782
|
+
[serviceId: string]: Array<string>;
|
|
783
|
+
};
|
|
784
|
+
tags: Array<string>;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Data item for Settings page
|
|
789
|
+
*/
|
|
790
|
+
export interface SettingsTileData extends HubItem {
|
|
1327
791
|
/**
|
|
1328
|
-
*
|
|
792
|
+
* Type Tag
|
|
1329
793
|
*/
|
|
1330
|
-
|
|
1331
|
-
|
|
794
|
+
kind: "settings";
|
|
1332
795
|
/**
|
|
1333
|
-
*
|
|
1334
|
-
*/
|
|
1335
|
-
|
|
796
|
+
* Unique name of the Home Tile. This value needs to be unique for the Pilet.
|
|
797
|
+
*/
|
|
798
|
+
name?: string;
|
|
799
|
+
}
|
|
1336
800
|
|
|
801
|
+
export interface LandingPageItem {
|
|
1337
802
|
/**
|
|
1338
|
-
*
|
|
803
|
+
* url path
|
|
1339
804
|
*/
|
|
1340
|
-
|
|
805
|
+
path: string;
|
|
806
|
+
/**
|
|
807
|
+
* Tile label
|
|
808
|
+
*/
|
|
809
|
+
label: string;
|
|
810
|
+
/**
|
|
811
|
+
* Icon location or an react element of svg icon.
|
|
812
|
+
* if an react element of svg is passed, the correct style for two types ("small" and "large") will be applied accordingly
|
|
813
|
+
* The styles which don't want to be affected based on the tile type can be passed as inline styles.
|
|
814
|
+
*/
|
|
815
|
+
icon: string | React.ReactNode;
|
|
816
|
+
/**
|
|
817
|
+
* Tile type
|
|
818
|
+
*/
|
|
819
|
+
type: "small" | "large";
|
|
820
|
+
/**
|
|
821
|
+
* Tile is disabled or enabled, default is false
|
|
822
|
+
*/
|
|
823
|
+
disabled?: boolean;
|
|
824
|
+
/**
|
|
825
|
+
* Subtitle resolver
|
|
826
|
+
*/
|
|
827
|
+
subtitle?: ValueOrOnDemand;
|
|
828
|
+
}
|
|
1341
829
|
|
|
830
|
+
export interface HomeStateConnectorProps {
|
|
831
|
+
/**
|
|
832
|
+
* Home Tile data currently available in the state.
|
|
833
|
+
*/
|
|
834
|
+
homeTileData: Array<HomeTileData>;
|
|
1342
835
|
/**
|
|
1343
|
-
*
|
|
836
|
+
* Settings Tile data currently available in the state.
|
|
1344
837
|
*/
|
|
1345
|
-
|
|
838
|
+
settingsTileData: Array<SettingsTileData>;
|
|
839
|
+
tileSorter?: TileSorter<HomeTileData>;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export type Dict<T> = Record<string, T>;
|
|
1346
843
|
|
|
844
|
+
/**
|
|
845
|
+
* The interface modeling the registration of a pilet page component.
|
|
846
|
+
*/
|
|
847
|
+
export interface PageRegistration extends BaseRegistration {
|
|
1347
848
|
/**
|
|
1348
|
-
* The
|
|
849
|
+
* The registered page component.
|
|
1349
850
|
*/
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
851
|
+
component: WrappedComponent<PageComponentProps>;
|
|
852
|
+
/**
|
|
853
|
+
* The page's associated metadata.
|
|
854
|
+
*/
|
|
855
|
+
meta: PiralPageMeta;
|
|
856
|
+
}
|
|
1356
857
|
|
|
858
|
+
/**
|
|
859
|
+
* The interface modeling the registration of a pilet extension component.
|
|
860
|
+
*/
|
|
861
|
+
export interface ExtensionRegistration extends BaseRegistration {
|
|
862
|
+
/**
|
|
863
|
+
* The wrapped registered extension component.
|
|
864
|
+
*/
|
|
865
|
+
component: WrappedComponent<ExtensionComponentProps<string>>;
|
|
1357
866
|
/**
|
|
1358
|
-
*
|
|
867
|
+
* The original extension component that has been registered.
|
|
1359
868
|
*/
|
|
1360
|
-
|
|
869
|
+
reference: any;
|
|
870
|
+
/**
|
|
871
|
+
* The default params (i.e., meta) of the extension.
|
|
872
|
+
*/
|
|
873
|
+
defaults: any;
|
|
874
|
+
}
|
|
1361
875
|
|
|
876
|
+
export interface NavigationPanelItem {
|
|
877
|
+
/**
|
|
878
|
+
* Unique name of the navigation item provided on registration (auto generated in case not provided)
|
|
879
|
+
*/
|
|
880
|
+
readonly name: string;
|
|
881
|
+
/**
|
|
882
|
+
* Menu item label text
|
|
883
|
+
*/
|
|
884
|
+
label: string;
|
|
885
|
+
/**
|
|
886
|
+
* Icon displayed with label
|
|
887
|
+
*/
|
|
888
|
+
icon?: string | React.ReactNode;
|
|
1362
889
|
/**
|
|
1363
|
-
*
|
|
890
|
+
* URL path
|
|
1364
891
|
*/
|
|
1365
|
-
|
|
892
|
+
path?: string;
|
|
893
|
+
/**
|
|
894
|
+
* Child navigation items, nested beneath drop down
|
|
895
|
+
*/
|
|
896
|
+
items?: Array<NavigationPanelItem>;
|
|
897
|
+
}
|
|
1366
898
|
|
|
899
|
+
export interface NavigationConnectorProps {
|
|
900
|
+
/**
|
|
901
|
+
* Registered navigation items
|
|
902
|
+
*/
|
|
903
|
+
items: Array<NavigationItem>;
|
|
1367
904
|
/**
|
|
1368
|
-
*
|
|
905
|
+
* registered navigation registry item transformer
|
|
1369
906
|
*/
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
* The provided error details.
|
|
1377
|
-
*/
|
|
1378
|
-
error: any;
|
|
1379
|
-
}
|
|
907
|
+
itemsTransformer?: NavigationTransformer<NavigationItem>;
|
|
908
|
+
/**
|
|
909
|
+
* Registered navigation tree transformer
|
|
910
|
+
*/
|
|
911
|
+
treeTransformer?: NavigationTransformer<NavigationPanelCategory>;
|
|
912
|
+
}
|
|
1380
913
|
|
|
914
|
+
export interface Notification {
|
|
1381
915
|
/**
|
|
1382
|
-
*
|
|
916
|
+
* Title shown in toast messages header
|
|
1383
917
|
*/
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
918
|
+
title: string;
|
|
919
|
+
/**
|
|
920
|
+
* Optional body of the notification
|
|
921
|
+
*/
|
|
922
|
+
body?: NotificationBody;
|
|
923
|
+
/**
|
|
924
|
+
* Additional options for the notification
|
|
925
|
+
*/
|
|
926
|
+
options?: NotificationOptions;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
export type NotificationId = string | number;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Navigation resolver function for resolver registration
|
|
933
|
+
*/
|
|
934
|
+
export type NavigationResolver = (dynamicRouteSegments?: Array<string>) => string | undefined;
|
|
935
|
+
|
|
936
|
+
export type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Custom component converters defined outside of piral-core.
|
|
940
|
+
*/
|
|
941
|
+
export interface PiralCustomComponentConverters<TProps> {}
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* Definition of a vanilla JavaScript component.
|
|
945
|
+
*/
|
|
946
|
+
export interface HtmlComponent<TProps> {
|
|
947
|
+
/**
|
|
948
|
+
* Renders a component into the provided element using the given props and context.
|
|
949
|
+
*/
|
|
950
|
+
component: ForeignComponent<TProps>;
|
|
951
|
+
/**
|
|
952
|
+
* The type of the HTML component.
|
|
953
|
+
*/
|
|
954
|
+
type: "html";
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/**
|
|
958
|
+
* Generic definition of a framework-independent component.
|
|
959
|
+
*/
|
|
960
|
+
export interface ForeignComponent<TProps> {
|
|
961
|
+
/**
|
|
962
|
+
* Called when the component is mounted.
|
|
963
|
+
* @param element The container hosting the element.
|
|
964
|
+
* @param props The props to transport.
|
|
965
|
+
* @param ctx The associated context.
|
|
966
|
+
* @param locals The local state of this component instance.
|
|
967
|
+
*/
|
|
968
|
+
mount(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
|
|
969
|
+
/**
|
|
970
|
+
* Called when the component should be updated.
|
|
971
|
+
* @param element The container hosting the element.
|
|
972
|
+
* @param props The props to transport.
|
|
973
|
+
* @param ctx The associated context.
|
|
974
|
+
* @param locals The local state of this component instance.
|
|
975
|
+
*/
|
|
976
|
+
update?(element: HTMLElement, props: TProps, ctx: ComponentContext, locals: Record<string, any>): void;
|
|
977
|
+
/**
|
|
978
|
+
* Called when a component is unmounted.
|
|
979
|
+
* @param element The container that was hosting the element.
|
|
980
|
+
* @param locals The local state of this component instance.
|
|
981
|
+
*/
|
|
982
|
+
unmount?(element: HTMLElement, locals: Record<string, any>): void;
|
|
983
|
+
}
|
|
1394
984
|
|
|
985
|
+
/**
|
|
986
|
+
* The props that every registered component obtains.
|
|
987
|
+
*/
|
|
988
|
+
export interface BaseComponentProps {
|
|
1395
989
|
/**
|
|
1396
|
-
* The
|
|
990
|
+
* The currently used pilet API.
|
|
1397
991
|
*/
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
* The type of the error.
|
|
1401
|
-
*/
|
|
1402
|
-
type: "page";
|
|
1403
|
-
/**
|
|
1404
|
-
* The provided error details.
|
|
1405
|
-
*/
|
|
1406
|
-
error: any;
|
|
1407
|
-
}
|
|
992
|
+
piral: PiletApi;
|
|
993
|
+
}
|
|
1408
994
|
|
|
995
|
+
export interface BreadCrumbMeta {
|
|
1409
996
|
/**
|
|
1410
|
-
*
|
|
997
|
+
* A function that provides the value that should be used in the breadcrumb.
|
|
1411
998
|
*/
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
999
|
+
breadcrumb?: BreadcrumbResolver;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
export interface PermissionMeta {
|
|
1003
|
+
permissions?: {
|
|
1004
|
+
[key: string]: Array<string>;
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Custom extension slots outside of piral-core.
|
|
1010
|
+
*/
|
|
1011
|
+
export interface PiralCustomExtensionSlotMap {}
|
|
1418
1012
|
|
|
1013
|
+
export interface HubItem extends TileProps {
|
|
1419
1014
|
/**
|
|
1420
|
-
*
|
|
1015
|
+
* Group name of the item
|
|
1421
1016
|
*/
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
* The type of the error.
|
|
1425
|
-
*/
|
|
1426
|
-
type: "unknown";
|
|
1427
|
-
/**
|
|
1428
|
-
* The provided error details.
|
|
1429
|
-
*/
|
|
1430
|
-
error: any;
|
|
1431
|
-
}
|
|
1017
|
+
groupName: string;
|
|
1018
|
+
}
|
|
1432
1019
|
|
|
1433
|
-
|
|
1434
|
-
[K in keyof T]: T[K];
|
|
1435
|
-
}[keyof T];
|
|
1020
|
+
export type ValueOrOnDemand = string | number | (() => Promise<string | number>);
|
|
1436
1021
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1022
|
+
/**
|
|
1023
|
+
* The base type for pilet component registration in the global state context.
|
|
1024
|
+
*/
|
|
1025
|
+
export interface BaseRegistration {
|
|
1026
|
+
/**
|
|
1027
|
+
* The pilet registering the component.
|
|
1028
|
+
*/
|
|
1029
|
+
pilet: string;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
export type WrappedComponent<TProps> = React.ComponentType<React.PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
|
|
1033
|
+
|
|
1034
|
+
export type NotificationBody = string | React.ReactNode | React.Component;
|
|
1446
1035
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1036
|
+
export interface NotificationOptions {
|
|
1037
|
+
type?: NotificationType;
|
|
1038
|
+
autoClose?: number | false;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* The context to be transported into the generic components.
|
|
1043
|
+
*/
|
|
1044
|
+
export interface ComponentContext {
|
|
1045
|
+
/**
|
|
1046
|
+
* The router-independent navigation API.
|
|
1047
|
+
*/
|
|
1048
|
+
navigation: NavigationApi___1;
|
|
1049
|
+
/**
|
|
1050
|
+
* The internal router object.
|
|
1051
|
+
* @deprecated Exposes internals that can change at any time.
|
|
1052
|
+
*/
|
|
1053
|
+
router: any;
|
|
1054
|
+
/**
|
|
1055
|
+
* The public path of the application.
|
|
1056
|
+
*/
|
|
1057
|
+
publicPath: string;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* A function that provides the value that should be used in the breadcrumb.
|
|
1062
|
+
*/
|
|
1063
|
+
export type BreadcrumbResolver = (routeParams: {
|
|
1064
|
+
[key: string]: string;
|
|
1065
|
+
}) => Breadcrumb["label"];
|
|
1066
|
+
|
|
1067
|
+
export interface TileProps {
|
|
1068
|
+
/**
|
|
1069
|
+
* url path
|
|
1070
|
+
*/
|
|
1071
|
+
path: string;
|
|
1072
|
+
/**
|
|
1073
|
+
* Tile label
|
|
1074
|
+
*/
|
|
1075
|
+
label: string;
|
|
1076
|
+
/**
|
|
1077
|
+
* Tile sub label
|
|
1078
|
+
*/
|
|
1079
|
+
subLabel?: string;
|
|
1080
|
+
/**
|
|
1081
|
+
* Icon location or an react element of svg icon.
|
|
1082
|
+
* if an react element of svg is passed, the correct style for two types ("small" and "large") will be applied accordingly
|
|
1083
|
+
* The styles which don't want to be affected based on the tile type can be passed as inline styles.
|
|
1084
|
+
*/
|
|
1085
|
+
icon: string | React.ReactNode;
|
|
1086
|
+
/**
|
|
1087
|
+
* Tile is disabled or enabled, default is false
|
|
1088
|
+
*/
|
|
1089
|
+
disabled?: boolean;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
1093
|
+
|
|
1094
|
+
export type NotificationType = "success" | "error" | "info" | "warning";
|
|
1095
|
+
|
|
1096
|
+
export interface NavigationApi___1 {
|
|
1097
|
+
/**
|
|
1098
|
+
* Pushes a new location onto the history stack.
|
|
1099
|
+
*/
|
|
1100
|
+
push(target: string, state?: any): void;
|
|
1101
|
+
/**
|
|
1102
|
+
* Replaces the current location with another.
|
|
1103
|
+
*/
|
|
1104
|
+
replace(target: string, state?: any): void;
|
|
1105
|
+
/**
|
|
1106
|
+
* Changes the current index in the history stack by a given delta.
|
|
1107
|
+
*/
|
|
1108
|
+
go(n: number): void;
|
|
1109
|
+
/**
|
|
1110
|
+
* Prevents changes to the history stack from happening.
|
|
1111
|
+
* This is useful when you want to prevent the user navigating
|
|
1112
|
+
* away from the current page, for example when they have some
|
|
1113
|
+
* unsaved data on the current page.
|
|
1114
|
+
* @param blocker The function being called with a transition request.
|
|
1115
|
+
* @returns The disposable for stopping the block.
|
|
1116
|
+
*/
|
|
1117
|
+
block(blocker: NavigationBlocker): Disposable;
|
|
1118
|
+
/**
|
|
1119
|
+
* Starts listening for location changes and calls the given
|
|
1120
|
+
* callback with an Update when it does.
|
|
1121
|
+
* @param listener The function being called when the route changes.
|
|
1122
|
+
* @returns The disposable for stopping the block.
|
|
1123
|
+
*/
|
|
1124
|
+
listen(listener: NavigationListener): Disposable;
|
|
1125
|
+
/**
|
|
1126
|
+
* Gets the current navigation / application path.
|
|
1127
|
+
*/
|
|
1128
|
+
path: string;
|
|
1129
|
+
/**
|
|
1130
|
+
* Gets the current navigation path incl. search and hash parts.
|
|
1131
|
+
*/
|
|
1132
|
+
url: string;
|
|
1133
|
+
/**
|
|
1134
|
+
* The original router behind the navigation. Don't depend on this
|
|
1135
|
+
* as the implementation is router specific and may change over time.
|
|
1136
|
+
*/
|
|
1137
|
+
router: any;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* Breadcrumb
|
|
1142
|
+
*/
|
|
1143
|
+
export interface Breadcrumb {
|
|
1144
|
+
/**
|
|
1145
|
+
* Text to be displayed in breadcrumb
|
|
1146
|
+
*/
|
|
1147
|
+
label: ValueOrOnDemand;
|
|
1148
|
+
/**
|
|
1149
|
+
* The link it leads to, must be absolute path
|
|
1150
|
+
*/
|
|
1151
|
+
url: string;
|
|
1152
|
+
/**
|
|
1153
|
+
* Collection of route parameters
|
|
1154
|
+
*/
|
|
1155
|
+
params: [];
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
export interface NavigationBlocker {
|
|
1159
|
+
(tx: NavigationTransition): void;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
export interface NavigationListener {
|
|
1163
|
+
(update: NavigationUpdate): void;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
export interface NavigationTransition extends NavigationUpdate {
|
|
1167
|
+
retry?(): void;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
export interface NavigationUpdate {
|
|
1171
|
+
action: NavigationAction;
|
|
1172
|
+
location: NavigationLocation;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
export type NavigationAction = "POP" | "PUSH" | "REPLACE";
|
|
1176
|
+
|
|
1177
|
+
export interface NavigationLocation {
|
|
1178
|
+
/**
|
|
1179
|
+
* The fully qualified URL incl. the origin and base path.
|
|
1180
|
+
*/
|
|
1181
|
+
href: string;
|
|
1182
|
+
/**
|
|
1183
|
+
* The location.pathname property is a string that contains an initial "/"
|
|
1184
|
+
* followed by the remainder of the URL up to the ?.
|
|
1185
|
+
*/
|
|
1186
|
+
pathname: string;
|
|
1187
|
+
/**
|
|
1188
|
+
* The location.search property is a string that contains an initial "?"
|
|
1189
|
+
* followed by the key=value pairs in the query string. If there are no
|
|
1190
|
+
* parameters, this value may be the empty string (i.e. '').
|
|
1191
|
+
*/
|
|
1192
|
+
search: string;
|
|
1193
|
+
/**
|
|
1194
|
+
* The location.hash property is a string that contains an initial "#"
|
|
1195
|
+
* followed by fragment identifier of the URL. If there is no fragment
|
|
1196
|
+
* identifier, this value may be the empty string (i.e. '').
|
|
1197
|
+
*/
|
|
1198
|
+
hash: string;
|
|
1199
|
+
/**
|
|
1200
|
+
* The location.state property is a user-supplied State object that is
|
|
1201
|
+
* associated with this location. This can be a useful place to store
|
|
1202
|
+
* any information you do not want to put in the URL, e.g. session-specific
|
|
1203
|
+
* data.
|
|
1204
|
+
*/
|
|
1205
|
+
state: unknown;
|
|
1206
|
+
/**
|
|
1207
|
+
* The location.key property is a unique string associated with this location.
|
|
1208
|
+
* On the initial location, this will be the string default. On all subsequent
|
|
1209
|
+
* locations, this string will be a unique identifier.
|
|
1210
|
+
*/
|
|
1211
|
+
key?: string;
|
|
1458
1212
|
}
|