@equinor/fusion-framework-react-app 14.1.2 → 14.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.
@@ -7,6 +7,8 @@ import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framewo
7
7
  export type ComponentRenderArgs<TFusion extends Fusion = Fusion, TEnv = AppEnv> = {
8
8
  fusion: TFusion;
9
9
  env: TEnv;
10
+ /** Receives uncaught errors raised while the application renders or initializes its modules. */
11
+ onError?: (error: unknown) => void;
10
12
  };
11
13
  export type ComponentRenderer<TFusion extends Fusion = Fusion, TEnv = AppEnv> = (fusion: TFusion, env: TEnv) => React.LazyExoticComponent<React.ComponentType>;
12
14
  /**
@@ -15,6 +15,8 @@ export type ComponentRenderArgs<TFusion extends Fusion = Fusion, TEnv = AppEnv>
15
15
  fusion: TFusion;
16
16
  /** The application environment (manifest, config, basename, etc.). */
17
17
  env: TEnv;
18
+ /** Receives failures raised while application modules initialize. */
19
+ onError?: (error: unknown) => void;
18
20
  };
19
21
  /**
20
22
  * Factory function that receives a Fusion instance and environment and returns a
@@ -45,10 +47,7 @@ export type ComponentRenderer<TFusion extends Fusion = Fusion, TEnv = AppEnv> =
45
47
  * @returns {React.LazyExoticComponent<React.ComponentType>} A lazy component that, when rendered,
46
48
  * initializes the specified modules and provides the necessary Fusion and module context.
47
49
  */
