signalk-alert-center 0.7.0 → 0.9.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 (70) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/DEVELOPERS.md +8 -4
  3. package/README.md +123 -24
  4. package/dist/alerts/policy.d.ts +3 -1
  5. package/dist/alerts/policy.js +21 -1
  6. package/dist/alerts/policy.js.map +1 -1
  7. package/dist/alerts/types.d.ts +10 -2
  8. package/dist/alerts/types.js.map +1 -1
  9. package/dist/api/openapi.d.ts +396 -0
  10. package/dist/api/openapi.js +241 -9
  11. package/dist/api/openapi.js.map +1 -1
  12. package/dist/api/routes.d.ts +15 -4
  13. package/dist/api/routes.js +56 -4
  14. package/dist/api/routes.js.map +1 -1
  15. package/dist/config-schema.d.ts +5 -5
  16. package/dist/config-schema.js +1 -1
  17. package/dist/config-schema.js.map +1 -1
  18. package/dist/delivery/scheduler.js +15 -6
  19. package/dist/delivery/scheduler.js.map +1 -1
  20. package/dist/runtime.d.ts +25 -0
  21. package/dist/runtime.js +215 -29
  22. package/dist/runtime.js.map +1 -1
  23. package/dist/signalk/alert-rules.d.ts +14 -0
  24. package/dist/signalk/alert-rules.js +52 -0
  25. package/dist/signalk/alert-rules.js.map +1 -0
  26. package/dist/signalk/core-alerts.d.ts +52 -0
  27. package/dist/signalk/core-alerts.js +119 -0
  28. package/dist/signalk/core-alerts.js.map +1 -0
  29. package/dist/signalk/ignored-paths.js +5 -1
  30. package/dist/signalk/ignored-paths.js.map +1 -1
  31. package/dist/signalk/ingestion-queue.js +5 -1
  32. package/dist/signalk/ingestion-queue.js.map +1 -1
  33. package/dist/signalk/message-sample.js +9 -1
  34. package/dist/signalk/message-sample.js.map +1 -1
  35. package/dist/signalk/notifications.d.ts +3 -0
  36. package/dist/signalk/notifications.js +9 -0
  37. package/dist/signalk/notifications.js.map +1 -1
  38. package/dist/storage/db.d.ts +16 -4
  39. package/dist/storage/db.js +381 -70
  40. package/dist/storage/db.js.map +1 -1
  41. package/dist/storage/migrations.d.ts +6 -0
  42. package/dist/storage/migrations.js +29 -1
  43. package/dist/storage/migrations.js.map +1 -1
  44. package/dist/storage/schema.d.ts +3 -1
  45. package/dist/storage/schema.js +5 -2
  46. package/dist/storage/schema.js.map +1 -1
  47. package/dist/transports/transport.js +9 -1
  48. package/dist/transports/transport.js.map +1 -1
  49. package/dist/transports/wyoming.js +9 -1
  50. package/dist/transports/wyoming.js.map +1 -1
  51. package/docs/core-alerts-migration.md +248 -0
  52. package/docs/screenshots/alert-center-dark.png +0 -0
  53. package/docs/screenshots/alert-center-overview.png +0 -0
  54. package/docs/screenshots/alert-center-tablet.png +0 -0
  55. package/docs/screenshots/alert-details.png +0 -0
  56. package/docs/screenshots/alert-history.png +0 -0
  57. package/docs/screenshots/alert-settings.png +0 -0
  58. package/docs/screenshots/delivery-history.png +0 -0
  59. package/docs/screenshots/global-snooze.jpg +0 -0
  60. package/package.json +5 -3
  61. package/public/alert-rules.js +117 -0
  62. package/public/app.js +380 -178
  63. package/public/config-4ce35b2ec71bd98f002c.js +2 -0
  64. package/public/index.html +129 -118
  65. package/public/live-values.js +7 -2
  66. package/public/remoteEntry.js +1 -1
  67. package/public/styles.css +207 -79
  68. package/public/theme.js +81 -0
  69. package/public/config-794111361b7b1730b81b.js +0 -2
  70. /package/public/{config-794111361b7b1730b81b.js.LICENSE.txt → config-4ce35b2ec71bd98f002c.js.LICENSE.txt} +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,107 @@ Versioning while it remains pre-1.0.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.9.0] - 2026-11-19
