UNPKG

@fabrix/spool-analytics

Version:

Spool: Analytics for Fabrix

56 lines (55 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const common_1 = require("@fabrix/fabrix/dist/common"); const lodash_1 = require("lodash"); class Analytic extends common_1.FabrixGeneric { constructor(app) { super(app); Object.defineProperties(this, { immutable: { enumerable: false, value: false, writable: true }, freeze: { enumerable: false, value: function () { this.immutable = true; }, writable: true }, unfreeze: { enumerable: false, value: function () { this.immutable = false; }, writable: true }, build: { enumerable: false, value: function () { const unhallowedMethods = ['publish', 'build']; const allowedMethods = lodash_1.difference(this.methods, unhallowedMethods); return Promise.all(allowedMethods.map(method => { return this[method](); })); }, writable: true }, publish: { enumerable: false, value: function (results, options = {}) { return app.models.Analytic.bulkCreate(results, options); }, writable: true } }); } get id() { return this.constructor.name.replace(/(\w+)Analytic/, '$1').toLowerCase(); } get name() { return this.constructor.name; } } exports.Analytic = Analytic;