Skip to content
Merged
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
19 changes: 12 additions & 7 deletions fastapi_startkit/src/fastapi_startkit/facades/Dump.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
from typing import Any, List, TYPE_CHECKING
from typing import Any, List

if TYPE_CHECKING:
from ..dumps import Dump as DumpObject
DumpObject = Any

class Dump:
"""Dumper facade."""

def clear(self) -> "Dump":
@staticmethod
def clear() -> "Dump":
"""Clear all dumped data"""
...
def dd(*objects: List[Any]):
@staticmethod
def dd(*objects: Any):
"""Dump all provided args and die, raising a DumpException."""
...
def dump(*objects: List[Any]):
@staticmethod
def dump(*objects: Any):
"""Dump all provided args and continue code execution. This does not raise a DumpException."""
...
@staticmethod
def get_dumps(ascending: bool = False) -> List[DumpObject]:
"""Get all dumps as Dump objects. If ascending is True, get dumps from oldest to most recents."""
...
def last(self) -> DumpObject:
@staticmethod
def last() -> DumpObject:
"""Return last added dump."""
...
@staticmethod
def get_serialized_dumps(ascending: bool = False) -> List[dict]:
"""Get all dumps as dict. If ascending is True, sort dumps from oldest to most recents."""
...
21 changes: 18 additions & 3 deletions fastapi_startkit/src/fastapi_startkit/facades/Gate.pyi
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
from typing import TYPE_CHECKING, Callable, List, Tuple, Any
from typing import Callable, List, Tuple, Any

if TYPE_CHECKING:
from ..authorization import AuthorizationResponse, Policy, Gate as GateObject
AuthorizationResponse = Any
Policy = Any
GateObject = Any

class Gate:
"""Gate facade."""

@staticmethod
def define(permission: str, condition: Callable): ...
@staticmethod
def register_policies(policies: List[Tuple[Any, Policy]]) -> "Gate": ...
@staticmethod
def get_policy_for(instance_or_class: "str|Any") -> "None|Policy": ...
@staticmethod
def before(before_callback: Callable): ...
@staticmethod
def after(after_callback: Callable): ...
@staticmethod
def allows(permission: str, *args) -> bool: ...
@staticmethod
def denies(permission, *args) -> bool: ...
@staticmethod
def has(permission: str) -> bool: ...
@staticmethod
def for_user(user: Any) -> GateObject: ...
@staticmethod
def any(permissions: List[str], *args) -> bool:
"""Check that every of those permissions are allowed."""
...
@staticmethod
def none(permissions: List[str], *args) -> bool:
"""Check that none of those permissions are allowed."""
...
@staticmethod
def authorize(permission: str, *args) -> bool: ...
@staticmethod
def inspect(permission: str, *args) -> "bool|AuthorizationResponse":
"""Get permission checks results for the given user then builds and returns an
authorization response."""
...
@staticmethod
def check(permission: str, *args):
"""The core of the authorization class. Run before() checks, permission check and then
after() checks."""
Expand Down
21 changes: 14 additions & 7 deletions fastapi_startkit/src/fastapi_startkit/facades/Hash.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
from typing import Any

class Hash:
@staticmethod
def add_driver(name: str, driver: Any): ...
@staticmethod
def set_configuration(config: dict) -> "Hash": ...
def get_driver(name: str = None) -> Any: ...
def get_config_options(driver: str = None) -> dict: ...
def make(string: str, options: dict = {}, driver: str = None) -> str:
@staticmethod
def get_driver(name: str | None = None) -> Any: ...
@staticmethod
def get_config_options(driver: str | None = None) -> dict: ...
@staticmethod
def make(string: str, options: dict = {}, driver: str | None = None) -> str:
"""Hash a string and return as string based on configured hashing protocol."""
...
def make_bytes(string: str, options: dict = {}, driver: str = None) -> bytes:
@staticmethod
def make_bytes(string: str, options: dict = {}, driver: str | None = None) -> bytes:
"""Hash a string and return as bytes based on configured hashing protocol."""
...
@staticmethod
def check(
self,
plain_string: str,
hashed_string: str,
options: dict = {},
driver: str = None,
driver: str | None = None,
) -> bool:
"""Verify that a given string matches its hashed version (based on configured hashing protocol)."""
...
def needs_rehash(hashed_string: str, options: dict = {}, driver: str = None) -> bool:
@staticmethod
def needs_rehash(hashed_string: str, options: dict = {}, driver: str | None = None) -> bool:
"""Verify that a given hash needs to be hashed again because parameters for generating
the hash have changed."""
...
17 changes: 11 additions & 6 deletions fastapi_startkit/src/fastapi_startkit/facades/Mail.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
from typing import Any, TYPE_CHECKING
from typing import Any

if TYPE_CHECKING:
from ..mail import Mailable
Mailable = Any

class Mail:
"""Mail facade."""

@staticmethod
def add_driver(name: str, driver: Any): ...
@staticmethod
def set_configuration(config: dict) -> "Mail": ...
def get_driver(name: str = None) -> Any: ...
def get_config_options(driver: str = None) -> dict: ...
@staticmethod
def get_driver(name: str | None = None) -> Any: ...
@staticmethod
def get_config_options(driver: str | None = None) -> dict: ...
@staticmethod
def mailable(mailable: "Mailable") -> "Mail": ...
def send(driver: str = None): ...
@staticmethod
def send(driver: str | None = None): ...
11 changes: 8 additions & 3 deletions fastapi_startkit/src/fastapi_startkit/facades/Notification.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from typing import Any, TYPE_CHECKING
from typing import Any

