@nodestackapp/server 1.3.0 → 2.0.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.
Files changed (92) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +10 -10
  3. package/dist/NodeStack.d.ts +5 -0
  4. package/dist/NodeStack.d.ts.map +1 -1
  5. package/dist/NodeStack.js +19 -1
  6. package/dist/NodeStack.js.map +1 -1
  7. package/dist/admin/AdminUIBundler.d.ts.map +1 -1
  8. package/dist/admin/AdminUIBundler.js +1 -0
  9. package/dist/admin/AdminUIBundler.js.map +1 -1
  10. package/dist/admin/ui/css/analytics.css +68 -11
  11. package/dist/admin/ui/css/main.css +2189 -2015
  12. package/dist/admin/ui/css/rules.css +292 -264
  13. package/dist/admin/ui/css/webhooks.css +34 -10
  14. package/dist/admin/ui/index.html +10434 -9850
  15. package/dist/admin/ui/js/analytics.js +673 -624
  16. package/dist/admin/ui/js/api.js +16 -0
  17. package/dist/admin/ui/js/app.js +9 -18
  18. package/dist/admin/ui/js/apps.js +24 -6
  19. package/dist/admin/ui/js/collections.js +3 -4
  20. package/dist/admin/ui/js/command-palette.js +49 -18
  21. package/dist/admin/ui/js/demo.js +373 -271
  22. package/dist/admin/ui/js/modals.js +14 -14
  23. package/dist/admin/ui/js/plugin-tester.js +6 -6
  24. package/dist/admin/ui/js/plugins.js +31 -21
  25. package/dist/admin/ui/js/records.js +9 -9
  26. package/dist/admin/ui/js/rules.js +1 -1
  27. package/dist/admin/ui/js/theme.js +120 -0
  28. package/dist/admin/ui/js/views.js +632 -714
  29. package/dist/admin/ui/js/webhooks.js +27 -9
  30. package/dist/apps/AppScope.d.ts +2 -0
  31. package/dist/apps/AppScope.d.ts.map +1 -1
  32. package/dist/apps/AppScope.js +7 -3
  33. package/dist/apps/AppScope.js.map +1 -1
  34. package/dist/auth/AuthService.d.ts.map +1 -1
  35. package/dist/auth/AuthService.js +36 -9
  36. package/dist/auth/AuthService.js.map +1 -1
  37. package/dist/cli/cli.d.ts.map +1 -1
  38. package/dist/cli/cli.js +65 -1
  39. package/dist/cli/cli.js.map +1 -1
  40. package/dist/core/config/ConfigService.d.ts +1 -0
  41. package/dist/core/config/ConfigService.d.ts.map +1 -1
  42. package/dist/core/config/ConfigService.js +4 -1
  43. package/dist/core/config/ConfigService.js.map +1 -1
  44. package/dist/core/container/Tokens.d.ts +2 -0
  45. package/dist/core/container/Tokens.d.ts.map +1 -1
  46. package/dist/core/container/Tokens.js +2 -0
  47. package/dist/core/container/Tokens.js.map +1 -1
  48. package/dist/database/migrations/SystemMigrations.js +1 -1
  49. package/dist/database/migrations/SystemMigrations.js.map +1 -1
  50. package/dist/demo/DemoService.d.ts +15 -103
  51. package/dist/demo/DemoService.d.ts.map +1 -1
  52. package/dist/demo/DemoService.js +14 -419
  53. package/dist/demo/DemoService.js.map +1 -1
  54. package/dist/http/HttpServer.d.ts +3 -1
  55. package/dist/http/HttpServer.d.ts.map +1 -1
  56. package/dist/http/HttpServer.js +43 -8
  57. package/dist/http/HttpServer.js.map +1 -1
  58. package/dist/http/controllers/DemoController.d.ts.map +1 -1
  59. package/dist/http/controllers/DemoController.js +1 -0
  60. package/dist/http/controllers/DemoController.js.map +1 -1
  61. package/dist/http/controllers/HealthController.js +2 -2
  62. package/dist/http/controllers/SnapshotController.d.ts +58 -0
  63. package/dist/http/controllers/SnapshotController.d.ts.map +1 -0
  64. package/dist/http/controllers/SnapshotController.js +79 -0
  65. package/dist/http/controllers/SnapshotController.js.map +1 -0
  66. package/dist/index.d.ts +4 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.js +7 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/records/QueryFilterParser.d.ts.map +1 -1
  71. package/dist/records/QueryFilterParser.js +2 -1
  72. package/dist/records/QueryFilterParser.js.map +1 -1
  73. package/dist/records/RecordService.d.ts.map +1 -1
  74. package/dist/records/RecordService.js +32 -14
  75. package/dist/records/RecordService.js.map +1 -1
  76. package/dist/rules/RuleEngine.d.ts +14 -0
  77. package/dist/rules/RuleEngine.d.ts.map +1 -1
  78. package/dist/rules/RuleEngine.js +144 -1
  79. package/dist/rules/RuleEngine.js.map +1 -1
  80. package/dist/schema/OpenApiGenerator.js +3 -3
  81. package/dist/snapshots/SnapshotService.d.ts +75 -0
  82. package/dist/snapshots/SnapshotService.d.ts.map +1 -0
  83. package/dist/snapshots/SnapshotService.js +775 -0
  84. package/dist/snapshots/SnapshotService.js.map +1 -0
  85. package/dist/snapshots/types.d.ts +63 -0
  86. package/dist/snapshots/types.d.ts.map +1 -0
  87. package/dist/snapshots/types.js +5 -0
  88. package/dist/snapshots/types.js.map +1 -0
  89. package/dist/templates/definitions/ecommerce.js +13 -13
  90. package/dist/templates/definitions/ecommerce.js.map +1 -1
  91. package/dist/webhooks/WebhookService.js +1 -1
  92. package/package.json +88 -88
