@gitpod/gitpod-protocol 0.1.5-update-ovsx.0 → 0.1.5-update-yarnlock.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 (455) hide show
  1. package/data/gitpod-schema.json +159 -25
  2. package/lib/accounting-protocol.d.ts +165 -0
  3. package/lib/accounting-protocol.d.ts.map +1 -0
  4. package/lib/accounting-protocol.js +120 -0
  5. package/lib/accounting-protocol.js.map +1 -0
  6. package/lib/admin-protocol.d.ts +51 -6
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +17 -2
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +44 -0
  11. package/lib/analytics.d.ts.map +1 -0
  12. package/lib/analytics.js +10 -0
  13. package/lib/analytics.js.map +1 -0
  14. package/lib/attribution.d.ts +25 -0
  15. package/lib/attribution.d.ts.map +1 -0
  16. package/lib/attribution.js +58 -0
  17. package/lib/attribution.js.map +1 -0
  18. package/lib/auth.d.ts +25 -0
  19. package/lib/auth.d.ts.map +1 -0
  20. package/lib/auth.js +16 -0
  21. package/lib/auth.js.map +1 -0
  22. package/lib/billing-mode.d.ts +45 -0
  23. package/lib/billing-mode.d.ts.map +1 -0
  24. package/lib/billing-mode.js +44 -0
  25. package/lib/billing-mode.js.map +1 -0
  26. package/lib/blocked-repositories-protocol.d.ts +13 -0
  27. package/lib/blocked-repositories-protocol.d.ts.map +1 -0
  28. package/lib/blocked-repositories-protocol.js +8 -0
  29. package/lib/blocked-repositories-protocol.js.map +1 -0
  30. package/lib/context-url.d.ts +30 -0
  31. package/lib/context-url.d.ts.map +1 -0
  32. package/lib/context-url.js +100 -0
  33. package/lib/context-url.js.map +1 -0
  34. package/lib/context-url.spec.d.ts +12 -0
  35. package/lib/context-url.spec.d.ts.map +1 -0
  36. package/lib/context-url.spec.js +81 -0
  37. package/lib/context-url.spec.js.map +1 -0
  38. package/lib/encryption/container-module.d.ts +2 -2
  39. package/lib/encryption/container-module.d.ts.map +1 -1
  40. package/lib/encryption/container-module.js +8 -6
  41. package/lib/encryption/container-module.js.map +1 -1
  42. package/lib/encryption/encryption-engine.d.ts +2 -2
  43. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  44. package/lib/encryption/encryption-engine.js +28 -28
  45. package/lib/encryption/encryption-engine.js.map +1 -1
  46. package/lib/encryption/encryption-engine.spec.d.ts +3 -3
  47. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  48. package/lib/encryption/encryption-engine.spec.js +32 -39
  49. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  50. package/lib/encryption/encryption-service.d.ts +2 -2
  51. package/lib/encryption/encryption-service.d.ts.map +1 -1
  52. package/lib/encryption/encryption-service.js +33 -46
  53. package/lib/encryption/encryption-service.js.map +1 -1
  54. package/lib/encryption/key-provider.d.ts +3 -3
  55. package/lib/encryption/key-provider.d.ts.map +1 -1
  56. package/lib/encryption/key-provider.js +34 -40
  57. package/lib/encryption/key-provider.js.map +1 -1
  58. package/lib/env.d.ts +2 -8
  59. package/lib/env.d.ts.map +1 -1
  60. package/lib/env.js +10 -29
  61. package/lib/env.js.map +1 -1
  62. package/lib/experiments/always-default.d.ts +8 -0
  63. package/lib/experiments/always-default.d.ts.map +1 -0
  64. package/lib/experiments/always-default.js +20 -0
  65. package/lib/experiments/always-default.js.map +1 -0
  66. package/lib/experiments/configcat-server.d.ts +10 -0
  67. package/lib/experiments/configcat-server.d.ts.map +1 -0
  68. package/lib/experiments/configcat-server.js +37 -0
  69. package/lib/experiments/configcat-server.js.map +1 -0
  70. package/lib/experiments/configcat.d.ts +21 -0
  71. package/lib/experiments/configcat.d.ts.map +1 -0
  72. package/lib/experiments/configcat.js +51 -0
  73. package/lib/experiments/configcat.js.map +1 -0
  74. package/lib/experiments/types.d.ts +22 -0
  75. package/lib/experiments/types.d.ts.map +1 -0
  76. package/lib/experiments/types.js +10 -0
  77. package/lib/experiments/types.js.map +1 -0
  78. package/lib/frontend-dashboard-service.d.ts +99 -0
  79. package/lib/frontend-dashboard-service.d.ts.map +1 -0
  80. package/lib/frontend-dashboard-service.js +55 -0
  81. package/lib/frontend-dashboard-service.js.map +1 -0
  82. package/lib/gitpod-file-parser.d.ts +2 -2
  83. package/lib/gitpod-file-parser.d.ts.map +1 -1
  84. package/lib/gitpod-file-parser.js +29 -44
  85. package/lib/gitpod-file-parser.js.map +1 -1
  86. package/lib/gitpod-file-parser.spec.d.ts +2 -2
  87. package/lib/gitpod-file-parser.spec.js +147 -144
  88. package/lib/gitpod-file-parser.spec.js.map +1 -1
  89. package/lib/gitpod-service.d.ts +290 -50
  90. package/lib/gitpod-service.d.ts.map +1 -1
  91. package/lib/gitpod-service.js +288 -123
  92. package/lib/gitpod-service.js.map +1 -1
  93. package/lib/headless-workspace-log.d.ts +11 -13
  94. package/lib/headless-workspace-log.d.ts.map +1 -1
  95. package/lib/headless-workspace-log.js +8 -9
  96. package/lib/headless-workspace-log.js.map +1 -1
  97. package/lib/ide-frontend-service.d.ts +26 -0
  98. package/lib/ide-frontend-service.d.ts.map +1 -0
  99. package/lib/ide-frontend-service.js +8 -0
  100. package/lib/ide-frontend-service.js.map +1 -0
  101. package/lib/ide-protocol.d.ts +126 -0
  102. package/lib/ide-protocol.d.ts.map +1 -0
  103. package/lib/ide-protocol.js +18 -0
  104. package/lib/ide-protocol.js.map +1 -0
  105. package/lib/index.d.ts +18 -12
  106. package/lib/index.d.ts.map +1 -1
  107. package/lib/index.js +28 -13
  108. package/lib/index.js.map +1 -1
  109. package/lib/installation-admin-protocol.d.ts +30 -0
  110. package/lib/installation-admin-protocol.d.ts.map +1 -0
  111. package/lib/installation-admin-protocol.js +31 -0
  112. package/lib/installation-admin-protocol.js.map +1 -0
  113. package/lib/license-protocol.d.ts +9 -2
  114. package/lib/license-protocol.d.ts.map +1 -1
  115. package/lib/license-protocol.js +3 -2
  116. package/lib/license-protocol.js.map +1 -1
  117. package/lib/messaging/browser/connection.d.ts +6 -4
  118. package/lib/messaging/browser/connection.d.ts.map +1 -1
  119. package/lib/messaging/browser/connection.js +188 -48
  120. package/lib/messaging/browser/connection.js.map +1 -1
  121. package/lib/messaging/browser/window-connection.d.ts +9 -4
  122. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  123. package/lib/messaging/browser/window-connection.js +48 -59
  124. package/lib/messaging/browser/window-connection.js.map +1 -1
  125. package/lib/messaging/client-call-metrics.d.ts +21 -0
  126. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  127. package/lib/messaging/client-call-metrics.js +95 -0
  128. package/lib/messaging/client-call-metrics.js.map +1 -0
  129. package/lib/messaging/error.d.ts +18 -4
  130. package/lib/messaging/error.d.ts.map +1 -1
  131. package/lib/messaging/error.js +38 -7
  132. package/lib/messaging/error.js.map +1 -1
  133. package/lib/messaging/handler.d.ts +10 -0
  134. package/lib/messaging/handler.d.ts.map +1 -1
  135. package/lib/messaging/handler.js +2 -1
  136. package/lib/messaging/handler.js.map +1 -1
  137. package/lib/messaging/node/connection.d.ts +1 -17
  138. package/lib/messaging/node/connection.d.ts.map +1 -1
  139. package/lib/messaging/node/connection.js +24 -59
  140. package/lib/messaging/node/connection.js.map +1 -1
  141. package/lib/messaging/proxy-factory.d.ts +3 -1
  142. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  143. package/lib/messaging/proxy-factory.js +76 -162
  144. package/lib/messaging/proxy-factory.js.map +1 -1
  145. package/lib/oss-allowlist.d.ts +14 -0
  146. package/lib/oss-allowlist.d.ts.map +1 -0
  147. package/lib/oss-allowlist.js +8 -0
  148. package/lib/oss-allowlist.js.map +1 -0
  149. package/lib/payment-protocol.d.ts +18 -0
  150. package/lib/payment-protocol.d.ts.map +1 -0
  151. package/lib/payment-protocol.js +13 -0
  152. package/lib/payment-protocol.js.map +1 -0
  153. package/lib/permission.d.ts +26 -15
  154. package/lib/permission.d.ts.map +1 -1
  155. package/lib/permission.js +50 -36
  156. package/lib/permission.js.map +1 -1
  157. package/lib/plans.d.ts +213 -0
  158. package/lib/plans.d.ts.map +1 -0
  159. package/lib/plans.js +625 -0
  160. package/lib/plans.js.map +1 -0
  161. package/lib/protocol.d.ts +338 -111
  162. package/lib/protocol.d.ts.map +1 -1
  163. package/lib/protocol.js +422 -201
  164. package/lib/protocol.js.map +1 -1
  165. package/lib/protocol.spec.d.ts +7 -0
  166. package/lib/protocol.spec.d.ts.map +1 -0
  167. package/lib/protocol.spec.js +127 -0
  168. package/lib/protocol.spec.js.map +1 -0
  169. package/lib/snapshot-url.d.ts +14 -0
  170. package/lib/snapshot-url.d.ts.map +1 -0
  171. package/lib/snapshot-url.js +26 -0
  172. package/lib/snapshot-url.js.map +1 -0
  173. package/lib/snapshot-url.spec.d.ts +7 -0
  174. package/lib/snapshot-url.spec.d.ts.map +1 -0
  175. package/lib/snapshot-url.spec.js +41 -0
  176. package/lib/snapshot-url.spec.js.map +1 -0
  177. package/lib/team-subscription-protocol.d.ts +93 -0
  178. package/lib/team-subscription-protocol.d.ts.map +1 -0
  179. package/lib/team-subscription-protocol.js +82 -0
  180. package/lib/team-subscription-protocol.js.map +1 -0
  181. package/lib/teams-projects-protocol.d.ts +136 -0
  182. package/lib/teams-projects-protocol.d.ts.map +1 -0
  183. package/lib/teams-projects-protocol.js +41 -0
  184. package/lib/teams-projects-protocol.js.map +1 -0
  185. package/lib/typings/globals.d.ts +8 -3
  186. package/lib/typings/globals.d.ts.map +1 -1
  187. package/lib/typings/globals.js +2 -2
  188. package/lib/usage.d.ts +73 -0
  189. package/lib/usage.d.ts.map +1 -0
  190. package/lib/usage.js +20 -0
  191. package/lib/usage.js.map +1 -0
  192. package/lib/util/analytics.d.ts +8 -0
  193. package/lib/util/analytics.d.ts.map +1 -0
  194. package/lib/util/analytics.js +88 -0
  195. package/lib/util/analytics.js.map +1 -0
  196. package/lib/util/async-iterator.d.ts +2 -2
  197. package/lib/util/async-iterator.d.ts.map +1 -1
  198. package/lib/util/async-iterator.js +60 -137
  199. package/lib/util/async-iterator.js.map +1 -1
  200. package/lib/util/cancelable.d.ts +2 -2
  201. package/lib/util/cancelable.js +20 -61
  202. package/lib/util/cancelable.js.map +1 -1
  203. package/lib/util/date-time.d.ts +2 -2
  204. package/lib/util/date-time.js +14 -13
  205. package/lib/util/date-time.js.map +1 -1
  206. package/lib/util/debug-app.d.ts +25 -0
  207. package/lib/util/debug-app.d.ts.map +1 -0
  208. package/lib/util/debug-app.js +100 -0
  209. package/lib/util/debug-app.js.map +1 -0
  210. package/lib/util/deep-partial.d.ts +2 -2
  211. package/lib/util/deep-partial.js +2 -2
  212. package/lib/util/deferred.d.ts +2 -2
  213. package/lib/util/deferred.js +13 -14
  214. package/lib/util/deferred.js.map +1 -1
  215. package/lib/util/disposable.d.ts +2 -2
  216. package/lib/util/disposable.d.ts.map +1 -1
  217. package/lib/util/disposable.js +28 -40
  218. package/lib/util/disposable.js.map +1 -1
  219. package/lib/util/event.d.ts +1 -1
  220. package/lib/util/event.d.ts.map +1 -1
  221. package/lib/util/event.js +64 -77
  222. package/lib/util/event.js.map +1 -1
  223. package/lib/util/garbage-collected-cache.d.ts +3 -2
  224. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  225. package/lib/util/garbage-collected-cache.js +35 -49
  226. package/lib/util/garbage-collected-cache.js.map +1 -1
  227. package/lib/util/generate-workspace-id.d.ts +9 -0
  228. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  229. package/lib/util/generate-workspace-id.js +491 -0
  230. package/lib/util/generate-workspace-id.js.map +1 -0
  231. package/lib/util/generate-workspace-id.spec.d.ts +7 -0
  232. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  233. package/lib/util/generate-workspace-id.spec.js +98 -0
  234. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  235. package/lib/util/gitpod-cookie.d.ts +20 -0
  236. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  237. package/lib/util/gitpod-cookie.js +41 -0
  238. package/lib/util/gitpod-cookie.js.map +1 -0
  239. package/lib/util/gitpod-host-url.d.ts +20 -8
  240. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  241. package/lib/util/gitpod-host-url.js +143 -85
  242. package/lib/util/gitpod-host-url.js.map +1 -1
  243. package/lib/util/gitpod-host-url.spec.d.ts +16 -0
  244. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
  245. package/lib/util/gitpod-host-url.spec.js +134 -0
  246. package/lib/util/gitpod-host-url.spec.js.map +1 -0
  247. package/lib/util/grpc.d.ts +35 -0
  248. package/lib/util/grpc.d.ts.map +1 -0
  249. package/lib/util/grpc.js +90 -0
  250. package/lib/util/grpc.js.map +1 -0
  251. package/lib/util/jaeger-client-types.d.ts +68 -0
  252. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  253. package/lib/util/jaeger-client-types.js +8 -0
  254. package/lib/util/jaeger-client-types.js.map +1 -0
  255. package/lib/util/logging.d.ts +58 -35
  256. package/lib/util/logging.d.ts.map +1 -1
  257. package/lib/util/logging.js +144 -129
  258. package/lib/util/logging.js.map +1 -1
  259. package/lib/util/logging.spec.d.ts +7 -0
  260. package/lib/util/logging.spec.d.ts.map +1 -0
  261. package/lib/util/logging.spec.js +52 -0
  262. package/lib/util/logging.spec.js.map +1 -0
  263. package/lib/util/make-link.d.ts +2 -2
  264. package/lib/util/make-link.js +8 -7
  265. package/lib/util/make-link.js.map +1 -1
  266. package/lib/util/nice-grpc.d.ts +9 -0
  267. package/lib/util/nice-grpc.d.ts.map +1 -0
  268. package/lib/util/nice-grpc.js +121 -0
  269. package/lib/util/nice-grpc.js.map +1 -0
  270. package/lib/util/parse-workspace-id.d.ts +15 -5
  271. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  272. package/lib/util/parse-workspace-id.js +39 -9
  273. package/lib/util/parse-workspace-id.js.map +1 -1
  274. package/lib/util/parse-workspace-id.spec.d.ts +10 -2
  275. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  276. package/lib/util/parse-workspace-id.spec.js +130 -49
  277. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  278. package/lib/util/queue.d.ts +2 -2
  279. package/lib/util/queue.js +19 -57
  280. package/lib/util/queue.js.map +1 -1
  281. package/lib/util/queue.spec.d.ts +2 -2
  282. package/lib/util/queue.spec.js +149 -288
  283. package/lib/util/queue.spec.js.map +1 -1
  284. package/lib/util/repeat.d.ts +15 -0
  285. package/lib/util/repeat.d.ts.map +1 -0
  286. package/lib/util/repeat.js +55 -0
  287. package/lib/util/repeat.js.map +1 -0
  288. package/lib/util/semaphore.d.ts +2 -2
  289. package/lib/util/semaphore.d.ts.map +1 -1
  290. package/lib/util/semaphore.js +18 -48
  291. package/lib/util/semaphore.js.map +1 -1
  292. package/lib/util/skip-if.d.ts +2 -2
  293. package/lib/util/skip-if.d.ts.map +1 -1
  294. package/lib/util/skip-if.js +9 -8
  295. package/lib/util/skip-if.js.map +1 -1
  296. package/lib/util/timeutil.d.ts +4 -2
  297. package/lib/util/timeutil.d.ts.map +1 -1
  298. package/lib/util/timeutil.js +43 -18
  299. package/lib/util/timeutil.js.map +1 -1
  300. package/lib/util/timeutil.spec.d.ts +4 -2
  301. package/lib/util/timeutil.spec.d.ts.map +1 -1
  302. package/lib/util/timeutil.spec.js +57 -25
  303. package/lib/util/timeutil.spec.js.map +1 -1
  304. package/lib/util/tracing.d.ts +55 -8
  305. package/lib/util/tracing.d.ts.map +1 -1
  306. package/lib/util/tracing.js +210 -66
  307. package/lib/util/tracing.js.map +1 -1
  308. package/lib/util/tracing.spec.d.ts +7 -0
  309. package/lib/util/tracing.spec.d.ts.map +1 -0
  310. package/lib/util/tracing.spec.js +121 -0
  311. package/lib/util/tracing.spec.js.map +1 -0
  312. package/lib/util/workspace-port-authentication.d.ts +9 -9
  313. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  314. package/lib/util/workspace-port-authentication.js +13 -14
  315. package/lib/util/workspace-port-authentication.js.map +1 -1
  316. package/lib/webhook-event.d.ts +44 -0
  317. package/lib/webhook-event.d.ts.map +1 -0
  318. package/lib/webhook-event.js +8 -0
  319. package/lib/webhook-event.js.map +1 -0
  320. package/lib/workspace-class.d.ts +14 -0
  321. package/lib/workspace-class.d.ts.map +1 -0
  322. package/lib/workspace-class.js +8 -0
  323. package/lib/workspace-class.js.map +1 -0
  324. package/lib/workspace-cluster.d.ts +80 -0
  325. package/lib/workspace-cluster.d.ts.map +1 -0
  326. package/lib/workspace-cluster.js +36 -0
  327. package/lib/workspace-cluster.js.map +1 -0
  328. package/lib/workspace-instance.d.ts +51 -8
  329. package/lib/workspace-instance.d.ts.map +1 -1
  330. package/lib/workspace-instance.js +2 -2
  331. package/lib/wsready.d.ts +8 -2
  332. package/lib/wsready.d.ts.map +1 -1
  333. package/lib/wsready.js +4 -3
  334. package/lib/wsready.js.map +1 -1
  335. package/package.json +42 -18
  336. package/pkg-yarn.lock +24 -10
  337. package/provenance-bundle.jsonl +2 -0
  338. package/src/accounting-protocol.ts +253 -0
  339. package/src/admin-protocol.ts +96 -21
  340. package/src/analytics.ts +52 -0
  341. package/src/attribution.ts +67 -0
  342. package/src/auth.ts +27 -0
  343. package/src/billing-mode.ts +84 -0
  344. package/src/blocked-repositories-protocol.ts +13 -0
  345. package/src/context-url.spec.ts +49 -0
  346. package/src/context-url.ts +107 -0
  347. package/src/encryption/container-module.ts +4 -5
  348. package/src/encryption/encryption-engine.spec.ts +11 -10
  349. package/src/encryption/encryption-engine.ts +22 -18
  350. package/src/encryption/encryption-service.ts +6 -7
  351. package/src/encryption/key-provider.ts +18 -21
  352. package/src/env.ts +3 -26
  353. package/src/experiments/always-default.ts +24 -0
  354. package/src/experiments/configcat-server.ts +42 -0
  355. package/src/experiments/configcat.ts +56 -0
  356. package/src/experiments/types.ts +34 -0
  357. package/src/frontend-dashboard-service.ts +148 -0
  358. package/src/gitpod-file-parser.spec.ts +57 -63
  359. package/src/gitpod-file-parser.ts +18 -19
  360. package/src/gitpod-service.ts +602 -99
  361. package/src/headless-workspace-log.ts +14 -16
  362. package/src/ide-frontend-service.ts +28 -0
  363. package/src/ide-protocol.ts +147 -0
  364. package/src/index.ts +18 -12
  365. package/src/installation-admin-protocol.ts +45 -0
  366. package/src/license-protocol.ts +14 -8
  367. package/src/messaging/browser/connection.ts +202 -26
  368. package/src/messaging/browser/window-connection.ts +45 -29
  369. package/src/messaging/client-call-metrics.ts +94 -0
  370. package/src/messaging/error.ts +51 -10
  371. package/src/messaging/handler.ts +13 -1
  372. package/src/messaging/node/connection.ts +23 -70
  373. package/src/messaging/proxy-factory.ts +35 -34
  374. package/src/oss-allowlist.ts +15 -0
  375. package/src/payment-protocol.ts +20 -0
  376. package/src/permission.ts +53 -40
  377. package/src/plans.ts +699 -0
  378. package/src/protocol.spec.ts +97 -0
  379. package/src/protocol.ts +790 -302
  380. package/src/snapshot-url.spec.ts +27 -0
  381. package/src/snapshot-url.ts +27 -0
  382. package/src/team-subscription-protocol.ts +153 -0
  383. package/src/teams-projects-protocol.ts +180 -0
  384. package/src/typings/globals.ts +13 -5
  385. package/src/usage.ts +85 -0
  386. package/src/util/analytics.ts +109 -0
  387. package/src/util/async-iterator.ts +6 -7
  388. package/src/util/cancelable.ts +5 -5
  389. package/src/util/date-time.ts +10 -10
  390. package/src/util/debug-app.ts +81 -0
  391. package/src/util/deep-partial.ts +2 -2
  392. package/src/util/deferred.ts +8 -8
  393. package/src/util/disposable.ts +3 -6
  394. package/src/util/event.ts +9 -11
  395. package/src/util/garbage-collected-cache.ts +18 -10
  396. package/src/util/generate-workspace-id.spec.ts +58 -0
  397. package/src/util/generate-workspace-id.ts +481 -0
  398. package/src/util/gitpod-cookie.ts +38 -0
  399. package/src/util/gitpod-host-url.spec.ts +76 -0
  400. package/src/util/gitpod-host-url.ts +119 -40
  401. package/src/util/grpc.ts +107 -0
  402. package/src/util/jaeger-client-types.ts +102 -0
  403. package/src/util/logging.spec.ts +23 -0
  404. package/src/util/logging.ts +163 -73
  405. package/src/util/make-link.ts +8 -9
  406. package/src/util/nice-grpc.ts +96 -0
  407. package/src/util/parse-workspace-id.spec.ts +62 -12
  408. package/src/util/parse-workspace-id.ts +40 -10
  409. package/src/util/queue.spec.ts +30 -28
  410. package/src/util/queue.ts +2 -2
  411. package/src/util/repeat.ts +45 -0
  412. package/src/util/semaphore.ts +8 -10
  413. package/src/util/skip-if.ts +12 -9
  414. package/src/util/timeutil.spec.ts +42 -16
  415. package/src/util/timeutil.ts +33 -17
  416. package/src/util/tracing.spec.ts +88 -0
  417. package/src/util/tracing.ts +211 -33
  418. package/src/util/workspace-port-authentication.ts +12 -15
  419. package/src/webhook-event.ts +55 -0
  420. package/src/workspace-class.ts +14 -0
  421. package/src/workspace-cluster.ts +121 -0
  422. package/src/workspace-instance.ts +120 -36
  423. package/src/wsready.ts +11 -4
  424. package/data/builtin-theia-plugins.json +0 -362
  425. package/lib/email-protocol.d.ts +0 -49
  426. package/lib/email-protocol.d.ts.map +0 -1
  427. package/lib/email-protocol.js +0 -27
  428. package/lib/email-protocol.js.map +0 -1
  429. package/lib/messaging/connection-error-handler.d.ts +0 -27
  430. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  431. package/lib/messaging/connection-error-handler.js +0 -45
  432. package/lib/messaging/connection-error-handler.js.map +0 -1
  433. package/lib/theia-plugins.d.ts +0 -11
  434. package/lib/theia-plugins.d.ts.map +0 -1
  435. package/lib/theia-plugins.js +0 -8
  436. package/lib/theia-plugins.js.map +0 -1
  437. package/lib/util/repeater.d.ts +0 -22
  438. package/lib/util/repeater.d.ts.map +0 -1
  439. package/lib/util/repeater.js +0 -117
  440. package/lib/util/repeater.js.map +0 -1
  441. package/lib/util/safe-promise.d.ts +0 -11
  442. package/lib/util/safe-promise.d.ts.map +0 -1
  443. package/lib/util/safe-promise.js +0 -33
  444. package/lib/util/safe-promise.js.map +0 -1
  445. package/lib/util/without.d.ts +0 -7
  446. package/lib/util/without.d.ts.map +0 -1
  447. package/lib/util/without.js +0 -8
  448. package/lib/util/without.js.map +0 -1
  449. package/src/email-protocol.ts +0 -67
  450. package/src/messaging/connection-error-handler.ts +0 -62
  451. package/src/theia-plugins.ts +0 -11
  452. package/src/util/jaeger-client.d.ts +0 -105
  453. package/src/util/repeater.ts +0 -49
  454. package/src/util/safe-promise.ts +0 -26
  455. package/src/util/without.ts +0 -8
