@grasp-labs/ds-microfrontends-integration 0.22.0 → 0.24.0-beta.20260225075929.9b4e423
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 +55 -29
- package/dist/components/schemaFields/ArrayField.d.ts +5 -5
- package/dist/components/schemaFields/BooleanField.d.ts +5 -5
- package/dist/components/schemaFields/DateField.d.ts +5 -5
- package/dist/components/schemaFields/EnumField.d.ts +5 -5
- package/dist/components/schemaFields/JsonField.d.ts +5 -5
- package/dist/components/schemaFields/NumberField.d.ts +5 -5
- package/dist/components/schemaFields/SchemaFields.d.ts +5 -5
- package/dist/components/schemaFields/SchemaFields.stories.d.ts +6 -1
- package/dist/components/schemaFields/TextField.d.ts +5 -5
- package/dist/components/schemaFields/VaultField.d.ts +5 -5
- package/dist/components/schemaFields/consts/index.d.ts +1 -0
- package/dist/components/schemaFields/consts/schemas.d.ts +5 -0
- package/dist/{index-BPNkNLtA.js → index-8Q3EeCug.js} +2157 -2138
- package/dist/{index.esm-fQDYRCEr-BRIPsGCl.js → index.esm-fQDYRCEr-Bj1dI6i0.js} +1 -1
- package/dist/index.js +22 -21
- package/dist/lib/schema/defaults.d.ts +1 -1
- package/dist/lib/schema/descriptor.d.ts +2 -2
- package/dist/lib/schema/index.d.ts +1 -1
- package/dist/lib/schema/schemaResolver/index.d.ts +2 -0
- package/dist/lib/schema/schemaResolver/schemaResolver.d.ts +4 -0
- package/dist/lib/schema/schemaResolver/utils.d.ts +10 -0
- package/dist/lib/schema/types.d.ts +2 -2
- package/dist/mf-common.d.ts +32 -1
- package/dist/mf-common.js +28 -17
- package/dist/types/Navigation.d.ts +11 -0
- package/dist/types/customErrorHandler.d.ts +3 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/lib/schema/schemaResolver.d.ts +0 -3
package/README.md
CHANGED
|
@@ -106,9 +106,42 @@ import "@grasp-labs/ds-microfrontends-integration/styles.css";
|
|
|
106
106
|
|
|
107
107
|
### Microfrontend Configuration (`/mf-common`)
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
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
110
|
|
|
111
|
-
|
|
111
|
+
`mf-common` enforces this contract. It provides a pre-configured Vite plugin, shared dependency definitions, and type-safe navigation primitives so that each remote is wired up correctly with minimal boilerplate.
|
|
112
|
+
|
|
113
|
+
#### The Contract
|
|
114
|
+
|
|
115
|
+
Every microfrontend must expose two modules:
|
|
116
|
+
|
|
117
|
+
| Expose key | Default path | What the host expects |
|
|
118
|
+
| ---------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
119
|
+
| `"."` | `"./src/App"` | A **React component** (not a full app with `ReactDOM.render`). The host mounts it inside its own router |
|
|
120
|
+
| `"./navigationConfig"` | `"./src/navigationConfig"` | A `ComposableNavigationConfig` object. The host reads it to build sidebar entries and route definitions |
|
|
121
|
+
|
|
122
|
+
#### Navigation Item Types
|
|
123
|
+
|
|
124
|
+
Each entry in the navigation config is a `NavigationItem` — either a **route** or a **category**:
|
|
125
|
+
|
|
126
|
+
| Type | Description |
|
|
127
|
+
| ---------- | -------------------------------------------------------------------------- |
|
|
128
|
+
| `visible` | A route that appears in the sidebar (default when `type` is omitted) |
|
|
129
|
+
| `hidden` | A route that is routable but does not appear in the sidebar |
|
|
130
|
+
| `category` | A non-routable group with `children` — used to create nested sidebar menus |
|
|
131
|
+
|
|
132
|
+
Every item has a `label` (display fallback), an optional `labelKey` (i18n key in the `navigation` namespace), and an `icon`.
|
|
133
|
+
|
|
134
|
+
#### Available Utilities
|
|
135
|
+
|
|
136
|
+
- `dsFederation(name, overrides?)` — Vite plugin that wraps Module Federation with the standard config
|
|
137
|
+
- `createModuleFederationConfig(name, overrides?)` — generates the raw Module Federation options if you need more control
|
|
138
|
+
- `createMicrofrontendsBase(name)` — returns the deployment base path (`microfrontends/<name>/`), used to set Vite's `base` in production
|
|
139
|
+
- `defineNavigation(config)` — defines a navigation config and extracts its page routes in one step, returning `{ navigationConfig, pageRoutes }`
|
|
140
|
+
- `extractPaths(config)` — recursively flattens a navigation config into a type-safe `{ KEY: path }` map
|
|
141
|
+
- `COMMON_SHARED_DEPS` — shared dependency definitions (React, React Router, this package) configured as singletons
|
|
142
|
+
- Types: `RouteConfig`, `CategoryConfig`, `NavigationItem`, `ComposableNavigationConfig`, `MicrofrontendExposes`
|
|
143
|
+
|
|
144
|
+
#### Vite Setup
|
|
112
145
|
|
|
113
146
|
```typescript
|
|
114
147
|
// vite.config.ts
|
|
@@ -128,14 +161,9 @@ export default defineConfig(({ mode }) => ({
|
|
|
128
161
|
}));
|
|
129
162
|
```
|
|
130
163
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
- `"."` → `"./src/App"` - Your main React component (not a full app with ReactDOM.render, just a component)
|
|
134
|
-
- `"./navigationConfig"` → `"./src/navigationConfig"` - Navigation configuration object of type `NavigationConfig`
|
|
135
|
-
|
|
136
|
-
#### App Component Example
|
|
164
|
+
#### App Component
|
|
137
165
|
|
|
138
|
-
Your `src/App.tsx` should export a React component with Routes
|
|
166
|
+
Your `src/App.tsx` should export a React component with `<Routes>`, not render it — the host handles mounting:
|
|
139
167
|
|
|
140
168
|
```tsx
|
|
141
169
|
// src/App.tsx
|
|
@@ -157,14 +185,16 @@ function App() {
|
|
|
157
185
|
export default App;
|
|
158
186
|
```
|
|
159
187
|
|
|
160
|
-
#### Navigation Configuration
|
|
188
|
+
#### Navigation Configuration
|
|
189
|
+
|
|
190
|
+
Use `defineNavigation` to define your navigation config and extract route paths in one step:
|
|
161
191
|
|
|
162
192
|
```typescript
|
|
163
193
|
// src/navigationConfig.ts
|
|
164
|
-
import
|
|
194
|
+
import { defineNavigation } from "@grasp-labs/ds-microfrontends-integration/mf-common";
|
|
165
195
|
|
|
166
|
-
|
|
167
|
-
|
|
196
|
+
const { navigationConfig, pageRoutes: PageRoutes } = defineNavigation({
|
|
197
|
+
HOME: {
|
|
168
198
|
label: "Home",
|
|
169
199
|
path: "/",
|
|
170
200
|
icon: "database",
|
|
@@ -181,21 +211,17 @@ export const navigationConfig = {
|
|
|
181
211
|
path: "/internal",
|
|
182
212
|
type: "hidden",
|
|
183
213
|
},
|
|
184
|
-
}
|
|
185
|
-
```
|
|
214
|
+
});
|
|
186
215
|
|
|
187
|
-
|
|
216
|
+
export { PageRoutes };
|
|
217
|
+
// PageRoutes.HOME === "/"
|
|
218
|
+
// PageRoutes.SETTINGS === "/settings"
|
|
219
|
+
// PageRoutes.INTERNAL === "/internal"
|
|
188
220
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
- Type-safe navigation and route configuration helpers
|
|
192
|
-
|
|
193
|
-
**Available utilities:**
|
|
221
|
+
export default navigationConfig;
|
|
222
|
+
```
|
|
194
223
|
|
|
195
|
-
|
|
196
|
-
- `createModuleFederationConfig(name, overrides?)` - Generate config object
|
|
197
|
-
- `COMMON_SHARED_DEPS` - Shared dependency configuration
|
|
198
|
-
- Types: `RouteConfig`, `NavigationConfig`, `MicrofrontendExposes`
|
|
224
|
+
For nested configs with categories, route paths are recursively flattened into a single map.
|
|
199
225
|
|
|
200
226
|
#### Shared Dependencies
|
|
201
227
|
|
|
@@ -203,10 +229,10 @@ Your microfrontend project must install compatible versions of these shared depe
|
|
|
203
229
|
|
|
204
230
|
| Dependency | Purpose |
|
|
205
231
|
| ------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
206
|
-
| `react` | UI library
|
|
207
|
-
| `react-dom` | React DOM renderer
|
|
208
|
-
| `react-router` | Routing library
|
|
209
|
-
| `@grasp-labs/ds-microfrontends-integration` | This package
|
|
232
|
+
| `react` | UI library — singleton ensures one React instance across all microfrontends |
|
|
233
|
+
| `react-dom` | React DOM renderer — must match React version |
|
|
234
|
+
| `react-router` | Routing library — singleton required for React context to work across microfrontends |
|
|
235
|
+
| `@grasp-labs/ds-microfrontends-integration` | This package — singleton required for React context to work across microfrontends |
|
|
210
236
|
|
|
211
237
|
These dependencies are configured as singletons to prevent multiple instances and ensure compatibility across the microfrontend architecture.
|
|
212
238
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Control } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
2
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
3
|
-
type ArrayFieldProps = {
|
|
4
|
-
descriptor: FieldDescriptor
|
|
5
|
-
control: Control
|
|
3
|
+
type ArrayFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function ArrayField({ descriptor, control }: ArrayFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function ArrayField<T extends FieldValues = FieldValues>({ descriptor, control, }: ArrayFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Control } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
2
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
3
|
-
type BooleanFieldProps = {
|
|
4
|
-
descriptor: FieldDescriptor
|
|
5
|
-
control: Control
|
|
3
|
+
type BooleanFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function BooleanField({ descriptor, control }: BooleanFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function BooleanField<T extends FieldValues = FieldValues>({ descriptor, control, }: BooleanFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
1
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
control: Control;
|
|
3
|
+
type DateFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function DateField({ descriptor, control }: DateFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function DateField<T extends FieldValues = FieldValues>({ descriptor, control, }: DateFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Control } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
2
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
3
|
-
type EnumFieldProps = {
|
|
4
|
-
descriptor: FieldDescriptor
|
|
5
|
-
control: Control
|
|
3
|
+
type EnumFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function EnumField({ descriptor, control }: EnumFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function EnumField<T extends FieldValues = FieldValues>({ descriptor, control, }: EnumFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Control } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
2
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
3
|
-
type JsonFieldProps = {
|
|
4
|
-
descriptor: FieldDescriptor
|
|
5
|
-
control: Control
|
|
3
|
+
type JsonFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function JsonField({ descriptor, control }: JsonFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function JsonField<T extends FieldValues = FieldValues>({ descriptor, control, }: JsonFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Control } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
2
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
3
|
-
type NumberFieldProps = {
|
|
4
|
-
descriptor: FieldDescriptor
|
|
5
|
-
control: Control
|
|
3
|
+
type NumberFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function NumberField({ descriptor, control }: NumberFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function NumberField<T extends FieldValues = FieldValues>({ descriptor, control, }: NumberFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Control, FieldErrors } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldErrors, FieldValues } from 'react-hook-form';
|
|
2
2
|
import { Schema } from 'src/types/Schema';
|
|
3
|
-
type SchemaFieldsProps = {
|
|
4
|
-
control: Control
|
|
5
|
-
errors: FieldErrors
|
|
3
|
+
type SchemaFieldsProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
control: Control<T>;
|
|
5
|
+
errors: FieldErrors<T>;
|
|
6
6
|
schema: Schema | null;
|
|
7
7
|
prefix?: string;
|
|
8
8
|
fieldDirection?: "horizontal" | "vertical";
|
|
9
9
|
};
|
|
10
|
-
export declare function SchemaFields({ control, errors, schema, prefix, fieldDirection, }: SchemaFieldsProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function SchemaFields<T extends FieldValues = FieldValues>({ control, errors, schema, prefix, fieldDirection, }: SchemaFieldsProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Resolver } from 'react-hook-form';
|
|
2
3
|
import { Schema } from 'src/types';
|
|
3
4
|
type SchemaFieldsExampleProps = {
|
|
4
5
|
schema: Schema;
|
|
5
6
|
defaultValues: Record<string, unknown>;
|
|
6
7
|
fieldDirection?: "horizontal" | "vertical";
|
|
8
|
+
resolver?: Resolver;
|
|
7
9
|
};
|
|
8
10
|
declare const meta: {
|
|
9
11
|
title: string;
|
|
10
|
-
component: ({ schema, defaultValues, fieldDirection, }: SchemaFieldsExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
component: ({ schema, defaultValues, fieldDirection, resolver, }: SchemaFieldsExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
parameters: {
|
|
12
14
|
layout: string;
|
|
13
15
|
};
|
|
@@ -16,15 +18,18 @@ declare const meta: {
|
|
|
16
18
|
schema: Schema;
|
|
17
19
|
defaultValues: Record<string, unknown>;
|
|
18
20
|
fieldDirection?: "horizontal" | "vertical" | undefined;
|
|
21
|
+
resolver?: Resolver | undefined;
|
|
19
22
|
}>, context: import('storybook/internal/csf').StoryContext<import('@storybook/react').ReactRenderer, {
|
|
20
23
|
schema: Schema;
|
|
21
24
|
defaultValues: Record<string, unknown>;
|
|
22
25
|
fieldDirection?: "horizontal" | "vertical" | undefined;
|
|
26
|
+
resolver?: Resolver | undefined;
|
|
23
27
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
24
28
|
};
|
|
25
29
|
export default meta;
|
|
26
30
|
type Story = StoryObj<typeof meta>;
|
|
27
31
|
export declare const BasicForm: Story;
|
|
32
|
+
export declare const BasicFormWithCustomValidation: Story;
|
|
28
33
|
export declare const BasicFormWithVerticalAlignment: Story;
|
|
29
34
|
export declare const NestedWithVault: Story;
|
|
30
35
|
export declare const PasswordFields: Story;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Control } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
2
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
3
|
-
type TextFieldProps = {
|
|
4
|
-
descriptor: FieldDescriptor
|
|
5
|
-
control: Control
|
|
3
|
+
type TextFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function TextField({ descriptor, control }: TextFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function TextField<T extends FieldValues = FieldValues>({ descriptor, control, }: TextFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Control } from 'react-hook-form';
|
|
1
|
+
import { Control, FieldValues, Path } from 'react-hook-form';
|
|
2
2
|
import { FieldDescriptor } from 'src/lib/schema';
|
|
3
|
-
type VaultFieldProps = {
|
|
4
|
-
descriptor: FieldDescriptor
|
|
5
|
-
control: Control
|
|
3
|
+
type VaultFieldProps<T extends FieldValues = FieldValues> = {
|
|
4
|
+
descriptor: FieldDescriptor<Path<T>>;
|
|
5
|
+
control: Control<T>;
|
|
6
6
|
};
|
|
7
|
-
export declare function VaultField({ descriptor, control }: VaultFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function VaultField<T extends FieldValues = FieldValues>({ descriptor, control, }: VaultFieldProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './schemas';
|