@anvil-works/anvil-pyright 0.0.1 → 0.0.2-canary
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anvil-typeshed/TODOS.md +70 -0
- package/dist/anvil-typeshed/client/anvil/__init__.pyi +1291 -0
- package/dist/anvil-typeshed/client/anvil/__pycache__/server.cpython-39.pyc +0 -0
- package/dist/anvil-typeshed/client/anvil/email.pyi +152 -0
- package/dist/anvil-typeshed/client/anvil/facebook/__init__.pyi +8 -0
- package/dist/anvil-typeshed/client/anvil/facebook/auth.pyi +30 -0
- package/dist/anvil-typeshed/client/anvil/google/__init__.pyi +11 -0
- package/dist/anvil-typeshed/client/anvil/google/auth.pyi +37 -0
- package/dist/anvil-typeshed/client/anvil/google/drive.pyi +98 -0
- package/dist/anvil-typeshed/client/anvil/google/sheets.pyi +98 -0
- package/dist/anvil-typeshed/client/anvil/http.pyi +66 -0
- package/dist/anvil-typeshed/client/anvil/image.pyi +30 -0
- package/dist/anvil-typeshed/client/anvil/js/__init__.pyi +143 -0
- package/dist/anvil-typeshed/client/anvil/js/window/__init__.pyi +2935 -0
- package/dist/anvil-typeshed/client/anvil/media.pyi +46 -0
- package/dist/anvil-typeshed/client/anvil/microsoft/__init__.pyi +8 -0
- package/dist/anvil-typeshed/client/anvil/microsoft/auth.pyi +34 -0
- package/dist/anvil-typeshed/client/anvil/mpl_util.pyi +29 -0
- package/dist/anvil-typeshed/client/anvil/plotly_templates.pyi +15 -0
- package/dist/anvil-typeshed/client/anvil/saml/__init__.pyi +8 -0
- package/dist/anvil-typeshed/client/anvil/saml/auth.pyi +24 -0
- package/dist/anvil-typeshed/client/anvil/secrets.pyi +22 -0
- package/dist/anvil-typeshed/client/anvil/server.pyi +376 -0
- package/dist/anvil-typeshed/client/anvil/stripe.pyi +23 -0
- package/dist/anvil-typeshed/client/anvil/tables/__init__.pyi +297 -0
- package/dist/anvil-typeshed/client/anvil/tables/query.pyi +88 -0
- package/dist/anvil-typeshed/client/anvil/tz.pyi +92 -0
- package/dist/anvil-typeshed/client/anvil/users/__init__.pyi +191 -0
- package/dist/anvil-typeshed/client/anvil/users/mfa.pyi +76 -0
- package/dist/anvil-typeshed/client/stripe/__init__.pyi +8 -0
- package/dist/anvil-typeshed/client/stripe/checkout.pyi +67 -0
- package/dist/anvil-typeshed/server/anvil/__init__.pyi +148 -0
- package/dist/anvil-typeshed/server/anvil/email.pyi +188 -0
- package/dist/anvil-typeshed/server/anvil/facebook/__init__.pyi +8 -0
- package/dist/anvil-typeshed/server/anvil/facebook/auth.pyi +27 -0
- package/dist/anvil-typeshed/server/anvil/files.pyi +53 -0
- package/dist/anvil-typeshed/server/anvil/google/__init__.pyi +11 -0
- package/dist/anvil-typeshed/server/anvil/google/auth.pyi +31 -0
- package/dist/anvil-typeshed/server/anvil/google/drive.pyi +98 -0
- package/dist/anvil-typeshed/server/anvil/google/mail.pyi +24 -0
- package/dist/anvil-typeshed/server/anvil/google/sheets.pyi +98 -0
- package/dist/anvil-typeshed/server/anvil/http.pyi +66 -0
- package/dist/anvil-typeshed/server/anvil/image.pyi +30 -0
- package/dist/anvil-typeshed/server/anvil/media.pyi +32 -0
- package/dist/anvil-typeshed/server/anvil/microsoft/__init__.pyi +8 -0
- package/dist/anvil-typeshed/server/anvil/microsoft/auth.pyi +31 -0
- package/dist/anvil-typeshed/server/anvil/mpl_util.pyi +29 -0
- package/dist/anvil-typeshed/server/anvil/pdf.pyi +61 -0
- package/dist/anvil-typeshed/server/anvil/plotly_templates.pyi +15 -0
- package/dist/anvil-typeshed/server/anvil/saml/__init__.pyi +8 -0
- package/dist/anvil-typeshed/server/anvil/saml/auth.pyi +21 -0
- package/dist/anvil-typeshed/server/anvil/secrets.pyi +22 -0
- package/dist/anvil-typeshed/server/anvil/server.pyi +470 -0
- package/dist/anvil-typeshed/server/anvil/stripe.pyi +23 -0
- package/dist/anvil-typeshed/server/anvil/tables/__init__.pyi +319 -0
- package/dist/anvil-typeshed/server/anvil/tables/query.pyi +88 -0
- package/dist/anvil-typeshed/server/anvil/tz.pyi +92 -0
- package/dist/anvil-typeshed/server/anvil/users/__init__.pyi +83 -0
- package/dist/anvil-typeshed/server/anvil/users/mfa.pyi +65 -0
- package/dist/anvil-typeshed/server/stripe/__init__.pyi +8 -0
- package/dist/anvil-typeshed/server/stripe/checkout.pyi +9 -0
- package/dist/anvil-typeshed/source/anvil/__init__.pyi +1306 -0
- package/dist/anvil-typeshed/source/anvil/email.pyi +188 -0
- package/dist/anvil-typeshed/source/anvil/facebook/__init__.pyi +4 -0
- package/dist/anvil-typeshed/source/anvil/facebook/auth.pyi +28 -0
- package/dist/anvil-typeshed/source/anvil/files.pyi +50 -0
- package/dist/anvil-typeshed/source/anvil/google/__init__.pyi +7 -0
- package/dist/anvil-typeshed/source/anvil/google/auth.pyi +35 -0
- package/dist/anvil-typeshed/source/anvil/google/drive.pyi +94 -0
- package/dist/anvil-typeshed/source/anvil/google/mail.pyi +21 -0
- package/dist/anvil-typeshed/source/anvil/google/sheets.pyi +94 -0
- package/dist/anvil-typeshed/source/anvil/http.pyi +62 -0
- package/dist/anvil-typeshed/source/anvil/image.pyi +26 -0
- package/dist/anvil-typeshed/source/anvil/js/__init__.pyi +140 -0
- package/dist/anvil-typeshed/source/anvil/js/window/__init__.pyi +2932 -0
- package/dist/anvil-typeshed/source/anvil/media.pyi +62 -0
- package/dist/anvil-typeshed/source/anvil/microsoft/__init__.pyi +4 -0
- package/dist/anvil-typeshed/source/anvil/microsoft/auth.pyi +32 -0
- package/dist/anvil-typeshed/source/anvil/mpl_util.pyi +25 -0
- package/dist/anvil-typeshed/source/anvil/pdf.pyi +58 -0
- package/dist/anvil-typeshed/source/anvil/plotly_templates.pyi +11 -0
- package/dist/anvil-typeshed/source/anvil/saml/__init__.pyi +4 -0
- package/dist/anvil-typeshed/source/anvil/saml/auth.pyi +22 -0
- package/dist/anvil-typeshed/source/anvil/secrets.pyi +18 -0
- package/dist/anvil-typeshed/source/anvil/server.pyi +511 -0
- package/dist/anvil-typeshed/source/anvil/stripe.pyi +19 -0
- package/dist/anvil-typeshed/source/anvil/tables/__init__.pyi +319 -0
- package/dist/anvil-typeshed/source/anvil/tables/query.pyi +84 -0
- package/dist/anvil-typeshed/source/anvil/tz.pyi +88 -0
- package/dist/anvil-typeshed/source/anvil/users/__init__.pyi +196 -0
- package/dist/anvil-typeshed/source/anvil/users/mfa.pyi +74 -0
- package/dist/anvil-typeshed/source/stripe/__init__.pyi +4 -0
- package/dist/anvil-typeshed/source/stripe/checkout.pyi +65 -0
- package/dist/pyright-langserver.js +1 -1
- package/dist/pyright-langserver.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.media module
|
|
6
|
+
# Generated files: client/anvil/media.pyi, server/anvil/media.pyi
|
|
7
|
+
|
|
8
|
+
from typing import IO, Any
|
|
9
|
+
|
|
10
|
+
from anvil import Media
|
|
11
|
+
|
|
12
|
+
def print_media(media: Media, /) -> None:
|
|
13
|
+
"""Print the given Media Object immediately in the user's browser."""
|
|
14
|
+
...
|
|
15
|
+
|
|
16
|
+
def download(media: Media, /) -> None:
|
|
17
|
+
"""Download the given Media Object immediately in the user's browser."""
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
class TempUrl:
|
|
21
|
+
"""Creates a temporary client-side URL for a Media object, even if the media has no permanent URL.
|
|
22
|
+
|
|
23
|
+
This URL should be revoked when you are finished with it. If you use TempUrl as a context
|
|
24
|
+
manager ('with TempUrl(media) as url:'), this happens automatically; if you instantiate it
|
|
25
|
+
manually you must call 'revoke()' on the instance.
|
|
26
|
+
|
|
27
|
+
The download argument only affects LazyMedia objects."""
|
|
28
|
+
|
|
29
|
+
url: str
|
|
30
|
+
"""The temporary URL."""
|
|
31
|
+
|
|
32
|
+
def __init__(self, media: Media, *, download: bool = True) -> None: ...
|
|
33
|
+
def __enter__(self) -> str:
|
|
34
|
+
"""Get the url using a 'with' block."""
|
|
35
|
+
...
|
|
36
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
37
|
+
"""Revoke a url when exiting a 'with' block."""
|
|
38
|
+
...
|
|
39
|
+
def revoke(self) -> None:
|
|
40
|
+
"""Revoke a url from a media object."""
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def write_to_file(media: Media, filename: str) -> None:
|
|
45
|
+
"""Write a Media object to the given file."""
|
|
46
|
+
...
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.microsoft module
|
|
6
|
+
# Generated files: client/anvil/microsoft/__init__.pyi, server/anvil/microsoft/__init__.pyi
|
|
7
|
+
|
|
8
|
+
from anvil.microsoft import auth as auth
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.microsoft.auth module
|
|
6
|
+
# Generated files: client/anvil/microsoft/auth.pyi, server/anvil/microsoft/auth.pyi
|
|
7
|
+
|
|
8
|
+
def login() -> None:
|
|
9
|
+
"""Prompt the user to log in with their Microsoft account."""
|
|
10
|
+
...
|
|
11
|
+
|
|
12
|
+
def get_user_email() -> str | None:
|
|
13
|
+
"""Get the email address of the currently-logged-in Microsoft user.
|
|
14
|
+
|
|
15
|
+
To log in with Microsoft, call anvil_microsoft.auth.login() from form code."""
|
|
16
|
+
...
|
|
17
|
+
|
|
18
|
+
def get_user_access_token() -> str | None:
|
|
19
|
+
"""Get the secret access token of the currently-logged-in Microsoft user, for use with the Microsoft REST API.
|
|
20
|
+
|
|
21
|
+
Requires this app to have its own Microsoft client ID and secret."""
|
|
22
|
+
...
|
|
23
|
+
|
|
24
|
+
def get_user_refresh_token() -> str | None:
|
|
25
|
+
"""Get the secret refresh token of the currently-logged-in Microsoft user, for use with the Microsoft REST API.
|
|
26
|
+
|
|
27
|
+
Requires this app to have its own Microsoft client ID and secret."""
|
|
28
|
+
...
|
|
29
|
+
|
|
30
|
+
def refresh_access_token(refresh_token: str, /) -> str:
|
|
31
|
+
"""Get a new access token from a refresh token you have saved, for use with the Microsoft REST API.
|
|
32
|
+
|
|
33
|
+
Requires this app to have its own Microsoft client ID and secret."""
|
|
34
|
+
...
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.mpl_util module
|
|
6
|
+
# Generated files: client/anvil/mpl_util.pyi, server/anvil/mpl_util.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from anvil import Media
|
|
11
|
+
|
|
12
|
+
def plot_image(
|
|
13
|
+
*,
|
|
14
|
+
dpi: int | None = None,
|
|
15
|
+
facecolor: Any | None = None,
|
|
16
|
+
edgecolor: Any | None = None,
|
|
17
|
+
format: str | None = None,
|
|
18
|
+
transparent: bool | None = None,
|
|
19
|
+
frameon: bool | None = None,
|
|
20
|
+
bbox_inches: str | Any | None = None,
|
|
21
|
+
pad_inches: float | None = None,
|
|
22
|
+
filename: str | None = None,
|
|
23
|
+
) -> Media:
|
|
24
|
+
"""Return the current Matplotlib figure as a PNG image.
|
|
25
|
+
|
|
26
|
+
Returns an Anvil Media object that can be displayed in Image components.
|
|
27
|
+
|
|
28
|
+
Optional arguments have the same meaning as for 'savefig()'."""
|
|
29
|
+
...
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.plotly_templates module
|
|
6
|
+
# Generated files: client/anvil/plotly_templates.pyi, server/anvil/plotly_templates.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
templates: dict[str, Any]
|
|
11
|
+
"""A dictionary of custom templates for anvil themes."""
|
|
12
|
+
|
|
13
|
+
def set_default(template: str | Any) -> None:
|
|
14
|
+
"""Sets the default plotly template."""
|
|
15
|
+
...
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.saml module
|
|
6
|
+
# Generated files: client/anvil/saml/__init__.pyi, server/anvil/saml/__init__.pyi
|
|
7
|
+
|
|
8
|
+
from anvil.saml import auth as auth
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.saml.auth module
|
|
6
|
+
# Generated files: client/anvil/saml/auth.pyi, server/anvil/saml/auth.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
def login() -> None:
|
|
11
|
+
"""Prompt the user to log in via SAML."""
|
|
12
|
+
...
|
|
13
|
+
|
|
14
|
+
def get_user_email() -> str | None:
|
|
15
|
+
"""Get the email address of the currently-logged-in SAML user.
|
|
16
|
+
|
|
17
|
+
To log in with SAML, call anvil.saml.auth.login() from form code."""
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
def get_user_attributes() -> dict[str, Any] | None:
|
|
21
|
+
"""Get the user attributes of the currently-logged-in SAML user.
|
|
22
|
+
|
|
23
|
+
The exact attributes available will depend on your SAML Identity Provider."""
|
|
24
|
+
...
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.secrets module
|
|
6
|
+
# Generated files: client/anvil/secrets.pyi, server/anvil/secrets.pyi
|
|
7
|
+
|
|
8
|
+
class SecretError(Exception):
|
|
9
|
+
"""Secret access or encryption error."""
|
|
10
|
+
...
|
|
11
|
+
|
|
12
|
+
def get_secret(secret_name: str) -> str:
|
|
13
|
+
"""Retrieve the named secret."""
|
|
14
|
+
...
|
|
15
|
+
|
|
16
|
+
def encrypt_with_key(key_name: str, value: str) -> str:
|
|
17
|
+
"""Encrypt a string with a cryptographic key derived from the named secret."""
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
def decrypt_with_key(key_name: str, value: str) -> str:
|
|
21
|
+
"""Decrypt a string with a cryptographic key derived from the named secret."""
|
|
22
|
+
...
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.server module
|
|
6
|
+
# Generated files: client/anvil/server.pyi, server/anvil/server.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any, Callable, TypeVar, overload, ParamSpec, Literal
|
|
9
|
+
from contextlib import contextmanager
|
|
10
|
+
|
|
11
|
+
_T = TypeVar("_T")
|
|
12
|
+
_P = ParamSpec("_P")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# ============================================================================
|
|
16
|
+
# Exceptions
|
|
17
|
+
# ============================================================================
|
|
18
|
+
|
|
19
|
+
class SerializationError(Exception):
|
|
20
|
+
"""Raised when serialization fails."""
|
|
21
|
+
...
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AppOfflineError(Exception):
|
|
25
|
+
"""Raised when the app is offline."""
|
|
26
|
+
...
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# ============================================================================
|
|
30
|
+
# Capabilities
|
|
31
|
+
# ============================================================================
|
|
32
|
+
|
|
33
|
+
class Capability:
|
|
34
|
+
"""A Capability represents the ability to perform an action.
|
|
35
|
+
|
|
36
|
+
[Anvil Docs](https://anvil.works/docs/server/capabilities)"""
|
|
37
|
+
|
|
38
|
+
ANY: Any
|
|
39
|
+
"""Sentinel value for unwrap_capability."""
|
|
40
|
+
|
|
41
|
+
scope: list[Any]
|
|
42
|
+
"""A list representing what this capability represents.
|
|
43
|
+
|
|
44
|
+
It can be extended by calling narrow(), but not shortened.
|
|
45
|
+
Eg: ['my_resource', 42, 'foo']"""
|
|
46
|
+
|
|
47
|
+
is_valid: bool
|
|
48
|
+
"""True if this Capability is still valid; False if it has been invalidated."""
|
|
49
|
+
|
|
50
|
+
def narrow(self, additional_scope: Any) -> "Capability":
|
|
51
|
+
"""Return a new capability that is narrower than this one.
|
|
52
|
+
|
|
53
|
+
Appends additional scope element(s) to it."""
|
|
54
|
+
...
|
|
55
|
+
|
|
56
|
+
def set_update_handler(
|
|
57
|
+
self,
|
|
58
|
+
apply_update: Callable[..., Any],
|
|
59
|
+
get_update: Callable[..., Any] | None = None,
|
|
60
|
+
) -> None:
|
|
61
|
+
"""Set a handler for what happens when an update is sent to this capability.
|
|
62
|
+
|
|
63
|
+
Optionally provide a function for aggregating updates."""
|
|
64
|
+
...
|
|
65
|
+
|
|
66
|
+
def send_update(self, update: Any) -> None:
|
|
67
|
+
"""Send an update to the update handler for this capability."""
|
|
68
|
+
...
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def unwrap_capability(capability: Capability, scope_pattern: list[Any]) -> list[Any]:
|
|
72
|
+
"""Check that the first argument is a valid Capability and its scope matches the pattern.
|
|
73
|
+
|
|
74
|
+
To match, the scope must:
|
|
75
|
+
- Be at least as broad as the pattern (ie the same length or shorter)
|
|
76
|
+
- Contain the same values in the same position as the pattern - unless that
|
|
77
|
+
position in the pattern is Capability.ANY, which matches any value
|
|
78
|
+
|
|
79
|
+
Returns a list of matched scope elements, of the same length as the pattern."""
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# ============================================================================
|
|
84
|
+
# Call Context
|
|
85
|
+
# ============================================================================
|
|
86
|
+
|
|
87
|
+
class _ClientInfo:
|
|
88
|
+
"""Information about the client that initiated the current session."""
|
|
89
|
+
|
|
90
|
+
type: str
|
|
91
|
+
"""The type of client (e.g., 'browser', 'uplink')."""
|
|
92
|
+
|
|
93
|
+
ip: str | None
|
|
94
|
+
"""The IP address of the client."""
|
|
95
|
+
|
|
96
|
+
location: "_Location | None"
|
|
97
|
+
"""The location of the client, if available."""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class _Location:
|
|
101
|
+
"""Geographic location information."""
|
|
102
|
+
|
|
103
|
+
city: str | None
|
|
104
|
+
country: str | None
|
|
105
|
+
latitude: float | None
|
|
106
|
+
longitude: float | None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class _StackFrame:
|
|
110
|
+
"""Information about a call stack frame."""
|
|
111
|
+
|
|
112
|
+
type: str
|
|
113
|
+
"""The execution environment type."""
|
|
114
|
+
|
|
115
|
+
is_trusted: bool
|
|
116
|
+
"""Whether this call is from trusted (server-side) code."""
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class CallContext:
|
|
120
|
+
"""Contains information about what triggered the currently running code."""
|
|
121
|
+
|
|
122
|
+
client: _ClientInfo
|
|
123
|
+
"""An object that describes the client that initiated the current session."""
|
|
124
|
+
|
|
125
|
+
type: str
|
|
126
|
+
"""The execution environment this code is running in.
|
|
127
|
+
|
|
128
|
+
May be 'browser', 'server_module' or 'uplink'."""
|
|
129
|
+
|
|
130
|
+
remote_caller: _StackFrame | None
|
|
131
|
+
"""An object describing the code that called this @anvil.server.callable function."""
|
|
132
|
+
|
|
133
|
+
background_task_id: str | None
|
|
134
|
+
"""The ID of the currently running background task, if there is one."""
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
context: CallContext
|
|
138
|
+
"""Contains information about what triggered the currently running code."""
|
|
139
|
+
|
|
140
|
+
# Call a server function
|
|
141
|
+
def call(fn_name: str, /, *args: Any, **kwargs: Any) -> Any:
|
|
142
|
+
"""Call a server function by name.
|
|
143
|
+
|
|
144
|
+
[Anvil Docs](https://anvil.works/docs/server)"""
|
|
145
|
+
...
|
|
146
|
+
|
|
147
|
+
def call_s(fn_name: str, /, *args: Any, **kwargs: Any) -> Any:
|
|
148
|
+
"""Call a server function by name without showing a loading indicator.
|
|
149
|
+
|
|
150
|
+
[Anvil Docs](https://anvil.works/docs/server)"""
|
|
151
|
+
...
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
# Server method decorator (for methods in portable classes)
|
|
155
|
+
@overload
|
|
156
|
+
def server_method(fn: Callable[_P, _T]) -> Callable[_P, _T]: ...
|
|
157
|
+
@overload
|
|
158
|
+
def server_method(*, require_user: bool | Callable[..., bool] | None = None) -> Callable[[Callable[_P, _T]], Callable[_P, _T]]: ...
|
|
159
|
+
def server_method(
|
|
160
|
+
fn: Callable[_P, _T] | None = ...,
|
|
161
|
+
*,
|
|
162
|
+
require_user: bool | Callable[..., bool] | None = None
|
|
163
|
+
) -> Callable[_P, _T] | Callable[[Callable[_P, _T]], Callable[_P, _T]]:
|
|
164
|
+
"""Mark a method in a portable class as callable from client code.
|
|
165
|
+
|
|
166
|
+
Methods decorated with @anvil.server.server_method can be called on portable
|
|
167
|
+
class instances from client code, and will execute on the server.
|
|
168
|
+
|
|
169
|
+
[Anvil Docs](https://anvil.works/docs/server/portable-classes#server-methods)"""
|
|
170
|
+
...
|
|
171
|
+
|
|
172
|
+
# Background task decorator
|
|
173
|
+
@overload
|
|
174
|
+
def background_task(fn: Callable[_P, _T]) -> Callable[_P, _T]: ...
|
|
175
|
+
@overload
|
|
176
|
+
def background_task() -> Callable[[Callable[_P, _T]], Callable[_P, _T]]: ...
|
|
177
|
+
def background_task(fn: Callable[_P, _T] | None = None) -> Callable[_P, _T] | Callable[[Callable[_P, _T]], Callable[_P, _T]]:
|
|
178
|
+
"""Mark a function as a background task.
|
|
179
|
+
|
|
180
|
+
[Anvil Docs](https://anvil.works/docs/background-tasks)"""
|
|
181
|
+
...
|
|
182
|
+
|
|
183
|
+
# Launch a background task
|
|
184
|
+
def launch_background_task(task_name: str, /, *args: Any, **kwargs: Any) -> Any:
|
|
185
|
+
"""Launch a background task by name.
|
|
186
|
+
|
|
187
|
+
[Anvil Docs](https://anvil.works/docs/background-tasks)"""
|
|
188
|
+
...
|
|
189
|
+
|
|
190
|
+
# Request context
|
|
191
|
+
class request:
|
|
192
|
+
"""HTTP request context for http_endpoint handlers.
|
|
193
|
+
|
|
194
|
+
[Anvil Docs](https://anvil.works/docs/server/http-endpoints)"""
|
|
195
|
+
method: str
|
|
196
|
+
path: str
|
|
197
|
+
body: bytes
|
|
198
|
+
body_json: Any | None
|
|
199
|
+
remote_address: str
|
|
200
|
+
headers: dict[str, str]
|
|
201
|
+
query_params: dict[str, str]
|
|
202
|
+
form_params: dict[str, str]
|
|
203
|
+
cookies: dict[str, str]
|
|
204
|
+
@staticmethod
|
|
205
|
+
def get_header(name: str) -> str | None: ...
|
|
206
|
+
|
|
207
|
+
# Session handling
|
|
208
|
+
class session:
|
|
209
|
+
"""Server-side session storage.
|
|
210
|
+
|
|
211
|
+
[Anvil Docs](https://anvil.works/docs/server/sessions)"""
|
|
212
|
+
@staticmethod
|
|
213
|
+
def get(key: str, default: Any = None) -> Any: ...
|
|
214
|
+
@staticmethod
|
|
215
|
+
def set(key: str, value: Any) -> None: ...
|
|
216
|
+
@staticmethod
|
|
217
|
+
def clear() -> None: ...
|
|
218
|
+
|
|
219
|
+
# HTTP endpoint decorator
|
|
220
|
+
def http_endpoint(path: str, methods: list[str] | None = None, authenticate_users: bool = False, enable_cors: bool = False, cross_site_session: bool = False) -> Callable[[Callable[_P, _T]], Callable[_P, _T]]:
|
|
221
|
+
"""Decorator to create an HTTP endpoint.
|
|
222
|
+
|
|
223
|
+
[Anvil Docs](https://anvil.works/docs/server/http-endpoints)"""
|
|
224
|
+
...
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
# Connect to other servers
|
|
228
|
+
def connect(url: str, /, **kwargs: Any) -> Any:
|
|
229
|
+
"""Connect to an Anvil Uplink server.
|
|
230
|
+
|
|
231
|
+
[Anvil Docs](https://anvil.works/docs/uplink)"""
|
|
232
|
+
...
|
|
233
|
+
|
|
234
|
+
# Portable classes
|
|
235
|
+
def portable_class(cls: type[_T], /) -> type[_T]:
|
|
236
|
+
"""Decorator to make a class portable across client and server.
|
|
237
|
+
|
|
238
|
+
[Anvil Docs](https://anvil.works/docs/server/portable-classes)"""
|
|
239
|
+
...
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
# ============================================================================
|
|
243
|
+
# URL and Origin Functions
|
|
244
|
+
# ============================================================================
|
|
245
|
+
|
|
246
|
+
def get_app_origin(environment_type: Literal["published"] | None = None) -> str:
|
|
247
|
+
"""Returns the root URL for the current app.
|
|
248
|
+
|
|
249
|
+
By default, this function returns the URL for the current environment,
|
|
250
|
+
which might be private or temporary. If you want the URL for the published
|
|
251
|
+
branch, pass 'published' as an argument.
|
|
252
|
+
|
|
253
|
+
[Anvil Docs](https://anvil.works/docs/http-apis/creating-http-endpoints#getting-the-url-for-your-api)"""
|
|
254
|
+
...
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def get_api_origin(environment_type: Literal["published"] | None = None) -> str:
|
|
258
|
+
"""Returns the root URL of the API for the current app.
|
|
259
|
+
|
|
260
|
+
By default, this function returns the URL for the current environment,
|
|
261
|
+
which might be private or temporary. If you want the URL for the published
|
|
262
|
+
branch, pass 'published' as an argument.
|
|
263
|
+
|
|
264
|
+
[Anvil Docs](https://anvil.works/docs/http-apis/creating-http-endpoints#getting-the-url-for-your-api)"""
|
|
265
|
+
...
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
# ============================================================================
|
|
269
|
+
# Session Functions
|
|
270
|
+
# ============================================================================
|
|
271
|
+
|
|
272
|
+
def get_session_id() -> str | None:
|
|
273
|
+
"""Get the current session ID, if any."""
|
|
274
|
+
...
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def reset_session() -> None:
|
|
278
|
+
"""Reset the current session."""
|
|
279
|
+
...
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# ============================================================================
|
|
283
|
+
# Background Tasks
|
|
284
|
+
# ============================================================================
|
|
285
|
+
|
|
286
|
+
class BackgroundTaskState:
|
|
287
|
+
"""Information about a background task."""
|
|
288
|
+
|
|
289
|
+
task_id: str
|
|
290
|
+
"""The ID of the background task."""
|
|
291
|
+
|
|
292
|
+
def get_id(self) -> str:
|
|
293
|
+
"""Get the ID of this background task."""
|
|
294
|
+
...
|
|
295
|
+
|
|
296
|
+
def get_state(self) -> dict[str, Any]:
|
|
297
|
+
"""Get the current state of this background task."""
|
|
298
|
+
...
|
|
299
|
+
|
|
300
|
+
def get_return_value(self) -> Any:
|
|
301
|
+
"""Get the return value of this background task, if completed."""
|
|
302
|
+
...
|
|
303
|
+
|
|
304
|
+
def get_error(self) -> Exception | None:
|
|
305
|
+
"""Get the error from this background task, if it failed."""
|
|
306
|
+
...
|
|
307
|
+
|
|
308
|
+
def is_completed(self) -> bool:
|
|
309
|
+
"""Check if this background task has completed."""
|
|
310
|
+
...
|
|
311
|
+
|
|
312
|
+
def is_running(self) -> bool:
|
|
313
|
+
"""Check if this background task is still running."""
|
|
314
|
+
...
|
|
315
|
+
|
|
316
|
+
def kill(self) -> None:
|
|
317
|
+
"""Kill this background task."""
|
|
318
|
+
...
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def get_background_task(id: str, /) -> BackgroundTaskState:
|
|
322
|
+
"""Returns the Task object of a background task from its id.
|
|
323
|
+
|
|
324
|
+
You can get the task id from task.get_id().
|
|
325
|
+
|
|
326
|
+
[Anvil Docs](https://anvil.works/docs/background-tasks/communicating-back)"""
|
|
327
|
+
...
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def list_background_tasks(all_environments: bool = False) -> list[BackgroundTaskState]:
|
|
331
|
+
"""Returns a list of all Tasks running in the current environment.
|
|
332
|
+
|
|
333
|
+
If all_environments is True, this function will return all of the app's
|
|
334
|
+
running Tasks regardless of environment.
|
|
335
|
+
|
|
336
|
+
[Anvil Docs](https://anvil.works/docs/background-tasks#list-background-tasks-from-code)"""
|
|
337
|
+
...
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
# ============================================================================
|
|
341
|
+
# Loading Indicator (client-only)
|
|
342
|
+
# ============================================================================
|
|
343
|
+
|
|
344
|
+
class _NoLoadingIndicator:
|
|
345
|
+
"""Context manager to suppress the loading indicator."""
|
|
346
|
+
|
|
347
|
+
def __enter__(self) -> None: ...
|
|
348
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
no_loading_indicator: _NoLoadingIndicator
|
|
352
|
+
"""Use `with anvil.server.no_loading_indicator:` to suppress the loading indicator when making server calls."""
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
@contextmanager
|
|
356
|
+
def loading_indicator(
|
|
357
|
+
*,
|
|
358
|
+
component_name: Any | None = None,
|
|
359
|
+
min_height: int | None = None,
|
|
360
|
+
) -> Any:
|
|
361
|
+
"""Create a loading indicator manually.
|
|
362
|
+
|
|
363
|
+
By default, a loading indicator is displayed when your app is retrieving data.
|
|
364
|
+
This context manager allows you to create loading indicators manually.
|
|
365
|
+
|
|
366
|
+
Args:
|
|
367
|
+
component_name: Optionally give the component or container that the loading
|
|
368
|
+
indicator should overlay.
|
|
369
|
+
min_height: Optionally set the minimum height of the loading indicator."""
|
|
370
|
+
...
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
# ============================================================================
|
|
374
|
+
# HTTP Response Classes
|
|
375
|
+
# ============================================================================
|
|
376
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# AUTO-GENERATED FILE - DO NOT EDIT
|
|
2
|
+
# Edit the source file in anvil-typeshed/source/ instead, then run:
|
|
3
|
+
# npm run generate-anvil-stubs
|
|
4
|
+
#
|
|
5
|
+
# Type stubs for anvil.stripe module
|
|
6
|
+
# Generated files: client/anvil/stripe.pyi, server/anvil/stripe.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
class Customer:
|
|
11
|
+
"""A Stripe Customer object."""
|
|
12
|
+
|
|
13
|
+
id: str
|
|
14
|
+
email: str
|
|
15
|
+
def __getattr__(self, name: str) -> Any: ...
|
|
16
|
+
|
|
17
|
+
def new_customer(email_address: str, token: str | None = None) -> Customer:
|
|
18
|
+
"""Create a new Stripe Customer record."""
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
def get_customer(customer_id: str, /) -> Customer:
|
|
22
|
+
"""Retrieve a Stripe Customer record by its ID."""
|
|
23
|
+
...
|