signalk-alert-center 0.8.0 → 0.9.1

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 (72) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/DEVELOPERS.md +8 -4
  3. package/README.md +110 -32
  4. package/dist/alerts/normalize.d.ts +2 -0
  5. package/dist/alerts/normalize.js +6 -1
  6. package/dist/alerts/normalize.js.map +1 -1
  7. package/dist/alerts/policy.d.ts +3 -1
  8. package/dist/alerts/policy.js +21 -1
  9. package/dist/alerts/policy.js.map +1 -1
  10. package/dist/alerts/types.d.ts +9 -1
  11. package/dist/alerts/types.js.map +1 -1
  12. package/dist/api/openapi.d.ts +286 -0
  13. package/dist/api/openapi.js +179 -7
  14. package/dist/api/openapi.js.map +1 -1
  15. package/dist/api/routes.d.ts +13 -3
  16. package/dist/api/routes.js +54 -6
  17. package/dist/api/routes.js.map +1 -1
  18. package/dist/config-schema.d.ts +13 -5
  19. package/dist/config-schema.js +9 -1
  20. package/dist/config-schema.js.map +1 -1
  21. package/dist/config.d.ts +1 -0
  22. package/dist/config.js +5 -0
  23. package/dist/config.js.map +1 -1
  24. package/dist/delivery/scheduler.js +15 -6
  25. package/dist/delivery/scheduler.js.map +1 -1
  26. package/dist/runtime.d.ts +16 -0
  27. package/dist/runtime.js +285 -28
  28. package/dist/runtime.js.map +1 -1
  29. package/dist/signalk/alert-rules.d.ts +14 -0
  30. package/dist/signalk/alert-rules.js +52 -0
  31. package/dist/signalk/alert-rules.js.map +1 -0
  32. package/dist/signalk/core-alerts.d.ts +52 -0
  33. package/dist/signalk/core-alerts.js +119 -0
  34. package/dist/signalk/core-alerts.js.map +1 -0
  35. package/dist/signalk/ignored-paths.js +5 -1
  36. package/dist/signalk/ignored-paths.js.map +1 -1
  37. package/dist/signalk/ingestion-queue.js +5 -1
  38. package/dist/signalk/ingestion-queue.js.map +1 -1
  39. package/dist/signalk/message-sample.js +9 -1
  40. package/dist/signalk/message-sample.js.map +1 -1
  41. package/dist/signalk/notifications.d.ts +8 -0
  42. package/dist/signalk/notifications.js +18 -1
  43. package/dist/signalk/notifications.js.map +1 -1
  44. package/dist/storage/db.d.ts +27 -4
  45. package/dist/storage/db.js +390 -42
  46. package/dist/storage/db.js.map +1 -1
  47. package/dist/storage/migrations.d.ts +4 -0
  48. package/dist/storage/migrations.js +17 -0
  49. package/dist/storage/migrations.js.map +1 -1
  50. package/dist/storage/schema.d.ts +1 -1
  51. package/dist/storage/schema.js +1 -1
  52. package/dist/transports/transport.js +9 -1
  53. package/dist/transports/transport.js.map +1 -1
  54. package/dist/transports/wyoming.js +9 -1
  55. package/dist/transports/wyoming.js.map +1 -1
  56. package/docs/core-alerts-migration.md +248 -0
  57. package/docs/screenshots/alert-center-dark.png +0 -0
  58. package/docs/screenshots/alert-center-overview.png +0 -0
  59. package/docs/screenshots/alert-center-tablet.png +0 -0
  60. package/docs/screenshots/alert-details.png +0 -0
  61. package/docs/screenshots/alert-history.png +0 -0
  62. package/docs/screenshots/delivery-history.png +0 -0
  63. package/docs/screenshots/global-snooze.jpg +0 -0
  64. package/package.json +5 -3
  65. package/public/alert-rules.js +117 -0
  66. package/public/app.js +272 -120
  67. package/public/config-d2a5aa14a22909369f1e.js +2 -0
  68. package/public/index.html +94 -116
  69. package/public/remoteEntry.js +1 -1
  70. package/public/styles.css +24 -2
  71. package/public/config-794111361b7b1730b81b.js +0 -2
  72. /package/public/{config-794111361b7b1730b81b.js.LICENSE.txt → config-d2a5aa14a22909369f1e.js.LICENSE.txt} +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,88 @@ Versioning while it remains pre-1.0.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.9.1] - 2026-11-20
