@gitpod/gitpod-protocol 0.1.5-wth-test.80 → 0.1.5-wv-add-image-builds-to-dashboard.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 (408) hide show
  1. package/data/gitpod-schema.json +132 -5
  2. package/lib/accounting-protocol.d.ts +19 -11
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +35 -33
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +19 -2
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +1 -1
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +1 -1
  11. package/lib/analytics.d.ts.map +1 -1
  12. package/lib/analytics.js +1 -1
  13. package/lib/analytics.js.map +1 -1
  14. package/lib/attribution.d.ts +24 -0
  15. package/lib/attribution.d.ts.map +1 -0
  16. package/lib/attribution.js +54 -0
  17. package/lib/attribution.js.map +1 -0
  18. package/lib/auth.d.ts +1 -1
  19. package/lib/auth.d.ts.map +1 -1
  20. package/lib/auth.js +1 -1
  21. package/lib/billing-mode.d.ts +45 -0
  22. package/lib/billing-mode.d.ts.map +1 -0
  23. package/lib/billing-mode.js +44 -0
  24. package/lib/billing-mode.js.map +1 -0
  25. package/lib/blocked-repositories-protocol.d.ts +13 -0
  26. package/lib/blocked-repositories-protocol.d.ts.map +1 -0
  27. package/lib/blocked-repositories-protocol.js +8 -0
  28. package/lib/blocked-repositories-protocol.js.map +1 -0
  29. package/lib/context-url.d.ts +1 -2
  30. package/lib/context-url.d.ts.map +1 -1
  31. package/lib/context-url.js +5 -7
  32. package/lib/context-url.js.map +1 -1
  33. package/lib/context-url.spec.d.ts +1 -3
  34. package/lib/context-url.spec.d.ts.map +1 -1
  35. package/lib/context-url.spec.js +13 -26
  36. package/lib/context-url.spec.js.map +1 -1
  37. package/lib/encryption/container-module.d.ts +1 -1
  38. package/lib/encryption/container-module.d.ts.map +1 -1
  39. package/lib/encryption/container-module.js +2 -2
  40. package/lib/encryption/container-module.js.map +1 -1
  41. package/lib/encryption/encryption-engine.d.ts +1 -1
  42. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  43. package/lib/encryption/encryption-engine.js +10 -10
  44. package/lib/encryption/encryption-engine.js.map +1 -1
  45. package/lib/encryption/encryption-engine.spec.d.ts +1 -1
  46. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  47. package/lib/encryption/encryption-engine.spec.js +3 -4
  48. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  49. package/lib/encryption/encryption-service.d.ts +1 -1
  50. package/lib/encryption/encryption-service.d.ts.map +1 -1
  51. package/lib/encryption/encryption-service.js +2 -2
  52. package/lib/encryption/encryption-service.js.map +1 -1
  53. package/lib/encryption/key-provider.d.ts +1 -1
  54. package/lib/encryption/key-provider.d.ts.map +1 -1
  55. package/lib/encryption/key-provider.js +8 -10
  56. package/lib/encryption/key-provider.js.map +1 -1
  57. package/lib/env.d.ts +1 -6
  58. package/lib/env.d.ts.map +1 -1
  59. package/lib/env.js +2 -21
  60. package/lib/env.js.map +1 -1
  61. package/lib/experiments/always-default.d.ts +8 -0
  62. package/lib/experiments/always-default.d.ts.map +1 -0
  63. package/lib/experiments/always-default.js +20 -0
  64. package/lib/experiments/always-default.js.map +1 -0
  65. package/lib/experiments/configcat-server.d.ts +10 -0
  66. package/lib/experiments/configcat-server.d.ts.map +1 -0
  67. package/lib/experiments/configcat-server.js +37 -0
  68. package/lib/experiments/configcat-server.js.map +1 -0
  69. package/lib/experiments/configcat.d.ts +21 -0
  70. package/lib/experiments/configcat.d.ts.map +1 -0
  71. package/lib/experiments/configcat.js +51 -0
  72. package/lib/experiments/configcat.js.map +1 -0
  73. package/lib/experiments/types.d.ts +22 -0
  74. package/lib/experiments/types.d.ts.map +1 -0
  75. package/lib/experiments/types.js +10 -0
  76. package/lib/experiments/types.js.map +1 -0
  77. package/lib/gitpod-file-parser.d.ts +1 -1
  78. package/lib/gitpod-file-parser.d.ts.map +1 -1
  79. package/lib/gitpod-file-parser.js +7 -7
  80. package/lib/gitpod-file-parser.js.map +1 -1
  81. package/lib/gitpod-file-parser.spec.d.ts +1 -1
  82. package/lib/gitpod-file-parser.spec.js +43 -40
  83. package/lib/gitpod-file-parser.spec.js.map +1 -1
  84. package/lib/gitpod-service.d.ts +70 -52
  85. package/lib/gitpod-service.d.ts.map +1 -1
  86. package/lib/gitpod-service.js +53 -34
  87. package/lib/gitpod-service.js.map +1 -1
  88. package/lib/headless-workspace-log.d.ts +2 -1
  89. package/lib/headless-workspace-log.d.ts.map +1 -1
  90. package/lib/headless-workspace-log.js +3 -2
  91. package/lib/headless-workspace-log.js.map +1 -1
  92. package/lib/ide-frontend-service.d.ts +2 -2
  93. package/lib/ide-frontend-service.js +1 -1
  94. package/lib/ide-protocol.d.ts +29 -8
  95. package/lib/ide-protocol.d.ts.map +1 -1
  96. package/lib/ide-protocol.js +11 -1
  97. package/lib/ide-protocol.js.map +1 -1
  98. package/lib/index.d.ts +17 -17
  99. package/lib/index.d.ts.map +1 -1
  100. package/lib/index.js +2 -2
  101. package/lib/index.js.map +1 -1
  102. package/lib/installation-admin-protocol.d.ts +4 -1
  103. package/lib/installation-admin-protocol.d.ts.map +1 -1
  104. package/lib/installation-admin-protocol.js +4 -3
  105. package/lib/installation-admin-protocol.js.map +1 -1
  106. package/lib/license-protocol.d.ts +8 -1
  107. package/lib/license-protocol.d.ts.map +1 -1
  108. package/lib/license-protocol.js +1 -1
  109. package/lib/license-protocol.js.map +1 -1
  110. package/lib/messaging/browser/connection.d.ts +1 -1
  111. package/lib/messaging/browser/connection.d.ts.map +1 -1
  112. package/lib/messaging/browser/connection.js +19 -19
  113. package/lib/messaging/browser/connection.js.map +1 -1
  114. package/lib/messaging/browser/window-connection.d.ts +5 -5
  115. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  116. package/lib/messaging/browser/window-connection.js +10 -7
  117. package/lib/messaging/browser/window-connection.js.map +1 -1
  118. package/lib/messaging/client-call-metrics.d.ts +5 -19
  119. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  120. package/lib/messaging/client-call-metrics.js +35 -23
  121. package/lib/messaging/client-call-metrics.js.map +1 -1
  122. package/lib/messaging/error.d.ts +10 -2
  123. package/lib/messaging/error.d.ts.map +1 -1
  124. package/lib/messaging/error.js +20 -4
  125. package/lib/messaging/error.js.map +1 -1
  126. package/lib/messaging/handler.d.ts.map +1 -1
  127. package/lib/messaging/handler.js +1 -1
  128. package/lib/messaging/node/connection.js +8 -8
  129. package/lib/messaging/node/connection.js.map +1 -1
  130. package/lib/messaging/proxy-factory.d.ts +1 -1
  131. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  132. package/lib/messaging/proxy-factory.js +7 -9
  133. package/lib/messaging/proxy-factory.js.map +1 -1
  134. package/lib/oss-allowlist.d.ts +1 -1
  135. package/lib/oss-allowlist.js +1 -1
  136. package/lib/payment-protocol.d.ts +1 -1
  137. package/lib/payment-protocol.d.ts.map +1 -1
  138. package/lib/payment-protocol.js +2 -2
  139. package/lib/payment-protocol.js.map +1 -1
  140. package/lib/permission.d.ts +3 -3
  141. package/lib/permission.d.ts.map +1 -1
  142. package/lib/permission.js +13 -24
  143. package/lib/permission.js.map +1 -1
  144. package/lib/plans.d.ts +5 -4
  145. package/lib/plans.d.ts.map +1 -1
  146. package/lib/plans.js +211 -172
  147. package/lib/plans.js.map +1 -1
  148. package/lib/protocol.d.ts +166 -61
  149. package/lib/protocol.d.ts.map +1 -1
  150. package/lib/protocol.js +282 -106
  151. package/lib/protocol.js.map +1 -1
  152. package/lib/protocol.spec.d.ts +7 -0
  153. package/lib/protocol.spec.d.ts.map +1 -0
  154. package/lib/protocol.spec.js +127 -0
  155. package/lib/protocol.spec.js.map +1 -0
  156. package/lib/snapshot-url.d.ts +1 -1
  157. package/lib/snapshot-url.js +1 -1
  158. package/lib/snapshot-url.spec.d.ts +1 -1
  159. package/lib/snapshot-url.spec.js +1 -1
  160. package/lib/snapshot-url.spec.js.map +1 -1
  161. package/lib/team-subscription-protocol.d.ts +23 -4
  162. package/lib/team-subscription-protocol.d.ts.map +1 -1
  163. package/lib/team-subscription-protocol.js +21 -6
  164. package/lib/team-subscription-protocol.js.map +1 -1
  165. package/lib/teams-projects-protocol.d.ts +26 -6
  166. package/lib/teams-projects-protocol.d.ts.map +1 -1
  167. package/lib/teams-projects-protocol.js +2 -2
  168. package/lib/teams-projects-protocol.js.map +1 -1
  169. package/lib/typings/globals.d.ts +3 -3
  170. package/lib/typings/globals.d.ts.map +1 -1
  171. package/lib/typings/globals.js +1 -1
  172. package/lib/usage.d.ts +73 -0
  173. package/lib/usage.d.ts.map +1 -0
  174. package/lib/usage.js +20 -0
  175. package/lib/usage.js.map +1 -0
  176. package/lib/util/analytics.d.ts +1 -1
  177. package/lib/util/analytics.d.ts.map +1 -1
  178. package/lib/util/analytics.js +7 -7
  179. package/lib/util/analytics.js.map +1 -1
  180. package/lib/util/async-iterator.d.ts +1 -1
  181. package/lib/util/async-iterator.d.ts.map +1 -1
  182. package/lib/util/async-iterator.js +4 -4
  183. package/lib/util/async-iterator.js.map +1 -1
  184. package/lib/util/cancelable.d.ts +1 -1
  185. package/lib/util/cancelable.js +1 -1
  186. package/lib/util/cancelable.js.map +1 -1
  187. package/lib/util/date-time.d.ts +1 -1
  188. package/lib/util/date-time.js +7 -7
  189. package/lib/util/date-time.js.map +1 -1
  190. package/lib/util/debug-app.d.ts +25 -0
  191. package/lib/util/debug-app.d.ts.map +1 -0
  192. package/lib/util/debug-app.js +100 -0
  193. package/lib/util/debug-app.js.map +1 -0
  194. package/lib/util/deep-partial.d.ts +1 -1
  195. package/lib/util/deep-partial.js +1 -1
  196. package/lib/util/deferred.d.ts +1 -1
  197. package/lib/util/deferred.js +1 -1
  198. package/lib/util/deferred.js.map +1 -1
  199. package/lib/util/disposable.d.ts.map +1 -1
  200. package/lib/util/disposable.js +2 -2
  201. package/lib/util/disposable.js.map +1 -1
  202. package/lib/util/event.d.ts.map +1 -1
  203. package/lib/util/event.js +5 -3
  204. package/lib/util/event.js.map +1 -1
  205. package/lib/util/garbage-collected-cache.d.ts +1 -1
  206. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  207. package/lib/util/garbage-collected-cache.js +7 -2
  208. package/lib/util/garbage-collected-cache.js.map +1 -1
  209. package/lib/util/generate-workspace-id.d.ts +5 -0
  210. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  211. package/lib/util/generate-workspace-id.js +446 -442
  212. package/lib/util/generate-workspace-id.js.map +1 -1
  213. package/lib/util/generate-workspace-id.spec.d.ts +1 -1
  214. package/lib/util/generate-workspace-id.spec.js +19 -8
  215. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  216. package/lib/util/gitpod-cookie.d.ts +2 -2
  217. package/lib/util/gitpod-cookie.d.ts.map +1 -1
  218. package/lib/util/gitpod-cookie.js +1 -4
  219. package/lib/util/gitpod-cookie.js.map +1 -1
  220. package/lib/util/gitpod-host-url.d.ts +6 -1
  221. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  222. package/lib/util/gitpod-host-url.js +60 -33
  223. package/lib/util/gitpod-host-url.js.map +1 -1
  224. package/lib/util/gitpod-host-url.spec.d.ts +1 -1
  225. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  226. package/lib/util/gitpod-host-url.spec.js +16 -6
  227. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  228. package/lib/util/grpc.d.ts +21 -1
  229. package/lib/util/grpc.d.ts.map +1 -1
  230. package/lib/util/grpc.js +74 -2
  231. package/lib/util/grpc.js.map +1 -1
  232. package/lib/util/jaeger-client-types.d.ts +1 -1
  233. package/lib/util/jaeger-client-types.d.ts.map +1 -1
  234. package/lib/util/jaeger-client-types.js +1 -1
  235. package/lib/util/logging.d.ts +2 -2
  236. package/lib/util/logging.d.ts.map +1 -1
  237. package/lib/util/logging.js +32 -26
  238. package/lib/util/logging.js.map +1 -1
  239. package/lib/util/logging.spec.d.ts +7 -0
  240. package/lib/util/logging.spec.d.ts.map +1 -0
  241. package/lib/util/logging.spec.js +52 -0
  242. package/lib/util/logging.spec.js.map +1 -0
  243. package/lib/util/make-link.d.ts +1 -1
  244. package/lib/util/make-link.js +6 -6
  245. package/lib/util/make-link.js.map +1 -1
  246. package/lib/util/nice-grpc.d.ts +9 -0
  247. package/lib/util/nice-grpc.d.ts.map +1 -0
  248. package/lib/util/nice-grpc.js +121 -0
  249. package/lib/util/nice-grpc.js.map +1 -0
  250. package/lib/util/parse-workspace-id.d.ts +1 -1
  251. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  252. package/lib/util/parse-workspace-id.js +2 -3
  253. package/lib/util/parse-workspace-id.js.map +1 -1
  254. package/lib/util/parse-workspace-id.spec.d.ts +1 -1
  255. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  256. package/lib/util/parse-workspace-id.spec.js +1 -1
  257. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  258. package/lib/util/queue.d.ts +1 -1
  259. package/lib/util/queue.js +1 -1
  260. package/lib/util/queue.spec.d.ts +1 -1
  261. package/lib/util/queue.spec.js +10 -7
  262. package/lib/util/queue.spec.js.map +1 -1
  263. package/lib/util/repeat.d.ts +1 -1
  264. package/lib/util/repeat.js +1 -1
  265. package/lib/util/semaphore.d.ts +1 -1
  266. package/lib/util/semaphore.d.ts.map +1 -1
  267. package/lib/util/semaphore.js +1 -1
  268. package/lib/util/semaphore.js.map +1 -1
  269. package/lib/util/skip-if.d.ts +1 -1
  270. package/lib/util/skip-if.d.ts.map +1 -1
  271. package/lib/util/skip-if.js +1 -1
  272. package/lib/util/skip-if.js.map +1 -1
  273. package/lib/util/timeutil.d.ts +3 -1
  274. package/lib/util/timeutil.d.ts.map +1 -1
  275. package/lib/util/timeutil.js +16 -4
  276. package/lib/util/timeutil.js.map +1 -1
  277. package/lib/util/timeutil.spec.d.ts +3 -1
  278. package/lib/util/timeutil.spec.d.ts.map +1 -1
  279. package/lib/util/timeutil.spec.js +35 -1
  280. package/lib/util/timeutil.spec.js.map +1 -1
  281. package/lib/util/tracing.d.ts +7 -7
  282. package/lib/util/tracing.d.ts.map +1 -1
  283. package/lib/util/tracing.js +15 -17
  284. package/lib/util/tracing.js.map +1 -1
  285. package/lib/util/tracing.spec.d.ts +1 -1
  286. package/lib/util/tracing.spec.js +4 -4
  287. package/lib/util/tracing.spec.js.map +1 -1
  288. package/lib/util/workspace-port-authentication.d.ts +8 -8
  289. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  290. package/lib/util/workspace-port-authentication.js +9 -12
  291. package/lib/util/workspace-port-authentication.js.map +1 -1
  292. package/lib/webhook-event.d.ts +44 -0
  293. package/lib/webhook-event.d.ts.map +1 -0
  294. package/lib/webhook-event.js +8 -0
  295. package/lib/webhook-event.js.map +1 -0
  296. package/lib/workspace-class.d.ts +14 -0
  297. package/lib/workspace-class.d.ts.map +1 -0
  298. package/lib/workspace-class.js +8 -0
  299. package/lib/workspace-class.js.map +1 -0
  300. package/lib/workspace-cluster.d.ts +13 -14
  301. package/lib/workspace-cluster.d.ts.map +1 -1
  302. package/lib/workspace-cluster.js +3 -5
  303. package/lib/workspace-cluster.js.map +1 -1
  304. package/lib/workspace-instance.d.ts +22 -4
  305. package/lib/workspace-instance.d.ts.map +1 -1
  306. package/lib/workspace-instance.js +1 -1
  307. package/lib/wsready.d.ts +8 -2
  308. package/lib/wsready.d.ts.map +1 -1
  309. package/lib/wsready.js +3 -3
  310. package/package.json +14 -6
  311. package/pkg-yarn.lock +10 -5
  312. package/provenance-bundle.jsonl +1 -1
  313. package/src/accounting-protocol.ts +67 -52
  314. package/src/admin-protocol.ts +48 -22
  315. package/src/analytics.ts +22 -22
  316. package/src/attribution.ts +63 -0
  317. package/src/auth.ts +3 -3
  318. package/src/billing-mode.ts +84 -0
  319. package/src/blocked-repositories-protocol.ts +13 -0
  320. package/src/context-url.spec.ts +18 -22
  321. package/src/context-url.ts +79 -79
  322. package/src/encryption/container-module.ts +3 -4
  323. package/src/encryption/encryption-engine.spec.ts +10 -9
  324. package/src/encryption/encryption-engine.ts +21 -17
  325. package/src/encryption/encryption-service.ts +5 -6
  326. package/src/encryption/key-provider.ts +17 -20
  327. package/src/env.ts +2 -25
  328. package/src/experiments/always-default.ts +24 -0
  329. package/src/experiments/configcat-server.ts +42 -0
  330. package/src/experiments/configcat.ts +56 -0
  331. package/src/experiments/types.ts +34 -0
  332. package/src/gitpod-file-parser.spec.ts +56 -62
  333. package/src/gitpod-file-parser.ts +17 -18
  334. package/src/gitpod-service.ts +216 -140
  335. package/src/headless-workspace-log.ts +7 -5
  336. package/src/ide-frontend-service.ts +3 -3
  337. package/src/ide-protocol.ts +38 -10
  338. package/src/index.ts +17 -17
  339. package/src/installation-admin-protocol.ts +12 -9
  340. package/src/license-protocol.ts +13 -7
  341. package/src/messaging/browser/connection.ts +45 -47
  342. package/src/messaging/browser/window-connection.ts +40 -30
  343. package/src/messaging/client-call-metrics.ts +79 -82
  344. package/src/messaging/error.ts +30 -8
  345. package/src/messaging/handler.ts +6 -6
  346. package/src/messaging/node/connection.ts +8 -8
  347. package/src/messaging/proxy-factory.ts +23 -30
  348. package/src/oss-allowlist.ts +4 -4
  349. package/src/payment-protocol.ts +3 -3
  350. package/src/permission.ts +21 -32
  351. package/src/plans.ts +241 -190
  352. package/src/protocol.spec.ts +97 -0
  353. package/src/protocol.ts +524 -265
  354. package/src/snapshot-url.spec.ts +10 -8
  355. package/src/snapshot-url.ts +1 -1
  356. package/src/team-subscription-protocol.ts +60 -23
  357. package/src/teams-projects-protocol.ts +36 -12
  358. package/src/typings/globals.ts +5 -5
  359. package/src/usage.ts +85 -0
  360. package/src/util/analytics.ts +47 -43
  361. package/src/util/async-iterator.ts +5 -6
  362. package/src/util/cancelable.ts +4 -4
  363. package/src/util/date-time.ts +9 -9
  364. package/src/util/debug-app.ts +81 -0
  365. package/src/util/deep-partial.ts +1 -1
  366. package/src/util/deferred.ts +7 -7
  367. package/src/util/disposable.ts +3 -6
  368. package/src/util/event.ts +9 -11
  369. package/src/util/garbage-collected-cache.ts +9 -7
  370. package/src/util/generate-workspace-id.spec.ts +27 -17
  371. package/src/util/generate-workspace-id.ts +461 -455
  372. package/src/util/gitpod-cookie.ts +9 -10
  373. package/src/util/gitpod-host-url.spec.ts +41 -14
  374. package/src/util/gitpod-host-url.ts +69 -37
  375. package/src/util/grpc.ts +94 -2
  376. package/src/util/jaeger-client-types.ts +3 -3
  377. package/src/util/logging.spec.ts +23 -0
  378. package/src/util/logging.ts +61 -43
  379. package/src/util/make-link.ts +7 -8
  380. package/src/util/nice-grpc.ts +96 -0
  381. package/src/util/parse-workspace-id.spec.ts +18 -9
  382. package/src/util/parse-workspace-id.ts +6 -7
  383. package/src/util/queue.spec.ts +28 -26
  384. package/src/util/queue.ts +1 -1
  385. package/src/util/repeat.ts +2 -2
  386. package/src/util/semaphore.ts +5 -7
  387. package/src/util/skip-if.ts +10 -7
  388. package/src/util/timeutil.spec.ts +41 -15
  389. package/src/util/timeutil.ts +28 -12
  390. package/src/util/tracing.spec.ts +29 -24
  391. package/src/util/tracing.ts +55 -52
  392. package/src/util/workspace-port-authentication.ts +11 -14
  393. package/src/webhook-event.ts +55 -0
  394. package/src/workspace-class.ts +14 -0
  395. package/src/workspace-cluster.ts +25 -19
  396. package/src/workspace-instance.ts +67 -25
  397. package/src/wsready.ts +11 -4
  398. package/data/builtin-theia-plugins.json +0 -372
  399. package/lib/email-protocol.d.ts +0 -49
  400. package/lib/email-protocol.d.ts.map +0 -1
  401. package/lib/email-protocol.js +0 -28
  402. package/lib/email-protocol.js.map +0 -1
  403. package/lib/theia-plugins.d.ts +0 -11
  404. package/lib/theia-plugins.d.ts.map +0 -1
  405. package/lib/theia-plugins.js +0 -8
  406. package/lib/theia-plugins.js.map +0 -1
  407. package/src/email-protocol.ts +0 -66
  408. package/src/theia-plugins.ts +0 -11
