@mui-toolpad-extended-tuni/main 3.4.0 → 3.4.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 +111 -1
- package/dist/ToolpadProvider.d.ts +0 -3
- package/dist/index.cjs +24 -24
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +575 -574
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Main package for MUI Toolpad Extended TUNI - provides ToolpadProvider, LMS components, and platform features.
|
|
4
4
|
|
|
5
|
+
## Version 3.4.1
|
|
6
|
+
|
|
7
|
+
**Bug Fix:**
|
|
8
|
+
- Fixed build issue where `useApiConfig` was incorrectly referenced (removed in v3.3.0). The package now correctly uses `useServiceApiConfig` and `useApiConfigContext` from core.
|
|
9
|
+
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
7
12
|
```bash
|
|
@@ -84,6 +89,111 @@ import {
|
|
|
84
89
|
} from '@mui-toolpad-extended-tuni/main';
|
|
85
90
|
```
|
|
86
91
|
|
|
92
|
+
## API Configuration
|
|
93
|
+
|
|
94
|
+
Each microservice accepts its own `apiEndpoints` prop, allowing you to configure endpoints independently. This modular approach means you only configure endpoints for the microservices you actually use.
|
|
95
|
+
|
|
96
|
+
### Basic Configuration
|
|
97
|
+
|
|
98
|
+
Configure endpoints directly on each microservice component:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { CourseMicroservice } from '@mui-toolpad-extended-tuni/courses';
|
|
102
|
+
import { UserMicroservice } from '@mui-toolpad-extended-tuni/users';
|
|
103
|
+
import type { CoursesApiEndpoints, UsersApiEndpoints } from '@mui-toolpad-extended-tuni/core';
|
|
104
|
+
|
|
105
|
+
const coursesEndpoints: CoursesApiEndpoints = {
|
|
106
|
+
get: "https://api.example.com/v1/courses",
|
|
107
|
+
getById: "https://api.example.com/v1/courses/:id",
|
|
108
|
+
post: "https://api.example.com/v1/courses",
|
|
109
|
+
put: "https://api.example.com/v1/courses/:id",
|
|
110
|
+
delete: "https://api.example.com/v1/courses/:id",
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const usersEndpoints: UsersApiEndpoints = {
|
|
114
|
+
getCurrent: "https://api.example.com/v1/users/me",
|
|
115
|
+
get: "https://api.example.com/v1/users",
|
|
116
|
+
post: "https://api.example.com/v1/users",
|
|
117
|
+
put: "https://api.example.com/v1/users/:id",
|
|
118
|
+
delete: "https://api.example.com/v1/users/:id",
|
|
119
|
+
logout: "https://api.example.com/v1/auth/logout",
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
<ToolpadProvider>
|
|
123
|
+
<Microservices>
|
|
124
|
+
<CourseMicroservice apiEndpoints={coursesEndpoints}>
|
|
125
|
+
{/* Your course microservices */}
|
|
126
|
+
</CourseMicroservice>
|
|
127
|
+
<UserMicroservice apiEndpoints={usersEndpoints} />
|
|
128
|
+
</Microservices>
|
|
129
|
+
</ToolpadProvider>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### URL Format Guidelines
|
|
133
|
+
|
|
134
|
+
You can use either:
|
|
135
|
+
|
|
136
|
+
1. **Full URLs**: `"https://api.example.com/v1/courses"`
|
|
137
|
+
- Use when your API is on a different domain
|
|
138
|
+
- Supports both HTTP and HTTPS
|
|
139
|
+
|
|
140
|
+
2. **Relative Paths**: `"api/courses/"` or `"/api/courses/"`
|
|
141
|
+
- Use when your API is on the same domain
|
|
142
|
+
- Relative paths are resolved against the base URL (defaults to `/`)
|
|
143
|
+
|
|
144
|
+
### Placeholder Support
|
|
145
|
+
|
|
146
|
+
Endpoints can include placeholders that are replaced at runtime:
|
|
147
|
+
|
|
148
|
+
- `:id` - Replaced with the actual resource ID
|
|
149
|
+
- `:courseId` - Replaced with course ID
|
|
150
|
+
- `:encodedUrl` - Replaced with base64-encoded URL (for courses)
|
|
151
|
+
|
|
152
|
+
**Example**:
|
|
153
|
+
```tsx
|
|
154
|
+
<CourseMicroservice apiEndpoints={{
|
|
155
|
+
getById: "api/courses/:id", // :id will be replaced with actual course ID
|
|
156
|
+
put: "api/courses/:id/", // Same placeholder support
|
|
157
|
+
}}>
|
|
158
|
+
{/* Your course microservices */}
|
|
159
|
+
</CourseMicroservice>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Default Endpoints
|
|
163
|
+
|
|
164
|
+
If no `apiEndpoints` prop is provided, each microservice uses its default endpoints. See each microservice's README for their default endpoint values.
|
|
165
|
+
|
|
166
|
+
### Partial Configuration
|
|
167
|
+
|
|
168
|
+
You can configure only the endpoints you need to customize. Unspecified endpoints will use defaults:
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
<CourseMicroservice apiEndpoints={{
|
|
172
|
+
get: "https://custom-api.com/courses", // Only override GET
|
|
173
|
+
// Other endpoints use defaults
|
|
174
|
+
}}>
|
|
175
|
+
{/* Your course microservices */}
|
|
176
|
+
</CourseMicroservice>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Accessing Configuration
|
|
180
|
+
|
|
181
|
+
Each microservice provides its own hook for accessing configuration. No need to know service keys:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { useCoursesApiConfig } from '@mui-toolpad-extended-tuni/courses';
|
|
185
|
+
import { useUsersApiConfig } from '@mui-toolpad-extended-tuni/users';
|
|
186
|
+
|
|
187
|
+
function MyComponent() {
|
|
188
|
+
const coursesConfig = useCoursesApiConfig();
|
|
189
|
+
const usersConfig = useUsersApiConfig();
|
|
190
|
+
const coursesEndpoint = coursesConfig?.get; // "api/courses/" or custom value
|
|
191
|
+
const usersEndpoint = usersConfig?.getCurrent; // "api/users/current/" or custom value
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Each microservice package exports its own hook - developers never need to know internal service keys!
|
|
196
|
+
|
|
87
197
|
## Features
|
|
88
198
|
|
|
89
199
|
### ToolpadProvider
|
|
@@ -121,7 +231,7 @@ If you're migrating from the deprecated `mui-toolpad-extended-tuni` package:
|
|
|
121
231
|
```json
|
|
122
232
|
{
|
|
123
233
|
"dependencies": {
|
|
124
|
-
"@mui-toolpad-extended-tuni/main": "^3.4.
|
|
234
|
+
"@mui-toolpad-extended-tuni/main": "^3.4.1"
|
|
125
235
|
}
|
|
126
236
|
}
|
|
127
237
|
```
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { ApiConfig } from '../../core/src';
|
|
3
2
|
export interface LogoConfig {
|
|
4
3
|
sidebarFooter?: {
|
|
5
4
|
smallLogo?: string;
|
|
@@ -10,8 +9,6 @@ export interface LogoConfig {
|
|
|
10
9
|
export interface ToolpadProviderProps {
|
|
11
10
|
children?: ReactNode;
|
|
12
11
|
logos?: LogoConfig;
|
|
13
|
-
/** API endpoint configuration for microservices. Each microservice can define its own endpoints. */
|
|
14
|
-
apiConfig?: ApiConfig;
|
|
15
12
|
}
|
|
16
13
|
export declare const useLogoContext: () => LogoConfig;
|
|
17
14
|
/**
|