@tencent-rtc/mcp 1.0.6 → 1.0.9

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 (342) hide show
  1. package/README.md +4 -4
  2. package/index.js +7 -8
  3. package/index.js.map +1 -1
  4. package/libs/@tencent/aegis-node-sdk/CHANGELOG.md +8 -0
  5. package/libs/@tencent/aegis-node-sdk/LICENSE +21 -0
  6. package/libs/@tencent/aegis-node-sdk/README.md +562 -0
  7. package/libs/@tencent/aegis-node-sdk/lib/aegis.min.js +1 -0
  8. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/constant/config.d.ts +14 -0
  9. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/constant/global.d.ts +1 -0
  10. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/constant/index.d.ts +9 -0
  11. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/constant/report-ignore.d.ts +2 -0
  12. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/core.d.ts +85 -0
  13. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/hooks/afterRequestHooks.d.ts +3 -0
  14. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/hooks/beforeRequestHooks.d.ts +9 -0
  15. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/hooks/modifyRequestHooks.d.ts +3 -0
  16. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/index.d.ts +9 -0
  17. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/interface/config.d.ts +62 -0
  18. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/interface/env.d.ts +11 -0
  19. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/interface/index.d.ts +4 -0
  20. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/interface/log.d.ts +130 -0
  21. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/interface/send.d.ts +34 -0
  22. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/format.d.ts +2 -0
  23. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/index.d.ts +18 -0
  24. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/length-limit.d.ts +8 -0
  25. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/pv.d.ts +8 -0
  26. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/remove-payload.d.ts +2 -0
  27. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/repeat-limit.d.ts +4 -0
  28. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/report.d.ts +10 -0
  29. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/sample.d.ts +3 -0
  30. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/throttle.d.ts +3 -0
  31. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/index.d.ts +34 -0
  32. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/jwt.d.ts +12 -0
  33. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/ot-js.d.ts +14 -0
  34. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/uuid.d.ts +2 -0
  35. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/whitelist.d.ts +12 -0
  36. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/write-before.d.ts +3 -0
  37. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/plugin.d.ts +33 -0
  38. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/polyfill.d.ts +0 -0
  39. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/util/destroy.d.ts +2 -0
  40. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/util/event-emitter.d.ts +18 -0
  41. package/libs/@tencent/aegis-node-sdk/lib/packages/core/src/util/index.d.ts +60 -0
  42. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/index.d.ts +15 -0
  43. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/interface/selector.d.ts +5 -0
  44. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/pipes/batch-report-pipe.d.ts +6 -0
  45. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/protocol/protocol_base.d.ts +18 -0
  46. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/protocol/protocol_http.d.ts +12 -0
  47. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/selector/ip_selector.d.ts +10 -0
  48. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/selector/polaris_selector.d.ts +20 -0
  49. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/selector/selector_base.d.ts +27 -0
  50. package/libs/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/util/eval_require.d.ts +2 -0
  51. package/libs/@tencent/aegis-node-sdk/package.json +19 -0
  52. package/libs/@tencent/polaris/README.md +407 -0
  53. package/libs/@tencent/polaris/dist/consumer/health.d.ts +126 -0
  54. package/libs/@tencent/polaris/dist/consumer/health.js +283 -0
  55. package/libs/@tencent/polaris/dist/consumer/health.js.map +1 -0
  56. package/libs/@tencent/polaris/dist/consumer/index.d.ts +120 -0
  57. package/libs/@tencent/polaris/dist/consumer/index.js +348 -0
  58. package/libs/@tencent/polaris/dist/consumer/index.js.map +1 -0
  59. package/libs/@tencent/polaris/dist/consumer/monitor.d.ts +145 -0
  60. package/libs/@tencent/polaris/dist/consumer/monitor.js +343 -0
  61. package/libs/@tencent/polaris/dist/consumer/monitor.js.map +1 -0
  62. package/libs/@tencent/polaris/dist/consumer/selector.d.ts +73 -0
  63. package/libs/@tencent/polaris/dist/consumer/selector.js +316 -0
  64. package/libs/@tencent/polaris/dist/consumer/selector.js.map +1 -0
  65. package/libs/@tencent/polaris/dist/errors.d.ts +373 -0
  66. package/libs/@tencent/polaris/dist/errors.js +154 -0
  67. package/libs/@tencent/polaris/dist/errors.js.map +1 -0
  68. package/libs/@tencent/polaris/dist/global.d.ts +16 -0
  69. package/libs/@tencent/polaris/dist/global.js +18 -0
  70. package/libs/@tencent/polaris/dist/global.js.map +1 -0
  71. package/libs/@tencent/polaris/dist/index.d.ts +62 -0
  72. package/libs/@tencent/polaris/dist/index.js +145 -0
  73. package/libs/@tencent/polaris/dist/index.js.map +1 -0
  74. package/libs/@tencent/polaris/dist/instance.d.ts +109 -0
  75. package/libs/@tencent/polaris/dist/instance.js +38 -0
  76. package/libs/@tencent/polaris/dist/instance.js.map +1 -0
  77. package/libs/@tencent/polaris/dist/limiter/bucket.d.ts +51 -0
  78. package/libs/@tencent/polaris/dist/limiter/bucket.js +152 -0
  79. package/libs/@tencent/polaris/dist/limiter/bucket.js.map +1 -0
  80. package/libs/@tencent/polaris/dist/limiter/index.d.ts +73 -0
  81. package/libs/@tencent/polaris/dist/limiter/index.js +149 -0
  82. package/libs/@tencent/polaris/dist/limiter/index.js.map +1 -0
  83. package/libs/@tencent/polaris/dist/limiter/ratelimit.d.ts +27 -0
  84. package/libs/@tencent/polaris/dist/limiter/ratelimit.js +134 -0
  85. package/libs/@tencent/polaris/dist/limiter/ratelimit.js.map +1 -0
  86. package/libs/@tencent/polaris/dist/limiter/ratelimiter/base.d.ts +17 -0
  87. package/libs/@tencent/polaris/dist/limiter/ratelimiter/base.js +15 -0
  88. package/libs/@tencent/polaris/dist/limiter/ratelimiter/base.js.map +1 -0
  89. package/libs/@tencent/polaris/dist/limiter/ratelimiter/global.d.ts +59 -0
  90. package/libs/@tencent/polaris/dist/limiter/ratelimiter/global.js +397 -0
  91. package/libs/@tencent/polaris/dist/limiter/ratelimiter/global.js.map +1 -0
  92. package/libs/@tencent/polaris/dist/limiter/ratelimiter/index.d.ts +3 -0
  93. package/libs/@tencent/polaris/dist/limiter/ratelimiter/index.js +19 -0
  94. package/libs/@tencent/polaris/dist/limiter/ratelimiter/index.js.map +1 -0
  95. package/libs/@tencent/polaris/dist/limiter/ratelimiter/local.d.ts +17 -0
  96. package/libs/@tencent/polaris/dist/limiter/ratelimiter/local.js +52 -0
  97. package/libs/@tencent/polaris/dist/limiter/ratelimiter/local.js.map +1 -0
  98. package/libs/@tencent/polaris/dist/location.d.ts +48 -0
  99. package/libs/@tencent/polaris/dist/location.js +67 -0
  100. package/libs/@tencent/polaris/dist/location.js.map +1 -0
  101. package/libs/@tencent/polaris/dist/logging.d.ts +106 -0
  102. package/libs/@tencent/polaris/dist/logging.js +130 -0
  103. package/libs/@tencent/polaris/dist/logging.js.map +1 -0
  104. package/libs/@tencent/polaris/dist/metadata.d.ts +78 -0
  105. package/libs/@tencent/polaris/dist/metadata.js +119 -0
  106. package/libs/@tencent/polaris/dist/metadata.js.map +1 -0
  107. package/libs/@tencent/polaris/dist/plugins/breaker/polaris.d.ts +47 -0
  108. package/libs/@tencent/polaris/dist/plugins/breaker/polaris.js +162 -0
  109. package/libs/@tencent/polaris/dist/plugins/breaker/polaris.js.map +1 -0
  110. package/libs/@tencent/polaris/dist/plugins/lb/base.d.ts +24 -0
  111. package/libs/@tencent/polaris/dist/plugins/lb/base.js +32 -0
  112. package/libs/@tencent/polaris/dist/plugins/lb/base.js.map +1 -0
  113. package/libs/@tencent/polaris/dist/plugins/lb/edf.d.ts +24 -0
  114. package/libs/@tencent/polaris/dist/plugins/lb/edf.js +77 -0
  115. package/libs/@tencent/polaris/dist/plugins/lb/edf.js.map +1 -0
  116. package/libs/@tencent/polaris/dist/plugins/lb/hashring.d.ts +24 -0
  117. package/libs/@tencent/polaris/dist/plugins/lb/hashring.js +53 -0
  118. package/libs/@tencent/polaris/dist/plugins/lb/hashring.js.map +1 -0
  119. package/libs/@tencent/polaris/dist/plugins/lb/sticky.d.ts +31 -0
  120. package/libs/@tencent/polaris/dist/plugins/lb/sticky.js +88 -0
  121. package/libs/@tencent/polaris/dist/plugins/lb/sticky.js.map +1 -0
  122. package/libs/@tencent/polaris/dist/plugins/lb/swrr.d.ts +25 -0
  123. package/libs/@tencent/polaris/dist/plugins/lb/swrr.js +72 -0
  124. package/libs/@tencent/polaris/dist/plugins/lb/swrr.js.map +1 -0
  125. package/libs/@tencent/polaris/dist/plugins/lb/wr.d.ts +17 -0
  126. package/libs/@tencent/polaris/dist/plugins/lb/wr.js +50 -0
  127. package/libs/@tencent/polaris/dist/plugins/lb/wr.js.map +1 -0
  128. package/libs/@tencent/polaris/dist/plugins/lb/wrr.d.ts +19 -0
  129. package/libs/@tencent/polaris/dist/plugins/lb/wrr.js +81 -0
  130. package/libs/@tencent/polaris/dist/plugins/lb/wrr.js.map +1 -0
  131. package/libs/@tencent/polaris/dist/plugins/logging/console.d.ts +10 -0
  132. package/libs/@tencent/polaris/dist/plugins/logging/console.js +38 -0
  133. package/libs/@tencent/polaris/dist/plugins/logging/console.js.map +1 -0
  134. package/libs/@tencent/polaris/dist/plugins/naming/local-server/index.d.ts +32 -0
  135. package/libs/@tencent/polaris/dist/plugins/naming/local-server/index.js +88 -0
  136. package/libs/@tencent/polaris/dist/plugins/naming/local-server/index.js.map +1 -0
  137. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/base.d.ts +124 -0
  138. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/base.js +398 -0
  139. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/base.js.map +1 -0
  140. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/discover.d.ts +27 -0
  141. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/discover.js +287 -0
  142. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/discover.js.map +1 -0
  143. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/index.d.ts +15 -0
  144. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/index.js +43 -0
  145. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/index.js.map +1 -0
  146. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/monitor.d.ts +28 -0
  147. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/monitor.js +249 -0
  148. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/monitor.js.map +1 -0
  149. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/ratelimit.d.ts +19 -0
  150. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/ratelimit.js +222 -0
  151. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/ratelimit.js.map +1 -0
  152. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/bidi.d.ts +26 -0
  153. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/bidi.js +99 -0
  154. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/bidi.js.map +1 -0
  155. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/index.d.ts +60 -0
  156. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/index.js +259 -0
  157. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/index.js.map +1 -0
  158. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/pb/discover.proto +24 -0
  159. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/pb/monitor.proto +18 -0
  160. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/pb/ratelimit.proto +12 -0
  161. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/http/index.d.ts +39 -0
  162. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/http/index.js +115 -0
  163. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/connector/http/index.js.map +1 -0
  164. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/api.proto +24 -0
  165. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/client.proto +22 -0
  166. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/model.proto +28 -0
  167. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/ratelimit.proto +80 -0
  168. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/request.proto +18 -0
  169. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/response.proto +65 -0
  170. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/routing.proto +66 -0
  171. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/service.proto +95 -0
  172. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/types.d.ts +1568 -0
  173. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/index.d.ts +36 -0
  174. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/index.js +51 -0
  175. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/index.js.map +1 -0
  176. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/api.proto +18 -0
  177. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/circuitbreak.proto +67 -0
  178. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/request.proto +82 -0
  179. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/response.proto +11 -0
  180. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/sdkcache.proto +46 -0
  181. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/sdkconfiguration.proto +16 -0
  182. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/sdktoken.proto +10 -0
  183. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/types.d.ts +1102 -0
  184. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/pool.d.ts +29 -0
  185. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/pool.js +77 -0
  186. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/pool.js.map +1 -0
  187. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/ratelimit-pb/api.proto +12 -0
  188. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/ratelimit-pb/ratelimit.proto +28 -0
  189. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/ratelimit-pb/types.d.ts +395 -0
  190. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/rules.d.ts +13 -0
  191. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/rules.js +116 -0
  192. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/rules.js.map +1 -0
  193. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/types.d.ts +67 -0
  194. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/types.js +67 -0
  195. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/types.js.map +1 -0
  196. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/utils.d.ts +99 -0
  197. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/utils.js +217 -0
  198. package/libs/@tencent/polaris/dist/plugins/naming/polaris-server/utils.js.map +1 -0
  199. package/libs/@tencent/polaris/dist/plugins/registry/memory.d.ts +10 -0
  200. package/libs/@tencent/polaris/dist/plugins/registry/memory.js +50 -0
  201. package/libs/@tencent/polaris/dist/plugins/registry/memory.js.map +1 -0
  202. package/libs/@tencent/polaris/dist/plugins/router/polaris/nearby.d.ts +51 -0
  203. package/libs/@tencent/polaris/dist/plugins/router/polaris/nearby.js +145 -0
  204. package/libs/@tencent/polaris/dist/plugins/router/polaris/nearby.js.map +1 -0
  205. package/libs/@tencent/polaris/dist/plugins/router/polaris/rule.d.ts +11 -0
  206. package/libs/@tencent/polaris/dist/plugins/router/polaris/rule.js +174 -0
  207. package/libs/@tencent/polaris/dist/plugins/router/polaris/rule.js.map +1 -0
  208. package/libs/@tencent/polaris/dist/plugins/router/trpc/canary.d.ts +25 -0
  209. package/libs/@tencent/polaris/dist/plugins/router/trpc/canary.js +36 -0
  210. package/libs/@tencent/polaris/dist/plugins/router/trpc/canary.js.map +1 -0
  211. package/libs/@tencent/polaris/dist/plugins/router/trpc/env.d.ts +10 -0
  212. package/libs/@tencent/polaris/dist/plugins/router/trpc/env.js +34 -0
  213. package/libs/@tencent/polaris/dist/plugins/router/trpc/env.js.map +1 -0
  214. package/libs/@tencent/polaris/dist/plugins/router/trpc/set.d.ts +56 -0
  215. package/libs/@tencent/polaris/dist/plugins/router/trpc/set.js +106 -0
  216. package/libs/@tencent/polaris/dist/plugins/router/trpc/set.js.map +1 -0
  217. package/libs/@tencent/polaris/dist/plugins/shaping/unirate.d.ts +31 -0
  218. package/libs/@tencent/polaris/dist/plugins/shaping/unirate.js +124 -0
  219. package/libs/@tencent/polaris/dist/plugins/shaping/unirate.js.map +1 -0
  220. package/libs/@tencent/polaris/dist/plugins/shaping/warmup.d.ts +61 -0
  221. package/libs/@tencent/polaris/dist/plugins/shaping/warmup.js +171 -0
  222. package/libs/@tencent/polaris/dist/plugins/shaping/warmup.js.map +1 -0
  223. package/libs/@tencent/polaris/dist/plugins/weight/polaris.d.ts +23 -0
  224. package/libs/@tencent/polaris/dist/plugins/weight/polaris.js +159 -0
  225. package/libs/@tencent/polaris/dist/plugins/weight/polaris.js.map +1 -0
  226. package/libs/@tencent/polaris/dist/plugins.d.ts +619 -0
  227. package/libs/@tencent/polaris/dist/plugins.js +91 -0
  228. package/libs/@tencent/polaris/dist/plugins.js.map +1 -0
  229. package/libs/@tencent/polaris/dist/polaris.d.ts +33 -0
  230. package/libs/@tencent/polaris/dist/polaris.js +59 -0
  231. package/libs/@tencent/polaris/dist/polaris.js.map +1 -0
  232. package/libs/@tencent/polaris/dist/provider/index.d.ts +102 -0
  233. package/libs/@tencent/polaris/dist/provider/index.js +168 -0
  234. package/libs/@tencent/polaris/dist/provider/index.js.map +1 -0
  235. package/libs/@tencent/polaris/dist/registry.d.ts +174 -0
  236. package/libs/@tencent/polaris/dist/registry.js +660 -0
  237. package/libs/@tencent/polaris/dist/registry.js.map +1 -0
  238. package/libs/@tencent/polaris/dist/rules.d.ts +163 -0
  239. package/libs/@tencent/polaris/dist/rules.js +24 -0
  240. package/libs/@tencent/polaris/dist/rules.js.map +1 -0
  241. package/libs/@tencent/polaris/dist/scripts/postinstall.d.ts +1 -0
  242. package/libs/@tencent/polaris/dist/scripts/postinstall.js +71 -0
  243. package/libs/@tencent/polaris/dist/scripts/postinstall.js.map +1 -0
  244. package/libs/@tencent/polaris/dist/service.d.ts +18 -0
  245. package/libs/@tencent/polaris/dist/service.js +3 -0
  246. package/libs/@tencent/polaris/dist/service.js.map +1 -0
  247. package/libs/@tencent/polaris/dist/skeleton.d.ts +87 -0
  248. package/libs/@tencent/polaris/dist/skeleton.js +282 -0
  249. package/libs/@tencent/polaris/dist/skeleton.js.map +1 -0
  250. package/libs/@tencent/polaris/dist/utils.d.ts +36 -0
  251. package/libs/@tencent/polaris/dist/utils.js +74 -0
  252. package/libs/@tencent/polaris/dist/utils.js.map +1 -0
  253. package/libs/@tencent/polaris/dist/weak.d.ts +11 -0
  254. package/libs/@tencent/polaris/dist/weak.js +44 -0
  255. package/libs/@tencent/polaris/dist/weak.js.map +1 -0
  256. package/libs/@tencent/polaris/package.json +114 -0
  257. package/libs/lib-generate-test-usersig-es.min.d.ts +6 -0
  258. package/libs/lib-generate-test-usersig-es.min.js +2 -0
  259. package/package.json +2 -1
  260. package/resource/doc/chatuikit/react/components/avatar.md +137 -0
  261. package/resource/doc/chatuikit/react/components/chat.md +44 -0
  262. package/resource/doc/chatuikit/react/components/chatheader.md +189 -0
  263. package/resource/doc/chatuikit/react/components/component-list.md +48 -0
  264. package/resource/doc/chatuikit/react/components/conversation-list.md +1017 -0
  265. package/resource/doc/chatuikit/react/components/message-input.md +950 -0
  266. package/resource/doc/chatuikit/react/components/message-list.md +485 -0
  267. package/resource/doc/chatuikit/react/components/tuikit.md +80 -0
  268. package/resource/doc/chatuikit/react/create-group.md +23 -0
  269. package/resource/doc/chatuikit/react/integration.md +83 -0
  270. package/resource/doc/chatuikit/react/login.md +26 -0
  271. package/resource/doc/chatuikit/vue/components/avatar.md +137 -0
  272. package/resource/doc/chatuikit/vue/components/chat.md +42 -0
  273. package/resource/doc/chatuikit/vue/components/chatheader.md +189 -0
  274. package/resource/doc/chatuikit/vue/components/component-list.md +102 -0
  275. package/resource/doc/chatuikit/vue/components/conversation-list.md +765 -0
  276. package/resource/doc/chatuikit/vue/components/message-input.md +1272 -0
  277. package/resource/doc/chatuikit/vue/components/message-list.md +662 -0
  278. package/resource/doc/chatuikit/vue/components/tuikit.md +45 -0
  279. package/resource/doc/chatuikit/vue/components/userpicker.md +315 -0
  280. package/resource/doc/chatuikit/vue/create-group.md +25 -0
  281. package/resource/doc/chatuikit/vue/integration.md +256 -0
  282. package/resource/doc/chatuikit/vue/login.md +31 -0
  283. package/resource/doc/chatuikit/vue3/components/MessageInput.md +1272 -0
  284. package/resource/doc/chatuikit/vue3/components/avatar.md +137 -0
  285. package/resource/doc/chatuikit/vue3/components/chatheader.md +189 -0
  286. package/resource/doc/chatuikit/vue3/components/component-list.md +102 -0
  287. package/resource/doc/chatuikit/vue3/components/userpicker.md +315 -0
  288. package/resource/doc/chatuikit/vue3/integration.md +256 -0
  289. package/server.js +10 -181
  290. package/server.js.map +1 -1
  291. package/streamable-http.js +69 -0
  292. package/streamable-http.js.map +1 -0
  293. package/tools/call/get-call-faq.js +32 -0
  294. package/tools/call/get-call-faq.js.map +1 -0
  295. package/tools/call/get-native-call-integration-guide.js +36 -0
  296. package/tools/call/get-native-call-integration-guide.js.map +1 -0
  297. package/tools/call/get-native-call-integration.js +35 -0
  298. package/tools/call/get-native-call-integration.js.map +1 -0
  299. package/tools/call/get-web-call-integration-guide.js +35 -0
  300. package/tools/call/get-web-call-integration-guide.js.map +1 -0
  301. package/tools/call/get-web-call-integration.js +35 -0
  302. package/tools/call/get-web-call-integration.js.map +1 -0
  303. package/tools/chat/create-group.js +30 -0
  304. package/tools/chat/create-group.js.map +1 -0
  305. package/tools/chat/get-chat-faq.js +32 -0
  306. package/tools/chat/get-chat-faq.js.map +1 -0
  307. package/tools/chat/get-native-chat-integration-guide.js +34 -0
  308. package/tools/chat/get-native-chat-integration-guide.js.map +1 -0
  309. package/tools/chat/get-native-chat-integration.js +34 -0
  310. package/tools/chat/get-native-chat-integration.js.map +1 -0
  311. package/tools/chat/get-web-chat-component-detail.js +36 -0
  312. package/tools/chat/get-web-chat-component-detail.js.map +1 -0
  313. package/tools/chat/get-web-chat-integration-guide.js +35 -0
  314. package/tools/chat/get-web-chat-integration-guide.js.map +1 -0
  315. package/tools/chat/get-web-chat-integration.js +37 -0
  316. package/tools/chat/get-web-chat-integration.js.map +1 -0
  317. package/tools/chat/get-web-chat-uikit-login.js +30 -0
  318. package/tools/chat/get-web-chat-uikit-login.js.map +1 -0
  319. package/tools/common/get-usersig.js +35 -0
  320. package/tools/common/get-usersig.js.map +1 -0
  321. package/tools/common/present-framework-choice.js +23 -0
  322. package/tools/common/present-framework-choice.js.map +1 -0
  323. package/tools/common/record-prompt.js +31 -0
  324. package/tools/common/record-prompt.js.map +1 -0
  325. package/tools/common/record-result.js +36 -0
  326. package/tools/common/record-result.js.map +1 -0
  327. package/tools/index.js +41 -0
  328. package/tools/index.js.map +1 -0
  329. package/tools/rtcengine/get-rtcengine-integration-guide.js +33 -0
  330. package/tools/rtcengine/get-rtcengine-integration-guide.js.map +1 -0
  331. package/tools/rtcengine/get-rtcenigne-faq.js +32 -0
  332. package/tools/rtcengine/get-rtcenigne-faq.js.map +1 -0
  333. package/utils/aegis-client.js +8 -0
  334. package/utils/aegis-client.js.map +1 -0
  335. package/utils/generate-usersig.js +14 -0
  336. package/utils/generate-usersig.js.map +1 -0
  337. package/utils/get-doc-content.js +47 -0
  338. package/utils/get-doc-content.js.map +1 -0
  339. package/utils/handle-component-name.js +12 -0
  340. package/utils/handle-component-name.js.map +1 -0
  341. package/utils/handle-framework.js +9 -0
  342. package/utils/handle-framework.js.map +1 -0
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PolarisGRPCClient = void 0;
4
+ const package_json_1 = require("@grpc/grpc-js/package.json");
5
+ const protoLoader = require("@grpc/proto-loader");
6
+ const path = require("path");
7
+ const semver = require("semver");
8
+ const __1 = require("../../../../..");
9
+ const utils_1 = require("../../../../../utils");
10
+ const adapter_1 = require("../../adapter");
11
+ const types_1 = require("../../types");
12
+ const utils_2 = require("../../utils");
13
+ const bidi_1 = require("./bidi");
14
+ /**
15
+ * `@grpc/grpc-js` 模块在导入时会校验当前环境是否满足其运行要求,
16
+ * 如不满足直接抛出异常,由于 `import` 语法所限无法进行捕获,
17
+ * 故在此采用 `require` 延迟加载。
18
+ */
19
+ let grpcjs;
20
+ const kProtoFile = {
21
+ [types_1.ServiceType.Discover]: path.join(__dirname, "pb", "discover.proto"),
22
+ [types_1.ServiceType.Monitor]: path.join(__dirname, "pb", "monitor.proto"),
23
+ [types_1.ServiceType.Ratelimit]: path.join(__dirname, "pb", "ratelimit.proto")
24
+ };
25
+ const kDefaultOptions = {
26
+ /**
27
+ * 调用超时时间
28
+ */
29
+ timeout: 10 * utils_1.kSeconds,
30
+ /**
31
+ * gRPC 配置项
32
+ */
33
+ grpc: {
34
+ /**
35
+ * gRPC CallOptions 配置项
36
+ */
37
+ call: {},
38
+ /**
39
+ * gRPC ChannelOptions 配置项
40
+ */
41
+ channel: {}
42
+ }
43
+ };
44
+ const isIDiscoverRequest = (arg) => "type" in arg && "service" in arg;
45
+ const isIDiscoverResponse = (arg) => "type" in arg;
46
+ const isIdentifiablePacket = (arg) => Object.prototype.hasOwnProperty.call(arg, "id") || Object.prototype.hasOwnProperty.call(arg, "key");
47
+ const loadPackageDefinition = (type) => {
48
+ // eslint-disable-next-line @typescript-eslint/unbound-method
49
+ const { emitWarning } = process;
50
+ /*
51
+ * note:
52
+ * 由于 `@grpc/proto-loader` 在处理 options.includeDirs 时,
53
+ * 对于 `import google/protobuf/*.proto` 会抛出不正确的异常,
54
+ * 故在此屏蔽进行屏蔽,并在调用完 `loadSync` 后进行重置。
55
+ */
56
+ process.emitWarning = () => { };
57
+ const packageDefinition = protoLoader.loadSync(kProtoFile[type], {
58
+ defaults: true,
59
+ keepCase: true,
60
+ longs: Number,
61
+ includeDirs: [utils_2.kProtoPath[type]]
62
+ });
63
+ process.emitWarning = emitWarning;
64
+ return grpcjs.loadPackageDefinition(packageDefinition).v1;
65
+ };
66
+ class PolarisGRPCClient extends adapter_1.PolarisServerAdapter {
67
+ constructor(remotes, options) {
68
+ super(remotes, options);
69
+ this.name = "PolarisGRPCClient";
70
+ this.protocol = PolarisGRPCClient.protocol;
71
+ this.format = utils_2.ProtobufFormat.Original;
72
+ this.options = Object.assign(Object.assign(Object.assign(Object.assign({}, this.options), kDefaultOptions), options), { grpc: Object.assign(Object.assign(Object.assign({}, this.options.grpc), kDefaultOptions.grpc), options === null || options === void 0 ? void 0 : options.grpc) });
73
+ if (!PolarisGRPCClient.isSupported()) {
74
+ throw new __1.PluginError(`grpc client only works on Node ${package_json_1.engines.node}`);
75
+ }
76
+ if (!grpcjs) {
77
+ grpcjs = require("@grpc/grpc-js"); // eslint-disable-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
78
+ }
79
+ this.clientConstructor = {
80
+ [types_1.ServiceType.Discover]: loadPackageDefinition(types_1.ServiceType.Discover).PolarisGRPC,
81
+ [types_1.ServiceType.Monitor]: loadPackageDefinition(types_1.ServiceType.Monitor).GrpcAPI,
82
+ [types_1.ServiceType.Ratelimit]: loadPackageDefinition(types_1.ServiceType.Ratelimit).RateLimitGRPC
83
+ };
84
+ }
85
+ static isSupported() {
86
+ return semver.satisfies(process.versions.node, package_json_1.engines.node);
87
+ }
88
+ box(value) {
89
+ if (value === null || typeof value === "undefined") {
90
+ return value;
91
+ }
92
+ return {
93
+ value
94
+ };
95
+ }
96
+ unbox(value, defaultValue) {
97
+ const val = value;
98
+ if (val && typeof val.value !== "undefined" && val.value !== null) {
99
+ return val.value;
100
+ }
101
+ if (typeof defaultValue === "function") {
102
+ return defaultValue();
103
+ }
104
+ return defaultValue;
105
+ }
106
+ // #region #AOP#
107
+ /**
108
+ * 实例化 Service Client,可重载此方法实现差异化配置
109
+ * @param address 远端地址
110
+ * @param type 远端类型
111
+ * @param ServiceClient Service Client Class,函数必须返回它的实例
112
+ * @param credentials grpc.credentials
113
+ */
114
+ instantiateServiceClient(address, type, ServiceClient, credentials) {
115
+ return new ServiceClient(address, credentials.createInsecure(), this.options.grpc.channel);
116
+ }
117
+ /**
118
+ * 获取 grpc.CallOptions 配置,可重载此方法实现差异化配置
119
+ * @param address 远端地址
120
+ * @param method 方法名
121
+ * @param streaming 是否为 Bidi Stream
122
+ */
123
+ getCallOptions(address, method, streaming) {
124
+ const { options: { timeout, grpc: { call: callOptions } } } = this;
125
+ if (streaming) {
126
+ return callOptions;
127
+ }
128
+ return Object.assign(Object.assign({}, callOptions), { deadline: Date.now() + timeout });
129
+ }
130
+ // #endregion
131
+ buildClient(address, type) {
132
+ const { logger, options: { timeout } } = this;
133
+ const { transaction } = logger;
134
+ logger.trace("Plugins" /* Plugins */, this.name, "buildClient", transaction, "remote address is", address, "and type is", type);
135
+ const ServiceClient = this.clientConstructor[type]; // eslint-disable-line @typescript-eslint/naming-convention
136
+ const grpcClient = this.instantiateServiceClient(address, type, ServiceClient, grpcjs.credentials);
137
+ const client = Object.create(null);
138
+ const bidi = [];
139
+ for (const name of Object.keys(ServiceClient.service)) {
140
+ const { requestStream, responseStream, originalName } = ServiceClient.service[name];
141
+ const method = (originalName || name);
142
+ if (!requestStream && !responseStream) {
143
+ /* Unary */
144
+ client[method] = ((request) => new Promise((resolve, reject) => {
145
+ grpcClient[name](request, this.getCallOptions(address, name, false), (err, value) => {
146
+ if (err) {
147
+ reject(err);
148
+ }
149
+ else {
150
+ resolve(value);
151
+ }
152
+ });
153
+ }));
154
+ }
155
+ else if (requestStream && responseStream) {
156
+ /* Bidi */
157
+ const caller = new bidi_1.StreamCaller(grpcClient[name]
158
+ .bind(grpcClient, this.getCallOptions(address, name, true)), this.keyGenerator.bind(this), timeout);
159
+ client[method] = ((request) => caller.request(request));
160
+ bidi.push(caller);
161
+ }
162
+ else {
163
+ (0, utils_1.UNREACHABLE)();
164
+ }
165
+ }
166
+ client.close = () => {
167
+ logger.trace("Plugins" /* Plugins */, this.name, "buildClient", transaction, "close all client");
168
+ bidi.forEach(caller => caller.close());
169
+ /*
170
+ * avoid GRPC Error:
171
+ * 14 UNAVAILABLE: No connection established
172
+ */
173
+ try {
174
+ grpcClient.close();
175
+ }
176
+ catch (e) {
177
+ logger.trace("Plugins" /* Plugins */, this.name, "buildClient", transaction, "close grpc client exception with", e);
178
+ logger.error(`[${this.name}] [close]`, e);
179
+ }
180
+ };
181
+ return client;
182
+ }
183
+ requestKeyGenerator(request) {
184
+ var _a;
185
+ if (isIDiscoverRequest(request) && request.service) {
186
+ const { namespace, name } = request.service;
187
+ return {
188
+ keys: [namespace, name],
189
+ type: request.type
190
+ };
191
+ }
192
+ if (isIdentifiablePacket(request)) {
193
+ return {
194
+ keys: [(_a = request.id) !== null && _a !== void 0 ? _a : request.key],
195
+ type: "*"
196
+ };
197
+ }
198
+ (0, utils_1.UNREACHABLE)();
199
+ }
200
+ responseKeyGenerator(response) {
201
+ var _a;
202
+ if (isIDiscoverResponse(response)) {
203
+ /** intentional convert */
204
+ switch (response.type) {
205
+ case types_1.DiscoverRequestType.INSTANCE: // [[fallthrough]]
206
+ case types_1.DiscoverRequestType.ROUTING: // [[fallthrough]]
207
+ case types_1.DiscoverRequestType.RATE_LIMIT: {
208
+ if (response.service) {
209
+ const { namespace, name } = response.service;
210
+ return {
211
+ keys: [namespace, name],
212
+ type: response.type
213
+ };
214
+ }
215
+ (0, utils_1.UNREACHABLE)();
216
+ }
217
+ case types_1.DiscoverRequestType.CLUSTER: // [[fallthrough]]
218
+ case types_1.DiscoverRequestType.UNKNOWN: // [[fallthrough]]
219
+ default: {
220
+ (0, utils_1.UNREACHABLE)();
221
+ }
222
+ }
223
+ (0, utils_1.UNREACHABLE)(); /** Stub */
224
+ }
225
+ if (isIdentifiablePacket(response)) {
226
+ return {
227
+ keys: [(_a = response.id) !== null && _a !== void 0 ? _a : response.key],
228
+ type: "*"
229
+ };
230
+ }
231
+ (0, utils_1.UNREACHABLE)();
232
+ }
233
+ keyGenerator(direction, packet) {
234
+ let type;
235
+ let keys;
236
+ switch (direction) {
237
+ case bidi_1.PacketDirection.Request: {
238
+ ({ keys, type } = this.requestKeyGenerator(packet));
239
+ break;
240
+ }
241
+ case bidi_1.PacketDirection.Response: {
242
+ ({ keys, type } = this.responseKeyGenerator(packet));
243
+ break;
244
+ }
245
+ default: {
246
+ (0, utils_1.UNREACHABLE)();
247
+ }
248
+ }
249
+ keys = keys.map(key => this.unbox(key, typeof key === "string" ? key : ""));
250
+ if (keys.every(key => key === "") || type === undefined) {
251
+ (0, utils_1.UNREACHABLE)();
252
+ }
253
+ return `${type}.${keys.join(".")}`;
254
+ }
255
+ }
256
+ exports.PolarisGRPCClient = PolarisGRPCClient;
257
+ PolarisGRPCClient.protocol = "grpc";
258
+ PolarisGRPCClient.port = 8081;
259
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/plugins/naming/polaris-server/connector/grpc/index.ts"],"names":[],"mappings":";;;AACA,6DAAyE;AACzE,kDAAkD;AAClD,6BAA6B;AAC7B,iCAAiC;AAEjC,sCAA4D;AAC5D,gDAA4E;AAE5E,2CAA4G;AAC5G,uCAA+D;AAC/D,uCAAyD;AACzD,iCAAuD;AAOvD;;;;GAIG;AACH,IAAI,MAA+B,CAAC;AAYpC,MAAM,UAAU,GAAwC;IACtD,CAAC,mBAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,gBAAgB,CAAC;IACpE,CAAC,mBAAW,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,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.proto";
7
+ import "request.proto";
8
+ import "response.proto";
9
+
10
+ service PolarisGRPC {
11
+ // 客户端上报
12
+ rpc ReportClient(Client) returns(Response) {}
13
+
14
+ // 被调方注册服务实例
15
+ rpc RegisterInstance(Instance) returns(Response) {}
16
+ // 被调方反注册服务实例
17
+ rpc DeregisterInstance(Instance) returns(Response) {}
18
+
19
+ // 统一发现接口
20
+ rpc Discover(stream DiscoverRequest) returns(stream DiscoverResponse) {}
21
+
22
+ // 被调方上报心跳
23
+ rpc Heartbeat(Instance) returns(Response) {}
24
+ }
@@ -0,0 +1,18 @@
1
+ syntax = "proto3";
2
+
3
+ package v1;
4
+
5
+ import "request.proto";
6
+ import "response.proto";
7
+ import "sdkconfiguration.proto";
8
+ import "sdkcache.proto";
9
+ import "circuitbreak.proto";
10
+
11
+ service GrpcAPI {
12
+ rpc CollectServerStatistics(stream ServerStatistics) returns(stream StatResponse) {}
13
+ rpc CollectSDKAPIStatistics(stream SDKAPIStatistics) returns(stream StatResponse) {}
14
+ rpc CollectServiceStatistics(stream ServiceStatistics) returns(stream StatResponse) {}
15
+ rpc CollectSDKConfiguration(SDKConfig) returns(StatResponse) {}
16
+ rpc CollectSDKCache(stream ServiceInfo) returns(stream StatResponse) {}
17
+ rpc CollectCircuitBreak(stream ServiceCircuitbreak) returns(stream StatResponse) {}
18
+ }
@@ -0,0 +1,12 @@
1
+ syntax = "proto3";
2
+
3
+ package v1;
4
+
5
+ import "ratelimit.proto";
6
+
7
+ service RateLimitGRPC {
8
+ // 限流KEY初始化
9
+ rpc InitializeQuota(RateLimitRequest) returns(RateLimitResponse) {}
10
+ // 获取限流配额
11
+ rpc AcquireQuota(stream RateLimitRequest) returns(stream RateLimitResponse) {}
12
+ }
@@ -0,0 +1,39 @@
1
+ /// <reference types="node" />
2
+ import { AxiosRequestConfig } from "axios";
3
+ import * as http from "http";
4
+ import type { BoxType, PolarisClient } from "../.."; /** only import type */
5
+ import { PolarisServerAdapter, ServerAdapterOptions } from "../../adapter";
6
+ import { ServiceType } from "../../types";
7
+ import { ProtobufFormat } from "../../utils";
8
+ declare const kDefaultOptions: {
9
+ /**
10
+ * 是否复用连接
11
+ */
12
+ keepAlive: boolean;
13
+ /**
14
+ * axios 配置项
15
+ */
16
+ axios: AxiosRequestConfig<any>;
17
+ };
18
+ export declare type PolarisHTTPClientOptions = typeof kDefaultOptions & ServerAdapterOptions;
19
+ export declare class PolarisHTTPClient extends PolarisServerAdapter {
20
+ static readonly protocol = "http";
21
+ static readonly port = 8080;
22
+ readonly name = "PolarisHTTPClient";
23
+ readonly protocol = "http";
24
+ readonly format = ProtobufFormat.JSON;
25
+ protected readonly options: PolarisHTTPClientOptions;
26
+ private sequence;
27
+ constructor(remotes: string[], options?: Partial<PolarisHTTPClientOptions>);
28
+ box<T>(value: T): BoxType<T> | T | null | undefined;
29
+ unbox<T>(value: BoxType<T> | T | null | undefined, defaultValue: T | (() => T)): T;
30
+ /**
31
+ * 获取 axios.AxiosRequestConfig 配置,可重载此方法实现差异化配置
32
+ * @param address 远端地址
33
+ * @param name 远端类型
34
+ * @param httpAgent http.Agent
35
+ */
36
+ protected getRequestConfig(address: string, name: string, httpAgent: http.Agent): AxiosRequestConfig;
37
+ protected buildClient<T extends PolarisClient>(address: string, type: ServiceType): T;
38
+ }
39
+ export {};
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PolarisHTTPClient = void 0;
4
+ const axios_1 = require("axios");
5
+ const http = require("http");
6
+ const __1 = require("../../../../..");
7
+ const utils_1 = require("../../../../../utils");
8
+ const adapter_1 = require("../../adapter");
9
+ const types_1 = require("../../types");
10
+ const utils_2 = require("../../utils");
11
+ const kDefaultOptions = {
12
+ /**
13
+ * 是否复用连接
14
+ */
15
+ keepAlive: true,
16
+ /**
17
+ * axios 配置项
18
+ */
19
+ axios: {
20
+ /**
21
+ * 调用超时时间
22
+ */
23
+ timeout: 10 * utils_1.kSeconds
24
+ }
25
+ };
26
+ const kUrlMapping = {
27
+ [types_1.ServiceType.Monitor]: {
28
+ collectServerStatistics: "/v1/CollectServerStatistics",
29
+ collectServiceStatistics: "/v1/CollectServiceStatistics",
30
+ collectCircuitBreak: "/v1/CollectCircuitBreak",
31
+ collectSdkCache: "/v1/CollectSDKCache",
32
+ collectSdkConfiguration: "/v1/collectSDKConfiguration",
33
+ collectSdkapiStatistics: "/v1/CollectSDKAPIStatistics"
34
+ },
35
+ [types_1.ServiceType.Discover]: {
36
+ discover: "/v1/Discover",
37
+ registerInstance: "/v1/RegisterInstance",
38
+ deregisterInstance: "/v1/DeregisterInstance",
39
+ heartbeat: "/v1/Heartbeat",
40
+ reportClient: "/v1/ReportClient"
41
+ },
42
+ [types_1.ServiceType.Ratelimit]: {
43
+ acquireQuota: "/v1/AcquireQuota",
44
+ initializeQuota: "/v1/InitializeQuota"
45
+ }
46
+ };
47
+ const kUA = `${utils_1.kModuleName}/${utils_1.kModuleVersion} Node.js/${process.versions.node}`;
48
+ class PolarisHTTPClient extends adapter_1.PolarisServerAdapter {
49
+ constructor(remotes, options) {
50
+ super(remotes, options);
51
+ this.name = "PolarisHTTPClient";
52
+ this.protocol = PolarisHTTPClient.protocol;
53
+ this.format = utils_2.ProtobufFormat.JSON;
54
+ this.sequence = 0;
55
+ this.options = Object.assign(Object.assign(Object.assign(Object.assign({}, this.options), kDefaultOptions), options), { axios: Object.assign(Object.assign(Object.assign({}, this.options.axios), kDefaultOptions.axios), options === null || options === void 0 ? void 0 : options.axios) });
56
+ }
57
+ box(value) {
58
+ return value;
59
+ }
60
+ unbox(value, defaultValue) {
61
+ const val = value;
62
+ if (typeof val !== "undefined" && val !== null) {
63
+ return val;
64
+ }
65
+ if (typeof defaultValue === "function") {
66
+ return defaultValue();
67
+ }
68
+ return defaultValue;
69
+ }
70
+ // #region #AOP#
71
+ /**
72
+ * 获取 axios.AxiosRequestConfig 配置,可重载此方法实现差异化配置
73
+ * @param address 远端地址
74
+ * @param name 远端类型
75
+ * @param httpAgent http.Agent
76
+ */
77
+ getRequestConfig(address, name, httpAgent) {
78
+ const { options: { axios: axiosOptions } } = this;
79
+ return Object.assign({ headers: Object.assign({ "User-Agent": kUA, "Request-Id": `${this.sequence++}` }, axiosOptions.headers),
80
+ /**
81
+ * 由于后端接口为 `RESTful` 架构,
82
+ * 故在在此放过所有 `StatusCode`,具体判断由业务层处理
83
+ */
84
+ validateStatus: () => true, httpAgent }, axiosOptions);
85
+ }
86
+ // #endregion
87
+ buildClient(address, type) {
88
+ const { logger } = this;
89
+ const { transaction } = logger;
90
+ logger.trace("Plugins" /* Plugins */, this.name, "buildClient", transaction, "remote address is", address, "and type is", type);
91
+ const mapping = kUrlMapping[type];
92
+ const client = Object.create(null);
93
+ const httpAgent = new http.Agent({
94
+ keepAlive: this.options.keepAlive
95
+ });
96
+ for (const name of Object.keys(mapping)) {
97
+ client[name] = async (request) => {
98
+ const { data } = await axios_1.default.post(`http://${address}${mapping[name]}`, request, this.getRequestConfig(address, name, httpAgent));
99
+ if (!data || typeof data !== "object") {
100
+ throw new __1.InvalidResponse(`Parsing response data, expect object but received ${typeof data}`);
101
+ }
102
+ return data;
103
+ };
104
+ }
105
+ client.close = () => {
106
+ logger.trace("Plugins" /* Plugins */, this.name, "buildClient", transaction, "destroy http agent");
107
+ httpAgent.destroy();
108
+ };
109
+ return client;
110
+ }
111
+ }
112
+ exports.PolarisHTTPClient = PolarisHTTPClient;
113
+ PolarisHTTPClient.protocol = "http";
114
+ PolarisHTTPClient.port = 8080;
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/plugins/naming/polaris-server/connector/http/index.ts"],"names":[],"mappings":";;;AAAA,iCAAkD;AAClD,6BAA6B;AAE7B,sCAAgE;AAChE,gDAA6E;AAE7E,2CAA2E;AAC3E,uCAA0C;AAC1C,uCAA6C;AAE7C,MAAM,eAAe,GAAG;IACtB;;OAEG;IACH,SAAS,EAAE,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,OAAO,CAAC,SAAS;SAClC,CAAC,CAAC;QAEH,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YACvC,MAAM,CAAC,IAAwB,CAAC,GAAG,KAAK,EAAqB,OAAgB,EAAqB,EAAE;gBAClG,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,UAAU,OAAO,GAAI,OAAkC,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,EACxE,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,CAChD,CAAC;gBAEF,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;oBACrC,MAAM,IAAI,mBAAe,CAAC,qDAAqD,OAAO,IAAI,EAAE,CAAC,CAAC;iBAC/F;gBAED,OAAO,IAAI,CAAC;YACd,CAAC,CAAC;SACH;QAEA,MAAY,CAAC,KAAK,GAAG,GAAG,EAAE;YACzB,MAAM,CAAC,KAAK,0BAAwB,IAAI,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAC;YACjG,SAAS,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC,CAAC;QAEF,OAAO,MAAW,CAAC;IACrB,CAAC;;AAtGH,8CAuGC;AAtGiB,0BAAQ,GAAG,MAAM,CAAC;AAClB,sBAAI,GAAG,IAAI,CAAC"}
@@ -0,0 +1,24 @@
1
+ syntax = "proto3";
2
+
3
+ package v1;
4
+
5
+ import "client.proto";
6
+ import "service.proto";
7
+ import "request.proto";
8
+ import "response.proto";
9
+
10
+ service ServerAPI {
11
+ // 客户端上报
12
+ rpc ReportClient(Client) returns(Response) {}
13
+
14
+ // 被调方注册服务实例
15
+ rpc RegisterInstance(Instance) returns(Response) {}
16
+ // 被调方反注册服务实例
17
+ rpc DeregisterInstance(Instance) returns(Response) {}
18
+
19
+ // 统一发现接口
20
+ rpc Discover(stream DiscoverRequest) returns(stream DiscoverResponse) {}
21
+
22
+ // 被调方上报心跳
23
+ rpc Heartbeat(Instance) returns(Response) {}
24
+ }
@@ -0,0 +1,22 @@
1
+ syntax = "proto3";
2
+
3
+ package v1;
4
+
5
+ import "google/protobuf/wrappers.proto";
6
+ import "model.proto";
7
+
8
+ message Client {
9
+ google.protobuf.StringValue host = 1;
10
+
11
+ enum ClientType {
12
+ UNKNOWN = 0;
13
+ SDK = 1;
14
+ AGENT = 2;
15
+ }
16
+
17
+ ClientType type = 2;
18
+
19
+ google.protobuf.StringValue version = 3;
20
+
21
+ Location location = 4;
22
+ }
@@ -0,0 +1,28 @@
1
+ syntax = "proto3";
2
+
3
+ package v1;
4
+
5
+ import "google/protobuf/wrappers.proto";
6
+
7
+ message Location {
8
+ google.protobuf.StringValue region = 1;
9
+ google.protobuf.StringValue zone = 2;
10
+ google.protobuf.StringValue campus = 3;
11
+ }
12
+
13
+ message MatchString {
14
+ enum MatchStringType {
15
+ EXACT = 0;
16
+ REGEX = 1;
17
+ }
18
+
19
+ enum ValueType {
20
+ TEXT = 0;
21
+ PARAMETER = 1;
22
+ VARIABLE = 2;
23
+ }
24
+
25
+ MatchStringType type = 1;
26
+ google.protobuf.StringValue value = 2;
27
+ ValueType value_type = 3;
28
+ }
@@ -0,0 +1,80 @@
1
+ syntax = "proto3";
2
+
3
+ package v1;
4
+
5
+ import "google/protobuf/wrappers.proto";
6
+ import "google/protobuf/duration.proto";
7
+ import "model.proto";
8
+
9
+ // 同一服务下限流规则集合
10
+ message RateLimit {
11
+ // 限流规则集合
12
+ repeated Rule rules = 1;
13
+ // 限流规则汇总的revision信息
14
+ google.protobuf.StringValue revision = 2;
15
+ }
16
+
17
+ // 单个限流规则信息
18
+ message Rule {
19
+ // 限流规则唯一标识
20
+ google.protobuf.StringValue id = 1;
21
+ // 限流规则所属服务名
22
+ google.protobuf.StringValue service = 2;
23
+ // 限流规则所属命名空间
24
+ google.protobuf.StringValue namespace = 3;
25
+ // 限流规则所属集群名
26
+ google.protobuf.StringValue cluster = 4;
27
+ // 限流规则优先级,0值最高
28
+ google.protobuf.UInt32Value priority = 5;
29
+ // 限流资源
30
+ enum Resource {
31
+ // 针对QPS进行限流
32
+ QPS = 0;
33
+ // 针对并发数进行限流
34
+ CONCURRENCY = 1;
35
+ }
36
+ Resource resource = 6;
37
+ // 限流类型
38
+ // global全局限流(默认)或者local单机限流
39
+ enum Type {
40
+ GLOBAL = 0;
41
+ LOCAL = 1;
42
+ }
43
+ Type type = 7;
44
+ // 业务标签集合,通过KV进行匹配,匹配到一个则使用该规则
45
+ map<string, MatchString> labels = 8;
46
+ // 限流阈值
47
+ // 可以有多个粒度的配置(比如同时针对秒级,分钟级,天级),匹配一个则进行限流
48
+ // 全局限流模式下,该值为服务配额总量;单机限流模式下,该值为单个节点能处理的配额量
49
+ repeated Amount amounts = 9;
50
+ // 限流动作,对应着客户端的插件名字
51
+ google.protobuf.StringValue action = 10;
52
+ // 是否停用该限流规则,默认启用
53
+ google.protobuf.BoolValue disable = 11;
54
+ // 限流上报方式,同时支持按固定周期上报,以及达到配额百分比后上报
55
+ Report report = 12;
56
+ // 限流规则创建时间
57
+ google.protobuf.StringValue ctime = 13;
58
+ // 限流规则修改时间
59
+ google.protobuf.StringValue mtime = 14;
60
+ // 限流规则revision信息
61
+ google.protobuf.StringValue revision = 15;
62
+ // 服务的TOKEN信息,仅用于控制台,discover接口不下发
63
+ google.protobuf.StringValue service_token = 16 [json_name="service_token"];
64
+ }
65
+
66
+ // 限流配额
67
+ message Amount {
68
+ // 时间周期内的最大配额数
69
+ google.protobuf.UInt32Value maxAmount = 1;
70
+ // 配额生效的时间周期,必须大于等于1s
71
+ google.protobuf.Duration validDuration = 2;
72
+ }
73
+
74
+ // 限流上报方式
75
+ message Report {
76
+ // 配额固定上报周期,单位毫秒
77
+ google.protobuf.Duration interval = 1;
78
+ // 使用了百分之多少配额后启动一次实时上报,值范围(0,100]
79
+ google.protobuf.UInt32Value amountPercent = 2;
80
+ }
@@ -0,0 +1,18 @@
1
+ syntax = "proto3";
2
+
3
+ package v1;
4
+
5
+ import "service.proto";
6
+
7
+ message DiscoverRequest {
8
+ enum DiscoverRequestType {
9
+ UNKNOWN = 0;
10
+ INSTANCE = 1;
11
+ CLUSTER = 2;
12
+ ROUTING = 3;
13
+ RATE_LIMIT = 4;
14
+ }
15
+
16
+ DiscoverRequestType type = 1;
17
+ Service service = 2;
18
+ }