@@ -111,6 +111,16 @@
111
111
  es.addEventListener('NS_CONNECT', handleConnect);
112
112
  es.addEventListener('NB_CONNECT', handleConnect);
113
113
 
114
+ es.addEventListener('SNAPSHOT_RESTORE', () => {
115
+ if (typeof fetchDemoStatus === 'function') fetchDemoStatus();
116
+ });
117
+ es.addEventListener('SNAPSHOT_CREATE', () => {
118
+ if (typeof fetchDemoStatus === 'function') fetchDemoStatus();
119
+ });
120
+ es.addEventListener('SNAPSHOT_DELETE', () => {
121
+ if (typeof fetchDemoStatus === 'function') fetchDemoStatus();
122
+ });
123
+
114
124
  // Listen for system demo state reset
115
125
  es.addEventListener('DEMO_RESET', () => {
116
126
  toast('✨ Clean demo baseline restored!', 'success');
@@ -263,6 +273,9 @@
263
273
  }
264
274
 
265
275
  closeModal();
276
+ if (typeof fetchApps === 'function') {
277
+ await fetchApps();
278
+ }
266
279
  await loadCollections();
267
280
  if (typeof renderPluginNavItems === 'function') renderPluginNavItems();
268
281
  if (typeof loadWebhookStats === 'function') loadWebhookStats();
@@ -325,6 +338,9 @@
325
338
  localStorage.setItem('nodestack_admin', JSON.stringify(res.admin));
326
339
 
327
340
  closeModal();
341
+ if (typeof fetchApps === 'function') {
342
+ await fetchApps();
343
+ }
328
344
  await loadCollections();
329
345
  if (typeof renderPluginNavItems === 'function') renderPluginNavItems();
330
346
  if (typeof loadWebhookStats === 'function') loadWebhookStats();
@@ -1,7 +1,7 @@
1
1
  // Application Navigation & Lifecycle
2
2
 
3
3
  function showPageView(viewName) {
4
- const views = ['home', 'collections', 'plugins', 'webhooks', 'analytics', 'snapshots', 'logs', 'settings'];
4
+ const views = ['home', 'collections', 'plugins', 'webhooks', 'analytics', 'snapshots', 'logs'];
5
5
  for (const v of views) {
6
6
  const el = document.getElementById('page-view-' + v);
7
7
  if (el) {
@@ -15,7 +15,7 @@ function showPageView(viewName) {
15
15
  }
16
16
 
17
17
  function clearSidebarNavActive() {
18
- const navIds = ['nav-home', 'nav-collections', 'nav-plugins', 'nav-webhooks', 'nav-analytics', 'nav-snapshots', 'nav-logs', 'nav-settings'];
18
+ const navIds = ['nav-home', 'nav-collections', 'nav-plugins', 'nav-webhooks', 'nav-analytics', 'nav-snapshots', 'nav-logs'];
19
19
  for (const id of navIds) {
20
20
  document.getElementById(id)?.classList.remove('active');
21
21
  }
@@ -48,7 +48,7 @@ async function selectNav(nav) {
48
48
  document.getElementById('collection-tabs').style.display = 'none';
49
49
  document.getElementById('view-badge').style.display = 'none';
50
50
  document.getElementById('nav-home')?.classList.add('active');
51
- document.getElementById('view-title').textContent = 'Dashboard Overview';
51
+ document.getElementById('view-title').textContent = 'Overview';
52
52
  document.getElementById('view-actions').innerHTML = '';
53
53
  if (typeof renderHomeView === 'function') renderHomeView();
54
54
  } else if (nav === 'collections') {
@@ -102,7 +102,7 @@ async function selectNav(nav) {
102
102
  document.getElementById('collection-tabs').style.display = 'none';
103
103
  document.getElementById('view-badge').style.display = 'none';
104
104
  document.getElementById('nav-analytics')?.classList.add('active');
105
- document.getElementById('view-title').textContent = 'Analytics & Metrics';
105
+ document.getElementById('view-title').textContent = 'Analytics';
106
106
  document.getElementById('view-actions').innerHTML = '';
107
107
  if (typeof renderAnalyticsView === 'function') renderAnalyticsView();
108
108
  if (typeof loadAnalytics === 'function') loadAnalytics();
@@ -116,10 +116,10 @@ async function selectNav(nav) {
116
116
  document.getElementById('collection-tabs').style.display = 'none';
117
117
  document.getElementById('view-badge').style.display = 'none';
118
118
  document.getElementById('nav-snapshots')?.classList.add('active');
119
- document.getElementById('view-title').textContent = 'Demo Snapshots';
119
+ document.getElementById('view-title').textContent = 'Snapshots';
120
120
  document.getElementById('view-actions').innerHTML = `
121
- <button class="btn btn-warning btn-sm" onclick="openResetDemoModal()" style="font-weight:700;">
122
- ↺ Reset Demo Data
121
+ <button class="btn btn-primary btn-sm" onclick="openCreateSnapshotModal()" style="font-weight:600;">
122
+ + Create Snapshot
123
123
  </button>
124
124
  `;
125
125
  if (typeof renderSnapshotsView === 'function') renderSnapshotsView();
@@ -130,23 +130,14 @@ async function selectNav(nav) {
130
130
  document.getElementById('collection-tabs').style.display = 'none';
131
131
  document.getElementById('view-badge').style.display = 'none';
132
132
  document.getElementById('nav-logs')?.classList.add('active');
133
- document.getElementById('view-title').textContent = 'Traffic & Logs';
133
+ document.getElementById('view-title').textContent = 'Audit Logs';
134
134
  if (typeof renderLogsView === 'function') renderLogsView();
135
135
  if (typeof loadLogsSubTab === 'function') {
136
136
  loadLogsSubTab();
137
137
  } else if (typeof loadLogs === 'function') {
138
138
  loadLogs();
139
139
  }
140
- } else if (nav === 'settings') {
141
- state.activeCollection = null;
142
- if (typeof renderCollectionsList === 'function') renderCollectionsList();
143
- showPageView('settings');
144
- document.getElementById('collection-tabs').style.display = 'none';
145
- document.getElementById('view-badge').style.display = 'none';
146
- document.getElementById('nav-settings')?.classList.add('active');
147
- document.getElementById('view-title').textContent = 'System Info';
148
- document.getElementById('view-actions').innerHTML = '';
149
- if (typeof renderSettingsView === 'function') renderSettingsView();
140
+
150
141
  } else if (state.pluginNavItems && state.pluginNavItems.some(p => p.id === nav || (nav === 'resend' && p.id === 'resend-email'))) {
151
142
  state.activeCollection = null;
152
143
  if (typeof renderCollectionsList === 'function') renderCollectionsList();
@@ -1,7 +1,10 @@
1
1
  // Multi-Application / MVP Management & App Switcher
2
2
 
3
3
  async function fetchApps() {
4
- if (!state.token) return;
4
+ if (!state.token) {
5
+ updateAppSwitcherUI();
6
+ return;
7
+ }
5
8
  try {
6
9
  const res = await api('/api/apps');
7
10
  state.apps = (res && res.items) ? res.items : [];
@@ -23,14 +26,15 @@ async function fetchApps() {
23
26
 
24
27
  updateAppSwitcherUI();
25
28
  } catch (err) {
29
+ console.warn('[NodeStack] fetchApps error:', err);
26
30
  // If apps endpoint fails or active app was not found, fallback to default
27
31
  if (!state.activeApp || (err && (err.status === 404 || err.message?.includes('Application ')))) {
28
32
  state.activeApp = { id: 'app_default', slug: 'default', name: 'Default App', isDefault: true };
29
33
  try {
30
34
  localStorage.setItem('nodestack_active_app', JSON.stringify(state.activeApp));
31
35
  } catch {}
32
- updateAppSwitcherUI();
33
36
  }
37
+ updateAppSwitcherUI();
34
38
  }
35
39
  }
36
40
 
@@ -63,14 +67,14 @@ function updateAppSwitcherUI() {
63
67
  <div
64
68
  class="app-switcher-item ${isActive ? 'active' : ''}"
65
69
  onclick="selectApp('${escapeHtml(app.slug)}')"
66
- style="display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: background 0.15s ease; ${isActive ? 'background: rgba(99, 102, 241, 0.15); font-weight: 600;' : ''}"
70
+ style="display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: background 0.15s ease; ${isActive ? 'background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 600;' : ''}"
67
71
  onmouseover="this.style.background='var(--bg-surface-elevated, #242933)'"
68
- onmouseout="this.style.background='${isActive ? 'rgba(99, 102, 241, 0.15)' : 'transparent'}'"
72
+ onmouseout="this.style.background='${isActive ? 'var(--nav-active-bg)' : 'transparent'}'"
69
73
  >
70
74
  <div style="display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
71
75
  <span>${isDefault ? '⚡' : '🚀'}</span>
72
76
  <span style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${escapeHtml(app.name)}</span>
73
- ${isDefault ? '<span style="font-size: 10px; opacity: 0.6; padding: 1px 4px; border-radius: 4px; background: rgba(255,255,255,0.08);">default</span>' : ''}
77
+ ${isDefault ? '<span class="badge" style="font-size: 10px; padding: 1px 4px; background: var(--bg-hover-subtle); color: var(--text-muted); border: 1px solid var(--border-subtle);">default</span>' : ''}
74
78
  </div>
75
79
  <div style="display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted, #94a3b8); flex-shrink: 0;">
76
80
  ${countInfo ? `<span>${countInfo}</span>` : ''}
@@ -106,6 +110,12 @@ function toggleAppSwitcher(e) {
106
110
  menu.style.display = isVisible ? 'none' : 'block';
107
111
 
108
112
  if (!isVisible) {
113
+ if (typeof updateAppSwitcherUI === 'function') {
114
+ updateAppSwitcherUI();
115
+ }
116
+ if (typeof fetchApps === 'function') {
117
+ fetchApps().catch(() => {});
118
+ }
109
119
  const closeListener = (evt) => {
110
120
  if (!menu.contains(evt.target)) {
111
121
  menu.style.display = 'none';
@@ -137,6 +147,10 @@ async function selectApp(slugOrId) {
137
147
  // Refresh active context
138
148
  state.collections = [];
139
149
  state.activeCollection = null;
150
+ if (typeof webhooksState !== 'undefined') {
151
+ webhooksState.webhooks = [];
152
+ webhooksState.deliveries = [];
153
+ }
140
154
 
141
155
  try {
142
156
  if (typeof loadCollections === 'function') {
@@ -145,6 +159,9 @@ async function selectApp(slugOrId) {
145
159
  if (typeof fetchDemoStatus === 'function') {
146
160
  await fetchDemoStatus();
147
161
  }
162
+ if (typeof loadWebhookStats === 'function') {
163
+ await loadWebhookStats();
164
+ }
148
165
  if (typeof loadWebhooksList === 'function' && state.activeNav === 'webhooks') {
149
166
  await loadWebhooksList();
150
167
  }
@@ -362,7 +379,7 @@ function promptDeleteApp(slug, name) {
362
379
  </div>
363
380
  <div class="modal-body" style="padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem;">
364
381
  <p style="font-size: 13px; color: #cbd5e1; line-height: 1.5; margin: 0;">
365
- Are you sure you want to permanently delete application <strong style="color: #fff; font-family: var(--font-mono);">${escapeHtml(name)}</strong> (<code style="font-size: 12px; color: var(--accent-primary, #6366f1);">${escapeHtml(slug)}</code>)?
382
+ Are you sure you want to permanently delete application <strong style="color: var(--text-heading); font-family: var(--font-mono);">${escapeHtml(name)}</strong> (<code style="font-size: 12px; color: var(--accent-primary, #6366f1);">${escapeHtml(slug)}</code>)?
366
383
  </p>
367
384
  <div style="background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.25); border-radius: 6px; padding: 0.75rem; font-size: 12px; color: #fca5a5; line-height: 1.4;">
368
385
  This will permanently delete its SQLite database, files in storage, and schema collections. This action cannot be undone.
@@ -434,3 +451,4 @@ async function submitDeleteApp(slug, name) {
434
451
  window.promptDeleteApp = promptDeleteApp;
435
452
  window.closeDeleteAppModal = closeDeleteAppModal;
436
453
  window.submitDeleteApp = submitDeleteApp;
454
+
@@ -346,13 +346,12 @@ function updateBreadcrumbs() {
346
346
  } else if (state.activeNav === 'home') {
347
347
  crumbs.push({ label: 'Overview', active: true });
348
348
  } else if (state.activeNav === 'analytics') {
349
- crumbs.push({ label: 'Analytics & Metrics', active: true });
349
+ crumbs.push({ label: 'Analytics', active: true });
350
350
  } else if (state.activeNav === 'snapshots') {
351
351
  crumbs.push({ label: 'Snapshots', active: true });
352
352
  } else if (state.activeNav === 'logs') {
353
- crumbs.push({ label: 'Traffic & Logs', active: true });
354
- } else if (state.activeNav === 'settings') {
355
- crumbs.push({ label: 'System Info', active: true });
353
+ crumbs.push({ label: 'Audit Logs', active: true });
354
+
356
355
  } else if (state.pluginNavItems && state.pluginNavItems.some(p => p.id === state.activeNav)) {
357
356
  const item = state.pluginNavItems.find(p => p.id === state.activeNav);
358
357
  crumbs.push({ label: 'Plugins', clickable: true, action: () => selectNav('plugins') });
@@ -30,7 +30,7 @@ function getAllCommandPaletteItems() {
30
30
  // 2. Navigation items
31
31
  items.push({
32
32
  id: 'nav-home',
33
- title: 'Dashboard Overview',
33
+ title: 'Overview',
34
34
  description: 'Server status, collections list, quick stats',
35
35
  category: 'Navigation',
36
36
  badge: 'PAGE',
@@ -74,19 +74,20 @@ function getAllCommandPaletteItems() {
74
74
 
75
75
  items.push({
76
76
  id: 'nav-analytics',
77
- title: 'Analytics & Metrics',
77
+ title: 'Analytics',
78
78
  description: 'Realtime telemetry, latency and request throughput',
79
79
  category: 'Navigation',
80
80
  badge: 'PAGE',
81
81
  icon: '📊',
82
- keywords: ['metrics', 'analytics', 'telemetry', 'stats', 'traffic', 'latency'],
82
+ keywords: ['metrics', 'analytics', 'telemetry', 'stats', 'traffic', 'latency', 'uptime', 'system'],
83
83
  action: () => selectNav('analytics')
84
84
  });
85
85
 
86
86
  items.push({
87
87
  id: 'nav-snapshots',
88
- title: 'Demo Snapshots',
89
- description: 'Capture or restore database demo state snapshots',
88
+ title: 'Snapshots',
89
+ description: 'Capture or restore application state snapshots',
90
+
90
91
  category: 'Navigation',
91
92
  badge: 'PAGE',
92
93
  icon: '📸',
@@ -96,26 +97,15 @@ function getAllCommandPaletteItems() {
96
97
 
97
98
  items.push({
98
99
  id: 'nav-logs',
99
- title: 'Traffic & Logs',
100
+ title: 'Audit Logs',
100
101
  description: 'Live HTTP request activity, errors and slow queries',
101
102
  category: 'Navigation',
102
103
  badge: 'PAGE',
103
104
  icon: '📝',
104
- keywords: ['logs', 'traffic', 'requests', 'errors', 'debug'],
105
+ keywords: ['audit', 'logs', 'traffic', 'requests', 'errors', 'debug'],
105
106
  action: () => selectNav('logs')
106
107
  });
107
108
 
108
- items.push({
109
- id: 'nav-settings',
110
- title: 'System Info',
111
- description: 'System specifications, runtime version, and server hooks',
112
- category: 'Navigation',
113
- badge: 'PAGE',
114
- icon: '⚙️',
115
- keywords: ['settings', 'system', 'system info', 'info', 'runtime', 'uptime', 'version', 'hooks'],
116
- action: () => selectNav('settings')
117
- });
118
-
119
109
  // 2.5 Plugin navigation items
120
110
  if (state.pluginNavItems && state.pluginNavItems.length > 0) {
121
111
  for (const p of state.pluginNavItems) {
@@ -332,6 +322,47 @@ function getAllCommandPaletteItems() {
332
322
  }
333
323
  });
334
324
 
325
+
326
+ // 9. Appearance & Theme
327
+ items.push({
328
+ id: 'theme-system',
329
+ title: 'Theme: System (Auto)',
330
+ description: 'Sync admin appearance with your operating system preference',
331
+ category: 'Appearance',
332
+ badge: 'THEME',
333
+ icon: '💻',
334
+ keywords: ['theme', 'appearance', 'system', 'auto', 'mode', 'color'],
335
+ action: () => {
336
+ if (typeof setTheme === 'function') setTheme('system');
337
+ }
338
+ });
339
+
340
+ items.push({
341
+ id: 'theme-light',
342
+ title: 'Theme: Light Mode',
343
+ description: 'Switch admin portal to clean light appearance',
344
+ category: 'Appearance',
345
+ badge: 'THEME',
346
+ icon: '☀️',
347
+ keywords: ['theme', 'appearance', 'light', 'white', 'day', 'mode', 'color'],
348
+ action: () => {
349
+ if (typeof setTheme === 'function') setTheme('light');
350
+ }
351
+ });
352
+
353
+ items.push({
354
+ id: 'theme-dark',
355
+ title: 'Theme: Dark Mode',
356
+ description: 'Switch admin portal to dark night appearance',
357
+ category: 'Appearance',
358
+ badge: 'THEME',
359
+ icon: '🌙',
360
+ keywords: ['theme', 'appearance', 'dark', 'black', 'night', 'mode', 'color'],
361
+ action: () => {
362
+ if (typeof setTheme === 'function') setTheme('dark');
363
+ }
364
+ });
365
+
335
366
  return items;
336
367
  }
337
368