@apex-pub/convector-core-controller 1.5.1 → 2.0.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/dist/src/controller.decorator.js +5 -3
- package/dist/src/controller.decorator.js.map +1 -1
- package/dist/src/convector-controller.js +3 -5
- package/dist/src/convector-controller.js.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/invokable.decorator.js +72 -98
- package/dist/src/invokable.decorator.js.map +1 -1
- package/dist/src/optional.decorator.js +5 -3
- package/dist/src/optional.decorator.js.map +1 -1
- package/dist/src/param.decorator.js +10 -9
- package/dist/src/param.decorator.js.map +1 -1
- package/package.json +10 -9
- package/CHANGELOG.md +0 -44
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exports.Controller = exports.controllerMetadataKey = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const g = tslib_1.__importStar(require("window-or-global"));
|
|
6
|
+
const convector_core_errors_1 = require("@apex-pub/convector-core-errors");
|
|
5
7
|
require("reflect-metadata");
|
|
6
8
|
exports.controllerMetadataKey = g.ConvectorControllerMetadataKey || Symbol('controller');
|
|
7
9
|
g.ConvectorControllerMetadataKey = exports.controllerMetadataKey;
|
|
8
10
|
function Controller(namespace) {
|
|
9
|
-
return
|
|
11
|
+
return ctor => {
|
|
10
12
|
if (typeof ctor !== 'function') {
|
|
11
13
|
throw new convector_core_errors_1.ControllerInvalidError(namespace);
|
|
12
14
|
}
|
|
@@ -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,4DAAsC;AACtC,2EAAyE;AACzE,4BAA0B;AAGb,QAAA,qBAAqB,GAAG,CAAC,CAAC,8BAA8B,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAC9F,CAAC,CAAC,8BAA8B,GAAG,6BAAqB,CAAC;AAWzD,SAAgB,UAAU,CAAC,SAAiB;IAC1C,OAAO,IAAI,CAAC,EAAE;QACZ,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;YAC/B,MAAM,IAAI,8CAAsB,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,CAAC,cAAc,CAAC,6BAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC;AACJ,CAAC;AARD,gCAQC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return ConvectorController;
|
|
7
|
-
}());
|
|
3
|
+
exports.ConvectorController = void 0;
|
|
4
|
+
class ConvectorController {
|
|
5
|
+
}
|
|
8
6
|
exports.ConvectorController = ConvectorController;
|
|
9
7
|
//# 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,MAAsB,mBAAmB;CAYxC;AAZD,kDAYC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const 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,116 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.getInvokables = exports.Invokable = exports.invokableMetadataKey = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const g = tslib_1.__importStar(require("window-or-global"));
|
|
6
|
+
const convector_core_errors_1 = require("@apex-pub/convector-core-errors");
|
|
6
7
|
require("reflect-metadata");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const param_decorator_1 = require("./param.decorator");
|
|
9
|
+
const optional_decorator_1 = require("./optional.decorator");
|
|
10
|
+
const controller_decorator_1 = require("./controller.decorator");
|
|
10
11
|
exports.invokableMetadataKey = g.ConvectorInvokableMetadataKey || Symbol('invokable');
|
|
11
12
|
g.ConvectorInvokableMetadataKey = exports.invokableMetadataKey;
|
|
12
13
|
function Invokable() {
|
|
13
|
-
return
|
|
14
|
-
|
|
14
|
+
return (target, key, descriptor) => {
|
|
15
|
+
const fn = descriptor.value;
|
|
15
16
|
if (typeof fn !== 'function') {
|
|
16
17
|
throw new convector_core_errors_1.ControllerInvalidFunctionError();
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
Reflect.defineMetadata(exports.invokableMetadataKey,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const invokables = Reflect.getMetadata(exports.invokableMetadataKey, target.constructor) || {};
|
|
20
|
+
Reflect.defineMetadata(exports.invokableMetadataKey, {
|
|
21
|
+
...invokables,
|
|
22
|
+
[key]: true
|
|
23
|
+
}, target.constructor);
|
|
24
|
+
descriptor.value = async function internalFn(_, args, extras, ...rest) {
|
|
25
|
+
let internalCall = false;
|
|
26
|
+
if ('_internal_invokable' in this) {
|
|
27
|
+
args = [_, args, extras, ...rest].filter(param => param !== undefined);
|
|
28
|
+
internalCall = true;
|
|
29
|
+
extras = {};
|
|
24
30
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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);
|
|
42
|
-
}
|
|
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];
|
|
31
|
+
const schemas = Reflect.getOwnMetadata(param_decorator_1.paramMetadataKey, target, key);
|
|
32
|
+
if (schemas) {
|
|
33
|
+
const optionals = Reflect.getOwnMetadata(optional_decorator_1.optionalMetadataKey, target, key) || [];
|
|
34
|
+
if (schemas.length - optionals.length > args.length) {
|
|
35
|
+
throw new convector_core_errors_1.ControllerInvalidInvokeError(key, args.length, schemas.length - optionals.length);
|
|
36
|
+
}
|
|
37
|
+
args = await schemas.reduce(async (result, [schema, opts, model], index) => {
|
|
38
|
+
let paramResult;
|
|
39
|
+
if (args[index] === undefined) {
|
|
40
|
+
if (optionals.indexOf(index) === -1) {
|
|
41
|
+
throw new convector_core_errors_1.ControllerUndefinedArgumentError(index);
|
|
42
|
+
}
|
|
43
|
+
return [...await result, undefined];
|
|
103
44
|
}
|
|
104
|
-
|
|
45
|
+
try {
|
|
46
|
+
if (opts.update) {
|
|
47
|
+
paramResult = schema.cast(args[index], opts);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
paramResult = await schema.validate(args[index], opts);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
throw new convector_core_errors_1.ControllerInvalidArgumentError(e, index, args[index]);
|
|
55
|
+
}
|
|
56
|
+
if (model) {
|
|
57
|
+
try {
|
|
58
|
+
paramResult = new model(JSON.parse(args[index]));
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
throw new convector_core_errors_1.ControllerArgumentParseError(e, index, args[index]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return [...await result, paramResult];
|
|
65
|
+
}, Promise.resolve([]));
|
|
66
|
+
}
|
|
67
|
+
const namespace = Reflect.getMetadata(controller_decorator_1.controllerMetadataKey, target.constructor);
|
|
68
|
+
const ctx = Object.create(internalCall ? this : this[namespace], {
|
|
69
|
+
...(extras || {}),
|
|
70
|
+
_internal_invokable: { value: true }
|
|
105
71
|
});
|
|
72
|
+
try {
|
|
73
|
+
const response = await fn.call(ctx, ...args);
|
|
74
|
+
return typeof response === 'object' ? JSON.parse(JSON.stringify(response)) : response;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
const error = new Error(e.message);
|
|
78
|
+
error.stack = e.stack;
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
106
81
|
};
|
|
107
|
-
var _a;
|
|
108
82
|
};
|
|
109
83
|
}
|
|
110
84
|
exports.Invokable = Invokable;
|
|
111
85
|
function getInvokables(controller) {
|
|
112
|
-
|
|
113
|
-
|
|
86
|
+
let namespace;
|
|
87
|
+
let invokables;
|
|
114
88
|
try {
|
|
115
89
|
namespace = Reflect.getMetadata(controller_decorator_1.controllerMetadataKey, controller);
|
|
116
90
|
if (!namespace) {
|
|
@@ -130,8 +104,8 @@ function getInvokables(controller) {
|
|
|
130
104
|
throw new convector_core_errors_1.ControllerInvokablesMissingError(e, namespace);
|
|
131
105
|
}
|
|
132
106
|
return {
|
|
133
|
-
invokables
|
|
134
|
-
namespace
|
|
107
|
+
invokables,
|
|
108
|
+
namespace
|
|
135
109
|
};
|
|
136
110
|
}
|
|
137
111
|
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,4DAAsC;AACtC,2EAQyC;AACzC,4BAA0B;AAE1B,uDAAqD;AACrD,6DAA2D;AAE3D,iEAA+D;AAGlD,QAAA,oBAAoB,GAAG,CAAC,CAAC,6BAA6B,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;AAC3F,CAAC,CAAC,6BAA6B,GAAG,4BAAoB,CAAC;AAavD,SAAgB,SAAS;IACvB,OAAO,CACL,MAAW,EACX,GAAW,EACX,UAAqE,EACrE,EAAE;QACF,MAAM,EAAE,GAAG,UAAU,CAAC,KAAM,CAAC;QAE7B,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,sDAA8B,EAAE,CAAC;QAC7C,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,4BAAoB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACvF,OAAO,CAAC,cAAc,CAAC,4BAAoB,EAAE;YAC3C,GAAG,UAAU;YACb,CAAC,GAAG,CAAC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;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,wDAAgC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO;QACL,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC;AA/BD,sCA+BC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.OptionalParam = exports.optionalMetadataKey = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const g = tslib_1.__importStar(require("window-or-global"));
|
|
4
6
|
require("reflect-metadata");
|
|
5
7
|
exports.optionalMetadataKey = g.ConvectorOptionalParamMetadataKey || Symbol('optional-param');
|
|
6
8
|
g.ConvectorOptionalParamMetadataKey = exports.optionalMetadataKey;
|
|
7
9
|
function OptionalParam() {
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
+
return (target, propertyKey, parameterIndex) => {
|
|
11
|
+
const optionals = Reflect.getOwnMetadata(exports.optionalMetadataKey, target, propertyKey) || [];
|
|
10
12
|
optionals.push(parameterIndex);
|
|
11
13
|
Reflect.defineMetadata(exports.optionalMetadataKey, optionals, target, propertyKey);
|
|
12
14
|
};
|
|
@@ -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,4DAAsC;AACtC,4BAA0B;AAGb,QAAA,mBAAmB,GAAG,CAAC,CAAC,iCAAiC,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACnG,CAAC,CAAC,iCAAiC,GAAG,2BAAmB,CAAC;AAO1D,SAAgB,aAAa;IAC3B,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,cAAsB,EAAE,EAAE;QAElE,MAAM,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,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
exports.Param = exports.paramMetadataKey = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const g = tslib_1.__importStar(require("window-or-global"));
|
|
6
|
+
const yup_1 = require("yup");
|
|
5
7
|
require("reflect-metadata");
|
|
6
|
-
|
|
8
|
+
const isSchema = (schema) => 'validate' in schema;
|
|
7
9
|
exports.paramMetadataKey = g.ConvectorParamMetadataKey || Symbol('param');
|
|
8
10
|
g.ConvectorParamMetadataKey = exports.paramMetadataKey;
|
|
9
|
-
function Param(model, opts) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.transform(function (value) { return value instanceof model ? value : new model(value); });
|
|
11
|
+
function Param(model, opts = { context: {} }) {
|
|
12
|
+
return (target, propertyKey, parameterIndex) => {
|
|
13
|
+
const schemas = Reflect.getOwnMetadata(exports.paramMetadataKey, target, propertyKey) || [];
|
|
14
|
+
const schema = isSchema(model) ? model : (0, yup_1.object)()
|
|
15
|
+
.transform(value => value instanceof model ? value : new model(value));
|
|
15
16
|
schemas[parameterIndex] = [schema, opts, !isSchema(model) && model];
|
|
16
17
|
Reflect.defineMetadata(exports.paramMetadataKey, schemas, target, propertyKey);
|
|
17
18
|
};
|
|
@@ -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,4DAAsC;AACtC,6BAAqC;AACrC,4BAA0B;AAG1B,MAAM,QAAQ,GAAG,CAAC,MAAW,EAAyB,EAAE,CAAC,UAAU,IAAI,MAAM,CAAC;AAGjE,QAAA,gBAAgB,GAAG,CAAC,CAAC,yBAAyB,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/E,CAAC,CAAC,yBAAyB,GAAG,wBAAgB,CAAC;AAmB/C,SAAgB,KAAK,CACnB,KAA2C,EAC3C,OAAY,EAAE,OAAO,EAAE,EAAE,EAAE;IAE3B,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,cAAsB,EAAE,EAAE;QAElE,MAAM,OAAO,GACX,OAAO,CAAC,cAAc,CAAC,wBAAgB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;QAEtE,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,YAAM,GAAE;aAC9C,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,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": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Convector Controller base class",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"clean:docs": "rimraf docs",
|
|
35
35
|
"build": "npm run clean && tsc",
|
|
36
36
|
"watch": "npm-scripts-watcher",
|
|
37
|
-
"prepare": "npm run build",
|
|
38
37
|
"lint": "tslint --fix -c '../../tslint.json' -p './tsconfig.json'",
|
|
39
38
|
"test": "mocha -r ts-node/register tests/**/*.spec.ts --reporter spec",
|
|
40
39
|
"predocs:generate": "npm run clean:docs",
|
|
@@ -50,21 +49,23 @@
|
|
|
50
49
|
"reflect-metadata": ">=0.1.12"
|
|
51
50
|
},
|
|
52
51
|
"dependencies": {
|
|
53
|
-
"@apex-pub/convector-core-errors": "^
|
|
54
|
-
"@apex-pub/convector-core-model": "^
|
|
52
|
+
"@apex-pub/convector-core-errors": "^2.0.0",
|
|
53
|
+
"@apex-pub/convector-core-model": "^2.0.0",
|
|
55
54
|
"tslib": "^1.9.0",
|
|
56
55
|
"window-or-global": "^1.0.1",
|
|
57
56
|
"yup": "^0.26.10"
|
|
58
57
|
},
|
|
59
58
|
"devDependencies": {
|
|
59
|
+
"fabric-shim": "^2.4.0",
|
|
60
60
|
"http-server": "^0.11.1",
|
|
61
|
-
"mocha": "^
|
|
61
|
+
"mocha": "^10.8.2",
|
|
62
62
|
"npm-scripts-watcher": "^1.0.2",
|
|
63
63
|
"reflect-metadata": "^0.1.12",
|
|
64
64
|
"rimraf": "^2.6.2",
|
|
65
|
-
"ts-node": "^
|
|
66
|
-
"tslint": "^
|
|
65
|
+
"ts-node": "^10.9.2",
|
|
66
|
+
"tslint": "^6.1.3",
|
|
67
67
|
"typedoc": "^0.11.1",
|
|
68
|
-
"typescript": "
|
|
69
|
-
}
|
|
68
|
+
"typescript": "5.4.5"
|
|
69
|
+
},
|
|
70
|
+
"gitHead": "14214eba330c45c52fb0e80401ab38ed2ffa2239"
|
|
70
71
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
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.1"></a>
|
|
7
|
-
## [1.5.1](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/compare/v1.5.0...v1.5.1) (2024-07-30)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
### Bug Fixes
|
|
11
|
-
|
|
12
|
-
* updates for apex-pub changes ([feb72c3](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/feb72c3))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<a name="1.5.0"></a>
|
|
18
|
-
# 1.5.0 (2024-07-29)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
### Bug Fixes
|
|
22
|
-
|
|
23
|
-
* **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)
|
|
24
|
-
* error handlers for testing and chaincode ([ef9bae6](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/ef9bae6))
|
|
25
|
-
* handle global on browser environments ([44fcd22](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/44fcd22))
|
|
26
|
-
* invokable local call ([882e8d9](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/882e8d9))
|
|
27
|
-
* name collition for optional decorator ([2716c78](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/2716c78))
|
|
28
|
-
* 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))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
### Features
|
|
32
|
-
|
|
33
|
-
* 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))
|
|
34
|
-
* allow internal calls for invokables ([84269cb](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/84269cb))
|
|
35
|
-
* export adapter-in-chaincode in fabric ([2b28edd](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/2b28edd))
|
|
36
|
-
* **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)
|
|
37
|
-
* flatten object invokable results ([9c90a9f](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/9c90a9f))
|
|
38
|
-
* group packages and update package.json's ([3971b44](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/3971b44))
|
|
39
|
-
* optional params on controllers ([cdf6782](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/cdf6782))
|
|
40
|
-
* 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))
|
|
41
|
-
* 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))
|
|
42
|
-
* refactor convector client implementation and add browser support ([30ec673](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller/commit/30ec673))
|
|
43
|
-
* 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))
|
|
44
|
-
* 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))
|