hypern 0.1.0__tar.gz

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.
Files changed (103) hide show
  1. hypern-0.1.0/.github/dependabot.yml +13 -0
  2. hypern-0.1.0/.github/workflows/codeql.yml +93 -0
  3. hypern-0.1.0/.github/workflows/codspeed.yml +51 -0
  4. hypern-0.1.0/.github/workflows/preview-deployments.yml +94 -0
  5. hypern-0.1.0/.github/workflows/security-scan.yml +105 -0
  6. hypern-0.1.0/.gitignore +74 -0
  7. hypern-0.1.0/.pre-commit-config.yaml +11 -0
  8. hypern-0.1.0/CODE_OF_CONDUCT.md +6 -0
  9. hypern-0.1.0/Cargo.lock +1073 -0
  10. hypern-0.1.0/Cargo.toml +34 -0
  11. hypern-0.1.0/LICENSE +24 -0
  12. hypern-0.1.0/PKG-INFO +121 -0
  13. hypern-0.1.0/README.md +95 -0
  14. hypern-0.1.0/SECURITY.md +3 -0
  15. hypern-0.1.0/benchmark.sh +72 -0
  16. hypern-0.1.0/hypern/__init__.py +4 -0
  17. hypern-0.1.0/hypern/application.py +234 -0
  18. hypern-0.1.0/hypern/auth/__init__.py +0 -0
  19. hypern-0.1.0/hypern/auth/authorization.py +2 -0
  20. hypern-0.1.0/hypern/background.py +4 -0
  21. hypern-0.1.0/hypern/caching/__init__.py +0 -0
  22. hypern-0.1.0/hypern/caching/base/__init__.py +8 -0
  23. hypern-0.1.0/hypern/caching/base/backend.py +3 -0
  24. hypern-0.1.0/hypern/caching/base/key_maker.py +8 -0
  25. hypern-0.1.0/hypern/caching/cache_manager.py +56 -0
  26. hypern-0.1.0/hypern/caching/cache_tag.py +10 -0
  27. hypern-0.1.0/hypern/caching/custom_key_maker.py +11 -0
  28. hypern-0.1.0/hypern/caching/redis_backend.py +3 -0
  29. hypern-0.1.0/hypern/cli/__init__.py +0 -0
  30. hypern-0.1.0/hypern/cli/commands.py +0 -0
  31. hypern-0.1.0/hypern/config.py +149 -0
  32. hypern-0.1.0/hypern/datastructures.py +27 -0
  33. hypern-0.1.0/hypern/db/__init__.py +0 -0
  34. hypern-0.1.0/hypern/db/nosql/__init__.py +25 -0
  35. hypern-0.1.0/hypern/db/nosql/addons/__init__.py +4 -0
  36. hypern-0.1.0/hypern/db/nosql/addons/color.py +16 -0
  37. hypern-0.1.0/hypern/db/nosql/addons/daterange.py +30 -0
  38. hypern-0.1.0/hypern/db/nosql/addons/encrypted.py +53 -0
  39. hypern-0.1.0/hypern/db/nosql/addons/password.py +134 -0
  40. hypern-0.1.0/hypern/db/nosql/addons/unicode.py +10 -0
  41. hypern-0.1.0/hypern/db/sql/__init__.py +176 -0
  42. hypern-0.1.0/hypern/db/sql/addons/__init__.py +14 -0
  43. hypern-0.1.0/hypern/db/sql/addons/color.py +15 -0
  44. hypern-0.1.0/hypern/db/sql/addons/daterange.py +22 -0
  45. hypern-0.1.0/hypern/db/sql/addons/datetime.py +22 -0
  46. hypern-0.1.0/hypern/db/sql/addons/encrypted.py +58 -0
  47. hypern-0.1.0/hypern/db/sql/addons/password.py +170 -0
  48. hypern-0.1.0/hypern/db/sql/addons/ts_vector.py +46 -0
  49. hypern-0.1.0/hypern/db/sql/addons/unicode.py +15 -0
  50. hypern-0.1.0/hypern/db/sql/repository.py +289 -0
  51. hypern-0.1.0/hypern/enum.py +13 -0
  52. hypern-0.1.0/hypern/exceptions.py +93 -0
  53. hypern-0.1.0/hypern/hypern.pyi +172 -0
  54. hypern-0.1.0/hypern/i18n/__init__.py +0 -0
  55. hypern-0.1.0/hypern/logging/__init__.py +3 -0
  56. hypern-0.1.0/hypern/logging/logger.py +91 -0
  57. hypern-0.1.0/hypern/middleware/__init__.py +5 -0
  58. hypern-0.1.0/hypern/middleware/base.py +16 -0
  59. hypern-0.1.0/hypern/middleware/cors.py +38 -0
  60. hypern-0.1.0/hypern/middleware/i18n.py +1 -0
  61. hypern-0.1.0/hypern/middleware/limit.py +174 -0
  62. hypern-0.1.0/hypern/openapi/__init__.py +5 -0
  63. hypern-0.1.0/hypern/openapi/schemas.py +64 -0
  64. hypern-0.1.0/hypern/openapi/swagger.py +3 -0
  65. hypern-0.1.0/hypern/py.typed +0 -0
  66. hypern-0.1.0/hypern/response/__init__.py +3 -0
  67. hypern-0.1.0/hypern/response/response.py +134 -0
  68. hypern-0.1.0/hypern/routing/__init__.py +4 -0
  69. hypern-0.1.0/hypern/routing/dispatcher.py +65 -0
  70. hypern-0.1.0/hypern/routing/endpoint.py +27 -0
  71. hypern-0.1.0/hypern/routing/parser.py +101 -0
  72. hypern-0.1.0/hypern/routing/router.py +279 -0
  73. hypern-0.1.0/hypern/scheduler.py +5 -0
  74. hypern-0.1.0/hypern/security.py +44 -0
  75. hypern-0.1.0/hypern/worker.py +30 -0
  76. hypern-0.1.0/poetry.lock +2301 -0
  77. hypern-0.1.0/pyproject.toml +81 -0
  78. hypern-0.1.0/scripts/format.sh +5 -0
  79. hypern-0.1.0/sonar-project.properties +6 -0
  80. hypern-0.1.0/src/background/background_task.rs +161 -0
  81. hypern-0.1.0/src/background/background_tasks.rs +152 -0
  82. hypern-0.1.0/src/background/mod.rs +2 -0
  83. hypern-0.1.0/src/cache/backend.rs +24 -0
  84. hypern-0.1.0/src/cache/mod.rs +2 -0
  85. hypern-0.1.0/src/cache/redis_backend.rs +37 -0
  86. hypern-0.1.0/src/lib.rs +26 -0
  87. hypern-0.1.0/src/openapi/mod.rs +3 -0
  88. hypern-0.1.0/src/openapi/schemas.rs +53 -0
  89. hypern-0.1.0/src/openapi/swagger.rs +86 -0
  90. hypern-0.1.0/src/scheduler/job.rs +148 -0
  91. hypern-0.1.0/src/scheduler/mod.rs +3 -0
  92. hypern-0.1.0/src/scheduler/retry.rs +46 -0
  93. hypern-0.1.0/src/scheduler/scheduler.rs +209 -0
  94. hypern-0.1.0/src/utils.rs +32 -0
  95. hypern-0.1.0/tests/__init__.py +0 -0
  96. hypern-0.1.0/tests/conftest.py +69 -0
  97. hypern-0.1.0/tests/server.py +165 -0
  98. hypern-0.1.0/tests/test_functional_handler.py +22 -0
  99. hypern-0.1.0/tests/test_request_file.py +16 -0
  100. hypern-0.1.0/tests/test_response_type.py +38 -0
  101. hypern-0.1.0/tests/test_sync_async.py +9 -0
  102. hypern-0.1.0/tests/test_validate_field.py +16 -0
  103. hypern-0.1.0/tests/utils.py +124 -0
