statement-fetch 0.5.0__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/CHANGELOG.md +34 -0
- statement_fetch-0.7.1/PKG-INFO +136 -0
- statement_fetch-0.7.1/README.md +115 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/pyproject.toml +7 -2
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/__init__.py +15 -1
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/_contracts.py +25 -1
- statement_fetch-0.7.1/src/statement_fetch/_playwright.py +1381 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/_registry.py +54 -2
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/_runner.py +309 -23
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/_staging.py +69 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/api.py +17 -1
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/cli.py +136 -13
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/tests/test_async_core_and_example.py +103 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/tests/test_demo_e2e_playwright.py +171 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/tests/test_public_hygiene.py +3 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/uv.lock +1 -1
- statement_fetch-0.5.0/PKG-INFO +0 -95
- statement_fetch-0.5.0/README.md +0 -74
- statement_fetch-0.5.0/src/statement_fetch/_playwright.py +0 -518
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/.github/workflows/ci.yml +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/.github/workflows/pypi.yml +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/.github/workflows/release.yml +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/.gitignore +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/CONTRIBUTING.md +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/LICENSE +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/Makefile +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/SECURITY.md +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/_validators.py +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/demo.py +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/providers/__init__.py +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/providers/example_bank.py +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/py.typed +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/sinks/__init__.py +0 -0
- {statement_fetch-0.5.0 → statement_fetch-0.7.1}/src/statement_fetch/sinks/directory.py +0 -0
|
@@ -2,6 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.7.1] - 2026-12-05
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- Tightened `_watch_post_login()` parameter annotations in `_runner.py` for strict `mypy>=1.14,<2` compatibility.
|
|
9
|
+
|
|
10
|
+
### Upgrade
|
|
11
|
+
- Action required: none.
|
|
12
|
+
- Rollback: compatible with `v0.7.0`.
|
|
13
|
+
|
|
14
|
+
## [0.7.0] - 2026-12-05
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- Pluggable browser host plugin contract (`HostPlugin` protocol and `statement_fetch.hosts` entry-point group) in `statement_fetch.api` and `PluginRegistry`.
|
|
18
|
+
- Built-in `--host chrome` (`ChromeProfileHost`): launches installed Google Chrome/Edge with a dedicated `0o700` persistent profile (preserving browser extensions and trusted-device cookies, full browser-context + CDP `Fetch.enable` confinement, `no_viewport=True`, and `--disable-blink-features=AutomationControlled`), plus `statement-fetch host-setup chrome` for one-time extension setup.
|
|
19
|
+
- Built-in `--host chrome-attach` (`CdpChromeHost`): attaches to an already-running Chrome via `DevToolsActivePort` auto-discovery or explicit loopback/TLS `--host-opt cdp_url=...`, with per-tab CDP `Fetch.enable` confinement, scoped `Browser.setDownloadBehavior` that leaves unrelated Chrome downloads untouched, and non-destructive tab-only teardown.
|
|
20
|
+
- Host-aware `statement-fetch doctor --host <id>` and `--host` / `--host-opt KEY=VALUE` across `fetch`, `accounts`, and `doctor`.
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
- `NativePage.download()` now captures downloads triggered inside popup interstitial pages (`target="_blank"` wait pages) and automatically closes download-only popup tabs.
|
|
24
|
+
- Fixed a CDP deadlock in `_install_host_guard()` on popup navigations and registered `Fetch.requestPaused` listeners before `Fetch.enable`.
|
|
25
|
+
|
|
26
|
+
### Upgrade
|
|
27
|
+
- Action required: none.
|
|
28
|
+
- Rollback: compatible with `v0.5.1`.
|
|
29
|
+
|
|
30
|
+
## [0.5.1] - 2026-12-05
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
- Broadened package description, CLI help text, and README positioning beyond banking to cover all authenticated document/statement/invoice web portals (insurance, utilities/SaaS billing, payroll/HR, private funds, government/tax, and downstream sinks).
|
|
34
|
+
|
|
35
|
+
### Upgrade
|
|
36
|
+
- Action required: none.
|
|
37
|
+
- Rollback: compatible with `v0.5.0`.
|
|
38
|
+
|
|
5
39
|
## [0.5.0] - 2026-12-05
|
|
6
40
|
|
|
7
41
|
### Added
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: statement-fetch
|
|
3
|
+
Version: 0.7.1
|
|
4
|
+
Summary: Zero-LLM async fetcher, structural validator, and pluggable sink runner for statements, invoices, and documents from authenticated web portals.
|
|
5
|
+
Project-URL: Homepage, https://github.com/benjamin-di/statement-fetch-oss
|
|
6
|
+
Project-URL: Repository, https://github.com/benjamin-di/statement-fetch-oss
|
|
7
|
+
Author: benjamin-di
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Provides-Extra: playwright
|
|
19
|
+
Requires-Dist: playwright<2,>=1.52; extra == 'playwright'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# statement-fetch
|
|
23
|
+
|
|
24
|
+
Zero-LLM async fetcher, structural validator, and pluggable sink runner for statements, invoices, and documents from authenticated web portals.
|
|
25
|
+
|
|
26
|
+
## What It's For
|
|
27
|
+
|
|
28
|
+
Any web portal behind human login/2FA that periodically issues PDFs, CSVs, JSONs, or ZIP archives can be automated as a small deterministic provider plugin — without ever handing credentials or live portal sessions to an LLM:
|
|
29
|
+
|
|
30
|
+
- **Banking, cards & brokerage:** monthly statements, transaction CSVs, trade confirmations, custody and tax reports.
|
|
31
|
+
- **Private funds & wealth portals:** quarterly partner reports, capital calls, distributions, K-1s, and audit letters.
|
|
32
|
+
- **Insurance & healthcare:** policy documents, claims summaries, explanation-of-benefits (EOBs), and annual tax certificates from insurer postboxes.
|
|
33
|
+
- **Billing, utilities & SaaS/cloud:** monthly VAT invoices and usage exports from telecoms, utilities, cloud providers, and SaaS billing portals.
|
|
34
|
+
- **Payroll, HR & pensions:** payslips, annual wage/tax statements, and retirement or pension summaries.
|
|
35
|
+
- **Government, tax & property:** tax assessment notices, social-security records, and mortgage/HOA/property-management statements.
|
|
36
|
+
- **Downstream pipelines (via `statement_fetch.sinks`):** route verified, SHA-256-hashed manifests directly into personal accounting ledgers, document management systems (e.g. Paperless-ngx), encrypted local folders, or private knowledge bases.
|
|
37
|
+
|
|
38
|
+
## Security Model ("Zero-LLM-in-Portal")
|
|
39
|
+
|
|
40
|
+
1. **Human sign-in:** A real Chromium browser opens the portal's login URL. The human completes authentication and 2FA; no credentials or LLM tokens touch the live session.
|
|
41
|
+
2. **Host confinement:** Top-level navigations, HTTP 3xx redirects (single/multi-hop and POST), `target="_blank"` popups, and in-page `fetch_bytes()` calls are confined to the provider's declared `allowed_hosts` via Chromium CDP `Fetch.enable` and context routing.
|
|
42
|
+
3. **Deterministic fetch & atomic staging:** After `is_logged_in()` succeeds, deterministic provider code downloads documents into a per-run `0o700` staging directory, validates every artifact using its declared validator (defaulting to non-empty; built-in validators cover PDF, CSV, JSON, and bounded ZIP), writes `0o600` artifacts with SHA-256 digests, and produces a portable `manifest.json`.
|
|
43
|
+
4. **Guaranteed logoff & pluggable sinks:** `logoff()` and browser teardown run in `finally:` even on error or Ctrl-C. Sinks (`statement_fetch.sinks`) verify every manifest entry and SHA-256 before delivering.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Requires Python 3.11+:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install "statement-fetch[playwright]"
|
|
51
|
+
playwright install chromium
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quickstart (Demo Portal, From a Clone)
|
|
55
|
+
|
|
56
|
+
Install Chromium into the project environment:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
uv run --extra playwright playwright install chromium
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
In one terminal, start the bundled zero-dependency loopback demo portal:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
uv run python -m statement_fetch.demo --port 8765
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
In another terminal, fetch statements and export them to a local directory with an immutable receipt manifest:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
uv run --extra playwright statement-fetch fetch example-bank \
|
|
72
|
+
--opt base_url=http://127.0.0.1:8765 \
|
|
73
|
+
--upload --sink dir --sink-dir ./exported
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Verify a staged or exported manifest offline:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
uv run statement-fetch upload ./exported/manifest-*.json --local-only --json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Browser Hosts (`--host`)
|
|
83
|
+
|
|
84
|
+
`statement-fetch` supports three built-in browser hosts (all via the optional `[playwright]` extra, with zero browser extensions or background daemons):
|
|
85
|
+
|
|
86
|
+
| Host | Command | Best for | Confinement |
|
|
87
|
+
|---|---|---|---|
|
|
88
|
+
| `playwright` *(default)* | `--host playwright` | Isolated ephemeral Playwright Chromium | Full browser-context + CDP `Fetch.enable` + popup confinement |
|
|
89
|
+
| `chrome` | `--host chrome` *(optional `--host-opt profile=<dir>`)* | Installed Google Chrome with a dedicated `0o700` persistent profile (keeps password-manager extensions & trusted-device cookies; no `playwright install chromium` needed) | Full browser-context + CDP `Fetch.enable` + popup confinement |
|
|
90
|
+
| `chrome-attach` | `--host chrome-attach` *(optional `--host-opt cdp_url=...`)* | Attaching to your already-open Chrome via `chrome://inspect/#remote-debugging` (auto-discovers `DevToolsActivePort`, never closes Chrome or other tabs) | Tab-scoped CDP `Fetch.enable` (main tab + 3xx redirects + `fetch_bytes`; shares your live Chrome context) |
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Check host readiness (does not require bundled Chromium for chrome / chrome-attach)
|
|
94
|
+
statement-fetch doctor --host chrome
|
|
95
|
+
statement-fetch doctor --host chrome-attach
|
|
96
|
+
|
|
97
|
+
# Optional one-time setup for --host chrome (install password-manager extensions into the dedicated profile, then close Chrome)
|
|
98
|
+
statement-fetch host-setup chrome
|
|
99
|
+
|
|
100
|
+
# Run with installed Chrome (persistent dedicated profile)
|
|
101
|
+
statement-fetch fetch example-bank --host chrome --opt base_url=http://127.0.0.1:8765
|
|
102
|
+
|
|
103
|
+
# Attach to your already-running Chrome (enable chrome://inspect/#remote-debugging once)
|
|
104
|
+
statement-fetch fetch example-bank --host chrome-attach --opt base_url=http://127.0.0.1:8765
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Plugin API (`API_VERSION = 1`)
|
|
108
|
+
|
|
109
|
+
Third-party providers, sinks, and browser hosts import from `statement_fetch.api` (or top-level `statement_fetch`) and register via Python entry points:
|
|
110
|
+
|
|
111
|
+
```toml
|
|
112
|
+
[project.entry-points."statement_fetch.providers"]
|
|
113
|
+
my-portal = "my_pkg.provider:MyPortalProvider"
|
|
114
|
+
|
|
115
|
+
[project.entry-points."statement_fetch.sinks"]
|
|
116
|
+
my-sink = "my_pkg.sink:MySink"
|
|
117
|
+
|
|
118
|
+
[project.entry-points."statement_fetch.hosts"]
|
|
119
|
+
my-host = "my_pkg.host:MyHostPlugin"
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- Reference provider: `src/statement_fetch/providers/example_bank.py`
|
|
123
|
+
- Reference sink: `src/statement_fetch/sinks/directory.py`
|
|
124
|
+
- Built-in hosts: `PlaywrightHostPlugin`, `ChromeHostPlugin`, `CdpChromeHostPlugin` in `statement_fetch.api`
|
|
125
|
+
- Versioning: the entry-point group names (`statement_fetch.providers`, `statement_fetch.sinks`, `statement_fetch.hosts`) define the `API_VERSION = 1` compatibility boundary.
|
|
126
|
+
|
|
127
|
+
## CLI Exit Codes & Manifest Schema
|
|
128
|
+
|
|
129
|
+
- **Exit codes:** `0` (`EXIT_OK`, ok/empty), `1` (`EXIT_ERROR`), `2` (`EXIT_USAGE`), `3` (`EXIT_LOGIN_TIMEOUT`), `4` (`EXIT_PARTIAL`), `130` (interrupted / Ctrl-C).
|
|
130
|
+
- **`manifest.json` (`schema_version = 1`):** `schema_version`, `api_version`, `tool_version`, `created_at`, `provider`, `period_start`, `period_end`, `artifacts[]` (`artifact_id`, `name`, `path` relative to manifest dir, `sha256`, `bytes`, `provider`, `kind`, `period`, `valid`, optional `currency`/`error`/`observed_start`/`observed_end`/`meta`), `skipped[]`, `errors[]`, `timings_s`.
|
|
131
|
+
|
|
132
|
+
## Development Checks
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
make check
|
|
136
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# statement-fetch
|
|
2
|
+
|
|
3
|
+
Zero-LLM async fetcher, structural validator, and pluggable sink runner for statements, invoices, and documents from authenticated web portals.
|
|
4
|
+
|
|
5
|
+
## What It's For
|
|
6
|
+
|
|
7
|
+
Any web portal behind human login/2FA that periodically issues PDFs, CSVs, JSONs, or ZIP archives can be automated as a small deterministic provider plugin — without ever handing credentials or live portal sessions to an LLM:
|
|
8
|
+
|
|
9
|
+
- **Banking, cards & brokerage:** monthly statements, transaction CSVs, trade confirmations, custody and tax reports.
|
|
10
|
+
- **Private funds & wealth portals:** quarterly partner reports, capital calls, distributions, K-1s, and audit letters.
|
|
11
|
+
- **Insurance & healthcare:** policy documents, claims summaries, explanation-of-benefits (EOBs), and annual tax certificates from insurer postboxes.
|
|
12
|
+
- **Billing, utilities & SaaS/cloud:** monthly VAT invoices and usage exports from telecoms, utilities, cloud providers, and SaaS billing portals.
|
|
13
|
+
- **Payroll, HR & pensions:** payslips, annual wage/tax statements, and retirement or pension summaries.
|
|
14
|
+
- **Government, tax & property:** tax assessment notices, social-security records, and mortgage/HOA/property-management statements.
|
|
15
|
+
- **Downstream pipelines (via `statement_fetch.sinks`):** route verified, SHA-256-hashed manifests directly into personal accounting ledgers, document management systems (e.g. Paperless-ngx), encrypted local folders, or private knowledge bases.
|
|
16
|
+
|
|
17
|
+
## Security Model ("Zero-LLM-in-Portal")
|
|
18
|
+
|
|
19
|
+
1. **Human sign-in:** A real Chromium browser opens the portal's login URL. The human completes authentication and 2FA; no credentials or LLM tokens touch the live session.
|
|
20
|
+
2. **Host confinement:** Top-level navigations, HTTP 3xx redirects (single/multi-hop and POST), `target="_blank"` popups, and in-page `fetch_bytes()` calls are confined to the provider's declared `allowed_hosts` via Chromium CDP `Fetch.enable` and context routing.
|
|
21
|
+
3. **Deterministic fetch & atomic staging:** After `is_logged_in()` succeeds, deterministic provider code downloads documents into a per-run `0o700` staging directory, validates every artifact using its declared validator (defaulting to non-empty; built-in validators cover PDF, CSV, JSON, and bounded ZIP), writes `0o600` artifacts with SHA-256 digests, and produces a portable `manifest.json`.
|
|
22
|
+
4. **Guaranteed logoff & pluggable sinks:** `logoff()` and browser teardown run in `finally:` even on error or Ctrl-C. Sinks (`statement_fetch.sinks`) verify every manifest entry and SHA-256 before delivering.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Requires Python 3.11+:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install "statement-fetch[playwright]"
|
|
30
|
+
playwright install chromium
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quickstart (Demo Portal, From a Clone)
|
|
34
|
+
|
|
35
|
+
Install Chromium into the project environment:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uv run --extra playwright playwright install chromium
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
In one terminal, start the bundled zero-dependency loopback demo portal:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv run python -m statement_fetch.demo --port 8765
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
In another terminal, fetch statements and export them to a local directory with an immutable receipt manifest:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
uv run --extra playwright statement-fetch fetch example-bank \
|
|
51
|
+
--opt base_url=http://127.0.0.1:8765 \
|
|
52
|
+
--upload --sink dir --sink-dir ./exported
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Verify a staged or exported manifest offline:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv run statement-fetch upload ./exported/manifest-*.json --local-only --json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Browser Hosts (`--host`)
|
|
62
|
+
|
|
63
|
+
`statement-fetch` supports three built-in browser hosts (all via the optional `[playwright]` extra, with zero browser extensions or background daemons):
|
|
64
|
+
|
|
65
|
+
| Host | Command | Best for | Confinement |
|
|
66
|
+
|---|---|---|---|
|
|
67
|
+
| `playwright` *(default)* | `--host playwright` | Isolated ephemeral Playwright Chromium | Full browser-context + CDP `Fetch.enable` + popup confinement |
|
|
68
|
+
| `chrome` | `--host chrome` *(optional `--host-opt profile=<dir>`)* | Installed Google Chrome with a dedicated `0o700` persistent profile (keeps password-manager extensions & trusted-device cookies; no `playwright install chromium` needed) | Full browser-context + CDP `Fetch.enable` + popup confinement |
|
|
69
|
+
| `chrome-attach` | `--host chrome-attach` *(optional `--host-opt cdp_url=...`)* | Attaching to your already-open Chrome via `chrome://inspect/#remote-debugging` (auto-discovers `DevToolsActivePort`, never closes Chrome or other tabs) | Tab-scoped CDP `Fetch.enable` (main tab + 3xx redirects + `fetch_bytes`; shares your live Chrome context) |
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Check host readiness (does not require bundled Chromium for chrome / chrome-attach)
|
|
73
|
+
statement-fetch doctor --host chrome
|
|
74
|
+
statement-fetch doctor --host chrome-attach
|
|
75
|
+
|
|
76
|
+
# Optional one-time setup for --host chrome (install password-manager extensions into the dedicated profile, then close Chrome)
|
|
77
|
+
statement-fetch host-setup chrome
|
|
78
|
+
|
|
79
|
+
# Run with installed Chrome (persistent dedicated profile)
|
|
80
|
+
statement-fetch fetch example-bank --host chrome --opt base_url=http://127.0.0.1:8765
|
|
81
|
+
|
|
82
|
+
# Attach to your already-running Chrome (enable chrome://inspect/#remote-debugging once)
|
|
83
|
+
statement-fetch fetch example-bank --host chrome-attach --opt base_url=http://127.0.0.1:8765
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Plugin API (`API_VERSION = 1`)
|
|
87
|
+
|
|
88
|
+
Third-party providers, sinks, and browser hosts import from `statement_fetch.api` (or top-level `statement_fetch`) and register via Python entry points:
|
|
89
|
+
|
|
90
|
+
```toml
|
|
91
|
+
[project.entry-points."statement_fetch.providers"]
|
|
92
|
+
my-portal = "my_pkg.provider:MyPortalProvider"
|
|
93
|
+
|
|
94
|
+
[project.entry-points."statement_fetch.sinks"]
|
|
95
|
+
my-sink = "my_pkg.sink:MySink"
|
|
96
|
+
|
|
97
|
+
[project.entry-points."statement_fetch.hosts"]
|
|
98
|
+
my-host = "my_pkg.host:MyHostPlugin"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- Reference provider: `src/statement_fetch/providers/example_bank.py`
|
|
102
|
+
- Reference sink: `src/statement_fetch/sinks/directory.py`
|
|
103
|
+
- Built-in hosts: `PlaywrightHostPlugin`, `ChromeHostPlugin`, `CdpChromeHostPlugin` in `statement_fetch.api`
|
|
104
|
+
- Versioning: the entry-point group names (`statement_fetch.providers`, `statement_fetch.sinks`, `statement_fetch.hosts`) define the `API_VERSION = 1` compatibility boundary.
|
|
105
|
+
|
|
106
|
+
## CLI Exit Codes & Manifest Schema
|
|
107
|
+
|
|
108
|
+
- **Exit codes:** `0` (`EXIT_OK`, ok/empty), `1` (`EXIT_ERROR`), `2` (`EXIT_USAGE`), `3` (`EXIT_LOGIN_TIMEOUT`), `4` (`EXIT_PARTIAL`), `130` (interrupted / Ctrl-C).
|
|
109
|
+
- **`manifest.json` (`schema_version = 1`):** `schema_version`, `api_version`, `tool_version`, `created_at`, `provider`, `period_start`, `period_end`, `artifacts[]` (`artifact_id`, `name`, `path` relative to manifest dir, `sha256`, `bytes`, `provider`, `kind`, `period`, `valid`, optional `currency`/`error`/`observed_start`/`observed_end`/`meta`), `skipped[]`, `errors[]`, `timings_s`.
|
|
110
|
+
|
|
111
|
+
## Development Checks
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
make check
|
|
115
|
+
```
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "statement-fetch"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Zero-LLM
|
|
7
|
+
version = "0.7.1"
|
|
8
|
+
description = "Zero-LLM async fetcher, structural validator, and pluggable sink runner for statements, invoices, and documents from authenticated web portals."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
authors = [{ name = "benjamin-di" }]
|
|
@@ -39,6 +39,11 @@ example-bank = "statement_fetch.providers.example_bank:ExampleBankProvider"
|
|
|
39
39
|
[project.entry-points."statement_fetch.sinks"]
|
|
40
40
|
dir = "statement_fetch.sinks.directory:DirectorySink"
|
|
41
41
|
|
|
42
|
+
[project.entry-points."statement_fetch.hosts"]
|
|
43
|
+
playwright = "statement_fetch._playwright:PlaywrightHostPlugin"
|
|
44
|
+
chrome = "statement_fetch._playwright:ChromeHostPlugin"
|
|
45
|
+
chrome-attach = "statement_fetch._playwright:CdpChromeHostPlugin"
|
|
46
|
+
|
|
42
47
|
[tool.hatch.build.targets.wheel]
|
|
43
48
|
packages = ["src/statement_fetch"]
|
|
44
49
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""statement-fetch: Zero-LLM
|
|
1
|
+
"""statement-fetch: Zero-LLM async fetcher, validator, and pluggable sink runner for authenticated web portals."""
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
from . import api
|
|
@@ -9,6 +9,7 @@ from .api import (
|
|
|
9
9
|
EXIT_OK,
|
|
10
10
|
EXIT_PARTIAL,
|
|
11
11
|
EXIT_USAGE,
|
|
12
|
+
HOST_ENTRY_POINT_GROUP,
|
|
12
13
|
MANIFEST_SCHEMA_VERSION,
|
|
13
14
|
PROVIDER_ENTRY_POINT_GROUP,
|
|
14
15
|
SINK_ENTRY_POINT_GROUP,
|
|
@@ -17,6 +18,10 @@ from .api import (
|
|
|
17
18
|
AccountsRequest,
|
|
18
19
|
Artifact,
|
|
19
20
|
ArtifactSpec,
|
|
21
|
+
CdpChromeHost,
|
|
22
|
+
CdpChromeHostPlugin,
|
|
23
|
+
ChromeHostPlugin,
|
|
24
|
+
ChromeProfileHost,
|
|
20
25
|
Click,
|
|
21
26
|
DownloadMismatchError,
|
|
22
27
|
DownloadTimeoutError,
|
|
@@ -27,6 +32,7 @@ from .api import (
|
|
|
27
32
|
FetchResult,
|
|
28
33
|
FrameLocator,
|
|
29
34
|
Host,
|
|
35
|
+
HostPlugin,
|
|
30
36
|
Keyboard,
|
|
31
37
|
Locator,
|
|
32
38
|
LoginTimeoutError,
|
|
@@ -34,6 +40,7 @@ from .api import (
|
|
|
34
40
|
OptionSpec,
|
|
35
41
|
Page,
|
|
36
42
|
PlaywrightHost,
|
|
43
|
+
PlaywrightHostPlugin,
|
|
37
44
|
PluginRegistry,
|
|
38
45
|
Provider,
|
|
39
46
|
ProviderSpec,
|
|
@@ -70,6 +77,7 @@ __all__ = [
|
|
|
70
77
|
"EXIT_OK",
|
|
71
78
|
"EXIT_PARTIAL",
|
|
72
79
|
"EXIT_USAGE",
|
|
80
|
+
"HOST_ENTRY_POINT_GROUP",
|
|
73
81
|
"MANIFEST_SCHEMA_VERSION",
|
|
74
82
|
"PROVIDER_ENTRY_POINT_GROUP",
|
|
75
83
|
"SINK_ENTRY_POINT_GROUP",
|
|
@@ -78,6 +86,10 @@ __all__ = [
|
|
|
78
86
|
"AccountsRequest",
|
|
79
87
|
"Artifact",
|
|
80
88
|
"ArtifactSpec",
|
|
89
|
+
"CdpChromeHost",
|
|
90
|
+
"CdpChromeHostPlugin",
|
|
91
|
+
"ChromeHostPlugin",
|
|
92
|
+
"ChromeProfileHost",
|
|
81
93
|
"Click",
|
|
82
94
|
"DownloadMismatchError",
|
|
83
95
|
"DownloadTimeoutError",
|
|
@@ -88,6 +100,7 @@ __all__ = [
|
|
|
88
100
|
"FetchResult",
|
|
89
101
|
"FrameLocator",
|
|
90
102
|
"Host",
|
|
103
|
+
"HostPlugin",
|
|
91
104
|
"Keyboard",
|
|
92
105
|
"Locator",
|
|
93
106
|
"LoginTimeoutError",
|
|
@@ -95,6 +108,7 @@ __all__ = [
|
|
|
95
108
|
"OptionSpec",
|
|
96
109
|
"Page",
|
|
97
110
|
"PlaywrightHost",
|
|
111
|
+
"PlaywrightHostPlugin",
|
|
98
112
|
"PluginRegistry",
|
|
99
113
|
"Provider",
|
|
100
114
|
"ProviderSpec",
|
|
@@ -17,6 +17,7 @@ API_VERSION = 1
|
|
|
17
17
|
MANIFEST_SCHEMA_VERSION = 1
|
|
18
18
|
PROVIDER_ENTRY_POINT_GROUP = "statement_fetch.providers"
|
|
19
19
|
SINK_ENTRY_POINT_GROUP = "statement_fetch.sinks"
|
|
20
|
+
HOST_ENTRY_POINT_GROUP = "statement_fetch.hosts"
|
|
20
21
|
|
|
21
22
|
EXIT_OK = 0
|
|
22
23
|
EXIT_ERROR = 1
|
|
@@ -179,6 +180,17 @@ class Host(Protocol):
|
|
|
179
180
|
async def close(self) -> None: ...
|
|
180
181
|
|
|
181
182
|
|
|
183
|
+
@runtime_checkable
|
|
184
|
+
class HostPlugin(Protocol):
|
|
185
|
+
"""Pluggable browser host factory registered via `statement_fetch.hosts` entry points."""
|
|
186
|
+
|
|
187
|
+
id: str
|
|
188
|
+
|
|
189
|
+
def validate_config(self, config: Mapping[str, str] | None = None) -> None: ...
|
|
190
|
+
def create(self, config: Mapping[str, str] | None = None) -> Host: ...
|
|
191
|
+
def check_health(self, config: Mapping[str, str] | None = None) -> dict[str, Any]: ...
|
|
192
|
+
|
|
193
|
+
|
|
182
194
|
# ---------------------------------------------------------------------------
|
|
183
195
|
# Validation, specification, request, artifact, and result contracts
|
|
184
196
|
# ---------------------------------------------------------------------------
|
|
@@ -205,6 +217,12 @@ class ArtifactSpec:
|
|
|
205
217
|
description: str = ""
|
|
206
218
|
validator: ValidatorFn | None = None
|
|
207
219
|
aliases: tuple[str, ...] = ()
|
|
220
|
+
period_mode: Literal["listing", "range", "single_period"] = "range"
|
|
221
|
+
cadence: Literal["daily", "monthly", "quarterly", "annual", "on_demand"] = "monthly"
|
|
222
|
+
max_lookback_days: int | None = None
|
|
223
|
+
max_span_days: int | None = None
|
|
224
|
+
content_addressed: bool = True
|
|
225
|
+
archive: bool = False
|
|
208
226
|
|
|
209
227
|
|
|
210
228
|
@dataclass(frozen=True)
|
|
@@ -307,6 +325,12 @@ class ProviderSpec:
|
|
|
307
325
|
"default": bool(a.default),
|
|
308
326
|
"description": a.description,
|
|
309
327
|
"aliases": list(a.aliases),
|
|
328
|
+
"period_mode": a.period_mode,
|
|
329
|
+
"cadence": a.cadence,
|
|
330
|
+
"max_lookback_days": a.max_lookback_days,
|
|
331
|
+
"max_span_days": a.max_span_days,
|
|
332
|
+
"content_addressed": bool(a.content_addressed),
|
|
333
|
+
"archive": bool(a.archive),
|
|
310
334
|
}
|
|
311
335
|
for a in self.artifacts
|
|
312
336
|
],
|
|
@@ -413,7 +437,7 @@ class Artifact:
|
|
|
413
437
|
@dataclass(frozen=True)
|
|
414
438
|
class FetchResult:
|
|
415
439
|
provider: str
|
|
416
|
-
status: Literal["ok", "empty", "partial", "login_timeout", "error"]
|
|
440
|
+
status: Literal["ok", "empty", "partial", "login_timeout", "window_closed", "error"]
|
|
417
441
|
stage_dir: Path | None
|
|
418
442
|
manifest_path: Path | None
|
|
419
443
|
artifacts: tuple[Artifact, ...] = ()
|