cndb 0.1.1__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 (146) hide show
  1. cndb-0.1.1/.bumpversion.toml +18 -0
  2. cndb-0.1.1/.copier-answers.yml +19 -0
  3. cndb-0.1.1/.coveragerc +19 -0
  4. cndb-0.1.1/.dockerignore +46 -0
  5. cndb-0.1.1/.gitattributes +30 -0
  6. cndb-0.1.1/.github/workflows/ci.yml +63 -0
  7. cndb-0.1.1/.github/workflows/release.yml +44 -0
  8. cndb-0.1.1/.gitignore +41 -0
  9. cndb-0.1.1/.pre-commit-config.yaml +21 -0
  10. cndb-0.1.1/.python-version +1 -0
  11. cndb-0.1.1/.readthedocs.yaml +23 -0
  12. cndb-0.1.1/Dockerfile +53 -0
  13. cndb-0.1.1/LICENSE +21 -0
  14. cndb-0.1.1/Makefile +114 -0
  15. cndb-0.1.1/PKG-INFO +169 -0
  16. cndb-0.1.1/README.md +123 -0
  17. cndb-0.1.1/deploy/Dockerfile +39 -0
  18. cndb-0.1.1/deploy/docker-compose.yml +39 -0
  19. cndb-0.1.1/docs/_static/.gitkeep +0 -0
  20. cndb-0.1.1/docs/api.rst +7 -0
  21. cndb-0.1.1/docs/changelog.rst +7 -0
  22. cndb-0.1.1/docs/conf.py +69 -0
  23. cndb-0.1.1/docs/index.rst +58 -0
  24. cndb-0.1.1/manage.py +20 -0
  25. cndb-0.1.1/pyproject.toml +56 -0
  26. cndb-0.1.1/pyrefly.toml +20 -0
  27. cndb-0.1.1/pytest.ini +6 -0
  28. cndb-0.1.1/ruff.toml +37 -0
  29. cndb-0.1.1/scripts/dev_setup.py +69 -0
  30. cndb-0.1.1/scripts/seed_demo.py +124 -0
  31. cndb-0.1.1/src/cndb/__init__.py +7 -0
  32. cndb-0.1.1/src/cndb/accounts/__init__.py +1 -0
  33. cndb-0.1.1/src/cndb/accounts/admin.py +16 -0
  34. cndb-0.1.1/src/cndb/accounts/apps.py +12 -0
  35. cndb-0.1.1/src/cndb/accounts/migrations/0001_initial.py +44 -0
  36. cndb-0.1.1/src/cndb/accounts/migrations/__init__.py +0 -0
  37. cndb-0.1.1/src/cndb/accounts/models.py +20 -0
  38. cndb-0.1.1/src/cndb/accounts/serializers.py +58 -0
  39. cndb-0.1.1/src/cndb/accounts/urls.py +14 -0
  40. cndb-0.1.1/src/cndb/accounts/views.py +59 -0
  41. cndb-0.1.1/src/cndb/asgi.py +11 -0
  42. cndb-0.1.1/src/cndb/py.typed +0 -0
  43. cndb-0.1.1/src/cndb/settings/__init__.py +1 -0
  44. cndb-0.1.1/src/cndb/settings/base.py +124 -0
  45. cndb-0.1.1/src/cndb/settings/dev.py +9 -0
  46. cndb-0.1.1/src/cndb/settings/prod.py +22 -0
  47. cndb-0.1.1/src/cndb/settings/test.py +16 -0
  48. cndb-0.1.1/src/cndb/tables/__init__.py +1 -0
  49. cndb-0.1.1/src/cndb/tables/access.py +161 -0
  50. cndb-0.1.1/src/cndb/tables/admin.py +23 -0
  51. cndb-0.1.1/src/cndb/tables/aggregations.py +129 -0
  52. cndb-0.1.1/src/cndb/tables/apps.py +12 -0
  53. cndb-0.1.1/src/cndb/tables/board_views.py +140 -0
  54. cndb-0.1.1/src/cndb/tables/ddl.py +110 -0
  55. cndb-0.1.1/src/cndb/tables/field_types/__init__.py +29 -0
  56. cndb-0.1.1/src/cndb/tables/field_types/base.py +63 -0
  57. cndb-0.1.1/src/cndb/tables/field_types/builtin.py +329 -0
  58. cndb-0.1.1/src/cndb/tables/field_types/registry.py +29 -0
  59. cndb-0.1.1/src/cndb/tables/form_urls.py +12 -0
  60. cndb-0.1.1/src/cndb/tables/form_views.py +96 -0
  61. cndb-0.1.1/src/cndb/tables/migrations/0001_initial.py +55 -0
  62. cndb-0.1.1/src/cndb/tables/migrations/0002_datafield_db_column_name.py +19 -0
  63. cndb-0.1.1/src/cndb/tables/migrations/0003_dataview.py +37 -0
  64. cndb-0.1.1/src/cndb/tables/migrations/0004_tablepermission.py +34 -0
  65. cndb-0.1.1/src/cndb/tables/migrations/0005_dataview_form_options_dataview_slug.py +23 -0
  66. cndb-0.1.1/src/cndb/tables/migrations/__init__.py +0 -0
  67. cndb-0.1.1/src/cndb/tables/models.py +237 -0
  68. cndb-0.1.1/src/cndb/tables/permission_rules.py +81 -0
  69. cndb-0.1.1/src/cndb/tables/permission_views.py +64 -0
  70. cndb-0.1.1/src/cndb/tables/query.py +185 -0
  71. cndb-0.1.1/src/cndb/tables/record_views.py +247 -0
  72. cndb-0.1.1/src/cndb/tables/records.py +226 -0
  73. cndb-0.1.1/src/cndb/tables/serializers.py +97 -0
  74. cndb-0.1.1/src/cndb/tables/services.py +88 -0
  75. cndb-0.1.1/src/cndb/tables/share_urls.py +11 -0
  76. cndb-0.1.1/src/cndb/tables/share_views.py +60 -0
  77. cndb-0.1.1/src/cndb/tables/sql.py +15 -0
  78. cndb-0.1.1/src/cndb/tables/transfer.py +150 -0
  79. cndb-0.1.1/src/cndb/tables/transfer_views.py +64 -0
  80. cndb-0.1.1/src/cndb/tables/urls.py +41 -0
  81. cndb-0.1.1/src/cndb/tables/view_rules.py +151 -0
  82. cndb-0.1.1/src/cndb/tables/view_views.py +138 -0
  83. cndb-0.1.1/src/cndb/tables/views.py +194 -0
  84. cndb-0.1.1/src/cndb/tokens/__init__.py +1 -0
  85. cndb-0.1.1/src/cndb/tokens/apps.py +12 -0
  86. cndb-0.1.1/src/cndb/tokens/authentication.py +36 -0
  87. cndb-0.1.1/src/cndb/tokens/migrations/0001_initial.py +34 -0
  88. cndb-0.1.1/src/cndb/tokens/migrations/__init__.py +0 -0
  89. cndb-0.1.1/src/cndb/tokens/models.py +61 -0
  90. cndb-0.1.1/src/cndb/tokens/serializers.py +16 -0
  91. cndb-0.1.1/src/cndb/tokens/urls.py +12 -0
  92. cndb-0.1.1/src/cndb/tokens/views.py +37 -0
  93. cndb-0.1.1/src/cndb/urls.py +16 -0
  94. cndb-0.1.1/src/cndb/webui/__init__.py +1 -0
  95. cndb-0.1.1/src/cndb/webui/apps.py +12 -0
  96. cndb-0.1.1/src/cndb/webui/static/webui/actions.js +1293 -0
  97. cndb-0.1.1/src/cndb/webui/static/webui/app.js +540 -0
  98. cndb-0.1.1/src/cndb/webui/static/webui/auth.js +54 -0
  99. cndb-0.1.1/src/cndb/webui/static/webui/form.js +59 -0
  100. cndb-0.1.1/src/cndb/webui/static/webui/share.js +56 -0
  101. cndb-0.1.1/src/cndb/webui/static/webui/style.css +730 -0
  102. cndb-0.1.1/src/cndb/webui/templates/webui/form.html +51 -0
  103. cndb-0.1.1/src/cndb/webui/templates/webui/index.html +94 -0
  104. cndb-0.1.1/src/cndb/webui/templates/webui/login.html +40 -0
  105. cndb-0.1.1/src/cndb/webui/templates/webui/share.html +33 -0
  106. cndb-0.1.1/src/cndb/webui/templatetags/__init__.py +0 -0
  107. cndb-0.1.1/src/cndb/webui/templatetags/static_version.py +25 -0
  108. cndb-0.1.1/src/cndb/webui/urls.py +14 -0
  109. cndb-0.1.1/src/cndb/webui/views.py +83 -0
  110. cndb-0.1.1/src/cndb/workspaces/__init__.py +1 -0
  111. cndb-0.1.1/src/cndb/workspaces/admin.py +22 -0
  112. cndb-0.1.1/src/cndb/workspaces/apps.py +12 -0
  113. cndb-0.1.1/src/cndb/workspaces/migrations/0001_initial.py +48 -0
  114. cndb-0.1.1/src/cndb/workspaces/migrations/__init__.py +0 -0
  115. cndb-0.1.1/src/cndb/workspaces/models.py +70 -0
  116. cndb-0.1.1/src/cndb/workspaces/permissions.py +46 -0
  117. cndb-0.1.1/src/cndb/workspaces/serializers.py +51 -0
  118. cndb-0.1.1/src/cndb/workspaces/urls.py +24 -0
  119. cndb-0.1.1/src/cndb/workspaces/views.py +143 -0
  120. cndb-0.1.1/src/cndb/wsgi.py +11 -0
  121. cndb-0.1.1/tests/__init__.py +0 -0
  122. cndb-0.1.1/tests/conftest.py +49 -0
  123. cndb-0.1.1/tests/test_accounts_views.py +102 -0
  124. cndb-0.1.1/tests/test_bench_rows.py +81 -0
  125. cndb-0.1.1/tests/test_cndb.py +17 -0
  126. cndb-0.1.1/tests/test_settings.py +31 -0
  127. cndb-0.1.1/tests/test_tables_access.py +165 -0
  128. cndb-0.1.1/tests/test_tables_aggregations.py +178 -0
  129. cndb-0.1.1/tests/test_tables_board.py +202 -0
  130. cndb-0.1.1/tests/test_tables_bulk.py +254 -0
  131. cndb-0.1.1/tests/test_tables_ddl.py +195 -0
  132. cndb-0.1.1/tests/test_tables_field_types.py +231 -0
  133. cndb-0.1.1/tests/test_tables_forms.py +291 -0
  134. cndb-0.1.1/tests/test_tables_models.py +66 -0
  135. cndb-0.1.1/tests/test_tables_permissions.py +305 -0
  136. cndb-0.1.1/tests/test_tables_query.py +178 -0
  137. cndb-0.1.1/tests/test_tables_records.py +189 -0
  138. cndb-0.1.1/tests/test_tables_share.py +149 -0
  139. cndb-0.1.1/tests/test_tables_transfer.py +195 -0
  140. cndb-0.1.1/tests/test_tables_view_rules.py +307 -0
  141. cndb-0.1.1/tests/test_tables_views.py +171 -0
  142. cndb-0.1.1/tests/test_tokens.py +133 -0
  143. cndb-0.1.1/tests/test_webui_views.py +179 -0
  144. cndb-0.1.1/tests/test_workspaces_views.py +288 -0
  145. cndb-0.1.1/tox.ini +21 -0
  146. cndb-0.1.1/uv.lock +1362 -0
