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'
    unknown = 'unknown'
    other = 'other'


class BuildingTypology(Enum):
    office = 'office'
    residential = 'residential'
    public = 'public'
    commercial = 'commercial'
    industrial = 'industrial'
    infrastructure = 'infrastructure'
    agricultural = 'agricultural'
    educational = 'educational'
    health = 'health'
    unknown = 'unknown'
    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'
    unknown = 'unknown'
    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",
        "unknown",
        "other"
      ]
    },
    "BuildingTypology": {
      "type": "string",
      "enum": [
        "office",
        "residential",
        "public",
        "commercial",
        "industrial",
        "infrastructure",
        "agricultural",
        "educational",
        "health",
        "unknown",
        "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",
        "unknown",
        "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,
    UNKNOWN,
    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,
    UNKNOWN,
    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,
    EDUCATIONAL,
    HEALTH,
    UNKNOWN,
    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,
            "educational" => BuildingTypology::EDUCATIONAL,
            "health" => BuildingTypology::HEALTH,
            _ => 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;
/**
* @param {Project} project
* @returns {Project}
*/
export function calculateProject(project: Project): Project;
export type JSProjects = Project[];

export type BuildingTypology = "office" | "residential" | "public" | "commercial" | "industrial" | "infrastructure" | "agricultural" | "educational" | "health" | "unknown" | "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" | "unknown" | "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" | "unknown" | "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 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 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 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 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 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, Unknown };

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

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

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

    public enum ProjectInfoType { BuildingInfo, InfrastructureInfo };

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

Download