UNPKG

@essential-projects/metadata

Version:

the core metadata service for using the metadata from inside the domain

50 lines (48 loc) 2.36 kB
define(["require", "exports", "@essential-projects/metadata_contracts", "./../provider"], function (require, exports, metadata_contracts_1, provider_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function requiresClaim(claim, namespace) { return function requiresClaimFactory(...args) { switch (args.length) { case 1: return classRequiresClaim.apply(this, [args[0], claim, namespace]); case 2: return propertyRequiresClaim.apply(this, [args[0], args[1], claim, namespace]); case 3: if (typeof args[2] === 'number') { } return methodRequiresClaim.apply(this, [args[0], args[1], args[2], claim, namespace]); default: throw new Error('Decorators are not valid here!'); } }; } exports.requiresClaim = requiresClaim; function classRequiresClaim(target, claim, namespace) { const type = target.prototype ? target.prototype.constructor.name : target.constructor.name; if (!claim.claim) { const claimString = `${type}`; claim.claim = claimString; } provider_1.MetadataProvider.setForType(metadata_contracts_1.MetadataType.RequiredClaim, claim, namespace, type); return target; } function propertyRequiresClaim(target, key, claim, namespace) { const type = target.prototype ? target.prototype.constructor.name : target.constructor.name; if (!claim.claim) { const claimString = `${type}.${key}`; claim.claim = claimString; } provider_1.MetadataProvider.setForType(metadata_contracts_1.MetadataType.RequiredClaim, claim, namespace, type, key); } function methodRequiresClaim(target, key, descriptor, claim, namespace) { const type = target.prototype ? target.prototype.constructor.name : target.constructor.name; if (!claim.claim) { const claimString = `${type}.${key}`; claim.claim = claimString; } provider_1.MetadataProvider.setForType(metadata_contracts_1.MetadataType.RequiredClaim, claim, namespace, type, key); return descriptor; } }); //# sourceMappingURL=requires_claim.js.map