@equinor/roma-framework 3.0.1 → 4.0.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/cypress.mjs +3 -112
- package/dev-portal/lib/api/ms-graph/api/group/find-group.d.ts +2 -0
- package/dev-portal/lib/api/ms-graph/api/group/get-groups-by-ids.d.ts +2 -0
- package/dev-portal/lib/api/ms-graph/api/user/get-user-by-id.d.ts +9 -0
- package/dev-portal/lib/api/ms-graph/api/user/search.d.ts +4 -0
- package/dev-portal/lib/api/ms-graph/index.d.ts +4 -0
- package/dev-portal/lib/api/roma/api/app-controller/app-controller.d.ts +10 -10
- package/dev-portal/lib/api/roma/api/category-controller/category-controller.d.ts +8 -8
- package/dev-portal/lib/api/roma/api/environment-controller/environment-controller.d.ts +2 -2
- package/dev-portal/lib/api/roma/api/feedback-controller/feedback-controller.d.ts +4 -4
- package/dev-portal/lib/api/roma/api/roma-configuration-controller/roma-configuration-controller.d.ts +14 -14
- package/dev-portal/lib/api/roma/api/server-side-event-controller/server-side-event-controller.d.ts +2 -2
- package/dev-portal/lib/api/roma/api/service-controller/service-controller.d.ts +8 -8
- package/dev-portal/lib/api/roma/api/setting-controller/setting-controller.d.ts +20 -20
- package/dev-portal/lib/app-provider.d.ts +7 -1
- package/dev-portal/lib/dev-portal/ErrorViewer.d.ts +2 -2
- package/dev-portal/lib/dev-portal/PortalStyles.d.ts +276 -0
- package/dev-portal/lib/dev-portal/config/AppClient.d.ts +62 -2
- package/dev-portal/lib/make-component.d.ts +1 -1
- package/dev-portal/lib/test-utils/roma-cypress-wrapper.d.ts +2 -2
- package/dev-portal/package.json +1 -1
- package/dev-portal/roma-framework.umd.js +4066 -3749
- package/lib/api/ms-graph/api/group/find-group.d.ts +2 -0
- package/lib/api/ms-graph/api/group/get-groups-by-ids.d.ts +2 -0
- package/lib/api/ms-graph/api/user/get-user-by-id.d.ts +9 -0
- package/lib/api/ms-graph/api/user/search.d.ts +4 -0
- package/lib/api/ms-graph/index.d.ts +4 -0
- package/lib/api/roma/api/app-controller/app-controller.d.ts +10 -10
- package/lib/api/roma/api/category-controller/category-controller.d.ts +8 -8
- package/lib/api/roma/api/environment-controller/environment-controller.d.ts +2 -2
- package/lib/api/roma/api/feedback-controller/feedback-controller.d.ts +4 -4
- package/lib/api/roma/api/roma-configuration-controller/roma-configuration-controller.d.ts +14 -14
- package/lib/api/roma/api/server-side-event-controller/server-side-event-controller.d.ts +2 -2
- package/lib/api/roma/api/service-controller/service-controller.d.ts +8 -8
- package/lib/api/roma/api/setting-controller/setting-controller.d.ts +20 -20
- package/lib/app-provider.d.ts +7 -1
- package/lib/dev-portal/ErrorViewer.d.ts +2 -2
- package/lib/dev-portal/PortalStyles.d.ts +276 -0
- package/lib/dev-portal/config/AppClient.d.ts +62 -2
- package/lib/make-component.d.ts +1 -1
- package/lib/test-utils/roma-cypress-wrapper.d.ts +2 -2
- package/package.json +1 -1
- package/roma-framework.mjs +308 -17
- package/{router-DDzmmkip.mjs → router-JkkLp8wN.mjs} +3 -3
package/roma-framework.mjs
CHANGED
|
@@ -13,18 +13,18 @@ import * as React from "react";
|
|
|
13
13
|
import { useState, useEffect, lazy, useRef, createContext, useContext, useMemo } from "react";
|
|
14
14
|
import { ModuleProvider } from "@equinor/fusion-framework-react-module";
|
|
15
15
|
import styled, { StyleSheetManager, keyframes } from "styled-components";
|
|
16
|
-
import { EdsProvider, StarProgress, Typography, Card, Button, TopBar, SideSheet, Menu, Tooltip, Icon } from "@equinor/eds-core-react";
|
|
17
|
-
import { E as EmptyError, o as operate, c as createOperatorSubscriber, i as innerFrom, a as identity, b as isFunction, I as IntlProvider, d as invariant, j as joinPaths, g as getPathContributingMatches, r as resolveTo, w as warning, s as stripBasename, e as createPath, B as BehaviorSubject, f as firstValueFrom, h as getDefaultExportFromCjs, k as of, l as from } from "./router-
|
|
16
|
+
import { EdsProvider, StarProgress, Typography, Card, Button, TopBar, Chip, SideSheet, Menu, Tooltip, Icon, List } from "@equinor/eds-core-react";
|
|
17
|
+
import { E as EmptyError, o as operate, c as createOperatorSubscriber, i as innerFrom, a as identity, b as isFunction, I as IntlProvider, d as invariant, j as joinPaths, g as getPathContributingMatches, r as resolveTo, w as warning, s as stripBasename, e as createPath, B as BehaviorSubject, f as firstValueFrom, h as getDefaultExportFromCjs, k as of, l as from } from "./router-JkkLp8wN.mjs";
|
|
18
18
|
import { QueryClient, QueryClientProvider, useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
|
|
19
19
|
import { useCurrentApp, useApps as useApps$1 } from "@equinor/fusion-framework-react/app";
|
|
20
20
|
import { App } from "@equinor/fusion-framework-module-app/app";
|
|
21
|
+
import { tokens } from "@equinor/eds-tokens";
|
|
21
22
|
import { comment_more, accessible, account_circle, help_outline } from "@equinor/eds-icons";
|
|
22
23
|
import { enableAppModule } from "@equinor/fusion-framework-module-app";
|
|
23
24
|
import { enableContext } from "@equinor/fusion-framework-module-context";
|
|
24
25
|
import { enableNavigation } from "@equinor/fusion-framework-module-navigation";
|
|
25
26
|
import { ModuleConfigBuilder } from "@equinor/fusion-framework-module";
|
|
26
27
|
import { enableServiceDiscovery } from "@equinor/fusion-framework-module-service-discovery";
|
|
27
|
-
import { tokens } from "@equinor/eds-tokens";
|
|
28
28
|
import { useHttpClient } from "@equinor/fusion-framework-react-module-http";
|
|
29
29
|
const createExtraScopePlugin = (scope) => {
|
|
30
30
|
const plugin = (element, index, childEls) => {
|
|
@@ -1138,6 +1138,12 @@ const Styled = {
|
|
|
1138
1138
|
margin-left: 1.5rem;
|
|
1139
1139
|
`
|
|
1140
1140
|
};
|
|
1141
|
+
const EnvChip = styled(Chip)`
|
|
1142
|
+
background-color: ${tokens.colors.interactive.primary__resting.rgba};
|
|
1143
|
+
color: ${tokens.colors.text.static_icons__primary_white.hex};
|
|
1144
|
+
margin-left: 16px;
|
|
1145
|
+
padding: 0 32px;
|
|
1146
|
+
`;
|
|
1141
1147
|
const StyledSideSheet = styled(SideSheet)`
|
|
1142
1148
|
position: fixed;
|
|
1143
1149
|
right: 0;
|
|
@@ -1310,7 +1316,18 @@ const HeaderMenu = ({ menuState }) => {
|
|
|
1310
1316
|
) })
|
|
1311
1317
|
] });
|
|
1312
1318
|
};
|
|
1319
|
+
const getEnvironment = async () => {
|
|
1320
|
+
const request = await fetch("/_discovery/environments/current");
|
|
1321
|
+
const environment = await request.json();
|
|
1322
|
+
const isProd = environment.type === "Production";
|
|
1323
|
+
return {
|
|
1324
|
+
name: environment.type,
|
|
1325
|
+
environmentName: environment.environmentName,
|
|
1326
|
+
isProd
|
|
1327
|
+
};
|
|
1328
|
+
};
|
|
1313
1329
|
const Header = () => {
|
|
1330
|
+
var _a;
|
|
1314
1331
|
const [a11yOpen, setA11yOpen] = useState(false);
|
|
1315
1332
|
const [userMenuOpen, setUserMenuOpen] = useState(false);
|
|
1316
1333
|
const [activityLogOpen, setActivityLogOpen] = useState(false);
|
|
@@ -1323,15 +1340,31 @@ const Header = () => {
|
|
|
1323
1340
|
activityLogOpen,
|
|
1324
1341
|
setActivityLogOpen
|
|
1325
1342
|
};
|
|
1343
|
+
const [env, setEnv] = useState(null);
|
|
1344
|
+
useEffect(() => {
|
|
1345
|
+
getEnvironment().then((info) => {
|
|
1346
|
+
setEnv(info);
|
|
1347
|
+
});
|
|
1348
|
+
}, []);
|
|
1326
1349
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1327
|
-
/* @__PURE__ */ jsxs(
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1350
|
+
/* @__PURE__ */ jsxs(
|
|
1351
|
+
TopBarFadeIn,
|
|
1352
|
+
{
|
|
1353
|
+
id: "cli-top-bar",
|
|
1354
|
+
style: !(env == null ? void 0 : env.isProd) ? {
|
|
1355
|
+
backgroundColor: tokens.colors.interactive.warning__highlight.rgba
|
|
1356
|
+
} : void 0,
|
|
1357
|
+
children: [
|
|
1358
|
+
/* @__PURE__ */ jsx(TopBar.Header, { children: /* @__PURE__ */ jsxs(Styled.Title, { children: [
|
|
1359
|
+
/* @__PURE__ */ jsx(Icon, { color: "#eb0037", data: logoIcon, viewBox: "0 0 42 48" }),
|
|
1360
|
+
/* @__PURE__ */ jsx("span", { children: "Roma" }),
|
|
1361
|
+
env && !(env == null ? void 0 : env.isProd) && /* @__PURE__ */ jsx(EnvChip, { children: (_a = env == null ? void 0 : env.environmentName) == null ? void 0 : _a.split(" ")[0].toUpperCase() })
|
|
1362
|
+
] }) }),
|
|
1363
|
+
/* @__PURE__ */ jsx(TopBar.CustomContent, {}),
|
|
1364
|
+
/* @__PURE__ */ jsx(TopBar.Actions, { children: /* @__PURE__ */ jsx(HeaderMenu, { menuState: headerMenuState }) })
|
|
1365
|
+
]
|
|
1366
|
+
}
|
|
1367
|
+
),
|
|
1335
1368
|
/* @__PURE__ */ jsx(SideSheets, { apps: allApps, menuState: headerMenuState })
|
|
1336
1369
|
] });
|
|
1337
1370
|
};
|
|
@@ -3890,9 +3923,10 @@ const rootSchema = create$3({
|
|
|
3890
3923
|
})
|
|
3891
3924
|
});
|
|
3892
3925
|
class CustomAppClient {
|
|
3893
|
-
constructor(client) {
|
|
3926
|
+
constructor(client, graphClient) {
|
|
3894
3927
|
__privateAdd(this, _manifests, []);
|
|
3895
3928
|
this.client = client;
|
|
3929
|
+
this.graphClient = graphClient;
|
|
3896
3930
|
}
|
|
3897
3931
|
// eslint-disable-next-line no-empty-pattern
|
|
3898
3932
|
getAppConfig({}) {
|
|
@@ -3911,7 +3945,75 @@ class CustomAppClient {
|
|
|
3911
3945
|
getAppManifests() {
|
|
3912
3946
|
return this.client.fetch$(`/api/apps`).pipe(
|
|
3913
3947
|
switchMap(
|
|
3914
|
-
(r) => from(r.json())
|
|
3948
|
+
(r) => from(r.json()).pipe(
|
|
3949
|
+
catchError(() => {
|
|
3950
|
+
let message = "Error fetching app manifests: ";
|
|
3951
|
+
if (r.status === 403 || r.status === 401) {
|
|
3952
|
+
message = /* @__PURE__ */ jsxs("div", { children: [
|
|
3953
|
+
/* @__PURE__ */ jsx(Typography, { children: "You are not authorized to view this page." }),
|
|
3954
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
3955
|
+
" ",
|
|
3956
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body_short", children: "Please apply for the relevant roles in Access IT:" }),
|
|
3957
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
3958
|
+
/* @__PURE__ */ jsxs(List, { children: [
|
|
3959
|
+
/* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsx(
|
|
3960
|
+
Tooltip,
|
|
3961
|
+
{
|
|
3962
|
+
title: "Will also grant access to Roma Workbench",
|
|
3963
|
+
children: /* @__PURE__ */ jsx(
|
|
3964
|
+
Typography,
|
|
3965
|
+
{
|
|
3966
|
+
variant: "body_short_link",
|
|
3967
|
+
as: "a",
|
|
3968
|
+
href: "https://accessit.equinor.com/Search/Search?term=COMMERCIAL+OPERATOR+LIQUIDS+ACCESS+CONTROL",
|
|
3969
|
+
children: "Cargo Operations - Commercial Operator"
|
|
3970
|
+
}
|
|
3971
|
+
)
|
|
3972
|
+
}
|
|
3973
|
+
) }),
|
|
3974
|
+
/* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsx(
|
|
3975
|
+
Tooltip,
|
|
3976
|
+
{
|
|
3977
|
+
title: "Apply for the access & sales office relevant for your role",
|
|
3978
|
+
children: /* @__PURE__ */ jsx(
|
|
3979
|
+
Typography,
|
|
3980
|
+
{
|
|
3981
|
+
variant: "body_short_link",
|
|
3982
|
+
as: "a",
|
|
3983
|
+
href: "https://accessit.equinor.com/Search/Search?term=LIQUIDS+ACCESS+CONTROL",
|
|
3984
|
+
children: "Trading systems"
|
|
3985
|
+
}
|
|
3986
|
+
)
|
|
3987
|
+
}
|
|
3988
|
+
) }),
|
|
3989
|
+
/* @__PURE__ */ jsx(List.Item, { children: /* @__PURE__ */ jsx(
|
|
3990
|
+
Tooltip,
|
|
3991
|
+
{
|
|
3992
|
+
title: "Autogranted via cargo / trading roles",
|
|
3993
|
+
children: /* @__PURE__ */ jsx(
|
|
3994
|
+
Typography,
|
|
3995
|
+
{
|
|
3996
|
+
variant: "body_short_link",
|
|
3997
|
+
as: "a",
|
|
3998
|
+
href: "https://accessit.equinor.com/Search/Search?term=User+%28TOPS+ROMA%29",
|
|
3999
|
+
children: "Roma Workbench - TOPS ROMA User"
|
|
4000
|
+
}
|
|
4001
|
+
)
|
|
4002
|
+
}
|
|
4003
|
+
) })
|
|
4004
|
+
] })
|
|
4005
|
+
] });
|
|
4006
|
+
} else {
|
|
4007
|
+
message = `${message} ${r.statusText}`;
|
|
4008
|
+
}
|
|
4009
|
+
window.Fusion.modules.event.dispatchEvent("workbenchInitError", {
|
|
4010
|
+
detail: {
|
|
4011
|
+
message
|
|
4012
|
+
}
|
|
4013
|
+
});
|
|
4014
|
+
return of([]);
|
|
4015
|
+
})
|
|
4016
|
+
)
|
|
3915
4017
|
),
|
|
3916
4018
|
map(
|
|
3917
4019
|
(v) => v.map((vv) => {
|
|
@@ -3925,6 +4027,7 @@ class CustomAppClient {
|
|
|
3925
4027
|
return {
|
|
3926
4028
|
...vv,
|
|
3927
4029
|
entry: pathname,
|
|
4030
|
+
config: vv.config ?? { groups: null, admins: null, roles: null },
|
|
3928
4031
|
keywords: vv.keywords ?? vv.tags,
|
|
3929
4032
|
appKey: vv.appKey ?? vv.key,
|
|
3930
4033
|
name: vv.displayName ?? vv.name,
|
|
@@ -3940,6 +4043,20 @@ class CustomAppClient {
|
|
|
3940
4043
|
};
|
|
3941
4044
|
})
|
|
3942
4045
|
),
|
|
4046
|
+
switchMap((apps) => {
|
|
4047
|
+
return this.graphClient.fetch(`v1.0/me/memberOf?$select=id`).then((r) => r.json()).then((res) => {
|
|
4048
|
+
const list = res.value.map(
|
|
4049
|
+
(v) => v.id
|
|
4050
|
+
);
|
|
4051
|
+
return apps.map((app) => {
|
|
4052
|
+
var _a, _b;
|
|
4053
|
+
return {
|
|
4054
|
+
...app,
|
|
4055
|
+
hasAccess: (((_a = app.config) == null ? void 0 : _a.groups) ?? []).length === 0 || ((_b = app.config) == null ? void 0 : _b.groups.some((g) => list.includes(g)))
|
|
4056
|
+
};
|
|
4057
|
+
});
|
|
4058
|
+
});
|
|
4059
|
+
}),
|
|
3943
4060
|
tap((v) => __privateSet(this, _manifests, v)),
|
|
3944
4061
|
catchError((err) => {
|
|
3945
4062
|
console.error("Error fetching app manifests", err);
|
|
@@ -3955,6 +4072,8 @@ class CustomAppClient {
|
|
|
3955
4072
|
console.log("updateAppSettings");
|
|
3956
4073
|
return of({});
|
|
3957
4074
|
}
|
|
4075
|
+
[Symbol.dispose]() {
|
|
4076
|
+
}
|
|
3958
4077
|
}
|
|
3959
4078
|
_manifests = new WeakMap();
|
|
3960
4079
|
class ServiceDiscoveryClient {
|
|
@@ -3983,14 +4102,19 @@ class ServiceDiscoveryClient {
|
|
|
3983
4102
|
}
|
|
3984
4103
|
}
|
|
3985
4104
|
const configure = async (config) => {
|
|
3986
|
-
var _a;
|
|
4105
|
+
var _a, _b;
|
|
3987
4106
|
const request = await fetch("/_discovery/environments/current");
|
|
3988
4107
|
const environment = await request.json();
|
|
3989
4108
|
const services = environment.services;
|
|
3990
4109
|
if (!services) {
|
|
3991
4110
|
throw new Error(`ServiceDiscoveryMissingError: No services found`);
|
|
3992
4111
|
}
|
|
3993
|
-
const portalService = (_a = environment.services) == null ? void 0 : _a.find(
|
|
4112
|
+
const portalService = (_a = environment.services) == null ? void 0 : _a.find(
|
|
4113
|
+
(v) => v.key === "portal"
|
|
4114
|
+
);
|
|
4115
|
+
const graphService = (_b = environment.services) == null ? void 0 : _b.find(
|
|
4116
|
+
(v) => v.key === "graph"
|
|
4117
|
+
);
|
|
3994
4118
|
if (!portalService || !environment.frontendClientId) {
|
|
3995
4119
|
const error = [];
|
|
3996
4120
|
if (!portalService) error.push(`Missing service: "portal"`);
|
|
@@ -4015,8 +4139,15 @@ ${error.join("\n")}`);
|
|
|
4015
4139
|
builder.setAssetUri(`/`);
|
|
4016
4140
|
builder.setClient(async (client) => {
|
|
4017
4141
|
const http = await client.requireInstance("http");
|
|
4018
|
-
const httpClient = http.createClient(
|
|
4019
|
-
|
|
4142
|
+
const httpClient = http.createClient({
|
|
4143
|
+
...portalService,
|
|
4144
|
+
baseUri: portalService.uri ?? portalService.baseUri
|
|
4145
|
+
});
|
|
4146
|
+
const graphHttpClient = http.createClient({
|
|
4147
|
+
...graphService,
|
|
4148
|
+
baseUri: (graphService == null ? void 0 : graphService.uri) ?? (graphService == null ? void 0 : graphService.baseUri)
|
|
4149
|
+
});
|
|
4150
|
+
return new CustomAppClient(httpClient, graphHttpClient);
|
|
4020
4151
|
});
|
|
4021
4152
|
});
|
|
4022
4153
|
enableNavigation(config);
|
|
@@ -5055,6 +5186,70 @@ const useFindGroupMembers = (groupId, query) => {
|
|
|
5055
5186
|
queryFn: () => findGroupMembers(client, groupId, query)
|
|
5056
5187
|
});
|
|
5057
5188
|
};
|
|
5189
|
+
const findGroup$1 = async (client, query) => {
|
|
5190
|
+
const headers = {
|
|
5191
|
+
ConsistencyLevel: "eventual"
|
|
5192
|
+
// Required to search by name
|
|
5193
|
+
};
|
|
5194
|
+
const params = new URLSearchParams();
|
|
5195
|
+
params.set("$count", "true");
|
|
5196
|
+
params.set("$orderby", "displayName");
|
|
5197
|
+
params.set("$select", "displayName,id");
|
|
5198
|
+
if (query) {
|
|
5199
|
+
params.set("$search", `"displayName:${query}"`);
|
|
5200
|
+
}
|
|
5201
|
+
const req = await client.fetch(`v1.0/groups?${params.toString()}`, {
|
|
5202
|
+
headers
|
|
5203
|
+
});
|
|
5204
|
+
if (req.status === 504) {
|
|
5205
|
+
throw new Error(`Application took to long to respond`);
|
|
5206
|
+
}
|
|
5207
|
+
const res = await req.json();
|
|
5208
|
+
if (req.status >= 400) {
|
|
5209
|
+
throw new Error(res.error.message);
|
|
5210
|
+
} else {
|
|
5211
|
+
return res;
|
|
5212
|
+
}
|
|
5213
|
+
};
|
|
5214
|
+
const useFindGroup = (query) => {
|
|
5215
|
+
const client = useHttpClient("graph");
|
|
5216
|
+
return useQuery({
|
|
5217
|
+
queryKey: ["graph", "group", "members", query],
|
|
5218
|
+
queryFn: () => findGroup$1(client, query),
|
|
5219
|
+
enabled: query.length > 2
|
|
5220
|
+
});
|
|
5221
|
+
};
|
|
5222
|
+
const findGroup = async (client, ids) => {
|
|
5223
|
+
const headers = {
|
|
5224
|
+
ConsistencyLevel: "eventual"
|
|
5225
|
+
// Required to search by name
|
|
5226
|
+
};
|
|
5227
|
+
const params = new URLSearchParams();
|
|
5228
|
+
params.set("$count", "true");
|
|
5229
|
+
params.set("$orderby", "displayName");
|
|
5230
|
+
params.set("$select", "displayName,id");
|
|
5231
|
+
params.set("$filter", `id in ('${ids.join("', '")}')`);
|
|
5232
|
+
const req = await client.fetch(`v1.0/groups?${params.toString()}`, {
|
|
5233
|
+
headers
|
|
5234
|
+
});
|
|
5235
|
+
if (req.status === 504) {
|
|
5236
|
+
throw new Error(`Application took to long to respond`);
|
|
5237
|
+
}
|
|
5238
|
+
const res = await req.json();
|
|
5239
|
+
if (req.status >= 400) {
|
|
5240
|
+
throw new Error(res.error.message);
|
|
5241
|
+
} else {
|
|
5242
|
+
return res;
|
|
5243
|
+
}
|
|
5244
|
+
};
|
|
5245
|
+
const useFindGroupById = (ids) => {
|
|
5246
|
+
const client = useHttpClient("graph");
|
|
5247
|
+
return useQuery({
|
|
5248
|
+
queryKey: ["graph", "group", "members", ids],
|
|
5249
|
+
queryFn: () => findGroup(client, ids),
|
|
5250
|
+
enabled: ids.length > 0
|
|
5251
|
+
});
|
|
5252
|
+
};
|
|
5058
5253
|
const findUsersByMail = async (client, email, fields) => {
|
|
5059
5254
|
const headers = {
|
|
5060
5255
|
ConsistencyLevel: "eventual"
|
|
@@ -5095,6 +5290,97 @@ const useFindUsersByShortname = (shortnames, fields = ["displayName", "mail", "g
|
|
|
5095
5290
|
const emails = (shortnames ?? []).map((name) => `${name}@equinor.com`);
|
|
5096
5291
|
return useFindUsersByMail(emails, fields);
|
|
5097
5292
|
};
|
|
5293
|
+
const searchUser = async (client, query) => {
|
|
5294
|
+
const headers = {
|
|
5295
|
+
ConsistencyLevel: "eventual"
|
|
5296
|
+
// Required to search by name
|
|
5297
|
+
};
|
|
5298
|
+
const params = new URLSearchParams();
|
|
5299
|
+
params.set("$orderby", "displayName");
|
|
5300
|
+
if (query) {
|
|
5301
|
+
params.set("$search", `"displayName:${query}" OR "mail:${query}"`);
|
|
5302
|
+
}
|
|
5303
|
+
const req = await client.fetch(`/v1.0/users?${params.toString()}`, {
|
|
5304
|
+
headers
|
|
5305
|
+
});
|
|
5306
|
+
if (req.status === 504) {
|
|
5307
|
+
throw new Error(`Application took to long to respond`);
|
|
5308
|
+
}
|
|
5309
|
+
const res = await req.json();
|
|
5310
|
+
if (req.status >= 400) {
|
|
5311
|
+
throw new Error(res.error.message);
|
|
5312
|
+
} else {
|
|
5313
|
+
return res;
|
|
5314
|
+
}
|
|
5315
|
+
};
|
|
5316
|
+
const searchServicePrincipal = async (client, query) => {
|
|
5317
|
+
const headers = {
|
|
5318
|
+
ConsistencyLevel: "eventual"
|
|
5319
|
+
// Required to search by name
|
|
5320
|
+
};
|
|
5321
|
+
const params = new URLSearchParams();
|
|
5322
|
+
params.set("$orderby", "displayName");
|
|
5323
|
+
params.set("$select", "id,appId,displayName");
|
|
5324
|
+
if (query) {
|
|
5325
|
+
params.set("$search", `"displayName:${query}"`);
|
|
5326
|
+
}
|
|
5327
|
+
const req = await client.fetch(
|
|
5328
|
+
`/v1.0/servicePrincipals?${params.toString()}`,
|
|
5329
|
+
{
|
|
5330
|
+
headers
|
|
5331
|
+
}
|
|
5332
|
+
);
|
|
5333
|
+
if (req.status === 504) {
|
|
5334
|
+
throw new Error(`Application took to long to respond`);
|
|
5335
|
+
}
|
|
5336
|
+
const res = await req.json();
|
|
5337
|
+
if (req.status >= 400) {
|
|
5338
|
+
throw new Error(res.error.message);
|
|
5339
|
+
} else {
|
|
5340
|
+
return res;
|
|
5341
|
+
}
|
|
5342
|
+
};
|
|
5343
|
+
const useFindUser = (query) => {
|
|
5344
|
+
const client = useHttpClient("graph");
|
|
5345
|
+
return useQuery({
|
|
5346
|
+
queryKey: ["graph", "group", "members", query],
|
|
5347
|
+
queryFn: async () => {
|
|
5348
|
+
const users = await searchUser(client, query);
|
|
5349
|
+
const servicePrincipals = await searchServicePrincipal(client, query);
|
|
5350
|
+
return {
|
|
5351
|
+
value: [...users.value ?? [], ...servicePrincipals.value ?? []]
|
|
5352
|
+
};
|
|
5353
|
+
},
|
|
5354
|
+
select: (data) => data ? data.value : [],
|
|
5355
|
+
enabled: query.length > 2
|
|
5356
|
+
});
|
|
5357
|
+
};
|
|
5358
|
+
const findUserById = async (client, id, fields) => {
|
|
5359
|
+
const headers = {
|
|
5360
|
+
ConsistencyLevel: "eventual"
|
|
5361
|
+
// Required to search by name
|
|
5362
|
+
};
|
|
5363
|
+
const req = await client.fetch(`v1.0/users/${id}`, {
|
|
5364
|
+
headers
|
|
5365
|
+
});
|
|
5366
|
+
if (req.status === 504) {
|
|
5367
|
+
throw new Error(`Application took to long to respond`);
|
|
5368
|
+
}
|
|
5369
|
+
const res = await req.json();
|
|
5370
|
+
if (req.status >= 400) {
|
|
5371
|
+
throw new Error(res.error.message);
|
|
5372
|
+
} else {
|
|
5373
|
+
return res;
|
|
5374
|
+
}
|
|
5375
|
+
};
|
|
5376
|
+
const useFindUserById = (id, fields = ["displayName", "mail", "givenName"]) => {
|
|
5377
|
+
const client = useHttpClient("graph");
|
|
5378
|
+
return useQuery({
|
|
5379
|
+
queryKey: ["graph", "user", "id", id],
|
|
5380
|
+
queryFn: () => findUserById(client, id),
|
|
5381
|
+
enabled: !!id
|
|
5382
|
+
});
|
|
5383
|
+
};
|
|
5098
5384
|
const checkRomaApi = (queryKey) => {
|
|
5099
5385
|
const first = (queryKey ?? []).at(0);
|
|
5100
5386
|
if (typeof first === "string") {
|
|
@@ -5464,6 +5750,7 @@ export {
|
|
|
5464
5750
|
StyleProvider,
|
|
5465
5751
|
configure,
|
|
5466
5752
|
createIDBPersister,
|
|
5753
|
+
findUserById,
|
|
5467
5754
|
findUsersByMail,
|
|
5468
5755
|
getGetAllAppsQueryKey,
|
|
5469
5756
|
getGetAllCategoriesQueryKey,
|
|
@@ -5526,7 +5813,11 @@ export {
|
|
|
5526
5813
|
useDeleteServiceByKey,
|
|
5527
5814
|
useDeleteServiceByKeyHook,
|
|
5528
5815
|
useDeleteServiceByKeyMutationOptions,
|
|
5816
|
+
useFindGroup,
|
|
5817
|
+
useFindGroupById,
|
|
5529
5818
|
useFindGroupMembers,
|
|
5819
|
+
useFindUser,
|
|
5820
|
+
useFindUserById,
|
|
5530
5821
|
useFindUsersByMail,
|
|
5531
5822
|
useFindUsersByShortname,
|
|
5532
5823
|
useGetAllApps,
|
|
@@ -68,8 +68,8 @@ function __generator(thisArg, body) {
|
|
|
68
68
|
var _ = { label: 0, sent: function() {
|
|
69
69
|
if (t[0] & 1) throw t[1];
|
|
70
70
|
return t[1];
|
|
71
|
-
}, trys: [], ops: [] }, f, y, t, g;
|
|
72
|
-
return g =
|
|
71
|
+
}, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
72
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
73
73
|
return this;
|
|
74
74
|
}), g;
|
|
75
75
|
function verb(n) {
|
|
@@ -176,7 +176,7 @@ function __await(v) {
|
|
|
176
176
|
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
177
177
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
178
178
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
179
|
-
return i =
|
|
179
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function() {
|
|
180
180
|
return this;
|
|
181
181
|
}, i;
|
|
182
182
|
function awaitReturn(f) {
|