@checkstack/maintenance-frontend 0.5.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,221 @@
1
1
  # @checkstack/maintenance-frontend
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 32d52c6: feat: unified notification-subscription manager dialog driven by spec registry
8
+
9
+ Replaces the bell-toggle UX (which only managed a single legacy
10
+ catalog group) with a modal that lists every notification type
11
+ registered against a target — system or group — and exposes both
12
+ per-type toggles and a bulk "Subscribe to all / Unsubscribe from all"
13
+ action. Both surfaces (system detail page header bell, dashboard group
14
+ header bell) now open the same `NotificationSubscriptionsManager`
15
+ component.
16
+
17
+ **Key change vs. the prior slot-based approach**: rows are now driven
18
+ by `notificationClient.listSubscriptionSpecs` — the backend's spec
19
+ registry is the single source of truth. Previously, a row only
20
+ appeared if a frontend plugin had remembered to register a
21
+ `createNotificationSubscriptionExtension`; this caused silent drift
22
+ (healthcheck and dependency registered backend specs without frontend
23
+ extensions, so the dialog counted them but never rendered rows). Now,
24
+ every spec the platform knows about renders a row using the spec's
25
+ `display` metadata (title, description, iconName resolved via
26
+ `DynamicIcon`).
27
+
28
+ **Sub-controls registry** (`@checkstack/notification-frontend`):
29
+ plugins that want sub-granularity (anomaly's per-field mute list,
30
+ future severity / channel filters) call
31
+ `registerSubscriptionSubControls(spec, Component)` at module load —
32
+ the manager looks the component up by `specId` when expanding a row.
33
+
34
+ **Removed (no compat)**:
35
+
36
+ - `createNotificationSubscriptionExtension` (replaced by the
37
+ spec-driven manager + the SubControls registry)
38
+ - `target.slot` field on `NotificationTarget` and the
39
+ `NotificationTargetInput.slot` parameter on
40
+ `defineNotificationTarget`
41
+ - `SystemNotificationSubscriptionsSlot` and
42
+ `GroupNotificationSubscriptionsSlot` from `@checkstack/catalog-common`
43
+ - `SystemNotificationsCard` from the system detail page's main column
44
+ - `SubscribeButton` wiring on dashboard group cards and the system
45
+ detail page header
46
+
47
+ **Migrated frontends**: anomaly (now registers `AnomalyFieldMuteList`
48
+ via the SubControls registry), incident, maintenance — all dropped
49
+ their `createNotificationSubscriptionExtension` calls. healthcheck and
50
+ dependency now show up automatically via the spec registry — no
51
+ frontend changes needed for them to render.
52
+
53
+ The trigger button reflects aggregate state — filled bell when at
54
+ least one spec is subscribed for the resource, ghost bell when none.
55
+
56
+ - 32d52c6: feat: notification target pattern + per-spec subscriptions
57
+
58
+ Replaces the all-or-nothing catalog system/group notification model with a
59
+ platform-level target pattern. Each notification-emitting plugin declares
60
+ _subscription specs_ against typed _target_ objects exported from the
61
+ target's owning plugin (catalog ships `catalogSystemTarget` and
62
+ `catalogGroupTarget`). Notification-backend handles every per-resource
63
+ group lifecycle, parent-edge inheritance, and legacy-subscription seeding
64
+ — plugins never author groupId helpers, lifecycle hooks, or migration
65
+ code again.
66
+
67
+ **Plugin-author surface area is now ~12 lines per emitter:**
68
+
69
+ ```ts
70
+ // <plugin>-common
71
+ const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
72
+ export const fooSystemSubscription = defineSubscription({
73
+ localId: "system",
74
+ target: catalogSystemTarget,
75
+ display: { title: "Foo Alerts", description: "...", iconName: "Bell" },
76
+ });
77
+
78
+ // <plugin>-backend register()
79
+ env.registerSubscriptionSpecs([fooSystemSubscription]);
80
+ // ^ feeds the plugin loader's dependency sorter — each spec's
81
+ // target.ownerPlugin becomes an implicit init-order dep, so this
82
+ // plugin automatically waits for catalog (the target owner) to
83
+ // finish init + afterPluginsReady before its own runs.
84
+
85
+ // <plugin>-backend afterPluginsReady
86
+ await notificationClient.registerSubscriptionSpec(
87
+ specToRegistration(fooSystemSubscription)
88
+ );
89
+ // dispatch
90
+ await notificationClient.notifyForSubscription({
91
+ specId: fooSystemSubscription.specId,
92
+ resourceKeys: [systemId],
93
+ title,
94
+ body,
95
+ importance,
96
+ action,
97
+ collapseKey,
98
+ subjects,
99
+ });
100
+
101
+ // <plugin>-frontend
102
+ createNotificationSubscriptionExtension({ spec: fooSystemSubscription });
103
+ ```
104
+
105
+ **Migrated plugins**: anomaly, incident, maintenance, healthcheck,
106
+ dependency. Each lost its bespoke `notification-groups.ts`,
107
+ `bootstrap*NotificationGroups`, `ensure*Group`, and inheritance walk —
108
+ all of that is now centralized in notification-backend's
109
+ `subscription-engine`.
110
+
111
+ **Plugin loader change** (`@checkstack/backend-api`,
112
+ `@checkstack/backend`): the register-time API gains
113
+ `env.registerSubscriptionSpecs([...specs])`. The dependency sorter
114
+ walks `spec.target.ownerPlugin` for every declared spec and adds the
115
+ target owner as an init-order dependency of the emitting plugin. This
116
+ guarantees that catalog (the owner of the platform's `system` and
117
+ `group` targets) completes init + afterPluginsReady before any
118
+ emitting plugin tries to register its specs against the notification
119
+ service — no string-prefix heuristics, no manual `dependsOnPlugins`
120
+ list, no stub rows. Plugins that fail to declare their specs at
121
+ register time get a clear `Target type X is not registered. Did the
122
+ emitting plugin declare this spec via env.registerSubscriptionSpecs?`
123
+ error from the dispatcher.
124
+
125
+ **Removed** (no backwards compat):
126
+
127
+ - `catalogClient.notifySystemSubscribers` and
128
+ `catalogClient.notifyManySystemSubscribers`
129
+ - `notificationClient.notifyUsers` and `notificationClient.notifyGroups`
130
+ as direct dispatch primitives — replaced by spec-bound
131
+ `notifyForSubscription`
132
+ - catalog's `bootstrapNotificationGroups` (replaced by
133
+ `bootstrapNotificationTargets`)
134
+
135
+ **Enforcement**: the dispatcher rejects calls referencing unregistered
136
+ specIds, specs owned by other plugins, or resourceKeys that haven't been
137
+ pushed via `upsertNotificationResource`. Display metadata for any
138
+ groupId is recoverable via the spec registry, so audit lists render
139
+ correct labels even when an emitter's frontend isn't loaded.
140
+
141
+ **Per-field anomaly mute** keeps working — it now lives inside the
142
+ generic SubscriptionRow's optional `SubControls` panel
143
+ (`AnomalyFieldMuteList`), exposed through the catalog system detail
144
+ page's notifications card.
145
+
146
+ The catalog system detail page renders a "Notifications" card hosting
147
+ `SystemNotificationSubscriptionsSlot`. The matching group surface is
148
+ not yet rendered — group-level subscriptions are wired end-to-end on
149
+ the backend; a follow-up will add the host UI.
150
+
151
+ **Migration of existing subscribers**: target types declare a
152
+ `legacyGroupIdTemplate`; on first registration of each spec,
153
+ notification-backend reads subscribers from the legacy
154
+ `catalog.system.<id>` / `catalog.group.<id>` groups and seeds the new
155
+ spec groups exactly once per (spec × resource) pair, tracked in
156
+ `subscription_migrations`. Anomaly stays opt-in (its target also
157
+ declares the template, but the user-explicit nature of the original
158
+ opt-in flow means the seeding produces the same set of subscribers
159
+ they already had).
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies [32d52c6]
164
+ - Updated dependencies [32d52c6]
165
+ - Updated dependencies [32d52c6]
166
+ - Updated dependencies [32d52c6]
167
+ - Updated dependencies [32d52c6]
168
+ - Updated dependencies [32d52c6]
169
+ - Updated dependencies [32d52c6]
170
+ - @checkstack/notification-common@1.0.0
171
+ - @checkstack/notification-frontend@0.3.0
172
+ - @checkstack/catalog-common@2.0.0
173
+ - @checkstack/maintenance-common@1.0.0
174
+ - @checkstack/dashboard-frontend@0.6.0
175
+ - @checkstack/frontend-api@0.4.1
176
+ - @checkstack/auth-frontend@0.5.32
177
+ - @checkstack/ui@1.7.0
178
+
179
+ ## 0.5.8
180
+
181
+ ### Patch Changes
182
+
183
+ - 208ad71: Centralize realtime cache invalidation: signals now carry their owning `pluginId` end-to-end, and a single `SignalAutoInvalidator` mounted near the React Query client invalidates `[[pluginId]]` for every incoming signal automatically.
184
+
185
+ **Breaking change to `createSignal`** (`@checkstack/signal-common`): the factory now takes a single object argument with `pluginMetadata`, `event`, and `payloadSchema`. The signal id is constructed as `${pluginMetadata.pluginId}.${event}` and the resulting `Signal` carries a `pluginId` field. The `SignalMessage` wire envelope and `ServerToClientMessage` `signal` variant gained a `pluginId` field so the frontend can route invalidations without parsing the id.
186
+
187
+ ```ts
188
+ // Before
189
+ export const ANOMALY_STATE_CHANGED = createSignal(
190
+ "anomaly.state_changed",
191
+ z.object({ ... }),
192
+ );
193
+
194
+ // After
195
+ export const ANOMALY_STATE_CHANGED = createSignal({
196
+ pluginMetadata,
197
+ event: "state_changed",
198
+ payloadSchema: z.object({ ... }),
199
+ });
200
+ ```
201
+
202
+ **New plugin field**: `FrontendPlugin.foreignSignals?: Signal<unknown>[]` lets a plugin opt its `[[pluginId]]` cache into invalidation when another plugin's signal fires (e.g. `dependency-frontend` declares `[SYSTEM_STATUS_CHANGED]` because dependency payloads embed system status). Same-plugin signals must NOT be listed — they are always auto-invalidated.
203
+
204
+ **Removed boilerplate**: per-component `useSignal(X, () => refetch())` and `useSignal(X, () => queryClient.invalidateQueries(...))` calls have been removed across `incident-frontend`, `maintenance-frontend`, `healthcheck-frontend`, `slo-frontend`, `dependency-frontend`, `satellite-frontend`, `announcement-frontend`, `notification-frontend`, and `dashboard-frontend`. The `NotificationBell` unread count is now derived directly from the `getUnreadCount` query (auto-invalidated) instead of a local state mirror.
205
+
206
+ **User-visible bug fix**: the system detail page anomaly widget (`SystemAnomalyWidget`) now updates in real-time when anomalies change, with no per-widget signal subscription required. The dashboard status page also stays fresh on `ANOMALY_STATE_CHANGED`, `ANOMALY_BASELINE_UPDATED`, and `ANOMALY_TREND_DETECTED`.
207
+
208
+ UI-state consumers that legitimately need a `useSignal` (the dashboard activity terminal, the queue lag alert, and the rolling-preset date refresh in `useHealthCheckData`) keep their handlers; the auto-invalidator runs alongside them.
209
+
210
+ - Updated dependencies [208ad71]
211
+ - @checkstack/signal-frontend@0.1.0
212
+ - @checkstack/frontend-api@0.4.0
213
+ - @checkstack/maintenance-common@0.5.0
214
+ - @checkstack/dashboard-frontend@0.5.1
215
+ - @checkstack/auth-frontend@0.5.31
216
+ - @checkstack/catalog-common@1.5.3
217
+ - @checkstack/ui@1.6.1
218
+
3
219
  ## 0.5.7
