UNPKG

oca_package

Version:

The wrapper of OCA bundle to generate OCA Package at ADC

53 lines (52 loc) 1.54 kB
import { saidify } from 'saidify'; import canonicalize from '../../../../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 = canonicalize(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] = saidify(this.toJSON()); return sad; } GenerateOverlay() { return JSON.stringify(this.Saidifying()); } } export default AttributeFraming;