@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
45 lines (40 loc) • 1.6 kB
JavaScript
import { gettext } from '@c8y/ngx-components/gettext';
import * as i0 from '@angular/core';
import { Injectable } from '@angular/core';
import { pickBy, has, without, difference, keys, includes } from 'lodash-es';
const EVENT_RESERVED_KEYS = [
'creationTime',
'id',
'self',
'source',
'text',
'time',
'type',
'c8y_IsBinary'
];
const EVENT_STANDARD_KEYS = {
type: gettext('Type'),
text: gettext('Text')
};
class EventsService {
getStandardKeys(event) {
return pickBy(EVENT_STANDARD_KEYS, (_, key) => has(event, key));
}
getNonStandardKeys(event, excluding = []) {
return without(difference(this.getKeys(event), keys(this.getStandardKeys(event))), ...excluding);
}
getKeys(managedObject) {
return Object.keys({ ...managedObject }).filter(key => !includes(EVENT_RESERVED_KEYS, key));
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: EventsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: EventsService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: EventsService, decorators: [{
type: Injectable,
args: [{ providedIn: 'root' }]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { EVENT_RESERVED_KEYS, EVENT_STANDARD_KEYS, EventsService };
//# sourceMappingURL=c8y-ngx-components-events.mjs.map