@checkstack/catalog-backend 1.3.1 → 1.4.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/drizzle/0003_tan_spot.sql +17 -0
  3. package/drizzle/0004_heavy_sharon_carter.sql +13 -0
  4. package/drizzle/0005_normal_shaman.sql +60 -0
  5. package/drizzle/0006_optimal_gamora.sql +43 -0
  6. package/drizzle/meta/0003_snapshot.json +479 -0
  7. package/drizzle/meta/0004_snapshot.json +495 -0
  8. package/drizzle/meta/0005_snapshot.json +592 -0
  9. package/drizzle/meta/0006_snapshot.json +592 -0
  10. package/drizzle/meta/_journal.json +28 -0
  11. package/package.json +20 -17
  12. package/src/ai/catalog-add-system-to-group.test.ts +51 -0
  13. package/src/ai/catalog-add-system-to-group.ts +68 -0
  14. package/src/ai/catalog-create-group.test.ts +62 -0
  15. package/src/ai/catalog-create-group.ts +71 -0
  16. package/src/ai/catalog-create-system.test.ts +62 -0
  17. package/src/ai/catalog-create-system.ts +78 -0
  18. package/src/ai/catalog-delete-group.test.ts +83 -0
  19. package/src/ai/catalog-delete-group.ts +77 -0
  20. package/src/ai/catalog-delete-system.test.ts +84 -0
  21. package/src/ai/catalog-delete-system.ts +77 -0
  22. package/src/ai/catalog-remove-system-from-group.test.ts +55 -0
  23. package/src/ai/catalog-remove-system-from-group.ts +74 -0
  24. package/src/ai/catalog-update-group.test.ts +85 -0
  25. package/src/ai/catalog-update-group.ts +88 -0
  26. package/src/ai/catalog-update-system.test.ts +87 -0
  27. package/src/ai/catalog-update-system.ts +93 -0
  28. package/src/ai/catalog.projection.test.ts +37 -0
  29. package/src/ai/register-ai-tools.ts +35 -0
  30. package/src/automations.test.ts +2 -1
  31. package/src/catalog-gitops-kinds.test.ts +288 -0
  32. package/src/index.ts +149 -0
  33. package/src/router.test.ts +107 -0
  34. package/src/router.ts +200 -26
  35. package/src/schema.ts +124 -38
  36. package/src/services/entity-service.test.ts +28 -0
  37. package/src/services/entity-service.ts +154 -1
  38. package/src/services/environment-membership.test.ts +66 -0
  39. package/src/services/environment-membership.ts +40 -0
  40. package/src/services/pg-errors.test.ts +24 -0
  41. package/src/services/pg-errors.ts +21 -0
  42. package/tsconfig.json +6 -0
