@gitpod/gitpod-protocol 0.1.5-ps-commit-email-fork.0 → 0.1.5-release-2022.6.1.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 (375) hide show
  1. package/data/gitpod-schema.json +206 -28
  2. package/lib/accounting-protocol.d.ts +17 -13
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +39 -47
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +21 -4
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  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/auth.d.ts.map +1 -1
  15. package/lib/context-url.d.ts +31 -0
  16. package/lib/context-url.d.ts.map +1 -0
  17. package/lib/context-url.js +102 -0
  18. package/lib/context-url.js.map +1 -0
  19. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +4 -0
  20. package/lib/context-url.spec.d.ts.map +1 -0
  21. package/lib/context-url.spec.js +109 -0
  22. package/lib/context-url.spec.js.map +1 -0
  23. package/lib/email-protocol.d.ts +1 -2
  24. package/lib/email-protocol.d.ts.map +1 -1
  25. package/lib/email-protocol.js +4 -4
  26. package/lib/email-protocol.js.map +1 -1
  27. package/lib/encryption/container-module.d.ts.map +1 -1
  28. package/lib/encryption/container-module.js +4 -4
  29. package/lib/encryption/container-module.js.map +1 -1
  30. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  31. package/lib/encryption/encryption-engine.js +25 -26
  32. package/lib/encryption/encryption-engine.js.map +1 -1
  33. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  34. package/lib/encryption/encryption-engine.spec.js +29 -37
  35. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  36. package/lib/encryption/encryption-service.d.ts.map +1 -1
  37. package/lib/encryption/encryption-service.js +30 -44
  38. package/lib/encryption/encryption-service.js.map +1 -1
  39. package/lib/encryption/key-provider.d.ts.map +1 -1
  40. package/lib/encryption/key-provider.js +31 -38
  41. package/lib/encryption/key-provider.js.map +1 -1
  42. package/lib/env.d.ts +0 -6
  43. package/lib/env.d.ts.map +1 -1
  44. package/lib/env.js +7 -27
  45. package/lib/env.js.map +1 -1
  46. package/lib/experiments/always-default.d.ts +8 -0
  47. package/lib/experiments/always-default.d.ts.map +1 -0
  48. package/lib/experiments/always-default.js +20 -0
  49. package/lib/experiments/always-default.js.map +1 -0
  50. package/lib/experiments/configcat-server.d.ts +8 -0
  51. package/lib/experiments/configcat-server.d.ts.map +1 -0
  52. package/lib/experiments/configcat-server.js +34 -0
  53. package/lib/experiments/configcat-server.js.map +1 -0
  54. package/lib/experiments/configcat.d.ts +21 -0
  55. package/lib/experiments/configcat.d.ts.map +1 -0
  56. package/lib/experiments/configcat.js +47 -0
  57. package/lib/experiments/configcat.js.map +1 -0
  58. package/lib/experiments/types.d.ts +19 -0
  59. package/lib/experiments/types.d.ts.map +1 -0
  60. package/lib/{util/without.js → experiments/types.js} +2 -2
  61. package/lib/experiments/types.js.map +1 -0
  62. package/lib/gitpod-file-parser.d.ts.map +1 -1
  63. package/lib/gitpod-file-parser.js +26 -42
  64. package/lib/gitpod-file-parser.js.map +1 -1
  65. package/lib/gitpod-file-parser.spec.js +145 -142
  66. package/lib/gitpod-file-parser.spec.js.map +1 -1
  67. package/lib/gitpod-service.d.ts +140 -38
  68. package/lib/gitpod-service.d.ts.map +1 -1
  69. package/lib/gitpod-service.js +181 -317
  70. package/lib/gitpod-service.js.map +1 -1
  71. package/lib/headless-workspace-log.d.ts +9 -11
  72. package/lib/headless-workspace-log.d.ts.map +1 -1
  73. package/lib/headless-workspace-log.js +6 -8
  74. package/lib/headless-workspace-log.js.map +1 -1
  75. package/lib/ide-frontend-service.d.ts +1 -1
  76. package/lib/ide-protocol.d.ts +105 -0
  77. package/lib/ide-protocol.d.ts.map +1 -0
  78. package/lib/ide-protocol.js +8 -0
  79. package/lib/ide-protocol.js.map +1 -0
  80. package/lib/index.d.ts +16 -10
  81. package/lib/index.d.ts.map +1 -1
  82. package/lib/index.js +6 -0
  83. package/lib/index.js.map +1 -1
  84. package/lib/installation-admin-protocol.d.ts +30 -0
  85. package/lib/installation-admin-protocol.d.ts.map +1 -0
  86. package/lib/installation-admin-protocol.js +31 -0
  87. package/lib/installation-admin-protocol.js.map +1 -0
  88. package/lib/license-protocol.d.ts +7 -0
  89. package/lib/license-protocol.d.ts.map +1 -1
  90. package/lib/license-protocol.js.map +1 -1
  91. package/lib/messaging/browser/connection.d.ts +3 -3
  92. package/lib/messaging/browser/connection.d.ts.map +1 -1
  93. package/lib/messaging/browser/connection.js +173 -36
  94. package/lib/messaging/browser/connection.js.map +1 -1
  95. package/lib/messaging/browser/window-connection.d.ts +4 -4
  96. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  97. package/lib/messaging/browser/window-connection.js +42 -59
  98. package/lib/messaging/browser/window-connection.js.map +1 -1
  99. package/lib/messaging/client-call-metrics.d.ts +35 -0
  100. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  101. package/lib/messaging/client-call-metrics.js +83 -0
  102. package/lib/messaging/client-call-metrics.js.map +1 -0
  103. package/lib/messaging/error.d.ts +5 -1
  104. package/lib/messaging/error.d.ts.map +1 -1
  105. package/lib/messaging/error.js +10 -2
  106. package/lib/messaging/error.js.map +1 -1
  107. package/lib/messaging/handler.d.ts +10 -0
  108. package/lib/messaging/handler.d.ts.map +1 -1
  109. package/lib/messaging/handler.js +1 -1
  110. package/lib/messaging/node/connection.d.ts +1 -17
  111. package/lib/messaging/node/connection.d.ts.map +1 -1
  112. package/lib/messaging/node/connection.js +24 -60
  113. package/lib/messaging/node/connection.js.map +1 -1
  114. package/lib/messaging/proxy-factory.d.ts +3 -1
  115. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  116. package/lib/messaging/proxy-factory.js +75 -162
  117. package/lib/messaging/proxy-factory.js.map +1 -1
  118. package/lib/oss-allowlist.d.ts +14 -0
  119. package/lib/oss-allowlist.d.ts.map +1 -0
  120. package/lib/oss-allowlist.js +8 -0
  121. package/lib/oss-allowlist.js.map +1 -0
  122. package/lib/payment-protocol.d.ts.map +1 -1
  123. package/lib/payment-protocol.js +1 -1
  124. package/lib/payment-protocol.js.map +1 -1
  125. package/lib/permission.d.ts +10 -3
  126. package/lib/permission.d.ts.map +1 -1
  127. package/lib/permission.js +41 -31
  128. package/lib/permission.js.map +1 -1
  129. package/lib/plans.d.ts +4 -4
  130. package/lib/plans.d.ts.map +1 -1
  131. package/lib/plans.js +225 -209
  132. package/lib/plans.js.map +1 -1
  133. package/lib/protocol.d.ts +172 -85
  134. package/lib/protocol.d.ts.map +1 -1
  135. package/lib/protocol.js +230 -187
  136. package/lib/protocol.js.map +1 -1
  137. package/lib/snapshot-url.d.ts +14 -0
  138. package/lib/snapshot-url.d.ts.map +1 -0
  139. package/lib/snapshot-url.js +26 -0
  140. package/lib/snapshot-url.js.map +1 -0
  141. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  142. package/lib/snapshot-url.spec.d.ts.map +1 -0
  143. package/lib/snapshot-url.spec.js +41 -0
  144. package/lib/snapshot-url.spec.js.map +1 -0
  145. package/lib/team-subscription-protocol.d.ts +22 -4
  146. package/lib/team-subscription-protocol.d.ts.map +1 -1
  147. package/lib/team-subscription-protocol.js +31 -17
  148. package/lib/team-subscription-protocol.js.map +1 -1
  149. package/lib/teams-projects-protocol.d.ts +118 -0
  150. package/lib/teams-projects-protocol.d.ts.map +1 -0
  151. package/lib/teams-projects-protocol.js +30 -0
  152. package/lib/teams-projects-protocol.js.map +1 -0
  153. package/lib/typings/globals.d.ts +2 -2
  154. package/lib/typings/globals.d.ts.map +1 -1
  155. package/lib/util/analytics.d.ts +8 -0
  156. package/lib/util/analytics.d.ts.map +1 -0
  157. package/lib/util/analytics.js +88 -0
  158. package/lib/util/analytics.js.map +1 -0
  159. package/lib/util/async-iterator.d.ts.map +1 -1
  160. package/lib/util/async-iterator.js +57 -135
  161. package/lib/util/async-iterator.js.map +1 -1
  162. package/lib/util/cancelable.js +17 -59
  163. package/lib/util/cancelable.js.map +1 -1
  164. package/lib/util/date-time.js +11 -11
  165. package/lib/util/date-time.js.map +1 -1
  166. package/lib/util/debug-app.d.ts +25 -0
  167. package/lib/util/debug-app.d.ts.map +1 -0
  168. package/lib/util/debug-app.js +100 -0
  169. package/lib/util/debug-app.js.map +1 -0
  170. package/lib/util/deferred.js +10 -12
  171. package/lib/util/deferred.js.map +1 -1
  172. package/lib/util/disposable.d.ts.map +1 -1
  173. package/lib/util/disposable.js +27 -40
  174. package/lib/util/disposable.js.map +1 -1
  175. package/lib/util/event.d.ts.map +1 -1
  176. package/lib/util/event.js +63 -77
  177. package/lib/util/event.js.map +1 -1
  178. package/lib/util/garbage-collected-cache.d.ts +1 -0
  179. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  180. package/lib/util/garbage-collected-cache.js +27 -47
  181. package/lib/util/garbage-collected-cache.js.map +1 -1
  182. package/lib/util/generate-workspace-id.d.ts +6 -1
  183. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  184. package/lib/util/generate-workspace-id.js +469 -502
  185. package/lib/util/generate-workspace-id.js.map +1 -1
  186. package/lib/util/generate-workspace-id.spec.js +68 -78
  187. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  188. package/lib/util/gitpod-cookie.d.ts +20 -0
  189. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  190. package/lib/util/gitpod-cookie.js +41 -0
  191. package/lib/util/gitpod-cookie.js.map +1 -0
  192. package/lib/util/gitpod-host-url.d.ts +1 -2
  193. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  194. package/lib/util/gitpod-host-url.js +108 -109
  195. package/lib/util/gitpod-host-url.js.map +1 -1
  196. package/lib/util/gitpod-host-url.spec.d.ts +6 -0
  197. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  198. package/lib/util/gitpod-host-url.spec.js +112 -30
  199. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  200. package/lib/util/grpc.d.ts +15 -0
  201. package/lib/util/grpc.d.ts.map +1 -0
  202. package/lib/util/grpc.js +18 -0
  203. package/lib/util/grpc.js.map +1 -0
  204. package/lib/util/jaeger-client-types.d.ts +68 -0
  205. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  206. package/lib/{theia-plugins.js → util/jaeger-client-types.js} +1 -1
  207. package/lib/util/jaeger-client-types.js.map +1 -0
  208. package/lib/util/logging.d.ts +49 -33
  209. package/lib/util/logging.d.ts.map +1 -1
  210. package/lib/util/logging.js +125 -129
  211. package/lib/util/logging.js.map +1 -1
  212. package/lib/util/make-link.js +5 -5
  213. package/lib/util/make-link.js.map +1 -1
  214. package/lib/util/parse-workspace-id.d.ts +10 -0
  215. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  216. package/lib/util/parse-workspace-id.js +30 -7
  217. package/lib/util/parse-workspace-id.js.map +1 -1
  218. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  219. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  220. package/lib/util/parse-workspace-id.spec.js +123 -84
  221. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  222. package/lib/util/queue.js +16 -55
  223. package/lib/util/queue.js.map +1 -1
  224. package/lib/util/queue.spec.js +147 -288
  225. package/lib/util/queue.spec.js.map +1 -1
  226. package/lib/util/repeat.d.ts +15 -0
  227. package/lib/util/repeat.d.ts.map +1 -0
  228. package/lib/util/repeat.js +55 -0
  229. package/lib/util/repeat.js.map +1 -0
  230. package/lib/util/semaphore.d.ts.map +1 -1
  231. package/lib/util/semaphore.js +15 -46
  232. package/lib/util/semaphore.js.map +1 -1
  233. package/lib/util/skip-if.d.ts.map +1 -1
  234. package/lib/util/skip-if.js +6 -6
  235. package/lib/util/skip-if.js.map +1 -1
  236. package/lib/util/timeutil.d.ts +1 -0
  237. package/lib/util/timeutil.d.ts.map +1 -1
  238. package/lib/util/timeutil.js +23 -17
  239. package/lib/util/timeutil.js.map +1 -1
  240. package/lib/util/timeutil.spec.d.ts.map +1 -1
  241. package/lib/util/timeutil.spec.js +21 -24
  242. package/lib/util/timeutil.spec.js.map +1 -1
  243. package/lib/util/tracing.d.ts +52 -6
  244. package/lib/util/tracing.d.ts.map +1 -1
  245. package/lib/util/tracing.js +197 -64
  246. package/lib/util/tracing.js.map +1 -1
  247. package/lib/util/tracing.spec.d.ts +7 -0
  248. package/lib/util/tracing.spec.d.ts.map +1 -0
  249. package/lib/util/tracing.spec.js +121 -0
  250. package/lib/util/tracing.spec.js.map +1 -0
  251. package/lib/util/workspace-port-authentication.d.ts +7 -7
  252. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  253. package/lib/util/workspace-port-authentication.js +9 -12
  254. package/lib/util/workspace-port-authentication.js.map +1 -1
  255. package/lib/workspace-cluster.d.ts +24 -3
  256. package/lib/workspace-cluster.d.ts.map +1 -1
  257. package/lib/workspace-cluster.js +19 -4
  258. package/lib/workspace-cluster.js.map +1 -1
  259. package/lib/workspace-instance.d.ts +42 -5
  260. package/lib/workspace-instance.d.ts.map +1 -1
  261. package/lib/wsready.d.ts +1 -1
  262. package/lib/wsready.d.ts.map +1 -1
  263. package/lib/wsready.js +2 -2
  264. package/lib/wsready.js.map +1 -1
  265. package/package.json +35 -18
  266. package/pkg-yarn.lock +20 -10
  267. package/provenance-bundle.jsonl +2 -0
  268. package/src/accounting-protocol.ts +63 -57
  269. package/src/admin-protocol.ts +43 -21
  270. package/src/analytics.ts +52 -0
  271. package/src/auth.ts +2 -2
  272. package/src/context-url.spec.ts +67 -0
  273. package/src/context-url.ts +109 -0
  274. package/src/email-protocol.ts +5 -7
  275. package/src/encryption/container-module.ts +2 -3
  276. package/src/encryption/encryption-engine.spec.ts +9 -8
  277. package/src/encryption/encryption-engine.ts +14 -14
  278. package/src/encryption/encryption-service.ts +4 -5
  279. package/src/encryption/key-provider.ts +16 -19
  280. package/src/env.ts +0 -22
  281. package/src/experiments/always-default.ts +24 -0
  282. package/src/experiments/configcat-server.ts +37 -0
  283. package/src/experiments/configcat.ts +53 -0
  284. package/src/experiments/types.ts +32 -0
  285. package/src/gitpod-file-parser.spec.ts +55 -61
  286. package/src/gitpod-file-parser.ts +16 -17
  287. package/src/gitpod-service.ts +278 -127
  288. package/src/headless-workspace-log.ts +12 -14
  289. package/src/ide-frontend-service.ts +2 -2
  290. package/src/ide-protocol.ts +119 -0
  291. package/src/index.ts +16 -10
  292. package/src/installation-admin-protocol.ts +45 -0
  293. package/src/license-protocol.ts +12 -6
  294. package/src/messaging/browser/connection.ts +185 -21
  295. package/src/messaging/browser/window-connection.ts +39 -29
  296. package/src/messaging/client-call-metrics.ts +96 -0
  297. package/src/messaging/error.ts +15 -5
  298. package/src/messaging/handler.ts +13 -1
  299. package/src/messaging/node/connection.ts +23 -70
  300. package/src/messaging/proxy-factory.ts +35 -34
  301. package/src/oss-allowlist.ts +15 -0
  302. package/src/payment-protocol.ts +2 -2
  303. package/src/permission.ts +42 -33
  304. package/src/plans.ts +236 -189
  305. package/src/protocol.ts +454 -276
  306. package/src/snapshot-url.spec.ts +27 -0
  307. package/src/snapshot-url.ts +27 -0
  308. package/src/team-subscription-protocol.ts +59 -23
  309. package/src/teams-projects-protocol.ts +153 -0
  310. package/src/typings/globals.ts +4 -4
  311. package/src/util/analytics.ts +109 -0
  312. package/src/util/async-iterator.ts +4 -5
  313. package/src/util/cancelable.ts +3 -3
  314. package/src/util/date-time.ts +8 -8
  315. package/src/util/debug-app.ts +81 -0
  316. package/src/util/deferred.ts +6 -6
  317. package/src/util/disposable.ts +3 -6
  318. package/src/util/event.ts +9 -11
  319. package/src/util/garbage-collected-cache.ts +9 -6
  320. package/src/util/generate-workspace-id.spec.ts +37 -10
  321. package/src/util/generate-workspace-id.ts +464 -438
  322. package/src/util/gitpod-cookie.ts +38 -0
  323. package/src/util/gitpod-host-url.spec.ts +58 -7
  324. package/src/util/gitpod-host-url.ts +52 -40
  325. package/src/util/grpc.ts +15 -0
  326. package/src/util/jaeger-client-types.ts +102 -0
  327. package/src/util/logging.ts +145 -72
  328. package/src/util/make-link.ts +6 -7
  329. package/src/util/parse-workspace-id.spec.ts +37 -8
  330. package/src/util/parse-workspace-id.ts +32 -7
  331. package/src/util/queue.spec.ts +27 -25
  332. package/src/util/repeat.ts +45 -0
  333. package/src/util/semaphore.ts +4 -6
  334. package/src/util/skip-if.ts +9 -6
  335. package/src/util/timeutil.spec.ts +14 -15
  336. package/src/util/timeutil.ts +21 -11
  337. package/src/util/tracing.spec.ts +88 -0
  338. package/src/util/tracing.ts +200 -31
  339. package/src/util/workspace-port-authentication.ts +10 -13
  340. package/src/workspace-cluster.ts +34 -7
  341. package/src/workspace-instance.ts +91 -31
  342. package/src/wsready.ts +3 -3
  343. package/data/builtin-theia-plugins.json +0 -372
  344. package/lib/messaging/connection-error-handler.d.ts +0 -27
  345. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  346. package/lib/messaging/connection-error-handler.js +0 -46
  347. package/lib/messaging/connection-error-handler.js.map +0 -1
  348. package/lib/theia-plugins.d.ts +0 -11
  349. package/lib/theia-plugins.d.ts.map +0 -1
  350. package/lib/theia-plugins.js.map +0 -1
  351. package/lib/util/context-url.d.ts +0 -13
  352. package/lib/util/context-url.d.ts.map +0 -1
  353. package/lib/util/context-url.js +0 -26
  354. package/lib/util/context-url.js.map +0 -1
  355. package/lib/util/context-url.spec.d.ts.map +0 -1
  356. package/lib/util/context-url.spec.js +0 -52
  357. package/lib/util/context-url.spec.js.map +0 -1
  358. package/lib/util/repeater.d.ts +0 -22
  359. package/lib/util/repeater.d.ts.map +0 -1
  360. package/lib/util/repeater.js +0 -118
  361. package/lib/util/repeater.js.map +0 -1
  362. package/lib/util/safe-promise.d.ts +0 -11
  363. package/lib/util/safe-promise.d.ts.map +0 -1
  364. package/lib/util/safe-promise.js +0 -34
  365. package/lib/util/safe-promise.js.map +0 -1
  366. package/lib/util/without.d.ts +0 -7
  367. package/lib/util/without.d.ts.map +0 -1
  368. package/lib/util/without.js.map +0 -1
  369. package/src/messaging/connection-error-handler.ts +0 -62
  370. package/src/theia-plugins.ts +0 -11
  371. package/src/util/context-url.spec.ts +0 -25
  372. package/src/util/context-url.ts +0 -23
  373. package/src/util/jaeger-client.d.ts +0 -105
  374. package/src/util/repeater.ts +0 -49
  375. package/src/util/safe-promise.ts +0 -26
