@checkstack/catalog-common 1.5.3 → 2.0.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 CHANGED
@@ -1,5 +1,291 @@
1
1
  # @checkstack/catalog-common
2
2
 
3
+ ## 2.0.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
+ - Updated dependencies [50e5f5f]
104
+ - @checkstack/auth-common@0.6.5
105
+ - @checkstack/common@0.8.0
106
+ - @checkstack/frontend-api@0.4.2
107
+ - @checkstack/notification-common@1.0.1
108
+
109
+ ## 2.0.0
110
+
111
+ ### Major Changes
112
+
113
+ - 32d52c6: feat: notification target pattern + per-spec subscriptions
114
+
115
+ Replaces the all-or-nothing catalog system/group notification model with a
116
+ platform-level target pattern. Each notification-emitting plugin declares
117
+ _subscription specs_ against typed _target_ objects exported from the
118
+ target's owning plugin (catalog ships `catalogSystemTarget` and
119
+ `catalogGroupTarget`). Notification-backend handles every per-resource
120
+ group lifecycle, parent-edge inheritance, and legacy-subscription seeding
121
+ — plugins never author groupId helpers, lifecycle hooks, or migration
122
+ code again.
123
+
124
+ **Plugin-author surface area is now ~12 lines per emitter:**
125
+
126
+ ```ts
127
+ // <plugin>-common
128
+ const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
129
+ export const fooSystemSubscription = defineSubscription({
130
+ localId: "system",
131
+ target: catalogSystemTarget,
132
+ display: { title: "Foo Alerts", description: "...", iconName: "Bell" },
133
+ });
134
+
135
+ // <plugin>-backend register()
136
+ env.registerSubscriptionSpecs([fooSystemSubscription]);
137
+ // ^ feeds the plugin loader's dependency sorter — each spec's
138
+ // target.ownerPlugin becomes an implicit init-order dep, so this
139
+ // plugin automatically waits for catalog (the target owner) to
140
+ // finish init + afterPluginsReady before its own runs.
141
+
142
+ // <plugin>-backend afterPluginsReady
143
+ await notificationClient.registerSubscriptionSpec(
144
+ specToRegistration(fooSystemSubscription)
145
+ );
146
+ // dispatch
147
+ await notificationClient.notifyForSubscription({
148
+ specId: fooSystemSubscription.specId,
149
+ resourceKeys: [systemId],
150
+ title,
151
+ body,
152
+ importance,
153
+ action,
154
+ collapseKey,
155
+ subjects,
156
+ });
157
+
158
+ // <plugin>-frontend
159
+ createNotificationSubscriptionExtension({ spec: fooSystemSubscription });
160
+ ```
161
+
162
+ **Migrated plugins**: anomaly, incident, maintenance, healthcheck,
163
+ dependency. Each lost its bespoke `notification-groups.ts`,
164
+ `bootstrap*NotificationGroups`, `ensure*Group`, and inheritance walk —
165
+ all of that is now centralized in notification-backend's
166
+ `subscription-engine`.
167
+
168
+ **Plugin loader change** (`@checkstack/backend-api`,
169
+ `@checkstack/backend`): the register-time API gains
170
+ `env.registerSubscriptionSpecs([...specs])`. The dependency sorter
171
+ walks `spec.target.ownerPlugin` for every declared spec and adds the
172
+ target owner as an init-order dependency of the emitting plugin. This
173
+ guarantees that catalog (the owner of the platform's `system` and
174
+ `group` targets) completes init + afterPluginsReady before any
175
+ emitting plugin tries to register its specs against the notification
176
+ service — no string-prefix heuristics, no manual `dependsOnPlugins`
177
+ list, no stub rows. Plugins that fail to declare their specs at
178
+ register time get a clear `Target type X is not registered. Did the
179
+ emitting plugin declare this spec via env.registerSubscriptionSpecs?`
180
+ error from the dispatcher.
181
+
182
+ **Removed** (no backwards compat):
183
+
184
+ - `catalogClient.notifySystemSubscribers` and
185
+ `catalogClient.notifyManySystemSubscribers`
186
+ - `notificationClient.notifyUsers` and `notificationClient.notifyGroups`
187
+ as direct dispatch primitives — replaced by spec-bound
188
+ `notifyForSubscription`
189
+ - catalog's `bootstrapNotificationGroups` (replaced by
190
+ `bootstrapNotificationTargets`)
191
+
192
+ **Enforcement**: the dispatcher rejects calls referencing unregistered
193
+ specIds, specs owned by other plugins, or resourceKeys that haven't been
194
+ pushed via `upsertNotificationResource`. Display metadata for any
195
+ groupId is recoverable via the spec registry, so audit lists render
196
+ correct labels even when an emitter's frontend isn't loaded.
197
+
198
+ **Per-field anomaly mute** keeps working — it now lives inside the
199
+ generic SubscriptionRow's optional `SubControls` panel
200
+ (`AnomalyFieldMuteList`), exposed through the catalog system detail
201
+ page's notifications card.
202
+
203
+ The catalog system detail page renders a "Notifications" card hosting
204
+ `SystemNotificationSubscriptionsSlot`. The matching group surface is
205
+ not yet rendered — group-level subscriptions are wired end-to-end on
206
+ the backend; a follow-up will add the host UI.
207
+
208
+ **Migration of existing subscribers**: target types declare a
209
+ `legacyGroupIdTemplate`; on first registration of each spec,
210
+ notification-backend reads subscribers from the legacy
211
+ `catalog.system.<id>` / `catalog.group.<id>` groups and seeds the new
212
+ spec groups exactly once per (spec × resource) pair, tracked in
213
+ `subscription_migrations`. Anomaly stays opt-in (its target also
214
+ declares the template, but the user-explicit nature of the original
215
+ opt-in flow means the seeding produces the same set of subscribers
216
+ they already had).
217
+
218
+ ### Minor Changes
219
+
220
+ - 32d52c6: Bulk notifications affecting multiple systems and collapse lifecycle events into a single card.
221
+
222
+ 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.
223
+
224
+ 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.
225
+
226
+ 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.).
227
+
228
+ - 32d52c6: feat: unified notification-subscription manager dialog driven by spec registry
229
+
230
+ Replaces the bell-toggle UX (which only managed a single legacy
231
+ catalog group) with a modal that lists every notification type
232
+ registered against a target — system or group — and exposes both
233
+ per-type toggles and a bulk "Subscribe to all / Unsubscribe from all"
234
+ action. Both surfaces (system detail page header bell, dashboard group
235
+ header bell) now open the same `NotificationSubscriptionsManager`
236
+ component.
237
+
238
+ **Key change vs. the prior slot-based approach**: rows are now driven
239
+ by `notificationClient.listSubscriptionSpecs` — the backend's spec
240
+ registry is the single source of truth. Previously, a row only
241
+ appeared if a frontend plugin had remembered to register a
242
+ `createNotificationSubscriptionExtension`; this caused silent drift
243
+ (healthcheck and dependency registered backend specs without frontend
244
+ extensions, so the dialog counted them but never rendered rows). Now,
245
+ every spec the platform knows about renders a row using the spec's
246
+ `display` metadata (title, description, iconName resolved via
247
+ `DynamicIcon`).
248
+
249
+ **Sub-controls registry** (`@checkstack/notification-frontend`):
250
+ plugins that want sub-granularity (anomaly's per-field mute list,
251
+ future severity / channel filters) call
252
+ `registerSubscriptionSubControls(spec, Component)` at module load —
253
+ the manager looks the component up by `specId` when expanding a row.
254
+
255
+ **Removed (no compat)**:
256
+
257
+ - `createNotificationSubscriptionExtension` (replaced by the
258
+ spec-driven manager + the SubControls registry)
259
+ - `target.slot` field on `NotificationTarget` and the
260
+ `NotificationTargetInput.slot` parameter on
261
+ `defineNotificationTarget`
262
+ - `SystemNotificationSubscriptionsSlot` and
263
+ `GroupNotificationSubscriptionsSlot` from `@checkstack/catalog-common`
264
+ - `SystemNotificationsCard` from the system detail page's main column
265
+ - `SubscribeButton` wiring on dashboard group cards and the system
266
+ detail page header
267
+
268
+ **Migrated frontends**: anomaly (now registers `AnomalyFieldMuteList`
269
+ via the SubControls registry), incident, maintenance — all dropped
270
+ their `createNotificationSubscriptionExtension` calls. healthcheck and
271
+ dependency now show up automatically via the spec registry — no
272
+ frontend changes needed for them to render.
273
+
274
+ The trigger button reflects aggregate state — filled bell when at
275
+ least one spec is subscribed for the resource, ghost bell when none.
276
+
277
+ ### Patch Changes
278
+
279
+ - Updated dependencies [32d52c6]
280
+ - Updated dependencies [32d52c6]
281
+ - Updated dependencies [32d52c6]
282
+ - Updated dependencies [32d52c6]
283
+ - Updated dependencies [32d52c6]
284
+ - Updated dependencies [32d52c6]
285
+ - @checkstack/notification-common@1.0.0
286
+ - @checkstack/frontend-api@0.4.1
287
+ - @checkstack/auth-common@0.6.4
288
+
3
289
  ## 1.5.3
