# Developer commands for the uniqos Python SDK.
# Mirrors the pnpm scripts of the TS SDK; all commands run through uv (ADR PY-0003).
#
#   make install   # create the venv and install the package + dev tools
#   make generate  # regenerate models from the shared OpenAPI snapshot (ADR PY-0004)
#   make check     # format-check + lint + typecheck + test (what CI runs)

.PHONY: install generate lint format format-check typecheck test build check clean

# Shared OpenAPI snapshot at the monorepo root — the SAME file the TS SDK reads.
OPENAPI := ../../openapi/openapi.json
GENERATED := src/uniqos/generated

install:
	uv sync

# Regenerate the streaming-event dataclasses from the shared OpenAPI snapshot.
# Scoped to `schemas` (the contract's only 6 named schemas, all streaming — ADR PY-0004).
# --disable-timestamp keeps the output byte-stable so regeneration is a no-op when the
# snapshot is unchanged (CI verifies with `git diff --exit-code`).
generate:
	uv run datamodel-codegen \
		--input $(OPENAPI) \
		--input-file-type openapi \
		--output $(GENERATED)/stream_events.py \
		--output-model-type dataclasses.dataclass \
		--openapi-scopes schemas \
		--enum-field-as-literal all \
		--frozen-dataclasses \
		--keyword-only \
		--target-python-version 3.10 \
		--use-standard-collections \
		--use-union-operator \
		--use-schema-description \
		--disable-timestamp

lint:
	uv run ruff check src tests examples

format:
	uv run ruff format src tests examples

format-check:
	uv run ruff format --check src tests examples

typecheck:
	uv run mypy

test:
	uv run pytest

build:
	uv build

check: format-check lint typecheck test

clean:
	rm -rf dist build .mypy_cache .ruff_cache .pytest_cache
	find . -type d -name __pycache__ -prune -exec rm -rf {} +
