@trusthab/composable-resources
Version:
migrating https://github.com/knetikmedia/hab-api/tree/integration/app/resources/composable
115 lines (101 loc) • 2.57 kB
JavaScript
const composer = require('../mixin_loader');
module.exports = (App) => {
const { underscore } = require('inflected');
class ZoneResource {
static mixins() {
return [
// Functionality
'Validatable',
'Templatable',
// ORMish
'Persistable',
'AreasPersistence',
// Mapping and helpers
'Common',
'Location',
'Nameable',
'Alertable'
// 'Thermostat'
];
}
static fields() {
return {
status: {
weight: 1,
type: 'text',
default_value: 'active'
},
type: {
weight: 2,
type: 'text',
path: 'additional_properties.type.value',
default_value: 'unit'
},
fan_speed: {
type: 'text',
or: ['null'],
path: 'additional_properties.fan_speed.value'
},
climate_mode: {
type: 'text',
or: ['null'],
path: 'additional_properties.climate_mode.value'
},
cool_min: {
type: 'integer',
or: ['null'],
path: 'additional_properties.cool_min.value'
},
cool_max: {
type: 'integer',
or: ['null'],
path: 'additional_properties.cool_max.value'
},
cool_target: {
type: 'integer',
or: ['null'],
path: 'additional_properties.cool_target.value'
},
heat_min: {
type: 'integer',
or: ['null'],
path: 'additional_properties.heat_min.value'
},
heat_max: {
type: 'integer',
or: ['null'],
path: 'additional_properties.heat_max.value'
},
heat_target: {
type: 'integer',
or: ['null'],
path: 'additional_properties.heat_target.value'
},
locked: {
type: 'boolean',
or: ['null'],
path: 'additional_properties.locked.value'
}
// just for testing serialize and deserialize
//
// tags: {
// type: 'list',
// path: 'additional_properties.tags.values',
// }
};
}
static areasParams_count() {
return { filter: { type: 'unit' } };
}
static areasParams_list() {
return { filter: { type: 'unit' } };
}
static areasParams_create() {
return { type: 'unit' };
}
static areasParams_update() {
return { type: 'unit' };
}
}
return composer(ZoneResource, App);
};