@@ -0,0 +1,592 @@
1
+ {
2
+ "id": "a9f9fe32-7efe-4e6b-8669-28e8a3b9d3cc",
3
+ "prevId": "7e238f67-b6aa-4cc0-a62d-0588c8764c35",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.environments": {
8
+ "name": "environments",
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
+ "description": {
24
+ "name": "description",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": false
28
+ },
29
+ "metadata": {
30
+ "name": "metadata",
31
+ "type": "json",
32
+ "primaryKey": false,
33
+ "notNull": false,
34
+ "default": "'{}'::json"
35
+ },
36
+ "created_at": {
37
+ "name": "created_at",
38
+ "type": "timestamp",
39
+ "primaryKey": false,
40
+ "notNull": true,
41
+ "default": "now()"
42
+ },
43
+ "updated_at": {
44
+ "name": "updated_at",
45
+ "type": "timestamp",
46
+ "primaryKey": false,
47
+ "notNull": true,
48
+ "default": "now()"
49
+ }
50
+ },
51
+ "indexes": {
52
+ "environments_name_unique": {
53
+ "name": "environments_name_unique",
54
+ "columns": [
55
+ {
56
+ "expression": "lower(\"name\")",
57
+ "asc": true,
58
+ "isExpression": true,
59
+ "nulls": "last"
60
+ }
61
+ ],
62
+ "isUnique": true,
63
+ "concurrently": false,
64
+ "method": "btree",
65
+ "with": {}
66
+ }
67
+ },
68
+ "foreignKeys": {},
69
+ "compositePrimaryKeys": {},
70
+ "uniqueConstraints": {},
71
+ "policies": {},
72
+ "checkConstraints": {},
73
+ "isRLSEnabled": false
74
+ },
75
+ "public.groups": {
76
+ "name": "groups",
77
+ "schema": "",
78
+ "columns": {
79
+ "id": {
80
+ "name": "id",
81
+ "type": "text",
82
+ "primaryKey": true,
83
+ "notNull": true
84
+ },
85
+ "name": {
86
+ "name": "name",
87
+ "type": "text",
88
+ "primaryKey": false,
89
+ "notNull": true
90
+ },
91
+ "metadata": {
92
+ "name": "metadata",
93
+ "type": "json",
94
+ "primaryKey": false,
95
+ "notNull": false,
96
+ "default": "'{}'::json"
97
+ },
98
+ "created_at": {
99
+ "name": "created_at",
100
+ "type": "timestamp",
101
+ "primaryKey": false,
102
+ "notNull": true,
103
+ "default": "now()"
104
+ },
105
+ "updated_at": {
106
+ "name": "updated_at",
107
+ "type": "timestamp",
108
+ "primaryKey": false,
109
+ "notNull": true,
110
+ "default": "now()"
111
+ }
112
+ },
113
+ "indexes": {
114
+ "groups_name_unique": {
115
+ "name": "groups_name_unique",
116
+ "columns": [
117
+ {
118
+ "expression": "lower(\"name\")",
119
+ "asc": true,
120
+ "isExpression": true,
121
+ "nulls": "last"
122
+ }
123
+ ],
124
+ "isUnique": true,
125
+ "concurrently": false,
126
+ "method": "btree",
127
+ "with": {}
128
+ }
129
+ },
130
+ "foreignKeys": {},
131
+ "compositePrimaryKeys": {},
132
+ "uniqueConstraints": {},
133
+ "policies": {},
134
+ "checkConstraints": {},
135
+ "isRLSEnabled": false
136
+ },
137
+ "public.system_contacts": {
138
+ "name": "system_contacts",
139
+ "schema": "",
140
+ "columns": {
141
+ "id": {
142
+ "name": "id",
143
+ "type": "text",
144
+ "primaryKey": true,
145
+ "notNull": true
146
+ },
147
+ "system_id": {
148
+ "name": "system_id",
149
+ "type": "text",
150
+ "primaryKey": false,
151
+ "notNull": true
152
+ },
153
+ "type": {
154
+ "name": "type",
155
+ "type": "contact_type",
156
+ "typeSchema": "public",
157
+ "primaryKey": false,
158
+ "notNull": true
159
+ },
160
+ "user_id": {
161
+ "name": "user_id",
162
+ "type": "text",
163
+ "primaryKey": false,
164
+ "notNull": false
165
+ },
166
+ "email": {
167
+ "name": "email",
168
+ "type": "text",
169
+ "primaryKey": false,
170
+ "notNull": false
171
+ },
172
+ "label": {
173
+ "name": "label",
174
+ "type": "text",
175
+ "primaryKey": false,
176
+ "notNull": false
177
+ },
178
+ "created_at": {
179
+ "name": "created_at",
180
+ "type": "timestamp",
181
+ "primaryKey": false,
182
+ "notNull": true,
183
+ "default": "now()"
184
+ }
185
+ },
186
+ "indexes": {
187
+ "system_contacts_system_user_unique": {
188
+ "name": "system_contacts_system_user_unique",
189
+ "columns": [
190
+ {
191
+ "expression": "system_id",
192
+ "isExpression": false,
193
+ "asc": true,
194
+ "nulls": "last"
195
+ },
196
+ {
197
+ "expression": "user_id",
198
+ "isExpression": false,
199
+ "asc": true,
200
+ "nulls": "last"
201
+ }
202
+ ],
203
+ "isUnique": true,
204
+ "concurrently": false,
205
+ "method": "btree",
206
+ "with": {}
207
+ },
208
+ "system_contacts_system_email_unique": {
209
+ "name": "system_contacts_system_email_unique",
210
+ "columns": [
211
+ {
212
+ "expression": "system_id",
213
+ "isExpression": false,
214
+ "asc": true,
215
+ "nulls": "last"
216
+ },
217
+ {
218
+ "expression": "email",
219
+ "isExpression": false,
220
+ "asc": true,
221
+ "nulls": "last"
222
+ }
223
+ ],
224
+ "isUnique": true,
225
+ "concurrently": false,
226
+ "method": "btree",
227
+ "with": {}
228
+ }
229
+ },
230
+ "foreignKeys": {
231
+ "system_contacts_system_id_systems_id_fk": {
232
+ "name": "system_contacts_system_id_systems_id_fk",
233
+ "tableFrom": "system_contacts",
234
+ "tableTo": "systems",
235
+ "columnsFrom": [
236
+ "system_id"
237
+ ],
238
+ "columnsTo": [
239
+ "id"
240
+ ],
241
+ "onDelete": "cascade",
242
+ "onUpdate": "no action"
243
+ }
244
+ },
245
+ "compositePrimaryKeys": {},
246
+ "uniqueConstraints": {},
247
+ "policies": {},
248
+ "checkConstraints": {},
249
+ "isRLSEnabled": false
250
+ },
251
+ "public.system_links": {
252
+ "name": "system_links",
253
+ "schema": "",
254
+ "columns": {
255
+ "id": {
256
+ "name": "id",
257
+ "type": "text",
258
+ "primaryKey": true,
259
+ "notNull": true
260
+ },
261
+ "system_id": {
262
+ "name": "system_id",
263
+ "type": "text",
264
+ "primaryKey": false,
265
+ "notNull": true
266
+ },
267
+ "label": {
268
+ "name": "label",
269
+ "type": "text",
270
+ "primaryKey": false,
271
+ "notNull": false
272
+ },
273
+ "url": {
274
+ "name": "url",
275
+ "type": "text",
276
+ "primaryKey": false,
277
+ "notNull": true
278
+ },
279
+ "created_at": {
280
+ "name": "created_at",
281
+ "type": "timestamp",
282
+ "primaryKey": false,
283
+ "notNull": true,
284
+ "default": "now()"
285
+ }
286
+ },
287
+ "indexes": {
288
+ "system_links_system_url_unique": {
289
+ "name": "system_links_system_url_unique",
290
+ "columns": [
291
+ {
292
+ "expression": "system_id",
293
+ "isExpression": false,
294
+ "asc": true,
295
+ "nulls": "last"
296
+ },
297
+ {
298
+ "expression": "url",
299
+ "isExpression": false,
300
+ "asc": true,
301
+ "nulls": "last"
302
+ }
303
+ ],
304
+ "isUnique": true,
305
+ "concurrently": false,
306
+ "method": "btree",
307
+ "with": {}
308
+ }
309
+ },
310
+ "foreignKeys": {
311
+ "system_links_system_id_systems_id_fk": {
312
+ "name": "system_links_system_id_systems_id_fk",
313
+ "tableFrom": "system_links",
314
+ "tableTo": "systems",
315
+ "columnsFrom": [
316
+ "system_id"
317
+ ],
318
+ "columnsTo": [
319
+ "id"
320
+ ],
321
+ "onDelete": "cascade",
322
+ "onUpdate": "no action"
323
+ }
324
+ },
325
+ "compositePrimaryKeys": {},
326
+ "uniqueConstraints": {},
327
+ "policies": {},
328
+ "checkConstraints": {},
329
+ "isRLSEnabled": false
330
+ },
331
+ "public.systems": {
332
+ "name": "systems",
333
+ "schema": "",
334
+ "columns": {
335
+ "id": {
336
+ "name": "id",
337
+ "type": "text",
338
+ "primaryKey": true,
339
+ "notNull": true
340
+ },
341
+ "name": {
342
+ "name": "name",
343
+ "type": "text",
344
+ "primaryKey": false,
345
+ "notNull": true
346
+ },
347
+ "description": {
348
+ "name": "description",
349
+ "type": "text",
350
+ "primaryKey": false,
351
+ "notNull": false
352
+ },
353
+ "metadata": {
354
+ "name": "metadata",
355
+ "type": "json",
356
+ "primaryKey": false,
357
+ "notNull": false,
358
+ "default": "'{}'::json"
359
+ },
360
+ "created_at": {
361
+ "name": "created_at",
362
+ "type": "timestamp",
363
+ "primaryKey": false,
364
+ "notNull": true,
365
+ "default": "now()"
366
+ },
367
+ "updated_at": {
368
+ "name": "updated_at",
369
+ "type": "timestamp",
370
+ "primaryKey": false,
371
+ "notNull": true,
372
+ "default": "now()"
373
+ }
374
+ },
375
+ "indexes": {
376
+ "systems_name_unique": {
377
+ "name": "systems_name_unique",
378
+ "columns": [
379
+ {
380
+ "expression": "lower(\"name\")",
381
+ "asc": true,
382
+ "isExpression": true,
383
+ "nulls": "last"
384
+ }
385
+ ],
386
+ "isUnique": true,
387
+ "concurrently": false,
388
+ "method": "btree",
389
+ "with": {}
390
+ }
391
+ },
392
+ "foreignKeys": {},
393
+ "compositePrimaryKeys": {},
394
+ "uniqueConstraints": {},
395
+ "policies": {},
396
+ "checkConstraints": {},
397
+ "isRLSEnabled": false
398
+ },
399
+ "public.systems_environments": {
400
+ "name": "systems_environments",
401
+ "schema": "",
402
+ "columns": {
403
+ "system_id": {
404
+ "name": "system_id",
405
+ "type": "text",
406
+ "primaryKey": false,
407
+ "notNull": true
408
+ },
409
+ "environment_id": {
410
+ "name": "environment_id",
411
+ "type": "text",
412
+ "primaryKey": false,
413
+ "notNull": true
414
+ }
415
+ },
416
+ "indexes": {},
417
+ "foreignKeys": {
418
+ "systems_environments_system_id_systems_id_fk": {
419
+ "name": "systems_environments_system_id_systems_id_fk",
420
+ "tableFrom": "systems_environments",
421
+ "tableTo": "systems",
422
+ "columnsFrom": [
423
+ "system_id"
424
+ ],
425
+ "columnsTo": [
426
+ "id"
427
+ ],
428
+ "onDelete": "cascade",
429
+ "onUpdate": "no action"
430
+ },
431
+ "systems_environments_environment_id_environments_id_fk": {
432
+ "name": "systems_environments_environment_id_environments_id_fk",
433
+ "tableFrom": "systems_environments",
434
+ "tableTo": "environments",
435
+ "columnsFrom": [
436
+ "environment_id"
437
+ ],
438
+ "columnsTo": [
439
+ "id"
440
+ ],
441
+ "onDelete": "cascade",
442
+ "onUpdate": "no action"
443
+ }
444
+ },
445
+ "compositePrimaryKeys": {
446
+ "systems_environments_system_id_environment_id_pk": {
447
+ "name": "systems_environments_system_id_environment_id_pk",
448
+ "columns": [
449
+ "system_id",
450
+ "environment_id"
451
+ ]
452
+ }
453
+ },
454
+ "uniqueConstraints": {},
455
+ "policies": {},
456
+ "checkConstraints": {},
457
+ "isRLSEnabled": false
458
+ },
459
+ "public.systems_groups": {
460
+ "name": "systems_groups",
461
+ "schema": "",
462
+ "columns": {
463
+ "system_id": {
464
+ "name": "system_id",
465
+ "type": "text",
466
+ "primaryKey": false,
467
+ "notNull": true
468
+ },
469
+ "group_id": {
470
+ "name": "group_id",
471
+ "type": "text",
472
+ "primaryKey": false,
473
+ "notNull": true
474
+ }
475
+ },
476
+ "indexes": {},
477
+ "foreignKeys": {
478
+ "systems_groups_system_id_systems_id_fk": {
479
+ "name": "systems_groups_system_id_systems_id_fk",
480
+ "tableFrom": "systems_groups",
481
+ "tableTo": "systems",
482
+ "columnsFrom": [
483
+ "system_id"
484
+ ],
485
+ "columnsTo": [
486
+ "id"
487
+ ],
488
+ "onDelete": "cascade",
489
+ "onUpdate": "no action"
490
+ },
491
+ "systems_groups_group_id_groups_id_fk": {
492
+ "name": "systems_groups_group_id_groups_id_fk",
493
+ "tableFrom": "systems_groups",
494
+ "tableTo": "groups",
495
+ "columnsFrom": [
496
+ "group_id"
497
+ ],
498
+ "columnsTo": [
499
+ "id"
500
+ ],
501
+ "onDelete": "cascade",
502
+ "onUpdate": "no action"
503
+ }
504
+ },
505
+ "compositePrimaryKeys": {
506
+ "systems_groups_system_id_group_id_pk": {
507
+ "name": "systems_groups_system_id_group_id_pk",
508
+ "columns": [
509
+ "system_id",
510
+ "group_id"
511
+ ]
512
+ }
513
+ },
514
+ "uniqueConstraints": {},
515
+ "policies": {},
516
+ "checkConstraints": {},
517
+ "isRLSEnabled": false
518
+ },
519
+ "public.views": {
520
+ "name": "views",
521
+ "schema": "",
522
+ "columns": {
523
+ "id": {
524
+ "name": "id",
525
+ "type": "text",
526
+ "primaryKey": true,
527
+ "notNull": true
528
+ },
529
+ "name": {
530
+ "name": "name",
531
+ "type": "text",
532
+ "primaryKey": false,
533
+ "notNull": true
534
+ },
535
+ "description": {
536
+ "name": "description",
537
+ "type": "text",
538
+ "primaryKey": false,
539
+ "notNull": false
540
+ },
541
+ "configuration": {
542
+ "name": "configuration",
543
+ "type": "json",
544
+ "primaryKey": false,
545
+ "notNull": true,
546
+ "default": "'[]'::json"
547
+ },
548
+ "created_at": {
549
+ "name": "created_at",
550
+ "type": "timestamp",
551
+ "primaryKey": false,
552
+ "notNull": true,
553
+ "default": "now()"
554
+ },
555
+ "updated_at": {
556
+ "name": "updated_at",
557
+ "type": "timestamp",
558
+ "primaryKey": false,
559
+ "notNull": true,
560
+ "default": "now()"
561
+ }
562
+ },
563
+ "indexes": {},
564
+ "foreignKeys": {},
565
+ "compositePrimaryKeys": {},
566
+ "uniqueConstraints": {},
567
+ "policies": {},
568
+ "checkConstraints": {},
569
+ "isRLSEnabled": false
570
+ }
571
+ },
572
+ "enums": {
573
+ "public.contact_type": {
574
+ "name": "contact_type",
575
+ "schema": "public",
576
+ "values": [
577
+ "user",
578
+ "mailbox"
579
+ ]
580
+ }
581
+ },
582
+ "schemas": {},
583
+ "sequences": {},
584
+ "roles": {},
585
+ "policies": {},
586
+ "views": {},
587
+ "_meta": {
588
+ "columns": {},
589
+ "schemas": {},
590
+ "tables": {}
591
+ }
592
+ }
@@ -22,6 +22,34 @@
22
22
  "when": 1777907813247,
