@checkstack/signal-frontend 0.0.16 → 0.1.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.
- package/CHANGELOG.md +138 -0
- package/package.json +5 -4
- package/src/SignalProvider.tsx +34 -1
- package/src/index.ts +10 -2
- package/src/useSignal.ts +25 -1
- package/tsconfig.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,143 @@
|
|
|
1
1
|
# @checkstack/signal-frontend
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 50e5f5f: Runtime plugin system: install + uninstall plugins from npm, GitHub releases
|
|
8
|
+
(including private GitHub Enterprise instances), or tarball uploads at
|
|
9
|
+
runtime, with multi-package bundles, dependency-derived compatibility checks,
|
|
10
|
+
multi-instance coordination via a Postgres artifact store, and
|
|
11
|
+
single-coordinator destructive cleanup.
|
|
12
|
+
|
|
13
|
+
Highlights:
|
|
14
|
+
|
|
15
|
+
- New `PluginSource` discriminated union and `PluginInstaller` /
|
|
16
|
+
`PluginInstallerRegistry` interfaces in `@checkstack/backend-api`. The
|
|
17
|
+
GitHub variant accepts an optional `apiBaseUrl` so deployments backed by
|
|
18
|
+
GitHub Enterprise can install from `https://ghe.example.com/api/v3`
|
|
19
|
+
instead of `api.github.com`.
|
|
20
|
+
- New `installPackageMetadataSchema` (Zod) in `@checkstack/common` validates
|
|
21
|
+
every plugin's `package.json` at install time. Required fields: `name`,
|
|
22
|
+
`version`, `description`, `author`, `license`, `checkstack.type`,
|
|
23
|
+
`checkstack.pluginId`. Optional: `checkstack.bundle`,
|
|
24
|
+
`checkstack.usageInstructions`, `checkstack.allowInstallScripts`.
|
|
25
|
+
- New `pluginManagerContract` in `@checkstack/pluginmanager-common` with
|
|
26
|
+
`list`, `previewInstall`, `install`, `previewUninstall`, `uninstall`, and
|
|
27
|
+
`events` procedures.
|
|
28
|
+
- New `@checkstack/pluginmanager-frontend` admin UI: installed-plugins list
|
|
29
|
+
with per-row uninstall (typed-confirmation modal, schema/configs/cascade
|
|
30
|
+
toggles), install page with NPM / Tarball Upload / GitHub Release tabs
|
|
31
|
+
(Catalog tab disabled — coming soon), and an events page surfacing the
|
|
32
|
+
install/uninstall audit log.
|
|
33
|
+
- New `bunx @checkstack/scripts plugin-pack` CLI for plugin authors —
|
|
34
|
+
per-package mode produces an npm-shaped tarball; `--bundle` mode produces
|
|
35
|
+
an outer tarball containing every sibling declared in
|
|
36
|
+
`package.json#checkstack.bundle`. Published to npm so external authors
|
|
37
|
+
can `bunx` it directly without a workspace checkout.
|
|
38
|
+
- Compatibility derived from `package.json#dependencies` ranges
|
|
39
|
+
(`semver.satisfies` against the platform's loaded `@checkstack/*`
|
|
40
|
+
versions) — no separate `compatibility` field.
|
|
41
|
+
- Multi-instance: originator persists artifacts + `plugins` rows + broadcasts
|
|
42
|
+
install/uninstall; receiving instances do in-process register/unregister
|
|
43
|
+
only. Destructive ops (drop schema, delete plugin_configs, delete
|
|
44
|
+
artifacts, delete `plugins` rows) run exactly once on the originator.
|
|
45
|
+
- Fresh-instance bootstrap: `loadPlugins()` hydrates any
|
|
46
|
+
`is_uninstallable=true` plugin missing from `node_modules` from the
|
|
47
|
+
artifact store before normal Phase 1 register.
|
|
48
|
+
- New schema: `plugin_artifacts` (tarball storage), `plugin_install_events`
|
|
49
|
+
(audit/error log). `plugins` extended with `version`, `metadata`,
|
|
50
|
+
`source`, `bundle_id`, `is_primary`. Local plugin sync now writes
|
|
51
|
+
`version` from each plugin's `package.json` so the admin UI shows real
|
|
52
|
+
versions instead of `—`.
|
|
53
|
+
- Tarball-upload endpoint (`POST /api/pluginmanager/upload-tarball`) for
|
|
54
|
+
the install UI; access-gated by `pluginmanager.plugin.manage`.
|
|
55
|
+
- Plugin Manager menu link added to the user menu (main grid, alongside
|
|
56
|
+
Profile / Notification Settings / etc.).
|
|
57
|
+
|
|
58
|
+
Cross-cutting changes:
|
|
59
|
+
|
|
60
|
+
- Backend request/response logging now flows through `rootLogger` (winston)
|
|
61
|
+
instead of `hono/logger`. 5xx responses include the response body inline
|
|
62
|
+
so swallowed early-return errors are visible in the log.
|
|
63
|
+
- The `/api/:pluginId/*` dispatcher now logs which core service is missing
|
|
64
|
+
or which `pluginId` had no metadata when it 500s.
|
|
65
|
+
- New `registerCorePluginMetadata` on `PluginManager` for core routers
|
|
66
|
+
(like the plugin manager itself) that need their metadata visible to the
|
|
67
|
+
RPC dispatcher without going through the full plugin lifecycle.
|
|
68
|
+
- ESLint: `unicorn/no-null` is now disabled globally. Drizzle distinguishes
|
|
69
|
+
between `null` (writes a real SQL NULL) and `undefined` (skip the column
|
|
70
|
+
on insert), so treating them as interchangeable produced latent bugs at
|
|
71
|
+
the persistence boundary. The bulk of the patch-bumped packages above
|
|
72
|
+
reflect lint-fix touches that landed when this rule was relaxed.
|
|
73
|
+
- Workspace-wide license normalization to `Elastic-2.0` (matches
|
|
74
|
+
`LICENSE.md`). Every `package.json` in the workspace now declares the
|
|
75
|
+
same SPDX identifier; the patch bumps capture this.
|
|
76
|
+
|
|
77
|
+
Plugin packages (every `plugins/*`): added a `pack` npm script
|
|
78
|
+
(`bunx @checkstack/scripts plugin-pack`), mirrored each plugin's
|
|
79
|
+
`pluginId` from `plugin-metadata.ts` into `package.json#checkstack.pluginId`
|
|
80
|
+
so install-time validation passes, stubbed any missing required metadata
|
|
81
|
+
fields (`description`, `author`, `license`), and added
|
|
82
|
+
`checkstack.bundle` to multi-package plugin primaries (telegram, rcon, ssh,
|
|
83
|
+
jira, queue-bullmq, queue-memory, cache-memory).
|
|
84
|
+
|
|
85
|
+
Breaking changes:
|
|
86
|
+
|
|
87
|
+
- The legacy single-method `PluginInstaller` interface (`install(packageName)`)
|
|
88
|
+
is removed. Callers must use `coreServices.pluginInstallerRegistry`.
|
|
89
|
+
- The old `pluginAdminContract` and `createPluginAdminRouter` are removed.
|
|
90
|
+
Replaced by `pluginManagerContract` in `@checkstack/pluginmanager-common`
|
|
91
|
+
and `createPluginManagerRouter` in `core/backend`.
|
|
92
|
+
- `@checkstack/test-utils-backend` no longer exports
|
|
93
|
+
`createMockPluginInstaller` / `MockPluginInstaller` (the legacy interface
|
|
94
|
+
it shimmed is gone).
|
|
95
|
+
|
|
96
|
+
Note: bumps are limited to `minor` (for packages with new public API
|
|
97
|
+
surface) and `patch` (for downstream consumers, license normalization,
|
|
98
|
+
and lint fixes). No `major` bumps despite the `PluginInstaller` removal —
|
|
99
|
+
the legacy interface had no third-party consumers in the wild before this
|
|
100
|
+
runtime plugin system landed, and the contract surface is the same shape
|
|
101
|
+
modulo the rename.
|
|
102
|
+
|
|
103
|
+
- @checkstack/signal-common@0.2.1
|
|
104
|
+
|
|
105
|
+
## 0.1.0
|
|
106
|
+
|
|
107
|
+
### Minor Changes
|
|
108
|
+
|
|
109
|
+
- 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.
|
|
110
|
+
|
|
111
|
+
**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.
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
// Before
|
|
115
|
+
export const ANOMALY_STATE_CHANGED = createSignal(
|
|
116
|
+
"anomaly.state_changed",
|
|
117
|
+
z.object({ ... }),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// After
|
|
121
|
+
export const ANOMALY_STATE_CHANGED = createSignal({
|
|
122
|
+
pluginMetadata,
|
|
123
|
+
event: "state_changed",
|
|
124
|
+
payloadSchema: z.object({ ... }),
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**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.
|
|
129
|
+
|
|
130
|
+
**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.
|
|
131
|
+
|
|
132
|
+
**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`.
|
|
133
|
+
|
|
134
|
+
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.
|
|
135
|
+
|
|
136
|
+
### Patch Changes
|
|
137
|
+
|
|
138
|
+
- Updated dependencies [208ad71]
|
|
139
|
+
- @checkstack/signal-common@0.2.0
|
|
140
|
+
|
|
3
141
|
## 0.0.16
|
|
4
142
|
|
|
5
143
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/signal-frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "Elastic-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"exports": {
|
|
6
7
|
".": {
|
|
@@ -11,16 +12,16 @@
|
|
|
11
12
|
"react": "^18.0.0"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
14
|
-
"@checkstack/signal-common": "0.
|
|
15
|
+
"@checkstack/signal-common": "0.2.0"
|
|
15
16
|
},
|
|
16
17
|
"devDependencies": {
|
|
17
18
|
"@types/react": "^18.0.0",
|
|
18
19
|
"typescript": "^5.7.2",
|
|
19
|
-
"@checkstack/tsconfig": "0.0.
|
|
20
|
+
"@checkstack/tsconfig": "0.0.6",
|
|
20
21
|
"@checkstack/scripts": "0.1.2"
|
|
21
22
|
},
|
|
22
23
|
"scripts": {
|
|
23
|
-
"typecheck": "
|
|
24
|
+
"typecheck": "tsgo -b",
|
|
24
25
|
"lint": "bun run lint:code",
|
|
25
26
|
"lint:code": "eslint . --max-warnings 0"
|
|
26
27
|
},
|
package/src/SignalProvider.tsx
CHANGED
|
@@ -15,11 +15,27 @@ import type {
|
|
|
15
15
|
// CONTEXT TYPES
|
|
16
16
|
// =============================================================================
|
|
17
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Wildcard subscription callback. Fires for every incoming signal message
|
|
20
|
+
* regardless of signalId, with the pluginId already extracted from the wire envelope.
|
|
21
|
+
* Used by the auto-invalidation layer; not intended for component-level use.
|
|
22
|
+
*/
|
|
23
|
+
export type SignalAllCallback = (props: {
|
|
24
|
+
signalId: string;
|
|
25
|
+
pluginId: string;
|
|
26
|
+
payload: unknown;
|
|
27
|
+
}) => void;
|
|
28
|
+
|
|
18
29
|
interface SignalContextValue {
|
|
19
30
|
/** Whether the WebSocket connection is established */
|
|
20
31
|
isConnected: boolean;
|
|
21
|
-
/** Subscribe to a signal. Returns an unsubscribe function. */
|
|
32
|
+
/** Subscribe to a specific signal. Returns an unsubscribe function. */
|
|
22
33
|
subscribe<T>(signal: Signal<T>, callback: (payload: T) => void): () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Subscribe to ALL incoming signals. Returns an unsubscribe function.
|
|
36
|
+
* Used by the auto-invalidation layer to receive every message.
|
|
37
|
+
*/
|
|
38
|
+
subscribeAll(callback: SignalAllCallback): () => void;
|
|
23
39
|
}
|
|
24
40
|
|
|
25
41
|
const SignalContext = createContext<SignalContextValue | undefined>(undefined);
|
|
@@ -58,6 +74,7 @@ export const SignalProvider: React.FC<SignalProviderProps> = ({
|
|
|
58
74
|
const listenersRef = useRef<Map<string, Set<(payload: unknown) => void>>>(
|
|
59
75
|
new Map()
|
|
60
76
|
);
|
|
77
|
+
const allListenersRef = useRef<Set<SignalAllCallback>>(new Set());
|
|
61
78
|
const reconnectTimeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(
|
|
62
79
|
undefined
|
|
63
80
|
);
|
|
@@ -115,6 +132,14 @@ export const SignalProvider: React.FC<SignalProviderProps> = ({
|
|
|
115
132
|
callback(message.payload);
|
|
116
133
|
}
|
|
117
134
|
}
|
|
135
|
+
// Notify wildcard listeners (auto-invalidator etc.)
|
|
136
|
+
for (const callback of allListenersRef.current) {
|
|
137
|
+
callback({
|
|
138
|
+
signalId: message.signalId,
|
|
139
|
+
pluginId: message.pluginId,
|
|
140
|
+
payload: message.payload,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
118
143
|
}
|
|
119
144
|
// Ignore "connected" and "pong" messages
|
|
120
145
|
} catch (error) {
|
|
@@ -154,9 +179,17 @@ export const SignalProvider: React.FC<SignalProviderProps> = ({
|
|
|
154
179
|
[]
|
|
155
180
|
);
|
|
156
181
|
|
|
182
|
+
const subscribeAll = useCallback((callback: SignalAllCallback) => {
|
|
183
|
+
allListenersRef.current.add(callback);
|
|
184
|
+
return () => {
|
|
185
|
+
allListenersRef.current.delete(callback);
|
|
186
|
+
};
|
|
187
|
+
}, []);
|
|
188
|
+
|
|
157
189
|
const value: SignalContextValue = {
|
|
158
190
|
isConnected,
|
|
159
191
|
subscribe,
|
|
192
|
+
subscribeAll,
|
|
160
193
|
};
|
|
161
194
|
|
|
162
195
|
return (
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
// Provider component
|
|
2
|
-
export {
|
|
2
|
+
export {
|
|
3
|
+
SignalProvider,
|
|
4
|
+
useSignalContext,
|
|
5
|
+
type SignalAllCallback,
|
|
6
|
+
} from "./SignalProvider";
|
|
3
7
|
|
|
4
8
|
// Hooks
|
|
5
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
useSignal,
|
|
11
|
+
useSignalConnection,
|
|
12
|
+
useSubscribeAllSignals,
|
|
13
|
+
} from "./useSignal";
|
package/src/useSignal.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import type { Signal } from "@checkstack/signal-common";
|
|
3
|
-
import { useSignalContext } from "./SignalProvider";
|
|
3
|
+
import { useSignalContext, type SignalAllCallback } from "./SignalProvider";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Subscribe to a signal and receive typed payloads.
|
|
@@ -65,3 +65,27 @@ export function useSignalConnection(): { isConnected: boolean } {
|
|
|
65
65
|
const { isConnected } = useSignalContext();
|
|
66
66
|
return { isConnected };
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Subscribe to ALL incoming signals. Used by the auto-invalidation layer.
|
|
71
|
+
*
|
|
72
|
+
* The callback receives `signalId`, `pluginId`, and the raw payload for every
|
|
73
|
+
* signal message that arrives over the WebSocket. Subscriptions are automatically
|
|
74
|
+
* cleaned up on unmount; the latest callback is always used (no stale closures).
|
|
75
|
+
*
|
|
76
|
+
* Component code should prefer the typed `useSignal(signal, ...)` hook over this.
|
|
77
|
+
*/
|
|
78
|
+
export function useSubscribeAllSignals(callback: SignalAllCallback): void {
|
|
79
|
+
const { subscribeAll } = useSignalContext();
|
|
80
|
+
|
|
81
|
+
const callbackRef = useRef(callback);
|
|
82
|
+
callbackRef.current = callback;
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const stableCallback: SignalAllCallback = (props) => {
|
|
86
|
+
callbackRef.current(props);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return subscribeAll(stableCallback);
|
|
90
|
+
}, [subscribeAll]);
|
|
91
|
+
}
|