@cloudscaile-eng/web-ext-utils 0.0.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/LICENSE +86 -0
- package/README.md +248 -0
- package/dist/cs-ext-utils.untrimmed.d.ts +298 -0
- package/dist/index.d.ts +298 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +219 -0
- package/dist/index.js.map +1 -0
- package/package.json +85 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
“License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
“Licensor” shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
“Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
“Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
“Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
“Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
|
22
|
+
|
|
23
|
+
“Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
|
|
24
|
+
|
|
25
|
+
“Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work.
|
|
26
|
+
|
|
27
|
+
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License.
|
|
30
|
+
|
|
31
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License.
|
|
34
|
+
|
|
35
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work.
|
|
36
|
+
|
|
37
|
+
4. Redistribution.
|
|
38
|
+
|
|
39
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
40
|
+
|
|
41
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
42
|
+
|
|
43
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
44
|
+
|
|
45
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work.
|
|
46
|
+
|
|
47
|
+
(d) If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file.
|
|
48
|
+
|
|
49
|
+
5. Submission of Contributions.
|
|
50
|
+
|
|
51
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License.
|
|
52
|
+
|
|
53
|
+
6. Trademarks.
|
|
54
|
+
|
|
55
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work.
|
|
56
|
+
|
|
57
|
+
7. Disclaimer of Warranty.
|
|
58
|
+
|
|
59
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
|
|
60
|
+
|
|
61
|
+
8. Limitation of Liability.
|
|
62
|
+
|
|
63
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages arising out of the use or inability to use the Work.
|
|
64
|
+
|
|
65
|
+
9. Accepting Warranty or Additional Liability.
|
|
66
|
+
|
|
67
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer support, warranty, indemnity, or other liability obligations, but only on Your own behalf.
|
|
68
|
+
|
|
69
|
+
END OF TERMS AND CONDITIONS
|
|
70
|
+
|
|
71
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
72
|
+
|
|
73
|
+
Copyright 2026 CloudScaile
|
|
74
|
+
|
|
75
|
+
Licensed under the Apache License, Version 2.0 (the “License”);
|
|
76
|
+
you may not use this file except in compliance with the License.
|
|
77
|
+
You may obtain a copy of the License at
|
|
78
|
+
|
|
79
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
80
|
+
|
|
81
|
+
Unless required by applicable law or agreed to in writing, software
|
|
82
|
+
distributed under the License is distributed on an “AS IS” BASIS,
|
|
83
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
84
|
+
See the License for the specific language governing permissions and
|
|
85
|
+
limitations under the License.
|
|
86
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# Web Extension Utils
|
|
2
|
+
|
|
3
|
+
Extension utilities for micro-frontend architecture.
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
|
|
7
|
+
Install the package:
|
|
8
|
+
```bash
|
|
9
|
+
npm install @cloudscaile-eng/web-ext-utils
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### Peer Dependencies
|
|
13
|
+
|
|
14
|
+
This package requires the following peer dependencies to be installed in the host application:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @mui/material @reduxjs/toolkit axios
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Note on TypeScript Support**: TypeScript type definitions for peer dependencies are bundled with this package's distribution. You will receive full IntelliSense support even during the initial installation. However, at runtime, the peer dependencies must be installed in your project for the package to function correctly.
|
|
21
|
+
|
|
22
|
+
## Host Application
|
|
23
|
+
|
|
24
|
+
The host application must initialize shared resources before any micro-frontends can access them.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { initializeHost } from '@cloudscaile-eng/web-ext-utils';
|
|
28
|
+
|
|
29
|
+
const hostAPI = initializeHost({
|
|
30
|
+
extAxios: axiosFunction,
|
|
31
|
+
reduxStore: store,
|
|
32
|
+
eventBus: eventBusInstance,
|
|
33
|
+
injectReducers: injectReducerFunction,
|
|
34
|
+
registerTranslation: registerTranslationFunction,
|
|
35
|
+
theme: themeObject,
|
|
36
|
+
toast: toastFunction,
|
|
37
|
+
getUser: getUserFunction,
|
|
38
|
+
validateUserPermission: validateUserPermissionFunction,
|
|
39
|
+
triggerLogin: triggerLoginFunction
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Micro-Frontend Application
|
|
44
|
+
|
|
45
|
+
A micro-frontend can access shared resources using individual functions with an extension object.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import {
|
|
49
|
+
getExtension,
|
|
50
|
+
getExtAxios,
|
|
51
|
+
getReduxStore,
|
|
52
|
+
getEventBus,
|
|
53
|
+
injectReducers,
|
|
54
|
+
registerTranslation,
|
|
55
|
+
getNsForTranslation,
|
|
56
|
+
getTheme,
|
|
57
|
+
toast,
|
|
58
|
+
getUser,
|
|
59
|
+
validateUserPermission,
|
|
60
|
+
triggerLogin
|
|
61
|
+
} from '@cloudscaile-eng/web-ext-utils';
|
|
62
|
+
|
|
63
|
+
// Create extension object
|
|
64
|
+
const extension = getExtension('<tenant>', '<extension>');
|
|
65
|
+
|
|
66
|
+
// Access shared resources
|
|
67
|
+
const axiosInstance = getExtAxios(extension, { errorToast: true });
|
|
68
|
+
const store = getReduxStore(extension);
|
|
69
|
+
const eventBus = getEventBus(extension);
|
|
70
|
+
|
|
71
|
+
// Inject additional reducers into the host application
|
|
72
|
+
injectReducers(extension, {
|
|
73
|
+
reducers: { auth: authSlice.reducer },
|
|
74
|
+
whitelist: ['auth']
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Register translations
|
|
78
|
+
registerTranslation(extension, {
|
|
79
|
+
ns: 'auth',
|
|
80
|
+
translation: { en: { login: 'Login', logout: 'Logout' } }
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Get namespace for translations
|
|
84
|
+
const ns = getNsForTranslation(extension, 'auth');
|
|
85
|
+
|
|
86
|
+
// Access theme, show toast, and get user information
|
|
87
|
+
const theme = getTheme(extension);
|
|
88
|
+
toast(extension, 'Welcome!', 'success');
|
|
89
|
+
const user = getUser(extension);
|
|
90
|
+
const permissions = validateUserPermission(extension, ['payment.refund', 'inventory.bill']); // Returns {"payment.refund": true, "inventory.bill": false}
|
|
91
|
+
|
|
92
|
+
// Trigger login with redirect
|
|
93
|
+
triggerLogin(extension, { redirect: '/home/dash' });
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## API Reference
|
|
97
|
+
|
|
98
|
+
### `initializeHost(config)`
|
|
99
|
+
|
|
100
|
+
Initializes shared resources in the host application.
|
|
101
|
+
|
|
102
|
+
#### Parameters
|
|
103
|
+
|
|
104
|
+
- `config.extAxios`: The shared Axios instance function.
|
|
105
|
+
- `config.reduxStore`: The shared Redux store.
|
|
106
|
+
- `config.eventBus`: The shared event bus.
|
|
107
|
+
- `config.injectReducers`: Function to inject reducers into the host.
|
|
108
|
+
- `config.registerTranslation`: Function to register translations into the host.
|
|
109
|
+
- `config.theme`: Theme object to share with micro-frontends.
|
|
110
|
+
- `config.toast`: Function to show toast notifications.
|
|
111
|
+
- `config.getUser`: Function to get user information.
|
|
112
|
+
- `config.validateUserPermission`: Function to validate user permissions.
|
|
113
|
+
- `config.triggerLogin`: Function to trigger login in the host.
|
|
114
|
+
- `config.validateUserPermission`: Function to validate user permissions.
|
|
115
|
+
|
|
116
|
+
#### Returns
|
|
117
|
+
|
|
118
|
+
- `getSharedResources()`: Returns the shared resources object.
|
|
119
|
+
|
|
120
|
+
### `getExtension(tenant, name)`
|
|
121
|
+
|
|
122
|
+
Creates an extension object with tenant and name identifiers.
|
|
123
|
+
|
|
124
|
+
#### Parameters
|
|
125
|
+
|
|
126
|
+
- `tenant`: The tenant identifier specified in the manifest.
|
|
127
|
+
- `name`: The extension name as defined in the manifest.
|
|
128
|
+
|
|
129
|
+
#### Returns
|
|
130
|
+
|
|
131
|
+
Extension object.
|
|
132
|
+
|
|
133
|
+
### Individual Resource Functions
|
|
134
|
+
|
|
135
|
+
All resource functions require an `extension` object as the first parameter:
|
|
136
|
+
|
|
137
|
+
#### `getExtAxios(extension, config)`
|
|
138
|
+
|
|
139
|
+
Returns the shared Axios instance with optional configuration.
|
|
140
|
+
|
|
141
|
+
**Parameters:**
|
|
142
|
+
|
|
143
|
+
- `extension`: Extension object from `getExtension()`.
|
|
144
|
+
- `config`: Optional configuration object with properties like `errorToast`, `errorMessage`, `host`, `type`, `open`, `local`.
|
|
145
|
+
|
|
146
|
+
#### `getReduxStore(extension)`
|
|
147
|
+
|
|
148
|
+
Returns the shared Redux store.
|
|
149
|
+
|
|
150
|
+
**Parameters:**
|
|
151
|
+
|
|
152
|
+
- `extension`: Extension object from `getExtension()`.
|
|
153
|
+
|
|
154
|
+
#### `getEventBus(extension)`
|
|
155
|
+
|
|
156
|
+
Returns the shared event bus.
|
|
157
|
+
|
|
158
|
+
**Parameters:**
|
|
159
|
+
|
|
160
|
+
- `extension`: Extension object from `getExtension()`.
|
|
161
|
+
|
|
162
|
+
#### `injectReducers(extension, options)`
|
|
163
|
+
|
|
164
|
+
Injects reducers into the host application.
|
|
165
|
+
|
|
166
|
+
**Parameters:**
|
|
167
|
+
|
|
168
|
+
- `extension`: Extension object from `getExtension()`.
|
|
169
|
+
- `options`: Object with `reducers`, `whitelist`, and `replace` properties.
|
|
170
|
+
|
|
171
|
+
#### `registerTranslation(extension, options)`
|
|
172
|
+
|
|
173
|
+
Registers translations into the host application.
|
|
174
|
+
|
|
175
|
+
**Parameters:**
|
|
176
|
+
|
|
177
|
+
- `extension`: Extension object from `getExtension()`.
|
|
178
|
+
- `options`: Object with `ns` (namespace) and `translation` properties.
|
|
179
|
+
|
|
180
|
+
#### `getNsForTranslation(extension, extensionNs)`
|
|
181
|
+
|
|
182
|
+
Returns the namespace string for translations.
|
|
183
|
+
|
|
184
|
+
**Parameters:**
|
|
185
|
+
|
|
186
|
+
- `extension`: Extension object from `getExtension()`.
|
|
187
|
+
- `extensionNs`: The extension-specific namespace.
|
|
188
|
+
|
|
189
|
+
#### `getTheme(extension)`
|
|
190
|
+
|
|
191
|
+
Returns the shared theme object.
|
|
192
|
+
|
|
193
|
+
**Parameters:**
|
|
194
|
+
|
|
195
|
+
- `extension`: Extension object from `getExtension()`.
|
|
196
|
+
|
|
197
|
+
#### `toast(extension, message, type)`
|
|
198
|
+
|
|
199
|
+
Shows a toast notification.
|
|
200
|
+
|
|
201
|
+
**Parameters:**
|
|
202
|
+
|
|
203
|
+
- `extension`: Extension object from `getExtension()`.
|
|
204
|
+
- `message`: The message to display.
|
|
205
|
+
- `type`: Toast type ('success', 'error', 'info', 'warn').
|
|
206
|
+
|
|
207
|
+
#### `getUser(extension)`
|
|
208
|
+
|
|
209
|
+
Returns the user information from the host application.
|
|
210
|
+
|
|
211
|
+
**Parameters:**
|
|
212
|
+
|
|
213
|
+
- `extension`: Extension object from `getExtension()`.
|
|
214
|
+
|
|
215
|
+
#### `validateUserPermission(extension, permissions)`
|
|
216
|
+
|
|
217
|
+
Validates user permissions for the given extension.
|
|
218
|
+
|
|
219
|
+
**Parameters:**
|
|
220
|
+
|
|
221
|
+
- `extension`: Extension object from `getExtension()`.
|
|
222
|
+
|
|
223
|
+
- `permissions`: Array of permission keys (e.g., `['payment.refund', 'inventory.bill']`).
|
|
224
|
+
|
|
225
|
+
**Returns:**
|
|
226
|
+
|
|
227
|
+
An object mapping each permission to a boolean (e.g., `{"payment.refund": true, "inventory.bill": false}`).
|
|
228
|
+
|
|
229
|
+
### `triggerLogin(extension, config)`
|
|
230
|
+
|
|
231
|
+
Triggers the login process in the host application for the given extension.
|
|
232
|
+
|
|
233
|
+
#### Parameters
|
|
234
|
+
|
|
235
|
+
- `extension`: Extension object from `getExtension()`.
|
|
236
|
+
|
|
237
|
+
- `config`: Optional configuration object with properties like `redirect` (e.g., `'/home/dash'`).
|
|
238
|
+
|
|
239
|
+
**Returns:**
|
|
240
|
+
|
|
241
|
+
The result of the triggerLogin resource.
|
|
242
|
+
|
|
243
|
+
## Error Handling
|
|
244
|
+
|
|
245
|
+
- If the host has not initialized resources, individual resource functions will throw an error.
|
|
246
|
+
- Ensure `initializeHost()` is called before loading any micro-frontends.
|
|
247
|
+
- If required resources are missing during host initialization, an error will be thrown.
|
|
248
|
+
- Extension validation will throw errors if `tenant` or `name` is missing from the extension
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
import { AxiosRequestConfig } from 'axios';
|
|
4
|
+
import { AxiosResponse } from 'axios';
|
|
5
|
+
import { CssVarsTheme } from '@mui/material/styles';
|
|
6
|
+
import { EnhancedStore } from '@reduxjs/toolkit';
|
|
7
|
+
import { StoreEnhancer } from '@reduxjs/toolkit';
|
|
8
|
+
import { Theme } from '@mui/material/styles';
|
|
9
|
+
import { ThemeOptions } from '@mui/material/styles';
|
|
10
|
+
import { ThunkDispatch } from '@reduxjs/toolkit';
|
|
11
|
+
import { Tuple } from '@reduxjs/toolkit';
|
|
12
|
+
import { UnknownAction } from '@reduxjs/toolkit';
|
|
13
|
+
|
|
14
|
+
export { AxiosError }
|
|
15
|
+
|
|
16
|
+
export { AxiosInstance }
|
|
17
|
+
|
|
18
|
+
export { AxiosRequestConfig }
|
|
19
|
+
|
|
20
|
+
export { AxiosResponse }
|
|
21
|
+
|
|
22
|
+
export { CssVarsTheme }
|
|
23
|
+
|
|
24
|
+
export { EnhancedStore }
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Callback function type for event handlers
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare type EventCallback<T = unknown> = (data: T) => void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Configuration options for the extension axios instance
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare type ExtAxiosConfig = {
|
|
37
|
+
errorToast?: boolean;
|
|
38
|
+
errorMessage?: string;
|
|
39
|
+
host?: boolean;
|
|
40
|
+
type?: string;
|
|
41
|
+
open?: boolean;
|
|
42
|
+
local?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Extension interface containing identification information
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare interface Extension {
|
|
50
|
+
tenant: string;
|
|
51
|
+
name: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the Event Bus resource for the given extension.
|
|
56
|
+
* @param extension - The extension object.
|
|
57
|
+
* @returns The Event Bus resource instance.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function getEventBus(extension: Extension): SharedResources['eventBus'];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns the extAxios resource for the given extension.
|
|
64
|
+
* @param extension - The extension object.
|
|
65
|
+
* @param config - Optional configuration for extAxios.
|
|
66
|
+
* @returns The extAxios resource instance.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export declare function getExtAxios(extension: Extension, config?: ExtAxiosConfig): AxiosInstance;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Creates an extension object with tenant and name.
|
|
73
|
+
* @param tenant - The tenant identifier.
|
|
74
|
+
* @param name - The extension name.
|
|
75
|
+
* @returns The extension object.
|
|
76
|
+
* @throws Will throw an error if tenant or name is missing.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare function getExtension(tenant: string, name: string): Extension;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Generates a translation namespace string for the given extension.
|
|
83
|
+
* @param extension - The extension object.
|
|
84
|
+
* @param extensionNs - The extension-specific namespace.
|
|
85
|
+
* @returns The generated namespace string.
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export declare function getNsForTranslation(extension: Extension, extensionNs: string): string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns the Redux store resource for the given extension.
|
|
92
|
+
* @param extension - The extension object.
|
|
93
|
+
* @returns The Redux store resource instance.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export declare function getReduxStore(extension: Extension): SharedResources['reduxStore'];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns the theme resource for the given extension.
|
|
100
|
+
* @param extension - The extension object.
|
|
101
|
+
* @returns The MUI theme resource instance.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare function getTheme(extension: Extension): Theme;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves the user information for the given extension.
|
|
108
|
+
* @param extension - The extension object.
|
|
109
|
+
* @returns The user information resource instance.
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare function getUser(extension: Extension): User;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Host API interface returned by initializeHost
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
export declare interface HostAPI {
|
|
119
|
+
getSharedResources(): SharedResources;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Host initialization configuration
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export declare interface HostConfig {
|
|
127
|
+
extAxios: SharedResources['extAxios'];
|
|
128
|
+
reduxStore: SharedResources['reduxStore'];
|
|
129
|
+
eventBus: SharedResources['eventBus'];
|
|
130
|
+
injectReducers: SharedResources['injectReducers'];
|
|
131
|
+
registerTranslation: SharedResources['registerTranslation'];
|
|
132
|
+
toast: SharedResources['toast'];
|
|
133
|
+
getUser: SharedResources['getUser'];
|
|
134
|
+
validateUserPermission: SharedResources['validateUserPermission'];
|
|
135
|
+
triggerLogin: SharedResources['triggerLogin'];
|
|
136
|
+
theme: SharedResources['theme'];
|
|
137
|
+
initialized?: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Initialize the communication package in the host application
|
|
142
|
+
* @param config - Configuration object containing:
|
|
143
|
+
* - extAxios: The axios interceptor from the host
|
|
144
|
+
* - reduxStore: The Redux store from the host
|
|
145
|
+
* - eventBus: The Event Bus from the host
|
|
146
|
+
* - injectReducers: Function to inject a reducer into the host store
|
|
147
|
+
* - registerTranslation: Function to register translations in the host
|
|
148
|
+
* - theme: The theme resource from the host
|
|
149
|
+
* - toast: Function to trigger toast notifications in the host
|
|
150
|
+
* - getUser: Function to get the user information from the host
|
|
151
|
+
* - validateUserPermission: Function to validate user permissions in the host
|
|
152
|
+
* - triggerLogin: Function to trigger login in the host
|
|
153
|
+
* @throws Will throw an error if any required configuration is missing
|
|
154
|
+
* @returns Object with method to access shared resources
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export declare function initializeHost(config: HostConfig): HostAPI;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Configuration for injecting reducers into the Redux store
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
export declare type InjectedReducer = {
|
|
164
|
+
reducers: Record<string, unknown>;
|
|
165
|
+
whitelist?: string[];
|
|
166
|
+
replace?: string[];
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Injects reducers into the host Redux store for the given extension.
|
|
171
|
+
* @param extension - The extension object.
|
|
172
|
+
* @param params - Reducer injection options.
|
|
173
|
+
* @returns The result of the injectReducers resource.
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
export declare function injectReducers(extension: Extension, params: InjectedReducer): boolean;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Configuration for registering translations
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
export declare type RegisterTranslation = {
|
|
183
|
+
ns: string;
|
|
184
|
+
translation: Record<string, unknown>;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Registers a translation namespace and content for the given extension.
|
|
189
|
+
* @param extension - The extension object.
|
|
190
|
+
* @param params - Translation registration options.
|
|
191
|
+
* @returns The result of the registerTranslation resource.
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare function registerTranslation(extension: Extension, params: RegisterTranslation): boolean;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Shared resources interface representing data shared between host and micro-frontends
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
200
|
+
export declare interface SharedResources {
|
|
201
|
+
extAxios: (config: ExtAxiosConfig & {
|
|
202
|
+
name: string;
|
|
203
|
+
tenant: string;
|
|
204
|
+
}) => AxiosInstance;
|
|
205
|
+
reduxStore: EnhancedStore<{
|
|
206
|
+
store: {
|
|
207
|
+
store: number;
|
|
208
|
+
active: number;
|
|
209
|
+
};
|
|
210
|
+
}, UnknownAction, Tuple<[
|
|
211
|
+
StoreEnhancer<{
|
|
212
|
+
dispatch: ThunkDispatch<{
|
|
213
|
+
store: {
|
|
214
|
+
store: number;
|
|
215
|
+
active: number;
|
|
216
|
+
};
|
|
217
|
+
}, undefined, UnknownAction>;
|
|
218
|
+
}>,
|
|
219
|
+
StoreEnhancer
|
|
220
|
+
]>>;
|
|
221
|
+
eventBus: {
|
|
222
|
+
events: Record<string, EventCallback[]>;
|
|
223
|
+
on<T = unknown>(event: string, callback: EventCallback<T>): void;
|
|
224
|
+
emit<T = unknown>(event: string, data: T): void;
|
|
225
|
+
};
|
|
226
|
+
injectReducers: (params: InjectedReducer) => boolean;
|
|
227
|
+
registerTranslation: (params: RegisterTranslation) => boolean;
|
|
228
|
+
toast: (message: string, type: ToastType) => void;
|
|
229
|
+
getUser: () => User;
|
|
230
|
+
validateUserPermission: (extension: Extension, permissions: string[]) => Record<string, boolean>;
|
|
231
|
+
triggerLogin: (config?: TriggerLoginConfig) => unknown;
|
|
232
|
+
theme: Theme;
|
|
233
|
+
initialized: boolean;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { StoreEnhancer }
|
|
237
|
+
|
|
238
|
+
export { Theme }
|
|
239
|
+
|
|
240
|
+
export { ThemeOptions }
|
|
241
|
+
|
|
242
|
+
export { ThunkDispatch }
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Triggers a toast notification for the given extension.
|
|
246
|
+
* @param extension - The extension object.
|
|
247
|
+
* @param message - The message to display in the toast.
|
|
248
|
+
* @param type - The type of toast (e.g., 'success', 'error').
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
export declare function toast(extension: Extension, message: string, type: ToastType): void;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Type of toast notification
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
export declare type ToastType = 'success' | 'error' | 'info' | 'warn';
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Triggers the login process in the host application for the given extension.
|
|
261
|
+
* @param extension - The extension object.
|
|
262
|
+
* @param config - Optional configuration for login.
|
|
263
|
+
* @returns The result of the triggerLogin resource.
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
export declare function triggerLogin(extension: Extension, config?: TriggerLoginConfig): unknown;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Configuration for triggering the login process
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
export declare type TriggerLoginConfig = {
|
|
273
|
+
redirect?: string;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export { Tuple }
|
|
277
|
+
|
|
278
|
+
export { UnknownAction }
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* User information object
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
284
|
+
export declare type User = {
|
|
285
|
+
data: object | null;
|
|
286
|
+
isAuthenticated: boolean;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Validates user permissions for the given extension.
|
|
291
|
+
* @param extension - The extension object.
|
|
292
|
+
* @param permissions - The list of permissions to validate.
|
|
293
|
+
* @returns The result of the validateUserPermission resource.
|
|
294
|
+
* @public
|
|
295
|
+
*/
|
|
296
|
+
export declare function validateUserPermission(extension: Extension, permissions: string[]): Record<string, boolean>;
|
|
297
|
+
|
|
298
|
+
export { }
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
import { AxiosRequestConfig } from 'axios';
|
|
4
|
+
import { AxiosResponse } from 'axios';
|
|
5
|
+
import { CssVarsTheme } from '@mui/material/styles';
|
|
6
|
+
import { EnhancedStore } from '@reduxjs/toolkit';
|
|
7
|
+
import { StoreEnhancer } from '@reduxjs/toolkit';
|
|
8
|
+
import { Theme } from '@mui/material/styles';
|
|
9
|
+
import { ThemeOptions } from '@mui/material/styles';
|
|
10
|
+
import { ThunkDispatch } from '@reduxjs/toolkit';
|
|
11
|
+
import { Tuple } from '@reduxjs/toolkit';
|
|
12
|
+
import { UnknownAction } from '@reduxjs/toolkit';
|
|
13
|
+
|
|
14
|
+
export { AxiosError }
|
|
15
|
+
|
|
16
|
+
export { AxiosInstance }
|
|
17
|
+
|
|
18
|
+
export { AxiosRequestConfig }
|
|
19
|
+
|
|
20
|
+
export { AxiosResponse }
|
|
21
|
+
|
|
22
|
+
export { CssVarsTheme }
|
|
23
|
+
|
|
24
|
+
export { EnhancedStore }
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Callback function type for event handlers
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare type EventCallback<T = unknown> = (data: T) => void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Configuration options for the extension axios instance
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare type ExtAxiosConfig = {
|
|
37
|
+
errorToast?: boolean;
|
|
38
|
+
errorMessage?: string;
|
|
39
|
+
host?: boolean;
|
|
40
|
+
type?: string;
|
|
41
|
+
open?: boolean;
|
|
42
|
+
local?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Extension interface containing identification information
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare interface Extension {
|
|
50
|
+
tenant: string;
|
|
51
|
+
name: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the Event Bus resource for the given extension.
|
|
56
|
+
* @param extension - The extension object.
|
|
57
|
+
* @returns The Event Bus resource instance.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function getEventBus(extension: Extension): SharedResources['eventBus'];
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Returns the extAxios resource for the given extension.
|
|
64
|
+
* @param extension - The extension object.
|
|
65
|
+
* @param config - Optional configuration for extAxios.
|
|
66
|
+
* @returns The extAxios resource instance.
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export declare function getExtAxios(extension: Extension, config?: ExtAxiosConfig): AxiosInstance;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Creates an extension object with tenant and name.
|
|
73
|
+
* @param tenant - The tenant identifier.
|
|
74
|
+
* @param name - The extension name.
|
|
75
|
+
* @returns The extension object.
|
|
76
|
+
* @throws Will throw an error if tenant or name is missing.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare function getExtension(tenant: string, name: string): Extension;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Generates a translation namespace string for the given extension.
|
|
83
|
+
* @param extension - The extension object.
|
|
84
|
+
* @param extensionNs - The extension-specific namespace.
|
|
85
|
+
* @returns The generated namespace string.
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
export declare function getNsForTranslation(extension: Extension, extensionNs: string): string;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns the Redux store resource for the given extension.
|
|
92
|
+
* @param extension - The extension object.
|
|
93
|
+
* @returns The Redux store resource instance.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
export declare function getReduxStore(extension: Extension): SharedResources['reduxStore'];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns the theme resource for the given extension.
|
|
100
|
+
* @param extension - The extension object.
|
|
101
|
+
* @returns The MUI theme resource instance.
|
|
102
|
+
* @public
|
|
103
|
+
*/
|
|
104
|
+
export declare function getTheme(extension: Extension): Theme;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Retrieves the user information for the given extension.
|
|
108
|
+
* @param extension - The extension object.
|
|
109
|
+
* @returns The user information resource instance.
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
export declare function getUser(extension: Extension): User;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Host API interface returned by initializeHost
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
export declare interface HostAPI {
|
|
119
|
+
getSharedResources(): SharedResources;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Host initialization configuration
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export declare interface HostConfig {
|
|
127
|
+
extAxios: SharedResources['extAxios'];
|
|
128
|
+
reduxStore: SharedResources['reduxStore'];
|
|
129
|
+
eventBus: SharedResources['eventBus'];
|
|
130
|
+
injectReducers: SharedResources['injectReducers'];
|
|
131
|
+
registerTranslation: SharedResources['registerTranslation'];
|
|
132
|
+
toast: SharedResources['toast'];
|
|
133
|
+
getUser: SharedResources['getUser'];
|
|
134
|
+
validateUserPermission: SharedResources['validateUserPermission'];
|
|
135
|
+
triggerLogin: SharedResources['triggerLogin'];
|
|
136
|
+
theme: SharedResources['theme'];
|
|
137
|
+
initialized?: boolean;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Initialize the communication package in the host application
|
|
142
|
+
* @param config - Configuration object containing:
|
|
143
|
+
* - extAxios: The axios interceptor from the host
|
|
144
|
+
* - reduxStore: The Redux store from the host
|
|
145
|
+
* - eventBus: The Event Bus from the host
|
|
146
|
+
* - injectReducers: Function to inject a reducer into the host store
|
|
147
|
+
* - registerTranslation: Function to register translations in the host
|
|
148
|
+
* - theme: The theme resource from the host
|
|
149
|
+
* - toast: Function to trigger toast notifications in the host
|
|
150
|
+
* - getUser: Function to get the user information from the host
|
|
151
|
+
* - validateUserPermission: Function to validate user permissions in the host
|
|
152
|
+
* - triggerLogin: Function to trigger login in the host
|
|
153
|
+
* @throws Will throw an error if any required configuration is missing
|
|
154
|
+
* @returns Object with method to access shared resources
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export declare function initializeHost(config: HostConfig): HostAPI;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Configuration for injecting reducers into the Redux store
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
export declare type InjectedReducer = {
|
|
164
|
+
reducers: Record<string, unknown>;
|
|
165
|
+
whitelist?: string[];
|
|
166
|
+
replace?: string[];
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Injects reducers into the host Redux store for the given extension.
|
|
171
|
+
* @param extension - The extension object.
|
|
172
|
+
* @param params - Reducer injection options.
|
|
173
|
+
* @returns The result of the injectReducers resource.
|
|
174
|
+
* @public
|
|
175
|
+
*/
|
|
176
|
+
export declare function injectReducers(extension: Extension, params: InjectedReducer): boolean;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Configuration for registering translations
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
export declare type RegisterTranslation = {
|
|
183
|
+
ns: string;
|
|
184
|
+
translation: Record<string, unknown>;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Registers a translation namespace and content for the given extension.
|
|
189
|
+
* @param extension - The extension object.
|
|
190
|
+
* @param params - Translation registration options.
|
|
191
|
+
* @returns The result of the registerTranslation resource.
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare function registerTranslation(extension: Extension, params: RegisterTranslation): boolean;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Shared resources interface representing data shared between host and micro-frontends
|
|
198
|
+
* @public
|
|
199
|
+
*/
|
|
200
|
+
export declare interface SharedResources {
|
|
201
|
+
extAxios: (config: ExtAxiosConfig & {
|
|
202
|
+
name: string;
|
|
203
|
+
tenant: string;
|
|
204
|
+
}) => AxiosInstance;
|
|
205
|
+
reduxStore: EnhancedStore<{
|
|
206
|
+
store: {
|
|
207
|
+
store: number;
|
|
208
|
+
active: number;
|
|
209
|
+
};
|
|
210
|
+
}, UnknownAction, Tuple<[
|
|
211
|
+
StoreEnhancer<{
|
|
212
|
+
dispatch: ThunkDispatch<{
|
|
213
|
+
store: {
|
|
214
|
+
store: number;
|
|
215
|
+
active: number;
|
|
216
|
+
};
|
|
217
|
+
}, undefined, UnknownAction>;
|
|
218
|
+
}>,
|
|
219
|
+
StoreEnhancer
|
|
220
|
+
]>>;
|
|
221
|
+
eventBus: {
|
|
222
|
+
events: Record<string, EventCallback[]>;
|
|
223
|
+
on<T = unknown>(event: string, callback: EventCallback<T>): void;
|
|
224
|
+
emit<T = unknown>(event: string, data: T): void;
|
|
225
|
+
};
|
|
226
|
+
injectReducers: (params: InjectedReducer) => boolean;
|
|
227
|
+
registerTranslation: (params: RegisterTranslation) => boolean;
|
|
228
|
+
toast: (message: string, type: ToastType) => void;
|
|
229
|
+
getUser: () => User;
|
|
230
|
+
validateUserPermission: (extension: Extension, permissions: string[]) => Record<string, boolean>;
|
|
231
|
+
triggerLogin: (config?: TriggerLoginConfig) => unknown;
|
|
232
|
+
theme: Theme;
|
|
233
|
+
initialized: boolean;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { StoreEnhancer }
|
|
237
|
+
|
|
238
|
+
export { Theme }
|
|
239
|
+
|
|
240
|
+
export { ThemeOptions }
|
|
241
|
+
|
|
242
|
+
export { ThunkDispatch }
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Triggers a toast notification for the given extension.
|
|
246
|
+
* @param extension - The extension object.
|
|
247
|
+
* @param message - The message to display in the toast.
|
|
248
|
+
* @param type - The type of toast (e.g., 'success', 'error').
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
export declare function toast(extension: Extension, message: string, type: ToastType): void;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Type of toast notification
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
export declare type ToastType = 'success' | 'error' | 'info' | 'warn';
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Triggers the login process in the host application for the given extension.
|
|
261
|
+
* @param extension - The extension object.
|
|
262
|
+
* @param config - Optional configuration for login.
|
|
263
|
+
* @returns The result of the triggerLogin resource.
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
export declare function triggerLogin(extension: Extension, config?: TriggerLoginConfig): unknown;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Configuration for triggering the login process
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
export declare type TriggerLoginConfig = {
|
|
273
|
+
redirect?: string;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export { Tuple }
|
|
277
|
+
|
|
278
|
+
export { UnknownAction }
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* User information object
|
|
282
|
+
* @public
|
|
283
|
+
*/
|
|
284
|
+
export declare type User = {
|
|
285
|
+
data: object | null;
|
|
286
|
+
isAuthenticated: boolean;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Validates user permissions for the given extension.
|
|
291
|
+
* @param extension - The extension object.
|
|
292
|
+
* @param permissions - The list of permissions to validate.
|
|
293
|
+
* @returns The result of the validateUserPermission resource.
|
|
294
|
+
* @public
|
|
295
|
+
*/
|
|
296
|
+
export declare function validateUserPermission(extension: Extension, permissions: string[]): Record<string, boolean>;
|
|
297
|
+
|
|
298
|
+
export { }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,KAAK,EACL,aAAa,EACb,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAIlD;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,IAAI,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
|
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*/
|
|
7
|
+
// ============ Implementation ============
|
|
8
|
+
let globalStore = {
|
|
9
|
+
initialized: false
|
|
10
|
+
};
|
|
11
|
+
const ERROR_MAPS = {
|
|
12
|
+
extAxios: 'Axios Interceptor',
|
|
13
|
+
reduxStore: 'Redux Store',
|
|
14
|
+
eventBus: 'Event Bus',
|
|
15
|
+
injectReducers: 'Inject Reducers',
|
|
16
|
+
registerTranslation: 'Register Translation',
|
|
17
|
+
theme: 'Theme',
|
|
18
|
+
toast: 'Toast',
|
|
19
|
+
getUser: 'Get User',
|
|
20
|
+
validateUserPermission: 'Validate User Permission',
|
|
21
|
+
triggerLogin: 'Trigger Login'
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Initialize the communication package in the host application
|
|
25
|
+
* @param config - Configuration object containing:
|
|
26
|
+
* - extAxios: The axios interceptor from the host
|
|
27
|
+
* - reduxStore: The Redux store from the host
|
|
28
|
+
* - eventBus: The Event Bus from the host
|
|
29
|
+
* - injectReducers: Function to inject a reducer into the host store
|
|
30
|
+
* - registerTranslation: Function to register translations in the host
|
|
31
|
+
* - theme: The theme resource from the host
|
|
32
|
+
* - toast: Function to trigger toast notifications in the host
|
|
33
|
+
* - getUser: Function to get the user information from the host
|
|
34
|
+
* - validateUserPermission: Function to validate user permissions in the host
|
|
35
|
+
* - triggerLogin: Function to trigger login in the host
|
|
36
|
+
* @throws Will throw an error if any required configuration is missing
|
|
37
|
+
* @returns Object with method to access shared resources
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
export function initializeHost(config) {
|
|
41
|
+
Object.keys(ERROR_MAPS).forEach((key) => {
|
|
42
|
+
if (!config[key]) {
|
|
43
|
+
throw new Error(`${ERROR_MAPS[key]} is required`);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
globalStore = {
|
|
47
|
+
...globalStore,
|
|
48
|
+
...config,
|
|
49
|
+
initialized: true
|
|
50
|
+
};
|
|
51
|
+
window.__MF_SHARED_RESOURCES__ = globalStore;
|
|
52
|
+
return {
|
|
53
|
+
getSharedResources: () => ({ ...globalStore })
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves a shared resource from the global window object.
|
|
58
|
+
* @param resource - The name of the resource to retrieve.
|
|
59
|
+
* @returns The requested shared resource instance.
|
|
60
|
+
* @throws Will throw an error if the resource is not found or not initialized by the host app.
|
|
61
|
+
*/
|
|
62
|
+
function getResource(resource) {
|
|
63
|
+
if (!window.__MF_SHARED_RESOURCES__?.[resource]) {
|
|
64
|
+
throw new Error(`Resource not found: ${resource}. Please ensure the host app has initialized this resource.`);
|
|
65
|
+
}
|
|
66
|
+
return window.__MF_SHARED_RESOURCES__[resource];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Validates that the extension object contains required properties.
|
|
70
|
+
* @param extension - The extension object to validate.
|
|
71
|
+
* @throws Will throw an error if the extension name or tenant is missing.
|
|
72
|
+
*/
|
|
73
|
+
function validateExtension(extension) {
|
|
74
|
+
if (!extension?.name) {
|
|
75
|
+
throw new Error('Extension name is required');
|
|
76
|
+
}
|
|
77
|
+
if (!extension?.tenant) {
|
|
78
|
+
throw new Error('Tenant is required for the extension');
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates an extension object with tenant and name.
|
|
83
|
+
* @param tenant - The tenant identifier.
|
|
84
|
+
* @param name - The extension name.
|
|
85
|
+
* @returns The extension object.
|
|
86
|
+
* @throws Will throw an error if tenant or name is missing.
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
export function getExtension(tenant, name) {
|
|
90
|
+
if (!name || !tenant) {
|
|
91
|
+
throw new Error('Tenant and extension name required');
|
|
92
|
+
}
|
|
93
|
+
return { tenant, name };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns the extAxios resource for the given extension.
|
|
97
|
+
* @param extension - The extension object.
|
|
98
|
+
* @param config - Optional configuration for extAxios.
|
|
99
|
+
* @returns The extAxios resource instance.
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
export function getExtAxios(extension, config = {}) {
|
|
103
|
+
validateExtension(extension);
|
|
104
|
+
const extAxios = getResource('extAxios');
|
|
105
|
+
return extAxios({ ...config, name: extension.name, tenant: extension.tenant });
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns the Redux store resource for the given extension.
|
|
109
|
+
* @param extension - The extension object.
|
|
110
|
+
* @returns The Redux store resource instance.
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export function getReduxStore(extension) {
|
|
114
|
+
validateExtension(extension);
|
|
115
|
+
return getResource('reduxStore');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns the Event Bus resource for the given extension.
|
|
119
|
+
* @param extension - The extension object.
|
|
120
|
+
* @returns The Event Bus resource instance.
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export function getEventBus(extension) {
|
|
124
|
+
validateExtension(extension);
|
|
125
|
+
return getResource('eventBus');
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Injects reducers into the host Redux store for the given extension.
|
|
129
|
+
* @param extension - The extension object.
|
|
130
|
+
* @param params - Reducer injection options.
|
|
131
|
+
* @returns The result of the injectReducers resource.
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
export function injectReducers(extension, params) {
|
|
135
|
+
validateExtension(extension);
|
|
136
|
+
const injectReducersResource = getResource('injectReducers');
|
|
137
|
+
return injectReducersResource(params);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Registers a translation namespace and content for the given extension.
|
|
141
|
+
* @param extension - The extension object.
|
|
142
|
+
* @param params - Translation registration options.
|
|
143
|
+
* @returns The result of the registerTranslation resource.
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
export function registerTranslation(extension, params) {
|
|
147
|
+
validateExtension(extension);
|
|
148
|
+
const registerTranslationResource = getResource('registerTranslation');
|
|
149
|
+
return registerTranslationResource(params);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Generates a translation namespace string for the given extension.
|
|
153
|
+
* @param extension - The extension object.
|
|
154
|
+
* @param extensionNs - The extension-specific namespace.
|
|
155
|
+
* @returns The generated namespace string.
|
|
156
|
+
* @public
|
|
157
|
+
*/
|
|
158
|
+
export function getNsForTranslation(extension, extensionNs) {
|
|
159
|
+
validateExtension(extension);
|
|
160
|
+
return `${extension.tenant}_${extension.name}_${extensionNs}`;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Returns the theme resource for the given extension.
|
|
164
|
+
* @param extension - The extension object.
|
|
165
|
+
* @returns The MUI theme resource instance.
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
export function getTheme(extension) {
|
|
169
|
+
validateExtension(extension);
|
|
170
|
+
return getResource('theme');
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Triggers a toast notification for the given extension.
|
|
174
|
+
* @param extension - The extension object.
|
|
175
|
+
* @param message - The message to display in the toast.
|
|
176
|
+
* @param type - The type of toast (e.g., 'success', 'error').
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
export function toast(extension, message, type) {
|
|
180
|
+
validateExtension(extension);
|
|
181
|
+
const toastResource = getResource('toast');
|
|
182
|
+
toastResource(message, type);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves the user information for the given extension.
|
|
186
|
+
* @param extension - The extension object.
|
|
187
|
+
* @returns The user information resource instance.
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
export function getUser(extension) {
|
|
191
|
+
validateExtension(extension);
|
|
192
|
+
const getUserResource = getResource('getUser');
|
|
193
|
+
return getUserResource();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Validates user permissions for the given extension.
|
|
197
|
+
* @param extension - The extension object.
|
|
198
|
+
* @param permissions - The list of permissions to validate.
|
|
199
|
+
* @returns The result of the validateUserPermission resource.
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
export function validateUserPermission(extension, permissions) {
|
|
203
|
+
validateExtension(extension);
|
|
204
|
+
const validateUserPermissionResource = getResource('validateUserPermission');
|
|
205
|
+
return validateUserPermissionResource(extension, permissions);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Triggers the login process in the host application for the given extension.
|
|
209
|
+
* @param extension - The extension object.
|
|
210
|
+
* @param config - Optional configuration for login.
|
|
211
|
+
* @returns The result of the triggerLogin resource.
|
|
212
|
+
* @public
|
|
213
|
+
*/
|
|
214
|
+
export function triggerLogin(extension, config) {
|
|
215
|
+
validateExtension(extension);
|
|
216
|
+
const triggerLoginResource = getResource('triggerLogin');
|
|
217
|
+
return triggerLoginResource(config);
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AAsKF,2CAA2C;AAE3C,IAAI,WAAW,GAA6B;IAC1C,WAAW,EAAE,KAAK;CACnB,CAAC;AAEF,MAAM,UAAU,GAA0D;IACxE,QAAQ,EAAE,mBAAmB;IAC7B,UAAU,EAAE,aAAa;IACzB,QAAQ,EAAE,WAAW;IACrB,cAAc,EAAE,iBAAiB;IACjC,mBAAmB,EAAE,sBAAsB;IAC3C,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,UAAU;IACnB,sBAAsB,EAAE,0BAA0B;IAClD,YAAY,EAAE,eAAe;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,MAAkB;IAC9C,MAAM,CAAC,IAAI,CAAC,UAAU,CAAoC,CAAC,OAAO,CAAC,CAAC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AE,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAoB;IAC3C,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7B,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,SAAoB,EAAE,OAAe,EAAE,IAAe;IAC1E,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAC3C,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,SAAoB;IAC1C,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,eAAe,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAoB,EACpB,WAAqB;IAErB,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,8BAA8B,GAAG,WAAW,CAAC,wBAAwB,CAAC,CAAC;IAC7E,OAAO,8BAA8B,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAChE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,SAAoB,EAAE,MAA2B;IAC5E,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,oBAAoB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;IACzD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloudscaile-eng/web-ext-utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Utilities for sharing host resources with micro-frontends in web applications",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "CloudScaile Engineering",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rimraf dist && tsc && api-extractor run --local || true",
|
|
24
|
+
"prepublishOnly": "npm run build",
|
|
25
|
+
"build:lint": "npm run format-check && npm run lint && npm run typecheck",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"lint": "eslint src",
|
|
28
|
+
"lint-fix": "eslint src --fix",
|
|
29
|
+
"format": "prettier --write .",
|
|
30
|
+
"format-check": "prettier --check .",
|
|
31
|
+
"prepare": "husky"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"cloudscaile",
|
|
35
|
+
"micro-frontend",
|
|
36
|
+
"redux",
|
|
37
|
+
"axios",
|
|
38
|
+
"extension"
|
|
39
|
+
],
|
|
40
|
+
"type": "module",
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@mui/material": "^7.0.0",
|
|
43
|
+
"@reduxjs/toolkit": "^2.0.0",
|
|
44
|
+
"axios": "^1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"@mui/material": {
|
|
48
|
+
"optional": false
|
|
49
|
+
},
|
|
50
|
+
"@reduxjs/toolkit": {
|
|
51
|
+
"optional": false
|
|
52
|
+
},
|
|
53
|
+
"axios": {
|
|
54
|
+
"optional": false
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@eslint/js": "^9.39.1",
|
|
59
|
+
"@microsoft/api-extractor": "^7.58.9",
|
|
60
|
+
"@mui/material": "^7.1.0",
|
|
61
|
+
"@reduxjs/toolkit": "^2.12.0",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
63
|
+
"@typescript-eslint/parser": "^8.48.1",
|
|
64
|
+
"axios": "^1.8.2",
|
|
65
|
+
"eslint": "^9.39.1",
|
|
66
|
+
"husky": "^9.1.7",
|
|
67
|
+
"lint-staged": "^16.2.7",
|
|
68
|
+
"prettier": "^3.7.4",
|
|
69
|
+
"rimraf": "^6.1.2",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"typescript-eslint": "^8.48.1"
|
|
72
|
+
},
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"*.{ts,tsx}": [
|
|
75
|
+
"npm run format",
|
|
76
|
+
"npm run lint"
|
|
77
|
+
],
|
|
78
|
+
"*.{json,md,css,yml,yaml}": [
|
|
79
|
+
"npm run format"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"publishConfig": {
|
|
83
|
+
"access": "public"
|
|
84
|
+
}
|
|
85
|
+
}
|