Skip to content

Schemas

Here you will find the specification for LCAx. The specification is provided both as JSON Schemas and Python classes with Pydantic.

LCAx

# generated by datamodel-codegen:
#   filename:  lcax.schema.json

from __future__ import annotations

from datetime import date
from enum import Enum
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel, ConfigDict, Field, RootModel


class BuildingModelScope(Enum):
    FACILITATING_WORKS = 'facilitating_works'
    SUBSTRUCTURE = 'substructure'
    SUPERSTRUCTURE_FRAME = 'superstructure_frame'
    SUPERSTRUCTURE_ENVELOPE = 'superstructure_envelope'
    SUPERSTRUCTURE_INTERNAL_ELEMENTS = 'superstructure_internal_elements'
    FINISHES = 'finishes'
    BUILDING_SERVICES = 'building_services'
    EXTERNAL_WORKS = 'external_works'
    FF_E = 'ff_e'


class BuildingType(Enum):
    NEW_CONSTRUCTION_WORKS = 'new_construction_works'
    DEMOLITION = 'demolition'
    DECONSTRUCTION_AND_NEW_CONSTRUCTION_WORKS = (
        'deconstruction_and_new_construction_works'
    )
    RETROFIT_WORKS = 'retrofit_works'
    EXTENSION_WORKS = 'extension_works'
    RETROFIT_AND_EXTENSION_WORKS = 'retrofit_and_extension_works'
    FIT_OUT_WORKS = 'fit_out_works'
    OPERATIONS = 'operations'
    OTHER = 'other'


class BuildingTypology(Enum):
    OFFICE = 'office'
    RESIDENTIAL = 'residential'
    PUBLIC = 'public'
    COMMERCIAL = 'commercial'
    INDUSTRIAL = 'industrial'
    INFRASTRUCTURE = 'infrastructure'
    AGRICULTURAL = 'agricultural'
    OTHER = 'other'


