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.
- package/helpers/class-validator.ts +94 -0
- package/index.ts +1 -0
- package/models/Building.ts +98 -0
- package/models/BuildingEnergyPropertiesAbridged.ts +65 -0
- package/models/BuildingPropertiesAbridged.ts +73 -0
- package/models/BuildingRadiancePropertiesAbridged.ts +63 -0
- package/models/ContextShade.ts +83 -0
- package/models/ContextShadeEnergyPropertiesAbridged.ts +74 -0
- package/models/ContextShadePropertiesAbridged.ts +73 -0
- package/models/ContextShadeRadiancePropertiesAbridged.ts +63 -0
- package/models/DetailedSkylights.ts +73 -0
- package/models/DetailedWindows.ts +73 -0
- package/models/ExteriorApertureGridParameter.ts +74 -0
- package/models/ExteriorApertureType.ts +8 -0
- package/models/ExteriorFaceGridParameter.ts +82 -0
- package/models/ExteriorFaceType.ts +9 -0
- package/models/ExtrudedBorder.ts +63 -0
- package/models/GriddedSkylightArea.ts +71 -0
- package/models/GriddedSkylightRatio.ts +71 -0
- package/models/LouversByCount.ts +63 -0
- package/models/LouversByDistance.ts +63 -0
- package/models/Model.ts +125 -0
- package/models/ModelEnergyProperties.ts +606 -0
- package/models/ModelProperties.ts +73 -0
- package/models/ModelRadianceProperties.ts +253 -0
- package/models/Overhang.ts +73 -0
- package/models/RectangularWindows.ts +89 -0
- package/models/RepeatingWindowRatio.ts +94 -0
- package/models/RoofSpecification.ts +67 -0
- package/models/Room2D.ts +166 -0
- package/models/Room2DEnergyPropertiesAbridged.ts +123 -0
- package/models/Room2DPropertiesAbridged.ts +73 -0
- package/models/Room2DRadiancePropertiesAbridged.ts +74 -0
- package/models/RoomGridParameter.ts +72 -0
- package/models/RoomRadialGridParameter.ts +80 -0
- package/models/SimpleWindowArea.ts +71 -0
- package/models/SimpleWindowRatio.ts +71 -0
- package/models/SingleWindow.ts +78 -0
- package/models/Story.ts +111 -0
- package/models/StoryEnergyPropertiesAbridged.ts +65 -0
- package/models/StoryPropertiesAbridged.ts +73 -0
- package/models/StoryRadiancePropertiesAbridged.ts +63 -0
- package/models/_GridParameterBase.ts +71 -0
- package/models/_LouversBase.ts +99 -0
- package/models/_OpenAPIGenBaseModel.ts +38 -0
- package/models/_WindowParameterBase.ts +62 -0
- package/models/index.ts +46 -0
- package/package.json +28 -0
- package/tsconfig.json +32 -0
- package/vite.config.ts +14 -0
|
@@ -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
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./models";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsArray, validate, ValidationError as TsValidationError } from 'class-validator';
|
|
2
|
+
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
|
|
3
|
+
import { BuildingPropertiesAbridged } from "./BuildingPropertiesAbridged";
|
|
4
|
+
import { IDdBaseModel } from "honeybee-schema";
|
|
5
|
+
import { RoofSpecification } from "./RoofSpecification";
|
|
6
|
+
import { Room } from "honeybee-schema";
|
|
7
|
+
import { Story } from "./Story";
|
|
8
|
+
|
|
9
|
+
/** Base class for all objects requiring a identifiers acceptable for all engines. */
|
|
10
|
+
export class Building extends IDdBaseModel {
|
|
11
|
+
@IsInstance(BuildingPropertiesAbridged)
|
|
12
|
+
@Type(() => BuildingPropertiesAbridged)
|
|
13
|
+
@ValidateNested()
|
|
14
|
+
@IsDefined()
|
|
15
|
+
/** Extension properties for particular simulation engines (Radiance, EnergyPlus). */
|
|
16
|
+
properties!: BuildingPropertiesAbridged;
|
|
17
|
+
|
|
18
|
+
@IsString()
|
|
19
|
+
@IsOptional()
|
|
20
|
+
@Matches(/^Building$/)
|
|
21
|
+
type?: string;
|
|
22
|
+
|
|
23
|
+
@IsArray()
|
|
24
|
+
@IsInstance(Story, { each: true })
|
|
25
|
+
@Type(() => Story)
|
|
26
|
+
@ValidateNested({ each: true })
|
|
27
|
+
@IsOptional()
|
|
28
|
+
/** An array of unique dragonfly Story objects that together form the entire building. Stories should generally be ordered from lowest floor to highest floor, though this is not required. Note that, if a given Story is repeated several times over the height of the building and this is represented by the multiplier, the unique story included in this list should be the first (lowest) story of the repeated floors. */
|
|
29
|
+
unique_stories?: Story [];
|
|
30
|
+
|
|
31
|
+
@IsArray()
|
|
32
|
+
@IsInstance(Room, { each: true })
|
|
33
|
+
@Type(() => Room)
|
|
34
|
+
@ValidateNested({ each: true })
|
|
35
|
+
@IsOptional()
|
|
36
|
+
/** An optional array of 3D Honeybee Room objects for additional Rooms that are a part of the Building but are not represented within the unique_stories. This is useful when there are parts of the Building geometry that cannot easily be represented with the extruded floor plate and sloped roof assumptions that underlie Dragonfly Room2Ds and RoofSpecification. Cases where this input is most useful include sloped walls and certain types of domed roofs that become tedious to implement with RoofSpecification. Matching the Honeybee Room.story property to the Dragonfly Story.display_name of an object within the unique_stories will effectively place the Honeybee Room on that Story for the purposes of floor_area, exterior_wall_area, etc. However, note that the Honeybee Room.multiplier property takes precedence over whatever multiplier is assigned to the Dragonfly Story that the Room.story may reference. (Default: None). */
|
|
37
|
+
room_3ds?: Room [];
|
|
38
|
+
|
|
39
|
+
@IsInstance(RoofSpecification)
|
|
40
|
+
@Type(() => RoofSpecification)
|
|
41
|
+
@ValidateNested()
|
|
42
|
+
@IsOptional()
|
|
43
|
+
/** An optional RoofSpecification object that provides an alternative way to describe roof geometry over rooms (instead of specifying roofs on each story). If trying to decide between the two, specifying geometry on each story is closer to how dragonfly natively works with roof geometry as it relates to rooms. However, when it is unknown which roof geometries correspond to which stories, this Building-level attribute may be used and each roof geometry will automatically be added to the best Story in the Building upon serialization to Python. This automatic assignment will happen by checking for overlaps between the Story Room2Ds and the Roof geometry in plan. When a given roof geometry overlaps with several Stories, the top-most Story will get the roof geometry assigned to it unless this top Story has a floor_height above the roof geometry, in which case the next highest story will be checked until a compatible one is found. */
|
|
44
|
+
roof?: RoofSpecification;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
this.type = "Building";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
override init(_data?: any) {
|
|
54
|
+
super.init(_data);
|
|
55
|
+
if (_data) {
|
|
56
|
+
const obj = plainToClass(Building, _data);
|
|
57
|
+
this.properties = obj.properties;
|
|
58
|
+
this.type = obj.type;
|
|
59
|
+
this.unique_stories = obj.unique_stories;
|
|
60
|
+
this.room_3ds = obj.room_3ds;
|
|
61
|
+
this.roof = obj.roof;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
static override fromJS(data: any): Building {
|
|
67
|
+
data = typeof data === 'object' ? data : {};
|
|
68
|
+
|
|
69
|
+
let result = new Building();
|
|
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["properties"] = this.properties;
|
|
82
|
+
data["type"] = this.type;
|
|
83
|
+
data["unique_stories"] = this.unique_stories;
|
|
84
|
+
data["room_3ds"] = this.room_3ds;
|
|
85
|
+
data["roof"] = this.roof;
|
|
86
|
+
data = super.toJSON(data);
|
|
87
|
+
return instanceToPlain(data);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async validate(): Promise<boolean> {
|
|
91
|
+
const errors = await validate(this);
|
|
92
|
+
if (errors.length > 0){
|
|
93
|
+
const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
|
|
94
|
+
throw new Error(`Validation failed: ${errorMessages}`);
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -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 BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
|
|
7
|
+
@IsString()
|
|
8
|
+
@IsOptional()
|
|
9
|
+
@Matches(/^BuildingEnergyPropertiesAbridged$/)
|
|
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 Building. If None, the Model global_construction_set will be used. */
|
|
17
|
+
construction_set?: string;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
this.type = "BuildingEnergyPropertiesAbridged";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
override init(_data?: any) {
|
|
27
|
+
super.init(_data);
|
|
28
|
+
if (_data) {
|
|
29
|
+
const obj = plainToClass(BuildingEnergyPropertiesAbridged, _data);
|
|
30
|
+
this.type = obj.type;
|
|
31
|
+
this.construction_set = obj.construction_set;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
static override fromJS(data: any): BuildingEnergyPropertiesAbridged {
|
|
37
|
+
data = typeof data === 'object' ? data : {};
|
|
38
|
+
|
|
39
|
+
let result = new BuildingEnergyPropertiesAbridged();
|
|
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 { BuildingEnergyPropertiesAbridged } from "./BuildingEnergyPropertiesAbridged";
|
|
5
|
+
import { BuildingRadiancePropertiesAbridged } from "./BuildingRadiancePropertiesAbridged";
|
|
6
|
+
|
|
7
|
+
export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel {
|
|
8
|
+
@IsString()
|
|
9
|
+
@IsOptional()
|
|
10
|
+
@Matches(/^BuildingPropertiesAbridged$/)
|
|
11
|
+
type?: string;
|
|
12
|
+
|
|
13
|
+
@IsInstance(BuildingEnergyPropertiesAbridged)
|
|
14
|
+
@Type(() => BuildingEnergyPropertiesAbridged)
|
|
15
|
+
@ValidateNested()
|
|
16
|
+
@IsOptional()
|
|
17
|
+
energy?: BuildingEnergyPropertiesAbridged;
|
|
18
|
+
|
|
19
|
+
@IsInstance(BuildingRadiancePropertiesAbridged)
|
|
20
|
+
@Type(() => BuildingRadiancePropertiesAbridged)
|
|
21
|
+
@ValidateNested()
|
|
22
|
+
@IsOptional()
|
|
23
|
+
radiance?: BuildingRadiancePropertiesAbridged;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.type = "BuildingPropertiesAbridged";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
override init(_data?: any) {
|
|
33
|
+
super.init(_data);
|
|
34
|
+
if (_data) {
|
|
35
|
+
const obj = plainToClass(BuildingPropertiesAbridged, _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): BuildingPropertiesAbridged {
|
|
44
|
+
data = typeof data === 'object' ? data : {};
|
|
45
|
+
|
|
46
|
+
let result = new BuildingPropertiesAbridged();
|
|
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 BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
|
|
7
|
+
@IsString()
|
|
8
|
+
@IsOptional()
|
|
9
|
+
@Matches(/^BuildingRadiancePropertiesAbridged$/)
|
|
10
|
+
type?: string;
|
|
11
|
+
|
|
12
|
+
@IsString()
|
|
13
|
+
@IsOptional()
|
|
14
|
+
/** Name of a ModifierSet to specify all modifiers for the Building. If None, the Model global_modifier_set will be used. */
|
|
15
|
+
modifier_set?: string;
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.type = "BuildingRadiancePropertiesAbridged";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
override init(_data?: any) {
|
|
25
|
+
super.init(_data);
|
|
26
|
+
if (_data) {
|
|
27
|
+
const obj = plainToClass(BuildingRadiancePropertiesAbridged, _data);
|
|
28
|
+
this.type = obj.type;
|
|
29
|
+
this.modifier_set = obj.modifier_set;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
static override fromJS(data: any): BuildingRadiancePropertiesAbridged {
|
|
35
|
+
data = typeof data === 'object' ? data : {};
|
|
36
|
+
|
|
37
|
+
let result = new BuildingRadiancePropertiesAbridged();
|
|
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,83 @@
|
|
|
1
|
+
import { IsArray, IsDefined, IsInstance, ValidateNested, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
|
|
2
|
+
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
|
|
3
|
+
import { ContextShadePropertiesAbridged } from "./ContextShadePropertiesAbridged";
|
|
4
|
+
import { Face3D } from "honeybee-schema";
|
|
5
|
+
import { IDdBaseModel } from "honeybee-schema";
|
|
6
|
+
import { Mesh3D } from "honeybee-schema";
|
|
7
|
+
|
|
8
|
+
/** Base class for all objects requiring a identifiers acceptable for all engines. */
|
|
9
|
+
export class ContextShade extends IDdBaseModel {
|
|
10
|
+
@IsArray()
|
|
11
|
+
@IsDefined()
|
|
12
|
+
/** An array of planar Face3Ds and or Mesh3Ds that together represent the context shade. */
|
|
13
|
+
geometry!: (Face3D | Mesh3D) [];
|
|
14
|
+
|
|
15
|
+
@IsInstance(ContextShadePropertiesAbridged)
|
|
16
|
+
@Type(() => ContextShadePropertiesAbridged)
|
|
17
|
+
@ValidateNested()
|
|
18
|
+
@IsDefined()
|
|
19
|
+
/** Extension properties for particular simulation engines (Radiance, EnergyPlus). */
|
|
20
|
+
properties!: ContextShadePropertiesAbridged;
|
|
21
|
+
|
|
22
|
+
@IsString()
|
|
23
|
+
@IsOptional()
|
|
24
|
+
@Matches(/^ContextShade$/)
|
|
25
|
+
type?: string;
|
|
26
|
+
|
|
27
|
+
@IsBoolean()
|
|
28
|
+
@IsOptional()
|
|
29
|
+
/** Boolean to note whether this shade is detached from any of the other geometry in the model. Cases where this should be True include shade representing surrounding buildings or context. */
|
|
30
|
+
is_detached?: boolean;
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
this.type = "ContextShade";
|
|
36
|
+
this.is_detached = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
override init(_data?: any) {
|
|
41
|
+
super.init(_data);
|
|
42
|
+
if (_data) {
|
|
43
|
+
const obj = plainToClass(ContextShade, _data);
|
|
44
|
+
this.geometry = obj.geometry;
|
|
45
|
+
this.properties = obj.properties;
|
|
46
|
+
this.type = obj.type;
|
|
47
|
+
this.is_detached = obj.is_detached;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
static override fromJS(data: any): ContextShade {
|
|
53
|
+
data = typeof data === 'object' ? data : {};
|
|
54
|
+
|
|
55
|
+
let result = new ContextShade();
|
|
56
|
+
result.init(data);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override toJSON(data?: any) {
|
|
61
|
+
data = typeof data === 'object' ? data : {};
|
|
62
|
+
for (var property in this) {
|
|
63
|
+
if (this.hasOwnProperty(property))
|
|
64
|
+
data[property] = this[property];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
data["geometry"] = this.geometry;
|
|
68
|
+
data["properties"] = this.properties;
|
|
69
|
+
data["type"] = this.type;
|
|
70
|
+
data["is_detached"] = this.is_detached;
|
|
71
|
+
data = super.toJSON(data);
|
|
72
|
+
return instanceToPlain(data);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async validate(): Promise<boolean> {
|
|
76
|
+
const errors = await validate(this);
|
|
77
|
+
if (errors.length > 0){
|
|
78
|
+
const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
|
|
79
|
+
throw new Error(`Validation failed: ${errorMessages}`);
|
|
80
|
+
}
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
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 ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
|
|
7
|
+
@IsString()
|
|
8
|
+
@IsOptional()
|
|
9
|
+
@Matches(/^ContextShadeEnergyPropertiesAbridged$/)
|
|
10
|
+
type?: string;
|
|
11
|
+
|
|
12
|
+
@IsString()
|
|
13
|
+
@IsOptional()
|
|
14
|
+
@MinLength(1)
|
|
15
|
+
@MaxLength(100)
|
|
16
|
+
/** Name of a ShadeConstruction to set the reflectance and specularity of the ContextShade. If None, the the EnergyPlus default of 0.2 diffuse reflectance will be used. */
|
|
17
|
+
construction?: string;
|
|
18
|
+
|
|
19
|
+
@IsString()
|
|
20
|
+
@IsOptional()
|
|
21
|
+
@MinLength(1)
|
|
22
|
+
@MaxLength(100)
|
|
23
|
+
/** Name of a schedule to set the transmittance of the ContextShade, which can vary throughout the simulation. If None, the ContextShade will be completely opaque. */
|
|
24
|
+
transmittance_schedule?: string;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this.type = "ContextShadeEnergyPropertiesAbridged";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
override init(_data?: any) {
|
|
34
|
+
super.init(_data);
|
|
35
|
+
if (_data) {
|
|
36
|
+
const obj = plainToClass(ContextShadeEnergyPropertiesAbridged, _data);
|
|
37
|
+
this.type = obj.type;
|
|
38
|
+
this.construction = obj.construction;
|
|
39
|
+
this.transmittance_schedule = obj.transmittance_schedule;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
static override fromJS(data: any): ContextShadeEnergyPropertiesAbridged {
|
|
45
|
+
data = typeof data === 'object' ? data : {};
|
|
46
|
+
|
|
47
|
+
let result = new ContextShadeEnergyPropertiesAbridged();
|
|
48
|
+
result.init(data);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
override toJSON(data?: any) {
|
|
53
|
+
data = typeof data === 'object' ? data : {};
|
|
54
|
+
for (var property in this) {
|
|
55
|
+
if (this.hasOwnProperty(property))
|
|
56
|
+
data[property] = this[property];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
data["type"] = this.type;
|
|
60
|
+
data["construction"] = this.construction;
|
|
61
|
+
data["transmittance_schedule"] = this.transmittance_schedule;
|
|
62
|
+
data = super.toJSON(data);
|
|
63
|
+
return instanceToPlain(data);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async validate(): Promise<boolean> {
|
|
67
|
+
const errors = await validate(this);
|
|
68
|
+
if (errors.length > 0){
|
|
69
|
+
const errorMessages = errors.map((error: TsValidationError) => Object.values(error.constraints || [error]).join(', ')).join('; ');
|
|
70
|
+
throw new Error(`Validation failed: ${errorMessages}`);
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -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 { ContextShadeEnergyPropertiesAbridged } from "./ContextShadeEnergyPropertiesAbridged";
|
|
5
|
+
import { ContextShadeRadiancePropertiesAbridged } from "./ContextShadeRadiancePropertiesAbridged";
|
|
6
|
+
|
|
7
|
+
export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel {
|
|
8
|
+
@IsString()
|
|
9
|
+
@IsOptional()
|
|
10
|
+
@Matches(/^ContextShadePropertiesAbridged$/)
|
|
11
|
+
type?: string;
|
|
12
|
+
|
|
13
|
+
@IsInstance(ContextShadeEnergyPropertiesAbridged)
|
|
14
|
+
@Type(() => ContextShadeEnergyPropertiesAbridged)
|
|
15
|
+
@ValidateNested()
|
|
16
|
+
@IsOptional()
|
|
17
|
+
energy?: ContextShadeEnergyPropertiesAbridged;
|
|
18
|
+
|
|
19
|
+
@IsInstance(ContextShadeRadiancePropertiesAbridged)
|
|
20
|
+
@Type(() => ContextShadeRadiancePropertiesAbridged)
|
|
21
|
+
@ValidateNested()
|
|
22
|
+
@IsOptional()
|
|
23
|
+
radiance?: ContextShadeRadiancePropertiesAbridged;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.type = "ContextShadePropertiesAbridged";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
override init(_data?: any) {
|
|
33
|
+
super.init(_data);
|
|
34
|
+
if (_data) {
|
|
35
|
+
const obj = plainToClass(ContextShadePropertiesAbridged, _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): ContextShadePropertiesAbridged {
|
|
44
|
+
data = typeof data === 'object' ? data : {};
|
|
45
|
+
|
|
46
|
+
let result = new ContextShadePropertiesAbridged();
|
|
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
|
+
}
|