48
- export declare const makeComponent: <TModules extends Array<AnyModule>, TRef extends Fusion = Fusion, TEnv extends AppEnv = AppEnv>(Component: React.ReactNode, args: {
49
- fusion: TRef;
50
- env: TEnv;
51
- }, configure?: AppModuleInitiator<TModules, TRef, TEnv>) => React.LazyExoticComponent<React.ComponentType>;
50
+ export declare const makeComponent: <TModules extends Array<AnyModule>, TRef extends Fusion = Fusion, TEnv extends AppEnv = AppEnv>(Component: React.ReactNode, args: ComponentRenderArgs<TRef, TEnv>, configure?: AppModuleInitiator<TModules, TRef, TEnv>) => React.LazyExoticComponent<React.ComponentType>;
52
51
  declare module '@equinor/fusion-framework-module-event' {
53
52
  interface FrameworkEventMap {
54
53
  onReactAppLoaded: FrameworkEvent<FrameworkEventInit<{
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Roles V2 React hooks for Fusion Framework applications.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export type { ActivateClaimableRoleAssignmentInput, RolesModule, } from '@equinor/fusion-framework-module-roles';
7
+ export { useAccessRole, type ClaimableRoleAssignmentActivationResult, type UseAccessRoleResult, } from './useAccessRole';
@@ -0,0 +1,63 @@
1
+ import type { ActivateClaimableRoleAssignmentInput, IRolesProvider } from '@equinor/fusion-framework-module-roles';
2
+ /** Result returned after a claimable role assignment activation succeeds. */
3
+ export type ClaimableRoleAssignmentActivationResult = Awaited<ReturnType<IRolesProvider['activateClaimableRoleAssignment']>>;
4
+ /**
5
+ * Reactive state and actions for one Roles V2 access role.
6
+ */
7
+ export interface UseAccessRoleResult {
8
+ /** Whether the access role is currently active, or `undefined` while the first check runs. */
9
+ hasAccessRole: boolean | undefined;
10
+ /** Whether a claimable role can grant the access role, or `undefined` while the first check runs. */
11
+ hasClaimableRoleAssignmentForAccessRole: boolean | undefined;
12
+ /** Whether active-access and claimable-assignment checks are running. */
13
+ isChecking: boolean;
14
+ /** Error from the latest access-role check. */
15
+ checkError: unknown;
16
+ /** Re-runs the active-access and claimable-assignment checks. */
17
+ checkAccessRole: () => Promise<void>;
18
+ /** Activates a claimable role assignment and refreshes access state after success. */
19
+ activateClaimableRoleAssignment: (input: ActivateClaimableRoleAssignmentInput) => Promise<ClaimableRoleAssignmentActivationResult>;
20
+ /** Whether a claimable-role-assignment activation is running. */
21
+ isActivating: boolean;
22
+ /** Error from the latest role activation request. */
23
+ activationError: unknown;
24
+ }
25
+ /**
26
+ * Checks one Roles V2 access role and activates a claimable role assignment when available.
27
+ *
28
+ * The hook checks both active access-role assignments and claimable access-role mappings when
29
+ * mounted. A successful activation triggers a new check so rendered access state follows it.
30
+ *
31
+ * @param accessRoleName - Exact, case-sensitive Roles V2 access-role name to check.
32
+ * @returns Access-role state and an activation action backed by the app-scoped Roles provider.
33
+ * @throws The function returned as `activateClaimableRoleAssignment` rethrows cancellation and
34
+ * Roles V2 failures.
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * const role = useAccessRole('Reports.Read');
39
+ *
40
+ * if (role.isChecking) return <Spinner />;
41
+ * if (role.checkError) return <ErrorMessage error={role.checkError} />;
42
+ * if (role.hasAccessRole) return <Reports />;
43
+ *
44
+ * // Consume the event-handler rejection; activationError below owns the visible failure.
45
+ * const handleActivate = (): void => {
46
+ * void role.activateClaimableRoleAssignment({
47
+ * assignmentId: claimableRoleId,
48
+ * reason: 'Open reports',
49
+ * hours: 2,
50
+ * }).catch(() => undefined);
51
+ * };
52
+ *
53
+ * return role.hasClaimableRoleAssignmentForAccessRole ? (
54
+ * <>
55
+ * {role.activationError ? <p role="alert">{String(role.activationError)}</p> : null}
56
+ * <button disabled={role.isActivating} onClick={handleActivate}>
57
+ * Claim access
58
+ * </button>
59
+ * </>
60
+ * ) : null;
61
+ * ```
62
+ */
63
+ export declare const useAccessRole: (accessRoleName: string) => UseAccessRoleResult;
@@ -1 +1 @@
1
- export declare const version = "14.1.2";
1
+ export declare const version = "14.2.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-react-app",
3
- "version": "14.1.2",
3
+ "version": "14.2.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -70,6 +70,10 @@
70
70
  "types": "./dist/types/routing/index.d.ts",
71
71
  "import": "./dist/esm/routing/index.js"
72
72
  },
73
+ "./roles": {
74
+ "types": "./dist/types/roles/index.d.ts",
75
+ "import": "./dist/esm/roles/index.js"
76
+ },
73
77
  "./ag-grid": {
74
78
  "types": "./dist/types/ag-grid/react.d.ts",
75
79
  "import": "./dist/esm/ag-grid/react.js"
@@ -138,6 +142,9 @@
138
142
  "routing": [
139
143
  "dist/types/routing/index.d.ts"
140
144
  ],
145
+ "roles": [
146
+ "dist/types/roles/index.d.ts"
147
+ ],
141
148
  "ag-grid": [
142
149
  "dist/types/ag-grid/react.d.ts"
143
150
  ],
@@ -170,15 +177,15 @@
170
177
  "directory": "packages/react"
171
178
  },
172
179
  "dependencies": {
173
- "@equinor/fusion-framework": "8.1.2",
180
+ "@equinor/fusion-framework": "8.1.3",
181
+ "@equinor/fusion-framework-app": "13.1.4",
174
182
  "@equinor/fusion-framework-module": "6.1.4",
175
- "@equinor/fusion-framework-module-app": "8.1.1",
176
- "@equinor/fusion-framework-app": "13.1.2",
177
- "@equinor/fusion-framework-module-navigation": "7.0.10",
178
183
  "@equinor/fusion-framework-module-http": "8.1.1",
184
+ "@equinor/fusion-framework-module-app": "8.2.0",
179
185
  "@equinor/fusion-framework-react": "9.0.1",
180
- "@equinor/fusion-framework-react-module-http": "12.0.1",
181
- "@equinor/fusion-framework-react-module": "4.0.4"
186
+ "@equinor/fusion-framework-react-module": "4.0.4",
187
+ "@equinor/fusion-framework-module-navigation": "7.0.10",
188
+ "@equinor/fusion-framework-react-module-http": "12.0.1"
182
189
  },
183
190
  "devDependencies": {
184
191
  "@remix-run/router": "^1.23.3",
@@ -192,21 +199,22 @@
192
199
  "typescript": "^7.0.2",
193
200
  "vitest": "^4.1.10",
194
201
  "vitest-browser-react": "^2.2.0",
195
- "@equinor/fusion-framework-react-ag-grid": "37.1.1",
196
202
  "@equinor/fusion-framework-module-ag-grid": "37.1.1",
197
- "@equinor/fusion-framework-module-analytics": "3.1.1",
198
- "@equinor/fusion-framework-module-bookmark": "4.1.1",
203
+ "@equinor/fusion-framework-react-ag-grid": "37.1.1",
204
+ "@equinor/fusion-framework-module-analytics": "3.1.3",
199
205
  "@equinor/fusion-framework-module-context": "9.0.1",
200
206
  "@equinor/fusion-framework-module-event": "6.1.1",
207
+ "@equinor/fusion-framework-module-bookmark": "4.1.2",
201
208
  "@equinor/fusion-framework-module-feature-flag": "2.1.1",
202
- "@equinor/fusion-framework-module-msal": "11.0.2",
209
+ "@equinor/fusion-framework-module-msal": "11.0.3",
203
210
  "@equinor/fusion-framework-module-state": "^2.0.4",
204
211
  "@equinor/fusion-framework-module-telemetry": "7.1.1",
205
212
  "@equinor/fusion-framework-react-module-bookmark": "7.0.1",
213
+ "@equinor/fusion-framework-module-roles": "^0.2.0",
206
214
  "@equinor/fusion-framework-react-module-context": "7.0.4",
207
- "@equinor/fusion-framework-react-router": "2.4.2",
208
- "@equinor/fusion-framework-vitest-plugin-react-app": "1.0.2",
209
- "@equinor/fusion-observable": "9.2.2"
215
+ "@equinor/fusion-framework-vitest-plugin-react-app": "1.0.5",
216
+ "@equinor/fusion-observable": "9.2.2",
217
+ "@equinor/fusion-framework-react-router": "2.4.4"
210
218
  },
211
219
  "peerDependencies": {
212
220
  "@types/react": "^18.0.0 || ^19.0.0",
@@ -215,9 +223,10 @@
215
223
  "rxjs": "^7.0.0",
216
224
  "@equinor/fusion-framework-module-ag-grid": "^37.1.1",
217
225
  "@equinor/fusion-framework-react-ag-grid": "^37.1.1",
218
- "@equinor/fusion-framework-module-msal": "^11.0.2",
226
+ "@equinor/fusion-framework-module-msal": "^11.0.3",
227
+ "@equinor/fusion-framework-module-roles": "^0.2.0",
219
228
  "@equinor/fusion-framework-module-state": "^2.0.4",
220
- "@equinor/fusion-framework-react-router": "^2.4.2"
229
+ "@equinor/fusion-framework-react-router": "^2.4.4"
221
230
  },
222
231
  "peerDependenciesMeta": {
223
232
  "@equinor/fusion-framework-module-ag-grid": {
@@ -235,6 +244,9 @@
235
244
  "@equinor/fusion-framework-module-navigation": {
236
245
  "optional": true
237
246
  },
247
+ "@equinor/fusion-framework-module-roles": {
248
+ "optional": true
249
+ },
238
250
  "@equinor/fusion-framework-react-module-bookmark": {
239
251
  "optional": true
240
252
  },