@@ -1,11 +1,12 @@
1
1
  /**
2
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,19 +16,19 @@ export interface LogContext {
15
16
  sessionId?: string;
16
17
  userId?: string;
17
18
  workspaceId?: string;
18
- };
19
+ }
19
20
  export namespace LogContext {
20
- export function from(params : { userId?: string, user?: any, request?: any } ) {
21
+ export function from(params: { userId?: string; user?: any; request?: any }) {
21
22
  return <LogContext>{
22
23
  sessionId: params.request?.requestID,
23
- userId: params.userId || params.user?.id
24
- }
24
+ userId: params.userId || params.user?.id,
25
+ };
25
26
  }
26
27
  }
27
28
 
28
29
  export interface LogPayload {
29
30
  // placeholder to indicate that only dictionary-style objects should be passed as payload
30
- };
31
+ }
31
32
 
32
33
  export namespace log {
33
34
  export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
@@ -97,7 +98,11 @@ export namespace log {
97
98
  /**
98
99
  * Do not use in frontend.
99
100
  */
100
- export function enableJSONLogging(componentArg: string, versionArg: string | undefined, logLevel?: LogrusLogLevel): void {
101
+ export function enableJSONLogging(
102
+ componentArg: string,
103
+ versionArg: string | undefined,
104
+ logLevel?: LogrusLogLevel,
105
+ ): void {
101
106
  component = componentArg;
102
107
  version = versionArg;
103
108
 
@@ -109,16 +114,16 @@ export namespace log {
109
114
 
110
115
  console.error = function (...args: any[]): void {
111
116
  errorLog(true, args);
112
- }
117
+ };
113
118
  console.warn = function (...args: any[]): void {
114
119
  warnLog(true, args);
115
- }
120
+ };
116
121
  console.info = function (...args: any[]): void {
117
122
  infoLog(true, args);
118
- }
123
+ };
119
124
  console.debug = function (...args: any[]): void {
120
125
  debugLog(true, args);
121
- }
126
+ };
122
127
 
