@omnia/tooling-composers
Version:
Provide tooling to work with manifest things.
53 lines (52 loc) • 2.51 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManifestGroupComposer = void 0;
const DependencyComposer_1 = require("./DependencyComposer");
const LoadableManifestRegistry_1 = require("./LoadableManifestRegistry");
const CombinableRuleComposer_1 = require("./CombinableRuleComposer");
const Enums_1 = require("./models/Enums");
const ManifestGroupRegistry_1 = require("./ManifestGroupRegistry");
class ManifestGroupComposer {
constructor(manifestId, manifestName) {
this.manifest = null;
this.ruleComposer = null;
this.registerManifestGroup = (groupOptions) => {
ManifestGroupRegistry_1.ManifestGroupRegistry.registerManifestGroup(this.manifest, groupOptions);
return this;
};
this.withLoadRules = () => {
this.ruleComposer = new CombinableRuleComposer_1.CombinableRuleComposer(this.persistCombinedRules, this);
return this.ruleComposer;
};
this.withNoDependency = () => {
return new DependencyComposer_1.DependencyComposer(this.manifest.resourceId, this).withNoDependency();
};
this.withDependency = (manifestId) => {
//Validate if dependency if needed, and add if ok
return new DependencyComposer_1.DependencyComposer(this.manifest.resourceId, this).withDependency(manifestId);
};
this.withExternalDependency = (omniaServiceId, manifestId) => {
return new DependencyComposer_1.DependencyComposer(this.manifest.resourceId, this).withExternalDependency(omniaServiceId, manifestId);
};
this.disableAuth = () => {
this.manifest.authDisabled = true;
return this;
};
this.persistCombinedRules = (rules) => {
ManifestGroupRegistry_1.ManifestGroupRegistry.newCombinedRules(this.manifest, rules);
};
this.manifest = LoadableManifestRegistry_1.LoadableManifestRegistry.getRegisteredManifest(manifestId);
if (this.manifest == null) {
this.manifest = {
manifestType: Enums_1.ClientManifestTypes.ManifestGroup,
resourceId: manifestId,
resourceName: manifestName
};
LoadableManifestRegistry_1.LoadableManifestRegistry.registerManifest(this.manifest);
}
else if (manifestName) {
this.manifest.resourceName = manifestName;
}
}
}
exports.ManifestGroupComposer = ManifestGroupComposer;