@checkstack/incident-backend 1.0.1 → 1.1.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 +166 -0
- package/drizzle/0002_brown_thena.sql +9 -0
- package/drizzle/meta/0002_snapshot.json +278 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +19 -18
- package/src/router.ts +30 -1
- package/src/schema.ts +14 -0
- package/src/service.ts +47 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,171 @@
|
|
|
1
1
|
# @checkstack/incident-backend
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 1ef2e79: feat: hotlinks on incidents/maintenances and additional links on systems
|
|
8
|
+
|
|
9
|
+
Users with `manage` access on an incident, maintenance, or system can now
|
|
10
|
+
attach free-form URL "hotlinks" — Jira tickets, runbooks, dashboards, ticket
|
|
11
|
+
tools, etc. — alongside the existing fields.
|
|
12
|
+
|
|
13
|
+
- **Incidents** & **maintenances**: links live on the entity itself and are
|
|
14
|
+
surfaced both in the editor dialog and on the public detail page. Two new
|
|
15
|
+
RPC procedures per plugin (`addLink`, `removeLink`) gated behind the
|
|
16
|
+
existing `manage` access rule. Links are returned as part of
|
|
17
|
+
`getIncident` / `getMaintenance` and cache-invalidated on every link
|
|
18
|
+
mutation.
|
|
19
|
+
- **Systems**: a parallel `system_links` table with `getSystemLinks`,
|
|
20
|
+
`addSystemLink`, `removeSystemLink` procedures. Surfaced inside the
|
|
21
|
+
system editor (next to contacts) and on the read-only system detail
|
|
22
|
+
sidebar. Cache-scoped per-system so list endpoints remain hot.
|
|
23
|
+
- **Shared UI**: a `LinksEditor` component in `@checkstack/ui` does the
|
|
24
|
+
presentation; the three plugins each own their own RPC wiring.
|
|
25
|
+
|
|
26
|
+
Database changes ship as additive migrations (new `incident_links`,
|
|
27
|
+
`maintenance_links`, `system_links` tables, all FK-cascaded on parent
|
|
28
|
+
delete). No existing columns or rows are touched.
|
|
29
|
+
|
|
30
|
+
The system incident and maintenance history pages now sort by relevance:
|
|
31
|
+
active entries (non-`resolved` incidents, `scheduled` or `in_progress`
|
|
32
|
+
maintenances) appear at the top, with creation date descending as the
|
|
33
|
+
tiebreaker.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [42abfff]
|
|
38
|
+
- Updated dependencies [1ef2e79]
|
|
39
|
+
- Updated dependencies [aa89bc5]
|
|
40
|
+
- @checkstack/common@0.9.0
|
|
41
|
+
- @checkstack/incident-common@1.1.0
|
|
42
|
+
- @checkstack/catalog-common@2.1.0
|
|
43
|
+
- @checkstack/catalog-backend@1.1.0
|
|
44
|
+
- @checkstack/cache-api@0.3.0
|
|
45
|
+
- @checkstack/auth-common@0.6.6
|
|
46
|
+
- @checkstack/backend-api@0.15.1
|
|
47
|
+
- @checkstack/command-backend@0.1.25
|
|
48
|
+
- @checkstack/integration-backend@0.1.25
|
|
49
|
+
- @checkstack/integration-common@0.3.2
|
|
50
|
+
- @checkstack/notification-common@1.0.2
|
|
51
|
+
- @checkstack/signal-common@0.2.2
|
|
52
|
+
- @checkstack/cache-utils@0.2.5
|
|
53
|
+
|
|
54
|
+
## 1.0.2
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- 50e5f5f: Runtime plugin system: install + uninstall plugins from npm, GitHub releases
|
|
59
|
+
(including private GitHub Enterprise instances), or tarball uploads at
|
|
60
|
+
runtime, with multi-package bundles, dependency-derived compatibility checks,
|
|
61
|
+
multi-instance coordination via a Postgres artifact store, and
|
|
62
|
+
single-coordinator destructive cleanup.
|
|
63
|
+
|
|
64
|
+
Highlights:
|
|
65
|
+
|
|
66
|
+
- New `PluginSource` discriminated union and `PluginInstaller` /
|
|
67
|
+
`PluginInstallerRegistry` interfaces in `@checkstack/backend-api`. The
|
|
68
|
+
GitHub variant accepts an optional `apiBaseUrl` so deployments backed by
|
|
69
|
+
GitHub Enterprise can install from `https://ghe.example.com/api/v3`
|
|
70
|
+
instead of `api.github.com`.
|
|
71
|
+
- New `installPackageMetadataSchema` (Zod) in `@checkstack/common` validates
|
|
72
|
+
every plugin's `package.json` at install time. Required fields: `name`,
|
|
73
|
+
`version`, `description`, `author`, `license`, `checkstack.type`,
|
|
74
|
+
`checkstack.pluginId`. Optional: `checkstack.bundle`,
|
|
75
|
+
`checkstack.usageInstructions`, `checkstack.allowInstallScripts`.
|
|
76
|
+
- New `pluginManagerContract` in `@checkstack/pluginmanager-common` with
|
|
77
|
+
`list`, `previewInstall`, `install`, `previewUninstall`, `uninstall`, and
|
|
78
|
+
`events` procedures.
|
|
79
|
+
- New `@checkstack/pluginmanager-frontend` admin UI: installed-plugins list
|
|
80
|
+
with per-row uninstall (typed-confirmation modal, schema/configs/cascade
|
|
81
|
+
toggles), install page with NPM / Tarball Upload / GitHub Release tabs
|
|
82
|
+
(Catalog tab disabled — coming soon), and an events page surfacing the
|
|
83
|
+
install/uninstall audit log.
|
|
84
|
+
- New `bunx @checkstack/scripts plugin-pack` CLI for plugin authors —
|
|
85
|
+
per-package mode produces an npm-shaped tarball; `--bundle` mode produces
|
|
86
|
+
an outer tarball containing every sibling declared in
|
|
87
|
+
`package.json#checkstack.bundle`. Published to npm so external authors
|
|
88
|
+
can `bunx` it directly without a workspace checkout.
|
|
89
|
+
- Compatibility derived from `package.json#dependencies` ranges
|
|
90
|
+
(`semver.satisfies` against the platform's loaded `@checkstack/*`
|
|
91
|
+
versions) — no separate `compatibility` field.
|
|
92
|
+
- Multi-instance: originator persists artifacts + `plugins` rows + broadcasts
|
|
93
|
+
install/uninstall; receiving instances do in-process register/unregister
|
|
94
|
+
only. Destructive ops (drop schema, delete plugin_configs, delete
|
|
95
|
+
artifacts, delete `plugins` rows) run exactly once on the originator.
|
|
96
|
+
- Fresh-instance bootstrap: `loadPlugins()` hydrates any
|
|
97
|
+
`is_uninstallable=true` plugin missing from `node_modules` from the
|
|
98
|
+
artifact store before normal Phase 1 register.
|
|
99
|
+
- New schema: `plugin_artifacts` (tarball storage), `plugin_install_events`
|
|
100
|
+
(audit/error log). `plugins` extended with `version`, `metadata`,
|
|
101
|
+
`source`, `bundle_id`, `is_primary`. Local plugin sync now writes
|
|
102
|
+
`version` from each plugin's `package.json` so the admin UI shows real
|
|
103
|
+
versions instead of `—`.
|
|
104
|
+
- Tarball-upload endpoint (`POST /api/pluginmanager/upload-tarball`) for
|
|
105
|
+
the install UI; access-gated by `pluginmanager.plugin.manage`.
|
|
106
|
+
- Plugin Manager menu link added to the user menu (main grid, alongside
|
|
107
|
+
Profile / Notification Settings / etc.).
|
|
108
|
+
|
|
109
|
+
Cross-cutting changes:
|
|
110
|
+
|
|
111
|
+
- Backend request/response logging now flows through `rootLogger` (winston)
|
|
112
|
+
instead of `hono/logger`. 5xx responses include the response body inline
|
|
113
|
+
so swallowed early-return errors are visible in the log.
|
|
114
|
+
- The `/api/:pluginId/*` dispatcher now logs which core service is missing
|
|
115
|
+
or which `pluginId` had no metadata when it 500s.
|
|
116
|
+
- New `registerCorePluginMetadata` on `PluginManager` for core routers
|
|
117
|
+
(like the plugin manager itself) that need their metadata visible to the
|
|
118
|
+
RPC dispatcher without going through the full plugin lifecycle.
|
|
119
|
+
- ESLint: `unicorn/no-null` is now disabled globally. Drizzle distinguishes
|
|
120
|
+
between `null` (writes a real SQL NULL) and `undefined` (skip the column
|
|
121
|
+
on insert), so treating them as interchangeable produced latent bugs at
|
|
122
|
+
the persistence boundary. The bulk of the patch-bumped packages above
|
|
123
|
+
reflect lint-fix touches that landed when this rule was relaxed.
|
|
124
|
+
- Workspace-wide license normalization to `Elastic-2.0` (matches
|
|
125
|
+
`LICENSE.md`). Every `package.json` in the workspace now declares the
|
|
126
|
+
same SPDX identifier; the patch bumps capture this.
|
|
127
|
+
|
|
128
|
+
Plugin packages (every `plugins/*`): added a `pack` npm script
|
|
129
|
+
(`bunx @checkstack/scripts plugin-pack`), mirrored each plugin's
|
|
130
|
+
`pluginId` from `plugin-metadata.ts` into `package.json#checkstack.pluginId`
|
|
131
|
+
so install-time validation passes, stubbed any missing required metadata
|
|
132
|
+
fields (`description`, `author`, `license`), and added
|
|
133
|
+
`checkstack.bundle` to multi-package plugin primaries (telegram, rcon, ssh,
|
|
134
|
+
jira, queue-bullmq, queue-memory, cache-memory).
|
|
135
|
+
|
|
136
|
+
Breaking changes:
|
|
137
|
+
|
|
138
|
+
- The legacy single-method `PluginInstaller` interface (`install(packageName)`)
|
|
139
|
+
is removed. Callers must use `coreServices.pluginInstallerRegistry`.
|
|
140
|
+
- The old `pluginAdminContract` and `createPluginAdminRouter` are removed.
|
|
141
|
+
Replaced by `pluginManagerContract` in `@checkstack/pluginmanager-common`
|
|
142
|
+
and `createPluginManagerRouter` in `core/backend`.
|
|
143
|
+
- `@checkstack/test-utils-backend` no longer exports
|
|
144
|
+
`createMockPluginInstaller` / `MockPluginInstaller` (the legacy interface
|
|
145
|
+
it shimmed is gone).
|
|
146
|
+
|
|
147
|
+
Note: bumps are limited to `minor` (for packages with new public API
|
|
148
|
+
surface) and `patch` (for downstream consumers, license normalization,
|
|
149
|
+
and lint fixes). No `major` bumps despite the `PluginInstaller` removal —
|
|
150
|
+
the legacy interface had no third-party consumers in the wild before this
|
|
151
|
+
runtime plugin system landed, and the contract surface is the same shape
|
|
152
|
+
modulo the rename.
|
|
153
|
+
|
|
154
|
+
- Updated dependencies [50e5f5f]
|
|
155
|
+
- @checkstack/auth-common@0.6.5
|
|
156
|
+
- @checkstack/backend-api@0.15.0
|
|
157
|
+
- @checkstack/catalog-backend@1.0.2
|
|
158
|
+
- @checkstack/catalog-common@2.0.1
|
|
159
|
+
- @checkstack/common@0.8.0
|
|
160
|
+
- @checkstack/integration-common@0.3.1
|
|
161
|
+
- @checkstack/cache-api@0.2.4
|
|
162
|
+
- @checkstack/cache-utils@0.2.4
|
|
163
|
+
- @checkstack/command-backend@0.1.24
|
|
164
|
+
- @checkstack/incident-common@1.0.1
|
|
165
|
+
- @checkstack/integration-backend@0.1.24
|
|
166
|
+
- @checkstack/notification-common@1.0.1
|
|
167
|
+
- @checkstack/signal-common@0.2.1
|
|
168
|
+
|
|
3
169
|
## 1.0.1
|
|
4
170
|
|
|
5
171
|
### Patch Changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
CREATE TABLE "incident_links" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"incident_id" text NOT NULL,
|
|
4
|
+
"label" text,
|
|
5
|
+
"url" text NOT NULL,
|
|
6
|
+
"created_at" timestamp DEFAULT now() NOT NULL
|
|
7
|
+
);
|
|
8
|
+
--> statement-breakpoint
|
|
9
|
+
ALTER TABLE "incident_links" ADD CONSTRAINT "incident_links_incident_id_incidents_id_fk" FOREIGN KEY ("incident_id") REFERENCES "incidents"("id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "0c166fdf-4881-4230-a0b3-50b6c4b89e16",
|
|
3
|
+
"prevId": "e53ec0d1-e4c4-45cb-b45d-7ac3c1317744",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"public.incident_links": {
|
|
8
|
+
"name": "incident_links",
|
|
9
|
+
"schema": "",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "text",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true
|
|
16
|
+
},
|
|
17
|
+
"incident_id": {
|
|
18
|
+
"name": "incident_id",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true
|
|
22
|
+
},
|
|
23
|
+
"label": {
|
|
24
|
+
"name": "label",
|
|
25
|
+
"type": "text",
|
|
26
|
+
"primaryKey": false,
|
|
27
|
+
"notNull": false
|
|
28
|
+
},
|
|
29
|
+
"url": {
|
|
30
|
+
"name": "url",
|
|
31
|
+
"type": "text",
|
|
32
|
+
"primaryKey": false,
|
|
33
|
+
"notNull": true
|
|
34
|
+
},
|
|
35
|
+
"created_at": {
|
|
36
|
+
"name": "created_at",
|
|
37
|
+
"type": "timestamp",
|
|
38
|
+
"primaryKey": false,
|
|
39
|
+
"notNull": true,
|
|
40
|
+
"default": "now()"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"indexes": {},
|
|
44
|
+
"foreignKeys": {
|
|
45
|
+
"incident_links_incident_id_incidents_id_fk": {
|
|
46
|
+
"name": "incident_links_incident_id_incidents_id_fk",
|
|
47
|
+
"tableFrom": "incident_links",
|
|
48
|
+
"tableTo": "incidents",
|
|
49
|
+
"columnsFrom": [
|
|
50
|
+
"incident_id"
|
|
51
|
+
],
|
|
52
|
+
"columnsTo": [
|
|
53
|
+
"id"
|
|
54
|
+
],
|
|
55
|
+
"onDelete": "cascade",
|
|
56
|
+
"onUpdate": "no action"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"compositePrimaryKeys": {},
|
|
60
|
+
"uniqueConstraints": {},
|
|
61
|
+
"policies": {},
|
|
62
|
+
"checkConstraints": {},
|
|
63
|
+
"isRLSEnabled": false
|
|
64
|
+
},
|
|
65
|
+
"public.incident_systems": {
|
|
66
|
+
"name": "incident_systems",
|
|
67
|
+
"schema": "",
|
|
68
|
+
"columns": {
|
|
69
|
+
"incident_id": {
|
|
70
|
+
"name": "incident_id",
|
|
71
|
+
"type": "text",
|
|
72
|
+
"primaryKey": false,
|
|
73
|
+
"notNull": true
|
|
74
|
+
},
|
|
75
|
+
"system_id": {
|
|
76
|
+
"name": "system_id",
|
|
77
|
+
"type": "text",
|
|
78
|
+
"primaryKey": false,
|
|
79
|
+
"notNull": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"indexes": {},
|
|
83
|
+
"foreignKeys": {
|
|
84
|
+
"incident_systems_incident_id_incidents_id_fk": {
|
|
85
|
+
"name": "incident_systems_incident_id_incidents_id_fk",
|
|
86
|
+
"tableFrom": "incident_systems",
|
|
87
|
+
"tableTo": "incidents",
|
|
88
|
+
"columnsFrom": [
|
|
89
|
+
"incident_id"
|
|
90
|
+
],
|
|
91
|
+
"columnsTo": [
|
|
92
|
+
"id"
|
|
93
|
+
],
|
|
94
|
+
"onDelete": "cascade",
|
|
95
|
+
"onUpdate": "no action"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"compositePrimaryKeys": {
|
|
99
|
+
"incident_systems_incident_id_system_id_pk": {
|
|
100
|
+
"name": "incident_systems_incident_id_system_id_pk",
|
|
101
|
+
"columns": [
|
|
102
|
+
"incident_id",
|
|
103
|
+
"system_id"
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"uniqueConstraints": {},
|
|
108
|
+
"policies": {},
|
|
109
|
+
"checkConstraints": {},
|
|
110
|
+
"isRLSEnabled": false
|
|
111
|
+
},
|
|
112
|
+
"public.incident_updates": {
|
|
113
|
+
"name": "incident_updates",
|
|
114
|
+
"schema": "",
|
|
115
|
+
"columns": {
|
|
116
|
+
"id": {
|
|
117
|
+
"name": "id",
|
|
118
|
+
"type": "text",
|
|
119
|
+
"primaryKey": true,
|
|
120
|
+
"notNull": true
|
|
121
|
+
},
|
|
122
|
+
"incident_id": {
|
|
123
|
+
"name": "incident_id",
|
|
124
|
+
"type": "text",
|
|
125
|
+
"primaryKey": false,
|
|
126
|
+
"notNull": true
|
|
127
|
+
},
|
|
128
|
+
"message": {
|
|
129
|
+
"name": "message",
|
|
130
|
+
"type": "text",
|
|
131
|
+
"primaryKey": false,
|
|
132
|
+
"notNull": true
|
|
133
|
+
},
|
|
134
|
+
"status_change": {
|
|
135
|
+
"name": "status_change",
|
|
136
|
+
"type": "incident_status",
|
|
137
|
+
"typeSchema": "public",
|
|
138
|
+
"primaryKey": false,
|
|
139
|
+
"notNull": false
|
|
140
|
+
},
|
|
141
|
+
"created_at": {
|
|
142
|
+
"name": "created_at",
|
|
143
|
+
"type": "timestamp",
|
|
144
|
+
"primaryKey": false,
|
|
145
|
+
"notNull": true,
|
|
146
|
+
"default": "now()"
|
|
147
|
+
},
|
|
148
|
+
"created_by": {
|
|
149
|
+
"name": "created_by",
|
|
150
|
+
"type": "text",
|
|
151
|
+
"primaryKey": false,
|
|
152
|
+
"notNull": false
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"indexes": {},
|
|
156
|
+
"foreignKeys": {
|
|
157
|
+
"incident_updates_incident_id_incidents_id_fk": {
|
|
158
|
+
"name": "incident_updates_incident_id_incidents_id_fk",
|
|
159
|
+
"tableFrom": "incident_updates",
|
|
160
|
+
"tableTo": "incidents",
|
|
161
|
+
"columnsFrom": [
|
|
162
|
+
"incident_id"
|
|
163
|
+
],
|
|
164
|
+
"columnsTo": [
|
|
165
|
+
"id"
|
|
166
|
+
],
|
|
167
|
+
"onDelete": "cascade",
|
|
168
|
+
"onUpdate": "no action"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"compositePrimaryKeys": {},
|
|
172
|
+
"uniqueConstraints": {},
|
|
173
|
+
"policies": {},
|
|
174
|
+
"checkConstraints": {},
|
|
175
|
+
"isRLSEnabled": false
|
|
176
|
+
},
|
|
177
|
+
"public.incidents": {
|
|
178
|
+
"name": "incidents",
|
|
179
|
+
"schema": "",
|
|
180
|
+
"columns": {
|
|
181
|
+
"id": {
|
|
182
|
+
"name": "id",
|
|
183
|
+
"type": "text",
|
|
184
|
+
"primaryKey": true,
|
|
185
|
+
"notNull": true
|
|
186
|
+
},
|
|
187
|
+
"title": {
|
|
188
|
+
"name": "title",
|
|
189
|
+
"type": "text",
|
|
190
|
+
"primaryKey": false,
|
|
191
|
+
"notNull": true
|
|
192
|
+
},
|
|
193
|
+
"description": {
|
|
194
|
+
"name": "description",
|
|
195
|
+
"type": "text",
|
|
196
|
+
"primaryKey": false,
|
|
197
|
+
"notNull": false
|
|
198
|
+
},
|
|
199
|
+
"status": {
|
|
200
|
+
"name": "status",
|
|
201
|
+
"type": "incident_status",
|
|
202
|
+
"typeSchema": "public",
|
|
203
|
+
"primaryKey": false,
|
|
204
|
+
"notNull": true,
|
|
205
|
+
"default": "'investigating'"
|
|
206
|
+
},
|
|
207
|
+
"severity": {
|
|
208
|
+
"name": "severity",
|
|
209
|
+
"type": "incident_severity",
|
|
210
|
+
"typeSchema": "public",
|
|
211
|
+
"primaryKey": false,
|
|
212
|
+
"notNull": true,
|
|
213
|
+
"default": "'major'"
|
|
214
|
+
},
|
|
215
|
+
"suppress_notifications": {
|
|
216
|
+
"name": "suppress_notifications",
|
|
217
|
+
"type": "boolean",
|
|
218
|
+
"primaryKey": false,
|
|
219
|
+
"notNull": true,
|
|
220
|
+
"default": false
|
|
221
|
+
},
|
|
222
|
+
"created_at": {
|
|
223
|
+
"name": "created_at",
|
|
224
|
+
"type": "timestamp",
|
|
225
|
+
"primaryKey": false,
|
|
226
|
+
"notNull": true,
|
|
227
|
+
"default": "now()"
|
|
228
|
+
},
|
|
229
|
+
"updated_at": {
|
|
230
|
+
"name": "updated_at",
|
|
231
|
+
"type": "timestamp",
|
|
232
|
+
"primaryKey": false,
|
|
233
|
+
"notNull": true,
|
|
234
|
+
"default": "now()"
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"indexes": {},
|
|
238
|
+
"foreignKeys": {},
|
|
239
|
+
"compositePrimaryKeys": {},
|
|
240
|
+
"uniqueConstraints": {},
|
|
241
|
+
"policies": {},
|
|
242
|
+
"checkConstraints": {},
|
|
243
|
+
"isRLSEnabled": false
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"enums": {
|
|
247
|
+
"public.incident_severity": {
|
|
248
|
+
"name": "incident_severity",
|
|
249
|
+
"schema": "public",
|
|
250
|
+
"values": [
|
|
251
|
+
"minor",
|
|
252
|
+
"major",
|
|
253
|
+
"critical"
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
"public.incident_status": {
|
|
257
|
+
"name": "incident_status",
|
|
258
|
+
"schema": "public",
|
|
259
|
+
"values": [
|
|
260
|
+
"investigating",
|
|
261
|
+
"identified",
|
|
262
|
+
"fixing",
|
|
263
|
+
"monitoring",
|
|
264
|
+
"resolved"
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
"schemas": {},
|
|
269
|
+
"sequences": {},
|
|
270
|
+
"roles": {},
|
|
271
|
+
"policies": {},
|
|
272
|
+
"views": {},
|
|
273
|
+
"_meta": {
|
|
274
|
+
"columns": {},
|
|
275
|
+
"schemas": {},
|
|
276
|
+
"tables": {}
|
|
277
|
+
}
|
|
278
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/incident-backend",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"license": "Elastic-2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"main": "src/index.ts",
|
|
6
7
|
"checkstack": {
|
|
@@ -13,28 +14,28 @@
|
|
|
13
14
|
"lint:code": "eslint . --max-warnings 0"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@checkstack/backend-api": "0.
|
|
17
|
-
"@checkstack/cache-api": "0.2.
|
|
18
|
-
"@checkstack/cache-utils": "0.2.
|
|
19
|
-
"@checkstack/incident-common": "1.0.
|
|
20
|
-
"@checkstack/catalog-common": "2.0.
|
|
21
|
-
"@checkstack/catalog-backend": "1.0.
|
|
22
|
-
"@checkstack/notification-common": "1.0.
|
|
23
|
-
"@checkstack/auth-common": "0.6.
|
|
24
|
-
"@checkstack/command-backend": "0.1.
|
|
25
|
-
"@checkstack/signal-common": "0.2.
|
|
26
|
-
"@checkstack/integration-backend": "0.1.
|
|
27
|
-
"@checkstack/integration-common": "0.3.
|
|
28
|
-
"@checkstack/common": "0.
|
|
17
|
+
"@checkstack/backend-api": "0.15.0",
|
|
18
|
+
"@checkstack/cache-api": "0.2.4",
|
|
19
|
+
"@checkstack/cache-utils": "0.2.4",
|
|
20
|
+
"@checkstack/incident-common": "1.0.1",
|
|
21
|
+
"@checkstack/catalog-common": "2.0.1",
|
|
22
|
+
"@checkstack/catalog-backend": "1.0.2",
|
|
23
|
+
"@checkstack/notification-common": "1.0.1",
|
|
24
|
+
"@checkstack/auth-common": "0.6.5",
|
|
25
|
+
"@checkstack/command-backend": "0.1.24",
|
|
26
|
+
"@checkstack/signal-common": "0.2.1",
|
|
27
|
+
"@checkstack/integration-backend": "0.1.24",
|
|
28
|
+
"@checkstack/integration-common": "0.3.1",
|
|
29
|
+
"@checkstack/common": "0.8.0",
|
|
29
30
|
"drizzle-orm": "^0.45.0",
|
|
30
31
|
"zod": "^4.2.1",
|
|
31
32
|
"@orpc/server": "^1.13.2"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@checkstack/drizzle-helper": "0.0.
|
|
35
|
-
"@checkstack/scripts": "0.
|
|
36
|
-
"@checkstack/test-utils-backend": "0.1.
|
|
37
|
-
"@checkstack/tsconfig": "0.0.
|
|
35
|
+
"@checkstack/drizzle-helper": "0.0.5",
|
|
36
|
+
"@checkstack/scripts": "0.3.0",
|
|
37
|
+
"@checkstack/test-utils-backend": "0.1.24",
|
|
38
|
+
"@checkstack/tsconfig": "0.0.7",
|
|
38
39
|
"@types/bun": "^1.0.0",
|
|
39
40
|
"drizzle-kit": "^0.31.10",
|
|
40
41
|
"typescript": "^5.0.0"
|
package/src/router.ts
CHANGED
|
@@ -105,7 +105,7 @@ export function createRouter(
|
|
|
105
105
|
service.getIncident(input.id),
|
|
106
106
|
);
|
|
107
107
|
if (!result) {
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
return null;
|
|
110
110
|
}
|
|
111
111
|
// User-name resolution stays outside the cache: it's a foreign-system
|
|
@@ -392,5 +392,34 @@ export function createRouter(
|
|
|
392
392
|
);
|
|
393
393
|
return { suppressed };
|
|
394
394
|
}),
|
|
395
|
+
|
|
396
|
+
addLink: os.addLink.handler(async ({ input }) => {
|
|
397
|
+
// Verify incident exists so the FK violation surfaces as NOT_FOUND.
|
|
398
|
+
const incident = await service.getIncident(input.incidentId);
|
|
399
|
+
if (!incident) {
|
|
400
|
+
throw new ORPCError("NOT_FOUND", { message: "Incident not found" });
|
|
401
|
+
}
|
|
402
|
+
const link = await service.addLink(input);
|
|
403
|
+
await cache.invalidateForMutation({
|
|
404
|
+
incidentId: incident.id,
|
|
405
|
+
systemIds: incident.systemIds,
|
|
406
|
+
});
|
|
407
|
+
return link;
|
|
408
|
+
}),
|
|
409
|
+
|
|
410
|
+
removeLink: os.removeLink.handler(async ({ input }) => {
|
|
411
|
+
const incidentId = await service.removeLink(input.id);
|
|
412
|
+
if (!incidentId) {
|
|
413
|
+
return { success: false };
|
|
414
|
+
}
|
|
415
|
+
const incident = await service.getIncident(incidentId);
|
|
416
|
+
if (incident) {
|
|
417
|
+
await cache.invalidateForMutation({
|
|
418
|
+
incidentId,
|
|
419
|
+
systemIds: incident.systemIds,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
return { success: true };
|
|
423
|
+
}),
|
|
395
424
|
});
|
|
396
425
|
}
|
package/src/schema.ts
CHANGED
|
@@ -72,3 +72,17 @@ export const incidentUpdates = pgTable("incident_updates", {
|
|
|
72
72
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
73
73
|
createdBy: text("created_by"),
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Hotlinks attached to an incident — e.g. a Jira ticket, runbook, or chat
|
|
78
|
+
* thread. Free-form URL + optional human label.
|
|
79
|
+
*/
|
|
80
|
+
export const incidentLinks = pgTable("incident_links", {
|
|
81
|
+
id: text("id").primaryKey(),
|
|
82
|
+
incidentId: text("incident_id")
|
|
83
|
+
.notNull()
|
|
84
|
+
.references(() => incidents.id, { onDelete: "cascade" }),
|
|
85
|
+
label: text("label"),
|
|
86
|
+
url: text("url").notNull(),
|
|
87
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
88
|
+
});
|
package/src/service.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { eq, and, inArray, ne } from "drizzle-orm";
|
|
2
2
|
import type { SafeDatabase } from "@checkstack/backend-api";
|
|
3
3
|
import * as schema from "./schema";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
incidents,
|
|
6
|
+
incidentSystems,
|
|
7
|
+
incidentUpdates,
|
|
8
|
+
incidentLinks,
|
|
9
|
+
} from "./schema";
|
|
5
10
|
import type {
|
|
6
11
|
IncidentWithSystems,
|
|
7
12
|
IncidentDetail,
|
|
8
13
|
IncidentUpdate,
|
|
14
|
+
IncidentLink,
|
|
15
|
+
AddIncidentLinkInput,
|
|
9
16
|
CreateIncidentInput,
|
|
10
17
|
UpdateIncidentInput,
|
|
11
18
|
AddIncidentUpdateInput,
|
|
@@ -100,6 +107,11 @@ export class IncidentService {
|
|
|
100
107
|
.from(incidentUpdates)
|
|
101
108
|
.where(eq(incidentUpdates.incidentId, id));
|
|
102
109
|
|
|
110
|
+
const links = await this.db
|
|
111
|
+
.select()
|
|
112
|
+
.from(incidentLinks)
|
|
113
|
+
.where(eq(incidentLinks.incidentId, id));
|
|
114
|
+
|
|
103
115
|
return {
|
|
104
116
|
...incident,
|
|
105
117
|
description: incident.description ?? undefined,
|
|
@@ -109,6 +121,7 @@ export class IncidentService {
|
|
|
109
121
|
statusChange: u.statusChange ?? undefined,
|
|
110
122
|
createdBy: u.createdBy ?? undefined,
|
|
111
123
|
})),
|
|
124
|
+
links,
|
|
112
125
|
};
|
|
113
126
|
}
|
|
114
127
|
|
|
@@ -332,6 +345,39 @@ export class IncidentService {
|
|
|
332
345
|
.where(eq(incidentSystems.systemId, systemId));
|
|
333
346
|
}
|
|
334
347
|
|
|
348
|
+
/**
|
|
349
|
+
* Add a hotlink to an incident.
|
|
350
|
+
*/
|
|
351
|
+
async addLink(input: AddIncidentLinkInput): Promise<IncidentLink> {
|
|
352
|
+
const id = generateId();
|
|
353
|
+
await this.db.insert(incidentLinks).values({
|
|
354
|
+
id,
|
|
355
|
+
incidentId: input.incidentId,
|
|
356
|
+
label: input.label,
|
|
357
|
+
url: input.url,
|
|
358
|
+
});
|
|
359
|
+
const [row] = await this.db
|
|
360
|
+
.select()
|
|
361
|
+
.from(incidentLinks)
|
|
362
|
+
.where(eq(incidentLinks.id, id));
|
|
363
|
+
return row;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Remove a hotlink. Returns the parent incidentId so the caller can
|
|
368
|
+
* invalidate the right cache entry, or undefined if the link did not
|
|
369
|
+
* exist.
|
|
370
|
+
*/
|
|
371
|
+
async removeLink(id: string): Promise<string | undefined> {
|
|
372
|
+
const [existing] = await this.db
|
|
373
|
+
.select()
|
|
374
|
+
.from(incidentLinks)
|
|
375
|
+
.where(eq(incidentLinks.id, id));
|
|
376
|
+
if (!existing) return undefined;
|
|
377
|
+
await this.db.delete(incidentLinks).where(eq(incidentLinks.id, id));
|
|
378
|
+
return existing.incidentId;
|
|
379
|
+
}
|
|
380
|
+
|
|
335
381
|
/**
|
|
336
382
|
* Check if a system has an active incident with notification suppression enabled.
|
|
337
383
|
* An incident is considered "active" if its status is NOT "resolved".
|