9
+
10
+ ### Fixes
11
+
12
+ - Close stored notifications that are no longer present after a Signal K
13
+ restart. Previously they stayed active indefinitely when their producer only
14
+ publishes on change and the condition ended while the server was down. After
15
+ startup, notifications that no producer republishes within the new **Startup
16
+ grace period** setting (120 seconds by default) are closed without a recovery
17
+ message; any queued initial delivery is kept, and PagerDuty incidents they
18
+ opened are not resolved. Notifications republished within the period continue
19
+ their existing occurrence without notifying again.
20
+ - The Alerts table and Normal severity filter now include recognized notifications
21
+ whose source explicitly reports normal, even when the path has never fired.
22
+
23
+ ## [0.9.0] - 2026-11-19
24
+
25
+ ### Features
26
+
27
+ - Support Signal K core alerts alongside legacy notifications, with durable
28
+ per-service delivery, grouped momentary alerts, and separate condition,
29
+ acknowledgement, silence, and source status. Acknowledge and silence through
30
+ the core API; Wyoming follows core silence and attention state.
31
+ - List Alert Rules definitions before they fire, including disabled and invalid
32
+ rules. Configure delivery once per rule; wildcard instances share those
33
+ settings while retaining separate history. Settings survive restart and work
34
+ with the dashboard closed. Alert Rules remains responsible for conditions and
35
+ thresholds and is recommended as an optional companion plugin.
36
+ - Use one search and filter toolbar across Alerts, Alert history, and Deliveries.
37
+ Search text, severity, and date bounds carry between tabs; each tab keeps its
38
+ relevant status or update filters. Search includes names, messages, paths, and
39
+ sources, plus service names and errors in Deliveries. Matching retained records
40
+ are found before pagination, and delivery results retain pending-work priority.
41
+ History severity filters match the displayed event severity; delivery filters
42
+ use recorded message and severity snapshots.
43
+
44
+ ### Fixes
45
+
46
+ - Load rule catalogs and delivery defaults without blocking the alert list.
47
+ History and delivery links within the open dashboard select and load their tab.
48
+ - Respect Signal K's disabled notification management when discovering metadata
49
+ zones. Hide stored zones without retained occurrences while preserving their
50
+ settings. Actual legacy alerts, history, queued deliveries, and the Alert Rules
51
+ catalog remain available.
52
+ - Use core terminal removal reasons to confirm recovery for completed conditions
53
+ and acknowledgements. Displaced alerts retain history and queued initial
54
+ deliveries without claiming recovery; superseded acknowledgement/recovery
55
+ work and repeats are suppressed. Missing or unknown reasons remain unclassified
56
+ unless recovery was independently confirmed.
57
+ - Preserve Alert Rules' formatted messages and units in the dashboard and all
58
+ delivery services, including speech. Legacy notification unit conversion remains
59
+ available.
60
+ - Ignore routine waypoint arrival-circle and perpendicular-passed notifications
61
+ by default, alongside per-target collision alarms. Existing explicit
62
+ `ignoredPaths` lists remain unchanged. Remove either exact course path from
63
+ the list to track and deliver it; other course notifications remain tracked.
64
+ - Refresh the README to describe the implemented core-alert support, rule
65
+ settings, manual installation, and upgrade requirements.
66
+
67
+ ### Compatibility, upgrade, and rollback
68
+
69
+ - Core support activates when the server exposes the compatible core alerts API.
70
+ Legacy notification support remains available on Signal K Server 2.31.1.
71
+ See [compatibility notes](docs/core-alerts-migration.md) for the tested core
72
+ server and Alert Rules revisions. Compatibility with other core API revisions
73
+ has not been verified.
74
+ - Stop Signal K and back up the Alert Center SQLite database before upgrading.
75
+ Schema 3 and 4 databases migrate transactionally to schema 5, preserving history,
76
+ policies, attempts, pending deliveries, and the delivery-history index.
77
+ Interrupted migrations roll back and retry on startup; no reset is required.
78
+ - Version 0.8.0 and older cannot open schema 5. Rollback requires both the older
79
+ package and the pre-upgrade database backup. Restoring that backup discards
80
+ history and delivery progress recorded after it was taken.
81
+ - Core `alerts.*` paths use separate delivery policies and permissions from legacy
82
+ `notifications.*` paths. ACL installations must grant `put` on allowed core
83
+ paths separately. Restricted admins are checked too; settings, rule-editor
84
+ links, maintenance, and dashboard snooze controls remain admin-only.
85
+ - Legacy policies are not transferred automatically. Core history is not replayed
86
+ for alerts that began and ended while Alert Center was stopped; missing active
87
+ alerts do not prove recovery. Alert Rules messages use the producer's units for
88
+ all recipients, without per-recipient conversion.
89
+
8
90
  ## [0.8.0] - 2026-11-12