@@ -0,0 +1,13 @@
1
+ # Keep GitHub Actions up to date with GitHub's Dependabot...
2
+ # https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
3
+ # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: github-actions
7
+ directory: /
8
+ groups:
9
+ github-actions:
10
+ patterns:
11
+ - "*" # Group all Actions updates into a single larger pull request
12
+ schedule:
13
+ interval: weekly
@@ -0,0 +1,93 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "stag", "main" ]
17
+ pull_request:
18
+ branches: [ "stag", "main" ]
19
+ schedule:
20
+ - cron: '18 9 * * 6'
21
+
22
+ jobs:
23
+ analyze:
24
+ name: Analyze (${{ matrix.language }})
25
+ # Runner size impacts CodeQL analysis time. To learn more, please see:
26
+ # - https://gh.io/recommended-hardware-resources-for-running-codeql
27
+ # - https://gh.io/supported-runners-and-hardware-resources
28
+ # - https://gh.io/using-larger-runners (GitHub.com only)
29
+ # Consider using larger runners or machines with greater resources for possible analysis time improvements.
30
+ runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31
+ timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
32
+ permissions:
33
+ # required for all workflows
34
+ security-events: write
35
+
36
+ # required to fetch internal or private CodeQL packs
37
+ packages: read
38
+
39
+ # only required for workflows in private repositories
40
+ actions: read
41
+ contents: read
42
+
43
+ strategy:
44
+ fail-fast: false
45
+ matrix:
46
+ include:
47
+ - language: python
48
+ build-mode: none
49
+ # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
50
+ # Use `c-cpp` to analyze code written in C, C++ or both
51
+ # Use 'java-kotlin' to analyze code written in Java, Kotlin or both
52
+ # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
53
+ # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
54
+ # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
55
+ # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
56
+ # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
57
+ steps:
58
+ - name: Checkout repository
59
+ uses: actions/checkout@v4
60
+
61
+ # Initializes the CodeQL tools for scanning.
62
+ - name: Initialize CodeQL
63
+ uses: github/codeql-action/init@v3
64
+ with:
65
+ languages: ${{ matrix.language }}
66
+ build-mode: ${{ matrix.build-mode }}
67
+ # If you wish to specify custom queries, you can do so here or in a config file.
68
+ # By default, queries listed here will override any specified in a config file.
69
+ # Prefix the list here with "+" to use these queries and those in the config file.
70
+
71
+ # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
72
+ # queries: security-extended,security-and-quality
73
+
74
+ # If the analyze step fails for one of the languages you are analyzing with
75
+ # "We were unable to automatically build your code", modify the matrix above
76
+ # to set the build mode to "manual" for that language. Then modify this step
77
+ # to build your code.
78
+ # ℹ️ Command-line programs to run using the OS shell.
79
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
80
+ - if: matrix.build-mode == 'manual'
81
+ shell: bash
82
+ run: |
83
+ echo 'If you are using a "manual" build mode for one or more of the' \
84
+ 'languages you are analyzing, replace this with the commands to build' \
85
+ 'your code, for example:'
86
+ echo ' make bootstrap'
87
+ echo ' make release'
88
+ exit 1
89
+
90
+ - name: Perform CodeQL Analysis
91
+ uses: github/codeql-action/analyze@v3
92
+ with:
93
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,51 @@
1
+ name: codspeed-benchmarks
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - "stag"
7
+ - "main"
8
+ pull_request:
9
+ # `workflow_dispatch` allows CodSpeed to trigger backtest
10
+ # performance analysis in order to generate initial data.
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+
15
+ benchmarks:
16
+ runs-on: ubuntu-latest
17
+ services:
18
+ redis:
19
+ # Docker Hub image
20
+ image: redis
21
+ # Set health checks to wait until redis has started
22
+ options: >-
23
+ --health-cmd "redis-cli ping"
24
+ --health-interval 10s
25
+ --health-timeout 5s
26
+ --health-retries 5
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: actions/setup-python@v5
30
+ with:
31
+ python-version: "3.10"
32
+
33
+ - name: Install dependencies
34
+ run: |
35
+ python -m pip install --upgrade pip
36
+ pip install poetry maturin
37
+ poetry export --with test --with dev --without-hashes --output requirements.txt
38
+ pip install -r requirements.txt
39
+ pip install -e .
40
+ - name: Setup Rust part of the project
41
+ run: |
42
+ maturin build -i python${{ matrix.python-version }} --release --out dist
43
+ pip install --force-reinstall dist/*.whl
44
+
45
+ - name: Run benchmarks
46
+ uses: CodSpeedHQ/action@v3
47
+ env:
48
+ REDIS_URL: redis://redis:6379
49
+ with:
50
+ token: ${{ secrets.CODSPEED_TOKEN }}
51
+ run: pytest tests --codspeed
@@ -0,0 +1,94 @@
1
+ # CI to release the project for Linux, Windows, and MacOS
2
+ # The purpose of this action is to verify if the release builds are working or not.
3
+
4
+ name: Preview Release
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - stag
10
+ - main
11
+ pull_request:
12
+ branches:
13
+ - stag
14
+ - main
15
+
16
+ jobs:
17
+ macos:
18
+ runs-on: macos-12
19
+ strategy:
20
+ matrix:
21
+ python-version: ["3.10", "3.11", "3.12"]
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: actions/setup-python@v5
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+ - uses: dtolnay/rust-toolchain@stable
28
+ with:
29
+ targets: aarch64-apple-darwin
30
+ - name: Build wheels - x86_64
31
+ uses: PyO3/maturin-action@v1
32
+ with:
33
+ target: x86_64
34
+ args: -i python --release --out dist
35
+ - name: Install build wheel - x86_64
36
+ run: |
37
+ pip install --force-reinstall dist/*.whl
38
+ cd ~ && python -c 'import hypern'
39
+ - name: Build wheels - universal2
40
+ uses: PyO3/maturin-action@v1
41
+ with:
42
+ args: -i python --release --target universal2-apple-darwin --out dist
43
+ - name: Install build wheel - universal2
44
+ run: |
45
+ pip install --force-reinstall dist/*_universal2.whl
46
+ cd ~ && python -c 'import hypern'
47
+
48
+ windows:
49
+ runs-on: windows-latest
50
+ strategy:
51
+ matrix:
52
+ python-version: ["3.10", "3.11", "3.12"]
53
+ target: [x64, x86]
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+ - uses: actions/setup-python@v5
57
+ with:
58
+ python-version: ${{ matrix.python-version }}
59
+ architecture: ${{ matrix.target }}
60
+ - uses: dtolnay/rust-toolchain@stable
61
+ - name: Build wheels
62
+ uses: PyO3/maturin-action@v1
63
+ with:
64
+ target: ${{ matrix.target }}
65
+ args: -i python --release --out dist
66
+ - name: Install build wheel
67
+ shell: bash
68
+ run: |
69
+ pip install --force-reinstall dist/*.whl
70
+ cd ~ && python -c 'import hypern'
71
+
72
+ linux:
73
+ runs-on: ubuntu-latest
74
+ strategy:
75
+ matrix:
76
+ python-version: ["3.10", "3.11", "3.12"]
77
+ target: [x86_64, i686]
78
+ steps:
79
+ - uses: actions/checkout@v4
80
+ - uses: dtolnay/rust-toolchain@stable
81
+ - uses: actions/setup-python@v5
82
+ with:
83
+ python-version: ${{ matrix.python-version }}
84
+ - name: Build Wheels
85
+ uses: PyO3/maturin-action@v1
86
+ with:
87
+ target: ${{ matrix.target }}
88
+ manylinux: auto
89
+ args: -i python${{ matrix.python-version }} --release --out dist
90
+ - name: Install build wheel
91
+ if: matrix.target == 'x86_64'
92
+ run: |
93
+ pip install --force-reinstall dist/*.whl
94
+ cd ~ && python -c 'import hypern'
@@ -0,0 +1,105 @@
1
+ name: Security Scan
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, stag ]
6
+ pull_request:
7
+ branches: [ main, stag ]
8
+
9
+ jobs:
10
+ security-scan:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: dtolnay/rust-toolchain@stable
15
+ - uses: actions/setup-python@v5
16
+ with:
17
+ python-version: '3.12'
18
+
19
+ - name: Export requirements
20
+ run: |
21
+ python -m pip install --upgrade pip
22
+ pip install poetry
23
+ poetry export --without-hashes --format=requirements.txt > requirements.txt
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install bandit safety
29
+
30
+ # Bandit - Scan for security vulnerabilities in Python code
31
+ - name: Run Bandit
32
+ run: |
33
+ bandit -r ./hypern -f json -o bandit-results.json --exit-zero
34
+
35
+ # Safety - Check dependencies for security vulnerabilities
36
+ - name: Run Safety Check
37
+ run: |
38
+ safety check -r requirements.txt --json > safety-results.json
39
+
40
+ # OWASP Dependency-Check
41
+ - name: OWASP Dependency Check
42
+ uses: dependency-check/Dependency-Check_Action@main
43
+ with:
44
+ project: 'Hypern'
45
+ path: '.'
46
+ format: 'JSON'
47
+
48
+ # SonarCloud analysis
49
+ - name: SonarCloud Scan
50
+ uses: SonarSource/sonarcloud-github-action@master
51
+ env:
52
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
54
+
55
+ # GitGuardian - Scan for secrets
56
+ - name: GitGuardian scan
57
+ uses: GitGuardian/ggshield/actions/secret@v1.33.0
58
+ with:
59
+ fetch-depth: 0
60
+ env:
61
+ GITHUB_PUSH_BEFORE: ${{ github.event.before }}
62
+ GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
63
+ GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
64
+ GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
65
+ GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
66
+
67
+ # Upload scan results as artifacts
68
+ - name: Upload scan results
69
+ uses: actions/upload-artifact@v4
70
+ with:
71
+ name: security-scan-results
72
+ path: |
73
+ bandit-results.json
74
+ safety-results.json
75
+ dependency-check-report.json
76
+
77
+ # Send notification on critical issues
78
+ - name: Notify Security Issues
79
+ if: failure()
80
+ uses: actions/github-script@v7
81
+ with:
82
+ script: |
83
+ const issueBody = `Security scan failed in ${process.env.GITHUB_WORKFLOW}
84
+ See detailed results in the workflow artifacts.`;
85
+
86
+ github.rest.issues.create({
87
+ owner: context.repo.owner,
88
+ repo: context.repo.repo,
89
+ title: '🚨 Security Scan Failed',
90
+ body: issueBody,
91
+ labels: ['security', 'automated-scan']
92
+ });
93
+ github-token: ${{ secrets.GITHUB_TOKEN }}
94
+
95
+ dependency-review:
96
+ runs-on: ubuntu-latest
97
+ if: github.event_name == 'pull_request'
98
+ steps:
99
+ - name: 'Checkout Repository'
100
+ uses: actions/checkout@v4
101
+
102
+ - name: 'Dependency Review'
103
+ uses: actions/dependency-review-action@v4
104
+ with:
105
+ fail-on-severity: critical
@@ -0,0 +1,74 @@
1
+ /target
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ .pytest_cache/
6
+ *.py[cod]
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ .venv/
14
+ env/
15
+ bin/
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ include/
26
+ man/
27
+ venv/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+ pip-selfcheck.json
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+
45
+ # Translations
46
+ *.mo
47
+
48
+ # Mr Developer
49
+ .mr.developer.cfg
50
+ .project
51
+ .pydevproject
52
+
53
+ # Rope
54
+ .ropeproject
55
+
56
+ # Django stuff:
57
+ *.log
58
+ *.pot
59
+
60
+ .DS_Store
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyCharm
66
+ .idea/
67
+
68
+ # VSCode
69
+ .vscode/
70
+
71
+ # Pyenv
72
+ .python-version
73
+ app.py
74
+ test.py
@@ -0,0 +1,11 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.4.10
4
+ hooks:
5
+ - id: ruff
6
+ args:
7
+ - --fix
8
+ - id: ruff-format
9
+ ci:
10
+ autoupdate_schedule: weekly
11
+
@@ -0,0 +1,6 @@
1
+ ### Hypern Open Source Community Guidelines
2
+
3
+ - **Be friendly and patient**.
4
+ - **Be welcoming**.
5
+ - **Be respectful**.
6
+ - **Be careful in the words that we choose**.