class Classification(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    code: str
    name: str
    system: str


class Country(Enum):
    UNKNOWN = 'unknown'
    AFG = 'afg'
    ALA = 'ala'
    ALB = 'alb'
    DZA = 'dza'
    ASM = 'asm'
    AND_ = 'and'
    AGO = 'ago'
    AIA = 'aia'
    ATA = 'ata'
    ATG = 'atg'
    ARG = 'arg'
    ARM = 'arm'
    ABW = 'abw'
    AUS = 'aus'
    AUT = 'aut'
    AZE = 'aze'
    BHS = 'bhs'
    BHR = 'bhr'
    BGD = 'bgd'
    BRB = 'brb'
    BLR = 'blr'
    BEL = 'bel'
    BLZ = 'blz'
    BEN = 'ben'
    BMU = 'bmu'
    BTN = 'btn'
    BOL = 'bol'
    BES = 'bes'
    BIH = 'bih'
    BWA = 'bwa'
    BVT = 'bvt'
    BRA = 'bra'
    IOT = 'iot'
    BRN = 'brn'
    BGR = 'bgr'
    BFA = 'bfa'
    BDI = 'bdi'
    CPV = 'cpv'
    KHM = 'khm'
    CMR = 'cmr'
    CAN = 'can'
    CYM = 'cym'
    CAF = 'caf'
    TCD = 'tcd'
    CHL = 'chl'
    CHN = 'chn'
    CXR = 'cxr'
    CCK = 'cck'
    COL = 'col'
    COM = 'com'
    COG = 'cog'
    COD = 'cod'
    COK = 'cok'
    CRI = 'cri'
    CIV = 'civ'
    HRV = 'hrv'
    CUB = 'cub'
    CUW = 'cuw'
    CYP = 'cyp'
    CZE = 'cze'
    DNK = 'dnk'
    DJI = 'dji'
    DMA = 'dma'
    DOM = 'dom'
    ECU = 'ecu'
    EGY = 'egy'
    SLV = 'slv'
    GNQ = 'gnq'
    ERI = 'eri'
    EST = 'est'
    SWZ = 'swz'
    ETH = 'eth'
    FLK = 'flk'
    FRO = 'fro'
    FJI = 'fji'
    FIN = 'fin'
    FRA = 'fra'
    GUF = 'guf'
    PYF = 'pyf'
    ATF = 'atf'
    GAB = 'gab'
    GMB = 'gmb'
    GEO = 'geo'
    DEU = 'deu'
    GHA = 'gha'
    GIB = 'gib'
    GRC = 'grc'
    GRL = 'grl'
    GRD = 'grd'
    GLP = 'glp'
    GUM = 'gum'
    GTM = 'gtm'
    GGY = 'ggy'
    GIN = 'gin'
    GNB = 'gnb'
    GUY = 'guy'
    HTI = 'hti'
    HMD = 'hmd'
    VAT = 'vat'
    HND = 'hnd'
    HKG = 'hkg'
    HUN = 'hun'
    ISL = 'isl'
    IND = 'ind'
    IDN = 'idn'
    IRN = 'irn'
    IRQ = 'irq'
    IRL = 'irl'
    IMN = 'imn'
    ISR = 'isr'
    ITA = 'ita'
    JAM = 'jam'
    JPN = 'jpn'
    JEY = 'jey'
    JOR = 'jor'
    KAZ = 'kaz'
    KEN = 'ken'
    KIR = 'kir'
    PRK = 'prk'
    KOR = 'kor'
    KWT = 'kwt'
    KGZ = 'kgz'
    LAO = 'lao'
    LVA = 'lva'
    LBN = 'lbn'
    LSO = 'lso'
    LBR = 'lbr'
    LBY = 'lby'
    LIE = 'lie'
    LTU = 'ltu'
    LUX = 'lux'
    MAC = 'mac'
    MDG = 'mdg'
    MWI = 'mwi'
    MYS = 'mys'
    MDV = 'mdv'
    MLI = 'mli'
    MLT = 'mlt'
    MHL = 'mhl'
    MTQ = 'mtq'
    MRT = 'mrt'
    MUS = 'mus'
    MYT = 'myt'
    MEX = 'mex'
    FSM = 'fsm'
    MDA = 'mda'
    MCO = 'mco'
    MNG = 'mng'
    MNE = 'mne'
    MSR = 'msr'
    MAR = 'mar'
    MOZ = 'moz'
    MMR = 'mmr'
    NAM = 'nam'
    NRU = 'nru'
    NPL = 'npl'
    NLD = 'nld'
    NCL = 'ncl'
    NZL = 'nzl'
    NIC = 'nic'
    NER = 'ner'
    NGA = 'nga'
    NIU = 'niu'
    NFK = 'nfk'
    MKD = 'mkd'
    MNP = 'mnp'
    NOR = 'nor'
    OMN = 'omn'
    PAK = 'pak'
    PLW = 'plw'
    PSE = 'pse'
    PAN = 'pan'
    PNG = 'png'
    PRY = 'pry'
    PER = 'per'
    PHL = 'phl'
    PCN = 'pcn'
    POL = 'pol'
    PRT = 'prt'
    PRI = 'pri'
    QAT = 'qat'
    REU = 'reu'
    ROU = 'rou'
    RUS = 'rus'
    RWA = 'rwa'
    BLM = 'blm'
    SHN = 'shn'
    KNA = 'kna'
    LCA = 'lca'
    MAF = 'maf'
    SPM = 'spm'
    VCT = 'vct'
    WSM = 'wsm'
    SMR = 'smr'
    STP = 'stp'
    SAU = 'sau'
    SEN = 'sen'
    SRB = 'srb'
    SYC = 'syc'
    SLE = 'sle'
    SGP = 'sgp'
    SXM = 'sxm'
    SVK = 'svk'
    SVN = 'svn'
    SLB = 'slb'
    SOM = 'som'
    ZAF = 'zaf'
    SGS = 'sgs'
    SSD = 'ssd'
    ESP = 'esp'
    LKA = 'lka'
    SDN = 'sdn'
    SUR = 'sur'
    SJM = 'sjm'
    SWE = 'swe'
    CHE = 'che'
    SYR = 'syr'
    TWN = 'twn'
    TJK = 'tjk'
    TZA = 'tza'
    THA = 'tha'
    TLS = 'tls'
    TGO = 'tgo'
    TKL = 'tkl'
    TON = 'ton'
    TTO = 'tto'
    TUN = 'tun'
    TUR = 'tur'
    TKM = 'tkm'
    TCA = 'tca'
    TUV = 'tuv'
    UGA = 'uga'
    UKR = 'ukr'
    ARE = 'are'
    GBR = 'gbr'
    USA = 'usa'
    UMI = 'umi'
    URY = 'ury'
    UZB = 'uzb'
    VUT = 'vut'
    VEN = 'ven'
    VNM = 'vnm'
    VGB = 'vgb'
    VIR = 'vir'
    WLF = 'wlf'
    ESH = 'esh'
    YEM = 'yem'
    ZMB = 'zmb'
    ZWE = 'zwe'


class GeneralEnergyClass(Enum):
    EXISTING = 'existing'
    STANDARD = 'standard'
    ADVANCED = 'advanced'
    UNKNOWN = 'unknown'


class ImpactCategoryKey(Enum):
    GWP = 'gwp'
    GWP_FOS = 'gwp_fos'
    GWP_BIO = 'gwp_bio'
    GWP_LUL = 'gwp_lul'
    ODP = 'odp'
    AP = 'ap'
    EP = 'ep'
    EP_FW = 'ep_fw'
    EP_MAR = 'ep_mar'
    EP_TER = 'ep_ter'
    POCP = 'pocp'
    ADPE = 'adpe'
    ADPF = 'adpf'
    PENRE = 'penre'
    PERE = 'pere'
    PERM = 'perm'
    PERT = 'pert'
    PENRT = 'penrt'
    PENRM = 'penrm'
    SM = 'sm'
    PM = 'pm'
    WDP = 'wdp'
    IRP = 'irp'
    ETP_FW = 'etp_fw'
    HTP_C = 'htp_c'
    HTP_NC = 'htp_nc'
    SQP = 'sqp'
    RSF = 'rsf'
    NRSF = 'nrsf'
    FW = 'fw'
    HWD = 'hwd'
    NHWD = 'nhwd'
    RWD = 'rwd'
    CRU = 'cru'
    MRF = 'mrf'
    MER = 'mer'
    EEE = 'eee'
    EET = 'eet'


class LifeCycleStage(Enum):
    A0 = 'a0'
    A1A3 = 'a1a3'
    A4 = 'a4'
    A5 = 'a5'
    B1 = 'b1'
    B2 = 'b2'
    B3 = 'b3'
    B4 = 'b4'
    B5 = 'b5'
    B6 = 'b6'
    B7 = 'b7'
    B8 = 'b8'
    C1 = 'c1'
    C2 = 'c2'
    C3 = 'c3'
    C4 = 'c4'
    D = 'd'


class Location(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    address: Optional[str] = None
    city: Optional[str] = None
    country: Country


class Type(Enum):
    BUILDING_INFO = 'buildingInfo'


class Type1(Enum):
    INFRASTRUCTURE_INFO = 'infrastructureInfo'


class ProjectInfo2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Type1


class ProjectPhase(Enum):
    STRATEGIC_DESIGN = 'strategic_design'
    CONCEPT_DESIGN = 'concept_design'
    TECHNICAL_DESIGN = 'technical_design'
    CONSTRUCTION = 'construction'
    POST_COMPLETION = 'post_completion'
    IN_USE = 'in_use'
    OTHER = 'other'


class Type2(Enum):
    ACTUAL = 'actual'


class Type3(Enum):
    REFERENCE = 'reference'


class ReferenceSourceForAssembly2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    format: Optional[str] = None
    overrides: Optional[Dict[str, Any]] = None
    type: Type3
    uri: str
    version: Optional[str] = None


class Type4(Enum):
    ACTUAL = 'actual'


class Type6(Enum):
    REFERENCE = 'reference'


class ReferenceSourceForImpactDataSource3(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    format: Optional[str] = None
    overrides: Optional[Dict[str, Any]] = None
    type: Type6
    uri: str
    version: Optional[str] = None


class Type7(Enum):
    ACTUAL = 'actual'


class Type8(Enum):
    REFERENCE = 'reference'


class ReferenceSourceForProduct2(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    format: Optional[str] = None
    overrides: Optional[Dict[str, Any]] = None
    type: Type8
    uri: str
    version: Optional[str] = None


class RoofType(Enum):
    FLAT = 'flat'
    PITCHED = 'pitched'
    SADDLE = 'saddle'
    PYRAMID = 'pyramid'
    OTHER = 'other'


class SoftwareInfo(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    calculation_type: Optional[str] = Field(None, alias='calculationType')
    goal_and_scope_definition: Optional[str] = Field(
        None, alias='goalAndScopeDefinition'
    )
    lca_software: str = Field(..., alias='lcaSoftware')


class Source(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    name: str
    url: Optional[str] = None


class Standard(Enum):
    EN15804A1 = 'en15804a1'
    EN15804A2 = 'en15804a2'
    UNKNOWN = 'unknown'


class SubType(Enum):
    GENERIC = 'generic'
    SPECIFIC = 'specific'
    INDUSTRY = 'industry'
    REPRESENTATIVE = 'representative'


class Unit(Enum):
    M = 'm'
    M2 = 'm2'
    M3 = 'm3'
    KG = 'kg'
    TONES = 'tones'
    PCS = 'pcs'
    KWH = 'kwh'
    L = 'l'
    M2R1 = 'm2r1'
    KM = 'km'
    TONES_KM = 'tones_km'
    KGM3 = 'kgm3'
    UNKNOWN = 'unknown'


class ValueUnit(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    unit: Unit
    value: float


class AreaType(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    definition: str
    unit: Unit
    value: float


class Conversion(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    meta_data: str = Field(..., alias='metaData')
    to: Unit
    value: float


class EPD(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    comment: Optional[str] = None
    conversions: Optional[List[Conversion]] = None
    declared_unit: Unit = Field(..., alias='declaredUnit')
    format_version: str = Field(..., alias='formatVersion')
    id: str
    impacts: Dict[str, Dict[str, Optional[float]]]
    location: Country
    meta_data: Optional[Dict[str, Any]] = Field(None, alias='metaData')
    name: str
    published_date: date = Field(..., alias='publishedDate')
    reference_service_life: Optional[int] = Field(
        None, alias='referenceServiceLife', ge=0
    )
    source: Optional[Source] = None
    standard: Standard
    subtype: SubType
    valid_until: date = Field(..., alias='validUntil')
    version: str


class ProjectInfo1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    building_completion_year: Optional[int] = Field(
        None, alias='buildingCompletionYear', ge=0
    )
    building_footprint: Optional[ValueUnit] = Field(None, alias='buildingFootprint')
    building_height: Optional[ValueUnit] = Field(None, alias='buildingHeight')
    building_mass: Optional[ValueUnit] = Field(None, alias='buildingMass')
    building_model_scope: Optional[List[BuildingModelScope]] = Field(
        None, alias='buildingModelScope'
    )
    building_permit_year: Optional[int] = Field(None, alias='buildingPermitYear', ge=0)
    building_type: BuildingType = Field(..., alias='buildingType')
    building_typology: List[BuildingTypology] = Field(..., alias='buildingTypology')
    building_users: Optional[int] = Field(None, alias='buildingUsers', ge=0)
    certifications: Optional[List[str]] = None
    energy_demand_electricity: Optional[float] = Field(
        None, alias='energyDemandElectricity'
    )
    energy_demand_heating: Optional[float] = Field(None, alias='energyDemandHeating')
    energy_supply_electricity: Optional[float] = Field(
        None, alias='energySupplyElectricity'
    )
    energy_supply_heating: Optional[float] = Field(None, alias='energySupplyHeating')
    exported_electricity: Optional[float] = Field(None, alias='exportedElectricity')
    floors_above_ground: int = Field(..., alias='floorsAboveGround', ge=0)
    floors_below_ground: Optional[int] = Field(None, alias='floorsBelowGround', ge=0)
    frame_type: Optional[str] = Field(None, alias='frameType')
    general_energy_class: GeneralEnergyClass = Field(..., alias='generalEnergyClass')
    gross_floor_area: Optional[AreaType] = Field(None, alias='grossFloorArea')
    heated_floor_area: Optional[AreaType] = Field(None, alias='heatedFloorArea')
    local_energy_class: Optional[str] = Field(None, alias='localEnergyClass')
    roof_type: RoofType = Field(..., alias='roofType')
    type: Type


class ReferenceSourceForImpactDataSource1(EPD):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Type4


class TechFlow(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    comment: Optional[str] = None
    conversions: Optional[List[Conversion]] = None
    declared_unit: Unit = Field(..., alias='declaredUnit')
    format_version: str = Field(..., alias='formatVersion')
    id: str
    impacts: Dict[str, Dict[str, Optional[float]]]
    location: Country
    meta_data: Optional[Dict[str, Any]] = Field(None, alias='metaData')
    name: str
    source: Optional[Source] = None


class ReferenceSourceForImpactDataSource2(TechFlow):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    type: Type4


class Transport(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    distance: float
    distance_unit: Unit = Field(..., alias='distanceUnit')
    id: str
    impact_data: Union[EPD, TechFlow] = Field(..., alias='impactData')
    life_cycle_stages: List[LifeCycleStage] = Field(..., alias='lifeCycleStages')
    name: str


class ReferenceSourceForProduct1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    description: Optional[str] = None
    id: str
    impact_data: Union[
        Union[ReferenceSourceForImpactDataSource1, ReferenceSourceForImpactDataSource2],
        ReferenceSourceForImpactDataSource3,
    ] = Field(..., alias='impactData')
    meta_data: Optional[Dict[str, Any]] = Field(None, alias='metaData')
    name: str
    quantity: float
    reference_service_life: int = Field(..., alias='referenceServiceLife', ge=0)
    results: Optional[Dict[str, Any]] = None
    transport: Optional[List[Transport]] = None
    type: Type7
    unit: Unit


class ReferenceSourceForAssembly1(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    classification: Optional[List[Classification]] = None
    comment: Optional[str] = None
    description: Optional[str] = None
    id: str
    meta_data: Optional[Dict[str, Any]] = Field(None, alias='metaData')
    name: str
    products: Dict[str, Union[ReferenceSourceForProduct1, ReferenceSourceForProduct2]]
    quantity: float
    results: Optional[Dict[str, Any]] = None
    type: Type2
    unit: Unit


class Project(BaseModel):
    model_config = ConfigDict(
        populate_by_name=True,
    )
    assemblies: Dict[
        str, Union[ReferenceSourceForAssembly1, ReferenceSourceForAssembly2]
    ]
    classification_system: Optional[str] = Field(None, alias='classificationSystem')
    comment: Optional[str] = None
    description: Optional[str] = None
    format_version: str = Field(..., alias='formatVersion')
    id: str
    impact_categories: List[ImpactCategoryKey] = Field(..., alias='impactCategories')
    lcia_method: Optional[str] = Field(None, alias='lciaMethod')
    life_cycle_stages: List[LifeCycleStage] = Field(..., alias='lifeCycleStages')
    location: Location
    meta_data: Optional[Dict[str, Any]] = Field(None, alias='metaData')
    name: str
    owner: Optional[str] = None
    project_info: Optional[Union[ProjectInfo1, ProjectInfo2]] = Field(
        None, alias='projectInfo'
    )
    project_phase: ProjectPhase = Field(..., alias='projectPhase')
    reference_study_period: Optional[int] = Field(
        None, alias='referenceStudyPeriod', ge=0
    )
    results: Optional[Dict[str, Any]] = None
    software_info: SoftwareInfo = Field(..., alias='softwareInfo')
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Project",
  "type": "object",
  "required": [
    "assemblies",
    "formatVersion",
    "id",
    "impactCategories",
    "lifeCycleStages",
    "location",
    "name",
    "projectPhase",
    "softwareInfo"
  ],
  "properties": {
    "assemblies": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/ReferenceSource_for_Assembly"
      }
    },
    "classificationSystem": {
      "type": [
        "string",
        "null"
      ]
    },
    "comment": {
      "type": [
        "string",
        "null"
      ]
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "formatVersion": {
      "type": "string"
    },
    "id": {
      "type": "string"
    },
    "impactCategories": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/ImpactCategoryKey"
      }
    },
    "lciaMethod": {
      "type": [
        "string",
        "null"
      ]
    },
    "lifeCycleStages": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/LifeCycleStage"
      }
    },
    "location": {
      "$ref": "#/definitions/Location"
    },
    "metaData": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "string"
      }
    },
    "name": {
      "type": "string"
    },
    "owner": {
      "type": [
        "string",
        "null"
      ]
    },
    "projectInfo": {
      "anyOf": [
        {
          "$ref": "#/definitions/ProjectInfo"
        },
        {
          "type": "null"
        }
      ]
    },
    "projectPhase": {
      "$ref": "#/definitions/ProjectPhase"
    },
    "referenceStudyPeriod": {
      "type": [
        "integer",
        "null"
      ],
      "format": "uint8",
      "minimum": 0.0
    },
    "results": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": "object",
        "additionalProperties": {
          "type": [
            "number",
            "null"
          ],
          "format": "double"
        }
      }
    },
    "softwareInfo": {
      "$ref": "#/definitions/SoftwareInfo"
    }
  },
  "definitions": {
    "AreaType": {
      "type": "object",
      "required": [
        "definition",
        "unit",
        "value"
      ],
      "properties": {
        "definition": {
          "type": "string"
        },
        "unit": {
          "$ref": "#/definitions/Unit"
        },
        "value": {
          "type": "number",
          "format": "double"
        }
      }
    },
    "BuildingModelScope": {
      "type": "string",
      "enum": [
        "facilitating_works",
        "substructure",
        "superstructure_frame",
        "superstructure_envelope",
        "superstructure_internal_elements",
        "finishes",
        "building_services",
        "external_works",
        "ff_e"
      ]
    },
    "BuildingType": {
      "type": "string",
      "enum": [
        "new_construction_works",
        "demolition",
        "deconstruction_and_new_construction_works",
        "retrofit_works",
        "extension_works",
        "retrofit_and_extension_works",
        "fit_out_works",
        "operations",
        "other"
      ]
    },
    "BuildingTypology": {
      "type": "string",
      "enum": [
        "office",
        "residential",
        "public",
        "commercial",
        "industrial",
        "infrastructure",
        "agricultural",
        "other"
      ]
    },
    "Classification": {
      "type": "object",
      "required": [
        "code",
        "name",
        "system"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "system": {
          "type": "string"
        }
      }
    },
    "Conversion": {
      "type": "object",
      "required": [
        "metaData",
        "to",
        "value"
      ],
      "properties": {
        "metaData": {
          "type": "string"
        },
        "to": {
          "$ref": "#/definitions/Unit"
        },
        "value": {
          "type": "number",
          "format": "double"
        }
      }
    },
    "Country": {
      "type": "string",
      "enum": [
        "unknown",
        "afg",
        "ala",
        "alb",
        "dza",
        "asm",
        "and",
        "ago",
        "aia",
        "ata",
        "atg",
        "arg",
        "arm",
        "abw",
        "aus",
        "aut",
        "aze",
        "bhs",
        "bhr",
        "bgd",
        "brb",
        "blr",
        "bel",
        "blz",
        "ben",
        "bmu",
        "btn",
        "bol",
        "bes",
        "bih",
        "bwa",
        "bvt",
        "bra",
        "iot",
        "brn",
        "bgr",
        "bfa",
        "bdi",
        "cpv",
        "khm",
        "cmr",
        "can",
        "cym",
        "caf",
        "tcd",
        "chl",
        "chn",
        "cxr",
        "cck",
        "col",
        "com",
        "cog",
        "cod",
        "cok",
        "cri",
        "civ",
        "hrv",
        "cub",
        "cuw",
        "cyp",
        "cze",
        "dnk",
        "dji",
        "dma",
        "dom",
        "ecu",
        "egy",
        "slv",
        "gnq",
        "eri",
        "est",
        "swz",
        "eth",
        "flk",
        "fro",
        "fji",
        "fin",
        "fra",
        "guf",
        "pyf",
        "atf",
        "gab",
        "gmb",
        "geo",
        "deu",
        "gha",
        "gib",
        "grc",
        "grl",
        "grd",
        "glp",
        "gum",
        "gtm",
        "ggy",
        "gin",
        "gnb",
        "guy",
        "hti",
        "hmd",
        "vat",
        "hnd",
        "hkg",
        "hun",
        "isl",
        "ind",
        "idn",
        "irn",
        "irq",
        "irl",
        "imn",
        "isr",
        "ita",
        "jam",
        "jpn",
        "jey",
        "jor",
        "kaz",
        "ken",
        "kir",
        "prk",
        "kor",
        "kwt",
        "kgz",
        "lao",
        "lva",
        "lbn",
        "lso",
        "lbr",
        "lby",
        "lie",
        "ltu",
        "lux",
        "mac",
        "mdg",
        "mwi",
        "mys",
        "mdv",
        "mli",
        "mlt",
        "mhl",
        "mtq",
        "mrt",
        "mus",
        "myt",
        "mex",
        "fsm",
        "mda",
        "mco",
        "mng",
        "mne",
        "msr",
        "mar",
        "moz",
        "mmr",
        "nam",
        "nru",
        "npl",
        "nld",
        "ncl",
        "nzl",
        "nic",
        "ner",
        "nga",
        "niu",
        "nfk",
        "mkd",
        "mnp",
        "nor",
        "omn",
        "pak",
        "plw",
        "pse",
        "pan",
        "png",
        "pry",
        "per",
        "phl",
        "pcn",
        "pol",
        "prt",
        "pri",
        "qat",
        "reu",
        "rou",
        "rus",
        "rwa",
        "blm",
        "shn",
        "kna",
        "lca",
        "maf",
        "spm",
        "vct",
        "wsm",
        "smr",
        "stp",
        "sau",
        "sen",
        "srb",
        "syc",
        "sle",
        "sgp",
        "sxm",
        "svk",
        "svn",
        "slb",
        "som",
        "zaf",
        "sgs",
        "ssd",
        "esp",
        "lka",
        "sdn",
        "sur",
        "sjm",
        "swe",
        "che",
        "syr",
        "twn",
        "tjk",
        "tza",
        "tha",
        "tls",
        "tgo",
        "tkl",
        "ton",
        "tto",
        "tun",
        "tur",
        "tkm",
        "tca",
        "tuv",
        "uga",
        "ukr",
        "are",
        "gbr",
        "usa",
        "umi",
        "ury",
        "uzb",
        "vut",
        "ven",
        "vnm",
        "vgb",
        "vir",
        "wlf",
        "esh",
        "yem",
        "zmb",
        "zwe"
      ]
    },
    "EPD": {
      "type": "object",
      "required": [
        "declaredUnit",
        "formatVersion",
        "id",
        "impacts",
        "location",
        "name",
        "publishedDate",
        "standard",
        "subtype",
        "validUntil",
        "version"
      ],
      "properties": {
        "comment": {
          "type": [
            "string",
            "null"
          ]
        },
        "conversions": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/Conversion"
          }
        },
        "declaredUnit": {
          "$ref": "#/definitions/Unit"
        },
        "formatVersion": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "impacts": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            }
          }
        },
        "location": {
          "$ref": "#/definitions/Country"
        },
        "metaData": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": {
            "type": "string"
          }
        },
        "name": {
          "type": "string"
        },
        "publishedDate": {
          "type": "string",
          "format": "date"
        },
        "referenceServiceLife": {
          "type": [
            "integer",
            "null"
          ],
          "format": "uint32",
          "minimum": 0.0
        },
        "source": {
          "anyOf": [
            {
              "$ref": "#/definitions/Source"
            },
            {
              "type": "null"
            }
          ]
        },
        "standard": {
          "$ref": "#/definitions/Standard"
        },
        "subtype": {
          "$ref": "#/definitions/SubType"
        },
        "validUntil": {
          "type": "string",
          "format": "date"
        },
        "version": {
          "type": "string"
        }
      }
    },
    "GeneralEnergyClass": {
      "type": "string",
      "enum": [
        "existing",
        "standard",
        "advanced",
        "unknown"
      ]
    },
    "ImpactCategoryKey": {
      "type": "string",
      "enum": [
        "gwp",
        "gwp_fos",
        "gwp_bio",
        "gwp_lul",
        "odp",
        "ap",
        "ep",
        "ep_fw",
        "ep_mar",
        "ep_ter",
        "pocp",
        "adpe",
        "adpf",
        "penre",
        "pere",
        "perm",
        "pert",
        "penrt",
        "penrm",
        "sm",
        "pm",
        "wdp",
        "irp",
        "etp_fw",
        "htp_c",
        "htp_nc",
        "sqp",
        "rsf",
        "nrsf",
        "fw",
        "hwd",
        "nhwd",
        "rwd",
        "cru",
        "mrf",
        "mer",
        "eee",
        "eet"
      ]
    },
    "ImpactDataSource": {
      "anyOf": [
        {
          "$ref": "#/definitions/EPD"
        },
        {
          "$ref": "#/definitions/TechFlow"
        }
      ]
    },
    "LifeCycleStage": {
      "type": "string",
      "enum": [
        "a0",
        "a1a3",
        "a4",
        "a5",
        "b1",
        "b2",
        "b3",
        "b4",
        "b5",
        "b6",
        "b7",
        "b8",
        "c1",
        "c2",
        "c3",
        "c4",
        "d"
      ]
    },
    "Location": {
      "type": "object",
      "required": [
        "country"
      ],
      "properties": {
        "address": {
          "type": [
            "string",
            "null"
          ]
        },
        "city": {
          "type": [
            "string",
            "null"
          ]
        },
        "country": {
          "$ref": "#/definitions/Country"
        }
      }
    },
    "ProjectInfo": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "buildingType",
            "buildingTypology",
            "floorsAboveGround",
            "generalEnergyClass",
            "roofType",
            "type"
          ],
          "properties": {
            "buildingCompletionYear": {
              "type": [
                "integer",
                "null"
              ],
              "format": "uint64",
              "minimum": 0.0
            },
            "buildingFootprint": {
              "anyOf": [
                {
                  "$ref": "#/definitions/ValueUnit"
                },
                {
                  "type": "null"
                }
              ]
            },
            "buildingHeight": {
              "anyOf": [
                {
                  "$ref": "#/definitions/ValueUnit"
                },
                {
                  "type": "null"
                }
              ]
            },
            "buildingMass": {
              "anyOf": [
                {
                  "$ref": "#/definitions/ValueUnit"
                },
                {
                  "type": "null"
                }
              ]
            },
            "buildingModelScope": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "$ref": "#/definitions/BuildingModelScope"
              }
            },
            "buildingPermitYear": {
              "type": [
                "integer",
                "null"
              ],
              "format": "uint64",
              "minimum": 0.0
            },
            "buildingType": {
              "$ref": "#/definitions/BuildingType"
            },
            "buildingTypology": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/BuildingTypology"
              }
            },
            "buildingUsers": {
              "type": [
                "integer",
                "null"
              ],
              "format": "uint64",
              "minimum": 0.0
            },
            "certifications": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "type": "string"
              }
            },
            "energyDemandElectricity": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            },
            "energyDemandHeating": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            },
            "energySupplyElectricity": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            },
            "energySupplyHeating": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            },
            "exportedElectricity": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            },
            "floorsAboveGround": {
              "type": "integer",
              "format": "uint16",
              "minimum": 0.0
            },
            "floorsBelowGround": {
              "type": [
                "integer",
                "null"
              ],
              "format": "uint16",
              "minimum": 0.0
            },
            "frameType": {
              "type": [
                "string",
                "null"
              ]
            },
            "generalEnergyClass": {
              "$ref": "#/definitions/GeneralEnergyClass"
            },
            "grossFloorArea": {
              "anyOf": [
                {
                  "$ref": "#/definitions/AreaType"
                },
                {
                  "type": "null"
                }
              ]
            },
            "heatedFloorArea": {
              "anyOf": [
                {
                  "$ref": "#/definitions/AreaType"
                },
                {
                  "type": "null"
                }
              ]
            },
            "localEnergyClass": {
              "type": [
                "string",
                "null"
              ]
            },
            "roofType": {
              "$ref": "#/definitions/RoofType"
            },
            "type": {
              "type": "string",
              "enum": [
                "buildingInfo"
              ]
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "infrastructureInfo"
              ]
            }
          }
        }
      ]
    },
    "ProjectPhase": {
      "type": "string",
      "enum": [
        "strategic_design",
        "concept_design",
        "technical_design",
        "construction",
        "post_completion",
        "in_use",
        "other"
      ]
    },
    "ReferenceSource_for_Assembly": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "id",
            "name",
            "products",
            "quantity",
            "type",
            "unit"
          ],
          "properties": {
            "classification": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "$ref": "#/definitions/Classification"
              }
            },
            "comment": {
              "type": [
                "string",
                "null"
              ]
            },
            "description": {
              "type": [
                "string",
                "null"
              ]
            },
            "id": {
              "type": "string"
            },
            "metaData": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "type": "string"
              }
            },
            "name": {
              "type": "string"
            },
            "products": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/ReferenceSource_for_Product"
              }
            },
            "quantity": {
              "type": "number",
              "format": "double"
            },
            "results": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "format": "double"
                }
              }
            },
            "type": {
              "type": "string",
              "enum": [
                "actual"
              ]
            },
            "unit": {
              "$ref": "#/definitions/Unit"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "uri"
          ],
          "properties": {
            "format": {
              "type": [
                "string",
                "null"
              ]
            },
            "overrides": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "type": "string"
              }
            },
            "type": {
              "type": "string",
              "enum": [
                "reference"
              ]
            },
            "uri": {
              "type": "string"
            },
            "version": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      ]
    },
    "ReferenceSource_for_ImpactDataSource": {
      "oneOf": [
        {
          "type": "object",
          "anyOf": [
            {
              "$ref": "#/definitions/EPD"
            },
            {
              "$ref": "#/definitions/TechFlow"
            }
          ],
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "actual"
              ]
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "uri"
          ],
          "properties": {
            "format": {
              "type": [
                "string",
                "null"
              ]
            },
            "overrides": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "type": "string"
              }
            },
            "type": {
              "type": "string",
              "enum": [
                "reference"
              ]
            },
            "uri": {
              "type": "string"
            },
            "version": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      ]
    },
    "ReferenceSource_for_Product": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "id",
            "impactData",
            "name",
            "quantity",
            "referenceServiceLife",
            "type",
            "unit"
          ],
          "properties": {
            "description": {
              "type": [
                "string",
                "null"
              ]
            },
            "id": {
              "type": "string"
            },
            "impactData": {
              "$ref": "#/definitions/ReferenceSource_for_ImpactDataSource"
            },
            "metaData": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "type": "string"
              }
            },
            "name": {
              "type": "string"
            },
            "quantity": {
              "type": "number",
              "format": "double"
            },
            "referenceServiceLife": {
              "type": "integer",
              "format": "uint32",
              "minimum": 0.0
            },
            "results": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "format": "double"
                }
              }
            },
            "transport": {
              "type": [
                "array",
                "null"
              ],
              "items": {
                "$ref": "#/definitions/Transport"
              }
            },
            "type": {
              "type": "string",
              "enum": [
                "actual"
              ]
            },
            "unit": {
              "$ref": "#/definitions/Unit"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "type",
            "uri"
          ],
          "properties": {
            "format": {
              "type": [
                "string",
                "null"
              ]
            },
            "overrides": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": {
                "type": "string"
              }
            },
            "type": {
              "type": "string",
              "enum": [
                "reference"
              ]
            },
            "uri": {
              "type": "string"
            },
            "version": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      ]
    },
    "RoofType": {
      "type": "string",
      "enum": [
        "flat",
        "pitched",
        "saddle",
        "pyramid",
        "other"
      ]
    },
    "SoftwareInfo": {
      "type": "object",
      "required": [
        "lcaSoftware"
      ],
      "properties": {
        "calculationType": {
          "type": [
            "string",
            "null"
          ]
        },
        "goalAndScopeDefinition": {
          "type": [
            "string",
            "null"
          ]
        },
        "lcaSoftware": {
          "type": "string"
        }
      }
    },
    "Source": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "url": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "Standard": {
      "type": "string",
      "enum": [
        "en15804a1",
        "en15804a2",
        "unknown"
      ]
    },
    "SubType": {
      "type": "string",
      "enum": [
        "generic",
        "specific",
        "industry",
        "representative"
      ]
    },
    "TechFlow": {
      "type": "object",
      "required": [
        "declaredUnit",
        "formatVersion",
        "id",
        "impacts",
        "location",
        "name"
      ],
      "properties": {
        "comment": {
          "type": [
            "string",
            "null"
          ]
        },
        "conversions": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/Conversion"
          }
        },
        "declaredUnit": {
          "$ref": "#/definitions/Unit"
        },
        "formatVersion": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "impacts": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            }
          }
        },
        "location": {
          "$ref": "#/definitions/Country"
        },
        "metaData": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": {
            "type": "string"
          }
        },
        "name": {
          "type": "string"
        },
        "source": {
          "anyOf": [
            {
              "$ref": "#/definitions/Source"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "Transport": {
      "type": "object",
      "required": [
        "distance",
        "distanceUnit",
        "id",
        "impactData",
        "lifeCycleStages",
        "name"
      ],
      "properties": {
        "distance": {
          "type": "number",
          "format": "double"
        },
        "distanceUnit": {
          "$ref": "#/definitions/Unit"
        },
        "id": {
          "type": "string"
        },
        "impactData": {
          "$ref": "#/definitions/ImpactDataSource"
        },
        "lifeCycleStages": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/LifeCycleStage"
          }
        },
        "name": {
          "type": "string"
        }
      }
    },
    "Unit": {
      "type": "string",
      "enum": [
        "m",
        "m2",
        "m3",
        "kg",
        "tones",
        "pcs",
        "kwh",
        "l",
        "m2r1",
        "km",
        "tones_km",
        "kgm3",
        "unknown"
      ]
    },
    "ValueUnit": {
      "type": "object",
      "required": [
        "unit",
        "value"
      ],
      "properties": {
        "unit": {
          "$ref": "#/definitions/Unit"
        },
        "value": {
          "type": "number",
          "format": "double"
        }
      }
    }
  }
}
use std::collections::HashMap;