9
+
10
+ ### Features
11
+
12
+ - Support Signal K core alerts alongside legacy notifications, with durable
13
+ per-service delivery, grouped momentary alerts, and separate condition,
14
+ acknowledgement, silence, and source status. Acknowledge and silence through
15
+ the core API; Wyoming follows core silence and attention state.
16
+ - List Alert Rules definitions before they fire, including disabled and invalid
17
+ rules. Configure delivery once per rule; wildcard instances share those
18
+ settings while retaining separate history. Settings survive restart and work
19
+ with the dashboard closed. Alert Rules remains responsible for conditions and
20
+ thresholds and is recommended as an optional companion plugin.
21
+ - Use one search and filter toolbar across Alerts, Alert history, and Deliveries.
22
+ Search text, severity, and date bounds carry between tabs; each tab keeps its
23
+ relevant status or update filters. Search includes names, messages, paths, and
24
+ sources, plus service names and errors in Deliveries. Matching retained records
25
+ are found before pagination, and delivery results retain pending-work priority.
26
+ History severity filters match the displayed event severity; delivery filters
27
+ use recorded message and severity snapshots.
28
+
29
+ ### Fixes
30
+
31
+ - Load rule catalogs and delivery defaults without blocking the alert list.
32
+ History and delivery links within the open dashboard select and load their tab.
33
+ - Respect Signal K's disabled notification management when discovering metadata
34
+ zones. Hide stored zones without retained occurrences while preserving their
35
+ settings. Actual legacy alerts, history, queued deliveries, and the Alert Rules
36
+ catalog remain available.
37
+ - Use core terminal removal reasons to confirm recovery for completed conditions
38
+ and acknowledgements. Displaced alerts retain history and queued initial
39
+ deliveries without claiming recovery; superseded acknowledgement/recovery
40
+ work and repeats are suppressed. Missing or unknown reasons remain unclassified
41
+ unless recovery was independently confirmed.
42
+ - Preserve Alert Rules' formatted messages and units in the dashboard and all
43
+ delivery services, including speech. Legacy notification unit conversion remains
44
+ available.
45
+ - Ignore routine waypoint arrival-circle and perpendicular-passed notifications
46
+ by default, alongside per-target collision alarms. Existing explicit
47
+ `ignoredPaths` lists remain unchanged. Remove either exact course path from
48
+ the list to track and deliver it; other course notifications remain tracked.
49
+ - Refresh the README to describe the implemented core-alert support, rule
50
+ settings, manual installation, and upgrade requirements.
51
+
52
+ ### Compatibility, upgrade, and rollback
53
+
54
+ - Core support activates when the server exposes the compatible core alerts API.
55
+ Legacy notification support remains available on Signal K Server 2.31.1.
56
+ See [compatibility notes](docs/core-alerts-migration.md) for the tested core
57
+ server and Alert Rules revisions. Compatibility with other core API revisions
58
+ has not been verified.
59
+ - Stop Signal K and back up the Alert Center SQLite database before upgrading.
60
+ Schema 3 and 4 databases migrate transactionally to schema 5, preserving history,
61
+ policies, attempts, pending deliveries, and the delivery-history index.
62
+ Interrupted migrations roll back and retry on startup; no reset is required.
63
+ - Version 0.8.0 and older cannot open schema 5. Rollback requires both the older
64
+ package and the pre-upgrade database backup. Restoring that backup discards
65
+ history and delivery progress recorded after it was taken.
66
+ - Core `alerts.*` paths use separate delivery policies and permissions from legacy
67
+ `notifications.*` paths. ACL installations must grant `put` on allowed core
68
+ paths separately. Restricted admins are checked too; settings, rule-editor
69
+ links, maintenance, and dashboard snooze controls remain admin-only.
70
+ - Legacy policies are not transferred automatically. Core history is not replayed
71
+ for alerts that began and ended while Alert Center was stopped; missing active
72
+ alerts do not prove recovery. Alert Rules messages use the producer's units for
73
+ all recipients, without per-recipient conversion.
74
+
75
+ ## [0.8.0] - 2026-11-12
76
+
77
+ ### Features
78
+
79
+ - Add a sun/moon appearance menu to Alert Center. Auto (the default) follows
80
+ Signal K's day/night mode, falling back to the device's appearance when
81
+ unavailable. Light and Dark overrides are saved per browser and server,
82
+ without changing the shared mode. Dark styling covers alerts, history,
83
+ delivery details, settings, and status banners.
84
+
85
+ ### Fixes
86
+
87
+ - Keep automatic appearance in sync when Signal K's day/night mode changes
88
+ rapidly, including falling back to the device after an invalid or cleared mode.
89
+ - Show the alert list as soon as its alert data arrives, without waiting for
90
+ units metadata, login status, or diagnostics. Load units in the background
91
+ and fetch history and deliveries only when their tab is selected. The delivery
92
+ badge now counts undelivered items (including failures), while the tab retains
93
+ the full delivery history. Detailed diagnostics load only when expanded.
94
+ - Use indexed pending counts and delivery-history pagination. The dashboard skips
95
+ lifetime totals; API clients still receive them unless they set
96
+ `includeTotal=false`. A lightweight `/summary` endpoint avoids historical and
97
+ service aggregates during page loading.
98
+ - Automatically upgrade storage to schema version 4 with a delivery-history index.
99
+ The first startup may take longer while the index builds. History, settings, and
100
+ pending work are preserved; no reset or configuration change is needed.
101
+
102
+ ### Upgrade and rollback
103
+
104
+ - Stop Signal K and back up the Alert Center SQLite database before upgrading.
105
+ Version 0.7.0 rejects the upgraded schema; rolling back requires both the older
106
+ package and the pre-upgrade database backup. Restoring that backup also discards
107
+ history and delivery progress recorded after it was taken.
108
+
8
109
  ## [0.7.0] - 2026-11-11