23
23
  "tag": "0002_harsh_carmella_unuscione",
24
24
  "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "7",
29
+ "when": 1780354912371,
30
+ "tag": "0003_tan_spot",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "7",
36
+ "when": 1780594817551,
37
+ "tag": "0004_heavy_sharon_carter",
38
+ "breakpoints": true
39
+ },
40
+ {
41
+ "idx": 5,
42
+ "version": "7",
43
+ "when": 1780649274989,
44
+ "tag": "0005_normal_shaman",
45
+ "breakpoints": true
46
+ },
47
+ {
48
+ "idx": 6,
49
+ "version": "7",
50
+ "when": 1780651494240,
51
+ "tag": "0006_optimal_gamora",
52
+ "breakpoints": true
25
53
  }
26
54
  ]
27
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/catalog-backend",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "license": "Elastic-2.0",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -15,28 +15,31 @@
15
15
  "test": "bun test"
16
16
  },
17
17
  "dependencies": {
18
- "@checkstack/backend-api": "0.18.0",
19
- "@checkstack/automation-backend": "0.2.0",
20
- "@checkstack/cache-api": "0.3.6",
21
- "@checkstack/cache-utils": "0.2.11",
22
- "@checkstack/auth-common": "0.7.2",
23
- "@checkstack/catalog-common": "2.2.3",
24
- "@checkstack/command-backend": "0.1.31",
25
- "@checkstack/auth-backend": "0.4.31",
26
- "@checkstack/gitops-backend": "0.3.7",
27
- "@checkstack/gitops-common": "0.4.2",
28
- "@checkstack/notification-common": "1.2.1",
29
- "@orpc/server": "^1.13.2",
18
+ "@checkstack/backend-api": "0.21.0",
19
+ "@checkstack/ai-backend": "0.1.0",
20
+ "@checkstack/ai-common": "0.1.0",
21
+ "@checkstack/automation-backend": "0.5.0",
22
+ "@checkstack/cache-api": "0.3.9",
23
+ "@checkstack/cache-utils": "0.2.14",
24
+ "@checkstack/auth-common": "0.8.0",
25
+ "@checkstack/catalog-common": "2.3.0",
26
+ "@checkstack/command-backend": "0.2.0",
27
+ "@checkstack/auth-backend": "0.5.0",
28
+ "@checkstack/gitops-backend": "0.5.0",
29
+ "@checkstack/gitops-common": "0.6.0",
30
+ "@checkstack/notification-common": "1.3.0",
31
+ "@orpc/contract": "^1.14.4",
32
+ "@orpc/server": "^1.14.4",
30
33
  "drizzle-orm": "^0.45.0",
31
- "hono": "^4.12.14",
34
+ "hono": "^4.12.23",
32
35
  "uuid": "^14.0.0",
33
36
  "zod": "^4.2.1",
34
- "@checkstack/common": "0.12.0"
37
+ "@checkstack/common": "0.13.0"
35
38
  },
36
39
  "devDependencies": {
37
40
  "@checkstack/drizzle-helper": "0.0.5",
38
- "@checkstack/scripts": "0.3.4",
39
- "@checkstack/test-utils-backend": "0.1.31",
41
+ "@checkstack/scripts": "0.4.0",
42
+ "@checkstack/test-utils-backend": "0.1.34",
40
43
  "@checkstack/tsconfig": "0.0.7",
41
44
  "@types/bun": "^1.3.5",
42
45
  "@types/node": "^20.0.0",