from __future__ import annotations

from product_data_portable import emit_error, emit_success, load_json_payload, load_records, validate_dataset_records


def main() -> int:
    try:
        payload = load_json_payload()
        records = load_records(payload)
        emit_success(validate_dataset_records(records))
        return 0
    except Exception as exc:  # noqa: BLE001 - CLI 需要把错误稳定转成 JSON
        emit_error(exc)
        return 1


if __name__ == "__main__":
    raise SystemExit(main())