use lcax_core::country::Country;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[cfg(feature = "jsbindings")]
use tsify::Tsify;

use crate::assembly::Assembly;
use crate::life_cycle_base::{ImpactCategoryKey, LifeCycleStage, Results};
use crate::shared::{ReferenceSource, Unit};

#[derive(Deserialize, Serialize, JsonSchema, Default, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(
    feature = "jsbindings",
    derive(Tsify),
    tsify(into_wasm_abi, from_wasm_abi)
)]
pub struct Project {
    pub id: String,
    pub name: String,
    pub description: Option<String>,
    pub comment: Option<String>,
    pub location: Location,
    pub owner: Option<String>,
    pub format_version: String,
    pub lcia_method: Option<String>,
    pub classification_system: Option<String>,
    pub reference_study_period: Option<u8>,
    pub life_cycle_stages: Vec<LifeCycleStage>,
    pub impact_categories: Vec<ImpactCategoryKey>,
    pub assemblies: HashMap<String, ReferenceSource<Assembly>>,
    pub results: Option<Results>,
    pub project_info: Option<ProjectInfo>,
    pub project_phase: ProjectPhase,
    pub software_info: SoftwareInfo,
    pub meta_data: Option<HashMap<String, String>>,
}

impl Project {
    pub fn new() -> Self {
        Project {
            id: uuid::Uuid::new_v4().to_string(),
            name: "".to_string(),
            description: None,
            comment: None,
            location: Location {
                country: Country::UNKNOWN,
                city: None,
                address: None,
            },
            owner: None,
            format_version: "0.1.0".to_string(),
            lcia_method: None,
            classification_system: None,
            reference_study_period: None,
            life_cycle_stages: vec![],
            impact_categories: vec![],
            assemblies: HashMap::new(),
            results: None,
            project_info: None,
            project_phase: ProjectPhase::STRATEGIC_DESIGN,
            software_info: SoftwareInfo {
                goal_and_scope_definition: None,
                lca_software: "lcax".to_string(),
                calculation_type: None,
            },
            meta_data: None,
        }
    }
}

