@nodestackapp/server 1.3.0 → 2.1.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/LICENSE +15 -0
- package/README.md +14 -13
- package/dist/NodeStack.d.ts +14 -0
- package/dist/NodeStack.d.ts.map +1 -1
- package/dist/NodeStack.js +42 -3
- package/dist/NodeStack.js.map +1 -1
- package/dist/admin/AdminUIBundler.d.ts.map +1 -1
- package/dist/admin/AdminUIBundler.js +10 -5
- package/dist/admin/AdminUIBundler.js.map +1 -1
- package/dist/admin/ui/css/analytics.css +68 -11
- package/dist/admin/ui/css/codemirror.css +98 -0
- package/dist/admin/ui/css/main.css +372 -78
- package/dist/admin/ui/css/rules.css +292 -264
- package/dist/admin/ui/css/webhooks.css +34 -10
- package/dist/admin/ui/index.html +9326 -5706
- package/dist/admin/ui/js/analytics.js +673 -624
- package/dist/admin/ui/js/api.js +60 -14
- package/dist/admin/ui/js/app.js +480 -263
- package/dist/admin/ui/js/apps.js +50 -17
- package/dist/admin/ui/js/codemirror.js +15 -0
- package/dist/admin/ui/js/collections.js +41 -13
- package/dist/admin/ui/js/command-palette.js +61 -19
- package/dist/admin/ui/js/demo.js +373 -271
- package/dist/admin/ui/js/functions-tester.js +432 -0
- package/dist/admin/ui/js/functions-workbench.js +1038 -0
- package/dist/admin/ui/js/functions.js +765 -0
- package/dist/admin/ui/js/modals.js +20 -16
- package/dist/admin/ui/js/plugin-tester.js +562 -559
- package/dist/admin/ui/js/plugins.js +221 -90
- package/dist/admin/ui/js/records.js +96 -61
- package/dist/admin/ui/js/rules.js +1 -1
- package/dist/admin/ui/js/schema.js +23 -9
- package/dist/admin/ui/js/theme.js +120 -0
- package/dist/admin/ui/js/views.js +680 -714
- package/dist/admin/ui/js/webhooks.js +1111 -1086
- package/dist/apps/AppScope.d.ts +6 -0
- package/dist/apps/AppScope.d.ts.map +1 -1
- package/dist/apps/AppScope.js +40 -4
- package/dist/apps/AppScope.js.map +1 -1
- package/dist/auth/ApiKeyService.d.ts +91 -0
- package/dist/auth/ApiKeyService.d.ts.map +1 -0
- package/dist/auth/ApiKeyService.js +414 -0
- package/dist/auth/ApiKeyService.js.map +1 -0
- package/dist/auth/AuthService.d.ts +33 -1
- package/dist/auth/AuthService.d.ts.map +1 -1
- package/dist/auth/AuthService.js +255 -10
- package/dist/auth/AuthService.js.map +1 -1
- package/dist/auth/oauth/AppleProvider.d.ts +23 -0
- package/dist/auth/oauth/AppleProvider.d.ts.map +1 -0
- package/dist/auth/oauth/AppleProvider.js +161 -0
- package/dist/auth/oauth/AppleProvider.js.map +1 -0
- package/dist/auth/oauth/BaseOAuthProvider.d.ts +18 -0
- package/dist/auth/oauth/BaseOAuthProvider.d.ts.map +1 -0
- package/dist/auth/oauth/BaseOAuthProvider.js +79 -0
- package/dist/auth/oauth/BaseOAuthProvider.js.map +1 -0
- package/dist/auth/oauth/DiscordProvider.d.ts +11 -0
- package/dist/auth/oauth/DiscordProvider.d.ts.map +1 -0
- package/dist/auth/oauth/DiscordProvider.js +47 -0
- package/dist/auth/oauth/DiscordProvider.js.map +1 -0
- package/dist/auth/oauth/GitHubProvider.d.ts +13 -0
- package/dist/auth/oauth/GitHubProvider.d.ts.map +1 -0
- package/dist/auth/oauth/GitHubProvider.js +90 -0
- package/dist/auth/oauth/GitHubProvider.js.map +1 -0
- package/dist/auth/oauth/GoogleProvider.d.ts +11 -0
- package/dist/auth/oauth/GoogleProvider.d.ts.map +1 -0
- package/dist/auth/oauth/GoogleProvider.js +43 -0
- package/dist/auth/oauth/GoogleProvider.js.map +1 -0
- package/dist/auth/oauth/MicrosoftProvider.d.ts +11 -0
- package/dist/auth/oauth/MicrosoftProvider.d.ts.map +1 -0
- package/dist/auth/oauth/MicrosoftProvider.js +83 -0
- package/dist/auth/oauth/MicrosoftProvider.js.map +1 -0
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts +32 -0
- package/dist/auth/oauth/OAuthProviderRegistry.d.ts.map +1 -0
- package/dist/auth/oauth/OAuthProviderRegistry.js +232 -0
- package/dist/auth/oauth/OAuthProviderRegistry.js.map +1 -0
- package/dist/auth/oauth/types.d.ts +63 -0
- package/dist/auth/oauth/types.d.ts.map +1 -0
- package/dist/auth/oauth/types.js +3 -0
- package/dist/auth/oauth/types.js.map +1 -0
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +74 -10
- package/dist/cli/cli.js.map +1 -1
- package/dist/core/config/ConfigService.d.ts +1 -0
- package/dist/core/config/ConfigService.d.ts.map +1 -1
- package/dist/core/config/ConfigService.js +4 -1
- package/dist/core/config/ConfigService.js.map +1 -1
- package/dist/core/container/Tokens.d.ts +4 -0
- package/dist/core/container/Tokens.d.ts.map +1 -1
- package/dist/core/container/Tokens.js +4 -0
- package/dist/core/container/Tokens.js.map +1 -1
- package/dist/core/plugins/PluginManager.d.ts.map +1 -1
- package/dist/core/plugins/PluginManager.js +73 -19
- package/dist/core/plugins/PluginManager.js.map +1 -1
- package/dist/database/migrations/SystemMigrations.d.ts.map +1 -1
- package/dist/database/migrations/SystemMigrations.js +41 -1
- package/dist/database/migrations/SystemMigrations.js.map +1 -1
- package/dist/demo/DemoService.d.ts +15 -103
- package/dist/demo/DemoService.d.ts.map +1 -1
- package/dist/demo/DemoService.js +14 -419
- package/dist/demo/DemoService.js.map +1 -1
- package/dist/functions/FunctionService.d.ts +80 -0
- package/dist/functions/FunctionService.d.ts.map +1 -0
- package/dist/functions/FunctionService.js +610 -0
- package/dist/functions/FunctionService.js.map +1 -0
- package/dist/functions/runtime/IFunctionRuntime.d.ts +23 -0
- package/dist/functions/runtime/IFunctionRuntime.d.ts.map +1 -0
- package/dist/functions/runtime/IFunctionRuntime.js +3 -0
- package/dist/functions/runtime/IFunctionRuntime.js.map +1 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.d.ts +21 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.d.ts.map +1 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.js +418 -0
- package/dist/functions/runtime/QuickJsWasmRuntime.js.map +1 -0
- package/dist/functions/runtime/SandboxedRunner.d.ts +31 -0
- package/dist/functions/runtime/SandboxedRunner.d.ts.map +1 -0
- package/dist/functions/runtime/SandboxedRunner.js +61 -0
- package/dist/functions/runtime/SandboxedRunner.js.map +1 -0
- package/dist/functions/security/SsrfGuard.d.ts +41 -0
- package/dist/functions/security/SsrfGuard.d.ts.map +1 -0
- package/dist/functions/security/SsrfGuard.js +470 -0
- package/dist/functions/security/SsrfGuard.js.map +1 -0
- package/dist/functions/types.d.ts +109 -0
- package/dist/functions/types.d.ts.map +1 -0
- package/dist/functions/types.js +3 -0
- package/dist/functions/types.js.map +1 -0
- package/dist/http/HttpServer.d.ts +9 -1
- package/dist/http/HttpServer.d.ts.map +1 -1
- package/dist/http/HttpServer.js +108 -8
- package/dist/http/HttpServer.js.map +1 -1
- package/dist/http/controllers/ApiKeyController.d.ts +31 -0
- package/dist/http/controllers/ApiKeyController.d.ts.map +1 -0
- package/dist/http/controllers/ApiKeyController.js +52 -0
- package/dist/http/controllers/ApiKeyController.js.map +1 -0
- package/dist/http/controllers/AuthController.d.ts +29 -1
- package/dist/http/controllers/AuthController.d.ts.map +1 -1
- package/dist/http/controllers/AuthController.js +42 -1
- package/dist/http/controllers/AuthController.js.map +1 -1
- package/dist/http/controllers/DemoController.d.ts.map +1 -1
- package/dist/http/controllers/DemoController.js +1 -0
- package/dist/http/controllers/DemoController.js.map +1 -1
- package/dist/http/controllers/FunctionController.d.ts +64 -0
- package/dist/http/controllers/FunctionController.d.ts.map +1 -0
- package/dist/http/controllers/FunctionController.js +202 -0
- package/dist/http/controllers/FunctionController.js.map +1 -0
- package/dist/http/controllers/HealthController.js +2 -2
- package/dist/http/controllers/RecordController.d.ts.map +1 -1
- package/dist/http/controllers/RecordController.js +4 -0
- package/dist/http/controllers/RecordController.js.map +1 -1
- package/dist/http/controllers/SnapshotController.d.ts +58 -0
- package/dist/http/controllers/SnapshotController.d.ts.map +1 -0
- package/dist/http/controllers/SnapshotController.js +79 -0
- package/dist/http/controllers/SnapshotController.js.map +1 -0
- package/dist/http/middleware/AuthMiddleware.d.ts +6 -1
- package/dist/http/middleware/AuthMiddleware.d.ts.map +1 -1
- package/dist/http/middleware/AuthMiddleware.js +79 -8
- package/dist/http/middleware/AuthMiddleware.js.map +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -3
- package/dist/index.js.map +1 -1
- package/dist/plugins/chat-notifications.d.ts +51 -0
- package/dist/plugins/chat-notifications.d.ts.map +1 -0
- package/dist/plugins/chat-notifications.js +545 -0
- package/dist/plugins/chat-notifications.js.map +1 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/webhooks.d.ts +5 -34
- package/dist/plugins/webhooks.d.ts.map +1 -1
- package/dist/plugins/webhooks.js +11 -412
- package/dist/plugins/webhooks.js.map +1 -1
- package/dist/records/MockDataService.d.ts.map +1 -1
- package/dist/records/MockDataService.js +3 -0
- package/dist/records/MockDataService.js.map +1 -1
- package/dist/records/QueryFilterParser.d.ts.map +1 -1
- package/dist/records/QueryFilterParser.js +2 -1
- package/dist/records/QueryFilterParser.js.map +1 -1
- package/dist/records/RecordService.d.ts.map +1 -1
- package/dist/records/RecordService.js +70 -43
- package/dist/records/RecordService.js.map +1 -1
- package/dist/records/RecordValidator.d.ts +6 -0
- package/dist/records/RecordValidator.d.ts.map +1 -0
- package/dist/records/RecordValidator.js +100 -0
- package/dist/records/RecordValidator.js.map +1 -0
- package/dist/rules/RuleEngine.d.ts +14 -0
- package/dist/rules/RuleEngine.d.ts.map +1 -1
- package/dist/rules/RuleEngine.js +144 -1
- package/dist/rules/RuleEngine.js.map +1 -1
- package/dist/schema/OpenApiGenerator.js +3 -3
- package/dist/snapshots/SnapshotService.d.ts +75 -0
- package/dist/snapshots/SnapshotService.d.ts.map +1 -0
- package/dist/snapshots/SnapshotService.js +775 -0
- package/dist/snapshots/SnapshotService.js.map +1 -0
- package/dist/snapshots/types.d.ts +63 -0
- package/dist/snapshots/types.d.ts.map +1 -0
- package/dist/snapshots/types.js +5 -0
- package/dist/snapshots/types.js.map +1 -0
- package/dist/templates/definitions/ecommerce.js +13 -13
- package/dist/templates/definitions/ecommerce.js.map +1 -1
- package/dist/webhooks/WebhookService.js +1 -1
- package/package.json +4 -3
|
@@ -1,714 +1,680 @@
|
|
|
1
|
-
// Overview
|
|
2
|
-
function renderHomeView() {
|
|
3
|
-
const main = document.getElementById('page-view-home') || document.getElementById('main-body');
|
|
4
|
-
const collections = state.collections || [];
|
|
5
|
-
const collectionsCount = collections.length;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<div style="
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<div style="
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<span
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<div style="
|
|
121
|
-
<
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<span
|
|
127
|
-
</
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
<
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
</
|
|
217
|
-
<
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
<
|
|
225
|
-
<
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
if (
|
|
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
|
-
|
|
379
|
-
function
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if (
|
|
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
|
-
|
|
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
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
function
|
|
510
|
-
const
|
|
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
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
if (
|
|
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
|
-
</td>
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
try {
|
|
616
|
-
const res = await api('/api/logs
|
|
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
|
-
try {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
<span style="color:var(--text-muted);">Version</span>
|
|
682
|
-
<code>${health.version}</code>
|
|
683
|
-
</div>
|
|
684
|
-
<div style="display:flex; justify-content:space-between; border-bottom:1px solid var(--border-subtle); padding-bottom:0.5rem;">
|
|
685
|
-
<span style="color:var(--text-muted);">Uptime</span>
|
|
686
|
-
<code>${Math.floor(health.uptime || 0)} seconds</code>
|
|
687
|
-
</div>
|
|
688
|
-
<div style="display:flex; justify-content:space-between; border-bottom:1px solid var(--border-subtle); padding-bottom:0.5rem;">
|
|
689
|
-
<span style="color:var(--text-muted);">Node.js Runtime</span>
|
|
690
|
-
<code>${window.navigator.userAgent}</code>
|
|
691
|
-
</div>
|
|
692
|
-
</div>
|
|
693
|
-
</div>
|
|
694
|
-
|
|
695
|
-
<div style="background:var(--bg-card); border:1px solid var(--border-subtle); border-radius:8px; padding:1.5rem;">
|
|
696
|
-
<h3 style="font-size:16px; font-weight:700; margin-bottom:0.5rem;">TypeScript Server Hooks</h3>
|
|
697
|
-
<p style="color:var(--text-muted); font-size:13px; margin-bottom:1rem;">
|
|
698
|
-
Extend your backend using standard TypeScript with full access to npm:
|
|
699
|
-
</p>
|
|
700
|
-
<pre style="background:var(--bg-input); padding:1rem; border-radius:6px; font-family:var(--font-mono); font-size:12px; overflow-x:auto;">
|
|
701
|
-
import { NodeStack } from 'nodestack';
|
|
702
|
-
|
|
703
|
-
const app = new NodeStack();
|
|
704
|
-
|
|
705
|
-
app.onRecordBeforeCreate('posts', async (e) => {
|
|
706
|
-
// Validate, enrich data, or call any npm library
|
|
707
|
-
console.log('Creating post:', e.record.title);
|
|
708
|
-
});
|
|
709
|
-
|
|
710
|
-
await app.start(8090);</pre>
|
|
711
|
-
</div>
|
|
712
|
-
</div>
|
|
713
|
-
`;
|
|
714
|
-
}
|
|
1
|
+
// Overview & Logs Views
|
|
2
|
+
function renderHomeView() {
|
|
3
|
+
const main = document.getElementById('page-view-home') || document.getElementById('main-body');
|
|
4
|
+
const collections = state.collections || [];
|
|
5
|
+
const collectionsCount = collections.length;
|
|
6
|
+
|
|
7
|
+
// Webhooks initial count
|
|
8
|
+
const webhooksInitial = (typeof webhooksState !== 'undefined' && webhooksState.stats?.totalWebhooks !== undefined)
|
|
9
|
+
? webhooksState.stats.totalWebhooks
|
|
10
|
+
: (typeof webhooksState !== 'undefined' && Array.isArray(webhooksState.webhooks))
|
|
11
|
+
? webhooksState.webhooks.length
|
|
12
|
+
: '--';
|
|
13
|
+
|
|
14
|
+
// Plugins initial count
|
|
15
|
+
const pluginsInitial = (state.pluginNavItems && Array.isArray(state.pluginNavItems))
|
|
16
|
+
? state.pluginNavItems.length
|
|
17
|
+
: '--';
|
|
18
|
+
|
|
19
|
+
// Functions initial count
|
|
20
|
+
const functionsInitial = (typeof functionsState !== 'undefined' && functionsState.stats?.totalFunctions !== undefined)
|
|
21
|
+
? functionsState.stats.totalFunctions
|
|
22
|
+
: (typeof functionsState !== 'undefined' && Array.isArray(functionsState.functions))
|
|
23
|
+
? functionsState.functions.length
|
|
24
|
+
: '--';
|
|
25
|
+
|
|
26
|
+
main.innerHTML = `
|
|
27
|
+
<div style="width: 100%; display: flex; flex-direction: column; gap: 1.25rem;">
|
|
28
|
+
|
|
29
|
+
<!-- Consolidated Header & Presentation Status Bar -->
|
|
30
|
+
<div style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 0.85rem 1.25rem; display: flex; flex-direction: column; gap: 0.65rem;">
|
|
31
|
+
<!-- Core Header Status Line -->
|
|
32
|
+
<div style="display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem;">
|
|
33
|
+
<div style="display: flex; align-items: center; gap: 0.75rem;">
|
|
34
|
+
<div style="width: 34px; height: 34px; border-radius: 8px; background: var(--bg-main); border: 1px solid rgba(59, 130, 246, 0.4); display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
|
|
35
|
+
<img src="/_/icon.svg" width="22" height="22" alt="NodeStack" style="display: block;" />
|
|
36
|
+
</div>
|
|
37
|
+
<div>
|
|
38
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
39
|
+
<span style="font-weight: 800; font-size: 15px; color: var(--text-heading); letter-spacing: -0.02em;">NodeStack Core</span>
|
|
40
|
+
<span class="version-tag version-tag-accent">v2.0.0</span>
|
|
41
|
+
<span class="badge badge-get" style="font-size: 10.5px; display: inline-flex; align-items: center; gap: 5px;">
|
|
42
|
+
<span class="live-dot" style="width: 6px; height: 6px;"></span>
|
|
43
|
+
<span>Server Online</span>
|
|
44
|
+
</span>
|
|
45
|
+
</div>
|
|
46
|
+
<div style="font-size: 11.5px; color: var(--text-muted); margin-top: 1px;">
|
|
47
|
+
TypeScript-Native Backend • Multi-App Multi-Tenancy • Realtime SSE • Extensible Plugins
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<!-- Demo State Notification Bar (populated dynamically by demo.js) -->
|
|
54
|
+
<div id="demo-state-home-card" style="border-top: 1px solid var(--border-subtle); padding-top: 0.55rem;">
|
|
55
|
+
<!-- Populated dynamically by demo.js -->
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<!-- Zone 1 (Vitals Strip): High-Density 7-KPI Row + Integrated Telemetry Bar -->
|
|
60
|
+
<div style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 10px; overflow: hidden;">
|
|
61
|
+
<!-- Top: 7 Horizontal KPI Metrics (Responsive auto-fitting row) -->
|
|
62
|
+
<div class="home-kpi-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 0.75rem; padding: 0.85rem 1.15rem;">
|
|
63
|
+
<!-- KPI 1: Collections -->
|
|
64
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.75rem 1rem; cursor: pointer; transition: border-color 0.15s ease;" onclick="selectNav('collections')" title="Click to view all collections directory">
|
|
65
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem;">
|
|
66
|
+
<div style="display: flex; align-items: center; gap: 6px;">
|
|
67
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></svg>
|
|
68
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Collections</span>
|
|
69
|
+
</div>
|
|
70
|
+
<span style="font-size: 11px; color: var(--accent-primary); font-weight: 600;">View ➔</span>
|
|
71
|
+
</div>
|
|
72
|
+
<div style="font-size: 22px; font-weight: 800; color: var(--text-heading);" id="home-stat-collections">${collectionsCount}</div>
|
|
73
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 2px;">Registered tables</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<!-- KPI 2: Active Records -->
|
|
77
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.75rem 1rem;">
|
|
78
|
+
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 0.35rem;">
|
|
79
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path></svg>
|
|
80
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Total Records</span>
|
|
81
|
+
</div>
|
|
82
|
+
<div style="font-size: 22px; font-weight: 800; color: var(--text-heading);" id="home-stat-records">--</div>
|
|
83
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 2px;">Active database rows</div>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<!-- KPI 3: Storage Size -->
|
|
87
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.75rem 1rem;">
|
|
88
|
+
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 0.35rem;">
|
|
89
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><line x1="22" y1="12" x2="2" y2="12"></line><path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"></path><line x1="6" y1="16" x2="6.01" y2="16"></line><line x1="10" y1="16" x2="10.01" y2="16"></line></svg>
|
|
90
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Storage Size</span>
|
|
91
|
+
</div>
|
|
92
|
+
<div style="font-size: 22px; font-weight: 800; color: var(--text-heading);" id="home-stat-size">--</div>
|
|
93
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 2px;">data.db + WAL journal</div>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<!-- KPI 4: Realtime Streams -->
|
|
97
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.75rem 1rem;">
|
|
98
|
+
<div style="display: flex; align-items: center; gap: 6px; margin-bottom: 0.35rem;">
|
|
99
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><path d="M4.93 4.93a10 10 0 0 0 0 14.14M8.46 8.46a5 5 0 0 0 0 7.08M12 12h.01"/></svg>
|
|
100
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Realtime Streams</span>
|
|
101
|
+
</div>
|
|
102
|
+
<div style="font-size: 22px; font-weight: 800; color: var(--text-heading);" id="home-stat-realtime">--</div>
|
|
103
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 2px;">Connected SSE clients</div>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
<!-- KPI 5: Webhooks -->
|
|
107
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.75rem 1rem; cursor: pointer; transition: border-color 0.15s ease;" onclick="selectNav('webhooks')" title="Click to view webhooks and delivery logs">
|
|
108
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem;">
|
|
109
|
+
<div style="display: flex; align-items: center; gap: 6px;">
|
|
110
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><path d="M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c0-2.21 1.79-4 4-4h5.99c1.1 0 1.95-.94 2.48-1.9A4 4 0 0 1 22 13c0 2.21-1.79 4-4 4z"/><circle cx="6" cy="17" r="1"/><circle cx="18" cy="13" r="1"/></svg>
|
|
111
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Webhooks</span>
|
|
112
|
+
</div>
|
|
113
|
+
<span style="font-size: 11px; color: var(--accent-primary); font-weight: 600;">View ➔</span>
|
|
114
|
+
</div>
|
|
115
|
+
<div style="font-size: 22px; font-weight: 800; color: var(--text-heading);" id="home-stat-webhooks">${webhooksInitial}</div>
|
|
116
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 2px;" id="home-stat-webhooks-sub">Endpoints & deliveries</div>
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<!-- KPI 6: Plugins -->
|
|
120
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.75rem 1rem; cursor: pointer; transition: border-color 0.15s ease;" onclick="selectNav('plugins')" title="Click to browse plugins and extensions">
|
|
121
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem;">
|
|
122
|
+
<div style="display: flex; align-items: center; gap: 6px;">
|
|
123
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><rect x="3" y="3" width="7" height="7"></rect><rect x="14" y="3" width="7" height="7"></rect><rect x="14" y="14" width="7" height="7"></rect><rect x="3" y="14" width="7" height="7"></rect></svg>
|
|
124
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Plugins</span>
|
|
125
|
+
</div>
|
|
126
|
+
<span style="font-size: 11px; color: var(--accent-primary); font-weight: 600;">View ➔</span>
|
|
127
|
+
</div>
|
|
128
|
+
<div style="font-size: 22px; font-weight: 800; color: var(--text-heading);" id="home-stat-plugins">${pluginsInitial}</div>
|
|
129
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 2px;" id="home-stat-plugins-sub">Active extensions</div>
|
|
130
|
+
</div>
|
|
131
|
+
|
|
132
|
+
<!-- KPI 7: Functions -->
|
|
133
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 0.75rem 1rem; cursor: pointer; transition: border-color 0.15s ease;" onclick="selectNav('functions')" title="Click to view serverless functions and execution logs">
|
|
134
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem;">
|
|
135
|
+
<div style="display: flex; align-items: center; gap: 6px;">
|
|
136
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><polyline points="16 18 22 12 16 6"></polyline><polyline points="8 6 2 12 8 18"></polyline></svg>
|
|
137
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Functions</span>
|
|
138
|
+
</div>
|
|
139
|
+
<span style="font-size: 11px; color: var(--accent-primary); font-weight: 600;">View ➔</span>
|
|
140
|
+
</div>
|
|
141
|
+
<div style="font-size: 22px; font-weight: 800; color: var(--text-heading);" id="home-stat-functions">${functionsInitial}</div>
|
|
142
|
+
<div style="font-size: 11px; color: var(--text-muted); margin-top: 2px;" id="home-stat-functions-sub">Serverless lambda logic</div>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<!-- Bottom: Integrated 24h Telemetry Strip -->
|
|
147
|
+
<div style="background: var(--bg-hover-subtle); border-top: 1px solid var(--border-subtle); padding: 0.65rem 1.15rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem;">
|
|
148
|
+
<div style="display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;">
|
|
149
|
+
<div style="display: flex; align-items: center; gap: 6px;">
|
|
150
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><line x1="18" y1="20" x2="18" y2="10"></line><line x1="12" y1="20" x2="12" y2="4"></line><line x1="6" y1="20" x2="6" y2="14"></line></svg>
|
|
151
|
+
<span style="font-size: 11px; font-weight: 700; color: var(--text-heading); text-transform: uppercase; letter-spacing: 0.04em;">24h Telemetry</span>
|
|
152
|
+
<span class="badge badge-status-200" style="font-size: 9.5px; padding: 1px 5px;">Live</span>
|
|
153
|
+
</div>
|
|
154
|
+
<div style="display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; font-size: 12px; color: var(--text-muted);">
|
|
155
|
+
<span>Requests: <strong id="home-snap-requests" style="color: var(--text-heading); font-family: var(--font-mono); font-weight: 700;">--</strong></span>
|
|
156
|
+
<span>Latency: <strong id="home-snap-latency" style="color: var(--text-heading); font-family: var(--font-mono); font-weight: 700;">--</strong></span>
|
|
157
|
+
<span>Error Rate: <strong id="home-snap-errors" style="color: var(--text-heading); font-family: var(--font-mono); font-weight: 700;">--</strong></span>
|
|
158
|
+
<span>Peak: <strong id="home-snap-peak" style="color: var(--text-heading); font-family: var(--font-mono); font-weight: 700;">--</strong></span>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
<button class="btn btn-secondary btn-sm" onclick="selectNav('analytics')" style="padding: 2px 8px; font-size: 11px; display: inline-flex; align-items: center; gap: 4px;" title="Open in-depth analytics">
|
|
162
|
+
<span>Full Metrics</span><span>➔</span>
|
|
163
|
+
</button>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<!-- Zone 2 (Accelerators & Tools): Starter Templates & Developer Tools -->
|
|
168
|
+
<div class="home-tools-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 1rem;">
|
|
169
|
+
<!-- Left: Starter Accelerators & Schema Recipes -->
|
|
170
|
+
<div style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; justify-content: space-between; gap: 0.85rem;">
|
|
171
|
+
<div>
|
|
172
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem;">
|
|
173
|
+
<div style="display: flex; align-items: center; gap: 7px;">
|
|
174
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>
|
|
175
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Starter Accelerators</span>
|
|
176
|
+
</div>
|
|
177
|
+
<button class="btn btn-secondary btn-sm" onclick="openTemplatesModal()" style="font-size: 11px; padding: 2px 8px;" title="Browse all template recipes">
|
|
178
|
+
All Recipes ➔
|
|
179
|
+
</button>
|
|
180
|
+
</div>
|
|
181
|
+
<h4 style="font-size: 14px; font-weight: 700; color: var(--text-heading); margin: 0 0 0.2rem;">Schema Creation & Recipes</h4>
|
|
182
|
+
<p style="font-size: 12px; color: var(--text-muted); line-height: 1.4; margin: 0;">
|
|
183
|
+
Design a new table schema from scratch, launch pre-seeded templates, or auto-infer structures from JSON.
|
|
184
|
+
</p>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); gap: 0.6rem;">
|
|
188
|
+
<button class="btn btn-primary btn-sm" onclick="openNewCollectionModal()" style="font-size: 12px; padding: 7px 12px; display: flex; align-items: center; justify-content: center; gap: 6px;" title="Create new blank collection">
|
|
189
|
+
<span>+</span><span>New Collection</span>
|
|
190
|
+
</button>
|
|
191
|
+
<button class="btn btn-secondary btn-sm" onclick="openApplyTemplateConfirmModal('ecommerce')" style="font-size: 12px; padding: 7px 12px; display: flex; align-items: center; justify-content: center; gap: 6px;" title="Preview & install E-Commerce recipe">
|
|
192
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--text-muted);"><circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/></svg><span>E-Commerce</span>
|
|
193
|
+
</button>
|
|
194
|
+
<button class="btn btn-secondary btn-sm" onclick="openApplyTemplateConfirmModal('blog')" style="font-size: 12px; padding: 7px 12px; display: flex; align-items: center; justify-content: center; gap: 6px;" title="Preview & install Blog recipe">
|
|
195
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--text-muted);"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg><span>Blog / CMS</span>
|
|
196
|
+
</button>
|
|
197
|
+
<button class="btn btn-secondary btn-sm" onclick="openApplyTemplateConfirmModal('crm')" style="font-size: 12px; padding: 7px 12px; display: flex; align-items: center; justify-content: center; gap: 6px;" title="Preview & install CRM recipe">
|
|
198
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--text-muted);"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg><span>SaaS / CRM</span>
|
|
199
|
+
</button>
|
|
200
|
+
<button class="btn btn-secondary btn-sm" onclick="openImportJsonModal()" style="font-size: 12px; padding: 7px 12px; display: flex; align-items: center; justify-content: center; gap: 6px;" title="Paste JSON → Auto-infer schema">
|
|
201
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--text-muted);"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg><span>Import JSON</span>
|
|
202
|
+
</button>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<!-- Right: Developer Quick Tools (TypeGen & Base Endpoints) -->
|
|
207
|
+
<div style="background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; justify-content: space-between; gap: 0.85rem;">
|
|
208
|
+
<div>
|
|
209
|
+
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem;">
|
|
210
|
+
<div style="display: flex; align-items: center; gap: 7px;">
|
|
211
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: var(--accent-primary);"><path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/></svg>
|
|
212
|
+
<span style="font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.05em;">Developer Quick Tools</span>
|
|
213
|
+
</div>
|
|
214
|
+
<span class="badge badge-get" style="font-size: 10px;">SDK & API</span>
|
|
215
|
+
</div>
|
|
216
|
+
<h4 style="font-size: 14px; font-weight: 700; color: var(--text-heading); margin: 0 0 0.2rem;">TypeGen & API Endpoints</h4>
|
|
217
|
+
<p style="font-size: 12px; color: var(--text-muted); line-height: 1.4; margin: 0;">
|
|
218
|
+
End-to-end type generation and connection URLs for client applications.
|
|
219
|
+
</p>
|
|
220
|
+
</div>
|
|
221
|
+
|
|
222
|
+
<div style="display: flex; flex-direction: column; gap: 0.6rem;">
|
|
223
|
+
<!-- Tool Row 1: TypeGen -->
|
|
224
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 0.65rem 0.9rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;">
|
|
225
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
226
|
+
<span style="font-size: 12.5px; font-weight: 700; color: var(--text-heading);">TypeScript TypeGen</span>
|
|
227
|
+
<span class="badge badge-get" style="font-size: 10px; padding: 1px 6px;">types.d.ts</span>
|
|
228
|
+
</div>
|
|
229
|
+
<div style="display: flex; align-items: center; gap: 6px;">
|
|
230
|
+
<button class="btn btn-secondary btn-sm" style="padding: 3px 9px; font-size: 11.5px;" onclick="window.open('/_/types.d.ts', '_blank')" title="View types.d.ts">View types.d.ts</button>
|
|
231
|
+
<button class="btn btn-primary btn-sm" style="padding: 3px 9px; font-size: 11.5px;" onclick="copyToClipboard('npx nodestack typegen > nodestack-types.ts', this)" title="Copy CLI command">Copy CLI</button>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<!-- Tool Row 2: API Endpoints -->
|
|
236
|
+
<div style="background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 0.65rem 0.9rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;">
|
|
237
|
+
<div style="display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1;">
|
|
238
|
+
<span style="font-size: 12.5px; font-weight: 700; color: var(--text-heading); white-space: nowrap;">API Base</span>
|
|
239
|
+
<span class="badge badge-post" style="font-size: 10px; padding: 1px 6px; white-space: nowrap;">REST + SSE</span>
|
|
240
|
+
<code class="code-badge" title="${window.location.origin}/api">${window.location.origin}/api</code>
|
|
241
|
+
</div>
|
|
242
|
+
<div style="display: flex; align-items: center; gap: 6px; flex-shrink: 0;">
|
|
243
|
+
<button class="btn btn-secondary btn-sm" style="padding: 3px 9px; font-size: 11.5px;" onclick="copyToClipboard('${window.location.origin}/api', this)" title="Copy REST API URL">Copy API</button>
|
|
244
|
+
<button class="btn btn-secondary btn-sm" style="padding: 3px 9px; font-size: 11.5px;" onclick="copyToClipboard('${window.location.origin}/api/realtime', this)" title="Copy SSE Realtime URL">Copy SSE</button>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
</div>
|
|
252
|
+
`;
|
|
253
|
+
|
|
254
|
+
if (typeof fetchDemoStatus === 'function') {
|
|
255
|
+
fetchDemoStatus();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Asynchronously enrich dashboard overview with live metrics and counts
|
|
259
|
+
api('/api/metrics').then((metrics) => {
|
|
260
|
+
if (!metrics) return;
|
|
261
|
+
|
|
262
|
+
// Top KPI row
|
|
263
|
+
const recEl = document.getElementById('home-stat-records');
|
|
264
|
+
if (recEl && metrics.database?.totalRecords !== undefined) {
|
|
265
|
+
recEl.textContent = metrics.database.totalRecords.toLocaleString();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const sizeEl = document.getElementById('home-stat-size');
|
|
269
|
+
if (sizeEl && metrics.database?.sizeFormatted) {
|
|
270
|
+
sizeEl.textContent = metrics.database.sizeFormatted;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const rtEl = document.getElementById('home-stat-realtime');
|
|
274
|
+
if (rtEl && metrics.realtime?.connectedClients !== undefined) {
|
|
275
|
+
rtEl.textContent = metrics.realtime.connectedClients.toString();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// System & Traffic Snapshot
|
|
279
|
+
const reqEl = document.getElementById('home-snap-requests');
|
|
280
|
+
if (reqEl && metrics.traffic24h?.totalRequests !== undefined) {
|
|
281
|
+
reqEl.textContent = metrics.traffic24h.totalRequests.toLocaleString();
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const latEl = document.getElementById('home-snap-latency');
|
|
285
|
+
if (latEl && metrics.traffic24h?.avgDuration !== undefined) {
|
|
286
|
+
latEl.textContent = `${metrics.traffic24h.avgDuration.toFixed(1)} ms`;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const errEl = document.getElementById('home-snap-errors');
|
|
290
|
+
if (errEl && metrics.traffic24h?.overallErrorRate !== undefined) {
|
|
291
|
+
const errRate = metrics.traffic24h.overallErrorRate;
|
|
292
|
+
errEl.textContent = `${errRate.toFixed(1)} %`;
|
|
293
|
+
errEl.style.color = errRate > 5 ? '#f87171' : 'var(--text-heading)';
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const peakEl = document.getElementById('home-snap-peak');
|
|
297
|
+
if (peakEl && metrics.traffic24h?.peakHourRequests !== undefined) {
|
|
298
|
+
peakEl.textContent = `${metrics.traffic24h.peakHourRequests} req/h`;
|
|
299
|
+
}
|
|
300
|
+
}).catch(() => {});
|
|
301
|
+
|
|
302
|
+
// Asynchronously load webhook vitals
|
|
303
|
+
api('/api/webhooks/stats').then((stats) => {
|
|
304
|
+
if (!stats) return;
|
|
305
|
+
const whEl = document.getElementById('home-stat-webhooks');
|
|
306
|
+
const whSubEl = document.getElementById('home-stat-webhooks-sub');
|
|
307
|
+
if (whEl) {
|
|
308
|
+
whEl.textContent = (stats.totalWebhooks !== undefined ? stats.totalWebhooks : 0).toString();
|
|
309
|
+
}
|
|
310
|
+
if (whSubEl) {
|
|
311
|
+
const active = stats.activeWebhooks || 0;
|
|
312
|
+
const deliveries = stats.totalDeliveries || 0;
|
|
313
|
+
whSubEl.textContent = `${active} active${deliveries > 0 ? ` • ${deliveries} delivered` : ' • 0 delivered'}`;
|
|
314
|
+
}
|
|
315
|
+
}).catch(() => {});
|
|
316
|
+
|
|
317
|
+
// Asynchronously load plugin vitals
|
|
318
|
+
api('/api/plugins').then((pluginData) => {
|
|
319
|
+
if (!pluginData) return;
|
|
320
|
+
const plugEl = document.getElementById('home-stat-plugins');
|
|
321
|
+
const plugSubEl = document.getElementById('home-stat-plugins-sub');
|
|
322
|
+
const navItems = pluginData.navItems || [];
|
|
323
|
+
const catalog = pluginData.catalog || [];
|
|
324
|
+
if (plugEl) {
|
|
325
|
+
plugEl.textContent = (navItems.length || 0).toString();
|
|
326
|
+
}
|
|
327
|
+
if (plugSubEl) {
|
|
328
|
+
plugSubEl.textContent = `${navItems.length} active / ${catalog.length || 5} available`;
|
|
329
|
+
}
|
|
330
|
+
}).catch(() => {});
|
|
331
|
+
|
|
332
|
+
// Asynchronously load function vitals
|
|
333
|
+
const fnSlug = typeof getActiveAppSlug === 'function' ? getActiveAppSlug() : 'default';
|
|
334
|
+
const fnEndpoint = fnSlug && fnSlug !== 'default' ? `/api/apps/${fnSlug}/functions/stats` : '/api/functions/stats';
|
|
335
|
+
api(fnEndpoint).then((stats) => {
|
|
336
|
+
if (!stats) return;
|
|
337
|
+
if (typeof functionsState !== 'undefined') {
|
|
338
|
+
functionsState.stats = stats;
|
|
339
|
+
}
|
|
340
|
+
const fnEl = document.getElementById('home-stat-functions');
|
|
341
|
+
const fnSubEl = document.getElementById('home-stat-functions-sub');
|
|
342
|
+
if (fnEl) {
|
|
343
|
+
fnEl.textContent = (stats.totalFunctions !== undefined ? stats.totalFunctions : (stats.activeFunctions || 0)).toString();
|
|
344
|
+
}
|
|
345
|
+
if (fnSubEl) {
|
|
346
|
+
const active = stats.activeFunctions || 0;
|
|
347
|
+
const execs = stats.totalExecutions || 0;
|
|
348
|
+
fnSubEl.textContent = `${active} active${execs > 0 ? ` • ${execs} runs` : ' • 0 runs'}`;
|
|
349
|
+
}
|
|
350
|
+
}).catch(() => {});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
let auditState = {
|
|
354
|
+
subTab: 'traffic', // 'traffic' | 'audit'
|
|
355
|
+
collection: '',
|
|
356
|
+
action: 'all',
|
|
357
|
+
search: '',
|
|
358
|
+
page: 1,
|
|
359
|
+
perPage: 25,
|
|
360
|
+
totalItems: 0,
|
|
361
|
+
totalPages: 1,
|
|
362
|
+
};
|
|
363
|
+
if (typeof window !== 'undefined') {
|
|
364
|
+
window.auditState = auditState;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function loadLogsSubTab() {
|
|
368
|
+
if (typeof auditState !== 'undefined' && auditState.subTab === 'audit') {
|
|
369
|
+
if (typeof loadAuditLogs === 'function') loadAuditLogs();
|
|
370
|
+
} else {
|
|
371
|
+
if (typeof loadLogs === 'function') loadLogs();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (typeof window !== 'undefined') {
|
|
375
|
+
window.loadLogsSubTab = loadLogsSubTab;
|
|
376
|
+
window.switchLogsSubTab = switchLogsSubTab;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function switchLogsSubTab(subTab, pushState = true) {
|
|
380
|
+
auditState.subTab = subTab;
|
|
381
|
+
if (pushState && typeof updateUrl === 'function') {
|
|
382
|
+
const path = (subTab === 'audit') ? '/_/logs/audit' : '/_/logs';
|
|
383
|
+
updateUrl(path);
|
|
384
|
+
}
|
|
385
|
+
if (typeof updateBreadcrumbs === 'function') {
|
|
386
|
+
updateBreadcrumbs();
|
|
387
|
+
}
|
|
388
|
+
renderLogsView();
|
|
389
|
+
loadLogsSubTab();
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function renderLogsView() {
|
|
393
|
+
const main = document.getElementById('page-view-logs') || document.getElementById('main-body');
|
|
394
|
+
const isAudit = auditState.subTab === 'audit';
|
|
395
|
+
|
|
396
|
+
// Update top actions
|
|
397
|
+
const viewActions = document.getElementById('view-actions');
|
|
398
|
+
if (viewActions) {
|
|
399
|
+
if (isAudit) {
|
|
400
|
+
viewActions.innerHTML = `
|
|
401
|
+
<button class="btn btn-secondary btn-sm" onclick="loadAuditLogs()">Refresh Audit</button>
|
|
402
|
+
<button class="btn btn-danger btn-sm" onclick="handlePruneAuditLogs()">Prune > 90 Days</button>
|
|
403
|
+
`;
|
|
404
|
+
} else {
|
|
405
|
+
viewActions.innerHTML = `
|
|
406
|
+
<button class="btn btn-secondary btn-sm" onclick="loadLogs()">Refresh</button>
|
|
407
|
+
<button class="btn btn-danger btn-sm" onclick="clearLogs()">Clear Logs</button>
|
|
408
|
+
`;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
main.innerHTML = `
|
|
413
|
+
<div class="audit-subtabs-bar">
|
|
414
|
+
<button class="audit-subtab-btn ${!isAudit ? 'active' : ''}" onclick="switchLogsSubTab('traffic')">
|
|
415
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>
|
|
416
|
+
<span>HTTP Traffic Logs</span>
|
|
417
|
+
</button>
|
|
418
|
+
<button class="audit-subtab-btn ${isAudit ? 'active' : ''}" onclick="switchLogsSubTab('audit')">
|
|
419
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
|
|
420
|
+
<span>Data Audit Trail</span>
|
|
421
|
+
</button>
|
|
422
|
+
</div>
|
|
423
|
+
|
|
424
|
+
<div id="logs-content-area">
|
|
425
|
+
${isAudit ? renderAuditLogsContentShell() : renderTrafficLogsContentShell()}
|
|
426
|
+
</div>
|
|
427
|
+
`;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function renderTrafficLogsContentShell() {
|
|
431
|
+
return `
|
|
432
|
+
<div class="table-container">
|
|
433
|
+
<table>
|
|
434
|
+
<thead>
|
|
435
|
+
<tr>
|
|
436
|
+
<th>Status</th>
|
|
437
|
+
<th>Method</th>
|
|
438
|
+
<th>URL</th>
|
|
439
|
+
<th>Duration</th>
|
|
440
|
+
<th>Time</th>
|
|
441
|
+
<th>Client IP</th>
|
|
442
|
+
</tr>
|
|
443
|
+
</thead>
|
|
444
|
+
<tbody id="logs-body">
|
|
445
|
+
<tr><td colspan="6" style="text-align:center;padding:2rem;">Loading logs...</td></tr>
|
|
446
|
+
</tbody>
|
|
447
|
+
</table>
|
|
448
|
+
</div>
|
|
449
|
+
`;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function renderAuditLogsContentShell() {
|
|
453
|
+
const collections = state.collections || [];
|
|
454
|
+
|
|
455
|
+
return `
|
|
456
|
+
<div class="audit-filter-bar">
|
|
457
|
+
<div style="display:flex; align-items:center; gap:8px;">
|
|
458
|
+
<label style="font-size:12px; font-weight:600; color:var(--text-muted);">Collection:</label>
|
|
459
|
+
<select class="form-input" style="padding:4px 8px; font-size:12px; width:auto;" id="audit-filter-col" onchange="handleAuditFilterChange()">
|
|
460
|
+
<option value="" ${auditState.collection === '' ? 'selected' : ''}>All Collections</option>
|
|
461
|
+
${collections.map(c => `<option value="${escapeHtml(c.name)}" ${auditState.collection === c.name ? 'selected' : ''}>${escapeHtml(c.name)}</option>`).join('')}
|
|
462
|
+
</select>
|
|
463
|
+
</div>
|
|
464
|
+
|
|
465
|
+
<div style="display:flex; align-items:center; gap:8px;">
|
|
466
|
+
<label style="font-size:12px; font-weight:600; color:var(--text-muted);">Action:</label>
|
|
467
|
+
<select class="form-input" style="padding:4px 8px; font-size:12px; width:auto;" id="audit-filter-action" onchange="handleAuditFilterChange()">
|
|
468
|
+
<option value="all" ${auditState.action === 'all' ? 'selected' : ''}>All Actions</option>
|
|
469
|
+
<option value="create" ${auditState.action === 'create' ? 'selected' : ''}>CREATE</option>
|
|
470
|
+
<option value="update" ${auditState.action === 'update' ? 'selected' : ''}>UPDATE</option>
|
|
471
|
+
<option value="delete" ${auditState.action === 'delete' ? 'selected' : ''}>DELETE</option>
|
|
472
|
+
</select>
|
|
473
|
+
</div>
|
|
474
|
+
|
|
475
|
+
<div style="display:flex; align-items:center; gap:8px; margin-left:auto;">
|
|
476
|
+
<input type="text" class="form-input" id="audit-filter-search" style="padding:4px 10px; font-size:12px; min-width:220px;" placeholder="Search records, actors..." value="${escapeHtml(auditState.search)}" onkeydown="if(event.key==='Enter')handleAuditFilterChange()">
|
|
477
|
+
<button class="btn btn-secondary btn-sm" onclick="handleAuditFilterChange()">Filter</button>
|
|
478
|
+
</div>
|
|
479
|
+
</div>
|
|
480
|
+
|
|
481
|
+
<div class="table-container">
|
|
482
|
+
<table>
|
|
483
|
+
<thead>
|
|
484
|
+
<tr>
|
|
485
|
+
<th style="width:140px;">Time</th>
|
|
486
|
+
<th style="width:90px;">Action</th>
|
|
487
|
+
<th style="width:130px;">Collection</th>
|
|
488
|
+
<th style="width:140px;">Record ID</th>
|
|
489
|
+
<th style="width:180px;">Actor</th>
|
|
490
|
+
<th>Changes (Diff)</th>
|
|
491
|
+
</tr>
|
|
492
|
+
</thead>
|
|
493
|
+
<tbody id="audit-logs-body">
|
|
494
|
+
<tr><td colspan="6" style="text-align:center;padding:2rem;">Loading audit trail...</td></tr>
|
|
495
|
+
</tbody>
|
|
496
|
+
</table>
|
|
497
|
+
</div>
|
|
498
|
+
|
|
499
|
+
<div class="pagination-footer" id="audit-pagination-footer" style="display:none; margin-top:1rem; align-items:center; justify-content:space-between;">
|
|
500
|
+
<div style="font-size:12px; color:var(--text-muted);" id="audit-page-info"></div>
|
|
501
|
+
<div style="display:flex; align-items:center; gap:8px;">
|
|
502
|
+
<button class="btn btn-secondary btn-sm" id="btn-audit-prev" onclick="changeAuditPage(-1)">Previous</button>
|
|
503
|
+
<button class="btn btn-secondary btn-sm" id="btn-audit-next" onclick="changeAuditPage(1)">Next</button>
|
|
504
|
+
</div>
|
|
505
|
+
</div>
|
|
506
|
+
`;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function handleAuditFilterChange() {
|
|
510
|
+
const colEl = document.getElementById('audit-filter-col');
|
|
511
|
+
const actionEl = document.getElementById('audit-filter-action');
|
|
512
|
+
const searchEl = document.getElementById('audit-filter-search');
|
|
513
|
+
|
|
514
|
+
if (colEl) auditState.collection = colEl.value;
|
|
515
|
+
if (actionEl) auditState.action = actionEl.value;
|
|
516
|
+
if (searchEl) auditState.search = searchEl.value;
|
|
517
|
+
auditState.page = 1;
|
|
518
|
+
|
|
519
|
+
loadAuditLogs();
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function changeAuditPage(delta) {
|
|
523
|
+
const newPage = auditState.page + delta;
|
|
524
|
+
if (newPage >= 1 && newPage <= auditState.totalPages) {
|
|
525
|
+
auditState.page = newPage;
|
|
526
|
+
loadAuditLogs();
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
async function loadAuditLogs() {
|
|
531
|
+
const tb = document.getElementById('audit-logs-body');
|
|
532
|
+
if (!tb) return;
|
|
533
|
+
|
|
534
|
+
try {
|
|
535
|
+
const queryParams = new URLSearchParams();
|
|
536
|
+
queryParams.set('page', String(auditState.page));
|
|
537
|
+
queryParams.set('perPage', String(auditState.perPage));
|
|
538
|
+
if (auditState.collection) queryParams.set('collection', auditState.collection);
|
|
539
|
+
if (auditState.action && auditState.action !== 'all') queryParams.set('action', auditState.action);
|
|
540
|
+
if (auditState.search) queryParams.set('search', auditState.search);
|
|
541
|
+
|
|
542
|
+
const res = await api('/api/audit-logs?' + queryParams.toString());
|
|
543
|
+
auditState.totalItems = res.totalItems;
|
|
544
|
+
auditState.totalPages = Math.max(1, res.totalPages);
|
|
545
|
+
|
|
546
|
+
const paginationFooter = document.getElementById('audit-pagination-footer');
|
|
547
|
+
const pageInfo = document.getElementById('audit-page-info');
|
|
548
|
+
const btnPrev = document.getElementById('btn-audit-prev');
|
|
549
|
+
const btnNext = document.getElementById('btn-audit-next');
|
|
550
|
+
|
|
551
|
+
if (paginationFooter && pageInfo) {
|
|
552
|
+
paginationFooter.style.display = 'flex';
|
|
553
|
+
pageInfo.textContent = `Showing page ${res.page} of ${auditState.totalPages} (${res.totalItems} total change${res.totalItems === 1 ? '' : 's'})`;
|
|
554
|
+
if (btnPrev) btnPrev.disabled = res.page <= 1;
|
|
555
|
+
if (btnNext) btnNext.disabled = res.page >= auditState.totalPages;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (!res.items || res.items.length === 0) {
|
|
559
|
+
tb.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:2.5rem;color:var(--text-muted);">No audit logs found matching your filters.</td></tr>';
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
tb.innerHTML = res.items.map(log => {
|
|
564
|
+
const action = (log.action || '').toLowerCase();
|
|
565
|
+
const actionClass = action === 'create' ? 'badge-get' : action === 'delete' ? 'badge-delete' : 'badge-post';
|
|
566
|
+
const actorText = log.authEmail || (log.authId ? 'User: ' + log.authId : 'System / Public');
|
|
567
|
+
const safeRecId = escapeHtml(log.recordId);
|
|
568
|
+
const safeCol = escapeHtml(log.collection);
|
|
569
|
+
const changedKeys = log.changedFields || Object.keys(log.diff || {});
|
|
570
|
+
|
|
571
|
+
const diffSummary = changedKeys.length === 0
|
|
572
|
+
? '<span style="color:var(--text-muted); font-size:11px;">No field changes</span>'
|
|
573
|
+
: changedKeys.map(k => {
|
|
574
|
+
const fieldDiff = log.diff?.[k];
|
|
575
|
+
const oldVal = fieldDiff?.old;
|
|
576
|
+
const newVal = fieldDiff?.new;
|
|
577
|
+
return `
|
|
578
|
+
<span style="display:inline-flex; align-items:center; gap:4px; margin:2px 4px; font-size:11px; background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.06); padding:2px 6px; border-radius:4px;">
|
|
579
|
+
<strong style="color:var(--text-heading);">${escapeHtml(k)}:</strong>
|
|
580
|
+
<span class="audit-diff-val-old">${formatAuditValue(oldVal)}</span>
|
|
581
|
+
<span class="audit-diff-arrow">➔</span>
|
|
582
|
+
<span class="audit-diff-val-new">${formatAuditValue(newVal)}</span>
|
|
583
|
+
</span>
|
|
584
|
+
`;
|
|
585
|
+
}).join('');
|
|
586
|
+
|
|
587
|
+
return `
|
|
588
|
+
<tr>
|
|
589
|
+
<td style="color:var(--text-muted);font-size:12px;white-space:nowrap;" title="${escapeHtml(log.created)}">
|
|
590
|
+
${new Date(log.created).toLocaleString()}
|
|
591
|
+
</td>
|
|
592
|
+
<td><span class="badge ${actionClass}" style="text-transform:uppercase; font-size:10px;">${escapeHtml(log.action)}</span></td>
|
|
593
|
+
<td><span class="badge badge-post">${safeCol}</span></td>
|
|
594
|
+
<td><span class="id-pill" title="${safeRecId}">${safeRecId}</span></td>
|
|
595
|
+
<td>
|
|
596
|
+
<span style="color: var(--accent-primary); font-size:12px; font-weight:600;" title="${escapeHtml(log.authCollection || '')}">
|
|
597
|
+
${escapeHtml(actorText)}
|
|
598
|
+
</span>
|
|
599
|
+
</td>
|
|
600
|
+
<td style="font-size:12px;">
|
|
601
|
+
<div style="display:flex; flex-wrap:wrap; max-width:480px;">
|
|
602
|
+
${diffSummary}
|
|
603
|
+
</div>
|
|
604
|
+
</td>
|
|
605
|
+
</tr>
|
|
606
|
+
`;
|
|
607
|
+
}).join('');
|
|
608
|
+
} catch (err) {
|
|
609
|
+
tb.innerHTML = `<tr><td colspan="6" style="text-align:center;padding:2rem;color:var(--accent-danger);">Failed to load audit logs: ${escapeHtml(err.message)}</td></tr>`;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
async function handlePruneAuditLogs() {
|
|
614
|
+
if (!confirm('Prune audit logs older than 90 days? Historical records older than 90 days will be removed.')) return;
|
|
615
|
+
try {
|
|
616
|
+
const res = await api('/api/audit-logs/prune', {
|
|
617
|
+
method: 'POST',
|
|
618
|
+
body: JSON.stringify({ olderThanDays: 90 })
|
|
619
|
+
});
|
|
620
|
+
toast(`Pruned ${res.deletedCount || 0} old audit records`, 'success');
|
|
621
|
+
loadAuditLogs();
|
|
622
|
+
} catch (err) {
|
|
623
|
+
toast(err.message, 'error');
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
async function loadLogs() {
|
|
628
|
+
try {
|
|
629
|
+
const res = await api('/api/logs?perPage=100');
|
|
630
|
+
const tb = document.getElementById('logs-body');
|
|
631
|
+
if (!tb) return;
|
|
632
|
+
|
|
633
|
+
if (!res.items || res.items.length === 0) {
|
|
634
|
+
tb.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:2rem;color:var(--text-muted);">No requests logged yet.</td></tr>';
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
tb.innerHTML = res.items.map(log => {
|
|
639
|
+
let statusClass = 'badge-status-200';
|
|
640
|
+
if (log.status >= 500) statusClass = 'badge-status-500';
|
|
641
|
+
else if (log.status >= 400) statusClass = 'badge-status-400';
|
|
642
|
+
|
|
643
|
+
const methodClass = `badge-${log.method.toLowerCase()}`;
|
|
644
|
+
const safeUrl = escapeHtml(log.url);
|
|
645
|
+
|
|
646
|
+
return `
|
|
647
|
+
<tr>
|
|
648
|
+
<td><span class="badge ${statusClass}">${escapeHtml(log.status)}</span></td>
|
|
649
|
+
<td><span class="badge ${methodClass}">${escapeHtml(log.method)}</span></td>
|
|
650
|
+
<td>
|
|
651
|
+
<div style="display:flex; align-items:center; justify-content:space-between; gap:8px;">
|
|
652
|
+
<code style="overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:280px;" title="${safeUrl}">${safeUrl}</code>
|
|
653
|
+
<button class="btn btn-secondary btn-sm" style="padding:4px 6px; flex-shrink:0; display:inline-flex; align-items:center; justify-content:center; border-radius:5px;" data-url="${safeUrl}" onclick="copyToClipboard(this.getAttribute('data-url'), this)" title="Copy URL">
|
|
654
|
+
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
|
|
655
|
+
</button>
|
|
656
|
+
</div>
|
|
657
|
+
</td>
|
|
658
|
+
<td>${log.duration.toFixed(1)}ms</td>
|
|
659
|
+
<td style="color:var(--text-muted);font-size:12px;">${new Date(log.created).toLocaleTimeString()}</td>
|
|
660
|
+
<td>${escapeHtml(log.ip || '127.0.0.1')}</td>
|
|
661
|
+
</tr>
|
|
662
|
+
`;
|
|
663
|
+
}).join('');
|
|
664
|
+
} catch (e) {
|
|
665
|
+
toast(e.message, 'error');
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
async function clearLogs() {
|
|
670
|
+
if (!confirm('Clear all logs?')) return;
|
|
671
|
+
try {
|
|
672
|
+
await api('/api/logs', { method: 'DELETE' });
|
|
673
|
+
toast('Logs cleared', 'success');
|
|
674
|
+
loadLogs();
|
|
675
|
+
} catch (e) {
|
|
676
|
+
toast(e.message, 'error');
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
|