main
md 52 lines 2.5 KB
Rendered Raw
1 # api_files_get.py DOX
2
3 ## Purpose
4
5 - Own the `api_files_get.py` API endpoint.
6 - This module returns downloadable or inspectable files exposed through the external API surface.
7 - Keep this file-level DOX profile synchronized with `api_files_get.py` because this directory is intentionally flat.
8
9 ## Ownership
10
11 - `api_files_get.py` owns the runtime implementation.
12 - `api_files_get.py.dox.md` owns durable notes about responsibilities, contracts, side effects, and verification for that implementation.
13 - Classes:
14 - `ApiFilesGet` (`ApiHandler`)
15 - `requires_auth(cls) -> bool`
16 - `requires_csrf(cls) -> bool`
17 - `requires_api_key(cls) -> bool`
18 - `get_methods(cls) -> list[str]`
19 - `async process(self, input: dict, request: Request) -> dict | Response`
20
21 ## Runtime Contracts
22
23 - HTTP handlers must derive from `helpers.api.ApiHandler`; WebSocket handlers must derive from `helpers.ws.WsHandler`.
24 - Update this file whenever request payloads, authentication or CSRF requirements, response shapes, route side effects, or WebSocket event contracts change.
25 - `ApiFilesGet` is an `ApiHandler`.
26 - `ApiFilesGet` defines `process(...)`.
27 - `ApiFilesGet` defines `get_methods(...)`.
28 - `ApiFilesGet` defines `requires_auth(...)`.
29 - `ApiFilesGet` defines `requires_csrf(...)`.
30 - `ApiFilesGet` defines `requires_api_key(...)`.
31 - Observed side-effect areas: filesystem reads, filesystem writes, settings/state persistence.
32 - Imported dependency areas include: `base64`, `helpers`, `helpers.api`, `helpers.print_style`, `json`, `os`.
33
34 ## Key Concepts
35
36 - Important called helpers/classes observed in the source: `Response`, `PrintStyle.error`, `path.startswith`, `PrintStyle`, `json.dumps`, `path.replace`, `files.get_abs_path`, `os.path.basename`, `os.path.exists`, `PrintStyle.warning`, `f.read`, `base64.b64encode.decode`, `base64.b64encode`.
37 - Keep request/response, tool, or helper semantics documented here at the same time as source changes.
38
39 ## Work Guidance
40
41 - Preserve authentication, CSRF, loopback, and API-key checks unless the endpoint contract explicitly changes.
42 - Update frontend callers, plugin callers, and tests together when payload shape changes.
43 - Use `helpers.api.Response` for non-JSON responses, files, redirects, or status-specific replies.
44
45 ## Verification
46
47 - Run endpoint-specific or API/WebSocket tests for changed behavior; smoke-test browser callers when no focused test exists.
48 - No direct test reference was found by name search; choose the nearest behavioral test or perform a focused smoke check.
49
50 ## Child DOX Index
51
52 No child DOX files.