@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.
Files changed (249) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/cell.yml +8 -0
  4. package/lib/common/annotation/autorpc.d.ts +6 -0
  5. package/lib/common/annotation/autorpc.d.ts.map +1 -0
  6. package/lib/common/annotation/autorpc.js +19 -0
  7. package/lib/common/annotation/autorpc.js.map +1 -0
  8. package/lib/common/annotation/detached/autorpc.d.ts +3 -0
  9. package/lib/common/annotation/detached/autorpc.d.ts.map +1 -0
  10. package/lib/common/annotation/detached/autorpc.js +15 -0
  11. package/lib/common/annotation/detached/autorpc.js.map +1 -0
  12. package/lib/common/annotation/detached/index.d.ts +2 -0
  13. package/lib/common/annotation/detached/index.d.ts.map +1 -0
  14. package/lib/common/annotation/detached/index.js +18 -0
  15. package/lib/common/annotation/detached/index.js.map +1 -0
  16. package/lib/common/annotation/index.d.ts +3 -0
  17. package/lib/common/annotation/index.d.ts.map +1 -0
  18. package/lib/common/annotation/index.js +19 -0
  19. package/lib/common/annotation/index.js.map +1 -0
  20. package/lib/common/annotation/rpc.d.ts +20 -0
  21. package/lib/common/annotation/rpc.d.ts.map +1 -0
  22. package/lib/common/annotation/rpc.js +41 -0
  23. package/lib/common/annotation/rpc.js.map +1 -0
  24. package/lib/common/channal/channel-protocol.d.ts +52 -0
  25. package/lib/common/channal/channel-protocol.d.ts.map +1 -0
  26. package/lib/common/channal/channel-protocol.js +38 -0
  27. package/lib/common/channal/channel-protocol.js.map +1 -0
  28. package/lib/common/channal/http-channel.d.ts +9 -0
  29. package/lib/common/channal/http-channel.d.ts.map +1 -0
  30. package/lib/common/channal/http-channel.js +26 -0
  31. package/lib/common/channal/http-channel.js.map +1 -0
  32. package/lib/common/channal/index.d.ts +3 -0
  33. package/lib/common/channal/index.d.ts.map +1 -0
  34. package/lib/common/channal/index.js +19 -0
  35. package/lib/common/channal/index.js.map +1 -0
  36. package/lib/common/constants.d.ts +2 -0
  37. package/lib/common/constants.d.ts.map +1 -0
  38. package/lib/common/constants.js +5 -0
  39. package/lib/common/constants.js.map +1 -0
  40. package/lib/common/converter/converter-protocol.d.ts +7 -0
  41. package/lib/common/converter/converter-protocol.d.ts.map +1 -0
  42. package/lib/common/converter/converter-protocol.js +6 -0
  43. package/lib/common/converter/converter-protocol.js.map +1 -0
  44. package/lib/common/converter/index.d.ts +2 -0
  45. package/lib/common/converter/index.d.ts.map +1 -0
  46. package/lib/common/converter/index.js +18 -0
  47. package/lib/common/converter/index.js.map +1 -0
  48. package/lib/common/endpoint/endpoint-protocol.d.ts +5 -0
  49. package/lib/common/endpoint/endpoint-protocol.d.ts.map +1 -0
  50. package/lib/common/endpoint/endpoint-protocol.js +5 -0
  51. package/lib/common/endpoint/endpoint-protocol.js.map +1 -0
  52. package/lib/common/endpoint/endpoint-resolver.d.ts +13 -0
  53. package/lib/common/endpoint/endpoint-resolver.d.ts.map +1 -0
  54. package/lib/common/endpoint/endpoint-resolver.js +61 -0
  55. package/lib/common/endpoint/endpoint-resolver.js.map +1 -0
  56. package/lib/common/endpoint/index.d.ts +3 -0
  57. package/lib/common/endpoint/index.d.ts.map +1 -0
  58. package/lib/common/endpoint/index.js +19 -0
  59. package/lib/common/endpoint/index.js.map +1 -0
  60. package/lib/common/error/error.d.ts +6 -0
  61. package/lib/common/error/error.d.ts.map +1 -0
  62. package/lib/common/error/error.js +12 -0
  63. package/lib/common/error/error.js.map +1 -0
  64. package/lib/common/error/index.d.ts +2 -0
  65. package/lib/common/error/index.d.ts.map +1 -0
  66. package/lib/common/error/index.js +18 -0
  67. package/lib/common/error/index.js.map +1 -0
  68. package/lib/common/factory/connection-factory.d.ts +10 -0
  69. package/lib/common/factory/connection-factory.d.ts.map +1 -0
  70. package/lib/common/factory/connection-factory.js +28 -0
  71. package/lib/common/factory/connection-factory.js.map +1 -0
  72. package/lib/common/factory/index.d.ts +5 -0
  73. package/lib/common/factory/index.d.ts.map +1 -0
  74. package/lib/common/factory/index.js +21 -0
  75. package/lib/common/factory/index.js.map +1 -0
  76. package/lib/common/factory/proxy-factory.d.ts +57 -0
  77. package/lib/common/factory/proxy-factory.d.ts.map +1 -0
  78. package/lib/common/factory/proxy-factory.js +182 -0
  79. package/lib/common/factory/proxy-factory.js.map +1 -0
  80. package/lib/common/factory/reader.d.ts +16 -0
  81. package/lib/common/factory/reader.d.ts.map +1 -0
  82. package/lib/common/factory/reader.js +48 -0
  83. package/lib/common/factory/reader.js.map +1 -0
  84. package/lib/common/factory/writer.d.ts +10 -0
  85. package/lib/common/factory/writer.d.ts.map +1 -0
  86. package/lib/common/factory/writer.js +25 -0
  87. package/lib/common/factory/writer.js.map +1 -0
  88. package/lib/common/handler/connection-handler.d.ts +7 -0
  89. package/lib/common/handler/connection-handler.d.ts.map +1 -0
  90. package/lib/common/handler/connection-handler.js +8 -0
  91. package/lib/common/handler/connection-handler.js.map +1 -0
  92. package/lib/common/handler/handler-protocol.d.ts +7 -0
  93. package/lib/common/handler/handler-protocol.d.ts.map +1 -0
  94. package/lib/common/handler/handler-protocol.js +5 -0
  95. package/lib/common/handler/handler-protocol.js.map +1 -0
  96. package/lib/common/handler/index.d.ts +3 -0
  97. package/lib/common/handler/index.d.ts.map +1 -0
  98. package/lib/common/handler/index.js +19 -0
  99. package/lib/common/handler/index.js.map +1 -0
  100. package/lib/common/index.d.ts +12 -0
  101. package/lib/common/index.d.ts.map +1 -0
  102. package/lib/common/index.js +28 -0
  103. package/lib/common/index.js.map +1 -0
  104. package/lib/common/module.d.ts +4 -0
  105. package/lib/common/module.d.ts.map +1 -0
  106. package/lib/common/module.js +22 -0
  107. package/lib/common/module.js.map +1 -0
  108. package/lib/common/processor/client-config-processor.d.ts +6 -0
  109. package/lib/common/processor/client-config-processor.d.ts.map +1 -0
  110. package/lib/common/processor/client-config-processor.js +20 -0
  111. package/lib/common/processor/client-config-processor.js.map +1 -0
  112. package/lib/common/processor/index.d.ts +3 -0
  113. package/lib/common/processor/index.d.ts.map +1 -0
  114. package/lib/common/processor/index.js +19 -0
  115. package/lib/common/processor/index.js.map +1 -0
  116. package/lib/common/processor/processor-protocol.d.ts +6 -0
  117. package/lib/common/processor/processor-protocol.d.ts.map +1 -0
  118. package/lib/common/processor/processor-protocol.js +5 -0
  119. package/lib/common/processor/processor-protocol.js.map +1 -0
  120. package/lib/common/proxy/delegating-http-proxy-creator.d.ts +24 -0
  121. package/lib/common/proxy/delegating-http-proxy-creator.d.ts.map +1 -0
  122. package/lib/common/proxy/delegating-http-proxy-creator.js +89 -0
  123. package/lib/common/proxy/delegating-http-proxy-creator.js.map +1 -0
  124. package/lib/common/proxy/http-proxy-creator.d.ts +43 -0
  125. package/lib/common/proxy/http-proxy-creator.d.ts.map +1 -0
  126. package/lib/common/proxy/http-proxy-creator.js +137 -0
  127. package/lib/common/proxy/http-proxy-creator.js.map +1 -0
  128. package/lib/common/proxy/index.d.ts +5 -0
  129. package/lib/common/proxy/index.d.ts.map +1 -0
  130. package/lib/common/proxy/index.js +21 -0
  131. package/lib/common/proxy/index.js.map +1 -0
  132. package/lib/common/proxy/proxy-protocol.d.ts +22 -0
  133. package/lib/common/proxy/proxy-protocol.d.ts.map +1 -0
  134. package/lib/common/proxy/proxy-protocol.js +6 -0
  135. package/lib/common/proxy/proxy-protocol.js.map +1 -0
  136. package/lib/common/proxy/proxy-provider.d.ts +10 -0
  137. package/lib/common/proxy/proxy-provider.d.ts.map +1 -0
  138. package/lib/common/proxy/proxy-provider.js +43 -0
  139. package/lib/common/proxy/proxy-provider.js.map +1 -0
  140. package/lib/common/utils/converter-util.d.ts +8 -0
  141. package/lib/common/utils/converter-util.d.ts.map +1 -0
  142. package/lib/common/utils/converter-util.js +32 -0
  143. package/lib/common/utils/converter-util.js.map +1 -0
  144. package/lib/common/utils/index.d.ts +4 -0
  145. package/lib/common/utils/index.d.ts.map +1 -0
  146. package/lib/common/utils/index.js +20 -0
  147. package/lib/common/utils/index.js.map +1 -0
  148. package/lib/common/utils/logger.d.ts +9 -0
  149. package/lib/common/utils/logger.d.ts.map +1 -0
  150. package/lib/common/utils/logger.js +22 -0
  151. package/lib/common/utils/logger.js.map +1 -0
  152. package/lib/common/utils/rpc-util.d.ts +13 -0
  153. package/lib/common/utils/rpc-util.d.ts.map +1 -0
  154. package/lib/common/utils/rpc-util.js +46 -0
  155. package/lib/common/utils/rpc-util.js.map +1 -0
  156. package/lib/node/channel/channel-manager.d.ts +10 -0
  157. package/lib/node/channel/channel-manager.d.ts.map +1 -0
  158. package/lib/node/channel/channel-manager.js +59 -0
  159. package/lib/node/channel/channel-manager.js.map +1 -0
  160. package/lib/node/channel/channel-middleware.d.ts +8 -0
  161. package/lib/node/channel/channel-middleware.d.ts.map +1 -0
  162. package/lib/node/channel/channel-middleware.js +40 -0
  163. package/lib/node/channel/channel-middleware.js.map +1 -0
  164. package/lib/node/channel/channel-protocol.d.ts +13 -0
  165. package/lib/node/channel/channel-protocol.d.ts.map +1 -0
  166. package/lib/node/channel/channel-protocol.js +9 -0
  167. package/lib/node/channel/channel-protocol.js.map +1 -0
  168. package/lib/node/channel/channel-strategy.d.ts +10 -0
  169. package/lib/node/channel/channel-strategy.d.ts.map +1 -0
  170. package/lib/node/channel/channel-strategy.js +64 -0
  171. package/lib/node/channel/channel-strategy.js.map +1 -0
  172. package/lib/node/channel/index.d.ts +5 -0
  173. package/lib/node/channel/index.d.ts.map +1 -0
  174. package/lib/node/channel/index.js +21 -0
  175. package/lib/node/channel/index.js.map +1 -0
  176. package/lib/node/handler/handler-adapter.d.ts +14 -0
  177. package/lib/node/handler/handler-adapter.d.ts.map +1 -0
  178. package/lib/node/handler/handler-adapter.js +55 -0
  179. package/lib/node/handler/handler-adapter.js.map +1 -0
  180. package/lib/node/handler/handler-protocol.d.ts +2 -0
  181. package/lib/node/handler/handler-protocol.d.ts.map +1 -0
  182. package/lib/node/handler/handler-protocol.js +5 -0
  183. package/lib/node/handler/handler-protocol.js.map +1 -0
  184. package/lib/node/handler/index.d.ts +3 -0
  185. package/lib/node/handler/index.d.ts.map +1 -0
  186. package/lib/node/handler/index.js +19 -0
  187. package/lib/node/handler/index.js.map +1 -0
  188. package/lib/node/index.d.ts +3 -0
  189. package/lib/node/index.d.ts.map +1 -0
  190. package/lib/node/index.js +19 -0
  191. package/lib/node/index.js.map +1 -0
  192. package/lib/node/module.d.ts +4 -0
  193. package/lib/node/module.d.ts.map +1 -0
  194. package/lib/node/module.js +6 -0
  195. package/lib/node/module.js.map +1 -0
  196. package/lib/package.spec.d.ts +1 -0
  197. package/lib/package.spec.d.ts.map +1 -0
  198. package/lib/package.spec.js +4 -0
  199. package/lib/package.spec.js.map +1 -0
  200. package/package.json +45 -0
  201. package/src/common/annotation/autorpc.ts +17 -0
  202. package/src/common/annotation/detached/autorpc.ts +12 -0
  203. package/src/common/annotation/detached/index.ts +1 -0
  204. package/src/common/annotation/index.ts +2 -0
  205. package/src/common/annotation/rpc.ts +41 -0
  206. package/src/common/channal/channel-protocol.ts +82 -0
  207. package/src/common/channal/http-channel.ts +30 -0
  208. package/src/common/channal/index.ts +2 -0
  209. package/src/common/constants.ts +1 -0
  210. package/src/common/converter/converter-protocol.ts +8 -0
  211. package/src/common/converter/index.ts +1 -0
  212. package/src/common/endpoint/endpoint-protocol.ts +5 -0
  213. package/src/common/endpoint/endpoint-resolver.ts +46 -0
  214. package/src/common/endpoint/index.ts +2 -0
  215. package/src/common/error/error.ts +7 -0
  216. package/src/common/error/index.ts +1 -0
  217. package/src/common/factory/connection-factory.ts +21 -0
  218. package/src/common/factory/index.ts +4 -0
  219. package/src/common/factory/proxy-factory.ts +219 -0
  220. package/src/common/factory/reader.ts +50 -0
  221. package/src/common/factory/writer.ts +26 -0
  222. package/src/common/handler/connection-handler.ts +7 -0
  223. package/src/common/handler/handler-protocol.ts +8 -0
  224. package/src/common/handler/index.ts +2 -0
  225. package/src/common/index.ts +11 -0
  226. package/src/common/module.ts +21 -0
  227. package/src/common/processor/client-config-processor.ts +12 -0
  228. package/src/common/processor/index.ts +2 -0
  229. package/src/common/processor/processor-protocol.ts +7 -0
  230. package/src/common/proxy/delegating-http-proxy-creator.ts +68 -0
  231. package/src/common/proxy/http-proxy-creator.ts +179 -0
  232. package/src/common/proxy/index.ts +5 -0
  233. package/src/common/proxy/proxy-protocol.ts +26 -0
  234. package/src/common/proxy/proxy-provider.ts +29 -0
  235. package/src/common/utils/converter-util.ts +29 -0
  236. package/src/common/utils/index.ts +3 -0
  237. package/src/common/utils/logger.ts +23 -0
  238. package/src/common/utils/rpc-util.ts +46 -0
  239. package/src/node/channel/channel-manager.ts +44 -0
  240. package/src/node/channel/channel-middleware.ts +27 -0
  241. package/src/node/channel/channel-protocol.ts +21 -0
  242. package/src/node/channel/channel-strategy.ts +56 -0
  243. package/src/node/channel/index.ts +4 -0
  244. package/src/node/handler/handler-adapter.ts +38 -0
  245. package/src/node/handler/handler-protocol.ts +1 -0
  246. package/src/node/handler/index.ts +2 -0
  247. package/src/node/index.ts +2 -0
  248. package/src/node/module.ts +4 -0
  249. package/src/package.spec.ts +4 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-adapter.js","sourceRoot":"","sources":["../../../src/node/handler/handler-adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAqE;AACrE,wCAA4C;AAC5C,yDAAkE;AAClE,+CAA+E;AAC/E,qCAA2C;AAC3C,yCAAwC;AAE3B,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAAvB;QACM,aAAQ,GAAG,+CAA4B,CAAC;IA0BrD,CAAC;IAZG,KAAK,CAAC,MAAM;QACR,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,cAAO,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,QAAQ,CAAC,IAAI,YAAY,eAAQ,EAAE;YACnC,QAAQ,CAAC,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;SAC/C;IACL,CAAC;IAED,KAAK,CAAC,SAAS;QACX,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACpF,CAAC;CAEJ,CAAA;AAxBG;IAAC,IAAA,gBAAS,EAAC,wBAAc,CAAC;8BACS,wBAAc;yDAAC;AAElD;IAAC,IAAA,gBAAS,EAAC,qBAAc,CAAC;;yDACwB;AAElD;IAAC,IAAA,gBAAS,EAAC,kBAAY,CAAC;;uDACsB;AAE9C;IAAC,IAAA,YAAK,EAAC,iBAAQ,CAAC;;kDACmB;AAb1B,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,qBAAc,CAAC;GACb,iBAAiB,CA2B7B;AA3BY,8CAAiB"}
