dragonfly-schema 1.12.1-v7 → 1.12.1-v9

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 (46) hide show
  1. package/helpers/class-validator.ts +94 -0
  2. package/models/Building.ts +4 -4
  3. package/models/BuildingEnergyPropertiesAbridged.ts +4 -4
  4. package/models/BuildingPropertiesAbridged.ts +4 -4
  5. package/models/BuildingRadiancePropertiesAbridged.ts +4 -4
  6. package/models/ContextShade.ts +4 -4
  7. package/models/ContextShadeEnergyPropertiesAbridged.ts +4 -4
  8. package/models/ContextShadePropertiesAbridged.ts +4 -4
  9. package/models/ContextShadeRadiancePropertiesAbridged.ts +4 -4
  10. package/models/DetailedSkylights.ts +7 -12
  11. package/models/DetailedWindows.ts +7 -12
  12. package/models/ExteriorApertureGridParameter.ts +4 -4
  13. package/models/ExteriorFaceGridParameter.ts +4 -4
  14. package/models/ExtrudedBorder.ts +4 -4
  15. package/models/GriddedSkylightArea.ts +4 -4
  16. package/models/GriddedSkylightRatio.ts +4 -4
  17. package/models/LouversByCount.ts +4 -4
  18. package/models/LouversByDistance.ts +4 -4
  19. package/models/Model.ts +4 -4
  20. package/models/ModelEnergyProperties.ts +4 -4
  21. package/models/ModelProperties.ts +4 -4
  22. package/models/ModelRadianceProperties.ts +4 -4
  23. package/models/Overhang.ts +4 -4
  24. package/models/RectangularWindows.ts +7 -9
  25. package/models/RepeatingWindowRatio.ts +4 -4
  26. package/models/RoofSpecification.ts +4 -4
  27. package/models/Room2D.ts +8 -16
  28. package/models/Room2DEnergyPropertiesAbridged.ts +4 -4
  29. package/models/Room2DPropertiesAbridged.ts +4 -4
  30. package/models/Room2DRadiancePropertiesAbridged.ts +4 -4
  31. package/models/RoomGridParameter.ts +4 -4
  32. package/models/RoomRadialGridParameter.ts +4 -4
  33. package/models/SimpleWindowArea.ts +4 -4
  34. package/models/SimpleWindowRatio.ts +4 -4
  35. package/models/SingleWindow.ts +4 -4
  36. package/models/Story.ts +4 -4
  37. package/models/StoryEnergyPropertiesAbridged.ts +4 -4
  38. package/models/StoryPropertiesAbridged.ts +4 -4
  39. package/models/StoryRadiancePropertiesAbridged.ts +4 -4
  40. package/models/_GridParameterBase.ts +4 -4
  41. package/models/_LouversBase.ts +4 -4
  42. package/models/_OpenAPIGenBaseModel.ts +3 -2
  43. package/models/_WindowParameterBase.ts +4 -4
  44. package/models/index.ts +32 -32
  45. package/package.json +2 -2
  46. package/tsconfig.json +1 -1
