UNPKG

oca_package

Version:

The wrapper of OCA bundle to generate OCA Package at ADC

58 lines (57 loc) 1.81 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const saidify_1 = require("saidify"); const canonical_js_1 = __importDefault(require("../../../../utils/canonical.js")); class AttributeFraming { constructor(dynOverlay) { if (!dynOverlay) { throw new Error('a dynamic extension overlay are required'); } this.dynOverlay = dynOverlay; } GetFramedAttributes() { const attributes = this.dynOverlay.attributes; const canonicalizedAttributes = (0, canonical_js_1.default)(attributes); const sortedAttributes = JSON.parse(canonicalizedAttributes); return sortedAttributes; } GetId() { return this.dynOverlay.framing_metadata.id; } GetLabel() { return this.dynOverlay.framing_metadata.label; } GetLocation() { return this.dynOverlay.framing_metadata.location; } GetVersion() { return this.dynOverlay.framing_metadata.version; } GetFramingMetadata() { return { id: this.GetId(), label: this.GetLabel(), location: this.GetLocation(), version: this.GetVersion(), }; } toJSON() { return { d: '', type: 'community/overlays/adc/attribute_framing/1.1', framing_metadata: this.GetFramingMetadata(), attributes: this.GetFramedAttributes(), }; } Saidifying() { const [, sad] = (0, saidify_1.saidify)(this.toJSON()); return sad; } GenerateOverlay() { return JSON.stringify(this.Saidifying()); } } exports.default = AttributeFraming;