@checkstack/catalog-backend 1.0.2 → 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 +50 -0
- package/drizzle/0002_harsh_carmella_unuscione.sql +9 -0
- package/drizzle/meta/0002_snapshot.json +367 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +15 -15
- package/src/cache.ts +8 -0
- package/src/router.test.ts +2 -0
- package/src/router.ts +30 -0
- package/src/schema.ts +14 -0
- package/src/services/entity-service.ts +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# @checkstack/catalog-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 [f6f9a5c]
|
|
39
|
+
- Updated dependencies [1ef2e79]
|
|
40
|
+
- Updated dependencies [aa89bc5]
|
|
41
|
+
- @checkstack/common@0.9.0
|
|
42
|
+
- @checkstack/gitops-common@0.3.0
|
|
43
|
+
- @checkstack/gitops-backend@0.3.0
|
|
44
|
+
- @checkstack/catalog-common@2.1.0
|
|
45
|
+
- @checkstack/cache-api@0.3.0
|
|
46
|
+
- @checkstack/auth-backend@0.4.25
|
|
47
|
+
- @checkstack/auth-common@0.6.6
|
|
48
|
+
- @checkstack/backend-api@0.15.1
|
|
49
|
+
- @checkstack/command-backend@0.1.25
|
|
50
|
+
- @checkstack/notification-common@1.0.2
|
|
51
|
+
- @checkstack/cache-utils@0.2.5
|
|
52
|
+
|
|
3
53
|
## 1.0.2
|
|
4
54
|
|
|
5
55
|
### Patch Changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
CREATE TABLE "system_links" (
|
|
2
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
3
|
+
"system_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 "system_links" ADD CONSTRAINT "system_links_system_id_systems_id_fk" FOREIGN KEY ("system_id") REFERENCES "systems"("id") ON DELETE cascade ON UPDATE no action;
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "d0f3aff8-8024-4eec-9407-77c1991ecf62",
|
|
3
|
+
"prevId": "72cd2f27-3627-475c-96f6-778b75a35418",
|
|
4
|
+
"version": "7",
|
|
5
|
+
"dialect": "postgresql",
|
|
6
|
+
"tables": {
|
|
7
|
+
"public.groups": {
|
|
8
|
+
"name": "groups",
|
|
9
|
+
"schema": "",
|
|
10
|
+
"columns": {
|
|
11
|
+
"id": {
|
|
12
|
+
"name": "id",
|
|
13
|
+
"type": "text",
|
|
14
|
+
"primaryKey": true,
|
|
15
|
+
"notNull": true
|
|
16
|
+
},
|
|
17
|
+
"name": {
|
|
18
|
+
"name": "name",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true
|
|
22
|
+
},
|
|
23
|
+
"metadata": {
|
|
24
|
+
"name": "metadata",
|
|
25
|
+
"type": "json",
|
|
26
|
+
"primaryKey": false,
|
|
27
|
+
"notNull": false,
|
|
28
|
+
"default": "'{}'::json"
|
|
29
|
+
},
|
|
30
|
+
"created_at": {
|
|
31
|
+
"name": "created_at",
|
|
32
|
+
"type": "timestamp",
|
|
33
|
+
"primaryKey": false,
|
|
34
|
+
"notNull": true,
|
|
35
|
+
"default": "now()"
|
|
36
|
+
},
|
|
37
|
+
"updated_at": {
|
|
38
|
+
"name": "updated_at",
|
|
39
|
+
"type": "timestamp",
|
|
40
|
+
"primaryKey": false,
|
|
41
|
+
"notNull": true,
|
|
42
|
+
"default": "now()"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"indexes": {},
|
|
46
|
+
"foreignKeys": {},
|
|
47
|
+
"compositePrimaryKeys": {},
|
|
48
|
+
"uniqueConstraints": {},
|
|
49
|
+
"policies": {},
|
|
50
|
+
"checkConstraints": {},
|
|
51
|
+
"isRLSEnabled": false
|
|
52
|
+
},
|
|
53
|
+
"public.system_contacts": {
|
|
54
|
+
"name": "system_contacts",
|
|
55
|
+
"schema": "",
|
|
56
|
+
"columns": {
|
|
57
|
+
"id": {
|
|
58
|
+
"name": "id",
|
|
59
|
+
"type": "text",
|
|
60
|
+
"primaryKey": true,
|
|
61
|
+
"notNull": true
|
|
62
|
+
},
|
|
63
|
+
"system_id": {
|
|
64
|
+
"name": "system_id",
|
|
65
|
+
"type": "text",
|
|
66
|
+
"primaryKey": false,
|
|
67
|
+
"notNull": true
|
|
68
|
+
},
|
|
69
|
+
"type": {
|
|
70
|
+
"name": "type",
|
|
71
|
+
"type": "contact_type",
|
|
72
|
+
"typeSchema": "public",
|
|
73
|
+
"primaryKey": false,
|
|
74
|
+
"notNull": true
|
|
75
|
+
},
|
|
76
|
+
"user_id": {
|
|
77
|
+
"name": "user_id",
|
|
78
|
+
"type": "text",
|
|
79
|
+
"primaryKey": false,
|
|
80
|
+
"notNull": false
|
|
81
|
+
},
|
|
82
|
+
"email": {
|
|
83
|
+
"name": "email",
|
|
84
|
+
"type": "text",
|
|
85
|
+
"primaryKey": false,
|
|
86
|
+
"notNull": false
|
|
87
|
+
},
|
|
88
|
+
"label": {
|
|
89
|
+
"name": "label",
|
|
90
|
+
"type": "text",
|
|
91
|
+
"primaryKey": false,
|
|
92
|
+
"notNull": false
|
|
93
|
+
},
|
|
94
|
+
"created_at": {
|
|
95
|
+
"name": "created_at",
|
|
96
|
+
"type": "timestamp",
|
|
97
|
+
"primaryKey": false,
|
|
98
|
+
"notNull": true,
|
|
99
|
+
"default": "now()"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"indexes": {},
|
|
103
|
+
"foreignKeys": {
|
|
104
|
+
"system_contacts_system_id_systems_id_fk": {
|
|
105
|
+
"name": "system_contacts_system_id_systems_id_fk",
|
|
106
|
+
"tableFrom": "system_contacts",
|
|
107
|
+
"tableTo": "systems",
|
|
108
|
+
"columnsFrom": [
|
|
109
|
+
"system_id"
|
|
110
|
+
],
|
|
111
|
+
"columnsTo": [
|
|
112
|
+
"id"
|
|
113
|
+
],
|
|
114
|
+
"onDelete": "cascade",
|
|
115
|
+
"onUpdate": "no action"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"compositePrimaryKeys": {},
|
|
119
|
+
"uniqueConstraints": {},
|
|
120
|
+
"policies": {},
|
|
121
|
+
"checkConstraints": {},
|
|
122
|
+
"isRLSEnabled": false
|
|
123
|
+
},
|
|
124
|
+
"public.system_links": {
|
|
125
|
+
"name": "system_links",
|
|
126
|
+
"schema": "",
|
|
127
|
+
"columns": {
|
|
128
|
+
"id": {
|
|
129
|
+
"name": "id",
|
|
130
|
+
"type": "text",
|
|
131
|
+
"primaryKey": true,
|
|
132
|
+
"notNull": true
|
|
133
|
+
},
|
|
134
|
+
"system_id": {
|
|
135
|
+
"name": "system_id",
|
|
136
|
+
"type": "text",
|
|
137
|
+
"primaryKey": false,
|
|
138
|
+
"notNull": true
|
|
139
|
+
},
|
|
140
|
+
"label": {
|
|
141
|
+
"name": "label",
|
|
142
|
+
"type": "text",
|
|
143
|
+
"primaryKey": false,
|
|
144
|
+
"notNull": false
|
|
145
|
+
},
|
|
146
|
+
"url": {
|
|
147
|
+
"name": "url",
|
|
148
|
+
"type": "text",
|
|
149
|
+
"primaryKey": false,
|
|
150
|
+
"notNull": true
|
|
151
|
+
},
|
|
152
|
+
"created_at": {
|
|
153
|
+
"name": "created_at",
|
|
154
|
+
"type": "timestamp",
|
|
155
|
+
"primaryKey": false,
|
|
156
|
+
"notNull": true,
|
|
157
|
+
"default": "now()"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"indexes": {},
|
|
161
|
+
"foreignKeys": {
|
|
162
|
+
"system_links_system_id_systems_id_fk": {
|
|
163
|
+
"name": "system_links_system_id_systems_id_fk",
|
|
164
|
+
"tableFrom": "system_links",
|
|
165
|
+
"tableTo": "systems",
|
|
166
|
+
"columnsFrom": [
|
|
167
|
+
"system_id"
|
|
168
|
+
],
|
|
169
|
+
"columnsTo": [
|
|
170
|
+
"id"
|
|
171
|
+
],
|
|
172
|
+
"onDelete": "cascade",
|
|
173
|
+
"onUpdate": "no action"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"compositePrimaryKeys": {},
|
|
177
|
+
"uniqueConstraints": {},
|
|
178
|
+
"policies": {},
|
|
179
|
+
"checkConstraints": {},
|
|
180
|
+
"isRLSEnabled": false
|
|
181
|
+
},
|
|
182
|
+
"public.systems": {
|
|
183
|
+
"name": "systems",
|
|
184
|
+
"schema": "",
|
|
185
|
+
"columns": {
|
|
186
|
+
"id": {
|
|
187
|
+
"name": "id",
|
|
188
|
+
"type": "text",
|
|
189
|
+
"primaryKey": true,
|
|
190
|
+
"notNull": true
|
|
191
|
+
},
|
|
192
|
+
"name": {
|
|
193
|
+
"name": "name",
|
|
194
|
+
"type": "text",
|
|
195
|
+
"primaryKey": false,
|
|
196
|
+
"notNull": true
|
|
197
|
+
},
|
|
198
|
+
"description": {
|
|
199
|
+
"name": "description",
|
|
200
|
+
"type": "text",
|
|
201
|
+
"primaryKey": false,
|
|
202
|
+
"notNull": false
|
|
203
|
+
},
|
|
204
|
+
"metadata": {
|
|
205
|
+
"name": "metadata",
|
|
206
|
+
"type": "json",
|
|
207
|
+
"primaryKey": false,
|
|
208
|
+
"notNull": false,
|
|
209
|
+
"default": "'{}'::json"
|
|
210
|
+
},
|
|
211
|
+
"created_at": {
|
|
212
|
+
"name": "created_at",
|
|
213
|
+
"type": "timestamp",
|
|
214
|
+
"primaryKey": false,
|
|
215
|
+
"notNull": true,
|
|
216
|
+
"default": "now()"
|
|
217
|
+
},
|
|
218
|
+
"updated_at": {
|
|
219
|
+
"name": "updated_at",
|
|
220
|
+
"type": "timestamp",
|
|
221
|
+
"primaryKey": false,
|
|
222
|
+
"notNull": true,
|
|
223
|
+
"default": "now()"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"indexes": {},
|
|
227
|
+
"foreignKeys": {},
|
|
228
|
+
"compositePrimaryKeys": {},
|
|
229
|
+
"uniqueConstraints": {},
|
|
230
|
+
"policies": {},
|
|
231
|
+
"checkConstraints": {},
|
|
232
|
+
"isRLSEnabled": false
|
|
233
|
+
},
|
|
234
|
+
"public.systems_groups": {
|
|
235
|
+
"name": "systems_groups",
|
|
236
|
+
"schema": "",
|
|
237
|
+
"columns": {
|
|
238
|
+
"system_id": {
|
|
239
|
+
"name": "system_id",
|
|
240
|
+
"type": "text",
|
|
241
|
+
"primaryKey": false,
|
|
242
|
+
"notNull": true
|
|
243
|
+
},
|
|
244
|
+
"group_id": {
|
|
245
|
+
"name": "group_id",
|
|
246
|
+
"type": "text",
|
|
247
|
+
"primaryKey": false,
|
|
248
|
+
"notNull": true
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
"indexes": {},
|
|
252
|
+
"foreignKeys": {
|
|
253
|
+
"systems_groups_system_id_systems_id_fk": {
|
|
254
|
+
"name": "systems_groups_system_id_systems_id_fk",
|
|
255
|
+
"tableFrom": "systems_groups",
|
|
256
|
+
"tableTo": "systems",
|
|
257
|
+
"columnsFrom": [
|
|
258
|
+
"system_id"
|
|
259
|
+
],
|
|
260
|
+
"columnsTo": [
|
|
261
|
+
"id"
|
|
262
|
+
],
|
|
263
|
+
"onDelete": "cascade",
|
|
264
|
+
"onUpdate": "no action"
|
|
265
|
+
},
|
|
266
|
+
"systems_groups_group_id_groups_id_fk": {
|
|
267
|
+
"name": "systems_groups_group_id_groups_id_fk",
|
|
268
|
+
"tableFrom": "systems_groups",
|
|
269
|
+
"tableTo": "groups",
|
|
270
|
+
"columnsFrom": [
|
|
271
|
+
"group_id"
|
|
272
|
+
],
|
|
273
|
+
"columnsTo": [
|
|
274
|
+
"id"
|
|
275
|
+
],
|
|
276
|
+
"onDelete": "cascade",
|
|
277
|
+
"onUpdate": "no action"
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
"compositePrimaryKeys": {
|
|
281
|
+
"systems_groups_system_id_group_id_pk": {
|
|
282
|
+
"name": "systems_groups_system_id_group_id_pk",
|
|
283
|
+
"columns": [
|
|
284
|
+
"system_id",
|
|
285
|
+
"group_id"
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
"uniqueConstraints": {},
|
|
290
|
+
"policies": {},
|
|
291
|
+
"checkConstraints": {},
|
|
292
|
+
"isRLSEnabled": false
|
|
293
|
+
},
|
|
294
|
+
"public.views": {
|
|
295
|
+
"name": "views",
|
|
296
|
+
"schema": "",
|
|
297
|
+
"columns": {
|
|
298
|
+
"id": {
|
|
299
|
+
"name": "id",
|
|
300
|
+
"type": "text",
|
|
301
|
+
"primaryKey": true,
|
|
302
|
+
"notNull": true
|
|
303
|
+
},
|
|
304
|
+
"name": {
|
|
305
|
+
"name": "name",
|
|
306
|
+
"type": "text",
|
|
307
|
+
"primaryKey": false,
|
|
308
|
+
"notNull": true
|
|
309
|
+
},
|
|
310
|
+
"description": {
|
|
311
|
+
"name": "description",
|
|
312
|
+
"type": "text",
|
|
313
|
+
"primaryKey": false,
|
|
314
|
+
"notNull": false
|
|
315
|
+
},
|
|
316
|
+
"configuration": {
|
|
317
|
+
"name": "configuration",
|
|
318
|
+
"type": "json",
|
|
319
|
+
"primaryKey": false,
|
|
320
|
+
"notNull": true,
|
|
321
|
+
"default": "'[]'::json"
|
|
322
|
+
},
|
|
323
|
+
"created_at": {
|
|
324
|
+
"name": "created_at",
|
|
325
|
+
"type": "timestamp",
|
|
326
|
+
"primaryKey": false,
|
|
327
|
+
"notNull": true,
|
|
328
|
+
"default": "now()"
|
|
329
|
+
},
|
|
330
|
+
"updated_at": {
|
|
331
|
+
"name": "updated_at",
|
|
332
|
+
"type": "timestamp",
|
|
333
|
+
"primaryKey": false,
|
|
334
|
+
"notNull": true,
|
|
335
|
+
"default": "now()"
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"indexes": {},
|
|
339
|
+
"foreignKeys": {},
|
|
340
|
+
"compositePrimaryKeys": {},
|
|
341
|
+
"uniqueConstraints": {},
|
|
342
|
+
"policies": {},
|
|
343
|
+
"checkConstraints": {},
|
|
344
|
+
"isRLSEnabled": false
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
"enums": {
|
|
348
|
+
"public.contact_type": {
|
|
349
|
+
"name": "contact_type",
|
|
350
|
+
"schema": "public",
|
|
351
|
+
"values": [
|
|
352
|
+
"user",
|
|
353
|
+
"mailbox"
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
"schemas": {},
|
|
358
|
+
"sequences": {},
|
|
359
|
+
"roles": {},
|
|
360
|
+
"policies": {},
|
|
361
|
+
"views": {},
|
|
362
|
+
"_meta": {
|
|
363
|
+
"columns": {},
|
|
364
|
+
"schemas": {},
|
|
365
|
+
"tables": {}
|
|
366
|
+
}
|
|
367
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/catalog-backend",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -14,27 +14,27 @@
|
|
|
14
14
|
"lint:code": "eslint . --max-warnings 0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@checkstack/backend-api": "0.
|
|
18
|
-
"@checkstack/cache-api": "0.2.
|
|
19
|
-
"@checkstack/cache-utils": "0.2.
|
|
20
|
-
"@checkstack/auth-common": "0.6.
|
|
21
|
-
"@checkstack/catalog-common": "2.0.
|
|
22
|
-
"@checkstack/command-backend": "0.1.
|
|
23
|
-
"@checkstack/auth-backend": "0.4.
|
|
24
|
-
"@checkstack/gitops-backend": "0.2.
|
|
25
|
-
"@checkstack/gitops-common": "0.2.
|
|
26
|
-
"@checkstack/notification-common": "1.0.
|
|
17
|
+
"@checkstack/backend-api": "0.15.0",
|
|
18
|
+
"@checkstack/cache-api": "0.2.4",
|
|
19
|
+
"@checkstack/cache-utils": "0.2.4",
|
|
20
|
+
"@checkstack/auth-common": "0.6.5",
|
|
21
|
+
"@checkstack/catalog-common": "2.0.1",
|
|
22
|
+
"@checkstack/command-backend": "0.1.24",
|
|
23
|
+
"@checkstack/auth-backend": "0.4.24",
|
|
24
|
+
"@checkstack/gitops-backend": "0.2.8",
|
|
25
|
+
"@checkstack/gitops-common": "0.2.2",
|
|
26
|
+
"@checkstack/notification-common": "1.0.1",
|
|
27
27
|
"@orpc/server": "^1.13.2",
|
|
28
28
|
"drizzle-orm": "^0.45.0",
|
|
29
29
|
"hono": "^4.12.14",
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
31
|
"zod": "^4.2.1",
|
|
32
|
-
"@checkstack/common": "0.
|
|
32
|
+
"@checkstack/common": "0.8.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@checkstack/drizzle-helper": "0.0.
|
|
36
|
-
"@checkstack/scripts": "0.
|
|
37
|
-
"@checkstack/tsconfig": "0.0.
|
|
35
|
+
"@checkstack/drizzle-helper": "0.0.5",
|
|
36
|
+
"@checkstack/scripts": "0.3.0",
|
|
37
|
+
"@checkstack/tsconfig": "0.0.7",
|
|
38
38
|
"@types/bun": "^1.3.5",
|
|
39
39
|
"@types/node": "^20.0.0",
|
|
40
40
|
"@types/uuid": "^11.0.0",
|
package/src/cache.ts
CHANGED
|
@@ -16,6 +16,7 @@ const CATALOG_TTL_MS = 25_000;
|
|
|
16
16
|
const ENTITY_PREFIX = "entity:";
|
|
17
17
|
const VIEW_PREFIX = "view:";
|
|
18
18
|
const CONTACTS_PREFIX = "contacts:";
|
|
19
|
+
const LINKS_PREFIX = "links:";
|
|
19
20
|
|
|
20
21
|
const ENTITIES_KEY = `${ENTITY_PREFIX}entities`;
|
|
21
22
|
const SYSTEMS_KEY = `${ENTITY_PREFIX}systems`;
|
|
@@ -27,6 +28,7 @@ const groupsForSystemKey = (systemId: string): string =>
|
|
|
27
28
|
`${ENTITY_PREFIX}groups-for-system:${systemId}`;
|
|
28
29
|
const contactsKey = (systemId: string): string =>
|
|
29
30
|
`${CONTACTS_PREFIX}${systemId}`;
|
|
31
|
+
const linksKey = (systemId: string): string => `${LINKS_PREFIX}${systemId}`;
|
|
30
32
|
|
|
31
33
|
export interface CatalogCache {
|
|
32
34
|
/** Read-through caches for the dashboard hot paths. */
|
|
@@ -40,6 +42,7 @@ export interface CatalogCache {
|
|
|
40
42
|
) => Promise<T>;
|
|
41
43
|
wrapViews: <T>(loader: () => Promise<T>) => Promise<T>;
|
|
42
44
|
wrapContacts: <T>(systemId: string, loader: () => Promise<T>) => Promise<T>;
|
|
45
|
+
wrapLinks: <T>(systemId: string, loader: () => Promise<T>) => Promise<T>;
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
48
|
* Drop the whole topology family (entities, systems, groups, per-system,
|
|
@@ -55,6 +58,9 @@ export interface CatalogCache {
|
|
|
55
58
|
/** Drop one system's contact cache. */
|
|
56
59
|
invalidateContacts: (systemId: string) => Promise<void>;
|
|
57
60
|
|
|
61
|
+
/** Drop one system's hotlink cache. */
|
|
62
|
+
invalidateLinks: (systemId: string) => Promise<void>;
|
|
63
|
+
|
|
58
64
|
scope: CachedScope;
|
|
59
65
|
}
|
|
60
66
|
|
|
@@ -84,10 +90,12 @@ export function createCatalogCache({
|
|
|
84
90
|
wrapViews: (loader) => scope.wrap(VIEWS_KEY, loader),
|
|
85
91
|
wrapContacts: (systemId, loader) =>
|
|
86
92
|
scope.wrap(contactsKey(systemId), loader),
|
|
93
|
+
wrapLinks: (systemId, loader) => scope.wrap(linksKey(systemId), loader),
|
|
87
94
|
|
|
88
95
|
invalidateTopology: () => scope.invalidatePrefix(ENTITY_PREFIX),
|
|
89
96
|
invalidateViews: () => scope.invalidatePrefix(VIEW_PREFIX),
|
|
90
97
|
invalidateContacts: (systemId) => scope.invalidate(contactsKey(systemId)),
|
|
98
|
+
invalidateLinks: (systemId) => scope.invalidate(linksKey(systemId)),
|
|
91
99
|
|
|
92
100
|
scope,
|
|
93
101
|
};
|
package/src/router.test.ts
CHANGED
|
@@ -12,9 +12,11 @@ const passthroughCache: CatalogCache = {
|
|
|
12
12
|
wrapGroupsForSystem: (_systemId, loader) => loader(),
|
|
13
13
|
wrapViews: (loader) => loader(),
|
|
14
14
|
wrapContacts: (_systemId, loader) => loader(),
|
|
15
|
+
wrapLinks: (_systemId, loader) => loader(),
|
|
15
16
|
invalidateTopology: async () => 0,
|
|
16
17
|
invalidateViews: async () => 0,
|
|
17
18
|
invalidateContacts: async () => {},
|
|
19
|
+
invalidateLinks: async () => {},
|
|
18
20
|
scope: {} as CatalogCache["scope"],
|
|
19
21
|
};
|
|
20
22
|
|
package/src/router.ts
CHANGED
|
@@ -497,6 +497,33 @@ export const createCatalogRouter = ({
|
|
|
497
497
|
},
|
|
498
498
|
);
|
|
499
499
|
|
|
500
|
+
// System Links handlers (free-form URL hotlinks attached to a system)
|
|
501
|
+
const getSystemLinks = os.getSystemLinks.handler(async ({ input }) =>
|
|
502
|
+
cache.wrapLinks(input.systemId, async () =>
|
|
503
|
+
entityService.getLinksForSystem(input.systemId),
|
|
504
|
+
),
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
const addSystemLink = os.addSystemLink.handler(async ({ input }) => {
|
|
508
|
+
await enforceNotGitOpsLocked("System", input.systemId);
|
|
509
|
+
const result = await entityService.addLink({
|
|
510
|
+
systemId: input.systemId,
|
|
511
|
+
label: input.label,
|
|
512
|
+
url: input.url,
|
|
513
|
+
});
|
|
514
|
+
await cache.invalidateLinks(input.systemId);
|
|
515
|
+
return result;
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
const removeSystemLink = os.removeSystemLink.handler(async ({ input }) => {
|
|
519
|
+
const removed = await entityService.removeLink(input);
|
|
520
|
+
if (removed) {
|
|
521
|
+
await enforceNotGitOpsLocked("System", removed.systemId);
|
|
522
|
+
await cache.invalidateLinks(removed.systemId);
|
|
523
|
+
}
|
|
524
|
+
return { success: !!removed };
|
|
525
|
+
});
|
|
526
|
+
|
|
500
527
|
/**
|
|
501
528
|
* Get the catalog group IDs that contain a specific system.
|
|
502
529
|
* Used by the dependency plugin for batched notification deduplication.
|
|
@@ -526,6 +553,9 @@ export const createCatalogRouter = ({
|
|
|
526
553
|
getSystemContacts,
|
|
527
554
|
addSystemContact,
|
|
528
555
|
removeSystemContact,
|
|
556
|
+
getSystemLinks,
|
|
557
|
+
addSystemLink,
|
|
558
|
+
removeSystemLink,
|
|
529
559
|
createGroup,
|
|
530
560
|
updateGroup,
|
|
531
561
|
deleteGroup,
|
package/src/schema.ts
CHANGED
|
@@ -59,6 +59,20 @@ export const systemsGroups = pgTable(
|
|
|
59
59
|
}),
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Free-form hotlinks attached to a system — e.g. Jira board, dashboard URL,
|
|
64
|
+
* runbook. Sits alongside contacts but is purely URL-based, no user/email.
|
|
65
|
+
*/
|
|
66
|
+
export const systemLinks = pgTable("system_links", {
|
|
67
|
+
id: text("id").primaryKey(),
|
|
68
|
+
systemId: text("system_id")
|
|
69
|
+
.notNull()
|
|
70
|
+
.references(() => systems.id, { onDelete: "cascade" }),
|
|
71
|
+
label: text("label"),
|
|
72
|
+
url: text("url").notNull(),
|
|
73
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
74
|
+
});
|
|
75
|
+
|
|
62
76
|
export const views = pgTable("views", {
|
|
63
77
|
id: text("id").primaryKey(),
|
|
64
78
|
name: text("name").notNull(),
|
|
@@ -98,6 +98,30 @@ export class EntityService {
|
|
|
98
98
|
.where(eq(schema.systemContacts.userId, userId));
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
// System Links — free-form URLs attached to a system
|
|
102
|
+
async getLinksForSystem(systemId: string) {
|
|
103
|
+
return this.database
|
|
104
|
+
.select()
|
|
105
|
+
.from(schema.systemLinks)
|
|
106
|
+
.where(eq(schema.systemLinks.systemId, systemId));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async addLink(props: { systemId: string; label?: string; url: string }) {
|
|
110
|
+
const result = await this.database
|
|
111
|
+
.insert(schema.systemLinks)
|
|
112
|
+
.values({ id: uuidv4(), ...props })
|
|
113
|
+
.returning();
|
|
114
|
+
return result[0];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async removeLink(linkId: string) {
|
|
118
|
+
const result = await this.database
|
|
119
|
+
.delete(schema.systemLinks)
|
|
120
|
+
.where(eq(schema.systemLinks.id, linkId))
|
|
121
|
+
.returning();
|
|
122
|
+
return result[0];
|
|
123
|
+
}
|
|
124
|
+
|
|
101
125
|
// Groups
|
|
102
126
|
async getGroups() {
|
|
103
127
|
// Fetch all groups
|