@@ -0,0 +1,94 @@
1
+ import { registerDecorator, ValidationOptions, ValidationArguments } from 'class-validator';
2
+
3
+
4
+ // Custom decorator to validate nested arrays of numbers
5
+ export function IsNestedNumberArray(validationOptions?: ValidationOptions) {
6
+ return function (object: Object, propertyName: string) {
7
+ registerDecorator({
8
+ name: 'isNestedNumberArray',
9
+ target: object.constructor,
10
+ propertyName: propertyName,
11
+ options: validationOptions,
12
+ validator: {
13
+ validate(value: any, args: ValidationArguments) {
14
+ if (value === undefined || value === null) return true; // Allow optional values
15
+ if (!Array.isArray(value)) return false;
16
+ return value.every(
17
+ (arr: any) => Array.isArray(arr) && arr.every(
18
+ (subArr: any) =>
19
+ (Array.isArray(subArr) && subArr.every(
20
+ (num: any) => typeof num === 'number'
21
+ )) ||
22
+ typeof subArr === 'number'
23
+ )
24
+ );
25
+ },
26
+ defaultMessage(args: ValidationArguments) {
27
+ return `${args.property} must be number[][] or number[][][]`;
28
+ }
29
+ }
30
+ });
31
+ };
32
+ }
33
+
34
+
35
+ // Custom decorator to validate nested arrays of numbers
36
+ export function IsNestedIntegerArray(validationOptions?: ValidationOptions) {
37
+ return function (object: Object, propertyName: string) {
38
+ registerDecorator({
39
+ name: 'isNestedIntegerArray',
40
+ target: object.constructor,
41
+ propertyName: propertyName,
42
+ options: validationOptions,
43
+ validator: {
44
+ validate(value: any, args: ValidationArguments) {
45
+ if (value === undefined || value === null) return true; // Allow optional values
46
+ if (!Array.isArray(value)) return false;
47
+ return value.every(
48
+ (arr: any) => Array.isArray(arr) && arr.every(
49
+ (subArr: any) =>
50
+ (Array.isArray(subArr) && subArr.every(
51
+ (num: any) => Number.isInteger(num)
52
+ )) ||
53
+ Number.isInteger(subArr)
54
+ )
55
+ );
56
+ },
57
+ defaultMessage(args: ValidationArguments) {
58
+ return `${args.property} must be number[][] or number[][][]`;
59
+ }
60
+ }
61
+ });
62
+ };
63
+ }
64
+
65
+
66
+ // Custom decorator to validate nested arrays of numbers
67
+ export function IsNestedStringArray(validationOptions?: ValidationOptions) {
68
+ return function (object: Object, propertyName: string) {
69
+ registerDecorator({
70
+ name: 'isNestedStringArray',
71
+ target: object.constructor,
72
+ propertyName: propertyName,
73
+ options: validationOptions,
74
+ validator: {
75
+ validate(value: any, args: ValidationArguments) {
76
+ if (value === undefined || value === null) return true; // Allow optional values
77
+ if (!Array.isArray(value)) return false;
78
+ return value.every(
79
+ (arr: any) => Array.isArray(arr) && arr.every(
80
+ (subArr: any) =>
81
+ (Array.isArray(subArr) && subArr.every(
82
+ (num: any) => typeof num === 'string'
83
+ )) ||
84
+ typeof subArr === 'string'
85
+ )
86
+ );
87
+ },
88
+ defaultMessage(args: ValidationArguments) {
89
+ return `${args.property} must be string[][] or string[][][]`;
90
+ }
91
+ }
92
+ });
93
+ };
94
+ }
@@ -1,5 +1,5 @@
1
1
  import { IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsArray, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { BuildingPropertiesAbridged } from "./BuildingPropertiesAbridged";
4
4
  import { IDdBaseModel } from "honeybee-schema";
5
5
  import { RoofSpecification } from "./RoofSpecification";
@@ -83,14 +83,14 @@ export class Building extends IDdBaseModel {
83
83
  data["unique_stories"] = this.unique_stories;
84
84
  data["room_3ds"] = this.room_3ds;
85
85
  data["roof"] = this.roof;
86
- super.toJSON(data);
87
- return data;
86
+ data = super.toJSON(data);
87
+ return instanceToPlain(data);
88
88
  }
89
89
 
90
90
  async validate(): Promise<boolean> {
91
91
  const errors = await validate(this);
92
92
  if (errors.length > 0){
93
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
93
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
94
94
  throw new Error(`Validation failed: ${errorMessages}`);
95
95
  }
96
96
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
 
5
5
  /** 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. */
@@ -50,14 +50,14 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
50
50
 
51
51
  data["type"] = this.type;
52
52
  data["construction_set"] = this.construction_set;
53
- super.toJSON(data);
54
- return data;
53
+ data = super.toJSON(data);
54
+ return instanceToPlain(data);
55
55
  }
56
56
 
57
57
  async validate(): Promise<boolean> {
58
58
  const errors = await validate(this);
59
59
  if (errors.length > 0){
60
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
60
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
61
61
  throw new Error(`Validation failed: ${errorMessages}`);
62
62
  }
63
63
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
  import { BuildingEnergyPropertiesAbridged } from "./BuildingEnergyPropertiesAbridged";
5
5
  import { BuildingRadiancePropertiesAbridged } from "./BuildingRadiancePropertiesAbridged";
@@ -58,14 +58,14 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel {
58
58
  data["type"] = this.type;
59
59
  data["energy"] = this.energy;
60
60
  data["radiance"] = this.radiance;
61
- super.toJSON(data);
62
- return data;
61
+ data = super.toJSON(data);
62
+ return instanceToPlain(data);
63
63
  }
64
64
 
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
 
5
5
  /** 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. */
@@ -48,14 +48,14 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
48
48
 
49
49
  data["type"] = this.type;
50
50
  data["modifier_set"] = this.modifier_set;
51
- super.toJSON(data);
52
- return data;
51
+ data = super.toJSON(data);
52
+ return instanceToPlain(data);
53
53
  }
54
54
 
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsArray, IsDefined, IsInstance, ValidateNested, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { ContextShadePropertiesAbridged } from "./ContextShadePropertiesAbridged";
4
4
  import { Face3D } from "honeybee-schema";
5
5
  import { IDdBaseModel } from "honeybee-schema";
@@ -68,14 +68,14 @@ export class ContextShade extends IDdBaseModel {
68
68
  data["properties"] = this.properties;
69
69
  data["type"] = this.type;
70
70
  data["is_detached"] = this.is_detached;
71
- super.toJSON(data);
72
- return data;
71
+ data = super.toJSON(data);
72
+ return instanceToPlain(data);
73
73
  }
74
74
 
75
75
  async validate(): Promise<boolean> {
76
76
  const errors = await validate(this);
77
77
  if (errors.length > 0){
78
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
78
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
79
79
  throw new Error(`Validation failed: ${errorMessages}`);
80
80
  }
81
81
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
 
5
5
  /** 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. */
@@ -59,14 +59,14 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
59
59
  data["type"] = this.type;
60
60
  data["construction"] = this.construction;
61
61
  data["transmittance_schedule"] = this.transmittance_schedule;
62
- super.toJSON(data);
63
- return data;
62
+ data = super.toJSON(data);
63
+ return instanceToPlain(data);
64
64
  }
65
65
 
66
66
  async validate(): Promise<boolean> {
67
67
  const errors = await validate(this);
68
68
  if (errors.length > 0){
69
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
69
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
70
70
  throw new Error(`Validation failed: ${errorMessages}`);
71
71
  }
72
72
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
  import { ContextShadeEnergyPropertiesAbridged } from "./ContextShadeEnergyPropertiesAbridged";
5
5
  import { ContextShadeRadiancePropertiesAbridged } from "./ContextShadeRadiancePropertiesAbridged";
@@ -58,14 +58,14 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel {
58
58
  data["type"] = this.type;
59
59
  data["energy"] = this.energy;
60
60
  data["radiance"] = this.radiance;
61
- super.toJSON(data);
62
- return data;
61
+ data = super.toJSON(data);
62
+ return instanceToPlain(data);
63
63
  }
64
64
 
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
 
5
5
  /** 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. */
@@ -48,14 +48,14 @@ export class ContextShadeRadiancePropertiesAbridged extends _OpenAPIGenBaseModel
48
48
 
49
49
  data["type"] = this.type;
50
50
  data["modifier"] = this.modifier;
51
- super.toJSON(data);
52
- return data;
51
+ data = super.toJSON(data);
52
+ return instanceToPlain(data);
53
53
  }
54
54
 
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -1,17 +1,12 @@
1
- import { IsArray, ValidateNested, IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
1
+ import { IsArray, IsDefined, 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";
3
4
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
5
 
5
6
  /** Several detailed skylights defined by 2D Polygons (lists of 2D vertices). */
6
7
  export class DetailedSkylights extends _OpenAPIGenBaseModel {
7
8
  @IsArray()
8
- @IsArray({ each: true })
9
- @ValidateNested({each: true })
10
- @Type(() => Array)
11
- @IsArray({ each: true })
12
- @ValidateNested({each: true })
13
- @Type(() => Array)
14
- @IsNumber({},{ each: true })
9
+ @IsNestedNumberArray()
15
10
  @IsDefined()
16
11
  /** An array of arrays with each sub-array representing a polygonal boundary of a skylight. Each sub-array should consist of arrays representing points, which contain 2 values for 2D coordinates in the world XY system. These coordinate values should lie within the parent Room2D Polygon. */
17
12
  polygons!: number [] [] [];
@@ -63,14 +58,14 @@ export class DetailedSkylights extends _OpenAPIGenBaseModel {
63
58
  data["polygons"] = this.polygons;
64
59
  data["type"] = this.type;
65
60
  data["are_doors"] = this.are_doors;
66
- super.toJSON(data);
67
- return data;
61
+ data = super.toJSON(data);
62
+ return instanceToPlain(data);
68
63
  }
69
64
 
70
65
  async validate(): Promise<boolean> {
71
66
  const errors = await validate(this);
72
67
  if (errors.length > 0){
73
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
74
69
  throw new Error(`Validation failed: ${errorMessages}`);
75
70
  }
76
71
  return true;
@@ -1,17 +1,12 @@
1
- import { IsArray, ValidateNested, IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
1
+ import { IsArray, IsDefined, 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";
3
4
  import { _WindowParameterBase } from "./_WindowParameterBase";
4
5
 
5
6
  /** Several detailed windows defined by 2D Polygons (lists of 2D vertices). */
6
7
  export class DetailedWindows extends _WindowParameterBase {
7
8
  @IsArray()
8
- @IsArray({ each: true })
9
- @ValidateNested({each: true })
10
- @Type(() => Array)
11
- @IsArray({ each: true })
12
- @ValidateNested({each: true })
13
- @Type(() => Array)
14
- @IsNumber({},{ each: true })
9
+ @IsNestedNumberArray()
15
10
  @IsDefined()
16
11
  /** An array of arrays with each sub-array representing a polygonal boundary of a window. Each sub-array should consist of arrays representing points, which can either contain 2 values (indicating they are 2D vertices within the plane of a parent wall segment) or they can contain 3 values (indicating they are 3D world coordinates). For 2D points, 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 point in the polygon should always be positive. Some sample code to convert from 2D vertices to 2D vertices in the plane of the wall can be found here: https://www.ladybug.tools/dragonfly-core/docs/dragonfly.windowparameter.html#dragonfly.windowparameter.DetailedWindows */
17
12
  polygons!: number [] [] [];
@@ -63,14 +58,14 @@ export class DetailedWindows extends _WindowParameterBase {
63
58
  data["polygons"] = this.polygons;
64
59
  data["type"] = this.type;
65
60
  data["are_doors"] = this.are_doors;
66
- super.toJSON(data);
67
- return data;
61
+ data = super.toJSON(data);
62
+ return instanceToPlain(data);
68
63
  }
69
64
 
70
65
  async validate(): Promise<boolean> {
71
66
  const errors = await validate(this);
72
67
  if (errors.length > 0){
73
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
74
69
  throw new Error(`Validation failed: ${errorMessages}`);
75
70
  }
76
71
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, IsNumber, IsEnum, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _GridParameterBase } from "./_GridParameterBase";
4
4
  import { ExteriorApertureType } from "./ExteriorApertureType";
5
5
 
@@ -59,14 +59,14 @@ export class ExteriorApertureGridParameter extends _GridParameterBase {
59
59
  data["type"] = this.type;
60
60
  data["offset"] = this.offset;
61
61
  data["aperture_type"] = this.aperture_type;
62
- super.toJSON(data);
63
- return data;
62
+ data = super.toJSON(data);
63
+ return instanceToPlain(data);
64
64
  }
65
65
 
66
66
  async validate(): Promise<boolean> {
67
67
  const errors = await validate(this);
68
68
  if (errors.length > 0){
69
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
69
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
70
70
  throw new Error(`Validation failed: ${errorMessages}`);
71
71
  }
72
72
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, IsNumber, IsEnum, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _GridParameterBase } from "./_GridParameterBase";
4
4
  import { ExteriorFaceType } from "./ExteriorFaceType";
5
5
 
@@ -67,14 +67,14 @@ export class ExteriorFaceGridParameter extends _GridParameterBase {
67
67
  data["offset"] = this.offset;
68
68
  data["face_type"] = this.face_type;
69
69
  data["punched_geometry"] = this.punched_geometry;
70
- super.toJSON(data);
71
- return data;
70
+ data = super.toJSON(data);
71
+ return instanceToPlain(data);
72
72
  }
73
73
 
74
74
  async validate(): Promise<boolean> {
75
75
  const errors = await validate(this);
76
76
  if (errors.length > 0){
77
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
77
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
78
78
  throw new Error(`Validation failed: ${errorMessages}`);
79
79
  }
80
80
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
 
5
5
  /** Extruded borders over all windows in the wall. */
@@ -48,14 +48,14 @@ export class ExtrudedBorder extends _OpenAPIGenBaseModel {
48
48
 
49
49
  data["depth"] = this.depth;
50
50
  data["type"] = this.type;
51
- super.toJSON(data);
52
- return data;
51
+ data = super.toJSON(data);
52
+ return instanceToPlain(data);
53
53
  }
54
54
 
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
  import { Autocalculate } from "honeybee-schema";
5
5
 
@@ -56,14 +56,14 @@ export class GriddedSkylightArea extends _OpenAPIGenBaseModel {
56
56
  data["skylight_area"] = this.skylight_area;
57
57
  data["type"] = this.type;
58
58
  data["spacing"] = this.spacing;
59
- super.toJSON(data);
60
- return data;
59
+ data = super.toJSON(data);
60
+ return instanceToPlain(data);
61
61
  }
62
62
 
63
63
  async validate(): Promise<boolean> {
64
64
  const errors = await validate(this);
65
65
  if (errors.length > 0){
66
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
67
  throw new Error(`Validation failed: ${errorMessages}`);
68
68
  }
69
69
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
  import { Autocalculate } from "honeybee-schema";
5
5
 
@@ -56,14 +56,14 @@ export class GriddedSkylightRatio extends _OpenAPIGenBaseModel {
56
56
  data["skylight_ratio"] = this.skylight_ratio;
57
57
  data["type"] = this.type;
58
58
  data["spacing"] = this.spacing;
59
- super.toJSON(data);
60
- return data;
59
+ data = super.toJSON(data);
60
+ return instanceToPlain(data);
61
61
  }
62
62
 
63
63
  async validate(): Promise<boolean> {
64
64
  const errors = await validate(this);
65
65
  if (errors.length > 0){
66
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
67
  throw new Error(`Validation failed: ${errorMessages}`);
68
68
  }
69
69
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsInt, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _LouversBase } from "./_LouversBase";
4
4
 
5
5
  /** A specific number of louvered Shades over a wall. */
@@ -48,14 +48,14 @@ export class LouversByCount extends _LouversBase {
48
48
 
49
49
  data["louver_count"] = this.louver_count;
50
50
  data["type"] = this.type;
51
- super.toJSON(data);
52
- return data;
51
+ data = super.toJSON(data);
52
+ return instanceToPlain(data);
53
53
  }
54
54
 
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsNumber, IsDefined, IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _LouversBase } from "./_LouversBase";
4
4
 
5
5
  /** A series of louvered Shades at a given distance between each louver. */
@@ -48,14 +48,14 @@ export class LouversByDistance extends _LouversBase {
48
48
 
49
49
  data["distance"] = this.distance;
50
50
  data["type"] = this.type;
51
- super.toJSON(data);
52
- return data;
51
+ data = super.toJSON(data);
52
+ return instanceToPlain(data);
53
53
  }
54
54
 
55
55
  async validate(): Promise<boolean> {
56
56
  const errors = await validate(this);
57
57
  if (errors.length > 0){
58
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
59
  throw new Error(`Validation failed: ${errorMessages}`);
60
60
  }
61
61
  return true;
package/models/Model.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsArray, IsEnum, IsNumber, Min, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { Building } from "./Building";
4
4
  import { ContextShade } from "./ContextShade";
5
5
  import { IDdBaseModel } from "honeybee-schema";
@@ -110,14 +110,14 @@ export class Model extends IDdBaseModel {
110
110
  data["units"] = this.units;
111
111
  data["tolerance"] = this.tolerance;
112
112
  data["angle_tolerance"] = this.angle_tolerance;
113
- super.toJSON(data);
114
- return data;
113
+ data = super.toJSON(data);
114
+ return instanceToPlain(data);
115
115
  }
116
116
 
117
117
  async validate(): Promise<boolean> {
118
118
  const errors = await validate(this);
119
119
  if (errors.length > 0){
120
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
120
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
121
121
  throw new Error(`Validation failed: ${errorMessages}`);
122
122
  }
123
123
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, IsInstance, ValidateNested, IsArray, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
  import { AirBoundaryConstruction } from "honeybee-schema";
5
5
  import { AirBoundaryConstructionAbridged } from "honeybee-schema";
@@ -591,14 +591,14 @@ export class ModelEnergyProperties extends _OpenAPIGenBaseModel {
591
591
  data["program_types"] = this.program_types;
592
592
  data["schedules"] = this.schedules;
593
593
  data["schedule_type_limits"] = this.schedule_type_limits;
594
- super.toJSON(data);
595
- return data;
594
+ data = super.toJSON(data);
595
+ return instanceToPlain(data);
596
596
  }
597
597
 
598
598
  async validate(): Promise<boolean> {
599
599
  const errors = await validate(this);
600
600
  if (errors.length > 0){
601
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
601
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
602
602
  throw new Error(`Validation failed: ${errorMessages}`);
603
603
  }
604
604
  return true;
@@ -1,5 +1,5 @@
1
1
  import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator';
2
- import { Type, plainToClass } from 'class-transformer';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
3
  import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
4
  import { ModelEnergyProperties } from "./ModelEnergyProperties";
5
5
  import { ModelRadianceProperties } from "./ModelRadianceProperties";
@@ -58,14 +58,14 @@ export class ModelProperties extends _OpenAPIGenBaseModel {
58
58
  data["type"] = this.type;
59
59
  data["energy"] = this.energy;
60
60
  data["radiance"] = this.radiance;
61
- super.toJSON(data);
62
- return data;
61
+ data = super.toJSON(data);
62
+ return instanceToPlain(data);
63
63
  }
64
64
 
65
65
  async validate(): Promise<boolean> {
66
66
  const errors = await validate(this);
67
67
  if (errors.length > 0){
68
- const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error.property]).join(', ')).join('; ');
68
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
69
69
  throw new Error(`Validation failed: ${errorMessages}`);
70
70
  }
71
71
  return true;