Skip to content

Commit

Permalink
Merge pull request #517 from supertokens/auto-transpiling
Browse files Browse the repository at this point in the history
Auto transpiling to catchup to node sdk (as of 19.0 branch of node sdk)
  • Loading branch information
rishabhpoddar authored Oct 25, 2024
2 parents 78e1072 + 04ffcf6 commit 9a67aa1
Show file tree
Hide file tree
Showing 251 changed files with 21,844 additions and 3,760 deletions.
1 change: 0 additions & 1 deletion .circleci/setupAndTestBackendSDKWithFreeCore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ ST_CONNECTION_URI=http://localhost:8081

# start test-server
pushd tests/test-server
sh setup-for-test.sh
SUPERTOKENS_ENV=testing API_PORT=$API_PORT ST_CONNECTION_URI=$ST_CONNECTION_URI python3 app.py &
popd

Expand Down
10 changes: 10 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
You are an expert Python and Typescript developer. Your job is to convert node code (in typescript) into Python code. The python code then goes into this SDK. The python code style should keep in mind:
- Avoid using TypeDict
- Avoid using generic Dict as much as possible, except when defining the types for `user_context`.
- If a function has multiple `status` strings as outputs, then define one unique class per unique `status` string. The class name should be such that it indicates the status it is associated with.
- Variable and function names should be in snake_case. Class names in PascalCase.
- Whenever importing `Literal`, import it from `typing_extensions`, and not `types`.
- Do not use `|` for OR type, instead use `Union`
- When defining API interface functions, make sure the output classes inherit from `APIResponse` class, and that they have a `to_json` function defined whose output matches the structure of the provided Typescript code output objects.

The semantic of the python code should be the same as what's of the provided Typescript code.
16 changes: 12 additions & 4 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[MASTER]

# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
Expand All @@ -20,11 +19,11 @@ fail-on=
fail-under=10.0

# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS
ignore=CVS,

# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths and can be in Posix or Windows format.
ignore-paths=
ignore-paths=tests/test-server

# Files or directories matching the regex patterns are skipped. The regex
# matches against base names, not paths.
Expand Down Expand Up @@ -116,7 +115,16 @@ disable=raw-checker-failed,
global-statement,
too-many-lines,
duplicate-code,
too-many-return-statements
too-many-return-statements,
logging-not-lazy,
logging-fstring-interpolation,
consider-using-f-string,
consider-using-in,
no-else-return,
no-self-use,
no-else-raise,
too-many-nested-blocks,


# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
90 changes: 90 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask, supertokens-website tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tests/frontendIntegration/flask-server/app.py",
"args": [
"--port",
"8080"
],
"cwd": "${workspaceFolder}/tests/frontendIntegration/flask-server",
"env": {
"FLASK_DEBUG": "1"
},
"jinja": true
},
{
"name": "Python: FastAPI, supertokens-website tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tests/frontendIntegration/fastapi-server/app.py",
"args": [
"--port",
"8080"
],
"cwd": "${workspaceFolder}/tests/frontendIntegration/fastapi-server",
"env": {
"FLASK_DEBUG": "1"
},
"jinja": true
},
{
"name": "Python: Flask, supertokens-auth-react tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tests/auth-react/flask-server/app.py",
"args": [
"--port",
"8083"
],
"cwd": "${workspaceFolder}/tests/auth-react/flask-server",
"env": {
"FLASK_DEBUG": "1"
},
"jinja": true
},
{
"name": "Python: FastAPI, supertokens-auth-react tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tests/auth-react/fastapi-server/app.py",
"args": [
"--port",
"8083"
],
"cwd": "${workspaceFolder}/tests/auth-react/fastapi-server",
"jinja": true
},
{
"name": "Python: Django, supertokens-auth-react tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tests/auth-react/django3x/manage.py",
"args": [
"runserver",
"0.0.0.0:8083"
],
"env": {
"PYTHONPATH": "${workspaceFolder}"
},
"cwd": "${workspaceFolder}/tests/auth-react/django3x",
"jinja": true
},
{
"name": "Python: backend-sdk-testing repo",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tests/test-server/app.py",
"cwd": "${workspaceFolder}/tests/test-server",
"env": {
"SUPERTOKENS_ENV": "testing",
"API_PORT": "3030",
"ST_CONNECTION_URI": "http://localhost:8081"
},
"console": "integratedTerminal"
},
]
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]


