@grasp-labs/ds-microfrontends-integration 1.0.3 → 1.1.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/README.md +49 -27
- package/dist/index-CsGT3jVC.js +25127 -0
- package/dist/{index.esm-fQDYRCEr-DMrT-B4r.js → index.esm-Cw_y1o-h-DcJWUeMH.js} +58 -58
- package/dist/index.js +10 -10
- package/dist/mf-common.js +1 -1
- package/dist/types/Navigation.d.ts +22 -14
- package/dist/utils/navigation.d.ts +4 -4
- package/package.json +7 -5
- package/dist/index-DOUsw_d8.js +0 -22691
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
|
-
###
|
|
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
|
-
|
|
28
|
-
secretsList
|
|
29
|
-
schema
|
|
30
|
-
generateSecret
|
|
31
|
-
updateSecret
|
|
32
|
-
deleteSecret
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
44
|
+
`VaultInput` and `VaultSecretDialog` use built-in translations, so they must be rendered inside `LanguageProvider`.
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
### Language
|
|
42
47
|
|
|
43
48
|
```tsx
|
|
44
49
|
import {
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
LanguageProvider,
|
|
51
|
+
useLanguage,
|
|
47
52
|
} from "@grasp-labs/ds-microfrontends-integration";
|
|
48
53
|
|
|
49
|
-
<
|
|
54
|
+
<LanguageProvider>
|
|
50
55
|
<App />
|
|
51
|
-
</
|
|
56
|
+
</LanguageProvider>;
|
|
52
57
|
|
|
53
58
|
function MyComponent() {
|
|
54
|
-
const
|
|
55
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
298
|
-
├── 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
|
|
331
|
+
2. Ensure `npm run check` passes
|
|
310
332
|
3. Create a pull request
|