@equinor/roma-nx-plugin 6.0.0-beta.8 → 6.0.0
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/CHANGELOG.md +45 -0
- package/generators.json +5 -0
- package/migrations.json +6 -6
- package/package.json +2 -3
- package/src/executors/create-vite-config.js +1 -3
- package/src/executors/create-vite-config.js.map +1 -1
- package/src/executors/publish/manifest-model.d.ts +11 -0
- package/src/executors/publish/publish-script.js +78 -1
- package/src/executors/publish/publish-script.js.map +1 -1
- package/src/executors/publish/readme.md +83 -27
- package/src/executors/serve/server.js +35 -24
- package/src/executors/serve/server.js.map +1 -1
- package/src/executors/utils/logger.js +7 -3
- package/src/executors/utils/logger.js.map +1 -1
- package/src/executors/utils/read-manifest.js +4 -1
- package/src/executors/utils/read-manifest.js.map +1 -1
- package/src/executors/utils/verify-manifest.d.ts +2 -0
- package/src/executors/utils/verify-manifest.js +18 -0
- package/src/executors/utils/verify-manifest.js.map +1 -0
- package/src/generators/app/data/generated-dependencies.json +23 -0
- package/src/generators/app/generator.js +7 -17
- package/src/generators/app/generator.js.map +1 -1
- package/src/generators/component-test/generator.js +1 -1
- package/src/generators/preset/generator.js.map +1 -1
- package/src/generators/preset/schema.d.ts +1 -0
- package/src/generators/skill/files/roma-app-development/SKILL.md +38 -0
- package/src/generators/skill/files/roma-app-development/fusion-modules.md +577 -0
- package/src/generators/skill/files/roma-app-development/generators.md +357 -0
- package/src/generators/skill/files/roma-app-development/roma-modules.md +409 -0
- package/src/generators/skill/files/roma-app-development/services.md +450 -0
- package/src/generators/skill/generator.d.ts +4 -0
- package/src/generators/skill/generator.js +14 -0
- package/src/generators/skill/generator.js.map +1 -0
- package/src/generators/skill/schema.d.ts +3 -0
- package/src/generators/skill/schema.json +14 -0
- package/src/generators/app/data/modules.d.ts +0 -19
- package/src/generators/app/data/modules.js +0 -23
- package/src/generators/app/data/modules.js.map +0 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
# Roma Custom Modules
|
|
2
|
+
|
|
3
|
+
Roma extends the Fusion Framework with custom modules in `libs/modules/`. Each module has a core package and a React bindings package.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Page Title
|
|
8
|
+
|
|
9
|
+
Automatically manages browser page titles based on route navigation. Supports dynamic title templates with parameter replacement and placeholder titles while data loads.
|
|
10
|
+
|
|
11
|
+
### Packages
|
|
12
|
+
|
|
13
|
+
| Package | Location | Description |
|
|
14
|
+
|---------|----------|-------------|
|
|
15
|
+
| `@equinor/roma-page-title-module` | `libs/modules/page-title` | Core module |
|
|
16
|
+
| `@equinor/roma-page-title-module-react` | `libs/modules/react/page-title` | React hooks |
|
|
17
|
+
|
|
18
|
+
### Configuration
|
|
19
|
+
|
|
20
|
+
Enable in your app's `config.ts`:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { enablePageTitle } from '@equinor/roma-page-title-module';
|
|
24
|
+
import type { AppModuleInitiator } from '@equinor/fusion-framework-react-app';
|
|
25
|
+
|
|
26
|
+
export const configure: AppModuleInitiator = (configurator, env) => {
|
|
27
|
+
enablePageTitle(configurator, (config) => {
|
|
28
|
+
config.setInitialTitle('My App');
|
|
29
|
+
config.setRoutes([
|
|
30
|
+
{ path: '/apps/my-app', title: 'My App' },
|
|
31
|
+
{ path: '/apps/my-app/list', title: 'Items' },
|
|
32
|
+
{
|
|
33
|
+
path: '/apps/my-app/details/:id',
|
|
34
|
+
title: '{name} | Details',
|
|
35
|
+
placeholder: 'Loading...',
|
|
36
|
+
arguments: { name: '' },
|
|
37
|
+
},
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Route configuration
|
|
44
|
+
|
|
45
|
+
Routes support pattern matching with parameters:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
type Route = {
|
|
49
|
+
path: string; // URL pattern, supports :param syntax
|
|
50
|
+
title: string; // Title template, {param} is replaced dynamically
|
|
51
|
+
placeholder?: string; // Shown before arguments are set
|
|
52
|
+
arguments?: Record<string, string | number>; // Default values
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- **`:param`** in `path` matches URL segments (e.g., `/details/:id` matches `/details/123`)
|
|
57
|
+
- **`{param}`** in `title` is replaced with values from `setArguments()`
|
|
58
|
+
- **`placeholder`** is shown while the real title is being resolved
|
|
59
|
+
|
|
60
|
+
### React hooks
|
|
61
|
+
|
|
62
|
+
#### `usePageTitle()`
|
|
63
|
+
|
|
64
|
+
Convenience hook for controlling page titles from components:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { usePageTitle } from '@equinor/roma-page-title-module-react';
|
|
68
|
+
|
|
69
|
+
function CargoDetail() {
|
|
70
|
+
const { setArguments, setTitle, setDisabled } = usePageTitle();
|
|
71
|
+
|
|
72
|
+
// Set dynamic title parameters after data loads
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (cargo) {
|
|
75
|
+
setArguments({ name: cargo.name, id: cargo.id });
|
|
76
|
+
}
|
|
77
|
+
}, [cargo]);
|
|
78
|
+
|
|
79
|
+
// Or set the title directly
|
|
80
|
+
setTitle('Custom Title');
|
|
81
|
+
|
|
82
|
+
// Disable automatic title updates (manual control mode)
|
|
83
|
+
setDisabled(true);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### `usePageTitleModule()`
|
|
88
|
+
|
|
89
|
+
Returns the raw module instance for advanced usage:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { usePageTitleModule } from '@equinor/roma-page-title-module-react';
|
|
93
|
+
|
|
94
|
+
const module = usePageTitleModule();
|
|
95
|
+
// Access the full IPageTitleProvider interface
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Roma example: administration app
|
|
99
|
+
|
|
100
|
+
From `apps/applications/administration/src/config.ts`:
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import { enablePageTitle } from '@equinor/roma-page-title-module';
|
|
104
|
+
|
|
105
|
+
export const configure: AppModuleInitiator = (configurator, env) => {
|
|
106
|
+
enablePageTitle(configurator, (config) => {
|
|
107
|
+
config.setInitialTitle('Administration');
|
|
108
|
+
config.setRoutes([
|
|
109
|
+
{ path: '/apps/administration', title: 'Administration' },
|
|
110
|
+
{ path: '/apps/administration/categories', title: 'Categories' },
|
|
111
|
+
{
|
|
112
|
+
path: '/apps/administration/applications/:id',
|
|
113
|
+
title: '{name} | Application',
|
|
114
|
+
placeholder: 'Loading application...',
|
|
115
|
+
},
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
From `apps/applications/administration/src/applications/edit/application.tsx`:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { usePageTitle } from '@equinor/roma-page-title-module-react';
|
|
125
|
+
|
|
126
|
+
export const Application = () => {
|
|
127
|
+
const { setArguments } = usePageTitle();
|
|
128
|
+
|
|
129
|
+
// Update the page title when the app data loads
|
|
130
|
+
if (app) {
|
|
131
|
+
setArguments({ name: app.name });
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Provider API
|
|
137
|
+
|
|
138
|
+
The `IPageTitleProvider` interface (for advanced usage):
|
|
139
|
+
|
|
140
|
+
| Method | Description |
|
|
141
|
+
|--------|-------------|
|
|
142
|
+
| `setTitleArguments(args)` | Set dynamic title parameters (`Record<string, string \| number>`) |
|
|
143
|
+
| `setTitle(title, route?)` | Manually set the page title |
|
|
144
|
+
| `setDisabled(disabled)` | Disable automatic title updates |
|
|
145
|
+
| `dispose()` | Clean up subscriptions |
|
|
146
|
+
|
|
147
|
+
### Events
|
|
148
|
+
|
|
149
|
+
The module emits an `onSetPageTitle` event via the Fusion event system when the title changes.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## SSE (Server-Sent Events)
|
|
154
|
+
|
|
155
|
+
Real-time event streaming with automatic token refresh, reconnection, persistent read-state tracking, and event caching via IndexedDB.
|
|
156
|
+
|
|
157
|
+
### Packages
|
|
158
|
+
|
|
159
|
+
| Package | Location | Description |
|
|
160
|
+
|---------|----------|-------------|
|
|
161
|
+
| `@equinor/roma-sse-module` | `libs/modules/sse` | Core module |
|
|
162
|
+
| `@equinor/roma-sse-module-react` | `libs/modules/react/sse` | React hooks |
|
|
163
|
+
|
|
164
|
+
### Configuration
|
|
165
|
+
|
|
166
|
+
Enable in your app's or portal's `config.ts`:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { enableSse } from '@equinor/roma-sse-module';
|
|
170
|
+
import type { AppModuleInitiator } from '@equinor/fusion-framework-react-app';
|
|
171
|
+
|
|
172
|
+
export const configure: AppModuleInitiator = (configurator, env) => {
|
|
173
|
+
// Register SSE endpoints by service discovery name
|
|
174
|
+
enableSse(configurator, 'activity');
|
|
175
|
+
enableSse(configurator, 'roma-alarm');
|
|
176
|
+
};
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The first argument is the configurator, the second is the service name (resolved via service discovery). An optional third argument allows custom configuration:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
enableSse(configurator, 'notifications', async (builder) => {
|
|
183
|
+
builder.addEndpoint('notifications', {
|
|
184
|
+
url: 'https://api.example.com/sse/events',
|
|
185
|
+
options: {
|
|
186
|
+
accessTokenFactory: async () => token,
|
|
187
|
+
reconnect: true,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Data model
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
type ServerSentEvent = {
|
|
197
|
+
id: string;
|
|
198
|
+
subject: string;
|
|
199
|
+
created: string; // ISO 8601
|
|
200
|
+
correlationId?: string;
|
|
201
|
+
sourceApplication: string; // e.g., "TOPS CO", "TOPS RatsCore"
|
|
202
|
+
payloadScheme?: string;
|
|
203
|
+
payload: Record<string, unknown>;
|
|
204
|
+
message: string;
|
|
205
|
+
read: boolean; // Persisted to IndexedDB
|
|
206
|
+
environment?: string;
|
|
207
|
+
updatedByUser?: string;
|
|
208
|
+
updatedBySystem?: string;
|
|
209
|
+
version: string;
|
|
210
|
+
};
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### React hooks
|
|
214
|
+
|
|
215
|
+
#### `useSse()` — Notification center hook
|
|
216
|
+
|
|
217
|
+
High-level hook with filtering, read-state management, and event enrichment:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import { useSse } from '@equinor/roma-sse-module-react';
|
|
221
|
+
|
|
222
|
+
function NotificationCenter() {
|
|
223
|
+
const { messages, setReadState, setAllRead } = useSse('activity', {
|
|
224
|
+
filter: activeFilter,
|
|
225
|
+
limit: 20,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<div>
|
|
230
|
+
{messages.map((msg) => (
|
|
231
|
+
<div key={msg.id}>
|
|
232
|
+
<strong>{msg.payload.details?.name || msg.message}</strong>
|
|
233
|
+
<button onClick={() => setReadState(msg.id, !msg.read)}>
|
|
234
|
+
{msg.read ? 'Mark unread' : 'Mark read'}
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
))}
|
|
238
|
+
<button onClick={setAllRead}>Mark All as Read</button>
|
|
239
|
+
</div>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Options:**
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
type Options = {
|
|
248
|
+
filter?: {
|
|
249
|
+
attributes: Partial<Record<keyof ServerSentEvent, any>>;
|
|
250
|
+
sources?: Array<string>;
|
|
251
|
+
};
|
|
252
|
+
limit?: number; // max 100
|
|
253
|
+
};
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Processing pipeline:** `useSse` applies these RxJS operators:
|
|
257
|
+
1. `debounceTime(100)` — reduce emissions
|
|
258
|
+
2. `filterUnique()` — deduplicate by ID
|
|
259
|
+
3. `readCache()` — load read-state from IndexedDB
|
|
260
|
+
4. `purgeStorage()` — remove stale cached items
|
|
261
|
+
5. `cacheDetails()` — persist event state to IndexedDB
|
|
262
|
+
6. `filterByWatched()` — filter by user's watched cargo/deals
|
|
263
|
+
7. `appendNotificationData()` — fetch cargo/deal/user details from APIs
|
|
264
|
+
|
|
265
|
+
#### `useSseListener()` — Generic event listener
|
|
266
|
+
|
|
267
|
+
Lower-level hook for custom SSE streams with optional browser notifications:
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
import { useSseListener } from '@equinor/roma-sse-module-react';
|
|
271
|
+
|
|
272
|
+
// Simple listener
|
|
273
|
+
function EventLog() {
|
|
274
|
+
const events = useSseListener('notifications');
|
|
275
|
+
return <div>{events.length} events</div>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// With custom filter
|
|
279
|
+
function FilteredEvents() {
|
|
280
|
+
const events = useSseListener('activity', (events) =>
|
|
281
|
+
events.filter((e) => e.sourceApplication === 'TOPS CO')
|
|
282
|
+
);
|
|
283
|
+
return <div>{events.length} cargo events</div>;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// With browser notifications
|
|
287
|
+
function AlertListener() {
|
|
288
|
+
const alarms = useSseListener<Alarm>(
|
|
289
|
+
'roma-alarm',
|
|
290
|
+
filterAlarmEvents,
|
|
291
|
+
(event) => {
|
|
292
|
+
if (event.subject.includes('critical')) {
|
|
293
|
+
return { title: `Alert: ${event.message}` };
|
|
294
|
+
}
|
|
295
|
+
return null; // suppress notification
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**Signature:**
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
useSseListener<T extends EventSourceMin>(
|
|
305
|
+
name: string,
|
|
306
|
+
filterCallback?: (events: Array<T>) => Array<T>,
|
|
307
|
+
notifyMapper?: (item: T) => NotifyPayload | null
|
|
308
|
+
): Array<T>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
#### `useSseModule()` — Raw module access
|
|
312
|
+
|
|
313
|
+
Returns the SSE provider instance for advanced usage:
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
import { useSseModule } from '@equinor/roma-sse-module-react';
|
|
317
|
+
|
|
318
|
+
const sseProvider = useSseModule();
|
|
319
|
+
const connection = sseProvider.connect<MyEvent>('activity');
|
|
320
|
+
|
|
321
|
+
// connection.messageList — BehaviorSubject of events
|
|
322
|
+
// connection.messageList$ — Observable of events
|
|
323
|
+
// connection.abort — AbortController to close
|
|
324
|
+
// connection.setReadState(eventId, read) — mark read/unread
|
|
325
|
+
// connection.setAllRead() — mark all as read
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Roma examples
|
|
329
|
+
|
|
330
|
+
#### Alarm notifications
|
|
331
|
+
|
|
332
|
+
From `apps/applications/notifications/src/App.tsx`:
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
import { useSseListener } from '@equinor/roma-sse-module-react';
|
|
336
|
+
|
|
337
|
+
export const App = () => {
|
|
338
|
+
const alarms = useSseListener<Alarm>(
|
|
339
|
+
'roma-alarm',
|
|
340
|
+
filterAlarmEvents,
|
|
341
|
+
permission === 'granted' ? alarmNotifyMapper : undefined
|
|
342
|
+
);
|
|
343
|
+
};
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
#### Activity feed widget
|
|
347
|
+
|
|
348
|
+
From `apps/widgets/activity-feed/src/App.tsx`:
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
import { useSse } from '@equinor/roma-sse-module-react';
|
|
352
|
+
import type { ServerSentEvent } from '@equinor/roma-sse-module';
|
|
353
|
+
|
|
354
|
+
const { messages, setReadState, setAllRead } = useSse(
|
|
355
|
+
'activity',
|
|
356
|
+
activeFilter?.value as Options | undefined
|
|
357
|
+
);
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
#### Unread badge
|
|
361
|
+
|
|
362
|
+
From `apps/applications/notifications/src/components/NotificationButton.tsx`:
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
import { useSse } from '@equinor/roma-sse-module-react';
|
|
366
|
+
|
|
367
|
+
const { messages } = useSse('activity');
|
|
368
|
+
const hasUnread = messages.some((m) => !m.read);
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Advanced features
|
|
372
|
+
|
|
373
|
+
#### Connection management
|
|
374
|
+
|
|
375
|
+
The SSE module uses connection pooling — connections are reused across components and closed when all listeners unsubscribe.
|
|
376
|
+
|
|
377
|
+
#### Automatic reconnection
|
|
378
|
+
|
|
379
|
+
The module reconnects automatically on connection errors (up to 5 consecutive errors). Keep-alive messages are filtered out.
|
|
380
|
+
|
|
381
|
+
#### Event persistence
|
|
382
|
+
|
|
383
|
+
Read-state and event details are persisted to IndexedDB via `idb-keyval`. This survives page refreshes and browser restarts.
|
|
384
|
+
|
|
385
|
+
#### Event deduplication
|
|
386
|
+
|
|
387
|
+
Events are deduplicated by ID. For cargo operations, outdated events are also filtered out based on correlation IDs.
|
|
388
|
+
|
|
389
|
+
#### Browser notifications
|
|
390
|
+
|
|
391
|
+
The `useSseListener` hook supports native Web Notifications via the `notifyMapper` parameter. Notifications are deduplicated across tabs using IndexedDB.
|
|
392
|
+
|
|
393
|
+
### Provider API
|
|
394
|
+
|
|
395
|
+
The `ISseProvider` interface:
|
|
396
|
+
|
|
397
|
+
| Method | Description |
|
|
398
|
+
|--------|-------------|
|
|
399
|
+
| `connect<T>(name)` | Connect to an SSE endpoint, returns `SseConnection<T>` |
|
|
400
|
+
|
|
401
|
+
The `SseConnection<T>` interface:
|
|
402
|
+
|
|
403
|
+
| Property/Method | Description |
|
|
404
|
+
|----------------|-------------|
|
|
405
|
+
| `messageList` | `BehaviorSubject<Array<T>>` — current event list |
|
|
406
|
+
| `messageList$` | `Observable<Array<T>>` — event stream |
|
|
407
|
+
| `abort` | `AbortController` — close the connection |
|
|
408
|
+
| `setReadState(id, read)` | Mark an event as read/unread (persisted) |
|
|
409
|
+
| `setAllRead()` | Mark all events as read |
|