@@ -1,11 +1,12 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
- * See License-AGPL.txt in the project root for license information.
4
+ * See License.AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- const inspect: (object: any) => string = require('util').inspect; // undefined in frontend
7
+ const inspect: (object: any) => string = require("util").inspect; // undefined in frontend
8
8
 
9
+ let plainLogging: boolean = false; // set to true during development to get non JSON output
9
10
  let jsonLogging: boolean = false;
10
11
  let component: string | undefined;
11
12
  let version: string | undefined;
@@ -15,73 +16,81 @@ export interface LogContext {
15
16
  sessionId?: string;
16
17
  userId?: string;
17
18
  workspaceId?: string;
18
- };
19
+ }
20
+ export namespace LogContext {
21
+ export function from(params: { userId?: string; user?: any; request?: any }) {
22
+ return <LogContext>{
23
+ sessionId: params.request?.requestID,
24
+ userId: params.userId || params.user?.id,
25
+ };
26
+ }
27
+ }
19
28
 
20
29
  export interface LogPayload {
21
30
  // placeholder to indicate that only dictionary-style objects should be passed as payload
22
- };
31
+ }
23
32
 
24
33
  export namespace log {
25
- export function error(context: LogContext, message: string, error: Error, payload: LogPayload): void;
26
- export function error(context: LogContext, message: string, error: Error): void;
34
+ export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
35
+ export function error(context: LogContext, message: string, error: any): void;
27
36
  export function error(context: LogContext, message: string, payload: LogPayload): void;
28
37
  export function error(context: LogContext, message: string): void;
29
- export function error(context: LogContext, error: Error, payload: LogPayload): void;
30
- export function error(context: LogContext, error: Error): void;
31
- export function error(message: string, error: Error, payload: LogPayload): void;
32
- export function error(message: string, error: Error): void;
38
+ export function error(context: LogContext, error: any, payload: LogPayload): void;
39
+ export function error(context: LogContext, error: any): void;
40
+ export function error(message: string, error: any, payload: LogPayload): void;
41
+ export function error(message: string, error: any): void;
33
42
  export function error(message: string, payload: LogPayload): void;
34
43
  export function error(message: string): void;
35
- export function error(error: Error, payload: LogPayload): void;
36
- export function error(error: Error): void;
44
+ export function error(error: any, payload: LogPayload): void;
45
+ export function error(error: any): void;
37
46
  export function error(...args: any[]): void {
38
47
  errorLog(false, args);
39
48
  }
40
49
 
41
- export function warn(context: LogContext, message: string, error: Error, payload: LogPayload): void;
42
- export function warn(context: LogContext, message: string, error: Error): void;
50
+ export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
51
+ export function warn(context: LogContext, message: string, error: any): void;
43
52
  export function warn(context: LogContext, message: string, payload: LogPayload): void;
44
53
  export function warn(context: LogContext, message: string): void;
45
- export function warn(context: LogContext, error: Error, payload: LogPayload): void;
46
- export function warn(context: LogContext, error: Error): void;
47
- export function warn(message: string, error: Error, payload: LogPayload): void;
48
- export function warn(message: string, error: Error): void;
54
+ export function warn(context: LogContext, error: any, payload: LogPayload): void;
55
+ export function warn(context: LogContext, error: any): void;
56
+ export function warn(message: string, error: any, payload: LogPayload): void;
57
+ export function warn(message: string, error: any): void;
49
58
  export function warn(message: string, payload: LogPayload): void;
50
59
  export function warn(message: string): void;
51
- export function warn(error: Error, payload: LogPayload): void;
52
- export function warn(error: Error): void;
60
+ export function warn(error: any, payload: LogPayload): void;
61
+ export function warn(error: any): void;
53
62
  export function warn(...args: any[]): void {
54
63
  warnLog(false, args);
55
64
  }
56
65
 
57
- export function info(context: LogContext, message: string, error: Error, payload: LogPayload): void;
58
- export function info(context: LogContext, message: string, error: Error): void;
66
+ export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
67
+ export function info(context: LogContext, message: string, error: any): void;
59
68
  export function info(context: LogContext, message: string, payload: LogPayload): void;
60
69
  export function info(context: LogContext, message: string): void;
61
- export function info(context: LogContext, error: Error, payload: LogPayload): void;
62
- export function info(context: LogContext, error: Error): void;
63
- export function info(message: string, error: Error, payload: LogPayload): void;
64
- export function info(message: string, error: Error): void;
70
+ export function info(context: LogContext, error: any, payload: LogPayload): void;
71
+ export function info(context: LogContext, error: any): void;
72
+ export function info(message: string, error: any, payload: LogPayload): void;
73
+ export function info(message: string, error: any): void;
65
74
  export function info(message: string, payload: LogPayload): void;
66
75
  export function info(message: string): void;
67
- export function info(error: Error, payload: LogPayload): void;
68
- export function info(error: Error): void;
76
+ export function info(error: any, payload: LogPayload): void;
77
+ export function info(error: any): void;
69
78
  export function info(...args: any[]): void {
70
79
  infoLog(false, args);
71
80
  }
72
81
 
73
- export function debug(context: LogContext, message: string, error: Error, payload: LogPayload): void;
74
- export function debug(context: LogContext, message: string, error: Error): void;
82
+ export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
83
+ export function debug(context: LogContext, message: string, error: any): void;
75
84
  export function debug(context: LogContext, message: string, payload: LogPayload): void;
76
85
  export function debug(context: LogContext, message: string): void;
77
- export function debug(context: LogContext, error: Error, payload: LogPayload): void;
78
- export function debug(context: LogContext, error: Error): void;
79
- export function debug(message: string, error: Error, payload: LogPayload): void;
80
- export function debug(message: string, error: Error): void;
86
+ export function debug(context: LogContext, error: any, payload: LogPayload): void;
87
+ export function debug(context: LogContext, error: any): void;
88
+ export function debug(message: string, error: any, payload: LogPayload): void;
89
+ export function debug(message: string, error: any): void;
81
90
  export function debug(message: string, payload: LogPayload): void;
82
91
  export function debug(message: string): void;
83
- export function debug(error: Error, payload: LogPayload): void;
84
- export function debug(error: Error): void;
92
+ export function debug(error: any, payload: LogPayload): void;
93
+ export function debug(error: any): void;
85
94
  export function debug(...args: any[]): void {
86
95
  debugLog(false, args);
87
96
  }
@@ -89,26 +98,46 @@ export namespace log {
89
98
  /**
90
99
  * Do not use in frontend.
91
100
  */
92
- export function enableJSONLogging(componentArg: string, versionArg: string | undefined): void {
101
+ export function enableJSONLogging(
102
+ componentArg: string,
103
+ versionArg: string | undefined,
104
+ logLevel?: LogrusLogLevel,
105
+ ): void {
93
106
  component = componentArg;
94
107
  version = versionArg;
95
108
 
109
+ setLogLevel(logLevel);
110
+ }
111
+
112
+ export function setLogLevel(logLevel: LogrusLogLevel | undefined) {
96
113
  jsonLogging = true;
97
114
 
98
115
  console.error = function (...args: any[]): void {
99
116
  errorLog(true, args);
100
- }
117
+ };
101
118
  console.warn = function (...args: any[]): void {
102
119
  warnLog(true, args);
103
- }
120
+ };
104
121
  console.info = function (...args: any[]): void {
105
122
  infoLog(true, args);
106
- }
123
+ };
107
124
  console.debug = function (...args: any[]): void {
108
125
  debugLog(true, args);
109
- }
126
+ };
127
+
110
128
  console.log = console.info;
