From a023ee6e58f3afc131263322b718268e77a543f9 Mon Sep 17 00:00:00 2001 From: Julian Bez Date: Fri, 28 Jun 2024 13:59:51 +0100 Subject: [PATCH] fix(types): Fix group type index to be integer (#23316) Fix group type index to be integer --- frontend/src/queries/schema.json | 29 +++++++++++++++++++++++++---- frontend/src/types.ts | 23 +++++++++++++---------- posthog/schema.py | 6 +++--- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json index 444e146a1676c..f3fc7f3ed0738 100644 --- a/frontend/src/queries/schema.json +++ b/frontend/src/queries/schema.json @@ -3217,19 +3217,33 @@ "type": "array" }, "aggregation_group_type_index": { - "type": "number" + "type": "integer" }, "breakdown": { "$ref": "#/definitions/BreakdownKeyType" }, "breakdown_group_type_index": { - "type": ["number", "null"] + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] }, "breakdown_hide_other_aggregation": { "type": ["boolean", "null"] }, "breakdown_limit": { - "type": "integer" + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] }, "breakdown_normalize_url": { "type": "boolean" @@ -4054,7 +4068,14 @@ "additionalProperties": false, "properties": { "group_type_index": { - "type": ["number", "null"] + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ] }, "key": { "type": "string" diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 32f5f5053be32..8f6e802c1e41a 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -44,6 +44,10 @@ import type { } from './queries/schema' import { NodeKind } from './queries/schema' +// Type alias for number to be reflected as integer in json-schema. +/** @asType integer */ +type integer = number + export type Optional = Omit & { [K in keyof T]?: T[K] } // Keep this in sync with backend constants/features/{product_name}.yml @@ -751,7 +755,7 @@ export interface CohortPropertyFilter extends BasePropertyFilter { export interface GroupPropertyFilter extends BasePropertyFilter { type: PropertyFilterType.Group - group_type_index?: number | null + group_type_index?: integer | null operator: PropertyOperator } @@ -1037,7 +1041,7 @@ export type EntityFilter = { export interface ActionFilter extends EntityFilter { math?: string math_property?: string - math_group_type_index?: number | null + math_group_type_index?: integer | null math_hogql?: string properties?: AnyPropertyFilter[] type: EntityType @@ -1139,7 +1143,7 @@ export interface GroupActorType extends CommonActorType { /** Group key. */ id: string group_key: string - group_type_index: number + group_type_index: integer } export type ActorType = PersonActorType | GroupActorType @@ -1164,7 +1168,7 @@ export interface CohortCriteriaType { value: BehavioralFilterType type: BehavioralFilterKey operator?: PropertyOperator | null - group_type_index?: number | null + group_type_index?: integer | null event_type?: TaxonomicFilterGroupType | null operator_value?: PropertyFilterValue time_value?: number | string | null @@ -2120,11 +2124,10 @@ export interface FilterType { breakdown?: BreakdownKeyType breakdown_normalize_url?: boolean breakdowns?: Breakdown[] - breakdown_group_type_index?: number | null + breakdown_group_type_index?: integer | null breakdown_hide_other_aggregation?: boolean | null - /** @asType integer */ - breakdown_limit?: number | null - aggregation_group_type_index?: number // Groups aggregation + breakdown_limit?: integer | null + aggregation_group_type_index?: integer // Groups aggregation } export interface PropertiesTimelineFilterType { @@ -2765,7 +2768,7 @@ export interface MultivariateFlagOptions { export interface FeatureFlagFilters { groups: FeatureFlagGroupType[] multivariate: MultivariateFlagOptions | null - aggregation_group_type_index?: number | null + aggregation_group_type_index?: integer | null payloads: Record super_groups?: FeatureFlagGroupType[] } @@ -3118,7 +3121,7 @@ export interface Experiment { recommended_sample_size?: number feature_flag_variants: MultivariateFlagVariant[] custom_exposure_filter?: FilterType - aggregation_group_type_index?: number + aggregation_group_type_index?: integer } start_date?: string | null end_date?: string | null diff --git a/posthog/schema.py b/posthog/schema.py index 8a30bb80574de..37dc55be49e6e 100644 --- a/posthog/schema.py +++ b/posthog/schema.py @@ -2028,7 +2028,7 @@ class GroupPropertyFilter(BaseModel): model_config = ConfigDict( extra="forbid", ) - group_type_index: Optional[float] = None + group_type_index: Optional[int] = None key: str label: Optional[str] = None operator: PropertyOperator @@ -3750,9 +3750,9 @@ class FilterType(BaseModel): extra="forbid", ) actions: Optional[list[dict[str, Any]]] = None - aggregation_group_type_index: Optional[float] = None + aggregation_group_type_index: Optional[int] = None breakdown: Optional[Union[str, float, list[Union[str, float]]]] = None - breakdown_group_type_index: Optional[float] = None + breakdown_group_type_index: Optional[int] = None breakdown_hide_other_aggregation: Optional[bool] = None breakdown_limit: Optional[int] = None breakdown_normalize_url: Optional[bool] = None