@checkstack/automation-backend 0.2.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +453 -0
  2. package/drizzle/0000_acoustic_diamondback.sql +80 -0
  3. package/drizzle/0001_mute_vindicator.sql +12 -0
  4. package/drizzle/0002_silky_omega_red.sql +12 -0
  5. package/drizzle/meta/0000_snapshot.json +688 -0
  6. package/drizzle/meta/0001_snapshot.json +785 -0
  7. package/drizzle/meta/0002_snapshot.json +861 -0
  8. package/drizzle/meta/_journal.json +27 -0
  9. package/drizzle.config.ts +12 -0
  10. package/package.json +41 -0
  11. package/src/action-registry.ts +83 -0
  12. package/src/action-types.ts +324 -0
  13. package/src/artifact-store.ts +140 -0
  14. package/src/artifact-type-registry.ts +64 -0
  15. package/src/automation-store.ts +227 -0
  16. package/src/builtin-actions.test.ts +185 -0
  17. package/src/builtin-actions.ts +132 -0
  18. package/src/builtin-triggers.test.ts +264 -0
  19. package/src/builtin-triggers.ts +365 -0
  20. package/src/dispatch/action-kind.ts +44 -0
  21. package/src/dispatch/condition.ts +61 -0
  22. package/src/dispatch/delay-queue.ts +91 -0
  23. package/src/dispatch/engine.test.ts +1198 -0
  24. package/src/dispatch/engine.ts +1672 -0
  25. package/src/dispatch/path-nav.ts +65 -0
  26. package/src/dispatch/render.test.ts +75 -0
  27. package/src/dispatch/render.ts +136 -0
  28. package/src/dispatch/run-state-store.ts +143 -0
  29. package/src/dispatch/run-state.ts +298 -0
  30. package/src/dispatch/scope.test.ts +40 -0
  31. package/src/dispatch/scope.ts +125 -0
  32. package/src/dispatch/stalled-sweeper.ts +164 -0
  33. package/src/dispatch/test-fixtures.ts +558 -0
  34. package/src/dispatch/trigger-subscriber.ts +397 -0
  35. package/src/dispatch/types.ts +259 -0
  36. package/src/extension-points.ts +88 -0
  37. package/src/index.ts +379 -0
  38. package/src/migration/from-webhook-subscriptions.test.ts +237 -0
  39. package/src/migration/from-webhook-subscriptions.ts +398 -0
  40. package/src/registries.test.ts +357 -0
  41. package/src/router.test.ts +724 -0
  42. package/src/router.ts +556 -0
  43. package/src/schema.ts +310 -0
  44. package/src/trigger-registry.ts +99 -0
  45. package/src/validate-definition.test.ts +306 -0
  46. package/src/validate-definition.ts +304 -0
  47. package/tsconfig.json +41 -0
