@mui-toolpad-extended-tuni/users 3.1.0 → 3.2.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 +24 -16
- package/dist/UserMicroservice.d.ts +4 -1
- package/dist/hooks/useUsersApiConfig.d.ts +15 -0
- package/dist/index.cjs +27 -27
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1381 -1374
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,11 +41,11 @@ npm install @mui-toolpad-extended-tuni/users @mui-toolpad-extended-tuni/main @mu
|
|
|
41
41
|
|
|
42
42
|
## API Configuration
|
|
43
43
|
|
|
44
|
-
This package uses configurable API endpoints.
|
|
44
|
+
This package uses configurable API endpoints. Each microservice accepts its own `apiEndpoints` prop, allowing you to configure endpoints independently for only the services you use.
|
|
45
45
|
|
|
46
46
|
### Default Endpoints
|
|
47
47
|
|
|
48
|
-
If no
|
|
48
|
+
If no `apiEndpoints` prop is provided, the package uses these default endpoints:
|
|
49
49
|
|
|
50
50
|
- `getCurrent: "api/users/current/"` - GET current authenticated user
|
|
51
51
|
- `get: "api/users/"` - GET list of users
|
|
@@ -56,30 +56,35 @@ If no configuration is provided, the package uses these default endpoints:
|
|
|
56
56
|
|
|
57
57
|
### Customizing Endpoints
|
|
58
58
|
|
|
59
|
-
Configure endpoints
|
|
59
|
+
Configure endpoints directly on the `UserMicroservice` component:
|
|
60
60
|
|
|
61
61
|
```tsx
|
|
62
|
-
import {
|
|
62
|
+
import { UserMicroservice } from '@mui-toolpad-extended-tuni/users';
|
|
63
63
|
import type { UsersApiEndpoints } from '@mui-toolpad-extended-tuni/users';
|
|
64
64
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
logout: "https://api.example.com/v1/auth/logout",
|
|
73
|
-
} as UsersApiEndpoints,
|
|
65
|
+
const usersEndpoints: UsersApiEndpoints = {
|
|
66
|
+
getCurrent: "https://api.example.com/v1/users/me",
|
|
67
|
+
get: "https://api.example.com/v1/users",
|
|
68
|
+
post: "https://api.example.com/v1/users",
|
|
69
|
+
put: "https://api.example.com/v1/users/:id",
|
|
70
|
+
delete: "https://api.example.com/v1/users/:id",
|
|
71
|
+
logout: "https://api.example.com/v1/auth/logout",
|
|
74
72
|
};
|
|
75
73
|
|
|
76
|
-
<
|
|
77
|
-
{/* Your app */}
|
|
78
|
-
</ToolpadProvider>
|
|
74
|
+
<UserMicroservice apiEndpoints={usersEndpoints} />
|
|
79
75
|
```
|
|
80
76
|
|
|
81
77
|
**Note**: You can use either full URLs or relative paths. Placeholders like `:id` will be replaced with actual values at runtime.
|
|
82
78
|
|
|
79
|
+
**Partial Configuration**: You can configure only the endpoints you need to customize. Unspecified endpoints will use defaults:
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<UserMicroservice apiEndpoints={{
|
|
83
|
+
getCurrent: "api/v2/users/me", // Only override getCurrent endpoint
|
|
84
|
+
// Other endpoints use defaults
|
|
85
|
+
}} />
|
|
86
|
+
```
|
|
87
|
+
|
|
83
88
|
## Usage
|
|
84
89
|
|
|
85
90
|
### Basic Setup
|
|
@@ -425,6 +430,9 @@ type PlatformRole = "admin" | "developer" | "moderator" | "creator" | "user" | "
|
|
|
425
430
|
- `deleteUser(userId: string)` - Delete user
|
|
426
431
|
- `logoutUser()` - Logout current user
|
|
427
432
|
|
|
433
|
+
### Hooks
|
|
434
|
+
- `useUsersApiConfig()` - Hook to access users API endpoint configuration
|
|
435
|
+
|
|
428
436
|
### Configuration
|
|
429
437
|
- `configureUserBus` - Configures UserBus with store methods (called automatically)
|
|
430
438
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
import { UsersApiEndpoints } from '@mui-toolpad-extended-tuni/core';
|
|
3
|
+
export interface UserMicroserviceProps {
|
|
3
4
|
children?: ReactNode;
|
|
5
|
+
/** API endpoint configuration for the users microservice */
|
|
6
|
+
apiEndpoints?: UsersApiEndpoints;
|
|
4
7
|
}
|
|
5
8
|
/**
|
|
6
9
|
* UserMicroservice Component
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UsersApiEndpoints } from '@mui-toolpad-extended-tuni/core';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access users API configuration.
|
|
4
|
+
* Returns the users endpoint configuration merged with defaults.
|
|
5
|
+
*
|
|
6
|
+
* @returns Users API endpoints configuration, or undefined if not registered
|
|
7
|
+
* @throws Error if used outside of ApiConfigProvider
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const usersConfig = useUsersApiConfig();
|
|
12
|
+
* const endpoint = usersConfig?.getCurrent; // "api/users/current/" or custom value
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare const useUsersApiConfig: () => UsersApiEndpoints | undefined;
|