@manta-eu/react 0.11.0 → 0.12.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/dist/providers/KnowledgeGraphStateContext.d.ts +2 -2
- package/dist/providers/KnowledgeGraphStateContext.d.ts.map +1 -1
- package/dist/providers/KnowledgeGraphStateProvider.d.ts.map +1 -1
- package/dist/providers/KnowledgeGraphStateProvider.js +8 -49
- package/dist/providers/KnowledgeGraphStateProvider.js.map +1 -1
- package/package.json +7 -7
- package/src/providers/KnowledgeGraphStateContext.ts +2 -2
- package/src/providers/KnowledgeGraphStateProvider.tsx +13 -65
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GQLKnowledgeGraphStateQuery } from "@manta-eu/client";
|
|
2
2
|
import type { KnowledgeGraphAvailability } from "./knowledge-graph-availability.js";
|
|
3
3
|
export declare const KnowledgeGraphStateContext: import("react").Context<KnowledgeGraphStateContextValue | undefined>;
|
|
4
4
|
export type KnowledgeGraphStateContextValue = {
|
|
5
|
-
knowledgeGraphState:
|
|
5
|
+
knowledgeGraphState: GQLKnowledgeGraphStateQuery["knowledgeGraphState"] | null;
|
|
6
6
|
knowledgeGraphAvailability: KnowledgeGraphAvailability | null;
|
|
7
7
|
isKnowledgeGraphUnavailable: boolean;
|
|
8
8
|
isLoading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnowledgeGraphStateContext.d.ts","sourceRoot":"","sources":["../../src/providers/KnowledgeGraphStateContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"KnowledgeGraphStateContext.d.ts","sourceRoot":"","sources":["../../src/providers/KnowledgeGraphStateContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,eAAO,MAAM,0BAA0B,sEAAwE,CAAC;AAEhH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,mBAAmB,EAAE,2BAA2B,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;IAC/E,0BAA0B,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAC9D,2BAA2B,EAAE,OAAO,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,wBAAgB,sBAAsB,IAAI,+BAA+B,CAQxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnowledgeGraphStateProvider.d.ts","sourceRoot":"","sources":["../../src/providers/KnowledgeGraphStateProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KnowledgeGraphStateProvider.d.ts","sourceRoot":"","sources":["../../src/providers/KnowledgeGraphStateProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,MAAM,MAAM,gCAAgC,GAAG;IAC7C,QAAQ,EAAE,SAAS,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,gCAAgC,2CAwFlF"}
|
|
@@ -17,54 +17,13 @@ export function KnowledgeGraphStateProvider(props) {
|
|
|
17
17
|
const pollIntervalMs = useKnowledgeGraphPollInterval();
|
|
18
18
|
const reportedNotProvisionedDatastoreIds = useRef(new Set());
|
|
19
19
|
const [previousDataVersion, setPreviousDataVersion] = useState();
|
|
20
|
-
const
|
|
21
|
-
const { data, isLoading, error } = useKnowledgeGraphStateQuery(mantaClient, { dataVersion: previousDataVersion }, {
|
|
22
|
-
// Keep dataVersion out of the key. It only lets the server skip the triple count, and with one cache
|
|
23
|
-
// entry per version the effect below can bounce between two cached answers forever.
|
|
24
|
-
queryKey: useKnowledgeGraphStateQuery.getKey(),
|
|
20
|
+
const { data, isLoading, error } = useKnowledgeGraphStateQuery(mantaClient, undefined, {
|
|
25
21
|
refetchInterval: pollIntervalMs,
|
|
26
22
|
refetchIntervalInBackground: false,
|
|
27
23
|
staleTime: 0,
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!rawState)
|
|
32
|
-
return;
|
|
33
|
-
const isCachedResponse = rawState.capacity.currentTriples === null &&
|
|
34
|
-
rawState.capacity.percentageFull === null &&
|
|
35
|
-
rawState.capacity.remainingCapacity === null &&
|
|
36
|
-
rawState.capacity.entitySummary === null &&
|
|
37
|
-
rawState.exists;
|
|
38
|
-
if (!isCachedResponse && (rawState.capacity.currentTriples !== null || !rawState.exists)) {
|
|
39
|
-
setCachedCapacity(rawState.capacity);
|
|
40
|
-
}
|
|
41
|
-
}, [data?.knowledgeGraphState]);
|
|
42
|
-
const enrichedKnowledgeGraphState = useMemo(() => {
|
|
43
|
-
const rawState = data?.knowledgeGraphState;
|
|
44
|
-
if (!rawState)
|
|
45
|
-
return null;
|
|
46
|
-
const isCachedResponse = rawState.capacity.currentTriples === null &&
|
|
47
|
-
rawState.capacity.percentageFull === null &&
|
|
48
|
-
rawState.capacity.remainingCapacity === null &&
|
|
49
|
-
rawState.capacity.entitySummary === null &&
|
|
50
|
-
rawState.exists;
|
|
51
|
-
if (isCachedResponse && cachedCapacity) {
|
|
52
|
-
return {
|
|
53
|
-
...rawState,
|
|
54
|
-
capacity: {
|
|
55
|
-
...rawState.capacity,
|
|
56
|
-
currentTriples: cachedCapacity.currentTriples,
|
|
57
|
-
percentageFull: cachedCapacity.percentageFull,
|
|
58
|
-
remainingCapacity: cachedCapacity.remainingCapacity,
|
|
59
|
-
entitySummary: cachedCapacity.entitySummary,
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return rawState;
|
|
65
|
-
}
|
|
66
|
-
}, [data?.knowledgeGraphState, cachedCapacity]);
|
|
67
|
-
const knowledgeGraphAvailability = useMemo(() => (enrichedKnowledgeGraphState ? deriveAvailability(enrichedKnowledgeGraphState) : null), [enrichedKnowledgeGraphState]);
|
|
25
|
+
const knowledgeGraphState = data?.knowledgeGraphState ?? null;
|
|
26
|
+
const knowledgeGraphAvailability = useMemo(() => (knowledgeGraphState ? deriveAvailability(knowledgeGraphState) : null), [knowledgeGraphState]);
|
|
68
27
|
useEffect(function reportNotProvisioned() {
|
|
69
28
|
if (knowledgeGraphAvailability !== "not-provisioned")
|
|
70
29
|
return;
|
|
@@ -85,7 +44,7 @@ export function KnowledgeGraphStateProvider(props) {
|
|
|
85
44
|
},
|
|
86
45
|
});
|
|
87
46
|
useEffect(function bringOnline() {
|
|
88
|
-
if (!
|
|
47
|
+
if (!knowledgeGraphState?.exists || !knowledgeGraphState?.offline)
|
|
89
48
|
return;
|
|
90
49
|
if (bringDataStoreOnline.isPending)
|
|
91
50
|
return;
|
|
@@ -93,8 +52,8 @@ export function KnowledgeGraphStateProvider(props) {
|
|
|
93
52
|
return;
|
|
94
53
|
bringDataStoreOnline.mutate({});
|
|
95
54
|
}, [
|
|
96
|
-
|
|
97
|
-
|
|
55
|
+
knowledgeGraphState?.exists,
|
|
56
|
+
knowledgeGraphState?.offline,
|
|
98
57
|
bringDataStoreOnline.isPending,
|
|
99
58
|
bringDataStoreOnline.mutate,
|
|
100
59
|
datastoreId,
|
|
@@ -111,12 +70,12 @@ export function KnowledgeGraphStateProvider(props) {
|
|
|
111
70
|
}
|
|
112
71
|
}, [data?.knowledgeGraphState?.dataVersion?.uniqueId, queryClient, previousDataVersion]);
|
|
113
72
|
const value = useMemo(() => ({
|
|
114
|
-
knowledgeGraphState
|
|
73
|
+
knowledgeGraphState,
|
|
115
74
|
knowledgeGraphAvailability,
|
|
116
75
|
isKnowledgeGraphUnavailable: isPresent(knowledgeGraphAvailability) && knowledgeGraphAvailability !== "online",
|
|
117
76
|
isLoading,
|
|
118
77
|
error: error,
|
|
119
|
-
}), [
|
|
78
|
+
}), [knowledgeGraphState, knowledgeGraphAvailability, isLoading, error]);
|
|
120
79
|
return _jsx(KnowledgeGraphStateContext.Provider, { value: value, children: children });
|
|
121
80
|
}
|
|
122
81
|
//# sourceMappingURL=KnowledgeGraphStateProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnowledgeGraphStateProvider.js","sourceRoot":"","sources":["../../src/providers/KnowledgeGraphStateProvider.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"KnowledgeGraphStateProvider.js","sourceRoot":"","sources":["../../src/providers/KnowledgeGraphStateProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,+BAA+B,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAO9E,MAAM,UAAU,2BAA2B,CAAC,KAAuC;IACjF,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACxC,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAAC;IACzC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,cAA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G,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,mBAAmB;QACnB,0BAA0B;QAC1B,2BAA2B,EAAE,SAAS,CAAC,0BAA0B,CAAC,IAAI,0BAA0B,KAAK,QAAQ;QAC7G,SAAS;QACT,KAAK,EAAE,KAAqB;KAC7B,CAAC,EACF,CAAC,mBAAmB,EAAE,0BAA0B,EAAE,SAAS,EAAE,KAAK,CAAC,CACpE,CAAC;IAEF,OAAO,KAAC,0BAA0B,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAuC,CAAC;AAC7G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manta-eu/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "The Manta design system, knowledge-graph UI and agent components",
|
|
5
5
|
"homepage": "https://developers.manta.eu",
|
|
6
6
|
"keywords": [
|
|
@@ -1154,12 +1154,12 @@
|
|
|
1154
1154
|
"usehooks-ts": "^3.1.1",
|
|
1155
1155
|
"zod": "^4.6.7",
|
|
1156
1156
|
"zustand": "^5.0.2",
|
|
1157
|
-
"@manta-eu/
|
|
1158
|
-
"@manta-eu/
|
|
1159
|
-
"@manta-eu/
|
|
1160
|
-
"@manta-eu/ldo": "0.
|
|
1161
|
-
"@manta-eu/lib": "0.
|
|
1162
|
-
"@manta-eu/rdf-lib": "0.
|
|
1157
|
+
"@manta-eu/auth": "0.12.0",
|
|
1158
|
+
"@manta-eu/client": "0.12.0",
|
|
1159
|
+
"@manta-eu/datalog-parser": "0.12.0",
|
|
1160
|
+
"@manta-eu/ldo": "0.12.0",
|
|
1161
|
+
"@manta-eu/lib": "0.12.0",
|
|
1162
|
+
"@manta-eu/rdf-lib": "0.12.0"
|
|
1163
1163
|
},
|
|
1164
1164
|
"peerDependencies": {
|
|
1165
1165
|
"@ulb-darmstadt/shacl-form": "^2.1.1-rc1",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GQLKnowledgeGraphStateQuery } from "@manta-eu/client";
|
|
2
2
|
import { createContext, use } from "react";
|
|
3
3
|
import type { KnowledgeGraphAvailability } from "./knowledge-graph-availability";
|
|
4
4
|
|
|
5
5
|
export const KnowledgeGraphStateContext = createContext<KnowledgeGraphStateContextValue | undefined>(undefined);
|
|
6
6
|
|
|
7
7
|
export type KnowledgeGraphStateContextValue = {
|
|
8
|
-
knowledgeGraphState:
|
|
8
|
+
knowledgeGraphState: GQLKnowledgeGraphStateQuery["knowledgeGraphState"] | null;
|
|
9
9
|
knowledgeGraphAvailability: KnowledgeGraphAvailability | null;
|
|
10
10
|
isKnowledgeGraphUnavailable: boolean;
|
|
11
11
|
isLoading: boolean;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { GQLKnowledgeGraphCapacity } from "@manta-eu/client";
|
|
2
1
|
import { useBringDatastoreOnlineMutation, useKnowledgeGraphStateQuery } from "@manta-eu/client";
|
|
3
2
|
import { isPresent } from "@manta-eu/lib/present";
|
|
4
3
|
import { usePostHog } from "@posthog/react";
|
|
@@ -26,67 +25,16 @@ export function KnowledgeGraphStateProvider(props: KnowledgeGraphStateProviderPr
|
|
|
26
25
|
const reportedNotProvisionedDatastoreIds = useRef(new Set<string>());
|
|
27
26
|
|
|
28
27
|
const [previousDataVersion, setPreviousDataVersion] = useState<string>();
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// Keep dataVersion out of the key. It only lets the server skip the triple count, and with one cache
|
|
36
|
-
// entry per version the effect below can bounce between two cached answers forever.
|
|
37
|
-
queryKey: useKnowledgeGraphStateQuery.getKey(),
|
|
38
|
-
refetchInterval: pollIntervalMs,
|
|
39
|
-
refetchIntervalInBackground: false,
|
|
40
|
-
staleTime: 0,
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const rawState = data?.knowledgeGraphState;
|
|
46
|
-
if (!rawState) return;
|
|
47
|
-
|
|
48
|
-
const isCachedResponse =
|
|
49
|
-
rawState.capacity.currentTriples === null &&
|
|
50
|
-
rawState.capacity.percentageFull === null &&
|
|
51
|
-
rawState.capacity.remainingCapacity === null &&
|
|
52
|
-
rawState.capacity.entitySummary === null &&
|
|
53
|
-
rawState.exists;
|
|
54
|
-
|
|
55
|
-
if (!isCachedResponse && (rawState.capacity.currentTriples !== null || !rawState.exists)) {
|
|
56
|
-
setCachedCapacity(rawState.capacity);
|
|
57
|
-
}
|
|
58
|
-
}, [data?.knowledgeGraphState]);
|
|
59
|
-
|
|
60
|
-
const enrichedKnowledgeGraphState = useMemo(() => {
|
|
61
|
-
const rawState = data?.knowledgeGraphState;
|
|
62
|
-
if (!rawState) return null;
|
|
63
|
-
|
|
64
|
-
const isCachedResponse =
|
|
65
|
-
rawState.capacity.currentTriples === null &&
|
|
66
|
-
rawState.capacity.percentageFull === null &&
|
|
67
|
-
rawState.capacity.remainingCapacity === null &&
|
|
68
|
-
rawState.capacity.entitySummary === null &&
|
|
69
|
-
rawState.exists;
|
|
70
|
-
|
|
71
|
-
if (isCachedResponse && cachedCapacity) {
|
|
72
|
-
return {
|
|
73
|
-
...rawState,
|
|
74
|
-
capacity: {
|
|
75
|
-
...rawState.capacity,
|
|
76
|
-
currentTriples: cachedCapacity.currentTriples,
|
|
77
|
-
percentageFull: cachedCapacity.percentageFull,
|
|
78
|
-
remainingCapacity: cachedCapacity.remainingCapacity,
|
|
79
|
-
entitySummary: cachedCapacity.entitySummary,
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
} else {
|
|
83
|
-
return rawState;
|
|
84
|
-
}
|
|
85
|
-
}, [data?.knowledgeGraphState, cachedCapacity]);
|
|
28
|
+
const { data, isLoading, error } = useKnowledgeGraphStateQuery(mantaClient, undefined, {
|
|
29
|
+
refetchInterval: pollIntervalMs,
|
|
30
|
+
refetchIntervalInBackground: false,
|
|
31
|
+
staleTime: 0,
|
|
32
|
+
});
|
|
33
|
+
const knowledgeGraphState = data?.knowledgeGraphState ?? null;
|
|
86
34
|
|
|
87
35
|
const knowledgeGraphAvailability = useMemo(
|
|
88
|
-
() => (
|
|
89
|
-
[
|
|
36
|
+
() => (knowledgeGraphState ? deriveAvailability(knowledgeGraphState) : null),
|
|
37
|
+
[knowledgeGraphState],
|
|
90
38
|
);
|
|
91
39
|
|
|
92
40
|
useEffect(
|
|
@@ -115,15 +63,15 @@ export function KnowledgeGraphStateProvider(props: KnowledgeGraphStateProviderPr
|
|
|
115
63
|
|
|
116
64
|
useEffect(
|
|
117
65
|
function bringOnline() {
|
|
118
|
-
if (!
|
|
66
|
+
if (!knowledgeGraphState?.exists || !knowledgeGraphState?.offline) return;
|
|
119
67
|
if (bringDataStoreOnline.isPending) return;
|
|
120
68
|
if (datastoreId && bringOnlineRefusedFor.current.has(datastoreId)) return;
|
|
121
69
|
|
|
122
70
|
bringDataStoreOnline.mutate({});
|
|
123
71
|
},
|
|
124
72
|
[
|
|
125
|
-
|
|
126
|
-
|
|
73
|
+
knowledgeGraphState?.exists,
|
|
74
|
+
knowledgeGraphState?.offline,
|
|
127
75
|
bringDataStoreOnline.isPending,
|
|
128
76
|
bringDataStoreOnline.mutate,
|
|
129
77
|
datastoreId,
|
|
@@ -146,13 +94,13 @@ export function KnowledgeGraphStateProvider(props: KnowledgeGraphStateProviderPr
|
|
|
146
94
|
|
|
147
95
|
const value = useMemo<KnowledgeGraphStateContextValue>(
|
|
148
96
|
() => ({
|
|
149
|
-
knowledgeGraphState
|
|
97
|
+
knowledgeGraphState,
|
|
150
98
|
knowledgeGraphAvailability,
|
|
151
99
|
isKnowledgeGraphUnavailable: isPresent(knowledgeGraphAvailability) && knowledgeGraphAvailability !== "online",
|
|
152
100
|
isLoading,
|
|
153
101
|
error: error as Error | null,
|
|
154
102
|
}),
|
|
155
|
-
[
|
|
103
|
+
[knowledgeGraphState, knowledgeGraphAvailability, isLoading, error],
|
|
156
104
|
);
|
|
157
105
|
|
|
158
106
|
return <KnowledgeGraphStateContext.Provider value={value}>{children}</KnowledgeGraphStateContext.Provider>;
|