UNPKG

vulcain-corejs

Version:
74 lines (72 loc) 2.35 kB
"use strict"; const system_1 = require('./../globals/system'); /** * Contains all service dependencies * * @export * @class VulcainManifest */ class VulcainManifest { constructor() { this.dependencies = { services: [], externals: [], databases: [] }; this.configurations = {}; } } exports.VulcainManifest = VulcainManifest; /** * Declare a vulcain service dependencie for the current service * * @export * @param {string} service Name of the called service * @param {string} version Version of the called service * @param {string} discoveryAddress Discovery address of the called service (ex:http://..:30000/api/_servicedesctipyion) * @returns */ function ServiceDependency(service, version, discoveryAddress) { return (target) => { target["$dependency:service"] = { targetServiceName: service, targetServiceVersion: version }; system_1.System.manifest.dependencies.services.push({ service: service, version: version, discoveryAddress: discoveryAddress }); }; } exports.ServiceDependency = ServiceDependency; /** * Declare an external http call dependencie for the current service * * @export * @param {string} uri External uri * @returns */ function HttpDependency(uri) { return (target) => { target["$dependency:external"] = { uri: uri }; system_1.System.manifest.dependencies.externals.push({ uri: uri }); }; } exports.HttpDependency = HttpDependency; /** * Declare a dynamic property configuration for the current service. * * @export * @param {string} propertyName Property name * @param {string} schema Property schema (can be a model or a native js type) * @returns */ function ConfigurationProperty(propertyName, schema) { return (target) => { if (!propertyName) throw new Error("Invalid property propertyName"); let existingSchema = system_1.System.manifest.configurations[propertyName]; if (existingSchema) { if (existingSchema !== schema) throw new Error("Inconsistant schema for configuration property " + propertyName); return; } system_1.System.manifest.configurations[propertyName] = schema; }; } exports.ConfigurationProperty = ConfigurationProperty; //# sourceMappingURL=annotations.js.map