111
129
  // FIXME wrap also other console methods (e.g. trace())
130
+
131
+ // set/unset log functions based on loglevel so we only have to evaluate once, not every call
132
+ const noop = () => {};
133
+ const setLog = (logFunc: DoLogFunction, funcLevel: LogrusLogLevel): DoLogFunction => {
134
+ return LogrusLogLevel.isGreatherOrEqual(funcLevel, logLevel) ? logFunc : noop;
135
+ };
136
+
137
+ errorLog = setLog(doErrorLog, "error");
138
+ warnLog = setLog(doWarnLog, "warning");
139
+ infoLog = setLog(doInfoLog, "info");
140
+ debugLog = setLog(doDebugLog, "debug");
112
141
  }
113
142
 
114
143
  export function resetToDefaultLogging(): void {
@@ -120,31 +149,79 @@ export namespace log {
120
149
  console.info = infoConsoleLog;
121
150
  console.debug = debugConsoleLog;
122
151
  }
152
+
153
+ export function setVersion(versionArg: string) {
154
+ version = versionArg;
155
+ }
156
+ }
157
+
158
+ type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
159
+
160
+ let errorLog = doErrorLog;
161
+ function doErrorLog(calledViaConsole: boolean, args: any[]): void {
162
+ doLog(calledViaConsole, errorConsoleLog, "ERROR", args);
123
163
  }
