@checkstack/anomaly-common 0.2.0 → 0.3.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,41 @@
1
1
  # @checkstack/anomaly-common
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
9
+ **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.
10
+
11
+ ```ts
12
+ // Before
13
+ export const ANOMALY_STATE_CHANGED = createSignal(
14
+ "anomaly.state_changed",
15
+ z.object({ ... }),
16
+ );
17
+
18
+ // After
19
+ export const ANOMALY_STATE_CHANGED = createSignal({
20
+ pluginMetadata,
21
+ event: "state_changed",
22
+ payloadSchema: z.object({ ... }),
23
+ });
24
+ ```
25
+
26
+ **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.
27
+
28
+ **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.
29
+
30
+ **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`.
31
+
32
+ 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.
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [208ad71]
37
+ - @checkstack/signal-common@0.2.0
38
+
3
39
  ## 0.2.0
4
40
 
5
41
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/anomaly-common",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -8,8 +8,8 @@
8
8
  }
9
9
  },
10
10
  "dependencies": {
11
- "@checkstack/common": "0.6.5",
12
- "@checkstack/signal-common": "0.1.9",
11
+ "@checkstack/common": "0.7.0",
12
+ "@checkstack/signal-common": "0.1.10",
13
13
  "zod": "^4.2.1"
14
14
  },
15
15
  "devDependencies": {
package/src/index.ts CHANGED
@@ -10,33 +10,37 @@ export * from "./plugin-metadata";
10
10
  import { createSignal } from "@checkstack/signal-common";
11
11
  import { z } from "zod";
12
12
  import { AnomalyStateSchema } from "./schema";
13
+ import { pluginMetadata } from "./plugin-metadata";
13
14
 
14
- export const ANOMALY_STATE_CHANGED = createSignal(
15
- "anomaly.state_changed",
16
- z.object({
15
+ export const ANOMALY_STATE_CHANGED = createSignal({
16
+ pluginMetadata,
17
+ event: "state_changed",
18
+ payloadSchema: z.object({
17
19
  systemId: z.string(),
18
20
  anomalyId: z.string(),
19
21
  newState: AnomalyStateSchema,
20
- })
21
- );
22
+ }),
23
+ });
22
24
 
23
- export const ANOMALY_BASELINE_UPDATED = createSignal(
24
- "anomaly.baseline_updated",
25
- z.object({
25
+ export const ANOMALY_BASELINE_UPDATED = createSignal({
26
+ pluginMetadata,
27
+ event: "baseline_updated",
28
+ payloadSchema: z.object({
26
29
  systemId: z.string(),
27
30
  configurationId: z.string(),
28
31
  fieldPath: z.string(),
29
32
  mean: z.number(),
30
33
  stdDev: z.number(),
31
34
  sampleCount: z.number(),
32
- })
33
- );
35
+ }),
36
+ });
34
37
 
35
- export const ANOMALY_TREND_DETECTED = createSignal(
36
- "anomaly.trend_detected",
37
- z.object({
38
+ export const ANOMALY_TREND_DETECTED = createSignal({
39
+ pluginMetadata,
40
+ event: "trend_detected",
41
+ payloadSchema: z.object({
38
42
  systemId: z.string(),
39
43
  anomalyId: z.string(),
40
44
  fieldPath: z.string(),
41
- })
42
- );
45
+ }),
46
+ });