123
128
  console.log = console.info;
124
129
  // FIXME wrap also other console methods (e.g. trace())
@@ -154,26 +159,26 @@ type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
154
159
 
155
160
  let errorLog = doErrorLog;
156
161
  function doErrorLog(calledViaConsole: boolean, args: any[]): void {
157
- doLog(calledViaConsole, errorConsoleLog, 'ERROR', args);
162
+ doLog(calledViaConsole, errorConsoleLog, "ERROR", args);
158
163
  }
159
164
 
160
165
  let warnLog = doWarnLog;
161
166
  function doWarnLog(calledViaConsole: boolean, args: any[]): void {
162
- doLog(calledViaConsole, warnConsoleLog, 'WARNING', args);
167
+ doLog(calledViaConsole, warnConsoleLog, "WARNING", args);
163
168
  }
164
169
 
165
170
  let infoLog = doInfoLog;
166
171
  function doInfoLog(calledViaConsole: boolean, args: any[]): void {
167
- doLog(calledViaConsole, infoConsoleLog, 'INFO', args);
172
+ doLog(calledViaConsole, infoConsoleLog, "INFO", args);
168
173
  }
169
174
 
170
175
  let debugLog = doDebugLog;
171
176
  function doDebugLog(calledViaConsole: boolean, args: any[]): void {
172
- doLog(calledViaConsole, debugConsoleLog, 'DEBUG', args);
177
+ doLog(calledViaConsole, debugConsoleLog, "DEBUG", args);
173
178
  }
