oca_package
Version:
The wrapper of OCA bundle to generate OCA Package at ADC
50 lines (49 loc) • 1.38 kB
JavaScript
import { saidify } from 'saidify';
import canonicalize from '../../../../utils/canonical.js';
class UnitFraming {
constructor(dynOverlay) {
if (!dynOverlay) {
throw new Error('a dynamic extension overlay are required');
}
this.dynOverlay = dynOverlay;
}
GetUnits() {
const units = this.dynOverlay.units;
const canonicalizedUnits = canonicalize(units);
const sortedUnits = JSON.parse(canonicalizedUnits);
return sortedUnits;
}
GetId() {
return this.dynOverlay.properties.id;
}
GetLabel() {
return this.dynOverlay.properties.label;
}
GetLocation() {
return this.dynOverlay.properties.location;
}
GetVersion() {
return this.dynOverlay.properties.version;
}
toJSON() {
return {
d: '',
type: 'community/overlays/adc/unit_framing/1.1',
framing_metadata: {
id: this.GetId(),
label: this.GetLabel(),
location: this.GetLocation(),
version: this.GetVersion(),
},
units: this.GetUnits(),
};
}
Saidifying() {
const [, sad] = saidify(this.toJSON());
return sad;
}
GenerateOverlay() {
return JSON.stringify(this.Saidifying());
}
}
export default UnitFraming;