From 0f70c90188014a911ca92d7a15b44aa1a242f7d6 Mon Sep 17 00:00:00 2001 From: Mingbo Peng Date: Mon, 23 Sep 2024 17:19:41 +0800 Subject: [PATCH 1/6] fix(Ts): add tests --- samples/Room_with_complex_skylights.dfjson | 2020 ++++++++++++++++++++ src/TypeScriptSDK/jest.config.js | 13 + src/TypeScriptSDK/package.json | 14 +- src/TypeScriptSDK/tests/Model.test.ts | 200 ++ src/TypeScriptSDK/tests/Room2D.test.ts | 228 +++ src/TypeScriptSDK/tests/jest.setup.ts | 1 + src/TypeScriptSDK/tsconfig.json | 6 +- 7 files changed, 2475 insertions(+), 7 deletions(-) create mode 100644 samples/Room_with_complex_skylights.dfjson create mode 100644 src/TypeScriptSDK/jest.config.js create mode 100644 src/TypeScriptSDK/tests/Model.test.ts create mode 100644 src/TypeScriptSDK/tests/Room2D.test.ts create mode 100644 src/TypeScriptSDK/tests/jest.setup.ts diff --git a/samples/Room_with_complex_skylights.dfjson b/samples/Room_with_complex_skylights.dfjson new file mode 100644 index 0000000..3ba3b72 --- /dev/null +++ b/samples/Room_with_complex_skylights.dfjson @@ -0,0 +1,2020 @@ +{ + "display_name": "unnamed", + "identifier": "unnamed_cb67f62e", + "tolerance": 0.01, + "angle_tolerance": 1, + "buildings": [ + { + "display_name": "Building_40", + "identifier": "Building_40_cf00ba3c", + "unique_stories": [ + { + "display_name": "Story_40", + "identifier": "Story_40_878374b9", + "multiplier": 1, + "floor_to_floor_height": 3, + "room_2ds": [ + { + "display_name": "Room_1", + "identifier": "Room_1_c4ee035e", + "floor_boundary": [ + [ + 0, + 0 + ], + [ + 20, + 0 + ], + [ + 20, + 10 + ], + [ + 0, + 10 + ] + ], + "is_ground_contact": true, + "is_top_exposed": true, + "skylight_parameters": { + "are_doors": [ + false, + false, + false, + false, + false + ], + "type": "DetailedSkylights", + "polygons": [ + [ + [ + 5.7451294461496705, + 3.5878286595674926 + ], + [ + 4.686974425923101, + 1.7550504022510025 + ], + [ + 6.803284466376239, + 1.7550504022510016 + ] + ], + [ + [ + 5.7451294461496705, + 3.587828659567493 + ], + [ + 3.628819405696533, + 3.587828659567493 + ], + [ + 4.6869744259231005, + 1.755050402251003 + ] + ], + [ + [ + 5.7451294461496705, + 3.587828659567492 + ], + [ + 6.80328446637624, + 1.755050402251002 + ], + [ + 7.861439486602809, + 3.587828659567492 + ] + ], + [ + [ + 3.604520215382093, + 3.871980327368499 + ], + [ + 7.942569010477452, + 3.871980327368499 + ], + [ + 7.942569010477452, + 5.984174391355977 + ], + [ + 3.604520215382093, + 5.984174391355977 + ] + ], + [ + [ + 12.299561250092879, + 5.614777223214669 + ], + [ + 16.476590766767664, + 5.614777223214669 + ], + [ + 16.476590766767664, + 7.97323606596302 + ], + [ + 12.299561250092879, + 7.97323606596302 + ] + ] + ] + }, + "floor_to_ceiling_height": 3, + "type": "Room2D", + "window_parameters": [ + { + "window_ratio": 0.4, + "type": "SimpleWindowRatio" + }, + { + "window_ratio": 0.4, + "type": "SimpleWindowRatio" + }, + { + "window_ratio": 0.4, + "type": "SimpleWindowRatio" + }, + { + "window_ratio": 0.4, + "type": "SimpleWindowRatio" + } + ], + "floor_height": 0, + "boundary_conditions": [ + { + "view_factor": { + "type": "Autocalculate" + }, + "sun_exposure": true, + "wind_exposure": true, + "type": "Outdoors" + }, + { + "view_factor": { + "type": "Autocalculate" + }, + "sun_exposure": true, + "wind_exposure": true, + "type": "Outdoors" + }, + { + "view_factor": { + "type": "Autocalculate" + }, + "sun_exposure": true, + "wind_exposure": true, + "type": "Outdoors" + }, + { + "view_factor": { + "type": "Autocalculate" + }, + "sun_exposure": true, + "wind_exposure": true, + "type": "Outdoors" + } + ], + "properties": { + "radiance": { + "type": "Room2DRadiancePropertiesAbridged" + }, + "energy": { + "program_type": "Generic Office Program", + "type": "Room2DEnergyPropertiesAbridged", + "hvac": "Room_1_c4ee035e Ideal Loads Air System" + }, + "type": "Room2DPropertiesAbridged", + "uwg": { + "type": "Room2DUWGPropertiesAbridged" + } + } + } + ], + "type": "Story", + "floor_height": 0, + "properties": { + "radiance": { + "type": "StoryRadiancePropertiesAbridged" + }, + "energy": { + "type": "StoryEnergyPropertiesAbridged" + }, + "type": "StoryPropertiesAbridged", + "uwg": { + "type": "StoryUWGPropertiesAbridged" + } + } + } + ], + "type": "Building", + "properties": { + "radiance": { + "type": "BuildingRadiancePropertiesAbridged" + }, + "energy": { + "type": "BuildingEnergyPropertiesAbridged" + }, + "type": "BuildingPropertiesAbridged", + "uwg": { + "fract_heat_to_canyon": 0.5, + "vintage": "New", + "roof_veg_fraction": 0, + "program": "LargeOffice", + "type": "BuildingUWGPropertiesAbridged" + } + } + } + ], + "type": "Model", + "version": "1.10.2", + "units": "Meters", + "properties": { + "radiance": { + "modifiers": [], + "type": "ModelRadianceProperties", + "global_modifier_set": { + "shade_set": { + "type": "ShadeModifierSetAbridged", + "interior_modifier": "generic_interior_shade_0.50", + "exterior_modifier": "generic_exterior_shade_0.35" + }, + "roof_ceiling_set": { + "type": "RoofCeilingModifierSetAbridged", + "interior_modifier": "generic_ceiling_0.80", + "exterior_modifier": "generic_ceiling_0.80" + }, + "context_modifier": "generic_context_0.20", + "modifiers": [ + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.5, + "identifier": "generic_wall_0.50", + "specularity": 0, + "b_reflectance": 0.5, + "r_reflectance": 0.5, + "type": "Plastic", + "roughness": 0 + }, + { + "b_transmissivity": 0.9584154328610596, + "r_transmissivity": 0.9584154328610596, + "modifier": null, + "identifier": "generic_interior_window_vis_0.88", + "refraction_index": null, + "type": "Glass", + "dependencies": [], + "g_transmissivity": 0.9584154328610596 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.5, + "identifier": "generic_interior_shade_0.50", + "specularity": 0, + "b_reflectance": 0.5, + "r_reflectance": 0.5, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.2, + "identifier": "generic_floor_0.20", + "specularity": 0, + "b_reflectance": 0.2, + "r_reflectance": 0.2, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.8, + "identifier": "generic_ceiling_0.80", + "specularity": 0, + "b_reflectance": 0.8, + "r_reflectance": 0.8, + "type": "Plastic", + "roughness": 0 + }, + { + "b_transmissivity": 0.6975761815384331, + "r_transmissivity": 0.6975761815384331, + "modifier": null, + "identifier": "generic_exterior_window_vis_0.64", + "refraction_index": null, + "type": "Glass", + "dependencies": [], + "g_transmissivity": 0.6975761815384331 + }, + { + "r_reflectance": 1, + "b_reflectance": 1, + "roughness": 0, + "identifier": "air_boundary", + "type": "Trans", + "dependencies": [], + "g_reflectance": 1, + "specularity": 0, + "transmitted_diff": 1, + "transmitted_spec": 1, + "modifier": null + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.35, + "identifier": "generic_exterior_shade_0.35", + "specularity": 0, + "b_reflectance": 0.35, + "r_reflectance": 0.35, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.5, + "identifier": "generic_opaque_door_0.50", + "specularity": 0, + "b_reflectance": 0.5, + "r_reflectance": 0.5, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.2, + "identifier": "generic_context_0.20", + "specularity": 0, + "b_reflectance": 0.2, + "r_reflectance": 0.2, + "type": "Plastic", + "roughness": 0 + } + ], + "wall_set": { + "type": "WallModifierSetAbridged", + "interior_modifier": "generic_wall_0.50", + "exterior_modifier": "generic_wall_0.50" + }, + "door_set": { + "exterior_glass_modifier": "generic_exterior_window_vis_0.64", + "interior_glass_modifier": "generic_interior_window_vis_0.88", + "overhead_modifier": "generic_opaque_door_0.50", + "exterior_modifier": "generic_opaque_door_0.50", + "interior_modifier": "generic_opaque_door_0.50", + "type": "DoorModifierSetAbridged" + }, + "floor_set": { + "type": "FloorModifierSetAbridged", + "interior_modifier": "generic_floor_0.20", + "exterior_modifier": "generic_floor_0.20" + }, + "type": "GlobalModifierSet", + "aperture_set": { + "interior_modifier": "generic_interior_window_vis_0.88", + "window_modifier": "generic_exterior_window_vis_0.64", + "skylight_modifier": "generic_exterior_window_vis_0.64", + "type": "ApertureModifierSetAbridged", + "operable_modifier": "generic_exterior_window_vis_0.64" + }, + "air_boundary_modifier": "air_boundary" + }, + "modifier_sets": [] + }, + "energy": { + "constructions": [], + "materials": [], + "shws": [], + "hvacs": [ + { + "identifier": "Room_1_c4ee035e Ideal Loads Air System", + "economizer_type": "DifferentialDryBulb", + "cooling_air_temperature": 13, + "sensible_heat_recovery": 0, + "latent_heat_recovery": 0, + "cooling_limit": { + "type": "Autosize" + }, + "heating_air_temperature": 50, + "heating_limit": { + "type": "Autosize" + }, + "demand_controlled_ventilation": false, + "type": "IdealAirSystemAbridged" + } + ], + "schedule_type_limits": [ + { + "upper_limit": { + "type": "NoLimit" + }, + "identifier": "Temperature", + "lower_limit": -273.15, + "numeric_type": "Continuous", + "unit_type": "Temperature", + "type": "ScheduleTypeLimit" + }, + { + "upper_limit": { + "type": "NoLimit" + }, + "identifier": "Activity Level", + "lower_limit": 0, + "numeric_type": "Continuous", + "unit_type": "ActivityLevel", + "type": "ScheduleTypeLimit" + }, + { + "upper_limit": 1, + "identifier": "Fractional", + "lower_limit": 0, + "numeric_type": "Continuous", + "unit_type": "Dimensionless", + "type": "ScheduleTypeLimit" + } + ], + "type": "ModelEnergyProperties", + "global_construction_set": { + "constructions": [ + { + "solar_reflectance": 0.2, + "identifier": "Generic Context", + "visible_reflectance": 0.2, + "is_specular": false, + "type": "ShadeConstruction" + }, + { + "type": "WindowConstructionAbridged", + "identifier": "Generic Single Pane", + "materials": [ + "Generic Clear Glass" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Interior Wall", + "materials": [ + "Generic Gypsum Board", + "Generic Wall Air Gap", + "Generic Gypsum Board" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Exposed Floor", + "materials": [ + "Generic Painted Metal", + "Generic Ceiling Air Gap", + "Generic 50mm Insulation", + "Generic LW Concrete" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Roof", + "materials": [ + "Generic Roof Membrane", + "Generic 50mm Insulation", + "Generic LW Concrete", + "Generic Ceiling Air Gap", + "Generic Acoustic Tile" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Exterior Door", + "materials": [ + "Generic Painted Metal", + "Generic 25mm Insulation", + "Generic Painted Metal" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Interior Door", + "materials": [ + "Generic 25mm Wood" + ] + }, + { + "air_mixing_schedule": "Always On", + "type": "AirBoundaryConstructionAbridged", + "identifier": "Generic Air Boundary", + "air_mixing_per_area": 0.1 + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Interior Floor", + "materials": [ + "Generic Acoustic Tile", + "Generic Ceiling Air Gap", + "Generic LW Concrete" + ] + }, + { + "solar_reflectance": 0.35, + "identifier": "Generic Shade", + "visible_reflectance": 0.35, + "is_specular": false, + "type": "ShadeConstruction" + }, + { + "type": "WindowConstructionAbridged", + "identifier": "Generic Double Pane", + "materials": [ + "Generic Low-e Glass", + "Generic Window Air Gap", + "Generic Clear Glass" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Underground Roof", + "materials": [ + "Generic 50mm Insulation", + "Generic HW Concrete", + "Generic Ceiling Air Gap", + "Generic Acoustic Tile" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Exterior Wall", + "materials": [ + "Generic Brick", + "Generic LW Concrete", + "Generic 50mm Insulation", + "Generic Wall Air Gap", + "Generic Gypsum Board" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Underground Wall", + "materials": [ + "Generic 50mm Insulation", + "Generic HW Concrete", + "Generic Wall Air Gap", + "Generic Gypsum Board" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Interior Ceiling", + "materials": [ + "Generic LW Concrete", + "Generic Ceiling Air Gap", + "Generic Acoustic Tile" + ] + }, + { + "type": "OpaqueConstructionAbridged", + "identifier": "Generic Ground Slab", + "materials": [ + "Generic 50mm Insulation", + "Generic HW Concrete" + ] + } + ], + "materials": [ + { + "conductivity": 0.15, + "specific_heat": 1630, + "density": 608, + "thermal_absorptance": 0.9, + "thickness": 0.0254, + "solar_absorptance": 0.5, + "visible_absorptance": 0.5, + "roughness": "MediumSmooth", + "type": "EnergyMaterial", + "identifier": "Generic 25mm Wood" + }, + { + "visible_reflectance_back": 0.21, + "solar_reflectance": 0.36, + "visible_reflectance": 0.21, + "type": "EnergyWindowMaterialGlazing", + "emissivity_back": 0.047, + "emissivity": 0.84, + "dirt_correction": 1, + "solar_diffusing": false, + "visible_transmittance": 0.71, + "infrared_transmittance": 0, + "conductivity": 1, + "solar_reflectance_back": 0.36, + "identifier": "Generic Low-e Glass", + "solar_transmittance": 0.45, + "thickness": 0.006 + }, + { + "conductivity": 0.53, + "specific_heat": 840, + "density": 1280, + "thermal_absorptance": 0.9, + "thickness": 0.1, + "solar_absorptance": 0.8, + "visible_absorptance": 0.8, + "roughness": "MediumRough", + "type": "EnergyMaterial", + "identifier": "Generic LW Concrete" + }, + { + "conductivity": 0.556, + "specific_heat": 1000, + "density": 1.28, + "thermal_absorptance": 0.9, + "thickness": 0.1, + "solar_absorptance": 0.7, + "visible_absorptance": 0.7, + "roughness": "Smooth", + "type": "EnergyMaterial", + "identifier": "Generic Ceiling Air Gap" + }, + { + "conductivity": 0.06, + "specific_heat": 590, + "density": 368, + "thermal_absorptance": 0.9, + "thickness": 0.02, + "solar_absorptance": 0.2, + "visible_absorptance": 0.2, + "roughness": "MediumSmooth", + "type": "EnergyMaterial", + "identifier": "Generic Acoustic Tile" + }, + { + "conductivity": 1.95, + "specific_heat": 900, + "density": 2240, + "thermal_absorptance": 0.9, + "thickness": 0.2, + "solar_absorptance": 0.8, + "visible_absorptance": 0.8, + "roughness": "MediumRough", + "type": "EnergyMaterial", + "identifier": "Generic HW Concrete" + }, + { + "conductivity": 0.667, + "specific_heat": 1000, + "density": 1.28, + "thermal_absorptance": 0.9, + "thickness": 0.1, + "solar_absorptance": 0.7, + "visible_absorptance": 0.7, + "roughness": "Smooth", + "type": "EnergyMaterial", + "identifier": "Generic Wall Air Gap" + }, + { + "conductivity": 0.16, + "specific_heat": 1460, + "density": 1120, + "thermal_absorptance": 0.9, + "thickness": 0.01, + "solar_absorptance": 0.65, + "visible_absorptance": 0.65, + "roughness": "MediumRough", + "type": "EnergyMaterial", + "identifier": "Generic Roof Membrane" + }, + { + "conductivity": 0.16, + "specific_heat": 1090, + "density": 800, + "thermal_absorptance": 0.9, + "thickness": 0.0127, + "solar_absorptance": 0.5, + "visible_absorptance": 0.5, + "roughness": "MediumSmooth", + "type": "EnergyMaterial", + "identifier": "Generic Gypsum Board" + }, + { + "gas_type": "Air", + "thickness": 0.0127, + "identifier": "Generic Window Air Gap", + "type": "EnergyWindowMaterialGas" + }, + { + "conductivity": 0.9, + "specific_heat": 790, + "density": 1920, + "thermal_absorptance": 0.9, + "thickness": 0.1, + "solar_absorptance": 0.65, + "visible_absorptance": 0.65, + "roughness": "MediumRough", + "type": "EnergyMaterial", + "identifier": "Generic Brick" + }, + { + "visible_reflectance_back": 0.08, + "solar_reflectance": 0.07, + "visible_reflectance": 0.08, + "type": "EnergyWindowMaterialGlazing", + "emissivity_back": 0.84, + "emissivity": 0.84, + "dirt_correction": 1, + "solar_diffusing": false, + "visible_transmittance": 0.88, + "infrared_transmittance": 0, + "conductivity": 1, + "solar_reflectance_back": 0.07, + "identifier": "Generic Clear Glass", + "solar_transmittance": 0.77, + "thickness": 0.006 + }, + { + "conductivity": 0.03, + "specific_heat": 1210, + "density": 43, + "thermal_absorptance": 0.9, + "thickness": 0.025, + "solar_absorptance": 0.7, + "visible_absorptance": 0.7, + "roughness": "MediumRough", + "type": "EnergyMaterial", + "identifier": "Generic 25mm Insulation" + }, + { + "conductivity": 0.03, + "specific_heat": 1210, + "density": 43, + "thermal_absorptance": 0.9, + "thickness": 0.05, + "solar_absorptance": 0.7, + "visible_absorptance": 0.7, + "roughness": "MediumRough", + "type": "EnergyMaterial", + "identifier": "Generic 50mm Insulation" + }, + { + "conductivity": 45, + "specific_heat": 410, + "density": 7690, + "thermal_absorptance": 0.9, + "thickness": 0.0015, + "solar_absorptance": 0.5, + "visible_absorptance": 0.5, + "roughness": "Smooth", + "type": "EnergyMaterial", + "identifier": "Generic Painted Metal" + } + ], + "air_boundary_construction": "Generic Air Boundary", + "shade_construction": "Generic Shade", + "roof_ceiling_set": { + "ground_construction": "Generic Underground Roof", + "interior_construction": "Generic Interior Ceiling", + "exterior_construction": "Generic Roof", + "type": "RoofCeilingConstructionSetAbridged" + }, + "wall_set": { + "ground_construction": "Generic Underground Wall", + "interior_construction": "Generic Interior Wall", + "exterior_construction": "Generic Exterior Wall", + "type": "WallConstructionSetAbridged" + }, + "door_set": { + "overhead_construction": "Generic Exterior Door", + "interior_glass_construction": "Generic Single Pane", + "exterior_glass_construction": "Generic Double Pane", + "type": "DoorConstructionSetAbridged", + "interior_construction": "Generic Interior Door", + "exterior_construction": "Generic Exterior Door" + }, + "context_construction": "Generic Context", + "floor_set": { + "ground_construction": "Generic Ground Slab", + "interior_construction": "Generic Interior Floor", + "exterior_construction": "Generic Exposed Floor", + "type": "FloorConstructionSetAbridged" + }, + "type": "GlobalConstructionSet", + "aperture_set": { + "skylight_construction": "Generic Double Pane", + "type": "ApertureConstructionSetAbridged", + "interior_construction": "Generic Single Pane", + "operable_construction": "Generic Double Pane", + "window_construction": "Generic Double Pane" + } + }, + "schedules": [ + { + "identifier": "Generic Office Infiltration", + "schedule_rules": [ + { + "apply_tuesday": true, + "apply_saturday": false, + "schedule_day": "OfficeMedium INFIL_SCH_PNNL_Wkdy", + "apply_friday": true, + "apply_monday": true, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": true, + "type": "ScheduleRuleAbridged", + "apply_thursday": true, + "apply_sunday": false + }, + { + "apply_tuesday": false, + "apply_saturday": true, + "schedule_day": "OfficeMedium INFIL_SCH_PNNL_Sat", + "apply_friday": false, + "apply_monday": false, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": false, + "type": "ScheduleRuleAbridged", + "apply_thursday": false, + "apply_sunday": false + } + ], + "default_day_schedule": "OfficeMedium INFIL_SCH_PNNL_Default", + "holiday_schedule": "OfficeMedium INFIL_SCH_PNNL_Default", + "summer_designday_schedule": "OfficeMedium INFIL_SCH_PNNL_Wkdy_SmrDsn", + "schedule_type_limit": "Fractional", + "type": "ScheduleRulesetAbridged", + "winter_designday_schedule": "OfficeMedium INFIL_SCH_PNNL_Sat_WntrDsn", + "day_schedules": [ + { + "identifier": "OfficeMedium INFIL_SCH_PNNL_Default", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 1 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium INFIL_SCH_PNNL_Wkdy_SmrDsn", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 1, + 0.25, + 1 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium INFIL_SCH_PNNL_Sat_WntrDsn", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 18, + 0 + ] + ], + "values": [ + 1, + 0.25, + 1 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium INFIL_SCH_PNNL_Wkdy", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 1, + 0.25, + 1 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium INFIL_SCH_PNNL_Sat", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 18, + 0 + ] + ], + "values": [ + 1, + 0.25, + 1 + ], + "type": "ScheduleDay", + "interpolate": false + } + ] + }, + { + "identifier": "Generic Office Heating", + "schedule_rules": [ + { + "apply_tuesday": true, + "apply_saturday": false, + "schedule_day": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Wkdy", + "apply_friday": true, + "apply_monday": true, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": true, + "type": "ScheduleRuleAbridged", + "apply_thursday": true, + "apply_sunday": false + }, + { + "apply_tuesday": false, + "apply_saturday": true, + "schedule_day": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Sat", + "apply_friday": false, + "apply_monday": false, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": false, + "type": "ScheduleRuleAbridged", + "apply_thursday": false, + "apply_sunday": false + } + ], + "default_day_schedule": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Default", + "holiday_schedule": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Default", + "summer_designday_schedule": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Default_SmrDsn", + "schedule_type_limit": "Temperature", + "type": "ScheduleRulesetAbridged", + "winter_designday_schedule": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_WntrDsn", + "day_schedules": [ + { + "identifier": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Default", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 15.6 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Default_SmrDsn", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 15.6 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_WntrDsn", + "times": [ + [ + 0, + 0 + ], + [ + 5, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 15.6, + 17.6, + 19.6, + 21, + 15.6 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Wkdy", + "times": [ + [ + 0, + 0 + ], + [ + 5, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 15.6, + 17.8, + 20, + 21, + 15.6 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium HTGSETP_SCH_YES_OPTIMUM_Sat", + "times": [ + [ + 0, + 0 + ], + [ + 5, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 17, + 0 + ] + ], + "values": [ + 15.6, + 17.8, + 20, + 21, + 15.6 + ], + "type": "ScheduleDay", + "interpolate": false + } + ] + }, + { + "identifier": "Generic Office Equipment", + "schedule_rules": [ + { + "apply_tuesday": true, + "apply_saturday": false, + "schedule_day": "OfficeMedium BLDG_EQUIP_SCH_2013_Wkdy", + "apply_friday": true, + "apply_monday": true, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": true, + "type": "ScheduleRuleAbridged", + "apply_thursday": true, + "apply_sunday": false + }, + { + "apply_tuesday": false, + "apply_saturday": true, + "schedule_day": "OfficeMedium BLDG_EQUIP_SCH_2013_Sat", + "apply_friday": false, + "apply_monday": false, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": false, + "type": "ScheduleRuleAbridged", + "apply_thursday": false, + "apply_sunday": false + } + ], + "default_day_schedule": "OfficeMedium BLDG_EQUIP_SCH_2013_Sun", + "holiday_schedule": "OfficeMedium BLDG_EQUIP_SCH_2013_Sat", + "summer_designday_schedule": "OfficeMedium BLDG_EQUIP_SCH_2013_SmrDsn", + "schedule_type_limit": "Fractional", + "type": "ScheduleRulesetAbridged", + "winter_designday_schedule": "OfficeMedium BLDG_EQUIP_SCH_2013_WntrDsn", + "day_schedules": [ + { + "identifier": "OfficeMedium BLDG_EQUIP_SCH_2013_Sun", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 18, + 0 + ] + ], + "values": [ + 0.2307553806, + 0.288107175, + 0.2307553806 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_EQUIP_SCH_2013_SmrDsn", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 1 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_EQUIP_SCH_2013_WntrDsn", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 0 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_EQUIP_SCH_2013_Sat", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 8, + 0 + ], + [ + 12, + 0 + ], + [ + 17, + 0 + ], + [ + 19, + 0 + ] + ], + "values": [ + 0.2307553806, + 0.381234796, + 0.476543495, + 0.3335804465, + 0.285926097, + 0.2307553806 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_EQUIP_SCH_2013_Wkdy", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 8, + 0 + ], + [ + 12, + 0 + ], + [ + 13, + 0 + ], + [ + 17, + 0 + ], + [ + 18, + 0 + ] + ], + "values": [ + 0.3076738408, + 0.381234796, + 0.857778291, + 0.762469592, + 0.857778291, + 0.476543495, + 0.381234796 + ], + "type": "ScheduleDay", + "interpolate": false + } + ] + }, + { + "identifier": "Generic Office Cooling", + "schedule_rules": [ + { + "apply_tuesday": true, + "apply_saturday": false, + "schedule_day": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Wkdy", + "apply_friday": true, + "apply_monday": true, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": true, + "type": "ScheduleRuleAbridged", + "apply_thursday": true, + "apply_sunday": false + }, + { + "apply_tuesday": false, + "apply_saturday": true, + "schedule_day": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Sat", + "apply_friday": false, + "apply_monday": false, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": false, + "type": "ScheduleRuleAbridged", + "apply_thursday": false, + "apply_sunday": false + } + ], + "default_day_schedule": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Default", + "holiday_schedule": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Default", + "summer_designday_schedule": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_SmrDsn", + "schedule_type_limit": "Temperature", + "type": "ScheduleRulesetAbridged", + "winter_designday_schedule": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Default_WntrDsn", + "day_schedules": [ + { + "identifier": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Default", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 26.7 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_SmrDsn", + "times": [ + [ + 0, + 0 + ], + [ + 5, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 26.7, + 25.7, + 25, + 24, + 26.7 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Default_WntrDsn", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 26.7 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Wkdy", + "times": [ + [ + 0, + 0 + ], + [ + 5, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 26.7, + 25.6, + 25, + 24, + 26.7 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium CLGSETP_SCH_YES_OPTIMUM_Sat", + "times": [ + [ + 0, + 0 + ], + [ + 5, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 17, + 0 + ] + ], + "values": [ + 26.7, + 25.7, + 25, + 24, + 26.7 + ], + "type": "ScheduleDay", + "interpolate": false + } + ] + }, + { + "identifier": "Seated Adult Activity", + "default_day_schedule": "Seated Adult Activity_Day Schedule", + "schedule_type_limit": "Activity Level", + "type": "ScheduleRulesetAbridged", + "day_schedules": [ + { + "identifier": "Seated Adult Activity_Day Schedule", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 120 + ], + "type": "ScheduleDay", + "interpolate": false + } + ] + }, + { + "identifier": "Generic Office Lighting", + "schedule_rules": [ + { + "apply_tuesday": true, + "apply_saturday": false, + "schedule_day": "OfficeMedium BLDG_LIGHT_SCH_2013_Wkdy", + "apply_friday": true, + "apply_monday": true, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": true, + "type": "ScheduleRuleAbridged", + "apply_thursday": true, + "apply_sunday": false + }, + { + "apply_tuesday": false, + "apply_saturday": true, + "schedule_day": "OfficeMedium BLDG_LIGHT_SCH_2013_Sat", + "apply_friday": false, + "apply_monday": false, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": false, + "type": "ScheduleRuleAbridged", + "apply_thursday": false, + "apply_sunday": false + } + ], + "default_day_schedule": "OfficeMedium BLDG_LIGHT_SCH_2013_Sun", + "holiday_schedule": "OfficeMedium BLDG_LIGHT_SCH_2013_Sat", + "summer_designday_schedule": "OfficeMedium BLDG_LIGHT_SCH_2013_SmrDsn", + "schedule_type_limit": "Fractional", + "type": "ScheduleRulesetAbridged", + "winter_designday_schedule": "OfficeMedium BLDG_LIGHT_SCH_2013_WntrDsn", + "day_schedules": [ + { + "identifier": "OfficeMedium BLDG_LIGHT_SCH_2013_Sun", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 18, + 0 + ] + ], + "values": [ + 0.05, + 0.04311628, + 0.05 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_LIGHT_SCH_2013_SmrDsn", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 1 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_LIGHT_SCH_2013_WntrDsn", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 0 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_LIGHT_SCH_2013_Sat", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 8, + 0 + ], + [ + 12, + 0 + ], + [ + 17, + 0 + ], + [ + 19, + 0 + ] + ], + "values": [ + 0.05, + 0.08623256, + 0.25869768, + 0.12934884, + 0.04311628, + 0.05 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_LIGHT_SCH_2013_Wkdy", + "times": [ + [ + 0, + 0 + ], + [ + 5, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 8, + 0 + ], + [ + 17, + 0 + ], + [ + 18, + 0 + ], + [ + 20, + 0 + ], + [ + 22, + 0 + ], + [ + 23, + 0 + ] + ], + "values": [ + 0.05, + 0.1, + 0.08623256, + 0.25869768, + 0.77609304, + 0.4311628, + 0.25869768, + 0.17246512, + 0.08623256, + 0.04311628 + ], + "type": "ScheduleDay", + "interpolate": false + } + ] + }, + { + "identifier": "Generic Office Occupancy", + "schedule_rules": [ + { + "apply_tuesday": true, + "apply_saturday": false, + "schedule_day": "OfficeMedium BLDG_OCC_SCH_Wkdy", + "apply_friday": true, + "apply_monday": true, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": true, + "type": "ScheduleRuleAbridged", + "apply_thursday": true, + "apply_sunday": false + }, + { + "apply_tuesday": false, + "apply_saturday": true, + "schedule_day": "OfficeMedium BLDG_OCC_SCH_Sat", + "apply_friday": false, + "apply_monday": false, + "start_date": [ + 1, + 1 + ], + "end_date": [ + 12, + 31 + ], + "apply_wednesday": false, + "type": "ScheduleRuleAbridged", + "apply_thursday": false, + "apply_sunday": false + } + ], + "default_day_schedule": "OfficeMedium BLDG_OCC_SCH_Default", + "holiday_schedule": "OfficeMedium BLDG_OCC_SCH_Default", + "summer_designday_schedule": "OfficeMedium BLDG_OCC_SCH_SmrDsn", + "schedule_type_limit": "Fractional", + "type": "ScheduleRulesetAbridged", + "winter_designday_schedule": "OfficeMedium BLDG_OCC_SCH_WntrDsn", + "day_schedules": [ + { + "identifier": "OfficeMedium BLDG_OCC_SCH_Default", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 18, + 0 + ] + ], + "values": [ + 0, + 0.05, + 0 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_OCC_SCH_SmrDsn", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 0, + 1, + 0.05 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_OCC_SCH_WntrDsn", + "times": [ + [ + 0, + 0 + ] + ], + "values": [ + 0 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_OCC_SCH_Wkdy", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 7, + 0 + ], + [ + 8, + 0 + ], + [ + 12, + 0 + ], + [ + 13, + 0 + ], + [ + 17, + 0 + ], + [ + 18, + 0 + ], + [ + 22, + 0 + ] + ], + "values": [ + 0, + 0.1, + 0.2, + 0.95, + 0.5, + 0.95, + 0.3, + 0.1, + 0.05 + ], + "type": "ScheduleDay", + "interpolate": false + }, + { + "identifier": "OfficeMedium BLDG_OCC_SCH_Sat", + "times": [ + [ + 0, + 0 + ], + [ + 6, + 0 + ], + [ + 8, + 0 + ], + [ + 12, + 0 + ], + [ + 17, + 0 + ], + [ + 19, + 0 + ] + ], + "values": [ + 0, + 0.1, + 0.3, + 0.1, + 0.05, + 0 + ], + "type": "ScheduleDay", + "interpolate": false + } + ] + } + ], + "program_types": [ + { + "identifier": "Generic Office Program", + "infiltration": { + "flow_per_exterior_area": 0.0002266, + "schedule": "Generic Office Infiltration", + "type": "InfiltrationAbridged", + "identifier": "Generic Office Infiltration" + }, + "lighting": { + "identifier": "Generic Office Lighting", + "radiant_fraction": 0.7, + "visible_fraction": 0.2, + "type": "LightingAbridged", + "return_air_fraction": 0, + "watts_per_area": 10.55, + "schedule": "Generic Office Lighting" + }, + "electric_equipment": { + "identifier": "Generic Office Equipment", + "radiant_fraction": 0.5, + "latent_fraction": 0, + "type": "ElectricEquipmentAbridged", + "watts_per_area": 10.33, + "lost_fraction": 0, + "schedule": "Generic Office Equipment" + }, + "setpoint": { + "heating_schedule": "Generic Office Heating", + "type": "SetpointAbridged", + "cooling_schedule": "Generic Office Cooling", + "identifier": "Generic Office Setpoints" + }, + "ventilation": { + "flow_per_area": 0.000305, + "type": "VentilationAbridged", + "flow_per_person": 0.00236, + "identifier": "Generic Office Ventilation" + }, + "type": "ProgramTypeAbridged", + "people": { + "identifier": "Generic Office People", + "radiant_fraction": 0.3, + "people_per_area": 0.0565, + "latent_fraction": { + "type": "Autocalculate" + }, + "occupancy_schedule": "Generic Office Occupancy", + "type": "PeopleAbridged", + "activity_schedule": "Seated Adult Activity" + } + } + ], + "construction_sets": [] + }, + "type": "ModelProperties", + "uwg": { + "grass_coverage_fraction": 0, + "type": "ModelUWGProperties", + "traffic": { + "type": "TrafficParameter" + } + } + } +} \ No newline at end of file diff --git a/src/TypeScriptSDK/jest.config.js b/src/TypeScriptSDK/jest.config.js new file mode 100644 index 0000000..b0faf4d --- /dev/null +++ b/src/TypeScriptSDK/jest.config.js @@ -0,0 +1,13 @@ +export default { + preset: 'ts-jest/presets/default-esm', + testEnvironment: 'node', + setupFiles: ['./tests/jest.setup.ts'], + transform: { + '^.+\\.ts?$': ['ts-jest', { useESM: true }], + }, + extensionsToTreatAsEsm: ['.ts'], + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, + }; + \ No newline at end of file diff --git a/src/TypeScriptSDK/package.json b/src/TypeScriptSDK/package.json index 84d0837..590bd5a 100644 --- a/src/TypeScriptSDK/package.json +++ b/src/TypeScriptSDK/package.json @@ -10,19 +10,23 @@ "compile": "tsc", "fix": "gts fix", "prepare": "tsc", - "pretest": "tsc" + "pretest": "tsc", + "test": "jest" }, "devDependencies": { + "@types/jest": "^29.5.13", "@types/node": "20.12.7", "gts": "^5.3.1", - "typescript": "^5.4.3", + "jest": "^29.7.0", + "reflect-metadata": "^0.2.2", + "ts-jest": "^29.2.5", + "typescript": "^5.6.2", "vite": "^5.4.1", "vite-tsconfig-paths": "^5.0.1" }, "dependencies": { - "class-validator": "^0.14.1", - "reflect-metadata": "^0.2.2", "class-transformer": "^0.5.1", - "honeybee-schema": "latest" + "class-validator": "^0.14.1", + "honeybee-schema": "file:D:/Dev/Schema/honeybee-schema-dotnet/src/TypeScriptSDK" } } diff --git a/src/TypeScriptSDK/tests/Model.test.ts b/src/TypeScriptSDK/tests/Model.test.ts new file mode 100644 index 0000000..7c3da95 --- /dev/null +++ b/src/TypeScriptSDK/tests/Model.test.ts @@ -0,0 +1,200 @@ +import { plainToClass } from "class-transformer"; +import { Model } from "../models"; +import { Face3D, GlobalModifierSet, WallModifierSetAbridged } from "honeybee-schema"; +import * as fs from 'fs'; +import * as path from 'path'; + +test('test model', () => { + const dir = path.dirname(path.dirname(path.dirname(__dirname))); + const sampleDir = path.join(dir, 'samples'); + console.log(sampleDir); + + const filePath = path.join(sampleDir, 'Room_with_complex_skylights.dfjson'); + const jsonData = fs.readFileSync(filePath, 'utf8'); + // console.log(jsonData); + + const json = JSON.parse(jsonData); + const model = Model.fromJS(json); + expect(model.identifier).toBe("unnamed_cb67f62e"); + expect(model.validate()).resolves.toBe(true); + +}); + +test('test wallSet', () => { + const data = { + "type": "WallModifierSetAbridged", + "interior_modifier": "generic_wall_0.50", + "exterior_modifier": "generic_wall_0.50" +}; + const obj = WallModifierSetAbridged.fromJS(data); + expect(obj.validate()).resolves.toBe(true); + + const jsonObj = obj.toJSON(); + expect(jsonObj.type).toBe("WallModifierSetAbridged"); + expect(jsonObj).toHaveProperty("interior_modifier"); + expect(jsonObj.hasOwnProperty("ground_construction")).toBe(false); + +}); + +test('test wallSet', () => { + const data = { + "shade_set": { + "type": "ShadeModifierSetAbridged", + "interior_modifier": "generic_interior_shade_0.50", + "exterior_modifier": "generic_exterior_shade_0.35" + }, + "roof_ceiling_set": { + "type": "RoofCeilingModifierSetAbridged", + "interior_modifier": "generic_ceiling_0.80", + "exterior_modifier": "generic_ceiling_0.80" + }, + "context_modifier": "generic_context_0.20", + "modifiers": [ + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.5, + "identifier": "generic_wall_0.50", + "specularity": 0, + "b_reflectance": 0.5, + "r_reflectance": 0.5, + "type": "Plastic", + "roughness": 0 + }, + { + "b_transmissivity": 0.9584154328610596, + "r_transmissivity": 0.9584154328610596, + "modifier": null, + "identifier": "generic_interior_window_vis_0.88", + "refraction_index": null, + "type": "Glass", + "dependencies": [], + "g_transmissivity": 0.9584154328610596 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.5, + "identifier": "generic_interior_shade_0.50", + "specularity": 0, + "b_reflectance": 0.5, + "r_reflectance": 0.5, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.2, + "identifier": "generic_floor_0.20", + "specularity": 0, + "b_reflectance": 0.2, + "r_reflectance": 0.2, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.8, + "identifier": "generic_ceiling_0.80", + "specularity": 0, + "b_reflectance": 0.8, + "r_reflectance": 0.8, + "type": "Plastic", + "roughness": 0 + }, + { + "b_transmissivity": 0.6975761815384331, + "r_transmissivity": 0.6975761815384331, + "modifier": null, + "identifier": "generic_exterior_window_vis_0.64", + "refraction_index": null, + "type": "Glass", + "dependencies": [], + "g_transmissivity": 0.6975761815384331 + }, + { + "r_reflectance": 1, + "b_reflectance": 1, + "roughness": 0, + "identifier": "air_boundary", + "type": "Trans", + "dependencies": [], + "g_reflectance": 1, + "specularity": 0, + "transmitted_diff": 1, + "transmitted_spec": 1, + "modifier": null + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.35, + "identifier": "generic_exterior_shade_0.35", + "specularity": 0, + "b_reflectance": 0.35, + "r_reflectance": 0.35, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.5, + "identifier": "generic_opaque_door_0.50", + "specularity": 0, + "b_reflectance": 0.5, + "r_reflectance": 0.5, + "type": "Plastic", + "roughness": 0 + }, + { + "dependencies": [], + "modifier": null, + "g_reflectance": 0.2, + "identifier": "generic_context_0.20", + "specularity": 0, + "b_reflectance": 0.2, + "r_reflectance": 0.2, + "type": "Plastic", + "roughness": 0 + } + ], + "wall_set": { + "type": "WallModifierSetAbridged", + "interior_modifier": "generic_wall_0.50", + "exterior_modifier": "generic_wall_0.50" + }, + "door_set": { + "exterior_glass_modifier": "generic_exterior_window_vis_0.64", + "interior_glass_modifier": "generic_interior_window_vis_0.88", + "overhead_modifier": "generic_opaque_door_0.50", + "exterior_modifier": "generic_opaque_door_0.50", + "interior_modifier": "generic_opaque_door_0.50", + "type": "DoorModifierSetAbridged" + }, + "floor_set": { + "type": "FloorModifierSetAbridged", + "interior_modifier": "generic_floor_0.20", + "exterior_modifier": "generic_floor_0.20" + }, + "type": "GlobalModifierSet", + "aperture_set": { + "interior_modifier": "generic_interior_window_vis_0.88", + "window_modifier": "generic_exterior_window_vis_0.64", + "skylight_modifier": "generic_exterior_window_vis_0.64", + "type": "ApertureModifierSetAbridged", + "operable_modifier": "generic_exterior_window_vis_0.64" + }, + "air_boundary_modifier": "air_boundary" +}; + const obj = GlobalModifierSet.fromJS(data); + expect(obj.validate()).resolves.toBe(true); + + const jsonObj = obj.toJSON(); + expect(jsonObj.type).toBe("WallModifierSetAbridged"); + expect(jsonObj).toHaveProperty("interior_modifier"); + expect(jsonObj.hasOwnProperty("ground_construction")).toBe(false); + +}); \ No newline at end of file diff --git a/src/TypeScriptSDK/tests/Room2D.test.ts b/src/TypeScriptSDK/tests/Room2D.test.ts new file mode 100644 index 0000000..a193901 --- /dev/null +++ b/src/TypeScriptSDK/tests/Room2D.test.ts @@ -0,0 +1,228 @@ +import { plainToClass } from "class-transformer"; +import { Model, Room2D, Room2DPropertiesAbridged } from "../models"; +import { Face3D } from "honeybee-schema"; +import * as fs from 'fs'; +import * as path from 'path'; + +test('test room2d', () => { + const roomData = { + "type": "Room2D", + "identifier": "Room_e6ac360b-aaed-4c3b-a130-36b4c2ac9d13-000d1467", + "display_name": "Master Bedroom-206", + "properties": { + "type": "Room2DPropertiesAbridged", + "energy": { "type": "Room2DEnergyPropertiesAbridged" } + }, + "floor_boundary": [ + [1.061931517437636, 2.8994060214182706], + [-4.888068482562394, 2.899406021418289], + [-4.8880684825623835, -3.302593978581498], + [-1.378068482562382, -3.302593978581509], + [-1.3780684825623764, 0.038406021418214205], + [-0.18806848256237596, 0.03840602141821037], + [1.0619315174376316, 0.03840602141820621], + [1.0619315174376338, 1.358406021418206] + ], + "floor_height": 3.0000000000000004, + "floor_to_ceiling_height": 6.000000000000001, + "is_ground_contact": false, + "is_top_exposed": true, + "boundary_conditions": [ + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + }, + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + }, + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + }, + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + }, + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + }, + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + }, + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + }, + { + "type": "Outdoors", + "sun_exposure": true, + "wind_exposure": true, + "view_factor": { "type": "Autocalculate" } + } + ], + "window_parameters": [ + { + "type": "DetailedWindows", + "polygons": [ + [ + [3.0000000000000084, 2.6999999999999935], + [4.500000000000007, 2.6999999999999926], + [4.500000000000007, 0.0009143999999994932], + [3.0000000000000084, 0.0009144000000000347] + ] + ], + "are_doors": [false], + "user_data": {} + }, + { + "type": "DetailedWindows", + "polygons": [ + [ + [1.620999999999999, 0.04000000000000011], + [1.620999999999999, 2.0800000000000005], + [3.0809999999999995, 2.0800000000000005], + [3.0809999999999995, 0.04000000000000011] + ], + [ + [3.120999999999999, 0.04000000000000011], + [3.120999999999999, 2.0800000000000005], + [4.581, 2.0800000000000005], + [4.581, 0.04000000000000011] + ], + [ + [4.620999999999893, 0.04000000000000011], + [4.620999999999893, 2.0800000000000005], + [6.060999999999892, 2.0800000000000005], + [6.060999999999892, 0.04000000000000011] + ], + [ + [0.25884214488802365, 3.02], + [1.5809999999999995, 4.39435106696338], + [1.5809999999999995, 3.02] + ], + [ + [1.620999999999999, 4.435930098140318], + [2.9876230980831053, 5.856501708198367], + [3.080999999999999, 5.766670945649302], + [3.080999999999999, 3.02], + [1.6209999999999998, 3.02] + ], + [ + [3.121, 3.02], + [3.121, 5.728190010555089], + [4.581, 4.323635879616347], + [4.581, 3.02] + ], + [ + [4.6209999999999996, 3.02], + [4.6209999999999996, 4.285154944522135], + [5.9360979220485985, 3.02] + ], + [ + [0.14099999999999935, 2.12], + [0.14099999999999935, 2.897505944593588], + [0.22036120979381166, 2.9800000000000004], + [1.5809999999999993, 2.9800000000000004], + [1.5809999999999993, 2.12] + ], + [ + [1.6209999999999993, 2.12], + [1.6209999999999993, 2.9800000000000004], + [3.080999999999999, 2.9800000000000004], + [3.080999999999999, 2.12] + ], + [ + [3.121, 2.12], + [3.121, 2.9800000000000004], + [4.5809999999999995, 2.9800000000000004], + [4.5809999999999995, 2.12] + ], + [ + [4.620999999999999, 2.12], + [4.620999999999999, 2.9800000000000004], + [5.977676953225537, 2.9800000000000004], + [6.060999999999788, 2.899841281130703], + [6.060999999999788, 2.12] + ] + ], + "are_doors": [ + false, + false, + false, + false, + false, + false, + false, + false, + false, + false, + false + ], + "user_data": {} + }, + { + "type": "DetailedWindows", + "polygons": [ + [ + [1.4500000000000255, 0.0009143999999994932], + [1.4500000000000255, 2.6999999999999926], + [2.950000000000024, 2.6999999999999935], + [2.950000000000024, 0.0009144000000000347] + ] + ], + "are_doors": [false], + "user_data": {} + }, + null, + null, + null, + null, + null + ], + "user_data": {} + } + const obj = Room2D.fromJS(roomData); + expect(obj.identifier).toBe("Room_e6ac360b-aaed-4c3b-a130-36b4c2ac9d13-000d1467"); + expect(obj.validate()).resolves.toBe(true); + + const jsonObj = obj.toJSON(); + const prop = jsonObj["properties"]; + expect(prop["energy"].hasOwnProperty("hvac")).toBe(false); + expect(prop.hasOwnProperty("radiance")).toBe(false); + + +}); + + + +test('test roomProperty', () => { + const roomData = { + "type": "Room2DPropertiesAbridged", + "energy": { "type": "Room2DEnergyPropertiesAbridged" } + }; + const obj = Room2DPropertiesAbridged.fromJS(roomData); + expect(obj.validate()).resolves.toBe(true); + + const jsonObj = obj.toJSON(); + expect(jsonObj.type).toBe("Room2DPropertiesAbridged"); + expect(jsonObj).toHaveProperty("energy"); + expect(jsonObj.hasOwnProperty("radiance")).toBe(false); + +}); \ No newline at end of file diff --git a/src/TypeScriptSDK/tests/jest.setup.ts b/src/TypeScriptSDK/tests/jest.setup.ts new file mode 100644 index 0000000..359e0de --- /dev/null +++ b/src/TypeScriptSDK/tests/jest.setup.ts @@ -0,0 +1 @@ +import 'reflect-metadata'; \ No newline at end of file diff --git a/src/TypeScriptSDK/tsconfig.json b/src/TypeScriptSDK/tsconfig.json index b50036b..66ca670 100644 --- a/src/TypeScriptSDK/tsconfig.json +++ b/src/TypeScriptSDK/tsconfig.json @@ -25,8 +25,10 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + + "types": ["node", "jest"], }, - "include": [ "models", "helpers"], + "include": [ "models", "helpers", "tests"], "exclude": ["node_modules"] } From 4fd8576d9a5879ecd815c63a5239e59ea067daba Mon Sep 17 00:00:00 2001 From: Mingbo Peng Date: Mon, 23 Sep 2024 17:20:34 +0800 Subject: [PATCH 2/6] fix(TS): regenerate with new toJSON --- .generator | 2 +- src/TypeScriptSDK/models/Building.ts | 6 +---- .../BuildingEnergyPropertiesAbridged.ts | 6 +---- .../models/BuildingPropertiesAbridged.ts | 6 +---- .../BuildingRadiancePropertiesAbridged.ts | 6 +---- src/TypeScriptSDK/models/ContextShade.ts | 6 +---- .../ContextShadeEnergyPropertiesAbridged.ts | 6 +---- .../models/ContextShadePropertiesAbridged.ts | 6 +---- .../ContextShadeRadiancePropertiesAbridged.ts | 6 +---- src/TypeScriptSDK/models/DetailedSkylights.ts | 6 +---- src/TypeScriptSDK/models/DetailedWindows.ts | 6 +---- .../models/ExteriorApertureGridParameter.ts | 6 +---- .../models/ExteriorFaceGridParameter.ts | 6 +---- src/TypeScriptSDK/models/ExtrudedBorder.ts | 6 +---- .../models/GriddedSkylightArea.ts | 6 +---- .../models/GriddedSkylightRatio.ts | 6 +---- src/TypeScriptSDK/models/LouversByCount.ts | 6 +---- src/TypeScriptSDK/models/LouversByDistance.ts | 6 +---- src/TypeScriptSDK/models/Model.ts | 6 +---- .../models/ModelEnergyProperties.ts | 6 +---- src/TypeScriptSDK/models/ModelProperties.ts | 6 +---- .../models/ModelRadianceProperties.ts | 6 +---- src/TypeScriptSDK/models/Overhang.ts | 6 +---- .../models/RectangularWindows.ts | 6 +---- .../models/RepeatingWindowRatio.ts | 6 +---- src/TypeScriptSDK/models/RoofSpecification.ts | 6 +---- src/TypeScriptSDK/models/Room2D.ts | 6 +---- .../models/Room2DEnergyPropertiesAbridged.ts | 6 +---- .../models/Room2DPropertiesAbridged.ts | 6 +---- .../Room2DRadiancePropertiesAbridged.ts | 6 +---- src/TypeScriptSDK/models/RoomGridParameter.ts | 6 +---- .../models/RoomRadialGridParameter.ts | 6 +---- src/TypeScriptSDK/models/SimpleWindowArea.ts | 6 +---- src/TypeScriptSDK/models/SimpleWindowRatio.ts | 6 +---- src/TypeScriptSDK/models/SingleWindow.ts | 6 +---- src/TypeScriptSDK/models/Story.ts | 6 +---- .../models/StoryEnergyPropertiesAbridged.ts | 6 +---- .../models/StoryPropertiesAbridged.ts | 6 +---- .../models/StoryRadiancePropertiesAbridged.ts | 6 +---- .../models/_GridParameterBase.ts | 6 +---- src/TypeScriptSDK/models/_LouversBase.ts | 6 +---- .../models/_OpenAPIGenBaseModel.ts | 22 +++++++++++++------ .../models/_WindowParameterBase.ts | 6 +---- 43 files changed, 57 insertions(+), 213 deletions(-) diff --git a/.generator b/.generator index 416f844..7f39558 160000 --- a/.generator +++ b/.generator @@ -1 +1 @@ -Subproject commit 416f8442b277424c2e7f50ffa3edf89e0249a59f +Subproject commit 7f395585e4ec7ea9633627f575edf48a10869ec6 diff --git a/src/TypeScriptSDK/models/Building.ts b/src/TypeScriptSDK/models/Building.ts index b634f87..0abe935 100644 --- a/src/TypeScriptSDK/models/Building.ts +++ b/src/TypeScriptSDK/models/Building.ts @@ -73,11 +73,6 @@ export class Building extends IDdBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["properties"] = this.properties; data["type"] = this.type; data["unique_stories"] = this.unique_stories; @@ -96,3 +91,4 @@ export class Building extends IDdBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts index f428ce8..bd65fff 100644 --- a/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts @@ -43,11 +43,6 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["construction_set"] = this.construction_set; data = super.toJSON(data); @@ -63,3 +58,4 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts index 03b47dc..c0983ef 100644 --- a/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts @@ -50,11 +50,6 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["energy"] = this.energy; data["radiance"] = this.radiance; @@ -71,3 +66,4 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts index bab2e21..b469476 100644 --- a/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts @@ -41,11 +41,6 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["modifier_set"] = this.modifier_set; data = super.toJSON(data); @@ -61,3 +56,4 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/ContextShade.ts b/src/TypeScriptSDK/models/ContextShade.ts index 95187e9..fe6f8f1 100644 --- a/src/TypeScriptSDK/models/ContextShade.ts +++ b/src/TypeScriptSDK/models/ContextShade.ts @@ -59,11 +59,6 @@ export class ContextShade extends IDdBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["geometry"] = this.geometry; data["properties"] = this.properties; data["type"] = this.type; @@ -81,3 +76,4 @@ export class ContextShade extends IDdBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts index a996441..0488308 100644 --- a/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts @@ -51,11 +51,6 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["construction"] = this.construction; data["transmittance_schedule"] = this.transmittance_schedule; @@ -72,3 +67,4 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts index 8c783e5..c615d69 100644 --- a/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts @@ -50,11 +50,6 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["energy"] = this.energy; data["radiance"] = this.radiance; @@ -71,3 +66,4 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts index aeed841..fde3d86 100644 --- a/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts @@ -41,11 +41,6 @@ export class ContextShadeRadiancePropertiesAbridged extends _OpenAPIGenBaseModel override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["modifier"] = this.modifier; data = super.toJSON(data); @@ -61,3 +56,4 @@ export class ContextShadeRadiancePropertiesAbridged extends _OpenAPIGenBaseModel return true; } } + diff --git a/src/TypeScriptSDK/models/DetailedSkylights.ts b/src/TypeScriptSDK/models/DetailedSkylights.ts index 62973a7..29bbdda 100644 --- a/src/TypeScriptSDK/models/DetailedSkylights.ts +++ b/src/TypeScriptSDK/models/DetailedSkylights.ts @@ -50,11 +50,6 @@ export class DetailedSkylights extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["polygons"] = this.polygons; data["type"] = this.type; data["are_doors"] = this.are_doors; @@ -71,3 +66,4 @@ export class DetailedSkylights extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/DetailedWindows.ts b/src/TypeScriptSDK/models/DetailedWindows.ts index 8be6e08..00cd615 100644 --- a/src/TypeScriptSDK/models/DetailedWindows.ts +++ b/src/TypeScriptSDK/models/DetailedWindows.ts @@ -50,11 +50,6 @@ export class DetailedWindows extends _WindowParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["polygons"] = this.polygons; data["type"] = this.type; data["are_doors"] = this.are_doors; @@ -71,3 +66,4 @@ export class DetailedWindows extends _WindowParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts b/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts index ea74886..d3006f4 100644 --- a/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts +++ b/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts @@ -51,11 +51,6 @@ export class ExteriorApertureGridParameter extends _GridParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["offset"] = this.offset; data["aperture_type"] = this.aperture_type; @@ -72,3 +67,4 @@ export class ExteriorApertureGridParameter extends _GridParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts b/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts index 96688dd..a73f470 100644 --- a/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts +++ b/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts @@ -58,11 +58,6 @@ export class ExteriorFaceGridParameter extends _GridParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["offset"] = this.offset; data["face_type"] = this.face_type; @@ -80,3 +75,4 @@ export class ExteriorFaceGridParameter extends _GridParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/ExtrudedBorder.ts b/src/TypeScriptSDK/models/ExtrudedBorder.ts index bdb28bc..f29b51c 100644 --- a/src/TypeScriptSDK/models/ExtrudedBorder.ts +++ b/src/TypeScriptSDK/models/ExtrudedBorder.ts @@ -41,11 +41,6 @@ export class ExtrudedBorder extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["depth"] = this.depth; data["type"] = this.type; data = super.toJSON(data); @@ -61,3 +56,4 @@ export class ExtrudedBorder extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/GriddedSkylightArea.ts b/src/TypeScriptSDK/models/GriddedSkylightArea.ts index 83b0a33..222c9ff 100644 --- a/src/TypeScriptSDK/models/GriddedSkylightArea.ts +++ b/src/TypeScriptSDK/models/GriddedSkylightArea.ts @@ -48,11 +48,6 @@ export class GriddedSkylightArea extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["skylight_area"] = this.skylight_area; data["type"] = this.type; data["spacing"] = this.spacing; @@ -69,3 +64,4 @@ export class GriddedSkylightArea extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/GriddedSkylightRatio.ts b/src/TypeScriptSDK/models/GriddedSkylightRatio.ts index 96dd9be..bbf1219 100644 --- a/src/TypeScriptSDK/models/GriddedSkylightRatio.ts +++ b/src/TypeScriptSDK/models/GriddedSkylightRatio.ts @@ -48,11 +48,6 @@ export class GriddedSkylightRatio extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["skylight_ratio"] = this.skylight_ratio; data["type"] = this.type; data["spacing"] = this.spacing; @@ -69,3 +64,4 @@ export class GriddedSkylightRatio extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/LouversByCount.ts b/src/TypeScriptSDK/models/LouversByCount.ts index 9239ea3..f5338a6 100644 --- a/src/TypeScriptSDK/models/LouversByCount.ts +++ b/src/TypeScriptSDK/models/LouversByCount.ts @@ -41,11 +41,6 @@ export class LouversByCount extends _LouversBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["louver_count"] = this.louver_count; data["type"] = this.type; data = super.toJSON(data); @@ -61,3 +56,4 @@ export class LouversByCount extends _LouversBase { return true; } } + diff --git a/src/TypeScriptSDK/models/LouversByDistance.ts b/src/TypeScriptSDK/models/LouversByDistance.ts index bbc71b2..d5225b0 100644 --- a/src/TypeScriptSDK/models/LouversByDistance.ts +++ b/src/TypeScriptSDK/models/LouversByDistance.ts @@ -41,11 +41,6 @@ export class LouversByDistance extends _LouversBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["distance"] = this.distance; data["type"] = this.type; data = super.toJSON(data); @@ -61,3 +56,4 @@ export class LouversByDistance extends _LouversBase { return true; } } + diff --git a/src/TypeScriptSDK/models/Model.ts b/src/TypeScriptSDK/models/Model.ts index c34dc80..a2b7e7a 100644 --- a/src/TypeScriptSDK/models/Model.ts +++ b/src/TypeScriptSDK/models/Model.ts @@ -97,11 +97,6 @@ export class Model extends IDdBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["properties"] = this.properties; data["type"] = this.type; data["version"] = this.version; @@ -123,3 +118,4 @@ export class Model extends IDdBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/ModelEnergyProperties.ts b/src/TypeScriptSDK/models/ModelEnergyProperties.ts index c3abe01..08bf3fd 100644 --- a/src/TypeScriptSDK/models/ModelEnergyProperties.ts +++ b/src/TypeScriptSDK/models/ModelEnergyProperties.ts @@ -576,11 +576,6 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["global_construction_set"] = this.global_construction_set; data["construction_sets"] = this.construction_sets; @@ -604,3 +599,4 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/ModelProperties.ts b/src/TypeScriptSDK/models/ModelProperties.ts index 2cf4b06..dbad654 100644 --- a/src/TypeScriptSDK/models/ModelProperties.ts +++ b/src/TypeScriptSDK/models/ModelProperties.ts @@ -50,11 +50,6 @@ export class ModelProperties extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["energy"] = this.energy; data["radiance"] = this.radiance; @@ -71,3 +66,4 @@ export class ModelProperties extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/ModelRadianceProperties.ts b/src/TypeScriptSDK/models/ModelRadianceProperties.ts index 24313d0..fc2d478 100644 --- a/src/TypeScriptSDK/models/ModelRadianceProperties.ts +++ b/src/TypeScriptSDK/models/ModelRadianceProperties.ts @@ -229,11 +229,6 @@ export class ModelRadianceProperties extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["global_modifier_set"] = this.global_modifier_set; data["modifier_sets"] = this.modifier_sets; @@ -251,3 +246,4 @@ export class ModelRadianceProperties extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/Overhang.ts b/src/TypeScriptSDK/models/Overhang.ts index 7554e70..c6b441f 100644 --- a/src/TypeScriptSDK/models/Overhang.ts +++ b/src/TypeScriptSDK/models/Overhang.ts @@ -50,11 +50,6 @@ export class Overhang extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["depth"] = this.depth; data["type"] = this.type; data["angle"] = this.angle; @@ -71,3 +66,4 @@ export class Overhang extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/RectangularWindows.ts b/src/TypeScriptSDK/models/RectangularWindows.ts index ea55d73..9cba631 100644 --- a/src/TypeScriptSDK/models/RectangularWindows.ts +++ b/src/TypeScriptSDK/models/RectangularWindows.ts @@ -64,11 +64,6 @@ export class RectangularWindows extends _WindowParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["origins"] = this.origins; data["widths"] = this.widths; data["heights"] = this.heights; @@ -87,3 +82,4 @@ export class RectangularWindows extends _WindowParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/RepeatingWindowRatio.ts b/src/TypeScriptSDK/models/RepeatingWindowRatio.ts index 2a4d1d5..ddc8853 100644 --- a/src/TypeScriptSDK/models/RepeatingWindowRatio.ts +++ b/src/TypeScriptSDK/models/RepeatingWindowRatio.ts @@ -68,11 +68,6 @@ export class RepeatingWindowRatio extends _WindowParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["window_ratio"] = this.window_ratio; data["window_height"] = this.window_height; data["sill_height"] = this.sill_height; @@ -92,3 +87,4 @@ export class RepeatingWindowRatio extends _WindowParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/RoofSpecification.ts b/src/TypeScriptSDK/models/RoofSpecification.ts index 0b44507..681bbcc 100644 --- a/src/TypeScriptSDK/models/RoofSpecification.ts +++ b/src/TypeScriptSDK/models/RoofSpecification.ts @@ -45,11 +45,6 @@ export class RoofSpecification extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["geometry"] = this.geometry; data["type"] = this.type; data = super.toJSON(data); @@ -65,3 +60,4 @@ export class RoofSpecification extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/Room2D.ts b/src/TypeScriptSDK/models/Room2D.ts index e0e9f50..9cc60f3 100644 --- a/src/TypeScriptSDK/models/Room2D.ts +++ b/src/TypeScriptSDK/models/Room2D.ts @@ -133,11 +133,6 @@ export class Room2D extends IDdBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["floor_boundary"] = this.floor_boundary; data["floor_height"] = this.floor_height; data["floor_to_ceiling_height"] = this.floor_to_ceiling_height; @@ -164,3 +159,4 @@ export class Room2D extends IDdBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts index f997d8d..2978952 100644 --- a/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts @@ -95,11 +95,6 @@ export class Room2DEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["construction_set"] = this.construction_set; data["program_type"] = this.program_type; @@ -121,3 +116,4 @@ export class Room2DEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts index 7c2b8d6..c920cb1 100644 --- a/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts @@ -50,11 +50,6 @@ export class Room2DPropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["energy"] = this.energy; data["radiance"] = this.radiance; @@ -71,3 +66,4 @@ export class Room2DPropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts index 9f89143..655f92a 100644 --- a/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts @@ -51,11 +51,6 @@ export class Room2DRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["modifier_set"] = this.modifier_set; data["grid_parameters"] = this.grid_parameters; @@ -72,3 +67,4 @@ export class Room2DRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/RoomGridParameter.ts b/src/TypeScriptSDK/models/RoomGridParameter.ts index 942e8f5..eb526f7 100644 --- a/src/TypeScriptSDK/models/RoomGridParameter.ts +++ b/src/TypeScriptSDK/models/RoomGridParameter.ts @@ -49,11 +49,6 @@ export class RoomGridParameter extends _GridParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["offset"] = this.offset; data["wall_offset"] = this.wall_offset; @@ -70,3 +65,4 @@ export class RoomGridParameter extends _GridParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/RoomRadialGridParameter.ts b/src/TypeScriptSDK/models/RoomRadialGridParameter.ts index 3f11f76..a3c92f4 100644 --- a/src/TypeScriptSDK/models/RoomRadialGridParameter.ts +++ b/src/TypeScriptSDK/models/RoomRadialGridParameter.ts @@ -56,11 +56,6 @@ export class RoomRadialGridParameter extends RoomGridParameter { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["dir_count"] = this.dir_count; data["start_vector"] = this.start_vector; data["mesh_radius"] = this.mesh_radius; @@ -78,3 +73,4 @@ export class RoomRadialGridParameter extends RoomGridParameter { return true; } } + diff --git a/src/TypeScriptSDK/models/SimpleWindowArea.ts b/src/TypeScriptSDK/models/SimpleWindowArea.ts index 8485717..952aec9 100644 --- a/src/TypeScriptSDK/models/SimpleWindowArea.ts +++ b/src/TypeScriptSDK/models/SimpleWindowArea.ts @@ -48,11 +48,6 @@ export class SimpleWindowArea extends _WindowParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["window_area"] = this.window_area; data["type"] = this.type; data["rect_split"] = this.rect_split; @@ -69,3 +64,4 @@ export class SimpleWindowArea extends _WindowParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/SimpleWindowRatio.ts b/src/TypeScriptSDK/models/SimpleWindowRatio.ts index ca4b310..11d5a47 100644 --- a/src/TypeScriptSDK/models/SimpleWindowRatio.ts +++ b/src/TypeScriptSDK/models/SimpleWindowRatio.ts @@ -48,11 +48,6 @@ export class SimpleWindowRatio extends _WindowParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["window_ratio"] = this.window_ratio; data["type"] = this.type; data["rect_split"] = this.rect_split; @@ -69,3 +64,4 @@ export class SimpleWindowRatio extends _WindowParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/SingleWindow.ts b/src/TypeScriptSDK/models/SingleWindow.ts index 74f722d..78a5b9e 100644 --- a/src/TypeScriptSDK/models/SingleWindow.ts +++ b/src/TypeScriptSDK/models/SingleWindow.ts @@ -54,11 +54,6 @@ export class SingleWindow extends _WindowParameterBase { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["width"] = this.width; data["height"] = this.height; data["type"] = this.type; @@ -76,3 +71,4 @@ export class SingleWindow extends _WindowParameterBase { return true; } } + diff --git a/src/TypeScriptSDK/models/Story.ts b/src/TypeScriptSDK/models/Story.ts index 87347e2..aedb0fa 100644 --- a/src/TypeScriptSDK/models/Story.ts +++ b/src/TypeScriptSDK/models/Story.ts @@ -84,11 +84,6 @@ export class Story extends IDdBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["room_2ds"] = this.room_2ds; data["properties"] = this.properties; data["type"] = this.type; @@ -109,3 +104,4 @@ export class Story extends IDdBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts index 5fef685..2bc0e88 100644 --- a/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts @@ -43,11 +43,6 @@ export class StoryEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["construction_set"] = this.construction_set; data = super.toJSON(data); @@ -63,3 +58,4 @@ export class StoryEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts index 414c9e7..1b3f914 100644 --- a/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts @@ -50,11 +50,6 @@ export class StoryPropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["energy"] = this.energy; data["radiance"] = this.radiance; @@ -71,3 +66,4 @@ export class StoryPropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts index f12922a..d308a26 100644 --- a/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts @@ -41,11 +41,6 @@ export class StoryRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; data["modifier_set"] = this.modifier_set; data = super.toJSON(data); @@ -61,3 +56,4 @@ export class StoryRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/_GridParameterBase.ts b/src/TypeScriptSDK/models/_GridParameterBase.ts index bc7ff89..9a88f6b 100644 --- a/src/TypeScriptSDK/models/_GridParameterBase.ts +++ b/src/TypeScriptSDK/models/_GridParameterBase.ts @@ -48,11 +48,6 @@ export class _GridParameterBase extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["dimension"] = this.dimension; data["include_mesh"] = this.include_mesh; data["type"] = this.type; @@ -69,3 +64,4 @@ export class _GridParameterBase extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/_LouversBase.ts b/src/TypeScriptSDK/models/_LouversBase.ts index 653684e..adc89db 100644 --- a/src/TypeScriptSDK/models/_LouversBase.ts +++ b/src/TypeScriptSDK/models/_LouversBase.ts @@ -73,11 +73,6 @@ export class _LouversBase extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["depth"] = this.depth; data["offset"] = this.offset; data["angle"] = this.angle; @@ -97,3 +92,4 @@ export class _LouversBase extends _OpenAPIGenBaseModel { return true; } } + diff --git a/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts b/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts index 7d23244..9a67b19 100644 --- a/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts +++ b/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts @@ -25,14 +25,22 @@ export abstract class _OpenAPIGenBaseModel { toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["type"] = this.type; - return Object.fromEntries( - Object.entries(data).filter(([_, v]) => v !== undefined)); + return removeUndefinedProperties(data); } } + +function removeUndefinedProperties(obj: any): any { + if (Array.isArray(obj)) { + return obj.map(removeUndefinedProperties); + } else if (obj !== null && typeof obj === 'object') { + return Object.entries(obj) + .filter(([_, value]) => value !== undefined) + .reduce((acc, [key, value]) => { + acc[key] = removeUndefinedProperties(value); + return acc; + }, {} as any); + } + return obj; +} diff --git a/src/TypeScriptSDK/models/_WindowParameterBase.ts b/src/TypeScriptSDK/models/_WindowParameterBase.ts index 27b4929..08050ee 100644 --- a/src/TypeScriptSDK/models/_WindowParameterBase.ts +++ b/src/TypeScriptSDK/models/_WindowParameterBase.ts @@ -40,11 +40,6 @@ export class _WindowParameterBase extends _OpenAPIGenBaseModel { override toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - for (var property in this) { - if (this.hasOwnProperty(property)) - data[property] = this[property]; - } - data["user_data"] = this.user_data; data["type"] = this.type; data = super.toJSON(data); @@ -60,3 +55,4 @@ export class _WindowParameterBase extends _OpenAPIGenBaseModel { return true; } } + From 445535c055d7f78c8eec0af4fc46fb2189ec9cf0 Mon Sep 17 00:00:00 2001 From: Mingbo Peng Date: Mon, 23 Sep 2024 19:44:39 +0800 Subject: [PATCH 3/6] test(Model): add more test for model --- src/TypeScriptSDK/tests/Model.test.ts | 63 ++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/src/TypeScriptSDK/tests/Model.test.ts b/src/TypeScriptSDK/tests/Model.test.ts index 7c3da95..b535faf 100644 --- a/src/TypeScriptSDK/tests/Model.test.ts +++ b/src/TypeScriptSDK/tests/Model.test.ts @@ -1,6 +1,6 @@ import { plainToClass } from "class-transformer"; import { Model } from "../models"; -import { Face3D, GlobalModifierSet, WallModifierSetAbridged } from "honeybee-schema"; +import { Face3D, GlobalModifierSet, ModelProperties, WallModifierSetAbridged } from "honeybee-schema"; import * as fs from 'fs'; import * as path from 'path'; @@ -18,7 +18,8 @@ test('test model', () => { expect(model.identifier).toBe("unnamed_cb67f62e"); expect(model.validate()).resolves.toBe(true); -}); +} +); test('test wallSet', () => { const data = { @@ -34,10 +35,10 @@ test('test wallSet', () => { expect(jsonObj).toHaveProperty("interior_modifier"); expect(jsonObj.hasOwnProperty("ground_construction")).toBe(false); -}); +} +); -test('test wallSet', () => { - const data = { +const GlobalModifierSetData = { "shade_set": { "type": "ShadeModifierSetAbridged", "interior_modifier": "generic_interior_shade_0.50", @@ -189,12 +190,50 @@ test('test wallSet', () => { }, "air_boundary_modifier": "air_boundary" }; - const obj = GlobalModifierSet.fromJS(data); - expect(obj.validate()).resolves.toBe(true); - const jsonObj = obj.toJSON(); - expect(jsonObj.type).toBe("WallModifierSetAbridged"); - expect(jsonObj).toHaveProperty("interior_modifier"); - expect(jsonObj.hasOwnProperty("ground_construction")).toBe(false); +test('test GlobalModifierSet', () => { + const data = GlobalModifierSetData; + const obj = GlobalModifierSet.fromJS(data); + expect(obj.validate()).resolves.toBe(true); + + const jsonObj = obj.toJSON(); + expect(jsonObj.type).toBe("GlobalModifierSet"); + expect(jsonObj).toHaveProperty("wall_set"); + expect(jsonObj.wall_set).toHaveProperty("interior_modifier"); + expect(jsonObj.wall_set.hasOwnProperty("ground_construction")).toBe(false); + +} +); + +test('test ModelProperties', () => { + const data = { + "radiance": + { + "global_modifier_set":GlobalModifierSetData + } + } + const obj = ModelProperties.fromJS(data); + // expect(obj.validate()).resolves.toBe(true); + expect(obj.radiance?.global_modifier_set?.wall_set).toBeInstanceOf(WallModifierSetAbridged); + + } +); + +test('test Model2', () => { + const data = { + "properties": + { + "radiance": + { + "global_modifier_set":GlobalModifierSetData + } + } + } -}); \ No newline at end of file + // const model = plainToClass(Model, data, { enableImplicitConversion: true }); + const obj = Model.fromJS(data); + expect(obj.properties.radiance?.global_modifier_set?.wall_set).toBeInstanceOf(WallModifierSetAbridged); + // expect(obj.validate()).resolves.toBe(true); + + } +); \ No newline at end of file From 9992d4da0f37bcd3cb351b7ae182017113ee4cd1 Mon Sep 17 00:00:00 2001 From: Mingbo Peng Date: Mon, 23 Sep 2024 19:45:27 +0800 Subject: [PATCH 4/6] fix(Ts): add enableImplicitConversion in plainToClass --- .generator | 2 +- src/TypeScriptSDK/models/Building.ts | 2 +- .../models/BuildingEnergyPropertiesAbridged.ts | 2 +- src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts | 2 +- .../models/BuildingRadiancePropertiesAbridged.ts | 2 +- src/TypeScriptSDK/models/ContextShade.ts | 2 +- .../models/ContextShadeEnergyPropertiesAbridged.ts | 2 +- .../models/ContextShadePropertiesAbridged.ts | 2 +- .../models/ContextShadeRadiancePropertiesAbridged.ts | 2 +- src/TypeScriptSDK/models/DetailedSkylights.ts | 2 +- src/TypeScriptSDK/models/DetailedWindows.ts | 2 +- src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts | 2 +- src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts | 2 +- src/TypeScriptSDK/models/ExtrudedBorder.ts | 2 +- src/TypeScriptSDK/models/GriddedSkylightArea.ts | 2 +- src/TypeScriptSDK/models/GriddedSkylightRatio.ts | 2 +- src/TypeScriptSDK/models/LouversByCount.ts | 2 +- src/TypeScriptSDK/models/LouversByDistance.ts | 2 +- src/TypeScriptSDK/models/Model.ts | 2 +- src/TypeScriptSDK/models/ModelEnergyProperties.ts | 2 +- src/TypeScriptSDK/models/ModelProperties.ts | 2 +- src/TypeScriptSDK/models/ModelRadianceProperties.ts | 2 +- src/TypeScriptSDK/models/Overhang.ts | 2 +- src/TypeScriptSDK/models/RectangularWindows.ts | 2 +- src/TypeScriptSDK/models/RepeatingWindowRatio.ts | 2 +- src/TypeScriptSDK/models/RoofSpecification.ts | 2 +- src/TypeScriptSDK/models/Room2D.ts | 2 +- .../models/Room2DEnergyPropertiesAbridged.ts | 2 +- src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts | 2 +- .../models/Room2DRadiancePropertiesAbridged.ts | 2 +- src/TypeScriptSDK/models/RoomGridParameter.ts | 2 +- src/TypeScriptSDK/models/RoomRadialGridParameter.ts | 2 +- src/TypeScriptSDK/models/SimpleWindowArea.ts | 2 +- src/TypeScriptSDK/models/SimpleWindowRatio.ts | 2 +- src/TypeScriptSDK/models/SingleWindow.ts | 2 +- src/TypeScriptSDK/models/Story.ts | 2 +- src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts | 2 +- src/TypeScriptSDK/models/StoryPropertiesAbridged.ts | 2 +- .../models/StoryRadiancePropertiesAbridged.ts | 2 +- src/TypeScriptSDK/models/_GridParameterBase.ts | 2 +- src/TypeScriptSDK/models/_LouversBase.ts | 2 +- src/TypeScriptSDK/models/_WindowParameterBase.ts | 2 +- src/TypeScriptSDK/models/index.ts | 8 ++++---- 43 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.generator b/.generator index 7f39558..ab3fa79 160000 --- a/.generator +++ b/.generator @@ -1 +1 @@ -Subproject commit 7f395585e4ec7ea9633627f575edf48a10869ec6 +Subproject commit ab3fa795827d6f6c01987a2d0c23c4d095641816 diff --git a/src/TypeScriptSDK/models/Building.ts b/src/TypeScriptSDK/models/Building.ts index 0abe935..4bc88ca 100644 --- a/src/TypeScriptSDK/models/Building.ts +++ b/src/TypeScriptSDK/models/Building.ts @@ -53,7 +53,7 @@ export class Building extends IDdBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Building, _data); + const obj = plainToClass(Building, _data, { enableImplicitConversion: true }); this.properties = obj.properties; this.type = obj.type; this.unique_stories = obj.unique_stories; diff --git a/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts index bd65fff..889a3a3 100644 --- a/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts @@ -26,7 +26,7 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(BuildingEnergyPropertiesAbridged, _data); + const obj = plainToClass(BuildingEnergyPropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.construction_set = obj.construction_set; } diff --git a/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts index c0983ef..c1986b0 100644 --- a/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts @@ -32,7 +32,7 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(BuildingPropertiesAbridged, _data); + const obj = plainToClass(BuildingPropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.energy = obj.energy; this.radiance = obj.radiance; diff --git a/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts index b469476..1d45fdc 100644 --- a/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts @@ -24,7 +24,7 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(BuildingRadiancePropertiesAbridged, _data); + const obj = plainToClass(BuildingRadiancePropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.modifier_set = obj.modifier_set; } diff --git a/src/TypeScriptSDK/models/ContextShade.ts b/src/TypeScriptSDK/models/ContextShade.ts index fe6f8f1..3a4472f 100644 --- a/src/TypeScriptSDK/models/ContextShade.ts +++ b/src/TypeScriptSDK/models/ContextShade.ts @@ -40,7 +40,7 @@ export class ContextShade extends IDdBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ContextShade, _data); + const obj = plainToClass(ContextShade, _data, { enableImplicitConversion: true }); this.geometry = obj.geometry; this.properties = obj.properties; this.type = obj.type; diff --git a/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts index 0488308..fcd3f13 100644 --- a/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts @@ -33,7 +33,7 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ContextShadeEnergyPropertiesAbridged, _data); + const obj = plainToClass(ContextShadeEnergyPropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.construction = obj.construction; this.transmittance_schedule = obj.transmittance_schedule; diff --git a/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts index c615d69..233c509 100644 --- a/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts @@ -32,7 +32,7 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ContextShadePropertiesAbridged, _data); + const obj = plainToClass(ContextShadePropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.energy = obj.energy; this.radiance = obj.radiance; diff --git a/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts index fde3d86..a490663 100644 --- a/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts @@ -24,7 +24,7 @@ export class ContextShadeRadiancePropertiesAbridged extends _OpenAPIGenBaseModel override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ContextShadeRadiancePropertiesAbridged, _data); + const obj = plainToClass(ContextShadeRadiancePropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.modifier = obj.modifier; } diff --git a/src/TypeScriptSDK/models/DetailedSkylights.ts b/src/TypeScriptSDK/models/DetailedSkylights.ts index 29bbdda..a04f6cc 100644 --- a/src/TypeScriptSDK/models/DetailedSkylights.ts +++ b/src/TypeScriptSDK/models/DetailedSkylights.ts @@ -32,7 +32,7 @@ export class DetailedSkylights extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(DetailedSkylights, _data); + const obj = plainToClass(DetailedSkylights, _data, { enableImplicitConversion: true }); this.polygons = obj.polygons; this.type = obj.type; this.are_doors = obj.are_doors; diff --git a/src/TypeScriptSDK/models/DetailedWindows.ts b/src/TypeScriptSDK/models/DetailedWindows.ts index 00cd615..fc3fa6a 100644 --- a/src/TypeScriptSDK/models/DetailedWindows.ts +++ b/src/TypeScriptSDK/models/DetailedWindows.ts @@ -32,7 +32,7 @@ export class DetailedWindows extends _WindowParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(DetailedWindows, _data); + const obj = plainToClass(DetailedWindows, _data, { enableImplicitConversion: true }); this.polygons = obj.polygons; this.type = obj.type; this.are_doors = obj.are_doors; diff --git a/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts b/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts index d3006f4..a19eaeb 100644 --- a/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts +++ b/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts @@ -33,7 +33,7 @@ export class ExteriorApertureGridParameter extends _GridParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ExteriorApertureGridParameter, _data); + const obj = plainToClass(ExteriorApertureGridParameter, _data, { enableImplicitConversion: true }); this.type = obj.type; this.offset = obj.offset; this.aperture_type = obj.aperture_type; diff --git a/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts b/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts index a73f470..3f9b3ce 100644 --- a/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts +++ b/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts @@ -39,7 +39,7 @@ export class ExteriorFaceGridParameter extends _GridParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ExteriorFaceGridParameter, _data); + const obj = plainToClass(ExteriorFaceGridParameter, _data, { enableImplicitConversion: true }); this.type = obj.type; this.offset = obj.offset; this.face_type = obj.face_type; diff --git a/src/TypeScriptSDK/models/ExtrudedBorder.ts b/src/TypeScriptSDK/models/ExtrudedBorder.ts index f29b51c..b341a23 100644 --- a/src/TypeScriptSDK/models/ExtrudedBorder.ts +++ b/src/TypeScriptSDK/models/ExtrudedBorder.ts @@ -24,7 +24,7 @@ export class ExtrudedBorder extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ExtrudedBorder, _data); + const obj = plainToClass(ExtrudedBorder, _data, { enableImplicitConversion: true }); this.depth = obj.depth; this.type = obj.type; } diff --git a/src/TypeScriptSDK/models/GriddedSkylightArea.ts b/src/TypeScriptSDK/models/GriddedSkylightArea.ts index 222c9ff..71772ad 100644 --- a/src/TypeScriptSDK/models/GriddedSkylightArea.ts +++ b/src/TypeScriptSDK/models/GriddedSkylightArea.ts @@ -30,7 +30,7 @@ export class GriddedSkylightArea extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(GriddedSkylightArea, _data); + const obj = plainToClass(GriddedSkylightArea, _data, { enableImplicitConversion: true }); this.skylight_area = obj.skylight_area; this.type = obj.type; this.spacing = obj.spacing; diff --git a/src/TypeScriptSDK/models/GriddedSkylightRatio.ts b/src/TypeScriptSDK/models/GriddedSkylightRatio.ts index bbf1219..5c63881 100644 --- a/src/TypeScriptSDK/models/GriddedSkylightRatio.ts +++ b/src/TypeScriptSDK/models/GriddedSkylightRatio.ts @@ -30,7 +30,7 @@ export class GriddedSkylightRatio extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(GriddedSkylightRatio, _data); + const obj = plainToClass(GriddedSkylightRatio, _data, { enableImplicitConversion: true }); this.skylight_ratio = obj.skylight_ratio; this.type = obj.type; this.spacing = obj.spacing; diff --git a/src/TypeScriptSDK/models/LouversByCount.ts b/src/TypeScriptSDK/models/LouversByCount.ts index f5338a6..beea779 100644 --- a/src/TypeScriptSDK/models/LouversByCount.ts +++ b/src/TypeScriptSDK/models/LouversByCount.ts @@ -24,7 +24,7 @@ export class LouversByCount extends _LouversBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(LouversByCount, _data); + const obj = plainToClass(LouversByCount, _data, { enableImplicitConversion: true }); this.louver_count = obj.louver_count; this.type = obj.type; } diff --git a/src/TypeScriptSDK/models/LouversByDistance.ts b/src/TypeScriptSDK/models/LouversByDistance.ts index d5225b0..31e1de3 100644 --- a/src/TypeScriptSDK/models/LouversByDistance.ts +++ b/src/TypeScriptSDK/models/LouversByDistance.ts @@ -24,7 +24,7 @@ export class LouversByDistance extends _LouversBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(LouversByDistance, _data); + const obj = plainToClass(LouversByDistance, _data, { enableImplicitConversion: true }); this.distance = obj.distance; this.type = obj.type; } diff --git a/src/TypeScriptSDK/models/Model.ts b/src/TypeScriptSDK/models/Model.ts index a2b7e7a..7bc046f 100644 --- a/src/TypeScriptSDK/models/Model.ts +++ b/src/TypeScriptSDK/models/Model.ts @@ -74,7 +74,7 @@ export class Model extends IDdBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Model, _data); + const obj = plainToClass(Model, _data, { enableImplicitConversion: true }); this.properties = obj.properties; this.type = obj.type; this.version = obj.version; diff --git a/src/TypeScriptSDK/models/ModelEnergyProperties.ts b/src/TypeScriptSDK/models/ModelEnergyProperties.ts index 08bf3fd..be8ada5 100644 --- a/src/TypeScriptSDK/models/ModelEnergyProperties.ts +++ b/src/TypeScriptSDK/models/ModelEnergyProperties.ts @@ -551,7 +551,7 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ModelEnergyProperties, _data); + const obj = plainToClass(ModelEnergyProperties, _data, { enableImplicitConversion: true }); this.type = obj.type; this.global_construction_set = obj.global_construction_set; this.construction_sets = obj.construction_sets; diff --git a/src/TypeScriptSDK/models/ModelProperties.ts b/src/TypeScriptSDK/models/ModelProperties.ts index dbad654..95ff841 100644 --- a/src/TypeScriptSDK/models/ModelProperties.ts +++ b/src/TypeScriptSDK/models/ModelProperties.ts @@ -32,7 +32,7 @@ export class ModelProperties extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ModelProperties, _data); + const obj = plainToClass(ModelProperties, _data, { enableImplicitConversion: true }); this.type = obj.type; this.energy = obj.energy; this.radiance = obj.radiance; diff --git a/src/TypeScriptSDK/models/ModelRadianceProperties.ts b/src/TypeScriptSDK/models/ModelRadianceProperties.ts index fc2d478..f883206 100644 --- a/src/TypeScriptSDK/models/ModelRadianceProperties.ts +++ b/src/TypeScriptSDK/models/ModelRadianceProperties.ts @@ -210,7 +210,7 @@ export class ModelRadianceProperties extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(ModelRadianceProperties, _data); + const obj = plainToClass(ModelRadianceProperties, _data, { enableImplicitConversion: true }); this.type = obj.type; this.global_modifier_set = obj.global_modifier_set; this.modifier_sets = obj.modifier_sets; diff --git a/src/TypeScriptSDK/models/Overhang.ts b/src/TypeScriptSDK/models/Overhang.ts index c6b441f..e266d38 100644 --- a/src/TypeScriptSDK/models/Overhang.ts +++ b/src/TypeScriptSDK/models/Overhang.ts @@ -32,7 +32,7 @@ export class Overhang extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Overhang, _data); + const obj = plainToClass(Overhang, _data, { enableImplicitConversion: true }); this.depth = obj.depth; this.type = obj.type; this.angle = obj.angle; diff --git a/src/TypeScriptSDK/models/RectangularWindows.ts b/src/TypeScriptSDK/models/RectangularWindows.ts index 9cba631..a06b2cc 100644 --- a/src/TypeScriptSDK/models/RectangularWindows.ts +++ b/src/TypeScriptSDK/models/RectangularWindows.ts @@ -44,7 +44,7 @@ export class RectangularWindows extends _WindowParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(RectangularWindows, _data); + const obj = plainToClass(RectangularWindows, _data, { enableImplicitConversion: true }); this.origins = obj.origins; this.widths = obj.widths; this.heights = obj.heights; diff --git a/src/TypeScriptSDK/models/RepeatingWindowRatio.ts b/src/TypeScriptSDK/models/RepeatingWindowRatio.ts index ddc8853..34f6c0b 100644 --- a/src/TypeScriptSDK/models/RepeatingWindowRatio.ts +++ b/src/TypeScriptSDK/models/RepeatingWindowRatio.ts @@ -47,7 +47,7 @@ export class RepeatingWindowRatio extends _WindowParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(RepeatingWindowRatio, _data); + const obj = plainToClass(RepeatingWindowRatio, _data, { enableImplicitConversion: true }); this.window_ratio = obj.window_ratio; this.window_height = obj.window_height; this.sill_height = obj.sill_height; diff --git a/src/TypeScriptSDK/models/RoofSpecification.ts b/src/TypeScriptSDK/models/RoofSpecification.ts index 681bbcc..9b65189 100644 --- a/src/TypeScriptSDK/models/RoofSpecification.ts +++ b/src/TypeScriptSDK/models/RoofSpecification.ts @@ -28,7 +28,7 @@ export class RoofSpecification extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(RoofSpecification, _data); + const obj = plainToClass(RoofSpecification, _data, { enableImplicitConversion: true }); this.geometry = obj.geometry; this.type = obj.type; } diff --git a/src/TypeScriptSDK/models/Room2D.ts b/src/TypeScriptSDK/models/Room2D.ts index 9cc60f3..a7dc56d 100644 --- a/src/TypeScriptSDK/models/Room2D.ts +++ b/src/TypeScriptSDK/models/Room2D.ts @@ -105,7 +105,7 @@ export class Room2D extends IDdBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Room2D, _data); + const obj = plainToClass(Room2D, _data, { enableImplicitConversion: true }); this.floor_boundary = obj.floor_boundary; this.floor_height = obj.floor_height; this.floor_to_ceiling_height = obj.floor_to_ceiling_height; diff --git a/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts index 2978952..858b0f5 100644 --- a/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts @@ -72,7 +72,7 @@ export class Room2DEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Room2DEnergyPropertiesAbridged, _data); + const obj = plainToClass(Room2DEnergyPropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.construction_set = obj.construction_set; this.program_type = obj.program_type; diff --git a/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts index c920cb1..9c4c4d1 100644 --- a/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts @@ -32,7 +32,7 @@ export class Room2DPropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Room2DPropertiesAbridged, _data); + const obj = plainToClass(Room2DPropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.energy = obj.energy; this.radiance = obj.radiance; diff --git a/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts index 655f92a..5a3e9e0 100644 --- a/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts @@ -33,7 +33,7 @@ export class Room2DRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Room2DRadiancePropertiesAbridged, _data); + const obj = plainToClass(Room2DRadiancePropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.modifier_set = obj.modifier_set; this.grid_parameters = obj.grid_parameters; diff --git a/src/TypeScriptSDK/models/RoomGridParameter.ts b/src/TypeScriptSDK/models/RoomGridParameter.ts index eb526f7..62c811f 100644 --- a/src/TypeScriptSDK/models/RoomGridParameter.ts +++ b/src/TypeScriptSDK/models/RoomGridParameter.ts @@ -31,7 +31,7 @@ export class RoomGridParameter extends _GridParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(RoomGridParameter, _data); + const obj = plainToClass(RoomGridParameter, _data, { enableImplicitConversion: true }); this.type = obj.type; this.offset = obj.offset; this.wall_offset = obj.wall_offset; diff --git a/src/TypeScriptSDK/models/RoomRadialGridParameter.ts b/src/TypeScriptSDK/models/RoomRadialGridParameter.ts index a3c92f4..0636e96 100644 --- a/src/TypeScriptSDK/models/RoomRadialGridParameter.ts +++ b/src/TypeScriptSDK/models/RoomRadialGridParameter.ts @@ -37,7 +37,7 @@ export class RoomRadialGridParameter extends RoomGridParameter { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(RoomRadialGridParameter, _data); + const obj = plainToClass(RoomRadialGridParameter, _data, { enableImplicitConversion: true }); this.dir_count = obj.dir_count; this.start_vector = obj.start_vector; this.mesh_radius = obj.mesh_radius; diff --git a/src/TypeScriptSDK/models/SimpleWindowArea.ts b/src/TypeScriptSDK/models/SimpleWindowArea.ts index 952aec9..86d42c2 100644 --- a/src/TypeScriptSDK/models/SimpleWindowArea.ts +++ b/src/TypeScriptSDK/models/SimpleWindowArea.ts @@ -30,7 +30,7 @@ export class SimpleWindowArea extends _WindowParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(SimpleWindowArea, _data); + const obj = plainToClass(SimpleWindowArea, _data, { enableImplicitConversion: true }); this.window_area = obj.window_area; this.type = obj.type; this.rect_split = obj.rect_split; diff --git a/src/TypeScriptSDK/models/SimpleWindowRatio.ts b/src/TypeScriptSDK/models/SimpleWindowRatio.ts index 11d5a47..e333f36 100644 --- a/src/TypeScriptSDK/models/SimpleWindowRatio.ts +++ b/src/TypeScriptSDK/models/SimpleWindowRatio.ts @@ -30,7 +30,7 @@ export class SimpleWindowRatio extends _WindowParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(SimpleWindowRatio, _data); + const obj = plainToClass(SimpleWindowRatio, _data, { enableImplicitConversion: true }); this.window_ratio = obj.window_ratio; this.type = obj.type; this.rect_split = obj.rect_split; diff --git a/src/TypeScriptSDK/models/SingleWindow.ts b/src/TypeScriptSDK/models/SingleWindow.ts index 78a5b9e..132abb7 100644 --- a/src/TypeScriptSDK/models/SingleWindow.ts +++ b/src/TypeScriptSDK/models/SingleWindow.ts @@ -35,7 +35,7 @@ export class SingleWindow extends _WindowParameterBase { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(SingleWindow, _data); + const obj = plainToClass(SingleWindow, _data, { enableImplicitConversion: true }); this.width = obj.width; this.height = obj.height; this.type = obj.type; diff --git a/src/TypeScriptSDK/models/Story.ts b/src/TypeScriptSDK/models/Story.ts index aedb0fa..d21dec7 100644 --- a/src/TypeScriptSDK/models/Story.ts +++ b/src/TypeScriptSDK/models/Story.ts @@ -62,7 +62,7 @@ export class Story extends IDdBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(Story, _data); + const obj = plainToClass(Story, _data, { enableImplicitConversion: true }); this.room_2ds = obj.room_2ds; this.properties = obj.properties; this.type = obj.type; diff --git a/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts index 2bc0e88..505f2ec 100644 --- a/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts @@ -26,7 +26,7 @@ export class StoryEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(StoryEnergyPropertiesAbridged, _data); + const obj = plainToClass(StoryEnergyPropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.construction_set = obj.construction_set; } diff --git a/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts index 1b3f914..3b5734c 100644 --- a/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts @@ -32,7 +32,7 @@ export class StoryPropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(StoryPropertiesAbridged, _data); + const obj = plainToClass(StoryPropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.energy = obj.energy; this.radiance = obj.radiance; diff --git a/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts index d308a26..bdf87b0 100644 --- a/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts @@ -24,7 +24,7 @@ export class StoryRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(StoryRadiancePropertiesAbridged, _data); + const obj = plainToClass(StoryRadiancePropertiesAbridged, _data, { enableImplicitConversion: true }); this.type = obj.type; this.modifier_set = obj.modifier_set; } diff --git a/src/TypeScriptSDK/models/_GridParameterBase.ts b/src/TypeScriptSDK/models/_GridParameterBase.ts index 9a88f6b..aac3634 100644 --- a/src/TypeScriptSDK/models/_GridParameterBase.ts +++ b/src/TypeScriptSDK/models/_GridParameterBase.ts @@ -30,7 +30,7 @@ export class _GridParameterBase extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(_GridParameterBase, _data); + const obj = plainToClass(_GridParameterBase, _data, { enableImplicitConversion: true }); this.dimension = obj.dimension; this.include_mesh = obj.include_mesh; this.type = obj.type; diff --git a/src/TypeScriptSDK/models/_LouversBase.ts b/src/TypeScriptSDK/models/_LouversBase.ts index adc89db..a1869c4 100644 --- a/src/TypeScriptSDK/models/_LouversBase.ts +++ b/src/TypeScriptSDK/models/_LouversBase.ts @@ -52,7 +52,7 @@ export class _LouversBase extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(_LouversBase, _data); + const obj = plainToClass(_LouversBase, _data, { enableImplicitConversion: true }); this.depth = obj.depth; this.offset = obj.offset; this.angle = obj.angle; diff --git a/src/TypeScriptSDK/models/_WindowParameterBase.ts b/src/TypeScriptSDK/models/_WindowParameterBase.ts index 08050ee..d2133dd 100644 --- a/src/TypeScriptSDK/models/_WindowParameterBase.ts +++ b/src/TypeScriptSDK/models/_WindowParameterBase.ts @@ -23,7 +23,7 @@ export class _WindowParameterBase extends _OpenAPIGenBaseModel { override init(_data?: any) { super.init(_data); if (_data) { - const obj = plainToClass(_WindowParameterBase, _data); + const obj = plainToClass(_WindowParameterBase, _data, { enableImplicitConversion: true }); this.user_data = obj.user_data; this.type = obj.type; } diff --git a/src/TypeScriptSDK/models/index.ts b/src/TypeScriptSDK/models/index.ts index 1efda84..c2fb398 100644 --- a/src/TypeScriptSDK/models/index.ts +++ b/src/TypeScriptSDK/models/index.ts @@ -1,5 +1,9 @@ // Auto-generated +export * from "./_GridParameterBase"; +export * from "./_LouversBase"; +export * from "./_OpenAPIGenBaseModel"; +export * from "./_WindowParameterBase"; export * from "./Building"; export * from "./BuildingEnergyPropertiesAbridged"; export * from "./BuildingPropertiesAbridged"; @@ -40,7 +44,3 @@ export * from "./Story"; export * from "./StoryEnergyPropertiesAbridged"; export * from "./StoryPropertiesAbridged"; export * from "./StoryRadiancePropertiesAbridged"; -export * from "./_GridParameterBase"; -export * from "./_LouversBase"; -export * from "./_OpenAPIGenBaseModel"; -export * from "./_WindowParameterBase"; From 9c35cd1e0d4b4d37c93c15cbd955f9a98a52c7a3 Mon Sep 17 00:00:00 2001 From: Mingbo Peng Date: Tue, 24 Sep 2024 17:09:20 +0800 Subject: [PATCH 5/6] fix(Ts): regenerate with @Transform --- .generator | 2 +- src/TypeScriptSDK/models/Building.ts | 9 ++- .../BuildingEnergyPropertiesAbridged.ts | 9 ++- .../models/BuildingPropertiesAbridged.ts | 9 ++- .../BuildingRadiancePropertiesAbridged.ts | 9 ++- src/TypeScriptSDK/models/ContextShade.ts | 14 +++- .../ContextShadeEnergyPropertiesAbridged.ts | 9 ++- .../models/ContextShadePropertiesAbridged.ts | 9 ++- .../ContextShadeRadiancePropertiesAbridged.ts | 9 ++- src/TypeScriptSDK/models/DetailedSkylights.ts | 9 ++- src/TypeScriptSDK/models/DetailedWindows.ts | 9 ++- .../models/ExteriorApertureGridParameter.ts | 9 ++- .../models/ExteriorFaceGridParameter.ts | 9 ++- src/TypeScriptSDK/models/ExtrudedBorder.ts | 9 ++- .../models/GriddedSkylightArea.ts | 9 ++- .../models/GriddedSkylightRatio.ts | 9 ++- src/TypeScriptSDK/models/LouversByCount.ts | 9 ++- src/TypeScriptSDK/models/LouversByDistance.ts | 9 ++- src/TypeScriptSDK/models/Model.ts | 9 ++- .../models/ModelEnergyProperties.ts | 73 ++++++++++++++++++- src/TypeScriptSDK/models/ModelProperties.ts | 9 ++- .../models/ModelRadianceProperties.ts | 26 ++++++- src/TypeScriptSDK/models/Overhang.ts | 9 ++- .../models/RectangularWindows.ts | 9 ++- .../models/RepeatingWindowRatio.ts | 9 ++- src/TypeScriptSDK/models/RoofSpecification.ts | 9 ++- src/TypeScriptSDK/models/Room2D.ts | 40 +++++++++- .../models/Room2DEnergyPropertiesAbridged.ts | 9 ++- .../models/Room2DPropertiesAbridged.ts | 9 ++- .../Room2DRadiancePropertiesAbridged.ts | 16 +++- src/TypeScriptSDK/models/RoomGridParameter.ts | 9 ++- .../models/RoomRadialGridParameter.ts | 9 ++- src/TypeScriptSDK/models/SimpleWindowArea.ts | 9 ++- src/TypeScriptSDK/models/SimpleWindowRatio.ts | 9 ++- src/TypeScriptSDK/models/SingleWindow.ts | 9 ++- src/TypeScriptSDK/models/Story.ts | 9 ++- .../models/StoryEnergyPropertiesAbridged.ts | 9 ++- .../models/StoryPropertiesAbridged.ts | 9 ++- .../models/StoryRadiancePropertiesAbridged.ts | 9 ++- .../models/_GridParameterBase.ts | 9 ++- src/TypeScriptSDK/models/_LouversBase.ts | 9 ++- .../models/_OpenAPIGenBaseModel.ts | 2 +- .../models/_WindowParameterBase.ts | 9 ++- src/TypeScriptSDK/tests/Model.test.ts | 7 +- 44 files changed, 459 insertions(+), 45 deletions(-) diff --git a/.generator b/.generator index ab3fa79..c9f3727 160000 --- a/.generator +++ b/.generator @@ -1 +1 @@ -Subproject commit ab3fa795827d6f6c01987a2d0c23c4d095641816 +Subproject commit c9f3727e1831d34350be47243a3da82f0e1a998e diff --git a/src/TypeScriptSDK/models/Building.ts b/src/TypeScriptSDK/models/Building.ts index 4bc88ca..d3f0317 100644 --- a/src/TypeScriptSDK/models/Building.ts +++ b/src/TypeScriptSDK/models/Building.ts @@ -1,5 +1,5 @@ import { IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsArray, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { BuildingPropertiesAbridged } from "./BuildingPropertiesAbridged"; import { IDdBaseModel } from "honeybee-schema"; import { RoofSpecification } from "./RoofSpecification"; @@ -66,6 +66,13 @@ export class Building extends IDdBaseModel { static override fromJS(data: any): Building { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Building(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts index 889a3a3..288ad67 100644 --- a/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */ @@ -36,6 +36,13 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): BuildingEnergyPropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new BuildingEnergyPropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts index c1986b0..8c8e3d9 100644 --- a/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { BuildingEnergyPropertiesAbridged } from "./BuildingEnergyPropertiesAbridged"; import { BuildingRadiancePropertiesAbridged } from "./BuildingRadiancePropertiesAbridged"; @@ -43,6 +43,13 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): BuildingPropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new BuildingPropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts index 1d45fdc..d401a43 100644 --- a/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */ @@ -34,6 +34,13 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): BuildingRadiancePropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new BuildingRadiancePropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ContextShade.ts b/src/TypeScriptSDK/models/ContextShade.ts index 3a4472f..fd6fdda 100644 --- a/src/TypeScriptSDK/models/ContextShade.ts +++ b/src/TypeScriptSDK/models/ContextShade.ts @@ -1,5 +1,5 @@ import { IsArray, IsDefined, IsInstance, ValidateNested, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { ContextShadePropertiesAbridged } from "./ContextShadePropertiesAbridged"; import { Face3D } from "honeybee-schema"; import { IDdBaseModel } from "honeybee-schema"; @@ -9,6 +9,11 @@ import { Mesh3D } from "honeybee-schema"; export class ContextShade extends IDdBaseModel { @IsArray() @IsDefined() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'Face3D') return Face3D.fromJS(item); + else if (item?.type === 'Mesh3D') return Mesh3D.fromJS(item); + else return item; + })) /** An array of planar Face3Ds and or Mesh3Ds that together represent the context shade. */ geometry!: (Face3D | Mesh3D) []; @@ -52,6 +57,13 @@ export class ContextShade extends IDdBaseModel { static override fromJS(data: any): ContextShade { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ContextShade(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts index fcd3f13..f0d415c 100644 --- a/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */ @@ -44,6 +44,13 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): ContextShadeEnergyPropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ContextShadeEnergyPropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts index 233c509..c895ed7 100644 --- a/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { ContextShadeEnergyPropertiesAbridged } from "./ContextShadeEnergyPropertiesAbridged"; import { ContextShadeRadiancePropertiesAbridged } from "./ContextShadeRadiancePropertiesAbridged"; @@ -43,6 +43,13 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): ContextShadePropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ContextShadePropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts index a490663..eb13879 100644 --- a/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/ContextShadeRadiancePropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */ @@ -34,6 +34,13 @@ export class ContextShadeRadiancePropertiesAbridged extends _OpenAPIGenBaseModel static override fromJS(data: any): ContextShadeRadiancePropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ContextShadeRadiancePropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/DetailedSkylights.ts b/src/TypeScriptSDK/models/DetailedSkylights.ts index a04f6cc..2bbc0f3 100644 --- a/src/TypeScriptSDK/models/DetailedSkylights.ts +++ b/src/TypeScriptSDK/models/DetailedSkylights.ts @@ -1,5 +1,5 @@ import { IsArray, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { IsNestedNumberArray } from "./../helpers/class-validator"; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; @@ -43,6 +43,13 @@ export class DetailedSkylights extends _OpenAPIGenBaseModel { static override fromJS(data: any): DetailedSkylights { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new DetailedSkylights(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/DetailedWindows.ts b/src/TypeScriptSDK/models/DetailedWindows.ts index fc3fa6a..1e7551d 100644 --- a/src/TypeScriptSDK/models/DetailedWindows.ts +++ b/src/TypeScriptSDK/models/DetailedWindows.ts @@ -1,5 +1,5 @@ import { IsArray, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { IsNestedNumberArray } from "./../helpers/class-validator"; import { _WindowParameterBase } from "./_WindowParameterBase"; @@ -43,6 +43,13 @@ export class DetailedWindows extends _WindowParameterBase { static override fromJS(data: any): DetailedWindows { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new DetailedWindows(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts b/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts index a19eaeb..7081487 100644 --- a/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts +++ b/src/TypeScriptSDK/models/ExteriorApertureGridParameter.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsNumber, IsEnum, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _GridParameterBase } from "./_GridParameterBase"; import { ExteriorApertureType } from "./ExteriorApertureType"; @@ -44,6 +44,13 @@ export class ExteriorApertureGridParameter extends _GridParameterBase { static override fromJS(data: any): ExteriorApertureGridParameter { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ExteriorApertureGridParameter(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts b/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts index 3f9b3ce..22fc010 100644 --- a/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts +++ b/src/TypeScriptSDK/models/ExteriorFaceGridParameter.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsNumber, IsEnum, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _GridParameterBase } from "./_GridParameterBase"; import { ExteriorFaceType } from "./ExteriorFaceType"; @@ -51,6 +51,13 @@ export class ExteriorFaceGridParameter extends _GridParameterBase { static override fromJS(data: any): ExteriorFaceGridParameter { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ExteriorFaceGridParameter(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ExtrudedBorder.ts b/src/TypeScriptSDK/models/ExtrudedBorder.ts index b341a23..f4c1d36 100644 --- a/src/TypeScriptSDK/models/ExtrudedBorder.ts +++ b/src/TypeScriptSDK/models/ExtrudedBorder.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Extruded borders over all windows in the wall. */ @@ -34,6 +34,13 @@ export class ExtrudedBorder extends _OpenAPIGenBaseModel { static override fromJS(data: any): ExtrudedBorder { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ExtrudedBorder(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/GriddedSkylightArea.ts b/src/TypeScriptSDK/models/GriddedSkylightArea.ts index 71772ad..be81cd8 100644 --- a/src/TypeScriptSDK/models/GriddedSkylightArea.ts +++ b/src/TypeScriptSDK/models/GriddedSkylightArea.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { Autocalculate } from "honeybee-schema"; @@ -41,6 +41,13 @@ export class GriddedSkylightArea extends _OpenAPIGenBaseModel { static override fromJS(data: any): GriddedSkylightArea { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new GriddedSkylightArea(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/GriddedSkylightRatio.ts b/src/TypeScriptSDK/models/GriddedSkylightRatio.ts index 5c63881..8459087 100644 --- a/src/TypeScriptSDK/models/GriddedSkylightRatio.ts +++ b/src/TypeScriptSDK/models/GriddedSkylightRatio.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { Autocalculate } from "honeybee-schema"; @@ -41,6 +41,13 @@ export class GriddedSkylightRatio extends _OpenAPIGenBaseModel { static override fromJS(data: any): GriddedSkylightRatio { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new GriddedSkylightRatio(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/LouversByCount.ts b/src/TypeScriptSDK/models/LouversByCount.ts index beea779..59a783b 100644 --- a/src/TypeScriptSDK/models/LouversByCount.ts +++ b/src/TypeScriptSDK/models/LouversByCount.ts @@ -1,5 +1,5 @@ import { IsInt, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _LouversBase } from "./_LouversBase"; /** A specific number of louvered Shades over a wall. */ @@ -34,6 +34,13 @@ export class LouversByCount extends _LouversBase { static override fromJS(data: any): LouversByCount { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new LouversByCount(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/LouversByDistance.ts b/src/TypeScriptSDK/models/LouversByDistance.ts index 31e1de3..31fd820 100644 --- a/src/TypeScriptSDK/models/LouversByDistance.ts +++ b/src/TypeScriptSDK/models/LouversByDistance.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _LouversBase } from "./_LouversBase"; /** A series of louvered Shades at a given distance between each louver. */ @@ -34,6 +34,13 @@ export class LouversByDistance extends _LouversBase { static override fromJS(data: any): LouversByDistance { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new LouversByDistance(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/Model.ts b/src/TypeScriptSDK/models/Model.ts index 7bc046f..4e029c0 100644 --- a/src/TypeScriptSDK/models/Model.ts +++ b/src/TypeScriptSDK/models/Model.ts @@ -1,5 +1,5 @@ import { IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsArray, IsEnum, IsNumber, Min, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { Building } from "./Building"; import { ContextShade } from "./ContextShade"; import { IDdBaseModel } from "honeybee-schema"; @@ -90,6 +90,13 @@ export class Model extends IDdBaseModel { static override fromJS(data: any): Model { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Model(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ModelEnergyProperties.ts b/src/TypeScriptSDK/models/ModelEnergyProperties.ts index be8ada5..0b19959 100644 --- a/src/TypeScriptSDK/models/ModelEnergyProperties.ts +++ b/src/TypeScriptSDK/models/ModelEnergyProperties.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, IsArray, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { AirBoundaryConstruction } from "honeybee-schema"; import { AirBoundaryConstructionAbridged } from "honeybee-schema"; @@ -67,21 +67,73 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel { @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'ConstructionSetAbridged') return ConstructionSetAbridged.fromJS(item); + else if (item?.type === 'ConstructionSet') return ConstructionSet.fromJS(item); + else return item; + })) /** List of all ConstructionSets in the Model. */ construction_sets?: (ConstructionSetAbridged | ConstructionSet) []; @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'OpaqueConstructionAbridged') return OpaqueConstructionAbridged.fromJS(item); + else if (item?.type === 'WindowConstructionAbridged') return WindowConstructionAbridged.fromJS(item); + else if (item?.type === 'ShadeConstruction') return ShadeConstruction.fromJS(item); + else if (item?.type === 'AirBoundaryConstructionAbridged') return AirBoundaryConstructionAbridged.fromJS(item); + else if (item?.type === 'OpaqueConstruction') return OpaqueConstruction.fromJS(item); + else if (item?.type === 'WindowConstruction') return WindowConstruction.fromJS(item); + else if (item?.type === 'AirBoundaryConstruction') return AirBoundaryConstruction.fromJS(item); + else return item; + })) /** A list of all unique constructions in the model. This includes constructions across all the Model construction_sets. */ constructions?: (OpaqueConstructionAbridged | WindowConstructionAbridged | ShadeConstruction | AirBoundaryConstructionAbridged | OpaqueConstruction | WindowConstruction | AirBoundaryConstruction) []; @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'EnergyMaterial') return EnergyMaterial.fromJS(item); + else if (item?.type === 'EnergyMaterialNoMass') return EnergyMaterialNoMass.fromJS(item); + else if (item?.type === 'EnergyMaterialVegetation') return EnergyMaterialVegetation.fromJS(item); + else if (item?.type === 'EnergyWindowMaterialGlazing') return EnergyWindowMaterialGlazing.fromJS(item); + else if (item?.type === 'EnergyWindowMaterialSimpleGlazSys') return EnergyWindowMaterialSimpleGlazSys.fromJS(item); + else if (item?.type === 'EnergyWindowMaterialGas') return EnergyWindowMaterialGas.fromJS(item); + else if (item?.type === 'EnergyWindowMaterialGasMixture') return EnergyWindowMaterialGasMixture.fromJS(item); + else if (item?.type === 'EnergyWindowMaterialGasCustom') return EnergyWindowMaterialGasCustom.fromJS(item); + else if (item?.type === 'EnergyWindowFrame') return EnergyWindowFrame.fromJS(item); + else if (item?.type === 'EnergyWindowMaterialBlind') return EnergyWindowMaterialBlind.fromJS(item); + else if (item?.type === 'EnergyWindowMaterialShade') return EnergyWindowMaterialShade.fromJS(item); + else return item; + })) /** A list of all unique materials in the model. This includes materials needed to make the Model constructions. */ materials?: (EnergyMaterial | EnergyMaterialNoMass | EnergyMaterialVegetation | EnergyWindowMaterialGlazing | EnergyWindowMaterialSimpleGlazSys | EnergyWindowMaterialGas | EnergyWindowMaterialGasMixture | EnergyWindowMaterialGasCustom | EnergyWindowFrame | EnergyWindowMaterialBlind | EnergyWindowMaterialShade) []; @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'IdealAirSystemAbridged') return IdealAirSystemAbridged.fromJS(item); + else if (item?.type === 'VAV') return VAV.fromJS(item); + else if (item?.type === 'PVAV') return PVAV.fromJS(item); + else if (item?.type === 'PSZ') return PSZ.fromJS(item); + else if (item?.type === 'PTAC') return PTAC.fromJS(item); + else if (item?.type === 'ForcedAirFurnace') return ForcedAirFurnace.fromJS(item); + else if (item?.type === 'FCUwithDOASAbridged') return FCUwithDOASAbridged.fromJS(item); + else if (item?.type === 'WSHPwithDOASAbridged') return WSHPwithDOASAbridged.fromJS(item); + else if (item?.type === 'VRFwithDOASAbridged') return VRFwithDOASAbridged.fromJS(item); + else if (item?.type === 'RadiantwithDOASAbridged') return RadiantwithDOASAbridged.fromJS(item); + else if (item?.type === 'FCU') return FCU.fromJS(item); + else if (item?.type === 'WSHP') return WSHP.fromJS(item); + else if (item?.type === 'VRF') return VRF.fromJS(item); + else if (item?.type === 'Baseboard') return Baseboard.fromJS(item); + else if (item?.type === 'EvaporativeCooler') return EvaporativeCooler.fromJS(item); + else if (item?.type === 'Residential') return Residential.fromJS(item); + else if (item?.type === 'WindowAC') return WindowAC.fromJS(item); + else if (item?.type === 'GasUnitHeater') return GasUnitHeater.fromJS(item); + else if (item?.type === 'Radiant') return Radiant.fromJS(item); + else if (item?.type === 'DetailedHVAC') return DetailedHVAC.fromJS(item); + else return item; + })) /** List of all HVAC systems in the Model. */ hvacs?: (IdealAirSystemAbridged | VAV | PVAV | PSZ | PTAC | ForcedAirFurnace | FCUwithDOASAbridged | WSHPwithDOASAbridged | VRFwithDOASAbridged | RadiantwithDOASAbridged | FCU | WSHP | VRF | Baseboard | EvaporativeCooler | Residential | WindowAC | GasUnitHeater | Radiant | DetailedHVAC) []; @@ -95,11 +147,23 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel { @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'ProgramTypeAbridged') return ProgramTypeAbridged.fromJS(item); + else if (item?.type === 'ProgramType') return ProgramType.fromJS(item); + else return item; + })) /** List of all ProgramTypes in the Model. */ program_types?: (ProgramTypeAbridged | ProgramType) []; @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'ScheduleRulesetAbridged') return ScheduleRulesetAbridged.fromJS(item); + else if (item?.type === 'ScheduleFixedIntervalAbridged') return ScheduleFixedIntervalAbridged.fromJS(item); + else if (item?.type === 'ScheduleRuleset') return ScheduleRuleset.fromJS(item); + else if (item?.type === 'ScheduleFixedInterval') return ScheduleFixedInterval.fromJS(item); + else return item; + })) /** A list of all unique schedules in the model. This includes schedules across all HVAC systems, ProgramTypes and ContextShades. */ schedules?: (ScheduleRulesetAbridged | ScheduleFixedIntervalAbridged | ScheduleRuleset | ScheduleFixedInterval) []; @@ -569,6 +633,13 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel { static override fromJS(data: any): ModelEnergyProperties { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ModelEnergyProperties(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ModelProperties.ts b/src/TypeScriptSDK/models/ModelProperties.ts index 95ff841..37a4db4 100644 --- a/src/TypeScriptSDK/models/ModelProperties.ts +++ b/src/TypeScriptSDK/models/ModelProperties.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { ModelEnergyProperties } from "./ModelEnergyProperties"; import { ModelRadianceProperties } from "./ModelRadianceProperties"; @@ -43,6 +43,13 @@ export class ModelProperties extends _OpenAPIGenBaseModel { static override fromJS(data: any): ModelProperties { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ModelProperties(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/ModelRadianceProperties.ts b/src/TypeScriptSDK/models/ModelRadianceProperties.ts index f883206..0a35acd 100644 --- a/src/TypeScriptSDK/models/ModelRadianceProperties.ts +++ b/src/TypeScriptSDK/models/ModelRadianceProperties.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, IsArray, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { BSDF } from "honeybee-schema"; import { Glass } from "honeybee-schema"; @@ -30,11 +30,28 @@ export class ModelRadianceProperties extends _OpenAPIGenBaseModel { @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'ModifierSet') return ModifierSet.fromJS(item); + else if (item?.type === 'ModifierSetAbridged') return ModifierSetAbridged.fromJS(item); + else return item; + })) /** List of all ModifierSets in the Model. */ modifier_sets?: (ModifierSet | ModifierSetAbridged) []; @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'Plastic') return Plastic.fromJS(item); + else if (item?.type === 'Glass') return Glass.fromJS(item); + else if (item?.type === 'BSDF') return BSDF.fromJS(item); + else if (item?.type === 'Glow') return Glow.fromJS(item); + else if (item?.type === 'Light') return Light.fromJS(item); + else if (item?.type === 'Trans') return Trans.fromJS(item); + else if (item?.type === 'Metal') return Metal.fromJS(item); + else if (item?.type === 'Void') return Void.fromJS(item); + else if (item?.type === 'Mirror') return Mirror.fromJS(item); + else return item; + })) /** A list of all unique modifiers in the model. This includes modifiers across all the Model modifier_sets. */ modifiers?: (Plastic | Glass | BSDF | Glow | Light | Trans | Metal | Void | Mirror) []; @@ -222,6 +239,13 @@ export class ModelRadianceProperties extends _OpenAPIGenBaseModel { static override fromJS(data: any): ModelRadianceProperties { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new ModelRadianceProperties(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/Overhang.ts b/src/TypeScriptSDK/models/Overhang.ts index e266d38..4d698a5 100644 --- a/src/TypeScriptSDK/models/Overhang.ts +++ b/src/TypeScriptSDK/models/Overhang.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, Min, Max, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** A single overhang over an entire wall. */ @@ -43,6 +43,13 @@ export class Overhang extends _OpenAPIGenBaseModel { static override fromJS(data: any): Overhang { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Overhang(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/RectangularWindows.ts b/src/TypeScriptSDK/models/RectangularWindows.ts index a06b2cc..e690b8c 100644 --- a/src/TypeScriptSDK/models/RectangularWindows.ts +++ b/src/TypeScriptSDK/models/RectangularWindows.ts @@ -1,5 +1,5 @@ import { IsArray, IsDefined, IsNumber, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { IsNestedNumberArray } from "./../helpers/class-validator"; import { _WindowParameterBase } from "./_WindowParameterBase"; @@ -57,6 +57,13 @@ export class RectangularWindows extends _WindowParameterBase { static override fromJS(data: any): RectangularWindows { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new RectangularWindows(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/RepeatingWindowRatio.ts b/src/TypeScriptSDK/models/RepeatingWindowRatio.ts index 34f6c0b..fa21ab4 100644 --- a/src/TypeScriptSDK/models/RepeatingWindowRatio.ts +++ b/src/TypeScriptSDK/models/RepeatingWindowRatio.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, Min, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _WindowParameterBase } from "./_WindowParameterBase"; /** Repeating windows derived from an area ratio with the base wall. */ @@ -61,6 +61,13 @@ export class RepeatingWindowRatio extends _WindowParameterBase { static override fromJS(data: any): RepeatingWindowRatio { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new RepeatingWindowRatio(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/RoofSpecification.ts b/src/TypeScriptSDK/models/RoofSpecification.ts index 9b65189..a619660 100644 --- a/src/TypeScriptSDK/models/RoofSpecification.ts +++ b/src/TypeScriptSDK/models/RoofSpecification.ts @@ -1,5 +1,5 @@ import { IsArray, IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { Face3D } from "honeybee-schema"; @@ -38,6 +38,13 @@ export class RoofSpecification extends _OpenAPIGenBaseModel { static override fromJS(data: any): RoofSpecification { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new RoofSpecification(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/Room2D.ts b/src/TypeScriptSDK/models/Room2D.ts index a7dc56d..528221a 100644 --- a/src/TypeScriptSDK/models/Room2D.ts +++ b/src/TypeScriptSDK/models/Room2D.ts @@ -1,5 +1,5 @@ import { IsArray, IsDefined, IsNumber, IsInstance, ValidateNested, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { IsNestedNumberArray } from "./../helpers/class-validator"; import { Adiabatic } from "honeybee-schema"; import { DetailedSkylights } from "./DetailedSkylights"; @@ -70,16 +70,40 @@ export class Room2D extends IDdBaseModel { @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'Ground') return Ground.fromJS(item); + else if (item?.type === 'Outdoors') return Outdoors.fromJS(item); + else if (item?.type === 'Surface') return Surface.fromJS(item); + else if (item?.type === 'Adiabatic') return Adiabatic.fromJS(item); + else if (item?.type === 'OtherSideTemperature') return OtherSideTemperature.fromJS(item); + else return item; + })) /** A list of boundary conditions that match the number of segments in the input floor_geometry + floor_holes. These will be used to assign boundary conditions to each of the walls of the Room in the resulting model. Their order should align with the order of segments in the floor_boundary and then with each hole segment. If None, all boundary conditions will be Outdoors or Ground depending on whether ceiling height of the room is at or below 0 (the assumed ground plane). */ boundary_conditions?: (Ground | Outdoors | Surface | Adiabatic | OtherSideTemperature) []; @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'SingleWindow') return SingleWindow.fromJS(item); + else if (item?.type === 'SimpleWindowArea') return SimpleWindowArea.fromJS(item); + else if (item?.type === 'SimpleWindowRatio') return SimpleWindowRatio.fromJS(item); + else if (item?.type === 'RepeatingWindowRatio') return RepeatingWindowRatio.fromJS(item); + else if (item?.type === 'RectangularWindows') return RectangularWindows.fromJS(item); + else if (item?.type === 'DetailedWindows') return DetailedWindows.fromJS(item); + else return item; + })) /** A list of WindowParameter objects that dictate how the window geometries will be generated for each of the walls. If None, no windows will exist over the entire Room2D. */ window_parameters?: (SingleWindow | SimpleWindowArea | SimpleWindowRatio | RepeatingWindowRatio | RectangularWindows | DetailedWindows) []; @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'ExtrudedBorder') return ExtrudedBorder.fromJS(item); + else if (item?.type === 'Overhang') return Overhang.fromJS(item); + else if (item?.type === 'LouversByDistance') return LouversByDistance.fromJS(item); + else if (item?.type === 'LouversByCount') return LouversByCount.fromJS(item); + else return item; + })) /** A list of ShadingParameter objects that dictate how the shade geometries will be generated for each of the walls. If None, no shades will exist over the entire Room2D. */ shading_parameters?: (ExtrudedBorder | Overhang | LouversByDistance | LouversByCount) []; @@ -90,6 +114,13 @@ export class Room2D extends IDdBaseModel { air_boundaries?: boolean []; @IsOptional() + @Transform(({ value }) => { + const item = value; + if (item?.type === 'GriddedSkylightArea') return GriddedSkylightArea.fromJS(item); + else if (item?.type === 'GriddedSkylightRatio') return GriddedSkylightRatio.fromJS(item); + else if (item?.type === 'DetailedSkylights') return DetailedSkylights.fromJS(item); + else return item; + }) /** A SkylightParameter object describing how to generate skylights. If None, no skylights will exist on the Room2D. */ skylight_parameters?: (GriddedSkylightArea | GriddedSkylightRatio | DetailedSkylights); @@ -126,6 +157,13 @@ export class Room2D extends IDdBaseModel { static override fromJS(data: any): Room2D { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Room2D(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts index 858b0f5..70c77d5 100644 --- a/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DEnergyPropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, MinLength, MaxLength, IsInstance, ValidateNested, IsArray, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { ProcessAbridged } from "honeybee-schema"; import { VentilationControlAbridged } from "honeybee-schema"; @@ -88,6 +88,13 @@ export class Room2DEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): Room2DEnergyPropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Room2DEnergyPropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts index 9c4c4d1..669b487 100644 --- a/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DPropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { Room2DEnergyPropertiesAbridged } from "./Room2DEnergyPropertiesAbridged"; import { Room2DRadiancePropertiesAbridged } from "./Room2DRadiancePropertiesAbridged"; @@ -43,6 +43,13 @@ export class Room2DPropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): Room2DPropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Room2DPropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts index 5a3e9e0..e5b5381 100644 --- a/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/Room2DRadiancePropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsArray, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { ExteriorApertureGridParameter } from "./ExteriorApertureGridParameter"; import { ExteriorFaceGridParameter } from "./ExteriorFaceGridParameter"; @@ -20,6 +20,13 @@ export class Room2DRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { @IsArray() @IsOptional() + @Transform(({ value }) => value.map((item: any) => { + if (item?.type === 'RoomGridParameter') return RoomGridParameter.fromJS(item); + else if (item?.type === 'RoomRadialGridParameter') return RoomRadialGridParameter.fromJS(item); + else if (item?.type === 'ExteriorFaceGridParameter') return ExteriorFaceGridParameter.fromJS(item); + else if (item?.type === 'ExteriorApertureGridParameter') return ExteriorApertureGridParameter.fromJS(item); + else return item; + })) /** An optional list of GridParameter objects to describe how sensor grids should be generated for the Room2D. */ grid_parameters?: (RoomGridParameter | RoomRadialGridParameter | ExteriorFaceGridParameter | ExteriorApertureGridParameter) []; @@ -44,6 +51,13 @@ export class Room2DRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): Room2DRadiancePropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Room2DRadiancePropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/RoomGridParameter.ts b/src/TypeScriptSDK/models/RoomGridParameter.ts index 62c811f..4e6fec7 100644 --- a/src/TypeScriptSDK/models/RoomGridParameter.ts +++ b/src/TypeScriptSDK/models/RoomGridParameter.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsNumber, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _GridParameterBase } from "./_GridParameterBase"; /** Instructions for a SensorGrid generated from a Room2D's floors. */ @@ -42,6 +42,13 @@ export class RoomGridParameter extends _GridParameterBase { static override fromJS(data: any): RoomGridParameter { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new RoomGridParameter(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/RoomRadialGridParameter.ts b/src/TypeScriptSDK/models/RoomRadialGridParameter.ts index 0636e96..49403ba 100644 --- a/src/TypeScriptSDK/models/RoomRadialGridParameter.ts +++ b/src/TypeScriptSDK/models/RoomRadialGridParameter.ts @@ -1,5 +1,5 @@ import { IsInt, IsOptional, IsArray, IsNumber, IsString, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { Autocalculate } from "honeybee-schema"; import { RoomGridParameter } from "./RoomGridParameter"; @@ -49,6 +49,13 @@ export class RoomRadialGridParameter extends RoomGridParameter { static override fromJS(data: any): RoomRadialGridParameter { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new RoomRadialGridParameter(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/SimpleWindowArea.ts b/src/TypeScriptSDK/models/SimpleWindowArea.ts index 86d42c2..5815f06 100644 --- a/src/TypeScriptSDK/models/SimpleWindowArea.ts +++ b/src/TypeScriptSDK/models/SimpleWindowArea.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _WindowParameterBase } from "./_WindowParameterBase"; /** A single window defined by an absolute area. */ @@ -41,6 +41,13 @@ export class SimpleWindowArea extends _WindowParameterBase { static override fromJS(data: any): SimpleWindowArea { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new SimpleWindowArea(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/SimpleWindowRatio.ts b/src/TypeScriptSDK/models/SimpleWindowRatio.ts index e333f36..3080512 100644 --- a/src/TypeScriptSDK/models/SimpleWindowRatio.ts +++ b/src/TypeScriptSDK/models/SimpleWindowRatio.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _WindowParameterBase } from "./_WindowParameterBase"; /** A single window defined by an area ratio with the base surface. */ @@ -41,6 +41,13 @@ export class SimpleWindowRatio extends _WindowParameterBase { static override fromJS(data: any): SimpleWindowRatio { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new SimpleWindowRatio(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/SingleWindow.ts b/src/TypeScriptSDK/models/SingleWindow.ts index 132abb7..6c2ca58 100644 --- a/src/TypeScriptSDK/models/SingleWindow.ts +++ b/src/TypeScriptSDK/models/SingleWindow.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _WindowParameterBase } from "./_WindowParameterBase"; /** A single window in the wall center defined by a width * height. */ @@ -47,6 +47,13 @@ export class SingleWindow extends _WindowParameterBase { static override fromJS(data: any): SingleWindow { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new SingleWindow(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/Story.ts b/src/TypeScriptSDK/models/Story.ts index d21dec7..837bd32 100644 --- a/src/TypeScriptSDK/models/Story.ts +++ b/src/TypeScriptSDK/models/Story.ts @@ -1,5 +1,5 @@ import { IsArray, IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsInt, Min, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { Autocalculate } from "honeybee-schema"; import { IDdBaseModel } from "honeybee-schema"; import { RoofSpecification } from "./RoofSpecification"; @@ -77,6 +77,13 @@ export class Story extends IDdBaseModel { static override fromJS(data: any): Story { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new Story(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts index 505f2ec..e78e4b0 100644 --- a/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryEnergyPropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */ @@ -36,6 +36,13 @@ export class StoryEnergyPropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): StoryEnergyPropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new StoryEnergyPropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts index 3b5734c..252ba09 100644 --- a/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryPropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; import { StoryEnergyPropertiesAbridged } from "./StoryEnergyPropertiesAbridged"; import { StoryRadiancePropertiesAbridged } from "./StoryRadiancePropertiesAbridged"; @@ -43,6 +43,13 @@ export class StoryPropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): StoryPropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new StoryPropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts b/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts index bdf87b0..e391ece 100644 --- a/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts +++ b/src/TypeScriptSDK/models/StoryRadiancePropertiesAbridged.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */ @@ -34,6 +34,13 @@ export class StoryRadiancePropertiesAbridged extends _OpenAPIGenBaseModel { static override fromJS(data: any): StoryRadiancePropertiesAbridged { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new StoryRadiancePropertiesAbridged(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/_GridParameterBase.ts b/src/TypeScriptSDK/models/_GridParameterBase.ts index aac3634..9122a29 100644 --- a/src/TypeScriptSDK/models/_GridParameterBase.ts +++ b/src/TypeScriptSDK/models/_GridParameterBase.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsBoolean, IsOptional, IsString, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base object for all GridParameters. */ @@ -41,6 +41,13 @@ export class _GridParameterBase extends _OpenAPIGenBaseModel { static override fromJS(data: any): _GridParameterBase { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new _GridParameterBase(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/_LouversBase.ts b/src/TypeScriptSDK/models/_LouversBase.ts index a1869c4..fdcdebe 100644 --- a/src/TypeScriptSDK/models/_LouversBase.ts +++ b/src/TypeScriptSDK/models/_LouversBase.ts @@ -1,5 +1,5 @@ import { IsNumber, IsDefined, IsOptional, Min, Max, IsArray, IsBoolean, IsString, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for for a series of louvered shades over a wall. */ @@ -66,6 +66,13 @@ export class _LouversBase extends _OpenAPIGenBaseModel { static override fromJS(data: any): _LouversBase { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new _LouversBase(); result.init(data); return result; diff --git a/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts b/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts index 9a67b19..7fb0369 100644 --- a/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts +++ b/src/TypeScriptSDK/models/_OpenAPIGenBaseModel.ts @@ -1,5 +1,5 @@ import { IsString, IsOptional, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; export abstract class _OpenAPIGenBaseModel { @IsString() diff --git a/src/TypeScriptSDK/models/_WindowParameterBase.ts b/src/TypeScriptSDK/models/_WindowParameterBase.ts index d2133dd..1c22231 100644 --- a/src/TypeScriptSDK/models/_WindowParameterBase.ts +++ b/src/TypeScriptSDK/models/_WindowParameterBase.ts @@ -1,5 +1,5 @@ import { IsOptional, IsString, Matches, validate, ValidationError as TsValidationError } from 'class-validator'; -import { Type, plainToClass, instanceToPlain } from 'class-transformer'; +import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer'; import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel"; /** Base class for all window parameters. */ @@ -33,6 +33,13 @@ export class _WindowParameterBase extends _OpenAPIGenBaseModel { static override fromJS(data: any): _WindowParameterBase { data = typeof data === 'object' ? data : {}; + if (Array.isArray(data)) { + const obj:any = {}; + for (var property in data) { + obj[property] = data[property]; + } + data = obj; + } let result = new _WindowParameterBase(); result.init(data); return result; diff --git a/src/TypeScriptSDK/tests/Model.test.ts b/src/TypeScriptSDK/tests/Model.test.ts index b535faf..c5ecd63 100644 --- a/src/TypeScriptSDK/tests/Model.test.ts +++ b/src/TypeScriptSDK/tests/Model.test.ts @@ -1,6 +1,6 @@ import { plainToClass } from "class-transformer"; import { Model } from "../models"; -import { Face3D, GlobalModifierSet, ModelProperties, WallModifierSetAbridged } from "honeybee-schema"; +import { Face3D, GlobalModifierSet, ModelProperties, Plastic, WallModifierSetAbridged } from "honeybee-schema"; import * as fs from 'fs'; import * as path from 'path'; @@ -195,6 +195,7 @@ test('test GlobalModifierSet', () => { const data = GlobalModifierSetData; const obj = GlobalModifierSet.fromJS(data); expect(obj.validate()).resolves.toBe(true); + expect(obj.modifiers?.at(0)).toBeInstanceOf(Plastic) const jsonObj = obj.toJSON(); expect(jsonObj.type).toBe("GlobalModifierSet"); @@ -236,4 +237,6 @@ test('test Model2', () => { // expect(obj.validate()).resolves.toBe(true); } -); \ No newline at end of file +); + + From e634a5d8537bbbb57eb84177941bd85f01834788 Mon Sep 17 00:00:00 2001 From: Mingbo Peng Date: Tue, 24 Sep 2024 17:23:38 +0800 Subject: [PATCH 6/6] fix(Ts): change honeybee-schema to latest --- src/TypeScriptSDK/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TypeScriptSDK/package.json b/src/TypeScriptSDK/package.json index 590bd5a..734a957 100644 --- a/src/TypeScriptSDK/package.json +++ b/src/TypeScriptSDK/package.json @@ -27,6 +27,6 @@ "dependencies": { "class-transformer": "^0.5.1", "class-validator": "^0.14.1", - "honeybee-schema": "file:D:/Dev/Schema/honeybee-schema-dotnet/src/TypeScriptSDK" + "honeybee-schema": "latest" } }