4
220
 
5
221
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/maintenance-frontend",
3
- "version": "0.5.7",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "main": "src/index.tsx",
6
6
  "checkstack": {
@@ -12,14 +12,16 @@
12
12
  "lint:code": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@checkstack/auth-frontend": "0.5.29",
16
- "@checkstack/catalog-common": "1.5.1",
17
- "@checkstack/common": "0.6.5",
18
- "@checkstack/dashboard-frontend": "0.4.6",
19
- "@checkstack/frontend-api": "0.3.10",
20
- "@checkstack/maintenance-common": "0.4.10",
21
- "@checkstack/signal-frontend": "0.0.15",
22
- "@checkstack/ui": "1.5.1",
15
+ "@checkstack/auth-frontend": "0.5.31",
16
+ "@checkstack/catalog-common": "1.5.3",
17
+ "@checkstack/common": "0.7.0",
18
+ "@checkstack/dashboard-frontend": "0.5.1",
19
+ "@checkstack/frontend-api": "0.4.0",
20
+ "@checkstack/maintenance-common": "0.5.0",
21
+ "@checkstack/notification-common": "0.3.0",
22
+ "@checkstack/notification-frontend": "0.2.36",
23
+ "@checkstack/signal-frontend": "0.1.0",
24
+ "@checkstack/ui": "1.6.1",
23
25
  "date-fns": "^4.1.0",
24
26
  "lucide-react": "^0.344.0",
25
27
  "react": "^18.2.0",
@@ -1,12 +1,8 @@
1
1
  import React from "react";
2
2
  import { usePluginClient, type SlotContext } from "@checkstack/frontend-api";
3
- import { useSignal } from "@checkstack/signal-frontend";
4
3
  import { SystemStateBadgesSlot } from "@checkstack/catalog-common";
5
4
  import { MaintenanceApi } from "../api";
6
- import {
7
- MAINTENANCE_UPDATED,
8
- type MaintenanceWithSystems,
9
- } from "@checkstack/maintenance-common";
5
+ import { type MaintenanceWithSystems } from "@checkstack/maintenance-common";
10
6
  import { Badge } from "@checkstack/ui";
11
7
  import { useSystemBadgeDataOptional } from "@checkstack/dashboard-frontend";
12
8
 
@@ -26,20 +22,19 @@ function hasActiveMaintenance(maintenances: MaintenanceWithSystems[]): boolean {
26
22
  * When rendered within SystemBadgeDataProvider, uses bulk-fetched data.
27
23
  * Otherwise, falls back to individual fetch.
28
24
  *
29
- * Listens for realtime updates via signals.
25
+ * Realtime updates arrive via the SignalAutoInvalidator (auto-invalidates
26
+ * `[["maintenance"]]` queries when MAINTENANCE_UPDATED fires).
30
27
  */
31
28
  export const SystemMaintenanceBadge: React.FC<Props> = ({ system }) => {
32
29
  const maintenanceClient = usePluginClient(MaintenanceApi);
33
30
  const badgeData = useSystemBadgeDataOptional();
34
31
 
35
- // Try to get data from provider first
36
32
  const providerData = badgeData?.getSystemBadgeData(system?.id ?? "");
37
33
  const providerHasActive = providerData
38
34
  ? hasActiveMaintenance(providerData.maintenances)
39
35
  : false;
40
36
 
41
- // Query for maintenances if not using provider
42
- const { data: maintenances, refetch } =
37
+ const { data: maintenances } =
43
38
  maintenanceClient.getMaintenancesForSystem.useQuery(
44
39
  { systemId: system?.id ?? "" },
45
40
  { enabled: !badgeData && !!system?.id }
@@ -49,14 +44,6 @@ export const SystemMaintenanceBadge: React.FC<Props> = ({ system }) => {
49
44
  ? hasActiveMaintenance(maintenances)
50
45
  : false;
51
46
 
52
- // Listen for realtime maintenance updates (only in fallback mode)
53
- useSignal(MAINTENANCE_UPDATED, ({ systemIds }) => {
54
- if (!badgeData && system?.id && systemIds.includes(system.id)) {
55
- void refetch();
56
- }
57
- });
58
-
59
- // Use provider data if available, otherwise use local state
60
47
  const hasActive = badgeData ? providerHasActive : localHasActive;
61
48
 
62
49
  if (!hasActive) return;
@@ -1,14 +1,10 @@
1
1
  import React from "react";
2
2
  import { Link } from "react-router-dom";
3
3
  import { usePluginClient, type SlotContext } from "@checkstack/frontend-api";
4
- import { useSignal } from "@checkstack/signal-frontend";
5
4
  import { resolveRoute } from "@checkstack/common";
6
5
  import { SystemDetailsSlot } from "@checkstack/catalog-common";
7
6
  import { MaintenanceApi } from "../api";
8
- import {
9
- maintenanceRoutes,
10
- MAINTENANCE_UPDATED,
11
- } from "@checkstack/maintenance-common";
7
+ import { maintenanceRoutes } from "@checkstack/maintenance-common";
12
8
  import { LoadingSpinner, Button } from "@checkstack/ui";
13
9
  import { Wrench, History } from "lucide-react";
14
10
 
@@ -21,22 +17,12 @@ type Props = SlotContext<typeof SystemDetailsSlot>;
21
17
  export const SystemMaintenancePanel: React.FC<Props> = ({ system }) => {
22
18
  const maintenanceClient = usePluginClient(MaintenanceApi);
23
19
 
24
- // Fetch maintenances with useQuery
25
- const {
26
- data: maintenances = [],
27
- isLoading: loading,
28
- refetch,
29
- } = maintenanceClient.getMaintenancesForSystem.useQuery(
30
- { systemId: system?.id ?? "" },
31
- { enabled: !!system?.id }
32
- );
33
-
34
- // Listen for realtime maintenance updates
35
- useSignal(MAINTENANCE_UPDATED, ({ systemIds }) => {
36
- if (system?.id && systemIds.includes(system.id)) {
37
- void refetch();
38
- }
39
- });
20
+ // Fetch maintenances with useQuery — kept fresh via SignalAutoInvalidator.
21
+ const { data: maintenances = [], isLoading: loading } =
22
+ maintenanceClient.getMaintenancesForSystem.useQuery(
23
+ { systemId: system?.id ?? "" },
24
+ { enabled: !!system?.id }
25
+ );
40
26
 
41
27
  if (loading) {
42
28
  return (