@checkstack/dependency-frontend 0.3.2 → 0.3.4

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,61 @@
1
1
  # @checkstack/dependency-frontend
2
2
 
3
+ ## 0.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [32d52c6]
8
+ - Updated dependencies [32d52c6]
9
+ - Updated dependencies [32d52c6]
10
+ - Updated dependencies [32d52c6]
11
+ - Updated dependencies [32d52c6]
12
+ - @checkstack/catalog-common@2.0.0
13
+ - @checkstack/healthcheck-common@1.0.0
14
+ - @checkstack/dependency-common@1.0.0
15
+ - @checkstack/dashboard-frontend@0.6.0
16
+ - @checkstack/frontend-api@0.4.1
17
+ - @checkstack/ui@1.7.0
18
+
19
+ ## 0.3.3
20
+
21
+ ### Patch Changes
22
+
23
+ - 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.
24
+
25
+ **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.
26
+
27
+ ```ts
28
+ // Before
29
+ export const ANOMALY_STATE_CHANGED = createSignal(
30
+ "anomaly.state_changed",
31
+ z.object({ ... }),
32
+ );
33
+
34
+ // After
35
+ export const ANOMALY_STATE_CHANGED = createSignal({
36
+ pluginMetadata,
37
+ event: "state_changed",
38
+ payloadSchema: z.object({ ... }),
39
+ });
40
+ ```
41
+
42
+ **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.
43
+
44
+ **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.
45
+
46
+ **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`.
47
+
48
+ 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.
49
+
50
+ - Updated dependencies [208ad71]
51
+ - @checkstack/signal-frontend@0.1.0
52
+ - @checkstack/frontend-api@0.4.0
53
+ - @checkstack/dependency-common@0.3.0
54
+ - @checkstack/healthcheck-common@0.13.0
55
+ - @checkstack/dashboard-frontend@0.5.1
56
+ - @checkstack/catalog-common@1.5.3
57
+ - @checkstack/ui@1.6.1
58
+
3
59
  ## 0.3.2
4
60
 
5
61
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/dependency-frontend",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "type": "module",
5
5
  "main": "src/index.tsx",
6
6
  "checkstack": {
@@ -12,14 +12,14 @@
12
12
  "lint:code": "eslint . --max-warnings 0"
13
13
  },
14
14
  "dependencies": {
15
- "@checkstack/catalog-common": "1.5.1",
16
- "@checkstack/common": "0.6.5",
17
- "@checkstack/dashboard-frontend": "0.4.6",
18
- "@checkstack/dependency-common": "0.2.2",
19
- "@checkstack/frontend-api": "0.3.10",
20
- "@checkstack/healthcheck-common": "0.11.0",
21
- "@checkstack/signal-frontend": "0.0.15",
22
- "@checkstack/ui": "1.5.1",
15
+ "@checkstack/catalog-common": "1.5.3",
16
+ "@checkstack/common": "0.7.0",
17
+ "@checkstack/dashboard-frontend": "0.5.1",
18
+ "@checkstack/dependency-common": "0.3.0",
19
+ "@checkstack/frontend-api": "0.4.0",
20
+ "@checkstack/healthcheck-common": "0.13.0",
21
+ "@checkstack/signal-frontend": "0.1.0",
22
+ "@checkstack/ui": "1.6.1",
23
23
  "@xyflow/react": "^12.10.2",
24
24
  "lucide-react": "^0.344.0",
25
25
  "react": "^18.2.0",
@@ -1,11 +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 { SystemDetailsTopSlot } from "@checkstack/catalog-common";
5
4
  import {
6
5
  DependencyApi,
7
- DEPENDENCY_CHANGED,
8
- DEPENDENCY_WARNINGS_CHANGED,
9
6
  type DerivedState,
10
7
  type AffectedUpstream,
11
8
  } from "@checkstack/dependency-common";
@@ -79,23 +76,11 @@ function getImpactBadge(impactType: string): React.ReactNode {
79
76
  export const DependencyAlert: React.FC<Props> = ({ system }) => {
80
77
  const depClient = usePluginClient(DependencyApi);
81
78
 
82
- const { data, refetch } = depClient.getWarningsForSystem.useQuery(
79
+ const { data } = depClient.getWarningsForSystem.useQuery(
83
80
  { systemId: system?.id ?? "" },
84
81
  { enabled: !!system?.id },
85
82
  );
86
83
 
87
- // Listen for dependency graph changes
88
- useSignal(DEPENDENCY_CHANGED, () => {
89
- void refetch();
90
- });
91
-
92
- // Listen for warning re-evaluations
93
- useSignal(DEPENDENCY_WARNINGS_CHANGED, ({ affectedSystemIds }) => {
94
- if (system?.id && affectedSystemIds.includes(system.id)) {
95
- void refetch();
96
- }
97
- });
98
-
99
84
  if (!data || data.affectedUpstreams.length === 0) return;
100
85
 
101
86
  const style = getAlertStyle(data.derivedState);
@@ -1,11 +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 {
6
5
  DependencyApi,
7
- DEPENDENCY_CHANGED,
8
- DEPENDENCY_WARNINGS_CHANGED,
9
6
  type DerivedState,
10
7
  } from "@checkstack/dependency-common";
11
8
  import { Badge } from "@checkstack/ui";
@@ -46,28 +43,18 @@ function getBadgeLabel(state: DerivedState): string {
46
43
  * Displays a dependency warning badge for a system on the dashboard.
47
44
  * Shows nothing if no upstream systems are affected.
48
45
  *
49
- * Listens for realtime updates via signals.
46
+ * Realtime updates arrive via SignalAutoInvalidator on `[["dependency"]]`,
47
+ * including foreign-signal invalidation on SYSTEM_STATUS_CHANGED (declared in
48
+ * the dependency plugin's `foreignSignals`).
50
49
  */
51
50
  export const DependencyBadge: React.FC<Props> = ({ system }) => {
52
51
  const depClient = usePluginClient(DependencyApi);
53
52
 
54
- const { data, refetch } = depClient.getWarningsForSystem.useQuery(
53
+ const { data } = depClient.getWarningsForSystem.useQuery(
55
54
  { systemId: system?.id ?? "" },
56
55
  { enabled: !!system?.id },
57
56
  );
58
57
 
59
- // Listen for dependency changes
60
- useSignal(DEPENDENCY_CHANGED, () => {
61
- void refetch();
62
- });
63
-
64
- // Listen for warning re-evaluations
65
- useSignal(DEPENDENCY_WARNINGS_CHANGED, ({ affectedSystemIds }) => {
66
- if (system?.id && affectedSystemIds.includes(system.id)) {
67
- void refetch();
68
- }
69
- });
70
-
71
58
  if (!data) return;
72
59
 
73
60
  return (
@@ -4,11 +4,9 @@ import {
4
4
  usePluginClient,
5
5
  type SlotContext,
6
6
  } from "@checkstack/frontend-api";
7
- import { useSignal } from "@checkstack/signal-frontend";
8
7
  import { SystemEditorSlot } from "@checkstack/catalog-common";
9
8
  import {
10
9
  DependencyApi,
11
- DEPENDENCY_CHANGED,
12
10
  dependencyRoutes,
13
11
  type Dependency,
14
12
  type ImpactType,
@@ -91,11 +89,6 @@ export const DependencyEditor: React.FC<Props> = ({ systemId }) => {
91
89
  return map;
92
90
  }, [systemsData]);
93
91
 
94
- // Listen for realtime changes
95
- useSignal(DEPENDENCY_CHANGED, () => {
96
- void refetchDeps();
97
- });
98
-
99
92
  const createMutation = depClient.createDependency.useMutation({
100
93
  onSuccess: () => {
101
94
  setIsAdding(false);
@@ -15,13 +15,10 @@ import {
15
15
  import "@xyflow/react/dist/style.css";
16
16
 
17
17
  import { usePluginClient, wrapInSuspense } from "@checkstack/frontend-api";
18
- import { useSignal } from "@checkstack/signal-frontend";
19
18
  import { CatalogApi } from "@checkstack/catalog-common";
20
- import { HealthCheckApi, SYSTEM_STATUS_CHANGED } from "@checkstack/healthcheck-common";
19
+ import { HealthCheckApi } from "@checkstack/healthcheck-common";
21
20
  import {
22
21
  DependencyApi,
23
- DEPENDENCY_CHANGED,
24
- DEPENDENCY_WARNINGS_CHANGED,
25
22
  type Dependency,
26
23
  type NodePosition,
27
24
  } from "@checkstack/dependency-common";
@@ -137,12 +134,12 @@ function DependencyMapContent() {
137
134
  { enabled: systemIds.length > 0 },
138
135
  );
139
136
 
140
- // Fetch real health statuses for all systems
141
- const { data: healthData, refetch: refetchHealth } =
142
- healthCheckClient.getBulkSystemHealthStatus.useQuery(
143
- { systemIds },
144
- { enabled: systemIds.length > 0 },
145
- );
137
+ // Fetch real health statuses for all systems — kept fresh via SignalAutoInvalidator
138
+ // (foreignSignals declares SYSTEM_STATUS_CHANGED on the dependency plugin).
139
+ const { data: healthData } = healthCheckClient.getBulkSystemHealthStatus.useQuery(
140
+ { systemIds },
141
+ { enabled: systemIds.length > 0 },
142
+ );
146
143
 
147
144
  // Save positions mutation
148
145
  const saveMutation = depClient.saveNodePositions.useMutation({
@@ -381,20 +378,6 @@ function DependencyMapContent() {
381
378
  savePositions({ positions });
382
379
  }, [savePositions]);
383
380
 
384
- // Listen for realtime dependency changes
385
- useSignal(DEPENDENCY_CHANGED, () => {
386
- void refetchDeps();
387
- });
388
-
389
- useSignal(DEPENDENCY_WARNINGS_CHANGED, () => {
390
- void refetchWarnings();
391
- });
392
-
393
- useSignal(SYSTEM_STATUS_CHANGED, () => {
394
- void refetchHealth();
395
- void refetchWarnings();
396
- });
397
-
398
381
  // Cleanup timeout on unmount
399
382
  useEffect(() => {
400
383
  return () => {
package/src/index.tsx CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  dependencyRoutes,
9
9
  dependencyAccess,
10
10
  } from "@checkstack/dependency-common";
11
+ import { SYSTEM_STATUS_CHANGED } from "@checkstack/healthcheck-common";
11
12
  import {
12
13
  SystemDetailsTopSlot,
13
14
  SystemStateBadgesSlot,
@@ -21,6 +22,10 @@ import { DependencyMenuItems } from "./components/DependencyMenuItems";
21
22
 
22
23
  export default createFrontendPlugin({
23
24
  metadata: pluginMetadata,
25
+ // Dependency queries embed system health, so a system status change must
26
+ // also invalidate this plugin's cache. Same-plugin signals (DEPENDENCY_*)
27
+ // are auto-invalidated and must NOT be listed here.
28
+ foreignSignals: [SYSTEM_STATUS_CHANGED],
24
29
  routes: [
25
30
  {
26
31
  route: dependencyRoutes.routes.map,