@checkstack/incident-common 0.5.0 → 1.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,147 @@
1
1
  # @checkstack/incident-common
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [50e5f5f]
8
+ - @checkstack/catalog-common@2.0.1
9
+ - @checkstack/common@0.8.0
10
+ - @checkstack/frontend-api@0.4.2
11
+ - @checkstack/notification-common@1.0.1
12
+ - @checkstack/signal-common@0.2.1
13
+
14
+ ## 1.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - 32d52c6: feat: notification target pattern + per-spec subscriptions
19
+
20
+ Replaces the all-or-nothing catalog system/group notification model with a
21
+ platform-level target pattern. Each notification-emitting plugin declares
22
+ _subscription specs_ against typed _target_ objects exported from the
23
+ target's owning plugin (catalog ships `catalogSystemTarget` and
24
+ `catalogGroupTarget`). Notification-backend handles every per-resource
25
+ group lifecycle, parent-edge inheritance, and legacy-subscription seeding
26
+ — plugins never author groupId helpers, lifecycle hooks, or migration
27
+ code again.
28
+
29
+ **Plugin-author surface area is now ~12 lines per emitter:**
30
+
31
+ ```ts
32
+ // <plugin>-common
33
+ const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
34
+ export const fooSystemSubscription = defineSubscription({
35
+ localId: "system",
36
+ target: catalogSystemTarget,
37
+ display: { title: "Foo Alerts", description: "...", iconName: "Bell" },
38
+ });
39
+
40
+ // <plugin>-backend register()
41
+ env.registerSubscriptionSpecs([fooSystemSubscription]);
42
+ // ^ feeds the plugin loader's dependency sorter — each spec's
43
+ // target.ownerPlugin becomes an implicit init-order dep, so this
44
+ // plugin automatically waits for catalog (the target owner) to
45
+ // finish init + afterPluginsReady before its own runs.
46
+
47
+ // <plugin>-backend afterPluginsReady
48
+ await notificationClient.registerSubscriptionSpec(
49
+ specToRegistration(fooSystemSubscription)
50
+ );
51
+ // dispatch
52
+ await notificationClient.notifyForSubscription({
53
+ specId: fooSystemSubscription.specId,
54
+ resourceKeys: [systemId],
55
+ title,
56
+ body,
57
+ importance,
58
+ action,
59
+ collapseKey,
60
+ subjects,
61
+ });
62
+
63
+ // <plugin>-frontend
64
+ createNotificationSubscriptionExtension({ spec: fooSystemSubscription });
65
+ ```
66
+
67
+ **Migrated plugins**: anomaly, incident, maintenance, healthcheck,
68
+ dependency. Each lost its bespoke `notification-groups.ts`,
69
+ `bootstrap*NotificationGroups`, `ensure*Group`, and inheritance walk —
70
+ all of that is now centralized in notification-backend's
71
+ `subscription-engine`.
72
+
73
+ **Plugin loader change** (`@checkstack/backend-api`,
74
+ `@checkstack/backend`): the register-time API gains
75
+ `env.registerSubscriptionSpecs([...specs])`. The dependency sorter
76
+ walks `spec.target.ownerPlugin` for every declared spec and adds the
77
+ target owner as an init-order dependency of the emitting plugin. This
78
+ guarantees that catalog (the owner of the platform's `system` and
79
+ `group` targets) completes init + afterPluginsReady before any
80
+ emitting plugin tries to register its specs against the notification
81
+ service — no string-prefix heuristics, no manual `dependsOnPlugins`
82
+ list, no stub rows. Plugins that fail to declare their specs at
83
+ register time get a clear `Target type X is not registered. Did the
84
+ emitting plugin declare this spec via env.registerSubscriptionSpecs?`
85
+ error from the dispatcher.
86
+
87
+ **Removed** (no backwards compat):
88
+
89
+ - `catalogClient.notifySystemSubscribers` and
90
+ `catalogClient.notifyManySystemSubscribers`
91
+ - `notificationClient.notifyUsers` and `notificationClient.notifyGroups`
92
+ as direct dispatch primitives — replaced by spec-bound
93
+ `notifyForSubscription`
94
+ - catalog's `bootstrapNotificationGroups` (replaced by
95
+ `bootstrapNotificationTargets`)
96
+
97
+ **Enforcement**: the dispatcher rejects calls referencing unregistered
98
+ specIds, specs owned by other plugins, or resourceKeys that haven't been
99
+ pushed via `upsertNotificationResource`. Display metadata for any
100
+ groupId is recoverable via the spec registry, so audit lists render
101
+ correct labels even when an emitter's frontend isn't loaded.
102
+
103
+ **Per-field anomaly mute** keeps working — it now lives inside the
104
+ generic SubscriptionRow's optional `SubControls` panel
105
+ (`AnomalyFieldMuteList`), exposed through the catalog system detail
106
+ page's notifications card.
107
+
108
+ The catalog system detail page renders a "Notifications" card hosting
109
+ `SystemNotificationSubscriptionsSlot`. The matching group surface is
110
+ not yet rendered — group-level subscriptions are wired end-to-end on
111
+ the backend; a follow-up will add the host UI.
112
+
113
+ **Migration of existing subscribers**: target types declare a
114
+ `legacyGroupIdTemplate`; on first registration of each spec,
115
+ notification-backend reads subscribers from the legacy
116
+ `catalog.system.<id>` / `catalog.group.<id>` groups and seeds the new
117
+ spec groups exactly once per (spec × resource) pair, tracked in
118
+ `subscription_migrations`. Anomaly stays opt-in (its target also
119
+ declares the template, but the user-explicit nature of the original
120
+ opt-in flow means the seeding produces the same set of subscribers
121
+ they already had).
122
+
123
+ ### Minor Changes
124
+
125
+ - 32d52c6: Bulk notifications affecting multiple systems and collapse lifecycle events into a single card.
126
+
127
+ 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.
128
+
129
+ 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.
130
+
131
+ 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.).
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies [32d52c6]
136
+ - Updated dependencies [32d52c6]
137
+ - Updated dependencies [32d52c6]
138
+ - Updated dependencies [32d52c6]
139
+ - Updated dependencies [32d52c6]
140
+ - Updated dependencies [32d52c6]
141
+ - @checkstack/notification-common@1.0.0
142
+ - @checkstack/catalog-common@2.0.0
143
+ - @checkstack/frontend-api@0.4.1
144
+
3
145
  ## 0.5.0
