symphony-forge 1.2.44__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.
- forge/__init__.py +4 -0
- forge/app_baseline.py +148 -0
- forge/approval.py +298 -0
- forge/autoreview.py +139 -0
- forge/backfill.py +298 -0
- forge/board.py +1197 -0
- forge/board_app/app.js +276 -0
- forge/board_app/assign.css +91 -0
- forge/board_app/assign.js +157 -0
- forge/board_app/insights.js +80 -0
- forge/board_app/item.css +380 -0
- forge/board_app/item.js +594 -0
- forge/board_app/markdown.js +110 -0
- forge/board_app/now.css +417 -0
- forge/board_app/now.js +248 -0
- forge/board_app/pages.css +178 -0
- forge/board_app/releases.js +203 -0
- forge/board_app/shell.html +31 -0
- forge/board_app/tokens.css +220 -0
- forge/board_facts.py +696 -0
- forge/board_graph.py +38 -0
- forge/board_server.py +431 -0
- forge/board_trends.py +105 -0
- forge/box.py +54 -0
- forge/box_ssh.py +209 -0
- forge/checks.py +743 -0
- forge/citime.py +259 -0
- forge/claude_sdk.py +56 -0
- forge/claude_turn.py +62 -0
- forge/cli.py +185 -0
- forge/close.py +1193 -0
- forge/close_remote.py +85 -0
- forge/codex.py +1200 -0
- forge/codex_turn.py +346 -0
- forge/deny.py +253 -0
- forge/design.py +201 -0
- forge/design_skills.py +16 -0
- forge/docskip.py +175 -0
- forge/doctor.py +578 -0
- forge/event_log.py +128 -0
- forge/fasttest.py +846 -0
- forge/feature.py +318 -0
- forge/feature_api.py +593 -0
- forge/feature_python.py +1107 -0
- forge/feature_python_contracts.py +268 -0
- forge/feature_python_tests.py +1134 -0
- forge/feature_python_tools.py +81 -0
- forge/feature_remove.py +189 -0
- forge/feature_schema.py +156 -0
- forge/feature_tests.py +1062 -0
- forge/fullrun.py +166 -0
- forge/gaps.py +109 -0
- forge/githooks.py +251 -0
- forge/github.py +191 -0
- forge/init.py +494 -0
- forge/intake.py +226 -0
- forge/journey.py +126 -0
- forge/known_issues.py +165 -0
- forge/land.py +882 -0
- forge/machine.py +821 -0
- forge/merge.py +530 -0
- forge/merge_review.py +84 -0
- forge/merge_timings.py +46 -0
- forge/migrate.py +673 -0
- forge/migration_warnings.py +108 -0
- forge/mod/.claude-plugin/plugin.json +20 -0
- forge/mod/hooks/hooks.json +3 -0
- forge/mod/hooks/pane.test.ts +608 -0
- forge/mod/hooks/register.ts +413 -0
- forge/mod/tsconfig.json +18 -0
- forge/native.py +306 -0
- forge/nextstep.py +1184 -0
- forge/node_workers.cjs +26 -0
- forge/noise.py +40 -0
- forge/open_decisions.py +205 -0
- forge/owner_choices.py +167 -0
- forge/payback.py +97 -0
- forge/plain_english.py +20 -0
- forge/plan_scope.py +76 -0
- forge/prcheck.py +640 -0
- forge/quicktest.py +198 -0
- forge/records.py +912 -0
- forge/releases.py +100 -0
- forge/repo.py +1154 -0
- forge/review.py +1199 -0
- forge/review_process.py +86 -0
- forge/review_skip.py +116 -0
- forge/roles.py +141 -0
- forge/round_limits.py +7 -0
- forge/score.py +192 -0
- forge/spotted.py +271 -0
- forge/standards.md +318 -0
- forge/story.py +1200 -0
- forge/sync.py +783 -0
- forge/task.py +1082 -0
- forge/templates/adapters/AGENTS.md +98 -0
- forge/templates/brief.md +834 -0
- forge/templates/cold-read.md +324 -0
- forge/templates/conventions/api.md +144 -0
- forge/templates/conventions/backend.md +171 -0
- forge/templates/conventions/database.md +81 -0
- forge/templates/conventions/demo-data.md +61 -0
- forge/templates/conventions/deploy.md +114 -0
- forge/templates/conventions/frontend.md +187 -0
- forge/templates/conventions/python.md +336 -0
- forge/templates/conventions/security.md +44 -0
- forge/templates/conventions/stack.md +96 -0
- forge/templates/conventions/testing.md +165 -0
- forge/templates/delegation.md +3 -0
- forge/templates/design/render-check.d.mts +25 -0
- forge/templates/design/render-check.mjs +113 -0
- forge/templates/design/support.js +159 -0
- forge/templates/design/ui-checks.js +111 -0
- forge/templates/fde.md +218 -0
- forge/templates/feature/kinds.toml +140 -0
- forge/templates/handover.md +26 -0
- forge/templates/migrate-skill.md +87 -0
- forge/templates/records-only-action.yml +16 -0
- forge/templates/review-light.md +48 -0
- forge/templates/review-tests.py +200 -0
- forge/templates/review.md +661 -0
- forge/templates/run-reference.md +328 -0
- forge/templates/skeleton/.dockerignore +18 -0
- forge/templates/skeleton/Dockerfile +10 -0
- forge/templates/skeleton/docs/decisions/README.md +13 -0
- forge/templates/skeleton/docs/product/BRIEF.md +47 -0
- forge/templates/skeleton/docs/product/DISCOVERY.md +46 -0
- forge/templates/skeleton/docs/specs/README.md +41 -0
- forge/templates/skeleton/services.toml +6 -0
- forge/templates/skill.md +2753 -0
- forge/templates/skills/agents/SKILL.md +446 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/README.md +131 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/__init__.py +5 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/chats.py +60 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/cleanup.py +91 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/app/assistant/models.py +57 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/migrations/versions/20261106_assistant.py +90 -0
- forge/templates/skills/agents/assistant-module/python/apps/api/tests/test_assistant_chats.py +173 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/prisma/migrations/20261106000000_assistant/migration.sql +17 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/prisma/schema/assistant.prisma +19 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/test/assistant-api.e2e-spec.ts +185 -0
- forge/templates/skills/agents/assistant-module/typescript/apps/api/test/assistant-chats.e2e-spec.ts +75 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/README.md +107 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/package.json +10 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/src/index.ts +66 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/contracts/tsconfig.json +12 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/package.json +23 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.chats.controller.ts +54 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.chats.service.ts +140 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.cleanup.ts +34 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/assistant.module.ts +20 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/src/index.ts +3 -0
- forge/templates/skills/agents/assistant-module/typescript/libs/assistant/server/tsconfig.json +15 -0
- forge/templates/skills/app-baseline/SKILL.md +241 -0
- forge/templates/skills/database/SKILL.md +155 -0
- forge/templates/skills/emil-design-eng/FORGE-NOTICE.md +9 -0
- forge/templates/skills/emil-design-eng/LICENSE +21 -0
- forge/templates/skills/emil-design-eng/SKILL.md +674 -0
- forge/templates/skills/impeccable/FORGE-NOTICE.md +10 -0
- forge/templates/skills/impeccable/LICENSE +191 -0
- forge/templates/skills/impeccable/NOTICE.md +11 -0
- forge/templates/skills/impeccable/SKILL.md +88 -0
- forge/templates/skills/impeccable/reference/adapt.md +318 -0
- forge/templates/skills/impeccable/reference/adapt.native.md +58 -0
- forge/templates/skills/impeccable/reference/android.md +46 -0
- forge/templates/skills/impeccable/reference/animate.md +89 -0
- forge/templates/skills/impeccable/reference/audit.md +139 -0
- forge/templates/skills/impeccable/reference/audit.native.md +139 -0
- forge/templates/skills/impeccable/reference/bolder.md +33 -0
- forge/templates/skills/impeccable/reference/clarify.md +94 -0
- forge/templates/skills/impeccable/reference/colorize.md +86 -0
- forge/templates/skills/impeccable/reference/component-review.md +63 -0
- forge/templates/skills/impeccable/reference/craft-floor.md +44 -0
- forge/templates/skills/impeccable/reference/craft.md +5 -0
- forge/templates/skills/impeccable/reference/critique.md +819 -0
- forge/templates/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- forge/templates/skills/impeccable/reference/degraded/documenter.md +24 -0
- forge/templates/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- forge/templates/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -0
- forge/templates/skills/impeccable/reference/delight.md +70 -0
- forge/templates/skills/impeccable/reference/distill.md +111 -0
- forge/templates/skills/impeccable/reference/doctor.md +54 -0
- forge/templates/skills/impeccable/reference/document.md +416 -0
- forge/templates/skills/impeccable/reference/extract.md +69 -0
- forge/templates/skills/impeccable/reference/generate.md +101 -0
- forge/templates/skills/impeccable/reference/harden.md +362 -0
- forge/templates/skills/impeccable/reference/hooks.md +114 -0
- forge/templates/skills/impeccable/reference/init.md +131 -0
- forge/templates/skills/impeccable/reference/ios.md +51 -0
- forge/templates/skills/impeccable/reference/layout.md +84 -0
- forge/templates/skills/impeccable/reference/live-setup.md +104 -0
- forge/templates/skills/impeccable/reference/live.md +325 -0
- forge/templates/skills/impeccable/reference/mode-operate.md +21 -0
- forge/templates/skills/impeccable/reference/mode-persuade.md +19 -0
- forge/templates/skills/impeccable/reference/mode-read.md +21 -0
- forge/templates/skills/impeccable/reference/new-work.md +154 -0
- forge/templates/skills/impeccable/reference/onboard.md +234 -0
- forge/templates/skills/impeccable/reference/operate.md +61 -0
- forge/templates/skills/impeccable/reference/optimize.md +257 -0
- forge/templates/skills/impeccable/reference/overdrive.md +127 -0
- forge/templates/skills/impeccable/reference/polish.md +105 -0
- forge/templates/skills/impeccable/reference/quieter.md +99 -0
- forge/templates/skills/impeccable/reference/region-map.md +26 -0
- forge/templates/skills/impeccable/reference/routing.md +24 -0
- forge/templates/skills/impeccable/reference/shape.md +59 -0
- forge/templates/skills/impeccable/reference/typeset.md +90 -0
- forge/templates/skills/impeccable/reference/visualize.md +47 -0
- forge/templates/skills/impeccable/scripts/VERSION +1 -0
- forge/templates/skills/impeccable/scripts/command-metadata.json +98 -0
- forge/templates/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- forge/templates/skills/impeccable/scripts/data/font-index.json +1 -0
- forge/templates/skills/impeccable/scripts/engine-checksums.txt +9 -0
- forge/templates/skills/impeccable/scripts/impeccable +249 -0
- forge/templates/skills/impeccable/scripts/impeccable.cmd +278 -0
- forge/templates/skills/impeccable/scripts/live-browser-dom.js +321 -0
- forge/templates/skills/impeccable/scripts/live-browser-ignores.js +247 -0
- forge/templates/skills/impeccable/scripts/live-browser-session.js +184 -0
- forge/templates/skills/impeccable/scripts/live-browser.js +13646 -0
- forge/templates/skills/impeccable/scripts/modern-screenshot.umd.js +15 -0
- forge/templates/skills/remote-approval/SKILL.md +40 -0
- forge/templates/skills/security-audit/AI-AND-LLM.md +83 -0
- forge/templates/skills/security-audit/ATTACK-CLASSES.md +130 -0
- forge/templates/skills/security-audit/CLIENT-SIDE.md +83 -0
- forge/templates/skills/security-audit/CLOUD-AND-DEPLOYMENT.md +86 -0
- forge/templates/skills/security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -0
- forge/templates/skills/security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -0
- forge/templates/skills/security-audit/HUNTING.md +251 -0
- forge/templates/skills/security-audit/LICENSE +21 -0
- forge/templates/skills/security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -0
- forge/templates/skills/security-audit/NOTICE.md +6 -0
- forge/templates/skills/security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -0
- forge/templates/skills/security-audit/RECONNAISSANCE.md +156 -0
- forge/templates/skills/security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -0
- forge/templates/skills/security-audit/SKILL.md +192 -0
- forge/templates/skills/security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -0
- forge/templates/skills/security-audit/VALIDATION-AND-REPORTING.md +186 -0
- forge/templates/skills/security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -0
- forge/templates/skills/security-audit/report-schema.json +461 -0
- forge/templates/skills/security-audit/validate-coverage-ledger.cjs +873 -0
- forge/templates/skills/security-audit/validate-findings.cjs +774 -0
- forge/templates/skills/simplified-technical-english/LICENSE +28 -0
- forge/templates/skills/simplified-technical-english/NOTICE.md +33 -0
- forge/templates/skills/simplified-technical-english/SKILL.md +127 -0
- forge/templates/skills/simplified-technical-english/examples/before-after.md +86 -0
- forge/templates/skills/simplified-technical-english/references/substitutions.md +113 -0
- forge/templates/skills/simplified-technical-english/references/writing-rules.md +209 -0
- forge/templates/skills/simplified-technical-english/scripts/ste_check.py +301 -0
- forge/templates/skills/test-audit/NOTICE.md +25 -0
- forge/templates/skills/test-audit/SKILL.md +182 -0
- forge/templates/start.md +27 -0
- forge/templates/starter/.env.example +14 -0
- forge/templates/starter/.gitignore +7 -0
- forge/templates/starter/.npmrc +1 -0
- forge/templates/starter/Dockerfile +23 -0
- forge/templates/starter/README.md +121 -0
- forge/templates/starter/apps/api/package.json +15 -0
- forge/templates/starter/apps/api/prisma/migrations/20261022000000_initial/migration.sql +68 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000000_organisations/migration.sql +44 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000100_invites/migration.sql +18 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000200_history/migration.sql +13 -0
- forge/templates/starter/apps/api/prisma/migrations/20261025000300_soft_delete_only/migration.sql +10 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000000_extensions/migration.sql +3 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000100_ids_and_updated_at/migration.sql +31 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000150_module_schemas/migration.sql +19 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000200_columns/migration.sql +51 -0
- forge/templates/starter/apps/api/prisma/migrations/20261026000300_history_subjects/migration.sql +11 -0
- forge/templates/starter/apps/api/prisma/migrations/20261027000000_agents/migration.sql +12 -0
- forge/templates/starter/apps/api/prisma/migrations/20261027000100_mcp/migration.sql +20 -0
- forge/templates/starter/apps/api/prisma/migrations/20261028000000_via_agent/migration.sql +7 -0
- forge/templates/starter/apps/api/prisma/migrations/20261102000000_sign_in_attempts/migration.sql +13 -0
- forge/templates/starter/apps/api/prisma/migrations/20261104000000_notifications/migration.sql +23 -0
- forge/templates/starter/apps/api/prisma/migrations/migration_lock.toml +1 -0
- forge/templates/starter/apps/api/prisma/schema/auth.prisma +65 -0
- forge/templates/starter/apps/api/prisma/schema/base.prisma +9 -0
- forge/templates/starter/apps/api/prisma/schema/history.prisma +19 -0
- forge/templates/starter/apps/api/prisma/schema/mcp.prisma +18 -0
- forge/templates/starter/apps/api/prisma/schema/notifications.prisma +20 -0
- forge/templates/starter/apps/api/prisma/schema/organisations.prisma +66 -0
- forge/templates/starter/apps/api/prisma/schema/projects.prisma +23 -0
- forge/templates/starter/apps/api/project.json +35 -0
- forge/templates/starter/apps/api/src/app.module.ts +36 -0
- forge/templates/starter/apps/api/src/health/health.controller.ts +16 -0
- forge/templates/starter/apps/api/src/health/health.module.ts +5 -0
- forge/templates/starter/apps/api/src/main.ts +44 -0
- forge/templates/starter/apps/api/src/setup-company.ts +33 -0
- forge/templates/starter/apps/api/test/agents.e2e-spec.ts +99 -0
- forge/templates/starter/apps/api/test/api.e2e-spec.ts +250 -0
- forge/templates/starter/apps/api/test/auth.e2e-spec.ts +287 -0
- forge/templates/starter/apps/api/test/database.e2e-spec.ts +171 -0
- forge/templates/starter/apps/api/test/environment.e2e-spec.ts +56 -0
- forge/templates/starter/apps/api/test/error-reports.e2e-spec.ts +72 -0
- forge/templates/starter/apps/api/test/exports.e2e-spec.ts +85 -0
- forge/templates/starter/apps/api/test/helpers.ts +103 -0
- forge/templates/starter/apps/api/test/history.e2e-spec.ts +93 -0
- forge/templates/starter/apps/api/test/invites.e2e-spec.ts +262 -0
- forge/templates/starter/apps/api/test/mcp.e2e-spec.ts +269 -0
- forge/templates/starter/apps/api/test/notifications.e2e-spec.ts +117 -0
- forge/templates/starter/apps/api/test/one-company.e2e-spec.ts +154 -0
- forge/templates/starter/apps/api/test/organisations.e2e-spec.ts +210 -0
- forge/templates/starter/apps/api/test/projects.e2e-spec.ts +824 -0
- forge/templates/starter/apps/api/test/soft-delete.e2e-spec.ts +31 -0
- forge/templates/starter/apps/api/tsconfig.json +44 -0
- forge/templates/starter/apps/api/tsconfig.test.json +17 -0
- forge/templates/starter/apps/api/vitest.config.ts +13 -0
- forge/templates/starter/apps/web/e2e/motion.spec.ts +88 -0
- forge/templates/starter/apps/web/e2e/rules/accept-invite.spec.ts +59 -0
- forge/templates/starter/apps/web/e2e/rules/members.spec.ts +212 -0
- forge/templates/starter/apps/web/e2e/rules/reset-password.spec.ts +78 -0
- forge/templates/starter/apps/web/e2e/rules/sign-in.spec.ts +87 -0
- forge/templates/starter/apps/web/e2e/served-app.spec.ts +19 -0
- forge/templates/starter/apps/web/index.html +14 -0
- forge/templates/starter/apps/web/package.json +9 -0
- forge/templates/starter/apps/web/playwright.config.ts +21 -0
- forge/templates/starter/apps/web/project.json +36 -0
- forge/templates/starter/apps/web/src/index.css +166 -0
- forge/templates/starter/apps/web/src/main.tsx +14 -0
- forge/templates/starter/apps/web/src/shared-states.test.tsx +40 -0
- forge/templates/starter/apps/web/tsconfig.json +30 -0
- forge/templates/starter/apps/web/vite.config.ts +19 -0
- forge/templates/starter/apps/web/vitest.config.ts +23 -0
- forge/templates/starter/apps/web/vitest.setup.ts +5 -0
- forge/templates/starter/compose.test.yml +66 -0
- forge/templates/starter/eslint.config.mjs +56 -0
- forge/templates/starter/libs/auth/contracts/package.json +17 -0
- forge/templates/starter/libs/auth/contracts/project.json +15 -0
- forge/templates/starter/libs/auth/contracts/src/index.ts +56 -0
- forge/templates/starter/libs/auth/contracts/tsconfig.json +18 -0
- forge/templates/starter/libs/auth/server/package.json +19 -0
- forge/templates/starter/libs/auth/server/project.json +15 -0
- forge/templates/starter/libs/auth/server/src/agents.controller.ts +24 -0
- forge/templates/starter/libs/auth/server/src/auth.controller.ts +136 -0
- forge/templates/starter/libs/auth/server/src/auth.dto.ts +53 -0
- forge/templates/starter/libs/auth/server/src/auth.module.ts +18 -0
- forge/templates/starter/libs/auth/server/src/auth.service.ts +251 -0
- forge/templates/starter/libs/auth/server/src/index.ts +3 -0
- forge/templates/starter/libs/auth/server/src/invites.controller.ts +37 -0
- forge/templates/starter/libs/auth/server/src/members.controller.ts +47 -0
- forge/templates/starter/libs/auth/server/src/session.guard.ts +52 -0
- forge/templates/starter/libs/auth/server/tsconfig.json +29 -0
- forge/templates/starter/libs/core/server/package.json +17 -0
- forge/templates/starter/libs/core/server/project.json +19 -0
- forge/templates/starter/libs/core/server/src/common/account-principal.ts +8 -0
- forge/templates/starter/libs/core/server/src/common/admin-only.decorator.ts +18 -0
- forge/templates/starter/libs/core/server/src/common/all-exceptions.filter.ts +55 -0
- forge/templates/starter/libs/core/server/src/common/api-envelope.decorator.ts +28 -0
- forge/templates/starter/libs/core/server/src/common/api-response.dto.ts +26 -0
- forge/templates/starter/libs/core/server/src/common/api-zod.decorator.ts +21 -0
- forge/templates/starter/libs/core/server/src/common/authenticated-request.ts +7 -0
- forge/templates/starter/libs/core/server/src/common/common.module.ts +7 -0
- forge/templates/starter/libs/core/server/src/common/correlation.middleware.ts +12 -0
- forge/templates/starter/libs/core/server/src/common/csrf.guard.ts +35 -0
- forge/templates/starter/libs/core/server/src/common/csv.ts +14 -0
- forge/templates/starter/libs/core/server/src/common/current-account.decorator.ts +11 -0
- forge/templates/starter/libs/core/server/src/common/envelope.interceptor.ts +10 -0
- forge/templates/starter/libs/core/server/src/common/error-report.ts +43 -0
- forge/templates/starter/libs/core/server/src/common/json-logger.test.ts +95 -0
- forge/templates/starter/libs/core/server/src/common/json-logger.ts +57 -0
- forge/templates/starter/libs/core/server/src/common/permissions.ts +49 -0
- forge/templates/starter/libs/core/server/src/common/prompts.ts +42 -0
- forge/templates/starter/libs/core/server/src/common/public.decorator.ts +4 -0
- forge/templates/starter/libs/core/server/src/common/request-log.middleware.ts +19 -0
- forge/templates/starter/libs/core/server/src/common/resources.ts +88 -0
- forge/templates/starter/libs/core/server/src/common/retry-keys.ts +31 -0
- forge/templates/starter/libs/core/server/src/common/tools.test.ts +205 -0
- forge/templates/starter/libs/core/server/src/common/tools.ts +266 -0
- forge/templates/starter/libs/core/server/src/common/zod-validation.pipe.ts +22 -0
- forge/templates/starter/libs/core/server/src/config/environment.ts +95 -0
- forge/templates/starter/libs/core/server/src/index.ts +27 -0
- forge/templates/starter/libs/core/server/src/mail/mail.module.ts +19 -0
- forge/templates/starter/libs/core/server/src/mail/mail.provider.ts +22 -0
- forge/templates/starter/libs/core/server/src/prisma/prisma.module.ts +7 -0
- forge/templates/starter/libs/core/server/src/prisma/prisma.service.ts +19 -0
- forge/templates/starter/libs/core/server/tsconfig.json +23 -0
- forge/templates/starter/libs/core/web/package.json +16 -0
- forge/templates/starter/libs/core/web/project.json +15 -0
- forge/templates/starter/libs/core/web/src/api-client.ts +42 -0
- forge/templates/starter/libs/core/web/src/error-report.ts +12 -0
- forge/templates/starter/libs/core/web/src/form-errors.ts +18 -0
- forge/templates/starter/libs/core/web/src/index.ts +4 -0
- forge/templates/starter/libs/core/web/src/permissions.ts +9 -0
- forge/templates/starter/libs/core/web/src/query-client.ts +10 -0
- forge/templates/starter/libs/core/web/tsconfig.json +18 -0
- forge/templates/starter/libs/history/contracts/package.json +14 -0
- forge/templates/starter/libs/history/contracts/project.json +15 -0
- forge/templates/starter/libs/history/contracts/src/index.ts +2 -0
- forge/templates/starter/libs/history/contracts/src/service.ts +21 -0
- forge/templates/starter/libs/history/contracts/tsconfig.json +14 -0
- forge/templates/starter/libs/history/server/package.json +19 -0
- forge/templates/starter/libs/history/server/project.json +19 -0
- forge/templates/starter/libs/history/server/src/history.controller.ts +45 -0
- forge/templates/starter/libs/history/server/src/history.dto.ts +22 -0
- forge/templates/starter/libs/history/server/src/history.module.ts +12 -0
- forge/templates/starter/libs/history/server/src/history.service.test.ts +18 -0
- forge/templates/starter/libs/history/server/src/history.service.ts +42 -0
- forge/templates/starter/libs/history/server/src/index.ts +2 -0
- forge/templates/starter/libs/history/server/tsconfig.json +29 -0
- forge/templates/starter/libs/mcp/server/package.json +18 -0
- forge/templates/starter/libs/mcp/server/project.json +15 -0
- forge/templates/starter/libs/mcp/server/src/index.ts +1 -0
- forge/templates/starter/libs/mcp/server/src/mcp.controller.ts +102 -0
- forge/templates/starter/libs/mcp/server/src/mcp.module.ts +5 -0
- forge/templates/starter/libs/mcp/server/tsconfig.json +26 -0
- forge/templates/starter/libs/notifications/contracts/package.json +14 -0
- forge/templates/starter/libs/notifications/contracts/project.json +12 -0
- forge/templates/starter/libs/notifications/contracts/src/index.ts +1 -0
- forge/templates/starter/libs/notifications/contracts/src/service.ts +19 -0
- forge/templates/starter/libs/notifications/contracts/tsconfig.json +12 -0
- forge/templates/starter/libs/notifications/server/package.json +18 -0
- forge/templates/starter/libs/notifications/server/project.json +12 -0
- forge/templates/starter/libs/notifications/server/src/index.ts +1 -0
- forge/templates/starter/libs/notifications/server/src/notifications.controller.ts +21 -0
- forge/templates/starter/libs/notifications/server/src/notifications.dto.ts +28 -0
- forge/templates/starter/libs/notifications/server/src/notifications.module.ts +12 -0
- forge/templates/starter/libs/notifications/server/src/notifications.service.ts +36 -0
- forge/templates/starter/libs/notifications/server/tsconfig.json +18 -0
- forge/templates/starter/libs/organisations/contracts/package.json +14 -0
- forge/templates/starter/libs/organisations/contracts/project.json +15 -0
- forge/templates/starter/libs/organisations/contracts/src/index.ts +54 -0
- forge/templates/starter/libs/organisations/contracts/src/service.ts +29 -0
- forge/templates/starter/libs/organisations/contracts/tsconfig.json +14 -0
- forge/templates/starter/libs/organisations/server/package.json +20 -0
- forge/templates/starter/libs/organisations/server/project.json +15 -0
- forge/templates/starter/libs/organisations/server/src/index.ts +2 -0
- forge/templates/starter/libs/organisations/server/src/organisations.controller.ts +101 -0
- forge/templates/starter/libs/organisations/server/src/organisations.dto.ts +46 -0
- forge/templates/starter/libs/organisations/server/src/organisations.module.ts +14 -0
- forge/templates/starter/libs/organisations/server/src/organisations.service.ts +221 -0
- forge/templates/starter/libs/organisations/server/tsconfig.json +32 -0
- forge/templates/starter/libs/projects/contracts/package.json +14 -0
- forge/templates/starter/libs/projects/contracts/project.json +15 -0
- forge/templates/starter/libs/projects/contracts/src/index.ts +87 -0
- forge/templates/starter/libs/projects/contracts/tsconfig.json +14 -0
- forge/templates/starter/libs/projects/server/package.json +21 -0
- forge/templates/starter/libs/projects/server/project.json +15 -0
- forge/templates/starter/libs/projects/server/src/index.ts +2 -0
- forge/templates/starter/libs/projects/server/src/projects.controller.ts +165 -0
- forge/templates/starter/libs/projects/server/src/projects.dto.ts +77 -0
- forge/templates/starter/libs/projects/server/src/projects.module.ts +19 -0
- forge/templates/starter/libs/projects/server/src/projects.permissions.ts +7 -0
- forge/templates/starter/libs/projects/server/src/projects.service.ts +314 -0
- forge/templates/starter/libs/projects/server/src/projects.tools.ts +28 -0
- forge/templates/starter/libs/projects/server/tsconfig.json +29 -0
- forge/templates/starter/libs/shared/ui/components.json +21 -0
- forge/templates/starter/libs/shared/ui/package.json +27 -0
- forge/templates/starter/libs/shared/ui/project.json +15 -0
- forge/templates/starter/libs/shared/ui/src/components/states.tsx +73 -0
- forge/templates/starter/libs/shared/ui/src/components/theme-provider.tsx +39 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/LICENSE +21 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/alert-dialog.tsx +196 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/alert.tsx +65 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/avatar.tsx +108 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/badge.tsx +47 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/breadcrumb.tsx +108 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/button.tsx +63 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/card.tsx +91 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/checkbox.tsx +29 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/collapsible.tsx +33 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/command.tsx +184 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/dialog.tsx +158 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/dropdown-menu.tsx +256 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/empty.tsx +103 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/form.tsx +167 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/input.tsx +20 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/label.tsx +23 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/popover.tsx +88 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/select.tsx +189 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/separator.tsx +27 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/sheet.tsx +142 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/sidebar.tsx +726 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/skeleton.tsx +13 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/sonner.tsx +40 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/switch.tsx +32 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/table.tsx +115 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/textarea.tsx +17 -0
- forge/templates/starter/libs/shared/ui/src/components/ui/tooltip.tsx +56 -0
- forge/templates/starter/libs/shared/ui/src/hooks/use-mobile.ts +19 -0
- forge/templates/starter/libs/shared/ui/src/lib/utils.ts +6 -0
- forge/templates/starter/libs/shared/ui/tsconfig.json +23 -0
- forge/templates/starter/libs/shared/util/package.json +14 -0
- forge/templates/starter/libs/shared/util/project.json +19 -0
- forge/templates/starter/libs/shared/util/src/csv-field.ts +6 -0
- forge/templates/starter/libs/shared/util/src/envelope.ts +9 -0
- forge/templates/starter/libs/shared/util/src/format.test.ts +33 -0
- forge/templates/starter/libs/shared/util/src/format.ts +43 -0
- forge/templates/starter/libs/shared/util/src/index.ts +12 -0
- forge/templates/starter/libs/shared/util/tsconfig.json +14 -0
- forge/templates/starter/nx.json +7 -0
- forge/templates/starter/package.json +97 -0
- forge/templates/starter/pnpm-lock.yaml +11587 -0
- forge/templates/starter/pnpm-workspace.yaml +4 -0
- forge/templates/starter/prisma.config.ts +13 -0
- forge/templates/starter/scripts/affected.mjs +27 -0
- forge/templates/starter/scripts/test-build.mjs +29 -0
- forge/templates/starter/scripts/test.mjs +107 -0
- forge/templates/starter/services.toml +7 -0
- forge/templates/starter/tsconfig.base.json +15 -0
- forge/templates/starter-python/.env.example +8 -0
- forge/templates/starter-python/.gitignore +13 -0
- forge/templates/starter-python/Dockerfile +30 -0
- forge/templates/starter-python/README.md +101 -0
- forge/templates/starter-python/apps/api/.python-version +1 -0
- forge/templates/starter-python/apps/api/alembic.ini +38 -0
- forge/templates/starter-python/apps/api/app/__init__.py +1 -0
- forge/templates/starter-python/apps/api/app/auth/__init__.py +27 -0
- forge/templates/starter-python/apps/api/app/auth/models.py +111 -0
- forge/templates/starter-python/apps/api/app/auth/routes.py +398 -0
- forge/templates/starter-python/apps/api/app/auth/schema.py +117 -0
- forge/templates/starter-python/apps/api/app/auth/service.py +453 -0
- forge/templates/starter-python/apps/api/app/core/__init__.py +89 -0
- forge/templates/starter-python/apps/api/app/core/admin.py +23 -0
- forge/templates/starter-python/apps/api/app/core/config.py +83 -0
- forge/templates/starter-python/apps/api/app/core/csv.py +40 -0
- forge/templates/starter-python/apps/api/app/core/database.py +21 -0
- forge/templates/starter-python/apps/api/app/core/envelope.py +40 -0
- forge/templates/starter-python/apps/api/app/core/error_report.py +85 -0
- forge/templates/starter-python/apps/api/app/core/errors.py +153 -0
- forge/templates/starter-python/apps/api/app/core/logging.py +66 -0
- forge/templates/starter-python/apps/api/app/core/mail.py +34 -0
- forge/templates/starter-python/apps/api/app/core/permissions.py +59 -0
- forge/templates/starter-python/apps/api/app/core/principal.py +12 -0
- forge/templates/starter-python/apps/api/app/core/prompts.py +96 -0
- forge/templates/starter-python/apps/api/app/core/resources.py +230 -0
- forge/templates/starter-python/apps/api/app/core/retry_keys.py +101 -0
- forge/templates/starter-python/apps/api/app/core/schema.py +13 -0
- forge/templates/starter-python/apps/api/app/core/security.py +197 -0
- forge/templates/starter-python/apps/api/app/core/tools.py +1117 -0
- forge/templates/starter-python/apps/api/app/history/__init__.py +5 -0
- forge/templates/starter-python/apps/api/app/history/models.py +48 -0
- forge/templates/starter-python/apps/api/app/history/routes.py +65 -0
- forge/templates/starter-python/apps/api/app/history/schema.py +29 -0
- forge/templates/starter-python/apps/api/app/history/service.py +77 -0
- forge/templates/starter-python/apps/api/app/main.py +115 -0
- forge/templates/starter-python/apps/api/app/mcp/__init__.py +3 -0
- forge/templates/starter-python/apps/api/app/mcp/server.py +192 -0
- forge/templates/starter-python/apps/api/app/notifications/__init__.py +5 -0
- forge/templates/starter-python/apps/api/app/notifications/models.py +62 -0
- forge/templates/starter-python/apps/api/app/notifications/routes.py +25 -0
- forge/templates/starter-python/apps/api/app/notifications/schema.py +39 -0
- forge/templates/starter-python/apps/api/app/notifications/service.py +70 -0
- forge/templates/starter-python/apps/api/app/openapi.py +17 -0
- forge/templates/starter-python/apps/api/app/organisations/__init__.py +10 -0
- forge/templates/starter-python/apps/api/app/organisations/models.py +128 -0
- forge/templates/starter-python/apps/api/app/organisations/routes.py +176 -0
- forge/templates/starter-python/apps/api/app/organisations/schema.py +76 -0
- forge/templates/starter-python/apps/api/app/organisations/service.py +403 -0
- forge/templates/starter-python/apps/api/app/projects/__init__.py +14 -0
- forge/templates/starter-python/apps/api/app/projects/models.py +67 -0
- forge/templates/starter-python/apps/api/app/projects/permissions.py +13 -0
- forge/templates/starter-python/apps/api/app/projects/routes.py +246 -0
- forge/templates/starter-python/apps/api/app/projects/schema.py +118 -0
- forge/templates/starter-python/apps/api/app/projects/service.py +359 -0
- forge/templates/starter-python/apps/api/app/projects/tools.py +28 -0
- forge/templates/starter-python/apps/api/app/setup_company.py +56 -0
- forge/templates/starter-python/apps/api/migrations/env.py +51 -0
- forge/templates/starter-python/apps/api/migrations/script.py.mako +25 -0
- forge/templates/starter-python/apps/api/migrations/versions/0001_initial.py +167 -0
- forge/templates/starter-python/apps/api/migrations/versions/0002_soft_delete_only.py +31 -0
- forge/templates/starter-python/apps/api/migrations/versions/0003_organisations.py +115 -0
- forge/templates/starter-python/apps/api/migrations/versions/0004_invites.py +58 -0
- forge/templates/starter-python/apps/api/migrations/versions/0005_history.py +51 -0
- forge/templates/starter-python/apps/api/migrations/versions/0006_extensions.py +22 -0
- forge/templates/starter-python/apps/api/migrations/versions/0007_ids_and_updated_at.py +52 -0
- forge/templates/starter-python/apps/api/migrations/versions/0008_module_schemas.py +42 -0
- forge/templates/starter-python/apps/api/migrations/versions/0009_columns.py +97 -0
- forge/templates/starter-python/apps/api/migrations/versions/0010_history_subjects.py +46 -0
- forge/templates/starter-python/apps/api/migrations/versions/0011_agents.py +44 -0
- forge/templates/starter-python/apps/api/migrations/versions/0012_mcp.py +71 -0
- forge/templates/starter-python/apps/api/migrations/versions/0013_via_agent.py +23 -0
- forge/templates/starter-python/apps/api/migrations/versions/20261103_sign_in_attempts.py +48 -0
- forge/templates/starter-python/apps/api/migrations/versions/20261105_notifications.py +84 -0
- forge/templates/starter-python/apps/api/pyproject.toml +86 -0
- forge/templates/starter-python/apps/api/tests/conftest.py +146 -0
- forge/templates/starter-python/apps/api/tests/test_agents.py +169 -0
- forge/templates/starter-python/apps/api/tests/test_api.py +319 -0
- forge/templates/starter-python/apps/api/tests/test_auth.py +428 -0
- forge/templates/starter-python/apps/api/tests/test_config.py +58 -0
- forge/templates/starter-python/apps/api/tests/test_database.py +204 -0
- forge/templates/starter-python/apps/api/tests/test_error_reports.py +119 -0
- forge/templates/starter-python/apps/api/tests/test_history.py +206 -0
- forge/templates/starter-python/apps/api/tests/test_invites.py +427 -0
- forge/templates/starter-python/apps/api/tests/test_logging.py +56 -0
- forge/templates/starter-python/apps/api/tests/test_mcp.py +556 -0
- forge/templates/starter-python/apps/api/tests/test_module_schemas.py +100 -0
- forge/templates/starter-python/apps/api/tests/test_notifications.py +182 -0
- forge/templates/starter-python/apps/api/tests/test_one_company.py +188 -0
- forge/templates/starter-python/apps/api/tests/test_organisations.py +231 -0
- forge/templates/starter-python/apps/api/tests/test_projects.py +874 -0
- forge/templates/starter-python/apps/api/tests/test_soft_delete.py +80 -0
- forge/templates/starter-python/apps/api/tests/test_tools.py +395 -0
- forge/templates/starter-python/apps/api/uv.lock +1277 -0
- forge/templates/starter-python/compose.test.yml +63 -0
- forge/templates/starter-python/eslint.config.mjs +49 -0
- forge/templates/starter-python/libs/auth/contracts/package.json +17 -0
- forge/templates/starter-python/libs/auth/contracts/src/index.ts +51 -0
- forge/templates/starter-python/libs/auth/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/history/contracts/package.json +17 -0
- forge/templates/starter-python/libs/history/contracts/src/index.ts +3 -0
- forge/templates/starter-python/libs/history/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/organisations/contracts/package.json +17 -0
- forge/templates/starter-python/libs/organisations/contracts/src/index.ts +30 -0
- forge/templates/starter-python/libs/organisations/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/projects/contracts/package.json +17 -0
- forge/templates/starter-python/libs/projects/contracts/src/index.ts +65 -0
- forge/templates/starter-python/libs/projects/contracts/tsconfig.json +16 -0
- forge/templates/starter-python/libs/shared/api-types/package.json +14 -0
- forge/templates/starter-python/libs/shared/api-types/tsconfig.json +14 -0
- forge/templates/starter-python/package.json +71 -0
- forge/templates/starter-python/pnpm-lock.yaml +7574 -0
- forge/templates/starter-python/pnpm-workspace.yaml +4 -0
- forge/templates/starter-python/scripts/affected.mjs +20 -0
- forge/templates/starter-python/scripts/test-browser.mjs +39 -0
- forge/templates/starter-python/scripts/test.mjs +86 -0
- forge/templates/starter-python/services.toml +7 -0
- forge/templates/story.md +89 -0
- forge/time_records.py +1022 -0
- forge/ui_checks.py +97 -0
- forge/upgrade.py +368 -0
- forge/worker.py +876 -0
- symphony_forge-1.2.44.dist-info/METADATA +7 -0
- symphony_forge-1.2.44.dist-info/RECORD +623 -0
- symphony_forge-1.2.44.dist-info/WHEEL +4 -0
- symphony_forge-1.2.44.dist-info/entry_points.txt +2 -0
- symphony_forge-1.2.44.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Waiting entries are an operational log, like change history, rather than editable records.
|
|
2
|
+
model Notification {
|
|
3
|
+
id String @id @default(dbgenerated("uuidv7()")) @db.Uuid
|
|
4
|
+
organisationId String @db.Uuid
|
|
5
|
+
recipientAccountId String @db.Uuid
|
|
6
|
+
subjectId String @db.Uuid
|
|
7
|
+
subjectName String
|
|
8
|
+
message String
|
|
9
|
+
createdAtUtc DateTime @default(now()) @db.Timestamptz(3)
|
|
10
|
+
resolvedAtUtc DateTime? @db.Timestamptz(3)
|
|
11
|
+
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Restrict)
|
|
12
|
+
recipientAccount Account @relation(fields: [recipientAccountId], references: [id], onDelete: Restrict)
|
|
13
|
+
|
|
14
|
+
@@index([organisationId], map: "idx_Notification_organisationId_fk")
|
|
15
|
+
@@index([recipientAccountId], map: "idx_Notification_recipientAccountId_fk")
|
|
16
|
+
@@index([subjectId], map: "idx_Notification_subjectId_fk")
|
|
17
|
+
@@index([organisationId, recipientAccountId, createdAtUtc(sort: Desc), id(sort: Desc)], map: "idx_Notification_list", where: { resolvedAtUtc: null })
|
|
18
|
+
@@index([organisationId, subjectId], map: "idx_Notification_subjectId_open", where: { resolvedAtUtc: null })
|
|
19
|
+
@@schema("notifications")
|
|
20
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
model Organisation {
|
|
2
|
+
id String @id @default(dbgenerated("uuidv7()")) @db.Uuid
|
|
3
|
+
createdAtUtc DateTime @default(now()) @db.Timestamptz(3)
|
|
4
|
+
updatedAtUtc DateTime @updatedAt @db.Timestamptz(3)
|
|
5
|
+
createdByAccountId String @db.Uuid
|
|
6
|
+
modifiedByAccountId String @db.Uuid
|
|
7
|
+
deletedAtUtc DateTime? @db.Timestamptz(3)
|
|
8
|
+
deletedByAccountId String? @db.Uuid
|
|
9
|
+
// The features whose delete and restore tools agents may use.
|
|
10
|
+
agentDeleteRestore String[] @default([])
|
|
11
|
+
memberships Membership[]
|
|
12
|
+
projects Project[]
|
|
13
|
+
invites Invite[]
|
|
14
|
+
idempotencyKeys IdempotencyKey[]
|
|
15
|
+
notifications Notification[]
|
|
16
|
+
|
|
17
|
+
@@index([createdByAccountId], map: "idx_Organisation_createdByAccountId")
|
|
18
|
+
@@index([modifiedByAccountId], map: "idx_Organisation_modifiedByAccountId")
|
|
19
|
+
@@index([deletedByAccountId], map: "idx_Organisation_deletedByAccountId")
|
|
20
|
+
@@schema("core")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Invites are temporary, single-use credentials and are removed when claimed.
|
|
24
|
+
model Invite {
|
|
25
|
+
id String @id @default(dbgenerated("uuidv7()")) @db.Uuid
|
|
26
|
+
organisationId String @db.Uuid
|
|
27
|
+
email String
|
|
28
|
+
tokenHash String @unique
|
|
29
|
+
expiresAtUtc DateTime @db.Timestamptz(3)
|
|
30
|
+
createdAtUtc DateTime @default(now()) @db.Timestamptz(3)
|
|
31
|
+
updatedAtUtc DateTime @updatedAt @db.Timestamptz(3)
|
|
32
|
+
createdByAccountId String @db.Uuid
|
|
33
|
+
modifiedByAccountId String @db.Uuid
|
|
34
|
+
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Restrict)
|
|
35
|
+
|
|
36
|
+
@@unique([organisationId, email])
|
|
37
|
+
@@index([expiresAtUtc], map: "idx_Invite_expiresAtUtc")
|
|
38
|
+
@@index([createdByAccountId], map: "idx_Invite_createdByAccountId")
|
|
39
|
+
@@index([modifiedByAccountId], map: "idx_Invite_modifiedByAccountId")
|
|
40
|
+
@@schema("core")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
model Membership {
|
|
44
|
+
id String @id @default(dbgenerated("uuidv7()")) @db.Uuid
|
|
45
|
+
accountId String @unique @db.Uuid
|
|
46
|
+
organisationId String @db.Uuid
|
|
47
|
+
email String
|
|
48
|
+
role String
|
|
49
|
+
isAgent Boolean @default(false)
|
|
50
|
+
// The SHA-256 of the agent's one key; null when it has none.
|
|
51
|
+
agentKeyHash String? @unique
|
|
52
|
+
createdAtUtc DateTime @default(now()) @db.Timestamptz(3)
|
|
53
|
+
updatedAtUtc DateTime @updatedAt @db.Timestamptz(3)
|
|
54
|
+
createdByAccountId String @db.Uuid
|
|
55
|
+
modifiedByAccountId String @db.Uuid
|
|
56
|
+
deletedAtUtc DateTime? @db.Timestamptz(3)
|
|
57
|
+
deletedByAccountId String? @db.Uuid
|
|
58
|
+
account Account @relation(fields: [accountId], references: [id], onDelete: Restrict)
|
|
59
|
+
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Restrict)
|
|
60
|
+
|
|
61
|
+
@@index([organisationId], map: "idx_Membership_organisationId")
|
|
62
|
+
@@index([createdByAccountId], map: "idx_Membership_createdByAccountId")
|
|
63
|
+
@@index([modifiedByAccountId], map: "idx_Membership_modifiedByAccountId")
|
|
64
|
+
@@index([deletedByAccountId], map: "idx_Membership_deletedByAccountId")
|
|
65
|
+
@@schema("core")
|
|
66
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
model Project {
|
|
2
|
+
id String @id @default(dbgenerated("uuidv7()")) @db.Uuid
|
|
3
|
+
organisationId String @db.Uuid
|
|
4
|
+
name String
|
|
5
|
+
status String @default("active")
|
|
6
|
+
createdAtUtc DateTime @default(now()) @db.Timestamptz(3)
|
|
7
|
+
updatedAtUtc DateTime @updatedAt @db.Timestamptz(3)
|
|
8
|
+
createdByAccountId String @db.Uuid
|
|
9
|
+
modifiedByAccountId String @db.Uuid
|
|
10
|
+
deletedAtUtc DateTime? @db.Timestamptz(3)
|
|
11
|
+
deletedByAccountId String? @db.Uuid
|
|
12
|
+
|
|
13
|
+
organisation Organisation @relation(fields: [organisationId], references: [id], onDelete: Restrict)
|
|
14
|
+
createdByAccount Account @relation("ProjectCreatedBy", fields: [createdByAccountId], references: [id], onDelete: Restrict)
|
|
15
|
+
modifiedByAccount Account @relation("ProjectModifiedBy", fields: [modifiedByAccountId], references: [id], onDelete: Restrict)
|
|
16
|
+
deletedByAccount Account? @relation("ProjectDeletedBy", fields: [deletedByAccountId], references: [id], onDelete: Restrict)
|
|
17
|
+
|
|
18
|
+
@@index([organisationId], map: "idx_Project_organisationId")
|
|
19
|
+
@@index([createdByAccountId], map: "idx_Project_createdByAccountId")
|
|
20
|
+
@@index([modifiedByAccountId], map: "idx_Project_modifiedByAccountId")
|
|
21
|
+
@@index([deletedByAccountId], map: "idx_Project_deletedByAccountId")
|
|
22
|
+
@@schema("projects")
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "api",
|
|
3
|
+
"projectType": "application",
|
|
4
|
+
"sourceRoot": "apps/api/src",
|
|
5
|
+
"targets": {
|
|
6
|
+
"lint": {
|
|
7
|
+
"executor": "nx:run-commands",
|
|
8
|
+
"options": { "command": "eslint apps/api" }
|
|
9
|
+
},
|
|
10
|
+
"test": {
|
|
11
|
+
"executor": "nx:run-commands",
|
|
12
|
+
"options": { "command": "vitest run --config apps/api/vitest.config.ts" }
|
|
13
|
+
},
|
|
14
|
+
"build": {
|
|
15
|
+
"executor": "nx:run-commands",
|
|
16
|
+
"options": {
|
|
17
|
+
"command": "tsc -b apps/api/tsconfig.json"
|
|
18
|
+
},
|
|
19
|
+
"outputs": [
|
|
20
|
+
"{workspaceRoot}/apps/api/dist",
|
|
21
|
+
"{workspaceRoot}/libs/*/*/dist"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"typecheck": {
|
|
25
|
+
"executor": "nx:run-commands",
|
|
26
|
+
"options": {
|
|
27
|
+
"command": "tsc -b apps/api/tsconfig.json && tsc --noEmit -p apps/api/tsconfig.test.json"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"tags": [
|
|
32
|
+
"type:api",
|
|
33
|
+
"scope:app"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { ConfigModule } from '@nestjs/config';
|
|
3
|
+
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from '@nestjs/core';
|
|
4
|
+
import { ThrottlerGuard, ThrottlerModule } from '@nestjs/throttler';
|
|
5
|
+
import { AllExceptionsFilter, CommonModule, CsrfGuard, EnvelopeInterceptor, getRateLimits, PrismaModule, validateEnvironment } from '@app/core-server';
|
|
6
|
+
import { AuthModule, SessionGuard } from '@app/auth-server';
|
|
7
|
+
import { HealthModule } from './health/health.module';
|
|
8
|
+
import { ProjectsModule } from '@app/projects-server';
|
|
9
|
+
import { HistoryModule } from '@app/history-server';
|
|
10
|
+
import { NotificationsModule } from '@app/notifications-server';
|
|
11
|
+
import { OrganisationsModule } from '@app/organisations-server';
|
|
12
|
+
import { McpModule } from '@app/mcp-server';
|
|
13
|
+
|
|
14
|
+
@Module({
|
|
15
|
+
imports: [
|
|
16
|
+
ConfigModule.forRoot({ isGlobal: true, validate: validateEnvironment }),
|
|
17
|
+
ThrottlerModule.forRoot([{ ttl: 60_000, limit: () => getRateLimits().other }]),
|
|
18
|
+
CommonModule,
|
|
19
|
+
PrismaModule,
|
|
20
|
+
AuthModule,
|
|
21
|
+
ProjectsModule,
|
|
22
|
+
OrganisationsModule,
|
|
23
|
+
McpModule,
|
|
24
|
+
HistoryModule,
|
|
25
|
+
NotificationsModule,
|
|
26
|
+
HealthModule,
|
|
27
|
+
],
|
|
28
|
+
providers: [
|
|
29
|
+
{ provide: APP_GUARD, useClass: ThrottlerGuard },
|
|
30
|
+
{ provide: APP_GUARD, useClass: SessionGuard },
|
|
31
|
+
{ provide: APP_GUARD, useClass: CsrfGuard },
|
|
32
|
+
{ provide: APP_FILTER, useClass: AllExceptionsFilter },
|
|
33
|
+
{ provide: APP_INTERCEPTOR, useClass: EnvelopeInterceptor },
|
|
34
|
+
],
|
|
35
|
+
})
|
|
36
|
+
export class AppModule {}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Controller, Get } from '@nestjs/common';
|
|
2
|
+
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
3
|
+
import { SkipThrottle } from '@nestjs/throttler';
|
|
4
|
+
import { Public } from '@app/core-server';
|
|
5
|
+
|
|
6
|
+
@ApiTags('Health')
|
|
7
|
+
@SkipThrottle()
|
|
8
|
+
@Controller('health')
|
|
9
|
+
export class HealthController {
|
|
10
|
+
@Public()
|
|
11
|
+
@Get()
|
|
12
|
+
@ApiOperation({ summary: 'Check whether the API is ready.' })
|
|
13
|
+
health(): { status: 'ok' } {
|
|
14
|
+
return { status: 'ok' };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RequestMethod } from '@nestjs/common';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import { NestFactory } from '@nestjs/core';
|
|
4
|
+
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
|
5
|
+
import cookieParser from 'cookie-parser';
|
|
6
|
+
import express, { type Express } from 'express';
|
|
7
|
+
import helmet from 'helmet';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { AppModule } from './app.module';
|
|
10
|
+
import { correlationMiddleware, JsonLogger, requestLogMiddleware } from '@app/core-server';
|
|
11
|
+
|
|
12
|
+
async function bootstrap(): Promise<void> {
|
|
13
|
+
const logger = new JsonLogger();
|
|
14
|
+
const app = await NestFactory.create(AppModule, { logger });
|
|
15
|
+
const config = app.get(ConfigService);
|
|
16
|
+
app.use(correlationMiddleware);
|
|
17
|
+
app.use(requestLogMiddleware);
|
|
18
|
+
app.use(helmet());
|
|
19
|
+
app.enableCors({
|
|
20
|
+
origin: config.getOrThrow<string>('APP_ORIGIN'),
|
|
21
|
+
credentials: true,
|
|
22
|
+
allowedHeaders: ['Content-Type', 'X-CSRF-Token', 'X-Correlation-Id', 'Idempotency-Key'],
|
|
23
|
+
});
|
|
24
|
+
app.use(cookieParser());
|
|
25
|
+
const webRoot = join(process.cwd(), 'apps/web/dist');
|
|
26
|
+
const expressApp: Express = app.getHttpAdapter().getInstance();
|
|
27
|
+
expressApp.use(express.static(webRoot));
|
|
28
|
+
expressApp.get(/^(?!\/api(?:\/|$)|\/health(?:\/|$)|\/mcp(?:\/|$)).*/, (request, response, next) => {
|
|
29
|
+
if (request.method !== 'GET' || !request.accepts('html')) return next();
|
|
30
|
+
return response.sendFile(join(webRoot, 'index.html'));
|
|
31
|
+
});
|
|
32
|
+
app.setGlobalPrefix('api/v1', { exclude: [{ path: 'health', method: RequestMethod.GET }, { path: 'mcp', method: RequestMethod.ALL }] });
|
|
33
|
+
const swaggerConfig = new DocumentBuilder()
|
|
34
|
+
.setTitle('Starter API')
|
|
35
|
+
.setDescription('Account sign-in and project management API.')
|
|
36
|
+
.setVersion('1.0.0')
|
|
37
|
+
.addCookieAuth('starter_session', { type: 'apiKey', in: 'cookie', name: 'starter_session' }, 'session')
|
|
38
|
+
.build();
|
|
39
|
+
SwaggerModule.setup('api/docs', app, SwaggerModule.createDocument(app, swaggerConfig));
|
|
40
|
+
app.enableShutdownHooks();
|
|
41
|
+
await app.listen(config.getOrThrow<number>('PORT'), '0.0.0.0');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void bootstrap();
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { HttpException } from '@nestjs/common';
|
|
3
|
+
import { ConfigService } from '@nestjs/config';
|
|
4
|
+
import { NestFactory } from '@nestjs/core';
|
|
5
|
+
import { AuthService } from '@app/auth-server';
|
|
6
|
+
import { signUpSchema } from '@app/auth-contracts';
|
|
7
|
+
import { AppModule } from './app.module';
|
|
8
|
+
|
|
9
|
+
async function setupCompany(): Promise<void> {
|
|
10
|
+
const app = await NestFactory.createApplicationContext(AppModule, { logger: false, abortOnError: false });
|
|
11
|
+
try {
|
|
12
|
+
const config = app.get(ConfigService);
|
|
13
|
+
const input = signUpSchema.safeParse({ email: config.get('ADMIN_EMAIL'), password: config.get('ADMIN_PASSWORD') });
|
|
14
|
+
if (!input.success) {
|
|
15
|
+
for (const issue of input.error.issues) process.stderr.write(`${issue.message}\n`);
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
await app.get(AuthService).setUpCompany(input.data.email, input.data.password);
|
|
20
|
+
process.stdout.write('The company and its first admin are ready.\n');
|
|
21
|
+
} finally {
|
|
22
|
+
await app.close();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
void setupCompany().catch((error: unknown) => {
|
|
27
|
+
const response = error instanceof HttpException ? error.getResponse() : null;
|
|
28
|
+
const message = response && typeof response === 'object' && 'message' in response
|
|
29
|
+
? String(response.message)
|
|
30
|
+
: 'Company setup failed. Check the app settings and database, then try again.';
|
|
31
|
+
process.stderr.write(`${message}\n`);
|
|
32
|
+
process.exitCode = 1;
|
|
33
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import request from 'supertest';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { apiBaseUrl, credentials, csrfToken, invite } from './helpers';
|
|
4
|
+
|
|
5
|
+
async function signedUpAdmin() {
|
|
6
|
+
const admin = credentials();
|
|
7
|
+
const client = request.agent(apiBaseUrl);
|
|
8
|
+
const signUp = await client.post('/api/v1/auth/sign-up').send(admin).expect(201);
|
|
9
|
+
return { admin, client, csrf: csrfToken(signUp) };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('agent accounts', () => {
|
|
13
|
+
it('an admin adds an agent account and creates and revokes its key', async () => {
|
|
14
|
+
const { admin, client, csrf } = await signedUpAdmin();
|
|
15
|
+
const added = await client.post('/api/v1/agents').set('x-csrf-token', csrf).send({ name: 'gantry', role: 'member' }).expect(201);
|
|
16
|
+
const agent = added.body.data;
|
|
17
|
+
expect(agent).toMatchObject({ role: 'member', isAgent: true, hasKey: false });
|
|
18
|
+
expect(agent.email).toMatch(/^gantry-[a-z0-9]{6}@agents\.invalid$/);
|
|
19
|
+
await client.post('/api/v1/agents').set('x-csrf-token', csrf).send({ name: 'Not valid', role: 'member' }).expect(400)
|
|
20
|
+
.expect(({ body }) => expect(body.error.details.fieldErrors).toEqual([expect.objectContaining({ field: 'name' })]));
|
|
21
|
+
|
|
22
|
+
const first = await client.post(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', csrf).expect(201);
|
|
23
|
+
expect(first.body.data.key).toMatch(/^agent_[A-Za-z0-9_-]{43}$/);
|
|
24
|
+
const second = await client.post(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', csrf).expect(201);
|
|
25
|
+
expect(second.body.data.key).toMatch(/^agent_/);
|
|
26
|
+
expect(second.body.data.key).not.toBe(first.body.data.key);
|
|
27
|
+
|
|
28
|
+
const listed = await client.get('/api/v1/members?page=1&limit=20').expect(200);
|
|
29
|
+
expect(listed.body.data.items).toEqual(expect.arrayContaining([
|
|
30
|
+
expect.objectContaining({ email: admin.email, isAgent: false, hasKey: false }),
|
|
31
|
+
expect.objectContaining({ email: agent.email, isAgent: true, hasKey: true }),
|
|
32
|
+
]));
|
|
33
|
+
// The key shows one time only: no list or member read returns it.
|
|
34
|
+
expect(JSON.stringify(listed.body)).not.toContain(second.body.data.key);
|
|
35
|
+
|
|
36
|
+
await client.delete(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', csrf).expect(200);
|
|
37
|
+
const revoked = await client.get('/api/v1/members?page=1&limit=20').expect(200);
|
|
38
|
+
expect(revoked.body.data.items).toEqual(expect.arrayContaining([expect.objectContaining({ email: agent.email, hasKey: false })]));
|
|
39
|
+
|
|
40
|
+
// A person's membership has no key to create.
|
|
41
|
+
const self = listed.body.data.items.find((member: { email: string }) => member.email === admin.email);
|
|
42
|
+
await client.post(`/api/v1/members/${self.accountId}/key`).set('x-csrf-token', csrf).expect(404)
|
|
43
|
+
.expect(({ body }) => expect(body.error.code).toBe('MEMBER_NOT_FOUND'));
|
|
44
|
+
|
|
45
|
+
const history = await client.get('/api/v1/history').expect(200);
|
|
46
|
+
expect(history.body.data.map((entry: { actorEmail: string; summary: string }) => [entry.actorEmail, entry.summary])).toEqual([
|
|
47
|
+
[admin.email, `Revoked the key for ${agent.email}`],
|
|
48
|
+
[admin.email, `Created a key for ${agent.email}`],
|
|
49
|
+
[admin.email, `Created a key for ${agent.email}`],
|
|
50
|
+
[admin.email, `Added the agent account ${agent.email} as Member`],
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
// The agent access list starts empty, and a change to it adds one history row.
|
|
54
|
+
await client.get('/api/v1/agent-tools').expect(200).expect(({ body }) => expect(body.data).toEqual({ deleteAndRestore: [] }));
|
|
55
|
+
await client.put('/api/v1/agent-tools/projects').set('x-csrf-token', csrf).send({ deleteAndRestore: true }).expect(200)
|
|
56
|
+
.expect(({ body }) => expect(body.data).toEqual({ deleteAndRestore: ['projects'] }));
|
|
57
|
+
await client.put('/api/v1/agent-tools/Not%20a%20feature').set('x-csrf-token', csrf).send({ deleteAndRestore: true }).expect(400);
|
|
58
|
+
const changed = await client.get('/api/v1/history').expect(200);
|
|
59
|
+
expect(changed.body.data[0]).toMatchObject({ actorEmail: admin.email, summary: 'Turned on agent delete and restore for projects' });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('a member cannot add an agent account or change its key or agent access', async () => {
|
|
63
|
+
const { client, csrf } = await signedUpAdmin();
|
|
64
|
+
const agent = (await client.post('/api/v1/agents').set('x-csrf-token', csrf).send({ name: 'reports-bot', role: 'admin' }).expect(201)).body.data;
|
|
65
|
+
const invited = credentials();
|
|
66
|
+
const token = await invite(client, csrf, invited.email);
|
|
67
|
+
const member = request.agent(apiBaseUrl);
|
|
68
|
+
const memberCsrf = csrfToken(await member.post('/api/v1/auth/accept-invite').send({ ...invited, token }).expect(201));
|
|
69
|
+
|
|
70
|
+
for (const call of [
|
|
71
|
+
member.post('/api/v1/agents').set('x-csrf-token', memberCsrf).send({ name: 'sneaky', role: 'admin' }),
|
|
72
|
+
member.post(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', memberCsrf),
|
|
73
|
+
member.delete(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', memberCsrf),
|
|
74
|
+
member.get('/api/v1/agent-tools'),
|
|
75
|
+
member.put('/api/v1/agent-tools/projects').set('x-csrf-token', memberCsrf).send({ deleteAndRestore: true }),
|
|
76
|
+
]) {
|
|
77
|
+
await call.expect(403).expect(({ body }) => expect(body.error.code).toBe('ADMIN_ONLY'));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Another organisation's admin cannot reach this agent.
|
|
81
|
+
const other = await signedUpAdmin();
|
|
82
|
+
await other.client.post(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', other.csrf).expect(404)
|
|
83
|
+
.expect(({ body }) => expect(body.error.code).toBe('MEMBER_NOT_FOUND'));
|
|
84
|
+
await other.client.delete(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', other.csrf).expect(404);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('an agent account cannot sign in with a password', async () => {
|
|
88
|
+
const { client, csrf } = await signedUpAdmin();
|
|
89
|
+
const agent = (await client.post('/api/v1/agents').set('x-csrf-token', csrf).send({ name: 'gantry', role: 'admin' }).expect(201)).body.data;
|
|
90
|
+
expect(agent.role).toBe('admin');
|
|
91
|
+
const history = await client.get('/api/v1/history').expect(200);
|
|
92
|
+
expect(history.body.data[0].summary).toBe(`Added the agent account ${agent.email} as Admin`);
|
|
93
|
+
await client.post(`/api/v1/members/${agent.accountId}/key`).set('x-csrf-token', csrf).expect(201);
|
|
94
|
+
for (const password of ['correct-horse-battery-staple', 'x'.repeat(12)]) {
|
|
95
|
+
await request(apiBaseUrl).post('/api/v1/auth/sign-in').send({ email: agent.email, password }).expect(401)
|
|
96
|
+
.expect(({ body }) => expect(body.error.code).toBe('INVALID_CREDENTIALS'));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
3
|
+
import request from 'supertest';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { apiBaseUrl, credentials, csrfToken, logEvents, productionApiBaseUrl, type LogEvent } from './helpers';
|
|
6
|
+
|
|
7
|
+
function latestResetToken(service: 'api' | 'production-api'): string {
|
|
8
|
+
const event = logEvents(service).reverse().find(({ context }) => typeof context?.resetUrl === 'string');
|
|
9
|
+
if (!event) throw new Error(`The ${service} service did not log a test reset link.`);
|
|
10
|
+
const token = new URL(String(event.context?.resetUrl)).searchParams.get('token');
|
|
11
|
+
if (!token) throw new Error('The reset mail log has no reset token.');
|
|
12
|
+
return token;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function apiRequestLog(correlationId: string): LogEvent {
|
|
16
|
+
const matches = logEvents('api').filter(
|
|
17
|
+
(event) => event.message === 'API request' && event.correlationId === correlationId,
|
|
18
|
+
);
|
|
19
|
+
expect(matches).toHaveLength(1);
|
|
20
|
+
const [event] = matches;
|
|
21
|
+
if (!event) throw new Error('The API did not write one request log line.');
|
|
22
|
+
return event;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('starter API', () => {
|
|
26
|
+
// Test audit:
|
|
27
|
+
// 1. Protects the observable API request line, safe route fields and excluded health/web paths.
|
|
28
|
+
// 2. Fails if a request is omitted or duplicated, a real path or query is logged, or exclusions log a line.
|
|
29
|
+
// 3. Existing tests cover API responses, not request logs or their path filtering.
|
|
30
|
+
// 4. Uses the running API and needs no production test seam.
|
|
31
|
+
it('each API request writes one log line without its query string', async () => {
|
|
32
|
+
const searchWord = `project-search-${randomUUID()}`;
|
|
33
|
+
const missingWord = `missing-route-${randomUUID()}`;
|
|
34
|
+
const successSearchWord = `account-search-${randomUUID()}`;
|
|
35
|
+
const unauthorizedCorrelationId = randomUUID();
|
|
36
|
+
const projectCorrelationId = randomUUID();
|
|
37
|
+
const missingCorrelationId = randomUUID();
|
|
38
|
+
const successCorrelationId = randomUUID();
|
|
39
|
+
const preflightCorrelationId = randomUUID();
|
|
40
|
+
const healthCorrelationId = randomUUID();
|
|
41
|
+
const webCorrelationId = randomUUID();
|
|
42
|
+
|
|
43
|
+
await request(apiBaseUrl)
|
|
44
|
+
.get(`/api/v1/projects?search=${encodeURIComponent(searchWord)}`)
|
|
45
|
+
.set('x-correlation-id', unauthorizedCorrelationId)
|
|
46
|
+
.expect(401);
|
|
47
|
+
const unauthorizedLog = apiRequestLog(unauthorizedCorrelationId);
|
|
48
|
+
expect(unauthorizedLog).toMatchObject({
|
|
49
|
+
message: 'API request',
|
|
50
|
+
level: 'info',
|
|
51
|
+
correlationId: unauthorizedCorrelationId,
|
|
52
|
+
});
|
|
53
|
+
expect(unauthorizedLog.context).toEqual({
|
|
54
|
+
method: 'GET',
|
|
55
|
+
route: '/api/v1/projects',
|
|
56
|
+
status: 401,
|
|
57
|
+
durationMs: expect.any(Number),
|
|
58
|
+
});
|
|
59
|
+
expect(Number.isInteger(unauthorizedLog.context?.durationMs)).toBe(true);
|
|
60
|
+
expect(Number(unauthorizedLog.context?.durationMs)).toBeGreaterThanOrEqual(0);
|
|
61
|
+
|
|
62
|
+
await request(apiBaseUrl)
|
|
63
|
+
.get(`/api/v1/projects/${randomUUID()}`)
|
|
64
|
+
.set('x-correlation-id', projectCorrelationId)
|
|
65
|
+
.expect(401);
|
|
66
|
+
expect(apiRequestLog(projectCorrelationId).context).toMatchObject({
|
|
67
|
+
method: 'GET',
|
|
68
|
+
route: '/api/v1/projects/:id',
|
|
69
|
+
status: 401,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await request(apiBaseUrl)
|
|
73
|
+
.get(`/api/v1/${missingWord}`)
|
|
74
|
+
.set('x-correlation-id', missingCorrelationId)
|
|
75
|
+
.expect(404);
|
|
76
|
+
expect(apiRequestLog(missingCorrelationId).context).toMatchObject({
|
|
77
|
+
method: 'GET',
|
|
78
|
+
route: null,
|
|
79
|
+
status: 404,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const client = request.agent(apiBaseUrl);
|
|
83
|
+
await client.post('/api/v1/auth/sign-up').send(credentials()).expect(201);
|
|
84
|
+
await client
|
|
85
|
+
.get(`/api/v1/auth/me?search=${encodeURIComponent(successSearchWord)}`)
|
|
86
|
+
.set('x-correlation-id', successCorrelationId)
|
|
87
|
+
.expect(200);
|
|
88
|
+
expect(apiRequestLog(successCorrelationId).context).toMatchObject({
|
|
89
|
+
method: 'GET',
|
|
90
|
+
route: '/api/v1/auth/me',
|
|
91
|
+
status: 200,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
await request(apiBaseUrl)
|
|
95
|
+
.options('/api/v1/projects')
|
|
96
|
+
.set('Origin', new URL(apiBaseUrl).origin)
|
|
97
|
+
.set('Access-Control-Request-Method', 'POST')
|
|
98
|
+
.set('x-correlation-id', preflightCorrelationId)
|
|
99
|
+
.expect(204);
|
|
100
|
+
expect(apiRequestLog(preflightCorrelationId).context).toMatchObject({
|
|
101
|
+
method: 'OPTIONS',
|
|
102
|
+
route: null,
|
|
103
|
+
status: 204,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
await request(apiBaseUrl)
|
|
107
|
+
.get('/health')
|
|
108
|
+
.set('x-correlation-id', healthCorrelationId)
|
|
109
|
+
.expect(200);
|
|
110
|
+
await request(apiBaseUrl)
|
|
111
|
+
.get('/')
|
|
112
|
+
.set('Accept', 'text/html')
|
|
113
|
+
.set('x-correlation-id', webCorrelationId)
|
|
114
|
+
.expect(200);
|
|
115
|
+
expect(logEvents('api').filter((event) =>
|
|
116
|
+
event.correlationId === healthCorrelationId || event.correlationId === webCorrelationId,
|
|
117
|
+
)).toEqual([]);
|
|
118
|
+
|
|
119
|
+
const logs = execFileSync('docker', ['compose', '-f', 'compose.test.yml', 'logs', '--no-color', 'api'], { encoding: 'utf8' });
|
|
120
|
+
for (const word of [searchWord, missingWord, successSearchWord]) {
|
|
121
|
+
expect(logs).not.toContain(word);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Audit: inspect the real container user, which a compose override can change even
|
|
126
|
+
// with a non-root Dockerfile. The template check cannot reach that runtime contract.
|
|
127
|
+
// A root-user regression fails here without a production seam or a fake process.
|
|
128
|
+
it('the API container runs as a user that is not root', () => {
|
|
129
|
+
const result = spawnSync('docker', [
|
|
130
|
+
'compose', '-f', 'compose.test.yml', 'exec', '-T', 'api', 'id', '-u',
|
|
131
|
+
], { encoding: 'utf8', timeout: 20_000, killSignal: 'SIGKILL' });
|
|
132
|
+
expect(result.status, `${result.error?.message ?? ''}${result.stdout}${result.stderr}`).toBe(0);
|
|
133
|
+
expect(result.stdout.trim()).toMatch(/^\d+$/);
|
|
134
|
+
expect(result.stdout.trim()).not.toBe('0');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('signs up, signs in, and signs out with a server session', async () => {
|
|
138
|
+
const account = credentials();
|
|
139
|
+
const client = request.agent(apiBaseUrl);
|
|
140
|
+
const signUp = await client.post('/api/v1/auth/sign-up').send(account).expect(201);
|
|
141
|
+
|
|
142
|
+
expect(signUp.body).toMatchObject({ success: true, data: { email: account.email }, error: null });
|
|
143
|
+
expect(signUp.get('Set-Cookie')).toEqual(
|
|
144
|
+
expect.arrayContaining([expect.stringMatching(/starter_session=.*HttpOnly.*SameSite=Lax/)]),
|
|
145
|
+
);
|
|
146
|
+
expect((await client.get('/api/v1/auth/me').expect(200)).body.data.email).toBe(account.email);
|
|
147
|
+
|
|
148
|
+
await client
|
|
149
|
+
.post('/api/v1/auth/sign-out')
|
|
150
|
+
.set('x-csrf-token', csrfToken(signUp))
|
|
151
|
+
.expect(200);
|
|
152
|
+
await client.get('/api/v1/auth/me').expect(401);
|
|
153
|
+
|
|
154
|
+
const signIn = await client.post('/api/v1/auth/sign-in').send(account).expect(200);
|
|
155
|
+
expect(signIn.body.data.email).toBe(account.email);
|
|
156
|
+
await client.get('/api/v1/auth/me').expect(200);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('forgot-password gives the same response for known and unknown email addresses', async () => {
|
|
160
|
+
const account = credentials();
|
|
161
|
+
await request(apiBaseUrl).post('/api/v1/auth/sign-up').send(account).expect(201);
|
|
162
|
+
|
|
163
|
+
const known = await request(apiBaseUrl).post('/api/v1/auth/forgot-password').send({ email: account.email }).expect(200);
|
|
164
|
+
const unknown = await request(apiBaseUrl)
|
|
165
|
+
.post('/api/v1/auth/forgot-password')
|
|
166
|
+
.send({ email: `missing-${randomUUID()}@example.test` })
|
|
167
|
+
.expect(200);
|
|
168
|
+
|
|
169
|
+
expect(known.body).toEqual(unknown.body);
|
|
170
|
+
expect(known.body.data.message).toBe('If an account exists, a reset link has been sent.');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('resets a password once, signs out old sessions, and accepts the new password', async () => {
|
|
174
|
+
const account = credentials();
|
|
175
|
+
const client = request.agent(apiBaseUrl);
|
|
176
|
+
await client.post('/api/v1/auth/sign-up').send(account).expect(201);
|
|
177
|
+
await request(apiBaseUrl).post('/api/v1/auth/forgot-password').send({ email: account.email }).expect(200);
|
|
178
|
+
const token = latestResetToken('api');
|
|
179
|
+
const newPassword = 'different-correct-horse-password';
|
|
180
|
+
|
|
181
|
+
await request(apiBaseUrl).post('/api/v1/auth/reset-password').send({ token, password: newPassword }).expect(200);
|
|
182
|
+
await client.get('/api/v1/auth/me').expect(401);
|
|
183
|
+
await request(apiBaseUrl).post('/api/v1/auth/sign-in').send(account).expect(401);
|
|
184
|
+
await request(apiBaseUrl).post('/api/v1/auth/sign-in').send({ ...account, password: newPassword }).expect(200);
|
|
185
|
+
await request(apiBaseUrl).post('/api/v1/auth/reset-password').send({ token, password: account.password }).expect(400);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('rejects invalid input with field errors in the API envelope', async () => {
|
|
189
|
+
const response = await request(apiBaseUrl)
|
|
190
|
+
.post('/api/v1/auth/sign-up')
|
|
191
|
+
.send({ email: 'not-an-email', password: 'short', unexpected: true })
|
|
192
|
+
.expect(400);
|
|
193
|
+
|
|
194
|
+
expect(response.body).toMatchObject({
|
|
195
|
+
success: false,
|
|
196
|
+
data: null,
|
|
197
|
+
error: { code: 'VALIDATION_ERROR', message: 'Check the fields and try again.' },
|
|
198
|
+
});
|
|
199
|
+
expect(response.body.error.details.fieldErrors).toEqual(expect.arrayContaining([
|
|
200
|
+
expect.objectContaining({ field: 'email' }),
|
|
201
|
+
expect.objectContaining({ field: 'password' }),
|
|
202
|
+
expect.objectContaining({ field: 'unexpected' }),
|
|
203
|
+
]));
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('rejects cross-origin sign-in requests before they can change server state', async () => {
|
|
207
|
+
const response = await request(apiBaseUrl)
|
|
208
|
+
.post('/api/v1/auth/sign-up')
|
|
209
|
+
.set('Origin', 'https://attacker.example')
|
|
210
|
+
.send(credentials())
|
|
211
|
+
.expect(403);
|
|
212
|
+
expect(response.body.error.code).toBe('CSRF_CHECK_FAILED');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('production keeps the default rate limits on account routes and other routes', async () => {
|
|
216
|
+
// The test api service raises both limits; production-api keeps 30 and 120 a minute.
|
|
217
|
+
const signIns = [];
|
|
218
|
+
for (let attempt = 0; attempt < 31; attempt += 1) {
|
|
219
|
+
signIns.push((await request(productionApiBaseUrl).post('/api/v1/auth/sign-in').send({})).status);
|
|
220
|
+
}
|
|
221
|
+
expect(signIns.slice(0, 30)).not.toContain(429);
|
|
222
|
+
expect(signIns[30]).toBe(429);
|
|
223
|
+
const reads = [];
|
|
224
|
+
for (let attempt = 0; attempt < 121; attempt += 1) {
|
|
225
|
+
reads.push((await request(productionApiBaseUrl).get('/api/v1/auth/options')).status);
|
|
226
|
+
}
|
|
227
|
+
expect(reads.slice(0, 120)).not.toContain(429);
|
|
228
|
+
expect(reads[120]).toBe(429);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('production forgot-password does not log a reset link', async () => {
|
|
232
|
+
const account = credentials();
|
|
233
|
+
await request(productionApiBaseUrl).post('/api/v1/auth/sign-up').send(account).expect(201);
|
|
234
|
+
|
|
235
|
+
const known = await request(productionApiBaseUrl)
|
|
236
|
+
.post('/api/v1/auth/forgot-password')
|
|
237
|
+
.send({ email: account.email })
|
|
238
|
+
.expect(200);
|
|
239
|
+
const unknown = await request(productionApiBaseUrl)
|
|
240
|
+
.post('/api/v1/auth/forgot-password')
|
|
241
|
+
.send({ email: `missing-${randomUUID()}@example.test` })
|
|
242
|
+
.expect(200);
|
|
243
|
+
expect(known.body).toEqual(unknown.body);
|
|
244
|
+
|
|
245
|
+
const logs = execFileSync('docker', ['compose', '-f', 'compose.test.yml', 'logs', '--no-color', 'production-api'], { encoding: 'utf8' });
|
|
246
|
+
// A reset request logs its route. Links and their secret tokens must stay out.
|
|
247
|
+
expect(logs).not.toMatch(/https?:\/\/[^\s"]*\/reset-password|\/reset-password\?/);
|
|
248
|
+
expect(logs).not.toMatch(/[A-Za-z0-9_-]{43}/);
|
|
249
|
+
});
|
|
250
|
+
});
|