@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,76 @@
|
|
|
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.users.mfa module
|
|
6
|
+
# Generated files: client/anvil/users/mfa.pyi, server/anvil/users/mfa.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any, Literal
|
|
9
|
+
|
|
10
|
+
from anvil.tables import Row
|
|
11
|
+
|
|
12
|
+
def create_fido_mfa_method(email_address: str) -> Any:
|
|
13
|
+
"""Generate a WebAuthn challenge that can be used to register a new hardware token for two-factor authentication."""
|
|
14
|
+
...
|
|
15
|
+
|
|
16
|
+
def get_fido_mfa_login(email_address: str, password: str) -> Any:
|
|
17
|
+
"""Generate a WebAuthn challenge that the given user can use to log in with a previously registered hardware token."""
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
def get_totp_mfa_login(code: str) -> Any:
|
|
21
|
+
"""Get an MFA login object representing a TOTP login code.
|
|
22
|
+
|
|
23
|
+
This can be passed to the login_with_email function as the mfa argument."""
|
|
24
|
+
...
|
|
25
|
+
|
|
26
|
+
def get_twilio_mfa_login(code: str) -> Any:
|
|
27
|
+
"""Get an MFA login object representing a Twilio Verify token.
|
|
28
|
+
|
|
29
|
+
This can be passed to the login_with_email function as the mfa argument."""
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
def generate_totp_secret(email_address: str) -> dict[str, Any]:
|
|
33
|
+
"""Generate a TOTP secret that can be added as two-factor authentication for the current user."""
|
|
34
|
+
...
|
|
35
|
+
|
|
36
|
+
def validate_totp_code(mfa_method: Any, code: str) -> bool:
|
|
37
|
+
"""Validate the given TOTP code against the given MFA method from a User row."""
|
|
38
|
+
...
|
|
39
|
+
|
|
40
|
+
def generate_twilio_mfa_method(phone: str) -> Any:
|
|
41
|
+
"""Generate a Twilio MFA method from the provided phone number."""
|
|
42
|
+
...
|
|
43
|
+
|
|
44
|
+
def send_twilio_token(mfa_method: Any, channel: Literal["sms", "call"]) -> None:
|
|
45
|
+
"""Send a Twilio Verify token using the given MFA method from a User row."""
|
|
46
|
+
...
|
|
47
|
+
|
|
48
|
+
def check_twilio_token(mfa_method: Any, token: str) -> bool:
|
|
49
|
+
"""Validate the given Twilio Verify token against the given MFA method from a User row."""
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
def add_mfa_method(password: str, mfa_method: Any, *, clear_existing: bool = False) -> None:
|
|
53
|
+
"""Add an MFA method to the current user by passing the user's password and the mfa method.
|
|
54
|
+
|
|
55
|
+
Optionally clearing all existing methods."""
|
|
56
|
+
...
|
|
57
|
+
|
|
58
|
+
def get_available_mfa_types(email_address: str, password: str) -> list[str]:
|
|
59
|
+
"""Get the available MFA types for the given user by passing their email and password."""
|
|
60
|
+
...
|
|
61
|
+
|
|
62
|
+
def get_enabled_mfa_types() -> list[str]:
|
|
63
|
+
"""Get all the enabled MFA types for this app."""
|
|
64
|
+
...
|
|
65
|
+
|
|
66
|
+
def mfa_login_with_form(email_address: str, password: str) -> Row | None:
|
|
67
|
+
"""Display a form to collect two-factor authentication credentials from the user currently logging in.
|
|
68
|
+
|
|
69
|
+
Pass the function their email and password."""
|
|
70
|
+
...
|
|
71
|
+
|
|
72
|
+
def configure_mfa_with_form(*, allow_cancel: bool = False) -> None:
|
|
73
|
+
"""Display a form for the user to configure 2-factor authentication.
|
|
74
|
+
|
|
75
|
+
allow_cancel: if True, the signup form has a Cancel button that the user can use to dismiss the form."""
|
|
76
|
+
...
|
|
@@ -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 stripe module
|
|
6
|
+
# Generated files: client/stripe/__init__.pyi, server/stripe/__init__.pyi
|
|
7
|
+
|
|
8
|
+
from stripe import checkout as checkout
|
|
@@ -0,0 +1,67 @@
|
|
|
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 stripe.checkout module
|
|
6
|
+
# Generated files: client/stripe/checkout.pyi, server/stripe/checkout.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
def get_token(
|
|
11
|
+
*,
|
|
12
|
+
amount: int,
|
|
13
|
+
currency: str,
|
|
14
|
+
title: str | None = None,
|
|
15
|
+
description: str | None = None,
|
|
16
|
+
icon_url: str | None = None,
|
|
17
|
+
billing_address: bool = False,
|
|
18
|
+
zipcode: bool = False,
|
|
19
|
+
raw: bool = False,
|
|
20
|
+
) -> tuple[str, dict[str, Any]]:
|
|
21
|
+
"""Show the Stripe checkout form and return a raw (token, user_details) tuple.
|
|
22
|
+
|
|
23
|
+
The token can be used to place charges from server modules.
|
|
24
|
+
The user_details are a dictionary of user-supplied data (eg 'email').
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
amount: A number, in least units of currency (eg cents or pennies).
|
|
28
|
+
currency: A three-letter currency code (eg 'USD').
|
|
29
|
+
title: Configures the checkout dialog title.
|
|
30
|
+
description: Configures the checkout dialog description.
|
|
31
|
+
icon_url: Path to an image to be used on the checkout form.
|
|
32
|
+
zipcode: Setting to True requires the user to enter their postal code.
|
|
33
|
+
billing_address: Setting to True requires the user to enter a billing address.
|
|
34
|
+
raw: Setting to True returns a token for your own API key.
|
|
35
|
+
|
|
36
|
+
[Anvil Docs](https://anvil.works/docs/integrations/stripe)"""
|
|
37
|
+
...
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def charge(
|
|
41
|
+
*,
|
|
42
|
+
amount: int,
|
|
43
|
+
currency: str,
|
|
44
|
+
title: str | None = None,
|
|
45
|
+
description: str | None = None,
|
|
46
|
+
icon_url: str | None = None,
|
|
47
|
+
billing_address: bool = False,
|
|
48
|
+
shipping_address: bool = False,
|
|
49
|
+
zipcode: bool = False,
|
|
50
|
+
) -> dict[str, Any]:
|
|
51
|
+
"""Charge the user for a one-off payment by showing a Stripe checkout form.
|
|
52
|
+
|
|
53
|
+
Returns a dictionary of information about the transaction on success.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
amount: A number, in least units of currency (eg cents or pennies).
|
|
57
|
+
currency: A three-letter currency code (eg 'USD').
|
|
58
|
+
title: Configures the checkout dialog title.
|
|
59
|
+
description: Configures the checkout dialog description.
|
|
60
|
+
icon_url: Path to an image to be used on the checkout form
|
|
61
|
+
(eg anvil.server.get_app_origin() + '/_/theme/icon.png').
|
|
62
|
+
billing_address: Setting to True requires the user to enter a billing address.
|
|
63
|
+
shipping_address: Setting to True requires the user to enter a shipping and billing address.
|
|
64
|
+
zipcode: Setting to True requires the user to enter their zipcode/postal code.
|
|
65
|
+
|
|
66
|
+
[Anvil Docs](https://anvil.works/docs/integrations/stripe)"""
|
|
67
|
+
...
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
|
6
|
+
# Generated files: client/anvil/__init__.pyi, server/anvil/__init__.pyi
|
|
7
|
+
|
|
8
|
+
from typing import Any, Callable, TypeVar, overload, Iterator, Mapping, Literal
|
|
9
|
+
|
|
10
|
+
_T = TypeVar("_T")
|
|
11
|
+
_F = TypeVar("_F", bound=Callable[..., Any])
|
|
12
|
+
|
|
13
|
+
# ============================================================================
|
|
14
|
+
# Media Classes
|
|
15
|
+
# ============================================================================
|
|
16
|
+
|
|
17
|
+
class Media:
|
|
18
|
+
"""A Media object represents binary data, such as a file.
|
|
19
|
+
|
|
20
|
+
[Anvil Docs](https://anvil.works/docs/media)"""
|
|
21
|
+
|
|
22
|
+
content_type: str
|
|
23
|
+
"""The MIME type of this Media."""
|
|
24
|
+
|
|
25
|
+
name: str | None
|
|
26
|
+
"""The file name associated with this Media, or None if it has no name."""
|
|
27
|
+
|
|
28
|
+
url: str | None
|
|
29
|
+
"""The URL where you can download this Media, or None if it is not downloadable."""
|
|
30
|
+
|
|
31
|
+
length: int
|
|
32
|
+
"""The length of this Media, in bytes."""
|
|
33
|
+
|
|
34
|
+
def get_bytes(self) -> bytes:
|
|
35
|
+
"""Get a binary string of the data represented by this Media object.
|
|
36
|
+
|
|
37
|
+
[Anvil Docs](https://anvil.works/docs/media)"""
|
|
38
|
+
...
|
|
39
|
+
|
|
40
|
+
def get_url(self) -> str | None:
|
|
41
|
+
"""Get a Media object's URL, or None if there isn't one associated with it.
|
|
42
|
+
|
|
43
|
+
[Anvil Docs](https://anvil.works/docs/media)"""
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class BlobMedia(Media):
|
|
48
|
+
"""Create a Media object with the specified content_type and content.
|
|
49
|
+
|
|
50
|
+
Optionally specify a filename as well.
|
|
51
|
+
|
|
52
|
+
[Anvil Docs](https://anvil.works/docs/media)"""
|
|
53
|
+
|
|
54
|
+
def __init__(self, content_type: str, content: bytes, *, name: str | None = None) -> None: ...
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class URLMedia(Media):
|
|
58
|
+
"""Create a Media object representing the data at a specific URL.
|
|
59
|
+
|
|
60
|
+
Caution: Getting data from URLs directly in your code will often fail
|
|
61
|
+
for security reasons, or fail to handle binary data.
|
|
62
|
+
|
|
63
|
+
[Anvil Docs](https://anvil.works/docs/media)"""
|
|
64
|
+
|
|
65
|
+
def __init__(self, url: str, /) -> None: ...
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# ============================================================================
|
|
69
|
+
# App Information
|
|
70
|
+
# ============================================================================
|
|
71
|
+
|
|
72
|
+
class AppEnvironment:
|
|
73
|
+
"""Information about the current app environment."""
|
|
74
|
+
|
|
75
|
+
name: str
|
|
76
|
+
"""The name of the current environment."""
|
|
77
|
+
|
|
78
|
+
tags: list[str]
|
|
79
|
+
"""Tags associated with the current environment."""
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class AppInfo:
|
|
83
|
+
"""Information about the current app.
|
|
84
|
+
|
|
85
|
+
[Anvil Docs](https://anvil.works/docs/deployment/environment-variables)"""
|
|
86
|
+
|
|
87
|
+
id: str
|
|
88
|
+
"""A unique identifier for the current app."""
|
|
89
|
+
|
|
90
|
+
branch: str
|
|
91
|
+
"""The Git branch from which the current app is being run.
|
|
92
|
+
|
|
93
|
+
This is 'master' for development apps or apps without a published version,
|
|
94
|
+
and 'published' if this app is being run from its published version."""
|
|
95
|
+
|
|
96
|
+
package_name: str
|
|
97
|
+
"""The package name of this app."""
|
|
98
|
+
|
|
99
|
+
environment: AppEnvironment
|
|
100
|
+
"""The environment in which the current app is being run."""
|
|
101
|
+
|
|
102
|
+
theme_colors: Mapping[str, str]
|
|
103
|
+
"""Theme colors for this app as a readonly dict."""
|
|
104
|
+
|
|
105
|
+
def get_asset(self, path: str | None = None) -> Media:
|
|
106
|
+
"""Get an asset file from the app's theme assets."""
|
|
107
|
+
...
|
|
108
|
+
|
|
109
|
+
def get_client_config(self, package_name: str | None = None) -> dict[str, Any]:
|
|
110
|
+
"""Get the client config for the specified package.
|
|
111
|
+
|
|
112
|
+
If no package name is specified, the client config for the current app is returned."""
|
|
113
|
+
...
|
|
114
|
+
|
|
115
|
+
def get_server_config(self, package_name: str | None = None) -> dict[str, Any]:
|
|
116
|
+
"""Get the server config for the specified package.
|
|
117
|
+
|
|
118
|
+
If no package name is specified, the server config for the current app is returned."""
|
|
119
|
+
...
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
app: AppInfo
|
|
123
|
+
"""Information about the current app, as an instance of AppInfo."""
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# ============================================================================
|
|
127
|
+
# Utility Functions
|
|
128
|
+
# ============================================================================
|
|
129
|
+
|
|
130
|
+
def is_server_side() -> bool:
|
|
131
|
+
"""Check whether Anvil is running server side or not."""
|
|
132
|
+
...
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
# ============================================================================
|
|
136
|
+
# Server-Only: Secrets Access
|
|
137
|
+
# ============================================================================
|
|
138
|
+
|
|
139
|
+
class _Secrets:
|
|
140
|
+
"""Access to app secrets.
|
|
141
|
+
|
|
142
|
+
[Anvil Docs](https://anvil.works/docs/deployment/secrets)"""
|
|
143
|
+
|
|
144
|
+
def get_secret(self, name: str) -> str | None: ...
|
|
145
|
+
def __getattr__(self, name: str) -> str | None: ...
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
secrets: _Secrets
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
"""The `anvil.email` module contains functions for sending and receiving email in your Anvil app.
|
|
6
|
+
|
|
7
|
+
[Anvil Docs](https://anvil.works/docs/email)"""
|
|
8
|
+
|
|
9
|
+
from typing import Callable, TypeVar, overload
|
|
10
|
+
|
|
11
|
+
from anvil import Media
|
|
12
|
+
|
|
13
|
+
# TypeVar for email handler functions
|
|
14
|
+
_MessageHandler = TypeVar("_MessageHandler", bound=Callable[["Message"], None])
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SendFailure(Exception):
|
|
18
|
+
"""Raised when sending an email fails."""
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DeliveryFailure(Exception):
|
|
23
|
+
"""While handling an error, you can raise a DeliveryFailure exception to reject email delivery.
|
|
24
|
+
|
|
25
|
+
Optionally, you may specify a message and SMTP error code with the rejection.
|
|
26
|
+
|
|
27
|
+
[Anvil Docs](https://anvil.works/docs/email/sending_and_receiving#rejecting-email)"""
|
|
28
|
+
|
|
29
|
+
def __init__(self, message: str | None = None, smtp_code: int = 554) -> None: ...
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Address:
|
|
33
|
+
"""Represents an email address."""
|
|
34
|
+
address: str
|
|
35
|
+
"""The email address this object represents."""
|
|
36
|
+
name: str
|
|
37
|
+
"""The name associated with the address this object represents."""
|
|
38
|
+
raw_value: str
|
|
39
|
+
"""The full string value of this address."""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class SendReport:
|
|
43
|
+
"""Report returned after sending an email."""
|
|
44
|
+
message_id: str
|
|
45
|
+
"""The Message-ID header given to this outgoing message."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Message:
|
|
49
|
+
"""Represents an incoming email message.
|
|
50
|
+
|
|
51
|
+
[Anvil Docs](https://anvil.works/docs/email/incoming)"""
|
|
52
|
+
|
|
53
|
+
class Envelope:
|
|
54
|
+
"""The sender and recipient of an email, according to the SMTP envelope."""
|
|
55
|
+
from_address: str
|
|
56
|
+
"""The email address from which this message was sent, according to the SMTP envelope."""
|
|
57
|
+
recipient: str
|
|
58
|
+
"""The email address that received this message.
|
|
59
|
+
|
|
60
|
+
Note that this email address may not appear in any of the headers (eg if the email has been BCCed or blind forwarded)."""
|
|
61
|
+
|
|
62
|
+
class DKIM:
|
|
63
|
+
"""Object describing whether a message was signed by the sending domain."""
|
|
64
|
+
valid_from_sender: bool
|
|
65
|
+
"""Was this message signed by the domain in its envelope "from" address?"""
|
|
66
|
+
domains: list[str]
|
|
67
|
+
"""A list of the DKIM domains that signed this message."""
|
|
68
|
+
|
|
69
|
+
class Addressees:
|
|
70
|
+
"""The addresses an email was sent from and to, according to the headers."""
|
|
71
|
+
to_addresses: list[Address]
|
|
72
|
+
"""The addresses this message was sent to."""
|
|
73
|
+
from_address: Address | None
|
|
74
|
+
"""The address this message was sent from."""
|
|
75
|
+
cc_addresses: list[Address]
|
|
76
|
+
"""The addresses this message was copied to."""
|
|
77
|
+
|
|
78
|
+
envelope: Envelope
|
|
79
|
+
"""The sender and recipient of this email, according to the SMTP envelope."""
|
|
80
|
+
dkim: DKIM
|
|
81
|
+
"""Object describing whether this message was signed by the sending domain."""
|
|
82
|
+
addressees: Addressees
|
|
83
|
+
"""The addresses this email was sent from and to, according to the headers."""
|
|
84
|
+
headers: list[tuple[str, str]]
|
|
85
|
+
"""All the headers in this email, as a list of (name, value) pairs."""
|
|
86
|
+
text: str | None
|
|
87
|
+
"""The plain-text content of this email, or None if there is no plain-text part."""
|
|
88
|
+
subject: str | None
|
|
89
|
+
"""The subject of this email, or None if there is no subject."""
|
|
90
|
+
html: str | None
|
|
91
|
+
"""The HTML content of this email, or None if there is no HTML part."""
|
|
92
|
+
attachments: list[Media]
|
|
93
|
+
"""A list of this email's attachments."""
|
|
94
|
+
inline_attachments: dict[str, Media]
|
|
95
|
+
"""A dictionary of this email's inline attachments. Keys are ContentID headers, values are the attachments as Media Objects."""
|
|
96
|
+
|
|
97
|
+
def get_header(self, header_name: str, default: str | None = None) -> str | None:
|
|
98
|
+
"""Return the value of the specified header, or default value if it is not present.
|
|
99
|
+
|
|
100
|
+
Case-insensitive. If the header is specified multiple times, returns the first value."""
|
|
101
|
+
...
|
|
102
|
+
|
|
103
|
+
def list_header(self, header_name: str) -> list[str]:
|
|
104
|
+
"""Return a list containing every value of the specified header. Case-insensitive."""
|
|
105
|
+
...
|
|
106
|
+
|
|
107
|
+
def reply(
|
|
108
|
+
self,
|
|
109
|
+
*,
|
|
110
|
+
to: str | list[str] | None = None,
|
|
111
|
+
cc: str | list[str] | None = None,
|
|
112
|
+
bcc: str | list[str] | None = None,
|
|
113
|
+
from_address: str | None = None,
|
|
114
|
+
from_name: str | None = None,
|
|
115
|
+
subject: str | None = None,
|
|
116
|
+
text: str | None = None,
|
|
117
|
+
html: str | None = None,
|
|
118
|
+
attachments: list[Media] | None = None,
|
|
119
|
+
) -> SendReport:
|
|
120
|
+
"""Reply to this email."""
|
|
121
|
+
...
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def send(
|
|
125
|
+
*,
|
|
126
|
+
to: str | list[str] | None = None,
|
|
127
|
+
cc: str | list[str] | None = None,
|
|
128
|
+
bcc: str | list[str] | None = None,
|
|
129
|
+
from_address: str = "no-reply",
|
|
130
|
+
from_name: str | None = None,
|
|
131
|
+
subject: str | None = None,
|
|
132
|
+
text: str | None = None,
|
|
133
|
+
html: str | None = None,
|
|
134
|
+
attachments: list[Media] | None = None,
|
|
135
|
+
inline_attachments: dict[str, Media] | None = None,
|
|
136
|
+
) -> SendReport:
|
|
137
|
+
"""Send an email.
|
|
138
|
+
|
|
139
|
+
Args:
|
|
140
|
+
to: The email recipient[s] in the 'To' field. Can be a string or list of strings.
|
|
141
|
+
Each string can be a bare address (eg 'joe@example.com') or include a display name (eg 'Joe Bloggs <joe@example.com>').
|
|
142
|
+
cc: The email recipient[s] in the 'Cc' field. Can be a string or list of strings.
|
|
143
|
+
bcc: The email recipient[s] in the 'Bcc' field. Can be a string or list of strings.
|
|
144
|
+
from_address: The From: address from this email. If no domain is specified, or the specified domain is not a legal sending domain for this app, the address will be replaced with a valid domain.
|
|
145
|
+
from_name: The name associated with the From: address for this email. (Only valid if the from_address is a bare email address.)
|
|
146
|
+
subject: The subject line for this email.
|
|
147
|
+
text: The plain-text (no HTML) content for this email. You must specify at least one of 'text' and 'html'.
|
|
148
|
+
html: The HTML content for this email. You must specify at least one of 'text' and 'html'.
|
|
149
|
+
attachments: A list of Media objects to send as attachments with this email.
|
|
150
|
+
inline_attachments: Inline attachments that can be used in this email's HTML, for example in <img> tags. Must be a dictionary whose keys are IDs and values are Media objects. IDs can then be used in a message's HTML with 'cid:xxx' URIs.
|
|
151
|
+
|
|
152
|
+
[Anvil Docs](https://anvil.works/docs/email)"""
|
|
153
|
+
...
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
@overload
|
|
157
|
+
def handle_message(fn: _MessageHandler) -> _MessageHandler:
|
|
158
|
+
"""Decorator to handle incoming emails.
|
|
159
|
+
|
|
160
|
+
[Anvil Docs](https://anvil.works/docs/email/incoming)"""
|
|
161
|
+
...
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@overload
|
|
165
|
+
def handle_message(*, require_dkim: bool = False) -> Callable[[_MessageHandler], _MessageHandler]:
|
|
166
|
+
"""Decorator to handle incoming emails.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
require_dkim: If True, reject emails without a valid DKIM signature from the sender.
|
|
170
|
+
|
|
171
|
+
[Anvil Docs](https://anvil.works/docs/email/incoming)"""
|
|
172
|
+
...
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def handle_message(
|
|
176
|
+
fn: _MessageHandler | None = None, require_dkim: bool = False
|
|
177
|
+
) -> _MessageHandler | Callable[[_MessageHandler], _MessageHandler]:
|
|
178
|
+
"""Decorator to handle incoming emails.
|
|
179
|
+
|
|
180
|
+
Can be used with or without arguments:
|
|
181
|
+
- `@anvil.email.handle_message` - handle all incoming emails
|
|
182
|
+
- `@anvil.email.handle_message(require_dkim=True)` - only handle emails with valid DKIM
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
require_dkim: If True, reject emails without a valid DKIM signature from the sender.
|
|
186
|
+
|
|
187
|
+
[Anvil Docs](https://anvil.works/docs/email/incoming)"""
|
|
188
|
+
...
|
|
@@ -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.facebook module
|
|
6
|
+
# Generated files: client/anvil/facebook/__init__.pyi, server/anvil/facebook/__init__.pyi
|
|
7
|
+
|
|
8
|
+
from anvil.facebook import auth as auth
|
|
@@ -0,0 +1,27 @@
|
|
|
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.facebook.auth module
|
|
6
|
+
# Generated files: client/anvil/facebook/auth.pyi, server/anvil/facebook/auth.pyi
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_user_email() -> str | None:
|
|
10
|
+
"""Get the email address of the currently-logged-in Facebook user.
|
|
11
|
+
|
|
12
|
+
To log in with Facebook, call facebook.auth.login() from form code."""
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
def get_user_id() -> str | None:
|
|
16
|
+
"""Get the Facebook user ID of the currently-logged-in Facebook user.
|
|
17
|
+
|
|
18
|
+
To log in with Facebook, call facebook.auth.login() from form code."""
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
def get_user_access_token() -> str | None:
|
|
22
|
+
"""Get the Facebook access token of the currently-logged-in Facebook user.
|
|
23
|
+
|
|
24
|
+
To log in with Facebook, call facebook.auth.login() from form code.
|
|
25
|
+
|
|
26
|
+
[Anvil Docs](https://anvil.works/docs/integrations/facebook)"""
|
|
27
|
+
...
|
|
@@ -0,0 +1,53 @@
|
|
|
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.files module
|
|
6
|
+
# Generated files: server/anvil/files.pyi
|
|
7
|
+
|
|
8
|
+
from typing import IO, Any
|
|
9
|
+
|
|
10
|
+
class OpenContextManager:
|
|
11
|
+
"""Context manager for opening data files."""
|
|
12
|
+
|
|
13
|
+
def __enter__(self) -> IO[Any]:
|
|
14
|
+
"""Open the file."""
|
|
15
|
+
...
|
|
16
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
17
|
+
"""Close the file, uploading its contents if it was opened for writing or appending."""
|
|
18
|
+
...
|
|
19
|
+
|
|
20
|
+
class EditingContextManager:
|
|
21
|
+
"""Context manager for editing data files."""
|
|
22
|
+
|
|
23
|
+
def __enter__(self) -> str:
|
|
24
|
+
"""Begin editing the file. Returns the path to a temporary file."""
|
|
25
|
+
...
|
|
26
|
+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
27
|
+
"""End editing the file, uploading its new contents."""
|
|
28
|
+
...
|
|
29
|
+
|
|
30
|
+
class Files:
|
|
31
|
+
"""Access to Data Files from the Data Files Service.
|
|
32
|
+
|
|
33
|
+
To access a file stored in the Data Files Service use square brackets
|
|
34
|
+
containing the path of the desired file - `data_files['<file_path>']`."""
|
|
35
|
+
|
|
36
|
+
def __getitem__(self, path: str) -> str:
|
|
37
|
+
"""Return the path of a file."""
|
|
38
|
+
...
|
|
39
|
+
def editing(self, path: str) -> EditingContextManager:
|
|
40
|
+
"""Edit a file.
|
|
41
|
+
|
|
42
|
+
To ensure the proper acquisition and release of the file, use the `editing`
|
|
43
|
+
function in a `with` statement e.g. `with data_files.editing('test.txt') as file:`"""
|
|
44
|
+
...
|
|
45
|
+
def open(self, path: str, mode: str = "r") -> OpenContextManager:
|
|
46
|
+
"""The open() function opens the file (if possible) and returns the corresponding file object."""
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
data_files: Files
|
|
50
|
+
"""Access Data Files from the Data Files Service.
|
|
51
|
+
|
|
52
|
+
To access a file stored in the Data Files Service use square brackets
|
|
53
|
+
containing the path of the desired file - `data_files['<file_path>']`."""
|
|
@@ -0,0 +1,11 @@
|
|
|
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.google module
|
|
6
|
+
# Generated files: client/anvil/google/__init__.pyi, server/anvil/google/__init__.pyi
|
|
7
|
+
|
|
8
|
+
from anvil.google import auth as auth
|
|
9
|
+
from anvil.google import drive as drive
|
|
10
|
+
from anvil.google import mail as mail
|
|
11
|
+
from anvil.google import sheets as sheets
|
|
@@ -0,0 +1,31 @@
|
|
|
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.google.auth module
|
|
6
|
+
# Generated files: client/anvil/google/auth.pyi, server/anvil/google/auth.pyi
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_user_email() -> str | None:
|
|
10
|
+
"""Get the email address of the currently-logged-in Google user.
|
|
11
|
+
|
|
12
|
+
To log in with Google, call anvil.google.auth.login() from form code."""
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
def get_user_access_token() -> str | None:
|
|
16
|
+
"""Get the secret access token of the currently-logged-in Google user, for use with the Google REST API.
|
|
17
|
+
|
|
18
|
+
Requires this app to have its own Google client ID and secret."""
|
|
19
|
+
...
|
|
20
|
+
|
|
21
|
+
def get_user_refresh_token() -> str | None:
|
|
22
|
+
"""Get the secret refresh token of the currently-logged-in Google user, for use with the Google REST API.
|
|
23
|
+
|
|
24
|
+
Requires this app to have its own Google client ID and secret."""
|
|
25
|
+
...
|
|
26
|
+
|
|
27
|
+
def refresh_access_token(refresh_token: str, /) -> str:
|
|
28
|
+
"""Get a new access token from a refresh token you have saved, for use with the Google REST API.
|
|
29
|
+
|
|
30
|
+
Requires this app to have its own Google client ID and secret."""
|
|
31
|
+
...
|