@checkstack/backend 0.7.0 → 0.8.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,136 @@
|
|
|
1
1
|
# @checkstack/backend
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 32d52c6: feat: notification target pattern + per-spec subscriptions
|
|
8
|
+
|
|
9
|
+
Replaces the all-or-nothing catalog system/group notification model with a
|
|
10
|
+
platform-level target pattern. Each notification-emitting plugin declares
|
|
11
|
+
_subscription specs_ against typed _target_ objects exported from the
|
|
12
|
+
target's owning plugin (catalog ships `catalogSystemTarget` and
|
|
13
|
+
`catalogGroupTarget`). Notification-backend handles every per-resource
|
|
14
|
+
group lifecycle, parent-edge inheritance, and legacy-subscription seeding
|
|
15
|
+
— plugins never author groupId helpers, lifecycle hooks, or migration
|
|
16
|
+
code again.
|
|
17
|
+
|
|
18
|
+
**Plugin-author surface area is now ~12 lines per emitter:**
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// <plugin>-common
|
|
22
|
+
const { defineSubscription } = createSubscriptionFactory(pluginMetadata);
|
|
23
|
+
export const fooSystemSubscription = defineSubscription({
|
|
24
|
+
localId: "system",
|
|
25
|
+
target: catalogSystemTarget,
|
|
26
|
+
display: { title: "Foo Alerts", description: "...", iconName: "Bell" },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// <plugin>-backend register()
|
|
30
|
+
env.registerSubscriptionSpecs([fooSystemSubscription]);
|
|
31
|
+
// ^ feeds the plugin loader's dependency sorter — each spec's
|
|
32
|
+
// target.ownerPlugin becomes an implicit init-order dep, so this
|
|
33
|
+
// plugin automatically waits for catalog (the target owner) to
|
|
34
|
+
// finish init + afterPluginsReady before its own runs.
|
|
35
|
+
|
|
36
|
+
// <plugin>-backend afterPluginsReady
|
|
37
|
+
await notificationClient.registerSubscriptionSpec(
|
|
38
|
+
specToRegistration(fooSystemSubscription)
|
|
39
|
+
);
|
|
40
|
+
// dispatch
|
|
41
|
+
await notificationClient.notifyForSubscription({
|
|
42
|
+
specId: fooSystemSubscription.specId,
|
|
43
|
+
resourceKeys: [systemId],
|
|
44
|
+
title,
|
|
45
|
+
body,
|
|
46
|
+
importance,
|
|
47
|
+
action,
|
|
48
|
+
collapseKey,
|
|
49
|
+
subjects,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// <plugin>-frontend
|
|
53
|
+
createNotificationSubscriptionExtension({ spec: fooSystemSubscription });
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Migrated plugins**: anomaly, incident, maintenance, healthcheck,
|
|
57
|
+
dependency. Each lost its bespoke `notification-groups.ts`,
|
|
58
|
+
`bootstrap*NotificationGroups`, `ensure*Group`, and inheritance walk —
|
|
59
|
+
all of that is now centralized in notification-backend's
|
|
60
|
+
`subscription-engine`.
|
|
61
|
+
|
|
62
|
+
**Plugin loader change** (`@checkstack/backend-api`,
|
|
63
|
+
`@checkstack/backend`): the register-time API gains
|
|
64
|
+
`env.registerSubscriptionSpecs([...specs])`. The dependency sorter
|
|
65
|
+
walks `spec.target.ownerPlugin` for every declared spec and adds the
|
|
66
|
+
target owner as an init-order dependency of the emitting plugin. This
|
|
67
|
+
guarantees that catalog (the owner of the platform's `system` and
|
|
68
|
+
`group` targets) completes init + afterPluginsReady before any
|
|
69
|
+
emitting plugin tries to register its specs against the notification
|
|
70
|
+
service — no string-prefix heuristics, no manual `dependsOnPlugins`
|
|
71
|
+
list, no stub rows. Plugins that fail to declare their specs at
|
|
72
|
+
register time get a clear `Target type X is not registered. Did the
|
|
73
|
+
emitting plugin declare this spec via env.registerSubscriptionSpecs?`
|
|
74
|
+
error from the dispatcher.
|
|
75
|
+
|
|
76
|
+
**Removed** (no backwards compat):
|
|
77
|
+
|
|
78
|
+
- `catalogClient.notifySystemSubscribers` and
|
|
79
|
+
`catalogClient.notifyManySystemSubscribers`
|
|
80
|
+
- `notificationClient.notifyUsers` and `notificationClient.notifyGroups`
|
|
81
|
+
as direct dispatch primitives — replaced by spec-bound
|
|
82
|
+
`notifyForSubscription`
|
|
83
|
+
- catalog's `bootstrapNotificationGroups` (replaced by
|
|
84
|
+
`bootstrapNotificationTargets`)
|
|
85
|
+
|
|
86
|
+
**Enforcement**: the dispatcher rejects calls referencing unregistered
|
|
87
|
+
specIds, specs owned by other plugins, or resourceKeys that haven't been
|
|
88
|
+
pushed via `upsertNotificationResource`. Display metadata for any
|
|
89
|
+
groupId is recoverable via the spec registry, so audit lists render
|
|
90
|
+
correct labels even when an emitter's frontend isn't loaded.
|
|
91
|
+
|
|
92
|
+
**Per-field anomaly mute** keeps working — it now lives inside the
|
|
93
|
+
generic SubscriptionRow's optional `SubControls` panel
|
|
94
|
+
(`AnomalyFieldMuteList`), exposed through the catalog system detail
|
|
95
|
+
page's notifications card.
|
|
96
|
+
|
|
97
|
+
The catalog system detail page renders a "Notifications" card hosting
|
|
98
|
+
`SystemNotificationSubscriptionsSlot`. The matching group surface is
|
|
99
|
+
not yet rendered — group-level subscriptions are wired end-to-end on
|
|
100
|
+
the backend; a follow-up will add the host UI.
|
|
101
|
+
|
|
102
|
+
**Migration of existing subscribers**: target types declare a
|
|
103
|
+
`legacyGroupIdTemplate`; on first registration of each spec,
|
|
104
|
+
notification-backend reads subscribers from the legacy
|
|
105
|
+
`catalog.system.<id>` / `catalog.group.<id>` groups and seeds the new
|
|
106
|
+
spec groups exactly once per (spec × resource) pair, tracked in
|
|
107
|
+
`subscription_migrations`. Anomaly stays opt-in (its target also
|
|
108
|
+
declares the template, but the user-explicit nature of the original
|
|
109
|
+
opt-in flow means the seeding produces the same set of subscribers
|
|
110
|
+
they already had).
|
|
111
|
+
|
|
112
|
+
### Patch Changes
|
|
113
|
+
|
|
114
|
+
- Updated dependencies [32d52c6]
|
|
115
|
+
- Updated dependencies [32d52c6]
|
|
116
|
+
- Updated dependencies [32d52c6]
|
|
117
|
+
- @checkstack/backend-api@0.14.0
|
|
118
|
+
- @checkstack/auth-common@0.6.4
|
|
119
|
+
- @checkstack/cache-api@0.2.2
|
|
120
|
+
- @checkstack/queue-api@0.2.16
|
|
121
|
+
- @checkstack/signal-backend@0.2.1
|
|
122
|
+
|
|
123
|
+
## 0.7.1
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [208ad71]
|
|
128
|
+
- @checkstack/signal-common@0.2.0
|
|
129
|
+
- @checkstack/signal-backend@0.2.0
|
|
130
|
+
- @checkstack/backend-api@0.13.1
|
|
131
|
+
- @checkstack/cache-api@0.2.1
|
|
132
|
+
- @checkstack/queue-api@0.2.15
|
|
133
|
+
|
|
3
134
|
## 0.7.0
|
|
4
135
|
|
|
5
136
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"checkstack": {
|
|
5
5
|
"type": "backend"
|
|
6
6
|
},
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"lint:code": "eslint . --max-warnings 0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@checkstack/api-docs-common": "0.1.
|
|
17
|
-
"@checkstack/auth-common": "0.6.
|
|
18
|
-
"@checkstack/backend-api": "0.
|
|
19
|
-
"@checkstack/common": "0.
|
|
16
|
+
"@checkstack/api-docs-common": "0.1.10",
|
|
17
|
+
"@checkstack/auth-common": "0.6.3",
|
|
18
|
+
"@checkstack/backend-api": "0.13.1",
|
|
19
|
+
"@checkstack/common": "0.7.0",
|
|
20
20
|
"@checkstack/drizzle-helper": "0.0.4",
|
|
21
|
-
"@checkstack/cache-api": "0.1
|
|
22
|
-
"@checkstack/queue-api": "0.2.
|
|
23
|
-
"@checkstack/signal-backend": "0.
|
|
24
|
-
"@checkstack/signal-common": "0.
|
|
21
|
+
"@checkstack/cache-api": "0.2.1",
|
|
22
|
+
"@checkstack/queue-api": "0.2.15",
|
|
23
|
+
"@checkstack/signal-backend": "0.2.0",
|
|
24
|
+
"@checkstack/signal-common": "0.2.0",
|
|
25
25
|
"@hono/zod-validator": "^0.7.6",
|
|
26
26
|
"@orpc/client": "^1.13.14",
|
|
27
27
|
"@orpc/contract": "^1.13.14",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@types/bun": "latest",
|
|
42
42
|
"@checkstack/tsconfig": "0.0.5",
|
|
43
43
|
"@checkstack/scripts": "0.1.2",
|
|
44
|
-
"@checkstack/test-utils-backend": "0.1.
|
|
44
|
+
"@checkstack/test-utils-backend": "0.1.21",
|
|
45
|
+
"drizzle-kit": "^0.31.10"
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -14,6 +14,15 @@ export function sortPlugins({
|
|
|
14
14
|
pendingInits: {
|
|
15
15
|
metadata: PluginMetadata;
|
|
16
16
|
deps: Record<string, ServiceRef<unknown>>;
|
|
17
|
+
/**
|
|
18
|
+
* Optional plugin-id-level dependencies. Each id adds an edge
|
|
19
|
+
* `dep -> consumer`, ensuring the consumer's init and
|
|
20
|
+
* afterPluginsReady run after the dep's. Used by the notification
|
|
21
|
+
* subscription pattern: emitter plugins automatically depend on
|
|
22
|
+
* the plugins that own the targets they emit subscriptions for,
|
|
23
|
+
* derived at register time from `spec.target.ownerPlugin`.
|
|
24
|
+
*/
|
|
25
|
+
pluginDependencies?: Set<string>;
|
|
17
26
|
}[];
|
|
18
27
|
providedBy: Map<string, string>;
|
|
19
28
|
logger: Logger;
|
|
@@ -59,6 +68,26 @@ export function sortPlugins({
|
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
|
|
71
|
+
// Plugin-id-level deps (currently sourced from declared
|
|
72
|
+
// notification subscription specs). Each entry forces the consumer
|
|
73
|
+
// to load after the named plugin even when there's no shared
|
|
74
|
+
// ServiceRef between them.
|
|
75
|
+
if (p.pluginDependencies) {
|
|
76
|
+
for (const depPluginId of p.pluginDependencies) {
|
|
77
|
+
if (depPluginId === consumerId) continue;
|
|
78
|
+
if (!graph.has(depPluginId)) {
|
|
79
|
+
// Dep plugin isn't loaded — skip silently. The runtime RPC
|
|
80
|
+
// layer (notification-backend) will produce a clearer error
|
|
81
|
+
// if the dep was actually required.
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (!graph.get(depPluginId)!.includes(consumerId)) {
|
|
85
|
+
graph.get(depPluginId)!.push(consumerId);
|
|
86
|
+
inDegree.set(consumerId, (inDegree.get(consumerId) || 0) + 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
62
91
|
// Special handling: if this plugin uses queueManager, it must wait for all queue plugin providers
|
|
63
92
|
const usesQueueManager = Object.values(p.deps).some(
|
|
64
93
|
(ref) => ref.id === coreServices.queueManager.id
|
|
@@ -88,6 +88,13 @@ export function registerPlugin({
|
|
|
88
88
|
// Store metadata for request-time context injection
|
|
89
89
|
deps.pluginMetadataRegistry.set(pluginId, backendPlugin.metadata);
|
|
90
90
|
|
|
91
|
+
// Plugin dependencies derived from declared subscription specs.
|
|
92
|
+
// Populated by `registerSubscriptionSpecs` below; attached to the
|
|
93
|
+
// PendingInit when registerInit fires (a plugin's register block
|
|
94
|
+
// calls registerInit at most once, so timing is deterministic
|
|
95
|
+
// regardless of registration order within register()).
|
|
96
|
+
const pluginDependencies = new Set<string>();
|
|
97
|
+
|
|
91
98
|
// Execute Register
|
|
92
99
|
backendPlugin.register({
|
|
93
100
|
registerInit: <
|
|
@@ -108,8 +115,22 @@ export function registerPlugin({
|
|
|
108
115
|
init: args.init as InitCallback,
|
|
109
116
|
afterPluginsReady: args.afterPluginsReady as InitCallback | undefined,
|
|
110
117
|
schema: args.schema,
|
|
118
|
+
pluginDependencies,
|
|
111
119
|
});
|
|
112
120
|
},
|
|
121
|
+
registerSubscriptionSpecs: (specs) => {
|
|
122
|
+
for (const spec of specs) {
|
|
123
|
+
if (spec.ownerPlugin !== pluginId) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Plugin ${pluginId} declared a subscription spec it does not own (ownerPlugin=${spec.ownerPlugin})`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const targetOwner = spec.target.ownerPlugin;
|
|
129
|
+
if (targetOwner && targetOwner !== pluginId) {
|
|
130
|
+
pluginDependencies.add(targetOwner);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
113
134
|
registerService: (ref: ServiceRef<unknown>, impl: unknown) => {
|
|
114
135
|
deps.registry.register(ref, impl);
|
|
115
136
|
providedBy.set(ref.id, pluginId);
|
|
@@ -11,4 +11,14 @@ export interface PendingInit {
|
|
|
11
11
|
init: InitCallback;
|
|
12
12
|
afterPluginsReady?: InitCallback;
|
|
13
13
|
schema?: Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Plugin ids this plugin must load *after*. Derived (not authored) —
|
|
16
|
+
* computed at register time from the owners of any notification
|
|
17
|
+
* subscription specs the plugin declared via
|
|
18
|
+
* `registerSubscriptionSpecs`. Each declared spec contributes its
|
|
19
|
+
* target's `ownerPlugin` to this set, so emitter plugins
|
|
20
|
+
* automatically wait for the target owner without anyone
|
|
21
|
+
* maintaining a manual dependency list.
|
|
22
|
+
*/
|
|
23
|
+
pluginDependencies: Set<string>;
|
|
14
24
|
}
|
package/src/plugin-manager.ts
CHANGED
|
@@ -423,6 +423,10 @@ export class PluginManager {
|
|
|
423
423
|
handlers.push(cleanup);
|
|
424
424
|
this.cleanupHandlers.set(metaPluginId, handlers);
|
|
425
425
|
},
|
|
426
|
+
registerSubscriptionSpecs: () => {
|
|
427
|
+
// No-op in this single-plugin registration path; ordering
|
|
428
|
+
// only matters during full-system load (plugin-loader).
|
|
429
|
+
},
|
|
426
430
|
getExtensionPoint: <T>(ref: ExtensionPoint<T>) =>
|
|
427
431
|
this.extensionPointManager.getExtensionPoint(ref),
|
|
428
432
|
registerRouter: (router: unknown, contract: AnyContractRouter) => {
|