@nodestackapp/server 2.5.0 → 2.7.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/README.md +42 -28
- package/dist/NodeStack.d.ts +5 -1
- package/dist/NodeStack.d.ts.map +1 -1
- package/dist/NodeStack.js +117 -18
- package/dist/NodeStack.js.map +1 -1
- package/dist/admin/AdminUIBundler.d.ts.map +1 -1
- package/dist/admin/AdminUIBundler.js +2 -0
- package/dist/admin/AdminUIBundler.js.map +1 -1
- package/dist/admin/ui/css/main.css +40 -3
- package/dist/admin/ui/css/webhooks.css +8 -0
- package/dist/admin/ui/index.html +21479 -17251
- package/dist/admin/ui/js/api-keys.js +1381 -0
- package/dist/admin/ui/js/api.js +8 -0
- package/dist/admin/ui/js/app.js +698 -641
- package/dist/admin/ui/js/apps.js +514 -489
- package/dist/admin/ui/js/collections.js +486 -484
- package/dist/admin/ui/js/command-palette.js +693 -673
- package/dist/admin/ui/js/cron.js +1706 -0
- package/dist/admin/ui/js/database.js +10 -0
- package/dist/admin/ui/js/flows-designer.js +1219 -1076
- package/dist/admin/ui/js/flows.js +947 -890
- package/dist/admin/ui/js/functions-tester.js +1 -1
- package/dist/admin/ui/js/functions-workbench.js +1162 -1101
- package/dist/admin/ui/js/functions.js +983 -979
- package/dist/admin/ui/js/rules.js +1080 -775
- package/dist/admin/ui/js/schema.js +346 -304
- package/dist/admin/ui/js/snapshots.js +338 -0
- package/dist/admin/ui/js/views.js +1 -1
- package/dist/apps/AppManager.d.ts +1 -1
- package/dist/apps/AppManager.d.ts.map +1 -1
- package/dist/apps/AppManager.js +11 -21
- package/dist/apps/AppManager.js.map +1 -1
- package/dist/apps/AppRegistry.d.ts +1 -0
- package/dist/apps/AppRegistry.d.ts.map +1 -1
- package/dist/apps/AppRegistry.js +78 -23
- package/dist/apps/AppRegistry.js.map +1 -1
- package/dist/apps/AppScope.d.ts +2 -1
- package/dist/apps/AppScope.d.ts.map +1 -1
- package/dist/apps/AppScope.js +27 -17
- package/dist/apps/AppScope.js.map +1 -1
- package/dist/auth/ApiKeyService.d.ts +63 -2
- package/dist/auth/ApiKeyService.d.ts.map +1 -1
- package/dist/auth/ApiKeyService.js +518 -8
- package/dist/auth/ApiKeyService.js.map +1 -1
- package/dist/auth/AuthService.d.ts +30 -1
- package/dist/auth/AuthService.d.ts.map +1 -1
- package/dist/auth/AuthService.js +468 -65
- package/dist/auth/AuthService.js.map +1 -1
- package/dist/auth/oauth/AppleProvider.d.ts +2 -0
- package/dist/auth/oauth/AppleProvider.d.ts.map +1 -1
- package/dist/auth/oauth/AppleProvider.js +40 -3
- package/dist/auth/oauth/AppleProvider.js.map +1 -1
- package/dist/auth/oauth/BaseOAuthProvider.d.ts +3 -2
- package/dist/auth/oauth/BaseOAuthProvider.d.ts.map +1 -1
- package/dist/auth/oauth/BaseOAuthProvider.js +29 -3
- package/dist/auth/oauth/BaseOAuthProvider.js.map +1 -1
- package/dist/auth/oauth/DiscordProvider.d.ts.map +1 -1
- package/dist/auth/oauth/DiscordProvider.js +4 -1
- package/dist/auth/oauth/DiscordProvider.js.map +1 -1
- package/dist/auth/oauth/GitHubProvider.d.ts.map +1 -1
- package/dist/auth/oauth/GitHubProvider.js +4 -1
- package/dist/auth/oauth/GitHubProvider.js.map +1 -1
- package/dist/auth/oauth/GoogleProvider.d.ts.map +1 -1
- package/dist/auth/oauth/GoogleProvider.js +4 -1
- package/dist/auth/oauth/GoogleProvider.js.map +1 -1
- package/dist/auth/oauth/MicrosoftProvider.d.ts.map +1 -1
- package/dist/auth/oauth/MicrosoftProvider.js +4 -1
- package/dist/auth/oauth/MicrosoftProvider.js.map +1 -1
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts +6 -2
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts.map +1 -1
- package/dist/auth/oauth/OAuthProviderRegistry.js +25 -10
- package/dist/auth/oauth/OAuthProviderRegistry.js.map +1 -1
- package/dist/auth/oauth/types.d.ts +4 -2
- package/dist/auth/oauth/types.d.ts.map +1 -1
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +228 -12
- package/dist/cli/cli.js.map +1 -1
- package/dist/core/config/ConfigService.d.ts.map +1 -1
- package/dist/core/config/ConfigService.js +5 -3
- package/dist/core/config/ConfigService.js.map +1 -1
- package/dist/core/config/EnvLoader.d.ts +14 -0
- package/dist/core/config/EnvLoader.d.ts.map +1 -1
- package/dist/core/config/EnvLoader.js +44 -0
- package/dist/core/config/EnvLoader.js.map +1 -1
- package/dist/core/container/Container.d.ts +14 -0
- package/dist/core/container/Container.d.ts.map +1 -1
- package/dist/core/container/Container.js +32 -0
- package/dist/core/container/Container.js.map +1 -1
- package/dist/core/container/Tokens.d.ts +2 -0
- package/dist/core/container/Tokens.d.ts.map +1 -1
- package/dist/core/container/Tokens.js +2 -0
- package/dist/core/container/Tokens.js.map +1 -1
- package/dist/core/errors/AppError.d.ts +7 -7
- package/dist/core/errors/AppError.d.ts.map +1 -1
- package/dist/core/errors/AppError.js +18 -14
- package/dist/core/errors/AppError.js.map +1 -1
- package/dist/core/events/EventBus.d.ts.map +1 -1
- package/dist/core/events/EventBus.js +36 -6
- package/dist/core/events/EventBus.js.map +1 -1
- package/dist/core/maintenance/MaintenanceGate.d.ts +47 -0
- package/dist/core/maintenance/MaintenanceGate.d.ts.map +1 -1
- package/dist/core/maintenance/MaintenanceGate.js +265 -7
- package/dist/core/maintenance/MaintenanceGate.js.map +1 -1
- package/dist/core/plugins/PluginManager.d.ts +20 -1
- package/dist/core/plugins/PluginManager.d.ts.map +1 -1
- package/dist/core/plugins/PluginManager.js +231 -146
- package/dist/core/plugins/PluginManager.js.map +1 -1
- package/dist/core/plugins/types.d.ts +48 -31
- package/dist/core/plugins/types.d.ts.map +1 -1
- package/dist/cron/CronParser.d.ts +83 -0
- package/dist/cron/CronParser.d.ts.map +1 -0
- package/dist/cron/CronParser.js +538 -0
- package/dist/cron/CronParser.js.map +1 -0
- package/dist/cron/CronService.d.ts +74 -0
- package/dist/cron/CronService.d.ts.map +1 -0
- package/dist/cron/CronService.js +1254 -0
- package/dist/cron/CronService.js.map +1 -0
- package/dist/cron/types.d.ts +98 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +3 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/database/DatabaseService.d.ts +4 -1
- package/dist/database/DatabaseService.d.ts.map +1 -1
- package/dist/database/DatabaseService.js +34 -9
- package/dist/database/DatabaseService.js.map +1 -1
- package/dist/database/config/DatabaseConfigService.d.ts +1 -0
- package/dist/database/config/DatabaseConfigService.d.ts.map +1 -1
- package/dist/database/config/DatabaseConfigService.js +4 -2
- package/dist/database/config/DatabaseConfigService.js.map +1 -1
- package/dist/database/drivers/DriverPackageLoader.d.ts +11 -0
- package/dist/database/drivers/DriverPackageLoader.d.ts.map +1 -0
- package/dist/database/drivers/DriverPackageLoader.js +112 -0
- package/dist/database/drivers/DriverPackageLoader.js.map +1 -0
- package/dist/database/drivers/DriverRegistry.d.ts +1 -0
- package/dist/database/drivers/DriverRegistry.d.ts.map +1 -1
- package/dist/database/drivers/DriverRegistry.js +29 -0
- package/dist/database/drivers/DriverRegistry.js.map +1 -1
- package/dist/database/drivers/IDatabaseDriver.d.ts +1 -0
- package/dist/database/drivers/IDatabaseDriver.d.ts.map +1 -1
- package/dist/database/drivers/MssqlDriver.d.ts.map +1 -1
- package/dist/database/drivers/MssqlDriver.js +10 -5
- package/dist/database/drivers/MssqlDriver.js.map +1 -1
- package/dist/database/drivers/NodeSqliteDriver.d.ts.map +1 -1
- package/dist/database/drivers/NodeSqliteDriver.js +15 -1
- package/dist/database/drivers/NodeSqliteDriver.js.map +1 -1
- package/dist/database/drivers/PostgresDriver.d.ts.map +1 -1
- package/dist/database/drivers/PostgresDriver.js +4 -5
- package/dist/database/drivers/PostgresDriver.js.map +1 -1
- package/dist/database/migration/DatabaseMigrationService.d.ts +1 -0
- package/dist/database/migration/DatabaseMigrationService.d.ts.map +1 -1
- package/dist/database/migration/DatabaseMigrationService.js +51 -0
- package/dist/database/migration/DatabaseMigrationService.js.map +1 -1
- package/dist/database/migrations/SystemMigrations.d.ts.map +1 -1
- package/dist/database/migrations/SystemMigrations.js +200 -5
- package/dist/database/migrations/SystemMigrations.js.map +1 -1
- package/dist/flows/FlowEngine.js.map +1 -1
- package/dist/flows/FlowService.d.ts +10 -1
- package/dist/flows/FlowService.d.ts.map +1 -1
- package/dist/flows/FlowService.js +227 -14
- package/dist/flows/FlowService.js.map +1 -1
- package/dist/flows/FlowValidator.d.ts +2 -1
- package/dist/flows/FlowValidator.d.ts.map +1 -1
- package/dist/flows/FlowValidator.js +89 -4
- package/dist/flows/FlowValidator.js.map +1 -1
- package/dist/flows/types.d.ts +20 -3
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/functions/FunctionService.d.ts +10 -2
- package/dist/functions/FunctionService.d.ts.map +1 -1
- package/dist/functions/FunctionService.js +271 -37
- package/dist/functions/FunctionService.js.map +1 -1
- package/dist/functions/runtime/QuickJsWasmRuntime.d.ts.map +1 -1
- package/dist/functions/runtime/QuickJsWasmRuntime.js +189 -177
- package/dist/functions/runtime/QuickJsWasmRuntime.js.map +1 -1
- package/dist/functions/types.d.ts +31 -2
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/http/HttpServer.d.ts +7 -1
- package/dist/http/HttpServer.d.ts.map +1 -1
- package/dist/http/HttpServer.js +187 -8
- package/dist/http/HttpServer.js.map +1 -1
- package/dist/http/controllers/ApiKeyController.d.ts +1 -0
- package/dist/http/controllers/ApiKeyController.d.ts.map +1 -1
- package/dist/http/controllers/ApiKeyController.js +47 -1
- package/dist/http/controllers/ApiKeyController.js.map +1 -1
- package/dist/http/controllers/AuthController.d.ts +12 -0
- package/dist/http/controllers/AuthController.d.ts.map +1 -1
- package/dist/http/controllers/AuthController.js +40 -2
- package/dist/http/controllers/AuthController.js.map +1 -1
- package/dist/http/controllers/CronController.d.ts +63 -0
- package/dist/http/controllers/CronController.d.ts.map +1 -0
- package/dist/http/controllers/CronController.js +92 -0
- package/dist/http/controllers/CronController.js.map +1 -0
- package/dist/http/controllers/DatabaseController.d.ts.map +1 -1
- package/dist/http/controllers/DatabaseController.js +53 -0
- package/dist/http/controllers/DatabaseController.js.map +1 -1
- package/dist/http/controllers/FlowController.d.ts.map +1 -1
- package/dist/http/controllers/FlowController.js +45 -4
- package/dist/http/controllers/FlowController.js.map +1 -1
- package/dist/http/controllers/FunctionController.d.ts.map +1 -1
- package/dist/http/controllers/FunctionController.js +16 -2
- package/dist/http/controllers/FunctionController.js.map +1 -1
- package/dist/http/controllers/HealthController.js +2 -2
- package/dist/http/middleware/AppResolutionMiddleware.d.ts +1 -1
- package/dist/http/middleware/AppResolutionMiddleware.d.ts.map +1 -1
- package/dist/http/middleware/AppResolutionMiddleware.js +2 -3
- package/dist/http/middleware/AppResolutionMiddleware.js.map +1 -1
- package/dist/http/middleware/AuthMiddleware.d.ts.map +1 -1
- package/dist/http/middleware/AuthMiddleware.js +6 -3
- package/dist/http/middleware/AuthMiddleware.js.map +1 -1
- package/dist/http/middleware/ChaosMiddleware.js +6 -6
- package/dist/http/middleware/ChaosMiddleware.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/queue/QueueService.d.ts +9 -0
- package/dist/queue/QueueService.d.ts.map +1 -1
- package/dist/queue/QueueService.js +143 -60
- package/dist/queue/QueueService.js.map +1 -1
- package/dist/queue/drivers/SqliteQueueDriver.d.ts +3 -0
- package/dist/queue/drivers/SqliteQueueDriver.d.ts.map +1 -1
- package/dist/queue/drivers/SqliteQueueDriver.js +315 -255
- package/dist/queue/drivers/SqliteQueueDriver.js.map +1 -1
- package/dist/records/FtsService.d.ts +7 -3
- package/dist/records/FtsService.d.ts.map +1 -1
- package/dist/records/FtsService.js +69 -5
- package/dist/records/FtsService.js.map +1 -1
- package/dist/records/QueryFilterParser.d.ts.map +1 -1
- package/dist/records/QueryFilterParser.js +58 -20
- package/dist/records/QueryFilterParser.js.map +1 -1
- package/dist/records/RecordSanitizer.d.ts.map +1 -1
- package/dist/records/RecordSanitizer.js +32 -4
- package/dist/records/RecordSanitizer.js.map +1 -1
- package/dist/records/RecordService.d.ts +6 -0
- package/dist/records/RecordService.d.ts.map +1 -1
- package/dist/records/RecordService.js +95 -14
- package/dist/records/RecordService.js.map +1 -1
- package/dist/records/RecordValidator.d.ts +10 -0
- package/dist/records/RecordValidator.d.ts.map +1 -1
- package/dist/records/RecordValidator.js +110 -2
- package/dist/records/RecordValidator.js.map +1 -1
- package/dist/records/fts/IFtsDriver.d.ts +7 -6
- package/dist/records/fts/IFtsDriver.d.ts.map +1 -1
- package/dist/records/fts/MssqlFtsDriver.d.ts +5 -1
- package/dist/records/fts/MssqlFtsDriver.d.ts.map +1 -1
- package/dist/records/fts/MssqlFtsDriver.js +35 -3
- package/dist/records/fts/MssqlFtsDriver.js.map +1 -1
- package/dist/records/fts/PostgresFtsDriver.d.ts +9 -2
- package/dist/records/fts/PostgresFtsDriver.d.ts.map +1 -1
- package/dist/records/fts/PostgresFtsDriver.js +116 -11
- package/dist/records/fts/PostgresFtsDriver.js.map +1 -1
- package/dist/records/fts/SqliteFts5Driver.d.ts +7 -1
- package/dist/records/fts/SqliteFts5Driver.d.ts.map +1 -1
- package/dist/records/fts/SqliteFts5Driver.js +66 -6
- package/dist/records/fts/SqliteFts5Driver.js.map +1 -1
- package/dist/schema/OpenApiGenerator.d.ts.map +1 -1
- package/dist/schema/OpenApiGenerator.js +103 -3
- package/dist/schema/OpenApiGenerator.js.map +1 -1
- package/dist/schema/models/Field.d.ts +1 -0
- package/dist/schema/models/Field.d.ts.map +1 -1
- package/dist/snapshots/SnapshotService.d.ts.map +1 -1
- package/dist/snapshots/SnapshotService.js +21 -9
- package/dist/snapshots/SnapshotService.js.map +1 -1
- package/dist/snapshots/drivers/LogicalSnapshotDriver.d.ts.map +1 -1
- package/dist/snapshots/drivers/LogicalSnapshotDriver.js +2 -0
- package/dist/snapshots/drivers/LogicalSnapshotDriver.js.map +1 -1
- package/dist/templates/definitions/ecommerce.js +6 -6
- package/dist/templates/definitions/ecommerce.js.map +1 -1
- package/dist/webhooks/WebhookService.js +1 -1
- package/package.json +5 -3
|
@@ -1,890 +1,947 @@
|
|
|
1
|
-
// Functions Flow Manager Module for NodeStack Admin UI
|
|
2
|
-
// State, flows list overview, executions history, and serverless functions lookup
|
|
3
|
-
|
|
4
|
-
let flowsState = {
|
|
5
|
-
currentView: 'list', // 'list' | 'designer'
|
|
6
|
-
subTab: 'flows', // 'flows' | 'executions'
|
|
7
|
-
flows: [],
|
|
8
|
-
executions: [],
|
|
9
|
-
functions: [], // loaded from /api/functions for dropdowns
|
|
10
|
-
filter: {
|
|
11
|
-
search: '',
|
|
12
|
-
status: 'all',
|
|
13
|
-
},
|
|
14
|
-
activeFlowForEdit: null,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
if (typeof window !== 'undefined') {
|
|
18
|
-
window.flowsState = flowsState;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// ==========================================
|
|
22
|
-
// 1. API Fetching
|
|
23
|
-
// ==========================================
|
|
24
|
-
|
|
25
|
-
function getFlowsApiBase() {
|
|
26
|
-
const slug = typeof getActiveAppSlug === 'function' ? getActiveAppSlug() : (typeof state !== 'undefined' && state?.activeApp?.slug ? state.activeApp.slug : 'default');
|
|
27
|
-
return slug && slug !== 'default' ? `/api/apps/${slug}/flows` : '/api/flows';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getFunctionsApiBase() {
|
|
31
|
-
const slug = typeof getActiveAppSlug === 'function' ? getActiveAppSlug() : (typeof state !== 'undefined' && state?.activeApp?.slug ? state.activeApp.slug : 'default');
|
|
32
|
-
return slug && slug !== 'default' ? `/api/apps/${slug}/functions` : '/api/functions';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (typeof window !== 'undefined') {
|
|
36
|
-
window.getFlowsApiBase = getFlowsApiBase;
|
|
37
|
-
window.getFunctionsApiBase = getFunctionsApiBase;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function loadFlows() {
|
|
41
|
-
try {
|
|
42
|
-
const endpoint = getFlowsApiBase();
|
|
43
|
-
const res = await api(endpoint);
|
|
44
|
-
flowsState.flows = Array.isArray(res) ? res : res?.data || [];
|
|
45
|
-
updateSidebarFlowsCount();
|
|
46
|
-
return flowsState.flows;
|
|
47
|
-
} catch (err) {
|
|
48
|
-
console.error('Failed to load flows:', err);
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function loadFlowExecutions(flowId = '') {
|
|
54
|
-
try {
|
|
55
|
-
const base = getFlowsApiBase();
|
|
56
|
-
const statusParam = flowsState.filter?.status && flowsState.filter.status !== 'all'
|
|
57
|
-
? `?status=${encodeURIComponent(flowsState.filter.status)}`
|
|
58
|
-
: '';
|
|
59
|
-
const url = flowId ? `${base}/${flowId}/executions${statusParam}` : `${base}/executions${statusParam}`;
|
|
60
|
-
const res = await api(url);
|
|
61
|
-
flowsState.executions = res?.items || (Array.isArray(res) ? res : []);
|
|
62
|
-
return flowsState.executions;
|
|
63
|
-
} catch (err) {
|
|
64
|
-
console.error('Failed to load flow executions:', err);
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async function loadFunctionsForPicker() {
|
|
70
|
-
try {
|
|
71
|
-
const endpoint = getFunctionsApiBase();
|
|
72
|
-
const res = await api(endpoint);
|
|
73
|
-
flowsState.functions = Array.isArray(res) ? res : res?.data || [];
|
|
74
|
-
} catch (err) {
|
|
75
|
-
console.error('Failed to load functions for picker:', err);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function updateSidebarFlowsCount() {
|
|
80
|
-
const count = (flowsState.flows || []).length;
|
|
81
|
-
const badge = document.getElementById('sidebar-flows-count');
|
|
82
|
-
if (badge) {
|
|
83
|
-
badge.textContent = count;
|
|
84
|
-
badge.style.display = count > 0 ? 'inline-block' : 'none';
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const homeFlowEl = document.getElementById('home-stat-flows');
|
|
88
|
-
const homeFlowSubEl = document.getElementById('home-stat-flows-sub');
|
|
89
|
-
if (homeFlowEl) {
|
|
90
|
-
homeFlowEl.textContent = String(count);
|
|
91
|
-
}
|
|
92
|
-
if (homeFlowSubEl) {
|
|
93
|
-
const active = (flowsState.flows || []).filter(f => f.enabled !== false).length;
|
|
94
|
-
const runs = (flowsState.executions && Array.isArray(flowsState.executions)) ? flowsState.executions.length : 0;
|
|
95
|
-
homeFlowSubEl.textContent = `${active} active${runs > 0 ? ` • ${runs} runs` : ' • visual pipelines'}`;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ==========================================
|
|
100
|
-
// 2. Flows Overview Page Render
|
|
101
|
-
// ==========================================
|
|
102
|
-
|
|
103
|
-
async function renderFlowsView() {
|
|
104
|
-
if (flowsState.currentView === 'designer') {
|
|
105
|
-
const active = (typeof designerState !== 'undefined' && designerState.activeFlow)
|
|
106
|
-
? designerState.activeFlow
|
|
107
|
-
: flowsState.activeFlowForEdit;
|
|
108
|
-
if (active && typeof renderFlowDesignerWorkbench === 'function') {
|
|
109
|
-
renderFlowDesignerWorkbench(active);
|
|
110
|
-
}
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const container = document.getElementById('page-view-flows') || document.getElementById('main-body');
|
|
115
|
-
if (!container) return;
|
|
116
|
-
|
|
117
|
-
container.innerHTML = `
|
|
118
|
-
<div class="flows-container">
|
|
119
|
-
<!-- Header -->
|
|
120
|
-
<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;">
|
|
121
|
-
<div>
|
|
122
|
-
<h2 style="font-size: 1.35rem; font-weight: 700; color: var(--text-main); margin: 0 0 0.25rem 0; display: flex; align-items: center; gap: 0.5rem;">
|
|
123
|
-
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
124
|
-
<circle cx="12" cy="5" r="3"/><line x1="12" y1="8" x2="12" y2="12"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="19" r="3"/><path d="M12 12h-6v4"/><path d="M12 12h6v4"/>
|
|
125
|
-
</svg>
|
|
126
|
-
Functions Flow
|
|
127
|
-
</h2>
|
|
128
|
-
<p style="font-size: 0.85rem; color: var(--text-muted); margin: 0;">
|
|
129
|
-
Visual state machine orchestration for chaining serverless functions with branching, loops, and map-reduce.
|
|
130
|
-
</p>
|
|
131
|
-
</div>
|
|
132
|
-
<div style="display: flex; align-items: center; gap: 8px;">
|
|
133
|
-
<button class="btn btn-secondary btn-sm" onclick="refreshFlowsView()" title="Refresh Flows">
|
|
134
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 4v6h-6M1 20v-6h6"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
|
|
135
|
-
Refresh
|
|
136
|
-
</button>
|
|
137
|
-
<button class="btn btn-primary btn-sm" onclick="openCreateFlowModal()">
|
|
138
|
-
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
|
139
|
-
New Flow
|
|
140
|
-
</button>
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
|
|
144
|
-
<!-- Stats Grid -->
|
|
145
|
-
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem;">
|
|
146
|
-
<div class="webhook-stat-card">
|
|
147
|
-
<span class="webhook-stat-label">Total Flows</span>
|
|
148
|
-
<div class="webhook-stat-value">
|
|
149
|
-
<span id="flow-stat-total">${flowsState.flows.length}</span>
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
<div class="webhook-stat-card">
|
|
153
|
-
<span class="webhook-stat-label">Active Flows</span>
|
|
154
|
-
<div class="webhook-stat-value">
|
|
155
|
-
<span id="flow-stat-active" style="color: var(--accent-success);">${flowsState.flows.filter(f => f.enabled).length}</span>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
<div class="webhook-stat-card">
|
|
159
|
-
<span class="webhook-stat-label">Available Functions</span>
|
|
160
|
-
<div class="webhook-stat-value" id="flow-stat-functions">
|
|
161
|
-
${flowsState.functions.length}
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
</div>
|
|
165
|
-
|
|
166
|
-
<!-- Subtabs Bar -->
|
|
167
|
-
<div style="display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-subtle, #334155); padding-bottom: 0.5rem; margin-top: 0.5rem;">
|
|
168
|
-
<div style="display: flex; gap: 1rem;">
|
|
169
|
-
<button class="btn-subtab ${flowsState.subTab === 'flows' ? 'active' : ''}" onclick="switchFlowsTab('flows')" style="background:none; border:none; color: ${flowsState.subTab === 'flows' ? 'var(--accent-primary, #6366f1)' : 'var(--text-muted)'}; font-weight: 600; font-size: 0.9rem; cursor: pointer; padding: 0.25rem 0.5rem; border-bottom: 2px solid ${flowsState.subTab === 'flows' ? 'var(--accent-primary, #6366f1)' : 'transparent'};">
|
|
170
|
-
Configured Flows (${flowsState.flows.length})
|
|
171
|
-
</button>
|
|
172
|
-
<button class="btn-subtab ${flowsState.subTab === 'executions' ? 'active' : ''}" onclick="switchFlowsTab('executions')" style="background:none; border:none; color: ${flowsState.subTab === 'executions' ? 'var(--accent-primary, #6366f1)' : 'var(--text-muted)'}; font-weight: 600; font-size: 0.9rem; cursor: pointer; padding: 0.25rem 0.5rem; border-bottom: 2px solid ${flowsState.subTab === 'executions' ? 'var(--accent-primary, #6366f1)' : 'transparent'};">
|
|
173
|
-
Execution History
|
|
174
|
-
</button>
|
|
175
|
-
</div>
|
|
176
|
-
<div style="display: flex; align-items: center; gap: 8px;">
|
|
177
|
-
${flowsState.subTab === 'executions' ? `
|
|
178
|
-
<select
|
|
179
|
-
id="flows-status-filter"
|
|
180
|
-
class="flow-field-select"
|
|
181
|
-
style="width: 145px; font-size: 0.8rem;"
|
|
182
|
-
onchange="handleFlowExecutionsStatusFilter(this.value)"
|
|
183
|
-
>
|
|
184
|
-
<option value="all" ${(flowsState.filter.status || 'all') === 'all' ? 'selected' : ''}>All Statuses</option>
|
|
185
|
-
<option value="queued" ${flowsState.filter.status === 'queued' ? 'selected' : ''}>Queued</option>
|
|
186
|
-
<option value="running" ${flowsState.filter.status === 'running' ? 'selected' : ''}>Running</option>
|
|
187
|
-
<option value="succeeded" ${flowsState.filter.status === 'succeeded' ? 'selected' : ''}>Succeeded</option>
|
|
188
|
-
<option value="failed" ${flowsState.filter.status === 'failed' ? 'selected' : ''}>Failed</option>
|
|
189
|
-
<option value="aborted" ${flowsState.filter.status === 'aborted' ? 'selected' : ''}>Aborted</option>
|
|
190
|
-
<option value="timeout" ${flowsState.filter.status === 'timeout' ? 'selected' : ''}>Timeout</option>
|
|
191
|
-
</select>
|
|
192
|
-
` : ''}
|
|
193
|
-
<input
|
|
194
|
-
type="text"
|
|
195
|
-
id="flows-search-input"
|
|
196
|
-
class="flow-field-input"
|
|
197
|
-
placeholder="Search flows by name..."
|
|
198
|
-
style="width: 220px;"
|
|
199
|
-
value="${escapeHtml(flowsState.filter.search || '')}"
|
|
200
|
-
oninput="handleFlowsSearch(this.value)"
|
|
201
|
-
/>
|
|
202
|
-
</div>
|
|
203
|
-
</div>
|
|
204
|
-
|
|
205
|
-
<!-- Content Section -->
|
|
206
|
-
<div id="flows-subtab-content">
|
|
207
|
-
${flowsState.subTab === 'flows' ? renderFlowsListHtml() : renderFlowExecutionsListHtml()}
|
|
208
|
-
</div>
|
|
209
|
-
</div>
|
|
210
|
-
`;
|
|
211
|
-
|
|
212
|
-
// Pre-load data in background
|
|
213
|
-
if (flowsState.functions.length === 0) {
|
|
214
|
-
loadFunctionsForPicker().then(() => {
|
|
215
|
-
const el = document.getElementById('flow-stat-functions');
|
|
216
|
-
if (el) el.textContent = flowsState.functions.length;
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function renderFlowsListHtml() {
|
|
222
|
-
const filtered = flowsState.flows.filter(f => {
|
|
223
|
-
if (!flowsState.filter.search) return true;
|
|
224
|
-
const q = flowsState.filter.search.toLowerCase();
|
|
225
|
-
return f.name.toLowerCase().includes(q) || (f.description && f.description.toLowerCase().includes(q));
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
if (filtered.length === 0) {
|
|
229
|
-
return `
|
|
230
|
-
<div style="text-align: center; padding: 4rem 2rem; background: var(--bg-card); border: 1px dashed var(--border-subtle); border-radius: 8px;">
|
|
231
|
-
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="var(--text-muted)" stroke-width="1.5" style="margin-bottom: 1rem;"><circle cx="12" cy="5" r="3"/><line x1="12" y1="8" x2="12" y2="12"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="19" r="3"/><path d="M12 12h-6v4"/><path d="M12 12h6v4"/></svg>
|
|
232
|
-
<h3 style="font-size: 1.1rem; color: var(--text-main); margin: 0 0 0.5rem 0;">No Functions Flows Yet</h3>
|
|
233
|
-
<p style="color: var(--text-muted); font-size: 0.85rem; max-width: 420px; margin: 0 auto 1.25rem auto;">
|
|
234
|
-
Create a state machine flow to connect serverless functions, add conditional branching, loops, or batch map-reduce.
|
|
235
|
-
</p>
|
|
236
|
-
<button class="btn btn-primary btn-sm" onclick="openCreateFlowModal()">
|
|
237
|
-
+ Create First Flow
|
|
238
|
-
</button>
|
|
239
|
-
</div>
|
|
240
|
-
`;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return `
|
|
244
|
-
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem;">
|
|
245
|
-
${filtered.map(flow => {
|
|
246
|
-
const stateCount = flow.definition && flow.definition.states ? Object.keys(flow.definition.states).length : 0;
|
|
247
|
-
return `
|
|
248
|
-
<div class="webhook-stat-card" style="cursor: default;">
|
|
249
|
-
<div style="display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;">
|
|
250
|
-
<div>
|
|
251
|
-
<
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
</
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
</
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
<span
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
<
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
<th style="padding: 0.75rem 1rem;">
|
|
316
|
-
<th style="padding: 0.75rem 1rem;">
|
|
317
|
-
<th style="padding: 0.75rem 1rem;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (typeof
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
await
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
<
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
function
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
<
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
</span>
|
|
783
|
-
<
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
if (typeof
|
|
889
|
-
|
|
890
|
-
|
|
1
|
+
// Functions Flow Manager Module for NodeStack Admin UI
|
|
2
|
+
// State, flows list overview, executions history, and serverless functions lookup
|
|
3
|
+
|
|
4
|
+
let flowsState = {
|
|
5
|
+
currentView: 'list', // 'list' | 'designer'
|
|
6
|
+
subTab: 'flows', // 'flows' | 'executions'
|
|
7
|
+
flows: [],
|
|
8
|
+
executions: [],
|
|
9
|
+
functions: [], // loaded from /api/functions for dropdowns
|
|
10
|
+
filter: {
|
|
11
|
+
search: '',
|
|
12
|
+
status: 'all',
|
|
13
|
+
},
|
|
14
|
+
activeFlowForEdit: null,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
if (typeof window !== 'undefined') {
|
|
18
|
+
window.flowsState = flowsState;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ==========================================
|
|
22
|
+
// 1. API Fetching
|
|
23
|
+
// ==========================================
|
|
24
|
+
|
|
25
|
+
function getFlowsApiBase() {
|
|
26
|
+
const slug = typeof getActiveAppSlug === 'function' ? getActiveAppSlug() : (typeof state !== 'undefined' && state?.activeApp?.slug ? state.activeApp.slug : 'default');
|
|
27
|
+
return slug && slug !== 'default' ? `/api/apps/${slug}/flows` : '/api/flows';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getFunctionsApiBase() {
|
|
31
|
+
const slug = typeof getActiveAppSlug === 'function' ? getActiveAppSlug() : (typeof state !== 'undefined' && state?.activeApp?.slug ? state.activeApp.slug : 'default');
|
|
32
|
+
return slug && slug !== 'default' ? `/api/apps/${slug}/functions` : '/api/functions';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof window !== 'undefined') {
|
|
36
|
+
window.getFlowsApiBase = getFlowsApiBase;
|
|
37
|
+
window.getFunctionsApiBase = getFunctionsApiBase;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function loadFlows() {
|
|
41
|
+
try {
|
|
42
|
+
const endpoint = getFlowsApiBase();
|
|
43
|
+
const res = await api(endpoint);
|
|
44
|
+
flowsState.flows = Array.isArray(res) ? res : res?.data || [];
|
|
45
|
+
updateSidebarFlowsCount();
|
|
46
|
+
return flowsState.flows;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
console.error('Failed to load flows:', err);
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function loadFlowExecutions(flowId = '') {
|
|
54
|
+
try {
|
|
55
|
+
const base = getFlowsApiBase();
|
|
56
|
+
const statusParam = flowsState.filter?.status && flowsState.filter.status !== 'all'
|
|
57
|
+
? `?status=${encodeURIComponent(flowsState.filter.status)}`
|
|
58
|
+
: '';
|
|
59
|
+
const url = flowId ? `${base}/${flowId}/executions${statusParam}` : `${base}/executions${statusParam}`;
|
|
60
|
+
const res = await api(url);
|
|
61
|
+
flowsState.executions = res?.items || (Array.isArray(res) ? res : []);
|
|
62
|
+
return flowsState.executions;
|
|
63
|
+
} catch (err) {
|
|
64
|
+
console.error('Failed to load flow executions:', err);
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function loadFunctionsForPicker() {
|
|
70
|
+
try {
|
|
71
|
+
const endpoint = getFunctionsApiBase();
|
|
72
|
+
const res = await api(endpoint);
|
|
73
|
+
flowsState.functions = Array.isArray(res) ? res : res?.data || [];
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error('Failed to load functions for picker:', err);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function updateSidebarFlowsCount() {
|
|
80
|
+
const count = (flowsState.flows || []).length;
|
|
81
|
+
const badge = document.getElementById('sidebar-flows-count');
|
|
82
|
+
if (badge) {
|
|
83
|
+
badge.textContent = count;
|
|
84
|
+
badge.style.display = count > 0 ? 'inline-block' : 'none';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const homeFlowEl = document.getElementById('home-stat-flows');
|
|
88
|
+
const homeFlowSubEl = document.getElementById('home-stat-flows-sub');
|
|
89
|
+
if (homeFlowEl) {
|
|
90
|
+
homeFlowEl.textContent = String(count);
|
|
91
|
+
}
|
|
92
|
+
if (homeFlowSubEl) {
|
|
93
|
+
const active = (flowsState.flows || []).filter(f => f.enabled !== false).length;
|
|
94
|
+
const runs = (flowsState.executions && Array.isArray(flowsState.executions)) ? flowsState.executions.length : 0;
|
|
95
|
+
homeFlowSubEl.textContent = `${active} active${runs > 0 ? ` • ${runs} runs` : ' • visual pipelines'}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ==========================================
|
|
100
|
+
// 2. Flows Overview Page Render
|
|
101
|
+
// ==========================================
|
|
102
|
+
|
|
103
|
+
async function renderFlowsView() {
|
|
104
|
+
if (flowsState.currentView === 'designer') {
|
|
105
|
+
const active = (typeof designerState !== 'undefined' && designerState.activeFlow)
|
|
106
|
+
? designerState.activeFlow
|
|
107
|
+
: flowsState.activeFlowForEdit;
|
|
108
|
+
if (active && typeof renderFlowDesignerWorkbench === 'function') {
|
|
109
|
+
renderFlowDesignerWorkbench(active);
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const container = document.getElementById('page-view-flows') || document.getElementById('main-body');
|
|
115
|
+
if (!container) return;
|
|
116
|
+
|
|
117
|
+
container.innerHTML = `
|
|
118
|
+
<div class="flows-container">
|
|
119
|
+
<!-- Header -->
|
|
120
|
+
<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;">
|
|
121
|
+
<div>
|
|
122
|
+
<h2 style="font-size: 1.35rem; font-weight: 700; color: var(--text-main); margin: 0 0 0.25rem 0; display: flex; align-items: center; gap: 0.5rem;">
|
|
123
|
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
124
|
+
<circle cx="12" cy="5" r="3"/><line x1="12" y1="8" x2="12" y2="12"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="19" r="3"/><path d="M12 12h-6v4"/><path d="M12 12h6v4"/>
|
|
125
|
+
</svg>
|
|
126
|
+
Functions Flow
|
|
127
|
+
</h2>
|
|
128
|
+
<p style="font-size: 0.85rem; color: var(--text-muted); margin: 0;">
|
|
129
|
+
Visual state machine orchestration for chaining serverless functions with branching, loops, and map-reduce.
|
|
130
|
+
</p>
|
|
131
|
+
</div>
|
|
132
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
133
|
+
<button class="btn btn-secondary btn-sm" onclick="refreshFlowsView()" title="Refresh Flows">
|
|
134
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 4v6h-6M1 20v-6h6"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
|
|
135
|
+
Refresh
|
|
136
|
+
</button>
|
|
137
|
+
<button class="btn btn-primary btn-sm" onclick="openCreateFlowModal()">
|
|
138
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
|
139
|
+
New Flow
|
|
140
|
+
</button>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<!-- Stats Grid -->
|
|
145
|
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem;">
|
|
146
|
+
<div class="webhook-stat-card">
|
|
147
|
+
<span class="webhook-stat-label">Total Flows</span>
|
|
148
|
+
<div class="webhook-stat-value">
|
|
149
|
+
<span id="flow-stat-total">${flowsState.flows.length}</span>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="webhook-stat-card">
|
|
153
|
+
<span class="webhook-stat-label">Active Flows</span>
|
|
154
|
+
<div class="webhook-stat-value">
|
|
155
|
+
<span id="flow-stat-active" style="color: var(--accent-success);">${flowsState.flows.filter(f => f.enabled).length}</span>
|
|
156
|
+
</div>
|
|
157
|
+
</div>
|
|
158
|
+
<div class="webhook-stat-card">
|
|
159
|
+
<span class="webhook-stat-label">Available Functions</span>
|
|
160
|
+
<div class="webhook-stat-value" id="flow-stat-functions">
|
|
161
|
+
${flowsState.functions.length}
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<!-- Subtabs Bar -->
|
|
167
|
+
<div style="display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border-subtle, #334155); padding-bottom: 0.5rem; margin-top: 0.5rem;">
|
|
168
|
+
<div style="display: flex; gap: 1rem;">
|
|
169
|
+
<button class="btn-subtab ${flowsState.subTab === 'flows' ? 'active' : ''}" onclick="switchFlowsTab('flows')" style="background:none; border:none; color: ${flowsState.subTab === 'flows' ? 'var(--accent-primary, #6366f1)' : 'var(--text-muted)'}; font-weight: 600; font-size: 0.9rem; cursor: pointer; padding: 0.25rem 0.5rem; border-bottom: 2px solid ${flowsState.subTab === 'flows' ? 'var(--accent-primary, #6366f1)' : 'transparent'};">
|
|
170
|
+
Configured Flows (${flowsState.flows.length})
|
|
171
|
+
</button>
|
|
172
|
+
<button class="btn-subtab ${flowsState.subTab === 'executions' ? 'active' : ''}" onclick="switchFlowsTab('executions')" style="background:none; border:none; color: ${flowsState.subTab === 'executions' ? 'var(--accent-primary, #6366f1)' : 'var(--text-muted)'}; font-weight: 600; font-size: 0.9rem; cursor: pointer; padding: 0.25rem 0.5rem; border-bottom: 2px solid ${flowsState.subTab === 'executions' ? 'var(--accent-primary, #6366f1)' : 'transparent'};">
|
|
173
|
+
Execution History
|
|
174
|
+
</button>
|
|
175
|
+
</div>
|
|
176
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
177
|
+
${flowsState.subTab === 'executions' ? `
|
|
178
|
+
<select
|
|
179
|
+
id="flows-status-filter"
|
|
180
|
+
class="flow-field-select"
|
|
181
|
+
style="width: 145px; font-size: 0.8rem;"
|
|
182
|
+
onchange="handleFlowExecutionsStatusFilter(this.value)"
|
|
183
|
+
>
|
|
184
|
+
<option value="all" ${(flowsState.filter.status || 'all') === 'all' ? 'selected' : ''}>All Statuses</option>
|
|
185
|
+
<option value="queued" ${flowsState.filter.status === 'queued' ? 'selected' : ''}>Queued</option>
|
|
186
|
+
<option value="running" ${flowsState.filter.status === 'running' ? 'selected' : ''}>Running</option>
|
|
187
|
+
<option value="succeeded" ${flowsState.filter.status === 'succeeded' ? 'selected' : ''}>Succeeded</option>
|
|
188
|
+
<option value="failed" ${flowsState.filter.status === 'failed' ? 'selected' : ''}>Failed</option>
|
|
189
|
+
<option value="aborted" ${flowsState.filter.status === 'aborted' ? 'selected' : ''}>Aborted</option>
|
|
190
|
+
<option value="timeout" ${flowsState.filter.status === 'timeout' ? 'selected' : ''}>Timeout</option>
|
|
191
|
+
</select>
|
|
192
|
+
` : ''}
|
|
193
|
+
<input
|
|
194
|
+
type="text"
|
|
195
|
+
id="flows-search-input"
|
|
196
|
+
class="flow-field-input"
|
|
197
|
+
placeholder="Search flows by name..."
|
|
198
|
+
style="width: 220px;"
|
|
199
|
+
value="${escapeHtml(flowsState.filter.search || '')}"
|
|
200
|
+
oninput="handleFlowsSearch(this.value)"
|
|
201
|
+
/>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<!-- Content Section -->
|
|
206
|
+
<div id="flows-subtab-content">
|
|
207
|
+
${flowsState.subTab === 'flows' ? renderFlowsListHtml() : renderFlowExecutionsListHtml()}
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
`;
|
|
211
|
+
|
|
212
|
+
// Pre-load data in background
|
|
213
|
+
if (flowsState.functions.length === 0) {
|
|
214
|
+
loadFunctionsForPicker().then(() => {
|
|
215
|
+
const el = document.getElementById('flow-stat-functions');
|
|
216
|
+
if (el) el.textContent = flowsState.functions.length;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function renderFlowsListHtml() {
|
|
222
|
+
const filtered = flowsState.flows.filter(f => {
|
|
223
|
+
if (!flowsState.filter.search) return true;
|
|
224
|
+
const q = flowsState.filter.search.toLowerCase();
|
|
225
|
+
return f.name.toLowerCase().includes(q) || (f.description && f.description.toLowerCase().includes(q));
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
if (filtered.length === 0) {
|
|
229
|
+
return `
|
|
230
|
+
<div style="text-align: center; padding: 4rem 2rem; background: var(--bg-card); border: 1px dashed var(--border-subtle); border-radius: 8px;">
|
|
231
|
+
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="var(--text-muted)" stroke-width="1.5" style="margin-bottom: 1rem;"><circle cx="12" cy="5" r="3"/><line x1="12" y1="8" x2="12" y2="12"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="19" r="3"/><path d="M12 12h-6v4"/><path d="M12 12h6v4"/></svg>
|
|
232
|
+
<h3 style="font-size: 1.1rem; color: var(--text-main); margin: 0 0 0.5rem 0;">No Functions Flows Yet</h3>
|
|
233
|
+
<p style="color: var(--text-muted); font-size: 0.85rem; max-width: 420px; margin: 0 auto 1.25rem auto;">
|
|
234
|
+
Create a state machine flow to connect serverless functions, add conditional branching, loops, or batch map-reduce.
|
|
235
|
+
</p>
|
|
236
|
+
<button class="btn btn-primary btn-sm" onclick="openCreateFlowModal()">
|
|
237
|
+
+ Create First Flow
|
|
238
|
+
</button>
|
|
239
|
+
</div>
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return `
|
|
244
|
+
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem;">
|
|
245
|
+
${filtered.map(flow => {
|
|
246
|
+
const stateCount = flow.definition && flow.definition.states ? Object.keys(flow.definition.states).length : 0;
|
|
247
|
+
return `
|
|
248
|
+
<div class="webhook-stat-card" style="cursor: default;">
|
|
249
|
+
<div style="display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem;">
|
|
250
|
+
<div>
|
|
251
|
+
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
|
|
252
|
+
<h4 style="margin: 0; font-size: 1rem; color: var(--text-main); font-weight: 600;">
|
|
253
|
+
${escapeHtml(flow.name)}
|
|
254
|
+
</h4>
|
|
255
|
+
<code style="font-size: 10px; color: var(--text-muted); background: var(--bg-card-hover); padding: 1px 5px; border-radius: 4px;" title="Unique Flow ID">${escapeHtml(flow.id)}</code>
|
|
256
|
+
</div>
|
|
257
|
+
<p style="margin: 0.25rem 0 0 0; font-size: 0.8rem; color: var(--text-muted); min-height: 1.2rem;">
|
|
258
|
+
${escapeHtml(flow.description || 'No description provided')}
|
|
259
|
+
</p>
|
|
260
|
+
</div>
|
|
261
|
+
<span class="badge ${flow.enabled ? 'badge-get' : 'badge-danger'}" style="font-size: 10px;">
|
|
262
|
+
${flow.enabled ? 'ACTIVE' : 'DISABLED'}
|
|
263
|
+
</span>
|
|
264
|
+
</div>
|
|
265
|
+
|
|
266
|
+
<div style="display: flex; align-items: center; gap: 0.75rem; margin: 0.75rem 0; font-size: 0.75rem; color: var(--text-muted); flex-wrap: wrap;">
|
|
267
|
+
<span><strong>Trigger:</strong> <code style="color: var(--accent-primary);">${formatFlowTriggerLabel(flow)}</code></span>
|
|
268
|
+
${flow.triggerType === 'http' ? `<span>•</span><span><strong>Auth:</strong> <code style="color: var(--text-heading);">${escapeHtml((flow.authPolicy || 'public').toUpperCase())}</code></span>` : ''}
|
|
269
|
+
<span>•</span>
|
|
270
|
+
<span><strong>Steps:</strong> ${stateCount} states</span>
|
|
271
|
+
<span>•</span>
|
|
272
|
+
<span><strong>Concurrency:</strong> ${flow.maxConcurrentExecutions ? escapeHtml(String(flow.maxConcurrentExecutions)) : 'Unlimited'}</span>
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<div style="display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border-subtle); padding-top: 0.75rem; margin-top: auto;">
|
|
276
|
+
<div style="display: flex; gap: 6px;">
|
|
277
|
+
<button class="btn btn-primary btn-sm" data-flow-id="${escapeHtml(flow.id)}" onclick="openFlowDesigner(this.getAttribute('data-flow-id'))" style="font-weight: 600;">
|
|
278
|
+
Open Designer
|
|
279
|
+
</button>
|
|
280
|
+
<button class="btn btn-secondary btn-sm" data-flow-id="${escapeHtml(flow.id)}" onclick="quickTestFlow(this.getAttribute('data-flow-id'))" title="Test Flow Execution">
|
|
281
|
+
▶ Run
|
|
282
|
+
</button>
|
|
283
|
+
</div>
|
|
284
|
+
<div style="display: flex; gap: 6px;">
|
|
285
|
+
<button class="btn btn-secondary btn-sm" data-flow-id="${escapeHtml(flow.id)}" data-enabled="${!flow.enabled}" onclick="toggleFlowStatus(this.getAttribute('data-flow-id'), this.getAttribute('data-enabled') === 'true')" title="${flow.enabled ? 'Disable' : 'Enable'}">
|
|
286
|
+
${flow.enabled ? 'Disable' : 'Enable'}
|
|
287
|
+
</button>
|
|
288
|
+
<button class="btn btn-danger btn-sm" data-flow-id="${escapeHtml(flow.id)}" data-flow-name="${escapeHtml(flow.name)}" onclick="deleteFlowPrompt(this.getAttribute('data-flow-id'), this.getAttribute('data-flow-name'))" title="Delete Flow">
|
|
289
|
+
🗑
|
|
290
|
+
</button>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
`;
|
|
295
|
+
}).join('')}
|
|
296
|
+
</div>
|
|
297
|
+
`;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function renderFlowExecutionsListHtml() {
|
|
301
|
+
const executions = flowsState.executions || [];
|
|
302
|
+
if (executions.length === 0) {
|
|
303
|
+
return `
|
|
304
|
+
<div style="text-align: center; padding: 3rem; background: var(--bg-card); border-radius: 8px; color: var(--text-muted);">
|
|
305
|
+
<p style="margin: 0;">No flow executions recorded yet. Run a flow to inspect step timeline and logs.</p>
|
|
306
|
+
</div>
|
|
307
|
+
`;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return `
|
|
311
|
+
<div style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 8px; overflow: hidden;">
|
|
312
|
+
<table style="width: 100%; border-collapse: collapse; font-size: 0.85rem; text-align: left;">
|
|
313
|
+
<thead>
|
|
314
|
+
<tr style="background: rgba(0,0,0,0.15); border-bottom: 1px solid var(--border-subtle); color: var(--text-muted);">
|
|
315
|
+
<th style="padding: 0.75rem 1rem;">Status</th>
|
|
316
|
+
<th style="padding: 0.75rem 1rem;">Flow Name</th>
|
|
317
|
+
<th style="padding: 0.75rem 1rem;">Duration</th>
|
|
318
|
+
<th style="padding: 0.75rem 1rem;">Steps</th>
|
|
319
|
+
<th style="padding: 0.75rem 1rem;">Caller</th>
|
|
320
|
+
<th style="padding: 0.75rem 1rem;">Started At</th>
|
|
321
|
+
<th style="padding: 0.75rem 1rem; text-align: right;">Action</th>
|
|
322
|
+
</tr>
|
|
323
|
+
</thead>
|
|
324
|
+
<tbody>
|
|
325
|
+
${executions.map(exec => {
|
|
326
|
+
const statusColor = exec.status === 'succeeded' ? 'var(--accent-success)' : exec.status === 'failed' ? 'var(--accent-danger)' : (exec.status === 'aborted' || exec.status === 'queued') ? 'var(--accent-warning, #f59e0b)' : '#3b82f6';
|
|
327
|
+
const stepCount = (exec.stepLogs || []).length;
|
|
328
|
+
return `
|
|
329
|
+
<tr style="border-bottom: 1px solid var(--border-subtle);">
|
|
330
|
+
<td style="padding: 0.75rem 1rem;">
|
|
331
|
+
<span style="font-weight: 700; color: ${statusColor}; text-transform: uppercase; font-size: 0.75rem;">
|
|
332
|
+
● ${exec.status}
|
|
333
|
+
</span>
|
|
334
|
+
</td>
|
|
335
|
+
<td style="padding: 0.75rem 1rem; font-weight: 600; color: var(--text-main);">
|
|
336
|
+
${escapeHtml(exec.flowName)}
|
|
337
|
+
</td>
|
|
338
|
+
<td style="padding: 0.75rem 1rem; color: var(--text-muted);">
|
|
339
|
+
${exec.durationMs}ms
|
|
340
|
+
</td>
|
|
341
|
+
<td style="padding: 0.75rem 1rem; color: var(--text-muted);">
|
|
342
|
+
${stepCount} steps
|
|
343
|
+
</td>
|
|
344
|
+
<td style="padding: 0.75rem 1rem; font-family: var(--font-mono, monospace); font-size: 0.8rem; color: var(--text-muted);">
|
|
345
|
+
<span class="badge" style="font-size: 11px; font-weight: 500; background: rgba(255,255,255,0.06);">${escapeHtml(exec.actorId || 'public')}</span>
|
|
346
|
+
</td>
|
|
347
|
+
<td style="padding: 0.75rem 1rem; color: var(--text-muted); font-size: 0.8rem;">
|
|
348
|
+
${new Date(exec.startedAt).toLocaleString()}
|
|
349
|
+
</td>
|
|
350
|
+
<td style="padding: 0.75rem 1rem; text-align: right;">
|
|
351
|
+
<button class="btn btn-secondary btn-sm" data-exec-id="${escapeHtml(exec.id)}" onclick="inspectExecutionDetail(this.getAttribute('data-exec-id'))">
|
|
352
|
+
Inspect
|
|
353
|
+
</button>
|
|
354
|
+
</td>
|
|
355
|
+
</tr>
|
|
356
|
+
`;
|
|
357
|
+
}).join('')}
|
|
358
|
+
</tbody>
|
|
359
|
+
</table>
|
|
360
|
+
</div>
|
|
361
|
+
`;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// ==========================================
|
|
365
|
+
// 3. User Actions
|
|
366
|
+
// ==========================================
|
|
367
|
+
|
|
368
|
+
async function refreshFlowsView() {
|
|
369
|
+
await loadFlows();
|
|
370
|
+
if (flowsState.subTab === 'executions') {
|
|
371
|
+
await loadFlowExecutions();
|
|
372
|
+
}
|
|
373
|
+
renderFlowsView();
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function switchFlowsTab(tab, pushState = true) {
|
|
377
|
+
flowsState.subTab = tab;
|
|
378
|
+
if (pushState && typeof updateUrl === 'function') {
|
|
379
|
+
const path = (tab === 'executions') ? '/_/flows/executions' : '/_/flows';
|
|
380
|
+
updateUrl(path);
|
|
381
|
+
}
|
|
382
|
+
if (typeof updateBreadcrumbs === 'function') {
|
|
383
|
+
updateBreadcrumbs();
|
|
384
|
+
}
|
|
385
|
+
if (tab === 'executions') {
|
|
386
|
+
loadFlowExecutions().then(() => renderFlowsView());
|
|
387
|
+
} else {
|
|
388
|
+
renderFlowsView();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function handleFlowsSearch(val) {
|
|
393
|
+
flowsState.filter.search = val;
|
|
394
|
+
const content = document.getElementById('flows-subtab-content');
|
|
395
|
+
if (content && flowsState.subTab === 'flows') {
|
|
396
|
+
content.innerHTML = renderFlowsListHtml();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async function handleFlowExecutionsStatusFilter(status) {
|
|
401
|
+
flowsState.filter.status = status || 'all';
|
|
402
|
+
await loadFlowExecutions();
|
|
403
|
+
const content = document.getElementById('flows-subtab-content');
|
|
404
|
+
if (content && flowsState.subTab === 'executions') {
|
|
405
|
+
content.innerHTML = renderFlowExecutionsListHtml();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
async function toggleFlowStatus(flowId, enabled) {
|
|
410
|
+
try {
|
|
411
|
+
const base = getFlowsApiBase();
|
|
412
|
+
await api(`${base}/${flowId}`, {
|
|
413
|
+
method: 'PATCH',
|
|
414
|
+
body: JSON.stringify({ enabled }),
|
|
415
|
+
});
|
|
416
|
+
await refreshFlowsView();
|
|
417
|
+
toast(`Flow ${enabled ? 'enabled' : 'disabled'} successfully`, 'success');
|
|
418
|
+
} catch (err) {
|
|
419
|
+
toast('Failed to update flow: ' + (err.message || err), 'error');
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function openDeleteFlowModal(flowId, name) {
|
|
424
|
+
let modalRoot = document.getElementById('modal-root');
|
|
425
|
+
if (!modalRoot) {
|
|
426
|
+
modalRoot = document.createElement('div');
|
|
427
|
+
modalRoot.id = 'modal-root';
|
|
428
|
+
document.body.appendChild(modalRoot);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const safeId = typeof escapeHtml === 'function' ? escapeHtml(flowId) : flowId;
|
|
432
|
+
const safeName = typeof escapeHtml === 'function' ? escapeHtml(name) : name;
|
|
433
|
+
|
|
434
|
+
modalRoot.innerHTML = `
|
|
435
|
+
<div class="modal-backdrop" id="delete-flow-backdrop" onclick="if(event.target===this)closeDeleteFlowModal()">
|
|
436
|
+
<div class="modal confirm-dialog">
|
|
437
|
+
<div class="modal-header" style="border-bottom-color: rgba(239, 68, 68, 0.2);">
|
|
438
|
+
<div style="display: flex; align-items: center; gap: 0.5rem;">
|
|
439
|
+
<span style="font-size: 18px;">⚠️</span>
|
|
440
|
+
<h2 class="modal-title danger" style="font-size: 16px;">Delete Flow</h2>
|
|
441
|
+
</div>
|
|
442
|
+
<button type="button" class="btn btn-secondary btn-sm" onclick="closeDeleteFlowModal()" aria-label="Close">✕</button>
|
|
443
|
+
</div>
|
|
444
|
+
<div class="modal-body" style="padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem;">
|
|
445
|
+
<p style="font-size: 13px; color: var(--text-main, #cbd5e1); line-height: 1.5; margin: 0;">
|
|
446
|
+
Are you sure you want to delete flow <strong style="color: var(--text-heading); font-family: var(--font-mono);">${safeName}</strong>? All execution history and logs will be permanently removed.
|
|
447
|
+
</p>
|
|
448
|
+
<div class="confirm-dialog-banner danger">
|
|
449
|
+
This action cannot be undone. Invocations to <code>/api/flows/${safeId}/execute</code> will return 404 Not Found.
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
<div class="modal-footer" style="padding: 0.75rem 1.25rem;">
|
|
453
|
+
<button type="button" class="btn btn-secondary" onclick="closeDeleteFlowModal()">Cancel</button>
|
|
454
|
+
<button type="button" class="btn btn-danger" id="btn-confirm-delete-flow" data-flow-id="${safeId}">
|
|
455
|
+
Delete Flow
|
|
456
|
+
</button>
|
|
457
|
+
</div>
|
|
458
|
+
</div>
|
|
459
|
+
</div>
|
|
460
|
+
`;
|
|
461
|
+
|
|
462
|
+
const confirmBtn = document.getElementById('btn-confirm-delete-flow');
|
|
463
|
+
if (confirmBtn) {
|
|
464
|
+
confirmBtn.addEventListener('click', () => confirmDeleteFlow(flowId, name));
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
setTimeout(() => {
|
|
468
|
+
document.getElementById('btn-confirm-delete-flow')?.focus();
|
|
469
|
+
}, 50);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function closeDeleteFlowModal() {
|
|
473
|
+
const modalRoot = document.getElementById('modal-root');
|
|
474
|
+
if (modalRoot) modalRoot.innerHTML = '';
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
async function confirmDeleteFlow(flowId, name) {
|
|
478
|
+
const btn = document.getElementById('btn-confirm-delete-flow');
|
|
479
|
+
if (btn) {
|
|
480
|
+
btn.disabled = true;
|
|
481
|
+
btn.textContent = 'Deleting...';
|
|
482
|
+
}
|
|
483
|
+
try {
|
|
484
|
+
const base = getFlowsApiBase();
|
|
485
|
+
await api(`${base}/${flowId}`, { method: 'DELETE' });
|
|
486
|
+
closeDeleteFlowModal();
|
|
487
|
+
await refreshFlowsView();
|
|
488
|
+
toast(`Flow "${name}" deleted successfully`, 'success');
|
|
489
|
+
} catch (err) {
|
|
490
|
+
if (btn) {
|
|
491
|
+
btn.disabled = false;
|
|
492
|
+
btn.textContent = 'Delete Flow';
|
|
493
|
+
}
|
|
494
|
+
toast('Failed to delete flow: ' + (err.message || err), 'error');
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function deleteFlowPrompt(flowId, name) {
|
|
499
|
+
openDeleteFlowModal(flowId, name);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function openCreateFlowModal() {
|
|
503
|
+
const modalRoot = document.getElementById('modal-root');
|
|
504
|
+
if (!modalRoot) return;
|
|
505
|
+
|
|
506
|
+
modalRoot.innerHTML = `
|
|
507
|
+
<div class="modal-backdrop" onclick="if(event.target===this)closeFlowModal()">
|
|
508
|
+
<div class="modal" style="max-width: 520px;">
|
|
509
|
+
<div class="modal-header">
|
|
510
|
+
<h2 class="modal-title" style="display: flex; align-items: center; gap: 8px;">
|
|
511
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="5" r="3"/><line x1="12" y1="8" x2="12" y2="12"/><circle cx="6" cy="19" r="3"/><circle cx="18" cy="19" r="3"/><path d="M12 12h-6v4"/><path d="M12 12h6v4"/></svg>
|
|
512
|
+
Create New Functions Flow
|
|
513
|
+
</h2>
|
|
514
|
+
<button type="button" class="btn btn-secondary btn-sm" onclick="closeFlowModal()">✕</button>
|
|
515
|
+
</div>
|
|
516
|
+
<form onsubmit="handleCreateFlowSubmit(event)">
|
|
517
|
+
<div class="modal-body">
|
|
518
|
+
<div class="form-group">
|
|
519
|
+
<label class="form-label" for="new-flow-name">Flow Name *</label>
|
|
520
|
+
<input
|
|
521
|
+
type="text"
|
|
522
|
+
id="new-flow-name"
|
|
523
|
+
class="form-input"
|
|
524
|
+
placeholder="e.g. OrderProcessingFlow"
|
|
525
|
+
required
|
|
526
|
+
autofocus
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
<div class="form-group">
|
|
530
|
+
<label class="form-label" for="new-flow-desc">Description</label>
|
|
531
|
+
<textarea
|
|
532
|
+
id="new-flow-desc"
|
|
533
|
+
class="form-textarea"
|
|
534
|
+
style="min-height: 60px;"
|
|
535
|
+
placeholder="Brief description of what this workflow orchestrates..."
|
|
536
|
+
></textarea>
|
|
537
|
+
</div>
|
|
538
|
+
<div class="form-group">
|
|
539
|
+
<label class="form-label" for="new-flow-trigger">Trigger Type</label>
|
|
540
|
+
<select id="new-flow-trigger" class="form-select" onchange="toggleFlowTriggerInput(this.value)">
|
|
541
|
+
<option value="http">HTTP Endpoint (POST /api/flows/:id/execute)</option>
|
|
542
|
+
<option value="event">Database Event Hook (e.g. orders:create)</option>
|
|
543
|
+
<option value="cron">Cron Schedule (Recurring Interval)</option>
|
|
544
|
+
<option value="manual">Manual Execution Only</option>
|
|
545
|
+
</select>
|
|
546
|
+
</div>
|
|
547
|
+
<div class="form-group" id="flow-http-auth-field" style="display: flex;">
|
|
548
|
+
<label class="form-label" for="new-flow-auth-policy">HTTP Authorization Policy</label>
|
|
549
|
+
<select id="new-flow-auth-policy" class="form-select">
|
|
550
|
+
<option value="admin" selected>Admin Only (Requires Admin Token)</option>
|
|
551
|
+
<option value="auth">User Token (Bearer JWT or Scoped API Key)</option>
|
|
552
|
+
<option value="apiKey">API Key (Requires flows scope)</option>
|
|
553
|
+
<option value="custom">Custom Rule (@request.auth.* or Scoped API Key)</option>
|
|
554
|
+
<option value="public">Public (No Token Required)</option>
|
|
555
|
+
</select>
|
|
556
|
+
</div>
|
|
557
|
+
<div class="form-group" id="flow-event-field" style="display: none;">
|
|
558
|
+
<label class="form-label" for="new-flow-event">Target Event Pattern</label>
|
|
559
|
+
<input
|
|
560
|
+
type="text"
|
|
561
|
+
id="new-flow-event"
|
|
562
|
+
class="form-input"
|
|
563
|
+
placeholder="collection:action (e.g. orders:create, users:*)"
|
|
564
|
+
/>
|
|
565
|
+
</div>
|
|
566
|
+
<div class="form-group" id="flow-cron-field" style="display: none; flex-direction: column; gap: 8px;">
|
|
567
|
+
<label class="form-label" for="new-flow-cron">Cron Expression & Timezone</label>
|
|
568
|
+
<div style="display: flex; gap: 8px;">
|
|
569
|
+
<input
|
|
570
|
+
type="text"
|
|
571
|
+
id="new-flow-cron"
|
|
572
|
+
class="form-input"
|
|
573
|
+
placeholder="e.g. 0 * * * * or */15 * * * *"
|
|
574
|
+
style="flex: 1; font-family: monospace;"
|
|
575
|
+
/>
|
|
576
|
+
<input
|
|
577
|
+
type="text"
|
|
578
|
+
id="new-flow-timezone"
|
|
579
|
+
class="form-input"
|
|
580
|
+
placeholder="UTC"
|
|
581
|
+
list="iana-timezones-list"
|
|
582
|
+
value="UTC"
|
|
583
|
+
style="width: 140px;"
|
|
584
|
+
/>
|
|
585
|
+
</div>
|
|
586
|
+
<span style="font-size: 0.72rem; color: var(--text-muted);">
|
|
587
|
+
Standard 5-field cron expression. Schedules will coordinate via atomic DB leases.
|
|
588
|
+
</span>
|
|
589
|
+
</div>
|
|
590
|
+
<div class="form-group">
|
|
591
|
+
<label class="form-label" for="new-flow-concurrency">Max Concurrent Executions (Optional)</label>
|
|
592
|
+
<input
|
|
593
|
+
type="number"
|
|
594
|
+
id="new-flow-concurrency"
|
|
595
|
+
class="form-input"
|
|
596
|
+
min="1"
|
|
597
|
+
step="1"
|
|
598
|
+
placeholder="Unlimited (default)"
|
|
599
|
+
/>
|
|
600
|
+
</div>
|
|
601
|
+
</div>
|
|
602
|
+
<div class="modal-footer">
|
|
603
|
+
<button type="button" class="btn btn-secondary" onclick="closeFlowModal()">Cancel</button>
|
|
604
|
+
<button type="submit" class="btn btn-primary" style="font-weight: 600;">+ Create & Open Designer</button>
|
|
605
|
+
</div>
|
|
606
|
+
</form>
|
|
607
|
+
</div>
|
|
608
|
+
</div>
|
|
609
|
+
`;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function closeFlowModal() {
|
|
613
|
+
const modalRoot = document.getElementById('modal-root');
|
|
614
|
+
if (modalRoot) modalRoot.innerHTML = '';
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function toggleFlowTriggerInput(val) {
|
|
618
|
+
const field = document.getElementById('flow-event-field');
|
|
619
|
+
if (field) field.style.display = val === 'event' ? 'flex' : 'none';
|
|
620
|
+
const httpAuthField = document.getElementById('flow-http-auth-field');
|
|
621
|
+
if (httpAuthField) httpAuthField.style.display = val === 'http' ? 'flex' : 'none';
|
|
622
|
+
const cronField = document.getElementById('flow-cron-field');
|
|
623
|
+
if (cronField) cronField.style.display = val === 'cron' ? 'flex' : 'none';
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
async function handleCreateFlowSubmit(e) {
|
|
627
|
+
e.preventDefault();
|
|
628
|
+
const nameInput = document.getElementById('new-flow-name');
|
|
629
|
+
const descInput = document.getElementById('new-flow-desc');
|
|
630
|
+
const triggerInput = document.getElementById('new-flow-trigger');
|
|
631
|
+
const authInput = document.getElementById('new-flow-auth-policy');
|
|
632
|
+
const eventInput = document.getElementById('new-flow-event');
|
|
633
|
+
const cronInput = document.getElementById('new-flow-cron');
|
|
634
|
+
const tzInput = document.getElementById('new-flow-timezone');
|
|
635
|
+
const concurrencyInput = document.getElementById('new-flow-concurrency');
|
|
636
|
+
|
|
637
|
+
const name = nameInput ? nameInput.value.trim() : '';
|
|
638
|
+
if (!name) return;
|
|
639
|
+
|
|
640
|
+
const triggerType = triggerInput ? triggerInput.value : 'http';
|
|
641
|
+
const authPolicy = triggerType === 'http' && authInput ? authInput.value : 'admin';
|
|
642
|
+
const invokeRule = triggerType === 'http' && authPolicy === 'custom' ? '@request.auth.id != ""' : null;
|
|
643
|
+
const eventTrigger = triggerType === 'event' && eventInput ? eventInput.value.trim() : null;
|
|
644
|
+
const cronSchedule = triggerType === 'cron' && cronInput ? cronInput.value.trim() || null : null;
|
|
645
|
+
const cronTimezone = triggerType === 'cron' && tzInput ? tzInput.value.trim() || 'UTC' : 'UTC';
|
|
646
|
+
const rawConcurrency = concurrencyInput ? concurrencyInput.value.trim() : '';
|
|
647
|
+
const maxConcurrentExecutions = rawConcurrency !== '' ? parseInt(rawConcurrency, 10) : null;
|
|
648
|
+
|
|
649
|
+
const initialFlow = {
|
|
650
|
+
name,
|
|
651
|
+
description: descInput ? descInput.value.trim() : '',
|
|
652
|
+
enabled: true,
|
|
653
|
+
triggerType,
|
|
654
|
+
authPolicy,
|
|
655
|
+
invokeRule,
|
|
656
|
+
eventTrigger,
|
|
657
|
+
cronSchedule,
|
|
658
|
+
cronTimezone,
|
|
659
|
+
maxConcurrentExecutions,
|
|
660
|
+
definition: {
|
|
661
|
+
startAt: 'FirstStep',
|
|
662
|
+
states: {
|
|
663
|
+
FirstStep: {
|
|
664
|
+
type: 'Pass',
|
|
665
|
+
result: { message: 'Hello from NodeStack Functions Flow!' },
|
|
666
|
+
end: true,
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
try {
|
|
673
|
+
const base = getFlowsApiBase();
|
|
674
|
+
const created = await api(base, {
|
|
675
|
+
method: 'POST',
|
|
676
|
+
body: JSON.stringify(initialFlow),
|
|
677
|
+
});
|
|
678
|
+
closeFlowModal();
|
|
679
|
+
await loadFlows();
|
|
680
|
+
openFlowDesigner(created.id);
|
|
681
|
+
} catch (err) {
|
|
682
|
+
toast('Failed to create flow: ' + (err.message || err), 'error');
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
function formatFlowTriggerLabel(flow) {
|
|
687
|
+
if (flow.triggerType === 'cron') {
|
|
688
|
+
return `⏱️ Cron: ${flow.cronSchedule || ''} (${flow.cronTimezone || 'UTC'})`;
|
|
689
|
+
}
|
|
690
|
+
if (flow.triggerType === 'event') {
|
|
691
|
+
return `DB Event${flow.eventTrigger ? `: ${escapeHtml(flow.eventTrigger)}` : ''}`;
|
|
692
|
+
}
|
|
693
|
+
if (flow.triggerType === 'manual') {
|
|
694
|
+
return 'Manual (On-demand)';
|
|
695
|
+
}
|
|
696
|
+
return 'HTTP API';
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function quickTestFlow(flowId) {
|
|
700
|
+
if (typeof openFlowDesigner === 'function') {
|
|
701
|
+
return openFlowDesigner(flowId, true);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
async function inspectExecutionDetail(executionId) {
|
|
706
|
+
try {
|
|
707
|
+
let exec = (flowsState.executions || []).find((e) => e.id === executionId);
|
|
708
|
+
if (!exec || !exec.stepLogs) {
|
|
709
|
+
const base = getFlowsApiBase();
|
|
710
|
+
exec = await api(`${base}/executions/${executionId}`);
|
|
711
|
+
}
|
|
712
|
+
if (!exec) {
|
|
713
|
+
toast('Execution record not found', 'error');
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
let root = document.getElementById('drawer-root');
|
|
718
|
+
if (!root) {
|
|
719
|
+
root = document.createElement('div');
|
|
720
|
+
root.id = 'drawer-root';
|
|
721
|
+
document.body.appendChild(root);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
const isSuccess = exec.status === 'succeeded';
|
|
725
|
+
const statusColor = isSuccess ? 'var(--accent-success)' : exec.status === 'failed' ? 'var(--accent-danger)' : (exec.status === 'aborted' || exec.status === 'queued') ? 'var(--accent-warning, #f59e0b)' : '#3b82f6';
|
|
726
|
+
const stepCount = (exec.stepLogs || []).length;
|
|
727
|
+
|
|
728
|
+
root.innerHTML = `
|
|
729
|
+
<div id="flow-exec-drawer-backdrop" class="drawer-backdrop" onclick="closeFlowExecutionDrawer()" aria-hidden="true"></div>
|
|
730
|
+
<aside id="flow-exec-drawer-panel" class="record-drawer flow-execution-drawer" role="dialog" aria-modal="true" aria-labelledby="flow-exec-drawer-title" tabindex="-1">
|
|
731
|
+
<!-- Drawer Header -->
|
|
732
|
+
<div class="drawer-header" style="display: flex; align-items: center; justify-content: space-between;">
|
|
733
|
+
<div class="drawer-title-area" style="display: flex; align-items: center; gap: 0.75rem;">
|
|
734
|
+
<span style="font-weight: 800; color: ${statusColor}; text-transform: uppercase; font-size: 0.78rem; background: rgba(0,0,0,0.2); padding: 4px 8px; border-radius: 6px; border: 1px solid ${statusColor}44;">
|
|
735
|
+
● ${escapeHtml(exec.status).toUpperCase()}
|
|
736
|
+
</span>
|
|
737
|
+
<div>
|
|
738
|
+
<h3 class="drawer-title" id="flow-exec-drawer-title" style="margin: 0; font-size: 1.1rem; color: var(--text-main);">
|
|
739
|
+
${escapeHtml(exec.flowName)}
|
|
740
|
+
</h3>
|
|
741
|
+
<span style="font-size: 11px; color: var(--text-muted); font-family: var(--font-mono, monospace);">
|
|
742
|
+
${escapeHtml(exec.id)} • ${exec.durationMs}ms
|
|
743
|
+
</span>
|
|
744
|
+
</div>
|
|
745
|
+
</div>
|
|
746
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
747
|
+
<button
|
|
748
|
+
class="btn btn-secondary btn-sm"
|
|
749
|
+
data-flow-id="${escapeHtml(exec.flowId)}"
|
|
750
|
+
data-exec-id="${escapeHtml(exec.id)}"
|
|
751
|
+
onclick="openFlowFromExecution(this.getAttribute('data-flow-id'), this.getAttribute('data-exec-id'))"
|
|
752
|
+
title="Open flow in visual designer with this execution"
|
|
753
|
+
style="font-size: 11px; padding: 4px 8px; font-weight: 600;"
|
|
754
|
+
>
|
|
755
|
+
Open in Designer ↗
|
|
756
|
+
</button>
|
|
757
|
+
<button class="drawer-close-btn" onclick="closeFlowExecutionDrawer()" aria-label="Close drawer">✕</button>
|
|
758
|
+
</div>
|
|
759
|
+
</div>
|
|
760
|
+
|
|
761
|
+
<!-- Drawer Body -->
|
|
762
|
+
<div class="drawer-body" style="padding: 1.25rem 1.5rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1.25rem;">
|
|
763
|
+
<!-- Meta Grid -->
|
|
764
|
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 10px 14px; font-size: 12px;">
|
|
765
|
+
<div>
|
|
766
|
+
<span style="font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; display: block;">Status</span>
|
|
767
|
+
<strong style="color: ${statusColor}; text-transform: uppercase;">${escapeHtml(exec.status)}</strong>
|
|
768
|
+
</div>
|
|
769
|
+
<div>
|
|
770
|
+
<span style="font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; display: block;">Duration</span>
|
|
771
|
+
<span style="font-weight: 600; color: var(--text-main);">${exec.durationMs}ms</span>
|
|
772
|
+
</div>
|
|
773
|
+
<div>
|
|
774
|
+
<span style="font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; display: block;">Steps</span>
|
|
775
|
+
<span style="font-weight: 600; color: var(--text-main);">${stepCount} steps</span>
|
|
776
|
+
</div>
|
|
777
|
+
<div>
|
|
778
|
+
<span style="font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; display: block;">Caller</span>
|
|
779
|
+
<span style="font-weight: 600; color: var(--accent-primary, #6366f1); font-family: monospace;">${escapeHtml(exec.actorId || 'public')}</span>
|
|
780
|
+
</div>
|
|
781
|
+
<div>
|
|
782
|
+
<span style="font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; display: block;">Started</span>
|
|
783
|
+
<span style="color: var(--text-muted);" title="${escapeHtml(exec.startedAt)}">${new Date(exec.startedAt).toLocaleTimeString()}</span>
|
|
784
|
+
</div>
|
|
785
|
+
</div>
|
|
786
|
+
|
|
787
|
+
<!-- Error Alert Banner (if failed) -->
|
|
788
|
+
${exec.error ? `
|
|
789
|
+
<div style="background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); border-radius: 6px; padding: 10px 14px; font-size: 12px; color: var(--accent-danger);">
|
|
790
|
+
<strong>Execution Error:</strong> ${escapeHtml(exec.error)}
|
|
791
|
+
</div>
|
|
792
|
+
` : ''}
|
|
793
|
+
|
|
794
|
+
<!-- Step-by-Step Execution Timeline -->
|
|
795
|
+
<div>
|
|
796
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 8px; letter-spacing: 0.05em;">
|
|
797
|
+
Step-by-Step Timeline (${stepCount})
|
|
798
|
+
</span>
|
|
799
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
800
|
+
${(exec.stepLogs || []).map((log, idx) => {
|
|
801
|
+
const stepSuccess = log.status === 'succeeded';
|
|
802
|
+
const stepColor = stepSuccess ? 'var(--accent-success)' : 'var(--accent-danger)';
|
|
803
|
+
return `
|
|
804
|
+
<div style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-left: 3px solid ${stepColor}; border-radius: 6px; padding: 10px 12px; font-size: 12px;">
|
|
805
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;">
|
|
806
|
+
<div style="display: flex; align-items: center; gap: 6px;">
|
|
807
|
+
<span style="font-size: 10px; color: var(--text-muted); font-weight: 700;">#${idx + 1}</span>
|
|
808
|
+
<strong style="color: var(--text-main); font-size: 13px;">${escapeHtml(log.step)}</strong>
|
|
809
|
+
<span class="flow-step-type-pill pill-${(log.type || 'Task').toLowerCase()}" style="font-size: 9px; padding: 1px 6px;">
|
|
810
|
+
${escapeHtml((log.type || 'TASK')).toUpperCase()}
|
|
811
|
+
</span>
|
|
812
|
+
</div>
|
|
813
|
+
<span style="color: var(--text-muted); font-size: 11px; font-family: var(--font-mono, monospace);">
|
|
814
|
+
${log.durationMs}ms
|
|
815
|
+
</span>
|
|
816
|
+
</div>
|
|
817
|
+
${log.error ? `
|
|
818
|
+
<div style="color: var(--accent-danger); font-size: 11px; margin-top: 4px;">
|
|
819
|
+
${escapeHtml(log.error)}
|
|
820
|
+
</div>
|
|
821
|
+
` : ''}
|
|
822
|
+
${log.output !== undefined ? `
|
|
823
|
+
<details style="margin-top: 6px; font-size: 11px;">
|
|
824
|
+
<summary style="cursor: pointer; color: var(--text-muted); font-weight: 600;">View Step Result</summary>
|
|
825
|
+
<pre style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 4px; padding: 6px 8px; margin-top: 4px; max-height: 120px; overflow-y: auto; font-size: 11px; color: var(--text-main); font-family: var(--font-mono, monospace);">${escapeHtml(JSON.stringify(log.output, null, 2))}</pre>
|
|
826
|
+
</details>
|
|
827
|
+
` : ''}
|
|
828
|
+
</div>
|
|
829
|
+
`;
|
|
830
|
+
}).join('')}
|
|
831
|
+
</div>
|
|
832
|
+
</div>
|
|
833
|
+
|
|
834
|
+
<!-- Input Payload -->
|
|
835
|
+
<div>
|
|
836
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;">
|
|
837
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">
|
|
838
|
+
Input Payload
|
|
839
|
+
</span>
|
|
840
|
+
<button class="btn btn-secondary btn-sm" onclick="copyFlowJson(this, 'flow-exec-input-json')" style="padding: 2px 8px; font-size: 10px;">
|
|
841
|
+
Copy JSON
|
|
842
|
+
</button>
|
|
843
|
+
</div>
|
|
844
|
+
<pre id="flow-exec-input-json" style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 10px 12px; font-family: var(--font-mono, monospace); font-size: 11px; color: var(--text-main); max-height: 160px; overflow-y: auto; margin: 0;">${escapeHtml(JSON.stringify(exec.input || {}, null, 2))}</pre>
|
|
845
|
+
</div>
|
|
846
|
+
|
|
847
|
+
<!-- Final Output Payload -->
|
|
848
|
+
<div>
|
|
849
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;">
|
|
850
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">
|
|
851
|
+
Final Output Payload
|
|
852
|
+
</span>
|
|
853
|
+
<button class="btn btn-secondary btn-sm" onclick="copyFlowJson(this, 'flow-exec-output-json')" style="padding: 2px 8px; font-size: 10px;">
|
|
854
|
+
Copy JSON
|
|
855
|
+
</button>
|
|
856
|
+
</div>
|
|
857
|
+
<pre id="flow-exec-output-json" style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 10px 12px; font-family: var(--font-mono, monospace); font-size: 11px; color: var(--text-main); max-height: 200px; overflow-y: auto; margin: 0;">${escapeHtml(JSON.stringify(exec.output !== undefined ? exec.output : (exec.error ? { error: exec.error } : {}), null, 2))}</pre>
|
|
858
|
+
</div>
|
|
859
|
+
</div>
|
|
860
|
+
</aside>
|
|
861
|
+
`;
|
|
862
|
+
|
|
863
|
+
setTimeout(() => {
|
|
864
|
+
document.getElementById('flow-exec-drawer-backdrop')?.classList.add('open');
|
|
865
|
+
document.getElementById('flow-exec-drawer-panel')?.classList.add('open');
|
|
866
|
+
}, 10);
|
|
867
|
+
} catch (err) {
|
|
868
|
+
toast('Failed to inspect flow execution: ' + (err.message || err), 'error');
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
function closeFlowExecutionDrawer() {
|
|
873
|
+
const backdrop = document.getElementById('flow-exec-drawer-backdrop');
|
|
874
|
+
const panel = document.getElementById('flow-exec-drawer-panel');
|
|
875
|
+
if (backdrop) backdrop.classList.remove('open');
|
|
876
|
+
if (panel) panel.classList.remove('open');
|
|
877
|
+
setTimeout(() => {
|
|
878
|
+
const root = document.getElementById('drawer-root');
|
|
879
|
+
if (root && root.querySelector('#flow-exec-drawer-panel')) {
|
|
880
|
+
root.innerHTML = '';
|
|
881
|
+
}
|
|
882
|
+
}, 200);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
async function openFlowFromExecution(flowId, executionId) {
|
|
886
|
+
const exec = (flowsState.executions || []).find((e) => e.id === executionId);
|
|
887
|
+
closeFlowExecutionDrawer();
|
|
888
|
+
if (typeof openFlowDesigner === 'function') {
|
|
889
|
+
await openFlowDesigner(flowId, true);
|
|
890
|
+
if (exec && typeof designerState !== 'undefined') {
|
|
891
|
+
designerState.latestExecution = exec;
|
|
892
|
+
const drawer = document.getElementById('flow-test-drawer');
|
|
893
|
+
if (drawer && typeof renderTestDrawerHtml === 'function') {
|
|
894
|
+
drawer.innerHTML = renderTestDrawerHtml(designerState.activeFlow);
|
|
895
|
+
}
|
|
896
|
+
if (typeof renderSvgFlowchart === 'function') {
|
|
897
|
+
renderSvgFlowchart(designerState.activeFlow);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
function copyFlowJson(btn, elementId) {
|
|
904
|
+
const el = document.getElementById(elementId);
|
|
905
|
+
if (!el) return;
|
|
906
|
+
try {
|
|
907
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
908
|
+
navigator.clipboard.writeText(el.textContent || '').then(() => {
|
|
909
|
+
const orig = btn.textContent;
|
|
910
|
+
btn.textContent = 'Copied!';
|
|
911
|
+
setTimeout(() => { btn.textContent = orig; }, 1500);
|
|
912
|
+
});
|
|
913
|
+
} else {
|
|
914
|
+
toast('Copied to clipboard', 'info');
|
|
915
|
+
}
|
|
916
|
+
} catch (_) {
|
|
917
|
+
toast('Copied to clipboard', 'info');
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
if (typeof window !== 'undefined') {
|
|
922
|
+
window.renderFlowsView = renderFlowsView;
|
|
923
|
+
window.loadFlows = loadFlows;
|
|
924
|
+
window.refreshFlowsView = refreshFlowsView;
|
|
925
|
+
window.switchFlowsTab = switchFlowsTab;
|
|
926
|
+
window.handleFlowsSearch = handleFlowsSearch;
|
|
927
|
+
window.handleFlowExecutionsStatusFilter = handleFlowExecutionsStatusFilter;
|
|
928
|
+
window.toggleFlowStatus = toggleFlowStatus;
|
|
929
|
+
window.deleteFlowPrompt = deleteFlowPrompt;
|
|
930
|
+
window.openDeleteFlowModal = openDeleteFlowModal;
|
|
931
|
+
window.closeDeleteFlowModal = closeDeleteFlowModal;
|
|
932
|
+
window.confirmDeleteFlow = confirmDeleteFlow;
|
|
933
|
+
window.openCreateFlowModal = openCreateFlowModal;
|
|
934
|
+
window.closeFlowModal = closeFlowModal;
|
|
935
|
+
window.toggleFlowTriggerInput = toggleFlowTriggerInput;
|
|
936
|
+
window.handleCreateFlowSubmit = handleCreateFlowSubmit;
|
|
937
|
+
window.quickTestFlow = quickTestFlow;
|
|
938
|
+
window.formatFlowTriggerLabel = formatFlowTriggerLabel;
|
|
939
|
+
window.inspectExecutionDetail = inspectExecutionDetail;
|
|
940
|
+
window.closeFlowExecutionDrawer = closeFlowExecutionDrawer;
|
|
941
|
+
window.openFlowFromExecution = openFlowFromExecution;
|
|
942
|
+
window.copyFlowJson = copyFlowJson;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
if (typeof state !== 'undefined' && state.token && typeof loadFlows === 'function') {
|
|
946
|
+
loadFlows();
|
|
947
|
+
}
|