124
164
 
125
- function errorLog(calledViaConsole: boolean, args: any[]): void {
126
- doLog(calledViaConsole, errorConsoleLog, 'ERROR', args);
165
+ let warnLog = doWarnLog;
166
+ function doWarnLog(calledViaConsole: boolean, args: any[]): void {
167
+ doLog(calledViaConsole, warnConsoleLog, "WARNING", args);
127
168
  }
128
169
 
129
- function warnLog(calledViaConsole: boolean, args: any[]): void {
130
- doLog(calledViaConsole, warnConsoleLog, 'WARNING', args);
170
+ let infoLog = doInfoLog;
171
+ function doInfoLog(calledViaConsole: boolean, args: any[]): void {
172
+ doLog(calledViaConsole, infoConsoleLog, "INFO", args);
131
173
  }
132
174
 
133
- function infoLog(calledViaConsole: boolean, args: any[]): void {
134
- doLog(calledViaConsole, infoConsoleLog, 'INFO', args);
175
+ let debugLog = doDebugLog;
176
+ function doDebugLog(calledViaConsole: boolean, args: any[]): void {
177
+ doLog(calledViaConsole, debugConsoleLog, "DEBUG", args);
135
178
  }
136
179
 
137
- function debugLog(calledViaConsole: boolean, args: any[]): void {
138
- doLog(calledViaConsole, debugConsoleLog, 'DEBUG', args);
180
+ // Ref: https://github.com/sirupsen/logrus#level-logging
181
+ export type LogrusLogLevel = keyof typeof LogrusLogLevels;
182
+ export const LogrusLogLevels = {
183
+ trace: true,
184
+ debug: true,
185
+ info: true,
186
+ warning: true,
187
+ error: true,
188
+ fatal: true,
189
+ panic: true,
190
+ };
191
+ export namespace LogrusLogLevel {
192
+ export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
193
+ if (lvl === undefined) {
194
+ return false;
195
+ }
196
+ if (ref === undefined) {
197
+ return true;
198
+ }
199
+ return getLevelArity(lvl) >= getLevelArity(ref);
200
+ }
201
+ function getLevelArity(lvl: LogrusLogLevel): number {
202
+ return Object.keys(LogrusLogLevels).findIndex((l) => l === lvl);
203
+ }
204
+ export function getFromEnv(): LogrusLogLevel | undefined {
205
+ const lvlStr = process.env.LOG_LEVEL;
206
+ if (!lvlStr) {
207
+ return undefined;
208
+ }
209
+ const lvl = lvlStr as LogrusLogLevel;
210
+ const exists = LogrusLogLevels[lvl];
211
+ if (!exists) {
212
+ return undefined;
213
+ }
214
+ return lvl;
215
+ }
139
216
  }
140
217
 
141
218
  // Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
142
- type GoogleLogSeverity = 'EMERGENCY' | 'ALERT' | 'CRITICAL' | 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
219
+ type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
143
220
  namespace GoogleLogSeverity {
144
221
  export const isGreaterOrEqualThanWarning = (severity: GoogleLogSeverity) => {
145
222
  switch (severity) {
146
- case 'INFO':
147
- case 'DEBUG':
223
+ case "INFO":
224
+ case "DEBUG":
148
225
  return false;
149
226
  default:
150
227
  return true;
@@ -172,7 +249,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
172
249
  // console.xyz(Error, ...any) / log.xyz(Error) / log.xyz(Error, LogPayload)
173
250
  error = args[0];
174
251
  payloadArgs = args.slice(1);
175
- } else if (typeof args[0] === 'string') {
252
+ } else if (typeof args[0] === "string") {
176
253
  message = args[0];
177
254
  if (args.length < 2 || !(args[1] instanceof Error)) {
178
255
  // console.xyz(string) / console.xyz(string, !Error, ...any) / log.xyz(string) / log.xyz(string, LogPayload)
@@ -192,7 +269,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
192
269
  // log.xyz(LogContext, Error) / log.xyz(LogContext, Error, LogPayload)
193
270
  error = args[1];
194
271
  payloadArgs = args.slice(2);
195
- } else if (typeof args[1] === 'string') {
272
+ } else if (typeof args[1] === "string") {
196
273
  message = args[1];
197
274
  if (args.length < 3 || !(args[2] instanceof Error)) {
198
275
  // log.xyz(LogContext, string) / log.xyz(LogContext, string, LogPayload)
@@ -215,9 +292,14 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
215
292
  }
216
293
  }
217
294
 
218
- function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefined, message: string | undefined,
219
- error: Error | undefined, payloadArgs: any[], calledViaConsole: boolean): string | undefined {
220
-
295
+ function makeLogItem(
296
+ severity: GoogleLogSeverity,
297
+ context: LogContext | undefined,
298
+ message: string | undefined,
299
+ error: Error | undefined,
300
+ payloadArgs: any[],
301
+ calledViaConsole: boolean,
302
+ ): string | undefined {
221
303
  if (context !== undefined && Object.keys(context).length == 0) {
222
304
  context = undefined;
223
305
  }
@@ -228,34 +310,40 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
228
310
  }
229
311
 
230
312
  const payload: any = payloadArgs.length == 0 ? undefined : payloadArgs.length == 1 ? payloadArgs[0] : payloadArgs;
231
- const logItem: any = {
313
+ const logItem = {
232
314
  // undefined fields get eliminated in JSON.stringify()
233
315
  ...reportedErrorEvent,
234
316
  component,
235
317
  severity,
236
318
  time: new Date().toISOString(),
237
- environment: process.env.KUBE_STAGE,
238
- region: process.env.GITPOD_REGION,
239
319
  context,
240
320
  message,
241
321
  error,
242
322
  payload,
243
- loggedViaConsole: calledViaConsole ? true : undefined
323
+ loggedViaConsole: calledViaConsole ? true : undefined,
244
324
  };
325
+ if (plainLogging) {
326
+ return `[${logItem.severity}] [${logItem.component}] ${logItem.message}
327
+ ${JSON.stringify(payload || "", undefined, " ")}
328
+ ${error || ""}
329
+ `.trim();
330
+ }
245
331
  let result: string = stringifyLogItem(logItem);
246
332
 
247
333
  if (result.length > maxAllowedLogItemLength && payload !== undefined) {
248
334
  delete logItem.payload;
249
- logItem.payloadStub = `Payload stripped as log item was longer than ${maxAllowedLogItemLength} characters`;
335
+ (<any>(
336
+ logItem
337
+ )).payloadStub = `Payload stripped as log item was longer than ${maxAllowedLogItemLength} characters`;
250
338
 
251
339
  result = stringifyLogItem(logItem);
252
340
 
253
341
  if (result.length <= maxAllowedLogItemLength) {
254
- log.warn('Log item too large, stripping payload', { logItemStub: makeLogItemStub(logItem) });
342
+ log.warn("Log item too large, stripping payload", { logItemStub: makeLogItemStub(logItem) });
255
343
  }
256
344
  }
257
345
  if (result.length > maxAllowedLogItemLength) {
258
- log.error('Log item too large w/o payload, discarding', { logItemStub: makeLogItemStub(logItem) });
346
+ log.error("Log item too large w/o payload, discarding", { logItemStub: makeLogItemStub(logItem) });
259
347
  return undefined;
260
348
  }
261
349
 
@@ -269,10 +357,10 @@ function makeReportedErrorEvent(error: Error | undefined) {
269
357
  // Serves as marker only
270
358
  "@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
271
359
  // This is useful for filtering in the UI
272
- "serviceContext": {
273
- "service": component || "<ts-not-set>",
274
- "version": version || "<ts-not-set>",
275
- }
360
+ serviceContext: {
361
+ service: component || "<ts-not-set>",
362
+ version: version || "<ts-not-set>",
363
+ },
276
364
  };
277
365
 
278
366
  if (error) {
@@ -292,9 +380,9 @@ function makeLogItemStub(logItem: any): any {
292
380
  severity: logItem.severity,
293
381
  time: logItem.time,
294
382
  environment: logItem.environment,
295
- region: logItem.region
383
+ region: logItem.region,
296
384
  };
297
- if (typeof (logItem.message) === 'string') {
385
+ if (typeof logItem.message === "string") {
298
386
  if (logItem.message.length <= maxMessageStubLength) {
299
387
  result.message = logItem.message;
300
388
  } else {
@@ -328,10 +416,12 @@ function stringifyLogItem(logItem: any): string {
328
416
  * Jsonifies Errors properly, not as {} only.
329
417
  */
330
418
  function jsonStringifyWithErrors(value: any): string {
331
- return JSON.stringify(value, (key: string, value: any): any => { return value instanceof Error ? value.stack : value });
419
+ return JSON.stringify(value, (key: string, value: any): any => {
420
+ return value instanceof Error ? value.stack : value;
421
+ });
332
422
  }
333
423
 
334
- type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
424
+ type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
335
425
  const logConsoleLog: ConsoleLog = console.log;
336
426
  const errorConsoleLog: ConsoleLog = console.error;
337
427
  const warnConsoleLog: ConsoleLog = console.warn;
@@ -1,22 +1,21 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
- * See License-AGPL.txt in the project root for license information.
4
+ * See License.AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
7
  function isOpenNewTab(event: MouseEvent): boolean {
8
- return event.metaKey || (event.ctrlKey);
8
+ return event.metaKey || event.ctrlKey;
9
9
  }
10
10
 
11
11
  export function makeLink(node: HTMLElement, url: string, hover: string): void {
12
- node.onclick = event => {
13
- let target = '_self';
12
+ node.onclick = (event) => {
13
+ let target = "_self";
14
14
  if (isOpenNewTab(event)) {
15
- target = '_blank';
15
+ target = "_blank";
16
16
  }
17
17
  window.open(url, target);
18
- }
19
- node.style.cursor = 'pointer';
18
+ };
19
+ node.style.cursor = "pointer";
20
20
  node.title = hover;
21
21
  }
22
-
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License.AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { isAbortError } from "abort-controller-x";
8
+ import {
9
+ CallOptions,
10
+ ClientError,
11
+ ClientMiddleware,
12
+ ClientMiddlewareCall,
13
+ Status,
14
+ MethodDescriptor,
15
+ } from "nice-grpc-common";
16
+ import { GrpcMethodType, IClientCallMetrics } from "./grpc";
17
+
18
+ function getLabels(method: MethodDescriptor) {
19
+ const callType = method.requestStream
20
+ ? method.responseStream
21
+ ? "bidi_stream"
22
+ : "client_stream"
23
+ : method.responseStream
24
+ ? "server_stream"
25
+ : "unary";
26
+ const { path } = method;
27
+ const [serviceName, methodName] = path.split("/").slice(1);
28
+
29
+ return {
30
+ type: callType as GrpcMethodType,
31
+ service: serviceName,
32
+ method: methodName,
33
+ };
34
+ }
35
+
36
+ async function* incrementStreamMessagesCounter<T>(iterable: AsyncIterable<T>, callback: () => void): AsyncIterable<T> {
37
+ for await (const item of iterable) {
38
+ callback();
39
+ yield item;
40
+ }
41
+ }
42
+
43
+ export function prometheusClientMiddleware(metrics: IClientCallMetrics): ClientMiddleware {
44
+ return async function* prometheusClientMiddlewareGenerator<Request, Response>(
45
+ call: ClientMiddlewareCall<Request, Response>,
46
+ options: CallOptions,
47
+ ): AsyncGenerator<Response, Response | void, undefined> {
48
+ const labels = getLabels(call.method);
49
+
50
+ metrics.started(labels);
51
+
52
+ const stopTimer = metrics.startHandleTimer(labels);
53
+
54
+ let settled = false;
55
+ let status: Status = Status.OK;
56
+
57
+ try {
58
+ let request;
59
+
60
+ if (!call.requestStream) {
61
+ request = call.request;
62
+ } else {
63
+ request = incrementStreamMessagesCounter(call.request, metrics.sent.bind(metrics, labels));
64
+ }
65
+
66
+ if (!call.responseStream) {
67
+ const response = yield* call.next(request, options);
68
+ settled = true;
69
+ return response;
70
+ } else {
71
+ yield* incrementStreamMessagesCounter(
72
+ call.next(request, options),
73
+ metrics.received.bind(metrics, labels),
74
+ );
75
+ settled = true;
76
+ return;
77
+ }
78
+ } catch (err) {
79
+ settled = true;
80
+ if (err instanceof ClientError) {
81
+ status = err.code;
82
+ } else if (isAbortError(err)) {
83
+ status = Status.CANCELLED;
84
+ } else {
85
+ status = Status.UNKNOWN;
86
+ }
87
+ throw err;
88
+ } finally {
89
+ if (!settled) {
90
+ status = Status.CANCELLED;
91
+ }
92
+ stopTimer({ grpc_code: Status[status] });
93
+ metrics.handled({ ...labels, code: Status[status] });
94
+ }
95
+ };
96
+ }
@@ -1,35 +1,85 @@
1
1
  /**
2
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
3
  * Licensed under the GNU Affero General Public License (AGPL).
4
- * See License-AGPL.txt in the project root for license information.
4
+ * See License.AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import * as chai from 'chai';
8
- import { suite, test } from 'mocha-typescript';
9
- import { parseWorkspaceIdFromHostname } from './parse-workspace-id';
7
+ import * as chai from "chai";
8
+ import { suite, test } from "mocha-typescript";
9
+ import {
10
+ matchesInstanceIdOrLegacyWorkspaceIdExactly,
11
+ matchesNewWorkspaceIdExactly,
12
+ parseWorkspaceIdFromHostname,
13
+ } from "./parse-workspace-id";
10
14
  const expect = chai.expect;
11
15
 
12
16
  @suite
13
17
  export class ParseWorkspaceIdTest {
14
-
15
18
  @test public parseWorkspaceIdFromHostname_fromWorkspaceLocation() {
19
+ const actual = parseWorkspaceIdFromHostname("moccasin-ferret-155799b3.ws-eu01.gitpod.io");
20
+ expect(actual).to.equal("moccasin-ferret-155799b3");
21
+ }
22
+
23
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocation() {
24
+ const actual = parseWorkspaceIdFromHostname("3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
25
+ expect(actual).to.equal("moccasin-ferret-155799b3");
26
+ }
27
+
28
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
29
+ const actual = parseWorkspaceIdFromHostname("webview-3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
30
+ expect(actual).to.equal("moccasin-ferret-155799b3");
31
+ }
32
+
33
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
34
+ const actual = parseWorkspaceIdFromHostname(
35
+ "webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com",
36
+ );
37
+ expect(actual).to.equal("moccasin-ferret-155799b3");
38
+ }
39
+
40
+ // legacy mode
41
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspaceLocation() {
16
42
  const actual = parseWorkspaceIdFromHostname("b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
17
43
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
18
44
  }
19
45
 
20
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocation() {
46
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocation() {
21
47
  const actual = parseWorkspaceIdFromHostname("3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
22
48
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
23
49
  }
24
50
 
25
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
26
- const actual = parseWorkspaceIdFromHostname("webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
51
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
52
+ const actual = parseWorkspaceIdFromHostname(
53
+ "webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io",
54
+ );
27
55
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
28
56
  }
29
57
 
30
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
31
- const actual = parseWorkspaceIdFromHostname("webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com");
58
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
59
+ const actual = parseWorkspaceIdFromHostname(
60
+ "webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com",
61
+ );
32
62
  expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
33
63
  }
64
+
65
+ // match - instance ID
66
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
67
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
68
+ expect(actual).to.be.true;
69
+ }
70
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
71
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
72
+ expect(actual).to.be.false;
73
+ }
74
+
75
+ // match - new workspace ID
76
+ @test public matchesWorkspaceIdExactly_new_positive() {
77
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
78
+ expect(actual).to.be.true;
79
+ }
80
+ @test public matchesWorkspaceIdExactly_new_negative() {
81
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
82
+ expect(actual).to.be.false;
83
+ }
34
84
  }
35
- module.exports = new ParseWorkspaceIdTest()
85
+ module.exports = new ParseWorkspaceIdTest();