9
91
 
10
92
  ### 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,17 +68,38 @@ 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
+
82
103
  ### Appearance
83
104
 
84
105
  Use the sun/moon button in the top-right header to choose **Auto**, **Light**, or
@@ -103,9 +124,11 @@ Reading alerts and history follows Signal K's read-only access settings, includi
103
124
  anonymous access when the server permits it. With security enabled:
104
125
 
105
126
  - **Acknowledge / Silence** require a readwrite or admin login and ACL `put`
106
- permission on the occurrence's exact notification path in `vessels.self`.
127
+ permission on the occurrence's exact alert path in `vessels.self`.
107
128
  For example, `notifications.electrical.*` permits electrical alerts without
108
- 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.
109
132
  - **Alert settings, policy resets, forgetting definitions, delivery deletion or
110
133
  retry, service tests, and global snooze buttons** require an admin login.
111
134
  - Existing Signal K PUT controls for snooze and quiet hours continue to use the
@@ -114,8 +137,9 @@ anonymous access when the server permits it. With security enabled:
114
137
  If you use ACLs, grant `put` on the specific paths your crew should control.
115
138
  A permission on the literal `notifications` path (used by the server's v2
116
139
  Notifications API) does not also match `notifications.electrical.*`; use explicit
117
- path patterns for Alert Center. Without configured ACLs, readwrite users retain
118
- 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
119
143
  available through Signal K's permissive security strategy. An unexpectedly
120
144
  missing permission checker blocks acknowledge/silence instead of allowing them.
121
145
 
@@ -150,6 +174,27 @@ You can configure:
150
174
 
151
175
  ### Alert and delivery history
152
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
+
153
198
  **Alert history** is a chronological record of Signal K alert changes. It is
154
199
  separate from **Deliveries**, which tracks attempts to send those alerts to
155
200
  notification services. These tabs load when selected. The Deliveries badge counts
@@ -159,15 +204,12 @@ excluded from the badge. The alert list loads independently, with preferred unit
159
204
  filled in as background metadata requests complete. Detailed diagnostics load when
160
205
  the System diagnostics section is expanded.
161
206
 