9
110
 
10
111
  ### Features
package/DEVELOPERS.md CHANGED
@@ -122,9 +122,13 @@ authorization support denies actions; disabled security is represented by the
122
122
  server's dummy strategy. Admin routes use Signal K's default plugin-router
123
123
  protection, without `router.access()`. No custom ACL matcher is used.
124
124
 
125
- The pending core-alert migration must preserve these guards and explicitly
126
- validate the `alerts.*` permission namespace before merging. The released
127
- implementation authorizes legacy notification paths.
125
+ Core actions use the same guard on their stored `alerts.<path>` in `vessels.self`.
126
+ The pinned server mirrors core alerts in that namespace; its in-process plugin
127
+ API receives no HTTP request, so it cannot enforce the caller's permissions.
128
+ `npm run test:core` runs both security-disabled lifecycle acceptance and a fresh
129
+ security-enabled server with scoped core/legacy grants, restricted admins,
130
+ denied-write state checks, and readwrite access with no configured ACLs.
131
+ See [core migration notes](docs/core-alerts-migration.md) for the pinned sources.
128
132
 
129
133
  Never point automated tests at real notification services or vessel hardware.
130
134
 
@@ -176,7 +180,7 @@ Regenerate the images after a material UI change.
176
180
 
177
181
  ## Schema changes
178
182
 
179
- The current schema remains version one. A change that would otherwise require a
183
+ The current schema is version 5. A change that would otherwise require a
180
184
  database reset must include a focused, transactional, restart-safe migration for
181
185
  the immediately preceding supported schema. Tests must create the old shape on
182
186
  disk, reopen it through `AlertDatabase`, verify preserved records, and verify that
package/README.md CHANGED
@@ -68,26 +68,67 @@ Open **Webapps → Signal K Alert Center** after enabling the plugin.
68
68
 
69
69
  The main table combines all known alert definitions:
70
70
 
71
- - Signal K paths that have been observed under `notifications.*`;
71
+ - Signal K core alerts and legacy `notifications.*` paths;
72
+ - Alert Rules definitions, including rules that have never fired;
72
73
  - paths defined by Signal K `meta.zones`, even before they fire;
73
74
  - the current state and severity, with active alerts first.
74
75
 
75
76
  Select an alert to see its latest occurrence, the five most recent occurrences,
76
- and its event history. **Acknowledge** and **Silence** use Signal K's notification
77
- API when the source supports those operations. They do not erase history or
77
+ and its event history. **Acknowledge** and **Silence** use Signal K's core alerts
78
+ or notification API when the source supports those operations. They do not erase history or
78
79
  pretend the underlying condition has cleared.
