@plumier/generic-controller
Advanced tools
Comparing version 1.0.5 to 1.0.6-canary.3
@@ -6,3 +6,3 @@ "use strict"; | ||
const core_1 = require("@plumier/core"); | ||
const reflect_1 = tslib_1.__importStar(require("@plumier/reflect")); | ||
const reflect_1 = (0, tslib_1.__importStar)(require("@plumier/reflect")); | ||
const decorator_1 = require("./decorator"); | ||
@@ -184,8 +184,8 @@ function getActionName(method) { | ||
core_1.route.root(root, { map }), | ||
decorator_1.decorateRoute("post", "", { applyTo: "save" }), | ||
decorator_1.decorateRoute("get", "", { applyTo: "list" }), | ||
decorator_1.decorateRoute("get", `:${id}`, { applyTo: "get" }), | ||
decorator_1.decorateRoute("put", `:${id}`, { applyTo: "replace" }), | ||
decorator_1.decorateRoute("patch", `:${id}`, { applyTo: "modify" }), | ||
decorator_1.decorateRoute("delete", `:${id}`, { applyTo: "delete" }), | ||
(0, decorator_1.decorateRoute)("post", "", { applyTo: "save" }), | ||
(0, decorator_1.decorateRoute)("get", "", { applyTo: "list" }), | ||
(0, decorator_1.decorateRoute)("get", `:${id}`, { applyTo: "get" }), | ||
(0, decorator_1.decorateRoute)("put", `:${id}`, { applyTo: "replace" }), | ||
(0, decorator_1.decorateRoute)("patch", `:${id}`, { applyTo: "modify" }), | ||
(0, decorator_1.decorateRoute)("delete", `:${id}`, { applyTo: "delete" }), | ||
]; | ||
@@ -220,3 +220,3 @@ } | ||
const target = key === "get" ? cnf.transformer.target : [cnf.transformer.target]; | ||
result.push(decorator_1.responseTransformer(target, cnf.transformer.fn, { applyTo: key })); | ||
result.push((0, decorator_1.responseTransformer)(target, cnf.transformer.fn, { applyTo: key })); | ||
} | ||
@@ -231,9 +231,9 @@ } | ||
if (get && get.getOneCustomQuery) { | ||
result.push(reflect_1.decorateClass({ kind: "plumier-meta:get-one-query", query: get.getOneCustomQuery.query })); | ||
result.push(core_1.responseType(get.getOneCustomQuery.type, { applyTo: "get" })); | ||
result.push((0, reflect_1.decorateClass)({ kind: "plumier-meta:get-one-query", query: get.getOneCustomQuery.query })); | ||
result.push((0, core_1.responseType)(get.getOneCustomQuery.type, { applyTo: "get" })); | ||
} | ||
const list = config.map.get("list"); | ||
if (list && list.getManyCustomQuery) { | ||
result.push(reflect_1.decorateClass({ kind: "plumier-meta:get-many-query", query: list.getManyCustomQuery.query })); | ||
result.push(core_1.responseType(list.getManyCustomQuery.type, { applyTo: "list" })); | ||
result.push((0, reflect_1.decorateClass)({ kind: "plumier-meta:get-many-query", query: list.getManyCustomQuery.query })); | ||
result.push((0, core_1.responseType)(list.getManyCustomQuery.type, { applyTo: "list" })); | ||
} | ||
@@ -244,11 +244,11 @@ return result; | ||
function decorateTagByClass(entity, nameConversion) { | ||
const meta = reflect_1.default(entity); | ||
const meta = (0, reflect_1.default)(entity); | ||
const tags = meta.decorators.filter((x) => x.kind === "ApiTag"); | ||
if (tags.length === 0) | ||
return [core_1.api.tag(nameConversion(entity.name))]; | ||
return tags.map(x => reflect_1.decorateClass(x)); | ||
return tags.map(x => (0, reflect_1.decorateClass)(x)); | ||
} | ||
exports.decorateTagByClass = decorateTagByClass; | ||
function decorateTagByRelation(info, nameConversion) { | ||
const meta = reflect_1.default(info.parent); | ||
const meta = (0, reflect_1.default)(info.parent); | ||
const relProp = meta.properties.find(x => x.name === info.parentProperty || x.name === info.childProperty); | ||
@@ -258,3 +258,3 @@ if (relProp) { | ||
if (tags.length > 0) | ||
return tags.map(x => reflect_1.decorateClass(x)); | ||
return tags.map(x => (0, reflect_1.decorateClass)(x)); | ||
} | ||
@@ -261,0 +261,0 @@ const parent = nameConversion(info.parent.name); |
@@ -7,3 +7,3 @@ "use strict"; | ||
const query_parser_1 = require("@plumier/query-parser"); | ||
const reflect_1 = tslib_1.__importStar(require("@plumier/reflect")); | ||
const reflect_1 = (0, tslib_1.__importStar)(require("@plumier/reflect")); | ||
const validator_1 = require("@plumier/validator"); | ||
@@ -17,3 +17,3 @@ const decorator_1 = require("./decorator"); | ||
function getDeletedProperty(type) { | ||
const meta = reflect_1.default(type); | ||
const meta = (0, reflect_1.default)(type); | ||
return meta.properties.find(x => x.decorators.some((d) => d.kind === "plumier-meta:delete-column")); | ||
@@ -34,7 +34,7 @@ } | ||
}; | ||
IdentifierResult = tslib_1.__decorate([ | ||
core_1.domain(), | ||
IdentifierResult = (0, tslib_1.__decorate)([ | ||
(0, core_1.domain)(), | ||
reflect_1.generic.parameter("TID"), | ||
tslib_1.__param(0, reflect_1.default.type("TID")), | ||
tslib_1.__metadata("design:paramtypes", [Object]) | ||
(0, tslib_1.__param)(0, reflect_1.default.type("TID")), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object]) | ||
], IdentifierResult); | ||
@@ -56,5 +56,5 @@ exports.IdentifierResult = IdentifierResult; | ||
async list(offset = 0, limit = 50, filter, select, order, ctx) { | ||
const query = helper_1.getManyCustomQuery(this.constructor); | ||
const query = (0, helper_1.getManyCustomQuery)(this.constructor); | ||
const result = query ? await query({ offset, limit, filter, order, select }, ctx) : await this.repo.find(offset, limit, filter, select, order); | ||
const transformer = helper_1.getTransformer(this.constructor, "list"); | ||
const transformer = (0, helper_1.getTransformer)(this.constructor, "list"); | ||
if (transformer) | ||
@@ -68,5 +68,5 @@ return result.map(x => transformer(x)); | ||
async get(id, select, ctx) { | ||
const query = helper_1.getOneCustomQuery(this.constructor); | ||
const query = (0, helper_1.getOneCustomQuery)(this.constructor); | ||
const result = query ? await query({ id, select }, ctx) : await this.findByIdOrNotFound(id, select); | ||
const transformer = helper_1.getTransformer(this.constructor, "get"); | ||
const transformer = (0, helper_1.getTransformer)(this.constructor, "get"); | ||
if (transformer) | ||
@@ -91,80 +91,80 @@ return transformer(result); | ||
}; | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
core_1.route.ignore(), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseControllerGeneric.prototype, "findByIdOrNotFound", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("get", ""), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("get", ""), | ||
core_1.api.hideRelations(), | ||
reflect_1.default.type(["T"]), | ||
tslib_1.__param(2, query_parser_1.filterParser(() => "T")), | ||
tslib_1.__param(3, query_parser_1.selectParser(x => "T")), | ||
tslib_1.__param(4, query_parser_1.orderParser(x => "T")), | ||
tslib_1.__param(5, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Number, Number, Object, Object, String, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(2, (0, query_parser_1.filterParser)(() => "T")), | ||
(0, tslib_1.__param)(3, (0, query_parser_1.selectParser)(x => "T")), | ||
(0, tslib_1.__param)(4, (0, query_parser_1.orderParser)(x => "T")), | ||
(0, tslib_1.__param)(5, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Number, Number, Object, Object, String, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseControllerGeneric.prototype, "list", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("post", ""), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("post", ""), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, core_1.api.hideRelations()), | ||
tslib_1.__param(0, reflect_1.default.type("T")), | ||
tslib_1.__param(1, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, core_1.api.hideRelations()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("T")), | ||
(0, tslib_1.__param)(1, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseControllerGeneric.prototype, "save", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("get", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("get", ":id"), | ||
core_1.api.hideRelations(), | ||
reflect_1.default.type("T"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("TID")), | ||
tslib_1.__param(1, query_parser_1.selectParser(x => "T")), | ||
tslib_1.__param(2, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(1, (0, query_parser_1.selectParser)(x => "T")), | ||
(0, tslib_1.__param)(2, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseControllerGeneric.prototype, "get", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("patch", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("patch", ":id"), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("TID")), | ||
tslib_1.__param(1, core_1.api.hideRelations()), | ||
tslib_1.__param(1, reflect_1.default.type("T")), | ||
tslib_1.__param(1, validator_1.val.partial("T")), | ||
tslib_1.__param(2, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(1, core_1.api.hideRelations()), | ||
(0, tslib_1.__param)(1, reflect_1.default.type("T")), | ||
(0, tslib_1.__param)(1, validator_1.val.partial("T")), | ||
(0, tslib_1.__param)(2, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseControllerGeneric.prototype, "modify", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("put", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("put", ":id"), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("TID")), | ||
tslib_1.__param(1, core_1.api.hideRelations()), | ||
tslib_1.__param(1, reflect_1.default.type("T")), | ||
tslib_1.__param(2, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(1, core_1.api.hideRelations()), | ||
(0, tslib_1.__param)(1, reflect_1.default.type("T")), | ||
(0, tslib_1.__param)(2, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseControllerGeneric.prototype, "replace", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("delete", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("delete", ":id"), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("TID")), | ||
tslib_1.__param(1, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(1, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseControllerGeneric.prototype, "delete", null); | ||
RepoBaseControllerGeneric = tslib_1.__decorate([ | ||
RepoBaseControllerGeneric = (0, tslib_1.__decorate)([ | ||
reflect_1.generic.parameter("T", "TID"), | ||
tslib_1.__metadata("design:paramtypes", [Function]) | ||
(0, tslib_1.__metadata)("design:paramtypes", [Function]) | ||
], RepoBaseControllerGeneric); | ||
@@ -175,3 +175,3 @@ exports.RepoBaseControllerGeneric = RepoBaseControllerGeneric; | ||
super(); | ||
const meta = reflect_1.default(this.constructor); | ||
const meta = (0, reflect_1.default)(this.constructor); | ||
const dec = meta.decorators.find((x) => x.kind === "plumier-meta:relation-prop-name"); | ||
@@ -197,5 +197,5 @@ const info = core_1.entityHelper.getRelationInfo([dec.type, dec.relation]); | ||
await this.findParentByIdOrNotFound(pid); | ||
const query = helper_1.getManyCustomQuery(this.constructor); | ||
const query = (0, helper_1.getManyCustomQuery)(this.constructor); | ||
const result = query ? await query({ pid, offset, limit, filter, order, select }, ctx) : await this.repo.find(pid, offset, limit, filter, select, order); | ||
const transformer = helper_1.getTransformer(this.constructor, "list"); | ||
const transformer = (0, helper_1.getTransformer)(this.constructor, "list"); | ||
if (transformer) | ||
@@ -211,5 +211,5 @@ return result.map(x => transformer(x)); | ||
await this.findParentByIdOrNotFound(pid); | ||
const query = helper_1.getOneCustomQuery(this.constructor); | ||
const query = (0, helper_1.getOneCustomQuery)(this.constructor); | ||
const result = query ? await query({ id, select }, ctx) : await this.findByIdOrNotFound(id, select); | ||
const transformer = helper_1.getTransformer(this.constructor, "get"); | ||
const transformer = (0, helper_1.getTransformer)(this.constructor, "get"); | ||
if (transformer) | ||
@@ -237,98 +237,98 @@ return transformer(result); | ||
}; | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
core_1.route.ignore(), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "findByIdOrNotFound", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
core_1.route.ignore(), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "findParentByIdOrNotFound", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("get", ""), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("get", ""), | ||
core_1.api.hideRelations(), | ||
reflect_1.default.type(["T"]), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("PID")), | ||
tslib_1.__param(3, query_parser_1.filterParser(() => "T")), | ||
tslib_1.__param(4, query_parser_1.selectParser(x => "T")), | ||
tslib_1.__param(5, query_parser_1.orderParser(x => "T")), | ||
tslib_1.__param(6, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Number, Number, Object, Object, String, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("PID")), | ||
(0, tslib_1.__param)(3, (0, query_parser_1.filterParser)(() => "T")), | ||
(0, tslib_1.__param)(4, (0, query_parser_1.selectParser)(x => "T")), | ||
(0, tslib_1.__param)(5, (0, query_parser_1.orderParser)(x => "T")), | ||
(0, tslib_1.__param)(6, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Number, Number, Object, Object, String, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "list", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("post", ""), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("post", ""), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("PID")), | ||
tslib_1.__param(1, core_1.api.hideRelations()), | ||
tslib_1.__param(1, reflect_1.default.type("T")), | ||
tslib_1.__param(2, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("PID")), | ||
(0, tslib_1.__param)(1, core_1.api.hideRelations()), | ||
(0, tslib_1.__param)(1, reflect_1.default.type("T")), | ||
(0, tslib_1.__param)(2, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "save", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("get", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("get", ":id"), | ||
core_1.api.hideRelations(), | ||
reflect_1.default.type("T"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("PID")), | ||
tslib_1.__param(1, validator_1.val.required()), | ||
tslib_1.__param(1, reflect_1.default.type("TID")), | ||
tslib_1.__param(2, query_parser_1.selectParser(x => "T")), | ||
tslib_1.__param(3, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("PID")), | ||
(0, tslib_1.__param)(1, validator_1.val.required()), | ||
(0, tslib_1.__param)(1, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(2, (0, query_parser_1.selectParser)(x => "T")), | ||
(0, tslib_1.__param)(3, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "get", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("patch", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("patch", ":id"), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("PID")), | ||
tslib_1.__param(1, validator_1.val.required()), | ||
tslib_1.__param(1, reflect_1.default.type("TID")), | ||
tslib_1.__param(2, core_1.api.hideRelations()), | ||
tslib_1.__param(2, validator_1.val.partial("T")), | ||
tslib_1.__param(3, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("PID")), | ||
(0, tslib_1.__param)(1, validator_1.val.required()), | ||
(0, tslib_1.__param)(1, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(2, core_1.api.hideRelations()), | ||
(0, tslib_1.__param)(2, validator_1.val.partial("T")), | ||
(0, tslib_1.__param)(3, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "modify", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("put", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("put", ":id"), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("PID")), | ||
tslib_1.__param(1, validator_1.val.required()), | ||
tslib_1.__param(1, reflect_1.default.type("TID")), | ||
tslib_1.__param(2, core_1.api.hideRelations()), | ||
tslib_1.__param(2, reflect_1.default.type("T")), | ||
tslib_1.__param(3, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("PID")), | ||
(0, tslib_1.__param)(1, validator_1.val.required()), | ||
(0, tslib_1.__param)(1, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(2, core_1.api.hideRelations()), | ||
(0, tslib_1.__param)(2, reflect_1.default.type("T")), | ||
(0, tslib_1.__param)(3, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "replace", null); | ||
tslib_1.__decorate([ | ||
decorator_1.decorateRoute("delete", ":id"), | ||
(0, tslib_1.__decorate)([ | ||
(0, decorator_1.decorateRoute)("delete", ":id"), | ||
reflect_1.default.type(IdentifierResult, "TID"), | ||
tslib_1.__param(0, validator_1.val.required()), | ||
tslib_1.__param(0, reflect_1.default.type("PID")), | ||
tslib_1.__param(1, validator_1.val.required()), | ||
tslib_1.__param(1, reflect_1.default.type("TID")), | ||
tslib_1.__param(2, core_1.bind.ctx()), | ||
tslib_1.__metadata("design:type", Function), | ||
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]), | ||
tslib_1.__metadata("design:returntype", Promise) | ||
(0, tslib_1.__param)(0, validator_1.val.required()), | ||
(0, tslib_1.__param)(0, reflect_1.default.type("PID")), | ||
(0, tslib_1.__param)(1, validator_1.val.required()), | ||
(0, tslib_1.__param)(1, reflect_1.default.type("TID")), | ||
(0, tslib_1.__param)(2, core_1.bind.ctx()), | ||
(0, tslib_1.__metadata)("design:type", Function), | ||
(0, tslib_1.__metadata)("design:paramtypes", [Object, Object, Object]), | ||
(0, tslib_1.__metadata)("design:returntype", Promise) | ||
], RepoBaseNestedControllerGeneric.prototype, "delete", null); | ||
RepoBaseNestedControllerGeneric = tslib_1.__decorate([ | ||
RepoBaseNestedControllerGeneric = (0, tslib_1.__decorate)([ | ||
reflect_1.generic.parameter("P", "T", "PID", "TID"), | ||
tslib_1.__metadata("design:paramtypes", [Function]) | ||
(0, tslib_1.__metadata)("design:paramtypes", [Function]) | ||
], RepoBaseNestedControllerGeneric); | ||
exports.RepoBaseNestedControllerGeneric = RepoBaseNestedControllerGeneric; |
@@ -14,4 +14,4 @@ "use strict"; | ||
const config = typeof opt === "string" ? (x) => x.setPath(opt) : opt; | ||
return reflect_1.decorate((...args) => { | ||
helper_1.updateGenericControllerRegistry(args[0]); | ||
return (0, reflect_1.decorate)((...args) => { | ||
(0, helper_1.updateGenericControllerRegistry)(args[0]); | ||
return { target: args[0], name: "plumier-meta:controller", config }; | ||
@@ -26,3 +26,3 @@ }); | ||
function decorateRoute(method, path, option) { | ||
return reflect_1.decorate({ | ||
return (0, reflect_1.decorate)({ | ||
[reflect_1.DecoratorId]: RouteDecoratorID, | ||
@@ -36,4 +36,4 @@ name: "plumier-meta:route", | ||
function responseTransformer(target, transformer, opt) { | ||
return reflect_1.mergeDecorator(reflect_1.decorate({ kind: "plumier-meta:response-transformer", transformer }, ["Method", "Class"], opt), core_1.responseType(target, opt)); | ||
return (0, reflect_1.mergeDecorator)((0, reflect_1.decorate)({ kind: "plumier-meta:response-transformer", transformer }, ["Method", "Class"], opt), (0, core_1.responseType)(target, opt)); | ||
} | ||
exports.responseTransformer = responseTransformer; |
@@ -15,3 +15,3 @@ "use strict"; | ||
const keys = []; | ||
path_to_regexp_1.pathToRegexp(path, keys); | ||
(0, path_to_regexp_1.pathToRegexp)(path, keys); | ||
if (!oneToMany && keys.length > 1) | ||
@@ -39,12 +39,12 @@ throw new Error(core_1.errorMessage.CustomRouteMustHaveOneParameter.format(path, entity.name)); | ||
Reflect.decorate([ | ||
core_1.entityProvider(entity, "id", { applyTo: ["get", "modify", "replace", "delete"] }), | ||
configuration_1.ignoreActions(config), | ||
...configuration_1.createRouteDecorators(path, map), | ||
...configuration_1.authorizeActions(config), | ||
...configuration_1.decorateTransformers(config), | ||
...configuration_1.decorateCustomQuery(config), | ||
(0, core_1.entityProvider)(entity, "id", { applyTo: ["get", "modify", "replace", "delete"] }), | ||
(0, configuration_1.ignoreActions)(config), | ||
...(0, configuration_1.createRouteDecorators)(path, map), | ||
...(0, configuration_1.authorizeActions)(config), | ||
...(0, configuration_1.decorateTransformers)(config), | ||
...(0, configuration_1.decorateCustomQuery)(config), | ||
], Controller); | ||
if (!opt.skipTag) { | ||
Reflect.decorate([ | ||
...configuration_1.decorateTagByClass(entity, opt.nameConversion), | ||
...(0, configuration_1.decorateTagByClass)(entity, opt.nameConversion), | ||
], Controller); | ||
@@ -68,14 +68,14 @@ } | ||
// re-assign oneToMany decorator which will be used on OneToManyController constructor | ||
reflect_1.decorateClass({ kind: "plumier-meta:relation-prop-name", type: type[0], relation: type[1] }), | ||
configuration_1.ignoreActions(config), | ||
core_1.entityProvider(info.parent, "pid", { applyTo: ["list", "save"] }), | ||
core_1.entityProvider(info.child, "id", { applyTo: ["get", "modify", "replace", "delete"] }), | ||
...configuration_1.createRouteDecorators(path, map), | ||
...configuration_1.authorizeActions(config), | ||
...configuration_1.decorateTransformers(config), | ||
...configuration_1.decorateCustomQuery(config), | ||
(0, reflect_1.decorateClass)({ kind: "plumier-meta:relation-prop-name", type: type[0], relation: type[1] }), | ||
(0, configuration_1.ignoreActions)(config), | ||
(0, core_1.entityProvider)(info.parent, "pid", { applyTo: ["list", "save"] }), | ||
(0, core_1.entityProvider)(info.child, "id", { applyTo: ["get", "modify", "replace", "delete"] }), | ||
...(0, configuration_1.createRouteDecorators)(path, map), | ||
...(0, configuration_1.authorizeActions)(config), | ||
...(0, configuration_1.decorateTransformers)(config), | ||
...(0, configuration_1.decorateCustomQuery)(config), | ||
], Controller); | ||
if (!opt.skipTag) { | ||
Reflect.decorate([ | ||
...configuration_1.decorateTagByRelation(info, opt.nameConversion) | ||
...(0, configuration_1.decorateTagByRelation)(info, opt.nameConversion) | ||
], Controller); | ||
@@ -82,0 +82,0 @@ } |
@@ -5,3 +5,3 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const reflect_1 = tslib_1.__importDefault(require("@plumier/reflect")); | ||
const reflect_1 = (0, tslib_1.__importDefault)(require("@plumier/reflect")); | ||
const genericControllerRegistry = new Map(); | ||
@@ -15,3 +15,3 @@ exports.genericControllerRegistry = genericControllerRegistry; | ||
var _a; | ||
const meta = reflect_1.default(type); | ||
const meta = (0, reflect_1.default)(type); | ||
const method = meta.methods.find(x => methodName === x.name); | ||
@@ -22,3 +22,3 @@ return (_a = method.decorators.find((x) => x.kind === "plumier-meta:response-transformer")) === null || _a === void 0 ? void 0 : _a.transformer; | ||
function getOneCustomQuery(type) { | ||
const meta = reflect_1.default(type); | ||
const meta = (0, reflect_1.default)(type); | ||
const decorator = meta.decorators.find((x) => x.kind === "plumier-meta:get-one-query"); | ||
@@ -29,3 +29,3 @@ return decorator === null || decorator === void 0 ? void 0 : decorator.query; | ||
function getManyCustomQuery(type) { | ||
const meta = reflect_1.default(type); | ||
const meta = (0, reflect_1.default)(type); | ||
const decorator = meta.decorators.find((x) => x.kind === "plumier-meta:get-many-query"); | ||
@@ -32,0 +32,0 @@ return decorator === null || decorator === void 0 ? void 0 : decorator.query; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./configuration"), exports); | ||
tslib_1.__exportStar(require("./controllers"), exports); | ||
tslib_1.__exportStar(require("./factory"), exports); | ||
tslib_1.__exportStar(require("./helper"), exports); | ||
tslib_1.__exportStar(require("./request-hook"), exports); | ||
tslib_1.__exportStar(require("./route-generator"), exports); | ||
tslib_1.__exportStar(require("./decorator"), exports); | ||
(0, tslib_1.__exportStar)(require("./configuration"), exports); | ||
(0, tslib_1.__exportStar)(require("./controllers"), exports); | ||
(0, tslib_1.__exportStar)(require("./factory"), exports); | ||
(0, tslib_1.__exportStar)(require("./helper"), exports); | ||
(0, tslib_1.__exportStar)(require("./request-hook"), exports); | ||
(0, tslib_1.__exportStar)(require("./route-generator"), exports); | ||
(0, tslib_1.__exportStar)(require("./decorator"), exports); |
@@ -17,3 +17,3 @@ "use strict"; | ||
async function executeSingleHooks(ctx, kind, type, value) { | ||
const meta = reflect_1.reflect(type); | ||
const meta = (0, reflect_1.reflect)(type); | ||
const hooks = meta.methods.filter(x => x.decorators.some((x) => x.kind === "plumier-meta:request-hook" | ||
@@ -24,3 +24,3 @@ && x.type === kind | ||
// bind request hook parameters | ||
const pars = await core_1.binder(hook, ctx); | ||
const pars = await (0, core_1.binder)(hook, ctx); | ||
// execute hook | ||
@@ -27,0 +27,0 @@ await type.prototype[hook.name].apply(value, pars); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const core_1 = require("@plumier/core"); | ||
const reflect_1 = tslib_1.__importDefault(require("@plumier/reflect")); | ||
const reflect_1 = (0, tslib_1.__importDefault)(require("@plumier/reflect")); | ||
const configuration_1 = require("./configuration"); | ||
@@ -21,3 +21,3 @@ const factory_1 = require("./factory"); | ||
function createBasicGenericControllerByDecorators(type, genericControllers, nameConversion) { | ||
const meta = reflect_1.default(type); | ||
const meta = (0, reflect_1.default)(type); | ||
const controllers = []; | ||
@@ -28,3 +28,3 @@ // basic generic controller | ||
const builder = getControllerBuilderFromConfig(decorator.config); | ||
const ctl = factory_1.createGenericControllerType(type, { | ||
const ctl = (0, factory_1.createGenericControllerType)(type, { | ||
builder, | ||
@@ -40,3 +40,3 @@ controller: genericControllers[0], | ||
function createNestedGenericControllerByDecorators(entity, genericControllers, nameConversion) { | ||
const meta = reflect_1.default(entity); | ||
const meta = (0, reflect_1.default)(entity); | ||
const controllers = []; | ||
@@ -48,3 +48,3 @@ // one to many controller on each relation property | ||
const builder = getControllerBuilderFromConfig(decorator.config); | ||
const ctl = factory_1.createNestedGenericControllerType([decorator.target, prop.name], { | ||
const ctl = (0, factory_1.createNestedGenericControllerType)([decorator.target, prop.name], { | ||
builder, | ||
@@ -67,6 +67,6 @@ controller: genericControllers[1], | ||
async function extractController(controller, option) { | ||
const classes = await core_1.findClassRecursive(controller, option); | ||
const classes = await (0, core_1.findClassRecursive)(controller, option); | ||
const result = []; | ||
for (const cls of classes) { | ||
const meta = reflect_1.default(cls.type); | ||
const meta = (0, reflect_1.default)(cls.type); | ||
// entity marked with generic controller | ||
@@ -88,3 +88,3 @@ if (!!helper_1.genericControllerRegistry.get(meta.type)) { | ||
for (const controller of controllers) { | ||
routes.push(...core_1.transformController(controller.type, Object.assign(Object.assign({}, opt), { rootPath: core_1.appendRoute(controller.root, opt.rootPath) }))); | ||
routes.push(...(0, core_1.transformController)(controller.type, Object.assign(Object.assign({}, opt), { rootPath: (0, core_1.appendRoute)(controller.root, opt.rootPath) }))); | ||
} | ||
@@ -91,0 +91,0 @@ return routes; |
{ | ||
"name": "@plumier/generic-controller", | ||
"version": "1.0.5", | ||
"version": "1.0.6-canary.3+b235819", | ||
"description": "Plumier generic controller implementation", | ||
@@ -23,4 +23,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@plumier/core": "^1.0.5", | ||
"@plumier/query-parser": "^1.0.5" | ||
"@plumier/core": "1.0.6-canary.3+b235819", | ||
"@plumier/query-parser": "1.0.6-canary.3+b235819" | ||
}, | ||
@@ -40,3 +40,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "5f6d204483657909bac31851522176b2b500e583" | ||
"gitHead": "b2358195477eaafb0654e92c8605bc1ecf7a8350" | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
60235
2
1
- Removed@plumier/core@1.1.3(transitive)
- Removed@plumier/reflect@1.1.3(transitive)
- Removed@plumier/validator@1.1.3(transitive)
- Removed@types/accepts@1.3.7(transitive)
- Removed@types/acorn@4.0.6(transitive)
- Removed@types/body-parser@1.19.5(transitive)
- Removed@types/connect@3.4.38(transitive)
- Removed@types/content-disposition@0.5.8(transitive)
- Removed@types/cookies@0.9.0(transitive)
- Removed@types/debug@4.1.12(transitive)
- Removed@types/estree@1.0.6(transitive)
- Removed@types/express@5.0.0(transitive)
- Removed@types/express-serve-static-core@5.0.6(transitive)
- Removed@types/glob@7.2.0(transitive)
- Removed@types/http-assert@1.5.6(transitive)
- Removed@types/http-errors@2.0.4(transitive)
- Removed@types/keygrip@1.0.6(transitive)
- Removed@types/koa@2.15.0(transitive)
- Removed@types/koa-compose@3.2.8(transitive)
- Removed@types/mime@1.3.5(transitive)
- Removed@types/minimatch@5.1.2(transitive)
- Removed@types/ms@2.1.0(transitive)
- Removed@types/node@22.13.5(transitive)
- Removed@types/qs@6.9.18(transitive)
- Removed@types/range-parser@1.2.7(transitive)
- Removed@types/send@0.17.4(transitive)
- Removed@types/serve-static@1.15.7(transitive)
- Removed@types/validator@13.12.2(transitive)
- Removedacorn@8.8.1(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddebug@4.4.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedms@2.1.3(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-to-regexp@6.3.0(transitive)
- Removedreflect-metadata@0.1.14(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedtslib@2.8.1(transitive)
- Removedundici-types@6.20.0(transitive)
- Removedvalidator@13.12.0(transitive)
- Removedwrappy@1.0.2(transitive)