Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

Thrive (codenamed Jupiter) is a life planning tool with a monorepo containing:

| Service | Port | Tech |
|---|---|---|
| **WebAPI** (backend) | 8004 | Python/FastAPI, SQLite |
| **Public API** | 8020 | Python/FastAPI (proxies to WebAPI) |
| **WebUI** (frontend) | 10020 | TypeScript/Remix/React |
| **Docs** | 8000 | Python/MkDocs |
| Service | Tech |
|---|---|
| **WebAPI** (backend) | Python/FastAPI, SQLite |
| **WebUI** (frontend) | TypeScript/Remix/React |
| **API** | Python/FastAPI |
| **MCP** | Python/FastAPI |
| **Docs** | Python/MkDocs |

### Tool versions

Expand All @@ -26,7 +27,7 @@ mise run prepare

### Running services

Start all 4 services (WebAPI, API, WebUI, Docs) via mise:
Start all 5 services (WebAPI, API, MCP, WebUI, Docs) via mise:

```bash
mise run run:srv --instance <instance-name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Contains endpoint functions for accessing the API"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
from http import HTTPStatus
from typing import Any

import httpx

from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error_response import ErrorResponse
from ...models.get_entity_mutation_history_args import GetEntityMutationHistoryArgs
from ...models.get_entity_mutation_history_result import GetEntityMutationHistoryResult
from ...types import UNSET, Response, Unset


def _get_kwargs(
*,
body: GetEntityMutationHistoryArgs | Unset = UNSET,
) -> dict[str, Any]:
headers: dict[str, Any] = {}

_kwargs: dict[str, Any] = {
"method": "post",
"url": "/get-entity-mutation-history",
}

if not isinstance(body, Unset):
_kwargs["json"] = body.to_dict()

headers["Content-Type"] = "application/json"

_kwargs["headers"] = headers
return _kwargs


def _parse_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> ErrorResponse | GetEntityMutationHistoryResult | None:
if response.status_code == 200:
response_200 = GetEntityMutationHistoryResult.from_dict(response.json())

return response_200

if response.status_code == 400:
response_400 = ErrorResponse.from_dict(response.json())

return response_400

if response.status_code == 401:
response_401 = ErrorResponse.from_dict(response.json())

return response_401

if response.status_code == 404:
response_404 = ErrorResponse.from_dict(response.json())

return response_404

if response.status_code == 406:
response_406 = ErrorResponse.from_dict(response.json())

return response_406

if response.status_code == 409:
response_409 = ErrorResponse.from_dict(response.json())

return response_409

if response.status_code == 410:
response_410 = ErrorResponse.from_dict(response.json())

return response_410

if response.status_code == 422:
response_422 = ErrorResponse.from_dict(response.json())

return response_422

if response.status_code == 426:
response_426 = ErrorResponse.from_dict(response.json())

return response_426

if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None


def _build_response(
*, client: AuthenticatedClient | Client, response: httpx.Response
) -> Response[ErrorResponse | GetEntityMutationHistoryResult]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
*,
client: AuthenticatedClient,
body: GetEntityMutationHistoryArgs | Unset = UNSET,
) -> Response[ErrorResponse | GetEntityMutationHistoryResult]:
"""Use case for loading the history of mutations for an entity.

Args:
body (GetEntityMutationHistoryArgs | Unset): Arguments for the entity mutation history.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | GetEntityMutationHistoryResult]
"""

kwargs = _get_kwargs(
body=body,
)

response = client.get_httpx_client().request(
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
*,
client: AuthenticatedClient,
body: GetEntityMutationHistoryArgs | Unset = UNSET,
) -> ErrorResponse | GetEntityMutationHistoryResult | None:
"""Use case for loading the history of mutations for an entity.

Args:
body (GetEntityMutationHistoryArgs | Unset): Arguments for the entity mutation history.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | GetEntityMutationHistoryResult
"""

return sync_detailed(
client=client,
body=body,
).parsed


async def asyncio_detailed(
*,
client: AuthenticatedClient,
body: GetEntityMutationHistoryArgs | Unset = UNSET,
) -> Response[ErrorResponse | GetEntityMutationHistoryResult]:
"""Use case for loading the history of mutations for an entity.

Args:
body (GetEntityMutationHistoryArgs | Unset): Arguments for the entity mutation history.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[ErrorResponse | GetEntityMutationHistoryResult]
"""

kwargs = _get_kwargs(
body=body,
)

response = await client.get_async_httpx_client().request(**kwargs)

return _build_response(client=client, response=response)


async def asyncio(
*,
client: AuthenticatedClient,
body: GetEntityMutationHistoryArgs | Unset = UNSET,
) -> ErrorResponse | GetEntityMutationHistoryResult | None:
"""Use case for loading the history of mutations for an entity.

Args:
body (GetEntityMutationHistoryArgs | Unset): Arguments for the entity mutation history.

Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
ErrorResponse | GetEntityMutationHistoryResult
"""

return (
await asyncio_detailed(
client=client,
body=body,
)
).parsed
6 changes: 6 additions & 0 deletions gen/py/webapi-client/jupiter_webapi_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@
from .gen_load_runs_result import GenLoadRunsResult
from .gen_log import GenLog
from .gen_log_entry import GenLogEntry
from .get_entity_mutation_history_args import GetEntityMutationHistoryArgs
from .get_entity_mutation_history_result import GetEntityMutationHistoryResult
from .get_summaries_args import GetSummariesArgs
from .get_summaries_result import GetSummariesResult
from .goal import Goal
Expand Down Expand Up @@ -302,6 +304,7 @@
from .habit_update_args_skip_rule import HabitUpdateArgsSkipRule
from .heading_block import HeadingBlock
from .heading_block_kind import HeadingBlockKind
from .history_entry import HistoryEntry
from .home_config import HomeConfig
from .home_config_load_args import HomeConfigLoadArgs
from .home_config_load_result import HomeConfigLoadResult
Expand Down Expand Up @@ -1185,6 +1188,8 @@
"GenLoadRunsResult",
"GenLog",
"GenLogEntry",
"GetEntityMutationHistoryArgs",
"GetEntityMutationHistoryResult",
"GetSummariesArgs",
"GetSummariesResult",
"Goal",
Expand Down Expand Up @@ -1239,6 +1244,7 @@
"HabitUpdateArgsSkipRule",
"HeadingBlock",
"HeadingBlockKind",
"HistoryEntry",
"HomeConfig",
"HomeConfigLoadArgs",
"HomeConfigLoadResult",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar, cast

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..models.named_entity_tag import NamedEntityTag
from ..types import UNSET, Unset

T = TypeVar("T", bound="GetEntityMutationHistoryArgs")


@_attrs_define
class GetEntityMutationHistoryArgs:
"""Arguments for the entity mutation history.

Attributes:
entity_type (NamedEntityTag): A tag for all known entities.
entity_ref_id (str): A generic entity id.
retrieve_offset (int | None | Unset):
retrieve_limit (int | None | Unset):
"""

entity_type: NamedEntityTag
entity_ref_id: str
retrieve_offset: int | None | Unset = UNSET
retrieve_limit: int | None | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> dict[str, Any]:
entity_type = self.entity_type.value

entity_ref_id = self.entity_ref_id

retrieve_offset: int | None | Unset
if isinstance(self.retrieve_offset, Unset):
retrieve_offset = UNSET
else:
retrieve_offset = self.retrieve_offset

retrieve_limit: int | None | Unset
if isinstance(self.retrieve_limit, Unset):
retrieve_limit = UNSET
else:
retrieve_limit = self.retrieve_limit

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"entity_type": entity_type,
"entity_ref_id": entity_ref_id,
}
)
if retrieve_offset is not UNSET:
field_dict["retrieve_offset"] = retrieve_offset
if retrieve_limit is not UNSET:
field_dict["retrieve_limit"] = retrieve_limit

return field_dict

@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
entity_type = NamedEntityTag(d.pop("entity_type"))

entity_ref_id = d.pop("entity_ref_id")

def _parse_retrieve_offset(data: object) -> int | None | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(int | None | Unset, data)

retrieve_offset = _parse_retrieve_offset(d.pop("retrieve_offset", UNSET))

def _parse_retrieve_limit(data: object) -> int | None | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(int | None | Unset, data)

retrieve_limit = _parse_retrieve_limit(d.pop("retrieve_limit", UNSET))

get_entity_mutation_history_args = cls(
entity_type=entity_type,
entity_ref_id=entity_ref_id,
retrieve_offset=retrieve_offset,
retrieve_limit=retrieve_limit,
)

get_entity_mutation_history_args.additional_properties = d
return get_entity_mutation_history_args

@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())

def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]

def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value

def __delitem__(self, key: str) -> None:
del self.additional_properties[key]

def __contains__(self, key: str) -> bool:
return key in self.additional_properties
Loading