@worldsibu/convector-core-controller
Advanced tools
Comparing version 1.3.9-0-alpha.e0bbcdd5 to 1.3.9-0-alpha.f0328439
export * from './param.decorator'; | ||
export * from './invokable.decorator'; | ||
export * from './optional.decorator'; | ||
export * from './controller.decorator'; | ||
export * from './convector-controller'; |
@@ -6,5 +6,4 @@ "use strict"; | ||
tslib_1.__exportStar(require("./invokable.decorator"), exports); | ||
tslib_1.__exportStar(require("./optional.decorator"), exports); | ||
tslib_1.__exportStar(require("./controller.decorator"), exports); | ||
tslib_1.__exportStar(require("./convector-controller"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,2 @@ "use strict"; | ||
var param_decorator_1 = require("./param.decorator"); | ||
var optional_decorator_1 = require("./optional.decorator"); | ||
var controller_decorator_1 = require("./controller.decorator"); | ||
@@ -22,23 +21,13 @@ exports.invokableMetadataKey = g.ConvectorInvokableMetadataKey || Symbol('invokable'); | ||
descriptor.value = function internalFn(_, args, extras) { | ||
var rest = []; | ||
for (var _i = 3; _i < arguments.length; _i++) { | ||
rest[_i - 3] = arguments[_i]; | ||
} | ||
if (extras === void 0) { extras = {}; } | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
var internalCall, schemas, optionals_1, namespace, ctx, response, e_1, error; | ||
var schemas, namespace, ctx, e_1, error; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
internalCall = false; | ||
if ('_internal_invokable' in this) { | ||
args = [_, args, extras].concat(rest).filter(function (param) { return param !== undefined; }); | ||
internalCall = true; | ||
extras = {}; | ||
} | ||
schemas = Reflect.getOwnMetadata(param_decorator_1.paramMetadataKey, target, key); | ||
if (!schemas) return [3, 2]; | ||
optionals_1 = Reflect.getOwnMetadata(optional_decorator_1.optionalMetadataKey, target, key) || []; | ||
if (schemas.length - optionals_1.length > args.length) { | ||
throw new convector_core_errors_1.ControllerInvalidInvokeError(key, args.length, schemas.length - optionals_1.length); | ||
if (schemas.length !== args.length) { | ||
throw new convector_core_errors_1.ControllerInvalidInvokeError(key, args.length, schemas.length); | ||
} | ||
@@ -52,22 +41,15 @@ return [4, schemas.reduce(function (result, _a, index) { | ||
case 0: | ||
if (!(args[index] === undefined)) return [3, 2]; | ||
if (optionals_1.indexOf(index) === -1) { | ||
throw new convector_core_errors_1.ControllerUndefinedArgumentError(index); | ||
} | ||
return [4, result]; | ||
case 1: return [2, (_b.sent()).concat([undefined])]; | ||
_b.trys.push([0, 4, , 5]); | ||
if (!opts.update) return [3, 1]; | ||
paramResult = schema.cast(args[index], opts); | ||
return [3, 3]; | ||
case 1: return [4, schema.validate(args[index], opts)]; | ||
case 2: | ||
_b.trys.push([2, 6, , 7]); | ||
if (!opts.update) return [3, 3]; | ||
paramResult = schema.cast(args[index], opts); | ||
return [3, 5]; | ||
case 3: return [4, schema.validate(args[index], opts)]; | ||
paramResult = _b.sent(); | ||
_b.label = 3; | ||
case 3: return [3, 5]; | ||
case 4: | ||
paramResult = _b.sent(); | ||
_b.label = 5; | ||
case 5: return [3, 7]; | ||
case 6: | ||
e_2 = _b.sent(); | ||
throw new convector_core_errors_1.ControllerInvalidArgumentError(e_2, index, args[index]); | ||
case 7: | ||
case 5: | ||
if (model) { | ||
@@ -82,3 +64,3 @@ try { | ||
return [4, result]; | ||
case 8: return [2, (_b.sent()).concat([paramResult])]; | ||
case 6: return [2, (_b.sent()).concat([paramResult])]; | ||
} | ||
@@ -93,3 +75,3 @@ }); | ||
namespace = Reflect.getMetadata(controller_decorator_1.controllerMetadataKey, target.constructor); | ||
ctx = Object.create(internalCall ? this : this[namespace], tslib_1.__assign({}, (extras || {}), { _internal_invokable: { value: true } })); | ||
ctx = Object.create(this[namespace], extras); | ||
_a.label = 3; | ||
@@ -99,5 +81,3 @@ case 3: | ||
return [4, fn.call.apply(fn, [ctx].concat(args))]; | ||
case 4: | ||
response = _a.sent(); | ||
return [2, typeof response === 'object' ? JSON.parse(JSON.stringify(response)) : response]; | ||
case 4: return [2, _a.sent()]; | ||
case 5: | ||
@@ -104,0 +84,0 @@ e_1 = _a.sent(); |
{ | ||
"name": "@worldsibu/convector-core-controller", | ||
"version": "1.3.9-0-alpha.e0bbcdd5", | ||
"version": "1.3.9-0-alpha.f0328439", | ||
"description": "Convector Controller base class", | ||
@@ -53,4 +53,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@worldsibu/convector-core-errors": "1.3.9-0-alpha.e0bbcdd5", | ||
"@worldsibu/convector-core-model": "1.3.9-0-alpha.e0bbcdd5", | ||
"@worldsibu/convector-core-errors": "1.3.9-0-alpha.f0328439", | ||
"@worldsibu/convector-core-model": "1.3.9-0-alpha.f0328439", | ||
"tslib": "^1.9.0", | ||
@@ -57,0 +57,0 @@ "window-or-global": "^1.0.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
28051
18
194
+ Added@worldsibu/convector-core-errors@1.3.9-0-alpha.f0328439(transitive)
+ Added@worldsibu/convector-core-model@1.3.9-0-alpha.f0328439(transitive)
+ Added@worldsibu/convector-core-storage@1.3.9-0-alpha.f0328439(transitive)
- Removed@worldsibu/convector-core-errors@1.3.9-0-alpha.e0bbcdd5(transitive)
- Removed@worldsibu/convector-core-model@1.3.9-0-alpha.e0bbcdd5(transitive)
- Removed@worldsibu/convector-core-storage@1.3.9-0-alpha.e0bbcdd5(transitive)
Updated@worldsibu/convector-core-errors@1.3.9-0-alpha.f0328439
Updated@worldsibu/convector-core-model@1.3.9-0-alpha.f0328439