@headless-adminapp/app 0.0.17-alpha.32 → 0.0.17-alpha.35
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/auth/AuthProvider.js
CHANGED
|
@@ -15,14 +15,7 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
15
15
|
const react_1 = require("react");
|
|
16
16
|
const context_1 = require("../mutable/context");
|
|
17
17
|
const context_2 = require("./context");
|
|
18
|
-
const
|
|
19
|
-
return {
|
|
20
|
-
email: 'demo@example.com',
|
|
21
|
-
fullName: 'Demo User',
|
|
22
|
-
exp: Date.now() / 1000 + 60 * 60 * 24,
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
const AuthProvider = ({ sessionResolver = defaultSessionResolver, onUnauthenticated, children, }) => {
|
|
18
|
+
const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
26
19
|
const onUnauthenticatedRef = (0, react_1.useRef)(onUnauthenticated);
|
|
27
20
|
onUnauthenticatedRef.current = onUnauthenticated;
|
|
28
21
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
@@ -40,9 +33,11 @@ const AuthProvider = ({ sessionResolver = defaultSessionResolver, onUnauthentica
|
|
|
40
33
|
.catch(console.error);
|
|
41
34
|
}, [queryClient]);
|
|
42
35
|
const contextValue = (0, context_1.useCreateContextStore)({
|
|
43
|
-
loading:
|
|
36
|
+
loading: !!sessionResolver,
|
|
44
37
|
loadError: false,
|
|
45
|
-
|
|
38
|
+
authenticated: !sessionResolver,
|
|
39
|
+
initialized: !sessionResolver,
|
|
40
|
+
skipAuthCheck: !sessionResolver,
|
|
46
41
|
loadSession: () => Promise.resolve(),
|
|
47
42
|
onUnauthenticated: onUnauthenticatedInternal,
|
|
48
43
|
});
|
|
@@ -54,6 +49,9 @@ const AuthProvider = ({ sessionResolver = defaultSessionResolver, onUnauthentica
|
|
|
54
49
|
var _a;
|
|
55
50
|
contextValue.setValue({ loading: true, loadError: false });
|
|
56
51
|
try {
|
|
52
|
+
if (!sessionResolverRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
57
55
|
const data = yield sessionResolverRef.current();
|
|
58
56
|
if (!data) {
|
|
59
57
|
contextValue.setValue({
|
package/auth/context.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ interface AuthStoreAuthorizedState<T extends AuthSession = AuthSession> {
|
|
|
16
16
|
export type AuthState = (AuthStoreLoadingState | AuthStoreUnauthorizedState | AuthStoreAuthorizedState) & {
|
|
17
17
|
loading: boolean;
|
|
18
18
|
loadError: boolean;
|
|
19
|
+
skipAuthCheck?: boolean;
|
|
19
20
|
loadSession: () => Promise<void>;
|
|
20
21
|
onUnauthenticated?: (reason: UnauthorizeReason) => void;
|
|
21
22
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsSkipAuthCheck(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsSkipAuthCheck = useIsSkipAuthCheck;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useIsSkipAuthCheck() {
|
|
7
|
+
return (0, mutable_1.useContextSelector)(context_1.AuthContext, (state) => { var _a; return (_a = state.skipAuthCheck) !== null && _a !== void 0 ? _a : false; });
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsightExpereince, InsightLookup } from '@headless-adminapp/core/experience/insights';
|
|
2
|
+
import { SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
export declare function InsightsProvider<SA extends SchemaAttributes = SchemaAttributes>({ children, experience, insightLookup, onInsightSelect, }: PropsWithChildren<{
|
|
5
|
+
experience: InsightExpereince<SA>;
|
|
6
|
+
insightLookup: InsightLookup[];
|
|
7
|
+
onInsightSelect: (id: string) => void;
|
|
8
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsightsProvider = InsightsProvider;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const mutable_1 = require("../mutable");
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
function InsightsProvider({ children, experience, insightLookup, onInsightSelect, }) {
|
|
9
|
+
const onInsightSelectRef = (0, react_1.useRef)(onInsightSelect);
|
|
10
|
+
onInsightSelectRef.current = onInsightSelect;
|
|
11
|
+
const onInsightSelectInternal = (0, react_1.useCallback)((id) => {
|
|
12
|
+
onInsightSelectRef.current(id);
|
|
13
|
+
}, [onInsightSelectRef]);
|
|
14
|
+
const insightsValues = (0, mutable_1.useCreateContextStore)({
|
|
15
|
+
experience,
|
|
16
|
+
data: experience.defaultData,
|
|
17
|
+
insightLookup: insightLookup,
|
|
18
|
+
onInsightSelect: onInsightSelectInternal,
|
|
19
|
+
});
|
|
20
|
+
(0, react_1.useEffect)(() => {
|
|
21
|
+
insightsValues.setValue({
|
|
22
|
+
experience,
|
|
23
|
+
data: experience.defaultData,
|
|
24
|
+
});
|
|
25
|
+
}, [experience, insightLookup]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(context_1.InsightsContext.Provider, { value: insightsValues, children: children }));
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"react-hook-form": "7.52.2",
|
|
40
40
|
"yup": "^1.4.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "2250994fad501c28490b8167c7fca8141323e2b3"
|
|
43
43
|
}
|