@celljs/rpc 3.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/LICENSE +21 -0
- package/README.md +1 -0
- package/cell.yml +8 -0
- package/lib/common/annotation/autorpc.d.ts +6 -0
- package/lib/common/annotation/autorpc.d.ts.map +1 -0
- package/lib/common/annotation/autorpc.js +19 -0
- package/lib/common/annotation/autorpc.js.map +1 -0
- package/lib/common/annotation/detached/autorpc.d.ts +3 -0
- package/lib/common/annotation/detached/autorpc.d.ts.map +1 -0
- package/lib/common/annotation/detached/autorpc.js +15 -0
- package/lib/common/annotation/detached/autorpc.js.map +1 -0
- package/lib/common/annotation/detached/index.d.ts +2 -0
- package/lib/common/annotation/detached/index.d.ts.map +1 -0
- package/lib/common/annotation/detached/index.js +18 -0
- package/lib/common/annotation/detached/index.js.map +1 -0
- package/lib/common/annotation/index.d.ts +3 -0
- package/lib/common/annotation/index.d.ts.map +1 -0
- package/lib/common/annotation/index.js +19 -0
- package/lib/common/annotation/index.js.map +1 -0
- package/lib/common/annotation/rpc.d.ts +20 -0
- package/lib/common/annotation/rpc.d.ts.map +1 -0
- package/lib/common/annotation/rpc.js +41 -0
- package/lib/common/annotation/rpc.js.map +1 -0
- package/lib/common/channal/channel-protocol.d.ts +52 -0
- package/lib/common/channal/channel-protocol.d.ts.map +1 -0
- package/lib/common/channal/channel-protocol.js +38 -0
- package/lib/common/channal/channel-protocol.js.map +1 -0
- package/lib/common/channal/http-channel.d.ts +9 -0
- package/lib/common/channal/http-channel.d.ts.map +1 -0
- package/lib/common/channal/http-channel.js +26 -0
- package/lib/common/channal/http-channel.js.map +1 -0
- package/lib/common/channal/index.d.ts +3 -0
- package/lib/common/channal/index.d.ts.map +1 -0
- package/lib/common/channal/index.js +19 -0
- package/lib/common/channal/index.js.map +1 -0
- package/lib/common/constants.d.ts +2 -0
- package/lib/common/constants.d.ts.map +1 -0
- package/lib/common/constants.js +5 -0
- package/lib/common/constants.js.map +1 -0
- package/lib/common/converter/converter-protocol.d.ts +7 -0
- package/lib/common/converter/converter-protocol.d.ts.map +1 -0
- package/lib/common/converter/converter-protocol.js +6 -0
- package/lib/common/converter/converter-protocol.js.map +1 -0
- package/lib/common/converter/index.d.ts +2 -0
- package/lib/common/converter/index.d.ts.map +1 -0
- package/lib/common/converter/index.js +18 -0
- package/lib/common/converter/index.js.map +1 -0
- package/lib/common/endpoint/endpoint-protocol.d.ts +5 -0
- package/lib/common/endpoint/endpoint-protocol.d.ts.map +1 -0
- package/lib/common/endpoint/endpoint-protocol.js +5 -0
- package/lib/common/endpoint/endpoint-protocol.js.map +1 -0
- package/lib/common/endpoint/endpoint-resolver.d.ts +13 -0
- package/lib/common/endpoint/endpoint-resolver.d.ts.map +1 -0
- package/lib/common/endpoint/endpoint-resolver.js +61 -0
- package/lib/common/endpoint/endpoint-resolver.js.map +1 -0
- package/lib/common/endpoint/index.d.ts +3 -0
- package/lib/common/endpoint/index.d.ts.map +1 -0
- package/lib/common/endpoint/index.js +19 -0
- package/lib/common/endpoint/index.js.map +1 -0
- package/lib/common/error/error.d.ts +6 -0
- package/lib/common/error/error.d.ts.map +1 -0
- package/lib/common/error/error.js +12 -0
- package/lib/common/error/error.js.map +1 -0
- package/lib/common/error/index.d.ts +2 -0
- package/lib/common/error/index.d.ts.map +1 -0
- package/lib/common/error/index.js +18 -0
- package/lib/common/error/index.js.map +1 -0
- package/lib/common/factory/connection-factory.d.ts +10 -0
- package/lib/common/factory/connection-factory.d.ts.map +1 -0
- package/lib/common/factory/connection-factory.js +28 -0
- package/lib/common/factory/connection-factory.js.map +1 -0
- package/lib/common/factory/index.d.ts +5 -0
- package/lib/common/factory/index.d.ts.map +1 -0
- package/lib/common/factory/index.js +21 -0
- package/lib/common/factory/index.js.map +1 -0
- package/lib/common/factory/proxy-factory.d.ts +57 -0
- package/lib/common/factory/proxy-factory.d.ts.map +1 -0
- package/lib/common/factory/proxy-factory.js +182 -0
- package/lib/common/factory/proxy-factory.js.map +1 -0
- package/lib/common/factory/reader.d.ts +16 -0
- package/lib/common/factory/reader.d.ts.map +1 -0
- package/lib/common/factory/reader.js +48 -0
- package/lib/common/factory/reader.js.map +1 -0
- package/lib/common/factory/writer.d.ts +10 -0
- package/lib/common/factory/writer.d.ts.map +1 -0
- package/lib/common/factory/writer.js +25 -0
- package/lib/common/factory/writer.js.map +1 -0
- package/lib/common/handler/connection-handler.d.ts +7 -0
- package/lib/common/handler/connection-handler.d.ts.map +1 -0
- package/lib/common/handler/connection-handler.js +8 -0
- package/lib/common/handler/connection-handler.js.map +1 -0
- package/lib/common/handler/handler-protocol.d.ts +7 -0
- package/lib/common/handler/handler-protocol.d.ts.map +1 -0
- package/lib/common/handler/handler-protocol.js +5 -0
- package/lib/common/handler/handler-protocol.js.map +1 -0
- package/lib/common/handler/index.d.ts +3 -0
- package/lib/common/handler/index.d.ts.map +1 -0
- package/lib/common/handler/index.js +19 -0
- package/lib/common/handler/index.js.map +1 -0
- package/lib/common/index.d.ts +12 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +28 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/module.d.ts +4 -0
- package/lib/common/module.d.ts.map +1 -0
- package/lib/common/module.js +22 -0
- package/lib/common/module.js.map +1 -0
- package/lib/common/processor/client-config-processor.d.ts +6 -0
- package/lib/common/processor/client-config-processor.d.ts.map +1 -0
- package/lib/common/processor/client-config-processor.js +20 -0
- package/lib/common/processor/client-config-processor.js.map +1 -0
- package/lib/common/processor/index.d.ts +3 -0
- package/lib/common/processor/index.d.ts.map +1 -0
- package/lib/common/processor/index.js +19 -0
- package/lib/common/processor/index.js.map +1 -0
- package/lib/common/processor/processor-protocol.d.ts +6 -0
- package/lib/common/processor/processor-protocol.d.ts.map +1 -0
- package/lib/common/processor/processor-protocol.js +5 -0
- package/lib/common/processor/processor-protocol.js.map +1 -0
- package/lib/common/proxy/delegating-http-proxy-creator.d.ts +24 -0
- package/lib/common/proxy/delegating-http-proxy-creator.d.ts.map +1 -0
- package/lib/common/proxy/delegating-http-proxy-creator.js +89 -0
- package/lib/common/proxy/delegating-http-proxy-creator.js.map +1 -0
- package/lib/common/proxy/http-proxy-creator.d.ts +43 -0
- package/lib/common/proxy/http-proxy-creator.d.ts.map +1 -0
- package/lib/common/proxy/http-proxy-creator.js +137 -0
- package/lib/common/proxy/http-proxy-creator.js.map +1 -0
- package/lib/common/proxy/index.d.ts +5 -0
- package/lib/common/proxy/index.d.ts.map +1 -0
- package/lib/common/proxy/index.js +21 -0
- package/lib/common/proxy/index.js.map +1 -0
- package/lib/common/proxy/proxy-protocol.d.ts +22 -0
- package/lib/common/proxy/proxy-protocol.d.ts.map +1 -0
- package/lib/common/proxy/proxy-protocol.js +6 -0
- package/lib/common/proxy/proxy-protocol.js.map +1 -0
- package/lib/common/proxy/proxy-provider.d.ts +10 -0
- package/lib/common/proxy/proxy-provider.d.ts.map +1 -0
- package/lib/common/proxy/proxy-provider.js +43 -0
- package/lib/common/proxy/proxy-provider.js.map +1 -0
- package/lib/common/utils/converter-util.d.ts +8 -0
- package/lib/common/utils/converter-util.d.ts.map +1 -0
- package/lib/common/utils/converter-util.js +32 -0
- package/lib/common/utils/converter-util.js.map +1 -0
- package/lib/common/utils/index.d.ts +4 -0
- package/lib/common/utils/index.d.ts.map +1 -0
- package/lib/common/utils/index.js +20 -0
- package/lib/common/utils/index.js.map +1 -0
- package/lib/common/utils/logger.d.ts +9 -0
- package/lib/common/utils/logger.d.ts.map +1 -0
- package/lib/common/utils/logger.js +22 -0
- package/lib/common/utils/logger.js.map +1 -0
- package/lib/common/utils/rpc-util.d.ts +13 -0
- package/lib/common/utils/rpc-util.d.ts.map +1 -0
- package/lib/common/utils/rpc-util.js +46 -0
- package/lib/common/utils/rpc-util.js.map +1 -0
- package/lib/node/channel/channel-manager.d.ts +10 -0
- package/lib/node/channel/channel-manager.d.ts.map +1 -0
- package/lib/node/channel/channel-manager.js +59 -0
- package/lib/node/channel/channel-manager.js.map +1 -0
- package/lib/node/channel/channel-middleware.d.ts +8 -0
- package/lib/node/channel/channel-middleware.d.ts.map +1 -0
- package/lib/node/channel/channel-middleware.js +40 -0
- package/lib/node/channel/channel-middleware.js.map +1 -0
- package/lib/node/channel/channel-protocol.d.ts +13 -0
- package/lib/node/channel/channel-protocol.d.ts.map +1 -0
- package/lib/node/channel/channel-protocol.js +9 -0
- package/lib/node/channel/channel-protocol.js.map +1 -0
- package/lib/node/channel/channel-strategy.d.ts +10 -0
- package/lib/node/channel/channel-strategy.d.ts.map +1 -0
- package/lib/node/channel/channel-strategy.js +64 -0
- package/lib/node/channel/channel-strategy.js.map +1 -0
- package/lib/node/channel/index.d.ts +5 -0
- package/lib/node/channel/index.d.ts.map +1 -0
- package/lib/node/channel/index.js +21 -0
- package/lib/node/channel/index.js.map +1 -0
- package/lib/node/handler/handler-adapter.d.ts +14 -0
- package/lib/node/handler/handler-adapter.d.ts.map +1 -0
- package/lib/node/handler/handler-adapter.js +55 -0
- package/lib/node/handler/handler-adapter.js.map +1 -0
- package/lib/node/handler/handler-protocol.d.ts +2 -0
- package/lib/node/handler/handler-protocol.d.ts.map +1 -0
- package/lib/node/handler/handler-protocol.js +5 -0
- package/lib/node/handler/handler-protocol.js.map +1 -0
- package/lib/node/handler/index.d.ts +3 -0
- package/lib/node/handler/index.d.ts.map +1 -0
- package/lib/node/handler/index.js +19 -0
- package/lib/node/handler/index.js.map +1 -0
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.d.ts.map +1 -0
- package/lib/node/index.js +19 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/module.d.ts +4 -0
- package/lib/node/module.d.ts.map +1 -0
- package/lib/node/module.js +6 -0
- package/lib/node/module.js.map +1 -0
- package/lib/package.spec.d.ts +1 -0
- package/lib/package.spec.d.ts.map +1 -0
- package/lib/package.spec.js +4 -0
- package/lib/package.spec.js.map +1 -0
- package/package.json +45 -0
- package/src/common/annotation/autorpc.ts +17 -0
- package/src/common/annotation/detached/autorpc.ts +12 -0
- package/src/common/annotation/detached/index.ts +1 -0
- package/src/common/annotation/index.ts +2 -0
- package/src/common/annotation/rpc.ts +41 -0
- package/src/common/channal/channel-protocol.ts +82 -0
- package/src/common/channal/http-channel.ts +30 -0
- package/src/common/channal/index.ts +2 -0
- package/src/common/constants.ts +1 -0
- package/src/common/converter/converter-protocol.ts +8 -0
- package/src/common/converter/index.ts +1 -0
- package/src/common/endpoint/endpoint-protocol.ts +5 -0
- package/src/common/endpoint/endpoint-resolver.ts +46 -0
- package/src/common/endpoint/index.ts +2 -0
- package/src/common/error/error.ts +7 -0
- package/src/common/error/index.ts +1 -0
- package/src/common/factory/connection-factory.ts +21 -0
- package/src/common/factory/index.ts +4 -0
- package/src/common/factory/proxy-factory.ts +219 -0
- package/src/common/factory/reader.ts +50 -0
- package/src/common/factory/writer.ts +26 -0
- package/src/common/handler/connection-handler.ts +7 -0
- package/src/common/handler/handler-protocol.ts +8 -0
- package/src/common/handler/index.ts +2 -0
- package/src/common/index.ts +11 -0
- package/src/common/module.ts +21 -0
- package/src/common/processor/client-config-processor.ts +12 -0
- package/src/common/processor/index.ts +2 -0
- package/src/common/processor/processor-protocol.ts +7 -0
- package/src/common/proxy/delegating-http-proxy-creator.ts +68 -0
- package/src/common/proxy/http-proxy-creator.ts +179 -0
- package/src/common/proxy/index.ts +5 -0
- package/src/common/proxy/proxy-protocol.ts +26 -0
- package/src/common/proxy/proxy-provider.ts +29 -0
- package/src/common/utils/converter-util.ts +29 -0
- package/src/common/utils/index.ts +3 -0
- package/src/common/utils/logger.ts +23 -0
- package/src/common/utils/rpc-util.ts +46 -0
- package/src/node/channel/channel-manager.ts +44 -0
- package/src/node/channel/channel-middleware.ts +27 -0
- package/src/node/channel/channel-protocol.ts +21 -0
- package/src/node/channel/channel-strategy.ts +56 -0
- package/src/node/channel/index.ts +4 -0
- package/src/node/handler/handler-adapter.ts +38 -0
- package/src/node/handler/handler-protocol.ts +1 -0
- package/src/node/handler/index.ts +2 -0
- package/src/node/index.ts +2 -0
- package/src/node/module.ts +4 -0
- package/src/package.spec.ts +4 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ProxyProviderImpl = void 0;
|
|
16
|
+
const core_1 = require("@celljs/core");
|
|
17
|
+
const proxy_protocol_1 = require("./proxy-protocol");
|
|
18
|
+
let ProxyProviderImpl = class ProxyProviderImpl {
|
|
19
|
+
constructor(proxyCreators) {
|
|
20
|
+
this.proxyCreators = proxyCreators;
|
|
21
|
+
}
|
|
22
|
+
provide(path, errorConverters, target) {
|
|
23
|
+
return this.prioritize(path)[0].create(path, errorConverters, target);
|
|
24
|
+
}
|
|
25
|
+
prioritize(path) {
|
|
26
|
+
const prioritized = core_1.Prioritizeable.prioritizeAllSync(this.proxyCreators, proxyCreator => {
|
|
27
|
+
try {
|
|
28
|
+
return proxyCreator.support(path);
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return prioritized.map(p => p.value);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
ProxyProviderImpl = __decorate([
|
|
38
|
+
(0, core_1.Component)(proxy_protocol_1.ProxyProvider),
|
|
39
|
+
__param(0, (0, core_1.Autowired)(proxy_protocol_1.ProxyCreator)),
|
|
40
|
+
__metadata("design:paramtypes", [Array])
|
|
41
|
+
], ProxyProviderImpl);
|
|
42
|
+
exports.ProxyProviderImpl = ProxyProviderImpl;
|
|
43
|
+
//# sourceMappingURL=proxy-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-provider.js","sourceRoot":"","sources":["../../../src/common/proxy/proxy-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAoE;AAGpE,qDAA+D;AAGxD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE1B,YAEuB,aAA6B;QAA7B,kBAAa,GAAb,aAAa,CAAgB;IAChD,CAAC;IAEL,OAAO,CAAmB,IAAY,EAAE,eAAkC,EAAE,MAAe;QACvF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;IAES,UAAU,CAAC,IAAY;QAC7B,MAAM,WAAW,GAAG,qBAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,EAAE;YACpF,IAAI;gBACA,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aACrC;YAAC,WAAM;gBACJ,OAAO,CAAC,CAAC;aACZ;QACL,CAAC,CAAC,CAAC;QACH,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CAEJ,CAAA;AAtBY,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,8BAAa,CAAC;IAIhB,WAAA,IAAA,gBAAS,EAAC,6BAAY,CAAC,CAAA;;GAHnB,iBAAiB,CAsB7B;AAtBY,8CAAiB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Container } from '@celljs/core';
|
|
2
|
+
import { ErrorConverter } from '../converter';
|
|
3
|
+
export declare namespace ConverterUtil {
|
|
4
|
+
function getErrorConverterIgnoreNoMatching<T>(task: () => T): T | undefined;
|
|
5
|
+
function getGlobalErrorConverters(container?: Container): ErrorConverter[];
|
|
6
|
+
function getErrorConverters(serviceIdentifier: any, container?: Container): ErrorConverter | undefined;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=converter-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter-util.d.ts","sourceRoot":"","sources":["../../../src/common/utils/converter-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,cAAc,EAAmB,MAAM,cAAc,CAAC;AAG/D,yBAAiB,aAAa,CAAC;IAE3B,SAAgB,iCAAiC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,SAAS,CAQjF;IAED,SAAgB,wBAAwB,CAAC,SAAS,CAAC,EAAE,SAAS,oBAI7D;IAED,SAAgB,kBAAkB,CAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,SAAS,8BAK/E;CACJ"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConverterUtil = void 0;
|
|
4
|
+
const core_1 = require("@celljs/core");
|
|
5
|
+
const converter_1 = require("../converter");
|
|
6
|
+
const rpc_util_1 = require("./rpc-util");
|
|
7
|
+
var ConverterUtil;
|
|
8
|
+
(function (ConverterUtil) {
|
|
9
|
+
function getErrorConverterIgnoreNoMatching(task) {
|
|
10
|
+
try {
|
|
11
|
+
return task();
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (!(error === null || error === void 0 ? void 0 : error.message.startsWith('No matching bindings found for serviceIdentifier: Symbol(ErrorConverter)'))) {
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
ConverterUtil.getErrorConverterIgnoreNoMatching = getErrorConverterIgnoreNoMatching;
|
|
20
|
+
function getGlobalErrorConverters(container) {
|
|
21
|
+
return getErrorConverterIgnoreNoMatching(() => container ? container.getAllNamed(converter_1.ErrorConverter, converter_1.GlobalConverter) :
|
|
22
|
+
core_1.ContainerUtil.getAllNamed(converter_1.ErrorConverter, converter_1.GlobalConverter)) || [];
|
|
23
|
+
}
|
|
24
|
+
ConverterUtil.getGlobalErrorConverters = getGlobalErrorConverters;
|
|
25
|
+
function getErrorConverters(serviceIdentifier, container) {
|
|
26
|
+
const name = rpc_util_1.RpcUtil.toName(serviceIdentifier);
|
|
27
|
+
return getErrorConverterIgnoreNoMatching(() => container ? container.getNamed(converter_1.ErrorConverter, name) :
|
|
28
|
+
core_1.ContainerUtil.getNamed(converter_1.ErrorConverter, name));
|
|
29
|
+
}
|
|
30
|
+
ConverterUtil.getErrorConverters = getErrorConverters;
|
|
31
|
+
})(ConverterUtil = exports.ConverterUtil || (exports.ConverterUtil = {}));
|
|
32
|
+
//# sourceMappingURL=converter-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter-util.js","sourceRoot":"","sources":["../../../src/common/utils/converter-util.ts"],"names":[],"mappings":";;;AAAA,uCAAwD;AACxD,4CAA+D;AAC/D,yCAAqC;AAErC,IAAiB,aAAa,CAwB7B;AAxBD,WAAiB,aAAa;IAE1B,SAAgB,iCAAiC,CAAI,IAAa;QAC9D,IAAI;YACA,OAAO,IAAI,EAAE,CAAC;SACjB;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC,UAAU,CAAC,0EAA0E,CAAC,CAAA,EAAE;gBACxG,MAAM,KAAK,CAAC;aACf;SACJ;IACL,CAAC;IARe,+CAAiC,oCAQhD,CAAA;IAED,SAAgB,wBAAwB,CAAC,SAAqB;QAC1D,OAAO,iCAAiC,CAAC,GAAG,EAAE,CAC1C,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAiB,0BAAc,EAAE,2BAAe,CAAC,CAAC,CAAC;YAChF,oBAAa,CAAC,WAAW,CAAiB,0BAAc,EAAE,2BAAe,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9F,CAAC;IAJe,sCAAwB,2BAIvC,CAAA;IAED,SAAgB,kBAAkB,CAAC,iBAAsB,EAAE,SAAqB;QAC5E,MAAM,IAAI,GAAG,kBAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC/C,OAAO,iCAAiC,CAAC,GAAG,EAAE,CAC1C,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAiB,0BAAc,EAAE,IAAI,CAAC,CAAC,CAAC;YAClE,oBAAa,CAAC,QAAQ,CAAiB,0BAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1E,CAAC;IALe,gCAAkB,qBAKjC,CAAA;AACL,CAAC,EAxBgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAwB7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./rpc-util"), exports);
|
|
18
|
+
__exportStar(require("./converter-util"), exports);
|
|
19
|
+
__exportStar(require("./logger"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,mDAAiC;AACjC,2CAAyB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger as ILoger } from 'vscode-jsonrpc';
|
|
2
|
+
export declare class ConsoleLogger implements ILoger {
|
|
3
|
+
error(message: string): void;
|
|
4
|
+
warn(message: string): void;
|
|
5
|
+
info(message: string): void;
|
|
6
|
+
log(message: string): void;
|
|
7
|
+
debug(message: string): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/common/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElD,qBAAa,aAAc,YAAW,MAAM;IACjC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI1B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAGtC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleLogger = void 0;
|
|
4
|
+
class ConsoleLogger {
|
|
5
|
+
error(message) {
|
|
6
|
+
console.error(message);
|
|
7
|
+
}
|
|
8
|
+
warn(message) {
|
|
9
|
+
console.warn(message);
|
|
10
|
+
}
|
|
11
|
+
info(message) {
|
|
12
|
+
console.info(message);
|
|
13
|
+
}
|
|
14
|
+
log(message) {
|
|
15
|
+
console.log(message);
|
|
16
|
+
}
|
|
17
|
+
debug(message) {
|
|
18
|
+
console.debug(message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ConsoleLogger = ConsoleLogger;
|
|
22
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/common/utils/logger.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IACf,KAAK,CAAC,OAAe;QACxB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;IAEM,IAAI,CAAC,OAAe;QACvB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAEM,IAAI,CAAC,OAAe;QACvB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAEM,GAAG,CAAC,OAAe;QACtB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,OAAe;QACxB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACJ;AApBD,sCAoBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentId } from '@celljs/core';
|
|
2
|
+
import { HttpProxyCreator, HttpProxyCreatorOptions, MergeOptions } from '../proxy/http-proxy-creator';
|
|
3
|
+
import { ProxyCreator } from '../proxy/proxy-protocol';
|
|
4
|
+
export declare namespace RpcUtil {
|
|
5
|
+
function get<T extends object>(rpcServiceIdentifier: ComponentId<T>): T;
|
|
6
|
+
function getDefaultProxyCreator(endpoint: string, options?: Partial<HttpProxyCreatorOptions<Partial<MergeOptions>>>): ProxyCreator | undefined;
|
|
7
|
+
function setDefaultProxyCreator(endpoint: string, options?: Partial<HttpProxyCreatorOptions<Partial<MergeOptions>>>): void;
|
|
8
|
+
function createProxyCreator(endpoint: string, options?: Partial<HttpProxyCreatorOptions<Partial<MergeOptions>>>): HttpProxyCreator;
|
|
9
|
+
function create<T extends object>(endpoint: string, rpcServiceIdentifier: ComponentId<T>, options?: Partial<HttpProxyCreatorOptions<Partial<MergeOptions>>>): T;
|
|
10
|
+
function toPath(serviceIdentifier: any): any;
|
|
11
|
+
function toName(serviceIdentifier: any): any;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=rpc-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-util.d.ts","sourceRoot":"","sources":["../../../src/common/utils/rpc-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,WAAW,EAAW,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD,yBAAiB,OAAO,CAAC;IACrB,SAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAK7E;IAED,SAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,4BAEzH;IAED,SAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,QAEzH;IAED,SAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,oBAMrH;IAED,SAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC,EAC3F,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAExE;IAED,SAAgB,MAAM,CAAC,iBAAiB,EAAE,GAAG,OAG5C;IAED,SAAgB,MAAM,CAAC,iBAAiB,EAAE,GAAG,OAG5C;CACJ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RpcUtil = void 0;
|
|
4
|
+
const core_1 = require("@celljs/core");
|
|
5
|
+
const annotation_1 = require("../annotation");
|
|
6
|
+
const http_proxy_creator_1 = require("../proxy/http-proxy-creator");
|
|
7
|
+
let defaultProxyCreator;
|
|
8
|
+
var RpcUtil;
|
|
9
|
+
(function (RpcUtil) {
|
|
10
|
+
function get(rpcServiceIdentifier) {
|
|
11
|
+
if (defaultProxyCreator) {
|
|
12
|
+
return defaultProxyCreator.create(toPath(rpcServiceIdentifier));
|
|
13
|
+
}
|
|
14
|
+
return core_1.ContainerUtil.getTagged(annotation_1.RPC, annotation_1.ID_KEY, rpcServiceIdentifier);
|
|
15
|
+
}
|
|
16
|
+
RpcUtil.get = get;
|
|
17
|
+
function getDefaultProxyCreator(endpoint, options) {
|
|
18
|
+
return defaultProxyCreator;
|
|
19
|
+
}
|
|
20
|
+
RpcUtil.getDefaultProxyCreator = getDefaultProxyCreator;
|
|
21
|
+
function setDefaultProxyCreator(endpoint, options) {
|
|
22
|
+
defaultProxyCreator = createProxyCreator(endpoint, options);
|
|
23
|
+
}
|
|
24
|
+
RpcUtil.setDefaultProxyCreator = setDefaultProxyCreator;
|
|
25
|
+
function createProxyCreator(endpoint, options) {
|
|
26
|
+
return new http_proxy_creator_1.HttpProxyCreator(Object.assign(Object.assign({}, options), { endpointResolver: {
|
|
27
|
+
resolve(serviceIdentifier) {
|
|
28
|
+
return Promise.resolve(core_1.UrlUtil.join(endpoint, serviceIdentifier));
|
|
29
|
+
}
|
|
30
|
+
} }));
|
|
31
|
+
}
|
|
32
|
+
RpcUtil.createProxyCreator = createProxyCreator;
|
|
33
|
+
function create(endpoint, rpcServiceIdentifier, options) {
|
|
34
|
+
return createProxyCreator(endpoint, options).create(toPath(rpcServiceIdentifier));
|
|
35
|
+
}
|
|
36
|
+
RpcUtil.create = create;
|
|
37
|
+
function toPath(serviceIdentifier) {
|
|
38
|
+
return typeof serviceIdentifier !== 'function' ? serviceIdentifier.toString() : serviceIdentifier.name || serviceIdentifier.toString();
|
|
39
|
+
}
|
|
40
|
+
RpcUtil.toPath = toPath;
|
|
41
|
+
function toName(serviceIdentifier) {
|
|
42
|
+
return typeof serviceIdentifier !== 'function' ? serviceIdentifier : serviceIdentifier.name || serviceIdentifier.toString();
|
|
43
|
+
}
|
|
44
|
+
RpcUtil.toName = toName;
|
|
45
|
+
})(RpcUtil = exports.RpcUtil || (exports.RpcUtil = {}));
|
|
46
|
+
//# sourceMappingURL=rpc-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-util.js","sourceRoot":"","sources":["../../../src/common/utils/rpc-util.ts"],"names":[],"mappings":";;;AAAA,uCAAmE;AACnE,8CAA4C;AAC5C,oEAAsG;AAGtG,IAAI,mBAA6C,CAAC;AAElD,IAAiB,OAAO,CAsCvB;AAtCD,WAAiB,OAAO;IACpB,SAAgB,GAAG,CAAmB,oBAAoC;QACtE,IAAI,mBAAmB,EAAE;YACrB,OAAO,mBAAmB,CAAC,MAAM,CAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;SACtE;QACD,OAAO,oBAAa,CAAC,SAAS,CAAC,gBAAG,EAAE,mBAAM,EAAE,oBAAoB,CAAC,CAAC;IACtE,CAAC;IALe,WAAG,MAKlB,CAAA;IAED,SAAgB,sBAAsB,CAAC,QAAgB,EAAE,OAAiE;QACtH,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAFe,8BAAsB,yBAErC,CAAA;IAED,SAAgB,sBAAsB,CAAC,QAAgB,EAAE,OAAiE;QACtH,mBAAmB,GAAG,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAFe,8BAAsB,yBAErC,CAAA;IAED,SAAgB,kBAAkB,CAAC,QAAgB,EAAE,OAAiE;QAClH,OAAO,IAAI,qCAAgB,iCAAM,OAAO,KAAE,gBAAgB,EAAE;gBACxD,OAAO,CAAC,iBAAyB;oBAC7B,OAAO,OAAO,CAAC,OAAO,CAAC,cAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAC;gBACtE,CAAC;aACJ,IAAE,CAAC;IACR,CAAC;IANe,0BAAkB,qBAMjC,CAAA;IAED,SAAgB,MAAM,CAAmB,QAAgB,EAAE,oBAAoC,EAC3F,OAAiE;QACjE,OAAO,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,MAAM,CAAI,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;IACzF,CAAC;IAHe,cAAM,SAGrB,CAAA;IAED,SAAgB,MAAM,CAAC,iBAAsB;QACzC,OAAO,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,IAAI,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IAE3I,CAAC;IAHe,cAAM,SAGrB,CAAA;IAED,SAAgB,MAAM,CAAC,iBAAsB;QACzC,OAAO,OAAO,iBAAiB,KAAK,UAAU,CAAC,CAAC,CAAkB,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,IAAI,IAAI,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IAEjJ,CAAC;IAHe,cAAM,SAGrB,CAAA;AACL,CAAC,EAtCgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAsCvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConnectionHandler, ConnnectionFactory, Channel } from '../../common';
|
|
2
|
+
export declare class ChannelManager {
|
|
3
|
+
protected readonly handlers: ConnectionHandler[];
|
|
4
|
+
protected connnectionFactory: ConnnectionFactory<Channel>;
|
|
5
|
+
protected _handlers: Map<string, ConnectionHandler>;
|
|
6
|
+
constructor(handlers: ConnectionHandler[], connnectionFactory: ConnnectionFactory<Channel>);
|
|
7
|
+
handleChannels(): Promise<void>;
|
|
8
|
+
protected getRealPath(path: string): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=channel-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-manager.d.ts","sourceRoot":"","sources":["../../../src/node/channel/channel-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,OAAO,EAAiB,MAAM,cAAc,CAAC;AAK7F,qBACa,cAAc;IAMnB,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,EAAE;IACjB,SAAS,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,OAAO,CAAC;IAL5F,SAAS,CAAC,SAAS,iCAAwC;gBAIpC,QAAQ,EAAE,iBAAiB,EAAE,EACP,kBAAkB,EAAE,kBAAkB,CAAC,OAAO,CAAC;IAOtF,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBrC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAI9C"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ChannelManager = void 0;
|
|
16
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
17
|
+
const common_1 = require("../../common");
|
|
18
|
+
const core_1 = require("@celljs/core");
|
|
19
|
+
const channel_protocol_1 = require("./channel-protocol");
|
|
20
|
+
// tslint:disable:no-any
|
|
21
|
+
let ChannelManager = class ChannelManager {
|
|
22
|
+
constructor(handlers, connnectionFactory) {
|
|
23
|
+
this.handlers = handlers;
|
|
24
|
+
this.connnectionFactory = connnectionFactory;
|
|
25
|
+
this._handlers = new Map();
|
|
26
|
+
for (const handler of handlers) {
|
|
27
|
+
this._handlers.set(handler.path, handler);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async handleChannels() {
|
|
31
|
+
const channelStrategy = node_1.Context.getAttr(channel_protocol_1.CURRENT_CHANNEL_STRATEGY_REQUEST_KEY);
|
|
32
|
+
node_1.Context.getResponse().body = new core_1.Deferred();
|
|
33
|
+
for (const message of await channelStrategy.getMessages()) {
|
|
34
|
+
const { id, path } = message;
|
|
35
|
+
if (path) {
|
|
36
|
+
const handler = this._handlers.get(this.getRealPath(path));
|
|
37
|
+
if (handler) {
|
|
38
|
+
const channel = await channelStrategy.createChannel(id);
|
|
39
|
+
handler.onConnection(this.connnectionFactory.create(channel, new common_1.ConsoleLogger()));
|
|
40
|
+
channel.handleMessage(message);
|
|
41
|
+
}
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
throw new node_1.NotFoundError(`Cannot find a service for the path: ${path}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
getRealPath(path) {
|
|
48
|
+
return path.split(':').pop();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
ChannelManager = __decorate([
|
|
52
|
+
(0, core_1.Component)(),
|
|
53
|
+
__param(0, (0, core_1.Autowired)(common_1.ConnectionHandler)),
|
|
54
|
+
__param(0, (0, core_1.Optional)()),
|
|
55
|
+
__param(1, (0, core_1.Autowired)(common_1.ConnnectionFactory)),
|
|
56
|
+
__metadata("design:paramtypes", [Array, Object])
|
|
57
|
+
], ChannelManager);
|
|
58
|
+
exports.ChannelManager = ChannelManager;
|
|
59
|
+
//# sourceMappingURL=channel-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-manager.js","sourceRoot":"","sources":["../../../src/node/channel/channel-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA8D;AAC9D,yCAA6F;AAC7F,uCAAwE;AACxE,yDAA2F;AAE3F,wBAAwB;AAEjB,IAAM,cAAc,GAApB,MAAM,cAAc;IAIvB,YAEuB,QAA6B,EACP,kBAA+C;QADrE,aAAQ,GAAR,QAAQ,CAAqB;QACP,uBAAkB,GAAlB,kBAAkB,CAA6B;QALlF,cAAS,GAAG,IAAI,GAAG,EAA6B,CAAC;QAOvD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC5B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SAC7C;IACL,CAAC;IAED,KAAK,CAAC,cAAc;QAChB,MAAM,eAAe,GAAoB,cAAO,CAAC,OAAO,CAAC,uDAAoC,CAAC,CAAC;QAC/F,cAAO,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,IAAI,eAAQ,EAAO,CAAC;QACjD,KAAK,MAAM,OAAO,IAAI,MAAM,eAAe,CAAC,WAAW,EAAE,EAAE;YACvD,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,OAAc,CAAC;YACpC,IAAI,IAAI,EAAE;gBACN,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC3D,IAAI,OAAO,EAAE;oBACT,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;oBACxD,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,sBAAa,EAAE,CAAC,CAAC,CAAC;oBACnF,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;iBAClC;gBACD,SAAS;aACZ;YACD,MAAM,IAAI,oBAAa,CAAC,uCAAuC,IAAI,EAAE,CAAC,CAAC;SAC1E;IACL,CAAC;IAES,WAAW,CAAC,IAAY;QAC9B,OAAe,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACzC,CAAC;CAEJ,CAAA;AApCY,cAAc;IAD1B,IAAA,gBAAS,GAAE;IAMH,WAAA,IAAA,gBAAS,EAAC,0BAAiB,CAAC,CAAA;IAAE,WAAA,IAAA,eAAQ,GAAE,CAAA;IAExC,WAAA,IAAA,gBAAS,EAAC,2BAAkB,CAAC,CAAA;;GAPzB,cAAc,CAoC1B;AApCY,wCAAc"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Middleware, Context } from '@celljs/web/lib/node';
|
|
2
|
+
import { ChannelStrategy } from './channel-protocol';
|
|
3
|
+
export declare class ChannelMiddleware implements Middleware {
|
|
4
|
+
protected readonly channelStrategies: ChannelStrategy[];
|
|
5
|
+
handle(ctx: Context, next: () => Promise<void>): Promise<void>;
|
|
6
|
+
readonly priority = 2100;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=channel-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-middleware.d.ts","sourceRoot":"","sources":["../../../src/node/channel/channel-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAqE,MAAM,oBAAoB,CAAC;AAGxH,qBACa,iBAAkB,YAAW,UAAU;IAGhD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,eAAe,EAAE,CAAC;IAElD,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAapE,QAAQ,CAAC,QAAQ,QAA+B;CAEnD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ChannelMiddleware = void 0;
|
|
13
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const channel_protocol_1 = require("./channel-protocol");
|
|
16
|
+
const http_1 = require("@celljs/http");
|
|
17
|
+
let ChannelMiddleware = class ChannelMiddleware {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.priority = channel_protocol_1.CHANNEL_MIDDLEWARE_PRIORITY;
|
|
20
|
+
}
|
|
21
|
+
async handle(ctx, next) {
|
|
22
|
+
for (const channelStrategy of this.channelStrategies) {
|
|
23
|
+
if (await channelStrategy.support()) {
|
|
24
|
+
node_1.Context.setAttr(channel_protocol_1.CURRENT_CHANNEL_STRATEGY_REQUEST_KEY, channelStrategy);
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
ctx.response.setHeader(http_1.HttpHeaders.CONTENT_TYPE, http_1.MediaType.APPLICATION_JSON_UTF8);
|
|
29
|
+
await next();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, core_1.Autowired)(channel_protocol_1.ChannelStrategy),
|
|
34
|
+
__metadata("design:type", Array)
|
|
35
|
+
], ChannelMiddleware.prototype, "channelStrategies", void 0);
|
|
36
|
+
ChannelMiddleware = __decorate([
|
|
37
|
+
(0, core_1.Component)(node_1.Middleware)
|
|
38
|
+
], ChannelMiddleware);
|
|
39
|
+
exports.ChannelMiddleware = ChannelMiddleware;
|
|
40
|
+
//# sourceMappingURL=channel-middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-middleware.js","sourceRoot":"","sources":["../../../src/node/channel/channel-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA2D;AAC3D,uCAAoD;AACpD,yDAAwH;AACxH,uCAAsD;AAG/C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QAkBM,aAAQ,GAAG,8CAA2B,CAAC;IAEpD,CAAC;IAfG,KAAK,CAAC,MAAM,CAAC,GAAY,EAAE,IAAyB;QAChD,KAAK,MAAM,eAAe,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAClD,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE,EAAE;gBACjC,cAAO,CAAC,OAAO,CAAC,uDAAoC,EAAE,eAAe,CAAC,CAAC;gBACvE,MAAM;aACT;SACJ;QAED,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,kBAAW,CAAC,YAAY,EAAE,gBAAS,CAAC,qBAAqB,CAAC,CAAC;QAElF,MAAM,IAAI,EAAE,CAAC;IACjB,CAAC;CAIJ,CAAA;AAlBG;IAAC,IAAA,gBAAS,EAAC,kCAAe,CAAC;;4DAC6B;AAH/C,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,iBAAU,CAAC;GACT,iBAAiB,CAoB7B;AApBY,8CAAiB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Channel } from '../../common';
|
|
2
|
+
export declare const ChannelStrategy: unique symbol;
|
|
3
|
+
export declare const CHANNEL_MIDDLEWARE_PRIORITY = 2100;
|
|
4
|
+
export declare const CURRENT_CHANNEL_STRATEGY_REQUEST_KEY = "CurrentChannelStrategyRequest";
|
|
5
|
+
export declare const CURRENT_MESSAGE_COUNT_REQUEST_KEY = "CurrentMessageCountRequest";
|
|
6
|
+
export declare const CURRENT_RESPONSE_MESSAGE_REQUEST_KEY = "CurrentResponseMessageRequest";
|
|
7
|
+
export interface ChannelStrategy {
|
|
8
|
+
getMessages(): Promise<Channel.Message[]>;
|
|
9
|
+
handleMessage(message: any): Promise<void>;
|
|
10
|
+
createChannel(id: number): Promise<Channel>;
|
|
11
|
+
support(): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=channel-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/channel/channel-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,eAAO,MAAM,eAAe,eAA4B,CAAC;AAEzD,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,eAAO,MAAM,oCAAoC,kCAAkC,CAAC;AACpF,eAAO,MAAM,iCAAiC,+BAA+B,CAAC;AAC9E,eAAO,MAAM,oCAAoC,kCAAkC,CAAC;AAEpF,MAAM,WAAW,eAAe;IAE5B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAE1C,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE3C,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAE/B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CURRENT_RESPONSE_MESSAGE_REQUEST_KEY = exports.CURRENT_MESSAGE_COUNT_REQUEST_KEY = exports.CURRENT_CHANNEL_STRATEGY_REQUEST_KEY = exports.CHANNEL_MIDDLEWARE_PRIORITY = exports.ChannelStrategy = void 0;
|
|
4
|
+
exports.ChannelStrategy = Symbol('ChannelStrategy');
|
|
5
|
+
exports.CHANNEL_MIDDLEWARE_PRIORITY = 2100;
|
|
6
|
+
exports.CURRENT_CHANNEL_STRATEGY_REQUEST_KEY = 'CurrentChannelStrategyRequest';
|
|
7
|
+
exports.CURRENT_MESSAGE_COUNT_REQUEST_KEY = 'CurrentMessageCountRequest';
|
|
8
|
+
exports.CURRENT_RESPONSE_MESSAGE_REQUEST_KEY = 'CurrentResponseMessageRequest';
|
|
9
|
+
//# sourceMappingURL=channel-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-protocol.js","sourceRoot":"","sources":["../../../src/node/channel/channel-protocol.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAE5C,QAAA,2BAA2B,GAAG,IAAI,CAAC;AAEnC,QAAA,oCAAoC,GAAG,+BAA+B,CAAC;AACvE,QAAA,iCAAiC,GAAG,4BAA4B,CAAC;AACjE,QAAA,oCAAoC,GAAG,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Channel } from '../../common/channal';
|
|
2
|
+
import { ChannelStrategy } from './channel-protocol';
|
|
3
|
+
export declare class HttpChannelStrategy implements ChannelStrategy {
|
|
4
|
+
getMessages(): Promise<Channel.Message[]>;
|
|
5
|
+
createChannel(id: number): Promise<Channel>;
|
|
6
|
+
handleMessage(message: string): Promise<void>;
|
|
7
|
+
protected consumeMessage(message: string): boolean;
|
|
8
|
+
support(): Promise<boolean>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=channel-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-strategy.d.ts","sourceRoot":"","sources":["../../../src/node/channel/channel-strategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAA2E,MAAM,oBAAoB,CAAC;AAI9H,qBACa,mBAAoB,YAAW,eAAe;IACjD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAezC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM3C,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM;IAelC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAIpC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HttpChannelStrategy = void 0;
|
|
10
|
+
const channal_1 = require("../../common/channal");
|
|
11
|
+
const channel_protocol_1 = require("./channel-protocol");
|
|
12
|
+
const core_1 = require("@celljs/core");
|
|
13
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
14
|
+
let HttpChannelStrategy = class HttpChannelStrategy {
|
|
15
|
+
async getMessages() {
|
|
16
|
+
let message = await node_1.Context.getRequest().body;
|
|
17
|
+
if (!Array.isArray(message)) {
|
|
18
|
+
message = [message];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const parsed = [];
|
|
22
|
+
for (const m of message) {
|
|
23
|
+
parsed.push(JSON.parse(m));
|
|
24
|
+
}
|
|
25
|
+
message = parsed;
|
|
26
|
+
}
|
|
27
|
+
node_1.Context.setAttr(channel_protocol_1.CURRENT_MESSAGE_COUNT_REQUEST_KEY, message.length);
|
|
28
|
+
return message;
|
|
29
|
+
}
|
|
30
|
+
async createChannel(id) {
|
|
31
|
+
return new channal_1.HttpChannel(id, async (content) => {
|
|
32
|
+
this.handleMessage(content);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async handleMessage(message) {
|
|
36
|
+
if (!this.consumeMessage(message)) {
|
|
37
|
+
const deferred = node_1.Context.getResponse().body;
|
|
38
|
+
const messages = node_1.Context.getAttr(channel_protocol_1.CURRENT_RESPONSE_MESSAGE_REQUEST_KEY);
|
|
39
|
+
deferred.resolve(messages.length > 1 ? JSON.stringify(messages) : message);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
consumeMessage(message) {
|
|
43
|
+
const messageCount = node_1.Context.getAttr(channel_protocol_1.CURRENT_MESSAGE_COUNT_REQUEST_KEY);
|
|
44
|
+
node_1.Context.setAttr(channel_protocol_1.CURRENT_MESSAGE_COUNT_REQUEST_KEY, messageCount - 1);
|
|
45
|
+
let messages = node_1.Context.getAttr(channel_protocol_1.CURRENT_RESPONSE_MESSAGE_REQUEST_KEY);
|
|
46
|
+
if (!messages) {
|
|
47
|
+
messages = [];
|
|
48
|
+
node_1.Context.setAttr(channel_protocol_1.CURRENT_RESPONSE_MESSAGE_REQUEST_KEY, messages);
|
|
49
|
+
}
|
|
50
|
+
messages.push(message);
|
|
51
|
+
if (messageCount - 1 <= 0) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
async support() {
|
|
57
|
+
return node_1.Context.getCurrent() instanceof node_1.Context;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
HttpChannelStrategy = __decorate([
|
|
61
|
+
(0, core_1.Component)(channel_protocol_1.ChannelStrategy)
|
|
62
|
+
], HttpChannelStrategy);
|
|
63
|
+
exports.HttpChannelStrategy = HttpChannelStrategy;
|
|
64
|
+
//# sourceMappingURL=channel-strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-strategy.js","sourceRoot":"","sources":["../../../src/node/channel/channel-strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,kDAA4D;AAC5D,yDAA8H;AAC9H,uCAAyC;AACzC,+CAA+C;AAGxC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC5B,KAAK,CAAC,WAAW;QACb,IAAI,OAAO,GAAG,MAAM,cAAO,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACzB,OAAO,GAAG,CAAE,OAAO,CAAE,CAAC;SACzB;aAAM;YACH,MAAM,MAAM,GAAsB,EAAE,CAAC;YACrC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9B;YACD,OAAO,GAAG,MAAM,CAAC;SACpB;QACD,cAAO,CAAC,OAAO,CAAC,oDAAiC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU;QAC1B,OAAO,IAAI,qBAAW,CAAC,EAAE,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;YACvC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAe;QAC/B,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YAC/B,MAAM,QAAQ,GAAG,cAAO,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC;YAC5C,MAAM,QAAQ,GAAG,cAAO,CAAC,OAAO,CAAW,uDAAoC,CAAC,CAAC;YACjF,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SAC9E;IACL,CAAC;IAES,cAAc,CAAC,OAAe;QACpC,MAAM,YAAY,GAAG,cAAO,CAAC,OAAO,CAAS,oDAAiC,CAAC,CAAC;QAChF,cAAO,CAAC,OAAO,CAAC,oDAAiC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;QACrE,IAAI,QAAQ,GAAG,cAAO,CAAC,OAAO,CAAW,uDAAoC,CAAC,CAAC;QAC/E,IAAI,CAAC,QAAQ,EAAE;YACX,QAAQ,GAAG,EAAE,CAAC;YACd,cAAO,CAAC,OAAO,CAAC,uDAAoC,EAAE,QAAQ,CAAC,CAAC;SACnE;QACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,YAAY,GAAG,CAAC,IAAI,CAAC,EAAE;YACvB,OAAO,KAAK,CAAC;SAChB;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,OAAO;QACT,OAAO,cAAO,CAAC,UAAU,EAAE,YAAY,cAAO,CAAC;IACnD,CAAC;CAEJ,CAAA;AAjDY,mBAAmB;IAD/B,IAAA,gBAAS,EAAC,kCAAe,CAAC;GACd,mBAAmB,CAiD/B;AAjDY,kDAAmB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/channel/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./channel-manager"), exports);
|
|
18
|
+
__exportStar(require("./channel-protocol"), exports);
|
|
19
|
+
__exportStar(require("./channel-strategy"), exports);
|
|
20
|
+
__exportStar(require("./channel-middleware"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/channel/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC;AACnC,qDAAmC;AACnC,uDAAqC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChannelManager } from '../channel';
|
|
2
|
+
import { RequestMatcher, HandlerAdapter } from '@celljs/web/lib/node';
|
|
3
|
+
import { PathResolver } from '@celljs/web';
|
|
4
|
+
export declare const PATH_PARMAS_ATTR = "pathParams";
|
|
5
|
+
export declare class RpcHandlerAdapter implements HandlerAdapter {
|
|
6
|
+
readonly priority = 1000;
|
|
7
|
+
protected readonly channelManager: ChannelManager;
|
|
8
|
+
protected readonly requestMatcher: RequestMatcher;
|
|
9
|
+
protected readonly pathResolver: PathResolver;
|
|
10
|
+
protected readonly rpcPath: string;
|
|
11
|
+
handle(): Promise<void>;
|
|
12
|
+
canHandle(): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=handler-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-adapter.d.ts","sourceRoot":"","sources":["../../../src/node/handler/handler-adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAE7C,qBACa,iBAAkB,YAAW,cAAc;IACpD,QAAQ,CAAC,QAAQ,QAAgC;IAGjD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAG9C,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAE7B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAQvB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;CAItC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RpcHandlerAdapter = exports.PATH_PARMAS_ATTR = void 0;
|
|
13
|
+
const core_1 = require("@celljs/core");
|
|
14
|
+
const channel_1 = require("../channel");
|
|
15
|
+
const handler_protocol_1 = require("./handler-protocol");
|
|
16
|
+
const node_1 = require("@celljs/web/lib/node");
|
|
17
|
+
const web_1 = require("@celljs/web");
|
|
18
|
+
const common_1 = require("../../common");
|
|
19
|
+
exports.PATH_PARMAS_ATTR = 'pathParams';
|
|
20
|
+
let RpcHandlerAdapter = class RpcHandlerAdapter {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.priority = handler_protocol_1.RPC_HANDLER_ADAPTER_PRIORITY;
|
|
23
|
+
}
|
|
24
|
+
async handle() {
|
|
25
|
+
await this.channelManager.handleChannels();
|
|
26
|
+
const response = node_1.Context.getResponse();
|
|
27
|
+
if (response.body instanceof core_1.Deferred) {
|
|
28
|
+
response.body = await response.body.promise;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async canHandle() {
|
|
32
|
+
return this.requestMatcher.match(await this.pathResolver.resolve(this.rpcPath));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, core_1.Autowired)(channel_1.ChannelManager),
|
|
37
|
+
__metadata("design:type", channel_1.ChannelManager)
|
|
38
|
+
], RpcHandlerAdapter.prototype, "channelManager", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, core_1.Autowired)(node_1.RequestMatcher),
|
|
41
|
+
__metadata("design:type", Object)
|
|
42
|
+
], RpcHandlerAdapter.prototype, "requestMatcher", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, core_1.Autowired)(web_1.PathResolver),
|
|
45
|
+
__metadata("design:type", Object)
|
|
46
|
+
], RpcHandlerAdapter.prototype, "pathResolver", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, core_1.Value)(common_1.RPC_PATH),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], RpcHandlerAdapter.prototype, "rpcPath", void 0);
|
|
51
|
+
RpcHandlerAdapter = __decorate([
|
|
52
|
+
(0, core_1.Component)(node_1.HandlerAdapter)
|
|
53
|
+
], RpcHandlerAdapter);
|
|
54
|
+
exports.RpcHandlerAdapter = RpcHandlerAdapter;
|
|
55
|
+
//# sourceMappingURL=handler-adapter.js.map
|