nucleus-core-ts 0.9.849 → 0.9.850
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/fe/components/IntegrationsPage/components/ConnectionForm.js +4 -1
- package/dist/fe/components/IntegrationsPage/components/ConnectionList.js +16 -2
- package/dist/fe/components/IntegrationsPage/components/ConnectionSettingsTab.js +15 -7
- package/dist/fe/components/IntegrationsPage/components/EndpointList.js +16 -2
- package/dist/fe/components/IntegrationsPage/components/MappingList.js +16 -2
- package/dist/fe/components/IntegrationsPage/components/RunHistory.js +15 -2
- package/dist/fe/components/IntegrationsPage/components/RunPanel.js +19 -2
- package/dist/fe/components/IntegrationsPage/components/useInfiniteList.d.ts +13 -0
- package/dist/fe/components/IntegrationsPage/components/useInfiniteList.js +7 -0
- package/dist/fe/components/IntegrationsPage/store/index.js +17 -2
- package/package.json +1 -1
|
@@ -54,11 +54,14 @@ export function ConnectionForm({ actions, source, loading = false, onSaved }) {
|
|
|
54
54
|
store.setError('The connection was not saved. The server did not return the record.');
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
+
// Told about the record BEFORE it is selected. The caller is what puts
|
|
58
|
+
// it into the list, and selecting an id the list does not hold is the
|
|
59
|
+
// state every card below renders a skeleton for.
|
|
60
|
+
onSaved?.(saved);
|
|
57
61
|
// Selecting resets everything hanging off a connection, so it is only
|
|
58
62
|
// right for a NEW one — doing it on an edit would empty the endpoint,
|
|
59
63
|
// mapping and run lists the operator is working in.
|
|
60
64
|
if (!source) store.selectSource(saved.id);
|
|
61
|
-
onSaved?.(saved);
|
|
62
65
|
}).catch((reason)=>{
|
|
63
66
|
setSaving(false);
|
|
64
67
|
store.setError(errorText(reason, 'The connection could not be saved.'));
|
|
@@ -59,17 +59,31 @@ export function ConnectionList({ actions, onNewConnection, reloadToken = 0 }) {
|
|
|
59
59
|
const publishLoading = useEffectEvent(()=>{
|
|
60
60
|
store.setSourcesLoading(list.loading);
|
|
61
61
|
});
|
|
62
|
+
// Only what the SERVER said. A reset empties the hook's items before the
|
|
63
|
+
// first page is asked for, and publishing that emptied the shared store —
|
|
64
|
+
// which is where the editor looks for the record it is editing. Saving
|
|
65
|
+
// triggers a reset, so saving is when the record vanished.
|
|
62
66
|
useEffect(()=>{
|
|
63
|
-
publishItems();
|
|
67
|
+
if (list.settled) publishItems();
|
|
64
68
|
}, [
|
|
65
69
|
list.items,
|
|
66
|
-
list.total
|
|
70
|
+
list.total,
|
|
71
|
+
list.settled
|
|
67
72
|
]);
|
|
68
73
|
useEffect(()=>{
|
|
69
74
|
publishLoading();
|
|
70
75
|
}, [
|
|
71
76
|
list.loading
|
|
72
77
|
]);
|
|
78
|
+
// Handed back on the way out. This flag has exactly one writer — this
|
|
79
|
+
// component — and unmounting mid-request left it true with nobody able to
|
|
80
|
+
// clear it, so whatever else reads it showed a skeleton for a request that
|
|
81
|
+
// had already finished.
|
|
82
|
+
useEffect(()=>{
|
|
83
|
+
return ()=>{
|
|
84
|
+
store.setSourcesLoading(false);
|
|
85
|
+
};
|
|
86
|
+
}, []);
|
|
73
87
|
const handleNew = ()=>{
|
|
74
88
|
store.selectSource(null);
|
|
75
89
|
onNewConnection?.();
|
|
@@ -22,27 +22,35 @@ import { CredentialFields } from './CredentialFields';
|
|
|
22
22
|
*/ export function ConnectionSettingsTab({ actions, onSaved, onDeleted }) {
|
|
23
23
|
const store = useIntegrationsStore();
|
|
24
24
|
const source = store.sources.find((candidate)=>candidate.id === store.selectedSourceId) ?? null;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Waiting for THIS record, and nothing else.
|
|
27
|
+
*
|
|
28
|
+
* It used to be `store.sourcesLoading || missingFromPage`, and sourcesLoading
|
|
29
|
+
* is true whenever the rail is fetching ANY page — including a page fetched
|
|
30
|
+
* because somebody typed a letter into the search box. With no connection
|
|
31
|
+
* chosen this tab is the blank "new connection" form, and every keystroke in
|
|
32
|
+
* the rail beside it replaced that form with skeletons.
|
|
33
|
+
*
|
|
34
|
+
* A form that is not editing a record is never loading: there is nothing to
|
|
35
|
+
* wait for. A form that IS editing one waits only until that record is here.
|
|
36
|
+
*/ const waitingForRecord = store.selectedSourceId !== null && source === null;
|
|
29
37
|
return /*#__PURE__*/ _jsxs("div", {
|
|
30
38
|
className: theme.layout.main,
|
|
31
39
|
children: [
|
|
32
40
|
/*#__PURE__*/ _jsx(ConnectionForm, {
|
|
33
41
|
actions: actions,
|
|
34
|
-
loading:
|
|
42
|
+
loading: waitingForRecord,
|
|
35
43
|
onSaved: onSaved,
|
|
36
44
|
source: source
|
|
37
45
|
}),
|
|
38
46
|
/*#__PURE__*/ _jsx(CredentialFields, {
|
|
39
47
|
actions: actions,
|
|
40
|
-
loading:
|
|
48
|
+
loading: waitingForRecord,
|
|
41
49
|
source: source
|
|
42
50
|
}),
|
|
43
51
|
/*#__PURE__*/ _jsx(ConnectionTest, {
|
|
44
52
|
actions: actions,
|
|
45
|
-
loading:
|
|
53
|
+
loading: waitingForRecord,
|
|
46
54
|
source: source
|
|
47
55
|
}),
|
|
48
56
|
/*#__PURE__*/ _jsx(ConnectionDelete, {
|
|
@@ -72,17 +72,31 @@ export function EndpointList({ sourceId, actions, onNewEndpoint, onSelect, reloa
|
|
|
72
72
|
const publishLoading = useEffectEvent(()=>{
|
|
73
73
|
store.setEndpointsLoading(list.loading);
|
|
74
74
|
});
|
|
75
|
+
// Only what the SERVER said. A reset empties the hook's items before the
|
|
76
|
+
// first page is asked for, and publishing that emptied the shared store —
|
|
77
|
+
// which is where the editor looks for the record it is editing. Saving
|
|
78
|
+
// triggers a reset, so saving is when the record vanished.
|
|
75
79
|
useEffect(()=>{
|
|
76
|
-
publishItems();
|
|
80
|
+
if (list.settled) publishItems();
|
|
77
81
|
}, [
|
|
78
82
|
list.items,
|
|
79
|
-
list.total
|
|
83
|
+
list.total,
|
|
84
|
+
list.settled
|
|
80
85
|
]);
|
|
81
86
|
useEffect(()=>{
|
|
82
87
|
publishLoading();
|
|
83
88
|
}, [
|
|
84
89
|
list.loading
|
|
85
90
|
]);
|
|
91
|
+
// Handed back on the way out. This flag has exactly one writer — this
|
|
92
|
+
// component — and unmounting mid-request left it true with nobody able to
|
|
93
|
+
// clear it, so whatever else reads it showed a skeleton for a request that
|
|
94
|
+
// had already finished.
|
|
95
|
+
useEffect(()=>{
|
|
96
|
+
return ()=>{
|
|
97
|
+
store.setEndpointsLoading(false);
|
|
98
|
+
};
|
|
99
|
+
}, []);
|
|
86
100
|
const handleNew = ()=>{
|
|
87
101
|
store.selectEndpoint(null);
|
|
88
102
|
onNewEndpoint?.();
|
|
@@ -83,17 +83,31 @@ export function MappingList({ actions, sourceId, selectedId, reloadToken, onSele
|
|
|
83
83
|
const publishLoading = useEffectEvent(()=>{
|
|
84
84
|
store.setMappingsLoading(list.loading);
|
|
85
85
|
});
|
|
86
|
+
// Only what the SERVER said. A reset empties the hook's items before the
|
|
87
|
+
// first page is asked for, and publishing that emptied the shared store —
|
|
88
|
+
// which is where the editor looks for the record it is editing. Saving
|
|
89
|
+
// triggers a reset, so saving is when the record vanished.
|
|
86
90
|
useEffect(()=>{
|
|
87
|
-
publishItems();
|
|
91
|
+
if (list.settled) publishItems();
|
|
88
92
|
}, [
|
|
89
93
|
list.items,
|
|
90
|
-
list.total
|
|
94
|
+
list.total,
|
|
95
|
+
list.settled
|
|
91
96
|
]);
|
|
92
97
|
useEffect(()=>{
|
|
93
98
|
publishLoading();
|
|
94
99
|
}, [
|
|
95
100
|
list.loading
|
|
96
101
|
]);
|
|
102
|
+
// Handed back on the way out. This flag has exactly one writer — this
|
|
103
|
+
// component — and unmounting mid-request left it true with nobody able to
|
|
104
|
+
// clear it, so whatever else reads it showed a skeleton for a request that
|
|
105
|
+
// had already finished.
|
|
106
|
+
useEffect(()=>{
|
|
107
|
+
return ()=>{
|
|
108
|
+
store.setMappingsLoading(false);
|
|
109
|
+
};
|
|
110
|
+
}, []);
|
|
97
111
|
const showSkeleton = list.loading && list.items.length === 0;
|
|
98
112
|
return /*#__PURE__*/ _jsxs("section", {
|
|
99
113
|
className: "flex flex-col gap-3",
|
|
@@ -51,17 +51,30 @@ export function RunHistory({ actions, mappingId, refreshKey, onRefresh }) {
|
|
|
51
51
|
const publishLoading = useEffectEvent(()=>{
|
|
52
52
|
store.setRunsLoading(list.loading);
|
|
53
53
|
});
|
|
54
|
+
// Only what the SERVER said — see the same guard on the other three lists: a
|
|
55
|
+
// reset empties the hook's items before the first page is asked for, and
|
|
56
|
+
// publishing that emptied the shared store.
|
|
54
57
|
useEffect(()=>{
|
|
55
|
-
publishRuns();
|
|
58
|
+
if (list.settled) publishRuns();
|
|
56
59
|
}, [
|
|
57
60
|
list.items,
|
|
58
|
-
list.total
|
|
61
|
+
list.total,
|
|
62
|
+
list.settled
|
|
59
63
|
]);
|
|
60
64
|
useEffect(()=>{
|
|
61
65
|
publishLoading();
|
|
62
66
|
}, [
|
|
63
67
|
list.loading
|
|
64
68
|
]);
|
|
69
|
+
// Handed back on the way out. This flag has exactly one writer — this
|
|
70
|
+
// component — and unmounting mid-request left it true with nobody able to
|
|
71
|
+
// clear it, so whatever else reads it showed a skeleton for a request that
|
|
72
|
+
// had already finished.
|
|
73
|
+
useEffect(()=>{
|
|
74
|
+
return ()=>{
|
|
75
|
+
store.setRunsLoading(false);
|
|
76
|
+
};
|
|
77
|
+
}, []);
|
|
65
78
|
const firstPagePending = list.loading && list.items.length === 0;
|
|
66
79
|
return /*#__PURE__*/ _jsxs("section", {
|
|
67
80
|
className: theme.card.wrapper,
|
|
@@ -66,11 +66,16 @@ export function RunPanel({ mapping, actions, onSubscribeProgress, onRunSettled }
|
|
|
66
66
|
setConfirming(true);
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
+
// A refusal ENDS the confirmation. Left standing, the panel kept asking
|
|
70
|
+
// "are you sure?" about an import the server had already turned down,
|
|
71
|
+
// and pressing the confirm button again just collected the same refusal.
|
|
69
72
|
if (result.error) {
|
|
73
|
+
setConfirming(false);
|
|
70
74
|
store.setError(result.error);
|
|
71
75
|
return;
|
|
72
76
|
}
|
|
73
77
|
if (!result.runId) {
|
|
78
|
+
setConfirming(false);
|
|
74
79
|
store.setError('The import was accepted but no run id came back, so it cannot be tracked.');
|
|
75
80
|
return;
|
|
76
81
|
}
|
|
@@ -80,6 +85,7 @@ export function RunPanel({ mapping, actions, onSubscribeProgress, onRunSettled }
|
|
|
80
85
|
store.setActiveRun(result.runId);
|
|
81
86
|
}).catch((error)=>{
|
|
82
87
|
setStarting(false);
|
|
88
|
+
setConfirming(false);
|
|
83
89
|
store.setError(errorText(error, 'The import could not be started.'));
|
|
84
90
|
});
|
|
85
91
|
};
|
|
@@ -120,10 +126,21 @@ export function RunPanel({ mapping, actions, onSubscribeProgress, onRunSettled }
|
|
|
120
126
|
*/ const pollActiveRun = useEffectEvent(()=>{
|
|
121
127
|
const runId = store.activeRunId;
|
|
122
128
|
if (!runId) return;
|
|
123
|
-
actions.
|
|
129
|
+
actions// NEWEST first, explicitly. Without a sort the server answers in its own
|
|
130
|
+
// order — which is the order the rows were written — so from the sixth
|
|
131
|
+
// import of a mapping onwards the run being watched was not among the
|
|
132
|
+
// five that came back. The tick below then found nothing, returned, and
|
|
133
|
+
// left the progress bar running for an import that had already finished.
|
|
134
|
+
.listRuns({
|
|
124
135
|
mappingId: mapping.id,
|
|
125
136
|
page: 1,
|
|
126
|
-
limit: 5
|
|
137
|
+
limit: 5,
|
|
138
|
+
sort: [
|
|
139
|
+
{
|
|
140
|
+
field: 'createdAt',
|
|
141
|
+
direction: 'desc'
|
|
142
|
+
}
|
|
143
|
+
]
|
|
127
144
|
}).then((result)=>{
|
|
128
145
|
if (store.activeRunId !== runId) return;
|
|
129
146
|
const run = result.items.find((item)=>item.id === runId);
|
|
@@ -33,6 +33,19 @@ export type UseInfiniteListResult<T> = {
|
|
|
33
33
|
* hook reports the failure and the caller must show it.
|
|
34
34
|
*/
|
|
35
35
|
error: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Whether what `items` holds has actually come back from the server.
|
|
38
|
+
*
|
|
39
|
+
* A reset empties `items` BEFORE the first page is asked for, and callers
|
|
40
|
+
* mirror `items` into the shared store — so every refetch published an empty
|
|
41
|
+
* page, and whatever was reading that store lost the record it was showing.
|
|
42
|
+
* Saving is what triggers a refetch, which is why saving is when it was seen:
|
|
43
|
+
* the editor asked the store for the record it had just saved and the store
|
|
44
|
+
* had been emptied a moment earlier.
|
|
45
|
+
*
|
|
46
|
+
* False from a reset until the first page settles, success or failure.
|
|
47
|
+
*/
|
|
48
|
+
settled: boolean;
|
|
36
49
|
/** Put this on an element after the last row; seeing it asks for the next page. */
|
|
37
50
|
sentinelRef: RefObject<HTMLDivElement | null>;
|
|
38
51
|
reload: () => void;
|
|
@@ -17,6 +17,7 @@ export function useInfiniteList(options) {
|
|
|
17
17
|
const [loading, setLoading] = useState(true);
|
|
18
18
|
const [error, setError] = useState(null);
|
|
19
19
|
const [reloadToken, setReloadToken] = useState(0);
|
|
20
|
+
const [settled, setSettled] = useState(false);
|
|
20
21
|
const sentinelRef = useRef(null);
|
|
21
22
|
const nextPageRef = useRef(1);
|
|
22
23
|
const loadedCountRef = useRef(0);
|
|
@@ -32,6 +33,7 @@ export function useInfiniteList(options) {
|
|
|
32
33
|
if (generation !== generationRef.current) return;
|
|
33
34
|
inFlightRef.current = false;
|
|
34
35
|
setLoading(false);
|
|
36
|
+
setSettled(true);
|
|
35
37
|
setTotal(result.total);
|
|
36
38
|
setItems((previous)=>page === 1 ? result.items : [
|
|
37
39
|
...previous,
|
|
@@ -47,6 +49,9 @@ export function useInfiniteList(options) {
|
|
|
47
49
|
if (generation !== generationRef.current) return;
|
|
48
50
|
inFlightRef.current = false;
|
|
49
51
|
setLoading(false);
|
|
52
|
+
// Settled, even though it failed: the caller must be free to show the
|
|
53
|
+
// error instead of waiting on a page that is never coming.
|
|
54
|
+
setSettled(true);
|
|
50
55
|
setError(reason instanceof Error ? reason.message : String(reason));
|
|
51
56
|
// Stop asking. The sentinel stays on screen, so retrying on failure
|
|
52
57
|
// would hammer a broken endpoint for as long as the panel is open;
|
|
@@ -67,6 +72,7 @@ export function useInfiniteList(options) {
|
|
|
67
72
|
setItems([]);
|
|
68
73
|
setTotal(0);
|
|
69
74
|
setLoading(true);
|
|
75
|
+
setSettled(false);
|
|
70
76
|
setError(null);
|
|
71
77
|
fetchPage(1);
|
|
72
78
|
return ()=>{
|
|
@@ -103,6 +109,7 @@ export function useInfiniteList(options) {
|
|
|
103
109
|
items,
|
|
104
110
|
total,
|
|
105
111
|
loading,
|
|
112
|
+
settled,
|
|
106
113
|
error,
|
|
107
114
|
sentinelRef,
|
|
108
115
|
reload
|
|
@@ -39,13 +39,24 @@ export const { useStore: useIntegrationsStore } = createStore(initial, {
|
|
|
39
39
|
store.tab = 'connection';
|
|
40
40
|
store.endpoints = [];
|
|
41
41
|
store.endpointsTotal = 0;
|
|
42
|
-
store.endpointsPage = 1;
|
|
43
42
|
store.endpointsSearch = '';
|
|
44
43
|
store.selectedEndpointId = null;
|
|
45
44
|
store.mappings = [];
|
|
46
45
|
store.mappingsTotal = 0;
|
|
47
|
-
store.mappingsPage = 1;
|
|
48
46
|
store.mappingsSearch = '';
|
|
47
|
+
// Every WAIT below a connection ends with it too. These are the flags the
|
|
48
|
+
// cards read to decide between a skeleton and their content, and their
|
|
49
|
+
// only writers live under the connection being left — so leaving one set
|
|
50
|
+
// meant the next connection opened onto a skeleton with nothing running.
|
|
51
|
+
store.endpointsLoading = false;
|
|
52
|
+
store.mappingsLoading = false;
|
|
53
|
+
store.runsLoading = false;
|
|
54
|
+
store.sample = null;
|
|
55
|
+
store.sampling = false;
|
|
56
|
+
store.plan = null;
|
|
57
|
+
store.planning = false;
|
|
58
|
+
store.activeRunId = null;
|
|
59
|
+
store.progress = null;
|
|
49
60
|
store.selectedMappingId = null;
|
|
50
61
|
store.runs = [];
|
|
51
62
|
store.runsTotal = 0;
|
|
@@ -127,6 +138,10 @@ export const { useStore: useIntegrationsStore } = createStore(initial, {
|
|
|
127
138
|
// A plan belongs to the mapping it was computed for. Showing it against a
|
|
128
139
|
// different one would have an operator approve counts from another import.
|
|
129
140
|
store.plan = null;
|
|
141
|
+
// And the WAIT for a plan goes with it. Discarding the plan while leaving
|
|
142
|
+
// this set put the next mapping's panel on a counting skeleton for a
|
|
143
|
+
// preview that had been computed for a different mapping and thrown away.
|
|
144
|
+
store.planning = false;
|
|
130
145
|
// And so does a RUN, which says something stronger than a plan does: that
|
|
131
146
|
// this import happened. Seen live — the Ünvanlar run stayed on screen
|
|
132
147
|
// under a header reading "Writes into locations", for a mapping that had
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.850",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|