@equinor/roma-framework 1.0.0 → 1.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/dev-portal/package.json +1 -1
- package/index.d.ts +13 -0
- package/lib/api/fetcher.d.ts +21 -0
- package/lib/api/ms-graph/api/group/find-group-members.d.ts +2 -0
- package/lib/api/ms-graph/api/user/find-user-by-shortname.d.ts +1 -0
- package/lib/api/ms-graph/api/user/find-users-by-mail.d.ts +2 -0
- package/lib/api/ms-graph/index.d.ts +11 -0
- package/lib/api/ms-graph/model/error.d.ts +11 -0
- package/lib/api/ms-graph/model/group-membership.d.ts +8 -0
- package/lib/api/ms-graph/model/user.d.ts +18 -0
- package/lib/api/roma/api/app-controller/app-controller.d.ts +121 -0
- package/lib/api/roma/api/category-controller/category-controller.d.ts +93 -0
- package/lib/api/roma/api/environment-controller/environment-controller.d.ts +26 -0
- package/lib/api/roma/api/feedback-controller/feedback-controller.d.ts +30 -0
- package/lib/api/roma/api/roma-configuration-controller/roma-configuration-controller.d.ts +161 -0
- package/lib/api/roma/api/server-side-event-controller/server-side-event-controller.d.ts +20 -0
- package/lib/api/roma/api/service-controller/service-controller.d.ts +93 -0
- package/lib/api/roma/api/setting-controller/setting-controller.d.ts +260 -0
- package/lib/api/roma/index.d.ts +9 -0
- package/lib/api/roma/model/appDto.d.ts +19 -0
- package/lib/api/roma/model/categoryDto.d.ts +13 -0
- package/lib/api/roma/model/environmentDto.d.ts +10 -0
- package/lib/api/roma/model/feedbackDetailsDto.d.ts +13 -0
- package/lib/api/roma/model/feedbackDto.d.ts +6 -0
- package/lib/api/roma/model/feedbackFeedbackDto.d.ts +13 -0
- package/lib/api/roma/model/feedbackResponseDto.d.ts +4 -0
- package/lib/api/roma/model/feedbackResponseIssueDto.d.ts +11 -0
- package/lib/api/roma/model/feedbackSolutionDto.d.ts +10 -0
- package/lib/api/roma/model/getAllApps200.d.ts +10 -0
- package/lib/api/roma/model/getAllCategories200.d.ts +10 -0
- package/lib/api/roma/model/getAllRomaConfigurationTypes200Item.d.ts +11 -0
- package/lib/api/roma/model/getAllServices200.d.ts +10 -0
- package/lib/api/roma/model/getSettingsByAppShortName200.d.ts +10 -0
- package/lib/api/roma/model/getSettingsByUserId200.d.ts +10 -0
- package/lib/api/roma/model/index.d.ts +31 -0
- package/lib/api/roma/model/romaConfigurationDto.d.ts +7 -0
- package/lib/api/roma/model/romaConfigurationDtoValue.d.ts +10 -0
- package/lib/api/roma/model/serverSentEventActivityLogDto.d.ts +8 -0
- package/lib/api/roma/model/serverSentEventStandardEventDto.d.ts +10 -0
- package/lib/api/roma/model/serviceDto.d.ts +16 -0
- package/lib/api/roma/model/settingDto.d.ts +9 -0
- package/lib/api/roma/model/settingDtoValue.d.ts +10 -0
- package/lib/api/roma/model/uploadBundleBody.d.ts +10 -0
- package/lib/api/roma/model/versionDto.d.ts +12 -0
- package/lib/api/roma/use-client.d.ts +34 -0
- package/lib/api/util.d.ts +1 -0
- package/lib/app-provider.d.ts +32 -0
- package/lib/dev-portal/AppLoader.d.ts +14 -0
- package/lib/dev-portal/AppViewer.d.ts +6 -0
- package/lib/dev-portal/EquinorLoader.d.ts +12 -0
- package/lib/dev-portal/ErrorViewer.d.ts +20 -0
- package/lib/dev-portal/Header.d.ts +2 -0
- package/lib/dev-portal/HttpErrorViewer.d.ts +13 -0
- package/lib/dev-portal/Navigation.d.ts +5 -0
- package/lib/dev-portal/Root.d.ts +5 -0
- package/lib/dev-portal/config.d.ts +3 -0
- package/lib/dev-portal/index.d.ts +13 -0
- package/lib/eds-event-provider.d.ts +6 -0
- package/lib/hooks/use-get-api-roles.d.ts +14 -0
- package/lib/hooks/use-has-api-role.d.ts +7 -0
- package/lib/make-component.d.ts +12 -0
- package/lib/query/persister.d.ts +6 -0
- package/lib/style-provider.d.ts +7 -0
- package/package.json +1 -1
- package/roma-framework.mjs +15 -11
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
type CustomClient<T> = (data: {
|
|
2
|
+
url: string;
|
|
3
|
+
method: 'get' | 'post' | 'put' | 'delete' | 'patch';
|
|
4
|
+
params?: Record<string, any>;
|
|
5
|
+
headers?: Record<string, any>;
|
|
6
|
+
data?: any;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}) => Promise<T>;
|
|
9
|
+
export declare const useCustomClient: <T>() => CustomClient<T>;
|
|
10
|
+
export default useCustomClient;
|
|
11
|
+
export type HttpErrorServerResponse = {
|
|
12
|
+
timestamp: string;
|
|
13
|
+
status: number;
|
|
14
|
+
error: string;
|
|
15
|
+
message: string;
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
export type HttpErrorResponse = {
|
|
19
|
+
status: number;
|
|
20
|
+
statusText: string;
|
|
21
|
+
message: unknown;
|
|
22
|
+
ok: boolean;
|
|
23
|
+
headers: Headers;
|
|
24
|
+
url: string;
|
|
25
|
+
};
|
|
26
|
+
export declare class HttpError extends Error {
|
|
27
|
+
readonly message: string;
|
|
28
|
+
readonly response: HttpErrorResponse;
|
|
29
|
+
constructor(message: string, response: HttpErrorResponse);
|
|
30
|
+
}
|
|
31
|
+
export type ErrorType<T> = HttpError;
|
|
32
|
+
export type BodyType<BodyData> = BodyData & {
|
|
33
|
+
headers?: any;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createUrlParamsFromObject: (obj: Record<string, unknown>) => URLSearchParams;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
3
|
+
import { QueryClientError } from '@equinor/fusion-query/client';
|
|
4
|
+
type AppLoadError = QueryClientError & {
|
|
5
|
+
cause: {
|
|
6
|
+
data: unknown;
|
|
7
|
+
name: string;
|
|
8
|
+
response: Response;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare const AppContext: import('react').Context<{
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
apps?: Array<AppManifest>;
|
|
14
|
+
error?: AppLoadError;
|
|
15
|
+
}>;
|
|
16
|
+
type ErrorPageProps = {
|
|
17
|
+
errorCode: number;
|
|
18
|
+
explanation: string;
|
|
19
|
+
solution: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function AppLoadError({ errorCode, explanation, solution, }: ErrorPageProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const AppProvider: ({ children }: {
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const useApps: ({ includeHidden, }?: {
|
|
26
|
+
includeHidden?: boolean;
|
|
27
|
+
}) => {
|
|
28
|
+
isLoading: boolean;
|
|
29
|
+
apps: AppManifest[];
|
|
30
|
+
error: AppLoadError | undefined;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
2
|
+
/**
|
|
3
|
+
* Component that will render a Fusion application
|
|
4
|
+
*
|
|
5
|
+
* @param app the AppManifest for the application to render
|
|
6
|
+
* @param kind whether the app is a widget or an application
|
|
7
|
+
* @param props any props to pass to the loaded application
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
export declare function AppLoader({ app, kind, props, }: {
|
|
11
|
+
app: AppManifest | null;
|
|
12
|
+
kind?: 'app' | 'widget';
|
|
13
|
+
props?: Record<string | number, any>;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Simple in-place loader for fusion apps
|
|
4
|
+
*
|
|
5
|
+
* @param children
|
|
6
|
+
* @param text
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
9
|
+
export declare const EquinorLoader: ({ children, text, }: React.PropsWithChildren<{
|
|
10
|
+
readonly text: string;
|
|
11
|
+
}>) => JSX.Element;
|
|
12
|
+
export default EquinorLoader;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactElement, CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Simple error display component.
|
|
4
|
+
* Does not create a pretty error, and should most likely be recreated for various error types (e.g. lack of access etc.)
|
|
5
|
+
* Reasonable to assume this will be a part of e.g. @equinor/roma-components in the future.
|
|
6
|
+
*
|
|
7
|
+
* @param error
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
export declare const ErrorViewer: ({ error }: {
|
|
11
|
+
readonly error: Error;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
type ErrorProps = {
|
|
14
|
+
title?: string;
|
|
15
|
+
message: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
actions?: ReactElement;
|
|
18
|
+
};
|
|
19
|
+
export declare const RomaErrorViewer: ({ style, title, message, actions, }: ErrorProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default ErrorViewer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpError } from '../api/fetcher';
|
|
2
|
+
/**
|
|
3
|
+
* Simple error display component.
|
|
4
|
+
* Does not create a pretty error, and should most likely be recreated for various error types (e.g. lack of access etc.)
|
|
5
|
+
* Reasonable to assume this will be a part of e.g. @equinor/roma-components in the future.
|
|
6
|
+
*
|
|
7
|
+
* @param error
|
|
8
|
+
* @constructor
|
|
9
|
+
*/
|
|
10
|
+
export declare const HttpErrorViewer: ({ error }: {
|
|
11
|
+
readonly error: HttpError;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default HttpErrorViewer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dev portal rotues
|
|
3
|
+
*/
|
|
4
|
+
export declare const routes: {
|
|
5
|
+
path: string;
|
|
6
|
+
element: import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
children: {
|
|
8
|
+
path: string;
|
|
9
|
+
element: import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
}[];
|
|
11
|
+
}[];
|
|
12
|
+
export declare function App(): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default App;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IEventModuleProvider } from '@equinor/fusion-framework-module-event';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export declare const EdsEventProvider: ({ event, children }: {
|
|
4
|
+
event: IEventModuleProvider;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a JWT token and returns an object with the roles contained in the token.
|
|
3
|
+
* @param token The JWT token to parse.
|
|
4
|
+
* @returns An object with the roles contained in the token.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseJwt(token: string): {
|
|
7
|
+
roles: Array<string>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the roles associated with a specified API from fusion's service discovery module.
|
|
11
|
+
* @param api The name of the API to retrieve roles for.
|
|
12
|
+
* @returns An array of roles associated with the specified API.
|
|
13
|
+
*/
|
|
14
|
+
export declare const useGetApiRoles: (api: string) => string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the current user has a specified role associated with a specified API using the `useGetApiRoles` hook.
|
|
3
|
+
* @param api The name of the API to check for the specified role.
|
|
4
|
+
* @param role The name of the role to check for.
|
|
5
|
+
* @returns True if the current user has the specified role associated with the specified API, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export declare const useHasApiRole: (api: string, role: string) => boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AnyModule } from '@equinor/fusion-framework-module';
|
|
2
|
+
import { Fusion } from '@equinor/fusion-framework-react';
|
|
3
|
+
import { AppEnv, AppModuleInitiator } from '@equinor/fusion-framework-app';
|
|
4
|
+
import { default as React, ReactNode } from 'react';
|
|
5
|
+
import { ComponentRenderArgs as FusionComponentRenderArgs } from '@equinor/fusion-framework-react-app';
|
|
6
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
7
|
+
export type RomaComponentRenderArgs = FusionComponentRenderArgs & {
|
|
8
|
+
query?: QueryClient;
|
|
9
|
+
};
|
|
10
|
+
export type RomaAppModuleInitiator<TModules extends Array<AnyModule> | unknown = unknown, TRef extends Fusion = Fusion, TEnv = AppEnv> = AppModuleInitiator<TModules, TRef, TEnv>;
|
|
11
|
+
export declare const makeComponent: <TModules extends Array<AnyModule>, TRef extends Fusion = Fusion<unknown>, TEnv extends AppEnv = AppEnv>(Component: React.ReactNode, args: RomaComponentRenderArgs, configure?: RomaAppModuleInitiator<TModules, TRef, TEnv>) => React.LazyExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
|
|
12
|
+
export declare const withStyleIsolation: (children: ReactNode, args: RomaComponentRenderArgs) => React.LazyExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
|
package/package.json
CHANGED
package/roma-framework.mjs
CHANGED
|
@@ -6372,19 +6372,23 @@ function parseJwt(token) {
|
|
|
6372
6372
|
}
|
|
6373
6373
|
}
|
|
6374
6374
|
const useGetApiRoles = (api) => {
|
|
6375
|
-
const {
|
|
6375
|
+
const {
|
|
6376
|
+
modules: { auth, serviceDiscovery }
|
|
6377
|
+
} = useFramework();
|
|
6376
6378
|
const [roles, setRoles] = useState([]);
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6379
|
+
useEffect(() => {
|
|
6380
|
+
serviceDiscovery.resolveService(api).then(async (s) => {
|
|
6381
|
+
const jwt = await auth.acquireAccessToken({
|
|
6382
|
+
scopes: s.defaultScopes
|
|
6383
|
+
});
|
|
6384
|
+
if (!jwt) {
|
|
6385
|
+
throw new Error(`No jwt found for ${api}`);
|
|
6386
|
+
}
|
|
6387
|
+
const token = parseJwt(jwt);
|
|
6388
|
+
if (roles.length === 0)
|
|
6389
|
+
setRoles((token == null ? void 0 : token.roles) ?? []);
|
|
6380
6390
|
});
|
|
6381
|
-
|
|
6382
|
-
throw new Error(`No jwt found for ${api}`);
|
|
6383
|
-
}
|
|
6384
|
-
const token = parseJwt(jwt);
|
|
6385
|
-
if (roles.length === 0)
|
|
6386
|
-
setRoles((token == null ? void 0 : token.roles) ?? []);
|
|
6387
|
-
});
|
|
6391
|
+
}, [api, auth, serviceDiscovery, roles.length]);
|
|
6388
6392
|
return roles;
|
|
6389
6393
|
};
|
|
6390
6394
|
const useHasApiRole = (api, role) => {
|