|
20 | 20 | DynamoFloat, |
21 | 21 | DynamoInt, |
22 | 22 | FeatureType, |
| 23 | + JsonGzipped, |
23 | 24 | UUIDStr, |
24 | 25 | ) |
25 | 26 |
|
@@ -200,19 +201,14 @@ class Webhook(TypedDict): |
200 | 201 | """Secret used to sign webhook payloads.""" |
201 | 202 |
|
202 | 203 |
|
203 | | -class _EnvironmentFields(TypedDict): |
| 204 | +class _EnvironmentBaseFields(TypedDict): |
204 | 205 | """Common fields for Environment documents.""" |
205 | 206 |
|
206 | 207 | name: NotRequired[str] |
207 | 208 | """Environment name. Defaults to an empty string if not set.""" |
208 | 209 | updated_at: NotRequired[DateTimeStr | None] |
209 | 210 | """Last updated timestamp. If not set, current timestamp should be assumed.""" |
210 | 211 |
|
211 | | - project: Project |
212 | | - """Project-specific data for this environment.""" |
213 | | - feature_states: list[FeatureState] |
214 | | - """List of feature states representing the environment defaults.""" |
215 | | - |
216 | 212 | allow_client_traits: NotRequired[bool] |
217 | 213 | """Whether the SDK API should allow clients to set traits for this environment. Identical to project-level's `persist_trait_data` setting. Defaults to `True`.""" |
218 | 214 | hide_sensitive_data: NotRequired[bool] |
@@ -240,7 +236,52 @@ class _EnvironmentFields(TypedDict): |
240 | 236 | """Webhook configuration.""" |
241 | 237 |
|
242 | 238 |
|
243 | | -### Root document schemas below. Indexed fields are marked as **INDEXED** in the docstrings. ### |
| 239 | +class _EnvironmentV1Fields(TypedDict): |
| 240 | + """Common fields for environment documents in `flagsmith_environments`.""" |
| 241 | + |
| 242 | + api_key: str |
| 243 | + """Public client-side API key for the environment. **INDEXED**.""" |
| 244 | + id: DynamoInt |
| 245 | + """Unique identifier for the environment in Core.""" |
| 246 | + |
| 247 | + |
| 248 | +class _EnvironmentV2MetaFields(TypedDict): |
| 249 | + """Common fields for environment documents in `flagsmith_environments_v2`.""" |
| 250 | + |
| 251 | + environment_id: str |
| 252 | + """Unique identifier for the environment in Core. Same as `Environment.id`, but string-typed to reduce coupling with Core's type definitions **INDEXED**.""" |
| 253 | + environment_api_key: str |
| 254 | + """Public client-side API key for the environment. **INDEXED**.""" |
| 255 | + document_key: Literal["_META"] |
| 256 | + """The fixed document key for the environment v2 document. Always `"_META"`. **INDEXED**.""" |
| 257 | + |
| 258 | + id: DynamoInt |
| 259 | + """Unique identifier for the environment in Core. Exists for compatibility with the API environment document schema.""" |
| 260 | + |
| 261 | + |
| 262 | +class _EnvironmentBaseFieldsUncompressed(TypedDict): |
| 263 | + """Common fields for uncompressed environment documents.""" |
| 264 | + |
| 265 | + project: Project |
| 266 | + """Project-specific data for this environment.""" |
| 267 | + feature_states: list[FeatureState] |
| 268 | + """List of feature states representing the environment defaults.""" |
| 269 | + compressed: NotRequired[Literal[False]] |
| 270 | + """Either `False` or absent to indicate the data is uncompressed.""" |
| 271 | + |
| 272 | + |
| 273 | +class _EnvironmentBaseFieldsCompressed(TypedDict): |
| 274 | + """Common fields for compressed environment documents.""" |
| 275 | + |
| 276 | + project: JsonGzipped[Project] |
| 277 | + """Project-specific data for this environment. **COMPRESSED**.""" |
| 278 | + feature_states: JsonGzipped[list[FeatureState]] |
| 279 | + """List of feature states representing the environment defaults. **COMPRESSED**.""" |
| 280 | + compressed: Literal[True] |
| 281 | + """Always `True` to indicate the data is compressed.""" |
| 282 | + |
| 283 | + |
| 284 | +### Root document schemas below. Indexed fields are marked as **INDEXED** in the docstrings. Compressed fields are marked as **COMPRESSED**. ### |
244 | 285 |
|
245 | 286 |
|
246 | 287 | class EnvironmentAPIKey(TypedDict): |
@@ -295,33 +336,50 @@ class Identity(TypedDict): |
295 | 336 | """Unique identifier for the identity in Core. If identity created via Core's `edge-identities` API, this can be missing or `None`.""" |
296 | 337 |
|
297 | 338 |
|
298 | | -class Environment(_EnvironmentFields): |
| 339 | +class Environment( |
| 340 | + _EnvironmentBaseFieldsUncompressed, |
| 341 | + _EnvironmentV1Fields, |
| 342 | + _EnvironmentBaseFields, |
| 343 | +): |
299 | 344 | """Represents a Flagsmith environment. Carries all necessary data for flag evaluation within the environment. |
300 | 345 |
|
301 | 346 | **DynamoDB table**: `flagsmith_environments` |
302 | 347 | """ |
303 | 348 |
|
304 | | - api_key: str |
305 | | - """Public client-side API key for the environment. **INDEXED**.""" |
306 | | - id: DynamoInt |
307 | | - """Unique identifier for the environment in Core.""" |
308 | 349 |
|
| 350 | +class EnvironmentCompressed( |
| 351 | + _EnvironmentBaseFieldsCompressed, |
| 352 | + _EnvironmentV1Fields, |
| 353 | + _EnvironmentBaseFields, |
| 354 | +): |
| 355 | + """Represents a Flagsmith environment. Carries all necessary data for flag evaluation within the environment. |
| 356 | + Has compressed fields. |
| 357 | +
|
| 358 | + **DynamoDB table**: `flagsmith_environments` |
| 359 | + """ |
309 | 360 |
|
310 | | -class EnvironmentV2Meta(_EnvironmentFields): |
| 361 | + |
| 362 | +class EnvironmentV2Meta( |
| 363 | + _EnvironmentBaseFieldsUncompressed, |
| 364 | + _EnvironmentV2MetaFields, |
| 365 | + _EnvironmentBaseFields, |
| 366 | +): |
311 | 367 | """Represents a Flagsmith environment. Carries all necessary data for flag evaluation within the environment. |
312 | 368 |
|
313 | 369 | **DynamoDB table**: `flagsmith_environments_v2` |
314 | 370 | """ |
315 | 371 |
|
316 | | - environment_id: str |
317 | | - """Unique identifier for the environment in Core. Same as `Environment.id`, but string-typed to reduce coupling with Core's type definitions **INDEXED**.""" |
318 | | - environment_api_key: str |
319 | | - """Public client-side API key for the environment. **INDEXED**.""" |
320 | | - document_key: Literal["_META"] |
321 | | - """The fixed document key for the environment v2 document. Always `"_META"`. **INDEXED**.""" |
322 | 372 |
|
323 | | - id: DynamoInt |
324 | | - """Unique identifier for the environment in Core. Exists for compatibility with the API environment document schema.""" |
| 373 | +class EnvironmentV2MetaCompressed( |
| 374 | + _EnvironmentBaseFieldsCompressed, |
| 375 | + _EnvironmentV2MetaFields, |
| 376 | + _EnvironmentBaseFields, |
| 377 | +): |
| 378 | + """Represents a Flagsmith environment. Carries all necessary data for flag evaluation within the environment. |
| 379 | + Has compressed fields. |
| 380 | +
|
| 381 | + **DynamoDB table**: `flagsmith_environments_v2` |
| 382 | + """ |
325 | 383 |
|
326 | 384 |
|
327 | 385 | class EnvironmentV2IdentityOverride(TypedDict): |
|
0 commit comments