@happyvertical/smrt-approvals 0.57.3 → 0.57.5

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.
@@ -2,163 +2,18 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-approvals",
5
- "packageVersion": "0.57.3",
5
+ "packageVersion": "0.57.5",
6
6
  "objects": {
7
- "@happyvertical/smrt-approvals:ApprovalEvent": {
8
- "name": "approvalevent",
9
- "className": "ApprovalEvent",
10
- "qualifiedName": "@happyvertical/smrt-approvals:ApprovalEvent",
7
+ "@happyvertical/smrt-approvals:ApprovalEventCollection": {
8
+ "name": "approvaleventcollection",
9
+ "className": "ApprovalEventCollection",
10
+ "qualifiedName": "@happyvertical/smrt-approvals:ApprovalEventCollection",
11
11
  "collection": "approvalevents",
12
- "description": "One immutable entry in an approval request's history.",
13
- "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/models/ApprovalEvent.ts",
12
+ "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/collections/ApprovalEventCollection.ts",
14
13
  "packageName": "@happyvertical/smrt-approvals",
15
- "fields": {
16
- "tenantId": {
17
- "type": "text",
18
- "required": true,
19
- "_meta": {
20
- "sqlType": "UUID",
21
- "__tenancy": {
22
- "isTenantIdField": true,
23
- "autoFilter": true,
24
- "required": true,
25
- "autoPopulate": true,
26
- "nullable": false,
27
- "mode": "required",
28
- "field": "tenantId",
29
- "allowSuperAdminBypass": false
30
- }
31
- }
32
- },
33
- "requestId": {
34
- "type": "foreignKey",
35
- "required": true,
36
- "related": "ApprovalRequest",
37
- "_meta": {
38
- "required": true,
39
- "constraint": {
40
- "engines": [
41
- "postgres",
42
- "sqlite"
43
- ]
44
- },
45
- "onDelete": "RESTRICT",
46
- "onUpdate": "RESTRICT"
47
- }
48
- },
49
- "type": {
50
- "type": "text",
51
- "required": true,
52
- "_meta": {
53
- "required": true,
54
- "readonly": true
55
- },
56
- "readonly": true
57
- },
58
- "actorId": {
59
- "type": "text",
60
- "required": true,
61
- "_meta": {
62
- "required": true,
63
- "readonly": true
64
- },
65
- "readonly": true
66
- },
67
- "actorType": {
68
- "type": "text",
69
- "required": false,
70
- "_meta": {
71
- "readonly": true
72
- },
73
- "enum": [
74
- "human",
75
- "agent",
76
- "service"
77
- ],
78
- "readonly": true
79
- },
80
- "reason": {
81
- "type": "text",
82
- "required": false,
83
- "_meta": {
84
- "readonly": true
85
- },
86
- "readonly": true
87
- },
88
- "subjectRevisionHash": {
89
- "type": "text",
90
- "required": false,
91
- "_meta": {
92
- "readonly": true
93
- },
94
- "readonly": true
95
- },
96
- "sequence": {
97
- "type": "integer",
98
- "required": false,
99
- "_meta": {
100
- "readonly": true
101
- },
102
- "readonly": true
103
- },
104
- "voteKey": {
105
- "type": "text",
106
- "required": false,
107
- "_meta": {
108
- "nullable": true,
109
- "readonly": true
110
- },
111
- "readonly": true
112
- },
113
- "occurredAt": {
114
- "type": "datetime",
115
- "required": false,
116
- "_meta": {
117
- "readonly": true
118
- },
119
- "readonly": true
120
- },
121
- "selfApproved": {
122
- "type": "boolean",
123
- "required": false,
124
- "default": false,
125
- "_meta": {
126
- "readonly": true,
127
- "default": false
128
- },
129
- "readonly": true
130
- },
131
- "selfApprovalPermission": {
132
- "type": "text",
133
- "required": false,
134
- "default": "",
135
- "_meta": {
136
- "readonly": true,
137
- "default": ""
138
- },
139
- "readonly": true
140
- }
141
- },
142
- "methods": {
143
- "save": {
144
- "name": "save",
145
- "async": true,
146
- "parameters": [],
147
- "returnType": "Promise<this>",
148
- "isStatic": false,
149
- "isPublic": true
150
- },
151
- "delete": {
152
- "name": "delete",
153
- "async": true,
154
- "parameters": [],
155
- "returnType": "Promise<void>",
156
- "isStatic": false,
157
- "isPublic": true
158
- }
159
- },
14
+ "fields": {},
15
+ "methods": {},
160
16
  "decoratorConfig": {
161
- "tableName": "approval_events",
162
17
  "api": {
163
18
  "include": [
164
19
  "list",
@@ -172,60 +27,12 @@
172
27
  ]
173
28
  },
174
29
  "cli": false,
175
- "indexes": [
176
- {
177
- "name": "approval_events_request_sequence_key",
178
- "columns": [
179
- "requestId",
180
- "sequence"
181
- ],
182
- "unique": true
183
- },
184
- {
185
- "name": "approval_events_request_vote_key",
186
- "columns": [
187
- "requestId",
188
- "voteKey"
189
- ],
190
- "unique": true
191
- },
192
- {
193
- "name": "approval_events_tenant_occurred_idx",
194
- "columns": [
195
- "tenantId",
196
- "occurredAt"
197
- ]
198
- }
199
- ],
200
- "tenantScoped": {
201
- "mode": "required"
202
- },
203
- "conflictColumns": [
204
- "tenant_id",
205
- "slug",
206
- "context"
207
- ]
30
+ "tableName": "approval_events"
208
31
  },
209
- "extends": "SmrtObject",
210
- "exportName": "ApprovalEvent",
211
- "collectionExportName": "ApprovalEventCollection",
212
- "validationRules": [
213
- {
214
- "field": "requestId",
215
- "rule": "required",
216
- "fieldType": "foreignKey"
217
- },
218
- {
219
- "field": "type",
220
- "rule": "required",
221
- "fieldType": "text"
222
- },
223
- {
224
- "field": "actorId",
225
- "rule": "required",
226
- "fieldType": "text"
227
- }
228
- ],
32
+ "extends": "SmrtCollection",
33
+ "extendsTypeArg": "ApprovalEvent",
34
+ "exportName": "ApprovalEventCollection",
35
+ "collectionExportName": "ApprovalEventCollectionCollection",
229
36
  "schema": {
230
37
  "tableName": "approval_events",
231
38
  "ddl": "CREATE TABLE IF NOT EXISTS \"approval_events\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"request_id\" UUID NOT NULL,\n \"type\" TEXT NOT NULL,\n \"actor_id\" TEXT NOT NULL,\n \"actor_type\" TEXT,\n \"reason\" TEXT,\n \"subject_revision_hash\" TEXT,\n \"sequence\" INTEGER,\n \"vote_key\" TEXT,\n \"occurred_at\" TIMESTAMP,\n \"self_approved\" BOOLEAN DEFAULT FALSE,\n \"self_approval_permission\" TEXT DEFAULT ''\n);",
@@ -375,77 +182,21 @@
375
182
  },
376
183
  "importPath": "@happyvertical/smrt-approvals"
377
184
  },
378
- "@happyvertical/smrt-approvals:ApprovalPolicy": {
379
- "name": "approvalpolicy",
380
- "className": "ApprovalPolicy",
381
- "qualifiedName": "@happyvertical/smrt-approvals:ApprovalPolicy",
185
+ "@happyvertical/smrt-approvals:ApprovalPolicyCollection": {
186
+ "name": "approvalpolicycollection",
187
+ "className": "ApprovalPolicyCollection",
188
+ "qualifiedName": "@happyvertical/smrt-approvals:ApprovalPolicyCollection",
382
189
  "collection": "approvalpolicies",
383
- "description": "Tenant-level tightening of an approval kind. One row per tenant and kind.",
384
- "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/models/ApprovalPolicy.ts",
190
+ "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/collections/ApprovalPolicyCollection.ts",
385
191
  "packageName": "@happyvertical/smrt-approvals",
386
- "fields": {
387
- "tenantId": {
388
- "type": "text",
389
- "required": true,
390
- "_meta": {
391
- "sqlType": "UUID",
392
- "__tenancy": {
393
- "isTenantIdField": true,
394
- "autoFilter": true,
395
- "required": true,
396
- "autoPopulate": true,
397
- "nullable": false,
398
- "mode": "required",
399
- "field": "tenantId",
400
- "allowSuperAdminBypass": false
401
- }
402
- }
403
- },
404
- "kind": {
405
- "type": "text",
406
- "required": true,
407
- "_meta": {
408
- "required": true
409
- }
410
- },
411
- "requiredApprovals": {
412
- "type": "integer",
413
- "required": false,
414
- "_meta": {}
415
- },
416
- "ttlMs": {
417
- "type": "integer",
418
- "required": false,
419
- "_meta": {}
420
- },
421
- "requiredPermission": {
422
- "type": "text",
423
- "required": false,
424
- "_meta": {}
425
- },
426
- "updatedBy": {
427
- "type": "text",
428
- "required": false,
429
- "_meta": {}
430
- }
431
- },
432
- "methods": {
433
- "save": {
434
- "name": "save",
435
- "async": true,
436
- "parameters": [],
437
- "returnType": "Promise<this>",
438
- "isStatic": false,
439
- "isPublic": true
440
- }
441
- },
442
- "decoratorConfig": {
443
- "tableName": "approval_policies",
444
- "api": {
445
- "include": [
446
- "list",
447
- "get"
448
- ]
192
+ "fields": {},
193
+ "methods": {},
194
+ "decoratorConfig": {
195
+ "api": {
196
+ "include": [
197
+ "list",
198
+ "get"
199
+ ]
449
200
  },
450
201
  "mcp": {
451
202
  "include": [
@@ -454,35 +205,12 @@
454
205
  ]
455
206
  },
456
207
  "cli": false,
457
- "indexes": [
458
- {
459
- "name": "approval_policies_tenant_kind_key",
460
- "columns": [
461
- "tenantId",
462
- "kind"
463
- ],
464
- "unique": true
465
- }
466
- ],
467
- "tenantScoped": {
468
- "mode": "required"
469
- },
470
- "conflictColumns": [
471
- "tenant_id",
472
- "slug",
473
- "context"
474
- ]
208
+ "tableName": "approval_policies"
475
209
  },
476
- "extends": "SmrtObject",
477
- "exportName": "ApprovalPolicy",
478
- "collectionExportName": "ApprovalPolicyCollection",
479
- "validationRules": [
480
- {
481
- "field": "kind",
482
- "rule": "required",
483
- "fieldType": "text"
484
- }
485
- ],
210
+ "extends": "SmrtCollection",
211
+ "extendsTypeArg": "ApprovalPolicy",
212
+ "exportName": "ApprovalPolicyCollection",
213
+ "collectionExportName": "ApprovalPolicyCollectionCollection",
486
214
  "schema": {
487
215
  "tableName": "approval_policies",
488
216
  "ddl": "CREATE TABLE IF NOT EXISTS \"approval_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL,\n \"required_approvals\" INTEGER,\n \"ttl_ms\" INTEGER,\n \"required_permission\" TEXT,\n \"updated_by\" TEXT\n);",
@@ -574,376 +302,89 @@
574
302
  },
575
303
  "importPath": "@happyvertical/smrt-approvals"
576
304
  },
577
- "@happyvertical/smrt-approvals:ApprovalRequest": {
578
- "name": "approvalrequest",
579
- "className": "ApprovalRequest",
580
- "qualifiedName": "@happyvertical/smrt-approvals:ApprovalRequest",
305
+ "@happyvertical/smrt-approvals:ApprovalRequestCollection": {
306
+ "name": "approvalrequestcollection",
307
+ "className": "ApprovalRequestCollection",
308
+ "qualifiedName": "@happyvertical/smrt-approvals:ApprovalRequestCollection",
581
309
  "collection": "approvalrequests",
582
- "description": "A request for approval of one subject revision.",
583
- "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/models/ApprovalRequest.ts",
310
+ "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/collections/ApprovalRequestCollection.ts",
584
311
  "packageName": "@happyvertical/smrt-approvals",
585
- "fields": {
586
- "tenantId": {
587
- "type": "text",
588
- "required": true,
589
- "_meta": {
590
- "sqlType": "UUID",
591
- "__tenancy": {
592
- "isTenantIdField": true,
593
- "autoFilter": true,
594
- "required": true,
595
- "autoPopulate": true,
596
- "nullable": false,
597
- "mode": "required",
598
- "field": "tenantId",
599
- "allowSuperAdminBypass": false
600
- }
601
- }
312
+ "fields": {},
313
+ "methods": {},
314
+ "decoratorConfig": {
315
+ "api": {
316
+ "include": [
317
+ "list",
318
+ "get"
319
+ ]
602
320
  },
603
- "kind": {
604
- "type": "text",
605
- "required": true,
606
- "_meta": {
607
- "required": true,
608
- "readonly": true
609
- },
610
- "readonly": true
321
+ "mcp": {
322
+ "include": [
323
+ "list",
324
+ "get"
325
+ ]
611
326
  },
612
- "subjectType": {
613
- "type": "text",
614
- "required": true,
615
- "_meta": {
616
- "required": true,
617
- "readonly": true
327
+ "cli": false,
328
+ "tableName": "approval_requests"
329
+ },
330
+ "extends": "SmrtCollection",
331
+ "extendsTypeArg": "ApprovalRequest",
332
+ "exportName": "ApprovalRequestCollection",
333
+ "collectionExportName": "ApprovalRequestCollectionCollection",
334
+ "schema": {
335
+ "tableName": "approval_requests",
336
+ "ddl": "CREATE TABLE IF NOT EXISTS \"approval_requests\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL,\n \"subject_type\" TEXT NOT NULL,\n \"subject_id\" TEXT NOT NULL,\n \"subject_revision_hash\" TEXT NOT NULL,\n \"request_key\" TEXT NOT NULL,\n \"requested_by\" TEXT NOT NULL,\n \"requested_by_type\" TEXT,\n \"summary\" TEXT,\n \"status\" TEXT,\n \"required_approvals\" INTEGER,\n \"approval_count\" INTEGER,\n \"required_permissions\" TEXT,\n \"version\" INTEGER,\n \"expires_at\" TIMESTAMP,\n \"decided_at\" TIMESTAMP,\n \"consumed_at\" TIMESTAMP,\n \"consumed_by\" TEXT\n);",
337
+ "columns": {
338
+ "id": {
339
+ "type": "UUID",
340
+ "primaryKey": true,
341
+ "referenceKind": "id",
342
+ "notNull": true
618
343
  },
619
- "readonly": true
620
- },
621
- "subjectId": {
622
- "type": "text",
623
- "required": true,
624
- "_meta": {
625
- "required": true,
626
- "readonly": true
344
+ "slug": {
345
+ "type": "TEXT",
346
+ "notNull": true
627
347
  },
628
- "readonly": true
629
- },
630
- "subjectRevisionHash": {
631
- "type": "text",
632
- "required": true,
633
- "_meta": {
634
- "required": true,
635
- "readonly": true
348
+ "context": {
349
+ "type": "TEXT",
350
+ "notNull": true,
351
+ "default": ""
636
352
  },
637
- "readonly": true
638
- },
639
- "requestKey": {
640
- "type": "text",
641
- "required": true,
642
- "_meta": {
643
- "required": true,
644
- "readonly": true
353
+ "created_at": {
354
+ "type": "TIMESTAMP",
355
+ "notNull": true,
356
+ "default": "current_timestamp"
645
357
  },
646
- "readonly": true
647
- },
648
- "requestedBy": {
649
- "type": "text",
650
- "required": true,
651
- "_meta": {
652
- "required": true,
653
- "readonly": true
358
+ "updated_at": {
359
+ "type": "TIMESTAMP",
360
+ "notNull": true,
361
+ "default": "current_timestamp"
654
362
  },
655
- "readonly": true
656
- },
657
- "requestedByType": {
658
- "type": "text",
659
- "required": false,
660
- "_meta": {
661
- "readonly": true
363
+ "tenant_id": {
364
+ "type": "UUID",
365
+ "referenceKind": "tenantId",
366
+ "notNull": true,
367
+ "unique": false
662
368
  },
663
- "enum": [
664
- "human",
665
- "agent",
666
- "service"
667
- ],
668
- "readonly": true
669
- },
670
- "summary": {
671
- "type": "text",
672
- "required": false,
673
- "_meta": {
674
- "readonly": true
369
+ "kind": {
370
+ "type": "TEXT",
371
+ "notNull": true,
372
+ "unique": false
675
373
  },
676
- "readonly": true
677
- },
678
- "status": {
679
- "type": "text",
680
- "required": false,
681
- "_meta": {
682
- "readonly": true
374
+ "subject_type": {
375
+ "type": "TEXT",
376
+ "notNull": true,
377
+ "unique": false
683
378
  },
684
- "readonly": true
685
- },
686
- "requiredApprovals": {
687
- "type": "integer",
688
- "required": false,
689
- "_meta": {
690
- "readonly": true
379
+ "subject_id": {
380
+ "type": "TEXT",
381
+ "notNull": true,
382
+ "unique": false
691
383
  },
692
- "readonly": true
693
- },
694
- "approvalCount": {
695
- "type": "integer",
696
- "required": false,
697
- "_meta": {
698
- "readonly": true
699
- },
700
- "readonly": true
701
- },
702
- "requiredPermissions": {
703
- "type": "text",
704
- "required": false,
705
- "_meta": {
706
- "readonly": true
707
- },
708
- "readonly": true
709
- },
710
- "version": {
711
- "type": "integer",
712
- "required": false,
713
- "_meta": {
714
- "readonly": true
715
- },
716
- "readonly": true
717
- },
718
- "expiresAt": {
719
- "type": "datetime",
720
- "required": false,
721
- "_meta": {
722
- "readonly": true
723
- },
724
- "readonly": true
725
- },
726
- "decidedAt": {
727
- "type": "datetime",
728
- "required": false,
729
- "_meta": {
730
- "readonly": true
731
- },
732
- "readonly": true
733
- },
734
- "consumedAt": {
735
- "type": "datetime",
736
- "required": false,
737
- "_meta": {
738
- "readonly": true
739
- },
740
- "readonly": true
741
- },
742
- "consumedBy": {
743
- "type": "text",
744
- "required": false,
745
- "_meta": {
746
- "readonly": true
747
- },
748
- "readonly": true
749
- }
750
- },
751
- "methods": {
752
- "getRequiredPermissions": {
753
- "name": "getRequiredPermissions",
754
- "async": false,
755
- "parameters": [],
756
- "returnType": "string[]",
757
- "isStatic": false,
758
- "isPublic": true
759
- },
760
- "setRequiredPermissions": {
761
- "name": "setRequiredPermissions",
762
- "async": false,
763
- "parameters": [
764
- {
765
- "name": "slugs",
766
- "type": "any",
767
- "optional": false,
768
- "typeUnresolved": true
769
- }
770
- ],
771
- "returnType": "void",
772
- "isStatic": false,
773
- "isPublic": true
774
- },
775
- "expiresAtMs": {
776
- "name": "expiresAtMs",
777
- "async": false,
778
- "parameters": [],
779
- "returnType": "number",
780
- "isStatic": false,
781
- "isPublic": true
782
- },
783
- "isConsumed": {
784
- "name": "isConsumed",
785
- "async": false,
786
- "parameters": [],
787
- "returnType": "boolean",
788
- "isStatic": false,
789
- "isPublic": true
790
- },
791
- "save": {
792
- "name": "save",
793
- "async": true,
794
- "parameters": [],
795
- "returnType": "Promise<this>",
796
- "isStatic": false,
797
- "isPublic": true
798
- },
799
- "delete": {
800
- "name": "delete",
801
- "async": true,
802
- "parameters": [],
803
- "returnType": "Promise<void>",
804
- "isStatic": false,
805
- "isPublic": true
806
- }
807
- },
808
- "decoratorConfig": {
809
- "tableName": "approval_requests",
810
- "api": {
811
- "include": [
812
- "list",
813
- "get"
814
- ]
815
- },
816
- "mcp": {
817
- "include": [
818
- "list",
819
- "get"
820
- ]
821
- },
822
- "cli": false,
823
- "indexes": [
824
- {
825
- "name": "approval_requests_tenant_request_key",
826
- "columns": [
827
- "tenantId",
828
- "requestKey"
829
- ],
830
- "unique": true
831
- },
832
- {
833
- "name": "approval_requests_status_expiry_idx",
834
- "columns": [
835
- "tenantId",
836
- "status",
837
- "expiresAt"
838
- ]
839
- },
840
- {
841
- "name": "approval_requests_subject_idx",
842
- "columns": [
843
- "tenantId",
844
- "subjectType",
845
- "subjectId"
846
- ]
847
- }
848
- ],
849
- "tenantScoped": {
850
- "mode": "required"
851
- },
852
- "conflictColumns": [
853
- "tenant_id",
854
- "slug",
855
- "context"
856
- ]
857
- },
858
- "extends": "SmrtObject",
859
- "exportName": "ApprovalRequest",
860
- "collectionExportName": "ApprovalRequestCollection",
861
- "validationRules": [
862
- {
863
- "field": "kind",
864
- "rule": "required",
865
- "fieldType": "text"
866
- },
867
- {
868
- "field": "subjectType",
869
- "rule": "required",
870
- "fieldType": "text"
871
- },
872
- {
873
- "field": "subjectId",
874
- "rule": "required",
875
- "fieldType": "text"
876
- },
877
- {
878
- "field": "subjectRevisionHash",
879
- "rule": "required",
880
- "fieldType": "text"
881
- },
882
- {
883
- "field": "requestKey",
884
- "rule": "required",
885
- "fieldType": "text"
886
- },
887
- {
888
- "field": "requestedBy",
889
- "rule": "required",
890
- "fieldType": "text"
891
- }
892
- ],
893
- "schema": {
894
- "tableName": "approval_requests",
895
- "ddl": "CREATE TABLE IF NOT EXISTS \"approval_requests\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL,\n \"subject_type\" TEXT NOT NULL,\n \"subject_id\" TEXT NOT NULL,\n \"subject_revision_hash\" TEXT NOT NULL,\n \"request_key\" TEXT NOT NULL,\n \"requested_by\" TEXT NOT NULL,\n \"requested_by_type\" TEXT,\n \"summary\" TEXT,\n \"status\" TEXT,\n \"required_approvals\" INTEGER,\n \"approval_count\" INTEGER,\n \"required_permissions\" TEXT,\n \"version\" INTEGER,\n \"expires_at\" TIMESTAMP,\n \"decided_at\" TIMESTAMP,\n \"consumed_at\" TIMESTAMP,\n \"consumed_by\" TEXT\n);",
896
- "columns": {
897
- "id": {
898
- "type": "UUID",
899
- "primaryKey": true,
900
- "referenceKind": "id",
901
- "notNull": true
902
- },
903
- "slug": {
904
- "type": "TEXT",
905
- "notNull": true
906
- },
907
- "context": {
908
- "type": "TEXT",
909
- "notNull": true,
910
- "default": ""
911
- },
912
- "created_at": {
913
- "type": "TIMESTAMP",
914
- "notNull": true,
915
- "default": "current_timestamp"
916
- },
917
- "updated_at": {
918
- "type": "TIMESTAMP",
919
- "notNull": true,
920
- "default": "current_timestamp"
921
- },
922
- "tenant_id": {
923
- "type": "UUID",
924
- "referenceKind": "tenantId",
925
- "notNull": true,
926
- "unique": false
927
- },
928
- "kind": {
929
- "type": "TEXT",
930
- "notNull": true,
931
- "unique": false
932
- },
933
- "subject_type": {
934
- "type": "TEXT",
935
- "notNull": true,
936
- "unique": false
937
- },
938
- "subject_id": {
939
- "type": "TEXT",
940
- "notNull": true,
941
- "unique": false
942
- },
943
- "subject_revision_hash": {
944
- "type": "TEXT",
945
- "notNull": true,
946
- "unique": false
384
+ "subject_revision_hash": {
385
+ "type": "TEXT",
386
+ "notNull": true,
387
+ "unique": false
947
388
  },
948
389
  "request_key": {
949
390
  "type": "TEXT",
@@ -1057,16 +498,161 @@
1057
498
  },
1058
499
  "importPath": "@happyvertical/smrt-approvals"
1059
500
  },
1060
- "@happyvertical/smrt-approvals:ApprovalEventCollection": {
1061
- "name": "approvaleventcollection",
1062
- "className": "ApprovalEventCollection",
1063
- "qualifiedName": "@happyvertical/smrt-approvals:ApprovalEventCollection",
501
+ "@happyvertical/smrt-approvals:ApprovalEvent": {
502
+ "name": "approvalevent",
503
+ "className": "ApprovalEvent",
504
+ "qualifiedName": "@happyvertical/smrt-approvals:ApprovalEvent",
1064
505
  "collection": "approvalevents",
1065
- "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/collections/ApprovalEventCollection.ts",
506
+ "description": "One immutable entry in an approval request's history.",
507
+ "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/models/ApprovalEvent.ts",
1066
508
  "packageName": "@happyvertical/smrt-approvals",
1067
- "fields": {},
1068
- "methods": {},
509
+ "fields": {
510
+ "tenantId": {
511
+ "type": "text",
512
+ "required": true,
513
+ "_meta": {
514
+ "sqlType": "UUID",
515
+ "__tenancy": {
516
+ "isTenantIdField": true,
517
+ "autoFilter": true,
518
+ "required": true,
519
+ "autoPopulate": true,
520
+ "nullable": false,
521
+ "mode": "required",
522
+ "field": "tenantId",
523
+ "allowSuperAdminBypass": false
524
+ }
525
+ }
526
+ },
527
+ "requestId": {
528
+ "type": "foreignKey",
529
+ "required": true,
530
+ "related": "ApprovalRequest",
531
+ "_meta": {
532
+ "required": true,
533
+ "constraint": {
534
+ "engines": [
535
+ "postgres",
536
+ "sqlite"
537
+ ]
538
+ },
539
+ "onDelete": "RESTRICT",
540
+ "onUpdate": "RESTRICT"
541
+ }
542
+ },
543
+ "type": {
544
+ "type": "text",
545
+ "required": true,
546
+ "_meta": {
547
+ "required": true,
548
+ "readonly": true
549
+ },
550
+ "readonly": true
551
+ },
552
+ "actorId": {
553
+ "type": "text",
554
+ "required": true,
555
+ "_meta": {
556
+ "required": true,
557
+ "readonly": true
558
+ },
559
+ "readonly": true
560
+ },
561
+ "actorType": {
562
+ "type": "text",
563
+ "required": false,
564
+ "_meta": {
565
+ "readonly": true
566
+ },
567
+ "enum": [
568
+ "human",
569
+ "agent",
570
+ "service"
571
+ ],
572
+ "readonly": true
573
+ },
574
+ "reason": {
575
+ "type": "text",
576
+ "required": false,
577
+ "_meta": {
578
+ "readonly": true
579
+ },
580
+ "readonly": true
581
+ },
582
+ "subjectRevisionHash": {
583
+ "type": "text",
584
+ "required": false,
585
+ "_meta": {
586
+ "readonly": true
587
+ },
588
+ "readonly": true
589
+ },
590
+ "sequence": {
591
+ "type": "integer",
592
+ "required": false,
593
+ "_meta": {
594
+ "readonly": true
595
+ },
596
+ "readonly": true
597
+ },
598
+ "voteKey": {
599
+ "type": "text",
600
+ "required": false,
601
+ "_meta": {
602
+ "nullable": true,
603
+ "readonly": true
604
+ },
605
+ "readonly": true
606
+ },
607
+ "occurredAt": {
608
+ "type": "datetime",
609
+ "required": false,
610
+ "_meta": {
611
+ "readonly": true
612
+ },
613
+ "readonly": true
614
+ },
615
+ "selfApproved": {
616
+ "type": "boolean",
617
+ "required": false,
618
+ "default": false,
619
+ "_meta": {
620
+ "readonly": true,
621
+ "default": false
622
+ },
623
+ "readonly": true
624
+ },
625
+ "selfApprovalPermission": {
626
+ "type": "text",
627
+ "required": false,
628
+ "default": "",
629
+ "_meta": {
630
+ "readonly": true,
631
+ "default": ""
632
+ },
633
+ "readonly": true
634
+ }
635
+ },
636
+ "methods": {
637
+ "save": {
638
+ "name": "save",
639
+ "async": true,
640
+ "parameters": [],
641
+ "returnType": "Promise<this>",
642
+ "isStatic": false,
643
+ "isPublic": true
644
+ },
645
+ "delete": {
646
+ "name": "delete",
647
+ "async": true,
648
+ "parameters": [],
649
+ "returnType": "Promise<void>",
650
+ "isStatic": false,
651
+ "isPublic": true
652
+ }
653
+ },
1069
654
  "decoratorConfig": {
655
+ "tableName": "approval_events",
1070
656
  "api": {
1071
657
  "include": [
1072
658
  "list",
@@ -1080,12 +666,60 @@
1080
666
  ]
1081
667
  },
1082
668
  "cli": false,
1083
- "tableName": "approval_events"
669
+ "indexes": [
670
+ {
671
+ "name": "approval_events_request_sequence_key",
672
+ "columns": [
673
+ "requestId",
674
+ "sequence"
675
+ ],
676
+ "unique": true
677
+ },
678
+ {
679
+ "name": "approval_events_request_vote_key",
680
+ "columns": [
681
+ "requestId",
682
+ "voteKey"
683
+ ],
684
+ "unique": true
685
+ },
686
+ {
687
+ "name": "approval_events_tenant_occurred_idx",
688
+ "columns": [
689
+ "tenantId",
690
+ "occurredAt"
691
+ ]
692
+ }
693
+ ],
694
+ "tenantScoped": {
695
+ "mode": "required"
696
+ },
697
+ "conflictColumns": [
698
+ "tenant_id",
699
+ "slug",
700
+ "context"
701
+ ]
1084
702
  },
1085
- "extends": "SmrtCollection",
1086
- "extendsTypeArg": "ApprovalEvent",
1087
- "exportName": "ApprovalEventCollection",
1088
- "collectionExportName": "ApprovalEventCollectionCollection",
703
+ "extends": "SmrtObject",
704
+ "exportName": "ApprovalEvent",
705
+ "collectionExportName": "ApprovalEventCollection",
706
+ "validationRules": [
707
+ {
708
+ "field": "requestId",
709
+ "rule": "required",
710
+ "fieldType": "foreignKey"
711
+ },
712
+ {
713
+ "field": "type",
714
+ "rule": "required",
715
+ "fieldType": "text"
716
+ },
717
+ {
718
+ "field": "actorId",
719
+ "rule": "required",
720
+ "fieldType": "text"
721
+ }
722
+ ],
1089
723
  "schema": {
1090
724
  "tableName": "approval_events",
1091
725
  "ddl": "CREATE TABLE IF NOT EXISTS \"approval_events\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"request_id\" UUID NOT NULL,\n \"type\" TEXT NOT NULL,\n \"actor_id\" TEXT NOT NULL,\n \"actor_type\" TEXT,\n \"reason\" TEXT,\n \"subject_revision_hash\" TEXT,\n \"sequence\" INTEGER,\n \"vote_key\" TEXT,\n \"occurred_at\" TIMESTAMP,\n \"self_approved\" BOOLEAN DEFAULT FALSE,\n \"self_approval_permission\" TEXT DEFAULT ''\n);",
@@ -1235,35 +869,114 @@
1235
869
  },
1236
870
  "importPath": "@happyvertical/smrt-approvals"
1237
871
  },
1238
- "@happyvertical/smrt-approvals:ApprovalPolicyCollection": {
1239
- "name": "approvalpolicycollection",
1240
- "className": "ApprovalPolicyCollection",
1241
- "qualifiedName": "@happyvertical/smrt-approvals:ApprovalPolicyCollection",
872
+ "@happyvertical/smrt-approvals:ApprovalPolicy": {
873
+ "name": "approvalpolicy",
874
+ "className": "ApprovalPolicy",
875
+ "qualifiedName": "@happyvertical/smrt-approvals:ApprovalPolicy",
1242
876
  "collection": "approvalpolicies",
1243
- "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/collections/ApprovalPolicyCollection.ts",
877
+ "description": "Tenant-level tightening of an approval kind. One row per tenant and kind.",
878
+ "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/models/ApprovalPolicy.ts",
1244
879
  "packageName": "@happyvertical/smrt-approvals",
1245
- "fields": {},
1246
- "methods": {},
1247
- "decoratorConfig": {
1248
- "api": {
1249
- "include": [
1250
- "list",
1251
- "get"
1252
- ]
880
+ "fields": {
881
+ "tenantId": {
882
+ "type": "text",
883
+ "required": true,
884
+ "_meta": {
885
+ "sqlType": "UUID",
886
+ "__tenancy": {
887
+ "isTenantIdField": true,
888
+ "autoFilter": true,
889
+ "required": true,
890
+ "autoPopulate": true,
891
+ "nullable": false,
892
+ "mode": "required",
893
+ "field": "tenantId",
894
+ "allowSuperAdminBypass": false
895
+ }
896
+ }
1253
897
  },
1254
- "mcp": {
1255
- "include": [
1256
- "list",
1257
- "get"
1258
- ]
898
+ "kind": {
899
+ "type": "text",
900
+ "required": true,
901
+ "_meta": {
902
+ "required": true
903
+ }
1259
904
  },
1260
- "cli": false,
1261
- "tableName": "approval_policies"
905
+ "requiredApprovals": {
906
+ "type": "integer",
907
+ "required": false,
908
+ "_meta": {}
909
+ },
910
+ "ttlMs": {
911
+ "type": "integer",
912
+ "required": false,
913
+ "_meta": {}
914
+ },
915
+ "requiredPermission": {
916
+ "type": "text",
917
+ "required": false,
918
+ "_meta": {}
919
+ },
920
+ "updatedBy": {
921
+ "type": "text",
922
+ "required": false,
923
+ "_meta": {}
924
+ }
1262
925
  },
1263
- "extends": "SmrtCollection",
1264
- "extendsTypeArg": "ApprovalPolicy",
1265
- "exportName": "ApprovalPolicyCollection",
1266
- "collectionExportName": "ApprovalPolicyCollectionCollection",
926
+ "methods": {
927
+ "save": {
928
+ "name": "save",
929
+ "async": true,
930
+ "parameters": [],
931
+ "returnType": "Promise<this>",
932
+ "isStatic": false,
933
+ "isPublic": true
934
+ }
935
+ },
936
+ "decoratorConfig": {
937
+ "tableName": "approval_policies",
938
+ "api": {
939
+ "include": [
940
+ "list",
941
+ "get"
942
+ ]
943
+ },
944
+ "mcp": {
945
+ "include": [
946
+ "list",
947
+ "get"
948
+ ]
949
+ },
950
+ "cli": false,
951
+ "indexes": [
952
+ {
953
+ "name": "approval_policies_tenant_kind_key",
954
+ "columns": [
955
+ "tenantId",
956
+ "kind"
957
+ ],
958
+ "unique": true
959
+ }
960
+ ],
961
+ "tenantScoped": {
962
+ "mode": "required"
963
+ },
964
+ "conflictColumns": [
965
+ "tenant_id",
966
+ "slug",
967
+ "context"
968
+ ]
969
+ },
970
+ "extends": "SmrtObject",
971
+ "exportName": "ApprovalPolicy",
972
+ "collectionExportName": "ApprovalPolicyCollection",
973
+ "validationRules": [
974
+ {
975
+ "field": "kind",
976
+ "rule": "required",
977
+ "fieldType": "text"
978
+ }
979
+ ],
1267
980
  "schema": {
1268
981
  "tableName": "approval_policies",
1269
982
  "ddl": "CREATE TABLE IF NOT EXISTS \"approval_policies\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL,\n \"required_approvals\" INTEGER,\n \"ttl_ms\" INTEGER,\n \"required_permission\" TEXT,\n \"updated_by\" TEXT\n);",
@@ -1355,16 +1068,239 @@
1355
1068
  },
1356
1069
  "importPath": "@happyvertical/smrt-approvals"
1357
1070
  },
1358
- "@happyvertical/smrt-approvals:ApprovalRequestCollection": {
1359
- "name": "approvalrequestcollection",
1360
- "className": "ApprovalRequestCollection",
1361
- "qualifiedName": "@happyvertical/smrt-approvals:ApprovalRequestCollection",
1071
+ "@happyvertical/smrt-approvals:ApprovalRequest": {
1072
+ "name": "approvalrequest",
1073
+ "className": "ApprovalRequest",
1074
+ "qualifiedName": "@happyvertical/smrt-approvals:ApprovalRequest",
1362
1075
  "collection": "approvalrequests",
1363
- "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/collections/ApprovalRequestCollection.ts",
1076
+ "description": "A request for approval of one subject revision.",
1077
+ "filePath": "/home/runner/work/smrt/smrt/packages/approvals/src/models/ApprovalRequest.ts",
1364
1078
  "packageName": "@happyvertical/smrt-approvals",
1365
- "fields": {},
1366
- "methods": {},
1079
+ "fields": {
1080
+ "tenantId": {
1081
+ "type": "text",
1082
+ "required": true,
1083
+ "_meta": {
1084
+ "sqlType": "UUID",
1085
+ "__tenancy": {
1086
+ "isTenantIdField": true,
1087
+ "autoFilter": true,
1088
+ "required": true,
1089
+ "autoPopulate": true,
1090
+ "nullable": false,
1091
+ "mode": "required",
1092
+ "field": "tenantId",
1093
+ "allowSuperAdminBypass": false
1094
+ }
1095
+ }
1096
+ },
1097
+ "kind": {
1098
+ "type": "text",
1099
+ "required": true,
1100
+ "_meta": {
1101
+ "required": true,
1102
+ "readonly": true
1103
+ },
1104
+ "readonly": true
1105
+ },
1106
+ "subjectType": {
1107
+ "type": "text",
1108
+ "required": true,
1109
+ "_meta": {
1110
+ "required": true,
1111
+ "readonly": true
1112
+ },
1113
+ "readonly": true
1114
+ },
1115
+ "subjectId": {
1116
+ "type": "text",
1117
+ "required": true,
1118
+ "_meta": {
1119
+ "required": true,
1120
+ "readonly": true
1121
+ },
1122
+ "readonly": true
1123
+ },
1124
+ "subjectRevisionHash": {
1125
+ "type": "text",
1126
+ "required": true,
1127
+ "_meta": {
1128
+ "required": true,
1129
+ "readonly": true
1130
+ },
1131
+ "readonly": true
1132
+ },
1133
+ "requestKey": {
1134
+ "type": "text",
1135
+ "required": true,
1136
+ "_meta": {
1137
+ "required": true,
1138
+ "readonly": true
1139
+ },
1140
+ "readonly": true
1141
+ },
1142
+ "requestedBy": {
1143
+ "type": "text",
1144
+ "required": true,
1145
+ "_meta": {
1146
+ "required": true,
1147
+ "readonly": true
1148
+ },
1149
+ "readonly": true
1150
+ },
1151
+ "requestedByType": {
1152
+ "type": "text",
1153
+ "required": false,
1154
+ "_meta": {
1155
+ "readonly": true
1156
+ },
1157
+ "enum": [
1158
+ "human",
1159
+ "agent",
1160
+ "service"
1161
+ ],
1162
+ "readonly": true
1163
+ },
1164
+ "summary": {
1165
+ "type": "text",
1166
+ "required": false,
1167
+ "_meta": {
1168
+ "readonly": true
1169
+ },
1170
+ "readonly": true
1171
+ },
1172
+ "status": {
1173
+ "type": "text",
1174
+ "required": false,
1175
+ "_meta": {
1176
+ "readonly": true
1177
+ },
1178
+ "readonly": true
1179
+ },
1180
+ "requiredApprovals": {
1181
+ "type": "integer",
1182
+ "required": false,
1183
+ "_meta": {
1184
+ "readonly": true
1185
+ },
1186
+ "readonly": true
1187
+ },
1188
+ "approvalCount": {
1189
+ "type": "integer",
1190
+ "required": false,
1191
+ "_meta": {
1192
+ "readonly": true
1193
+ },
1194
+ "readonly": true
1195
+ },
1196
+ "requiredPermissions": {
1197
+ "type": "text",
1198
+ "required": false,
1199
+ "_meta": {
1200
+ "readonly": true
1201
+ },
1202
+ "readonly": true
1203
+ },
1204
+ "version": {
1205
+ "type": "integer",
1206
+ "required": false,
1207
+ "_meta": {
1208
+ "readonly": true
1209
+ },
1210
+ "readonly": true
1211
+ },
1212
+ "expiresAt": {
1213
+ "type": "datetime",
1214
+ "required": false,
1215
+ "_meta": {
1216
+ "readonly": true
1217
+ },
1218
+ "readonly": true
1219
+ },
1220
+ "decidedAt": {
1221
+ "type": "datetime",
1222
+ "required": false,
1223
+ "_meta": {
1224
+ "readonly": true
1225
+ },
1226
+ "readonly": true
1227
+ },
1228
+ "consumedAt": {
1229
+ "type": "datetime",
1230
+ "required": false,
1231
+ "_meta": {
1232
+ "readonly": true
1233
+ },
1234
+ "readonly": true
1235
+ },
1236
+ "consumedBy": {
1237
+ "type": "text",
1238
+ "required": false,
1239
+ "_meta": {
1240
+ "readonly": true
1241
+ },
1242
+ "readonly": true
1243
+ }
1244
+ },
1245
+ "methods": {
1246
+ "getRequiredPermissions": {
1247
+ "name": "getRequiredPermissions",
1248
+ "async": false,
1249
+ "parameters": [],
1250
+ "returnType": "string[]",
1251
+ "isStatic": false,
1252
+ "isPublic": true
1253
+ },
1254
+ "setRequiredPermissions": {
1255
+ "name": "setRequiredPermissions",
1256
+ "async": false,
1257
+ "parameters": [
1258
+ {
1259
+ "name": "slugs",
1260
+ "type": "any",
1261
+ "optional": false,
1262
+ "typeUnresolved": true
1263
+ }
1264
+ ],
1265
+ "returnType": "void",
1266
+ "isStatic": false,
1267
+ "isPublic": true
1268
+ },
1269
+ "expiresAtMs": {
1270
+ "name": "expiresAtMs",
1271
+ "async": false,
1272
+ "parameters": [],
1273
+ "returnType": "number",
1274
+ "isStatic": false,
1275
+ "isPublic": true
1276
+ },
1277
+ "isConsumed": {
1278
+ "name": "isConsumed",
1279
+ "async": false,
1280
+ "parameters": [],
1281
+ "returnType": "boolean",
1282
+ "isStatic": false,
1283
+ "isPublic": true
1284
+ },
1285
+ "save": {
1286
+ "name": "save",
1287
+ "async": true,
1288
+ "parameters": [],
1289
+ "returnType": "Promise<this>",
1290
+ "isStatic": false,
1291
+ "isPublic": true
1292
+ },
1293
+ "delete": {
1294
+ "name": "delete",
1295
+ "async": true,
1296
+ "parameters": [],
1297
+ "returnType": "Promise<void>",
1298
+ "isStatic": false,
1299
+ "isPublic": true
1300
+ }
1301
+ },
1367
1302
  "decoratorConfig": {
1303
+ "tableName": "approval_requests",
1368
1304
  "api": {
1369
1305
  "include": [
1370
1306
  "list",
@@ -1378,12 +1314,76 @@
1378
1314
  ]
1379
1315
  },
1380
1316
  "cli": false,
1381
- "tableName": "approval_requests"
1317
+ "indexes": [
1318
+ {
1319
+ "name": "approval_requests_tenant_request_key",
1320
+ "columns": [
1321
+ "tenantId",
1322
+ "requestKey"
1323
+ ],
1324
+ "unique": true
1325
+ },
1326
+ {
1327
+ "name": "approval_requests_status_expiry_idx",
1328
+ "columns": [
1329
+ "tenantId",
1330
+ "status",
1331
+ "expiresAt"
1332
+ ]
1333
+ },
1334
+ {
1335
+ "name": "approval_requests_subject_idx",
1336
+ "columns": [
1337
+ "tenantId",
1338
+ "subjectType",
1339
+ "subjectId"
1340
+ ]
1341
+ }
1342
+ ],
1343
+ "tenantScoped": {
1344
+ "mode": "required"
1345
+ },
1346
+ "conflictColumns": [
1347
+ "tenant_id",
1348
+ "slug",
1349
+ "context"
1350
+ ]
1382
1351
  },
1383
- "extends": "SmrtCollection",
1384
- "extendsTypeArg": "ApprovalRequest",
1385
- "exportName": "ApprovalRequestCollection",
1386
- "collectionExportName": "ApprovalRequestCollectionCollection",
1352
+ "extends": "SmrtObject",
1353
+ "exportName": "ApprovalRequest",
1354
+ "collectionExportName": "ApprovalRequestCollection",
1355
+ "validationRules": [
1356
+ {
1357
+ "field": "kind",
1358
+ "rule": "required",
1359
+ "fieldType": "text"
1360
+ },
1361
+ {
1362
+ "field": "subjectType",
1363
+ "rule": "required",
1364
+ "fieldType": "text"
1365
+ },
1366
+ {
1367
+ "field": "subjectId",
1368
+ "rule": "required",
1369
+ "fieldType": "text"
1370
+ },
1371
+ {
1372
+ "field": "subjectRevisionHash",
1373
+ "rule": "required",
1374
+ "fieldType": "text"
1375
+ },
1376
+ {
1377
+ "field": "requestKey",
1378
+ "rule": "required",
1379
+ "fieldType": "text"
1380
+ },
1381
+ {
1382
+ "field": "requestedBy",
1383
+ "rule": "required",
1384
+ "fieldType": "text"
1385
+ }
1386
+ ],
1387
1387
  "schema": {
1388
1388
  "tableName": "approval_requests",
1389
1389
  "ddl": "CREATE TABLE IF NOT EXISTS \"approval_requests\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"kind\" TEXT NOT NULL,\n \"subject_type\" TEXT NOT NULL,\n \"subject_id\" TEXT NOT NULL,\n \"subject_revision_hash\" TEXT NOT NULL,\n \"request_key\" TEXT NOT NULL,\n \"requested_by\" TEXT NOT NULL,\n \"requested_by_type\" TEXT,\n \"summary\" TEXT,\n \"status\" TEXT,\n \"required_approvals\" INTEGER,\n \"approval_count\" INTEGER,\n \"required_permissions\" TEXT,\n \"version\" INTEGER,\n \"expires_at\" TIMESTAMP,\n \"decided_at\" TIMESTAMP,\n \"consumed_at\" TIMESTAMP,\n \"consumed_by\" TEXT\n);",