@trusthab/composable-resources
Version:
migrating https://github.com/knetikmedia/hab-api/tree/integration/app/resources/composable
112 lines (99 loc) • 2.66 kB
JavaScript
const composer = require('../mixin_loader');
module.exports = (App) => {
const { underscore } = require('inflected');
class BuildingResource {
static mixins() {
return [
// Functionality
'Validatable',
'Templatable',
// ORMish
'Persistable',
'AreasPersistence',
// Mapping and helpers
'Common',
'Location',
'Nameable',
'Alertable'
];
}
static fields() {
return {
status: {
weight: 1,
type: 'text',
default_value: 'active'
},
type: {
weight: 2,
type: 'text',
path: 'additional_properties.type.value',
default_value: 'building'
},
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'
},
auto_min: {
type: 'integer',
or: ['null'],
path: 'additional_properties.auto_min.value'
},
auto_max: {
type: 'integer',
or: ['null'],
path: 'additional_properties.auto_max.value'
},
profile_id: {
type: 'integer',
or: ['null'],
path: 'additional_properties.global_settings_id.value'
},
profile_name: {
type: 'text',
or: ['null'],
path: 'additional_properties.global_settings_name.value'
}
};
}
static areasParams_count() {
return { filter: { type: 'building' } };
}
static areasParams_list() {
return { filter: { type: 'building' } };
}
static areasParams_create(data) {
return { additional_properties: { type: { type: 'text', value: 'building' } } };
}
static areasParams_update() {
return { additional_properties: { type: { type: 'text', value: 'building' } } };
}
}
return composer(BuildingResource, App);
};