4
146
 
5
147
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@checkstack/incident-common",
3
- "version": "0.5.0",
3
+ "version": "1.0.1",
4
+ "license": "Elastic-2.0",
4
5
  "type": "module",
5
6
  "exports": {
6
7
  ".": {
@@ -9,18 +10,20 @@
9
10
  },
10
11
  "dependencies": {
11
12
  "@checkstack/common": "0.7.0",
12
- "@checkstack/frontend-api": "0.3.11",
13
- "@checkstack/signal-common": "0.1.10",
13
+ "@checkstack/catalog-common": "2.0.0",
14
+ "@checkstack/frontend-api": "0.4.1",
15
+ "@checkstack/notification-common": "1.0.0",
16
+ "@checkstack/signal-common": "0.2.0",
14
17
  "@orpc/contract": "^1.13.14",
15
18
  "zod": "^4.2.1"
16
19
  },
17
20
  "devDependencies": {
18
21
  "typescript": "^5.7.2",
19
- "@checkstack/tsconfig": "0.0.5",
22
+ "@checkstack/tsconfig": "0.0.6",
20
23
  "@checkstack/scripts": "0.1.2"
21
24
  },
22
25
  "scripts": {
23
- "typecheck": "tsc --noEmit",
26
+ "typecheck": "tsgo -b",
24
27
  "lint": "bun run lint:code",
25
28
  "lint:code": "eslint . --max-warnings 0"
26
29
  },
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ export {
26
26
  } from "./schemas";
27
27
  export { IncidentDetailsSlot, IncidentStatusSlot } from "./slots";
28
28
  export * from "./plugin-metadata";
29
+ export * from "./notifications";
29
30
  export { incidentRoutes } from "./routes";
30
31
 
31
32
  // =============================================================================
@@ -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 incidentCollapseKey = createCollapseKeyBuilder(
12
+ pluginMetadata,
13
+ "incident",
14
+ );
15
+
16
+ const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
17
+
18
+ export const incidentSystemSubscription = defineSubscription({
19
+ localId: "system",
20
+ target: catalogSystemTarget,
21
+ display: {
22
+ title: "Incidents",
23
+ description: "Incidents reported, updated, and resolved for this system.",
24
+ iconName: "AlertTriangle",
25
+ },
26
+ });
27
+
28
+ export const incidentGroupSubscription = defineSubscription({
29
+ localId: "group",
30
+ target: catalogGroupTarget,
31
+ display: {
32
+ title: "Incidents",
33
+ description: "Incidents for any system in this group.",
34
+ iconName: "AlertTriangle",
35
+ },
36
+ });
package/tsconfig.json CHANGED
@@ -2,5 +2,22 @@
2
2
  "extends": "@checkstack/tsconfig/common.json",
3
3
  "include": [
4
4
  "src"
5
+ ],
6
+ "references": [
7
+ {
8
+ "path": "../catalog-common"
9
+ },
10
+ {
11
+ "path": "../common"
12
+ },
13
+ {
14
+ "path": "../frontend-api"
15
+ },
16
+ {
17
+ "path": "../notification-common"
18
+ },
19
+ {
20
+ "path": "../signal-common"
21
+ }
5
22
  ]
6
- }
23
+ }