4
290
 
5
291
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@checkstack/catalog-common",
3
- "version": "1.5.3",
3
+ "version": "2.0.1",
4
+ "license": "Elastic-2.0",
4
5
  "type": "module",
5
6
  "exports": {
6
7
  ".": {
@@ -9,18 +10,19 @@
9
10
  },
10
11
  "dependencies": {
11
12
  "@checkstack/common": "0.7.0",
12
- "@checkstack/auth-common": "0.6.3",
13
- "@checkstack/frontend-api": "0.3.11",
13
+ "@checkstack/auth-common": "0.6.4",
14
+ "@checkstack/frontend-api": "0.4.1",
15
+ "@checkstack/notification-common": "1.0.0",
14
16
  "@orpc/contract": "^1.13.14",
15
17
  "zod": "^4.2.1"
16
18
  },
17
19
  "devDependencies": {
18
20
  "typescript": "^5.7.2",
19
- "@checkstack/tsconfig": "0.0.5",
21
+ "@checkstack/tsconfig": "0.0.6",
20
22
  "@checkstack/scripts": "0.1.2"
21
23
  },
22
24
  "scripts": {
23
- "typecheck": "tsc --noEmit",
25
+ "typecheck": "tsgo -b",
24
26
  "lint": "bun run lint:code",
25
27
  "lint:code": "eslint . --max-warnings 0"
26
28
  },
package/src/index.ts CHANGED
@@ -3,4 +3,5 @@ export * from "./rpc-contract";
3
3
  export * from "./types";
4
4
  export * from "./slots";
5
5
  export * from "./plugin-metadata";
6
+ export * from "./notifications";
6
7
  export { catalogRoutes } from "./routes";
@@ -0,0 +1,71 @@
1
+ import {
2
+ createSubjectKindBuilder,
3
+ defineNotificationTarget,
4
+ } from "@checkstack/notification-common";
5
+ import { pluginMetadata } from "./plugin-metadata";
6
+
7
+ /**
8
+ * Builders for the catalog plugin's notification subject kinds. Use these
9
+ * instead of constructing `NotificationSubject` literals so the kind
10
+ * namespace stays in sync with the plugin id.
11
+ */
12
+ export const createSystemSubject = createSubjectKindBuilder(
13
+ pluginMetadata,
14
+ "system",
15
+ );
16
+
17
+ export const createGroupSubject = createSubjectKindBuilder(
18
+ pluginMetadata,
19
+ "group",
20
+ );
21
+
22
+ // ─── Notification targets ────────────────────────────────────────────────────
23
+ // Catalog owns the platform's "system" and "group" target types. Emitting
24
+ // plugins (anomaly, incident, maintenance, healthcheck, ...) reference
25
+ // these objects directly when defining their subscription specs — no
26
+ // strings, no per-plugin lifecycle code.
27
+
28
+ export interface CatalogSystemResource {
29
+ systemId: string;
30
+ systemName: string;
31
+ }
32
+
33
+ export interface CatalogGroupResource {
34
+ groupId: string;
35
+ groupName: string;
36
+ }
37
+
38
+ /**
39
+ * The "system" target type. Resources are the entries of catalog's
40
+ * `systems` table; the catalog backend pushes them to notification-
41
+ * backend whenever a system is created, renamed, or deleted, and
42
+ * declares each system's parent catalog groups.
43
+ *
44
+ * `legacy.legacyGroupIdTemplate` covers users who were already
45
+ * subscribed to the pre-pattern `catalog.system.<id>` group — the
46
+ * notification backend seeds new spec groups from those subscribers
47
+ * exactly once per (spec × resource) pair.
48
+ */
49
+ export const catalogSystemTarget = defineNotificationTarget<CatalogSystemResource>({
50
+ pluginMetadata,
51
+ localId: "system",
52
+ resourceKind: "system",
53
+ keyOf: ({ systemId }) => systemId,
54
+ labelOf: ({ systemName }) => systemName,
55
+ parents: { targetTypeId: `${pluginMetadata.pluginId}.group` },
56
+ legacy: { legacyGroupIdTemplate: "catalog.system.{resourceKey}" },
57
+ });
58
+
59
+ /**
60
+ * The "group" target type. Catalog groups don't currently have parent
61
+ * resources; emitting plugins targeting groups deliver only to direct
62
+ * subscribers of the group.
63
+ */
64
+ export const catalogGroupTarget = defineNotificationTarget<CatalogGroupResource>({
65
+ pluginMetadata,
66
+ localId: "group",
67
+ resourceKind: "group",
68
+ keyOf: ({ groupId }) => groupId,
69
+ labelOf: ({ groupName }) => groupName,
70
+ legacy: { legacyGroupIdTemplate: "catalog.group.{resourceKey}" },
71
+ });
@@ -83,6 +83,21 @@ export const catalogContract = {
83
83
  access: [catalogAccess.group.read],
84
84
  }).output(z.array(GroupSchema)),
