dragonfly-schema 1.12.1-v10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/helpers/class-validator.ts +94 -0
  2. package/index.ts +1 -0
  3. package/models/Building.ts +98 -0
  4. package/models/BuildingEnergyPropertiesAbridged.ts +65 -0
  5. package/models/BuildingPropertiesAbridged.ts +73 -0
  6. package/models/BuildingRadiancePropertiesAbridged.ts +63 -0
  7. package/models/ContextShade.ts +83 -0
  8. package/models/ContextShadeEnergyPropertiesAbridged.ts +74 -0
  9. package/models/ContextShadePropertiesAbridged.ts +73 -0
  10. package/models/ContextShadeRadiancePropertiesAbridged.ts +63 -0
  11. package/models/DetailedSkylights.ts +73 -0
  12. package/models/DetailedWindows.ts +73 -0
  13. package/models/ExteriorApertureGridParameter.ts +74 -0
  14. package/models/ExteriorApertureType.ts +8 -0
  15. package/models/ExteriorFaceGridParameter.ts +82 -0
  16. package/models/ExteriorFaceType.ts +9 -0
  17. package/models/ExtrudedBorder.ts +63 -0
  18. package/models/GriddedSkylightArea.ts +71 -0
  19. package/models/GriddedSkylightRatio.ts +71 -0
  20. package/models/LouversByCount.ts +63 -0
  21. package/models/LouversByDistance.ts +63 -0
  22. package/models/Model.ts +125 -0
  23. package/models/ModelEnergyProperties.ts +606 -0
  24. package/models/ModelProperties.ts +73 -0
  25. package/models/ModelRadianceProperties.ts +253 -0
  26. package/models/Overhang.ts +73 -0
  27. package/models/RectangularWindows.ts +89 -0
  28. package/models/RepeatingWindowRatio.ts +94 -0
  29. package/models/RoofSpecification.ts +67 -0
  30. package/models/Room2D.ts +166 -0
  31. package/models/Room2DEnergyPropertiesAbridged.ts +123 -0
  32. package/models/Room2DPropertiesAbridged.ts +73 -0
  33. package/models/Room2DRadiancePropertiesAbridged.ts +74 -0
  34. package/models/RoomGridParameter.ts +72 -0
  35. package/models/RoomRadialGridParameter.ts +80 -0
  36. package/models/SimpleWindowArea.ts +71 -0
  37. package/models/SimpleWindowRatio.ts +71 -0
  38. package/models/SingleWindow.ts +78 -0
  39. package/models/Story.ts +111 -0
  40. package/models/StoryEnergyPropertiesAbridged.ts +65 -0
  41. package/models/StoryPropertiesAbridged.ts +73 -0
  42. package/models/StoryRadiancePropertiesAbridged.ts +63 -0
  43. package/models/_GridParameterBase.ts +71 -0
  44. package/models/_LouversBase.ts +99 -0
  45. package/models/_OpenAPIGenBaseModel.ts +38 -0
  46. package/models/_WindowParameterBase.ts +62 -0
  47. package/models/index.ts +46 -0
  48. package/package.json +28 -0
  49. package/tsconfig.json +32 -0
  50. package/vite.config.ts +14 -0