if TYPE_CHECKING:
from ..notification import Notification as NotificationObject
NotificationObject = Any

class Notification:
"""Notification handler facade, which handle sending/queuing notifications anonymously
or to notifiables through different channels."""

@staticmethod
def add_driver(name: str, driver: str): ...
@staticmethod
def get_driver(name: str) -> Any: ...
@staticmethod
def set_configuration(config: dict) -> "Notification": ...
@staticmethod
def get_config_options(driver: str) -> dict: ...
@staticmethod
def send(
notifiables: list,
notification: "NotificationObject",
Expand All @@ -20,6 +24,7 @@ class Notification:
) -> Any:
"""Send the given notification to the given notifiables."""
...
@staticmethod
def route(driver: str, route: str) -> Any:
"""Specify how to send a notification to an anonymous notifiable."""
...
7 changes: 7 additions & 0 deletions fastapi_startkit/src/fastapi_startkit/facades/Queue.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from typing import Any

class Queue:
@staticmethod
def add_driver(name: str, driver: str): ...
@staticmethod
def get_driver(name: str) -> Any: ...
@staticmethod
def set_configuration(config: dict) -> "Queue": ...
@staticmethod
def get_config_options(driver: str) -> dict: ...
@staticmethod
def push(*jobs, **options) -> None: ...
@staticmethod
def consume(options: dict) -> Any: ...
@staticmethod
def retry(options: dict) -> Any: ...
37 changes: 30 additions & 7 deletions fastapi_startkit/src/fastapi_startkit/facades/Request.pyi
Original file line number Diff line number Diff line change
@@ -1,88 +1,111 @@
from typing import TYPE_CHECKING, List, Any
from typing import Any

if TYPE_CHECKING:
from ..routes import Route
Route = Any

class Request:
"""Request facade."""

@staticmethod
def load():
"""Load request from environment."""
...
def load_params(params: dict = None):
@staticmethod
def load_params(params: dict | None = None):
"""Load request parameters."""
...
@staticmethod
def param(param: str, default: str = "") -> str:
"""Get query string parameter from request."""
...
@staticmethod
def get_route() -> "Route":
"""Get Route associated to request if any."""
...
@staticmethod
def get_path() -> str:
"""Get request path (read from PATH_INFO) environment variable without eventual query
string parameters."""
...
@staticmethod
def get_path_with_query() -> str:
"""Get request path (read from PATH_INFO) environment variable with eventual query
string parameters."""
...
@staticmethod
def get_back_path() -> str:
"""Get previous request path if it has been defined as '__back' input."""
...
@staticmethod
def get_request_method() -> str:
"""Get request method (read from REQUEST_METHOD environment variable)."""
...
@staticmethod
def input(name: str, default: str = "") -> str:
"""Get a specific request input value with the given name. If the value does not exist in
the request return the default value."""
...
def cookie(name: str, value: str = None, **options) -> None:
@staticmethod
def cookie(name: str, value: str | None = None, **options) -> None:
"""If no value provided, read the cookie value with the given name from the request. Else
create a cookie in the request with the given name and value.
Some options can be passed when creating cookie, refer to CookieJar class."""
...
@staticmethod
def delete_cookie(name: str) -> "Request":
"""Delete cookie with the given name from the request."""
...
def header(name: str, value: str = None) -> "str|None":
@staticmethod
def header(name: str, value: str | None = None) -> "str|None":
"""If no value provided, read the header value with the given name from the request. Else
add a header in the request with the given name and value."""
...
@staticmethod
def all() -> dict:
"""Get all inputs from the request as a dictionary."""
...
def only(*inputs: List[str]) -> dict:
@staticmethod
def only(*inputs: str) -> dict:
"""Get only the given inputs from the request as a dictionary."""
...
@staticmethod
def old(key: str):
"""Get value from session for the given key."""
...
@staticmethod
def is_not_safe() -> bool:
"""Check if the current request is considered 'safe', meaning that the request method is
GET, OPTIONS or HEAD."""
...
@staticmethod
def user() -> "None|Any":
"""Get the current authenticated user if any. LoadUserMiddleware needs to be used for user
to be populated in request."""
...
@staticmethod
def set_user(user: Any) -> "Request":
"""Set the current authenticated user of the request."""
...
@staticmethod
def remove_user() -> "Request":
"""Log out user of the current request."""
...
@staticmethod
def contains(route: str) -> bool:
"""Check if current request path match the given URL."""
...
@staticmethod
def get_subdomain(exclude_www: bool = True) -> "None|str":
"""Get the request subdomain if subdomains are enabled."""
...
@staticmethod
def get_host() -> str:
"""Get the request host (from HTTP_HOST environment variable)."""
...
@staticmethod
def activate_subdomains():
"""Enable subdomains for this request."""
...
@staticmethod
def is_ajax() -> bool:
"""Check if the current request is an AJAX request."""
...
Loading
Loading