Skip to content

Commit

Permalink
Fix ambiguous Kind enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Oct 30, 2024
1 parent 849b918 commit 2458864
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 94 deletions.
67 changes: 35 additions & 32 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -651,38 +651,8 @@
"type": "string"
},
"kind": {
"description": "The kind of this completion item. Based on the kind an icon is chosen by the editor.",
"enum": [
"Method",
"Function",
"Constructor",
"Field",
"Variable",
"Class",
"Struct",
"Interface",
"Module",
"Property",
"Event",
"Operator",
"Unit",
"Value",
"Constant",
"Enum",
"EnumMember",
"Keyword",
"Text",
"Color",
"File",
"Reference",
"Customcolor",
"Folder",
"TypeParameter",
"User",
"Issue",
"Snippet"
],
"type": "string"
"$ref": "#/definitions/AutocompleteCompletionKind",
"description": "The kind of this completion item. Based on the kind an icon is chosen by the editor."
},
"label": {
"description": "The label of this completion item. By default this is also the text that is inserted when selecting this completion.",
Expand All @@ -692,6 +662,39 @@
"required": ["label", "insertText", "kind"],
"type": "object"
},
"AutocompleteCompletionKind": {
"enum": [
"Method",
"Function",
"Constructor",
"Field",
"Variable",
"Class",
"Struct",
"Interface",
"Module",
"Property",
"Event",
"Operator",
"Unit",
"Value",
"Constant",
"Enum",
"EnumMember",
"Keyword",
"Text",
"Color",
"File",
"Reference",
"Customcolor",
"Folder",
"TypeParameter",
"User",
"Issue",
"Snippet"
],
"type": "string"
},
"BaseMathType": {
"enum": ["total", "dau", "weekly_active", "monthly_active", "unique_session", "first_time_for_user"],
"type": "string"
Expand Down
60 changes: 31 additions & 29 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,36 @@ export interface HogQLMetadataResponse {
query_status?: never
}

export type AutocompleteCompletionKind =
| 'Method'
| 'Function'
| 'Constructor'
| 'Field'
| 'Variable'
| 'Class'
| 'Struct'
| 'Interface'
| 'Module'
| 'Property'
| 'Event'
| 'Operator'
| 'Unit'
| 'Value'
| 'Constant'
| 'Enum'
| 'EnumMember'
| 'Keyword'
| 'Text'
| 'Color'
| 'File'
| 'Reference'
| 'Customcolor'
| 'Folder'
| 'TypeParameter'
| 'User'
| 'Issue'
| 'Snippet'

export interface AutocompleteCompletionItem {
/**
* The label of this completion item. By default
Expand All @@ -385,35 +415,7 @@ export interface AutocompleteCompletionItem {
* The kind of this completion item. Based on the kind
* an icon is chosen by the editor.
*/
kind:
| 'Method'
| 'Function'
| 'Constructor'
| 'Field'
| 'Variable'
| 'Class'
| 'Struct'
| 'Interface'
| 'Module'
| 'Property'
| 'Event'
| 'Operator'
| 'Unit'
| 'Value'
| 'Constant'
| 'Enum'
| 'EnumMember'
| 'Keyword'
| 'Text'
| 'Color'
| 'File'
| 'Reference'
| 'Customcolor'
| 'Folder'
| 'TypeParameter'
| 'User'
| 'Issue'
| 'Snippet'
kind: AutocompleteCompletionKind
}

export interface HogQLAutocompleteResponse {
Expand Down
66 changes: 33 additions & 33 deletions posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AssistantMessageType(StrEnum):
AI_VIZ = "ai/viz"


class Kind(StrEnum):
class AutocompleteCompletionKind(StrEnum):
METHOD = "Method"
FUNCTION = "Function"
CONSTRUCTOR = "Constructor"
Expand Down Expand Up @@ -108,34 +108,6 @@ class Kind(StrEnum):
SNIPPET = "Snippet"


class AutocompleteCompletionItem(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
detail: Optional[str] = Field(
default=None,
description=(
"A human-readable string with additional information about this item, like type or symbol information."
),
)
documentation: Optional[str] = Field(
default=None, description="A human-readable string that represents a doc-comment."
)
insertText: str = Field(
..., description="A string or snippet that should be inserted in a document when selecting this completion."
)
kind: Kind = Field(
..., description="The kind of this completion item. Based on the kind an icon is chosen by the editor."
)
label: str = Field(
...,
description=(
"The label of this completion item. By default this is also the text that is inserted when selecting this"
" completion."
),
)


class BaseMathType(StrEnum):
TOTAL = "total"
DAU = "dau"
Expand Down Expand Up @@ -1132,7 +1104,7 @@ class RecordingPropertyFilter(BaseModel):
value: Optional[Union[str, float, list[Union[str, float]]]] = None


class Kind1(StrEnum):
class Kind(StrEnum):
ACTIONS_NODE = "ActionsNode"
EVENTS_NODE = "EventsNode"

Expand All @@ -1143,7 +1115,7 @@ class RetentionEntity(BaseModel):
)
custom_name: Optional[str] = None
id: Optional[Union[str, float]] = None
kind: Optional[Kind1] = None
kind: Optional[Kind] = None
name: Optional[str] = None
order: Optional[int] = None
type: Optional[EntityType] = None
Expand Down Expand Up @@ -1563,7 +1535,7 @@ class WebGoalsQueryResponse(BaseModel):
types: Optional[list] = None


class Kind2(StrEnum):
class Kind1(StrEnum):
UNIT = "unit"
DURATION_S = "duration_s"
PERCENTAGE = "percentage"
Expand All @@ -1576,7 +1548,7 @@ class WebOverviewItem(BaseModel):
changeFromPreviousPct: Optional[float] = None
isIncreaseBad: Optional[bool] = None
key: str
kind: Kind2
kind: Kind1
previous: Optional[float] = None
value: Optional[float] = None

Expand Down Expand Up @@ -1745,6 +1717,34 @@ class AlertCondition(BaseModel):
type: AlertConditionType


class AutocompleteCompletionItem(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
detail: Optional[str] = Field(
default=None,
description=(
"A human-readable string with additional information about this item, like type or symbol information."
),
)
documentation: Optional[str] = Field(
default=None, description="A human-readable string that represents a doc-comment."
)
insertText: str = Field(
..., description="A string or snippet that should be inserted in a document when selecting this completion."
)
kind: AutocompleteCompletionKind = Field(
..., description="The kind of this completion item. Based on the kind an icon is chosen by the editor."
)
label: str = Field(
...,
description=(
"The label of this completion item. By default this is also the text that is inserted when selecting this"
" completion."
),
)


class Breakdown(BaseModel):
model_config = ConfigDict(
extra="forbid",
Expand Down

0 comments on commit 2458864

Please sign in to comment.