oca_package
Version:
The wrapper of OCA bundle to generate OCA Package at ADC
55 lines (54 loc) • 1.66 kB
JavaScript
"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 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 = (0, canonical_js_1.default)(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] = (0, saidify_1.saidify)(this.toJSON());
return sad;
}
GenerateOverlay() {
return JSON.stringify(this.Saidifying());
}
}
exports.default = UnitFraming;