@@ -0,0 +1,253 @@
1
+ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, IsArray, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+ import { BSDF } from "honeybee-schema";
5
+ import { Glass } from "honeybee-schema";
6
+ import { GlobalModifierSet } from "honeybee-schema";
7
+ import { Glow } from "honeybee-schema";
8
+ import { Light } from "honeybee-schema";
9
+ import { Metal } from "honeybee-schema";
10
+ import { Mirror } from "honeybee-schema";
11
+ import { ModifierSet } from "honeybee-schema";
12
+ import { ModifierSetAbridged } from "honeybee-schema";
13
+ import { Plastic } from "honeybee-schema";
14
+ import { Trans } from "honeybee-schema";
15
+ import { Void } from "honeybee-schema";
16
+
17
+ /** 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. */
18
+ export class ModelRadianceProperties extends _OpenAPIGenBaseModel {
19
+ @IsString()
20
+ @IsOptional()
21
+ @Matches(/^ModelRadianceProperties$/)
22
+ type?: string;
23
+
24
+ @IsInstance(GlobalModifierSet)
25
+ @Type(() => GlobalModifierSet)
26
+ @ValidateNested()
27
+ @IsOptional()
28
+ /** Global Radiance modifier set. */
29
+ global_modifier_set?: GlobalModifierSet;
30
+
31
+ @IsArray()
32
+ @IsOptional()
33
+ /** List of all ModifierSets in the Model. */
34
+ modifier_sets?: (ModifierSet | ModifierSetAbridged) [];
35
+
36
+ @IsArray()
37
+ @IsOptional()
38
+ /** A list of all unique modifiers in the model. This includes modifiers across all the Model modifier_sets. */
39
+ modifiers?: (Plastic | Glass | BSDF | Glow | Light | Trans | Metal | Void | Mirror) [];
40
+
41
+
42
+ constructor() {
43
+ super();
44
+ this.type = "ModelRadianceProperties";
45
+ this.global_modifier_set = GlobalModifierSet.fromJS({
46
+ "type": "GlobalModifierSet",
47
+ "modifiers": [
48
+ {
49
+ "identifier": "generic_floor_0.20",
50
+ "display_name": null,
51
+ "type": "Plastic",
52
+ "modifier": null,
53
+ "dependencies": [],
54
+ "r_reflectance": 0.2,
55
+ "g_reflectance": 0.2,
56
+ "b_reflectance": 0.2,
57
+ "specularity": 0.0,
58
+ "roughness": 0.0
59
+ },
60
+ {
61
+ "identifier": "generic_wall_0.50",
62
+ "display_name": null,
63
+ "type": "Plastic",
64
+ "modifier": null,
65
+ "dependencies": [],
66
+ "r_reflectance": 0.5,
67
+ "g_reflectance": 0.5,
68
+ "b_reflectance": 0.5,
69
+ "specularity": 0.0,
70
+ "roughness": 0.0
71
+ },
72
+ {
73
+ "identifier": "generic_ceiling_0.80",
74
+ "display_name": null,
75
+ "type": "Plastic",
76
+ "modifier": null,
77
+ "dependencies": [],
78
+ "r_reflectance": 0.8,
79
+ "g_reflectance": 0.8,
80
+ "b_reflectance": 0.8,
81
+ "specularity": 0.0,
82
+ "roughness": 0.0
83
+ },
84
+ {
85
+ "identifier": "generic_opaque_door_0.50",
86
+ "display_name": null,
87
+ "type": "Plastic",
88
+ "modifier": null,
89
+ "dependencies": [],
90
+ "r_reflectance": 0.5,
91
+ "g_reflectance": 0.5,
92
+ "b_reflectance": 0.5,
93
+ "specularity": 0.0,
94
+ "roughness": 0.0
95
+ },
96
+ {
97
+ "identifier": "generic_interior_shade_0.50",
98
+ "display_name": null,
99
+ "type": "Plastic",
100
+ "modifier": null,
101
+ "dependencies": [],
102
+ "r_reflectance": 0.5,
103
+ "g_reflectance": 0.5,
104
+ "b_reflectance": 0.5,
105
+ "specularity": 0.0,
106
+ "roughness": 0.0
107
+ },
108
+ {
109
+ "identifier": "generic_exterior_shade_0.35",
110
+ "display_name": null,
111
+ "type": "Plastic",
112
+ "modifier": null,
113
+ "dependencies": [],
114
+ "r_reflectance": 0.35,
115
+ "g_reflectance": 0.35,
116
+ "b_reflectance": 0.35,
117
+ "specularity": 0.0,
118
+ "roughness": 0.0
119
+ },
120
+ {
121
+ "identifier": "generic_context_0.20",
122
+ "display_name": null,
123
+ "type": "Plastic",
124
+ "modifier": null,
125
+ "dependencies": [],
126
+ "r_reflectance": 0.2,
127
+ "g_reflectance": 0.2,
128
+ "b_reflectance": 0.2,
129
+ "specularity": 0.0,
130
+ "roughness": 0.0
131
+ },
132
+ {
133
+ "identifier": "generic_interior_window_vis_0.88",
134
+ "display_name": null,
135
+ "type": "Glass",
136
+ "modifier": null,
137
+ "dependencies": [],
138
+ "r_transmissivity": 0.9584154328610596,
139
+ "g_transmissivity": 0.9584154328610596,
140
+ "b_transmissivity": 0.9584154328610596,
141
+ "refraction_index": null
142
+ },
143
+ {
144
+ "identifier": "generic_exterior_window_vis_0.64",
145
+ "display_name": null,
146
+ "type": "Glass",
147
+ "modifier": null,
148
+ "dependencies": [],
149
+ "r_transmissivity": 0.6975761815384331,
150
+ "g_transmissivity": 0.6975761815384331,
151
+ "b_transmissivity": 0.6975761815384331,
152
+ "refraction_index": null
153
+ },
154
+ {
155
+ "identifier": "air_boundary",
156
+ "display_name": null,
157
+ "type": "Trans",
158
+ "modifier": null,
159
+ "dependencies": [],
160
+ "r_reflectance": 1.0,
161
+ "g_reflectance": 1.0,
162
+ "b_reflectance": 1.0,
163
+ "specularity": 0.0,
164
+ "roughness": 0.0,
165
+ "transmitted_diff": 1.0,
166
+ "transmitted_spec": 1.0
167
+ }
168
+ ],
169
+ "wall_set": {
170
+ "exterior_modifier": "generic_wall_0.50",
171
+ "interior_modifier": "generic_wall_0.50",
172
+ "type": "WallModifierSetAbridged"
173
+ },
174
+ "floor_set": {
175
+ "exterior_modifier": "generic_floor_0.20",
176
+ "interior_modifier": "generic_floor_0.20",
177
+ "type": "FloorModifierSetAbridged"
178
+ },
179
+ "roof_ceiling_set": {
180
+ "exterior_modifier": "generic_ceiling_0.80",
181
+ "interior_modifier": "generic_ceiling_0.80",
182
+ "type": "RoofCeilingModifierSetAbridged"
183
+ },
184
+ "aperture_set": {
185
+ "type": "ApertureModifierSetAbridged",
186
+ "window_modifier": "generic_exterior_window_vis_0.64",
187
+ "interior_modifier": "generic_interior_window_vis_0.88",
188
+ "skylight_modifier": "generic_exterior_window_vis_0.64",
189
+ "operable_modifier": "generic_exterior_window_vis_0.64"
190
+ },
191
+ "door_set": {
192
+ "exterior_modifier": "generic_opaque_door_0.50",
193
+ "interior_modifier": "generic_opaque_door_0.50",
194
+ "type": "DoorModifierSetAbridged",
195
+ "interior_glass_modifier": "generic_interior_window_vis_0.88",
196
+ "exterior_glass_modifier": "generic_exterior_window_vis_0.64",
197
+ "overhead_modifier": "generic_opaque_door_0.50"
198
+ },
199
+ "shade_set": {
200
+ "exterior_modifier": "generic_exterior_shade_0.35",
201
+ "interior_modifier": "generic_interior_shade_0.50",
202
+ "type": "ShadeModifierSetAbridged"
203
+ },
204
+ "air_boundary_modifier": "air_boundary",
205
+ "context_modifier": "generic_context_0.20"
206
+ });
207
+ }
208
+
209
+
210
+ override init(_data?: any) {
211
+ super.init(_data);
212
+ if (_data) {
213
+ const obj = plainToClass(ModelRadianceProperties, _data);
214
+ this.type = obj.type;
215
+ this.global_modifier_set = obj.global_modifier_set;
216
+ this.modifier_sets = obj.modifier_sets;
217
+ this.modifiers = obj.modifiers;
218
+ }
219
+ }
220
+
221
+
222
+ static override fromJS(data: any): ModelRadianceProperties {
223
+ data = typeof data === 'object' ? data : {};
224
+
225
+ let result = new ModelRadianceProperties();
226
+ result.init(data);
227
+ return result;
228
+ }
229
+
230
+ override toJSON(data?: any) {
231
+ data = typeof data === 'object' ? data : {};
232
+ for (var property in this) {
233
+ if (this.hasOwnProperty(property))
234
+ data[property] = this[property];
235
+ }
236
+
237
+ data["type"] = this.type;
238
+ data["global_modifier_set"] = this.global_modifier_set;
239
+ data["modifier_sets"] = this.modifier_sets;
240
+ data["modifiers"] = this.modifiers;
241
+ data = super.toJSON(data);
242
+ return instanceToPlain(data);
243
+ }
244
+
245
+ async validate(): Promise<boolean> {
246
+ const errors = await validate(this);
247
+ if (errors.length > 0){
248
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
249
+ throw new Error(`Validation failed: ${errorMessages}`);
250
+ }
251
+ return true;
252
+ }
253
+ }
@@ -0,0 +1,73 @@
1
+ import { IsNumber, IsDefined, IsString, IsOptional, Matches, Min, Max, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+
5
+ /** A single overhang over an entire wall. */
6
+ export class Overhang extends _OpenAPIGenBaseModel {
7
+ @IsNumber()
8
+ @IsDefined()
9
+ /** A number for the overhang depth. */
10
+ depth!: number;
11
+
12
+ @IsString()
13
+ @IsOptional()
14
+ @Matches(/^Overhang$/)
15
+ type?: string;
16
+
17
+ @IsNumber()
18
+ @IsOptional()
19
+ @Min(-90)
20
+ @Max(90)
21
+ /** A number between -90 and 90 for the for an angle to rotate the overhang in degrees. 0 indicates an overhang perpendicular to the wall. Positive values indicate a downward rotation. Negative values indicate an upward rotation. */
22
+ angle?: number;
23
+
24
+
25
+ constructor() {
26
+ super();
27
+ this.type = "Overhang";
28
+ this.angle = 0;
29
+ }
30
+
31
+
32
+ override init(_data?: any) {
33
+ super.init(_data);
34
+ if (_data) {
35
+ const obj = plainToClass(Overhang, _data);
36
+ this.depth = obj.depth;
37
+ this.type = obj.type;
38
+ this.angle = obj.angle;
39
+ }
40
+ }
41
+
42
+
43
+ static override fromJS(data: any): Overhang {
44
+ data = typeof data === 'object' ? data : {};
45
+
46
+ let result = new Overhang();
47
+ result.init(data);
48
+ return result;
49
+ }
50
+
51
+ override toJSON(data?: any) {
52
+ data = typeof data === 'object' ? data : {};
53
+ for (var property in this) {
54
+ if (this.hasOwnProperty(property))
55
+ data[property] = this[property];
56
+ }
57
+
58
+ data["depth"] = this.depth;
59
+ data["type"] = this.type;
60
+ data["angle"] = this.angle;
61
+ data = super.toJSON(data);
62
+ return instanceToPlain(data);
63
+ }
64
+
65
+ async validate(): Promise<boolean> {
66
+ const errors = await validate(this);
67
+ if (errors.length > 0){
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
+ throw new Error(`Validation failed: ${errorMessages}`);
70
+ }
71
+ return true;
72
+ }
73
+ }
@@ -0,0 +1,89 @@
1
+ import { IsArray, IsDefined, IsNumber, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { IsNestedNumberArray } from "./../helpers/class-validator";
4
+ import { _WindowParameterBase } from "./_WindowParameterBase";
5
+
6
+ /** Several rectangular windows, defined by origin, width and height. */
7
+ export class RectangularWindows extends _WindowParameterBase {
8
+ @IsArray()
9
+ @IsNestedNumberArray()
10
+ @IsDefined()
11
+ /** An array of 2D points within the plane of the wall for the origin of each window. Each point should be a list of 2 (x, y) values. The wall plane is assumed to have an origin at the first point of the wall segment and an X-axis extending along the length of the segment. The wall plane Y-axis always points upwards. Therefore, both X and Y values of each origin point should be positive. */
12
+ origins!: number [] [];
13
+
14
+ @IsArray()
15
+ @IsNumber({},{ each: true })
16
+ @IsDefined()
17
+ /** An array of positive numbers for the window widths. The length of this list must match the length of the origins. */
18
+ widths!: number [];
19
+
20
+ @IsArray()
21
+ @IsNumber({},{ each: true })
22
+ @IsDefined()
23
+ /** An array of positive numbers for the window heights. The length of this list must match the length of the origins. */
24
+ heights!: number [];
25
+
26
+ @IsString()
27
+ @IsOptional()
28
+ @Matches(/^RectangularWindows$/)
29
+ type?: string;
30
+
31
+ @IsArray()
32
+ @IsBoolean({ each: true })
33
+ @IsOptional()
34
+ /** An array of booleans that align with the origins and note whether each of the geometries represents a door (True) or a window (False). If None, it will be assumed that all geometries represent windows and they will be translated to Apertures in any resulting Honeybee model. */
35
+ are_doors?: boolean [];
36
+
37
+
38
+ constructor() {
39
+ super();
40
+ this.type = "RectangularWindows";
41
+ }
42
+
43
+
44
+ override init(_data?: any) {
45
+ super.init(_data);
46
+ if (_data) {
47
+ const obj = plainToClass(RectangularWindows, _data);
48
+ this.origins = obj.origins;
49
+ this.widths = obj.widths;
50
+ this.heights = obj.heights;
51
+ this.type = obj.type;
52
+ this.are_doors = obj.are_doors;
53
+ }
54
+ }
55
+
56
+
57
+ static override fromJS(data: any): RectangularWindows {
58
+ data = typeof data === 'object' ? data : {};
59
+
60
+ let result = new RectangularWindows();
61
+ result.init(data);
62
+ return result;
63
+ }
64
+
65
+ override toJSON(data?: any) {
66
+ data = typeof data === 'object' ? data : {};
67
+ for (var property in this) {
68
+ if (this.hasOwnProperty(property))
69
+ data[property] = this[property];
70
+ }
71
+
72
+ data["origins"] = this.origins;
73
+ data["widths"] = this.widths;
74
+ data["heights"] = this.heights;
75
+ data["type"] = this.type;
76
+ data["are_doors"] = this.are_doors;
77
+ data = super.toJSON(data);
78
+ return instanceToPlain(data);
79
+ }
80
+
81
+ async validate(): Promise<boolean> {
82
+ const errors = await validate(this);
83
+ if (errors.length > 0){
84
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
85
+ throw new Error(`Validation failed: ${errorMessages}`);
86
+ }
87
+ return true;
88
+ }
89
+ }
@@ -0,0 +1,94 @@
1
+ import { IsNumber, IsDefined, Min, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _WindowParameterBase } from "./_WindowParameterBase";
4
+
5
+ /** Repeating windows derived from an area ratio with the base wall. */
6
+ export class RepeatingWindowRatio extends _WindowParameterBase {
7
+ @IsNumber()
8
+ @IsDefined()
9
+ /** A number between 0 and 1 for the ratio between the window area and the parent wall surface area. */
10
+ window_ratio!: number;
11
+
12
+ @IsNumber()
13
+ @IsDefined()
14
+ /** A number for the target height of the windows. Note that, if the window ratio is too large for the height, the ratio will take precedence and the actual window_height will be larger than this value. */
15
+ window_height!: number;
16
+
17
+ @IsNumber()
18
+ @IsDefined()
19
+ /** A number for the target height above the bottom edge of the wall to start the windows. Note that, if the ratio is too large for the height, the ratio will take precedence and the sill_height will be smaller than this value. */
20
+ sill_height!: number;
21
+
22
+ @IsNumber()
23
+ @IsDefined()
24
+ @Min(0)
25
+ /** A number for the target separation between individual window centerlines. If this number is larger than the parent rectangle base, only one window will be produced. */
26
+ horizontal_separation!: number;
27
+
28
+ @IsString()
29
+ @IsOptional()
30
+ @Matches(/^RepeatingWindowRatio$/)
31
+ type?: string;
32
+
33
+ @IsNumber()
34
+ @IsOptional()
35
+ @Min(0)
36
+ /** An optional number to create a single vertical separation between top and bottom windows. */
37
+ vertical_separation?: number;
38
+
39
+
40
+ constructor() {
41
+ super();
42
+ this.type = "RepeatingWindowRatio";
43
+ this.vertical_separation = 0;
44
+ }
45
+
46
+
47
+ override init(_data?: any) {
48
+ super.init(_data);
49
+ if (_data) {
50
+ const obj = plainToClass(RepeatingWindowRatio, _data);
51
+ this.window_ratio = obj.window_ratio;
52
+ this.window_height = obj.window_height;
53
+ this.sill_height = obj.sill_height;
54
+ this.horizontal_separation = obj.horizontal_separation;
55
+ this.type = obj.type;
56
+ this.vertical_separation = obj.vertical_separation;
57
+ }
58
+ }
59
+
60
+
61
+ static override fromJS(data: any): RepeatingWindowRatio {
62
+ data = typeof data === 'object' ? data : {};
63
+
64
+ let result = new RepeatingWindowRatio();
65
+ result.init(data);
66
+ return result;
67
+ }
68
+
69
+ override toJSON(data?: any) {
70
+ data = typeof data === 'object' ? data : {};
71
+ for (var property in this) {
72
+ if (this.hasOwnProperty(property))
73
+ data[property] = this[property];
74
+ }
75
+
76
+ data["window_ratio"] = this.window_ratio;
77
+ data["window_height"] = this.window_height;
78
+ data["sill_height"] = this.sill_height;
79
+ data["horizontal_separation"] = this.horizontal_separation;
80
+ data["type"] = this.type;
81
+ data["vertical_separation"] = this.vertical_separation;
82
+ data = super.toJSON(data);
83
+ return instanceToPlain(data);
84
+ }
85
+
86
+ async validate(): Promise<boolean> {
87
+ const errors = await validate(this);
88
+ if (errors.length > 0){
89
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
90
+ throw new Error(`Validation failed: ${errorMessages}`);
91
+ }
92
+ return true;
93
+ }
94
+ }
@@ -0,0 +1,67 @@
1
+ import { IsArray, IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+ import { Face3D } from "honeybee-schema";
5
+
6
+ /** Geometry for specifying sloped roofs over a Story. */
7
+ export class RoofSpecification extends _OpenAPIGenBaseModel {
8
+ @IsArray()
9
+ @IsInstance(Face3D, { each: true })
10
+ @Type(() => Face3D)
11
+ @ValidateNested({ each: true })
12
+ @IsDefined()
13
+ /** An array of Face3D objects representing the geometry of the Roof. None of these geometries should overlap in plan and, together, these Face3D should either completely cover or skip each Room2D of the Story to which the RoofSpecification is assigned. */
14
+ geometry!: Face3D [];
15
+
16
+ @IsString()
17
+ @IsOptional()
18
+ @Matches(/^RoofSpecification$/)
19
+ type?: string;
20
+
21
+
22
+ constructor() {
23
+ super();
24
+ this.type = "RoofSpecification";
25
+ }
26
+
27
+
28
+ override init(_data?: any) {
29
+ super.init(_data);
30
+ if (_data) {
31
+ const obj = plainToClass(RoofSpecification, _data);
32
+ this.geometry = obj.geometry;
33
+ this.type = obj.type;
34
+ }
35
+ }
36
+
37
+
38
+ static override fromJS(data: any): RoofSpecification {
39
+ data = typeof data === 'object' ? data : {};
40
+
41
+ let result = new RoofSpecification();
42
+ result.init(data);
43
+ return result;
44
+ }
45
+
46
+ override toJSON(data?: any) {
47
+ data = typeof data === 'object' ? data : {};
48
+ for (var property in this) {
49
+ if (this.hasOwnProperty(property))
50
+ data[property] = this[property];
51
+ }
52
+
53
+ data["geometry"] = this.geometry;
54
+ data["type"] = this.type;
55
+ data = super.toJSON(data);
56
+ return instanceToPlain(data);
57
+ }
58
+
59
+ async validate(): Promise<boolean> {
60
+ const errors = await validate(this);
61
+ if (errors.length > 0){
62
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
63
+ throw new Error(`Validation failed: ${errorMessages}`);
64
+ }
65
+ return true;
66
+ }
67
+ }