Typedef
Typedef methods list the types and props Novant defines for zones,
spaces, assets, and points. These are the values used in the
type and props fields of project records and imports.
| Method | Description |
|---|---|
typedefZones |
List zone types |
typedefSpaces |
List space types and props |
typedefAssets |
List asset types and props |
typedefPoints |
List point types and props |
Types and props are the same for every project, so these methods take
no proj_id, work with any API key, and do not count toward
a project’s monthly data
usage. Types change rarely, so fetch them once and cache them rather
than on every request.
typedefZones()
typedefSpaces()
typedefAssets()
typedefPoints()Returns
TypedefList with the following fields:
| Field | Type | Description |
|---|---|---|
types |
TypeDef[] |
Valid types |
props |
PropDef[] |
Props; always empty for zones |
Each TypeDef has:
| Field | Type | Description |
|---|---|---|
id |
string |
Type ID, as used in the type field of records |
name |
string |
Display name |
desc |
string |
Description |
service |
string |
Building service the type belongs to; omitted if none |
ontology |
Ontology |
Mappings to other ontologies, such as Brick and Haystack |
Each PropDef has:
| Field | Type | Description |
|---|---|---|
id |
string |
Prop ID |
name |
string |
Display name |
type |
string |
Value type |
values |
string[] |
Allowed values, when the prop has a fixed set; omitted otherwise |
on |
string[] |
Types the prop applies to: exact IDs, * for all, or a
prefix ending in * |
desc |
string |
Description |
Only valid types are listed. Deprecated types are omitted, so a
record may have a type that is not in these lists. See Typedef for details.
Example
// display names for asset types
const { types } = await client.typedefAssets();
const names = new Map(types.map((t) => [t.id, t.name]));
const { assets } = await client.assets();
for (const a of assets) {
console.log(a.name, names.get(a.type) ?? a.type);
}
// props that apply to a point type
const typedef = await client.typedefPoints();
const applies = (p, type) =>
p.on.some((on) => on === "*" || on === type ||
(on.endsWith("*") && type.startsWith(on.slice(0, -1))));
const props = typedef.props.filter((p) => applies(p, "elec_power_sensor"));