@omnia/tooling-composers
Version:
Provide tooling to work with manifest things.
97 lines (96 loc) • 4.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Composer = void 0;
const BlockingComposer_1 = require("./BlockingComposer");
const ResourcesComposer_1 = require("./ResourcesComposer");
const ComponentComposer_1 = require("./ComponentComposer");
const LocalizationComposer_1 = require("./LocalizationComposer");
const Utils_1 = require("./Utils");
const ManifestGroupComposer_1 = require("./ManifestGroupComposer");
const ServiceComposer_1 = require("./ServiceComposer");
const ServiceAppRegistry_1 = require("./ServiceAppRegistry");
const ServiceRoleRegistry_1 = require("./ServiceRoleRegistry");
const ImportManifestRegistry_1 = require("./ImportManifestRegistry");
const _1 = require(".");
const ServiceFeatureComposer_1 = require("./ServiceFeatureComposer");
class NewManifestComposer {
constructor(manifestId, manifestName) {
this.manifestId = manifestId;
this.manifestName = manifestName;
this.registerWebComponent = (componentOptions) => {
return new ComponentComposer_1.ComponentComposer(this.manifestId, this.manifestName).registerComponent(componentOptions);
};
this.registerResourceGroup = (componentGroupOptions) => {
return new ManifestGroupComposer_1.ManifestGroupComposer(this.manifestId, this.manifestName).registerManifestGroup(componentGroupOptions);
};
this.registerResources = (resourceDescription) => {
return new ResourcesComposer_1.ResourcesComposer(this.manifestId, this.manifestName).registerResource(resourceDescription);
};
this.registerLocalization = (localizationOptions) => {
return new LocalizationComposer_1.Localization(localizationOptions, this.manifestId);
};
this.registerFeature = (options) => {
return new ServiceFeatureComposer_1.ServiceFeatureComposer(this.manifestId, options);
};
this.registerAppDefinition = (options) => {
ServiceAppRegistry_1.ServiceAppRegistry.AddAppDefinition(this.manifestId, options);
};
this.registerRoleDefinition = (options) => {
ServiceRoleRegistry_1.ServiceRoleRegistry.AddRoleDefinition(this.manifestId, options);
};
if (!manifestId) {
Utils_1.Utils.ensureValidManifestId(manifestId);
}
}
/** Specify service type for this omnia service project.
E.g. A service could be a worker, doing simple async jobs, worker queues etc
it can also be a webapp serving UI resources
*/
registerService(serviceInfo) {
return new ServiceComposer_1.ServiceComposer(this.manifestId, this.manifestName, serviceInfo);
}
}
class Composer {
/** Do not instantiate, use static members instead of constructor / new Composer().
E.g. Composer.registerComponent()
*/
constructor() {
}
/** Add information about things you want to block.
E.g. block a manifest from being loaded, so you can provide your own implementation
*/
static get block() {
return new BlockingComposer_1.BlockingComposer();
}
}
exports.Composer = Composer;
/**
* Registers a new manifest
* @param manifestId the unique id of the manifest, must be a valid guid.
* @param name a friendly name of the manifest.
*/
Composer.registerManifest = (manifestId, name) => {
return new NewManifestComposer(manifestId.toString(), name);
};
/**
* Re-opens resources manifest, so more resources can be included.
* {param}:manifestId the unique id of the resource manifest to open, must be a valid guid.
*/
Composer.openResourceManifest = (manifestId) => {
return new ResourcesComposer_1.ReOpenedResourceComposer(manifestId.toString());
};
Composer.importManifests = (folderPath) => {
ImportManifestRegistry_1.ImportManifestRegistry.add(folderPath);
return {
configuration: (omniaServiceId, configurationType) => {
return _1.ConfigurationClientServiceRegistry.Add(omniaServiceId, configurationType, [Composer]);
},
done: () => {
return {
registerManifest: Composer.registerManifest,
openResourceManifest: Composer.openResourceManifest,
block: Composer.block
};
}
};
};