pvoutput-client 0.0.3

Client for the PVOutput.org API
Documentation
//! Regex patterns for parsing error responses.
//! See the tests in `/src/tests/parse/error.rs` for examples of what these patterns parse.

use std::sync::LazyLock;

use regex_lite::Regex;

/// Groups:
/// 1. Date (possibly)
/// 2. Date (possibly)
pub static INVALID_DATE: LazyLock<Regex> = LazyLock::new(|| {
	Regex::new(r"^(?:(?:Invalid )?Date(?: is invalid)? \[(.+?)](?: invalid)?|Invalid date: (.+))$").unwrap()
});

/// Groups:
/// 1. Date
pub static DATE_TOO_OLD: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Date(?: is older than \d+ days)? \[(\d{8})](?: too old)?$").unwrap());

/// Groups:
/// 1. Date
pub static DATE_TOO_NEW: LazyLock<Regex> = LazyLock::new(|| {
	Regex::new(r"^(?:Date(?: is in the future)?|Invalid future date) \[(\d{8})](?: too new)?$").unwrap()
});

/// Groups:
/// 1. `Generation` or `Export`
/// 2. Generation/export value
/// 3. System size
/// 4. Date
pub static GENERATION_OR_EXPORT_TOO_HIGH: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^(Generation|Export) \[(.+?)] too high for system size \[(\d+)] on (\d{8})$").unwrap());

/// Groups:
/// 1. Export
/// 2. Generation
pub static EXPORT_EXCEEDS_GENERATION: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Export \[(.+?)] cannot exceed generation \[(.?+)] by 15%$").unwrap());

/// Groups:
/// 1. Consumption
/// 2. Date
pub static CONSUMPTION_TOO_HIGH: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Consumption \[(.+?)] too high on (\d{8})$").unwrap());

/// Groups:
/// 1. Power
/// 2. Size
/// 3. Date
pub static PEAK_POWER_TOO_HIGH: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Peak power \[(.+?)] too high for system size \[(\d+)] on (\d{8})$").unwrap());

/// Groups:
/// 1. `Min` or `Max`
/// 2. Date
pub static TEMPERATURE_MISSING: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^(Min|Max) temp missing on \[(\d{8})]$").unwrap());

/// Groups:
/// 1. Time (possibly)
/// 2. Time (possibly)
pub static INVALID_TIME: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^(?:(?:Invalid Time|Time is invalid) \[(.+?)]|Invalid time: (.+))$").unwrap());

/// Groups:
/// 1. `Power` or `Energy`
/// 1. Power or energy value
/// 2. System size
pub static PRODUCTION_TOO_HIGH: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^(Power|Energy) value \[(.+?)] too high for system size \[(\d+)]$").unwrap());

/// Groups:
/// 1. Energy value
/// 2. Hour
/// 3. Minute
pub static ENERGY_TOO_HIGH_FOR_TIME: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Energy value \[(.+?)] too high for \[(\d\d?):(\d\d)]$").unwrap());

/// Groups:
/// 1. Data
pub static INVALID_DATA_FORMAT: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Invalid data format \[(.+?)]$").unwrap());

/// Groups:
/// 1. Extended data value
/// 2. `unit` or `label`
pub static MISSING_EXTENDED_DATA_FIELD: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Missing v(\d\d?) (unit|label) \(v\d\d?[ul]\)$").unwrap());

/// Groups:
/// 1. Extended data value
/// 2. `unit` or `label`
pub static EXTENDED_DATA_FIELD_TOO_LONG: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^v(\d\d?) (unit|label) \(v\d\d?[ul]\) too long \(\d+\)$").unwrap());

/// Groups:
/// 1. Extended data value
pub static INVALID_EXTENDED_DATA_GRAPH: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^Invalid v(\d\d?) graph type$").unwrap());

/// Groups:
/// 1. Extended data value
pub static INVALID_EXTENDED_DATA_AXIS: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^v(\d\d?) axis \(v\d\d?a\) not between \d+ and \d+$").unwrap());

// v7 colour (v7c) not a valid hex colour code [a-f0-9]{6}
/// Groups:
/// 1. Extended data value
pub static INVALID_EXTENDED_DATA_COLOUR: LazyLock<Regex> =
	LazyLock::new(|| Regex::new(r"^v(\d\d?) colour \(v\d\d?c\) not a valid hex colour code \[a-f0-9]\{6}$").unwrap());