@plumier/generic-controller
Advanced tools
Comparing version 1.0.3-canary.13 to 1.0.3-canary.16
@@ -1,2 +0,2 @@ | ||
import { Class } from "@plumier/core"; | ||
import { Class, EntityRelationInfo } from "@plumier/core"; | ||
import { ResponseTransformer } from "./decorator"; | ||
@@ -129,2 +129,4 @@ import { GetManyCustomQueryFunction, GetOneCustomQueryFunction } from "./helper"; | ||
declare function decorateCustomQuery(config: GenericControllerOptions): ((...args: any[]) => any)[]; | ||
export { ControllerBuilder, GenericControllerOptions, GenericControllerConfiguration, splitPath, createRouteDecorators, ignoreActions, authorizeActions, decorateTransformers, decorateCustomQuery, }; | ||
declare function decorateTagByClass(entity: Class, nameConversion: (x: string) => string): (...args: any[]) => any; | ||
declare function decorateTagByRelation(info: EntityRelationInfo, nameConversion: (x: string) => string): (...args: any[]) => any; | ||
export { ControllerBuilder, GenericControllerOptions, GenericControllerConfiguration, splitPath, createRouteDecorators, ignoreActions, authorizeActions, decorateTransformers, decorateCustomQuery, decorateTagByRelation, decorateTagByClass }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorateCustomQuery = exports.decorateTransformers = exports.authorizeActions = exports.ignoreActions = exports.createRouteDecorators = exports.splitPath = exports.ControllerBuilder = void 0; | ||
exports.decorateTagByClass = exports.decorateTagByRelation = exports.decorateCustomQuery = exports.decorateTransformers = exports.authorizeActions = exports.ignoreActions = exports.createRouteDecorators = exports.splitPath = exports.ControllerBuilder = void 0; | ||
const tslib_1 = require("tslib"); | ||
const core_1 = require("@plumier/core"); | ||
const reflect_1 = require("@plumier/reflect"); | ||
const reflect_1 = tslib_1.__importStar(require("@plumier/reflect")); | ||
const decorator_1 = require("./decorator"); | ||
@@ -238,1 +239,22 @@ function getActionName(method) { | ||
exports.decorateCustomQuery = decorateCustomQuery; | ||
function decorateTagByClass(entity, nameConversion) { | ||
const meta = reflect_1.default(entity); | ||
const tag = meta.decorators.find((x) => x.kind === "ApiTag"); | ||
if (!tag) | ||
return core_1.api.tag(nameConversion(entity.name)); | ||
return reflect_1.decorateClass(tag); | ||
} | ||
exports.decorateTagByClass = decorateTagByClass; | ||
function decorateTagByRelation(info, nameConversion) { | ||
const meta = reflect_1.default(info.parent); | ||
const relProp = meta.properties.find(x => x.name === info.parentProperty || x.name === info.childProperty); | ||
if (relProp) { | ||
const tag = relProp.decorators.find((x) => x.kind === "ApiTag"); | ||
if (tag) | ||
return reflect_1.decorateClass(tag); | ||
} | ||
const parent = nameConversion(info.parent.name); | ||
const child = nameConversion(info.child.name); | ||
return core_1.api.tag(`${parent} ${child}`); | ||
} | ||
exports.decorateTagByRelation = decorateTagByRelation; |
@@ -38,9 +38,9 @@ "use strict"; | ||
Reflect.decorate([ | ||
...configuration_1.createRouteDecorators(path, map), | ||
core_1.entityProvider(entity, "id", { applyTo: ["get", "modify", "replace", "delete"] }), | ||
configuration_1.ignoreActions(config), | ||
configuration_1.decorateTagByClass(entity, nameConversion), | ||
...configuration_1.createRouteDecorators(path, map), | ||
...configuration_1.authorizeActions(config), | ||
...configuration_1.decorateTransformers(config), | ||
...configuration_1.decorateCustomQuery(config), | ||
core_1.api.tag(nameConversion(entity.name)) | ||
], Controller); | ||
@@ -62,3 +62,2 @@ return Controller; | ||
Reflect.decorate([ | ||
...configuration_1.createRouteDecorators(path, map), | ||
// re-assign oneToMany decorator which will be used on OneToManyController constructor | ||
@@ -69,6 +68,7 @@ reflect_1.decorateClass({ kind: "plumier-meta:relation-prop-name", type: type[0], relation: type[1] }), | ||
core_1.entityProvider(info.child, "id", { applyTo: ["get", "modify", "replace", "delete"] }), | ||
configuration_1.decorateTagByRelation(info, nameConversion), | ||
...configuration_1.createRouteDecorators(path, map), | ||
...configuration_1.authorizeActions(config), | ||
...configuration_1.decorateTransformers(config), | ||
...configuration_1.decorateCustomQuery(config), | ||
core_1.api.tag(`${nameConversion(info.parent.name)} ${nameConversion(info.child.name)}`) | ||
], Controller); | ||
@@ -75,0 +75,0 @@ return Controller; |
{ | ||
"name": "@plumier/generic-controller", | ||
"version": "1.0.3-canary.13+e1d725a", | ||
"version": "1.0.3-canary.16+6a18218", | ||
"description": "Plumier generic controller implementation", | ||
@@ -23,4 +23,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@plumier/core": "1.0.3-canary.13+e1d725a", | ||
"@plumier/query-parser": "1.0.3-canary.13+e1d725a" | ||
"@plumier/core": "1.0.3-canary.16+6a18218", | ||
"@plumier/query-parser": "1.0.3-canary.16+6a18218" | ||
}, | ||
@@ -40,3 +40,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "e1d725a20031673de8774b6555ef61a5178c44be" | ||
"gitHead": "6a182186de06555adcb4d7864d177ee8a4df9413" | ||
} |
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
57403
1132