@plumile/backoffice-react 0.1.199 → 0.1.201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/lib/esm/auth/backofficeAuthHeaders.js +18 -0
- package/lib/esm/auth/backofficeAuthHeaders.js.map +1 -0
- package/lib/esm/components/backoffice/actions/BackofficeEntityActionFormDialog.js.map +1 -1
- package/lib/esm/components/backoffice/layout/breadcrumb/buildBreadcrumbs.js.map +1 -1
- package/lib/esm/components/backoffice/layout/sidebarUtils.js.map +1 -1
- package/lib/esm/components/backoffice/pickers/EntityIdPickerDialog.js +1 -1
- package/lib/esm/components/backoffice/pickers/EntityIdPickerDialog.js.map +1 -1
- package/lib/esm/index.js +76 -75
- package/lib/esm/pages/BackofficeAcceptInvitationPage.js +7 -7
- package/lib/esm/pages/BackofficeEntityDetailLayoutPage.js +1 -1
- package/lib/esm/pages/BackofficeEntityDetailLayoutPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.helpers.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityDetailPage.js +169 -169
- package/lib/esm/pages/BackofficeEntityDetailPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityListDataPage.js +1 -1
- package/lib/esm/pages/BackofficeEntityListDataPage.js.map +1 -1
- package/lib/esm/pages/BackofficeEntityListPage.helpers.js.map +1 -1
- package/lib/esm/pages/BackofficeLayoutPage.js +41 -41
- package/lib/esm/pages/BackofficeLayoutPage.js.map +1 -1
- package/lib/esm/pages/BackofficeLoginPage.js +11 -11
- package/lib/esm/pages/BackofficePasswordResetCompletePage.js +14 -14
- package/lib/esm/pages/BackofficeVerifyEmailPage.js +14 -14
- package/lib/esm/provider/BackofficeProvider.js +78 -77
- package/lib/esm/provider/BackofficeProvider.js.map +1 -1
- package/lib/esm/provider/entityRegistry.js +39 -36
- package/lib/esm/provider/entityRegistry.js.map +1 -1
- package/lib/esm/provider/useBackofficeAuthRouteGate.js +39 -0
- package/lib/esm/provider/useBackofficeAuthRouteGate.js.map +1 -0
- package/lib/esm/relay/createInlineReader.js.map +1 -1
- package/lib/esm/relay/envHelpers.js +30 -22
- package/lib/esm/relay/envHelpers.js.map +1 -1
- package/lib/esm/relay/typedRelayHooks.js +11 -2
- package/lib/esm/relay/typedRelayHooks.js.map +1 -1
- package/lib/esm/router/backofficeAuthPaths.js +11 -2
- package/lib/esm/router/backofficeAuthPaths.js.map +1 -1
- package/lib/esm/router/createBackofficeRoutes.js.map +1 -1
- package/lib/types/auth/backofficeAuthHeaders.d.ts +5 -0
- package/lib/types/auth/backofficeAuthHeaders.d.ts.map +1 -0
- package/lib/types/components/backoffice/actions/BackofficeEntityActionFormDialog.d.ts +2 -2
- package/lib/types/components/backoffice/actions/BackofficeEntityActionFormDialog.d.ts.map +1 -1
- package/lib/types/components/backoffice/layout/sidebarUtils.d.ts.map +1 -1
- package/lib/types/components/backoffice/pickers/EntityIdPickerDialog.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityDetailPage.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityDetailPage.helpers.d.ts +3 -3
- package/lib/types/pages/BackofficeEntityDetailPage.helpers.d.ts.map +1 -1
- package/lib/types/pages/BackofficeEntityListPage.helpers.d.ts +2 -2
- package/lib/types/pages/BackofficeEntityListPage.helpers.d.ts.map +1 -1
- package/lib/types/provider/BackofficeProvider.d.ts.map +1 -1
- package/lib/types/provider/entityRegistry.d.ts.map +1 -1
- package/lib/types/provider/types.d.ts +1 -1
- package/lib/types/provider/types.d.ts.map +1 -1
- package/lib/types/provider/useBackofficeAuthRouteGate.d.ts +2 -0
- package/lib/types/provider/useBackofficeAuthRouteGate.d.ts.map +1 -0
- package/lib/types/relay/createInlineReader.d.ts +4 -1
- package/lib/types/relay/createInlineReader.d.ts.map +1 -1
- package/lib/types/relay/envHelpers.d.ts.map +1 -1
- package/lib/types/relay/typedRelayHooks.d.ts +15 -5
- package/lib/types/relay/typedRelayHooks.d.ts.map +1 -1
- package/lib/types/router/backofficeAuthPaths.d.ts +1 -0
- package/lib/types/router/backofficeAuthPaths.d.ts.map +1 -1
- package/lib/types/router/createBackofficeRoutes.d.ts +1 -1
- package/lib/types/router/createBackofficeRoutes.d.ts.map +1 -1
- package/package.json +13 -13
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { getBackofficePasswordResetPath as e } from "../router/backofficeAuthPaths.js";
|
|
2
|
+
import { LoginFlow as t } from "../auth/login/LoginFlow.js";
|
|
3
|
+
import { synchronizeAuthStatusQuery as n } from "../auth/login/synchronizeAuthStatusQuery.js";
|
|
4
|
+
import { useBackofficeConfig as r } from "../provider/BackofficeConfigContext.js";
|
|
5
|
+
import { useRelayEnvironment as i } from "../relay/useRelayEnvironment.js";
|
|
6
|
+
import { useBackofficeAuth as a } from "../hooks/useBackofficeAuth.js";
|
|
7
|
+
import { useBackofficeAuthLoginConfig as o } from "../provider/useBackofficeLazyValue.js";
|
|
8
8
|
import { useCallback as s, useContext as c, useRef as l } from "react";
|
|
9
9
|
import { jsx as u } from "react/jsx-runtime";
|
|
10
10
|
import * as d from "react-relay";
|
|
11
11
|
import f from "@plumile/router/routing/RoutingContext.js";
|
|
12
12
|
//#region src/pages/BackofficeLoginPage.tsx
|
|
13
13
|
var { usePreloadedQuery: p } = d, m = ({ prepared: d }) => {
|
|
14
|
-
let m = c(f), { auth: h, basePath: g } =
|
|
14
|
+
let m = c(f), { auth: h, basePath: g } = r(), _ = o(), v = a(), y = i(), b = l(!1), x = p(_.loginQuery, d.query).oidcProviders ?? [], S = s(() => {
|
|
15
15
|
b.current || (b.current = !0, (async () => {
|
|
16
16
|
try {
|
|
17
17
|
let e = await h.session.load();
|
|
@@ -19,7 +19,7 @@ var { usePreloadedQuery: p } = d, m = ({ prepared: d }) => {
|
|
|
19
19
|
m?.history.push({ pathname: g });
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
if (await h.lifecycle?.onLoginSuccess?.(), !await
|
|
22
|
+
if (await h.lifecycle?.onLoginSuccess?.(), !await n(y, e.authStatusQuery)) return;
|
|
23
23
|
m?.history.push({ pathname: g });
|
|
24
24
|
} catch {} finally {
|
|
25
25
|
b.current = !1;
|
|
@@ -32,9 +32,9 @@ var { usePreloadedQuery: p } = d, m = ({ prepared: d }) => {
|
|
|
32
32
|
y,
|
|
33
33
|
m?.history
|
|
34
34
|
]), C = s(() => {
|
|
35
|
-
m?.history.push({ pathname:
|
|
35
|
+
m?.history.push({ pathname: e(g) });
|
|
36
36
|
}, [g, m?.history]);
|
|
37
|
-
return /* @__PURE__ */ u(
|
|
37
|
+
return /* @__PURE__ */ u(t, {
|
|
38
38
|
auth: v,
|
|
39
39
|
oidcProviders: x,
|
|
40
40
|
onLoginSuccess: S,
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { getBackofficeLoginPath as e } from "../router/backofficeAuthPaths.js";
|
|
2
|
+
import { useBackofficeReactTranslation as t } from "../i18n/useBackofficeReactTranslation.js";
|
|
3
|
+
import { PasswordResetCompleteScreen as n } from "../auth/pages/PasswordResetCompleteScreen.js";
|
|
4
|
+
import { requireField as r, resolveMutationOutcome as i } from "../relay/mutationResult.js";
|
|
5
|
+
import { useBackofficeConfig as a } from "../provider/BackofficeConfigContext.js";
|
|
6
|
+
import { useBackofficeAuthPasswordResetCompleteConfig as o } from "../provider/useBackofficeLazyValue.js";
|
|
7
7
|
import { useCallback as s, useContext as c } from "react";
|
|
8
8
|
import { jsx as l } from "react/jsx-runtime";
|
|
9
9
|
import * as u from "react-relay";
|
|
10
10
|
import d from "@plumile/router/routing/RoutingContext.js";
|
|
11
11
|
//#region src/pages/BackofficePasswordResetCompletePage.tsx
|
|
12
12
|
var { useMutation: f } = u, p = () => {
|
|
13
|
-
let u = c(d), { basePath: p } =
|
|
14
|
-
u?.history.push({ pathname:
|
|
13
|
+
let u = c(d), { basePath: p } = a(), m = o(), { t: h } = t(), [g] = f(m.completePasswordResetMutation), _ = s(() => {
|
|
14
|
+
u?.history.push({ pathname: e(p) });
|
|
15
15
|
}, [p, u?.history]), v = s(async (e) => {
|
|
16
|
-
let t = h("auth.passwordResetComplete.errors.invalid"),
|
|
16
|
+
let t = h("auth.passwordResetComplete.errors.invalid"), n = t;
|
|
17
17
|
return new Promise((a, o) => {
|
|
18
18
|
g({
|
|
19
19
|
variables: { input: e },
|
|
20
20
|
onCompleted: (e) => {
|
|
21
|
-
let s =
|
|
22
|
-
defaultErrorMessage:
|
|
21
|
+
let s = i(e.completePasswordReset ?? null, {
|
|
22
|
+
defaultErrorMessage: n,
|
|
23
23
|
mapReason: (e) => {
|
|
24
24
|
switch (e) {
|
|
25
25
|
case "INVALID_TOKEN": return t;
|
|
@@ -34,7 +34,7 @@ var { useMutation: f } = u, p = () => {
|
|
|
34
34
|
o(Error(s.message));
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
let c =
|
|
37
|
+
let c = r(s.payload.success ?? null, n);
|
|
38
38
|
if (!c.ok) {
|
|
39
39
|
o(Error(c.message));
|
|
40
40
|
return;
|
|
@@ -42,12 +42,12 @@ var { useMutation: f } = u, p = () => {
|
|
|
42
42
|
a(c.value);
|
|
43
43
|
},
|
|
44
44
|
onError: () => {
|
|
45
|
-
o(Error(
|
|
45
|
+
o(Error(n));
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}, [g, h]);
|
|
50
|
-
return /* @__PURE__ */ l(
|
|
50
|
+
return /* @__PURE__ */ l(n, {
|
|
51
51
|
onBackToLogin: _,
|
|
52
52
|
onCompletePasswordReset: v
|
|
53
53
|
});
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { getBackofficeLoginPath as e } from "../router/backofficeAuthPaths.js";
|
|
2
|
+
import { useBackofficeReactTranslation as t } from "../i18n/useBackofficeReactTranslation.js";
|
|
3
|
+
import { VerifyEmailScreen as n } from "../auth/pages/VerifyEmailScreen.js";
|
|
4
|
+
import { requireField as r, resolveMutationOutcome as i } from "../relay/mutationResult.js";
|
|
5
|
+
import { useBackofficeConfig as a } from "../provider/BackofficeConfigContext.js";
|
|
6
|
+
import { useBackofficeAuthVerifyEmailConfig as o } from "../provider/useBackofficeLazyValue.js";
|
|
7
7
|
import { useCallback as s, useContext as c } from "react";
|
|
8
8
|
import { jsx as l } from "react/jsx-runtime";
|
|
9
9
|
import * as u from "react-relay";
|
|
10
10
|
import d from "@plumile/router/routing/RoutingContext.js";
|
|
11
11
|
//#region src/pages/BackofficeVerifyEmailPage.tsx
|
|
12
12
|
var { useMutation: f } = u, p = () => {
|
|
13
|
-
let u = c(d), { basePath: p } =
|
|
14
|
-
u?.history.push({ pathname:
|
|
13
|
+
let u = c(d), { basePath: p } = a(), m = o(), { t: h } = t(), [g] = f(m.verifyEmailMutation), _ = s(() => {
|
|
14
|
+
u?.history.push({ pathname: e(p) });
|
|
15
15
|
}, [p, u?.history]), v = s(async (e) => {
|
|
16
|
-
let t = h("auth.verifyEmail.errors.invalid"),
|
|
16
|
+
let t = h("auth.verifyEmail.errors.invalid"), n = t;
|
|
17
17
|
return new Promise((a, o) => {
|
|
18
18
|
g({
|
|
19
19
|
variables: { input: e },
|
|
20
20
|
onCompleted: (e) => {
|
|
21
|
-
let s =
|
|
22
|
-
defaultErrorMessage:
|
|
21
|
+
let s = i(e.verifyEmail ?? null, {
|
|
22
|
+
defaultErrorMessage: n,
|
|
23
23
|
mapReason: (e) => {
|
|
24
24
|
switch (e) {
|
|
25
25
|
case "INVALID_TOKEN": return t;
|
|
@@ -34,7 +34,7 @@ var { useMutation: f } = u, p = () => {
|
|
|
34
34
|
o(Error(s.message));
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
let c =
|
|
37
|
+
let c = r(s.payload.success ?? null, n);
|
|
38
38
|
if (!c.ok) {
|
|
39
39
|
o(Error(c.message));
|
|
40
40
|
return;
|
|
@@ -42,12 +42,12 @@ var { useMutation: f } = u, p = () => {
|
|
|
42
42
|
a(c.value);
|
|
43
43
|
},
|
|
44
44
|
onError: () => {
|
|
45
|
-
o(Error(
|
|
45
|
+
o(Error(n));
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
}, [g, h]);
|
|
50
|
-
return /* @__PURE__ */ l(
|
|
50
|
+
return /* @__PURE__ */ l(n, {
|
|
51
51
|
onBackToLogin: _,
|
|
52
52
|
onVerifyEmail: v
|
|
53
53
|
});
|
|
@@ -7,31 +7,32 @@ import { withBackofficeReactI18nResources as o } from "../i18n/resources.js";
|
|
|
7
7
|
import { createBackofficeRoutes as s } from "../router/createBackofficeRoutes.js";
|
|
8
8
|
import { createBackofficeEntityRegistry as c } from "./entityRegistry.js";
|
|
9
9
|
import { BackofficeListUiStateProvider as l } from "./BackofficeListUiStateContext.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import v from "
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import C from "
|
|
17
|
-
import w from "@plumile/router/routing/
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
10
|
+
import { useBackofficeAuthRouteGate as u } from "./useBackofficeAuthRouteGate.js";
|
|
11
|
+
import { StrictMode as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
12
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
13
|
+
import { I18nextProvider as v } from "react-i18next";
|
|
14
|
+
import y from "@plumile/router/routing/RoutingContext.js";
|
|
15
|
+
import { RelayProvider as b, configureRelayEnvironment as x, useRelayOperationActivity as S } from "@plumile/relay";
|
|
16
|
+
import { createInstance as C } from "i18next";
|
|
17
|
+
import w from "@plumile/router/routing/createRouter.js";
|
|
18
|
+
import T from "@plumile/router/routing/RouterRenderer.js";
|
|
19
|
+
import { BackofficeThemeProvider as E } from "@plumile/ui/admin/theme/BackofficeThemeProvider.js";
|
|
20
|
+
import { RoutePendingBar as D } from "@plumile/ui/components/routing/RoutePendingBar.js";
|
|
20
21
|
//#region src/provider/BackofficeProvider.tsx
|
|
21
|
-
var
|
|
22
|
-
let n =
|
|
22
|
+
var O = (e) => e.trim() === "" || e === "/" ? "/" : e.startsWith("/") ? e.endsWith("/") ? e.slice(0, -1) : e : `/${e}`, k = (e, t) => {
|
|
23
|
+
let n = O(t), r = O(e);
|
|
23
24
|
return r === "/" || n === r || n.startsWith(`${r}/`) ? n : n === "/" ? r : `${r}${n}`;
|
|
24
|
-
},
|
|
25
|
+
}, A = (e, t) => Object.fromEntries(Object.entries(e).map(([e, n]) => [e, {
|
|
25
26
|
...n,
|
|
26
27
|
routes: {
|
|
27
|
-
list:
|
|
28
|
-
detail: (e) =>
|
|
29
|
-
detailPage: (e, r) =>
|
|
28
|
+
list: k(t, n.routes.list),
|
|
29
|
+
detail: (e) => k(t, n.routes.detail(e)),
|
|
30
|
+
detailPage: (e, r) => k(t, n.routes.detailPage(e, r))
|
|
30
31
|
}
|
|
31
|
-
}])),
|
|
32
|
-
let [r, i] =
|
|
33
|
-
return
|
|
34
|
-
let r =
|
|
32
|
+
}])), j = ({ routes: e, context: t, instrumentations: n }) => {
|
|
33
|
+
let [r, i] = h(null), a = m(null);
|
|
34
|
+
return f(() => {
|
|
35
|
+
let r = w(e, {
|
|
35
36
|
context: t,
|
|
36
37
|
instrumentations: n
|
|
37
38
|
});
|
|
@@ -43,58 +44,58 @@ var D = (e) => e.trim() === "" || e === "/" ? "/" : e.startsWith("/") ? e.endsWi
|
|
|
43
44
|
n,
|
|
44
45
|
e
|
|
45
46
|
]), r;
|
|
46
|
-
},
|
|
47
|
-
let r = i(), a =
|
|
47
|
+
}, M = ({ routes: e, instrumentations: t }) => {
|
|
48
|
+
let r = i(), a = S(), o = j({
|
|
48
49
|
routes: e,
|
|
49
|
-
context:
|
|
50
|
+
context: p(() => ({ relayEnvironment: r }), [r]),
|
|
50
51
|
instrumentations: t
|
|
51
52
|
});
|
|
52
|
-
return o == null ? /* @__PURE__ */
|
|
53
|
+
return o == null ? /* @__PURE__ */ g(n, {}) : /* @__PURE__ */ g(y.Provider, {
|
|
53
54
|
value: o.context,
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
+
children: /* @__PURE__ */ g(T, {
|
|
55
56
|
enableTransition: !0,
|
|
56
57
|
externalPending: a.pendingCount > 0,
|
|
57
|
-
fallback: /* @__PURE__ */
|
|
58
|
-
pending: /* @__PURE__ */
|
|
58
|
+
fallback: /* @__PURE__ */ g(n, {}),
|
|
59
|
+
pending: /* @__PURE__ */ g(D, {})
|
|
59
60
|
})
|
|
60
61
|
});
|
|
61
|
-
},
|
|
62
|
-
let i =
|
|
63
|
-
|
|
64
|
-
let e =
|
|
65
|
-
|
|
62
|
+
}, N = (n) => {
|
|
63
|
+
let i = O(n.basePath ?? "/"), m = u(i), y = p(() => A(n.entityManifest, i), [i, n.entityManifest]), S = p(() => c(y, { basePath: i }), [i, y]), w = n.graphql, T = p(() => t(n.dashboards), [n.dashboards]);
|
|
64
|
+
f(() => {
|
|
65
|
+
let e = w.httpUrl ?? w.endpoint, t = w.wsUrl ?? w.wsEndpoint;
|
|
66
|
+
x({
|
|
66
67
|
httpUrl: e,
|
|
67
68
|
wsUrl: t,
|
|
68
|
-
getDataId:
|
|
69
|
-
logEvents:
|
|
70
|
-
getAuthHeaders:
|
|
69
|
+
getDataId: w.getDataId,
|
|
70
|
+
logEvents: w.logEvents,
|
|
71
|
+
getAuthHeaders: w.getAuthHeaders
|
|
71
72
|
});
|
|
72
73
|
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
w.endpoint,
|
|
75
|
+
w.getAuthHeaders,
|
|
76
|
+
w.getDataId,
|
|
77
|
+
w.httpUrl,
|
|
78
|
+
w.logEvents,
|
|
79
|
+
w.wsEndpoint,
|
|
80
|
+
w.wsUrl
|
|
80
81
|
]);
|
|
81
|
-
let
|
|
82
|
-
|
|
82
|
+
let D = p(() => o(n.i18n?.resources ?? {}), [n.i18n?.resources]), k = p(() => n.i18n?.instance ?? C(), [n.i18n?.instance]), [j, N] = h(k.isInitialized);
|
|
83
|
+
f(() => {
|
|
83
84
|
let e = !0, t = () => {
|
|
84
|
-
e &&
|
|
85
|
+
e && N(!0);
|
|
85
86
|
};
|
|
86
|
-
if (
|
|
87
|
-
e = !1,
|
|
87
|
+
if (k.on("initialized", t), k.isInitialized) return t(), () => {
|
|
88
|
+
e = !1, k.off("initialized", t);
|
|
88
89
|
};
|
|
89
90
|
let r = globalThis.setTimeout(() => {
|
|
90
|
-
|
|
91
|
+
k.isInitialized && t();
|
|
91
92
|
}, 0), i = n.i18n?.initOptions ?? {}, o = i.defaultNS ?? "translations", s = i.ns ?? [
|
|
92
93
|
"backofficeReact",
|
|
93
94
|
"translations",
|
|
94
95
|
"ui"
|
|
95
96
|
];
|
|
96
97
|
return a({
|
|
97
|
-
resources:
|
|
98
|
+
resources: D,
|
|
98
99
|
lng: n.i18n?.lng,
|
|
99
100
|
fallbackLng: n.i18n?.fallbackLng,
|
|
100
101
|
initOptions: {
|
|
@@ -106,75 +107,75 @@ var D = (e) => e.trim() === "" || e === "/" ? "/" : e.startsWith("/") ? e.endsWi
|
|
|
106
107
|
...i.react
|
|
107
108
|
}
|
|
108
109
|
},
|
|
109
|
-
instance:
|
|
110
|
+
instance: k,
|
|
110
111
|
useLanguageDetector: n.i18n?.useLanguageDetector,
|
|
111
112
|
detection: n.i18n?.detection
|
|
112
113
|
}).then(t).catch((e) => {
|
|
113
114
|
t(), console.error(e);
|
|
114
115
|
}), () => {
|
|
115
|
-
e = !1, globalThis.clearTimeout(r),
|
|
116
|
+
e = !1, globalThis.clearTimeout(r), k.off("initialized", t);
|
|
116
117
|
};
|
|
117
118
|
}, [
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
k,
|
|
120
|
+
D,
|
|
120
121
|
n.i18n?.initOptions,
|
|
121
122
|
n.i18n?.detection,
|
|
122
123
|
n.i18n?.fallbackLng,
|
|
123
124
|
n.i18n?.lng,
|
|
124
125
|
n.i18n?.useLanguageDetector
|
|
125
126
|
]);
|
|
126
|
-
let
|
|
127
|
+
let P = p(() => ({
|
|
127
128
|
basePath: i,
|
|
128
|
-
entities:
|
|
129
|
-
entityManifest:
|
|
130
|
-
entityRegistry:
|
|
129
|
+
entities: y,
|
|
130
|
+
entityManifest: y,
|
|
131
|
+
entityRegistry: S,
|
|
131
132
|
filterColumnAliases: n.filterColumnAliases,
|
|
132
133
|
sidebar: n.sidebar,
|
|
133
134
|
dashboard: n.dashboard,
|
|
134
|
-
dashboards:
|
|
135
|
+
dashboards: T,
|
|
135
136
|
auth: n.auth,
|
|
136
137
|
graphql: n.graphql
|
|
137
138
|
}), [
|
|
138
139
|
i,
|
|
139
140
|
n.auth,
|
|
140
141
|
n.dashboard,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
T,
|
|
143
|
+
y,
|
|
144
|
+
S,
|
|
144
145
|
n.filterColumnAliases,
|
|
145
146
|
n.graphql,
|
|
146
147
|
n.sidebar
|
|
147
|
-
]),
|
|
148
|
+
]), F = p(() => s({
|
|
148
149
|
basePath: i,
|
|
149
|
-
entityManifest:
|
|
150
|
-
entityRegistry:
|
|
150
|
+
entityManifest: y,
|
|
151
|
+
entityRegistry: S,
|
|
151
152
|
sidebar: n.sidebar,
|
|
152
153
|
auth: n.auth,
|
|
153
154
|
dashboard: n.dashboard,
|
|
154
|
-
dashboards:
|
|
155
|
+
dashboards: T,
|
|
155
156
|
toolsOperationPage: n.toolsOperationPage
|
|
156
157
|
}), [
|
|
157
158
|
i,
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
y,
|
|
160
|
+
S,
|
|
160
161
|
n.auth,
|
|
161
162
|
n.dashboard,
|
|
162
|
-
|
|
163
|
+
T,
|
|
163
164
|
n.toolsOperationPage,
|
|
164
165
|
n.sidebar
|
|
165
|
-
]),
|
|
166
|
-
return
|
|
167
|
-
value:
|
|
168
|
-
children: [n.overlay, /* @__PURE__ */
|
|
169
|
-
routes:
|
|
166
|
+
]), I = /* @__PURE__ */ g(r, { label: "Loading..." });
|
|
167
|
+
return j && m && (I = /* @__PURE__ */ g(E, { children: /* @__PURE__ */ g(b, { children: /* @__PURE__ */ _(e, {
|
|
168
|
+
value: P,
|
|
169
|
+
children: [n.overlay, /* @__PURE__ */ g(l, { children: /* @__PURE__ */ g(M, {
|
|
170
|
+
routes: F,
|
|
170
171
|
instrumentations: n.instrumentations
|
|
171
172
|
}) })]
|
|
172
|
-
}) }) })), /* @__PURE__ */
|
|
173
|
-
i18n:
|
|
174
|
-
children:
|
|
173
|
+
}) }) })), /* @__PURE__ */ g(d, { children: /* @__PURE__ */ g(v, {
|
|
174
|
+
i18n: k,
|
|
175
|
+
children: I
|
|
175
176
|
}) });
|
|
176
177
|
};
|
|
177
178
|
//#endregion
|
|
178
|
-
export {
|
|
179
|
+
export { N as BackofficeProvider, N as default };
|
|
179
180
|
|
|
180
181
|
//# sourceMappingURL=BackofficeProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackofficeProvider.js","names":[],"sources":["../../../src/provider/BackofficeProvider.tsx"],"sourcesContent":["import {\n StrictMode,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ContextType,\n type JSX,\n} from 'react';\nimport { createInstance } from 'i18next';\nimport { I18nextProvider } from 'react-i18next';\nimport createRouter from '@plumile/router/routing/createRouter.js';\nimport RouterRenderer from '@plumile/router/routing/RouterRenderer.js';\nimport RoutingContext from '@plumile/router/routing/RoutingContext.js';\nimport { BackofficeThemeProvider } from '@plumile/ui/admin/theme/BackofficeThemeProvider.js';\nimport { RoutePendingBar } from '@plumile/ui/components/routing/RoutePendingBar.js';\n\nimport { type BackofficeEntityManifestMap } from '@plumile/backoffice-core/types.js';\nimport {\n RelayProvider,\n configureRelayEnvironment,\n useRelayOperationActivity,\n} from '@plumile/relay';\n\nimport { createI18nInstance } from '../i18n/createI18nInstance.js';\nimport { withBackofficeReactI18nResources } from '../i18n/resources.js';\nimport { useRelayEnvironment } from '../relay/useRelayEnvironment.js';\nimport { BackofficeConfigProvider } from './BackofficeConfigContext.js';\nimport {\n createBackofficeRoutes,\n type BackofficeRouterContext,\n} from '../router/createBackofficeRoutes.js';\nimport type { BackofficeProviderProps } from './types.js';\nimport { validateBackofficeDashboardRegistrations } from './dashboardRegistrations.js';\nimport {\n BackofficeRouteFallback,\n BackofficeStaticRouteFallback,\n} from '../components/backoffice/routing/BackofficeRouteFallback.js';\nimport { createBackofficeEntityRegistry } from './entityRegistry.js';\nimport { BackofficeListUiStateProvider } from './BackofficeListUiStateContext.js';\n\nconst normalizeAbsolutePath = (value: string): string => {\n if (value.trim() === '' || value === '/') {\n return '/';\n }\n if (!value.startsWith('/')) {\n return `/${value}`;\n }\n if (value.endsWith('/')) {\n return value.slice(0, -1);\n }\n return value;\n};\n\nconst prefixRoutePath = (basePath: string, value: string): string => {\n const normalizedPath = normalizeAbsolutePath(value);\n const normalizedBasePath = normalizeAbsolutePath(basePath);\n if (normalizedBasePath === '/') {\n return normalizedPath;\n }\n if (\n normalizedPath === normalizedBasePath ||\n normalizedPath.startsWith(`${normalizedBasePath}/`)\n ) {\n return normalizedPath;\n }\n if (normalizedPath === '/') {\n return normalizedBasePath;\n }\n return `${normalizedBasePath}${normalizedPath}`;\n};\n\nconst resolveEntityManifest = (\n manifest: BackofficeEntityManifestMap,\n basePath: string,\n): BackofficeEntityManifestMap => {\n return Object.fromEntries(\n Object.entries(manifest).map(([entityId, item]) => {\n return [\n entityId,\n {\n ...item,\n routes: {\n list: prefixRoutePath(basePath, item.routes.list),\n detail: (id: string) => {\n return prefixRoutePath(basePath, item.routes.detail(id));\n },\n detailPage: (id: string, pageId: string) => {\n return prefixRoutePath(\n basePath,\n item.routes.detailPage(id, pageId),\n );\n },\n },\n } satisfies BackofficeEntityManifestMap[string],\n ] as const;\n }),\n );\n};\n\ntype RouterShellProps = {\n routes: ReturnType<typeof createBackofficeRoutes>;\n instrumentations?: BackofficeProviderProps['instrumentations'];\n};\n\ntype BackofficeRouterInstance = {\n context: NonNullable<ContextType<typeof RoutingContext>>;\n cleanup: () => void;\n};\n\nconst useBackofficeRouterInstance = ({\n routes,\n context,\n instrumentations,\n}: {\n routes: ReturnType<typeof createBackofficeRoutes>;\n context: BackofficeRouterContext;\n instrumentations?: BackofficeProviderProps['instrumentations'];\n}): BackofficeRouterInstance | null => {\n const [router, setRouter] = useState<BackofficeRouterInstance | null>(null);\n const routerRef = useRef<BackofficeRouterInstance | null>(null);\n\n useEffect(() => {\n const nextRouter = createRouter(routes, {\n context,\n instrumentations,\n });\n routerRef.current = nextRouter;\n setRouter(nextRouter);\n\n return () => {\n if (routerRef.current === nextRouter) {\n routerRef.current = null;\n }\n nextRouter.cleanup();\n };\n }, [context, instrumentations, routes]);\n\n return router;\n};\n\nconst RouterShell = ({\n routes,\n instrumentations,\n}: RouterShellProps): JSX.Element => {\n const relayEnvironment = useRelayEnvironment();\n const relayOperationActivity = useRelayOperationActivity();\n\n const routerContext = useMemo(() => {\n return { relayEnvironment };\n }, [relayEnvironment]);\n\n const router = useBackofficeRouterInstance({\n routes,\n context: routerContext,\n instrumentations,\n });\n\n if (router == null) {\n return <BackofficeRouteFallback />;\n }\n\n return (\n <RoutingContext.Provider value={router.context}>\n <RouterRenderer\n enableTransition\n externalPending={relayOperationActivity.pendingCount > 0}\n fallback={<BackofficeRouteFallback />}\n pending={<RoutePendingBar />}\n />\n </RoutingContext.Provider>\n );\n};\n\nexport const BackofficeProvider = (\n props: BackofficeProviderProps,\n): JSX.Element => {\n const basePath = normalizeAbsolutePath(props.basePath ?? '/');\n\n const entityManifest = useMemo(() => {\n return resolveEntityManifest(props.entityManifest, basePath);\n }, [basePath, props.entityManifest]);\n const entityRegistry = useMemo(() => {\n return createBackofficeEntityRegistry(entityManifest, { basePath });\n }, [basePath, entityManifest]);\n\n const graphQLConfig = props.graphql;\n const dashboards = useMemo(() => {\n return validateBackofficeDashboardRegistrations(props.dashboards);\n }, [props.dashboards]);\n\n useEffect(() => {\n const httpUrl = graphQLConfig.httpUrl ?? graphQLConfig.endpoint;\n const wsUrl = graphQLConfig.wsUrl ?? graphQLConfig.wsEndpoint;\n configureRelayEnvironment({\n httpUrl,\n wsUrl,\n getDataId: graphQLConfig.getDataId,\n logEvents: graphQLConfig.logEvents,\n getAuthHeaders: graphQLConfig.getAuthHeaders,\n });\n }, [\n graphQLConfig.endpoint,\n graphQLConfig.getAuthHeaders,\n graphQLConfig.getDataId,\n graphQLConfig.httpUrl,\n graphQLConfig.logEvents,\n graphQLConfig.wsEndpoint,\n graphQLConfig.wsUrl,\n ]);\n\n const mergedResources = useMemo(() => {\n return withBackofficeReactI18nResources(props.i18n?.resources ?? {});\n }, [props.i18n?.resources]);\n\n const i18nInstance = useMemo(() => {\n return props.i18n?.instance ?? createInstance();\n }, [props.i18n?.instance]);\n const [isI18nReady, setIsI18nReady] = useState(i18nInstance.isInitialized);\n\n useEffect(() => {\n let isCurrent = true;\n const markI18nReady = (): void => {\n if (isCurrent) {\n setIsI18nReady(true);\n }\n };\n\n i18nInstance.on('initialized', markI18nReady);\n if (i18nInstance.isInitialized) {\n markI18nReady();\n return () => {\n isCurrent = false;\n i18nInstance.off('initialized', markI18nReady);\n };\n }\n\n const readyCheck = globalThis.setTimeout(() => {\n if (i18nInstance.isInitialized) {\n markI18nReady();\n }\n }, 0);\n\n const initOptions = props.i18n?.initOptions ?? {};\n const defaultNs = initOptions.defaultNS ?? 'translations';\n const ns = initOptions.ns ?? ['backofficeReact', 'translations', 'ui'];\n createI18nInstance({\n resources: mergedResources,\n lng: props.i18n?.lng,\n fallbackLng: props.i18n?.fallbackLng,\n initOptions: {\n ...initOptions,\n defaultNS: defaultNs,\n ns,\n react: {\n useSuspense: false,\n ...initOptions.react,\n },\n },\n instance: i18nInstance,\n useLanguageDetector: props.i18n?.useLanguageDetector,\n detection: props.i18n?.detection,\n })\n .then(markI18nReady)\n .catch((error: unknown) => {\n markI18nReady();\n // eslint-disable-next-line no-console\n console.error(error);\n });\n\n return () => {\n isCurrent = false;\n globalThis.clearTimeout(readyCheck);\n i18nInstance.off('initialized', markI18nReady);\n };\n }, [\n i18nInstance,\n mergedResources,\n props.i18n?.initOptions,\n props.i18n?.detection,\n props.i18n?.fallbackLng,\n props.i18n?.lng,\n props.i18n?.useLanguageDetector,\n ]);\n\n const configValue = useMemo(() => {\n return {\n basePath,\n entities: entityManifest,\n entityManifest,\n entityRegistry,\n filterColumnAliases: props.filterColumnAliases,\n sidebar: props.sidebar,\n dashboard: props.dashboard,\n dashboards,\n auth: props.auth,\n graphql: props.graphql,\n };\n }, [\n basePath,\n props.auth,\n props.dashboard,\n dashboards,\n entityManifest,\n entityRegistry,\n props.filterColumnAliases,\n props.graphql,\n props.sidebar,\n ]);\n\n const routes = useMemo(() => {\n return createBackofficeRoutes({\n basePath,\n entityManifest,\n entityRegistry,\n sidebar: props.sidebar,\n auth: props.auth,\n dashboard: props.dashboard,\n dashboards,\n toolsOperationPage: props.toolsOperationPage,\n });\n }, [\n basePath,\n entityManifest,\n entityRegistry,\n props.auth,\n props.dashboard,\n dashboards,\n props.toolsOperationPage,\n props.sidebar,\n ]);\n\n let contentNode = <BackofficeStaticRouteFallback label=\"Loading...\" />;\n if (isI18nReady) {\n contentNode = (\n <BackofficeThemeProvider>\n <RelayProvider>\n <BackofficeConfigProvider value={configValue}>\n {props.overlay}\n <BackofficeListUiStateProvider>\n <RouterShell\n routes={routes}\n instrumentations={props.instrumentations}\n />\n </BackofficeListUiStateProvider>\n </BackofficeConfigProvider>\n </RelayProvider>\n </BackofficeThemeProvider>\n );\n }\n\n return (\n <StrictMode>\n <I18nextProvider i18n={i18nInstance}>{contentNode}</I18nextProvider>\n </StrictMode>\n );\n};\n\nexport default BackofficeProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyCA,IAAM,KAAyB,MACzB,EAAM,KAAK,MAAM,MAAM,MAAU,MAC5B,MAEJ,EAAM,WAAW,GAAG,IAGrB,EAAM,SAAS,GAAG,IACb,EAAM,MAAM,GAAG,EAAE,IAEnB,IALE,IAAI,KAQT,KAAmB,GAAkB,MAA0B;CACnE,IAAM,IAAiB,EAAsB,CAAK,GAC5C,IAAqB,EAAsB,CAAQ;CAazD,OAZI,MAAuB,OAIzB,MAAmB,KACnB,EAAe,WAAW,GAAG,EAAmB,EAAE,IAE3C,IAEL,MAAmB,MACd,IAEF,GAAG,IAAqB;AACjC,GAEM,KACJ,GACA,MAEO,OAAO,YACZ,OAAO,QAAQ,CAAQ,CAAC,CAAC,KAAK,CAAC,GAAU,OAChC,CACL,GACA;CACE,GAAG;CACH,QAAQ;EACN,MAAM,EAAgB,GAAU,EAAK,OAAO,IAAI;EAChD,SAAS,MACA,EAAgB,GAAU,EAAK,OAAO,OAAO,CAAE,CAAC;EAEzD,aAAa,GAAY,MAChB,EACL,GACA,EAAK,OAAO,WAAW,GAAI,CAAM,CACnC;CAEJ;AACF,CACF,CACD,CACH,GAaI,KAA+B,EACnC,WACA,YACA,0BAKqC;CACrC,IAAM,CAAC,GAAQ,KAAa,EAA0C,IAAI,GACpE,IAAY,EAAwC,IAAI;CAkB9D,OAhBA,QAAgB;EACd,IAAM,IAAa,EAAa,GAAQ;GACtC;GACA;EACF,CAAC;EAID,OAHA,EAAU,UAAU,GACpB,EAAU,CAAU,SAEP;GAIX,AAHI,EAAU,YAAY,MACxB,EAAU,UAAU,OAEtB,EAAW,Q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,EAAM;EACN,EAAM;EACN,EAAM;CACR,CAAC,GAEK,IAAS,QACN,EAAuB;EAC5B;EACA;EACA;EACA,SAAS,EAAM;EACf,MAAM,EAAM;EACZ,WAAW,EAAM;EACjB;EACA,oBAAoB,EAAM;CAC5B,CAAC,GACA;EACD;EACA;EACA;EACA,EAAM;EACN,EAAM;EACN;EACA,EAAM;EACN,EAAM;CACR,CAAC,GAEG,IAAc,kBAAC,GAAD,EAA+B,OAAM,aAAc,CAAA;CAmBrE,OAlBI,MACF,IACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAA0B,OAAO;EAAjC,UAAA,CACG,EAAM,SACP,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GACU;GACR,kBAAkB,EAAM;EACzB,CAAA,EAC4B,CAAA,CACP;CACb,CAAA,EAAA,CAAA,EACQ,CAAA,IAK3B,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAAiB,MAAM;EAAe,UAAA;CAA6B,CAAA,EACzD,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"BackofficeProvider.js","names":[],"sources":["../../../src/provider/BackofficeProvider.tsx"],"sourcesContent":["import {\n StrictMode,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ContextType,\n type JSX,\n} from 'react';\nimport { createInstance } from 'i18next';\nimport { I18nextProvider } from 'react-i18next';\nimport createRouter from '@plumile/router/routing/createRouter.js';\nimport RouterRenderer from '@plumile/router/routing/RouterRenderer.js';\nimport RoutingContext from '@plumile/router/routing/RoutingContext.js';\nimport { BackofficeThemeProvider } from '@plumile/ui/admin/theme/BackofficeThemeProvider.js';\nimport { RoutePendingBar } from '@plumile/ui/components/routing/RoutePendingBar.js';\n\nimport { type BackofficeEntityManifestMap } from '@plumile/backoffice-core/types.js';\nimport {\n RelayProvider,\n configureRelayEnvironment,\n useRelayOperationActivity,\n} from '@plumile/relay';\n\nimport { createI18nInstance } from '../i18n/createI18nInstance.js';\nimport { withBackofficeReactI18nResources } from '../i18n/resources.js';\nimport { useRelayEnvironment } from '../relay/useRelayEnvironment.js';\nimport { BackofficeConfigProvider } from './BackofficeConfigContext.js';\nimport {\n createBackofficeRoutes,\n type BackofficeRouterContext,\n} from '../router/createBackofficeRoutes.js';\nimport type { BackofficeProviderProps } from './types.js';\nimport { validateBackofficeDashboardRegistrations } from './dashboardRegistrations.js';\nimport {\n BackofficeRouteFallback,\n BackofficeStaticRouteFallback,\n} from '../components/backoffice/routing/BackofficeRouteFallback.js';\nimport { createBackofficeEntityRegistry } from './entityRegistry.js';\nimport { BackofficeListUiStateProvider } from './BackofficeListUiStateContext.js';\nimport { useBackofficeAuthRouteGate } from './useBackofficeAuthRouteGate.js';\n\nconst normalizeAbsolutePath = (value: string): string => {\n if (value.trim() === '' || value === '/') {\n return '/';\n }\n if (!value.startsWith('/')) {\n return `/${value}`;\n }\n if (value.endsWith('/')) {\n return value.slice(0, -1);\n }\n return value;\n};\n\nconst prefixRoutePath = (basePath: string, value: string): string => {\n const normalizedPath = normalizeAbsolutePath(value);\n const normalizedBasePath = normalizeAbsolutePath(basePath);\n if (normalizedBasePath === '/') {\n return normalizedPath;\n }\n if (\n normalizedPath === normalizedBasePath ||\n normalizedPath.startsWith(`${normalizedBasePath}/`)\n ) {\n return normalizedPath;\n }\n if (normalizedPath === '/') {\n return normalizedBasePath;\n }\n return `${normalizedBasePath}${normalizedPath}`;\n};\n\nconst resolveEntityManifest = (\n manifest: BackofficeEntityManifestMap,\n basePath: string,\n): BackofficeEntityManifestMap => {\n return Object.fromEntries(\n Object.entries(manifest).map(([entityId, item]) => {\n return [\n entityId,\n {\n ...item,\n routes: {\n list: prefixRoutePath(basePath, item.routes.list),\n detail: (id: string) => {\n return prefixRoutePath(basePath, item.routes.detail(id));\n },\n detailPage: (id: string, pageId: string) => {\n return prefixRoutePath(\n basePath,\n item.routes.detailPage(id, pageId),\n );\n },\n },\n } satisfies BackofficeEntityManifestMap[string],\n ] as const;\n }),\n );\n};\n\ntype RouterShellProps = {\n routes: ReturnType<typeof createBackofficeRoutes>;\n instrumentations?: BackofficeProviderProps['instrumentations'];\n};\n\ntype BackofficeRouterInstance = {\n context: NonNullable<ContextType<typeof RoutingContext>>;\n cleanup: () => void;\n};\n\nconst useBackofficeRouterInstance = ({\n routes,\n context,\n instrumentations,\n}: {\n routes: ReturnType<typeof createBackofficeRoutes>;\n context: BackofficeRouterContext;\n instrumentations?: BackofficeProviderProps['instrumentations'];\n}): BackofficeRouterInstance | null => {\n const [router, setRouter] = useState<BackofficeRouterInstance | null>(null);\n const routerRef = useRef<BackofficeRouterInstance | null>(null);\n\n useEffect(() => {\n const nextRouter = createRouter(routes, {\n context,\n instrumentations,\n });\n routerRef.current = nextRouter;\n setRouter(nextRouter);\n\n return () => {\n if (routerRef.current === nextRouter) {\n routerRef.current = null;\n }\n nextRouter.cleanup();\n };\n }, [context, instrumentations, routes]);\n\n return router;\n};\n\nconst RouterShell = ({\n routes,\n instrumentations,\n}: RouterShellProps): JSX.Element => {\n const relayEnvironment = useRelayEnvironment();\n const relayOperationActivity = useRelayOperationActivity();\n\n const routerContext = useMemo(() => {\n return { relayEnvironment };\n }, [relayEnvironment]);\n\n const router = useBackofficeRouterInstance({\n routes,\n context: routerContext,\n instrumentations,\n });\n\n if (router == null) {\n return <BackofficeRouteFallback />;\n }\n\n return (\n <RoutingContext.Provider value={router.context}>\n <RouterRenderer\n enableTransition\n externalPending={relayOperationActivity.pendingCount > 0}\n fallback={<BackofficeRouteFallback />}\n pending={<RoutePendingBar />}\n />\n </RoutingContext.Provider>\n );\n};\n\nexport const BackofficeProvider = (\n props: BackofficeProviderProps,\n): JSX.Element => {\n const basePath = normalizeAbsolutePath(props.basePath ?? '/');\n const canMountRouter = useBackofficeAuthRouteGate(basePath);\n\n const entityManifest = useMemo(() => {\n return resolveEntityManifest(props.entityManifest, basePath);\n }, [basePath, props.entityManifest]);\n const entityRegistry = useMemo(() => {\n return createBackofficeEntityRegistry(entityManifest, { basePath });\n }, [basePath, entityManifest]);\n\n const graphQLConfig = props.graphql;\n const dashboards = useMemo(() => {\n return validateBackofficeDashboardRegistrations(props.dashboards);\n }, [props.dashboards]);\n\n useEffect(() => {\n const httpUrl = graphQLConfig.httpUrl ?? graphQLConfig.endpoint;\n const wsUrl = graphQLConfig.wsUrl ?? graphQLConfig.wsEndpoint;\n configureRelayEnvironment({\n httpUrl,\n wsUrl,\n getDataId: graphQLConfig.getDataId,\n logEvents: graphQLConfig.logEvents,\n getAuthHeaders: graphQLConfig.getAuthHeaders,\n });\n }, [\n graphQLConfig.endpoint,\n graphQLConfig.getAuthHeaders,\n graphQLConfig.getDataId,\n graphQLConfig.httpUrl,\n graphQLConfig.logEvents,\n graphQLConfig.wsEndpoint,\n graphQLConfig.wsUrl,\n ]);\n\n const mergedResources = useMemo(() => {\n return withBackofficeReactI18nResources(props.i18n?.resources ?? {});\n }, [props.i18n?.resources]);\n\n const i18nInstance = useMemo(() => {\n return props.i18n?.instance ?? createInstance();\n }, [props.i18n?.instance]);\n const [isI18nReady, setIsI18nReady] = useState(i18nInstance.isInitialized);\n\n useEffect(() => {\n let isCurrent = true;\n const markI18nReady = (): void => {\n if (isCurrent) {\n setIsI18nReady(true);\n }\n };\n\n i18nInstance.on('initialized', markI18nReady);\n if (i18nInstance.isInitialized) {\n markI18nReady();\n return () => {\n isCurrent = false;\n i18nInstance.off('initialized', markI18nReady);\n };\n }\n\n const readyCheck = globalThis.setTimeout(() => {\n if (i18nInstance.isInitialized) {\n markI18nReady();\n }\n }, 0);\n\n const initOptions = props.i18n?.initOptions ?? {};\n const defaultNs = initOptions.defaultNS ?? 'translations';\n const ns = initOptions.ns ?? ['backofficeReact', 'translations', 'ui'];\n createI18nInstance({\n resources: mergedResources,\n lng: props.i18n?.lng,\n fallbackLng: props.i18n?.fallbackLng,\n initOptions: {\n ...initOptions,\n defaultNS: defaultNs,\n ns,\n react: {\n useSuspense: false,\n ...initOptions.react,\n },\n },\n instance: i18nInstance,\n useLanguageDetector: props.i18n?.useLanguageDetector,\n detection: props.i18n?.detection,\n })\n .then(markI18nReady)\n .catch((error: unknown) => {\n markI18nReady();\n // eslint-disable-next-line no-console\n console.error(error);\n });\n\n return () => {\n isCurrent = false;\n globalThis.clearTimeout(readyCheck);\n i18nInstance.off('initialized', markI18nReady);\n };\n }, [\n i18nInstance,\n mergedResources,\n props.i18n?.initOptions,\n props.i18n?.detection,\n props.i18n?.fallbackLng,\n props.i18n?.lng,\n props.i18n?.useLanguageDetector,\n ]);\n\n const configValue = useMemo(() => {\n return {\n basePath,\n entities: entityManifest,\n entityManifest,\n entityRegistry,\n filterColumnAliases: props.filterColumnAliases,\n sidebar: props.sidebar,\n dashboard: props.dashboard,\n dashboards,\n auth: props.auth,\n graphql: props.graphql,\n };\n }, [\n basePath,\n props.auth,\n props.dashboard,\n dashboards,\n entityManifest,\n entityRegistry,\n props.filterColumnAliases,\n props.graphql,\n props.sidebar,\n ]);\n\n const routes = useMemo(() => {\n return createBackofficeRoutes({\n basePath,\n entityManifest,\n entityRegistry,\n sidebar: props.sidebar,\n auth: props.auth,\n dashboard: props.dashboard,\n dashboards,\n toolsOperationPage: props.toolsOperationPage,\n });\n }, [\n basePath,\n entityManifest,\n entityRegistry,\n props.auth,\n props.dashboard,\n dashboards,\n props.toolsOperationPage,\n props.sidebar,\n ]);\n\n let contentNode = <BackofficeStaticRouteFallback label=\"Loading...\" />;\n if (isI18nReady && canMountRouter) {\n contentNode = (\n <BackofficeThemeProvider>\n <RelayProvider>\n <BackofficeConfigProvider value={configValue}>\n {props.overlay}\n <BackofficeListUiStateProvider>\n <RouterShell\n routes={routes}\n instrumentations={props.instrumentations}\n />\n </BackofficeListUiStateProvider>\n </BackofficeConfigProvider>\n </RelayProvider>\n </BackofficeThemeProvider>\n );\n }\n\n return (\n <StrictMode>\n <I18nextProvider i18n={i18nInstance}>{contentNode}</I18nextProvider>\n </StrictMode>\n );\n};\n\nexport default BackofficeProvider;\n"],"mappings":";;;;;;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EAAM;EACN;EACA,EAAM;EACN,EAAM;CACR,CAAC,GAEG,IAAc,kBAAC,GAAD,EAA+B,OAAM,aAAc,CAAA;CAmBrE,OAlBI,KAAe,MACjB,IACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAA0B,OAAO;EAAjC,UAAA,CACG,EAAM,SACP,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GACU;GACR,kBAAkB,EAAM;EACzB,CAAA,EAC4B,CAAA,CACP;CACb,CAAA,EAAA,CAAA,EACQ,CAAA,IAK3B,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAAiB,MAAM;EAAe,UAAA;CAA6B,CAAA,EACzD,CAAA;AAEhB"}
|
|
@@ -1,95 +1,98 @@
|
|
|
1
1
|
import { resolveBackofficeLoadedFacetModule as e } from "@plumile/backoffice-core/resolve.js";
|
|
2
2
|
//#region src/provider/entityRegistry.ts
|
|
3
|
-
var t = "cache-first", n = "detail-page", r = "detail-layout", i = "list", a = "picker", o = "tool", s = (e) => e.kind === "list-detail", c = (e) => e.kind === "tool", l = (e, t, r) => t === n ? `${e}:${t}:${r ?? ""}` : `${e}:${t}`, u = (e) => e instanceof Error ? e : Error(String(e)), d = (e) => e?.status !== "loaded" || e.module == null ? null : e.module,
|
|
3
|
+
var t = "cache-first", n = "detail-page", r = "detail-layout", i = "list", a = "picker", o = "tool", s = (e) => e.kind === "list-detail", c = (e) => e.kind === "tool", l = (e, t, r) => t === n ? `${e}:${t}:${r ?? ""}` : `${e}:${t}`, u = (e) => e instanceof Error ? e : Error(String(e)), d = (e, t) => e.kind === t, f = (e, t) => e?.status !== "loaded" || e.module == null ? null : d(e.module, t) ? e.module : null, p = (e, t) => {
|
|
4
4
|
let n = e[t];
|
|
5
5
|
if (n == null) throw Error(`Unknown backoffice entity: ${t}`);
|
|
6
6
|
return n;
|
|
7
|
-
},
|
|
8
|
-
let
|
|
9
|
-
if ((
|
|
10
|
-
let t =
|
|
7
|
+
}, m = (m, h) => {
|
|
8
|
+
let g = /* @__PURE__ */ new Map(), _ = (e) => m[e] ?? null, v = async (e, n, r, i) => {
|
|
9
|
+
if ((r?.mode ?? t) === "cache-first") {
|
|
10
|
+
let t = f(g.get(e), n);
|
|
11
11
|
if (t != null) return t;
|
|
12
|
-
let
|
|
13
|
-
if (
|
|
12
|
+
let r = g.get(e);
|
|
13
|
+
if (r?.status === "loading" && r.promise != null) return r.promise.then((e) => {
|
|
14
|
+
if (!d(e, n)) throw Error(`Cached backoffice facet kind mismatch: ${n}`);
|
|
15
|
+
return e;
|
|
16
|
+
});
|
|
14
17
|
}
|
|
15
|
-
let
|
|
18
|
+
let a = i().then((t) => (g.set(e, {
|
|
16
19
|
status: "loaded",
|
|
17
20
|
module: t
|
|
18
21
|
}), t)).catch((t) => {
|
|
19
22
|
let n = u(t);
|
|
20
|
-
throw
|
|
23
|
+
throw g.set(e, {
|
|
21
24
|
status: "error",
|
|
22
25
|
error: n
|
|
23
26
|
}), n;
|
|
24
27
|
});
|
|
25
|
-
return
|
|
28
|
+
return g.set(e, {
|
|
26
29
|
status: "loading",
|
|
27
|
-
promise:
|
|
28
|
-
}),
|
|
30
|
+
promise: a
|
|
31
|
+
}), a;
|
|
29
32
|
};
|
|
30
33
|
return {
|
|
31
|
-
getManifest:
|
|
32
|
-
getLoadedListEntity: (e) =>
|
|
33
|
-
getLoadedPickerEntity: (e) =>
|
|
34
|
-
getLoadedDetailLayoutEntity: (e) =>
|
|
35
|
-
getLoadedDetailPageEntity: (e, t) =>
|
|
36
|
-
getLoadedToolEntity: (e) =>
|
|
34
|
+
getManifest: _,
|
|
35
|
+
getLoadedListEntity: (e) => f(g.get(l(e, i)), i),
|
|
36
|
+
getLoadedPickerEntity: (e) => f(g.get(l(e, a)), a),
|
|
37
|
+
getLoadedDetailLayoutEntity: (e) => f(g.get(l(e, r)), r),
|
|
38
|
+
getLoadedDetailPageEntity: (e, t) => f(g.get(l(e, n, t)), n),
|
|
39
|
+
getLoadedToolEntity: (e) => f(g.get(l(e, o)), o),
|
|
37
40
|
loadListEntity: async (t, n) => {
|
|
38
|
-
let r =
|
|
41
|
+
let r = p(m, t);
|
|
39
42
|
if (!s(r)) throw Error(`Backoffice entity ${t} does not expose a list facet.`);
|
|
40
43
|
let a = r.facets.list;
|
|
41
44
|
if (a == null) throw Error(`Backoffice entity ${t} does not expose a list facet.`);
|
|
42
|
-
return
|
|
43
|
-
let n = await a(), o = e(r, n,
|
|
45
|
+
return v(l(t, i), i, n, async () => {
|
|
46
|
+
let n = await a(), o = e(r, n, h);
|
|
44
47
|
if (o.kind !== i) throw Error(`Backoffice entity ${t} did not resolve to a list facet.`);
|
|
45
48
|
return o;
|
|
46
49
|
});
|
|
47
50
|
},
|
|
48
51
|
loadPickerEntity: async (t, n) => {
|
|
49
|
-
let r =
|
|
52
|
+
let r = p(m, t);
|
|
50
53
|
if (!s(r)) throw Error(`Backoffice entity ${t} does not expose a picker facet.`);
|
|
51
54
|
let i = r.facets.picker;
|
|
52
55
|
if (i == null) throw Error(`Backoffice entity ${t} does not expose a picker facet.`);
|
|
53
|
-
return
|
|
54
|
-
let n = await i(), o = e(r, n,
|
|
56
|
+
return v(l(t, a), a, n, async () => {
|
|
57
|
+
let n = await i(), o = e(r, n, h);
|
|
55
58
|
if (o.kind !== a) throw Error(`Backoffice entity ${t} did not resolve to a picker facet.`);
|
|
56
59
|
return o;
|
|
57
60
|
});
|
|
58
61
|
},
|
|
59
62
|
loadDetailLayoutEntity: async (t, n) => {
|
|
60
|
-
let i =
|
|
63
|
+
let i = p(m, t);
|
|
61
64
|
if (!s(i)) throw Error(`Backoffice entity ${t} does not expose a detail-layout facet.`);
|
|
62
|
-
return
|
|
63
|
-
let n = await i.facets.detailLayout(), a = e(i, n,
|
|
65
|
+
return v(l(t, r), r, n, async () => {
|
|
66
|
+
let n = await i.facets.detailLayout(), a = e(i, n, h);
|
|
64
67
|
if (a.kind !== r) throw Error(`Backoffice entity ${t} did not resolve to a detail-layout facet.`);
|
|
65
68
|
return a;
|
|
66
69
|
});
|
|
67
70
|
},
|
|
68
71
|
loadDetailPageEntity: async (t, r, i) => {
|
|
69
|
-
let a =
|
|
72
|
+
let a = p(m, t);
|
|
70
73
|
if (!s(a)) throw Error(`Backoffice entity ${t} does not expose a detail-page facet.`);
|
|
71
|
-
return
|
|
72
|
-
let i = await a.facets.detailPage(r), o = e(a, i,
|
|
74
|
+
return v(l(t, n, r), n, i, async () => {
|
|
75
|
+
let i = await a.facets.detailPage(r), o = e(a, i, h);
|
|
73
76
|
if (o.kind !== n) throw Error(`Backoffice entity ${t} did not resolve to a detail-page facet.`);
|
|
74
77
|
return o;
|
|
75
78
|
});
|
|
76
79
|
},
|
|
77
80
|
loadToolEntity: async (t, n) => {
|
|
78
|
-
let r =
|
|
81
|
+
let r = p(m, t);
|
|
79
82
|
if (!c(r)) throw Error(`Backoffice entity ${t} does not expose a tool facet.`);
|
|
80
|
-
return
|
|
81
|
-
let n = await r.facets.tool(), i = e(r, n,
|
|
83
|
+
return v(l(t, o), o, n, async () => {
|
|
84
|
+
let n = await r.facets.tool(), i = e(r, n, h);
|
|
82
85
|
if (i.kind !== o) throw Error(`Backoffice entity ${t} did not resolve to a tool facet.`);
|
|
83
86
|
return i;
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
|
-
},
|
|
90
|
+
}, h = {
|
|
88
91
|
buildFacetCacheKey: l,
|
|
89
|
-
resolveManifest:
|
|
92
|
+
resolveManifest: p,
|
|
90
93
|
toError: u
|
|
91
94
|
};
|
|
92
95
|
//#endregion
|
|
93
|
-
export {
|
|
96
|
+
export { h as __test, m as createBackofficeEntityRegistry, m as default };
|
|
94
97
|
|
|
95
98
|
//# sourceMappingURL=entityRegistry.js.map
|