@@ -0,0 +1,18 @@
1
+ [tool.bumpversion]
2
+ current_version = "0.1.1"
3
+ commit = true
4
+ exclude = ["template/*"]
5
+ message = "chore: 更新版本 {current_version} → {new_version}"
6
+ tag = true
7
+ tag_name = "v{new_version}"
8
+
9
+ [[tool.bumpversion.files]]
10
+ filename = "pyproject.toml"
11
+ regex = true
12
+ search = '(version\s+=\s+)"{current_version}"'
13
+ replace = '\1"{new_version}"'
14
+
15
+ [[tool.bumpversion.files]]
16
+ filename = "src/cndb/__init__.py"
17
+ search = '__version__ = "{current_version}"'
18
+ replace = '__version__ = "{new_version}"'
@@ -0,0 +1,19 @@
1
+ # Changes here will be overwritten by Copier
2
+ _commit: v0.9.5
3
+ _src_path: https://gitee.com/gooker_young/coopie.git
4
+ author_email: gooker_young@qq.com
5
+ author_name: gookeryoung
6
+ coverage_fail_under: 95
7
+ description: 通用数据库管理平台。
8
+ license: MIT
9
+ max_python_version: '3.14'
10
+ min_python_version: '3.11'
11
+ package_name: cndb
12
+ project_name: cndb
13
+ project_type: library
14
+ use_cicd: true
15
+ use_docker: true
16
+ use_docs: true
17
+ use_domestic_mirrors: true
18
+ use_tox: true
19
+
cndb-0.1.1/.coveragerc ADDED
@@ -0,0 +1,19 @@
1
+ [run]
2
+ branch = true
3
+ concurrency = thread
4
+ omit =
5
+ tests/*
6
+ */migrations/*
7
+ */admin.py
8
+ **/wsgi.py
9
+ **/asgi.py
10
+ source = cndb
11
+
12
+ [report]
13
+ fail_under = 95
14
+ exclude_lines =
15
+ if TYPE_CHECKING:
16
+ if __name__ == .__main__.:
17
+ pragma: no cover
18
+ raise NotImplementedError
19
+ show_missing = true
@@ -0,0 +1,46 @@
1
+ # 版本控制
2
+ .git
3
+ .gitignore
4
+ .github
5
+
6
+ # Python 缓存与构建产物
7
+ __pycache__
8
+ *.pyc
9
+ *.pyo
10
+ *.pyd
11
+ *.egg-info
12
+ *.egg
13
+ dist
14
+ build
15
+ .eggs
16
+
17
+ # 测试与覆盖率
18
+ .pytest_cache
19
+ .coverage
20
+ htmlcov
21
+ .tox
22
+ coverage.xml
23
+
24
+ # 虚拟环境
25
+ .venv
26
+ venv
27
+ env
28
+
29
+ # 工具缓存
30
+ .uv-cache
31
+ .ruff_cache
32
+ .pyrefly_cache
33
+ .mypy_cache
34
+
35
+ # IDE 与编辑器
36
+ .idea
37
+ .vscode
38
+ *.swp
39
+ *.swo
40
+
41
+ # 文档(按需保留)
42
+ docs
43
+
44
+ # 系统文件
45
+ .DS_Store
46
+ Thumbs.db
@@ -0,0 +1,30 @@
1
+ # Git 行尾规范化
2
+ # 默认所有文本文件使用 LF 行尾(跨平台一致)
3
+ * text=auto eol=lf
4
+
5
+ # Windows 脚本使用 CRLF
6
+ *.bat text eol=crlf
7
+ *.cmd text eol=crlf
8
+ *.ps1 text eol=crlf
9
+
10
+ # 二进制文件(不做行尾转换)
11
+ *.png binary
12
+ *.jpg binary
13
+ *.jpeg binary
14
+ *.gif binary
15
+ *.ico binary
16
+ *.icns binary
17
+ *.pdf binary
18
+ *.zip binary
19
+ *.gz binary
20
+ *.tar binary
21
+ *.tgz binary
22
+ *.whl binary
23
+ *.egg binary
24
+ *.pyc binary
25
+ *.pyo binary
26
+ *.so binary
27
+ *.dll binary
28
+ *.dylib binary
29
+ *.qrc binary
30
+ *.qss binary
@@ -0,0 +1,63 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, develop]
6
+ pull_request:
7
+ branches: [main, develop]
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ lint:
15
+ name: Lint & Typecheck
16
+ runs-on: ubuntu-latest
17
+ timeout-minutes: 10
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v8.3.2
23
+ with:
24
+ enable-cache: true
25
+ cache-dependency-glob: "uv.lock"
26
+
27
+ - name: Sync dependencies
28
+ run: uv sync --frozen --extra lint
29
+
30
+ - name: Ruff check
31
+ run: uv run ruff check src tests
32
+
33
+ - name: Ruff format check
34
+ run: uv run ruff format --check src tests
35
+
36
+ - name: Pyrefly check
37
+ run: uv run pyrefly check
38
+
39
+ test:
40
+ name: Test (Python 3.11 & 3.14)
41
+ runs-on: ubuntu-latest
42
+ timeout-minutes: 15
43
+ strategy:
44
+ fail-fast: false
45
+ matrix:
46
+ python-version: ["3.11", "3.14"]
47
+ steps:
48
+ - uses: actions/checkout@v5
49
+
50
+ - name: Install uv
51
+ uses: astral-sh/setup-uv@v8.3.2
52
+ with:
53
+ enable-cache: true
54
+ cache-dependency-glob: "uv.lock"
55
+
56
+ - name: Set up Python ${{ matrix.python-version }}
57
+ run: uv python install ${{ matrix.python-version }}
58
+
59
+ - name: Sync dependencies
60
+ run: uv sync --frozen --extra test --python ${{ matrix.python-version }}
61
+
62
+ - name: Run tests
63
+ run: uv run pytest -m "not slow" --cov=cndb --cov-fail-under=95 --cov-report=term-missing
@@ -0,0 +1,44 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ['v*.*.*']
6
+
7
+ permissions:
8
+ contents: write
9
+ id-token: write
10
+
11
+ concurrency:
12
+ group: release-${{ github.ref }}
13
+ cancel-in-progress: false
14
+
15
+ jobs:
16
+ release:
17
+ name: Build & Publish
18
+ runs-on: ubuntu-latest
19
+ environment: pypi
20
+ timeout-minutes: 10
21
+ steps:
22
+ - uses: actions/checkout@v5
23
+
24
+ - name: Install uv
25
+ uses: astral-sh/setup-uv@v8.3.2
26
+ with:
27
+ enable-cache: true
28
+ cache-dependency-glob: "uv.lock"
29
+
30
+ - name: Build distributions
31
+ run: uv build
32
+
33
+ - name: Publish to PyPI (OIDC)
34
+ run: uv publish
35
+
36
+ - name: Create GitHub Release
37
+ env:
38
+ GH_TOKEN: ${{ github.token }}
39
+ TAG_NAME: ${{ github.ref_name }}
40
+ run: |
41
+ gh release create "$TAG_NAME" \
42
+ --title "Release $TAG_NAME" \
43
+ --generate-notes \
44
+ dist/*
cndb-0.1.1/.gitignore ADDED
@@ -0,0 +1,41 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # 测试与覆盖率
13
+ .coverage
14
+ .coverage.*
15
+ htmlcov/
16
+ coverage.xml
17
+ .tox/
18
+
19
+ # 工具缓存
20
+ .ruff_cache/
21
+ .pyrefly_cache/
22
+ .mypy_cache/
23
+ .uv-cache/
24
+
25
+ # IDE
26
+ .idea/
27
+ *_profile.html
28
+
29
+ # 环境变量与凭证(勿提交)
30
+ .env
31
+ .env.*
32
+
33
+ # Sphinx 文档构建输出
34
+ docs/_build/
35
+
36
+ # 本地协作产物(需求/迭代记录,勿提交)
37
+ /.trae/
38
+
39
+ # Django 开发数据
40
+ data/
41
+ *.sqlite3
@@ -0,0 +1,21 @@
1
+ # prek / pre-commit 配置
2
+ # See https://pre-commit.com for more information
3
+ repos:
4
+ - repo: https://github.com/astral-sh/ruff-pre-commit
5
+ # Ruff 版本 - 与 pyproject.toml 保持同步
6
+ rev: v0.15.21
7
+ hooks:
8
+ # 运行 linter
9
+ - id: ruff
10
+ args: [--fix, --exit-non-zero-on-fix]
11
+ # 运行格式化
12
+ - id: ruff-format
13
+ - repo: https://github.com/pre-commit/pre-commit-hooks
14
+ rev: v5.0.0
15
+ hooks:
16
+ - id: check-merge-conflict
17
+ - id: debug-statements
18
+ - id: fix-byte-order-marker
19
+ - id: trailing-whitespace
20
+ args: [--markdown-linebreak-ext=md]
21
+ - id: end-of-file-fixer
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,23 @@
1
+ # ReadTheDocs 配置
2
+ # https://docs.readthedocs.io/en/stable/config-file/v2.html
3
+ version: 2
4
+
5
+ # 构建配置
6
+ build:
7
+ os: ubuntu-24.04
8
+ tools:
9
+ python: "3.11"
10
+
11
+ # Python 依赖与构建命令
12
+ python:
13
+ install:
14
+ - method: pip
15
+ path: .
16
+ extra_requirements:
17
+ - docs
18
+
19
+ # Sphinx 构建
20
+ sphinx:
21
+ configuration: docs/conf.py
22
+ builder: html
23
+ fail_on_warning: false
cndb-0.1.1/Dockerfile ADDED
@@ -0,0 +1,53 @@
1
+ # CI/容器化用 Dockerfile
2
+ # 使用国内镜像源拉取基础镜像(如不需要可替换为官方镜像)
3
+ # 备选镜像源前缀:docker.1ms.run / dockerpull.com / docker.xuanyuan.me
4
+ FROM docker.m.daocloud.io/python:3.14-slim
5
+
6
+ # ---- 国内镜像源 ----
7
+ ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
8
+ ENV PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
9
+ ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
10
+ ENV UV_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
11
+
12
+ # 环境变量:非交互 + 路径配置
13
+ ENV DEBIAN_FRONTEND=noninteractive \
14
+ LANG=C.UTF-8 \
15
+ LC_ALL=C.UTF-8 \
16
+ UV_LINK_MODE=copy \
17
+ UV_CACHE_DIR=/uv-cache \
18
+ UV_PROJECT_ENVIRONMENT=/opt/venv \
19
+ PATH="/opt/venv/bin:${PATH}"
20
+
21
+ # 配置 apt 国内镜像(阿里云)并安装系统依赖
22
+ RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources \
23
+ && apt-get update \
24
+ && apt-get install -y --no-install-recommends \
25
+ ca-certificates \
26
+ curl \
27
+ git \
28
+ build-essential \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+
32
+ # 安装 uv(国内镜像)
33
+ RUN pip install --no-cache-dir uv -i https://mirrors.aliyun.com/pypi/simple/
34
+
35
+ # 预装项目所需 Python 版本
36
+ RUN uv python install 3.11 3.14
37
+
38
+ # 预装项目 dev 依赖(仅复制依赖描述文件,利用 Docker 层缓存)
39
+ WORKDIR /workspace
40
+ COPY pyproject.toml uv.toml tox.ini README.md ./
41
+ COPY src/ ./src/
42
+
43
+ # 同步依赖到 /opt/venv(CI 时直接复用)
44
+ RUN uv sync --frozen --no-install-project 2>/dev/null || uv sync --no-install-project
45
+
46
+ # 预装 tox 环境(首尾两个版本)
47
+ RUN uvx tox run -e py311,py314 --notest 2>/dev/null || true
48
+
49
+ # 持久化 uv 缓存目录(CI 可挂载到宿主机加速)
50
+ VOLUME ["/uv-cache"]
51
+
52
+ # 默认入口
53
+ CMD ["/bin/bash"]
cndb-0.1.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 gookeryoung
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cndb-0.1.1/Makefile ADDED
@@ -0,0 +1,114 @@
1
+ # Makefile - cndb 项目快捷命令
2
+ # 运行 `make help` 查看所有可用命令
3
+
4
+ PACKAGE := cndb
5
+ COV_THRESHOLD := 95
6
+ COMPOSE := docker compose -f deploy/docker-compose.yml
7
+
8
+ .DEFAULT_GOAL := help
9
+ .PHONY: help sync build b clean c test cov lint typecheck typecheck-ci check doc tox bump patch minor major push \
10
+ dev migrate makemigrations su shell dbshell routes static seed bench up down logs ps
11
+
12
+ help: ## 显示帮助信息
13
+ @uv run python -c "import re,sys;ms=[(m.group(1),m.group(2).strip()) for f in sys.argv[1:] for l in open(f,encoding='utf-8') if (m:=re.match(r'^([a-zA-Z][\w -]*):.*?##\s*(.*)',l))];[print(f' {n:<18} {d}') for n,d in ms]" $(MAKEFILE_LIST)
14
+
15
+ sync: ## 安装开发依赖
16
+ uv sync --extra dev
17
+
18
+ # ---------- 本地运行 ----------
19
+
20
+ dev: ## 启动开发服务器 (http://127.0.0.1:8000,SQLite)
21
+ uv run python manage.py migrate
22
+ uv run python manage.py runserver
23
+
24
+ migrate: ## 执行数据库迁移
25
+ uv run python manage.py migrate
26
+
27
+ makemigrations: ## 生成数据库迁移文件
28
+ uv run python manage.py makemigrations
29
+
30
+ su: ## 创建超级用户 (需 DJANGO_SUPERUSER_PASSWORD 环境变量,用户名默认 admin)
31
+ @uv run python scripts/dev_setup.py --superuser
32
+
33
+ shell: ## 进入 Django shell
34
+ uv run python manage.py shell
35
+
36
+ dbshell: ## 进入数据库 shell
37
+ uv run python manage.py dbshell
38
+
39
+ routes: ## 列出全部 URL 路由
40
+ uv run python scripts/dev_setup.py --routes
41
+
42
+ static: ## 收集静态文件到 STATIC_ROOT
43
+ uv run python manage.py collectstatic --noinput
44
+
45
+ seed: ## 写入演示数据(用户/工作区/表/字段/视图/示例行,幂等可重复执行)
46
+ uv run python scripts/seed_demo.py
47
+
48
+ bench: ## 运行行数据压测基准(slow 标记)
49
+ uv run pytest tests/test_bench_rows.py -m slow -s --no-cov
50
+
51
+ # ---------- 容器部署 ----------
52
+
53
+ up: ## 启动生产容器 (gunicorn + PostgreSQL,需 deploy/.env)
54
+ $(COMPOSE) up -d --build
55
+
56
+ down: ## 停止生产容器
57
+ $(COMPOSE) down
58
+
59
+ logs: ## 跟随查看容器日志
60
+ $(COMPOSE) logs -f web
61
+
62
+ ps: ## 查看容器状态
63
+ $(COMPOSE) ps
64
+
65
+ # ---------- 工具链 ----------
66
+
67
+ build b: ## 构建分发包 (wheel + sdist)
68
+ uv build
69
+
70
+ clean c: ## 清理构建产物与缓存
71
+ rm -rf build/ dist/ wheels/ *.egg-info htmlcov/ .coverage .coverage.* coverage.xml docs/_build/ .tox/
72
+ rm -rf .ruff_cache/ .pyrefly_cache/ .mypy_cache/
73
+ find src tests -type d -name __pycache__ -exec rm -rf {} +
74
+ find src tests -type f -name "*.py[oc]" -delete
75
+
76
+ test: ## 运行测试(不含覆盖率)
77
+ uv run pytest -m "not slow"
78
+
79
+ cov: ## 运行测试并检查覆盖率
80
+ uv run pytest -m "not slow" --cov=$(PACKAGE) --cov-fail-under=$(COV_THRESHOLD) -n auto
81
+
82
+ lint: ## 代码风格检查 (ruff)
83
+ uv run ruff check .
84
+ uv run ruff format --check .
85
+
86
+ typecheck: ## 类型检查 (pyrefly)
87
+ uv run pyrefly check
88
+
89
+ typecheck-ci: ## 类型检查 (pyrefly, CI 平台 linux — 捕获跨平台问题)
90
+ uv run pyrefly check --python-platform linux
91
+
92
+ check: lint typecheck typecheck-ci cov ## 运行全套门禁 (lint + typecheck + typecheck-ci + cov)
93
+
94
+ doc: ## 构建 Sphinx 文档
95
+ uv run sphinx-build -b html docs docs/_build/html
96
+
97
+
98
+ tox: ## 多版本测试 (tox)
99
+ uvx tox -p auto
100
+
101
+ BUMP_PART := $(filter-out bump,$(MAKECMDGOALS))
102
+
103
+ bump: ## 版本号 bump (默认 patch,用法: make bump [minor|major])
104
+ @uvx bump-my-version bump $(if $(BUMP_PART),$(firstword $(BUMP_PART)),patch) --tag
105
+
106
+ patch minor major:
107
+ @:
108
+
109
+ pub: ## 推送到pypi
110
+ uvx twine upload ./dist/**
111
+
112
+ push: ## 推送代码到所有远程仓库
113
+ @uv run python -c "import subprocess as sp; [print(f'\u63a8\u9001 {r}...',flush=True) or (sp.run(['git','push',r],check=True) and sp.run(['git','push',r,'--tags'],check=True)) for r in sp.check_output(['git','remote'],text=True).split()]"
114
+
cndb-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.5
2
+ Name: cndb
3
+ Version: 0.1.1
4
+ Summary: 通用数据库管理平台。
5
+ Author-email: gookeryoung <gooker_young@qq.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Requires-Python: >=3.11
15
+ Requires-Dist: django>=5.2.6
16
+ Requires-Dist: djangorestframework>=3.16
17
+ Requires-Dist: gunicorn>=23.0
18
+ Requires-Dist: psycopg[binary]>=3.2.6
19
+ Provides-Extra: dev
20
+ Requires-Dist: prek>=0.4.5; extra == 'dev'
21
+ Requires-Dist: pyrefly>=1.1.1; extra == 'dev'
22
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
23
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
24
+ Requires-Dist: pytest-django>=4.11.0; extra == 'dev'
25
+ Requires-Dist: pytest-html>=4.1.1; extra == 'dev'
26
+ Requires-Dist: pytest-xdist>=3.6.1; extra == 'dev'
27
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.8.0; extra == 'dev'
29
+ Requires-Dist: tox-uv>=1.13.1; extra == 'dev'
30
+ Requires-Dist: tox>=4.25.0; extra == 'dev'
31
+ Provides-Extra: docs
32
+ Requires-Dist: myst-parser>=3.0; extra == 'docs'
33
+ Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
34
+ Requires-Dist: sphinx>=7.0; extra == 'docs'
35
+ Provides-Extra: lint
36
+ Requires-Dist: pyrefly>=1.1.1; extra == 'lint'
37
+ Requires-Dist: ruff>=0.8.0; extra == 'lint'
38
+ Provides-Extra: test
39
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'test'
40
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'test'
41
+ Requires-Dist: pytest-django>=4.11.0; extra == 'test'
42
+ Requires-Dist: pytest-html>=4.1.1; extra == 'test'
43
+ Requires-Dist: pytest-xdist>=3.6.1; extra == 'test'
44
+ Requires-Dist: pytest>=8.0.0; extra == 'test'
45
+ Description-Content-Type: text/markdown
46
+
47
+ # cndb
48
+
49
+ > 通用数据库管理平台。
50
+
51
+ [![PyPI](https://img.shields.io/pypi/v/cndb)](https://pypi.org/project/cndb/)
52
+ [![CI](https://github.com/gookeryoung/cndb/actions/workflows/ci.yml/badge.svg)](https://github.com/gookeryoung/cndb/actions/workflows/ci.yml)
53
+ ![Python](https://img.shields.io/badge/python-3.11%2B-blue.svg)
54
+ ![License](https://img.shields.io/badge/license-MIT-green.svg)
55
+ ![Coverage](https://img.shields.io/badge/coverage-%E2%89%A595%25-brightgreen.svg)
56
+
57
+ ## 特性
58
+
59
+ - **技术栈**:Django 5.2 + DRF + PostgreSQL(开发/测试可用 SQLite)
60
+ - **元数据驱动**:数据表/字段定义存元数据库,字段类型系统插件式扩展(9 种内置类型)
61
+ - **动态 DDL**:物理表/列名系统生成,用户输入永不进入 SQL 标识符
62
+ - **视图规则**:Grid/Kanban/Calendar/Gallery/Form 五种形态,筛选/排序/字段选项保存期校验,聚合统计(count/sum/avg/min/max)
63
+ - **权限体系**:工作区五级角色 → 表级动作制 → 行级范围 → 字段级隐藏;API Token 认证
64
+ - **表单与共享**:表单视图匿名提交;grid 视图公开共享(slug 匿名只读)
65
+ - **导入导出**:CSV/JSON 双向流转,错误行按原始行号报告
66
+ - **前端**:Django 模板 + 原生 JS 无构建(登录/工作区/表/Grid)
67
+
68
+ ## 快速上手
69
+
70
+ ```bash
71
+ # 安装依赖并启动开发服务器(自动迁移,http://127.0.0.1:8000)
72
+ uv sync --extra dev
73
+ make dev
74
+
75
+ # 写入演示数据(示例用户/工作区/任务表/看板/日历/公开表单/共享视图,幂等)
76
+ make seed
77
+ ```
78
+
79
+ 演示账号:`demo-owner` / `demo-editor`,密码均为 `Demo-Pass-42`。
80
+
81
+ 常用命令(`make help` 查看全部):
82
+
83
+ | 命令 | 说明 |
84
+ |------|------|
85
+ | `make dev` | 启动开发服务器(自动迁移) |
86
+ | `make seed` | 写入演示数据(幂等) |
87
+ | `make su` | 创建超级用户(需 `DJANGO_SUPERUSER_PASSWORD` 环境变量) |
88
+ | `make routes` | 列出全部 URL 路由 |
89
+ | `make up` / `make down` | 启停生产容器(gunicorn + PostgreSQL) |
90
+ | `make check` | 全套门禁(lint + typecheck + cov ≥95%) |
91
+
92
+ REST API 入口:`/api/auth/`、`/api/workspaces/`、`/api/tokens/`、`/api/forms/`、`/api/views/`,管理后台:`/admin/`。
93
+
94
+ 切换 PostgreSQL:设置 `CNDB_DB=postgres` 及 `CNDB_DB_NAME/CNDB_DB_USER/CNDB_DB_PASSWORD` 等环境变量。
95
+
96
+ ## 部署
97
+
98
+ 生产部署使用 Docker Compose(gunicorn + PostgreSQL 17):
99
+
100
+ ```bash
101
+ cd deploy
102
+ # 在 .env 中设置 CNDB_SECRET_KEY 与 CNDB_DB_PASSWORD(必填)
103
+ echo "CNDB_SECRET_KEY=<随机密钥>" > .env
104
+ echo "CNDB_DB_PASSWORD=<数据库密码>" >> .env
105
+ docker compose up -d
106
+ docker compose exec web python manage.py migrate # 首次启动执行迁移
107
+ ```
108
+
109
+ 访问 `http://localhost:8000/`。`CNDB_ALLOWED_HOSTS` 环境变量控制允许的Host 头(默认 `localhost,127.0.0.1`)。
110
+
111
+ ## 性能基准
112
+
113
+ 行数据服务层吞吐基准(`make check` 之外单独运行):
114
+
115
+ ```bash
116
+ uv run pytest tests/test_bench_rows.py -m slow -s --no-cov
117
+ ```
118
+
119
+ ## 开发
120
+
121
+ ```bash
122
+ # 安装开发依赖
123
+ uv sync --extra dev
124
+
125
+ # 运行测试(含覆盖率,阈值 95%)
126
+ uv run pytest -m "not slow" --cov=cndb --cov-fail-under=95
127
+
128
+ # 类型检查
129
+ uv run pyrefly check .
130
+
131
+ # 代码风格
132
+ uv run ruff check src tests
133
+ uv run ruff format --check src tests
134
+ ```
135
+
136
+ ### Make 快捷命令
137
+
138
+ 项目提供 Makefile 封装常用操作,运行 `make help` 查看全部命令:
139
+
140
+ ```bash
141
+ make sync # 安装开发依赖
142
+ make check # 全套门禁 (lint + typecheck + cov)
143
+ make build # 构建分发包
144
+ make clean # 清理构建产物
145
+ make bump PART=patch # 版本号 bump
146
+ ```
147
+
148
+
149
+ ## 文档
150
+
151
+ 文档由 Sphinx 构建,托管在 ReadTheDocs:
152
+
153
+ ```bash
154
+ # 本地构建文档
155
+ make doc
156
+ ```
157
+
158
+
159
+ ## 多版本测试
160
+
161
+ 使用 tox 在多个 Python 版本(py311, py312, py313, py314)下运行测试:
162
+
163
+ ```bash
164
+ make tox
165
+ ```
166
+
167
+ ## 许可证
168
+
169
+ MIT