@apex-pub/convector-core-controller 1.4.1-4-alpha.808cd029 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/src/controller.decorator.js +3 -5
- package/dist/src/controller.decorator.js.map +1 -1
- package/dist/src/convector-controller.js +5 -3
- package/dist/src/convector-controller.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/invokable.decorator.js +98 -68
- package/dist/src/invokable.decorator.js.map +1 -1
- package/dist/src/optional.decorator.js +3 -5
- package/dist/src/optional.decorator.js.map +1 -1
- package/dist/src/param.decorator.js +9 -10
- package/dist/src/param.decorator.js.map +1 -1
- package/package.json +13 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
<a name="1.5.0"></a>
|
|
7
|
+
# 1.5.0 (2024-07-29)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **core-model,core-controller:** convector model to accept yup.lazy ([c7e67ed](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/c7e67ed)), closes [#50](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/50)
|
|
13
|
+
* error handlers for testing and chaincode ([ef9bae6](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/ef9bae6))
|
|
14
|
+
* handle global on browser environments ([44fcd22](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/44fcd22))
|
|
15
|
+
* invokable local call ([882e8d9](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/882e8d9))
|
|
16
|
+
* name collition for optional decorator ([2716c78](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/2716c78))
|
|
17
|
+
* update access public to the packages (pull request [#27](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/27)) ([f2eebde](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/f2eebde))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* Add documentation (pull request [#28](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/28)) ([fc8ddbc](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/fc8ddbc))
|
|
23
|
+
* allow internal calls for invokables ([84269cb](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/84269cb))
|
|
24
|
+
* export adapter-in-chaincode in fabric ([2b28edd](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/2b28edd))
|
|
25
|
+
* **core-chaincode,core-controller:** remove the use of fabric-client in controllers ([e5db472](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/e5db472)), closes [#37](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/37) [#34](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/34)
|
|
26
|
+
* flatten object invokable results ([9c90a9f](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/9c90a9f))
|
|
27
|
+
* group packages and update package.json's ([3971b44](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/3971b44))
|
|
28
|
+
* optional params on controllers ([cdf6782](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/cdf6782))
|
|
29
|
+
* Preparing versions for stable release (pull request [#25](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/25)) ([1f5a876](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/1f5a876))
|
|
30
|
+
* Production readiness (pull request [#48](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/48)) ([5bb7287](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/5bb7287))
|
|
31
|
+
* refactor convector client implementation and add browser support ([30ec673](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/30ec673))
|
|
32
|
+
* Refactor fabric logic (pull request [#24](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/24)) ([ec7f0ab](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/ec7f0ab))
|
|
33
|
+
* Rename logically (pull request [#21](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/issues/21)) ([d1a78ad](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/d1a78ad))
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const g = tslib_1.__importStar(require("window-or-global"));
|
|
6
|
-
const convector_core_errors_1 = require("@apex-pub/convector-core-errors");
|
|
3
|
+
var g = require("window-or-global");
|
|
4
|
+
var convector_core_errors_1 = require("@apex-pub/convector-core-errors");
|
|
7
5
|
require("reflect-metadata");
|
|
8
6
|
exports.controllerMetadataKey = g.ConvectorControllerMetadataKey || Symbol('controller');
|
|
9
7
|
g.ConvectorControllerMetadataKey = exports.controllerMetadataKey;
|
|
10
8
|
function Controller(namespace) {
|
|
11
|
-
return ctor
|
|
9
|
+
return function (ctor) {
|
|
12
10
|
if (typeof ctor !== 'function') {
|
|
13
11
|
throw new convector_core_errors_1.ControllerInvalidError(namespace);
|
|
14
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.decorator.js","sourceRoot":"","sources":["../../src/controller.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.decorator.js","sourceRoot":"","sources":["../../src/controller.decorator.ts"],"names":[],"mappings":";;AAEA,oCAAsC;AACtC,yEAAyE;AACzE,4BAA0B;AAGb,QAAA,qBAAqB,GAAG,CAAC,CAAC,8BAA8B,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAC9F,CAAC,CAAC,8BAA8B,GAAG,6BAAqB,CAAC;AAWzD,oBAA2B,SAAiB;IAC1C,OAAO,UAAA,IAAI;QACT,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;YAC9B,MAAM,IAAI,8CAAsB,CAAC,SAAS,CAAC,CAAC;SAC7C;QAED,OAAO,CAAC,cAAc,CAAC,6BAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC;AACJ,CAAC;AARD,gCAQC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
var ConvectorController = (function () {
|
|
4
|
+
function ConvectorController() {
|
|
5
|
+
}
|
|
6
|
+
return ConvectorController;
|
|
7
|
+
}());
|
|
6
8
|
exports.ConvectorController = ConvectorController;
|
|
7
9
|
//# sourceMappingURL=convector-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convector-controller.js","sourceRoot":"","sources":["../../src/convector-controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convector-controller.js","sourceRoot":"","sources":["../../src/convector-controller.ts"],"names":[],"mappings":";;AAGA;IAAA;IAYA,CAAC;IAAD,0BAAC;AAAD,CAAC,AAZD,IAYC;AAZqB,kDAAmB"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./param.decorator"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./invokable.decorator"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./optional.decorator"), exports);
|
|
@@ -1,86 +1,116 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const convector_core_errors_1 = require("@apex-pub/convector-core-errors");
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var g = require("window-or-global");
|
|
5
|
+
var convector_core_errors_1 = require("@apex-pub/convector-core-errors");
|
|
7
6
|
require("reflect-metadata");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
var param_decorator_1 = require("./param.decorator");
|
|
8
|
+
var optional_decorator_1 = require("./optional.decorator");
|
|
9
|
+
var controller_decorator_1 = require("./controller.decorator");
|
|
11
10
|
exports.invokableMetadataKey = g.ConvectorInvokableMetadataKey || Symbol('invokable');
|
|
12
11
|
g.ConvectorInvokableMetadataKey = exports.invokableMetadataKey;
|
|
13
12
|
function Invokable() {
|
|
14
|
-
return (target, key, descriptor)
|
|
15
|
-
|
|
13
|
+
return function (target, key, descriptor) {
|
|
14
|
+
var fn = descriptor.value;
|
|
16
15
|
if (typeof fn !== 'function') {
|
|
17
16
|
throw new convector_core_errors_1.ControllerInvalidFunctionError();
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
Reflect.defineMetadata(exports.invokableMetadataKey,
|
|
21
|
-
descriptor.value = function internalFn(_, args, extras
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (args[index] === undefined) {
|
|
38
|
-
if (optionals.indexOf(index) === -1) {
|
|
39
|
-
throw new convector_core_errors_1.ControllerUndefinedArgumentError(index);
|
|
40
|
-
}
|
|
41
|
-
return [...yield result, undefined];
|
|
42
|
-
}
|
|
43
|
-
try {
|
|
44
|
-
if (opts.update) {
|
|
45
|
-
paramResult = schema.cast(args[index], opts);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
paramResult = yield schema.validate(args[index], opts);
|
|
18
|
+
var invokables = Reflect.getMetadata(exports.invokableMetadataKey, target.constructor) || {};
|
|
19
|
+
Reflect.defineMetadata(exports.invokableMetadataKey, tslib_1.__assign({}, invokables, (_a = {}, _a[key] = true, _a)), target.constructor);
|
|
20
|
+
descriptor.value = function internalFn(_, args, extras) {
|
|
21
|
+
var rest = [];
|
|
22
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
23
|
+
rest[_i - 3] = arguments[_i];
|
|
24
|
+
}
|
|
25
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
26
|
+
var _this = this;
|
|
27
|
+
var internalCall, schemas, optionals_1, namespace, ctx, response, e_1, error;
|
|
28
|
+
return tslib_1.__generator(this, function (_a) {
|
|
29
|
+
switch (_a.label) {
|
|
30
|
+
case 0:
|
|
31
|
+
internalCall = false;
|
|
32
|
+
if ('_internal_invokable' in this) {
|
|
33
|
+
args = [_, args, extras].concat(rest).filter(function (param) { return param !== undefined; });
|
|
34
|
+
internalCall = true;
|
|
35
|
+
extras = {};
|
|
49
36
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
paramResult = new model(JSON.parse(args[index]));
|
|
37
|
+
schemas = Reflect.getOwnMetadata(param_decorator_1.paramMetadataKey, target, key);
|
|
38
|
+
if (!schemas) return [3, 2];
|
|
39
|
+
optionals_1 = Reflect.getOwnMetadata(optional_decorator_1.optionalMetadataKey, target, key) || [];
|
|
40
|
+
if (schemas.length - optionals_1.length > args.length) {
|
|
41
|
+
throw new convector_core_errors_1.ControllerInvalidInvokeError(key, args.length, schemas.length - optionals_1.length);
|
|
57
42
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
43
|
+
return [4, schemas.reduce(function (result, _a, index) {
|
|
44
|
+
var schema = _a[0], opts = _a[1], model = _a[2];
|
|
45
|
+
return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
46
|
+
var paramResult, e_2;
|
|
47
|
+
return tslib_1.__generator(this, function (_b) {
|
|
48
|
+
switch (_b.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
if (!(args[index] === undefined)) return [3, 2];
|
|
51
|
+
if (optionals_1.indexOf(index) === -1) {
|
|
52
|
+
throw new convector_core_errors_1.ControllerUndefinedArgumentError(index);
|
|
53
|
+
}
|
|
54
|
+
return [4, result];
|
|
55
|
+
case 1: return [2, (_b.sent()).concat([undefined])];
|
|
56
|
+
case 2:
|
|
57
|
+
_b.trys.push([2, 6, , 7]);
|
|
58
|
+
if (!opts.update) return [3, 3];
|
|
59
|
+
paramResult = schema.cast(args[index], opts);
|
|
60
|
+
return [3, 5];
|
|
61
|
+
case 3: return [4, schema.validate(args[index], opts)];
|
|
62
|
+
case 4:
|
|
63
|
+
paramResult = _b.sent();
|
|
64
|
+
_b.label = 5;
|
|
65
|
+
case 5: return [3, 7];
|
|
66
|
+
case 6:
|
|
67
|
+
e_2 = _b.sent();
|
|
68
|
+
throw new convector_core_errors_1.ControllerInvalidArgumentError(e_2, index, args[index]);
|
|
69
|
+
case 7:
|
|
70
|
+
if (model) {
|
|
71
|
+
try {
|
|
72
|
+
paramResult = new model(JSON.parse(args[index]));
|
|
73
|
+
}
|
|
74
|
+
catch (e) {
|
|
75
|
+
throw new convector_core_errors_1.ControllerArgumentParseError(e, index, args[index]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return [4, result];
|
|
79
|
+
case 8: return [2, (_b.sent()).concat([paramResult])];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}, Promise.resolve([]))];
|
|
84
|
+
case 1:
|
|
85
|
+
args = _a.sent();
|
|
86
|
+
_a.label = 2;
|
|
87
|
+
case 2:
|
|
88
|
+
namespace = Reflect.getMetadata(controller_decorator_1.controllerMetadataKey, target.constructor);
|
|
89
|
+
ctx = Object.create(internalCall ? this : this[namespace], tslib_1.__assign({}, (extras || {}), { _internal_invokable: { value: true } }));
|
|
90
|
+
_a.label = 3;
|
|
91
|
+
case 3:
|
|
92
|
+
_a.trys.push([3, 5, , 6]);
|
|
93
|
+
return [4, fn.call.apply(fn, [ctx].concat(args))];
|
|
94
|
+
case 4:
|
|
95
|
+
response = _a.sent();
|
|
96
|
+
return [2, typeof response === 'object' ? JSON.parse(JSON.stringify(response)) : response];
|
|
97
|
+
case 5:
|
|
98
|
+
e_1 = _a.sent();
|
|
99
|
+
error = new Error(e_1.message);
|
|
100
|
+
error.stack = e_1.stack;
|
|
101
|
+
throw error;
|
|
102
|
+
case 6: return [2];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
76
105
|
});
|
|
77
106
|
};
|
|
107
|
+
var _a;
|
|
78
108
|
};
|
|
79
109
|
}
|
|
80
110
|
exports.Invokable = Invokable;
|
|
81
111
|
function getInvokables(controller) {
|
|
82
|
-
|
|
83
|
-
|
|
112
|
+
var namespace;
|
|
113
|
+
var invokables;
|
|
84
114
|
try {
|
|
85
115
|
namespace = Reflect.getMetadata(controller_decorator_1.controllerMetadataKey, controller);
|
|
86
116
|
if (!namespace) {
|
|
@@ -100,8 +130,8 @@ function getInvokables(controller) {
|
|
|
100
130
|
throw new convector_core_errors_1.ControllerInvokablesMissingError(e, namespace);
|
|
101
131
|
}
|
|
102
132
|
return {
|
|
103
|
-
invokables,
|
|
104
|
-
namespace
|
|
133
|
+
invokables: invokables,
|
|
134
|
+
namespace: namespace
|
|
105
135
|
};
|
|
106
136
|
}
|
|
107
137
|
exports.getInvokables = getInvokables;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invokable.decorator.js","sourceRoot":"","sources":["../../src/invokable.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invokable.decorator.js","sourceRoot":"","sources":["../../src/invokable.decorator.ts"],"names":[],"mappings":";;;AAGA,oCAAsC;AACtC,yEAQyC;AACzC,4BAA0B;AAE1B,qDAAqD;AACrD,2DAA2D;AAE3D,+DAA+D;AAGlD,QAAA,oBAAoB,GAAG,CAAC,CAAC,6BAA6B,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;AAC3F,CAAC,CAAC,6BAA6B,GAAG,4BAAoB,CAAC;AAavD;IACE,OAAO,UACL,MAAW,EACX,GAAW,EACX,UAAqE;QAErE,IAAM,EAAE,GAAG,UAAU,CAAC,KAAM,CAAC;QAE7B,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC5B,MAAM,IAAI,sDAA8B,EAAE,CAAC;SAC5C;QAED,IAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,4BAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACvF,OAAO,CAAC,cAAc,CAAC,4BAAoB,uBACtC,UAAU,eACZ,GAAG,IAAG,IAAI,QACV,MAAM,CAAC,WAAW,CAAC,CAAC;QAGvB,UAAU,CAAC,KAAK,GAAG,oBAGjB,CAAM,EACN,IAAc,EACd,MAAW;YACX,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,6BAAc;;;;;;;;4BAEV,YAAY,GAAG,KAAK,CAAC;4BAEzB,IAAI,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;;4BAEhF,KAAK,GAAG,IAAI,KAAK,CAAC,GAAC,CAAC,OAAO,CAAC,CAAC;4BACnC,KAAK,CAAC,KAAK,GAAG,GAAC,CAAC,KAAK,CAAC;4BACtB,MAAM,KAAK,CAAC;;;;;SAEf,CAAC;;IACJ,CAAC,CAAC;AACJ,CAAC;AA/FD,8BA+FC;AAYD,uBAA8B,UAAuD;IAInF,IAAI,SAAiB,CAAC;IACtB,IAAI,UAAe,CAAC;IAEpB,IAAI;QACF,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,4CAAqB,EAAE,UAAU,CAAC,CAAC;QAEnE,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,SAAS,EAAE,CAAC;SACvB;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,uDAA+B,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;KAC/D;IAED,IAAI;QACF,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,4BAAoB,EAAE,UAAU,CAAC,CAAC;QAEnE,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,SAAS,EAAE,CAAC;SACvB;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,wDAAgC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;KAC1D;IAED,OAAO;QACL,UAAU,YAAA;QACV,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AA/BD,sCA+BC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const g = tslib_1.__importStar(require("window-or-global"));
|
|
3
|
+
var g = require("window-or-global");
|
|
6
4
|
require("reflect-metadata");
|
|
7
5
|
exports.optionalMetadataKey = g.ConvectorOptionalParamMetadataKey || Symbol('optional-param');
|
|
8
6
|
g.ConvectorOptionalParamMetadataKey = exports.optionalMetadataKey;
|
|
9
7
|
function OptionalParam() {
|
|
10
|
-
return (target, propertyKey, parameterIndex)
|
|
11
|
-
|
|
8
|
+
return function (target, propertyKey, parameterIndex) {
|
|
9
|
+
var optionals = Reflect.getOwnMetadata(exports.optionalMetadataKey, target, propertyKey) || [];
|
|
12
10
|
optionals.push(parameterIndex);
|
|
13
11
|
Reflect.defineMetadata(exports.optionalMetadataKey, optionals, target, propertyKey);
|
|
14
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.decorator.js","sourceRoot":"","sources":["../../src/optional.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optional.decorator.js","sourceRoot":"","sources":["../../src/optional.decorator.ts"],"names":[],"mappings":";;AAEA,oCAAsC;AACtC,4BAA0B;AAGb,QAAA,mBAAmB,GAAG,CAAC,CAAC,iCAAiC,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACnG,CAAC,CAAC,iCAAiC,GAAG,2BAAmB,CAAC;AAO1D;IACE,OAAO,UAAC,MAAW,EAAE,WAAmB,EAAE,cAAsB;QAE9D,IAAM,SAAS,GACb,OAAO,CAAC,cAAc,CAAC,2BAAmB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAEzE,SAAS,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/B,OAAO,CAAC,cAAc,CAAC,2BAAmB,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC9E,CAAC,CAAC;AACJ,CAAC;AATD,sCASC"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const g = tslib_1.__importStar(require("window-or-global"));
|
|
6
|
-
const yup_1 = require("yup");
|
|
3
|
+
var g = require("window-or-global");
|
|
4
|
+
var yup_1 = require("yup");
|
|
7
5
|
require("reflect-metadata");
|
|
8
|
-
|
|
6
|
+
var isSchema = function (schema) { return 'validate' in schema; };
|
|
9
7
|
exports.paramMetadataKey = g.ConvectorParamMetadataKey || Symbol('param');
|
|
10
8
|
g.ConvectorParamMetadataKey = exports.paramMetadataKey;
|
|
11
|
-
function Param(model, opts
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
function Param(model, opts) {
|
|
10
|
+
if (opts === void 0) { opts = { context: {} }; }
|
|
11
|
+
return function (target, propertyKey, parameterIndex) {
|
|
12
|
+
var schemas = Reflect.getOwnMetadata(exports.paramMetadataKey, target, propertyKey) || [];
|
|
13
|
+
var schema = isSchema(model) ? model : yup_1.object()
|
|
14
|
+
.transform(function (value) { return value instanceof model ? value : new model(value); });
|
|
16
15
|
schemas[parameterIndex] = [schema, opts, !isSchema(model) && model];
|
|
17
16
|
Reflect.defineMetadata(exports.paramMetadataKey, schemas, target, propertyKey);
|
|
18
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"param.decorator.js","sourceRoot":"","sources":["../../src/param.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"param.decorator.js","sourceRoot":"","sources":["../../src/param.decorator.ts"],"names":[],"mappings":";;AAEA,oCAAsC;AACtC,2BAAqC;AACrC,4BAA0B;AAG1B,IAAM,QAAQ,GAAG,UAAC,MAAW,IAA4B,OAAA,UAAU,IAAI,MAAM,EAApB,CAAoB,CAAC;AAGjE,QAAA,gBAAgB,GAAG,CAAC,CAAC,yBAAyB,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/E,CAAC,CAAC,yBAAyB,GAAG,wBAAgB,CAAC;AAmB/C,eACE,KAA2C,EAC3C,IAA2B;IAA3B,qBAAA,EAAA,SAAc,OAAO,EAAE,EAAE,EAAE;IAE3B,OAAO,UAAC,MAAW,EAAE,WAAmB,EAAE,cAAsB;QAE9D,IAAM,OAAO,GACX,OAAO,CAAC,cAAc,CAAC,wBAAgB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAEtE,IAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAM,EAAE;aAC9C,SAAS,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,EAAjD,CAAiD,CAAC,CAAC;QAEzE,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC;QACpE,OAAO,CAAC,cAAc,CAAC,wBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC,CAAC;AACJ,CAAC;AAfD,sBAeC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apex-pub/convector-core-controller",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Convector Controller base class",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -50,12 +50,21 @@
|
|
|
50
50
|
"reflect-metadata": ">=0.1.12"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@apex-pub/convector-core-errors": "1.
|
|
54
|
-
"@apex-pub/convector-core-model": "1.
|
|
53
|
+
"@apex-pub/convector-core-errors": "^1.5.0",
|
|
54
|
+
"@apex-pub/convector-core-model": "^1.5.0",
|
|
55
|
+
"tslib": "^1.9.0",
|
|
55
56
|
"window-or-global": "^1.0.1",
|
|
56
57
|
"yup": "^0.26.10"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"
|
|
60
|
+
"http-server": "^0.11.1",
|
|
61
|
+
"mocha": "^5.0.3",
|
|
62
|
+
"npm-scripts-watcher": "^1.0.2",
|
|
63
|
+
"reflect-metadata": "^0.1.12",
|
|
64
|
+
"rimraf": "^2.6.2",
|
|
65
|
+
"ts-node": "^6.0.3",
|
|
66
|
+
"tslint": "^5.9.1",
|
|
67
|
+
"typedoc": "^0.11.1",
|
|
68
|
+
"typescript": "2.8.3"
|
|
60
69
|
}
|
|
61
70
|
}
|