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,71 @@
1
+ import { IsNumber, IsDefined, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _WindowParameterBase } from "./_WindowParameterBase";
4
+
5
+ /** A single window defined by an area ratio with the base surface. */
6
+ export class SimpleWindowRatio 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
+ @IsString()
13
+ @IsOptional()
14
+ @Matches(/^SimpleWindowRatio$/)
15
+ type?: string;
16
+
17
+ @IsBoolean()
18
+ @IsOptional()
19
+ /** Boolean to note whether rectangular portions of base Face should be extracted before scaling them to create apertures. For pentagonal gabled geometries, this results in one rectangle and one triangle, which can often look more realistic and is a better input for engines like EnergyPlus that cannot model windows with more than 4 vertices. However, if a single pentagonal window is desired for such a gabled shape, this input can be set to False to produce such a result. */
20
+ rect_split?: boolean;
21
+
22
+
23
+ constructor() {
24
+ super();
25
+ this.type = "SimpleWindowRatio";
26
+ this.rect_split = true;
27
+ }
28
+
29
+
30
+ override init(_data?: any) {
31
+ super.init(_data);
32
+ if (_data) {
33
+ const obj = plainToClass(SimpleWindowRatio, _data);
34
+ this.window_ratio = obj.window_ratio;
35
+ this.type = obj.type;
36
+ this.rect_split = obj.rect_split;
37
+ }
38
+ }
39
+
40
+
41
+ static override fromJS(data: any): SimpleWindowRatio {
42
+ data = typeof data === 'object' ? data : {};
43
+
44
+ let result = new SimpleWindowRatio();
45
+ result.init(data);
46
+ return result;
47
+ }
48
+
49
+ override toJSON(data?: any) {
50
+ data = typeof data === 'object' ? data : {};
51
+ for (var property in this) {
52
+ if (this.hasOwnProperty(property))
53
+ data[property] = this[property];
54
+ }
55
+
56
+ data["window_ratio"] = this.window_ratio;
57
+ data["type"] = this.type;
58
+ data["rect_split"] = this.rect_split;
59
+ data = super.toJSON(data);
60
+ return instanceToPlain(data);
61
+ }
62
+
63
+ async validate(): Promise<boolean> {
64
+ const errors = await validate(this);
65
+ if (errors.length > 0){
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
+ throw new Error(`Validation failed: ${errorMessages}`);
68
+ }
69
+ return true;
70
+ }
71
+ }
@@ -0,0 +1,78 @@
1
+ import { IsNumber, IsDefined, 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
+ /** A single window in the wall center defined by a width * height. */
6
+ export class SingleWindow extends _WindowParameterBase {
7
+ @IsNumber()
8
+ @IsDefined()
9
+ /** A number for the window width. Note that, if this width is applied to a wall that is too narrow for this width, the generated window will automatically be shortened when it is applied to the wall. In this way, setting the width to be `float(""inf"")` will create parameters that always generate a ribbon window. */
10
+ width!: number;
11
+
12
+ @IsNumber()
13
+ @IsDefined()
14
+ /** A number for the window height. Note that, if this height is applied to a wall that is too short for this height, the generated window will automatically be shortened when it is applied to the wall. */
15
+ height!: number;
16
+
17
+ @IsString()
18
+ @IsOptional()
19
+ @Matches(/^SingleWindow$/)
20
+ type?: string;
21
+
22
+ @IsNumber()
23
+ @IsOptional()
24
+ /** A number for the window sill height. */
25
+ sill_height?: number;
26
+
27
+
28
+ constructor() {
29
+ super();
30
+ this.type = "SingleWindow";
31
+ this.sill_height = 1;
32
+ }
33
+
34
+
35
+ override init(_data?: any) {
36
+ super.init(_data);
37
+ if (_data) {
38
+ const obj = plainToClass(SingleWindow, _data);
39
+ this.width = obj.width;
40
+ this.height = obj.height;
41
+ this.type = obj.type;
42
+ this.sill_height = obj.sill_height;
43
+ }
44
+ }
45
+
46
+
47
+ static override fromJS(data: any): SingleWindow {
48
+ data = typeof data === 'object' ? data : {};
49
+
50
+ let result = new SingleWindow();
51
+ result.init(data);
52
+ return result;
53
+ }
54
+
55
+ override toJSON(data?: any) {
56
+ data = typeof data === 'object' ? data : {};
57
+ for (var property in this) {
58
+ if (this.hasOwnProperty(property))
59
+ data[property] = this[property];
60
+ }
61
+
62
+ data["width"] = this.width;
63
+ data["height"] = this.height;
64
+ data["type"] = this.type;
65
+ data["sill_height"] = this.sill_height;
66
+ data = super.toJSON(data);
67
+ return instanceToPlain(data);
68
+ }
69
+
70
+ async validate(): Promise<boolean> {
71
+ const errors = await validate(this);
72
+ if (errors.length > 0){
73
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
74
+ throw new Error(`Validation failed: ${errorMessages}`);
75
+ }
76
+ return true;
77
+ }
78
+ }
@@ -0,0 +1,111 @@
1
+ import { IsArray, IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsInt, Min, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { Autocalculate } from "honeybee-schema";
4
+ import { IDdBaseModel } from "honeybee-schema";
5
+ import { RoofSpecification } from "./RoofSpecification";
6
+ import { Room2D } from "./Room2D";
7
+ import { StoryPropertiesAbridged } from "./StoryPropertiesAbridged";
8
+
9
+ /** Base class for all objects requiring a identifiers acceptable for all engines. */
10
+ export class Story extends IDdBaseModel {
11
+ @IsArray()
12
+ @IsInstance(Room2D, { each: true })
13
+ @Type(() => Room2D)
14
+ @ValidateNested({ each: true })
15
+ @IsDefined()
16
+ /** An array of dragonfly Room2D objects that together form an entire story of a building. */
17
+ room_2ds!: Room2D [];
18
+
19
+ @IsInstance(StoryPropertiesAbridged)
20
+ @Type(() => StoryPropertiesAbridged)
21
+ @ValidateNested()
22
+ @IsDefined()
23
+ /** Extension properties for particular simulation engines (Radiance, EnergyPlus). */
24
+ properties!: StoryPropertiesAbridged;
25
+
26
+ @IsString()
27
+ @IsOptional()
28
+ @Matches(/^Story$/)
29
+ type?: string;
30
+
31
+ @IsOptional()
32
+ /** A number for the distance from the floor plate of this story to the floor of the story above this one (if it exists). If Autocalculate, this value will be the maximum floor_to_ceiling_height of the input room_2ds. */
33
+ floor_to_floor_height?: (Autocalculate | number);
34
+
35
+ @IsOptional()
36
+ /** A number to indicate the height of the floor plane in the Z axis.If Autocalculate, this will be the minimum floor height of all the room_2ds, which is suitable for cases where there are no floor plenums. */
37
+ floor_height?: (Autocalculate | number);
38
+
39
+ @IsInt()
40
+ @IsOptional()
41
+ @Min(1)
42
+ /** An integer that denotes the number of times that this Story is repeated over the height of the building. */
43
+ multiplier?: number;
44
+
45
+ @IsInstance(RoofSpecification)
46
+ @Type(() => RoofSpecification)
47
+ @ValidateNested()
48
+ @IsOptional()
49
+ /** An optional RoofSpecification object containing geometry for generating sloped roofs over the Story. The RoofSpecification will only affect the child Room2Ds that have a True is_top_exposed property and it will only be utilized in translation to Honeybee when the Story multiplier is 1. If None, all Room2D ceilings will be flat. */
50
+ roof?: RoofSpecification;
51
+
52
+
53
+ constructor() {
54
+ super();
55
+ this.type = "Story";
56
+ this.floor_to_floor_height = new Autocalculate();
57
+ this.floor_height = new Autocalculate();
58
+ this.multiplier = 1;
59
+ }
60
+
61
+
62
+ override init(_data?: any) {
63
+ super.init(_data);
64
+ if (_data) {
65
+ const obj = plainToClass(Story, _data);
66
+ this.room_2ds = obj.room_2ds;
67
+ this.properties = obj.properties;
68
+ this.type = obj.type;
69
+ this.floor_to_floor_height = obj.floor_to_floor_height;
70
+ this.floor_height = obj.floor_height;
71
+ this.multiplier = obj.multiplier;
72
+ this.roof = obj.roof;
73
+ }
74
+ }
75
+
76
+
77
+ static override fromJS(data: any): Story {
78
+ data = typeof data === 'object' ? data : {};
79
+
80
+ let result = new Story();
81
+ result.init(data);
82
+ return result;
83
+ }
84
+
85
+ override toJSON(data?: any) {
86
+ data = typeof data === 'object' ? data : {};
87
+ for (var property in this) {
88
+ if (this.hasOwnProperty(property))
89
+ data[property] = this[property];
90
+ }
91
+
92
+ data["room_2ds"] = this.room_2ds;
93
+ data["properties"] = this.properties;
94
+ data["type"] = this.type;
95
+ data["floor_to_floor_height"] = this.floor_to_floor_height;
96
+ data["floor_height"] = this.floor_height;
97
+ data["multiplier"] = this.multiplier;
98
+ data["roof"] = this.roof;
99
+ data = super.toJSON(data);
100
+ return instanceToPlain(data);
101
+ }
102
+
103
+ async validate(): Promise<boolean> {
104
+ const errors = await validate(this);
105
+ if (errors.length > 0){
106
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
107
+ throw new Error(`Validation failed: ${errorMessages}`);
108
+ }
109
+ return true;
110
+ }
111
+ }
@@ -0,0 +1,65 @@
1
+ import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+
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. */
6
+ export class StoryEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
7
+ @IsString()
8
+ @IsOptional()
9
+ @Matches(/^StoryEnergyPropertiesAbridged$/)
10
+ type?: string;
11
+
12
+ @IsString()
13
+ @IsOptional()
14
+ @MinLength(1)
15
+ @MaxLength(100)
16
+ /** Name of a ConstructionSet to specify all constructions for the Story. If None, the Story will use the Building construction_set or the Model global_construction_set. Any ConstructionSet assigned here will override those assigned to these objects. */
17
+ construction_set?: string;
18
+
19
+
20
+ constructor() {
21
+ super();
22
+ this.type = "StoryEnergyPropertiesAbridged";
23
+ }
24
+
25
+
26
+ override init(_data?: any) {
27
+ super.init(_data);
28
+ if (_data) {
29
+ const obj = plainToClass(StoryEnergyPropertiesAbridged, _data);
30
+ this.type = obj.type;
31
+ this.construction_set = obj.construction_set;
32
+ }
33
+ }
34
+
35
+
36
+ static override fromJS(data: any): StoryEnergyPropertiesAbridged {
37
+ data = typeof data === 'object' ? data : {};
38
+
39
+ let result = new StoryEnergyPropertiesAbridged();
40
+ result.init(data);
41
+ return result;
42
+ }
43
+
44
+ override toJSON(data?: any) {
45
+ data = typeof data === 'object' ? data : {};
46
+ for (var property in this) {
47
+ if (this.hasOwnProperty(property))
48
+ data[property] = this[property];
49
+ }
50
+
51
+ data["type"] = this.type;
52
+ data["construction_set"] = this.construction_set;
53
+ data = super.toJSON(data);
54
+ return instanceToPlain(data);
55
+ }
56
+
57
+ async validate(): Promise<boolean> {
58
+ const errors = await validate(this);
59
+ if (errors.length > 0){
60
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
61
+ throw new Error(`Validation failed: ${errorMessages}`);
62
+ }
63
+ return true;
64
+ }
65
+ }
@@ -0,0 +1,73 @@
1
+ import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+ import { StoryEnergyPropertiesAbridged } from "./StoryEnergyPropertiesAbridged";
5
+ import { StoryRadiancePropertiesAbridged } from "./StoryRadiancePropertiesAbridged";
6
+
7
+ export class StoryPropertiesAbridged extends _OpenAPIGenBaseModel {
8
+ @IsString()
9
+ @IsOptional()
10
+ @Matches(/^StoryPropertiesAbridged$/)
11
+ type?: string;
12
+
13
+ @IsInstance(StoryEnergyPropertiesAbridged)
14
+ @Type(() => StoryEnergyPropertiesAbridged)
15
+ @ValidateNested()
16
+ @IsOptional()
17
+ energy?: StoryEnergyPropertiesAbridged;
18
+
19
+ @IsInstance(StoryRadiancePropertiesAbridged)
20
+ @Type(() => StoryRadiancePropertiesAbridged)
21
+ @ValidateNested()
22
+ @IsOptional()
23
+ radiance?: StoryRadiancePropertiesAbridged;
24
+
25
+
26
+ constructor() {
27
+ super();
28
+ this.type = "StoryPropertiesAbridged";
29
+ }
30
+
31
+
32
+ override init(_data?: any) {
33
+ super.init(_data);
34
+ if (_data) {
35
+ const obj = plainToClass(StoryPropertiesAbridged, _data);
36
+ this.type = obj.type;
37
+ this.energy = obj.energy;
38
+ this.radiance = obj.radiance;
39
+ }
40
+ }
41
+
42
+
43
+ static override fromJS(data: any): StoryPropertiesAbridged {
44
+ data = typeof data === 'object' ? data : {};
45
+
46
+ let result = new StoryPropertiesAbridged();
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["type"] = this.type;
59
+ data["energy"] = this.energy;
60
+ data["radiance"] = this.radiance;
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,63 @@
1
+ import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+
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. */
6
+ export class StoryRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
7
+ @IsString()
8
+ @IsOptional()
9
+ @Matches(/^StoryRadiancePropertiesAbridged$/)
10
+ type?: string;
11
+
12
+ @IsString()
13
+ @IsOptional()
14
+ /** Name of a ModifierSet to specify all modifiers for the Story. If None, the Story will use the Building modifier_set or the Model global_modifier_set. Any ModifierSet assigned here will override those assigned to the parent objects. */
15
+ modifier_set?: string;
16
+
17
+
18
+ constructor() {
19
+ super();
20
+ this.type = "StoryRadiancePropertiesAbridged";
21
+ }
22
+
23
+
24
+ override init(_data?: any) {
25
+ super.init(_data);
26
+ if (_data) {
27
+ const obj = plainToClass(StoryRadiancePropertiesAbridged, _data);
28
+ this.type = obj.type;
29
+ this.modifier_set = obj.modifier_set;
30
+ }
31
+ }
32
+
33
+
34
+ static override fromJS(data: any): StoryRadiancePropertiesAbridged {
35
+ data = typeof data === 'object' ? data : {};
36
+
37
+ let result = new StoryRadiancePropertiesAbridged();
38
+ result.init(data);
39
+ return result;
40
+ }
41
+
42
+ override toJSON(data?: any) {
43
+ data = typeof data === 'object' ? data : {};
44
+ for (var property in this) {
45
+ if (this.hasOwnProperty(property))
46
+ data[property] = this[property];
47
+ }
48
+
49
+ data["type"] = this.type;
50
+ data["modifier_set"] = this.modifier_set;
51
+ data = super.toJSON(data);
52
+ return instanceToPlain(data);
53
+ }
54
+
55
+ async validate(): Promise<boolean> {
56
+ const errors = await validate(this);
57
+ if (errors.length > 0){
58
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
59
+ throw new Error(`Validation failed: ${errorMessages}`);
60
+ }
61
+ return true;
62
+ }
63
+ }
@@ -0,0 +1,71 @@
1
+ import { IsNumber, IsDefined, IsBoolean, IsOptional, IsString, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+
5
+ /** Base object for all GridParameters. */
6
+ export class _GridParameterBase extends _OpenAPIGenBaseModel {
7
+ @IsNumber()
8
+ @IsDefined()
9
+ /** The dimension of the grid cells as a number. */
10
+ dimension!: number;
11
+
12
+ @IsBoolean()
13
+ @IsOptional()
14
+ /** A boolean to note whether the resulting SensorGrid should include the mesh. */
15
+ include_mesh?: boolean;
16
+
17
+ @IsString()
18
+ @IsOptional()
19
+ @Matches(/^_GridParameterBase$/)
20
+ type?: string;
21
+
22
+
23
+ constructor() {
24
+ super();
25
+ this.include_mesh = true;
26
+ this.type = "_GridParameterBase";
27
+ }
28
+
29
+
30
+ override init(_data?: any) {
31
+ super.init(_data);
32
+ if (_data) {
33
+ const obj = plainToClass(_GridParameterBase, _data);
34
+ this.dimension = obj.dimension;
35
+ this.include_mesh = obj.include_mesh;
36
+ this.type = obj.type;
37
+ }
38
+ }
39
+
40
+
41
+ static override fromJS(data: any): _GridParameterBase {
42
+ data = typeof data === 'object' ? data : {};
43
+
44
+ let result = new _GridParameterBase();
45
+ result.init(data);
46
+ return result;
47
+ }
48
+
49
+ override toJSON(data?: any) {
50
+ data = typeof data === 'object' ? data : {};
51
+ for (var property in this) {
52
+ if (this.hasOwnProperty(property))
53
+ data[property] = this[property];
54
+ }
55
+
56
+ data["dimension"] = this.dimension;
57
+ data["include_mesh"] = this.include_mesh;
58
+ data["type"] = this.type;
59
+ data = super.toJSON(data);
60
+ return instanceToPlain(data);
61
+ }
62
+
63
+ async validate(): Promise<boolean> {
64
+ const errors = await validate(this);
65
+ if (errors.length > 0){
66
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
67
+ throw new Error(`Validation failed: ${errorMessages}`);
68
+ }
69
+ return true;
70
+ }
71
+ }
@@ -0,0 +1,99 @@
1
+ import { IsNumber, IsDefined, IsOptional, Min, Max, IsArray, IsBoolean, IsString, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+ import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
4
+
5
+ /** Base class for for a series of louvered shades over a wall. */
6
+ export class _LouversBase extends _OpenAPIGenBaseModel {
7
+ @IsNumber()
8
+ @IsDefined()
9
+ /** A number for the depth to extrude the louvers. */
10
+ depth!: number;
11
+
12
+ @IsNumber()
13
+ @IsOptional()
14
+ @Min(0)
15
+ /** A number for the distance to louvers from the wall. */
16
+ offset?: number;
17
+
18
+ @IsNumber()
19
+ @IsOptional()
20
+ @Min(-90)
21
+ @Max(90)
22
+ /** A number between -90 and 90 for the for an angle to rotate the louvers in degrees. 0 indicates louvers perpendicular to the wall. Positive values indicate a downward rotation. Negative values indicate an upward rotation. */
23
+ angle?: number;
24
+
25
+ @IsArray()
26
+ @IsNumber({},{ each: true })
27
+ @IsOptional()
28
+ /** A list of two float values representing the (x, y) of a 2D vector for the direction along which contours are generated. (0, 1) will generate horizontal contours, (1, 0) will generate vertical contours, and (1, 1) will generate diagonal contours. */
29
+ contour_vector?: number [];
30
+
31
+ @IsBoolean()
32
+ @IsOptional()
33
+ /** Boolean to note whether the side the louvers start from should be flipped. Default is False to have contours on top or right. Setting to True will start contours on the bottom or left. */
34
+ flip_start_side?: boolean;
35
+
36
+ @IsString()
37
+ @IsOptional()
38
+ @Matches(/^_LouversBase$/)
39
+ type?: string;
40
+
41
+
42
+ constructor() {
43
+ super();
44
+ this.offset = 0;
45
+ this.angle = 0;
46
+ this.contour_vector = [0, 1];
47
+ this.flip_start_side = false;
48
+ this.type = "_LouversBase";
49
+ }
50
+
51
+
52
+ override init(_data?: any) {
53
+ super.init(_data);
54
+ if (_data) {
55
+ const obj = plainToClass(_LouversBase, _data);
56
+ this.depth = obj.depth;
57
+ this.offset = obj.offset;
58
+ this.angle = obj.angle;
59
+ this.contour_vector = obj.contour_vector;
60
+ this.flip_start_side = obj.flip_start_side;
61
+ this.type = obj.type;
62
+ }
63
+ }
64
+
65
+
66
+ static override fromJS(data: any): _LouversBase {
67
+ data = typeof data === 'object' ? data : {};
68
+
69
+ let result = new _LouversBase();
70
+ result.init(data);
71
+ return result;
72
+ }
73
+
74
+ override toJSON(data?: any) {
75
+ data = typeof data === 'object' ? data : {};
76
+ for (var property in this) {
77
+ if (this.hasOwnProperty(property))
78
+ data[property] = this[property];
79
+ }
80
+
81
+ data["depth"] = this.depth;
82
+ data["offset"] = this.offset;
83
+ data["angle"] = this.angle;
84
+ data["contour_vector"] = this.contour_vector;
85
+ data["flip_start_side"] = this.flip_start_side;
86
+ data["type"] = this.type;
87
+ data = super.toJSON(data);
88
+ return instanceToPlain(data);
89
+ }
90
+
91
+ async validate(): Promise<boolean> {
92
+ const errors = await validate(this);
93
+ if (errors.length > 0){
94
+ const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
95
+ throw new Error(`Validation failed: ${errorMessages}`);
96
+ }
97
+ return true;
98
+ }
99
+ }
@@ -0,0 +1,38 @@
1
+ import { IsString, IsOptional, validate, ValidationError as TsValidationError } from 'class-validator';
2
+ import { Type, plainToClass, instanceToPlain } from 'class-transformer';
3
+
4
+ export abstract class _OpenAPIGenBaseModel {
5
+ @IsString()
6
+ @IsOptional()
7
+ /** A base class to use when there is no baseclass available to fall on. */
8
+ type?: string;
9
+
10
+
11
+ constructor() {
12
+ this.type = "InvalidType";
13
+ }
14
+
15
+
16
+ init(_data?: any) {
17
+ }
18
+
19
+
20
+ static fromJS(data: any): _OpenAPIGenBaseModel {
21
+ data = typeof data === 'object' ? data : {};
22
+
23
+ throw new Error("The abstract class '_OpenAPIGenBaseModel' cannot be instantiated.");
24
+ }
25
+
26
+ toJSON(data?: any) {
27
+ data = typeof data === 'object' ? data : {};
28
+ for (var property in this) {
29
+ if (this.hasOwnProperty(property))
30
+ data[property] = this[property];
31
+ }
32
+
33
+ data["type"] = this.type;
34
+ return Object.fromEntries(
35
+ Object.entries(data).filter(([_, v]) => v !== undefined));
36
+ }
37
+
38
+ }