@checkstack/maintenance-common 0.4.11 → 1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,173 @@
1
1
  # @checkstack/maintenance-common
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 32d52c6: feat: notification target pattern + per-spec subscriptions
8
+
9
+ Replaces the all-or-nothing catalog system/group notification model with a
10
+ platform-level target pattern. Each notification-emitting plugin declares
11
+ _subscription specs_ against typed _target_ objects exported from the
12
+ target's owning plugin (catalog ships `catalogSystemTarget` and
13
+ `catalogGroupTarget`). Notification-backend handles every per-resource
14
+ group lifecycle, parent-edge inheritance, and legacy-subscription seeding
15
+ — plugins never author groupId helpers, lifecycle hooks, or migration
16
+ code again.
17
+
18
+ **Plugin-author surface area is now ~12 lines per emitter:**
19
+
20
+ ```ts
21
+ // <plugin>-common
22
+ const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
23
+ export const fooSystemSubscription = defineSubscription({
24
+ localId: "system",
25
+ target: catalogSystemTarget,
26
+ display: { title: "Foo Alerts", description: "...", iconName: "Bell" },
27
+ });
28
+
29
+ // <plugin>-backend register()
30
+ env.registerSubscriptionSpecs([fooSystemSubscription]);
31
+ // ^ feeds the plugin loader's dependency sorter — each spec's
32
+ // target.ownerPlugin becomes an implicit init-order dep, so this
33
+ // plugin automatically waits for catalog (the target owner) to
34
+ // finish init + afterPluginsReady before its own runs.
35
+
36
+ // <plugin>-backend afterPluginsReady
37
+ await notificationClient.registerSubscriptionSpec(
38
+ specToRegistration(fooSystemSubscription)
39
+ );
40
+ // dispatch
41
+ await notificationClient.notifyForSubscription({
42
+ specId: fooSystemSubscription.specId,
43
+ resourceKeys: [systemId],
44
+ title,
45
+ body,
46
+ importance,
47
+ action,
48
+ collapseKey,
49
+ subjects,
50
+ });
51
+
52
+ // <plugin>-frontend
53
+ createNotificationSubscriptionExtension({ spec: fooSystemSubscription });
54
+ ```
55
+
56
+ **Migrated plugins**: anomaly, incident, maintenance, healthcheck,
57
+ dependency. Each lost its bespoke `notification-groups.ts`,
58
+ `bootstrap*NotificationGroups`, `ensure*Group`, and inheritance walk —
59
+ all of that is now centralized in notification-backend's
60
+ `subscription-engine`.
61
+
62
+ **Plugin loader change** (`@checkstack/backend-api`,
63
+ `@checkstack/backend`): the register-time API gains
64
+ `env.registerSubscriptionSpecs([...specs])`. The dependency sorter
65
+ walks `spec.target.ownerPlugin` for every declared spec and adds the
66
+ target owner as an init-order dependency of the emitting plugin. This
67
+ guarantees that catalog (the owner of the platform's `system` and
68
+ `group` targets) completes init + afterPluginsReady before any
69
+ emitting plugin tries to register its specs against the notification
70
+ service — no string-prefix heuristics, no manual `dependsOnPlugins`
71
+ list, no stub rows. Plugins that fail to declare their specs at
72
+ register time get a clear `Target type X is not registered. Did the
73
+ emitting plugin declare this spec via env.registerSubscriptionSpecs?`
74
+ error from the dispatcher.
75
+
76
+ **Removed** (no backwards compat):
77
+
78
+ - `catalogClient.notifySystemSubscribers` and
79
+ `catalogClient.notifyManySystemSubscribers`
80
+ - `notificationClient.notifyUsers` and `notificationClient.notifyGroups`
81
+ as direct dispatch primitives — replaced by spec-bound
82
+ `notifyForSubscription`
83
+ - catalog's `bootstrapNotificationGroups` (replaced by
84
+ `bootstrapNotificationTargets`)
85
+
86
+ **Enforcement**: the dispatcher rejects calls referencing unregistered
87
+ specIds, specs owned by other plugins, or resourceKeys that haven't been
88
+ pushed via `upsertNotificationResource`. Display metadata for any
89
+ groupId is recoverable via the spec registry, so audit lists render
90
+ correct labels even when an emitter's frontend isn't loaded.
91
+
92
+ **Per-field anomaly mute** keeps working — it now lives inside the
93
+ generic SubscriptionRow's optional `SubControls` panel
94
+ (`AnomalyFieldMuteList`), exposed through the catalog system detail
95
+ page's notifications card.
96
+
97
+ The catalog system detail page renders a "Notifications" card hosting
98
+ `SystemNotificationSubscriptionsSlot`. The matching group surface is
99
+ not yet rendered — group-level subscriptions are wired end-to-end on
100
+ the backend; a follow-up will add the host UI.
101
+
102
+ **Migration of existing subscribers**: target types declare a
103
+ `legacyGroupIdTemplate`; on first registration of each spec,
104
+ notification-backend reads subscribers from the legacy
105
+ `catalog.system.<id>` / `catalog.group.<id>` groups and seeds the new
106
+ spec groups exactly once per (spec × resource) pair, tracked in
107
+ `subscription_migrations`. Anomaly stays opt-in (its target also
108
+ declares the template, but the user-explicit nature of the original
109
+ opt-in flow means the seeding produces the same set of subscribers
110
+ they already had).
111
+
112
+ ### Minor Changes
113
+
114
+ - 32d52c6: Bulk notifications affecting multiple systems and collapse lifecycle events into a single card.
115
+
116
+ Notifications now carry an optional `subjects` array (the entities they affect) and an optional `collapseKey` (so related notifications collapse into one row per recipient). Incidents, maintenances, anomalies, healthchecks, and dependency-impact events route through these new fields, so an incident affecting three systems produces one in-app notification + one external send per subscriber instead of three. Lifecycle updates for the same entity (created → updated → resolved) also collapse, with an expandable "+N updates" timeline.
117
+
118
+ Subject kinds are namespaced as `<pluginId>.<localKind>` and built via type-safe helpers exported from each domain's common package (`createSystemSubject`, `incidentCollapseKey`, etc.). The frontend kind registry (`registerSubjectKind`) lets plugins bind icon + label for their kinds; unknown kinds fall back to a generic chip.
119
+
120
+ All notification strategies (SMTP, Slack, Discord, Teams, Telegram, Pushover, Gotify, Webex, Backstage) render the affected subjects natively in their format (HTML cards, Slack blocks, Discord embed fields, adaptive cards, markdown lists, etc.).
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies [32d52c6]
125
+ - Updated dependencies [32d52c6]
126
+ - Updated dependencies [32d52c6]
127
+ - Updated dependencies [32d52c6]
128
+ - Updated dependencies [32d52c6]
129
+ - Updated dependencies [32d52c6]
130
+ - @checkstack/notification-common@1.0.0
131
+ - @checkstack/catalog-common@2.0.0
132
+ - @checkstack/frontend-api@0.4.1
133
+
134
+ ## 0.5.0
135
+
136
+ ### Minor Changes
137
+
138
+ - 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.
139
+
140
+ **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.
141
+
142
+ ```ts
143
+ // Before
144
+ export const ANOMALY_STATE_CHANGED = createSignal(
145
+ "anomaly.state_changed",
146
+ z.object({ ... }),
147
+ );
148
+
149
+ // After
150
+ export const ANOMALY_STATE_CHANGED = createSignal({
151
+ pluginMetadata,
152
+ event: "state_changed",
153
+ payloadSchema: z.object({ ... }),
154
+ });
155
+ ```
156
+
157
+ **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.
158
+
159
+ **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.
160
+
161
+ **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`.
162
+
163
+ 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.
164
+
165
+ ### Patch Changes
166
+
167
+ - Updated dependencies [208ad71]
168
+ - @checkstack/signal-common@0.2.0
169
+ - @checkstack/frontend-api@0.4.0
170
+
3
171
  ## 0.4.11
4
172
 
5
173
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/maintenance-common",
3
- "version": "0.4.11",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -8,9 +8,11 @@
8
8
  }
9
9
  },
10
10
  "dependencies": {
11
- "@checkstack/common": "0.6.5",
12
- "@checkstack/frontend-api": "0.3.10",
13
- "@checkstack/signal-common": "0.1.9",
11
+ "@checkstack/common": "0.7.0",
12
+ "@checkstack/catalog-common": "1.5.3",
13
+ "@checkstack/frontend-api": "0.4.0",
14
+ "@checkstack/notification-common": "0.3.0",
15
+ "@checkstack/signal-common": "0.2.0",
14
16
  "@orpc/contract": "^1.13.14",
15
17
  "zod": "^4.2.1"
16
18
  },
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@ export {
24
24
  } from "./schemas";
25
25
  export { MaintenanceDetailsSlot, MaintenanceStatusSlot } from "./slots";
26
26
  export * from "./plugin-metadata";
27
+ export * from "./notifications";
27
28
  export { maintenanceRoutes } from "./routes";
28
29
 
29
30
  // =============================================================================
@@ -32,16 +33,18 @@ export { maintenanceRoutes } from "./routes";
32
33
 
33
34
  import { createSignal } from "@checkstack/signal-common";
34
35
  import { z } from "zod";
36
+ import { pluginMetadata } from "./plugin-metadata";
35
37
 
36
38
  /**
37
39
  * Broadcast when a maintenance is created, updated, or closed.
38
40
  * Frontend components listening to this signal can refetch state for affected systems.
39
41
  */
40
- export const MAINTENANCE_UPDATED = createSignal(
41
- "maintenance.updated",
42
- z.object({
42
+ export const MAINTENANCE_UPDATED = createSignal({
43
+ pluginMetadata,
44
+ event: "updated",
45
+ payloadSchema: z.object({
43
46
  maintenanceId: z.string(),
44
47
  systemIds: z.array(z.string()),
45
48
  action: z.enum(["created", "updated", "closed"]),
46
- })
47
- );
49
+ }),
50
+ });
@@ -0,0 +1,36 @@
1
+ import {
2
+ createCollapseKeyBuilder,
3
+ createSubscriptionFactory,
4
+ } from "@checkstack/notification-common";
5
+ import {
6
+ catalogSystemTarget,
7
+ catalogGroupTarget,
8
+ } from "@checkstack/catalog-common";
9
+ import { pluginMetadata } from "./plugin-metadata";
10
+
11
+ export const maintenanceCollapseKey = createCollapseKeyBuilder(
12
+ pluginMetadata,
13
+ "maintenance",
14
+ );
15
+
16
+ const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
17
+
18
+ export const maintenanceSystemSubscription = defineSubscription({
19
+ localId: "system",
20
+ target: catalogSystemTarget,
21
+ display: {
22
+ title: "Maintenance",
23
+ description: "Maintenance windows scheduled and updated for this system.",
24
+ iconName: "Wrench",
25
+ },
26
+ });
27
+
28
+ export const maintenanceGroupSubscription = defineSubscription({
29
+ localId: "group",
30
+ target: catalogGroupTarget,
31
+ display: {
32
+ title: "Maintenance",
33
+ description: "Maintenance windows for any system in this group.",
34
+ iconName: "Wrench",
35
+ },
36
+ });