## [0.25.0] - 2024-09-18

### Breaking changes
- `supertokens_python.recipe.emailverification.types.User` has been renamed to `supertokens_python.recipe.emailverification.types.EmailVerificationUser`
- The user object has been changed to be a global one, containing information about all emails, phone numbers, third party info and login methods associated with that user.
- Type of `get_email_for_user_id` in `emailverification.init` has changed
- Session recipe's error handlers take an extra param of recipe_user_id as well
- Session recipe, removes `validate_claims_in_jwt_payload` that is exposed to the user.
- TODO..

## [0.24.4] - 2024-10-16

- Updates `phonenumbers` and `twilio` to latest versions

>>>>>>> 0.24
## [0.24.3] - 2024-09-24

- Adds support for form field related improvements by making fields accept any type of values
- Adds support for optional fields to properly optional
>>>>>>> 0.24
### Migration

Expand Down
4 changes: 2 additions & 2 deletions coreDriverInterfaceSupported.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"_comment": "contains a list of core-driver interfaces branch names that this core supports",
"versions": [
"3.1"
"5.1"
]
}
}
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ uvicorn==0.18.2
Werkzeug==2.0.3
wrapt==1.13.3
zipp==3.7.0
pyotp==2.9.0
aiofiles==23.2.1
6 changes: 5 additions & 1 deletion frontendDriverInterfaceSupported.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"_comment": "contains a list of frontend-driver interfaces branch names that this core supports",
"versions": [
"1.17",
"2.0"
"1.18",
"1.19",
"2.0",
"3.0",
"3.1"
]
}
13 changes: 10 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
"Fastapi",
"uvicorn==0.18.2",
"python-dotenv==0.19.2",
"pyotp<3",
"aiofiles==23.2.1",
]
),
"flask": (
[
"flask_cors",
"Flask",
"python-dotenv==0.19.2",
"pyotp<3",
]
),
"django": (
Expand All @@ -35,6 +38,7 @@
"django-stubs==1.9.0",
"uvicorn==0.18.2",
"python-dotenv==0.19.2",
"pyotp<3",
]
),
"django2x": (
Expand All @@ -44,6 +48,7 @@
"django-stubs==1.9.0",
"gunicorn==20.1.0",
"python-dotenv==0.19.2",
"pyotp<3",
]
),
"drf": (
Expand All @@ -57,6 +62,7 @@
"uvicorn==0.18.2",
"python-dotenv==0.19.2",
"tzdata==2021.5",
"pyotp<3",
]
),
}
Expand All @@ -83,7 +89,7 @@

setup(
name="supertokens_python",
version="0.24.4",
version="0.25.0",
author="SuperTokens",
license="Apache 2.0",
author_email="[email protected]",
Expand Down Expand Up @@ -121,10 +127,11 @@
"asgiref>=3.4.1,<4",
"typing_extensions>=4.1.1,<5.0.0",
"Deprecated==1.2.13",
"phonenumbers==8.13.47",
"twilio==9.3.3",
"phonenumbers<9",
"twilio<10",
"aiosmtplib>=1.1.6,<4.0.0",
"pkce==1.0.3",
"pyotp<3",
],
python_requires=">=3.7",
include_package_data=True,
Expand Down
5 changes: 5 additions & 0 deletions supertokens_python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing_extensions import Literal

from supertokens_python.framework.request import BaseRequest
from supertokens_python.types import RecipeUserId

from . import supertokens
from .recipe_module import RecipeModule
Expand Down Expand Up @@ -49,3 +50,7 @@ def get_request_from_user_context(
user_context: Optional[Dict[str, Any]],
) -> Optional[BaseRequest]:
return Supertokens.get_instance().get_request_from_user_context(user_context)


def convert_to_recipe_user_id(user_id: str) -> RecipeUserId:
return RecipeUserId(user_id)
Loading

0 comments on commit 9a67aa1

Please sign in to comment.