85
85
 
86
+ /**
87
+ * Returns the catalog groups a system belongs to. Used by host plugins
88
+ * (catalog) and emitting plugins (e.g. anomaly) to walk parent
89
+ * subscriptions and surface inheritance hints. Server-side join — no
90
+ * client-side filtering of `getGroups()` needed.
91
+ */
92
+ getSystemGroups: proc({
93
+ operationType: "query",
94
+ userType: "public",
95
+ access: [catalogAccess.system.read],
96
+ instanceAccess: { idParam: "systemId" },
97
+ })
98
+ .input(z.object({ systemId: z.string() }))
99
+ .output(z.array(GroupSchema)),
100
+
86
101
  // ==========================================================================
87
102
  // SYSTEM MANAGEMENT (userType: "authenticated" with manage access)
88
103
  // ==========================================================================
@@ -229,44 +244,6 @@ export const catalogContract = {
229
244
  // SERVICE INTERFACE (userType: "service" - backend-to-backend only)
230
245
  // ==========================================================================
231
246
 
232
- /**
233
- * Notify all users subscribed to a system (and optionally its groups).
234
- * This is used by other plugins (e.g., maintenance) to send notifications
235
- * to system subscribers without needing direct access to the notification service.
236
- *
237
- * Deduplication: If includeGroupSubscribers is true, subscribers are
238
- * deduplicated so users subscribed to both the system AND its groups
239
- * receive only one notification.
240
- */
241
- notifySystemSubscribers: proc({
242
- operationType: "mutation",
243
- userType: "service",
244
- access: [], // Service-to-service, no access rules needed
245
- })
246
- .input(
247
- z.object({
248
- systemId: z
249
- .string()
250
- .describe("The system ID to notify subscribers for"),
251
- title: z.string().describe("Notification title"),
252
- body: z.string().describe("Notification body (supports markdown)"),
253
- importance: z.enum(["info", "warning", "critical"]).optional(),
254
- action: z
255
- .object({
256
- label: z.string(),
257
- url: z.string(),
258
- })
259
- .optional(),
260
- includeGroupSubscribers: z
261
- .boolean()
262
- .optional()
263
- .describe(
264
- "If true, also notify subscribers of groups that contain this system",
265
- ),
266
- }),
267
- )
268
- .output(z.object({ notifiedCount: z.number() })),
269
-
270
247
  /**
271
248
  * Get the catalog group IDs that contain a specific system.
272
249
  * Returns raw group IDs (not namespaced with notification prefix).
package/tsconfig.json CHANGED
@@ -2,5 +2,19 @@
2
2
  "extends": "@checkstack/tsconfig/common.json",
3
3
  "include": [
4
4
  "src"
5
+ ],
6
+ "references": [
7
+ {
8
+ "path": "../auth-common"
9
+ },
10
+ {
11
+ "path": "../common"
12
+ },
13
+ {
14
+ "path": "../frontend-api"
15
+ },
16
+ {
17
+ "path": "../notification-common"
18
+ }
5
19
  ]
6
- }
20
+ }