@grasp-labs/ds-microfrontends-integration 1.0.3 → 1.1.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 CHANGED
@@ -14,45 +14,54 @@ npm install @grasp-labs/ds-microfrontends-integration
14
14
 
15
15
  Components for managing secrets with JSON Schema-based forms.
16
16
 
17
- ### React Components
17
+ ### Vault Usage
18
18
 
19
19
  ```tsx
20
20
  import {
21
+ LanguageProvider,
21
22
  VaultInput,
22
23
  VaultProvider,
23
24
  VaultSecretDialog,
24
25
  } from "@grasp-labs/ds-microfrontends-integration";
25
26
  import "@grasp-labs/ds-microfrontends-integration/styles.css";
26
27
 
27
- <VaultProvider
28
- secretsList={secrets}
29
- schema={jsonSchema}
30
- generateSecret={async (data) => newSecret}
31
- updateSecret={async (secret) => updatedSecret}
32
- deleteSecret={async (id) => {}}
33
- >
34
- <VaultInput name="apiKey" label="API Key" />
35
- <VaultSecretDialog isOpen={isOpen} onClose={handleClose} />
36
- </VaultProvider>;
28
+ const vaultValue = {
29
+ secretsList: secrets,
30
+ schema: jsonSchema,
31
+ generateSecret: async (data) => newSecret,
32
+ updateSecret: async (secret) => updatedSecret,
33
+ deleteSecret: async (id) => {},
34
+ };
35
+
36
+ <LanguageProvider>
37
+ <VaultProvider value={vaultValue}>
38
+ <VaultInput name="apiKey" label="API Key" />
39
+ <VaultSecretDialog isOpen={isOpen} onClose={handleClose} />
40
+ </VaultProvider>
41
+ </LanguageProvider>;
37
42
  ```
38
43
 
39
- ### Translation
44
+ `VaultInput` and `VaultSecretDialog` use built-in translations, so they must be rendered inside `LanguageProvider`.
40
45
 
41
- i18next-based translation system with dynamic resource loading.
46
+ ### Language
42
47
 
43
48
  ```tsx
44
49
  import {
45
- TranslationProvider,
46
- useTranslation,
50
+ LanguageProvider,
51
+ useLanguage,
47
52
  } from "@grasp-labs/ds-microfrontends-integration";
48
53
 
49
- <TranslationProvider language="en">
54
+ <LanguageProvider>
50
55
  <App />
51
- </TranslationProvider>;
56
+ </LanguageProvider>;
52
57
 
53
58
  function MyComponent() {
54
- const t = useTranslation();
55
- return <h1>{t("common.title")}</h1>;
59
+ const { language, setLanguage } = useLanguage();
60
+ return (
61
+ <button onClick={() => setLanguage(language === "en" ? "no" : "en")}>
62
+ Switch language ({language})
63
+ </button>
64
+ );
56
65
  }
57
66
  ```
58
67
 
@@ -75,8 +84,7 @@ function MyComponent() {
75
84
 
76
85
  const showSuccess = () => {
77
86
  addToast({
78
- title: "Success",
79
- description: "Operation completed successfully",
87
+ message: "Operation completed successfully",
80
88
  variant: "success",
81
89
  duration: 5000, // optional, defaults to 5000ms
82
90
  });
@@ -96,15 +104,25 @@ import { SchemaFields } from "@grasp-labs/ds-microfrontends-integration";
96
104
  <SchemaFields schema={jsonSchema} control={control} errors={errors} />;
97
105
  ```
98
106
 
107
+ ### Groups and User Context
108
+
109
+ Helpers for auth-aware rendering:
110
+
111
+ - `UserProvider` / `useUser`
112
+ - `GroupsProvider` / `useGroups`
113
+ - `GroupGuard` for conditional rendering by required groups
114
+
99
115
  ## Styling
100
116
 
101
- The library requires styles from `@grasp-labs/ds-react-components`:
117
+ Import the package stylesheet once:
102
118
 
103
119
  ```tsx
104
120
  import "@grasp-labs/ds-microfrontends-integration/styles.css";
105
121
  ```
106
122
 
107
- ### Microfrontend Configuration (`/mf-common`)
123
+ It includes the required styles from `@grasp-labs/ds-react-components`.
124
+
125
+ ## Microfrontend Configuration (`/mf-common`)
108
126
 
109
127
  The platform uses a **host / remote** architecture powered by [Module Federation](https://module-federation.io/). A central host application dynamically discovers and mounts independent microfrontend remotes at runtime. For this to work, every remote must follow a shared contract — exposing the same entry points, using compatible shared dependencies, and providing a navigation config so the host can build its sidebar and routing.
110
128
 
@@ -129,7 +147,7 @@ Each entry in the navigation config is a `NavigationItem` — either a **route**
129
147
  | `hidden` | A route that is routable but does not appear in the sidebar |
130
148
  | `category` | A non-routable group with `children` — used to create nested sidebar menus |
131
149
 
132
- Every item has a `label` (display fallback), an optional `labelKey` (i18n key in the `navigation` namespace), and an `icon`.
150
+ Every item has a `label` (display fallback), an optional `labelKey` (i18n key in the `navigation` namespace, kept for backward compatibility), an optional `translations` dictionary, and an `icon`.
133
151
 
134
152
  #### Available Utilities
135
153
 
@@ -215,6 +233,7 @@ const { navigationConfig, pageRoutes: PageRoutes } = defineNavigation({
215
233
  INTERNAL: {
216
234
  label: "Internal Page",
217
235
  path: "/internal",
236
+ icon: "cogWheel",
218
237
  type: "hidden",
219
238
  },
220
239
  });
@@ -289,13 +308,16 @@ After a successful login, the middleware redirects to `process.env.VITE_BASE_PAT
289
308
  - `npm test` - Run tests
290
309
  - `npm run test:watch` - Run tests in watch mode
291
310
  - `npm run test:coverage` - Generate test coverage report
311
+ - `npm run tsc` - Run TypeScript type-checking
312
+ - `npm run check` - Run `tsc`, lint, format check, and tests
292
313
 
293
314
  ### Project Structure
294
315
 
295
316
  ```
296
317
  src/
297
- ├── components/ # React components (vault, translation, schema fields, etc.)
298
- ├── hooks/ # Custom React hooks
318
+ ├── components/ # React components (vault, language, schema fields, toast, groups, user)
319
+ ├── hooks/ # Shared hook exports
320
+ ├── dev/ # Dev auth middleware entrypoint
299
321
  ├── lib/ # JSON schema utilities and shared logic
300
322
  ├── types/ # TypeScript type definitions
301
323
  ├── utils/ # Shared helper functions
@@ -306,5 +328,5 @@ src/
306
328
  ## Contributing
307
329
 
308
330
  1. Create a feature branch
309
- 2. Ensure `npm test`, `npm run lint`, and `npm run format:check` pass
331
+ 2. Ensure `npm run check` passes
310
332
  3. Create a pull request