nucleus-core-ts 0.9.818 → 0.9.819
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.
|
@@ -93,6 +93,46 @@ export function RunPanel({ mapping, actions, onSubscribeProgress, onRunSettled }
|
|
|
93
93
|
onRunSettled?.();
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
+
/**
|
|
97
|
+
* Ask the server whether the run has finished.
|
|
98
|
+
*
|
|
99
|
+
* Progress frames are PUSHED — over whatever realtime channel the app wires
|
|
100
|
+
* up — and an app that wires none, or a socket that drops, leaves this panel
|
|
101
|
+
* saying "waiting for the first update" over an import that finished minutes
|
|
102
|
+
* ago, with a Cancel button for a run that is not running. The bar was the
|
|
103
|
+
* only thing on screen and it was lying.
|
|
104
|
+
*
|
|
105
|
+
* So the run's own row is the authority: it is polled while one is active, it
|
|
106
|
+
* settles the panel when the status is terminal, and it says what happened.
|
|
107
|
+
* Realtime stays the fast path and is no longer the only one.
|
|
108
|
+
*/ const pollActiveRun = useEffectEvent(()=>{
|
|
109
|
+
const runId = store.activeRunId;
|
|
110
|
+
if (!runId) return;
|
|
111
|
+
actions.listRuns({
|
|
112
|
+
mappingId: mapping.id,
|
|
113
|
+
page: 1,
|
|
114
|
+
limit: 5
|
|
115
|
+
}).then((result)=>{
|
|
116
|
+
if (store.activeRunId !== runId) return;
|
|
117
|
+
const run = result.items.find((item)=>item.id === runId);
|
|
118
|
+
if (!run || run.status === 'running' || run.status === 'queued') return;
|
|
119
|
+
store.setActiveRun(null);
|
|
120
|
+
store.setProgress(null);
|
|
121
|
+
if (run.status === 'failed') {
|
|
122
|
+
store.setError(run.errors?.[0] ?? 'The import failed. Its history entry has the detail.');
|
|
123
|
+
}
|
|
124
|
+
onRunSettled?.();
|
|
125
|
+
}).catch(()=>{
|
|
126
|
+
// A failed poll is not a failed run. The next tick asks again.
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
useEffect(()=>{
|
|
130
|
+
if (!activeRunId) return;
|
|
131
|
+
const timer = setInterval(pollActiveRun, 2000);
|
|
132
|
+
return ()=>clearInterval(timer);
|
|
133
|
+
}, [
|
|
134
|
+
activeRunId
|
|
135
|
+
]);
|
|
96
136
|
const openProgressStream = useEffectEvent(()=>onSubscribeProgress?.(applyProgress));
|
|
97
137
|
useEffect(()=>{
|
|
98
138
|
// The app hands back its own unsubscribe; returning it is the cleanup.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.819",
|
|
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",
|