demf-rules-list 3.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/README.md ADDED
@@ -0,0 +1,371 @@
1
+ # Digital Enabler Rules List
2
+
3
+ The Rules List microfrontend shows a list of rules created and lets create a new one. The Rules List works within the Rule Manager (RM) tool in which it is mounted, and is an access point to the Rule Editor microfrontend.
4
+
5
+ Built with **Vue 3**, **Vuetify 3**, and **Vite**. Designed for **Single-SPA** integration.
6
+
7
+ > 📌 **See also:**
8
+ >
9
+ > - [Root Config integration guide](https://github.com/digital-enabler/root-config-microfrontend-vite-template)
10
+ > - [Microfrontend template documentation](https://github.com/digital-enabler/vuejs3-microfrontend-vite-template)
11
+
12
+ ---
13
+
14
+ ## 📦 Installation
15
+
16
+ ### Via CDN
17
+
18
+ This project is available from the following CDN:
19
+
20
+ ```
21
+ https://cdn.jsdelivr.net/npm/demf-rules-list@latest/mf-app.js
22
+ ```
23
+
24
+ Add it to your root-config import map:
25
+
26
+ ```json
27
+ {
28
+ "imports": {
29
+ "demf-rules-list": "https://cdn.jsdelivr.net/npm/demf-rules-list@latest/mf-app.js"
30
+ }
31
+ }
32
+ ```
33
+
34
+ ---
35
+
36
+ ## 🚀 Quick Start
37
+
38
+ ### Prerequisites
39
+
40
+ Before you continue you need to have:
41
+
42
+ - A Digital Enabler **root-config** application running
43
+ - **Single-SPA** layout engine configured
44
+ - A configuration file for the Rules List (see below)
45
+
46
+ ### Integration Steps
47
+
48
+ **1. Add to Import Map**
49
+
50
+ In your root-config `importmap.json`:
51
+
52
+ ```json
53
+ {
54
+ "imports": {
55
+ "demf-rules-list": "https://cdn.jsdelivr.net/npm/demf-rules-list@latest/mf-app.js"
56
+ }
57
+ }
58
+ ```
59
+
60
+ For local development:
61
+
62
+ ```json
63
+ {
64
+ "imports": {
65
+ "demf-rules-list": "http://localhost:9010/mf-app.js"
66
+ }
67
+ }
68
+ ```
69
+
70
+ **2. Register in Layout**
71
+
72
+ In your root-config layout HTML:
73
+
74
+ ```html
75
+ <application name="demf-rules-list" props="realm, palette, rules-list-config">
76
+ </application>
77
+ ```
78
+
79
+ **3. Create Configuration File**
80
+
81
+ Create a `rules-list-config.json` file with these settings:
82
+
83
+ ```json
84
+ {
85
+ "name": "rules-list",
86
+ "mf": "demf-rules-list",
87
+ "api": "https://[generic_api_location]/api"
88
+ }
89
+ ```
90
+
91
+ This JSON file must be:
92
+
93
+ - Stored in a location accessible to the root-config
94
+ - Included in the root-config's remote configuration
95
+ - Passed as the `rules-list-config` prop to the microfrontend
96
+
97
+ > 📖 For details on configuration management, see:
98
+ >
99
+ > - [Microfrontend Template Guide](https://github.com/digital-enabler/vuejs3-microfrontend-vite-template)
100
+ > - [Root Config Documentation](https://github.com/digital-enabler/root-config-microfrontend-vite-template)
101
+
102
+ ---
103
+
104
+ ## ⚙️ Configuration
105
+
106
+ The Rules List microfrontend receives a configuration object via the `rules-list-config` prop:
107
+
108
+ ```json
109
+ {
110
+ "name": "rules-list",
111
+ "mf": "demf-rules-list",
112
+ "api": "https://your-api-endpoint.com/api"
113
+ }
114
+ ```
115
+
116
+ ### Configuration Fields
117
+
118
+ | Field | Type | Required | Description |
119
+ | ----- | ------ | -------- | -------------------------------------------- |
120
+ | `mf` | string | Yes | Microfrontend identifier (use "demf-rules-list") |
121
+ | `api` | string | Yes | Base URL for API calls |
122
+
123
+ ### Additional Props from Root-Config
124
+
125
+ The microfrontend also receives these props automatically from the root-config:
126
+
127
+ - **`realm`**: Current tenant/realm identifier
128
+ - **`palette`**: Dynamic theme colors (primary, secondary, etc.)
129
+
130
+ These props are used to:
131
+
132
+ - Apply consistent theming across the platform
133
+ - Configure tenant-specific behavior
134
+ - Adapt the Rules List appearance to the current application theme
135
+
136
+ ### Standard Error Event Mixin
137
+
138
+ The template includes `src/mixins/events.js` with a standardized `setError(err, prevent, actionEv)` helper.
139
+
140
+ This helper:
141
+
142
+ - Safely handles network errors where `err.response` is missing
143
+ - Dispatches normalized browser events (`error-<status>`)
144
+ - Uses `preventDefault: Boolean(prevent)` for consistent behavior
145
+ - Writes explicit technical details to browser console for debugging
146
+
147
+ ---
148
+
149
+ ## 🛠️ Development
150
+
151
+ ### Prerequisites
152
+
153
+ Before you continue you need to have:
154
+
155
+ - [NPM](https://www.npmjs.com/) installed
156
+ - [Node.js](https://nodejs.org/) (v22+ or v24.8+) installed
157
+ - [Vue.js](https://v3.vuejs.org/) and [Vite](https://vitejs.dev/) knowledge
158
+ - A [GitHub](https://github.com/) account
159
+ - Visual Studio Code or IntelliJ IDEA as your development IDE
160
+
161
+ ### Project Management
162
+
163
+ #### Installation
164
+
165
+ Open a **Terminal** window in the project folder and go inside the `app` folder, then launch:
166
+
167
+ ```bash
168
+ npm install
169
+ ```
170
+
171
+ > **NOTE:** When install finishes, do not worry about warnings on versions and vulnerability problems reported. **DO NOT** launch `npm audit fix` or `npm audit fix --force` commands.
172
+
173
+ #### Development Server (with hot-reload)
174
+
175
+ ```bash
176
+ npm run dev
177
+ ```
178
+
179
+ This command:
180
+
181
+ 1. Generates Vuetify locales automatically (via `predev` script)
182
+ 2. Builds the microfrontend in watch mode
183
+ 3. Starts a preview server at `http://localhost:9010`
184
+
185
+ The microfrontend will be available at: `http://localhost:9010/mf-app.js`
186
+
187
+ #### Build for Production
188
+
189
+ ```bash
190
+ npm run build
191
+ ```
192
+
193
+ This command:
194
+
195
+ 1. Generates Vuetify locales automatically (via `prebuild` script)
196
+ 2. Creates an optimized production build in the `dist/` folder
197
+ 3. Outputs a SystemJS bundle ready for deployment
198
+
199
+ #### Code Quality
200
+
201
+ ```bash
202
+ npm run lint # Lint and fix files with ESLint
203
+ npm run format # Format code with Prettier
204
+ ```
205
+
206
+ > **NOTE:** Alternatively to the commands indicated above you can use the Vue UI browser interface.
207
+
208
+ ---
209
+
210
+ ## 🌐 Internationalization
211
+
212
+ The Rules List microfrontend supports multiple languages through **vue-i18n** with automatic **Vuetify locale integration**.
213
+
214
+ ### How It Works
215
+
216
+ - Locale files are stored in `src/locales/*.json` (e.g., `en.json`, `it.json`)
217
+ - The script `scripts/generate-vuetify-locales.mjs` automatically scans these files
218
+ - Matching Vuetify translations are imported and merged
219
+ - The active language is read from `localStorage.getItem('lang')` (defaults to `en`)
220
+
221
+ ### Supported Languages
222
+
223
+ The Rules List includes translations for the languages defined in `src/locales/`:
224
+
225
+ - English (`en`)
226
+ - Italian (`it`)
227
+ - [Add other languages as needed]
228
+
229
+ ### Adding a New Language
230
+
231
+ 1. Create a new file: `src/locales/<code>.json` (e.g., `es.json`)
232
+ 2. Add your translations following the existing structure
233
+ 3. Run `npm run dev` or `npm run build`
234
+ 4. The generator will automatically include Vuetify translations for that language
235
+
236
+ ---
237
+
238
+ ## 🎨 Features
239
+
240
+ - **Dynamic theming**: Automatically adapts to the palette passed from root-config
241
+ - **Multi-language support**: Full internationalization with vue-i18n
242
+ - **Responsive design**: Works seamlessly on mobile, tablet, and desktop
243
+ - **Material Design**: Built with Vuetify 3 components and Material Design Icons
244
+ - **Consistent branding**: Shows uniform Rules List across all Digital Enabler services
245
+ - **Platform information**: Displays version, copyright, and relevant links
246
+
247
+ ---
248
+
249
+ ## 📁 Project Structure
250
+
251
+ ```
252
+ demf-rules-list/
253
+ ├── app/
254
+ │ ├── src/
255
+ │ │ ├── App.vue # Main component
256
+ │ │ ├── main.js # Entry point
257
+ │ │ ├── components/ # Rules List components
258
+ │ │ ├── mixins/
259
+ │ │ │ └── events.js # Shared setError helper
260
+ │ │ ├── locales/
261
+ │ │ │ ├── i18n.js # i18n configuration
262
+ │ │ │ ├── en.json # English translations
263
+ │ │ │ ├── it.json # Italian translations
264
+ │ │ │ └── vuetify-generated.js # Auto-generated Vuetify locales
265
+ │ │ ├── plugins/
266
+ │ │ │ └── vuetify.js # Vuetify configuration
267
+ │ │ ├── router/
268
+ │ │ └── store/
269
+ │ ├── scripts/
270
+ │ │ └── generate-vuetify-locales.mjs
271
+ │ ├── public/
272
+ │ ├── dist/ # Build output
273
+ │ ├── package.json
274
+ │ ├── vite.config.js
275
+ │ └── eslint.config.js
276
+ ├── docker/
277
+ └── README.md
278
+ ```
279
+
280
+ ---
281
+
282
+ ## 🔍 Troubleshooting
283
+
284
+ ### Rules List not visible
285
+
286
+ - Verify the import map includes `demf-rules-list`
287
+ - Check the layout HTML has the `<application>` tag with correct name
288
+ - Ensure the bundle is accessible at the configured URL
289
+ - Look for console errors in the browser developer tools
290
+
291
+ ### Configuration not working
292
+
293
+ - Check that `rules-list-config` prop is passed in the layout
294
+ - Verify the configuration JSON structure matches the expected format
295
+ - Ensure the root-config is loading the remote configuration correctly
296
+ - Check console for warnings about missing configuration
297
+
298
+ ### Styling issues
299
+
300
+ - Ensure the `palette` prop is being passed from root-config
301
+ - Verify Material Design Icons fonts are loaded
302
+ - Check that Vuetify theme configuration is correct
303
+ - Clear browser cache and reload
304
+
305
+ ### API connection errors
306
+
307
+ - Verify the `api` field in `rules-list-config.json` is correct
308
+ - Check network tab for failed API requests
309
+ - Ensure CORS is properly configured on the backend
310
+ - Verify the API endpoint is accessible from the browser
311
+
312
+ ### Development server not starting
313
+
314
+ - Check that port 9001 is not already in use
315
+ - Verify Node.js version is compatible (v22+ or v24.8+)
316
+ - Try removing `node_modules` and running `npm install` again
317
+ - Ensure all dependencies are correctly installed
318
+
319
+ ---
320
+
321
+ ## 📚 Tech Stack
322
+
323
+ ### Runtime Dependencies
324
+
325
+ - **Vue 3** (^3.5.22) - Progressive JavaScript framework
326
+ - **Vuetify 3** (^3.10.7) - Material Design component library
327
+ - **Single-SPA Vue** (^3.0.1) - Single-SPA integration for Vue
328
+ - **Vue Router** (^4.6.3) - Official router for Vue.js
329
+ - **Vue i18n** (^9.14.5) - Internationalization plugin
330
+ - **Vuex** (^4.1.0) - State management
331
+ - **Axios** (^1.13.0) - HTTP client
332
+ - **Material Design Icons** (^7.4.47) - Icon library
333
+
334
+ ### Development Dependencies
335
+
336
+ - **Vite** (^7.1.12) - Next generation frontend tooling
337
+ - **ESLint** (^9.38.0) - Code linting
338
+ - **Prettier** (^3.6.2) - Code formatting
339
+ - **Vite Plugin Vue DevTools** (^8.0.3) - Vue DevTools integration
340
+ - **Concurrently** (^9.2.1) - Run multiple commands
341
+
342
+ For complete dependencies, see [`package.json`](./app/package.json).
343
+
344
+ ---
345
+
346
+ ## 📖 Related Documentation
347
+
348
+ - [Digital Enabler Root Config Template](https://github.com/digital-enabler/root-config-microfrontend-vite-template)
349
+ - [Digital Enabler Microfrontend Template](https://github.com/digital-enabler/vuejs3-microfrontend-vite-template)
350
+ - [Single-SPA Documentation](https://single-spa.js.org/)
351
+ - [Vue 3 Documentation](https://vuejs.org/)
352
+ - [Vuetify 3 Documentation](https://vuetifyjs.com/)
353
+ - [Vite Documentation](https://vitejs.dev/)
354
+
355
+ ---
356
+
357
+ ## 📄 License
358
+
359
+ This project is part of Digital Enabler Ecosystem.
360
+
361
+ © 2025 Engineering Ingegneria Informatica S.p.A.
362
+
363
+ ---
364
+
365
+ ## 🆘 Support
366
+
367
+ For support, questions, or issues:
368
+
369
+ - Open an issue on [GitHub](https://github.com/digital-enabler/demf-rules-list/issues)
370
+ - Contact the Digital Enabler development team
371
+ - Check the [Digital Enabler documentation](https://github.com/digital-enabler)