@nodestackapp/server 2.5.0 → 2.6.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 +40 -28
- package/dist/NodeStack.d.ts +1 -1
- package/dist/NodeStack.d.ts.map +1 -1
- package/dist/NodeStack.js +73 -12
- package/dist/NodeStack.js.map +1 -1
- package/dist/admin/AdminUIBundler.d.ts.map +1 -1
- package/dist/admin/AdminUIBundler.js +1 -0
- package/dist/admin/AdminUIBundler.js.map +1 -1
- package/dist/admin/ui/css/main.css +34 -0
- package/dist/admin/ui/css/webhooks.css +8 -0
- package/dist/admin/ui/index.html +19150 -17212
- package/dist/admin/ui/js/api-keys.js +1381 -0
- package/dist/admin/ui/js/app.js +667 -641
- package/dist/admin/ui/js/apps.js +496 -489
- package/dist/admin/ui/js/collections.js +486 -484
- package/dist/admin/ui/js/command-palette.js +683 -673
- package/dist/admin/ui/js/flows-designer.js +1125 -1076
- package/dist/admin/ui/js/flows.js +908 -890
- package/dist/admin/ui/js/functions-tester.js +1 -1
- package/dist/admin/ui/js/functions-workbench.js +1144 -1101
- package/dist/admin/ui/js/functions.js +980 -979
- package/dist/admin/ui/js/rules.js +1080 -775
- package/dist/admin/ui/js/schema.js +346 -304
- 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 +4 -18
- 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 +0 -1
- package/dist/apps/AppScope.d.ts.map +1 -1
- package/dist/apps/AppScope.js +5 -15
- package/dist/apps/AppScope.js.map +1 -1
- package/dist/auth/ApiKeyService.d.ts +62 -2
- package/dist/auth/ApiKeyService.d.ts.map +1 -1
- package/dist/auth/ApiKeyService.js +503 -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/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/database/DatabaseService.d.ts +1 -0
- package/dist/database/DatabaseService.d.ts.map +1 -1
- package/dist/database/DatabaseService.js +24 -6
- package/dist/database/DatabaseService.js.map +1 -1
- 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 +8 -2
- 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/migrations/SystemMigrations.d.ts.map +1 -1
- package/dist/database/migrations/SystemMigrations.js +62 -5
- package/dist/database/migrations/SystemMigrations.js.map +1 -1
- package/dist/flows/FlowEngine.js.map +1 -1
- package/dist/flows/FlowService.d.ts +7 -1
- package/dist/flows/FlowService.d.ts.map +1 -1
- package/dist/flows/FlowService.js +126 -12
- package/dist/flows/FlowService.js.map +1 -1
- package/dist/flows/FlowValidator.d.ts +1 -0
- package/dist/flows/FlowValidator.d.ts.map +1 -1
- package/dist/flows/FlowValidator.js +76 -1
- package/dist/flows/FlowValidator.js.map +1 -1
- package/dist/flows/types.d.ts +14 -2
- package/dist/flows/types.d.ts.map +1 -1
- package/dist/functions/FunctionService.d.ts +5 -1
- package/dist/functions/FunctionService.d.ts.map +1 -1
- package/dist/functions/FunctionService.js +84 -33
- package/dist/functions/FunctionService.js.map +1 -1
- package/dist/functions/runtime/QuickJsWasmRuntime.d.ts.map +1 -1
- package/dist/functions/runtime/QuickJsWasmRuntime.js +19 -10
- package/dist/functions/runtime/QuickJsWasmRuntime.js.map +1 -1
- package/dist/functions/types.d.ts +16 -2
- package/dist/functions/types.d.ts.map +1 -1
- package/dist/http/HttpServer.d.ts +3 -0
- package/dist/http/HttpServer.d.ts.map +1 -1
- package/dist/http/HttpServer.js +153 -6
- 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/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/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 +4 -3
package/dist/admin/ui/js/app.js
CHANGED
|
@@ -1,641 +1,667 @@
|
|
|
1
|
-
// Application Navigation & Lifecycle
|
|
2
|
-
|
|
3
|
-
// URL Routing, Deep Linking & History API
|
|
4
|
-
|
|
5
|
-
function getAppQueryParam() {
|
|
6
|
-
if (typeof window === 'undefined' || !window.location) return '';
|
|
7
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
8
|
-
const activeSlug = getActiveAppSlug();
|
|
9
|
-
if (activeSlug && activeSlug !== 'default') {
|
|
10
|
-
searchParams.set('app', activeSlug);
|
|
11
|
-
} else {
|
|
12
|
-
searchParams.delete('app');
|
|
13
|
-
}
|
|
14
|
-
const q = searchParams.toString();
|
|
15
|
-
return q ? `?${q}` : '';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function updateUrl(targetPath, replace = false) {
|
|
19
|
-
if (typeof window === 'undefined' || !window.history || !window.location) return;
|
|
20
|
-
const targetUrl = targetPath + getAppQueryParam();
|
|
21
|
-
const currentUrl = window.location.pathname + window.location.search;
|
|
22
|
-
if (currentUrl === targetUrl) return;
|
|
23
|
-
|
|
24
|
-
if (replace) {
|
|
25
|
-
window.history.replaceState({ path: targetPath }, '', targetUrl);
|
|
26
|
-
} else {
|
|
27
|
-
window.history.pushState({ path: targetPath }, '', targetUrl);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async function parseUrlAndNavigate(initial = false) {
|
|
32
|
-
if (typeof window === 'undefined' || !window.location) return;
|
|
33
|
-
|
|
34
|
-
// Resolve and synchronize active application from URL query parameter (?app=<slugOrId>)
|
|
35
|
-
const searchParams = new URLSearchParams(window.location.search || '');
|
|
36
|
-
const requestedAppSlug = searchParams.get('app');
|
|
37
|
-
|
|
38
|
-
if (requestedAppSlug) {
|
|
39
|
-
let targetApp = (state.apps || []).find(a => a.slug === requestedAppSlug || a.id === requestedAppSlug || (requestedAppSlug === 'default' && a.isDefault));
|
|
40
|
-
if (!targetApp) {
|
|
41
|
-
try {
|
|
42
|
-
await fetchApps();
|
|
43
|
-
targetApp = (state.apps || []).find(a => a.slug === requestedAppSlug || a.id === requestedAppSlug || (requestedAppSlug === 'default' && a.isDefault));
|
|
44
|
-
} catch (_) {}
|
|
45
|
-
}
|
|
46
|
-
const currentSlug = getActiveAppSlug();
|
|
47
|
-
if (targetApp && currentSlug !== targetApp.slug) {
|
|
48
|
-
state.activeApp = targetApp;
|
|
49
|
-
try {
|
|
50
|
-
localStorage.setItem('nodestack_active_app', JSON.stringify(targetApp));
|
|
51
|
-
} catch (_) {}
|
|
52
|
-
updateAppSwitcherUI();
|
|
53
|
-
updateDocsLinks(targetApp.slug);
|
|
54
|
-
try {
|
|
55
|
-
await loadCollections();
|
|
56
|
-
} catch (_) {}
|
|
57
|
-
}
|
|
58
|
-
} else if (!initial && state.activeApp && state.activeApp.slug !== 'default') {
|
|
59
|
-
// Navigating back/forward (popstate) to a route without ?app= query parameter; restore default app
|
|
60
|
-
const defaultApp = (state.apps || []).find(a => a.isDefault || a.slug === 'default') || { id: 'app_default', slug: 'default', name: 'Default App', isDefault: true };
|
|
61
|
-
if (state.activeApp.slug !== defaultApp.slug) {
|
|
62
|
-
state.activeApp = defaultApp;
|
|
63
|
-
try {
|
|
64
|
-
localStorage.setItem('nodestack_active_app', JSON.stringify(defaultApp));
|
|
65
|
-
} catch (_) {}
|
|
66
|
-
updateAppSwitcherUI();
|
|
67
|
-
updateDocsLinks(defaultApp.slug);
|
|
68
|
-
try {
|
|
69
|
-
await loadCollections();
|
|
70
|
-
} catch (_) {}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const pathname = window.location.pathname || '/';
|
|
75
|
-
|
|
76
|
-
// Normalise route:
|
|
77
|
-
// e.g. '/_/' -> ''
|
|
78
|
-
// '/_/collections' -> 'collections'
|
|
79
|
-
// '/_/collections/users/schema' -> 'collections/users/schema'
|
|
80
|
-
let route = pathname;
|
|
81
|
-
if (route.startsWith('/_')) {
|
|
82
|
-
route = route.slice(2);
|
|
83
|
-
}
|
|
84
|
-
if (route.startsWith('/')) {
|
|
85
|
-
route = route.slice(1);
|
|
86
|
-
}
|
|
87
|
-
if (route.endsWith('/')) {
|
|
88
|
-
route = route.slice(0, -1);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const parts = route ? route.split('/').map(p => decodeURIComponent(p)) : [];
|
|
92
|
-
|
|
93
|
-
if (parts.length === 0 || parts[0] === 'home') {
|
|
94
|
-
await selectNav('home', false);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const root = parts[0];
|
|
99
|
-
|
|
100
|
-
if (root === 'collections') {
|
|
101
|
-
if (parts.length === 1) {
|
|
102
|
-
await selectNav('collections', false);
|
|
103
|
-
} else {
|
|
104
|
-
const colName = parts[1];
|
|
105
|
-
const tab = (parts[2] === 'schema') ? 'schema' : 'records';
|
|
106
|
-
const allCols = Array.isArray(state.collections)
|
|
107
|
-
? state.collections
|
|
108
|
-
: (state.collections && Array.isArray(state.collections.items) ? state.collections.items : []);
|
|
109
|
-
const colExists = allCols.some(c => c.name === colName);
|
|
110
|
-
if (colExists) {
|
|
111
|
-
state.collectionTab = tab;
|
|
112
|
-
await selectCollection(colName, false);
|
|
113
|
-
if (tab === 'schema') {
|
|
114
|
-
switchCollectionTab('schema', false);
|
|
115
|
-
} else {
|
|
116
|
-
switchCollectionTab('records', false);
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
await selectNav('collections', false);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
} else if (root === 'functions') {
|
|
123
|
-
if (typeof functionsState !== 'undefined') {
|
|
124
|
-
functionsState.subTab = (parts[1] === 'logs') ? 'logs' : 'functions';
|
|
125
|
-
if (parts.length < 2 || parts[1] === 'logs') {
|
|
126
|
-
functionsState.currentView = 'list';
|
|
127
|
-
functionsState.activeFunctionForEdit = null;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
await selectNav('functions', false);
|
|
131
|
-
if (parts.length >= 2 && parts[1] && parts[1] !== 'logs') {
|
|
132
|
-
if (typeof openFunctionEditor === 'function') {
|
|
133
|
-
await openFunctionEditor(parts[1], false);
|
|
134
|
-
}
|
|
135
|
-
} else if (parts[1] === 'logs') {
|
|
136
|
-
if (typeof switchFunctionsTab === 'function') switchFunctionsTab('logs', false);
|
|
137
|
-
} else {
|
|
138
|
-
if (typeof switchFunctionsTab === 'function') switchFunctionsTab('functions', false);
|
|
139
|
-
}
|
|
140
|
-
} else if (root === 'flows') {
|
|
141
|
-
if (typeof flowsState !== 'undefined') {
|
|
142
|
-
flowsState.subTab = (parts[1] === 'executions') ? 'executions' : 'flows';
|
|
143
|
-
if (parts.length < 2 || parts[1] === 'executions') {
|
|
144
|
-
flowsState.currentView = 'list';
|
|
145
|
-
flowsState.activeFlowForEdit = null;
|
|
146
|
-
if (typeof designerState !== 'undefined') {
|
|
147
|
-
designerState.activeFlow = null;
|
|
148
|
-
designerState.latestExecution = null;
|
|
149
|
-
designerState.isTestDrawerOpen = false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
await selectNav('flows', false);
|
|
154
|
-
if (parts.length >= 2 && parts[1]) {
|
|
155
|
-
if (parts[1] === 'executions') {
|
|
156
|
-
if (typeof switchFlowsTab === 'function') switchFlowsTab('executions', false);
|
|
157
|
-
} else {
|
|
158
|
-
if (typeof openFlowDesigner === 'function') await openFlowDesigner(parts[1], false, false);
|
|
159
|
-
}
|
|
160
|
-
} else {
|
|
161
|
-
if (typeof closeFlowDesigner === 'function' && typeof flowsState !== 'undefined' && flowsState.currentView === 'designer') {
|
|
162
|
-
closeFlowDesigner(false);
|
|
163
|
-
} else if (typeof switchFlowsTab === 'function') {
|
|
164
|
-
switchFlowsTab('flows', false);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
} else if (root === 'queues') {
|
|
168
|
-
const isMessages = parts[1] === 'messages' || parts[1] === 'jobs';
|
|
169
|
-
if (typeof queuesState !== 'undefined') {
|
|
170
|
-
queuesState.subTab = isMessages ? 'messages' : 'queues';
|
|
171
|
-
}
|
|
172
|
-
await selectNav('queues', false);
|
|
173
|
-
if (isMessages) {
|
|
174
|
-
if (typeof switchQueuesTab === 'function') switchQueuesTab('messages', false);
|
|
175
|
-
} else {
|
|
176
|
-
if (typeof switchQueuesTab === 'function') switchQueuesTab('queues', false);
|
|
177
|
-
}
|
|
178
|
-
} else if (root === 'webhooks') {
|
|
179
|
-
if (typeof webhooksState !== 'undefined') {
|
|
180
|
-
webhooksState.subTab = (parts[1] === 'deliveries') ? 'deliveries' : 'webhooks';
|
|
181
|
-
}
|
|
182
|
-
await selectNav('webhooks', false);
|
|
183
|
-
if (parts[1] === 'deliveries') {
|
|
184
|
-
if (typeof switchWebhooksTab === 'function') switchWebhooksTab('deliveries', false);
|
|
185
|
-
} else {
|
|
186
|
-
if (typeof switchWebhooksTab === 'function') switchWebhooksTab('webhooks', false);
|
|
187
|
-
}
|
|
188
|
-
} else if (root === 'plugins') {
|
|
189
|
-
if (parts.length >= 2 && state.pluginNavItems && state.pluginNavItems.some(p => p.id === parts[1])) {
|
|
190
|
-
await selectNav(parts[1], false);
|
|
191
|
-
} else {
|
|
192
|
-
await selectNav('plugins', false);
|
|
193
|
-
}
|
|
194
|
-
} else if (root === 'analytics') {
|
|
195
|
-
await selectNav('analytics', false);
|
|
196
|
-
} else if (root === '
|
|
197
|
-
await selectNav('
|
|
198
|
-
} else if (root === '
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (typeof switchLogsSubTab === 'function') switchLogsSubTab('
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
} else if (
|
|
211
|
-
await selectNav(
|
|
212
|
-
} else {
|
|
213
|
-
await selectNav(
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (typeof
|
|
228
|
-
if (typeof
|
|
229
|
-
if (typeof
|
|
230
|
-
if (typeof
|
|
231
|
-
if (typeof
|
|
232
|
-
if (typeof
|
|
233
|
-
if (typeof
|
|
234
|
-
if (typeof
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
if (typeof
|
|
288
|
-
if (typeof
|
|
289
|
-
if (typeof
|
|
290
|
-
if (typeof
|
|
291
|
-
if (typeof
|
|
292
|
-
if (typeof
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (typeof
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
document.getElementById('view-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
document.getElementById('
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
document.getElementById('view-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (typeof
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if (typeof
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
document.getElementById('
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
if (typeof
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
document.getElementById('
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
if (typeof
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
document.getElementById('
|
|
448
|
-
document.getElementById('view-
|
|
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
|
-
} else if (
|
|
482
|
-
state.activeCollection = null;
|
|
483
|
-
if (typeof
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
updateUrl('/_/
|
|
514
|
-
} else if (nav === '
|
|
515
|
-
updateUrl('/_/
|
|
516
|
-
} else if (
|
|
517
|
-
updateUrl('/_/
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
})
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
if (
|
|
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
|
-
e.
|
|
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
|
-
if (typeof
|
|
630
|
-
if (typeof
|
|
631
|
-
if (typeof
|
|
632
|
-
if (typeof
|
|
633
|
-
if (typeof
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
if (typeof
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
1
|
+
// Application Navigation & Lifecycle
|
|
2
|
+
|
|
3
|
+
// URL Routing, Deep Linking & History API
|
|
4
|
+
|
|
5
|
+
function getAppQueryParam() {
|
|
6
|
+
if (typeof window === 'undefined' || !window.location) return '';
|
|
7
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
8
|
+
const activeSlug = getActiveAppSlug();
|
|
9
|
+
if (activeSlug && activeSlug !== 'default') {
|
|
10
|
+
searchParams.set('app', activeSlug);
|
|
11
|
+
} else {
|
|
12
|
+
searchParams.delete('app');
|
|
13
|
+
}
|
|
14
|
+
const q = searchParams.toString();
|
|
15
|
+
return q ? `?${q}` : '';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function updateUrl(targetPath, replace = false) {
|
|
19
|
+
if (typeof window === 'undefined' || !window.history || !window.location) return;
|
|
20
|
+
const targetUrl = targetPath + getAppQueryParam();
|
|
21
|
+
const currentUrl = window.location.pathname + window.location.search;
|
|
22
|
+
if (currentUrl === targetUrl) return;
|
|
23
|
+
|
|
24
|
+
if (replace) {
|
|
25
|
+
window.history.replaceState({ path: targetPath }, '', targetUrl);
|
|
26
|
+
} else {
|
|
27
|
+
window.history.pushState({ path: targetPath }, '', targetUrl);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function parseUrlAndNavigate(initial = false) {
|
|
32
|
+
if (typeof window === 'undefined' || !window.location) return;
|
|
33
|
+
|
|
34
|
+
// Resolve and synchronize active application from URL query parameter (?app=<slugOrId>)
|
|
35
|
+
const searchParams = new URLSearchParams(window.location.search || '');
|
|
36
|
+
const requestedAppSlug = searchParams.get('app');
|
|
37
|
+
|
|
38
|
+
if (requestedAppSlug) {
|
|
39
|
+
let targetApp = (state.apps || []).find(a => a.slug === requestedAppSlug || a.id === requestedAppSlug || (requestedAppSlug === 'default' && a.isDefault));
|
|
40
|
+
if (!targetApp) {
|
|
41
|
+
try {
|
|
42
|
+
await fetchApps();
|
|
43
|
+
targetApp = (state.apps || []).find(a => a.slug === requestedAppSlug || a.id === requestedAppSlug || (requestedAppSlug === 'default' && a.isDefault));
|
|
44
|
+
} catch (_) {}
|
|
45
|
+
}
|
|
46
|
+
const currentSlug = getActiveAppSlug();
|
|
47
|
+
if (targetApp && currentSlug !== targetApp.slug) {
|
|
48
|
+
state.activeApp = targetApp;
|
|
49
|
+
try {
|
|
50
|
+
localStorage.setItem('nodestack_active_app', JSON.stringify(targetApp));
|
|
51
|
+
} catch (_) {}
|
|
52
|
+
updateAppSwitcherUI();
|
|
53
|
+
updateDocsLinks(targetApp.slug);
|
|
54
|
+
try {
|
|
55
|
+
await loadCollections();
|
|
56
|
+
} catch (_) {}
|
|
57
|
+
}
|
|
58
|
+
} else if (!initial && state.activeApp && state.activeApp.slug !== 'default') {
|
|
59
|
+
// Navigating back/forward (popstate) to a route without ?app= query parameter; restore default app
|
|
60
|
+
const defaultApp = (state.apps || []).find(a => a.isDefault || a.slug === 'default') || { id: 'app_default', slug: 'default', name: 'Default App', isDefault: true };
|
|
61
|
+
if (state.activeApp.slug !== defaultApp.slug) {
|
|
62
|
+
state.activeApp = defaultApp;
|
|
63
|
+
try {
|
|
64
|
+
localStorage.setItem('nodestack_active_app', JSON.stringify(defaultApp));
|
|
65
|
+
} catch (_) {}
|
|
66
|
+
updateAppSwitcherUI();
|
|
67
|
+
updateDocsLinks(defaultApp.slug);
|
|
68
|
+
try {
|
|
69
|
+
await loadCollections();
|
|
70
|
+
} catch (_) {}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const pathname = window.location.pathname || '/';
|
|
75
|
+
|
|
76
|
+
// Normalise route:
|
|
77
|
+
// e.g. '/_/' -> ''
|
|
78
|
+
// '/_/collections' -> 'collections'
|
|
79
|
+
// '/_/collections/users/schema' -> 'collections/users/schema'
|
|
80
|
+
let route = pathname;
|
|
81
|
+
if (route.startsWith('/_')) {
|
|
82
|
+
route = route.slice(2);
|
|
83
|
+
}
|
|
84
|
+
if (route.startsWith('/')) {
|
|
85
|
+
route = route.slice(1);
|
|
86
|
+
}
|
|
87
|
+
if (route.endsWith('/')) {
|
|
88
|
+
route = route.slice(0, -1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const parts = route ? route.split('/').map(p => decodeURIComponent(p)) : [];
|
|
92
|
+
|
|
93
|
+
if (parts.length === 0 || parts[0] === 'home') {
|
|
94
|
+
await selectNav('home', false);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const root = parts[0];
|
|
99
|
+
|
|
100
|
+
if (root === 'collections') {
|
|
101
|
+
if (parts.length === 1) {
|
|
102
|
+
await selectNav('collections', false);
|
|
103
|
+
} else {
|
|
104
|
+
const colName = parts[1];
|
|
105
|
+
const tab = (parts[2] === 'schema') ? 'schema' : 'records';
|
|
106
|
+
const allCols = Array.isArray(state.collections)
|
|
107
|
+
? state.collections
|
|
108
|
+
: (state.collections && Array.isArray(state.collections.items) ? state.collections.items : []);
|
|
109
|
+
const colExists = allCols.some(c => c.name === colName);
|
|
110
|
+
if (colExists) {
|
|
111
|
+
state.collectionTab = tab;
|
|
112
|
+
await selectCollection(colName, false);
|
|
113
|
+
if (tab === 'schema') {
|
|
114
|
+
switchCollectionTab('schema', false);
|
|
115
|
+
} else {
|
|
116
|
+
switchCollectionTab('records', false);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
await selectNav('collections', false);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} else if (root === 'functions') {
|
|
123
|
+
if (typeof functionsState !== 'undefined') {
|
|
124
|
+
functionsState.subTab = (parts[1] === 'logs') ? 'logs' : 'functions';
|
|
125
|
+
if (parts.length < 2 || parts[1] === 'logs') {
|
|
126
|
+
functionsState.currentView = 'list';
|
|
127
|
+
functionsState.activeFunctionForEdit = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
await selectNav('functions', false);
|
|
131
|
+
if (parts.length >= 2 && parts[1] && parts[1] !== 'logs') {
|
|
132
|
+
if (typeof openFunctionEditor === 'function') {
|
|
133
|
+
await openFunctionEditor(parts[1], false);
|
|
134
|
+
}
|
|
135
|
+
} else if (parts[1] === 'logs') {
|
|
136
|
+
if (typeof switchFunctionsTab === 'function') switchFunctionsTab('logs', false);
|
|
137
|
+
} else {
|
|
138
|
+
if (typeof switchFunctionsTab === 'function') switchFunctionsTab('functions', false);
|
|
139
|
+
}
|
|
140
|
+
} else if (root === 'flows') {
|
|
141
|
+
if (typeof flowsState !== 'undefined') {
|
|
142
|
+
flowsState.subTab = (parts[1] === 'executions') ? 'executions' : 'flows';
|
|
143
|
+
if (parts.length < 2 || parts[1] === 'executions') {
|
|
144
|
+
flowsState.currentView = 'list';
|
|
145
|
+
flowsState.activeFlowForEdit = null;
|
|
146
|
+
if (typeof designerState !== 'undefined') {
|
|
147
|
+
designerState.activeFlow = null;
|
|
148
|
+
designerState.latestExecution = null;
|
|
149
|
+
designerState.isTestDrawerOpen = false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
await selectNav('flows', false);
|
|
154
|
+
if (parts.length >= 2 && parts[1]) {
|
|
155
|
+
if (parts[1] === 'executions') {
|
|
156
|
+
if (typeof switchFlowsTab === 'function') switchFlowsTab('executions', false);
|
|
157
|
+
} else {
|
|
158
|
+
if (typeof openFlowDesigner === 'function') await openFlowDesigner(parts[1], false, false);
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
if (typeof closeFlowDesigner === 'function' && typeof flowsState !== 'undefined' && flowsState.currentView === 'designer') {
|
|
162
|
+
closeFlowDesigner(false);
|
|
163
|
+
} else if (typeof switchFlowsTab === 'function') {
|
|
164
|
+
switchFlowsTab('flows', false);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} else if (root === 'queues') {
|
|
168
|
+
const isMessages = parts[1] === 'messages' || parts[1] === 'jobs';
|
|
169
|
+
if (typeof queuesState !== 'undefined') {
|
|
170
|
+
queuesState.subTab = isMessages ? 'messages' : 'queues';
|
|
171
|
+
}
|
|
172
|
+
await selectNav('queues', false);
|
|
173
|
+
if (isMessages) {
|
|
174
|
+
if (typeof switchQueuesTab === 'function') switchQueuesTab('messages', false);
|
|
175
|
+
} else {
|
|
176
|
+
if (typeof switchQueuesTab === 'function') switchQueuesTab('queues', false);
|
|
177
|
+
}
|
|
178
|
+
} else if (root === 'webhooks') {
|
|
179
|
+
if (typeof webhooksState !== 'undefined') {
|
|
180
|
+
webhooksState.subTab = (parts[1] === 'deliveries') ? 'deliveries' : 'webhooks';
|
|
181
|
+
}
|
|
182
|
+
await selectNav('webhooks', false);
|
|
183
|
+
if (parts[1] === 'deliveries') {
|
|
184
|
+
if (typeof switchWebhooksTab === 'function') switchWebhooksTab('deliveries', false);
|
|
185
|
+
} else {
|
|
186
|
+
if (typeof switchWebhooksTab === 'function') switchWebhooksTab('webhooks', false);
|
|
187
|
+
}
|
|
188
|
+
} else if (root === 'plugins') {
|
|
189
|
+
if (parts.length >= 2 && state.pluginNavItems && state.pluginNavItems.some(p => p.id === parts[1])) {
|
|
190
|
+
await selectNav(parts[1], false);
|
|
191
|
+
} else {
|
|
192
|
+
await selectNav('plugins', false);
|
|
193
|
+
}
|
|
194
|
+
} else if (root === 'analytics') {
|
|
195
|
+
await selectNav('analytics', false);
|
|
196
|
+
} else if (root === 'api-keys') {
|
|
197
|
+
await selectNav('api-keys', false);
|
|
198
|
+
} else if (root === 'snapshots') {
|
|
199
|
+
await selectNav('snapshots', false);
|
|
200
|
+
} else if (root === 'logs') {
|
|
201
|
+
if (typeof auditState !== 'undefined') {
|
|
202
|
+
auditState.subTab = (parts[1] === 'audit') ? 'audit' : 'traffic';
|
|
203
|
+
}
|
|
204
|
+
await selectNav('logs', false);
|
|
205
|
+
if (parts[1] === 'audit') {
|
|
206
|
+
if (typeof switchLogsSubTab === 'function') switchLogsSubTab('audit', false);
|
|
207
|
+
} else {
|
|
208
|
+
if (typeof switchLogsSubTab === 'function') switchLogsSubTab('traffic', false);
|
|
209
|
+
}
|
|
210
|
+
} else if (root === "database") {
|
|
211
|
+
await selectNav("database", false);
|
|
212
|
+
} else if (state.pluginNavItems && state.pluginNavItems.some(p => p.id === root)) {
|
|
213
|
+
await selectNav(root, false);
|
|
214
|
+
} else {
|
|
215
|
+
await selectNav('home', false);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let isRouterInitialized = false;
|
|
220
|
+
|
|
221
|
+
function initRouter() {
|
|
222
|
+
if (typeof window === 'undefined' || isRouterInitialized) return;
|
|
223
|
+
isRouterInitialized = true;
|
|
224
|
+
|
|
225
|
+
window.addEventListener('popstate', async () => {
|
|
226
|
+
// Gracefully dismiss open modals, drawers, or command palette on Back/Forward navigation
|
|
227
|
+
if (typeof closeModal === 'function') closeModal();
|
|
228
|
+
if (typeof closeRecordDrawer === 'function') closeRecordDrawer();
|
|
229
|
+
if (typeof closeWebhookModal === 'function') closeWebhookModal();
|
|
230
|
+
if (typeof closeWebhookDrawer === 'function') closeWebhookDrawer();
|
|
231
|
+
if (typeof closeFunctionModal === 'function') closeFunctionModal();
|
|
232
|
+
if (typeof closeFlowModal === 'function') closeFlowModal();
|
|
233
|
+
if (typeof closeFlowExecutionDrawer === 'function') closeFlowExecutionDrawer();
|
|
234
|
+
if (typeof closeQueueModal === 'function') closeQueueModal();
|
|
235
|
+
if (typeof closeQueueDrawer === 'function') closeQueueDrawer();
|
|
236
|
+
if (typeof closeApiKeyDrawer === 'function') closeApiKeyDrawer();
|
|
237
|
+
if (typeof closeApiKeySecretModal === 'function') closeApiKeySecretModal();
|
|
238
|
+
if (typeof closeCommandPalette === 'function') closeCommandPalette();
|
|
239
|
+
|
|
240
|
+
await parseUrlAndNavigate(false);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
function showPageView(viewName) {
|
|
246
|
+
const views = ['home', 'collections', 'plugins', 'webhooks', 'functions', 'flows', 'queues', 'api-keys', 'analytics', 'snapshots', 'database', 'logs'];
|
|
247
|
+
for (const v of views) {
|
|
248
|
+
const el = document.getElementById('page-view-' + v);
|
|
249
|
+
if (el) {
|
|
250
|
+
if (v === 'collections' || v === 'plugins' || v === 'flows') {
|
|
251
|
+
el.style.display = (v === viewName) ? 'flex' : 'none';
|
|
252
|
+
} else {
|
|
253
|
+
el.style.display = (v === viewName) ? 'block' : 'none';
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function clearSidebarNavActive() {
|
|
260
|
+
const navIds = ['nav-home', 'nav-collections', 'nav-plugins', 'nav-webhooks', 'nav-functions', 'nav-flows', 'nav-queues', 'nav-api-keys', 'nav-analytics', 'nav-snapshots', 'nav-database', 'nav-logs'];
|
|
261
|
+
for (const id of navIds) {
|
|
262
|
+
document.getElementById(id)?.classList.remove('active');
|
|
263
|
+
}
|
|
264
|
+
if (state.pluginNavItems && Array.isArray(state.pluginNavItems)) {
|
|
265
|
+
for (const item of state.pluginNavItems) {
|
|
266
|
+
document.getElementById('nav-' + item.id)?.classList.remove('active');
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
document.querySelectorAll('.sidebar-nav-item.active').forEach(el => el.classList.remove('active'));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function selectNav(nav, pushState = true) {
|
|
273
|
+
state.activeNav = nav;
|
|
274
|
+
|
|
275
|
+
if (typeof stopAnalyticsAutoRefresh === 'function') {
|
|
276
|
+
stopAnalyticsAutoRefresh();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
clearSidebarNavActive();
|
|
280
|
+
|
|
281
|
+
const colActions = document.getElementById('collection-actions');
|
|
282
|
+
if (colActions && nav !== 'collection') {
|
|
283
|
+
colActions.innerHTML = '';
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (pushState) {
|
|
287
|
+
if (typeof closeModal === 'function') closeModal();
|
|
288
|
+
if (typeof closeRecordDrawer === 'function') closeRecordDrawer();
|
|
289
|
+
if (typeof closeWebhookModal === 'function') closeWebhookModal();
|
|
290
|
+
if (typeof closeWebhookDrawer === 'function') closeWebhookDrawer();
|
|
291
|
+
if (typeof closeFunctionModal === 'function') closeFunctionModal();
|
|
292
|
+
if (typeof closeFlowModal === 'function') closeFlowModal();
|
|
293
|
+
if (typeof closeFlowExecutionDrawer === 'function') closeFlowExecutionDrawer();
|
|
294
|
+
if (typeof closeQueueModal === 'function') closeQueueModal();
|
|
295
|
+
if (typeof closeQueueDrawer === 'function') closeQueueDrawer();
|
|
296
|
+
if (typeof closeApiKeyDrawer === 'function') closeApiKeyDrawer();
|
|
297
|
+
if (typeof closeApiKeySecretModal === 'function') closeApiKeySecretModal();
|
|
298
|
+
if (typeof closeCommandPalette === 'function') closeCommandPalette();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (nav === 'home') {
|
|
302
|
+
state.activeCollection = null;
|
|
303
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
304
|
+
showPageView('home');
|
|
305
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
306
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
307
|
+
document.getElementById('nav-home')?.classList.add('active');
|
|
308
|
+
document.getElementById('view-title').textContent = 'Overview';
|
|
309
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
310
|
+
if (typeof renderHomeView === 'function') renderHomeView();
|
|
311
|
+
} else if (nav === 'collections') {
|
|
312
|
+
state.activeCollection = null;
|
|
313
|
+
state.collectionTab = 'records';
|
|
314
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
315
|
+
showPageView('collections');
|
|
316
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
317
|
+
document.getElementById('nav-collections')?.classList.add('active');
|
|
318
|
+
document.getElementById('view-title').textContent = 'Collections';
|
|
319
|
+
document.getElementById('view-title').style.display = 'inline-block';
|
|
320
|
+
const count = state.collections ? state.collections.length : 0;
|
|
321
|
+
const badgeEl = document.getElementById('view-badge');
|
|
322
|
+
badgeEl.textContent = count + ' Tables';
|
|
323
|
+
badgeEl.className = 'badge badge-get';
|
|
324
|
+
badgeEl.style.display = 'inline-block';
|
|
325
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
326
|
+
if (typeof renderCollectionsHubView === 'function') renderCollectionsHubView();
|
|
327
|
+
} else if (nav === 'plugins') {
|
|
328
|
+
state.activeCollection = null;
|
|
329
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
330
|
+
showPageView('plugins');
|
|
331
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
332
|
+
document.getElementById('nav-plugins')?.classList.add('active');
|
|
333
|
+
document.getElementById('view-title').textContent = 'Plugins';
|
|
334
|
+
document.getElementById('view-title').style.display = 'inline-block';
|
|
335
|
+
const pCount = (state.pluginNavItems || []).length;
|
|
336
|
+
const badgeEl = document.getElementById('view-badge');
|
|
337
|
+
badgeEl.textContent = pCount + ' Active';
|
|
338
|
+
badgeEl.className = 'badge badge-primary';
|
|
339
|
+
badgeEl.style.display = pCount > 0 ? 'inline-block' : 'none';
|
|
340
|
+
document.getElementById('view-actions').innerHTML = `
|
|
341
|
+
<a href="/_/docs" target="_blank" onclick="openDocsWithApp(event)" class="btn btn-secondary btn-sm" style="text-decoration:none;">OpenAPI Specs ↗</a>
|
|
342
|
+
`;
|
|
343
|
+
if (typeof renderPluginNavItems === 'function') renderPluginNavItems();
|
|
344
|
+
if (typeof renderPluginsHubView === 'function') renderPluginsHubView();
|
|
345
|
+
} else if (nav === 'webhooks') {
|
|
346
|
+
state.activeCollection = null;
|
|
347
|
+
if (pushState && typeof webhooksState !== 'undefined') {
|
|
348
|
+
webhooksState.subTab = 'webhooks';
|
|
349
|
+
}
|
|
350
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
351
|
+
showPageView('webhooks');
|
|
352
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
353
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
354
|
+
document.getElementById('nav-webhooks')?.classList.add('active');
|
|
355
|
+
document.getElementById('view-title').textContent = 'Webhooks Manager';
|
|
356
|
+
document.getElementById('view-title').style.display = 'none';
|
|
357
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
358
|
+
if (typeof renderWebhooksView === 'function') renderWebhooksView();
|
|
359
|
+
} else if (nav === 'functions') {
|
|
360
|
+
state.activeCollection = null;
|
|
361
|
+
if (pushState) {
|
|
362
|
+
if (typeof functionsState !== 'undefined') {
|
|
363
|
+
functionsState.subTab = 'functions';
|
|
364
|
+
functionsState.currentView = 'list';
|
|
365
|
+
functionsState.activeFunctionForEdit = null;
|
|
366
|
+
}
|
|
367
|
+
if (typeof closeFunctionEditor === 'function') closeFunctionEditor(false);
|
|
368
|
+
}
|
|
369
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
370
|
+
showPageView('functions');
|
|
371
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
372
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
373
|
+
document.getElementById('nav-functions')?.classList.add('active');
|
|
374
|
+
document.getElementById('view-title').textContent = 'Functions';
|
|
375
|
+
document.getElementById('view-title').style.display = 'none';
|
|
376
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
377
|
+
if (typeof renderFunctionsView === 'function') renderFunctionsView();
|
|
378
|
+
} else if (nav === 'flows') {
|
|
379
|
+
state.activeCollection = null;
|
|
380
|
+
if (pushState) {
|
|
381
|
+
if (typeof flowsState !== 'undefined') {
|
|
382
|
+
flowsState.subTab = 'flows';
|
|
383
|
+
flowsState.currentView = 'list';
|
|
384
|
+
flowsState.activeFlowForEdit = null;
|
|
385
|
+
}
|
|
386
|
+
if (typeof designerState !== 'undefined') {
|
|
387
|
+
designerState.activeFlow = null;
|
|
388
|
+
designerState.latestExecution = null;
|
|
389
|
+
designerState.isTestDrawerOpen = false;
|
|
390
|
+
}
|
|
391
|
+
if (typeof closeFlowDesigner === 'function') closeFlowDesigner(false);
|
|
392
|
+
}
|
|
393
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
394
|
+
showPageView('flows');
|
|
395
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
396
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
397
|
+
document.getElementById('nav-flows')?.classList.add('active');
|
|
398
|
+
document.getElementById('view-title').textContent = 'Functions Flow';
|
|
399
|
+
document.getElementById('view-title').style.display = 'none';
|
|
400
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
401
|
+
if (typeof renderFlowsView === 'function') renderFlowsView();
|
|
402
|
+
if (typeof loadFlows === 'function') loadFlows().then(() => { if (typeof renderFlowsView === 'function') renderFlowsView(); });
|
|
403
|
+
} else if (nav === 'queues') {
|
|
404
|
+
state.activeCollection = null;
|
|
405
|
+
if (pushState && typeof queuesState !== 'undefined') {
|
|
406
|
+
queuesState.subTab = 'queues';
|
|
407
|
+
}
|
|
408
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
409
|
+
showPageView('queues');
|
|
410
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
411
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
412
|
+
document.getElementById('nav-queues')?.classList.add('active');
|
|
413
|
+
document.getElementById('view-title').textContent = 'Queues Manager';
|
|
414
|
+
document.getElementById('view-title').style.display = 'none';
|
|
415
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
416
|
+
if (typeof renderQueuesView === 'function') renderQueuesView();
|
|
417
|
+
} else if (nav === 'api-keys') {
|
|
418
|
+
state.activeCollection = null;
|
|
419
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
420
|
+
showPageView('api-keys');
|
|
421
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
422
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
423
|
+
document.getElementById('nav-api-keys')?.classList.add('active');
|
|
424
|
+
document.getElementById('view-title').textContent = 'API Keys';
|
|
425
|
+
document.getElementById('view-title').style.display = 'none';
|
|
426
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
427
|
+
if (typeof renderApiKeysView === 'function') renderApiKeysView();
|
|
428
|
+
if (typeof loadApiKeys === 'function') loadApiKeys();
|
|
429
|
+
} else if (nav === 'analytics') {
|
|
430
|
+
state.activeCollection = null;
|
|
431
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
432
|
+
showPageView('analytics');
|
|
433
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
434
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
435
|
+
document.getElementById('nav-analytics')?.classList.add('active');
|
|
436
|
+
document.getElementById('view-title').textContent = 'Analytics';
|
|
437
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
438
|
+
if (typeof renderAnalyticsView === 'function') renderAnalyticsView();
|
|
439
|
+
if (typeof loadAnalytics === 'function') loadAnalytics();
|
|
440
|
+
if (typeof analyticsState !== 'undefined' && analyticsState.autoRefreshEnabled && typeof startAnalyticsAutoRefresh === 'function') {
|
|
441
|
+
startAnalyticsAutoRefresh();
|
|
442
|
+
}
|
|
443
|
+
} else if (nav === 'snapshots') {
|
|
444
|
+
state.activeCollection = null;
|
|
445
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
446
|
+
showPageView('snapshots');
|
|
447
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
448
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
449
|
+
document.getElementById('nav-snapshots')?.classList.add('active');
|
|
450
|
+
document.getElementById('view-title').textContent = 'Snapshots';
|
|
451
|
+
document.getElementById('view-actions').innerHTML = `
|
|
452
|
+
<button class="btn btn-primary btn-sm" onclick="openCreateSnapshotModal()" style="font-weight:600;">
|
|
453
|
+
+ Create Snapshot
|
|
454
|
+
</button>
|
|
455
|
+
`;
|
|
456
|
+
if (typeof renderSnapshotsView === 'function') renderSnapshotsView();
|
|
457
|
+
} else if (nav === 'database') {
|
|
458
|
+
state.activeCollection = null;
|
|
459
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
460
|
+
showPageView('database');
|
|
461
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
462
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
463
|
+
document.getElementById('sidebar-database-link')?.classList.add('active');
|
|
464
|
+
document.getElementById('nav-database')?.classList.add('active');
|
|
465
|
+
document.getElementById('view-title').textContent = 'Database Engine';
|
|
466
|
+
document.getElementById('view-actions').innerHTML = '';
|
|
467
|
+
if (typeof databaseState !== 'undefined' && !databaseState.showConfirmSwitch && !databaseState.isSwitching) {
|
|
468
|
+
databaseState.selectedProvider = databaseState.status?.provider ? databaseState.status.provider.toLowerCase() : null;
|
|
469
|
+
}
|
|
470
|
+
if (typeof renderDatabaseView === 'function') renderDatabaseView();
|
|
471
|
+
if (typeof fetchDatabaseStatus === 'function') {
|
|
472
|
+
fetchDatabaseStatus().then((status) => {
|
|
473
|
+
if (typeof databaseState !== 'undefined' && !databaseState.showConfirmSwitch && !databaseState.isSwitching && status?.provider) {
|
|
474
|
+
databaseState.selectedProvider = status.provider.toLowerCase();
|
|
475
|
+
}
|
|
476
|
+
if (state.activeNav === 'database' && typeof renderDatabaseView === 'function') {
|
|
477
|
+
renderDatabaseView();
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
} else if (nav === 'logs') {
|
|
482
|
+
state.activeCollection = null;
|
|
483
|
+
if (pushState && typeof auditState !== 'undefined') {
|
|
484
|
+
auditState.subTab = 'traffic';
|
|
485
|
+
}
|
|
486
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
487
|
+
showPageView('logs');
|
|
488
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
489
|
+
document.getElementById('view-badge').style.display = 'none';
|
|
490
|
+
document.getElementById('nav-logs')?.classList.add('active');
|
|
491
|
+
document.getElementById('view-title').textContent = 'Audit Logs';
|
|
492
|
+
if (typeof renderLogsView === 'function') renderLogsView();
|
|
493
|
+
if (typeof loadLogsSubTab === 'function') {
|
|
494
|
+
loadLogsSubTab();
|
|
495
|
+
} else if (typeof loadLogs === 'function') {
|
|
496
|
+
loadLogs();
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
} else if (state.pluginNavItems && state.pluginNavItems.some(p => p.id === nav || (nav === 'resend' && p.id === 'resend-email'))) {
|
|
500
|
+
state.activeCollection = null;
|
|
501
|
+
if (typeof renderCollectionsList === 'function') renderCollectionsList();
|
|
502
|
+
showPageView('plugins');
|
|
503
|
+
document.getElementById('collection-tabs').style.display = 'none';
|
|
504
|
+
document.getElementById('nav-plugins')?.classList.add('active');
|
|
505
|
+
document.getElementById('nav-' + nav)?.classList.add('active');
|
|
506
|
+
const pluginItem = state.pluginNavItems.find(p => p.id === nav || (nav === 'resend' && p.id === 'resend-email'));
|
|
507
|
+
if (typeof renderPluginView === 'function') renderPluginView(pluginItem);
|
|
508
|
+
}
|
|
509
|
+
if (typeof updateBreadcrumbs === 'function') updateBreadcrumbs();
|
|
510
|
+
|
|
511
|
+
if (pushState) {
|
|
512
|
+
if (nav === 'home') {
|
|
513
|
+
updateUrl('/_/');
|
|
514
|
+
} else if (nav === 'collections') {
|
|
515
|
+
updateUrl('/_/collections');
|
|
516
|
+
} else if (nav === 'webhooks') {
|
|
517
|
+
updateUrl('/_/webhooks');
|
|
518
|
+
} else if (nav === 'functions') {
|
|
519
|
+
updateUrl('/_/functions');
|
|
520
|
+
} else if (nav === 'flows') {
|
|
521
|
+
updateUrl('/_/flows');
|
|
522
|
+
} else if (nav === 'queues') {
|
|
523
|
+
updateUrl('/_/queues');
|
|
524
|
+
} else if (nav === 'api-keys') {
|
|
525
|
+
updateUrl('/_/api-keys');
|
|
526
|
+
} else if (nav === 'analytics') {
|
|
527
|
+
updateUrl('/_/analytics');
|
|
528
|
+
} else if (nav === 'snapshots') {
|
|
529
|
+
updateUrl('/_/snapshots');
|
|
530
|
+
} else if (nav === 'database') {
|
|
531
|
+
updateUrl('/_/database');
|
|
532
|
+
} else if (nav === 'logs') {
|
|
533
|
+
updateUrl('/_/logs');
|
|
534
|
+
} else if (nav === 'plugins') {
|
|
535
|
+
updateUrl('/_/plugins');
|
|
536
|
+
} else if (state.pluginNavItems && state.pluginNavItems.some(p => p.id === nav || (nav === 'resend' && p.id === 'resend-email'))) {
|
|
537
|
+
updateUrl('/_/plugins/' + encodeURIComponent(nav));
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// Close dropdown menu when clicking outside
|
|
543
|
+
window.addEventListener('click', (e) => {
|
|
544
|
+
const menu = document.getElementById('collection-create-menu');
|
|
545
|
+
if (menu && !e.target.closest('#btn-collection-new-dropdown') && !e.target.closest('#collection-create-menu')) {
|
|
546
|
+
menu.style.display = 'none';
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
// Global Keydown shortcuts: Ctrl+K / Cmd+K and Escape
|
|
551
|
+
window.addEventListener('keydown', (e) => {
|
|
552
|
+
if ((e.ctrlKey || e.metaKey) && (e.key === 'k' || e.key === 'K')) {
|
|
553
|
+
e.preventDefault();
|
|
554
|
+
if (typeof toggleCommandPalette === 'function') {
|
|
555
|
+
toggleCommandPalette();
|
|
556
|
+
}
|
|
557
|
+
} else if (e.key === 'Escape') {
|
|
558
|
+
if (typeof closeCollectionCreateMenu === 'function') {
|
|
559
|
+
closeCollectionCreateMenu();
|
|
560
|
+
}
|
|
561
|
+
const root = document.getElementById('command-palette-root');
|
|
562
|
+
if (root && root.innerHTML.trim().length > 0) {
|
|
563
|
+
e.preventDefault();
|
|
564
|
+
e.stopImmediatePropagation();
|
|
565
|
+
if (typeof closeCommandPalette === 'function') {
|
|
566
|
+
closeCommandPalette();
|
|
567
|
+
}
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
const drawerRoot = document.getElementById('drawer-root');
|
|
571
|
+
if (drawerRoot && drawerRoot.innerHTML.trim().length > 0) {
|
|
572
|
+
e.preventDefault();
|
|
573
|
+
e.stopImmediatePropagation();
|
|
574
|
+
if (typeof closePluginTesterDrawer === 'function') {
|
|
575
|
+
closePluginTesterDrawer();
|
|
576
|
+
}
|
|
577
|
+
if (typeof closeRecordDrawer === 'function') {
|
|
578
|
+
closeRecordDrawer();
|
|
579
|
+
}
|
|
580
|
+
if (typeof closeWebhookDrawer === 'function') {
|
|
581
|
+
closeWebhookDrawer();
|
|
582
|
+
}
|
|
583
|
+
if (typeof closeFlowExecutionDrawer === 'function') {
|
|
584
|
+
closeFlowExecutionDrawer();
|
|
585
|
+
}
|
|
586
|
+
if (typeof closeQueueDrawer === 'function') {
|
|
587
|
+
closeQueueDrawer();
|
|
588
|
+
}
|
|
589
|
+
if (typeof closeApiKeyDrawer === 'function') {
|
|
590
|
+
closeApiKeyDrawer();
|
|
591
|
+
}
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const modalRoot = document.getElementById('modal-root');
|
|
595
|
+
if (modalRoot && modalRoot.innerHTML.trim().length > 0) {
|
|
596
|
+
e.preventDefault();
|
|
597
|
+
e.stopImmediatePropagation();
|
|
598
|
+
if (typeof closeWebhookModal === 'function') {
|
|
599
|
+
closeWebhookModal();
|
|
600
|
+
}
|
|
601
|
+
if (typeof closeModal === 'function') {
|
|
602
|
+
closeModal();
|
|
603
|
+
}
|
|
604
|
+
if (typeof closeFlowModal === 'function') {
|
|
605
|
+
closeFlowModal();
|
|
606
|
+
}
|
|
607
|
+
if (typeof closeQueueModal === 'function') {
|
|
608
|
+
closeQueueModal();
|
|
609
|
+
}
|
|
610
|
+
if (typeof closeApiKeySecretModal === 'function') {
|
|
611
|
+
closeApiKeySecretModal();
|
|
612
|
+
}
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
// Expose core navigation & lifecycle helpers on window
|
|
619
|
+
if (typeof window !== 'undefined') {
|
|
620
|
+
window.showPageView = showPageView;
|
|
621
|
+
window.clearSidebarNavActive = clearSidebarNavActive;
|
|
622
|
+
window.selectNav = selectNav;
|
|
623
|
+
window.getAppQueryParam = getAppQueryParam;
|
|
624
|
+
window.updateUrl = updateUrl;
|
|
625
|
+
window.parseUrlAndNavigate = parseUrlAndNavigate;
|
|
626
|
+
window.initRouter = initRouter;
|
|
627
|
+
|
|
628
|
+
// Mirror modular exports to window if present
|
|
629
|
+
if (typeof selectCollection !== 'undefined') window.selectCollection = selectCollection;
|
|
630
|
+
if (typeof switchCollectionTab !== 'undefined') window.switchCollectionTab = switchCollectionTab;
|
|
631
|
+
if (typeof renderCollectionsList !== 'undefined') window.renderCollectionsList = renderCollectionsList;
|
|
632
|
+
if (typeof toggleCollectionSection !== 'undefined') window.toggleCollectionSection = toggleCollectionSection;
|
|
633
|
+
if (typeof handleCollectionFilterInput !== 'undefined') window.handleCollectionFilterInput = handleCollectionFilterInput;
|
|
634
|
+
if (typeof clearCollectionFilter !== 'undefined') window.clearCollectionFilter = clearCollectionFilter;
|
|
635
|
+
if (typeof updateBreadcrumbs !== 'undefined') window.updateBreadcrumbs = updateBreadcrumbs;
|
|
636
|
+
if (typeof handleBreadcrumbClick !== 'undefined') window.handleBreadcrumbClick = handleBreadcrumbClick;
|
|
637
|
+
if (typeof openCommandPalette !== 'undefined') window.openCommandPalette = openCommandPalette;
|
|
638
|
+
if (typeof closeCommandPalette !== 'undefined') window.closeCommandPalette = closeCommandPalette;
|
|
639
|
+
if (typeof toggleCommandPalette !== 'undefined') window.toggleCommandPalette = toggleCommandPalette;
|
|
640
|
+
if (typeof getAllCommandPaletteItems !== 'undefined') window.getAllCommandPaletteItems = getAllCommandPaletteItems;
|
|
641
|
+
if (typeof filterCommandPaletteItems !== 'undefined') window.filterCommandPaletteItems = filterCommandPaletteItems;
|
|
642
|
+
if (typeof executeCommandPaletteItem !== 'undefined') window.executeCommandPaletteItem = executeCommandPaletteItem;
|
|
643
|
+
if (typeof handleCommandPaletteInput !== 'undefined') window.handleCommandPaletteInput = handleCommandPaletteInput;
|
|
644
|
+
if (typeof handleCommandPaletteKeyDown !== 'undefined') window.handleCommandPaletteKeyDown = handleCommandPaletteKeyDown;
|
|
645
|
+
if (typeof setCommandPaletteActiveIndex !== 'undefined') window.setCommandPaletteActiveIndex = setCommandPaletteActiveIndex;
|
|
646
|
+
if (typeof renderPluginNavItems !== 'undefined') window.renderPluginNavItems = renderPluginNavItems;
|
|
647
|
+
if (typeof renderPluginView !== 'undefined') window.renderPluginView = renderPluginView;
|
|
648
|
+
if (typeof openPluginTesterDrawer !== 'undefined') window.openPluginTesterDrawer = openPluginTesterDrawer;
|
|
649
|
+
if (typeof closePluginTesterDrawer !== 'undefined') window.closePluginTesterDrawer = closePluginTesterDrawer;
|
|
650
|
+
if (typeof executePluginTest !== 'undefined') window.executePluginTest = executePluginTest;
|
|
651
|
+
if (typeof checkPluginTesterStatus !== 'undefined') window.checkPluginTesterStatus = checkPluginTesterStatus;
|
|
652
|
+
if (typeof runStripeCheckoutTest !== 'undefined') window.runStripeCheckoutTest = runStripeCheckoutTest;
|
|
653
|
+
if (typeof runStripeWebhookSimulation !== 'undefined') window.runStripeWebhookSimulation = runStripeWebhookSimulation;
|
|
654
|
+
if (typeof runS3PresignedUrlTest !== 'undefined') window.runS3PresignedUrlTest = runS3PresignedUrlTest;
|
|
655
|
+
if (typeof runS3StatusTest !== 'undefined') window.runS3StatusTest = runS3StatusTest;
|
|
656
|
+
if (typeof runResendSendTest !== 'undefined') window.runResendSendTest = runResendSendTest;
|
|
657
|
+
if (typeof runWebhookDispatchTest !== 'undefined') window.runWebhookDispatchTest = runWebhookDispatchTest;
|
|
658
|
+
if (typeof runAlgoliaReindexTest !== 'undefined') window.runAlgoliaReindexTest = runAlgoliaReindexTest;
|
|
659
|
+
if (typeof runAlgoliaProcessQueueTest !== 'undefined') window.runAlgoliaProcessQueueTest = runAlgoliaProcessQueueTest;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (typeof window !== 'undefined') {
|
|
663
|
+
initRouter();
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// Run on startup
|
|
667
|
+
window.addEventListener('DOMContentLoaded', init);
|