79
80
 
80
81
  ![Alert details with recent occurrences and event history](./docs/screenshots/alert-details.png)
81
82
 
83
+ ### Core alerts and Alert Rules
84
+
85
+ Alert Center supports Signal K core alerts alongside legacy notifications when
86
+ the server provides the core alerts API. Core condition, acknowledgement,
87
+ silence, and source status remain visible, with history and delivery tracked
88
+ independently for each occurrence.
89
+
90
+ [Signal K Alert Rules](https://github.com/hatlabs/signalk-alert-rules) is an
91
+ optional companion for creating rules. Its definitions appear before they fire,
92
+ including disabled and invalid rules. Configure delivery once per rule; wildcard
93
+ instances share those settings while keeping separate history. Saved delivery
94
+ settings survive restarts and work with the dashboard closed. Edit conditions
95
+ and thresholds in Alert Rules.
96
+
97
+ Core alerts use separate policies and permissions from legacy notifications;
98
+ existing legacy policies are not transferred automatically. Alerts that both
99
+ begin and end while Alert Center is stopped are not backfilled from core history.
100
+ See [core alerts compatibility and migration](docs/core-alerts-migration.md) for
101
+ the tested server API, lifecycle details, and migration limits.
102
+
103
+ ### Appearance
104
+
105
+ Use the sun/moon button in the top-right header to choose **Auto**, **Light**, or
106
+ **Dark**. Auto is the default: it follows Signal K's
107
+ `vessels.self.environment.mode` (`day` or `night`) and falls back to your device's
108
+ appearance when that value is unavailable or unrecognised. The menu shows which
109
+ source is being followed. Changes arrive through the existing live Signal K
110
+ connection; no App Dock installation is required.
111
+
112
+ Light and Dark override both Signal K and device changes. The choice is saved
113
+ per browser profile and server address, survives reloads, and is shared between
114
+ tabs for that server. It never changes the boat's shared mode or other devices.
115
+ Choose Auto to resume following Signal K; clearing browser site data also resets
116
+ the preference to Auto. If browser storage is blocked, the menu explains that the
117
+ choice lasts only for the current page.
118
+
119
+ ![Alert Center in dark mode with the appearance menu open](./docs/screenshots/alert-center-dark.png)
120
+
82
121
  ### Access and permissions
83
122
 
84
123
  Reading alerts and history follows Signal K's read-only access settings, including
85
124
  anonymous access when the server permits it. With security enabled:
86
125
 
87
126
  - **Acknowledge / Silence** require a readwrite or admin login and ACL `put`
88
- permission on the occurrence's exact notification path in `vessels.self`.
127
+ permission on the occurrence's exact alert path in `vessels.self`.
89
128
  For example, `notifications.electrical.*` permits electrical alerts without
90
- granting control of navigation alerts. An admin login does not bypass this ACL.
129
+ granting control of navigation alerts. Core alerts require their separate
130
+ `alerts.*` paths, such as `alerts.electrical.*`. An admin login does not bypass
131
+ this ACL.
91
132
  - **Alert settings, policy resets, forgetting definitions, delivery deletion or
92
133
  retry, service tests, and global snooze buttons** require an admin login.
93
134
  - Existing Signal K PUT controls for snooze and quiet hours continue to use the
@@ -96,8 +137,9 @@ anonymous access when the server permits it. With security enabled:
96
137
  If you use ACLs, grant `put` on the specific paths your crew should control.
97
138
  A permission on the literal `notifications` path (used by the server's v2
98
139
  Notifications API) does not also match `notifications.electrical.*`; use explicit
99
- path patterns for Alert Center. Without configured ACLs, readwrite users retain
100
- acknowledge/silence access. With server security disabled, actions remain
140
+ path patterns for Alert Center. Likewise, a literal `alerts` grant or a legacy
141
+ `notifications.*` grant does not authorize core `alerts.*` actions. Without
142
+ configured ACLs, readwrite users retain acknowledge/silence access. With server security disabled, actions remain
101
143
  available through Signal K's permissive security strategy. An unexpectedly
102
144
  missing permission checker blocks acknowledge/silence instead of allowing them.
103
145
 
@@ -132,9 +174,42 @@ You can configure:
132
174
 
133
175
  ### Alert and delivery history
134
176
 
177
+ A shared toolbar keeps search text, severity, and date bounds when switching
178
+ between **Alerts**, **Alert history**, and **Deliveries**. **Clear** resets all
179
+ filters. Search matches literal text (including `%` and `_`) in alert names,
180
+ paths, sources, and messages. Matching ignores ASCII case; other characters match
181
+ exactly. Deliveries also searches service names, operations,
182
+ status codes, and errors; Alert history includes lifecycle event details. Searches
183
+ run before pagination, so older matching records remain discoverable.
184
+
185
+ Alerts searches retained occurrences as well as definitions that have never fired,
186
+ while displaying current active occurrences first. A matching past occurrence can
187
+ therefore find an alert whose current message has changed. The **Cleared history
188
+ only** and date filters restrict this view to matching occurrences. Severity means
189
+ current severity in Alerts, displayed event severity in Alert history, and the
190
+ recorded delivery severity in Deliveries. Date bounds are inclusive and refer to
191
+ occurrence start, lifecycle update, and delivery queue time respectively. Pending
192
+ deliveries remain ahead of completed work even while filtering.
193
+
194
+ The `/occurrences` and `/alert-history` APIs accept `search`; `/deliveries` accepts
195
+ `search`, `state`, `severity`, `from`, and `to`. Filters combine with AND, totals
196
+ count matching deliveries, and cursors must be reused with the same filters.
197
+
135
198
  **Alert history** is a chronological record of Signal K alert changes. It is
136
199
  separate from **Deliveries**, which tracks attempts to send those alerts to
137
- notification services.
200
+ notification services. These tabs load when selected. The Deliveries badge counts
201
+ undelivered items, including queued, retrying, paused, and permanently failed
202
+ attempts; completed and suppressed deliveries remain in the full history but are
203
+ excluded from the badge. The alert list loads independently, with preferred units
204
+ filled in as background metadata requests complete. Detailed diagnostics load when
205
+ the System diagnostics section is expanded.
206
+
207
+ When Signal K’s `settings.notifications.manageNotifications` is explicitly `false`,
208
+ Alert Center skips metadata zone discovery and hides stored zones with no retained
209
+ occurrences.
210
+ Saved policies, history and pending delivery remain intact. Actual legacy
211
+ notifications (including on a stored zone path) and the Alert Rules catalog remain
212
+ visible. See [zone ownership and upgrade notes](docs/core-alerts-migration.md#zone-notification-ownership).
138
213
 
139
214
  ![Chronological Signal K alert changes, separate from delivery attempts](./docs/screenshots/alert-history.png)
140
215
 
@@ -233,6 +308,22 @@ physical speaker was audible.
233
308
 
234
309
  ## Installation and first run
235
310
 
311
+ Requires Node.js 22.5 or newer. Legacy notification support is tested against
312
+ Signal K Server 2.31.1; core alerts additionally require a server exposing the
313
+ compatible core alerts API described in the [compatibility notes](docs/core-alerts-migration.md).
314
+
315
+ ### Upgrading to 0.9.0
316
+
317
+ Stop Signal K and back up the Alert Center SQLite database before upgrading.
318
+ The automatic schema-5 migration preserves history, settings, delivery attempts,
319
+ and pending work. Databases on schema 3 or 4 are upgraded transactionally; an
320
+ interrupted migration rolls back and retries on startup. No database reset is
321
+ required.
322
+
323
+ Version 0.8.0 and older cannot open schema 5. Rolling back requires both the older
324
+ package and the pre-upgrade database backup; restoring that backup discards any
325
+ history and delivery progress recorded since it was taken.
326
+
236
327
  ### From the Signal K App Store
237
328
 
238
329
  1. Open the Signal K **App Store**.
@@ -251,19 +342,18 @@ The default database is stored in the plugin's Signal K data directory. You do
251
342
  not need to enter an absolute path. Existing supported database layouts are
252
343
  migrated in place on startup.
253
344
 
254
- ### Install without publishing to npm
345
+ ### Manual installation
255
346
 
256
- Download or clone this repository on the Signal K host, build it, and install the
257
- resulting package archive into the Signal K data directory:
347
+ Download the package archive for the version you want from
348
+ [GitHub Releases](https://github.com/arodus/signalk-alert-center/releases), then
349
+ install it into the Signal K data directory:
258
350
 
259
351
  ```sh
260
- npm ci
261
- npm run build
262
- npm pack
263
- cd ~/.signalk
264
- npm install /path/to/signalk-alert-center-0.6.0.tgz
352
+ npm install --prefix ~/.signalk /path/to/signalk-alert-center-0.9.0.tgz
265
353
  ```
266
354
 
355
+ To build from source, see the [developer guide](./DEVELOPERS.md).
356
+
267
357
  Restart Signal K after installation. Docker installations should run the final
268
358
  `npm install` command inside the Signal K container or bake the archive into a
269
359
  derived image so the installation survives container replacement.
@@ -323,26 +413,34 @@ local state-recheck interval remain configurable in Alert Center.
323
413
  ## Notification paths to leave out
324
414
 
325
415
  Under **Storage & advanced → Notification paths to leave out**, enter one
326
- pattern per line. By default, Alert Center ignores per-target collision alarms:
416
+ pattern per line. By default, Alert Center ignores per-target collision alarms
417
+ and routine waypoint arrival notifications:
327
418
 
328
419
  ```json
329
420
  {
330
- "ignoredPaths": ["navigation.closestApproach.*"]
421
+ "ignoredPaths": [
422
+ "navigation.closestApproach.*",
423
+ "navigation.course.arrivalCircleEntered",
424
+ "navigation.course.perpendicularPassed"
425
+ ]
331
426
  }
332
427
  ```
333
428
 
334
429
  Patterns match the whole notification path, with or without the leading
335
430
  `notifications.`. Matching is case-sensitive. Only `*` is special: it matches
336
431
  one or more characters, including dots between nested path segments. For example,
337
- the default matches both `navigation.closestApproach.urn:mrn:imo:mmsi:244954000`
432
+ the collision pattern matches both `navigation.closestApproach.urn:mrn:imo:mmsi:244954000`
338
433
  and `navigation.closestApproach.radar:bridge:1`. An exact path matches only itself.
339
- Clear the list (or set `ignoredPaths: []`) to track all notification paths.
434
+ The two course paths are exact matches; other course notifications remain tracked.
435
+ Remove either course entry to track and deliver that notification, or clear the
436
+ list (or set `ignoredPaths: []`) to track all notification paths.
340
437
 
341
438
  Matching updates and clears are skipped before queueing or creating definitions,
342
439
  history, deliveries, or connectivity requests. The same filter applies to startup
343
440
  snapshots and zone discovery. Other Signal K apps still receive these alerts.
344
441
 
345
- This default also applies after upgrading if `ignoredPaths` has never been set.
442
+ These defaults also apply after upgrading if `ignoredPaths` has never been set.
443
+ An explicitly saved list, including an empty list, is used unchanged.
346
444
  Existing definitions, history, per-alert settings, and queued delivery work are
347
445
  preserved. Existing occurrences stop receiving updates and clears while their
348
446
  path is ignored; ignoring a path does not cancel pending deliveries or wake work.
@@ -384,13 +482,14 @@ service selected for that alert.
384
482
 
385
483
  ## Operational notes
386
484
 
387
- - Alert Center subscribes to `notifications.*` and reconciles the current Signal K
388
- notification tree at startup.
485
+ - Alert Center reconciles core alerts and the legacy notification tree at
486
+ startup, then processes live updates. Missing core alerts are recorded as
487
+ removed without assuming the condition recovered.
389
488
  - A `normal`, `nominal`, cleared, or null notification transition clears the
390
489
  current occurrence but does not delete its history.
391
490
  - Delivery is persisted before network activity begins. Pending work is recovered
392
491
  after a Signal K or plugin restart.
393
- - Every Signal K severity-state change creates a new durable delivery cycle for
492
+ - Every legacy notification severity-state change creates a new durable delivery cycle for
394
493
  services targeted by the earlier state. Each cycle keeps its own severity and
395
494
  message snapshot, even when the previous cycle is still queued or retrying.
396
495
  This includes escalation and de-escalation; a clear creates one recovery
@@ -1,6 +1,6 @@
1
1
  import { PluginConfig } from "../config";
2
2
  import { AlertDatabase } from "../storage/db";
3
- import { AlertDefinitionRecord, AlertPolicyField, ConnectivityMode, Severity } from "./types";
3
+ import { AlertDefinitionRecord, AlertPolicyField, ConnectivityMode, NormalizedAlert, Severity } from "./types";
4
4
  import { ConfiguredZonePath } from "./zones";
5
5
  export interface PolicyValues {
6
6
  enabled: boolean;
@@ -32,6 +32,8 @@ export declare class AlertPolicyResolver {
32
32
  private applyStored;
33
33
  forPath(path: string, _severity?: Severity): EffectivePolicy;
34
34
  forDefinition(definition: AlertDefinitionRecord): EffectivePolicy;
35
+ defaultPolicy(): EffectivePolicy;
36
+ ensureDefinitionForAlert(alert: NormalizedAlert): string;
35
37
  seedDefinitions(zones: ConfiguredZonePath[]): void;
36
38
  ensureDefinitionForPath(path: string): string;
37
39
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AlertPolicyResolver = exports.pathDefinitionId = void 0;
4
+ const alert_rules_1 = require("../signalk/alert-rules");
4
5
  const types_1 = require("./types");
5
6
  const pathDefinitionId = (notificationPath) => `path:${notificationPath}`;
6
7
  exports.pathDefinitionId = pathDefinitionId;
@@ -93,7 +94,26 @@ class AlertPolicyResolver {
93
94
  return this.applyStored(this.defaults(), this.database.getPolicy((0, exports.pathDefinitionId)(path)));
94
95
  }
95
96
  forDefinition(definition) {
96
- return this.forPath(definition.pathPattern);
97
+ if (definition.sourceType !== "rule")
98
+ return this.forPath(definition.pathPattern);
99
+ return this.applyStored(this.defaults(), this.database.getPolicy(definition.id));
100
+ }
101
+ defaultPolicy() {
102
+ return this.applyStored(this.defaults(), undefined);
103
+ }
104
+ ensureDefinitionForAlert(alert) {
105
+ const rule = (0, alert_rules_1.ruleFromAlert)(alert);
106
+ if (!rule)
107
+ return this.ensureDefinitionForPath(alert.path);
108
+ const definition = (0, alert_rules_1.ruleDefinition)(rule);
109
+ try {
110
+ // Retain the catalog's wildcard path and the saved rule identity.
111
+ this.database.getDefinition(definition.id);
112
+ }
113
+ catch {
114
+ this.database.upsertDefinition(definition);
115
+ }
116
+ return definition.id;
97
117
  }
98
118
  seedDefinitions(zones) {
99
119
  zones.forEach((zone) => {
@@ -1 +1 @@
1
- {"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/alerts/policy.ts"],"names":[],"mappings":";;;AAEA,mCAOiB;AA0BV,MAAM,gBAAgB,GAAG,CAAC,gBAAwB,EAAU,EAAE,CACnE,QAAQ,gBAAgB,EAAE,CAAC;AADhB,QAAA,gBAAgB,oBACA;AAE7B,MAAa,mBAAmB;IAEX;IACA;IAFnB,YACmB,QAAuB,EACvB,MAAoB;QADpB,aAAQ,GAAR,QAAQ,CAAe;QACvB,WAAM,GAAN,MAAM,CAAc;IACpC,CAAC;IAEI,QAAQ;QACd,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,IAAI,IAAI;YAC9C,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,IAAI,KAAK;YAC/C,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,IAAI,QAAQ;YAC9D,sBAAsB,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,sBAAsB,IAAI,CAAC;YACzE,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;YACrE,WAAW,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;YACzD,uBAAuB,EAAE,MAAM,CAAC,WAAW,CACzC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC9C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,EAAE,CAAC,CAAC;QAC7C,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,UAAU,CAAC,EAAE,CAAC;IACvB,CAAC;IAED,eAAe,CAAC,KAA2B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,MAAM,IAAI,GAAG,iBAAiB,IAAI,CAAC,IAAI,EAAE,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAC7B,EAAE,EAAE,IAAA,wBAAgB,EAAC,IAAI,CAAC;gBAC1B,UAAU,EAAE,MAAM;gBAClB,WAAW,EAAE,IAAI;gBACjB,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI;gBAC3C,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uBAAuB,CAAC,IAAY;QAClC,MAAM,EAAE,GAAG,IAAA,wBAAgB,EAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAChC,OAAO,EAAE,CAAC;QACZ,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YAC7B,EAAE;YACF,UAAU,EAAE,YAAY;YACxB,WAAW,EAAE,IAAI;YACjB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA/JD,kDA+JC"}
@@ -1,3 +1,4 @@
1
+ import type { CoreAlert } from "../signalk/core-alerts";
1
2
  /** Reading captured at notification receipt; raw Signal K message stays intact. */
2
3
  export interface MessageSample {
3
4
  message: string;
@@ -17,6 +18,9 @@ export type ConnectivityMode = {
17
18
  delaySeconds: number;
18
19
  };
19
20
  export interface AlertRecord {
21
+ coreAlert?: CoreAlert;
22
+ /** True only when a condition return or successful terminal action was observed. */
23
+ coreResolutionConfirmed?: boolean;
20
24
  id: string;
21
25
  definitionId?: string;
22
26
  occurrenceNumber?: number;
@@ -79,6 +83,7 @@ export interface AlertHistoryRecord extends AlertEventRecord {
79
83
  clearedAt?: Date;
80
84
  }
81
85
  export interface AlertHistoryQuery {
86
+ search?: string;
82
87
  definitionId?: string;
83
88
  path?: string;
84
89
  source?: string;
@@ -97,7 +102,7 @@ export interface AlertHistoryPage {
97
102
  }
98
103
  export interface AlertDefinitionRecord {
99
104
  id: string;
100
- sourceType: "zone" | "recognized";
105
+ sourceType: "zone" | "recognized" | "rule";
101
106
  pathPattern: string;
102
107
  name: string;
103
108
  metadata?: unknown;
@@ -198,7 +203,7 @@ export interface WyomingPlaybackRecord {
198
203
  export interface DeliveryPage {
199
204
  items: DeliveryRecord[];
200
205
  nextCursor?: string;
201
- total: number;
206
+ total?: number;
202
207
  }
203
208
  export interface DeliveryAttemptPage {
204
209
  items: DeliveryAttemptRecord[];
@@ -224,6 +229,7 @@ export interface IngestOptions {
224
229
  speechMinimumSeverity?: Severity;
225
230
  }
226
231
  export interface OccurrenceQuery {
232
+ search?: string;
227
233
  definitionId?: string;
228
234
  path?: string;
229
235
  source?: string;
@@ -240,6 +246,8 @@ export interface OccurrencePage {
240
246
  nextCursor?: string;
241
247
  }
242
248
  export interface NormalizedAlert {
249
+ coreAlert?: CoreAlert;
250
+ coreResolutionConfirmed?: boolean;
243
251
  sourceKey: string;
244
252
  path: string;
245
253
  source?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/alerts/types.ts"],"names":[],"mappings":";;;AAQa,QAAA,UAAU,GAAG;IACxB,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,WAAW;CACH,CAAC;AA4HE,QAAA,iBAAiB,GAAG;IAC/B,SAAS;IACT,SAAS;IACT,iBAAiB;IACjB,wBAAwB;IACxB,cAAc;IACd,aAAa;IACb,cAAc;IACd,SAAS;IACT,eAAe;IACf,uBAAuB;IACvB,gBAAgB;IAChB,qBAAqB;CACb,CAAC;AAuKJ,MAAM,YAAY,GAAG,CAAC,QAAkB,EAAU,EAAE,CACzD,kBAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AADlB,QAAA,YAAY,gBACM"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/alerts/types.ts"],"names":[],"mappings":";;;AASa,QAAA,UAAU,GAAG;IACxB,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,WAAW;CACH,CAAC;AAgIE,QAAA,iBAAiB,GAAG;IAC/B,SAAS;IACT,SAAS;IACT,iBAAiB;IACjB,wBAAwB;IACxB,cAAc;IACd,aAAa;IACb,cAAc;IACd,SAAS;IACT,eAAe;IACf,uBAAuB;IACvB,gBAAgB;IAChB,qBAAqB;CACb,CAAC;AA0KJ,MAAM,YAAY,GAAG,CAAC,QAAkB,EAAU,EAAE,CACzD,kBAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AADlB,QAAA,YAAY,gBACM"}