Rewrite frontend types and HTTP client in src.
Export names match the leftover pages. Billing HTTP wrappers stay so gateway seams are not restyled here.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Native frontend types and API client live under periscope/src."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SRC = ROOT / "periscope" / "src" / "frontend" / "src" / "lib"
|
||||
DEP = ROOT / "periscope" / "dependency" / "frontend" / "src" / "lib"
|
||||
|
||||
|
||||
def _exports(path: Path) -> set[str]:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
names = set(re.findall(r"^export (?:async )?function (\w+)", text, re.M))
|
||||
names |= set(re.findall(r"^export (?:interface|type|class|const) (\w+)", text, re.M))
|
||||
return names
|
||||
|
||||
|
||||
def test_frontend_lib_is_src():
|
||||
for name in ("api.ts", "types.ts", "utils.ts"):
|
||||
path = SRC / name
|
||||
assert path.is_file(), name
|
||||
head = path.read_text(encoding="utf-8")[:400]
|
||||
assert "Native Periscope overlay" not in head
|
||||
|
||||
|
||||
def test_api_keeps_page_exports():
|
||||
src = _exports(SRC / "api.ts")
|
||||
dep = _exports(DEP / "api.ts")
|
||||
missing = dep - src
|
||||
assert not missing, sorted(missing)
|
||||
|
||||
|
||||
def test_types_keep_page_exports():
|
||||
src = _exports(SRC / "types.ts")
|
||||
dep = _exports(DEP / "types.ts")
|
||||
missing = dep - src
|
||||
assert not missing, sorted(missing)
|
||||
Reference in New Issue
Block a user