#[derive(Deserialize, Serialize, JsonSchema, Default, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub struct SoftwareInfo {
    pub goal_and_scope_definition: Option<String>,
    pub lca_software: String,
    pub calculation_type: Option<String>,
}

#[derive(Deserialize, Serialize, JsonSchema, Default, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum ProjectPhase {
    #[allow(non_camel_case_types)]
    STRATEGIC_DESIGN,
    #[allow(non_camel_case_types)]
    CONCEPT_DESIGN,
    #[allow(non_camel_case_types)]
    TECHNICAL_DESIGN,
    CONSTRUCTION,
    #[allow(non_camel_case_types)]
    POST_COMPLETION,
    #[allow(non_camel_case_types)]
    IN_USE,
    #[default]
    OTHER,
}

#[derive(Deserialize, Serialize, JsonSchema, Default, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub struct Location {
    pub country: Country,
    pub city: Option<String>,
    pub address: Option<String>,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum ProjectInfo {
    BuildingInfo(BuildingInfo),
    InfrastructureInfo(HashMap<String, String>),
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub struct BuildingInfo {
    pub building_type: BuildingType,
    pub building_typology: Vec<BuildingTypology>,
    pub certifications: Option<Vec<String>>,
    pub building_mass: Option<ValueUnit>,
    pub building_height: Option<ValueUnit>,
    pub gross_floor_area: Option<AreaType>,
    pub heated_floor_area: Option<AreaType>,
    pub building_footprint: Option<ValueUnit>,
    pub floors_above_ground: u16,
    pub floors_below_ground: Option<u16>,
    pub roof_type: RoofType,
    pub frame_type: Option<String>,
    pub building_completion_year: Option<u64>,
    pub building_permit_year: Option<u64>,
    pub energy_demand_heating: Option<f64>,
    pub energy_supply_heating: Option<f64>,
    pub energy_demand_electricity: Option<f64>,
    pub energy_supply_electricity: Option<f64>,
    pub exported_electricity: Option<f64>,
    pub general_energy_class: GeneralEnergyClass,
    pub local_energy_class: Option<String>,
    pub building_users: Option<u64>,
    pub building_model_scope: Option<Vec<BuildingModelScope>>,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub struct AreaType {
    pub value: f64,
    pub unit: Unit,
    pub definition: String,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub struct ValueUnit {
    value: f64,
    unit: Unit,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum RoofType {
    FLAT,
    PITCHED,
    SADDLE,
    PYRAMID,
    OTHER,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum GeneralEnergyClass {
    EXISTING,
    STANDARD,
    ADVANCED,
    UNKNOWN,
}

impl From<&String> for GeneralEnergyClass {
    fn from(class: &String) -> Self {
        match class.to_ascii_lowercase().as_str() {
            "lowenergy" => GeneralEnergyClass::ADVANCED,
            _ => GeneralEnergyClass::UNKNOWN,
        }
    }
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum BuildingModelScope {
    #[allow(non_camel_case_types)]
    FACILITATING_WORKS,
    SUBSTRUCTURE,
    #[allow(non_camel_case_types)]
    SUPERSTRUCTURE_FRAME,
    #[allow(non_camel_case_types)]
    SUPERSTRUCTURE_ENVELOPE,
    #[allow(non_camel_case_types)]
    SUPERSTRUCTURE_INTERNAL_ELEMENTS,
    FINISHES,
    #[allow(non_camel_case_types)]
    BUILDING_SERVICES,
    #[allow(non_camel_case_types)]
    EXTERNAL_WORKS,
    #[allow(non_camel_case_types)]
    FF_E,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum BuildingType {
    #[allow(non_camel_case_types)]
    NEW_CONSTRUCTION_WORKS,
    DEMOLITION,
    #[allow(non_camel_case_types)]
    DECONSTRUCTION_AND_NEW_CONSTRUCTION_WORKS,
    #[allow(non_camel_case_types)]
    RETROFIT_WORKS,
    #[allow(non_camel_case_types)]
    EXTENSION_WORKS,
    #[allow(non_camel_case_types)]
    RETROFIT_AND_EXTENSION_WORKS,
    #[allow(non_camel_case_types)]
    FIT_OUT_WORKS,
    OPERATIONS,
    OTHER,
}

#[derive(Deserialize, Serialize, JsonSchema, Clone)]
#[serde(rename_all = "lowercase")]
#[cfg_attr(feature = "jsbindings", derive(Tsify))]
pub enum BuildingTypology {
    OFFICE,
    RESIDENTIAL,
    PUBLIC,
    COMMERCIAL,
    INDUSTRIAL,
    INFRASTRUCTURE,
    AGRICULTURAL,
    OTHER,
}

impl From<&String> for BuildingTypology {
    fn from(unit: &String) -> Self {
        match unit.to_ascii_lowercase().as_str() {
            "office" => BuildingTypology::OFFICE,
            "residential" => BuildingTypology::RESIDENTIAL,
            "public" => BuildingTypology::PUBLIC,
            "commercial" => BuildingTypology::COMMERCIAL,
            "industrial" => BuildingTypology::INDUSTRIAL,
            "infrastructure" => BuildingTypology::INFRASTRUCTURE,
            "agricultural" => BuildingTypology::AGRICULTURAL,
            _ => BuildingTypology::OTHER,
        }
    }
}
/* tslint:disable */
/* eslint-disable */
/**
* @param {string} data
* @param {string | undefined} [resultData]
* @returns {Project}
*/
export function convertLCAbyg(data: string, resultData?: string): Project;
/**
* @param {string} data
* @returns {EPD}
*/
export function convertIlcd(data: string): EPD;
/**
* @param {Uint8Array} file
* @returns {JSProjects}
*/
export function convertSLiCE(file: Uint8Array): JSProjects;
export type JSProjects = Project[];

export type BuildingTypology = "office" | "residential" | "public" | "commercial" | "industrial" | "infrastructure" | "agricultural" | "other";

export type BuildingType = "new_construction_works" | "demolition" | "deconstruction_and_new_construction_works" | "retrofit_works" | "extension_works" | "retrofit_and_extension_works" | "fit_out_works" | "operations" | "other";

export type BuildingModelScope = "facilitating_works" | "substructure" | "superstructure_frame" | "superstructure_envelope" | "superstructure_internal_elements" | "finishes" | "building_services" | "external_works" | "ff_e";

export type GeneralEnergyClass = "existing" | "standard" | "advanced" | "unknown";

export type RoofType = "flat" | "pitched" | "saddle" | "pyramid" | "other";

export interface ValueUnit {
    value: number;
    unit: Unit;
}

export interface AreaType {
    value: number;
    unit: Unit;
    definition: string;
}

export interface BuildingInfo {
    buildingType: BuildingType;
    buildingTypology: BuildingTypology[];
    certifications: string[] | null;
    buildingMass: ValueUnit | null;
    buildingHeight: ValueUnit | null;
    grossFloorArea: AreaType | null;
    heatedFloorArea: AreaType | null;
    buildingFootprint: ValueUnit | null;
    floorsAboveGround: number;
    floorsBelowGround: number | null;
    roofType: RoofType;
    frameType: string | null;
    buildingCompletionYear: number | null;
    buildingPermitYear: number | null;
    energyDemandHeating: number | null;
    energySupplyHeating: number | null;
    energyDemandElectricity: number | null;
    energySupplyElectricity: number | null;
    exportedElectricity: number | null;
    generalEnergyClass: GeneralEnergyClass;
    localEnergyClass: string | null;
    buildingUsers: number | null;
    buildingModelScope: BuildingModelScope[] | null;
}

export type ProjectInfo = ({ type: "buildingInfo" } & BuildingInfo) | ({ type: "infrastructureInfo" } & Record<string, string>);

export interface Location {
    country: Country;
    city: string | null;
    address: string | null;
}

export type ProjectPhase = "strategic_design" | "concept_design" | "technical_design" | "construction" | "post_completion" | "in_use" | "other";

export interface SoftwareInfo {
    goalAndScopeDefinition: string | null;
    lcaSoftware: string;
    calculationType: string | null;
}

export interface Project {
    id: string;
    name: string;
    description: string | null;
    comment: string | null;
    location: Location;
    owner: string | null;
    formatVersion: string;
    lciaMethod: string | null;
    classificationSystem: string | null;
    referenceStudyPeriod: number | null;
    lifeCycleStages: LifeCycleStage[];
    impactCategories: ImpactCategoryKey[];
    assemblies: Record<string, ReferenceSource<Assembly>>;
    results: Results | null;
    projectInfo: ProjectInfo | null;
    projectPhase: ProjectPhase;
    softwareInfo: SoftwareInfo;
    metaData: Record<string, string> | null;
}

export type SubType = "generic" | "specific" | "industry" | "representative";

export type Standard = "en15804a1" | "en15804a2" | "unknown";

export interface EPD {
    id: string;
    name: string;
    declaredUnit: Unit;
    version: string;
    publishedDate: NaiveDate;
    validUntil: NaiveDate;
    formatVersion: string;
    source: Source | null;
    referenceServiceLife: number | null;
    standard: Standard;
    comment: string | null;
    location: Country;
    subtype: SubType;
    conversions: Conversion[] | null;
    impacts: Record<ImpactCategoryKey, ImpactCategory>;
    metaData: Record<string, string> | null;
}

export interface Reference {
    uri: string;
    format: string | null;
    version: string | null;
    overrides: Record<string, string> | null;
}

export type ReferenceSource<T> = ({ type: "actual" } & T) | ({ type: "reference" } & Reference);

export interface Source {
    name: string;
    url: string | null;
}

export interface Conversion {
    value: number;
    to: Unit;
    metaData: string;
}

export type Unit = "m" | "m2" | "m3" | "kg" | "tones" | "pcs" | "kwh" | "l" | "m2r1" | "km" | "tones_km" | "kgm3" | "unknown";

export type ImpactCategoryKey = "gwp" | "gwp_fos" | "gwp_bio" | "gwp_lul" | "odp" | "ap" | "ep" | "ep_fw" | "ep_mar" | "ep_ter" | "pocp" | "adpe" | "adpf" | "penre" | "pere" | "perm" | "pert" | "penrt" | "penrm" | "sm" | "pm" | "wdp" | "irp" | "etp_fw" | "htp_c" | "htp_nc" | "sqp" | "rsf" | "nrsf" | "fw" | "hwd" | "nhwd" | "rwd" | "cru" | "mrf" | "mer" | "eee" | "eet";

export type LifeCycleStage = "a0" | "a1a3" | "a4" | "a5" | "b1" | "b2" | "b3" | "b4" | "b5" | "b6" | "b7" | "b8" | "c1" | "c2" | "c3" | "c4" | "d";

export interface TechFlow {
    id: string;
    name: string;
    declaredUnit: Unit;
    formatVersion: string;
    source: Source | null;
    comment: string | null;
    location: Country;
    conversions: Conversion[] | null;
    impacts: Record<ImpactCategoryKey, ImpactCategory>;
    metaData: Record<string, string> | null;
}

export interface Classification {
    system: string;
    code: string;
    name: string;
}

export interface Assembly {
    id: string;
    name: string;
    description: string | null;
    comment: string | null;
    quantity: number;
    unit: Unit;
    classification: Classification[] | null;
    products: Record<string, ReferenceSource<Product>>;
    results: Results | null;
    metaData: Record<string, string> | null;
}

export interface InternalImpactData {
    path: string;
}

export interface ExternalImpactData {
    url: string;
    format: string;
    version: string | null;
}

export type ImpactDataSource = EPD | TechFlow;

export interface Transport {
    id: string;
    name: string;
    lifeCycleStages: LifeCycleStage[];
    distance: number;
    distanceUnit: Unit;
    impactData: ImpactDataSource;
}

export interface Product {
    id: string;
    name: string;
    description: string | null;
    referenceServiceLife: number;
    impactData: ReferenceSource<ImpactDataSource>;
    quantity: number;
    unit: Unit;
    transport: Transport[] | null;
    results: Results | null;
    metaData: Record<string, string> | null;
}
namespace LCAx
{

    public partial class Lcax
    {
        public Dictionary<string, ReferenceSourceForAssembly> Assemblies { get; set; }
        public string ClassificationSystem { get; set; }
        public string Comment { get; set; }
        public string Description { get; set; }
        public string FormatVersion { get; set; }
        public string Id { get; set; }
        public ImpactCategoryKey[] ImpactCategories { get; set; }
        public string LciaMethod { get; set; }
        public LifeCycleStage[] LifeCycleStages { get; set; }
        public Location Location { get; set; }
        public Dictionary<string, string> MetaData { get; set; }
        public string Name { get; set; }
        public string Owner { get; set; }
        public ProjectInfo ProjectInfo { get; set; }
        public ProjectPhase ProjectPhase { get; set; }
        public long? ReferenceStudyPeriod { get; set; }
        public Dictionary<string, Dictionary<string, double?>> Results { get; set; }
        public SoftwareInfo SoftwareInfo { get; set; }
    }

    public partial class ReferenceSourceForAssembly
    {
        public Classification[] Classification { get; set; }
        public string Comment { get; set; }
        public string Description { get; set; }
        public string Id { get; set; }
        public Dictionary<string, string> MetaData { get; set; }
        public string Name { get; set; }
        public Dictionary<string, ReferenceSourceForProduct> Products { get; set; }
        public double? Quantity { get; set; }
        public Dictionary<string, Dictionary<string, double?>> Results { get; set; }
        public ReferenceSourceForImpactDataSourceType Type { get; set; }
        public Unit? Unit { get; set; }
        public string Format { get; set; }
        public Dictionary<string, string> Overrides { get; set; }
        public string Uri { get; set; }
        public string Version { get; set; }
    }

    public partial class Classification
    {
        public string Code { get; set; }
        public string Name { get; set; }
        public string System { get; set; }
    }

    public partial class ReferenceSourceForProduct
    {
        public string Description { get; set; }
        public string Id { get; set; }
        public ReferenceSourceForImpactDataSource ImpactData { get; set; }
        public Dictionary<string, string> MetaData { get; set; }
        public string Name { get; set; }
        public double? Quantity { get; set; }
        public long? ReferenceServiceLife { get; set; }
        public Dictionary<string, Dictionary<string, double?>> Results { get; set; }
        public Transport[] Transport { get; set; }
        public ReferenceSourceForImpactDataSourceType Type { get; set; }
        public Unit? Unit { get; set; }
        public string Format { get; set; }
        public Dictionary<string, string> Overrides { get; set; }
        public string Uri { get; set; }
        public string Version { get; set; }
    }

    public partial class ReferenceSourceForImpactDataSource
    {
        public ReferenceSourceForImpactDataSourceType Type { get; set; }
        public string Comment { get; set; }
        public Conversion[] Conversions { get; set; }
        public Unit? DeclaredUnit { get; set; }
        public string FormatVersion { get; set; }
        public string Id { get; set; }
        public Dictionary<string, Dictionary<string, double?>> Impacts { get; set; }
        public Country? Location { get; set; }
        public Dictionary<string, string> MetaData { get; set; }
        public string Name { get; set; }
        public DateTimeOffset? PublishedDate { get; set; }
        public long? ReferenceServiceLife { get; set; }
        public Source Source { get; set; }
        public Standard? Standard { get; set; }
        public SubType? Subtype { get; set; }
        public DateTimeOffset? ValidUntil { get; set; }
        public string Version { get; set; }
        public string Format { get; set; }
        public Dictionary<string, string> Overrides { get; set; }
        public string Uri { get; set; }
    }

    public partial class Conversion
    {
        public string MetaData { get; set; }
        public Unit To { get; set; }
        public double Value { get; set; }
    }

    public partial class Source
    {
        public string Name { get; set; }
        public string Url { get; set; }
    }

    public partial class Transport
    {
        public double Distance { get; set; }
        public Unit DistanceUnit { get; set; }
        public string Id { get; set; }
        public ImpactDataSource ImpactData { get; set; }
        public LifeCycleStage[] LifeCycleStages { get; set; }
        public string Name { get; set; }
    }

    public partial class ImpactDataSource
    {
        public string Comment { get; set; }
        public Conversion[] Conversions { get; set; }
        public Unit DeclaredUnit { get; set; }
        public string FormatVersion { get; set; }
        public string Id { get; set; }
        public Dictionary<string, Dictionary<string, double?>> Impacts { get; set; }
        public Country Location { get; set; }
        public Dictionary<string, string> MetaData { get; set; }
        public string Name { get; set; }
        public DateTimeOffset? PublishedDate { get; set; }
        public long? ReferenceServiceLife { get; set; }
        public Source Source { get; set; }
        public Standard? Standard { get; set; }
        public SubType? Subtype { get; set; }
        public DateTimeOffset? ValidUntil { get; set; }
        public string Version { get; set; }
    }

    public partial class Location
    {
        public string Address { get; set; }
        public string City { get; set; }
        public Country Country { get; set; }
    }

    public partial class ProjectInfo
    {
        public long? BuildingCompletionYear { get; set; }
        public ValueUnit BuildingFootprint { get; set; }
        public ValueUnit BuildingHeight { get; set; }
        public ValueUnit BuildingMass { get; set; }
        public string[] BuildingModelScope { get; set; }
        public long? BuildingPermitYear { get; set; }
        public BuildingType? BuildingType { get; set; }
        public BuildingTypology[] BuildingTypology { get; set; }
        public long? BuildingUsers { get; set; }
        public string[] Certifications { get; set; }
        public double? EnergyDemandElectricity { get; set; }
        public double? EnergyDemandHeating { get; set; }
        public double? EnergySupplyElectricity { get; set; }
        public double? EnergySupplyHeating { get; set; }
        public double? ExportedElectricity { get; set; }
        public long? FloorsAboveGround { get; set; }
        public long? FloorsBelowGround { get; set; }
        public string FrameType { get; set; }
        public GeneralEnergyClass? GeneralEnergyClass { get; set; }
        public AreaType GrossFloorArea { get; set; }
        public AreaType HeatedFloorArea { get; set; }
        public string LocalEnergyClass { get; set; }
        public RoofType? RoofType { get; set; }
        public ProjectInfoType Type { get; set; }
    }

    public partial class ValueUnit
    {
        public Unit Unit { get; set; }
        public double Value { get; set; }
    }

    public partial class AreaType
    {
        public string Definition { get; set; }
        public Unit Unit { get; set; }
        public double Value { get; set; }
    }

    public partial class SoftwareInfo
    {
        public string CalculationType { get; set; }
        public string GoalAndScopeDefinition { get; set; }
        public string LcaSoftware { get; set; }
    }

    public enum Unit { Kg, Kgm3, Km, Kwh, L, M, M2, M2R1, M3, Pcs, Tones, TonesKm, Unknown };

    public enum Country { Abw, Afg, Ago, Aia, Ala, Alb, And, Are, Arg, Arm, Asm, Ata, Atf, Atg, Aus, Aut, Aze, Bdi, Bel, Ben, Bes, Bfa, Bgd, Bgr, Bhr, Bhs, Bih, Blm, Blr, Blz, Bmu, Bol, Bra, Brb, Brn, Btn, Bvt, Bwa, Caf, Can, Cck, Che, Chl, Chn, Civ, Cmr, Cod, Cog, Cok, Col, Com, Cpv, Cri, Cub, Cuw, Cxr, Cym, Cyp, Cze, Deu, Dji, Dma, Dnk, Dom, Dza, Ecu, Egy, Eri, Esh, Esp, Est, Eth, Fin, Fji, Flk, Fra, Fro, Fsm, Gab, Gbr, Geo, Ggy, Gha, Gib, Gin, Glp, Gmb, Gnb, Gnq, Grc, Grd, Grl, Gtm, Guf, Gum, Guy, Hkg, Hmd, Hnd, Hrv, Hti, Hun, Idn, Imn, Ind, Iot, Irl, Irn, Irq, Isl, Isr, Ita, Jam, Jey, Jor, Jpn, Kaz, Ken, Kgz, Khm, Kir, Kna, Kor, Kwt, Lao, Lbn, Lbr, Lby, Lca, Lie, Lka, Lso, Ltu, Lux, Lva, Mac, Maf, Mar, Mco, Mda, Mdg, Mdv, Mex, Mhl, Mkd, Mli, Mlt, Mmr, Mne, Mng, Mnp, Moz, Mrt, Msr, Mtq, Mus, Mwi, Mys, Myt, Nam, Ncl, Ner, Nfk, Nga, Nic, Niu, Nld, Nor, Npl, Nru, Nzl, Omn, Pak, Pan, Pcn, Per, Phl, Plw, Png, Pol, Pri, Prk, Prt, Pry, Pse, Pyf, Qat, Reu, Rou, Rus, Rwa, Sau, Sdn, Sen, Sgp, Sgs, Shn, Sjm, Slb, Sle, Slv, Smr, Som, Spm, Srb, Ssd, Stp, Sur, Svk, Svn, Swe, Swz, Sxm, Syc, Syr, Tca, Tcd, Tgo, Tha, Tjk, Tkl, Tkm, Tls, Ton, Tto, Tun, Tur, Tuv, Twn, Tza, Uga, Ukr, Umi, Unknown, Ury, Usa, Uzb, Vat, Vct, Ven, Vgb, Vir, Vnm, Vut, Wlf, Wsm, Yem, Zaf, Zmb, Zwe };

    public enum Standard { En15804A1, En15804A2, Unknown };

    public enum SubType { Generic, Industry, Representative, Specific };

    public enum ReferenceSourceForImpactDataSourceType { Actual, Reference };

    public enum LifeCycleStage { A0, A1A3, A4, A5, B1, B2, B3, B4, B5, B6, B7, B8, C1, C2, C3, C4, D };

    public enum ImpactCategoryKey { Adpe, Adpf, Ap, Cru, Eee, Eet, Ep, EpFw, EpMar, EpTer, EtpFw, Fw, Gwp, GwpBio, GwpFos, GwpLul, HtpC, HtpNc, Hwd, Irp, Mer, Mrf, Nhwd, Nrsf, Odp, Penre, Penrm, Penrt, Pere, Perm, Pert, Pm, Pocp, Rsf, Rwd, Sm, Sqp, Wdp };

    public enum BuildingModelScope { BuildingServices, ExternalWorks, FacilitatingWorks, FfE, Finishes, Substructure, SuperstructureEnvelope, SuperstructureFrame, SuperstructureInternalElements };

    public enum BuildingType { DeconstructionAndNewConstructionWorks, Demolition, ExtensionWorks, FitOutWorks, NewConstructionWorks, Operations, Other, RetrofitAndExtensionWorks, RetrofitWorks };

    public enum BuildingTypology { Agricultural, Commercial, Industrial, Infrastructure, Office, Other, Public, Residential };

    public enum GeneralEnergyClass { Advanced, Existing, Standard, Unknown };

    public enum RoofType { Flat, Other, Pitched, Pyramid, Saddle };

    public enum ProjectInfoType { BuildingInfo, InfrastructureInfo };

    public enum ProjectPhase { ConceptDesign, Construction, InUse, Other, PostCompletion, StrategicDesign, TechnicalDesign };
}

Download