162
- The dashboard uses a lightweight `/summary` endpoint and requests delivery pages
163
- with `includeTotal=false` to avoid counting the full history. Other API clients
164
- retain the existing `/status` response and lifetime delivery totals by default.
165
- Database schema version 4 adds an index automatically on upgrade; the first startup
166
- may take longer while SQLite builds it. Existing history, settings, and pending
167
- work are preserved, and no reset is required. Stop Signal K and back up the
168
- Alert Center SQLite database before upgrading. Version 0.7.0 cannot open the
169
- upgraded database; rollback requires the older package and the pre-upgrade backup,
170
- which does not contain history or delivery progress recorded after that backup.
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).
171
213
 
172
214
  ![Chronological Signal K alert changes, separate from delivery attempts](./docs/screenshots/alert-history.png)
173
215
 
@@ -266,6 +308,22 @@ physical speaker was audible.
266
308
 
267
309
  ## Installation and first run
268
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
+
269
327
  ### From the Signal K App Store
270
328
 
271
329
  1. Open the Signal K **App Store**.
@@ -284,19 +342,18 @@ The default database is stored in the plugin's Signal K data directory. You do
284
342
  not need to enter an absolute path. Existing supported database layouts are
285
343
  migrated in place on startup.
286
344
 
287
- ### Install without publishing to npm
345
+ ### Manual installation
288
346
 
289
- Download or clone this repository on the Signal K host, build it, and install the
290
- 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:
291
350
 
292
351
  ```sh
293
- npm ci
294
- npm run build
295
- npm pack
296
- cd ~/.signalk
297
- npm install /path/to/signalk-alert-center-0.8.0.tgz
352
+ npm install --prefix ~/.signalk /path/to/signalk-alert-center-0.9.0.tgz
298
353
  ```
299
354
 
355
+ To build from source, see the [developer guide](./DEVELOPERS.md).
356
+
300
357
  Restart Signal K after installation. Docker installations should run the final
301
358
  `npm install` command inside the Signal K container or bake the archive into a
302
359
  derived image so the installation survives container replacement.
@@ -356,26 +413,34 @@ local state-recheck interval remain configurable in Alert Center.
356
413
  ## Notification paths to leave out
357
414
 
358
415
  Under **Storage & advanced → Notification paths to leave out**, enter one
359
- 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:
360
418
 
361
419
  ```json
362
420
  {
363
- "ignoredPaths": ["navigation.closestApproach.*"]
421
+ "ignoredPaths": [
422
+ "navigation.closestApproach.*",
423
+ "navigation.course.arrivalCircleEntered",
424
+ "navigation.course.perpendicularPassed"
425
+ ]
364
426
  }
365
427
  ```
366
428
 
367
429
  Patterns match the whole notification path, with or without the leading
368
430
  `notifications.`. Matching is case-sensitive. Only `*` is special: it matches
369
431
  one or more characters, including dots between nested path segments. For example,
370
- the default matches both `navigation.closestApproach.urn:mrn:imo:mmsi:244954000`
432
+ the collision pattern matches both `navigation.closestApproach.urn:mrn:imo:mmsi:244954000`
371
433
  and `navigation.closestApproach.radar:bridge:1`. An exact path matches only itself.
372
- 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.
373
437
 
374
438
  Matching updates and clears are skipped before queueing or creating definitions,
375
439
  history, deliveries, or connectivity requests. The same filter applies to startup
376
440
  snapshots and zone discovery. Other Signal K apps still receive these alerts.
377
441
 
378
- 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.
379
444
  Existing definitions, history, per-alert settings, and queued delivery work are
380
445
  preserved. Existing occurrences stop receiving updates and clears while their
381
446
  path is ignored; ignoring a path does not cancel pending deliveries or wake work.
@@ -417,13 +482,26 @@ service selected for that alert.
417
482
 
418
483
  ## Operational notes
419
484
 
