@plumier/generic-controller
Advanced tools
Comparing version 1.0.0-canary.kd13oe59.0 to 1.0.0-canary.kd18a18n.0
@@ -22,11 +22,20 @@ "use strict"; | ||
} | ||
function getIgnore(entity, property) { | ||
const meta = tinspector_1.default(entity); | ||
if (property) { | ||
const prop = meta.properties.find(x => x.name === property); | ||
return prop.decorators.find((x) => x.name === "Ignore"); | ||
function copyDecorators(decorators) { | ||
const result = []; | ||
for (const decorator of decorators) { | ||
if (decorator.name === "Ignore") { | ||
result.push(decorator); | ||
} | ||
const authDec = decorator; | ||
if (authDec.type === "plumier-meta:authorize" && authDec.access === "all") { | ||
result.push(decorator); | ||
} | ||
} | ||
else | ||
return meta.decorators.find((x) => x.name === "Ignore"); | ||
return result; | ||
} | ||
function decorateController(controller, decorators) { | ||
for (const decorator of decorators) { | ||
Reflect.decorate([tinspector_1.decorateClass(decorator)], controller); | ||
} | ||
} | ||
function createController(rootPath, entity, controller, nameConversion) { | ||
@@ -40,6 +49,5 @@ // get type of ID column on entity | ||
const path = core_1.appendRoute(rootPath, name); | ||
// copy @route.ignore() on entity to the controller to control route generation | ||
const ignore = getIgnore(entity); | ||
if (ignore) | ||
Reflect.decorate([core_1.route.ignore(...ignore.methods)], Controller); | ||
// copy @route.ignore() and @authorize on entity to the controller to control route generation | ||
const meta = tinspector_1.default(entity); | ||
decorateController(Controller, copyDecorators(meta.decorators)); | ||
Reflect.decorate([core_1.route.root(path)], Controller); | ||
@@ -62,5 +70,5 @@ Reflect.decorate([core_1.api.tag(entity.name)], Controller); | ||
// copy @route.ignore() on entity to the controller to control route generation | ||
const ignore = getIgnore(dec.parentType, dec.propertyName); | ||
if (ignore) | ||
Reflect.decorate([core_1.route.ignore(...ignore.methods)], Controller); | ||
const meta = tinspector_1.default(dec.parentType); | ||
const decorators = meta.properties.find(x => x.name === dec.propertyName).decorators; | ||
decorateController(Controller, copyDecorators(decorators)); | ||
Reflect.decorate([ | ||
@@ -67,0 +75,0 @@ core_1.route.root(path), |
{ | ||
"name": "@plumier/generic-controller", | ||
"version": "1.0.0-canary.kd13oe59.0+25feb79", | ||
"version": "1.0.0-canary.kd18a18n.0+10ae92f", | ||
"description": "Plumier generic controller implementation", | ||
@@ -18,3 +18,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@plumier/core": "1.0.0-canary.kd13oe59.0+25feb79", | ||
"@plumier/core": "1.0.0-canary.kd18a18n.0+10ae92f", | ||
"@types/pluralize": "^0.0.29", | ||
@@ -33,3 +33,3 @@ "pluralize": "^8.0.0" | ||
}, | ||
"gitHead": "25feb797777dbf094590690812eb01976354fefa" | ||
"gitHead": "10ae92fec6d9aca11ad78a96578b7473c8a50af7" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
39480
575