-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMutationRequestQuery.cs
More file actions
163 lines (138 loc) · 5.25 KB
/
Copy pathMutationRequestQuery.cs
File metadata and controls
163 lines (138 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
using ModularityKit.Mutator.Abstractions.Intent;
using ModularityKit.Mutator.Governance.Abstractions.Lifecycle.Model;
using ModularityKit.Mutator.Governance.Abstractions.Requests.Decisions;
namespace ModularityKit.Mutator.Governance.Abstractions.Queries.Model;
/// <summary>
/// Defines storage-agnostic filters for governed mutation request queries.
/// </summary>
public sealed record MutationRequestQuery
{
/// <summary>
/// Specific request identifiers to include.
/// </summary>
public IReadOnlySet<string> RequestIds { get; init; } = new HashSet<string>();
/// <summary>
/// State identifiers to include.
/// </summary>
public IReadOnlySet<string> StateIds { get; init; } = new HashSet<string>();
/// <summary>
/// State types to include.
/// </summary>
public IReadOnlySet<string> StateTypes { get; init; } = new HashSet<string>();
/// <summary>
/// Mutation types to include.
/// </summary>
public IReadOnlySet<string> MutationTypes { get; init; } = new HashSet<string>();
/// <summary>
/// Actor identifiers to include.
/// </summary>
public IReadOnlySet<string> ActorIds { get; init; } = new HashSet<string>();
/// <summary>
/// Actor names to include.
/// </summary>
public IReadOnlySet<string> ActorNames { get; init; } = new HashSet<string>();
/// <summary>
/// Mutation categories to include.
/// </summary>
public IReadOnlySet<string> Categories { get; init; } = new HashSet<string>();
/// <summary>
/// Request statuses to include.
/// </summary>
public IReadOnlySet<MutationRequestStatus> Statuses { get; init; } = new HashSet<MutationRequestStatus>();
/// <summary>
/// Pending reasons to include.
/// </summary>
public IReadOnlySet<PendingMutationReason> PendingReasons { get; init; } = new HashSet<PendingMutationReason>();
/// <summary>
/// Tags to include from the request intent.
/// </summary>
public IReadOnlySet<string> Tags { get; init; } = new HashSet<string>();
/// <summary>
/// Tag matching strategy.
/// </summary>
public MutationRequestTagMatchMode TagMatchMode { get; init; } = MutationRequestTagMatchMode.Any;
/// <summary>
/// Exact metadata key/value pairs to match against request metadata.
/// </summary>
public IReadOnlyDictionary<string, object?> Metadata { get; init; } = new Dictionary<string, object?>();
/// <summary>
/// Minimum estimated blast radius scope to include.
/// </summary>
public BlastRadiusScope? MinimumBlastRadiusScope { get; init; }
/// <summary>
/// Maximum estimated blast radius scope to include.
/// </summary>
public BlastRadiusScope? MaximumBlastRadiusScope { get; init; }
/// <summary>
/// Inclusive lower bound for request creation time.
/// </summary>
public DateTimeOffset? CreatedFrom { get; init; }
/// <summary>
/// Inclusive upper bound for request creation time.
/// </summary>
public DateTimeOffset? CreatedTo { get; init; }
/// <summary>
/// Inclusive lower bound for request update time.
/// </summary>
public DateTimeOffset? UpdatedFrom { get; init; }
/// <summary>
/// Inclusive upper bound for request update time.
/// </summary>
public DateTimeOffset? UpdatedTo { get; init; }
/// <summary>
/// Decision categories that must appear in the request history.
/// </summary>
public IReadOnlySet<MutationRequestDecisionCategory> DecisionCategories { get; init; }
= new HashSet<MutationRequestDecisionCategory>();
/// <summary>
/// Creates a query that targets pending requests.
/// </summary>
public static MutationRequestQuery Pending()
=> new()
{
Statuses = new HashSet<MutationRequestStatus> { MutationRequestStatus.Pending }
};
/// <summary>
/// Creates a query that targets the pending approval queue.
/// </summary>
public static MutationRequestQuery PendingApprovalQueue()
=> new()
{
Statuses = new HashSet<MutationRequestStatus> { MutationRequestStatus.Pending },
PendingReasons = new HashSet<PendingMutationReason> { PendingMutationReason.Approval },
DecisionCategories = new HashSet<MutationRequestDecisionCategory>
{
MutationRequestDecisionCategory.Approval
}
};
/// <summary>
/// Creates a query that targets approval-driven requests that recently moved through approval.
/// </summary>
public static MutationRequestQuery RecentApprovals()
=> new()
{
Statuses = new HashSet<MutationRequestStatus>
{
MutationRequestStatus.Approved,
MutationRequestStatus.Executed
},
DecisionCategories = new HashSet<MutationRequestDecisionCategory>
{
MutationRequestDecisionCategory.Approval
}
};
}
/// <summary>
/// Controls how tag filters are evaluated.
/// </summary>
public enum MutationRequestTagMatchMode
{
/// <summary>
/// Match requests that contain at least one of the requested tags.
/// </summary>
Any = 0,
/// <summary>
/// Match requests that contain all requested tags.
/// </summary>
All = 1
}