420
- - Alert Center subscribes to `notifications.*` and reconciles the current Signal K
421
- 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. Signal K does not keep
488
+ legacy notifications across a server restart, and it starts data providers
489
+ only after plugins. A stored active notification that no producer republishes
490
+ within the startup grace period (`ingestion.startupGraceSeconds`, 120 seconds
491
+ by default) is closed with a `missing on startup` event. No recovery message is
492
+ sent, and any queued initial delivery is kept. A PagerDuty incident it opened
493
+ stays open, even if its trigger is delivered after the close. A notification
494
+ republished within the period continues its existing occurrence without
495
+ notifying again; one republished later starts a new occurrence and notifies
496
+ again. Signal K
497
+ starts data providers after plugins, so `0` closes almost every ongoing
498
+ condition at startup and re-notifies it when it returns.
499
+ Notifications on ignored paths keep their stored state.
422
500
  - A `normal`, `nominal`, cleared, or null notification transition clears the
423
501
  current occurrence but does not delete its history.
424
502
  - Delivery is persisted before network activity begins. Pending work is recovered
425
503
  after a Signal K or plugin restart.
426
- - Every Signal K severity-state change creates a new durable delivery cycle for
504
+ - Every legacy notification severity-state change creates a new durable delivery cycle for
427
505
  services targeted by the earlier state. Each cycle keeps its own severity and
428
506
  message snapshot, even when the previous cycle is still queued or retrying.
429
507
  This includes escalation and de-escalation; a clear creates one recovery
@@ -1,4 +1,6 @@
1
1
  import { NormalizedAlert, Severity } from "./types";
2
2
  export declare function normalizeSeverity(value: unknown): Severity;
3
+ /** Identity of one producer's notification on a path. */
4
+ export declare function notificationSourceKey(path: string, source?: string): string;
3
5
  export declare function normalizeNotification(path: string, value: unknown, source?: string, sourceTimestamp?: Date): NormalizedAlert;
4
6
  export declare function isSeverity(value: unknown): value is Severity;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeSeverity = normalizeSeverity;
4
+ exports.notificationSourceKey = notificationSourceKey;
4
5
  exports.normalizeNotification = normalizeNotification;
5
6
  exports.isSeverity = isSeverity;
6
7
  const types_1 = require("./types");
@@ -20,6 +21,10 @@ function normalizeSeverity(value) {
20
21
  : undefined;
21
22
  return normalized ?? "alert";
22
23
  }
24
+ /** Identity of one producer's notification on a path. */
25
+ function notificationSourceKey(path, source) {
26
+ return source ? `${path}@${source}` : path;
27
+ }
23
28
  function normalizeNotification(path, value, source, sourceTimestamp) {
24
29
  const record = value && typeof value === "object"
25
30
  ? value
@@ -48,7 +53,7 @@ function normalizeNotification(path, value, source, sourceTimestamp) {
48
53
  // Multiple sources can legitimately raise the same path independently
49
54
  // (e.g. two GPS units both losing signal); coalesce per source instead
50
55
  // of collapsing them into a single alert.
51
- sourceKey: source ? `${path}@${source}` : path,
56
+ sourceKey: notificationSourceKey(path, source),
52
57
  path,
53
58
  source,
54
59
  severity,
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/alerts/normalize.ts"],"names":[],"mappings":";;AAaA,8CAMC;AAED,sDAiDC;AAED,gCAKC;AA7ED,mCAAgE;AAEhE,MAAM,eAAe,GAA6B;IAChD,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,WAAW;CACtB,CAAC;AAEF,SAAgB,iBAAiB,CAAC,KAAc;IAC9C,MAAM,UAAU,GACd,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC,CAAC,SAAS,CA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AC1C,SAAS,EAAE,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC;QAC9C,IAAI;QACJ,MAAM;QACN,QAAQ;QACR,KAAK;QACL,OAAO;QACP,aAAa,EAAE,KAAK;QACpB,cAAc;QACd,YAAY,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI;QAC3C,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACxB,kBAAgC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAClD,CAAC;AACJ,CAAC"}
@@ -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;YACz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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;
@@ -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"}