@@ -0,0 +1,2 @@
1
+ export declare const RPC_HANDLER_ADAPTER_PRIORITY = 1000;
2
+ //# sourceMappingURL=handler-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/handler/handler-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,4BAA4B,OAAO,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RPC_HANDLER_ADAPTER_PRIORITY = void 0;
4
+ exports.RPC_HANDLER_ADAPTER_PRIORITY = 1000;
5
+ //# sourceMappingURL=handler-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handler-protocol.js","sourceRoot":"","sources":["../../../src/node/handler/handler-protocol.ts"],"names":[],"mappings":";;;AAAa,QAAA,4BAA4B,GAAG,IAAI,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './handler-adapter';
2
+ export * from './handler-protocol';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/handler/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,19 @@
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("./handler-adapter"), exports);
18
+ __exportStar(require("./handler-protocol"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/handler/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,qDAAmC"}
@@ -0,0 +1,3 @@
1
+ export * from './channel';
2
+ export * from './handler';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,19 @@
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"), exports);
18
+ __exportStar(require("./handler"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,4CAA0B"}
@@ -0,0 +1,4 @@
1
+ import './index';
2
+ declare const _default: import("inversify/lib/interfaces/interfaces").interfaces.ContainerModule;
3
+ export default _default;
4
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,CAAC;;AAEjB,wBAA0B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@celljs/core");
4
+ require("./index");
5
+ exports.default = (0, core_1.autoBind)();
6
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/node/module.ts"],"names":[],"mappings":";;AAAA,uCAAwC;AACxC,mBAAiB;AAEjB,kBAAe,IAAA,eAAQ,GAAE,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=package.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.d.ts","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ describe('rpc package', () => {
2
+ it('support code coverage statistics', () => { });
3
+ });
4
+ //# sourceMappingURL=package.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.spec.js","sourceRoot":"","sources":["../src/package.spec.ts"],"names":[],"mappings":"AAAA,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAEzB,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@celljs/rpc",
3
+ "version": "3.0.0",
4
+ "description": "",
5
+ "main": "lib/common/index.js",
6
+ "typings": "lib/common/index.d.ts",
7
+ "dependencies": {
8
+ "@celljs/core": "3.0.0",
9
+ "@celljs/http": "3.0.0",
10
+ "@celljs/web": "3.0.0",
11
+ "axios": "^0.26.1",
12
+ "vscode-jsonrpc": "^6.0.0"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "keywords": [
18
+ "cell-component"
19
+ ],
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/cellbang/cell.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/cellbang/cell/issues"
27
+ },
28
+ "homepage": "https://github.com/cellbang/cell",
29
+ "files": [
30
+ "lib",
31
+ "src",
32
+ "cell.yml"
33
+ ],
34
+ "scripts": {
35
+ "lint": "cell-component lint",
36
+ "build": "cell-component build",
37
+ "watch": "cell-component watch",
38
+ "clean": "cell-component clean",
39
+ "test": "cell-component test:js"
40
+ },
41
+ "devDependencies": {
42
+ "@celljs/component": "3.0.0"
43
+ },
44
+ "gitHead": "c0ef8d269e33a795406bcbb240cac4b845c6c24c"
45
+ }
@@ -0,0 +1,17 @@
1
+ import { applyAutowiredDecorator, IdOrAutowiredOptionWithoutMulti, DoInject, parseAutowiredOption, Tagged, Inject } from '@celljs/core';
2
+
3
+ export const RPC = Symbol('RPC');
4
+ export const ID_KEY = Symbol('ID_KEY');
5
+
6
+ export const Autorpc = function (idOrOption?: IdOrAutowiredOptionWithoutMulti): PropertyDecorator & ParameterDecorator {
7
+ return (target: any, targetKey: string, index?: number) => {
8
+ const option = parseAutowiredOption(target, targetKey, index, idOrOption);
9
+ applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutorpc);
10
+ };
11
+ };
12
+
13
+ export const doInjectForAutorpc: DoInject = (option, t, k, i) => {
14
+ Inject(RPC)(t, k, i);
15
+ Tagged(ID_KEY, option.id!)(t, k, i);
16
+ };
17
+
@@ -0,0 +1,12 @@
1
+ import { applyAutowiredDecorator, ContainerUtil, DoGetValue, IdOrAutowiredOptionWithoutMulti, parseAutowiredOption } from '@celljs/core';
2
+ import { RPC, ID_KEY, doInjectForAutorpc } from '../autorpc';
3
+
4
+ export const Autorpc = function (idOrOption?: IdOrAutowiredOptionWithoutMulti): PropertyDecorator & ParameterDecorator {
5
+ return (target: any, targetKey: string, index?: number) => {
6
+ const option = parseAutowiredOption(target, targetKey, index, idOrOption);
7
+ option.detached = true;
8
+ applyAutowiredDecorator(option, target, targetKey, index, doInjectForAutorpc, doGetValueForAutorpc);
9
+ };
10
+ };
11
+
12
+ const doGetValueForAutorpc: DoGetValue = (option, t, property) => ContainerUtil.getTagged(RPC, ID_KEY, option.id!);
@@ -0,0 +1 @@
1
+ export * from './autorpc';
@@ -0,0 +1,2 @@
1
+ export * from './rpc';
2
+ export * from './autorpc';
@@ -0,0 +1,41 @@
1
+ import { ComponentDecorator, applyComponentDecorator, ComponentOption, parseComponentOption, Logger, Container } from '@celljs/core';
2
+ import { AOP_POINTCUT, PipeManager } from '@celljs/web';
3
+ import { ConnectionHandler } from '../handler';
4
+ import { JsonRpcConnectionHandler } from '../factory';
5
+ import { RpcUtil, ConverterUtil } from '../utils';
6
+
7
+ export const RPC_TAG = 'Rpc';
8
+
9
+ export const Rpc = <ComponentDecorator>function (...idOrOption: any): ClassDecorator {
10
+ return target => {
11
+ const option = parseRpcOption(target, idOrOption);
12
+ applyRpcDecorator(option, target);
13
+ };
14
+ };
15
+
16
+ export function parseRpcOption(target: any, idOrOption: any) {
17
+ const parsed = parseComponentOption(target, idOrOption);
18
+
19
+ if (idOrOption[0].proxy === undefined) {
20
+ parsed.proxy = true;
21
+ }
22
+ parsed.sysTags!.push(AOP_POINTCUT, RPC_TAG);
23
+ return parsed;
24
+ }
25
+
26
+ export function applyRpcDecorator(option: ComponentOption, target: any) {
27
+ const { ids } = applyComponentDecorator(option, target);
28
+ const id = ids[1] || ids[0];
29
+ return applyComponentDecorator({ id: ConnectionHandler, onActivation: context => {
30
+ const t = context.container.get(id);
31
+ const pipeManager = context.container.get<PipeManager>(PipeManager);
32
+ const logger = context.container.get<Logger>(Logger);
33
+ const errorConverters = ConverterUtil.getGlobalErrorConverters(context.container as Container);
34
+ const errorConverter = ConverterUtil.getErrorConverters(id, context.container as Container);
35
+ if (errorConverter) {
36
+ errorConverters.push(errorConverter);
37
+ }
38
+ return new JsonRpcConnectionHandler(RpcUtil.toPath(id), () => t, errorConverters, pipeManager, logger);
39
+ }}, target);
40
+ }
41
+
@@ -0,0 +1,82 @@
1
+ import { Disposable } from 'vscode-jsonrpc';
2
+ import { DisposableCollection } from '@celljs/core';
3
+
4
+ export interface Channel {
5
+ handleMessage(message: Channel.Message): void;
6
+ send(content: string): void;
7
+ onMessage(cb: (data: any) => void): void;
8
+ }
9
+
10
+ export namespace Channel {
11
+ export interface OpenMessage {
12
+ kind: 'open'
13
+ id: number
14
+ path: string
15
+ }
16
+ export interface ReadyMessage {
17
+ kind: 'ready'
18
+ id: number
19
+ }
20
+ export interface DataMessage {
21
+ kind: 'data'
22
+ id: number
23
+ content: string
24
+ }
25
+ export interface CloseMessage {
26
+ kind: 'close'
27
+ id: number
28
+ code: number
29
+ reason: string
30
+ }
31
+ export interface HttpMessage {
32
+ kind: 'http'
33
+ id: number
34
+ path?: string
35
+ content: string
36
+ }
37
+ export type Message = OpenMessage | ReadyMessage | DataMessage | CloseMessage | HttpMessage;
38
+ }
39
+
40
+ export abstract class AbstractChannel implements Channel, Disposable {
41
+
42
+ protected readonly toDispose = new DisposableCollection();
43
+
44
+ constructor(
45
+ readonly id: number,
46
+ protected readonly doSend: (content: string) => Promise<void>
47
+ ) { }
48
+
49
+ dispose(): void {
50
+ this.toDispose.dispose();
51
+ }
52
+
53
+ protected checkNotDisposed(): void {
54
+ if (this.toDispose.disposed) {
55
+ throw new Error('The channel has been disposed.');
56
+ }
57
+ }
58
+
59
+ abstract handleMessage(message: Channel.Message): void;
60
+
61
+ abstract doGetMessage(content: string): Channel.Message;
62
+
63
+ send(content: string): void {
64
+ this.checkNotDisposed();
65
+ this.doSend(JSON.stringify(this.doGetMessage(content)));
66
+ }
67
+
68
+ protected fireMessage: (data: any) => void = () => { };
69
+ onMessage(cb: (data: any) => void): void {
70
+ this.checkNotDisposed();
71
+ this.fireMessage = cb;
72
+ this.toDispose.push(Disposable.create(() => this.fireMessage = () => { }));
73
+ }
74
+
75
+ fireError: (reason: any) => void = () => { };
76
+ onError(cb: (reason: any) => void): void {
77
+ this.checkNotDisposed();
78
+ this.fireError = cb;
79
+ this.toDispose.push(Disposable.create(() => this.fireError = () => { }));
80
+ }
81
+
82
+ }
@@ -0,0 +1,30 @@
1
+ import { Channel, AbstractChannel } from './channel-protocol';
2
+
3
+ export class HttpChannel extends AbstractChannel {
4
+
5
+ constructor(
6
+ id: number,
7
+ doSend: (content: string) => Promise<void>,
8
+ protected readonly path?: string
9
+ ) {
10
+ super(id, doSend);
11
+ }
12
+
13
+ protected override checkNotDisposed(): void {
14
+ // noop
15
+ }
16
+
17
+ handleMessage(message: Channel.HttpMessage) {
18
+ this.fireMessage(message.content);
19
+ }
20
+
21
+ doGetMessage(content: string): Channel.Message {
22
+ return <Channel.HttpMessage>{
23
+ kind: 'http',
24
+ id: this.id,
25
+ path: this.path,
26
+ content
27
+ };
28
+ }
29
+
30
+ }
@@ -0,0 +1,2 @@
1
+ export * from './http-channel';
2
+ export * from './channel-protocol';
@@ -0,0 +1 @@
1
+ export const RPC_PATH = 'cell.rpc.path';
@@ -0,0 +1,8 @@
1
+ export const ErrorConverter = Symbol('ErrorConverter');
2
+
3
+ export const GlobalConverter = Symbol('GlobalConverter');
4
+
5
+ export interface ErrorConverter {
6
+ serialize(e: any): any;
7
+ deserialize(e: any): any
8
+ }
@@ -0,0 +1 @@
1
+ export * from './converter-protocol';
@@ -0,0 +1,5 @@
1
+ export const EndpointResolver = Symbol('EndpointResolver');
2
+
3
+ export interface EndpointResolver {
4
+ resolve(serviceIdentifier: string): Promise<string>;
5
+ }
@@ -0,0 +1,46 @@
1
+ import { Autowired, Component, Value } from '@celljs/core';
2
+ import { RPC_PATH } from '../constants';
3
+ import { PathResolver } from '@celljs/web';
4
+ import { EndpointNotFoundError } from '../error';
5
+ import { EndpointResolver } from './endpoint-protocol';
6
+
7
+ @Component(EndpointResolver)
8
+ export class EndpointResolverImpl implements EndpointResolver {
9
+
10
+ @Value('cell.rpc.endpoint')
11
+ protected readonly endpoint?: { [id: string]: string };
12
+
13
+ @Value('cell.rpc.defaultEndpoint')
14
+ protected readonly defaultEndpoint?: string;
15
+
16
+ @Value(RPC_PATH)
17
+ protected readonly rpcPath: string;
18
+
19
+ @Autowired(PathResolver)
20
+ protected pathResolver: PathResolver;
21
+
22
+ protected parsed: Map<string, string>;
23
+
24
+ async resolve(serviceIdentifier: string): Promise<string> {
25
+ let result: string | undefined;
26
+ if (this.endpoint) {
27
+ result = this.endpoint[serviceIdentifier];
28
+ }
29
+ if (/^https?:/i.test(serviceIdentifier)) {
30
+ result = serviceIdentifier;
31
+ }
32
+ if (!result) {
33
+ result = this.defaultEndpoint;
34
+ }
35
+ if (!result && typeof location !== 'undefined') {
36
+ result = `${location.protocol}//${location.host}{rpcPath}/{serviceIdentifier}`;
37
+ }
38
+ if (!result) {
39
+ throw new EndpointNotFoundError(serviceIdentifier);
40
+ }
41
+ return result
42
+ .replace(/{rpcPath}/g, await this.pathResolver.resolve(this.rpcPath))
43
+ .replace(/{serviceIdentifier}/g, serviceIdentifier);
44
+ }
45
+
46
+ }
@@ -0,0 +1,2 @@
1
+ export * from './endpoint-protocol';
2
+ export * from './endpoint-resolver';
@@ -0,0 +1,7 @@
1
+ import { CustomError } from '@celljs/core';
2
+
3
+ export class EndpointNotFoundError extends CustomError {
4
+ constructor(public serviceId: string) {
5
+ super(`No endpoint found: ${serviceId}`);
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ export * from './error';
@@ -0,0 +1,21 @@
1
+ import { MessageConnection, createMessageConnection, Logger } from 'vscode-jsonrpc';
2
+ import { Channel } from '../channal/channel-protocol';
3
+ import { ChannelMessageReader } from './reader';
4
+ import { ChannelMessageWriter } from './writer';
5
+ import { Component } from '@celljs/core';
6
+
7
+ export const ConnnectionFactory = Symbol('ConnnectionFactory');
8
+
9
+ export interface ConnnectionFactory<T> {
10
+ create(t: T, logger: Logger): MessageConnection;
11
+ }
12
+ @Component(ConnnectionFactory)
13
+ export class ConnnectionFactoryImpl implements ConnnectionFactory<Channel> {
14
+ create(channel: Channel, logger: Logger): MessageConnection {
15
+ const messageReader = new ChannelMessageReader(channel);
16
+ const messageWriter = new ChannelMessageWriter(channel);
17
+ const connection = createMessageConnection(messageReader, messageWriter, logger);
18
+ connection.onClose(() => connection.dispose());
19
+ return connection;
20
+ }
21
+ }
@@ -0,0 +1,4 @@
1
+ export * from './proxy-factory';
2
+ export * from './connection-factory';
3
+ export * from './reader';
4
+ export * from './writer';