@aventoapp/framework 0.2.0 → 0.2.2
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 +281 -0
- package/dist/index.js.map +1 -1
- package/dist/native/index.js.map +1 -1
- package/dist/offline/index.js.map +1 -1
- package/dist/server/index.js +69 -6
- package/dist/server/index.js.map +2 -2
- package/dist/server/workflow/index.js.map +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/web/index.js.map +1 -1
- package/package.json +84 -79
- package/schemas/Workflow.json +14 -14
- package/schemas/WorkflowHistory.json +22 -22
- package/schemas/WorkflowInstance.json +16 -16
- package/schemas/WorkflowState.json +18 -18
- package/schemas/WorkflowTransition.json +27 -27
- package/src/index.js +8 -8
- package/src/native/components/NativeAuthProvider.jsx +249 -249
- package/src/native/components/NativeDetail.jsx +270 -270
- package/src/native/components/NativeForm.jsx +543 -543
- package/src/native/components/NativeGrid.jsx +90 -90
- package/src/native/components/NativeJsonGrid.jsx +213 -213
- package/src/native/components/NativeJsonView.jsx +454 -454
- package/src/native/components/NativeJsonViewContext.js +17 -17
- package/src/native/components/NativeShell.jsx +68 -68
- package/src/native/components/NativeViewComponent.jsx +351 -351
- package/src/native/extensions/NativeExtensionRegistry.js +81 -81
- package/src/native/hooks/useNativeStore.js +72 -72
- package/src/native/index.js +15 -15
- package/src/native/layouts/NativeStackLayout.jsx +30 -30
- package/src/native/layouts/NativeTabLayout.jsx +96 -96
- package/src/native/storage.js +13 -13
- package/src/native/stores/NativeBaseStore.js +348 -348
- package/src/native/stores/NativeStoreContext.jsx +53 -53
- package/src/offline/index.js +1 -1
- package/src/server/ai/capabilities-routes.js +106 -106
- package/src/server/ai/index.js +1 -1
- package/src/server/cache/MemoryCache.js +153 -153
- package/src/server/cache/index.js +2 -2
- package/src/server/cache/middleware.js +12 -12
- package/src/server/db/index.js +14 -14
- package/src/server/db/mongo.js +137 -137
- package/src/server/db/postgres.js +144 -144
- package/src/server/index.js +42 -42
- package/src/server/middleware/auth.js +682 -682
- package/src/server/middleware/can-flags.js +132 -132
- package/src/server/middleware/entityRoles.js +105 -105
- package/src/server/middleware/index.js +58 -58
- package/src/server/middleware/permissions.js +240 -240
- package/src/server/middleware/tenant.js +203 -203
- package/src/server/offline/field-lww.js +98 -6
- package/src/server/realtime/EventBus.js +45 -45
- package/src/server/realtime/WebSocketServer.js +105 -105
- package/src/server/realtime/index.js +3 -3
- package/src/server/realtime/middleware.js +18 -18
- package/src/server/services/email-templates.js +157 -157
- package/src/server/services/email.js +78 -78
- package/src/server/services/index.js +15 -15
- package/src/server/services/storage.js +119 -119
- package/src/server/utils/index.js +16 -16
- package/src/server/utils/paginate.js +65 -65
- package/src/server/utils/query-builder.js +293 -293
- package/src/server/utils/route-loader.js +61 -61
- package/src/server/workflow/WorkflowEngine.js +494 -494
- package/src/server/workflow/index.js +2 -2
- package/src/server/workflow/workflow-routes.js +174 -174
- package/src/shared/index.js +10 -10
- package/src/shared/utils/field-accessor.js +108 -108
- package/src/shared/utils/index.js +7 -7
- package/src/shared/utils/validation-utils.js +83 -83
- package/src/web/components/AppRouter/AppRouter.jsx +130 -130
- package/src/web/components/AppRouter/index.js +1 -1
- package/src/web/components/AppShell/AppShell.jsx +101 -101
- package/src/web/components/AppShell/DefaultUserMenu.jsx +54 -54
- package/src/web/components/AppShell/ShellConfig.js +53 -53
- package/src/web/components/AppShell/index.js +3 -3
- package/src/web/components/AuthProvider.jsx +426 -426
- package/src/web/components/CardList/CardList.jsx +272 -272
- package/src/web/components/CardList/index.js +2 -2
- package/src/web/components/DetailView/DetailView.jsx +281 -281
- package/src/web/components/DetailView/index.js +2 -2
- package/src/web/components/Form/Form.jsx +300 -300
- package/src/web/components/Form/FormField.jsx +226 -226
- package/src/web/components/Form/index.js +3 -3
- package/src/web/components/Grid/Grid.jsx +304 -304
- package/src/web/components/Grid/index.js +2 -2
- package/src/web/components/IconRegistry/IconRegistry.jsx +127 -127
- package/src/web/components/IconRegistry/index.js +1 -1
- package/src/web/components/JsonView/JsonView.jsx +647 -647
- package/src/web/components/JsonView/ViewComponent.jsx +1045 -1045
- package/src/web/components/JsonView/ViewToolbar.jsx +141 -141
- package/src/web/components/JsonView/index.js +14 -14
- package/src/web/components/JsonView/layouts/SingleLayout.jsx +41 -41
- package/src/web/components/JsonView/layouts/SplitLayout.jsx +122 -122
- package/src/web/components/JsonView/layouts/TabLayout.jsx +112 -112
- package/src/web/components/JsonView/layouts/index.js +8 -8
- package/src/web/components/Layout.jsx +265 -265
- package/src/web/components/MobileLayout/MobileLayout.jsx +385 -385
- package/src/web/components/MobileLayout/index.js +1 -1
- package/src/web/components/Navigation/Navigation.jsx +248 -248
- package/src/web/components/Navigation/index.js +1 -1
- package/src/web/components/NotificationProvider.jsx +55 -55
- package/src/web/components/Pagination/InfiniteScroll.jsx +82 -82
- package/src/web/components/Pagination/Pagination.jsx +73 -73
- package/src/web/components/Pagination/index.js +8 -8
- package/src/web/components/SimpleList/SimpleList.jsx +177 -177
- package/src/web/components/SimpleList/index.js +2 -2
- package/src/web/components/TenantProvider.jsx +121 -121
- package/src/web/components/WorkflowActions/WorkflowActions.jsx +71 -71
- package/src/web/components/WorkflowActions/index.js +1 -1
- package/src/web/components/WorkflowField/WorkflowField.jsx +176 -176
- package/src/web/components/WorkflowField/index.js +2 -2
- package/src/web/components/WorkflowField/workflowColors.js +32 -32
- package/src/web/components/auth/DevTenantSelector.jsx +90 -90
- package/src/web/components/auth/ForgotPasswordForm.jsx +94 -94
- package/src/web/components/auth/RegisterForm.jsx +168 -168
- package/src/web/components/auth/ResetPasswordForm.jsx +121 -121
- package/src/web/components/auth/VerifyEmailView.jsx +85 -85
- package/src/web/components/auth/index.js +5 -5
- package/src/web/components/index.js +39 -39
- package/src/web/components/layouts/CardListLayout.jsx +68 -68
- package/src/web/components/layouts/FullscreenLayout.jsx +30 -30
- package/src/web/components/layouts/MobileStackLayout.jsx +28 -28
- package/src/web/components/layouts/WizardLayout.jsx +86 -86
- package/src/web/components/layouts/index.js +4 -4
- package/src/web/components/mobile/Badge.jsx +105 -105
- package/src/web/components/mobile/BadgeThemeEditor.jsx +104 -104
- package/src/web/components/mobile/EmptyState.jsx +30 -30
- package/src/web/components/mobile/QuickActionButton.jsx +77 -77
- package/src/web/components/mobile/ServerAutocomplete.jsx +123 -123
- package/src/web/components/mobile/StarRating.jsx +42 -42
- package/src/web/components/mobile/StatCard.jsx +65 -65
- package/src/web/components/mobile/index.js +7 -7
- package/src/web/extensions/ExtensionRegistry.js +79 -79
- package/src/web/extensions/index.js +7 -7
- package/src/web/hooks/index.js +15 -15
- package/src/web/hooks/useApi.js +76 -76
- package/src/web/hooks/useAuth.js +37 -37
- package/src/web/hooks/useDebouncedSave.js +158 -158
- package/src/web/hooks/useIsMobile.js +14 -14
- package/src/web/hooks/useOfflineQueue.js +99 -99
- package/src/web/hooks/useSelectionModel.js +143 -143
- package/src/web/hooks/useServerAutocomplete.js +146 -146
- package/src/web/hooks/useStore.js +107 -107
- package/src/web/hooks/useSubscription.js +130 -130
- package/src/web/hooks/useTenant.js +39 -39
- package/src/web/hooks/useTenantResolver.js +65 -65
- package/src/web/hooks/useUndoRedo.js +77 -77
- package/src/web/hooks/useViews.js +113 -113
- package/src/web/hooks/useWorkflow.js +190 -190
- package/src/web/index.js +117 -117
- package/src/web/stores/BaseStore.js +439 -439
- package/src/web/stores/StoreContext.jsx +93 -93
- package/src/web/stores/index.js +3 -3
- package/src/web/theme/index.js +3 -3
- package/src/web/theme/mui-theme.js +228 -228
- package/src/web/utils/formatTimeAgo.js +22 -22
- package/src/web/utils/index.js +1 -1
- package/src/web/views/ViewRegistry.js +235 -235
- package/src/web/views/index.js +2 -2
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* useWorkflow Hook
|
|
3
|
-
*
|
|
4
|
-
* Manages workflow state, available transitions, and transition execution
|
|
5
|
-
* for entities with workflow instances.
|
|
6
|
-
*/
|
|
7
|
-
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
8
|
-
import { useAuth } from './useAuth.js';
|
|
9
|
-
import { useTenant } from './useTenant.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Hook for interacting with a workflow instance
|
|
13
|
-
*
|
|
14
|
-
* @param {string} workflowInstanceId - UUID of the workflow instance
|
|
15
|
-
* @param {Object} [options] - Optional configuration
|
|
16
|
-
* @param {Object} [options.headers] - Extra headers for API calls
|
|
17
|
-
* @returns {Object} Workflow state and actions
|
|
18
|
-
*/
|
|
19
|
-
export function useWorkflow(workflowInstanceId, options = {}) {
|
|
20
|
-
const { token } = useAuth();
|
|
21
|
-
const { tenant } = useTenant();
|
|
22
|
-
const [transitions, setTransitions] = useState([]);
|
|
23
|
-
const [workflowState, setWorkflowState] = useState(null);
|
|
24
|
-
const [history, setHistory] = useState([]);
|
|
25
|
-
const [loading, setLoading] = useState(false);
|
|
26
|
-
const [error, setError] = useState(null);
|
|
27
|
-
|
|
28
|
-
const headers = useMemo(() => {
|
|
29
|
-
const h = { 'Content-Type': 'application/json' };
|
|
30
|
-
if (token) h.Authorization = `Bearer ${token}`;
|
|
31
|
-
if (tenant?.id) h['X-Tenant-ID'] = tenant.id;
|
|
32
|
-
return { ...h, ...options.headers };
|
|
33
|
-
}, [token, tenant?.id, options.headers]);
|
|
34
|
-
|
|
35
|
-
// Fetch instance state and transitions when instanceId changes
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (!workflowInstanceId) {
|
|
38
|
-
setTransitions([]);
|
|
39
|
-
setWorkflowState(null);
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let cancelled = false;
|
|
44
|
-
|
|
45
|
-
async function fetchWorkflowData() {
|
|
46
|
-
setLoading(true);
|
|
47
|
-
setError(null);
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
// Fetch instance and transitions in parallel
|
|
51
|
-
const [instanceRes, transitionsRes] = await Promise.all([
|
|
52
|
-
fetch(`/api/workflow/${workflowInstanceId}`, { headers }),
|
|
53
|
-
fetch(`/api/workflow/${workflowInstanceId}/transitions`, { headers })
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
if (!cancelled) {
|
|
57
|
-
if (instanceRes.ok) {
|
|
58
|
-
const instance = await instanceRes.json();
|
|
59
|
-
setWorkflowState(instance.current_state);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (transitionsRes.ok) {
|
|
63
|
-
const data = await transitionsRes.json();
|
|
64
|
-
setTransitions(data.transitions || []);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
} catch (err) {
|
|
68
|
-
if (!cancelled) {
|
|
69
|
-
setError(err.message);
|
|
70
|
-
}
|
|
71
|
-
} finally {
|
|
72
|
-
if (!cancelled) {
|
|
73
|
-
setLoading(false);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
fetchWorkflowData();
|
|
79
|
-
|
|
80
|
-
return () => { cancelled = true; };
|
|
81
|
-
}, [workflowInstanceId]);
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Re-fetch instance state and transitions
|
|
85
|
-
*/
|
|
86
|
-
const refetch = useCallback(async () => {
|
|
87
|
-
if (!workflowInstanceId) return;
|
|
88
|
-
|
|
89
|
-
setLoading(true);
|
|
90
|
-
setError(null);
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
const [instanceRes, transitionsRes] = await Promise.all([
|
|
94
|
-
fetch(`/api/workflow/${workflowInstanceId}`, { headers }),
|
|
95
|
-
fetch(`/api/workflow/${workflowInstanceId}/transitions`, { headers })
|
|
96
|
-
]);
|
|
97
|
-
|
|
98
|
-
if (instanceRes.ok) {
|
|
99
|
-
const instance = await instanceRes.json();
|
|
100
|
-
setWorkflowState(instance.current_state);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (transitionsRes.ok) {
|
|
104
|
-
const data = await transitionsRes.json();
|
|
105
|
-
setTransitions(data.transitions || []);
|
|
106
|
-
}
|
|
107
|
-
} catch (err) {
|
|
108
|
-
setError(err.message);
|
|
109
|
-
} finally {
|
|
110
|
-
setLoading(false);
|
|
111
|
-
}
|
|
112
|
-
}, [workflowInstanceId, headers]);
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Execute a workflow transition
|
|
116
|
-
* @param {string} ruleId - Rule UUID to execute
|
|
117
|
-
* @param {string} [comment] - Optional comment
|
|
118
|
-
* @returns {Object} Transition result
|
|
119
|
-
*/
|
|
120
|
-
const executeTransition = useCallback(async (ruleId, comment) => {
|
|
121
|
-
if (!workflowInstanceId) return null;
|
|
122
|
-
|
|
123
|
-
setLoading(true);
|
|
124
|
-
setError(null);
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
const res = await fetch(`/api/workflow/${workflowInstanceId}/transition`, {
|
|
128
|
-
method: 'POST',
|
|
129
|
-
headers,
|
|
130
|
-
body: JSON.stringify({ ruleId, comment })
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const result = await res.json();
|
|
134
|
-
|
|
135
|
-
if (!res.ok) {
|
|
136
|
-
throw new Error(result.error || 'Transition failed');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Update local state
|
|
140
|
-
setWorkflowState(result.newState);
|
|
141
|
-
|
|
142
|
-
// Re-fetch transitions for new state
|
|
143
|
-
const transitionsRes = await fetch(
|
|
144
|
-
`/api/workflow/${workflowInstanceId}/transitions`,
|
|
145
|
-
{ headers }
|
|
146
|
-
);
|
|
147
|
-
if (transitionsRes.ok) {
|
|
148
|
-
const data = await transitionsRes.json();
|
|
149
|
-
setTransitions(data.transitions || []);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return result;
|
|
153
|
-
} catch (err) {
|
|
154
|
-
setError(err.message);
|
|
155
|
-
throw err;
|
|
156
|
-
} finally {
|
|
157
|
-
setLoading(false);
|
|
158
|
-
}
|
|
159
|
-
}, [workflowInstanceId]);
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Fetch workflow history
|
|
163
|
-
*/
|
|
164
|
-
const fetchHistory = useCallback(async () => {
|
|
165
|
-
if (!workflowInstanceId) return;
|
|
166
|
-
|
|
167
|
-
try {
|
|
168
|
-
const res = await fetch(`/api/workflow/${workflowInstanceId}/history`, { headers });
|
|
169
|
-
if (res.ok) {
|
|
170
|
-
const data = await res.json();
|
|
171
|
-
setHistory(data.history || []);
|
|
172
|
-
}
|
|
173
|
-
} catch (err) {
|
|
174
|
-
console.error('Failed to fetch workflow history:', err);
|
|
175
|
-
}
|
|
176
|
-
}, [workflowInstanceId]);
|
|
177
|
-
|
|
178
|
-
return {
|
|
179
|
-
transitions,
|
|
180
|
-
workflowState,
|
|
181
|
-
history,
|
|
182
|
-
loading,
|
|
183
|
-
error,
|
|
184
|
-
executeTransition,
|
|
185
|
-
fetchHistory,
|
|
186
|
-
refetch
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export default useWorkflow;
|
|
1
|
+
/**
|
|
2
|
+
* useWorkflow Hook
|
|
3
|
+
*
|
|
4
|
+
* Manages workflow state, available transitions, and transition execution
|
|
5
|
+
* for entities with workflow instances.
|
|
6
|
+
*/
|
|
7
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
8
|
+
import { useAuth } from './useAuth.js';
|
|
9
|
+
import { useTenant } from './useTenant.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Hook for interacting with a workflow instance
|
|
13
|
+
*
|
|
14
|
+
* @param {string} workflowInstanceId - UUID of the workflow instance
|
|
15
|
+
* @param {Object} [options] - Optional configuration
|
|
16
|
+
* @param {Object} [options.headers] - Extra headers for API calls
|
|
17
|
+
* @returns {Object} Workflow state and actions
|
|
18
|
+
*/
|
|
19
|
+
export function useWorkflow(workflowInstanceId, options = {}) {
|
|
20
|
+
const { token } = useAuth();
|
|
21
|
+
const { tenant } = useTenant();
|
|
22
|
+
const [transitions, setTransitions] = useState([]);
|
|
23
|
+
const [workflowState, setWorkflowState] = useState(null);
|
|
24
|
+
const [history, setHistory] = useState([]);
|
|
25
|
+
const [loading, setLoading] = useState(false);
|
|
26
|
+
const [error, setError] = useState(null);
|
|
27
|
+
|
|
28
|
+
const headers = useMemo(() => {
|
|
29
|
+
const h = { 'Content-Type': 'application/json' };
|
|
30
|
+
if (token) h.Authorization = `Bearer ${token}`;
|
|
31
|
+
if (tenant?.id) h['X-Tenant-ID'] = tenant.id;
|
|
32
|
+
return { ...h, ...options.headers };
|
|
33
|
+
}, [token, tenant?.id, options.headers]);
|
|
34
|
+
|
|
35
|
+
// Fetch instance state and transitions when instanceId changes
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (!workflowInstanceId) {
|
|
38
|
+
setTransitions([]);
|
|
39
|
+
setWorkflowState(null);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let cancelled = false;
|
|
44
|
+
|
|
45
|
+
async function fetchWorkflowData() {
|
|
46
|
+
setLoading(true);
|
|
47
|
+
setError(null);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
// Fetch instance and transitions in parallel
|
|
51
|
+
const [instanceRes, transitionsRes] = await Promise.all([
|
|
52
|
+
fetch(`/api/workflow/${workflowInstanceId}`, { headers }),
|
|
53
|
+
fetch(`/api/workflow/${workflowInstanceId}/transitions`, { headers })
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
if (!cancelled) {
|
|
57
|
+
if (instanceRes.ok) {
|
|
58
|
+
const instance = await instanceRes.json();
|
|
59
|
+
setWorkflowState(instance.current_state);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (transitionsRes.ok) {
|
|
63
|
+
const data = await transitionsRes.json();
|
|
64
|
+
setTransitions(data.transitions || []);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
if (!cancelled) {
|
|
69
|
+
setError(err.message);
|
|
70
|
+
}
|
|
71
|
+
} finally {
|
|
72
|
+
if (!cancelled) {
|
|
73
|
+
setLoading(false);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fetchWorkflowData();
|
|
79
|
+
|
|
80
|
+
return () => { cancelled = true; };
|
|
81
|
+
}, [workflowInstanceId]);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Re-fetch instance state and transitions
|
|
85
|
+
*/
|
|
86
|
+
const refetch = useCallback(async () => {
|
|
87
|
+
if (!workflowInstanceId) return;
|
|
88
|
+
|
|
89
|
+
setLoading(true);
|
|
90
|
+
setError(null);
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
const [instanceRes, transitionsRes] = await Promise.all([
|
|
94
|
+
fetch(`/api/workflow/${workflowInstanceId}`, { headers }),
|
|
95
|
+
fetch(`/api/workflow/${workflowInstanceId}/transitions`, { headers })
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
if (instanceRes.ok) {
|
|
99
|
+
const instance = await instanceRes.json();
|
|
100
|
+
setWorkflowState(instance.current_state);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (transitionsRes.ok) {
|
|
104
|
+
const data = await transitionsRes.json();
|
|
105
|
+
setTransitions(data.transitions || []);
|
|
106
|
+
}
|
|
107
|
+
} catch (err) {
|
|
108
|
+
setError(err.message);
|
|
109
|
+
} finally {
|
|
110
|
+
setLoading(false);
|
|
111
|
+
}
|
|
112
|
+
}, [workflowInstanceId, headers]);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Execute a workflow transition
|
|
116
|
+
* @param {string} ruleId - Rule UUID to execute
|
|
117
|
+
* @param {string} [comment] - Optional comment
|
|
118
|
+
* @returns {Object} Transition result
|
|
119
|
+
*/
|
|
120
|
+
const executeTransition = useCallback(async (ruleId, comment) => {
|
|
121
|
+
if (!workflowInstanceId) return null;
|
|
122
|
+
|
|
123
|
+
setLoading(true);
|
|
124
|
+
setError(null);
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const res = await fetch(`/api/workflow/${workflowInstanceId}/transition`, {
|
|
128
|
+
method: 'POST',
|
|
129
|
+
headers,
|
|
130
|
+
body: JSON.stringify({ ruleId, comment })
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const result = await res.json();
|
|
134
|
+
|
|
135
|
+
if (!res.ok) {
|
|
136
|
+
throw new Error(result.error || 'Transition failed');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Update local state
|
|
140
|
+
setWorkflowState(result.newState);
|
|
141
|
+
|
|
142
|
+
// Re-fetch transitions for new state
|
|
143
|
+
const transitionsRes = await fetch(
|
|
144
|
+
`/api/workflow/${workflowInstanceId}/transitions`,
|
|
145
|
+
{ headers }
|
|
146
|
+
);
|
|
147
|
+
if (transitionsRes.ok) {
|
|
148
|
+
const data = await transitionsRes.json();
|
|
149
|
+
setTransitions(data.transitions || []);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return result;
|
|
153
|
+
} catch (err) {
|
|
154
|
+
setError(err.message);
|
|
155
|
+
throw err;
|
|
156
|
+
} finally {
|
|
157
|
+
setLoading(false);
|
|
158
|
+
}
|
|
159
|
+
}, [workflowInstanceId]);
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Fetch workflow history
|
|
163
|
+
*/
|
|
164
|
+
const fetchHistory = useCallback(async () => {
|
|
165
|
+
if (!workflowInstanceId) return;
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
const res = await fetch(`/api/workflow/${workflowInstanceId}/history`, { headers });
|
|
169
|
+
if (res.ok) {
|
|
170
|
+
const data = await res.json();
|
|
171
|
+
setHistory(data.history || []);
|
|
172
|
+
}
|
|
173
|
+
} catch (err) {
|
|
174
|
+
console.error('Failed to fetch workflow history:', err);
|
|
175
|
+
}
|
|
176
|
+
}, [workflowInstanceId]);
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
transitions,
|
|
180
|
+
workflowState,
|
|
181
|
+
history,
|
|
182
|
+
loading,
|
|
183
|
+
error,
|
|
184
|
+
executeTransition,
|
|
185
|
+
fetchHistory,
|
|
186
|
+
refetch
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export default useWorkflow;
|
package/src/web/index.js
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
// @avento/framework/web
|
|
2
|
-
// React components and hooks for client apps
|
|
3
|
-
|
|
4
|
-
// Components
|
|
5
|
-
export {
|
|
6
|
-
AuthProvider,
|
|
7
|
-
AuthContext,
|
|
8
|
-
TenantProvider,
|
|
9
|
-
TenantContext,
|
|
10
|
-
NotificationProvider,
|
|
11
|
-
useNotification,
|
|
12
|
-
Layout,
|
|
13
|
-
Navigation,
|
|
14
|
-
AppRouter,
|
|
15
|
-
// Universal Config-Driven Components
|
|
16
|
-
Grid,
|
|
17
|
-
Form,
|
|
18
|
-
FormField,
|
|
19
|
-
DetailView,
|
|
20
|
-
// Pagination Components
|
|
21
|
-
Pagination,
|
|
22
|
-
InfiniteScroll,
|
|
23
|
-
// JSON View System
|
|
24
|
-
JsonView,
|
|
25
|
-
JsonViewContext,
|
|
26
|
-
useJsonView,
|
|
27
|
-
ViewComponent,
|
|
28
|
-
ViewToolbar,
|
|
29
|
-
SplitLayout,
|
|
30
|
-
TabLayout,
|
|
31
|
-
SingleLayout,
|
|
32
|
-
// Workflow Components
|
|
33
|
-
WorkflowActions,
|
|
34
|
-
// Shell
|
|
35
|
-
AppShell,
|
|
36
|
-
useShellConfig,
|
|
37
|
-
MobileLayout,
|
|
38
|
-
IconRegistry,
|
|
39
|
-
iconRegistry,
|
|
40
|
-
resolveIcon,
|
|
41
|
-
// Mobile Layouts
|
|
42
|
-
MobileStackLayout,
|
|
43
|
-
CardListLayout,
|
|
44
|
-
FullscreenLayout,
|
|
45
|
-
WizardLayout,
|
|
46
|
-
// Mobile Primitives
|
|
47
|
-
QuickActionButton,
|
|
48
|
-
StatCard,
|
|
49
|
-
EmptyState,
|
|
50
|
-
StarRating,
|
|
51
|
-
Badge,
|
|
52
|
-
BadgeLegend,
|
|
53
|
-
BadgeThemeEditor,
|
|
54
|
-
ServerAutocomplete,
|
|
55
|
-
// List Components
|
|
56
|
-
SimpleList,
|
|
57
|
-
CardList,
|
|
58
|
-
// Auth Components
|
|
59
|
-
DevTenantSelector,
|
|
60
|
-
RegisterForm,
|
|
61
|
-
ForgotPasswordForm,
|
|
62
|
-
ResetPasswordForm,
|
|
63
|
-
VerifyEmailView,
|
|
64
|
-
} from './components/index.js';
|
|
65
|
-
|
|
66
|
-
// Hooks
|
|
67
|
-
export {
|
|
68
|
-
useAuth,
|
|
69
|
-
useTenant,
|
|
70
|
-
useSelectionModel,
|
|
71
|
-
useStore,
|
|
72
|
-
useViews,
|
|
73
|
-
useWorkflow,
|
|
74
|
-
useIsMobile,
|
|
75
|
-
useTenantResolver,
|
|
76
|
-
useSubscription,
|
|
77
|
-
useOfflineQueue,
|
|
78
|
-
enqueueOffline,
|
|
79
|
-
getOfflineQueueLength,
|
|
80
|
-
useDebouncedSave,
|
|
81
|
-
useApi,
|
|
82
|
-
useUndoRedo,
|
|
83
|
-
useServerAutocomplete,
|
|
84
|
-
} from './hooks/index.js';
|
|
85
|
-
|
|
86
|
-
// Utils
|
|
87
|
-
export {
|
|
88
|
-
formatTimeAgo,
|
|
89
|
-
} from './utils/index.js';
|
|
90
|
-
|
|
91
|
-
// Stores
|
|
92
|
-
export {
|
|
93
|
-
BaseStore,
|
|
94
|
-
StoreProvider,
|
|
95
|
-
StoreContext,
|
|
96
|
-
useStoreContext
|
|
97
|
-
} from './stores/index.js';
|
|
98
|
-
|
|
99
|
-
// Views
|
|
100
|
-
export {
|
|
101
|
-
ViewRegistry,
|
|
102
|
-
viewRegistry
|
|
103
|
-
} from './views/index.js';
|
|
104
|
-
|
|
105
|
-
// Theme
|
|
106
|
-
export {
|
|
107
|
-
aventoTheme,
|
|
108
|
-
createAventoTheme,
|
|
109
|
-
mobileThemeOverrides,
|
|
110
|
-
theme
|
|
111
|
-
} from './theme/index.js';
|
|
112
|
-
|
|
113
|
-
// Extensions
|
|
114
|
-
export {
|
|
115
|
-
ExtensionRegistry,
|
|
116
|
-
extensionRegistry
|
|
117
|
-
} from './extensions/index.js';
|
|
1
|
+
// @avento/framework/web
|
|
2
|
+
// React components and hooks for client apps
|
|
3
|
+
|
|
4
|
+
// Components
|
|
5
|
+
export {
|
|
6
|
+
AuthProvider,
|
|
7
|
+
AuthContext,
|
|
8
|
+
TenantProvider,
|
|
9
|
+
TenantContext,
|
|
10
|
+
NotificationProvider,
|
|
11
|
+
useNotification,
|
|
12
|
+
Layout,
|
|
13
|
+
Navigation,
|
|
14
|
+
AppRouter,
|
|
15
|
+
// Universal Config-Driven Components
|
|
16
|
+
Grid,
|
|
17
|
+
Form,
|
|
18
|
+
FormField,
|
|
19
|
+
DetailView,
|
|
20
|
+
// Pagination Components
|
|
21
|
+
Pagination,
|
|
22
|
+
InfiniteScroll,
|
|
23
|
+
// JSON View System
|
|
24
|
+
JsonView,
|
|
25
|
+
JsonViewContext,
|
|
26
|
+
useJsonView,
|
|
27
|
+
ViewComponent,
|
|
28
|
+
ViewToolbar,
|
|
29
|
+
SplitLayout,
|
|
30
|
+
TabLayout,
|
|
31
|
+
SingleLayout,
|
|
32
|
+
// Workflow Components
|
|
33
|
+
WorkflowActions,
|
|
34
|
+
// Shell
|
|
35
|
+
AppShell,
|
|
36
|
+
useShellConfig,
|
|
37
|
+
MobileLayout,
|
|
38
|
+
IconRegistry,
|
|
39
|
+
iconRegistry,
|
|
40
|
+
resolveIcon,
|
|
41
|
+
// Mobile Layouts
|
|
42
|
+
MobileStackLayout,
|
|
43
|
+
CardListLayout,
|
|
44
|
+
FullscreenLayout,
|
|
45
|
+
WizardLayout,
|
|
46
|
+
// Mobile Primitives
|
|
47
|
+
QuickActionButton,
|
|
48
|
+
StatCard,
|
|
49
|
+
EmptyState,
|
|
50
|
+
StarRating,
|
|
51
|
+
Badge,
|
|
52
|
+
BadgeLegend,
|
|
53
|
+
BadgeThemeEditor,
|
|
54
|
+
ServerAutocomplete,
|
|
55
|
+
// List Components
|
|
56
|
+
SimpleList,
|
|
57
|
+
CardList,
|
|
58
|
+
// Auth Components
|
|
59
|
+
DevTenantSelector,
|
|
60
|
+
RegisterForm,
|
|
61
|
+
ForgotPasswordForm,
|
|
62
|
+
ResetPasswordForm,
|
|
63
|
+
VerifyEmailView,
|
|
64
|
+
} from './components/index.js';
|
|
65
|
+
|
|
66
|
+
// Hooks
|
|
67
|
+
export {
|
|
68
|
+
useAuth,
|
|
69
|
+
useTenant,
|
|
70
|
+
useSelectionModel,
|
|
71
|
+
useStore,
|
|
72
|
+
useViews,
|
|
73
|
+
useWorkflow,
|
|
74
|
+
useIsMobile,
|
|
75
|
+
useTenantResolver,
|
|
76
|
+
useSubscription,
|
|
77
|
+
useOfflineQueue,
|
|
78
|
+
enqueueOffline,
|
|
79
|
+
getOfflineQueueLength,
|
|
80
|
+
useDebouncedSave,
|
|
81
|
+
useApi,
|
|
82
|
+
useUndoRedo,
|
|
83
|
+
useServerAutocomplete,
|
|
84
|
+
} from './hooks/index.js';
|
|
85
|
+
|
|
86
|
+
// Utils
|
|
87
|
+
export {
|
|
88
|
+
formatTimeAgo,
|
|
89
|
+
} from './utils/index.js';
|
|
90
|
+
|
|
91
|
+
// Stores
|
|
92
|
+
export {
|
|
93
|
+
BaseStore,
|
|
94
|
+
StoreProvider,
|
|
95
|
+
StoreContext,
|
|
96
|
+
useStoreContext
|
|
97
|
+
} from './stores/index.js';
|
|
98
|
+
|
|
99
|
+
// Views
|
|
100
|
+
export {
|
|
101
|
+
ViewRegistry,
|
|
102
|
+
viewRegistry
|
|
103
|
+
} from './views/index.js';
|
|
104
|
+
|
|
105
|
+
// Theme
|
|
106
|
+
export {
|
|
107
|
+
aventoTheme,
|
|
108
|
+
createAventoTheme,
|
|
109
|
+
mobileThemeOverrides,
|
|
110
|
+
theme
|
|
111
|
+
} from './theme/index.js';
|
|
112
|
+
|
|
113
|
+
// Extensions
|
|
114
|
+
export {
|
|
115
|
+
ExtensionRegistry,
|
|
116
|
+
extensionRegistry
|
|
117
|
+
} from './extensions/index.js';
|