Skip to content

Commit

Permalink
schema
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Sep 19, 2023
1 parent 99bd927 commit bbdb745
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 49 deletions.
22 changes: 22 additions & 0 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2062,14 +2062,36 @@
"SourcedPersonsQuery": {
"additionalProperties": false,
"properties": {
"day": {
"type": "string"
},
"group": {
"type": "string"
},
"kind": {
"const": "SourcedPersonsQuery",
"type": "string"
},
"properties": {
"items": {
"anyOf": [
{
"$ref": "#/definitions/PersonPropertyFilter"
},
{
"$ref": "#/definitions/HogQLPropertyFilter"
}
]
},
"type": "array"
},
"response": {
"$ref": "#/definitions/SourcedPersonsQueryResponse",
"description": "Cached query response"
},
"search": {
"type": "string"
},
"source": {
"$ref": "#/definitions/InsightQueryNode"
}
Expand Down
132 changes: 83 additions & 49 deletions posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@ class ShownAsValue(str, Enum):
Lifecycle = "Lifecycle"


class SourcedPersonsQueryResponse(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
hogql: str
results: List[List] = Field(
..., description="Results in the format: [ ['uuid', breakdown1, breakdown2, ...], ... ]"
)
timings: Optional[List[QueryTiming]] = None


class StepOrderValue(str, Enum):
strict = "strict"
unordered = "unordered"
Expand Down Expand Up @@ -623,6 +634,7 @@ class LifecycleQueryResponse(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
hogql: str
result: List[Dict[str, Any]]
timings: Optional[List[QueryTiming]] = None

Expand Down Expand Up @@ -945,54 +957,6 @@ class ActionsNode(BaseModel):
response: Optional[Dict[str, Any]] = Field(default=None, description="Cached query response")


class DataTableNode(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
allowSorting: Optional[bool] = Field(
default=None, description="Can the user click on column headers to sort the table? (default: true)"
)
columns: Optional[List[str]] = Field(
default=None, description="Columns shown in the table, unless the `source` provides them."
)
embedded: Optional[bool] = Field(default=None, description="Uses the embedded version of LemonTable")
expandable: Optional[bool] = Field(
default=None, description="Can expand row to show raw event data (default: true)"
)
full: Optional[bool] = Field(default=None, description="Show with most visual options enabled. Used in scenes.")
hiddenColumns: Optional[List[str]] = Field(
default=None, description="Columns that aren't shown in the table, even if in columns or returned data"
)
kind: Literal["DataTableNode"] = "DataTableNode"
propertiesViaUrl: Optional[bool] = Field(default=None, description="Link properties via the URL (default: false)")
showActions: Optional[bool] = Field(default=None, description="Show the kebab menu at the end of the row")
showColumnConfigurator: Optional[bool] = Field(
default=None, description="Show a button to configure the table's columns if possible"
)
showDateRange: Optional[bool] = Field(default=None, description="Show date range selector")
showElapsedTime: Optional[bool] = Field(default=None, description="Show the time it takes to run a query")
showEventFilter: Optional[bool] = Field(
default=None, description="Include an event filter above the table (EventsNode only)"
)
showExport: Optional[bool] = Field(default=None, description="Show the export button")
showHogQLEditor: Optional[bool] = Field(default=None, description="Include a HogQL query editor above HogQL tables")
showOpenEditorButton: Optional[bool] = Field(
default=None, description="Show a button to open the current query as a new insight. (default: true)"
)
showPersistentColumnConfigurator: Optional[bool] = Field(
default=None, description="Show a button to configure and persist the table's default columns if possible"
)
showPropertyFilter: Optional[bool] = Field(default=None, description="Include a property filter above the table")
showReload: Optional[bool] = Field(default=None, description="Show a reload button")
showResultsTable: Optional[bool] = Field(default=None, description="Show a results table")
showSavedQueries: Optional[bool] = Field(default=None, description="Shows a list of saved queries")
showSearch: Optional[bool] = Field(default=None, description="Include a free text search field (PersonsNode only)")
showTimings: Optional[bool] = Field(default=None, description="Show a detailed query timing breakdown")
source: Union[EventsNode, EventsQuery, PersonsNode, HogQLQuery, TimeToSeeDataSessionsQuery] = Field(
..., description="Source of the events"
)


class PropertyGroupFilter(BaseModel):
model_config = ConfigDict(
extra="forbid",
Expand Down Expand Up @@ -1245,6 +1209,67 @@ class InsightVizNode(BaseModel):
source: Union[TrendsQuery, FunnelsQuery, RetentionQuery, PathsQuery, StickinessQuery, LifecycleQuery]


class SourcedPersonsQuery(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
day: Optional[str] = None
group: Optional[str] = None
kind: Literal["SourcedPersonsQuery"] = "SourcedPersonsQuery"
properties: Optional[List[Union[PersonPropertyFilter, HogQLPropertyFilter]]] = None
response: Optional[SourcedPersonsQueryResponse] = Field(default=None, description="Cached query response")
search: Optional[str] = None
source: Union[TrendsQuery, FunnelsQuery, RetentionQuery, PathsQuery, StickinessQuery, LifecycleQuery]


class DataTableNode(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
allowSorting: Optional[bool] = Field(
default=None, description="Can the user click on column headers to sort the table? (default: true)"
)
columns: Optional[List[str]] = Field(
default=None, description="Columns shown in the table, unless the `source` provides them."
)
embedded: Optional[bool] = Field(default=None, description="Uses the embedded version of LemonTable")
expandable: Optional[bool] = Field(
default=None, description="Can expand row to show raw event data (default: true)"
)
full: Optional[bool] = Field(default=None, description="Show with most visual options enabled. Used in scenes.")
hiddenColumns: Optional[List[str]] = Field(
default=None, description="Columns that aren't shown in the table, even if in columns or returned data"
)
kind: Literal["DataTableNode"] = "DataTableNode"
propertiesViaUrl: Optional[bool] = Field(default=None, description="Link properties via the URL (default: false)")
showActions: Optional[bool] = Field(default=None, description="Show the kebab menu at the end of the row")
showColumnConfigurator: Optional[bool] = Field(
default=None, description="Show a button to configure the table's columns if possible"
)
showDateRange: Optional[bool] = Field(default=None, description="Show date range selector")
showElapsedTime: Optional[bool] = Field(default=None, description="Show the time it takes to run a query")
showEventFilter: Optional[bool] = Field(
default=None, description="Include an event filter above the table (EventsNode only)"
)
showExport: Optional[bool] = Field(default=None, description="Show the export button")
showHogQLEditor: Optional[bool] = Field(default=None, description="Include a HogQL query editor above HogQL tables")
showOpenEditorButton: Optional[bool] = Field(
default=None, description="Show a button to open the current query as a new insight. (default: true)"
)
showPersistentColumnConfigurator: Optional[bool] = Field(
default=None, description="Show a button to configure and persist the table's default columns if possible"
)
showPropertyFilter: Optional[bool] = Field(default=None, description="Include a property filter above the table")
showReload: Optional[bool] = Field(default=None, description="Show a reload button")
showResultsTable: Optional[bool] = Field(default=None, description="Show a results table")
showSavedQueries: Optional[bool] = Field(default=None, description="Shows a list of saved queries")
showSearch: Optional[bool] = Field(default=None, description="Include a free text search field (PersonsNode only)")
showTimings: Optional[bool] = Field(default=None, description="Show a detailed query timing breakdown")
source: Union[
EventsNode, EventsQuery, PersonsNode, SourcedPersonsQuery, HogQLQuery, TimeToSeeDataSessionsQuery
] = Field(..., description="Source of the events")


class Model(RootModel):
root: Union[
DataTableNode,
Expand All @@ -1258,7 +1283,16 @@ class Model(RootModel):
LifecycleQuery,
TimeToSeeDataSessionsQuery,
DatabaseSchemaQuery,
Union[EventsNode, EventsQuery, ActionsNode, PersonsNode, HogQLQuery, HogQLMetadata, TimeToSeeDataSessionsQuery],
Union[
EventsNode,
EventsQuery,
ActionsNode,
PersonsNode,
HogQLQuery,
HogQLMetadata,
TimeToSeeDataSessionsQuery,
SourcedPersonsQuery,
],
]


Expand Down

0 comments on commit bbdb745

Please sign in to comment.