174
179
 
175
180
  // Ref: https://github.com/sirupsen/logrus#level-logging
176
- export type LogrusLogLevel = keyof (typeof LogrusLogLevels);
181
+ export type LogrusLogLevel = keyof typeof LogrusLogLevels;
177
182
  export const LogrusLogLevels = {
178
183
  trace: true,
179
184
  debug: true,
@@ -182,7 +187,7 @@ export const LogrusLogLevels = {
182
187
  error: true,
183
188
  fatal: true,
184
189
  panic: true,
185
- }
190
+ };
186
191
  export namespace LogrusLogLevel {
187
192
  export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
188
193
  if (lvl === undefined) {
@@ -194,8 +199,7 @@ export namespace LogrusLogLevel {
194
199
  return getLevelArity(lvl) >= getLevelArity(ref);
195
200
  }
196
201
  function getLevelArity(lvl: LogrusLogLevel): number {
197
- return Object.keys(LogrusLogLevels)
198
- .findIndex((l) => l === lvl);
202
+ return Object.keys(LogrusLogLevels).findIndex((l) => l === lvl);
199
203
  }
200
204
  export function getFromEnv(): LogrusLogLevel | undefined {
201
205
  const lvlStr = process.env.LOG_LEVEL;
@@ -203,7 +207,7 @@ export namespace LogrusLogLevel {
203
207
  return undefined;
204
208
  }
205
209
  const lvl = lvlStr as LogrusLogLevel;
206
- const exists = LogrusLogLevels[lvl]
210
+ const exists = LogrusLogLevels[lvl];
207
211
  if (!exists) {
208
212
  return undefined;
209
213
  }
@@ -212,12 +216,12 @@ export namespace LogrusLogLevel {
212
216
  }
213
217
 
214
218
  // Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
215
- type GoogleLogSeverity = 'EMERGENCY' | 'ALERT' | 'CRITICAL' | 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
219
+ type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
216
220
  namespace GoogleLogSeverity {
217
221
  export const isGreaterOrEqualThanWarning = (severity: GoogleLogSeverity) => {
218
222
  switch (severity) {
219
- case 'INFO':
220
- case 'DEBUG':
223
+ case "INFO":
224
+ case "DEBUG":
221
225
  return false;
222
226
  default:
223
227
  return true;
@@ -245,7 +249,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
245
249
  // console.xyz(Error, ...any) / log.xyz(Error) / log.xyz(Error, LogPayload)
246
250
  error = args[0];
247
251
  payloadArgs = args.slice(1);
248
- } else if (typeof args[0] === 'string') {
252
+ } else if (typeof args[0] === "string") {
249
253
  message = args[0];
250
254
  if (args.length < 2 || !(args[1] instanceof Error)) {
251
255
  // console.xyz(string) / console.xyz(string, !Error, ...any) / log.xyz(string) / log.xyz(string, LogPayload)
@@ -265,7 +269,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
265
269
  // log.xyz(LogContext, Error) / log.xyz(LogContext, Error, LogPayload)
266
270
  error = args[1];
267
271
  payloadArgs = args.slice(2);
268
- } else if (typeof args[1] === 'string') {
272
+ } else if (typeof args[1] === "string") {
269
273
  message = args[1];
270
274
  if (args.length < 3 || !(args[2] instanceof Error)) {
271
275
  // log.xyz(LogContext, string) / log.xyz(LogContext, string, LogPayload)
@@ -288,9 +292,14 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
288
292
  }
289
293
  }
290
294
 
291
- function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefined, message: string | undefined,
292
- error: Error | undefined, payloadArgs: any[], calledViaConsole: boolean): string | undefined {
293
-
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 {
294
303
  if (context !== undefined && Object.keys(context).length == 0) {
295
304
  context = undefined;
296
305
  }
@@ -301,33 +310,40 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
301
310
  }
302
311
 
303
312
  const payload: any = payloadArgs.length == 0 ? undefined : payloadArgs.length == 1 ? payloadArgs[0] : payloadArgs;
304
- const logItem: any = {
313
+ const logItem = {
305
314
  // undefined fields get eliminated in JSON.stringify()
306
315
  ...reportedErrorEvent,
307
316
  component,
308
317
  severity,
309
318
  time: new Date().toISOString(),
310
- environment: process.env.KUBE_STAGE,
311
319
  context,
312
320
  message,
313
321
  error,
314
322
  payload,
315
- loggedViaConsole: calledViaConsole ? true : undefined
323
+ loggedViaConsole: calledViaConsole ? true : undefined,
316
324
  };
325
+ if (plainLogging) {
326
+ return `[${logItem.severity}] [${logItem.component}] ${logItem.message}
327
+ ${JSON.stringify(payload || "", undefined, " ")}
328
+ ${error || ""}
329
+ `.trim();
330
+ }
317
331
  let result: string = stringifyLogItem(logItem);
318
332
 
319
333
  if (result.length > maxAllowedLogItemLength && payload !== undefined) {
320
334
  delete logItem.payload;
321
- 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`;
322
338
 
323
339
  result = stringifyLogItem(logItem);
324
340
 
325
341
  if (result.length <= maxAllowedLogItemLength) {
326
- log.warn('Log item too large, stripping payload', { logItemStub: makeLogItemStub(logItem) });
342
+ log.warn("Log item too large, stripping payload", { logItemStub: makeLogItemStub(logItem) });
327
343
  }
328
344
  }
329
345
  if (result.length > maxAllowedLogItemLength) {
330
- 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) });
331
347
  return undefined;
332
348
  }
333
349
 
@@ -341,10 +357,10 @@ function makeReportedErrorEvent(error: Error | undefined) {
341
357
  // Serves as marker only
342
358
  "@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
343
359
  // This is useful for filtering in the UI
344
- "serviceContext": {
345
- "service": component || "<ts-not-set>",
346
- "version": version || "<ts-not-set>",
347
- }
360
+ serviceContext: {
361
+ service: component || "<ts-not-set>",
362
+ version: version || "<ts-not-set>",
363
+ },
348
364
  };
349
365
 
350
366
  if (error) {
@@ -364,9 +380,9 @@ function makeLogItemStub(logItem: any): any {
364
380
  severity: logItem.severity,
365
381
  time: logItem.time,
366
382
  environment: logItem.environment,
367
- region: logItem.region
383
+ region: logItem.region,
368
384
  };
369
- if (typeof (logItem.message) === 'string') {
385
+ if (typeof logItem.message === "string") {
370
386
  if (logItem.message.length <= maxMessageStubLength) {
371
387
  result.message = logItem.message;
372
388
  } else {
@@ -400,10 +416,12 @@ function stringifyLogItem(logItem: any): string {
400
416
  * Jsonifies Errors properly, not as {} only.
401
417
  */
402
418
  function jsonStringifyWithErrors(value: any): string {
403
- 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
+ });
404
422
  }
405
423
 
406
- type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
424
+ type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
407
425
  const logConsoleLog: ConsoleLog = console.log;
408
426
  const errorConsoleLog: ConsoleLog = console.error;
409
427
  const warnConsoleLog: ConsoleLog = console.warn;
@@ -1,22 +1,21 @@
1
1
  /**
2
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,17 +1,20 @@
1
1
  /**
2
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 { matchesInstanceIdOrLegacyWorkspaceIdExactly, matchesNewWorkspaceIdExactly, 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() {
16
19
  const actual = parseWorkspaceIdFromHostname("moccasin-ferret-155799b3.ws-eu01.gitpod.io");
17
20
  expect(actual).to.equal("moccasin-ferret-155799b3");
@@ -28,7 +31,9 @@ export class ParseWorkspaceIdTest {
28
31
  }
29
32
 
30
33
  @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
31
- const actual = parseWorkspaceIdFromHostname("webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com");
34
+ const actual = parseWorkspaceIdFromHostname(
35
+ "webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com",
36
+ );
32
37
  expect(actual).to.equal("moccasin-ferret-155799b3");
33
38
  }
34
39
 
@@ -44,12 +49,16 @@ export class ParseWorkspaceIdTest {
44
49
  }
45
50
 
46
51
  @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
47
- const actual = parseWorkspaceIdFromHostname("webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
52
+ const actual = parseWorkspaceIdFromHostname(
53
+ "webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io",
54
+ );
48
55
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
49
56
  }
50
57
 
51
58
  @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
52
- const actual = parseWorkspaceIdFromHostname("webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com");
59
+ const actual = parseWorkspaceIdFromHostname(
60
+ "webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com",
61
+ );
53
62
  expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
54
63
  }
55
64
 
@@ -73,4 +82,4 @@ export class ParseWorkspaceIdTest {
73
82
  expect(actual).to.be.false;
74
83
  }
75
84
  }
76
- module.exports = new ParseWorkspaceIdTest()
85
+ module.exports = new ParseWorkspaceIdTest();
@@ -1,7 +1,7 @@
1
1
  /**
2
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
  const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
@@ -20,7 +20,7 @@ const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_I
20
20
  * - webview-1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io (or any other string replacing webview)
21
21
  * @param hostname The hostname the request is headed to
22
22
  */
23
- export const parseWorkspaceIdFromHostname = function(hostname: string) {
23
+ export const parseWorkspaceIdFromHostname = function (hostname: string) {
24
24
  const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
25
25
  if (match && match.length >= 2) {
26
26
  return match[1];
@@ -41,15 +41,14 @@ const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
41
41
  * @param maybeId
42
42
  * @returns
43
43
  */
44
- export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function(maybeId: string): boolean {
45
- return REGEX_INSTANCE_ID_EXACT.test(maybeId)
46
- || REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
44
+ export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function (maybeId: string): boolean {
45
+ return REGEX_INSTANCE_ID_EXACT.test(maybeId) || REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
47
46
  };
48
47
 
49
48
  /**
50
49
  * @param maybeWorkspaceId
51
50
  * @returns
52
51
  */
53
- export const matchesNewWorkspaceIdExactly = function(maybeWorkspaceId: string): boolean {
52
+ export const matchesNewWorkspaceIdExactly = function (maybeWorkspaceId: string): boolean {
54
53
  return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
55
- };
54
+ };
@@ -1,22 +1,22 @@
1
1
  /**
2
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 { suite, test, slow, timeout } from 'mocha-typescript'
8
- import * as chai from 'chai'
9
- const chaiSubset = require('chai-subset');
7
+ import { suite, test, slow, timeout } from "mocha-typescript";
8
+ import * as chai from "chai";
9
+ const chaiSubset = require("chai-subset");
10
10
  chai.use(chaiSubset);
11
11
 
12
- import { Queue } from '..';
13
- import { fail } from 'assert';
14
- import { Deferred } from './deferred';
12
+ import { Queue } from "..";
13
+ import { fail } from "assert";
14
+ import { Deferred } from "./deferred";
15
15
 
16
- const expect = chai.expect
17
-
18
- @suite class QueueSpec {
16
+ const expect = chai.expect;
19
17
 
18
+ @suite
19
+ class QueueSpec {
20
20
  queue: Queue;
21
21
  seq: number[];
22
22
 
@@ -35,8 +35,7 @@ const expect = chai.expect
35
35
  resolve(undefined);
36
36
  }, sleep);
37
37
  });
38
- else
39
- this.seq.push(seqNr);
38
+ else this.seq.push(seqNr);
40
39
  };
41
40
 
42
41
  if (nextTick)
@@ -45,20 +44,22 @@ const expect = chai.expect
45
44
  push().then(resolve);
46
45
  });
47
46
  });
48
- else
49
- await push();
47
+ else await push();
50
48
  });
51
49
  }
52
50
  execError(seqNr: number): Deferred<boolean> {
53
51
  const deferred = new Deferred<boolean>();
54
- this.queue.enqueue(async () => {
55
- this.seq.push(seqNr);
56
- throw new Error('test error');
57
- }).then(() => {
58
- deferred.reject(false);
59
- }).catch(() => {
60
- deferred.resolve(true);
61
- });
52
+ this.queue
53
+ .enqueue(async () => {
54
+ this.seq.push(seqNr);
55
+ throw new Error("test error");
56
+ })
57
+ .then(() => {
58
+ deferred.reject(false);
59
+ })
60
+ .catch(() => {
61
+ deferred.resolve(true);
62
+ });
62
63
 
63
64
  return deferred;
64
65
  }
@@ -67,7 +68,9 @@ const expect = chai.expect
67
68
  expect(actual).to.have.lengthOf(expected.length);
68
69
  const expIt = expected.entries();
69
70
  for (const act of actual) {
70
- const { value: [, exp] } = expIt.next();
71
+ const {
72
+ value: [, exp],
73
+ } = expIt.next();
71
74
  expect(act).to.deep.equal(exp);
72
75
  }
73
76
  }
@@ -93,7 +96,6 @@ const expect = chai.expect
93
96
  this.expectArray(this.seq, [1, 2]);
94
97
  }
95
98
 
96
-
97
99
  @test public async continueDespiteError() {
98
100
  this.exec(1);
99
101
  const receivedError = this.execError(2);
@@ -107,7 +109,7 @@ const expect = chai.expect
107
109
  @test public async mustCatchError() {
108
110
  const f = async () => {
109
111
  throw new Error();
110
- }
112
+ };
111
113
  try {
112
114
  const p = this.queue.enqueue(async () => {
113
115
  return f();
@@ -124,7 +126,7 @@ const expect = chai.expect
124
126
  @test public async expectUncaughtError() {
125
127
  const f = async () => {
126
128
  throw new Error();
127
- }
129
+ };
128
130
  const p = this.queue.enqueue(async () => {
129
131
  return f();
130
132
  });
package/src/util/queue.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
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
  import { Deferred } from "./deferred";
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Copyright (c) 2021 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
  import { Disposable } from "..";
@@ -42,4 +42,4 @@ export function repeat(op: () => Promise<void> | void, everyMilliseconds: number
42
42
  clearTimeout(timer);
43
43
  }
44
44
  });
45
- }
45
+ }
@@ -1,22 +1,21 @@
1
1
  /**
2
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
-
8
7
  export class Semaphore {
9
8
  protected queue: (() => void)[] = [];
10
9
  protected used: number;
11
10
 
12
11
  constructor(protected readonly capacity: number) {
13
- if(capacity < 1) {
12
+ if (capacity < 1) {
14
13
  throw new Error("Capacity cannot be less than 1");
15
14
  }
16
15
  }
17
16
 
18
17
  public release() {
19
- if(this.used == 0) return;
18
+ if (this.used == 0) return;
20
19
 
21
20
  const queued = this.queue.shift();
22
21
  if (queued) {
@@ -28,7 +27,7 @@ export class Semaphore {
28
27
 
29
28
  public async acquire(): Promise<void> {
30
29
  this.used++;
31
- if(this.used <= this.capacity) {
30
+ if (this.used <= this.capacity) {
32
31
  return Promise.resolve();
33
32
  }
34
33
 
@@ -36,5 +35,4 @@ export class Semaphore {
36
35
  this.queue.push(rs);
37
36
  });
38
37
  }
39
-
40
- }
38
+ }