-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathevaluationContext.types.ts
More file actions
247 lines (245 loc) · 6.34 KB
/
evaluationContext.types.ts
File metadata and controls
247 lines (245 loc) · 6.34 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
/**
* Unique environment key. May be used for selecting a value for a multivariate feature, or for % split segmentation.
*/
export type Key = string;
/**
* An environment's human-readable name.
*/
export type Name = string;
/**
* A unique identifier for an identity as displayed in the Flagsmith UI.
*/
export type Identifier = string;
/**
* Key used when selecting a value for a multivariate feature, or for % split segmentation. Set to an internal identifier or a composite value based on the environment key and identifier, depending on Flagsmith implementation.
*/
export type Key1 = string;
/**
* Unique segment key used for % split segmentation.
*/
export type Key2 = string;
/**
* The name of the segment.
*/
export type Name1 = string;
/**
* Segment rule type. Represents a logical quantifier for the conditions and sub-rules.
*/
export type Type = 'ALL' | 'ANY' | 'NONE';
export type SegmentCondition = SegmentCondition1 | InSegmentCondition;
/**
* A reference to the identity trait or value in the evaluation context.
*/
export type Property = string;
/**
* The operator to use for evaluating the condition.
*/
export type Operator =
| 'EQUAL'
| 'GREATER_THAN'
| 'LESS_THAN'
| 'LESS_THAN_INCLUSIVE'
| 'CONTAINS'
| 'GREATER_THAN_INCLUSIVE'
| 'NOT_CONTAINS'
| 'NOT_EQUAL'
| 'REGEX'
| 'PERCENTAGE_SPLIT'
| 'MODULO'
| 'IS_SET'
| 'IS_NOT_SET'
| 'IN';
/**
* The value to compare against the trait or context value.
*/
export type Value = string;
/**
* A reference to the identity trait or value in the evaluation context.
*/
export type Property1 = string;
/**
* The operator to use for evaluating the condition.
*/
export type Operator1 = 'IN';
/**
* The values to compare against the trait or context value.
*/
export type Value1 = string[];
/**
* Conditions that must be met for the rule to apply.
*/
export type Conditions = SegmentCondition[];
/**
* Sub-rules nested within the segment rule.
*/
export type SubRules = SegmentRule[];
/**
* Rules that define the segment.
*/
export type Rules = SegmentRule[];
/**
* Unique feature key used when selecting a variant if the feature is multivariate. Set to an internal identifier or a UUID, depending on Flagsmith implementation.
*/
export type Key3 = string;
/**
* Feature name.
*/
export type Name2 = string;
/**
* Indicates whether the feature is enabled in the environment.
*/
export type Enabled = boolean;
/**
* A default environment value for the feature. If the feature is multivariate, this will be the control value.
*/
export type Value2 = string | number | boolean | null;
/**
* The value of the feature.
*/
export type Value3 = string | number | boolean | null;
/**
* The weight of the feature value variant, as a percentage number (i.e. 100.0).
*/
export type Weight = number;
/**
* Priority of the feature flag variant. Lower values indicate a higher priority when multiple variants apply to the same context key.
*/
export type VariantPriority = number;
/**
* An array of environment default values associated with the feature. Empty for standard features, or contains multiple values for multivariate features.
*/
export type Variants = FeatureValue[];
/**
* Priority of the feature context. Lower values indicate a higher priority when multiple contexts apply to the same feature.
*/
export type FeaturePriority = number;
/**
* Feature overrides for the segment.
*/
export type Overrides = FeatureContext[];
/**
* A context object containing the necessary information to evaluate Flagsmith feature flags.
*/
export interface EvaluationContext {
environment: EnvironmentContext;
/**
* Identity context used for identity-based evaluation.
*/
identity?: IdentityContext | null;
segments?: Segments;
features?: Features;
[k: string]: unknown;
}
/**
* Environment context required for evaluation.
*/
export interface EnvironmentContext {
key: Key;
name: Name;
[k: string]: unknown;
}
/**
* Represents an identity context for feature flag evaluation.
*/
export interface IdentityContext {
identifier: Identifier;
key?: Key1;
traits?: Traits;
[k: string]: unknown;
}
/**
* A map of traits associated with the identity, where the key is the trait name and the value is the trait value.
*/
export interface Traits {
[k: string]: string | number | boolean | null;
}
/**
* Segments applicable to the evaluation context.
*/
export interface Segments {
[k: string]: SegmentContext;
}
/**
* Represents a segment context for feature flag evaluation.
*/
export interface SegmentContext {
key: Key2;
name: Name1;
rules: Rules;
overrides?: Overrides;
metadata?: SegmentMetadata;
[k: string]: unknown;
}
/**
* Represents a rule within a segment for feature flag evaluation.
*/
export interface SegmentRule {
type: Type;
conditions?: Conditions;
rules?: SubRules;
[k: string]: unknown;
}
/**
* Represents a condition within a segment rule for feature flag evaluation.
*/
export interface SegmentCondition1 {
property: Property;
operator: Operator;
value: Value;
[k: string]: unknown;
}
/**
* Represents an IN condition within a segment rule for feature flag evaluation.
*/
export interface InSegmentCondition {
property: Property1;
operator: Operator1;
value: Value1;
[k: string]: unknown;
}
/**
* Represents a feature context for feature flag evaluation.
*/
export interface FeatureContext {
key: Key3;
name: Name2;
enabled: Enabled;
value: Value2;
variants?: Variants;
priority?: FeaturePriority;
metadata?: FeatureMetadata;
[k: string]: unknown;
}
/**
* Represents a multivariate value for a feature flag.
*/
export interface FeatureValue {
value: Value3;
weight: Weight;
priority: VariantPriority;
[k: string]: unknown;
}
/**
* Additional metadata associated with the feature.
*/
export interface FeatureMetadata {
[k: string]: unknown;
}
/**
* Additional metadata associated with the segment.
*/
export interface SegmentMetadata {
[k: string]: unknown;
}
/**
* Features to be evaluated in the context.
*/
export interface Features {
[k: string]: FeatureContext;
}