@@ -0,0 +1,688 @@
1
+ {
2
+ "id": "af7c1867-eb13-4cc1-9eca-9898055ec012",
3
+ "prevId": "00000000-0000-0000-0000-000000000000",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "public.automation_artifacts": {
8
+ "name": "automation_artifacts",
9
+ "schema": "",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "automation_id": {
18
+ "name": "automation_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "run_id": {
24
+ "name": "run_id",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "step_id": {
30
+ "name": "step_id",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true
34
+ },
35
+ "action_id": {
36
+ "name": "action_id",
37
+ "type": "text",
38
+ "primaryKey": false,
39
+ "notNull": false
40
+ },
41
+ "artifact_type": {
42
+ "name": "artifact_type",
43
+ "type": "text",
44
+ "primaryKey": false,
45
+ "notNull": true
46
+ },
47
+ "data": {
48
+ "name": "data",
49
+ "type": "jsonb",
50
+ "primaryKey": false,
51
+ "notNull": true
52
+ },
53
+ "context_key": {
54
+ "name": "context_key",
55
+ "type": "text",
56
+ "primaryKey": false,
57
+ "notNull": false
58
+ },
59
+ "closed_at": {
60
+ "name": "closed_at",
61
+ "type": "timestamp",
62
+ "primaryKey": false,
63
+ "notNull": false
64
+ },
65
+ "created_at": {
66
+ "name": "created_at",
67
+ "type": "timestamp",
68
+ "primaryKey": false,
69
+ "notNull": true,
70
+ "default": "now()"
71
+ }
72
+ },
73
+ "indexes": {
74
+ "automation_artifacts_context_lookup_idx": {
75
+ "name": "automation_artifacts_context_lookup_idx",
76
+ "columns": [
77
+ {
78
+ "expression": "automation_id",
79
+ "isExpression": false,
80
+ "asc": true,
81
+ "nulls": "last"
82
+ },
83
+ {
84
+ "expression": "context_key",
85
+ "isExpression": false,
86
+ "asc": true,
87
+ "nulls": "last"
88
+ },
89
+ {
90
+ "expression": "artifact_type",
91
+ "isExpression": false,
92
+ "asc": true,
93
+ "nulls": "last"
94
+ },
95
+ {
96
+ "expression": "created_at",
97
+ "isExpression": false,
98
+ "asc": true,
99
+ "nulls": "last"
100
+ }
101
+ ],
102
+ "isUnique": false,
103
+ "concurrently": false,
104
+ "method": "btree",
105
+ "with": {}
106
+ },
107
+ "automation_artifacts_action_lookup_idx": {
108
+ "name": "automation_artifacts_action_lookup_idx",
109
+ "columns": [
110
+ {
111
+ "expression": "automation_id",
112
+ "isExpression": false,
113
+ "asc": true,
114
+ "nulls": "last"
115
+ },
116
+ {
117
+ "expression": "action_id",
118
+ "isExpression": false,
119
+ "asc": true,
120
+ "nulls": "last"
121
+ },
122
+ {
123
+ "expression": "created_at",
124
+ "isExpression": false,
125
+ "asc": true,
126
+ "nulls": "last"
127
+ }
128
+ ],
129
+ "isUnique": false,
130
+ "concurrently": false,
131
+ "method": "btree",
132
+ "with": {}
133
+ },
134
+ "automation_artifacts_open_idx": {
135
+ "name": "automation_artifacts_open_idx",
136
+ "columns": [
137
+ {
138
+ "expression": "automation_id",
139
+ "isExpression": false,
140
+ "asc": true,
141
+ "nulls": "last"
142
+ },
143
+ {
144
+ "expression": "closed_at",
145
+ "isExpression": false,
146
+ "asc": true,
147
+ "nulls": "last"
148
+ }
149
+ ],
150
+ "isUnique": false,
151
+ "concurrently": false,
152
+ "method": "btree",
153
+ "with": {}
154
+ }
155
+ },
156
+ "foreignKeys": {
157
+ "automation_artifacts_automation_id_automations_id_fk": {
158
+ "name": "automation_artifacts_automation_id_automations_id_fk",
159
+ "tableFrom": "automation_artifacts",
160
+ "tableTo": "automations",
161
+ "columnsFrom": [
162
+ "automation_id"
163
+ ],
164
+ "columnsTo": [
165
+ "id"
166
+ ],
167
+ "onDelete": "cascade",
168
+ "onUpdate": "no action"
169
+ },
170
+ "automation_artifacts_run_id_automation_runs_id_fk": {
171
+ "name": "automation_artifacts_run_id_automation_runs_id_fk",
172
+ "tableFrom": "automation_artifacts",
173
+ "tableTo": "automation_runs",
174
+ "columnsFrom": [
175
+ "run_id"
176
+ ],
177
+ "columnsTo": [
178
+ "id"
179
+ ],
180
+ "onDelete": "cascade",
181
+ "onUpdate": "no action"
182
+ },
183
+ "automation_artifacts_step_id_automation_run_steps_id_fk": {
184
+ "name": "automation_artifacts_step_id_automation_run_steps_id_fk",
185
+ "tableFrom": "automation_artifacts",
186
+ "tableTo": "automation_run_steps",
187
+ "columnsFrom": [
188
+ "step_id"
189
+ ],
190
+ "columnsTo": [
191
+ "id"
192
+ ],
193
+ "onDelete": "cascade",
194
+ "onUpdate": "no action"
195
+ }
196
+ },
197
+ "compositePrimaryKeys": {},
198
+ "uniqueConstraints": {},
199
+ "policies": {},
200
+ "checkConstraints": {},
201
+ "isRLSEnabled": false
202
+ },
203
+ "public.automation_run_steps": {
204
+ "name": "automation_run_steps",
205
+ "schema": "",
206
+ "columns": {
207
+ "id": {
208
+ "name": "id",
209
+ "type": "text",
210
+ "primaryKey": true,
211
+ "notNull": true
212
+ },
213
+ "run_id": {
214
+ "name": "run_id",
215
+ "type": "text",
216
+ "primaryKey": false,
217
+ "notNull": true
218
+ },
219
+ "action_path": {
220
+ "name": "action_path",
221
+ "type": "text",
222
+ "primaryKey": false,
223
+ "notNull": true
224
+ },
225
+ "action_id": {
226
+ "name": "action_id",
227
+ "type": "text",
228
+ "primaryKey": false,
229
+ "notNull": false
230
+ },
231
+ "action_kind": {
232
+ "name": "action_kind",
233
+ "type": "text",
234
+ "primaryKey": false,
235
+ "notNull": true
236
+ },
237
+ "provider_action_id": {
238
+ "name": "provider_action_id",
239
+ "type": "text",
240
+ "primaryKey": false,
241
+ "notNull": false
242
+ },
243
+ "status": {
244
+ "name": "status",
245
+ "type": "text",
246
+ "primaryKey": false,
247
+ "notNull": true,
248
+ "default": "'pending'"
249
+ },
250
+ "attempts": {
251
+ "name": "attempts",
252
+ "type": "integer",
253
+ "primaryKey": false,
254
+ "notNull": true,
255
+ "default": 0
256
+ },
257
+ "error_message": {
258
+ "name": "error_message",
259
+ "type": "text",
260
+ "primaryKey": false,
261
+ "notNull": false
262
+ },
263
+ "result_payload": {
264
+ "name": "result_payload",
265
+ "type": "jsonb",
266
+ "primaryKey": false,
267
+ "notNull": false
268
+ },
269
+ "started_at": {
270
+ "name": "started_at",
271
+ "type": "timestamp",
272
+ "primaryKey": false,
273
+ "notNull": true,
274
+ "default": "now()"
275
+ },
276
+ "finished_at": {
277
+ "name": "finished_at",
278
+ "type": "timestamp",
279
+ "primaryKey": false,
280
+ "notNull": false
281
+ }
282
+ },
283
+ "indexes": {
284
+ "automation_run_steps_run_idx": {
285
+ "name": "automation_run_steps_run_idx",
286
+ "columns": [
287
+ {
288
+ "expression": "run_id",
289
+ "isExpression": false,
290
+ "asc": true,
291
+ "nulls": "last"
292
+ }
293
+ ],
294
+ "isUnique": false,
295
+ "concurrently": false,
296
+ "method": "btree",
297
+ "with": {}
298
+ }
299
+ },
300
+ "foreignKeys": {
301
+ "automation_run_steps_run_id_automation_runs_id_fk": {
302
+ "name": "automation_run_steps_run_id_automation_runs_id_fk",
303
+ "tableFrom": "automation_run_steps",
304
+ "tableTo": "automation_runs",
305
+ "columnsFrom": [
306
+ "run_id"
307
+ ],
308
+ "columnsTo": [
309
+ "id"
310
+ ],
311
+ "onDelete": "cascade",
312
+ "onUpdate": "no action"
313
+ }
314
+ },
315
+ "compositePrimaryKeys": {},
316
+ "uniqueConstraints": {},
317
+ "policies": {},
318
+ "checkConstraints": {},
319
+ "isRLSEnabled": false
320
+ },
321
+ "public.automation_runs": {
322
+ "name": "automation_runs",
323
+ "schema": "",
324
+ "columns": {
325
+ "id": {
326
+ "name": "id",
327
+ "type": "text",
328
+ "primaryKey": true,
329
+ "notNull": true
330
+ },
331
+ "automation_id": {
332
+ "name": "automation_id",
333
+ "type": "text",
334
+ "primaryKey": false,
335
+ "notNull": true
336
+ },
337
+ "trigger_id": {
338
+ "name": "trigger_id",
339
+ "type": "text",
340
+ "primaryKey": false,
341
+ "notNull": true
342
+ },
343
+ "trigger_event_id": {
344
+ "name": "trigger_event_id",
345
+ "type": "text",
346
+ "primaryKey": false,
347
+ "notNull": true
348
+ },
349
+ "trigger_payload": {
350
+ "name": "trigger_payload",
351
+ "type": "jsonb",
352
+ "primaryKey": false,
353
+ "notNull": true
354
+ },
355
+ "context_key": {
356
+ "name": "context_key",
357
+ "type": "text",
358
+ "primaryKey": false,
359
+ "notNull": false
360
+ },
361
+ "status": {
362
+ "name": "status",
363
+ "type": "text",
364
+ "primaryKey": false,
365
+ "notNull": true,
366
+ "default": "'pending'"
367
+ },
368
+ "error_message": {
369
+ "name": "error_message",
370
+ "type": "text",
371
+ "primaryKey": false,
372
+ "notNull": false
373
+ },
374
+ "started_at": {
375
+ "name": "started_at",
376
+ "type": "timestamp",
377
+ "primaryKey": false,
378
+ "notNull": true,
379
+ "default": "now()"
380
+ },
381
+ "finished_at": {
382
+ "name": "finished_at",
383
+ "type": "timestamp",
384
+ "primaryKey": false,
385
+ "notNull": false
386
+ }
387
+ },
388
+ "indexes": {
389
+ "automation_runs_automation_idx": {
390
+ "name": "automation_runs_automation_idx",
391
+ "columns": [
392
+ {
393
+ "expression": "automation_id",
394
+ "isExpression": false,
395
+ "asc": true,
396
+ "nulls": "last"
397
+ },
398
+ {
399
+ "expression": "started_at",
400
+ "isExpression": false,
401
+ "asc": true,
402
+ "nulls": "last"
403
+ }
404
+ ],
405
+ "isUnique": false,
406
+ "concurrently": false,
407
+ "method": "btree",
408
+ "with": {}
409
+ },
410
+ "automation_runs_status_idx": {
411
+ "name": "automation_runs_status_idx",
412
+ "columns": [
413
+ {
414
+ "expression": "status",
415
+ "isExpression": false,
416
+ "asc": true,
417
+ "nulls": "last"
418
+ }
419
+ ],
420
+ "isUnique": false,
421
+ "concurrently": false,
422
+ "method": "btree",
423
+ "with": {}
424
+ },
425
+ "automation_runs_context_key_idx": {
426
+ "name": "automation_runs_context_key_idx",
427
+ "columns": [
428
+ {
429
+ "expression": "automation_id",
430
+ "isExpression": false,
431
+ "asc": true,
432
+ "nulls": "last"
433
+ },
434
+ {
435
+ "expression": "context_key",
436
+ "isExpression": false,
437
+ "asc": true,
438
+ "nulls": "last"
439
+ }
440
+ ],
441
+ "isUnique": false,
442
+ "concurrently": false,
443
+ "method": "btree",
444
+ "with": {}
445
+ }
446
+ },
447
+ "foreignKeys": {
448
+ "automation_runs_automation_id_automations_id_fk": {
449
+ "name": "automation_runs_automation_id_automations_id_fk",
450
+ "tableFrom": "automation_runs",
451
+ "tableTo": "automations",
452
+ "columnsFrom": [
453
+ "automation_id"
454
+ ],
455
+ "columnsTo": [
456
+ "id"
457
+ ],
458
+ "onDelete": "cascade",
459
+ "onUpdate": "no action"
460
+ }
461
+ },
462
+ "compositePrimaryKeys": {},
463
+ "uniqueConstraints": {},
464
+ "policies": {},
465
+ "checkConstraints": {},
466
+ "isRLSEnabled": false
467
+ },
468
+ "public.automation_wait_locks": {
469
+ "name": "automation_wait_locks",
470
+ "schema": "",
471
+ "columns": {
472
+ "id": {
473
+ "name": "id",
474
+ "type": "text",
475
+ "primaryKey": true,
476
+ "notNull": true
477
+ },
478
+ "run_id": {
479
+ "name": "run_id",
480
+ "type": "text",
481
+ "primaryKey": false,
482
+ "notNull": true
483
+ },
484
+ "action_path": {
485
+ "name": "action_path",
486
+ "type": "text",
487
+ "primaryKey": false,
488
+ "notNull": true
489
+ },
490
+ "event_id": {
491
+ "name": "event_id",
492
+ "type": "text",
493
+ "primaryKey": false,
494
+ "notNull": true
495
+ },
496
+ "context_key": {
497
+ "name": "context_key",
498
+ "type": "text",
499
+ "primaryKey": false,
500
+ "notNull": false
501
+ },
502
+ "filter_template": {
503
+ "name": "filter_template",
504
+ "type": "text",
505
+ "primaryKey": false,
506
+ "notNull": false
507
+ },
508
+ "timeout_at": {
509
+ "name": "timeout_at",
510
+ "type": "timestamp",
511
+ "primaryKey": false,
512
+ "notNull": false
513
+ },
514
+ "created_at": {
515
+ "name": "created_at",
516
+ "type": "timestamp",
517
+ "primaryKey": false,
518
+ "notNull": true,
519
+ "default": "now()"
520
+ }
521
+ },
522
+ "indexes": {
523
+ "automation_wait_locks_event_lookup_idx": {
524
+ "name": "automation_wait_locks_event_lookup_idx",
525
+ "columns": [
526
+ {
527
+ "expression": "event_id",
528
+ "isExpression": false,
529
+ "asc": true,
530
+ "nulls": "last"
531
+ },
532
+ {
533
+ "expression": "context_key",
534
+ "isExpression": false,
535
+ "asc": true,
536
+ "nulls": "last"
537
+ }
538
+ ],
539
+ "isUnique": false,
540
+ "concurrently": false,
541
+ "method": "btree",
542
+ "with": {}
543
+ },
544
+ "automation_wait_locks_timeout_idx": {
545
+ "name": "automation_wait_locks_timeout_idx",
546
+ "columns": [
547
+ {
548
+ "expression": "timeout_at",
549
+ "isExpression": false,
550
+ "asc": true,
551
+ "nulls": "last"
552
+ }
553
+ ],
554
+ "isUnique": false,
555
+ "concurrently": false,
556
+ "method": "btree",
557
+ "with": {}
558
+ }
559
+ },
560
+ "foreignKeys": {
561
+ "automation_wait_locks_run_id_automation_runs_id_fk": {
562
+ "name": "automation_wait_locks_run_id_automation_runs_id_fk",
563
+ "tableFrom": "automation_wait_locks",
564
+ "tableTo": "automation_runs",
565
+ "columnsFrom": [
566
+ "run_id"
567
+ ],
568
+ "columnsTo": [
569
+ "id"
570
+ ],
571
+ "onDelete": "cascade",
572
+ "onUpdate": "no action"
573
+ }
574
+ },
575
+ "compositePrimaryKeys": {},
576
+ "uniqueConstraints": {},
577
+ "policies": {},
578
+ "checkConstraints": {},
579
+ "isRLSEnabled": false
580
+ },
581
+ "public.automations": {
582
+ "name": "automations",
583
+ "schema": "",
584
+ "columns": {
585
+ "id": {
586
+ "name": "id",
587
+ "type": "text",
588
+ "primaryKey": true,
589
+ "notNull": true
590
+ },
591
+ "name": {
592
+ "name": "name",
593
+ "type": "text",
594
+ "primaryKey": false,
595
+ "notNull": true
596
+ },
597
+ "description": {
598
+ "name": "description",
599
+ "type": "text",
600
+ "primaryKey": false,
601
+ "notNull": false
602
+ },
603
+ "status": {
604
+ "name": "status",
605
+ "type": "text",
606
+ "primaryKey": false,
607
+ "notNull": true,
608
+ "default": "'enabled'"
609
+ },
610
+ "definition": {
611
+ "name": "definition",
612
+ "type": "jsonb",
613
+ "primaryKey": false,
614
+ "notNull": true
615
+ },
616
+ "managed_by": {
617
+ "name": "managed_by",
618
+ "type": "text",
619
+ "primaryKey": false,
620
+ "notNull": false
621
+ },
622
+ "created_at": {
623
+ "name": "created_at",
624
+ "type": "timestamp",
625
+ "primaryKey": false,
626
+ "notNull": true,
627
+ "default": "now()"
628
+ },
629
+ "updated_at": {
630
+ "name": "updated_at",
631
+ "type": "timestamp",
632
+ "primaryKey": false,
633
+ "notNull": true,
634
+ "default": "now()"
635
+ }
636
+ },
637
+ "indexes": {
638
+ "automations_status_idx": {
639
+ "name": "automations_status_idx",
640
+ "columns": [
641
+ {
642
+ "expression": "status",
643
+ "isExpression": false,
644
+ "asc": true,
645
+ "nulls": "last"
646
+ }
647
+ ],
648
+ "isUnique": false,
649
+ "concurrently": false,
650
+ "method": "btree",
651
+ "with": {}
652
+ },
653
+ "automations_managed_by_idx": {
654
+ "name": "automations_managed_by_idx",
655
+ "columns": [
656
+ {
657
+ "expression": "managed_by",
658
+ "isExpression": false,
659
+ "asc": true,
660
+ "nulls": "last"
661
+ }
662
+ ],
663
+ "isUnique": false,
664
+ "concurrently": false,
665
+ "method": "btree",
666
+ "with": {}
667
+ }
668
+ },
669
+ "foreignKeys": {},
670
+ "compositePrimaryKeys": {},
671
+ "uniqueConstraints": {},
672
+ "policies": {},
673
+ "checkConstraints": {},
674
+ "isRLSEnabled": false
675
+ }
676
+ },
677
+ "enums": {},
678
+ "schemas": {},
679
+ "sequences": {},
680
+ "roles": {},
681
+ "policies": {},
682
+ "views": {},
683
+ "_meta": {
684
+ "columns": {},
685
+ "schemas": {},
686
+ "tables": {}
687
+ }
688
+ }