package/src/util/event.ts CHANGED
@@ -6,13 +6,12 @@
6
6
  */
7
7
 
8
8
  import { Disposable } from "./disposable";
9
- import { log } from './logging';
9
+ import { log } from "./logging";
10
10
 
11
11
  /**
12
12
  * Represents a typed event.
13
13
  */
14
14
  export interface Event<T> {
15
-
16
15
  /**
17
16
  *
18
17
  * @param listener The listener function will be call when the event happens.
@@ -24,12 +23,13 @@ export interface Event<T> {
24
23
  }
25
24
 
26
25
  export namespace Event {
27
- const _disposable = { dispose() { } };
28
- export const None: Event<any> = function () { return _disposable; };
26
+ const _disposable = { dispose() {} };
27
+ export const None: Event<any> = function () {
28
+ return _disposable;
29
+ };
29
30
  }
30
31
 
31
32
  class CallbackList {
32
-
33
33
  private _callbacks: Function[] | undefined;
34
34
  private _contexts: any[] | undefined;
35
35
 
@@ -66,7 +66,7 @@ class CallbackList {
66
66
  }
67
67
 
68
68
  if (foundCallbackWithDifferentContext) {
69
- throw new Error('When adding a listener with a context, you should remove it with the same context');
69
+ throw new Error("When adding a listener with a context, you should remove it with the same context");
70
70
  }
71
71
  }
72
72
 
@@ -105,14 +105,12 @@ export interface EmitterOptions {
105
105
  }
106
106
 
107
107
  export class Emitter<T> {
108
-
109
- private static _noop = function () { };
108
+ private static _noop = function () {};
110
109
 
111
110
  private _event: Event<T>;
112
111
  private _callbacks: CallbackList | undefined;
113
112
 
114
- constructor(private _options?: EmitterOptions) {
115
- }
113
+ constructor(private _options?: EmitterOptions) {}
116
114
 
117
115
  /**
118
116
  * For the public to allow to subscribe
@@ -137,7 +135,7 @@ export class Emitter<T> {
137
135
  if (this._options && this._options.onLastListenerRemove && this._callbacks!.isEmpty()) {
138
136
  this._options.onLastListenerRemove(this);
139
137
  }
140
- }
138
+ },
141
139
  };
142
140
  if (Array.isArray(disposables)) {
143
141
  disposables.push(result);
@@ -4,6 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
+ import { repeat } from "./repeat";
7
8
 
8
9
  interface CacheEntry<T> {
9
10
  key: string;
@@ -14,9 +15,7 @@ interface CacheEntry<T> {
14
15
  export class GarbageCollectedCache<T> {
15
16
  protected readonly store = new Map<string, CacheEntry<T>>();
16
17
 
17
- constructor(
18
- protected readonly defaultMaxAgeSeconds: number,
19
- protected readonly gcIntervalSeconds: number) {
18
+ constructor(protected readonly defaultMaxAgeSeconds: number, protected readonly gcIntervalSeconds: number) {
20
19
  this.regularlyCollectGarbage();
21
20
  }
22
21
 
@@ -41,8 +40,12 @@ export class GarbageCollectedCache<T> {
41
40
  return entry.value;
42
41
  }
43
42
 
43
+ public delete(key: string) {
44
+ this.store.delete(key);
45
+ }
46
+
44
47
  protected regularlyCollectGarbage() {
45
- setInterval(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
48
+ repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
46
49
  }
47
50
 
48
51
  protected collectGarbage() {
@@ -55,6 +58,6 @@ export class GarbageCollectedCache<T> {
55
58
  }
56
59
 
57
60
  protected calcExpiryDate(maxAgeSeconds?: number): number {
58
- return Date.now() + ((maxAgeSeconds || this.defaultMaxAgeSeconds) * 1000);
61
+ return Date.now() + (maxAgeSeconds || this.defaultMaxAgeSeconds) * 1000;
59
62
  }
60
- }
63
+ }
@@ -4,19 +4,19 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { suite, test } from "mocha-typescript"
8
- import * as chai from "chai"
7
+ import { suite, test } from "mocha-typescript";
8
+ import * as chai from "chai";
9
9
  import { generateWorkspaceID, colors, animals } from "./generate-workspace-id";
10
- import { workspaceIDRegex } from "./gitpod-host-url";
10
+ import { GitpodHostUrl } from "./gitpod-host-url";
11
11
 
12
- const expect = chai.expect
13
-
14
- @suite class TestGenerateWorkspaceId {
12
+ const expect = chai.expect;
15
13
 
14
+ @suite
15
+ class TestGenerateWorkspaceId {
16
16
  @test public async testGenerateWorkspaceId() {
17
- for (let i = 0; i < 100; i++) {
18
- const name = await generateWorkspaceID();
19
- expect(workspaceIDRegex.test(name), name).to.be.true;
17
+ for (let i = 0; i < 10; i++) {
18
+ const id = await generateWorkspaceID();
19
+ expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
20
20
  }
21
21
  }
22
22
 
@@ -27,5 +27,32 @@ const expect = chai.expect
27
27
  expect(longestName.length <= 36, `"${longestName}" is longer than 36 chars (${longestName.length})`).to.be.true;
28
28
  }
29
29
 
30
+ @test public async testCustomName() {
31
+ const data = [
32
+ ["foo", "bar", "foo-bar-"],
33
+ ["f", "bar", ".{2,16}-bar-"],
34
+ ["gitpod-io", "gitpod", "gitpodio-gitpod-"],
35
+ ["breatheco-de", "python-flask-api-tutorial", "breathecode-pythonflask-"],
36
+ ["short", "muchlongerthaneleven", "short-muchlongerthanel-"],
37
+ ["muchlongerthaneleven", "short", "muchlongerthanel-short-"],
38
+ [
39
+ 'this is rather long and has some "§$"% special chars',
40
+ "also here pretty long and needs abbreviation",
41
+ "thisisrathe-alsoherepre-",
42
+ ],
43
+ ["UPPER", "CaSe", "upper-case-"],
44
+ [
45
+ "superlongfirstsegment",
46
+ "---------",
47
+ "superlong" /* we don't mantch for the whole first segment, because it has different length depending on the animal that is used to replace the -------*/,
48
+ ],
49
+ ];
50
+ for (const d of data) {
51
+ const id = await generateWorkspaceID(d[0], d[1]);
52
+ expect(id).match(new RegExp("^" + d[2]));
53
+ expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
54
+ expect(id.length <= 36, `"${id}" is longer than 36 chars (${id.length})`).to.be.true;
55
+ }
56
+ }
30
57
  }
31
- module.exports = new TestGenerateWorkspaceId()
58
+ module.exports = new TestGenerateWorkspaceId();