@bpmnkit/operate 0.0.5
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 +131 -0
- package/dist/components/badge.d.ts +2 -0
- package/dist/components/badge.js +2 -0
- package/dist/components/card.d.ts +2 -0
- package/dist/components/card.js +2 -0
- package/dist/components/chart.d.ts +6 -0
- package/dist/components/chart.js +161 -0
- package/dist/components/filter-table.d.ts +20 -0
- package/dist/components/filter-table.js +215 -0
- package/dist/components/table.d.ts +2 -0
- package/dist/components/table.js +2 -0
- package/dist/css.d.ts +2 -0
- package/dist/css.js +1071 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/mock-data.d.ts +18 -0
- package/dist/mock-data.js +509 -0
- package/dist/operate.d.ts +3 -0
- package/dist/operate.js +308 -0
- package/dist/router.d.ts +9 -0
- package/dist/router.js +49 -0
- package/dist/stores/base.d.ts +20 -0
- package/dist/stores/base.js +32 -0
- package/dist/stores/dashboard.d.ts +6 -0
- package/dist/stores/dashboard.js +19 -0
- package/dist/stores/decisions.d.ts +9 -0
- package/dist/stores/decisions.js +19 -0
- package/dist/stores/definitions.d.ts +9 -0
- package/dist/stores/definitions.js +19 -0
- package/dist/stores/incidents.d.ts +10 -0
- package/dist/stores/incidents.js +27 -0
- package/dist/stores/instances.d.ts +15 -0
- package/dist/stores/instances.js +33 -0
- package/dist/stores/jobs.d.ts +10 -0
- package/dist/stores/jobs.js +19 -0
- package/dist/stores/tasks.d.ts +10 -0
- package/dist/stores/tasks.js +19 -0
- package/dist/stream.d.ts +12 -0
- package/dist/stream.js +42 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.js +2 -0
- package/dist/views/dashboard.d.ts +6 -0
- package/dist/views/dashboard.js +98 -0
- package/dist/views/decision-detail.d.ts +15 -0
- package/dist/views/decision-detail.js +167 -0
- package/dist/views/decisions.d.ts +7 -0
- package/dist/views/decisions.js +78 -0
- package/dist/views/definition-detail.d.ts +15 -0
- package/dist/views/definition-detail.js +339 -0
- package/dist/views/definitions.d.ts +7 -0
- package/dist/views/definitions.js +70 -0
- package/dist/views/header.d.ts +9 -0
- package/dist/views/header.js +49 -0
- package/dist/views/incident-detail.d.ts +14 -0
- package/dist/views/incident-detail.js +540 -0
- package/dist/views/incidents.d.ts +7 -0
- package/dist/views/incidents.js +108 -0
- package/dist/views/instance-detail.d.ts +16 -0
- package/dist/views/instance-detail.js +728 -0
- package/dist/views/instances.d.ts +7 -0
- package/dist/views/instances.js +249 -0
- package/dist/views/jobs.d.ts +6 -0
- package/dist/views/jobs.js +60 -0
- package/dist/views/messages.d.ts +11 -0
- package/dist/views/messages.js +431 -0
- package/dist/views/nav.d.ts +10 -0
- package/dist/views/nav.js +60 -0
- package/dist/views/task-detail.d.ts +13 -0
- package/dist/views/task-detail.js +187 -0
- package/dist/views/tasks.d.ts +7 -0
- package/dist/views/tasks.js +72 -0
- package/package.json +46 -0
package/dist/operate.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { applyTheme, injectUiStyles, loadPersistedTheme } from "@bpmnkit/ui";
|
|
2
|
+
import { injectOperateStyles } from "./css.js";
|
|
3
|
+
import { createRouter } from "./router.js";
|
|
4
|
+
import { DashboardStore } from "./stores/dashboard.js";
|
|
5
|
+
import { DecisionsStore } from "./stores/decisions.js";
|
|
6
|
+
import { DefinitionsStore } from "./stores/definitions.js";
|
|
7
|
+
import { IncidentsStore } from "./stores/incidents.js";
|
|
8
|
+
import { InstancesStore } from "./stores/instances.js";
|
|
9
|
+
import { JobsStore } from "./stores/jobs.js";
|
|
10
|
+
import { TasksStore } from "./stores/tasks.js";
|
|
11
|
+
import { createDashboardView } from "./views/dashboard.js";
|
|
12
|
+
import { createDecisionDetailView } from "./views/decision-detail.js";
|
|
13
|
+
import { createDecisionsView } from "./views/decisions.js";
|
|
14
|
+
import { createDefinitionDetailView } from "./views/definition-detail.js";
|
|
15
|
+
import { createDefinitionsView } from "./views/definitions.js";
|
|
16
|
+
import { createHeader } from "./views/header.js";
|
|
17
|
+
import { createIncidentDetailView } from "./views/incident-detail.js";
|
|
18
|
+
import { createIncidentsView } from "./views/incidents.js";
|
|
19
|
+
import { createInstanceDetailView } from "./views/instance-detail.js";
|
|
20
|
+
import { createInstancesView } from "./views/instances.js";
|
|
21
|
+
import { createJobsView } from "./views/jobs.js";
|
|
22
|
+
import { createMessagesView } from "./views/messages.js";
|
|
23
|
+
import { createNav } from "./views/nav.js";
|
|
24
|
+
import { createTaskDetailView } from "./views/task-detail.js";
|
|
25
|
+
import { createTasksView } from "./views/tasks.js";
|
|
26
|
+
export function createOperate(options) {
|
|
27
|
+
injectUiStyles();
|
|
28
|
+
injectOperateStyles();
|
|
29
|
+
const { container, proxyUrl = "http://localhost:3033", pollInterval = 30_000, mock = false, } = options;
|
|
30
|
+
let profile = options.profile ?? null;
|
|
31
|
+
const initialTheme = loadPersistedTheme() ?? options.theme ?? "auto";
|
|
32
|
+
// ── Root element ──────────────────────────────────────────────────────────
|
|
33
|
+
const el = document.createElement("div");
|
|
34
|
+
el.className = "op-root";
|
|
35
|
+
applyTheme(el, initialTheme);
|
|
36
|
+
container.appendChild(el);
|
|
37
|
+
// ── Stores ────────────────────────────────────────────────────────────────
|
|
38
|
+
const dashStore = new DashboardStore();
|
|
39
|
+
const defStore = new DefinitionsStore();
|
|
40
|
+
const decStore = new DecisionsStore();
|
|
41
|
+
const instStore = new InstancesStore();
|
|
42
|
+
const incStore = new IncidentsStore();
|
|
43
|
+
const jobStore = new JobsStore();
|
|
44
|
+
const taskStore = new TasksStore();
|
|
45
|
+
function disconnectAll() {
|
|
46
|
+
dashStore.disconnect();
|
|
47
|
+
defStore.disconnect();
|
|
48
|
+
decStore.disconnect();
|
|
49
|
+
instStore.disconnect();
|
|
50
|
+
incStore.disconnect();
|
|
51
|
+
jobStore.disconnect();
|
|
52
|
+
taskStore.disconnect();
|
|
53
|
+
}
|
|
54
|
+
let reconnectCurrent = null;
|
|
55
|
+
function connectAll() {
|
|
56
|
+
reconnectCurrent?.();
|
|
57
|
+
}
|
|
58
|
+
// ── Profiles ──────────────────────────────────────────────────────────────
|
|
59
|
+
let profiles = [];
|
|
60
|
+
if (!mock) {
|
|
61
|
+
fetchProfiles();
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
profiles = [{ name: "demo", active: true, apiType: "saas", baseUrl: null, authType: "none" }];
|
|
65
|
+
}
|
|
66
|
+
function fetchProfiles() {
|
|
67
|
+
fetch(`${proxyUrl}/profiles`)
|
|
68
|
+
.then((r) => r.json())
|
|
69
|
+
.then((data) => {
|
|
70
|
+
profiles = data;
|
|
71
|
+
const active = data.find((p) => p.active);
|
|
72
|
+
if (!profile && active)
|
|
73
|
+
profile = active.name;
|
|
74
|
+
header.setProfiles(profiles, profile);
|
|
75
|
+
})
|
|
76
|
+
.catch(() => { });
|
|
77
|
+
}
|
|
78
|
+
// ── Layout ────────────────────────────────────────────────────────────────
|
|
79
|
+
const layout = document.createElement("div");
|
|
80
|
+
layout.className = "op-layout";
|
|
81
|
+
el.appendChild(layout);
|
|
82
|
+
const router = createRouter();
|
|
83
|
+
const nav = createNav((path) => router.navigate(path));
|
|
84
|
+
layout.appendChild(nav.el);
|
|
85
|
+
const main = document.createElement("div");
|
|
86
|
+
main.className = "op-main";
|
|
87
|
+
layout.appendChild(main);
|
|
88
|
+
const header = createHeader((name) => {
|
|
89
|
+
profile = name;
|
|
90
|
+
connectAll();
|
|
91
|
+
}, (theme, resolved) => {
|
|
92
|
+
el.setAttribute("data-theme", resolved);
|
|
93
|
+
currentTheme = theme;
|
|
94
|
+
currentViewSetTheme?.(resolved);
|
|
95
|
+
}, initialTheme);
|
|
96
|
+
header.setProfiles(profiles, profile);
|
|
97
|
+
main.appendChild(header.el);
|
|
98
|
+
const content = document.createElement("div");
|
|
99
|
+
content.className = "op-content";
|
|
100
|
+
main.appendChild(content);
|
|
101
|
+
// ── Router ────────────────────────────────────────────────────────────────
|
|
102
|
+
let destroyView = null;
|
|
103
|
+
let currentTheme = initialTheme;
|
|
104
|
+
let currentViewSetTheme = null;
|
|
105
|
+
function showView(viewEl, destroy, setTheme) {
|
|
106
|
+
destroyView?.();
|
|
107
|
+
destroyView = destroy;
|
|
108
|
+
currentViewSetTheme = setTheme ?? null;
|
|
109
|
+
content.innerHTML = "";
|
|
110
|
+
content.appendChild(viewEl);
|
|
111
|
+
}
|
|
112
|
+
function getTheme() {
|
|
113
|
+
return el.getAttribute("data-theme") === "light" ? "light" : "dark";
|
|
114
|
+
}
|
|
115
|
+
router.on("/", () => {
|
|
116
|
+
reconnectCurrent = () => {
|
|
117
|
+
disconnectAll();
|
|
118
|
+
dashStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
119
|
+
};
|
|
120
|
+
reconnectCurrent();
|
|
121
|
+
header.setTitle("Dashboard");
|
|
122
|
+
nav.setActive("/");
|
|
123
|
+
const { el: vEl, destroy } = createDashboardView(dashStore, (path) => router.navigate(path));
|
|
124
|
+
showView(vEl, destroy);
|
|
125
|
+
});
|
|
126
|
+
router.on("/definitions", () => {
|
|
127
|
+
reconnectCurrent = () => {
|
|
128
|
+
disconnectAll();
|
|
129
|
+
defStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
130
|
+
};
|
|
131
|
+
reconnectCurrent();
|
|
132
|
+
header.setTitle("Processes");
|
|
133
|
+
nav.setActive("/definitions");
|
|
134
|
+
const { el: vEl, destroy } = createDefinitionsView(defStore, (def) => {
|
|
135
|
+
router.navigate(`/definitions/${def.processDefinitionKey ?? ""}`);
|
|
136
|
+
});
|
|
137
|
+
showView(vEl, destroy);
|
|
138
|
+
});
|
|
139
|
+
router.on("/definitions/:key", (params) => {
|
|
140
|
+
disconnectAll();
|
|
141
|
+
reconnectCurrent = () => {
|
|
142
|
+
disconnectAll();
|
|
143
|
+
};
|
|
144
|
+
header.setTitle("Process Definition");
|
|
145
|
+
nav.setActive("/definitions");
|
|
146
|
+
const { el: vEl, destroy, setTheme, } = createDefinitionDetailView(params.key ?? "", defStore, { proxyUrl, profile, mock, theme: getTheme(), navigate: (path) => router.navigate(path) }, () => router.navigate("/definitions"));
|
|
147
|
+
showView(vEl, destroy, setTheme);
|
|
148
|
+
});
|
|
149
|
+
router.on("/decisions", () => {
|
|
150
|
+
reconnectCurrent = () => {
|
|
151
|
+
disconnectAll();
|
|
152
|
+
decStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
153
|
+
};
|
|
154
|
+
reconnectCurrent();
|
|
155
|
+
header.setTitle("Decisions");
|
|
156
|
+
nav.setActive("/decisions");
|
|
157
|
+
const { el: vEl, destroy } = createDecisionsView(decStore, (def) => {
|
|
158
|
+
router.navigate(`/decisions/${def.decisionDefinitionKey}`);
|
|
159
|
+
});
|
|
160
|
+
showView(vEl, destroy);
|
|
161
|
+
});
|
|
162
|
+
router.on("/decisions/:key", (params) => {
|
|
163
|
+
disconnectAll();
|
|
164
|
+
reconnectCurrent = () => {
|
|
165
|
+
disconnectAll();
|
|
166
|
+
decStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
167
|
+
};
|
|
168
|
+
reconnectCurrent();
|
|
169
|
+
header.setTitle("Decision Definition");
|
|
170
|
+
nav.setActive("/decisions");
|
|
171
|
+
const { el: vEl, destroy, setTheme, } = createDecisionDetailView(params.key ?? "", decStore, { proxyUrl, profile, mock, theme: getTheme(), navigate: (path) => router.navigate(path) }, () => router.navigate("/decisions"));
|
|
172
|
+
showView(vEl, destroy, setTheme);
|
|
173
|
+
});
|
|
174
|
+
router.on("/instances", () => {
|
|
175
|
+
reconnectCurrent = () => {
|
|
176
|
+
disconnectAll();
|
|
177
|
+
instStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
178
|
+
};
|
|
179
|
+
reconnectCurrent();
|
|
180
|
+
header.setTitle("Instances");
|
|
181
|
+
nav.setActive("/instances");
|
|
182
|
+
const { el: vEl, destroy } = createInstancesView(instStore, (inst) => router.navigate(`/instances/${inst.processInstanceKey}`), (state) => {
|
|
183
|
+
instStore.connect(proxyUrl, profile, pollInterval, mock, { state: state || undefined });
|
|
184
|
+
});
|
|
185
|
+
showView(vEl, destroy);
|
|
186
|
+
});
|
|
187
|
+
router.on("/instances/:key", (params) => {
|
|
188
|
+
reconnectCurrent = () => {
|
|
189
|
+
disconnectAll();
|
|
190
|
+
instStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
191
|
+
};
|
|
192
|
+
reconnectCurrent();
|
|
193
|
+
const instanceKey = params.key ?? "";
|
|
194
|
+
header.setTitle(`Instance ${instanceKey}`);
|
|
195
|
+
nav.setActive("/instances");
|
|
196
|
+
const { el: vEl, destroy, setTheme, } = createInstanceDetailView(instanceKey, instStore, {
|
|
197
|
+
proxyUrl,
|
|
198
|
+
profile,
|
|
199
|
+
interval: pollInterval,
|
|
200
|
+
mock,
|
|
201
|
+
theme: getTheme(),
|
|
202
|
+
navigate: (path) => router.navigate(path),
|
|
203
|
+
}, () => router.navigate("/instances"));
|
|
204
|
+
showView(vEl, destroy, setTheme);
|
|
205
|
+
});
|
|
206
|
+
router.on("/incidents", () => {
|
|
207
|
+
reconnectCurrent = () => {
|
|
208
|
+
disconnectAll();
|
|
209
|
+
incStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
210
|
+
};
|
|
211
|
+
reconnectCurrent();
|
|
212
|
+
header.setTitle("Incidents");
|
|
213
|
+
nav.setActive("/incidents");
|
|
214
|
+
const { el: vEl, destroy } = createIncidentsView(incStore, (inc) => {
|
|
215
|
+
router.navigate(`/incidents/${inc.incidentKey ?? ""}`);
|
|
216
|
+
});
|
|
217
|
+
showView(vEl, destroy);
|
|
218
|
+
});
|
|
219
|
+
router.on("/incidents/:key", (params) => {
|
|
220
|
+
reconnectCurrent = () => {
|
|
221
|
+
disconnectAll();
|
|
222
|
+
incStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
223
|
+
};
|
|
224
|
+
reconnectCurrent();
|
|
225
|
+
const incidentKey = params.key ?? "";
|
|
226
|
+
header.setTitle(`Incident ${incidentKey}`);
|
|
227
|
+
nav.setActive("/incidents");
|
|
228
|
+
const { el: vEl, destroy } = createIncidentDetailView(incidentKey, incStore, { proxyUrl, profile, mock, theme: getTheme(), navigate: (path) => router.navigate(path) }, () => router.navigate("/incidents"));
|
|
229
|
+
showView(vEl, destroy);
|
|
230
|
+
});
|
|
231
|
+
router.on("/jobs", () => {
|
|
232
|
+
reconnectCurrent = () => {
|
|
233
|
+
disconnectAll();
|
|
234
|
+
jobStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
235
|
+
};
|
|
236
|
+
reconnectCurrent();
|
|
237
|
+
header.setTitle("Jobs");
|
|
238
|
+
nav.setActive("/jobs");
|
|
239
|
+
const { el: vEl, destroy } = createJobsView(jobStore);
|
|
240
|
+
showView(vEl, destroy);
|
|
241
|
+
});
|
|
242
|
+
router.on("/tasks", () => {
|
|
243
|
+
reconnectCurrent = () => {
|
|
244
|
+
disconnectAll();
|
|
245
|
+
taskStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
246
|
+
};
|
|
247
|
+
reconnectCurrent();
|
|
248
|
+
header.setTitle("Tasks");
|
|
249
|
+
nav.setActive("/tasks");
|
|
250
|
+
const { el: vEl, destroy } = createTasksView(taskStore, (task) => {
|
|
251
|
+
router.navigate(`/tasks/${task.userTaskKey}`);
|
|
252
|
+
});
|
|
253
|
+
showView(vEl, destroy);
|
|
254
|
+
});
|
|
255
|
+
router.on("/tasks/:key", (params) => {
|
|
256
|
+
reconnectCurrent = () => {
|
|
257
|
+
disconnectAll();
|
|
258
|
+
taskStore.connect(proxyUrl, profile, pollInterval, mock);
|
|
259
|
+
};
|
|
260
|
+
reconnectCurrent();
|
|
261
|
+
const taskKey = params.key ?? "";
|
|
262
|
+
header.setTitle(`Task ${taskKey}`);
|
|
263
|
+
nav.setActive("/tasks");
|
|
264
|
+
const { el: vEl, destroy } = createTaskDetailView(taskKey, taskStore, { proxyUrl, profile, mock, theme: getTheme() }, () => router.navigate("/tasks"));
|
|
265
|
+
showView(vEl, destroy);
|
|
266
|
+
});
|
|
267
|
+
router.on("/messages", () => {
|
|
268
|
+
reconnectCurrent = () => {
|
|
269
|
+
disconnectAll();
|
|
270
|
+
};
|
|
271
|
+
reconnectCurrent();
|
|
272
|
+
header.setTitle("Messages & Signals");
|
|
273
|
+
nav.setActive("/messages");
|
|
274
|
+
const { el: vEl, destroy } = createMessagesView({ proxyUrl, profile, mock });
|
|
275
|
+
showView(vEl, destroy);
|
|
276
|
+
});
|
|
277
|
+
const stopRouter = router.start();
|
|
278
|
+
// ── Public API ────────────────────────────────────────────────────────────
|
|
279
|
+
return {
|
|
280
|
+
el,
|
|
281
|
+
setProfile(name) {
|
|
282
|
+
profile = name;
|
|
283
|
+
connectAll();
|
|
284
|
+
header.setProfiles(profiles, profile);
|
|
285
|
+
},
|
|
286
|
+
setTheme(t) {
|
|
287
|
+
currentTheme = t;
|
|
288
|
+
applyTheme(el, t);
|
|
289
|
+
header.setTheme(t);
|
|
290
|
+
},
|
|
291
|
+
navigate(path) {
|
|
292
|
+
router.navigate(path);
|
|
293
|
+
},
|
|
294
|
+
destroy() {
|
|
295
|
+
stopRouter();
|
|
296
|
+
destroyView?.();
|
|
297
|
+
dashStore.destroy();
|
|
298
|
+
defStore.destroy();
|
|
299
|
+
decStore.destroy();
|
|
300
|
+
instStore.destroy();
|
|
301
|
+
incStore.destroy();
|
|
302
|
+
jobStore.destroy();
|
|
303
|
+
taskStore.destroy();
|
|
304
|
+
el.remove();
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=operate.js.map
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type RouteHandler = (params: Record<string, string>) => void;
|
|
2
|
+
export declare function createRouter(): {
|
|
3
|
+
on(path: string, handler: RouteHandler): void;
|
|
4
|
+
navigate(path: string): void;
|
|
5
|
+
start(): () => void;
|
|
6
|
+
currentPath(): string;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=router.d.ts.map
|
package/dist/router.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export function createRouter() {
|
|
2
|
+
const routes = [];
|
|
3
|
+
let _current = "/";
|
|
4
|
+
function patternFor(path) {
|
|
5
|
+
const keys = [];
|
|
6
|
+
const src = path.replace(/:([^/]+)/g, (_, key) => {
|
|
7
|
+
keys.push(key);
|
|
8
|
+
return "([^/]+)";
|
|
9
|
+
});
|
|
10
|
+
return { pattern: new RegExp(`^${src}$`), keys };
|
|
11
|
+
}
|
|
12
|
+
function dispatch(path) {
|
|
13
|
+
_current = path;
|
|
14
|
+
for (const route of routes) {
|
|
15
|
+
const m = route.pattern.exec(path);
|
|
16
|
+
if (m) {
|
|
17
|
+
const params = {};
|
|
18
|
+
for (let i = 0; i < route.keys.length; i++) {
|
|
19
|
+
const key = route.keys[i];
|
|
20
|
+
if (key)
|
|
21
|
+
params[key] = m[i + 1] ?? "";
|
|
22
|
+
}
|
|
23
|
+
route.handler(params);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function on(path, handler) {
|
|
29
|
+
const { pattern, keys } = patternFor(path);
|
|
30
|
+
routes.push({ pattern, keys, handler });
|
|
31
|
+
}
|
|
32
|
+
function navigate(path) {
|
|
33
|
+
window.location.hash = path;
|
|
34
|
+
}
|
|
35
|
+
function onHashChange() {
|
|
36
|
+
const hash = window.location.hash.slice(1) || "/";
|
|
37
|
+
dispatch(hash);
|
|
38
|
+
}
|
|
39
|
+
function start() {
|
|
40
|
+
window.addEventListener("hashchange", onHashChange);
|
|
41
|
+
onHashChange();
|
|
42
|
+
return () => window.removeEventListener("hashchange", onHashChange);
|
|
43
|
+
}
|
|
44
|
+
function currentPath() {
|
|
45
|
+
return _current;
|
|
46
|
+
}
|
|
47
|
+
return { on, navigate, start, currentPath };
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface StoreState<T> {
|
|
2
|
+
data: T | null;
|
|
3
|
+
loading: boolean;
|
|
4
|
+
error: string | null;
|
|
5
|
+
}
|
|
6
|
+
type Listener = () => void;
|
|
7
|
+
export declare class Store<T> {
|
|
8
|
+
private _state;
|
|
9
|
+
private _listeners;
|
|
10
|
+
private _unsub;
|
|
11
|
+
get state(): StoreState<T>;
|
|
12
|
+
subscribe(fn: Listener): () => void;
|
|
13
|
+
protected set(patch: Partial<StoreState<T>>): void;
|
|
14
|
+
protected setUnsub(unsub: () => void): void;
|
|
15
|
+
/** Stop polling without clearing data or listeners. Safe to reconnect later. */
|
|
16
|
+
disconnect(): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export class Store {
|
|
2
|
+
_state = { data: null, loading: false, error: null };
|
|
3
|
+
_listeners = new Set();
|
|
4
|
+
_unsub = null;
|
|
5
|
+
get state() {
|
|
6
|
+
return this._state;
|
|
7
|
+
}
|
|
8
|
+
subscribe(fn) {
|
|
9
|
+
this._listeners.add(fn);
|
|
10
|
+
return () => this._listeners.delete(fn);
|
|
11
|
+
}
|
|
12
|
+
set(patch) {
|
|
13
|
+
this._state = { ...this._state, ...patch };
|
|
14
|
+
for (const fn of this._listeners)
|
|
15
|
+
fn();
|
|
16
|
+
}
|
|
17
|
+
setUnsub(unsub) {
|
|
18
|
+
this._unsub?.();
|
|
19
|
+
this._unsub = unsub;
|
|
20
|
+
}
|
|
21
|
+
/** Stop polling without clearing data or listeners. Safe to reconnect later. */
|
|
22
|
+
disconnect() {
|
|
23
|
+
this._unsub?.();
|
|
24
|
+
this._unsub = null;
|
|
25
|
+
}
|
|
26
|
+
destroy() {
|
|
27
|
+
this._unsub?.();
|
|
28
|
+
this._unsub = null;
|
|
29
|
+
this._listeners.clear();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DashboardData } from "../types.js";
|
|
2
|
+
import { Store } from "./base.js";
|
|
3
|
+
export declare class DashboardStore extends Store<DashboardData> {
|
|
4
|
+
connect(proxyUrl: string, profile: string | null, interval: number, mock: boolean): void;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getMockDashboard } from "../mock-data.js";
|
|
2
|
+
import { createMockStream, createStream } from "../stream.js";
|
|
3
|
+
import { Store } from "./base.js";
|
|
4
|
+
export class DashboardStore extends Store {
|
|
5
|
+
connect(proxyUrl, profile, interval, mock) {
|
|
6
|
+
this.set({ loading: true, error: null });
|
|
7
|
+
if (mock) {
|
|
8
|
+
this.setUnsub(createMockStream(getMockDashboard, (payload) => this.set({ data: payload, loading: false }), interval));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const params = new URLSearchParams({ topic: "dashboard" });
|
|
12
|
+
if (profile)
|
|
13
|
+
params.set("profile", profile);
|
|
14
|
+
if (interval > 0)
|
|
15
|
+
params.set("interval", String(interval));
|
|
16
|
+
this.setUnsub(createStream(`${proxyUrl}/operate/stream?${params}`, (payload) => this.set({ data: payload, loading: false }), (msg) => this.set({ error: msg, loading: false })));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=dashboard.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DecisionDefinitionResult } from "../types.js";
|
|
2
|
+
import { Store } from "./base.js";
|
|
3
|
+
export interface DecisionsPayload {
|
|
4
|
+
items: DecisionDefinitionResult[];
|
|
5
|
+
}
|
|
6
|
+
export declare class DecisionsStore extends Store<DecisionsPayload> {
|
|
7
|
+
connect(proxyUrl: string, profile: string | null, interval: number, mock: boolean): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=decisions.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MOCK_DECISIONS } from "../mock-data.js";
|
|
2
|
+
import { createMockStream, createStream } from "../stream.js";
|
|
3
|
+
import { Store } from "./base.js";
|
|
4
|
+
export class DecisionsStore extends Store {
|
|
5
|
+
connect(proxyUrl, profile, interval, mock) {
|
|
6
|
+
this.set({ loading: true, error: null });
|
|
7
|
+
if (mock) {
|
|
8
|
+
this.setUnsub(createMockStream(() => ({ items: MOCK_DECISIONS }), (payload) => this.set({ data: payload, loading: false }), interval));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const params = new URLSearchParams({ topic: "decisions" });
|
|
12
|
+
if (profile)
|
|
13
|
+
params.set("profile", profile);
|
|
14
|
+
if (interval > 0)
|
|
15
|
+
params.set("interval", String(interval));
|
|
16
|
+
this.setUnsub(createStream(`${proxyUrl}/operate/stream?${params}`, (payload) => this.set({ data: payload, loading: false }), (msg) => this.set({ error: msg, loading: false })));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=decisions.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ProcessDefinitionResult } from "../types.js";
|
|
2
|
+
import { Store } from "./base.js";
|
|
3
|
+
export interface DefinitionsPayload {
|
|
4
|
+
items: ProcessDefinitionResult[];
|
|
5
|
+
}
|
|
6
|
+
export declare class DefinitionsStore extends Store<DefinitionsPayload> {
|
|
7
|
+
connect(proxyUrl: string, profile: string | null, interval: number, mock: boolean): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MOCK_DEFINITIONS } from "../mock-data.js";
|
|
2
|
+
import { createMockStream, createStream } from "../stream.js";
|
|
3
|
+
import { Store } from "./base.js";
|
|
4
|
+
export class DefinitionsStore extends Store {
|
|
5
|
+
connect(proxyUrl, profile, interval, mock) {
|
|
6
|
+
this.set({ loading: true, error: null });
|
|
7
|
+
if (mock) {
|
|
8
|
+
this.setUnsub(createMockStream(() => ({ items: MOCK_DEFINITIONS }), (payload) => this.set({ data: payload, loading: false }), interval));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const params = new URLSearchParams({ topic: "definitions" });
|
|
12
|
+
if (profile)
|
|
13
|
+
params.set("profile", profile);
|
|
14
|
+
if (interval > 0)
|
|
15
|
+
params.set("interval", String(interval));
|
|
16
|
+
this.setUnsub(createStream(`${proxyUrl}/operate/stream?${params}`, (payload) => this.set({ data: payload, loading: false }), (msg) => this.set({ error: msg, loading: false })));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IncidentResult } from "../types.js";
|
|
2
|
+
import { Store } from "./base.js";
|
|
3
|
+
export interface IncidentsPayload {
|
|
4
|
+
items: IncidentResult[];
|
|
5
|
+
total: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class IncidentsStore extends Store<IncidentsPayload> {
|
|
8
|
+
connect(proxyUrl: string, profile: string | null, interval: number, mock: boolean, processInstanceKey?: string): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=incidents.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MOCK_INCIDENTS } from "../mock-data.js";
|
|
2
|
+
import { createMockStream, createStream } from "../stream.js";
|
|
3
|
+
import { Store } from "./base.js";
|
|
4
|
+
export class IncidentsStore extends Store {
|
|
5
|
+
connect(proxyUrl, profile, interval, mock, processInstanceKey) {
|
|
6
|
+
this.set({ loading: true, error: null });
|
|
7
|
+
if (mock) {
|
|
8
|
+
const getFiltered = () => {
|
|
9
|
+
const items = processInstanceKey
|
|
10
|
+
? MOCK_INCIDENTS.filter((i) => i.processInstanceKey === processInstanceKey)
|
|
11
|
+
: MOCK_INCIDENTS;
|
|
12
|
+
return { items, total: items.length };
|
|
13
|
+
};
|
|
14
|
+
this.setUnsub(createMockStream(getFiltered, (payload) => this.set({ data: payload, loading: false }), interval));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const params = new URLSearchParams({ topic: "incidents" });
|
|
18
|
+
if (profile)
|
|
19
|
+
params.set("profile", profile);
|
|
20
|
+
if (interval > 0)
|
|
21
|
+
params.set("interval", String(interval));
|
|
22
|
+
if (processInstanceKey)
|
|
23
|
+
params.set("processInstanceKey", processInstanceKey);
|
|
24
|
+
this.setUnsub(createStream(`${proxyUrl}/operate/stream?${params}`, (payload) => this.set({ data: payload, loading: false }), (msg) => this.set({ error: msg, loading: false })));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=incidents.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ProcessInstanceResult } from "../types.js";
|
|
2
|
+
import { Store } from "./base.js";
|
|
3
|
+
export interface InstancesPayload {
|
|
4
|
+
items: ProcessInstanceResult[];
|
|
5
|
+
total: number;
|
|
6
|
+
}
|
|
7
|
+
export interface InstancesFilter {
|
|
8
|
+
state?: string;
|
|
9
|
+
processDefinitionKey?: string;
|
|
10
|
+
page?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare class InstancesStore extends Store<InstancesPayload> {
|
|
13
|
+
connect(proxyUrl: string, profile: string | null, interval: number, mock: boolean, filter?: InstancesFilter): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=instances.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MOCK_INSTANCES } from "../mock-data.js";
|
|
2
|
+
import { createMockStream, createStream } from "../stream.js";
|
|
3
|
+
import { Store } from "./base.js";
|
|
4
|
+
export class InstancesStore extends Store {
|
|
5
|
+
connect(proxyUrl, profile, interval, mock, filter = {}) {
|
|
6
|
+
this.set({ loading: true, error: null });
|
|
7
|
+
if (mock) {
|
|
8
|
+
const getFiltered = () => {
|
|
9
|
+
let items = MOCK_INSTANCES;
|
|
10
|
+
if (filter.state)
|
|
11
|
+
items = items.filter((i) => i.state === filter.state);
|
|
12
|
+
if (filter.processDefinitionKey)
|
|
13
|
+
items = items.filter((i) => i.processDefinitionKey === filter.processDefinitionKey);
|
|
14
|
+
return { items, total: items.length };
|
|
15
|
+
};
|
|
16
|
+
this.setUnsub(createMockStream(getFiltered, (payload) => this.set({ data: payload, loading: false }), interval));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const params = new URLSearchParams({ topic: "instances" });
|
|
20
|
+
if (profile)
|
|
21
|
+
params.set("profile", profile);
|
|
22
|
+
if (interval > 0)
|
|
23
|
+
params.set("interval", String(interval));
|
|
24
|
+
if (filter.state)
|
|
25
|
+
params.set("state", filter.state);
|
|
26
|
+
if (filter.processDefinitionKey)
|
|
27
|
+
params.set("processDefinitionKey", filter.processDefinitionKey);
|
|
28
|
+
if (filter.page)
|
|
29
|
+
params.set("page", String(filter.page));
|
|
30
|
+
this.setUnsub(createStream(`${proxyUrl}/operate/stream?${params}`, (payload) => this.set({ data: payload, loading: false }), (msg) => this.set({ error: msg, loading: false })));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=instances.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JobSearchResult } from "../types.js";
|
|
2
|
+
import { Store } from "./base.js";
|
|
3
|
+
export interface JobsPayload {
|
|
4
|
+
items: JobSearchResult[];
|
|
5
|
+
total: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class JobsStore extends Store<JobsPayload> {
|
|
8
|
+
connect(proxyUrl: string, profile: string | null, interval: number, mock: boolean): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=jobs.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MOCK_JOBS } from "../mock-data.js";
|
|
2
|
+
import { createMockStream, createStream } from "../stream.js";
|
|
3
|
+
import { Store } from "./base.js";
|
|
4
|
+
export class JobsStore extends Store {
|
|
5
|
+
connect(proxyUrl, profile, interval, mock) {
|
|
6
|
+
this.set({ loading: true, error: null });
|
|
7
|
+
if (mock) {
|
|
8
|
+
this.setUnsub(createMockStream(() => ({ items: MOCK_JOBS, total: MOCK_JOBS.length }), (payload) => this.set({ data: payload, loading: false }), interval));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const params = new URLSearchParams({ topic: "jobs" });
|
|
12
|
+
if (profile)
|
|
13
|
+
params.set("profile", profile);
|
|
14
|
+
if (interval > 0)
|
|
15
|
+
params.set("interval", String(interval));
|
|
16
|
+
this.setUnsub(createStream(`${proxyUrl}/operate/stream?${params}`, (payload) => this.set({ data: payload, loading: false }), (msg) => this.set({ error: msg, loading: false })));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UserTaskResult } from "../types.js";
|
|
2
|
+
import { Store } from "./base.js";
|
|
3
|
+
export interface TasksPayload {
|
|
4
|
+
items: UserTaskResult[];
|
|
5
|
+
total: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class TasksStore extends Store<TasksPayload> {
|
|
8
|
+
connect(proxyUrl: string, profile: string | null, interval: number, mock: boolean): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=tasks.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MOCK_TASKS } from "../mock-data.js";
|
|
2
|
+
import { createMockStream, createStream } from "../stream.js";
|
|
3
|
+
import { Store } from "./base.js";
|
|
4
|
+
export class TasksStore extends Store {
|
|
5
|
+
connect(proxyUrl, profile, interval, mock) {
|
|
6
|
+
this.set({ loading: true, error: null });
|
|
7
|
+
if (mock) {
|
|
8
|
+
this.setUnsub(createMockStream(() => ({ items: MOCK_TASKS, total: MOCK_TASKS.length }), (payload) => this.set({ data: payload, loading: false }), interval));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const params = new URLSearchParams({ topic: "tasks" });
|
|
12
|
+
if (profile)
|
|
13
|
+
params.set("profile", profile);
|
|
14
|
+
if (interval > 0)
|
|
15
|
+
params.set("interval", String(interval));
|
|
16
|
+
this.setUnsub(createStream(`${proxyUrl}/operate/stream?${params}`, (payload) => this.set({ data: payload, loading: false }), (msg) => this.set({ error: msg, loading: false })));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=tasks.js.map
|