pz-cli 5.0.0__py3-none-any.whl
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.
- pz_cli-5.0.0.dist-info/METADATA +51 -0
- pz_cli-5.0.0.dist-info/RECORD +399 -0
- pz_cli-5.0.0.dist-info/WHEEL +4 -0
- pz_cli-5.0.0.dist-info/entry_points.txt +5 -0
- pz_core/__init__.py +64 -0
- pz_core/__main__.py +7 -0
- pz_core/app.py +45 -0
- pz_core/assembly/__init__.py +17 -0
- pz_core/assembly/app_discovery.py +1240 -0
- pz_core/assembly/apps/__init__.py +25 -0
- pz_core/assembly/apps/compiler.py +824 -0
- pz_core/assembly/apps/providers.py +188 -0
- pz_core/assembly/cli/__init__.py +9 -0
- pz_core/assembly/cli/compiler.py +166 -0
- pz_core/assembly/diagnostics/__init__.py +21 -0
- pz_core/assembly/diagnostics/checks.py +257 -0
- pz_core/assembly/diagnostics/dev_sources.py +569 -0
- pz_core/assembly/events/__init__.py +5 -0
- pz_core/assembly/events/compiler.py +219 -0
- pz_core/assembly/extensions/__init__.py +5 -0
- pz_core/assembly/extensions/compiler.py +696 -0
- pz_core/assembly/infra/__init__.py +6 -0
- pz_core/assembly/infra/compiler.py +272 -0
- pz_core/assembly/lifecycle/__init__.py +5 -0
- pz_core/assembly/lifecycle/compiler.py +95 -0
- pz_core/assembly/middlewares/__init__.py +19 -0
- pz_core/assembly/middlewares/compiler.py +508 -0
- pz_core/assembly/project/__init__.py +7 -0
- pz_core/assembly/project/compiler.py +9 -0
- pz_core/assembly/project/context.py +17 -0
- pz_core/assembly/project/discovery.py +227 -0
- pz_core/assembly/resources/__init__.py +19 -0
- pz_core/assembly/resources/compiler.py +310 -0
- pz_core/assembly/resources/settings.py +129 -0
- pz_core/assembly/routes/__init__.py +7 -0
- pz_core/assembly/routes/compiler.py +400 -0
- pz_core/assembly/runtime_manifests/__init__.py +13 -0
- pz_core/assembly/runtime_manifests/compiler.py +159 -0
- pz_core/assembly/settings/__init__.py +17 -0
- pz_core/assembly/settings/compiler.py +786 -0
- pz_core/assembly/settings/host_project_overrides.py +82 -0
- pz_core/assembly/settings/host_runtime_endpoint.py +207 -0
- pz_core/authoring/__init__.py +79 -0
- pz_core/authoring/app_init_service.py +946 -0
- pz_core/authoring/app_versions.py +814 -0
- pz_core/authoring/cli.py +192 -0
- pz_core/authoring/commands.py +1810 -0
- pz_core/authoring/conflicts.py +180 -0
- pz_core/authoring/dev_bindings.py +916 -0
- pz_core/authoring/dev_git.py +1087 -0
- pz_core/authoring/dev_import.py +1061 -0
- pz_core/authoring/dev_manifest.py +522 -0
- pz_core/authoring/dev_sources.py +1638 -0
- pz_core/authoring/env_cli.py +454 -0
- pz_core/authoring/files.py +109 -0
- pz_core/authoring/ide_projection.py +1129 -0
- pz_core/authoring/naming.py +58 -0
- pz_core/authoring/official_dev_sources.py +432 -0
- pz_core/authoring/official_sources.json +156 -0
- pz_core/authoring/orchestration_service.py +558 -0
- pz_core/authoring/project_default.jsonc +53 -0
- pz_core/authoring/project_defaults.py +88 -0
- pz_core/authoring/project_metadata_service.py +199 -0
- pz_core/authoring/project_settings_checks.py +51 -0
- pz_core/authoring/project_settings_cli.py +299 -0
- pz_core/authoring/project_settings_service.py +1700 -0
- pz_core/authoring/project_state.py +399 -0
- pz_core/authoring/publish_git.py +423 -0
- pz_core/authoring/publish_lock.py +188 -0
- pz_core/authoring/publish_source.py +195 -0
- pz_core/authoring/release.py +1382 -0
- pz_core/authoring/repo_keys.py +29 -0
- pz_core/authoring/root_cli.py +28 -0
- pz_core/authoring/scaffold_service.py +325 -0
- pz_core/authoring/sync_service.py +787 -0
- pz_core/authoring/templates/app/__init__.py +1 -0
- pz_core/authoring/templates/app/api.py +25 -0
- pz_core/authoring/templates/app/apps.py +31 -0
- pz_core/authoring/templates/app/auth_package_init.py +14 -0
- pz_core/authoring/templates/app/auth_readme.py +29 -0
- pz_core/authoring/templates/app/configs_package_init.py +14 -0
- pz_core/authoring/templates/app/default_env.py +18 -0
- pz_core/authoring/templates/app/default_jsonc.py +25 -0
- pz_core/authoring/templates/app/locales_readme.py +25 -0
- pz_core/authoring/templates/app/migrations_readme.py +19 -0
- pz_core/authoring/templates/app/models.py +14 -0
- pz_core/authoring/templates/app/package_init.py +8 -0
- pz_core/authoring/templates/app/pages_base.py +161 -0
- pz_core/authoring/templates/app/pages_readme.py +25 -0
- pz_core/authoring/templates/app/public.py +31 -0
- pz_core/authoring/templates/app/pyproject.py +77 -0
- pz_core/authoring/templates/app/readme.py +74 -0
- pz_core/authoring/templates/app/settings.py +46 -0
- pz_core/authoring/templates/app/static_app_js.py +24 -0
- pz_core/authoring/templates/app/static_readme.py +31 -0
- pz_core/authoring/templates/app/template_config_page.py +23 -0
- pz_core/authoring/templates/app/template_index_html.py +28 -0
- pz_core/authoring/templates/app/templates_readme.py +32 -0
- pz_core/authoring/templates/app/urls.py +36 -0
- pz_core/authoring/templates/app/views.py +36 -0
- pz_core/authoring/templates/project/__init__.py +1 -0
- pz_core/authoring/templates/project/agents.py +51 -0
- pz_core/authoring/templates/project/apps_container_readme.py +37 -0
- pz_core/authoring/templates/project/main_py.py +59 -0
- pz_core/authoring/templates/project/project_env.py +19 -0
- pz_core/authoring/templates/project/pyproject.py +26 -0
- pz_core/authoring/templates/project/pz_env_env.py +65 -0
- pz_core/authoring/templates/project/pz_env_jsonc.py +69 -0
- pz_core/authoring/templates/project/pz_jsonc.py +12 -0
- pz_core/authoring/templates/project/readme.py +94 -0
- pz_core/authoring/templates/project/root_gitkeep.py +8 -0
- pz_core/authoring/templates/shared/__init__.py +5 -0
- pz_core/authoring/templates/shared/text.py +10 -0
- pz_core/authoring/venv_service.py +87 -0
- pz_core/authoring/workspace.py +167 -0
- pz_core/cli.py +291 -0
- pz_core/cli_options.py +74 -0
- pz_core/core/__init__.py +3 -0
- pz_core/core/errors/__init__.py +5 -0
- pz_core/core/errors/models.py +117 -0
- pz_core/core/events/__init__.py +5 -0
- pz_core/core/events/registry.py +54 -0
- pz_core/core/extensions/__init__.py +51 -0
- pz_core/core/extensions/registry.py +790 -0
- pz_core/core/health/__init__.py +6 -0
- pz_core/core/health/contracts.py +10 -0
- pz_core/core/middlewares/__init__.py +6 -0
- pz_core/core/middlewares/models.py +24 -0
- pz_core/core/routing/__init__.py +5 -0
- pz_core/core/routing/models.py +21 -0
- pz_core/core/settings_contracts.py +25 -0
- pz_core/docs/README.md +20 -0
- pz_core/docs/distribution-README.md +438 -0
- pz_core/docs/pz/345/221/275/344/273/244/346/200/273/350/247/210.md +1011 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/00-pz/346/236/266/346/236/204/346/200/273/347/272/262.md +240 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/01-/347/233/256/345/275/225/344/270/216/345/210/206/345/261/202/350/247/204/350/214/203.md +216 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/02-/345/214/205/344/270/216/345/210/206/345/217/221/350/247/204/350/214/203.md +403 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/03-App/346/234/200/345/260/217/345/255/220/345/214/205/350/247/204/350/214/203.md +571 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/04-Settings/344/270/216/351/205/215/347/275/256/350/247/204/350/214/203.md +1177 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/05-/350/265/204/346/272/220/344/270/216/350/277/220/350/241/214/347/233/256/345/275/225/350/247/204/350/214/203.md +575 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/06-/346/225/260/346/215/256/345/272/223/344/270/216/345/217/257/351/200/211/345/237/272/347/241/200/350/256/276/346/226/275/350/247/204/350/214/203.md +499 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/07-App/346/233/277/346/215/242/350/247/204/350/214/203.md +206 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/08-/345/271/263/345/217/260/347/272/247App/344/270/216/350/277/220/350/241/214/346/227/266/345/215/225/344/276/213/350/247/204/350/214/203.md +445 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/09-CLI/344/270/216Worker/345/205/245/345/217/243/350/247/204/350/214/203.md +950 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/10-/346/265/213/350/257/225/344/270/216/345/245/221/347/272/246/350/247/204/350/214/203.md +1001 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/11-/344/273/223/345/272/223/347/234/237/347/233/270/346/272/220/345/234/260/345/233/276.md +102 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/12-/346/236/204/345/273/272/344/270/216/345/217/221/345/270/203/346/243/200/346/237/245/346/270/205/345/215/225.md +171 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/13-/346/255/243/345/274/217Facade/346/200/273/350/241/250.md +402 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/14-/345/210/206/345/261/202/344/270/216/346/211/251/345/261/225/350/247/204/350/214/203.md +550 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/15-/345/255/220/345/214/205/345/274/200/345/217/221/344/275/277/347/224/250/346/211/213/345/206/214.md +1004 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/16-/346/211/251/345/261/225/347/202/271/346/255/243/345/274/217/345/215/217/350/256/256/346/270/205/345/215/225.md +352 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/17-pz.protocols.v1/346/255/243/345/274/217/345/215/217/350/256/256.md +266 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/18-/346/211/251/345/261/225/347/202/271/345/206/262/347/252/201/350/243/201/345/206/263/346/200/273/350/241/250.md +131 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/19-/351/224/231/350/257/257/347/240/201/344/270/216/350/257/212/346/226/255/345/215/217/350/256/256.md +176 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/20-/347/247/201/346/234/211/345/214/205/344/273/223/344/270/216/347/273/237/344/270/200/350/256/244/350/257/201/351/203/250/347/275/262/350/247/204/350/214/203.md +243 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/21-contrib/347/272/246/345/256/232/344/270/216Provider/346/216/245/345/205/245/350/247/204/350/214/203.md +365 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/22-/345/244/232/345/233/275/350/257/255/350/250/200/350/265/204/346/272/220/346/262/273/347/220/206/344/270/216/346/214/211/351/234/200/345/212/240/350/275/275/350/247/204/350/214/203.md +912 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/23-/351/246/226/345/261/217/345/261/225/347/244/272/344/270/216/351/246/226/345/270/247/347/250/263/345/256/232/350/247/204/350/214/203.md +269 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/24-pz/345/220/257/345/212/250/344/270/216/350/277/220/350/241/214/346/227/266/347/274/226/350/257/221/346/265/201/347/250/213.md +245 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/25-/351/235/242/345/220/221/345/257/271/350/261/241/345/274/200/345/217/221/350/247/204/350/214/203.md +300 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/README.md +98 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/00-legacy_core/346/240/207/345/207/206pip/345/214/205/345/214/226/351/207/215/346/236/204/346/200/273/347/272/262.md +1073 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/01-/347/233/256/345/275/225/344/270/216/345/210/206/345/261/202/351/207/215/346/236/204/346/211/247/350/241/214/346/226/271/346/241/210.md +224 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/02-/345/214/205/344/270/216/345/210/206/345/217/221/350/247/204/350/214/203-/345/220/253/345/216/206/345/217/262/345/217/243/345/276/204.md +671 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/13-/344/270/200/346/254/241/346/200/247/345/256/236/346/226/275/346/270/205/345/215/225.md +387 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/14-/345/255/220/345/214/205/351/200/202/351/205/215/346/224/271/351/200/240/346/270/205/345/215/225.md +592 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/15-infra/350/243/201/345/211/252/344/270/216/350/220/275/344/275/215/346/270/205/345/215/225.md +81 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/19-core/345/215/225/344/270/200/346/255/243/345/274/217/346/226/271/346/241/210/346/224/266/346/225/233/346/211/247/350/241/214/346/270/205/345/215/225.md +161 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/25-/345/215/217/350/256/256/345/210/260/346/272/220/347/240/201/345/267/256/350/267/235/346/270/205/345/215/225.md +377 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/26-cutover/345/256/214/345/267/245/346/243/200/346/237/245/346/270/205/345/215/225.md +117 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/29-/345/244/232/345/233/275/350/257/255/350/250/200/350/265/204/346/272/220/346/262/273/347/220/206/344/270/216/346/214/211/351/234/200/345/212/240/350/275/275/350/247/204/350/214/203-/345/220/253/350/277/201/347/247/273/347/255/226/347/225/245.md +956 -0
- pz_core/docs/pz/350/247/204/350/214/203/344/270/216/344/275/277/347/224/250/archive//344/270/255/351/227/264/346/200/201/99-/350/265/204/346/272/220/346/224/266/345/217/243/345/220/216/347/273/255TODO.md +84 -0
- pz_core/docs//345/217/221/347/211/210/345/211/215/346/270/205/345/215/225-4.0.11.md +84 -0
- pz_core/docs//346/226/260/346/211/213/346/214/207/345/215/227.md +422 -0
- pz_core/infra/__init__.py +17 -0
- pz_core/infra/db/__init__.py +23 -0
- pz_core/infra/db/contracts.py +73 -0
- pz_core/infra/health/__init__.py +5 -0
- pz_core/infra/health/contracts.py +8 -0
- pz_core/infra/kv/__init__.py +5 -0
- pz_core/infra/kv/contracts.py +17 -0
- pz_core/infra/observability/__init__.py +23 -0
- pz_core/infra/observability/contracts.py +142 -0
- pz_core/infra/resilience/__init__.py +5 -0
- pz_core/infra/resilience/contracts.py +17 -0
- pz_core/infra/resources/__init__.py +5 -0
- pz_core/infra/resources/contracts.py +16 -0
- pz_core/infra/settings/__init__.py +17 -0
- pz_core/infra/settings/models.py +81 -0
- pz_core/infra/storage/__init__.py +5 -0
- pz_core/infra/storage/ports.py +27 -0
- pz_core/project_root_commands.py +282 -0
- pz_core/project_runtime_cli.py +344 -0
- pz_core/project_sources.py +253 -0
- pz_core/pz_launcher.py +209 -0
- pz_core/root_cli.py +70 -0
- pz_core/runtime/__init__.py +229 -0
- pz_core/runtime/access.py +86 -0
- pz_core/runtime/adapters/__init__.py +5 -0
- pz_core/runtime/adapters/base.py +18 -0
- pz_core/runtime/asyncio_bridge.py +18 -0
- pz_core/runtime/bindings/__init__.py +5 -0
- pz_core/runtime/bindings/container.py +50 -0
- pz_core/runtime/cli/__init__.py +5 -0
- pz_core/runtime/cli/_args.py +67 -0
- pz_core/runtime/cli/app_commands.py +417 -0
- pz_core/runtime/cli/check.py +214 -0
- pz_core/runtime/cli/db.py +297 -0
- pz_core/runtime/cli/main.py +89 -0
- pz_core/runtime/cli/resources.py +280 -0
- pz_core/runtime/discovery.py +23 -0
- pz_core/runtime/environment_integrity.py +157 -0
- pz_core/runtime/errors.py +5 -0
- pz_core/runtime/events.py +87 -0
- pz_core/runtime/facades/__init__.py +38 -0
- pz_core/runtime/facades/_capabilities.py +46 -0
- pz_core/runtime/facades/cache.py +103 -0
- pz_core/runtime/facades/database.py +71 -0
- pz_core/runtime/facades/events.py +380 -0
- pz_core/runtime/facades/health.py +101 -0
- pz_core/runtime/facades/mail.py +121 -0
- pz_core/runtime/facades/observability.py +102 -0
- pz_core/runtime/facades/providers.py +75 -0
- pz_core/runtime/facades/resources.py +52 -0
- pz_core/runtime/facades/storage.py +296 -0
- pz_core/runtime/health/__init__.py +5 -0
- pz_core/runtime/health/service.py +102 -0
- pz_core/runtime/host.py +188 -0
- pz_core/runtime/host_runner.py +282 -0
- pz_core/runtime/http/__init__.py +20 -0
- pz_core/runtime/http/app.py +576 -0
- pz_core/runtime/http_timing.py +173 -0
- pz_core/runtime/invocation.py +29 -0
- pz_core/runtime/json_safe.py +47 -0
- pz_core/runtime/lifecycle/__init__.py +25 -0
- pz_core/runtime/lifecycle/manager.py +533 -0
- pz_core/runtime/plan.py +214 -0
- pz_core/runtime/plan_context.py +33 -0
- pz_core/runtime/plan_snapshot.py +177 -0
- pz_core/runtime/registries/__init__.py +27 -0
- pz_core/runtime/registries/capabilities.py +101 -0
- pz_core/runtime/registries/providers.py +396 -0
- pz_core/runtime/resource_assets.py +344 -0
- pz_core/runtime/run_cli.py +211 -0
- pz_core/runtime/settings.py +888 -0
- pz_core/runtime/worker/__init__.py +21 -0
- pz_core/runtime/worker/engine.py +921 -0
- pz_core/runtime/worker/runtime.py +25 -0
- pz_core/testing/__init__.py +15 -0
- pz_core/testing/doc_route_contracts.py +305 -0
- pz_core/utils/__init__.py +44 -0
- pz_core/utils/env.py +65 -0
- pz_core/utils/project_jsonc/__init__.py +29 -0
- pz_core/utils/project_jsonc/document.py +420 -0
- pz_core/utils/project_settings.py +99 -0
- pz_foundation/__init__.py +50 -0
- pz_foundation/_contracts.py +81 -0
- pz_foundation/_errors.py +34 -0
- pz_foundation/api.py +14 -0
- pz_foundation/apps.py +127 -0
- pz_foundation/auth/__init__.py +1 -0
- pz_foundation/cache_control.py +233 -0
- pz_foundation/cli/__init__.py +2 -0
- pz_foundation/cli/workers.py +565 -0
- pz_foundation/configs/__init__.py +0 -0
- pz_foundation/configs/default.env +15 -0
- pz_foundation/configs/default.jsonc +452 -0
- pz_foundation/db/__init__.py +94 -0
- pz_foundation/db/aerich_executor.py +664 -0
- pz_foundation/db/config.py +358 -0
- pz_foundation/db/connection_manager.py +689 -0
- pz_foundation/db/connection_probe.py +204 -0
- pz_foundation/db/database.py +1291 -0
- pz_foundation/db/deps.py +47 -0
- pz_foundation/db/lifecycle_status.py +85 -0
- pz_foundation/db/migrations.py +477 -0
- pz_foundation/db/mysql.py +57 -0
- pz_foundation/db/postgresql.py +409 -0
- pz_foundation/db/production_pool_fallback.py +143 -0
- pz_foundation/db/public.py +45 -0
- pz_foundation/db/session.py +369 -0
- pz_foundation/db/sqlite.py +15 -0
- pz_foundation/db/tortoise_manager.py +724 -0
- pz_foundation/db/tortoise_psycopg.py +148 -0
- pz_foundation/docs/README.md +18 -0
- pz_foundation/docs/distribution-README.md +319 -0
- pz_foundation/docs/infra/350/243/201/345/211/252/344/270/216/350/220/275/344/275/215/350/257/264/346/230/216.md +39 -0
- pz_foundation/docs//345/205/254/345/274/200/345/205/215/350/264/271/346/216/245/345/217/243/351/230/262/346/273/245/347/224/250/344/270/216/344/272/272/346/234/272/346/240/241/351/252/214.md +680 -0
- pz_foundation/docs//350/256/276/350/256/241/346/226/207/346/241/243.md +288 -0
- pz_foundation/docs//350/267/257/347/224/261/344/270/216URL/345/244/204/347/220/206/350/247/204/350/214/203.md +119 -0
- pz_foundation/health.py +105 -0
- pz_foundation/host/__init__.py +11 -0
- pz_foundation/host/builder.py +34 -0
- pz_foundation/host/cache_runtime.py +44 -0
- pz_foundation/host/db/__init__.py +17 -0
- pz_foundation/host/db/aerich_config.py +36 -0
- pz_foundation/host/db/config.py +106 -0
- pz_foundation/host/db/connection_manager.py +48 -0
- pz_foundation/host/db/deps.py +5 -0
- pz_foundation/host/db/orm_retry_patch.py +566 -0
- pz_foundation/host/db/request_adapter.py +325 -0
- pz_foundation/host/db/router.py +28 -0
- pz_foundation/host/db/session.py +284 -0
- pz_foundation/host/db/tortoise_manager.py +10 -0
- pz_foundation/host/idempotency.py +132 -0
- pz_foundation/host/lifespan.py +247 -0
- pz_foundation/host/redis_runtime.py +100 -0
- pz_foundation/host/web.py +790 -0
- pz_foundation/infra_provider.py +236 -0
- pz_foundation/kv/__init__.py +25 -0
- pz_foundation/kv/cache.py +1166 -0
- pz_foundation/kv/deps.py +84 -0
- pz_foundation/kv/public.py +25 -0
- pz_foundation/kv/redis_manager.py +1531 -0
- pz_foundation/lazy_exports.py +43 -0
- pz_foundation/lazy_imports.py +124 -0
- pz_foundation/lifecycle.py +392 -0
- pz_foundation/managed_workers.py +1117 -0
- pz_foundation/middlewares/__init__.py +26 -0
- pz_foundation/middlewares/_settings.py +250 -0
- pz_foundation/middlewares/analytics.py +124 -0
- pz_foundation/middlewares/cache_control.py +156 -0
- pz_foundation/middlewares/compression.py +202 -0
- pz_foundation/middlewares/cors.py +62 -0
- pz_foundation/middlewares/geo_country.py +44 -0
- pz_foundation/middlewares/inner_router.py +50 -0
- pz_foundation/middlewares/rate_limited/__init__.py +3 -0
- pz_foundation/middlewares/rate_limited/key_limiter.py +115 -0
- pz_foundation/middlewares/request_logging.py +104 -0
- pz_foundation/middlewares/route_owner.py +309 -0
- pz_foundation/middlewares/security_csrf.py +44 -0
- pz_foundation/middlewares/security_headers/__init__.py +4 -0
- pz_foundation/middlewares/security_headers/conflicts.py +44 -0
- pz_foundation/middlewares/security_headers/csp_nonce.py +200 -0
- pz_foundation/middlewares/security_headers/security_headers.py +44 -0
- pz_foundation/migrations/__init__.py +1 -0
- pz_foundation/migrations/pz_foundation/__init__.py +1 -0
- pz_foundation/models.py +22 -0
- pz_foundation/notifications/__init__.py +23 -0
- pz_foundation/notifications/email.py +542 -0
- pz_foundation/notifications/public.py +31 -0
- pz_foundation/observability/__init__.py +71 -0
- pz_foundation/observability/http.py +34 -0
- pz_foundation/observability/logger/__init__.py +49 -0
- pz_foundation/observability/logger/_bot_settings.py +126 -0
- pz_foundation/observability/logger/bot_message.py +592 -0
- pz_foundation/observability/logger/core.py +385 -0
- pz_foundation/observability/logger/delivery_audit.py +84 -0
- pz_foundation/observability/logger/feishu_bot.py +199 -0
- pz_foundation/observability/logger/telegram_bot.py +194 -0
- pz_foundation/observability/metrics.py +365 -0
- pz_foundation/observability/runtime.py +68 -0
- pz_foundation/public.py +405 -0
- pz_foundation/resources/__init__.py +12 -0
- pz_foundation/resources/builder.py +900 -0
- pz_foundation/resources/images.py +363 -0
- pz_foundation/root_cli.py +20 -0
- pz_foundation/routing/__init__.py +203 -0
- pz_foundation/routing/canonical.py +486 -0
- pz_foundation/routing/convertors.py +82 -0
- pz_foundation/routing/declarations.py +843 -0
- pz_foundation/routing/exports.py +148 -0
- pz_foundation/routing/loaders.py +138 -0
- pz_foundation/routing/manifest.py +215 -0
- pz_foundation/routing/manifest_provider.py +47 -0
- pz_foundation/routing/mounts.py +101 -0
- pz_foundation/routing/ordering.py +172 -0
- pz_foundation/routing/registry.py +133 -0
- pz_foundation/routing/utils.py +28 -0
- pz_foundation/runtime.py +234 -0
- pz_foundation/settings.py +253 -0
- pz_foundation/settings_normalization.py +130 -0
- pz_foundation/storage/__init__.py +25 -0
- pz_foundation/storage/local.py +209 -0
- pz_foundation/storage/public.py +106 -0
- pz_foundation/storage/s3.py +116 -0
- pz_foundation/storage/service.py +234 -0
- pz_foundation/urls.py +19 -0
- pz_foundation/utils/__init__.py +6 -0
- pz_foundation/utils/merge.py +160 -0
- pz_foundation/worker_replicas.py +55 -0
- pz_settings_center/__init__.py +5 -0
- pz_settings_center/api/__init__.py +5 -0
- pz_settings_center/api/runtime_overrides.py +360 -0
- pz_settings_center/apps.py +28 -0
- pz_settings_center/configs/__init__.py +0 -0
- pz_settings_center/configs/default.env +2 -0
- pz_settings_center/configs/default.jsonc +1 -0
- pz_settings_center/docs/01-settings_center/350/203/275/345/212/233/350/276/271/347/225/214.md +124 -0
- pz_settings_center/docs/README.md +12 -0
- pz_settings_center/docs/distribution-README.md +150 -0
- pz_settings_center/docs//350/256/276/350/256/241/346/226/207/346/241/243.md +48 -0
- pz_settings_center/integration_payload.py +18 -0
- pz_settings_center/project_helpers.py +405 -0
- pz_settings_center/public.py +139 -0
- pz_settings_center/routing_helpers.py +73 -0
- pz_settings_center/runtime_override_provider.py +61 -0
- pz_settings_center/typed_settings.py +324 -0
- pz_settings_center/urls.py +9 -0
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
import tempfile
|
|
7
|
+
from collections.abc import Mapping
|
|
8
|
+
from dataclasses import dataclass
|
|
9
|
+
from pathlib import Path, PurePosixPath
|
|
10
|
+
from types import MappingProxyType
|
|
11
|
+
from typing import Literal, cast
|
|
12
|
+
|
|
13
|
+
from pz_core.project_sources import resolve_sources_manifest_path
|
|
14
|
+
from pz_core.runtime.errors import PzError
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
MANIFEST_SCHEMA_VERSION = 5
|
|
18
|
+
MANIFEST_ERROR_CODE = "PZ_DEV_MANIFEST_INVALID"
|
|
19
|
+
_OBJECT_KEY = re.compile(r"^[a-z][a-z0-9_]*$")
|
|
20
|
+
_JSON_IDENTIFIER = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
|
|
21
|
+
_TOP_LEVEL_FIELDS = ("schema_version", "business_app_id", "repos", "bindings")
|
|
22
|
+
_REPO_FIELDS = ("source", "checkout", "base_branch", "branch")
|
|
23
|
+
_BINDING_FIELDS = (
|
|
24
|
+
"kind",
|
|
25
|
+
"source_kind",
|
|
26
|
+
"repo_key",
|
|
27
|
+
"source",
|
|
28
|
+
"link",
|
|
29
|
+
"subpath",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True, slots=True)
|
|
34
|
+
class DevRepo:
|
|
35
|
+
source: str
|
|
36
|
+
checkout: PurePosixPath
|
|
37
|
+
base_branch: Literal["develop", "main"]
|
|
38
|
+
branch: str
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass(frozen=True, slots=True)
|
|
42
|
+
class DevBinding:
|
|
43
|
+
kind: Literal["directory", "app"]
|
|
44
|
+
source_kind: Literal["git", "link"]
|
|
45
|
+
repo_key: str | None
|
|
46
|
+
source: str
|
|
47
|
+
link: PurePosixPath
|
|
48
|
+
subpath: PurePosixPath
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass(frozen=True, slots=True)
|
|
52
|
+
class DevManifest:
|
|
53
|
+
schema_version: Literal[5]
|
|
54
|
+
business_app_id: str
|
|
55
|
+
repos: Mapping[str, DevRepo]
|
|
56
|
+
bindings: Mapping[str, DevBinding]
|
|
57
|
+
|
|
58
|
+
def __post_init__(self) -> None:
|
|
59
|
+
object.__setattr__(self, "repos", MappingProxyType(dict(self.repos)))
|
|
60
|
+
object.__setattr__(self, "bindings", MappingProxyType(dict(self.bindings)))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _json_child(path: str, key: str) -> str:
|
|
64
|
+
if _JSON_IDENTIFIER.fullmatch(key):
|
|
65
|
+
return f"{path}.{key}"
|
|
66
|
+
return f"{path}[{json.dumps(key, ensure_ascii=True)}]"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _invalid(path: str, reason: str, *, action: str) -> PzError:
|
|
70
|
+
return PzError(
|
|
71
|
+
code=MANIFEST_ERROR_CODE,
|
|
72
|
+
message=f"{path}: {reason}",
|
|
73
|
+
stage="dev",
|
|
74
|
+
owner="pz_core.authoring.dev_manifest",
|
|
75
|
+
action=action,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _require_object(
|
|
80
|
+
value: object,
|
|
81
|
+
path: str,
|
|
82
|
+
expected_fields: tuple[str, ...],
|
|
83
|
+
*,
|
|
84
|
+
action: str,
|
|
85
|
+
) -> dict[str, object]:
|
|
86
|
+
if not isinstance(value, dict) or not all(isinstance(key, str) for key in value):
|
|
87
|
+
raise _invalid(path, "expected an object", action=action)
|
|
88
|
+
expected = set(expected_fields)
|
|
89
|
+
unknown = sorted(set(value) - expected)
|
|
90
|
+
if unknown:
|
|
91
|
+
raise _invalid(_json_child(path, unknown[0]), "unknown field", action=action)
|
|
92
|
+
for field in expected_fields:
|
|
93
|
+
if field not in value:
|
|
94
|
+
raise _invalid(
|
|
95
|
+
_json_child(path, field), "required field is missing", action=action
|
|
96
|
+
)
|
|
97
|
+
return cast(dict[str, object], value)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _require_mapping(value: object, path: str, *, action: str) -> dict[str, object]:
|
|
101
|
+
if not isinstance(value, dict) or not all(isinstance(key, str) for key in value):
|
|
102
|
+
raise _invalid(path, "expected an object with string keys", action=action)
|
|
103
|
+
return cast(dict[str, object], value)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _require_nonempty_string(value: object, path: str, *, action: str) -> str:
|
|
107
|
+
if not isinstance(value, str) or not value.strip() or value != value.strip():
|
|
108
|
+
raise _invalid(path, "expected a non-empty normalized string", action=action)
|
|
109
|
+
if any(ord(character) < 0x20 for character in value):
|
|
110
|
+
raise _invalid(path, "control characters are not allowed", action=action)
|
|
111
|
+
return value
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _require_object_key(value: str, path: str, *, action: str) -> str:
|
|
115
|
+
if not _OBJECT_KEY.fullmatch(value):
|
|
116
|
+
raise _invalid(
|
|
117
|
+
path,
|
|
118
|
+
"expected lowercase letters, digits, and underscores starting with a letter",
|
|
119
|
+
action=action,
|
|
120
|
+
)
|
|
121
|
+
return value
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _require_posix_path(
|
|
125
|
+
value: object,
|
|
126
|
+
path: str,
|
|
127
|
+
*,
|
|
128
|
+
allow_dot: bool,
|
|
129
|
+
action: str,
|
|
130
|
+
) -> PurePosixPath:
|
|
131
|
+
raw = _require_nonempty_string(value, path, action=action)
|
|
132
|
+
if "\\" in raw:
|
|
133
|
+
raise _invalid(path, "expected POSIX separators", action=action)
|
|
134
|
+
candidate = PurePosixPath(raw)
|
|
135
|
+
if candidate.is_absolute() or ".." in candidate.parts:
|
|
136
|
+
raise _invalid(
|
|
137
|
+
path, "expected a project-relative path without traversal", action=action
|
|
138
|
+
)
|
|
139
|
+
if candidate == PurePosixPath("."):
|
|
140
|
+
if allow_dot and raw == ".":
|
|
141
|
+
return candidate
|
|
142
|
+
raise _invalid(path, "path must identify a project child", action=action)
|
|
143
|
+
if candidate.as_posix() != raw:
|
|
144
|
+
raise _invalid(path, "path must be normalized POSIX form", action=action)
|
|
145
|
+
return candidate
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def _parse_repo(key: str, raw: object, *, action: str) -> DevRepo:
|
|
149
|
+
path = _json_child("$.repos", key)
|
|
150
|
+
_require_object_key(key, path, action=action)
|
|
151
|
+
record = _require_object(raw, path, _REPO_FIELDS, action=action)
|
|
152
|
+
source = _require_nonempty_string(
|
|
153
|
+
record["source"], _json_child(path, "source"), action=action
|
|
154
|
+
)
|
|
155
|
+
checkout_path = _json_child(path, "checkout")
|
|
156
|
+
checkout = _require_posix_path(
|
|
157
|
+
record["checkout"], checkout_path, allow_dot=False, action=action
|
|
158
|
+
)
|
|
159
|
+
if checkout.parts[:2] != ("apps", ".sources") or len(checkout.parts) < 3:
|
|
160
|
+
raise _invalid(
|
|
161
|
+
checkout_path,
|
|
162
|
+
"checkout must be below apps/.sources",
|
|
163
|
+
action=action,
|
|
164
|
+
)
|
|
165
|
+
base_branch = record["base_branch"]
|
|
166
|
+
if base_branch not in {"develop", "main"}:
|
|
167
|
+
raise _invalid(
|
|
168
|
+
_json_child(path, "base_branch"),
|
|
169
|
+
"expected 'develop' or 'main'",
|
|
170
|
+
action=action,
|
|
171
|
+
)
|
|
172
|
+
branch = _require_nonempty_string(
|
|
173
|
+
record["branch"], _json_child(path, "branch"), action=action
|
|
174
|
+
)
|
|
175
|
+
return DevRepo(
|
|
176
|
+
source=source,
|
|
177
|
+
checkout=checkout,
|
|
178
|
+
base_branch=cast(Literal["develop", "main"], base_branch),
|
|
179
|
+
branch=branch,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def _parse_binding(key: str, raw: object, *, action: str) -> DevBinding:
|
|
184
|
+
path = _json_child("$.bindings", key)
|
|
185
|
+
_require_object_key(key, path, action=action)
|
|
186
|
+
record = _require_object(raw, path, _BINDING_FIELDS, action=action)
|
|
187
|
+
kind = record["kind"]
|
|
188
|
+
if kind not in {"directory", "app"}:
|
|
189
|
+
raise _invalid(
|
|
190
|
+
_json_child(path, "kind"),
|
|
191
|
+
"expected 'directory' or 'app'",
|
|
192
|
+
action=action,
|
|
193
|
+
)
|
|
194
|
+
source_kind = record["source_kind"]
|
|
195
|
+
if source_kind not in {"git", "link"}:
|
|
196
|
+
raise _invalid(
|
|
197
|
+
_json_child(path, "source_kind"),
|
|
198
|
+
"expected 'git' or 'link'",
|
|
199
|
+
action=action,
|
|
200
|
+
)
|
|
201
|
+
repo_key = record["repo_key"]
|
|
202
|
+
if repo_key is not None and not isinstance(repo_key, str):
|
|
203
|
+
raise _invalid(
|
|
204
|
+
_json_child(path, "repo_key"),
|
|
205
|
+
"expected a repo key or null",
|
|
206
|
+
action=action,
|
|
207
|
+
)
|
|
208
|
+
source = _require_nonempty_string(
|
|
209
|
+
record["source"], _json_child(path, "source"), action=action
|
|
210
|
+
)
|
|
211
|
+
link_path = _json_child(path, "link")
|
|
212
|
+
link = _require_posix_path(
|
|
213
|
+
record["link"], link_path, allow_dot=False, action=action
|
|
214
|
+
)
|
|
215
|
+
if link.parts[0] != "apps" or len(link.parts) < 2:
|
|
216
|
+
raise _invalid(link_path, "link must be below apps", action=action)
|
|
217
|
+
if link.parts[:2] == ("apps", ".sources"):
|
|
218
|
+
raise _invalid(
|
|
219
|
+
link_path,
|
|
220
|
+
"link cannot occupy the physical source checkout tree",
|
|
221
|
+
action=action,
|
|
222
|
+
)
|
|
223
|
+
subpath = _require_posix_path(
|
|
224
|
+
record["subpath"],
|
|
225
|
+
_json_child(path, "subpath"),
|
|
226
|
+
allow_dot=True,
|
|
227
|
+
action=action,
|
|
228
|
+
)
|
|
229
|
+
return DevBinding(
|
|
230
|
+
kind=cast(Literal["directory", "app"], kind),
|
|
231
|
+
source_kind=cast(Literal["git", "link"], source_kind),
|
|
232
|
+
repo_key=repo_key,
|
|
233
|
+
source=source,
|
|
234
|
+
link=link,
|
|
235
|
+
subpath=subpath,
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def _paths_overlap(first: PurePosixPath, second: PurePosixPath) -> bool:
|
|
240
|
+
return first == second or first in second.parents or second in first.parents
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _absolute_paths_overlap(first: Path, second: Path) -> bool:
|
|
244
|
+
return first == second or first in second.parents or second in first.parents
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def _binding_source_path(
|
|
248
|
+
project_dir: Path,
|
|
249
|
+
binding: DevBinding,
|
|
250
|
+
repos: Mapping[str, DevRepo],
|
|
251
|
+
) -> Path:
|
|
252
|
+
if binding.source_kind == "git":
|
|
253
|
+
assert binding.repo_key is not None
|
|
254
|
+
base = project_dir / Path(*repos[binding.repo_key].checkout.parts)
|
|
255
|
+
else:
|
|
256
|
+
base = Path(binding.source)
|
|
257
|
+
if binding.subpath == PurePosixPath("."):
|
|
258
|
+
return base.resolve(strict=False)
|
|
259
|
+
return (base / Path(*binding.subpath.parts)).resolve(strict=False)
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def _validate_normalized_manifest(
|
|
263
|
+
project_dir: Path,
|
|
264
|
+
manifest: DevManifest,
|
|
265
|
+
*,
|
|
266
|
+
action: str,
|
|
267
|
+
) -> None:
|
|
268
|
+
project_root = project_dir.expanduser().resolve(strict=False)
|
|
269
|
+
repos = manifest.repos
|
|
270
|
+
bindings = manifest.bindings
|
|
271
|
+
|
|
272
|
+
ordered_repos = sorted(repos.items())
|
|
273
|
+
for index, (repo_key, repo) in enumerate(ordered_repos):
|
|
274
|
+
repo_path = _json_child("$.repos", repo_key)
|
|
275
|
+
expected_checkout = PurePosixPath("apps/.sources") / repo_key
|
|
276
|
+
if repo.checkout != expected_checkout:
|
|
277
|
+
raise _invalid(
|
|
278
|
+
_json_child(repo_path, "checkout"),
|
|
279
|
+
f"checkout must be {expected_checkout.as_posix()!r}",
|
|
280
|
+
action=action,
|
|
281
|
+
)
|
|
282
|
+
if repo.branch != manifest.business_app_id:
|
|
283
|
+
raise _invalid(
|
|
284
|
+
_json_child(repo_path, "branch"),
|
|
285
|
+
"branch must equal the manifest business_app_id",
|
|
286
|
+
action=action,
|
|
287
|
+
)
|
|
288
|
+
for previous_key, previous in ordered_repos[:index]:
|
|
289
|
+
if _paths_overlap(repo.checkout, previous.checkout):
|
|
290
|
+
raise _invalid(
|
|
291
|
+
_json_child(repo_path, "checkout"),
|
|
292
|
+
f"checkout overlaps repo {previous_key!r}",
|
|
293
|
+
action=action,
|
|
294
|
+
)
|
|
295
|
+
if repo.source == previous.source:
|
|
296
|
+
raise _invalid(
|
|
297
|
+
_json_child(repo_path, "source"),
|
|
298
|
+
f"source duplicates repo {previous_key!r}",
|
|
299
|
+
action=action,
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
ordered_bindings = sorted(bindings.items())
|
|
303
|
+
for index, (binding_key, binding) in enumerate(ordered_bindings):
|
|
304
|
+
binding_path = _json_child("$.bindings", binding_key)
|
|
305
|
+
if binding.source_kind == "git":
|
|
306
|
+
if not binding.repo_key:
|
|
307
|
+
raise _invalid(
|
|
308
|
+
_json_child(binding_path, "repo_key"),
|
|
309
|
+
"git binding requires a repo key",
|
|
310
|
+
action=action,
|
|
311
|
+
)
|
|
312
|
+
resolved_repo = repos.get(binding.repo_key)
|
|
313
|
+
if resolved_repo is None:
|
|
314
|
+
raise _invalid(
|
|
315
|
+
_json_child(binding_path, "repo_key"),
|
|
316
|
+
"binding references an unknown repo",
|
|
317
|
+
action=action,
|
|
318
|
+
)
|
|
319
|
+
if binding.source != resolved_repo.source:
|
|
320
|
+
raise _invalid(
|
|
321
|
+
_json_child(binding_path, "source"),
|
|
322
|
+
"git binding source must match its repo source",
|
|
323
|
+
action=action,
|
|
324
|
+
)
|
|
325
|
+
else:
|
|
326
|
+
if binding.repo_key is not None:
|
|
327
|
+
raise _invalid(
|
|
328
|
+
_json_child(binding_path, "repo_key"),
|
|
329
|
+
"direct-link binding requires a null repo key",
|
|
330
|
+
action=action,
|
|
331
|
+
)
|
|
332
|
+
source = Path(binding.source).expanduser()
|
|
333
|
+
if not source.is_absolute() or source.resolve(strict=False) != source:
|
|
334
|
+
raise _invalid(
|
|
335
|
+
_json_child(binding_path, "source"),
|
|
336
|
+
"direct-link source must be an absolute canonical path",
|
|
337
|
+
action=action,
|
|
338
|
+
)
|
|
339
|
+
for repo_key, repo in ordered_repos:
|
|
340
|
+
checkout = (project_root / Path(*repo.checkout.parts)).resolve(
|
|
341
|
+
strict=False
|
|
342
|
+
)
|
|
343
|
+
if _absolute_paths_overlap(source, checkout):
|
|
344
|
+
raise _invalid(
|
|
345
|
+
_json_child(binding_path, "source"),
|
|
346
|
+
f"direct-link source overlaps repo {repo_key!r}",
|
|
347
|
+
action=action,
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
source_path = _binding_source_path(project_root, binding, repos)
|
|
351
|
+
for previous_key, previous_binding in ordered_bindings[:index]:
|
|
352
|
+
previous_path = _json_child("$.bindings", previous_key)
|
|
353
|
+
if _paths_overlap(binding.link, previous_binding.link):
|
|
354
|
+
raise _invalid(
|
|
355
|
+
_json_child(binding_path, "link"),
|
|
356
|
+
f"link overlaps {previous_path}",
|
|
357
|
+
action=action,
|
|
358
|
+
)
|
|
359
|
+
previous_source = _binding_source_path(
|
|
360
|
+
project_root, previous_binding, repos
|
|
361
|
+
)
|
|
362
|
+
if _absolute_paths_overlap(source_path, previous_source):
|
|
363
|
+
raise _invalid(
|
|
364
|
+
_json_child(binding_path, "subpath"),
|
|
365
|
+
f"source overlaps {previous_path}",
|
|
366
|
+
action=action,
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def _parse_manifest(
|
|
371
|
+
project_dir: Path,
|
|
372
|
+
raw: object,
|
|
373
|
+
*,
|
|
374
|
+
action: str,
|
|
375
|
+
) -> DevManifest:
|
|
376
|
+
payload = _require_object(raw, "$", _TOP_LEVEL_FIELDS, action=action)
|
|
377
|
+
if type(payload["schema_version"]) is not int or payload["schema_version"] != 5:
|
|
378
|
+
raise _invalid("$.schema_version", "expected schema version 5", action=action)
|
|
379
|
+
business_app_id = _require_nonempty_string(
|
|
380
|
+
payload["business_app_id"], "$.business_app_id", action=action
|
|
381
|
+
)
|
|
382
|
+
_require_object_key(business_app_id, "$.business_app_id", action=action)
|
|
383
|
+
raw_repos = _require_mapping(payload["repos"], "$.repos", action=action)
|
|
384
|
+
raw_bindings = _require_mapping(payload["bindings"], "$.bindings", action=action)
|
|
385
|
+
repos = {
|
|
386
|
+
key: _parse_repo(key, value, action=action) for key, value in raw_repos.items()
|
|
387
|
+
}
|
|
388
|
+
bindings = {
|
|
389
|
+
key: _parse_binding(key, value, action=action)
|
|
390
|
+
for key, value in raw_bindings.items()
|
|
391
|
+
}
|
|
392
|
+
manifest = DevManifest(
|
|
393
|
+
schema_version=5,
|
|
394
|
+
business_app_id=business_app_id,
|
|
395
|
+
repos=repos,
|
|
396
|
+
bindings=bindings,
|
|
397
|
+
)
|
|
398
|
+
_validate_normalized_manifest(project_dir, manifest, action=action)
|
|
399
|
+
return manifest
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
def _manifest_payload(manifest: DevManifest, *, action: str) -> dict[str, object]:
|
|
403
|
+
if not isinstance(manifest, DevManifest):
|
|
404
|
+
raise _invalid("$", "expected a DevManifest", action=action)
|
|
405
|
+
repos: dict[str, object] = {}
|
|
406
|
+
for key, repo in manifest.repos.items():
|
|
407
|
+
path = _json_child("$.repos", str(key))
|
|
408
|
+
if not isinstance(key, str) or not isinstance(repo, DevRepo):
|
|
409
|
+
raise _invalid(path, "expected a DevRepo", action=action)
|
|
410
|
+
if not isinstance(repo.checkout, PurePosixPath):
|
|
411
|
+
raise _invalid(
|
|
412
|
+
_json_child(path, "checkout"),
|
|
413
|
+
"expected a PurePosixPath",
|
|
414
|
+
action=action,
|
|
415
|
+
)
|
|
416
|
+
repos[key] = {
|
|
417
|
+
"source": repo.source,
|
|
418
|
+
"checkout": repo.checkout.as_posix(),
|
|
419
|
+
"base_branch": repo.base_branch,
|
|
420
|
+
"branch": repo.branch,
|
|
421
|
+
}
|
|
422
|
+
bindings: dict[str, object] = {}
|
|
423
|
+
for key, binding in manifest.bindings.items():
|
|
424
|
+
path = _json_child("$.bindings", str(key))
|
|
425
|
+
if not isinstance(key, str) or not isinstance(binding, DevBinding):
|
|
426
|
+
raise _invalid(path, "expected a DevBinding", action=action)
|
|
427
|
+
if not isinstance(binding.link, PurePosixPath):
|
|
428
|
+
raise _invalid(
|
|
429
|
+
_json_child(path, "link"),
|
|
430
|
+
"expected a PurePosixPath",
|
|
431
|
+
action=action,
|
|
432
|
+
)
|
|
433
|
+
if not isinstance(binding.subpath, PurePosixPath):
|
|
434
|
+
raise _invalid(
|
|
435
|
+
_json_child(path, "subpath"),
|
|
436
|
+
"expected a PurePosixPath",
|
|
437
|
+
action=action,
|
|
438
|
+
)
|
|
439
|
+
bindings[key] = {
|
|
440
|
+
"kind": binding.kind,
|
|
441
|
+
"source_kind": binding.source_kind,
|
|
442
|
+
"repo_key": binding.repo_key,
|
|
443
|
+
"source": binding.source,
|
|
444
|
+
"link": binding.link.as_posix(),
|
|
445
|
+
"subpath": binding.subpath.as_posix(),
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
"schema_version": manifest.schema_version,
|
|
449
|
+
"business_app_id": manifest.business_app_id,
|
|
450
|
+
"repos": repos,
|
|
451
|
+
"bindings": bindings,
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
def validate_dev_manifest(project_dir: Path, manifest: DevManifest) -> DevManifest:
|
|
456
|
+
payload = _manifest_payload(manifest, action="validate_dev_manifest")
|
|
457
|
+
_parse_manifest(project_dir, payload, action="validate_dev_manifest")
|
|
458
|
+
return manifest
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
def manifest_bytes(manifest: DevManifest) -> bytes:
|
|
462
|
+
payload = _manifest_payload(manifest, action="manifest_bytes")
|
|
463
|
+
return (
|
|
464
|
+
json.dumps(payload, ensure_ascii=True, indent=2, sort_keys=True) + "\n"
|
|
465
|
+
).encode("utf-8")
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
def load_dev_manifest(project_dir: Path) -> DevManifest | None:
|
|
469
|
+
path = resolve_sources_manifest_path(project_dir)
|
|
470
|
+
if not path.exists():
|
|
471
|
+
return None
|
|
472
|
+
if not path.is_file():
|
|
473
|
+
raise _invalid("$", "manifest path is not a file", action="load_dev_manifest")
|
|
474
|
+
try:
|
|
475
|
+
raw = json.loads(path.read_text(encoding="utf-8"))
|
|
476
|
+
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
|
477
|
+
raise _invalid(
|
|
478
|
+
"$", f"cannot parse manifest JSON: {exc}", action="load_dev_manifest"
|
|
479
|
+
) from exc
|
|
480
|
+
return _parse_manifest(project_dir, raw, action="load_dev_manifest")
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
def save_dev_manifest(project_dir: Path, manifest: DevManifest) -> None:
|
|
484
|
+
validate_dev_manifest(project_dir, manifest)
|
|
485
|
+
encoded = manifest_bytes(manifest)
|
|
486
|
+
path = resolve_sources_manifest_path(project_dir)
|
|
487
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
488
|
+
descriptor, temporary_name = tempfile.mkstemp(
|
|
489
|
+
dir=path.parent,
|
|
490
|
+
prefix=f".{path.name}.",
|
|
491
|
+
suffix=".tmp",
|
|
492
|
+
)
|
|
493
|
+
temporary = Path(temporary_name)
|
|
494
|
+
try:
|
|
495
|
+
with os.fdopen(descriptor, "wb") as handle:
|
|
496
|
+
handle.write(encoded)
|
|
497
|
+
handle.flush()
|
|
498
|
+
os.fsync(handle.fileno())
|
|
499
|
+
os.replace(temporary, path)
|
|
500
|
+
directory_descriptor = os.open(
|
|
501
|
+
path.parent,
|
|
502
|
+
os.O_RDONLY | getattr(os, "O_DIRECTORY", 0),
|
|
503
|
+
)
|
|
504
|
+
try:
|
|
505
|
+
os.fsync(directory_descriptor)
|
|
506
|
+
finally:
|
|
507
|
+
os.close(directory_descriptor)
|
|
508
|
+
finally:
|
|
509
|
+
temporary.unlink(missing_ok=True)
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
__all__ = [
|
|
513
|
+
"DevBinding",
|
|
514
|
+
"DevManifest",
|
|
515
|
+
"DevRepo",
|
|
516
|
+
"MANIFEST_ERROR_CODE",
|
|
517
|
+
"MANIFEST_SCHEMA_VERSION",
|
|
518
|
+
"load_dev_manifest",
|
|
519
|
+
"manifest_bytes",
|
|
520
|
+
"save_dev_manifest",
|
|
521
|
+
"validate_dev_manifest",
|
|
522
|
+
]
|