Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev #150

Merged
merged 6 commits into from
Sep 24, 2024
Merged

dev #150

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,020 changes: 2,020 additions & 0 deletions samples/Room_with_complex_skylights.dfjson

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/TypeScriptSDK/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
setupFiles: ['./tests/jest.setup.ts'],
transform: {
'^.+\\.ts?$': ['ts-jest', { useESM: true }],
},
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
};

17 changes: 10 additions & 7 deletions src/TypeScriptSDK/models/Building.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsArray, validate, ValidationError as TsValidationError } from 'class-validator';
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer';
import { BuildingPropertiesAbridged } from "./BuildingPropertiesAbridged";
import { IDdBaseModel } from "honeybee-schema";
import { RoofSpecification } from "./RoofSpecification";
Expand Down Expand Up @@ -53,7 +53,7 @@ export class Building extends IDdBaseModel {
override init(_data?: any) {
super.init(_data);
if (_data) {
const obj = plainToClass(Building, _data);
const obj = plainToClass(Building, _data, { enableImplicitConversion: true });
this.properties = obj.properties;
this.type = obj.type;
this.unique_stories = obj.unique_stories;
Expand All @@ -66,18 +66,20 @@ export class Building extends IDdBaseModel {
static override fromJS(data: any): Building {
data = typeof data === 'object' ? data : {};

if (Array.isArray(data)) {
const obj:any = {};
for (var property in data) {
obj[property] = data[property];
}
data = obj;
}
let result = new Building();
result.init(data);
return result;
}

override toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
for (var property in this) {
if (this.hasOwnProperty(property))
data[property] = this[property];
}

data["properties"] = this.properties;
data["type"] = this.type;
data["unique_stories"] = this.unique_stories;
Expand All @@ -96,3 +98,4 @@ export class Building extends IDdBaseModel {
return true;
}
}

17 changes: 10 additions & 7 deletions src/TypeScriptSDK/models/BuildingEnergyPropertiesAbridged.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator';
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer';
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";

/** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */
Expand All @@ -26,7 +26,7 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
override init(_data?: any) {
super.init(_data);
if (_data) {
const obj = plainToClass(BuildingEnergyPropertiesAbridged, _data);
const obj = plainToClass(BuildingEnergyPropertiesAbridged, _data, { enableImplicitConversion: true });
this.type = obj.type;
this.construction_set = obj.construction_set;
}
Expand All @@ -36,18 +36,20 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
static override fromJS(data: any): BuildingEnergyPropertiesAbridged {
data = typeof data === 'object' ? data : {};

if (Array.isArray(data)) {
const obj:any = {};
for (var property in data) {
obj[property] = data[property];
}
data = obj;
}
let result = new BuildingEnergyPropertiesAbridged();
result.init(data);
return result;
}

override toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
for (var property in this) {
if (this.hasOwnProperty(property))
data[property] = this[property];
}

data["type"] = this.type;
data["construction_set"] = this.construction_set;
data = super.toJSON(data);
Expand All @@ -63,3 +65,4 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
return true;
}
}

17 changes: 10 additions & 7 deletions src/TypeScriptSDK/models/BuildingPropertiesAbridged.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator';
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer';
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
import { BuildingEnergyPropertiesAbridged } from "./BuildingEnergyPropertiesAbridged";
import { BuildingRadiancePropertiesAbridged } from "./BuildingRadiancePropertiesAbridged";
Expand Down Expand Up @@ -32,7 +32,7 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel {
override init(_data?: any) {
super.init(_data);
if (_data) {
const obj = plainToClass(BuildingPropertiesAbridged, _data);
const obj = plainToClass(BuildingPropertiesAbridged, _data, { enableImplicitConversion: true });
this.type = obj.type;
this.energy = obj.energy;
this.radiance = obj.radiance;
Expand All @@ -43,18 +43,20 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel {
static override fromJS(data: any): BuildingPropertiesAbridged {
data = typeof data === 'object' ? data : {};

if (Array.isArray(data)) {
const obj:any = {};
for (var property in data) {
obj[property] = data[property];
}
data = obj;
}
let result = new BuildingPropertiesAbridged();
result.init(data);
return result;
}

override toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
for (var property in this) {
if (this.hasOwnProperty(property))
data[property] = this[property];
}

data["type"] = this.type;
data["energy"] = this.energy;
data["radiance"] = this.radiance;
Expand All @@ -71,3 +73,4 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel {
return true;
}
}

17 changes: 10 additions & 7 deletions src/TypeScriptSDK/models/BuildingRadiancePropertiesAbridged.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer';
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";

/** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */
Expand All @@ -24,7 +24,7 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
override init(_data?: any) {
super.init(_data);
if (_data) {
const obj = plainToClass(BuildingRadiancePropertiesAbridged, _data);
const obj = plainToClass(BuildingRadiancePropertiesAbridged, _data, { enableImplicitConversion: true });
this.type = obj.type;
this.modifier_set = obj.modifier_set;
}
Expand All @@ -34,18 +34,20 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
static override fromJS(data: any): BuildingRadiancePropertiesAbridged {
data = typeof data === 'object' ? data : {};

if (Array.isArray(data)) {
const obj:any = {};
for (var property in data) {
obj[property] = data[property];
}
data = obj;
}
let result = new BuildingRadiancePropertiesAbridged();
result.init(data);
return result;
}

override toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
for (var property in this) {
if (this.hasOwnProperty(property))
data[property] = this[property];
}

data["type"] = this.type;
data["modifier_set"] = this.modifier_set;
data = super.toJSON(data);
Expand All @@ -61,3 +63,4 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
return true;
}
}

22 changes: 15 additions & 7 deletions src/TypeScriptSDK/models/ContextShade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsArray, IsDefined, IsInstance, ValidateNested, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer';
import { ContextShadePropertiesAbridged } from "./ContextShadePropertiesAbridged";
import { Face3D } from "honeybee-schema";
import { IDdBaseModel } from "honeybee-schema";
Expand All @@ -9,6 +9,11 @@ import { Mesh3D } from "honeybee-schema";
export class ContextShade extends IDdBaseModel {
@IsArray()
@IsDefined()
@Transform(({ value }) => value.map((item: any) => {
if (item?.type === 'Face3D') return Face3D.fromJS(item);
else if (item?.type === 'Mesh3D') return Mesh3D.fromJS(item);
else return item;
}))
/** An array of planar Face3Ds and or Mesh3Ds that together represent the context shade. */
geometry!: (Face3D | Mesh3D) [];

Expand Down Expand Up @@ -40,7 +45,7 @@ export class ContextShade extends IDdBaseModel {
override init(_data?: any) {
super.init(_data);
if (_data) {
const obj = plainToClass(ContextShade, _data);
const obj = plainToClass(ContextShade, _data, { enableImplicitConversion: true });
this.geometry = obj.geometry;
this.properties = obj.properties;
this.type = obj.type;
Expand All @@ -52,18 +57,20 @@ export class ContextShade extends IDdBaseModel {
static override fromJS(data: any): ContextShade {
data = typeof data === 'object' ? data : {};

if (Array.isArray(data)) {
const obj:any = {};
for (var property in data) {
obj[property] = data[property];
}
data = obj;
}
let result = new ContextShade();
result.init(data);
return result;
}

override toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
for (var property in this) {
if (this.hasOwnProperty(property))
data[property] = this[property];
}

data["geometry"] = this.geometry;
data["properties"] = this.properties;
data["type"] = this.type;
Expand All @@ -81,3 +88,4 @@ export class ContextShade extends IDdBaseModel {
return true;
}
}

17 changes: 10 additions & 7 deletions src/TypeScriptSDK/models/ContextShadeEnergyPropertiesAbridged.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator';
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer';
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";

/** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */
Expand Down Expand Up @@ -33,7 +33,7 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
override init(_data?: any) {
super.init(_data);
if (_data) {
const obj = plainToClass(ContextShadeEnergyPropertiesAbridged, _data);
const obj = plainToClass(ContextShadeEnergyPropertiesAbridged, _data, { enableImplicitConversion: true });
this.type = obj.type;
this.construction = obj.construction;
this.transmittance_schedule = obj.transmittance_schedule;
Expand All @@ -44,18 +44,20 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
static override fromJS(data: any): ContextShadeEnergyPropertiesAbridged {
data = typeof data === 'object' ? data : {};

if (Array.isArray(data)) {
const obj:any = {};
for (var property in data) {
obj[property] = data[property];
}
data = obj;
}
let result = new ContextShadeEnergyPropertiesAbridged();
result.init(data);
return result;
}

override toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
for (var property in this) {
if (this.hasOwnProperty(property))
data[property] = this[property];
}

data["type"] = this.type;
data["construction"] = this.construction;
data["transmittance_schedule"] = this.transmittance_schedule;
Expand All @@ -72,3 +74,4 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
return true;
}
}

17 changes: 10 additions & 7 deletions src/TypeScriptSDK/models/ContextShadePropertiesAbridged.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator';
import { Type, plainToClass, instanceToPlain } from 'class-transformer';
import { Type, plainToClass, instanceToPlain, Transform } from 'class-transformer';
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
import { ContextShadeEnergyPropertiesAbridged } from "./ContextShadeEnergyPropertiesAbridged";
import { ContextShadeRadiancePropertiesAbridged } from "./ContextShadeRadiancePropertiesAbridged";
Expand Down Expand Up @@ -32,7 +32,7 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel {
override init(_data?: any) {
super.init(_data);
if (_data) {
const obj = plainToClass(ContextShadePropertiesAbridged, _data);
const obj = plainToClass(ContextShadePropertiesAbridged, _data, { enableImplicitConversion: true });
this.type = obj.type;
this.energy = obj.energy;
this.radiance = obj.radiance;
Expand All @@ -43,18 +43,20 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel {
static override fromJS(data: any): ContextShadePropertiesAbridged {
data = typeof data === 'object' ? data : {};

if (Array.isArray(data)) {
const obj:any = {};
for (var property in data) {
obj[property] = data[property];
}
data = obj;
}
let result = new ContextShadePropertiesAbridged();
result.init(data);
return result;
}

override toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
for (var property in this) {
if (this.hasOwnProperty(property))
data[property] = this[property];
}

data["type"] = this.type;
data["energy"] = this.energy;
data["radiance"] = this.radiance;
Expand All @@ -71,3 +73,4 @@ export class ContextShadePropertiesAbridged extends _OpenAPIGenBaseModel {
return true;
}
}

Loading
Loading