@apex-pub/convector-core-controller 1.4.1-4-alpha.8939dce7 → 1.4.1-4-alpha.5d0544b6
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 +13 -8
- package/dist/src/controller.decorator.js.map +1 -1
- package/dist/src/convector-controller.js +5 -1
- package/dist/src/convector-controller.js.map +1 -1
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.js +8 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/invokable.decorator.d.ts +1 -1
- package/dist/src/invokable.decorator.js +71 -69
- package/dist/src/invokable.decorator.js.map +1 -1
- package/dist/src/optional.decorator.js +12 -7
- package/dist/src/optional.decorator.js.map +1 -1
- package/dist/src/param.decorator.js +14 -9
- package/dist/src/param.decorator.js.map +1 -1
- package/package.json +3 -4
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
g
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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");
|
|
7
|
+
require("reflect-metadata");
|
|
8
|
+
exports.controllerMetadataKey = g.ConvectorControllerMetadataKey || Symbol('controller');
|
|
9
|
+
g.ConvectorControllerMetadataKey = exports.controllerMetadataKey;
|
|
10
|
+
function Controller(namespace) {
|
|
7
11
|
return ctor => {
|
|
8
12
|
if (typeof ctor !== 'function') {
|
|
9
|
-
throw new ControllerInvalidError(namespace);
|
|
13
|
+
throw new convector_core_errors_1.ControllerInvalidError(namespace);
|
|
10
14
|
}
|
|
11
|
-
Reflect.defineMetadata(controllerMetadataKey, namespace, ctor);
|
|
15
|
+
Reflect.defineMetadata(exports.controllerMetadataKey, namespace, ctor);
|
|
12
16
|
};
|
|
13
17
|
}
|
|
18
|
+
exports.Controller = Controller;
|
|
14
19
|
//# sourceMappingURL=controller.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.decorator.js","sourceRoot":"","sources":["../../src/controller.decorator.ts"],"names":[],"mappings":"AAEA,
|
|
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;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,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConvectorController = void 0;
|
|
4
|
+
class ConvectorController {
|
|
2
5
|
}
|
|
6
|
+
exports.ConvectorController = ConvectorController;
|
|
3
7
|
//# sourceMappingURL=convector-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convector-controller.js","sourceRoot":"","sources":["../../src/convector-controller.ts"],"names":[],"mappings":"AAGA,
|
|
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.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './param.decorator
|
|
2
|
-
export * from './invokable.decorator
|
|
3
|
-
export * from './optional.decorator
|
|
4
|
-
export * from './controller.decorator
|
|
5
|
-
export * from './convector-controller
|
|
1
|
+
export * from './param.decorator';
|
|
2
|
+
export * from './invokable.decorator';
|
|
3
|
+
export * from './optional.decorator';
|
|
4
|
+
export * from './controller.decorator';
|
|
5
|
+
export * from './convector-controller';
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./param.decorator"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./invokable.decorator"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./optional.decorator"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./controller.decorator"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./convector-controller"), exports);
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAQA,4DAAkC;AAClC,gEAAsC;AACtC,+DAAqC;AACrC,iEAAuC;AACvC,iEAAuC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { ConvectorController } from './convector-controller
|
|
2
|
+
import { ConvectorController } from './convector-controller';
|
|
3
3
|
export declare const invokableMetadataKey: any;
|
|
4
4
|
export declare function Invokable(): (target: any, key: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>) => void;
|
|
5
5
|
export declare function getInvokables(controller: new (...args: any[]) => ConvectorController): {
|
|
@@ -1,106 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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");
|
|
7
|
+
require("reflect-metadata");
|
|
8
|
+
const param_decorator_1 = require("./param.decorator");
|
|
9
|
+
const optional_decorator_1 = require("./optional.decorator");
|
|
10
|
+
const controller_decorator_1 = require("./controller.decorator");
|
|
11
|
+
exports.invokableMetadataKey = g.ConvectorInvokableMetadataKey || Symbol('invokable');
|
|
12
|
+
g.ConvectorInvokableMetadataKey = exports.invokableMetadataKey;
|
|
13
|
+
function Invokable() {
|
|
10
14
|
return (target, key, descriptor) => {
|
|
11
15
|
const fn = descriptor.value;
|
|
12
16
|
if (typeof fn !== 'function') {
|
|
13
|
-
throw new ControllerInvalidFunctionError();
|
|
17
|
+
throw new convector_core_errors_1.ControllerInvalidFunctionError();
|
|
14
18
|
}
|
|
15
|
-
const invokables = Reflect.getMetadata(invokableMetadataKey, target.constructor) || {};
|
|
16
|
-
Reflect.defineMetadata(invokableMetadataKey, {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
internalCall = true;
|
|
25
|
-
extras = {};
|
|
26
|
-
}
|
|
27
|
-
const schemas = Reflect.getOwnMetadata(paramMetadataKey, target, key);
|
|
28
|
-
if (schemas) {
|
|
29
|
-
const optionals = Reflect.getOwnMetadata(optionalMetadataKey, target, key) || [];
|
|
30
|
-
if (schemas.length - optionals.length > args.length) {
|
|
31
|
-
throw new ControllerInvalidInvokeError(key, args.length, schemas.length - optionals.length);
|
|
19
|
+
const invokables = Reflect.getMetadata(exports.invokableMetadataKey, target.constructor) || {};
|
|
20
|
+
Reflect.defineMetadata(exports.invokableMetadataKey, Object.assign(Object.assign({}, invokables), { [key]: true }), target.constructor);
|
|
21
|
+
descriptor.value = function internalFn(_, args, extras, ...rest) {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
let internalCall = false;
|
|
24
|
+
if ('_internal_invokable' in this) {
|
|
25
|
+
args = [_, args, extras, ...rest].filter(param => param !== undefined);
|
|
26
|
+
internalCall = true;
|
|
27
|
+
extras = {};
|
|
32
28
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
return [...await result, undefined];
|
|
29
|
+
const schemas = Reflect.getOwnMetadata(param_decorator_1.paramMetadataKey, target, key);
|
|
30
|
+
if (schemas) {
|
|
31
|
+
const optionals = Reflect.getOwnMetadata(optional_decorator_1.optionalMetadataKey, target, key) || [];
|
|
32
|
+
if (schemas.length - optionals.length > args.length) {
|
|
33
|
+
throw new convector_core_errors_1.ControllerInvalidInvokeError(key, args.length, schemas.length - optionals.length);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
35
|
+
args = yield schemas.reduce((result, [schema, opts, model], index) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
let paramResult;
|
|
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];
|
|
47
42
|
}
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
throw new ControllerInvalidArgumentError(e, index, args[index]);
|
|
51
|
-
}
|
|
52
|
-
if (model) {
|
|
53
43
|
try {
|
|
54
|
-
|
|
44
|
+
if (opts.update) {
|
|
45
|
+
paramResult = schema.cast(args[index], opts);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
paramResult = yield schema.validate(args[index], opts);
|
|
49
|
+
}
|
|
55
50
|
}
|
|
56
51
|
catch (e) {
|
|
57
|
-
throw new
|
|
52
|
+
throw new convector_core_errors_1.ControllerInvalidArgumentError(e, index, args[index]);
|
|
58
53
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
if (model) {
|
|
55
|
+
try {
|
|
56
|
+
paramResult = new model(JSON.parse(args[index]));
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
throw new convector_core_errors_1.ControllerArgumentParseError(e, index, args[index]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return [...yield result, paramResult];
|
|
63
|
+
}), Promise.resolve([]));
|
|
64
|
+
}
|
|
65
|
+
const namespace = Reflect.getMetadata(controller_decorator_1.controllerMetadataKey, target.constructor);
|
|
66
|
+
const ctx = Object.create(internalCall ? this : this[namespace], Object.assign(Object.assign({}, (extras || {})), { _internal_invokable: { value: true } }));
|
|
67
|
+
try {
|
|
68
|
+
const response = yield fn.call(ctx, ...args);
|
|
69
|
+
return typeof response === 'object' ? JSON.parse(JSON.stringify(response)) : response;
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
const error = new Error(e.message);
|
|
73
|
+
error.stack = e.stack;
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
67
76
|
});
|
|
68
|
-
try {
|
|
69
|
-
const response = await fn.call(ctx, ...args);
|
|
70
|
-
return typeof response === 'object' ? JSON.parse(JSON.stringify(response)) : response;
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
const error = new Error(e.message);
|
|
74
|
-
error.stack = e.stack;
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
exports.Invokable = Invokable;
|
|
81
|
+
function getInvokables(controller) {
|
|
81
82
|
let namespace;
|
|
82
83
|
let invokables;
|
|
83
84
|
try {
|
|
84
|
-
namespace = Reflect.getMetadata(controllerMetadataKey, controller);
|
|
85
|
+
namespace = Reflect.getMetadata(controller_decorator_1.controllerMetadataKey, controller);
|
|
85
86
|
if (!namespace) {
|
|
86
87
|
throw new TypeError();
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
catch (e) {
|
|
90
|
-
throw new ControllerNamespaceMissingError(e, controller.name);
|
|
91
|
+
throw new convector_core_errors_1.ControllerNamespaceMissingError(e, controller.name);
|
|
91
92
|
}
|
|
92
93
|
try {
|
|
93
|
-
invokables = Reflect.getMetadata(invokableMetadataKey, controller);
|
|
94
|
+
invokables = Reflect.getMetadata(exports.invokableMetadataKey, controller);
|
|
94
95
|
if (!invokables) {
|
|
95
96
|
throw new TypeError();
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
catch (e) {
|
|
99
|
-
throw new ControllerInvokablesMissingError(e, namespace);
|
|
100
|
+
throw new convector_core_errors_1.ControllerInvokablesMissingError(e, namespace);
|
|
100
101
|
}
|
|
101
102
|
return {
|
|
102
103
|
invokables,
|
|
103
104
|
namespace
|
|
104
105
|
};
|
|
105
106
|
}
|
|
107
|
+
exports.getInvokables = getInvokables;
|
|
106
108
|
//# sourceMappingURL=invokable.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invokable.decorator.js","sourceRoot":"","sources":["../../src/invokable.decorator.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"invokable.decorator.js","sourceRoot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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;QACV,SAAS;KACV,CAAC;AACJ,CAAC;AA/BD,sCA+BC"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OptionalParam = exports.optionalMetadataKey = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const g = tslib_1.__importStar(require("window-or-global"));
|
|
6
|
+
require("reflect-metadata");
|
|
7
|
+
exports.optionalMetadataKey = g.ConvectorOptionalParamMetadataKey || Symbol('optional-param');
|
|
8
|
+
g.ConvectorOptionalParamMetadataKey = exports.optionalMetadataKey;
|
|
9
|
+
function OptionalParam() {
|
|
6
10
|
return (target, propertyKey, parameterIndex) => {
|
|
7
|
-
const optionals = Reflect.getOwnMetadata(optionalMetadataKey, target, propertyKey) || [];
|
|
11
|
+
const optionals = Reflect.getOwnMetadata(exports.optionalMetadataKey, target, propertyKey) || [];
|
|
8
12
|
optionals.push(parameterIndex);
|
|
9
|
-
Reflect.defineMetadata(optionalMetadataKey, optionals, target, propertyKey);
|
|
13
|
+
Reflect.defineMetadata(exports.optionalMetadataKey, optionals, target, propertyKey);
|
|
10
14
|
};
|
|
11
15
|
}
|
|
16
|
+
exports.OptionalParam = OptionalParam;
|
|
12
17
|
//# sourceMappingURL=optional.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.decorator.js","sourceRoot":"","sources":["../../src/optional.decorator.ts"],"names":[],"mappings":"AAEA,
|
|
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,16 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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");
|
|
7
|
+
require("reflect-metadata");
|
|
4
8
|
const isSchema = (schema) => 'validate' in schema;
|
|
5
|
-
|
|
6
|
-
g.ConvectorParamMetadataKey = paramMetadataKey;
|
|
7
|
-
|
|
9
|
+
exports.paramMetadataKey = g.ConvectorParamMetadataKey || Symbol('param');
|
|
10
|
+
g.ConvectorParamMetadataKey = exports.paramMetadataKey;
|
|
11
|
+
function Param(model, opts = { context: {} }) {
|
|
8
12
|
return (target, propertyKey, parameterIndex) => {
|
|
9
|
-
const schemas = Reflect.getOwnMetadata(paramMetadataKey, target, propertyKey) || [];
|
|
10
|
-
const schema = isSchema(model) ? model : object()
|
|
13
|
+
const schemas = Reflect.getOwnMetadata(exports.paramMetadataKey, target, propertyKey) || [];
|
|
14
|
+
const schema = isSchema(model) ? model : (0, yup_1.object)()
|
|
11
15
|
.transform(value => value instanceof model ? value : new model(value));
|
|
12
16
|
schemas[parameterIndex] = [schema, opts, !isSchema(model) && model];
|
|
13
|
-
Reflect.defineMetadata(paramMetadataKey, schemas, target, propertyKey);
|
|
17
|
+
Reflect.defineMetadata(exports.paramMetadataKey, schemas, target, propertyKey);
|
|
14
18
|
};
|
|
15
19
|
}
|
|
20
|
+
exports.Param = Param;
|
|
16
21
|
//# sourceMappingURL=param.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"param.decorator.js","sourceRoot":"","sources":["../../src/param.decorator.ts"],"names":[],"mappings":"AAEA,
|
|
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,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apex-pub/convector-core-controller",
|
|
3
|
-
"version": "1.4.1-4-alpha.
|
|
3
|
+
"version": "1.4.1-4-alpha.5d0544b6",
|
|
4
4
|
"description": "Convector Controller base class",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
6
|
"repository": {
|
|
8
7
|
"type": "git",
|
|
9
8
|
"url": "https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-controller"
|
|
@@ -51,8 +50,8 @@
|
|
|
51
50
|
"reflect-metadata": ">=0.1.12"
|
|
52
51
|
},
|
|
53
52
|
"dependencies": {
|
|
54
|
-
"@apex-pub/convector-core-errors": "1.4.1-4-alpha.
|
|
55
|
-
"@apex-pub/convector-core-model": "1.4.1-4-alpha.
|
|
53
|
+
"@apex-pub/convector-core-errors": "1.4.1-4-alpha.5d0544b6",
|
|
54
|
+
"@apex-pub/convector-core-model": "1.4.1-4-alpha.5d0544b6",
|
|
56
55
|
"window-or-global": "^1.0.1",
|
|
57
56
|
"yup": "^0.26.10"
|
|
58
57
|
},
|