@gitpod/gitpod-protocol 0.1.5-test.8 → 0.1.5-to-new-image.2

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 (365) hide show
  1. package/data/builtin-theia-plugins.json +28 -18
  2. package/data/gitpod-schema.json +34 -19
  3. package/lib/accounting-protocol.d.ts +155 -0
  4. package/lib/accounting-protocol.d.ts.map +1 -0
  5. package/lib/accounting-protocol.js +109 -0
  6. package/lib/accounting-protocol.js.map +1 -0
  7. package/lib/admin-protocol.d.ts +34 -5
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +16 -1
  10. package/lib/admin-protocol.js.map +1 -1
  11. package/lib/analytics.d.ts +44 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/auth.d.ts +25 -0
  16. package/lib/auth.d.ts.map +1 -0
  17. package/lib/auth.js +16 -0
  18. package/lib/auth.js.map +1 -0
  19. package/lib/context-url.d.ts +31 -0
  20. package/lib/context-url.d.ts.map +1 -0
  21. package/lib/context-url.js +102 -0
  22. package/lib/context-url.js.map +1 -0
  23. package/lib/context-url.spec.d.ts +14 -0
  24. package/lib/context-url.spec.d.ts.map +1 -0
  25. package/lib/context-url.spec.js +94 -0
  26. package/lib/context-url.spec.js.map +1 -0
  27. package/lib/email-protocol.d.ts +2 -2
  28. package/lib/email-protocol.d.ts.map +1 -1
  29. package/lib/email-protocol.js +6 -5
  30. package/lib/email-protocol.js.map +1 -1
  31. package/lib/encryption/container-module.d.ts +1 -1
  32. package/lib/encryption/container-module.js +7 -5
  33. package/lib/encryption/container-module.js.map +1 -1
  34. package/lib/encryption/encryption-engine.d.ts +1 -1
  35. package/lib/encryption/encryption-engine.js +21 -21
  36. package/lib/encryption/encryption-engine.js.map +1 -1
  37. package/lib/encryption/encryption-engine.spec.d.ts +2 -2
  38. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  39. package/lib/encryption/encryption-engine.spec.js +31 -37
  40. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  41. package/lib/encryption/encryption-service.d.ts +1 -1
  42. package/lib/encryption/encryption-service.js +31 -44
  43. package/lib/encryption/encryption-service.js.map +1 -1
  44. package/lib/encryption/key-provider.d.ts +2 -2
  45. package/lib/encryption/key-provider.d.ts.map +1 -1
  46. package/lib/encryption/key-provider.js +27 -31
  47. package/lib/encryption/key-provider.js.map +1 -1
  48. package/lib/env.d.ts +2 -3
  49. package/lib/env.d.ts.map +1 -1
  50. package/lib/env.js +21 -21
  51. package/lib/env.js.map +1 -1
  52. package/lib/gitpod-file-parser.d.ts +1 -1
  53. package/lib/gitpod-file-parser.js +27 -42
  54. package/lib/gitpod-file-parser.js.map +1 -1
  55. package/lib/gitpod-file-parser.spec.d.ts +1 -1
  56. package/lib/gitpod-file-parser.spec.js +117 -117
  57. package/lib/gitpod-file-parser.spec.js.map +1 -1
  58. package/lib/gitpod-service.d.ts +213 -35
  59. package/lib/gitpod-service.d.ts.map +1 -1
  60. package/lib/gitpod-service.js +241 -116
  61. package/lib/gitpod-service.js.map +1 -1
  62. package/lib/headless-workspace-log.d.ts +9 -12
  63. package/lib/headless-workspace-log.d.ts.map +1 -1
  64. package/lib/headless-workspace-log.js +5 -7
  65. package/lib/headless-workspace-log.js.map +1 -1
  66. package/lib/ide-frontend-service.d.ts +26 -0
  67. package/lib/ide-frontend-service.d.ts.map +1 -0
  68. package/lib/ide-frontend-service.js +8 -0
  69. package/lib/ide-frontend-service.js.map +1 -0
  70. package/lib/ide-protocol.d.ts +105 -0
  71. package/lib/ide-protocol.d.ts.map +1 -0
  72. package/lib/{util/without.js → ide-protocol.js} +2 -2
  73. package/lib/ide-protocol.js.map +1 -0
  74. package/lib/index.d.ts +7 -1
  75. package/lib/index.d.ts.map +1 -1
  76. package/lib/index.js +27 -12
  77. package/lib/index.js.map +1 -1
  78. package/lib/installation-admin-protocol.d.ts +27 -0
  79. package/lib/installation-admin-protocol.d.ts.map +1 -0
  80. package/lib/installation-admin-protocol.js +30 -0
  81. package/lib/installation-admin-protocol.js.map +1 -0
  82. package/lib/license-protocol.d.ts +1 -1
  83. package/lib/license-protocol.js +2 -1
  84. package/lib/license-protocol.js.map +1 -1
  85. package/lib/messaging/browser/connection.d.ts +6 -4
  86. package/lib/messaging/browser/connection.d.ts.map +1 -1
  87. package/lib/messaging/browser/connection.js +188 -48
  88. package/lib/messaging/browser/connection.js.map +1 -1
  89. package/lib/messaging/browser/window-connection.d.ts +26 -0
  90. package/lib/messaging/browser/window-connection.d.ts.map +1 -0
  91. package/lib/messaging/browser/window-connection.js +68 -0
  92. package/lib/messaging/browser/window-connection.js.map +1 -0
  93. package/lib/messaging/client-call-metrics.d.ts +35 -0
  94. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  95. package/lib/messaging/client-call-metrics.js +83 -0
  96. package/lib/messaging/client-call-metrics.js.map +1 -0
  97. package/lib/messaging/error.d.ts +7 -2
  98. package/lib/messaging/error.d.ts.map +1 -1
  99. package/lib/messaging/error.js +15 -4
  100. package/lib/messaging/error.js.map +1 -1
  101. package/lib/messaging/handler.d.ts +10 -0
  102. package/lib/messaging/handler.d.ts.map +1 -1
  103. package/lib/messaging/handler.js +1 -0
  104. package/lib/messaging/handler.js.map +1 -1
  105. package/lib/messaging/node/connection.d.ts +1 -17
  106. package/lib/messaging/node/connection.d.ts.map +1 -1
  107. package/lib/messaging/node/connection.js +23 -58
  108. package/lib/messaging/node/connection.js.map +1 -1
  109. package/lib/messaging/proxy-factory.d.ts +2 -0
  110. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  111. package/lib/messaging/proxy-factory.js +75 -169
  112. package/lib/messaging/proxy-factory.js.map +1 -1
  113. package/lib/oss-allowlist.d.ts +14 -0
  114. package/lib/oss-allowlist.d.ts.map +1 -0
  115. package/lib/oss-allowlist.js +8 -0
  116. package/lib/oss-allowlist.js.map +1 -0
  117. package/lib/payment-protocol.d.ts +18 -0
  118. package/lib/payment-protocol.d.ts.map +1 -0
  119. package/lib/payment-protocol.js +13 -0
  120. package/lib/payment-protocol.js.map +1 -0
  121. package/lib/permission.d.ts +20 -12
  122. package/lib/permission.d.ts.map +1 -1
  123. package/lib/permission.js +42 -20
  124. package/lib/permission.js.map +1 -1
  125. package/lib/plans.d.ts +210 -0
  126. package/lib/plans.d.ts.map +1 -0
  127. package/lib/plans.js +570 -0
  128. package/lib/plans.js.map +1 -0
  129. package/lib/protocol.d.ts +146 -65
  130. package/lib/protocol.d.ts.map +1 -1
  131. package/lib/protocol.js +134 -118
  132. package/lib/protocol.js.map +1 -1
  133. package/lib/snapshot-url.d.ts +14 -0
  134. package/lib/snapshot-url.d.ts.map +1 -0
  135. package/lib/snapshot-url.js +26 -0
  136. package/lib/snapshot-url.js.map +1 -0
  137. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +3 -4
  138. package/lib/snapshot-url.spec.d.ts.map +1 -0
  139. package/lib/snapshot-url.spec.js +41 -0
  140. package/lib/snapshot-url.spec.js.map +1 -0
  141. package/lib/team-subscription-protocol.d.ts +73 -0
  142. package/lib/team-subscription-protocol.d.ts.map +1 -0
  143. package/lib/team-subscription-protocol.js +63 -0
  144. package/lib/team-subscription-protocol.js.map +1 -0
  145. package/lib/teams-projects-protocol.d.ts +113 -0
  146. package/lib/teams-projects-protocol.d.ts.map +1 -0
  147. package/lib/teams-projects-protocol.js +30 -0
  148. package/lib/teams-projects-protocol.js.map +1 -0
  149. package/lib/theia-plugins.d.ts +1 -1
  150. package/lib/theia-plugins.js +1 -1
  151. package/lib/typings/globals.d.ts +12 -0
  152. package/lib/typings/globals.d.ts.map +1 -0
  153. package/lib/typings/globals.js +7 -0
  154. package/lib/typings/globals.js.map +1 -0
  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 +79 -0
  158. package/lib/util/analytics.js.map +1 -0
  159. package/lib/util/async-iterator.d.ts +1 -1
  160. package/lib/util/async-iterator.js +57 -134
  161. package/lib/util/async-iterator.js.map +1 -1
  162. package/lib/util/cancelable.d.ts +1 -1
  163. package/lib/util/cancelable.js +19 -60
  164. package/lib/util/cancelable.js.map +1 -1
  165. package/lib/util/date-time.d.ts +1 -1
  166. package/lib/util/date-time.js +10 -9
  167. package/lib/util/date-time.js.map +1 -1
  168. package/lib/util/deep-partial.d.ts +1 -1
  169. package/lib/util/deep-partial.js +1 -1
  170. package/lib/util/deferred.d.ts +1 -1
  171. package/lib/util/deferred.js +12 -13
  172. package/lib/util/deferred.js.map +1 -1
  173. package/lib/util/disposable.d.ts +2 -2
  174. package/lib/util/disposable.d.ts.map +1 -1
  175. package/lib/util/disposable.js +27 -39
  176. package/lib/util/disposable.js.map +1 -1
  177. package/lib/util/event.d.ts +1 -1
  178. package/lib/util/event.d.ts.map +1 -1
  179. package/lib/util/event.js +59 -74
  180. package/lib/util/event.js.map +1 -1
  181. package/lib/util/garbage-collected-cache.d.ts +2 -1
  182. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  183. package/lib/util/garbage-collected-cache.js +28 -47
  184. package/lib/util/garbage-collected-cache.js.map +1 -1
  185. package/lib/util/generate-workspace-id.d.ts +4 -0
  186. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  187. package/lib/util/generate-workspace-id.js +487 -0
  188. package/lib/util/generate-workspace-id.js.map +1 -0
  189. package/lib/util/generate-workspace-id.spec.d.ts +7 -0
  190. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  191. package/lib/util/generate-workspace-id.spec.js +87 -0
  192. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  193. package/lib/util/gitpod-cookie.d.ts +20 -0
  194. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  195. package/lib/util/gitpod-cookie.js +44 -0
  196. package/lib/util/gitpod-cookie.js.map +1 -0
  197. package/lib/util/gitpod-host-url.d.ts +8 -4
  198. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  199. package/lib/util/gitpod-host-url.js +103 -76
  200. package/lib/util/gitpod-host-url.js.map +1 -1
  201. package/lib/util/gitpod-host-url.spec.d.ts +16 -0
  202. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
  203. package/lib/util/gitpod-host-url.spec.js +124 -0
  204. package/lib/util/gitpod-host-url.spec.js.map +1 -0
  205. package/lib/util/grpc.d.ts +15 -0
  206. package/lib/util/grpc.d.ts.map +1 -0
  207. package/lib/util/grpc.js +18 -0
  208. package/lib/util/grpc.js.map +1 -0
  209. package/lib/util/jaeger-client-types.d.ts +68 -0
  210. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  211. package/lib/util/jaeger-client-types.js +8 -0
  212. package/lib/util/jaeger-client-types.js.map +1 -0
  213. package/lib/util/logging.d.ts +57 -34
  214. package/lib/util/logging.d.ts.map +1 -1
  215. package/lib/util/logging.js +119 -110
  216. package/lib/util/logging.js.map +1 -1
  217. package/lib/util/make-link.d.ts +1 -1
  218. package/lib/util/make-link.js +4 -3
  219. package/lib/util/make-link.js.map +1 -1
  220. package/lib/util/parse-workspace-id.d.ts +14 -4
  221. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  222. package/lib/util/parse-workspace-id.js +39 -8
  223. package/lib/util/parse-workspace-id.js.map +1 -1
  224. package/lib/util/parse-workspace-id.spec.d.ts +9 -1
  225. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  226. package/lib/util/parse-workspace-id.spec.js +129 -48
  227. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  228. package/lib/util/queue.d.ts +1 -1
  229. package/lib/util/queue.js +18 -56
  230. package/lib/util/queue.js.map +1 -1
  231. package/lib/util/queue.spec.d.ts +1 -1
  232. package/lib/util/queue.spec.js +145 -287
  233. package/lib/util/queue.spec.js.map +1 -1
  234. package/lib/util/repeat.d.ts +15 -0
  235. package/lib/util/repeat.d.ts.map +1 -0
  236. package/lib/util/repeat.js +55 -0
  237. package/lib/util/repeat.js.map +1 -0
  238. package/lib/util/semaphore.d.ts +1 -1
  239. package/lib/util/semaphore.js +17 -47
  240. package/lib/util/semaphore.js.map +1 -1
  241. package/lib/util/skip-if.d.ts +1 -1
  242. package/lib/util/skip-if.js +8 -7
  243. package/lib/util/skip-if.js.map +1 -1
  244. package/lib/util/timeutil.d.ts +1 -1
  245. package/lib/util/timeutil.d.ts.map +1 -1
  246. package/lib/util/timeutil.js +30 -17
  247. package/lib/util/timeutil.js.map +1 -1
  248. package/lib/util/timeutil.spec.d.ts +1 -1
  249. package/lib/util/timeutil.spec.js +23 -25
  250. package/lib/util/timeutil.spec.js.map +1 -1
  251. package/lib/util/tracing.d.ts +52 -6
  252. package/lib/util/tracing.d.ts.map +1 -1
  253. package/lib/util/tracing.js +199 -63
  254. package/lib/util/tracing.js.map +1 -1
  255. package/lib/util/tracing.spec.d.ts +7 -0
  256. package/lib/util/tracing.spec.d.ts.map +1 -0
  257. package/lib/util/tracing.spec.js +121 -0
  258. package/lib/util/tracing.spec.js.map +1 -0
  259. package/lib/util/workspace-port-authentication.d.ts +1 -1
  260. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  261. package/lib/util/workspace-port-authentication.js +5 -3
  262. package/lib/util/workspace-port-authentication.js.map +1 -1
  263. package/lib/workspace-cluster.d.ts +76 -0
  264. package/lib/workspace-cluster.d.ts.map +1 -0
  265. package/lib/workspace-cluster.js +33 -0
  266. package/lib/workspace-cluster.js.map +1 -0
  267. package/lib/workspace-instance.d.ts +29 -4
  268. package/lib/workspace-instance.d.ts.map +1 -1
  269. package/lib/workspace-instance.js +1 -1
  270. package/lib/wsready.d.ts +1 -1
  271. package/lib/wsready.js +3 -2
  272. package/lib/wsready.js.map +1 -1
  273. package/package.json +35 -17
  274. package/pkg-yarn.lock +18 -9
  275. package/provenance-bundle.jsonl +2 -0
  276. package/src/accounting-protocol.ts +229 -0
  277. package/src/admin-protocol.ts +56 -6
  278. package/src/analytics.ts +52 -0
  279. package/src/auth.ts +27 -0
  280. package/src/context-url.spec.ts +53 -0
  281. package/src/context-url.ts +107 -0
  282. package/src/email-protocol.ts +3 -4
  283. package/src/encryption/container-module.ts +1 -1
  284. package/src/encryption/encryption-engine.spec.ts +1 -1
  285. package/src/encryption/encryption-engine.ts +1 -1
  286. package/src/encryption/encryption-service.ts +1 -1
  287. package/src/encryption/key-provider.ts +1 -1
  288. package/src/env.ts +11 -11
  289. package/src/gitpod-file-parser.spec.ts +1 -1
  290. package/src/gitpod-file-parser.ts +1 -1
  291. package/src/gitpod-service.ts +420 -56
  292. package/src/headless-workspace-log.ts +8 -12
  293. package/src/ide-frontend-service.ts +28 -0
  294. package/src/ide-protocol.ts +119 -0
  295. package/src/index.ts +8 -2
  296. package/src/installation-admin-protocol.ts +42 -0
  297. package/src/license-protocol.ts +1 -1
  298. package/src/messaging/browser/connection.ts +201 -23
  299. package/src/messaging/browser/window-connection.ts +72 -0
  300. package/src/messaging/client-call-metrics.ts +97 -0
  301. package/src/messaging/error.ts +19 -4
  302. package/src/messaging/handler.ts +12 -0
  303. package/src/messaging/node/connection.ts +21 -68
  304. package/src/messaging/proxy-factory.ts +16 -14
  305. package/src/oss-allowlist.ts +15 -0
  306. package/src/payment-protocol.ts +20 -0
  307. package/src/permission.ts +31 -11
  308. package/src/plans.ts +632 -0
  309. package/src/protocol.ts +243 -99
  310. package/src/snapshot-url.spec.ts +25 -0
  311. package/src/snapshot-url.ts +27 -0
  312. package/src/team-subscription-protocol.ts +113 -0
  313. package/src/teams-projects-protocol.ts +147 -0
  314. package/src/theia-plugins.ts +1 -1
  315. package/src/typings/globals.ts +12 -0
  316. package/src/util/analytics.ts +87 -0
  317. package/src/util/async-iterator.ts +1 -1
  318. package/src/util/cancelable.ts +1 -1
  319. package/src/util/date-time.ts +1 -1
  320. package/src/util/deep-partial.ts +1 -1
  321. package/src/util/deferred.ts +2 -2
  322. package/src/util/garbage-collected-cache.ts +10 -4
  323. package/src/util/generate-workspace-id.spec.ts +48 -0
  324. package/src/util/generate-workspace-id.ts +475 -0
  325. package/src/util/gitpod-cookie.ts +39 -0
  326. package/src/util/gitpod-host-url.spec.ts +49 -0
  327. package/src/util/gitpod-host-url.ts +56 -16
  328. package/src/util/grpc.ts +15 -0
  329. package/src/util/jaeger-client-types.ts +102 -0
  330. package/src/util/logging.ts +111 -39
  331. package/src/util/make-link.ts +1 -1
  332. package/src/util/parse-workspace-id.spec.ts +46 -5
  333. package/src/util/parse-workspace-id.ts +39 -8
  334. package/src/util/queue.spec.ts +2 -2
  335. package/src/util/queue.ts +1 -1
  336. package/src/util/repeat.ts +45 -0
  337. package/src/util/semaphore.ts +3 -3
  338. package/src/util/skip-if.ts +2 -2
  339. package/src/util/timeutil.spec.ts +1 -1
  340. package/src/util/timeutil.ts +5 -5
  341. package/src/util/tracing.spec.ts +83 -0
  342. package/src/util/tracing.ts +184 -18
  343. package/src/util/workspace-port-authentication.ts +1 -1
  344. package/src/workspace-cluster.ts +104 -0
  345. package/src/workspace-instance.ts +58 -16
  346. package/src/wsready.ts +2 -2
  347. package/lib/messaging/connection-error-handler.d.ts +0 -27
  348. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  349. package/lib/messaging/connection-error-handler.js +0 -45
  350. package/lib/messaging/connection-error-handler.js.map +0 -1
  351. package/lib/util/repeater.d.ts +0 -22
  352. package/lib/util/repeater.d.ts.map +0 -1
  353. package/lib/util/repeater.js +0 -117
  354. package/lib/util/repeater.js.map +0 -1
  355. package/lib/util/safe-promise.d.ts +0 -11
  356. package/lib/util/safe-promise.d.ts.map +0 -1
  357. package/lib/util/safe-promise.js +0 -33
  358. package/lib/util/safe-promise.js.map +0 -1
  359. package/lib/util/without.d.ts +0 -7
  360. package/lib/util/without.d.ts.map +0 -1
  361. package/lib/util/without.js.map +0 -1
  362. package/src/messaging/connection-error-handler.ts +0 -62
  363. package/src/util/jaeger-client.d.ts +0 -105
  364. package/src/util/repeater.ts +0 -49
  365. package/src/util/safe-promise.ts +0 -26
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Copyright (c) 2021 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 { v4 as uuidv4 } from 'uuid';
8
+ import { Subscription } from "./accounting-protocol";
9
+
10
+ export interface TeamSubscription {
11
+ id: string;
12
+ userId: string;
13
+ planId: string;
14
+ startDate: string;
15
+ endDate?: string;
16
+ quantity: number;
17
+ /** The Chargebee subscription id */
18
+ paymentReference: string;
19
+ cancellationDate?: string;
20
+ deleted?: boolean;
21
+ }
22
+
23
+ export namespace TeamSubscription {
24
+ export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
25
+ const withId = ts as TeamSubscription;
26
+ withId.id = uuidv4();
27
+ return withId;
28
+ }
29
+ export const isActive = (ts: TeamSubscription, date: string): boolean => {
30
+ return ts.startDate <= date && (ts.endDate === undefined || date < ts.endDate);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * A slot represents one unit of a TeamSubscription that gets assigned to one user at a time
36
+ */
37
+ export interface TeamSubscriptionSlot {
38
+ id: string;
39
+ teamSubscriptionId: string;
40
+ assigneeId?: string;
41
+ assigneeIdentifier?: AssigneeIdentifier;
42
+ subscriptionId?: string;
43
+ cancellationDate?: string;
44
+ }
45
+ export type TeamSubscriptionSlotDeactivated = TeamSubscriptionSlot & { assigneeId: string, assigneeIdentifier: AssigneeIdentifier };
46
+ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscriptionSlotDeactivated & { subscriptionId: string };
47
+
48
+ export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
49
+
50
+ export namespace TeamSubscriptionSlot {
51
+ export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
52
+ const withId = ts as TeamSubscriptionSlot;
53
+ withId.id = uuidv4();
54
+ return withId;
55
+ }
56
+ export const assign = (slot: TeamSubscriptionSlot, assigneeId: string, subscriptionId: string, assigneeIdentifier: AssigneeIdentifier) => {
57
+ slot.assigneeId = assigneeId;
58
+ slot.subscriptionId = subscriptionId;
59
+ slot.assigneeIdentifier = assigneeIdentifier;
60
+ }
61
+ export const deactivate = (slot: TeamSubscriptionSlot, cancellationDate: string) => {
62
+ slot.subscriptionId = undefined;
63
+ slot.cancellationDate = cancellationDate;
64
+ }
65
+ export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
66
+ slot.subscriptionId = subscriptionId;
67
+ slot.cancellationDate = undefined;
68
+ }
69
+ export const status = (slot: TeamSubscriptionSlot, now: string): TeamSubscriptionSlotState => {
70
+ if (slot.cancellationDate) {
71
+ if (slot.cancellationDate < now) {
72
+ return 'cancelled';
73
+ } else {
74
+ return 'deactivated';
75
+ }
76
+ } else {
77
+ if (slot.subscriptionId) {
78
+ return 'assigned';
79
+ } else {
80
+ return 'unassigned';
81
+ }
82
+ }
83
+
84
+ }
85
+ export const isActive = (slot: TeamSubscriptionSlot): boolean => {
86
+ return !slot.cancellationDate;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * The mapping between a TeamSubscription and a resulting Subscription, resolved
92
+ */
93
+ export interface TeamSubscriptionSlotResolved {
94
+ id: string;
95
+ teamSubscription: TeamSubscription;
96
+ state: TeamSubscriptionSlotState;
97
+ assigneeId?: string;
98
+ assigneeIdentifier?: AssigneeIdentifier;
99
+ subscription?: Subscription;
100
+ cancellationDate?: string;
101
+ hoursLeft?: number;
102
+ }
103
+
104
+ /**
105
+ * Contains the data structure that the assigner used to identify the assignee.
106
+ */
107
+ export type AssigneeIdentifier = AssigneeIdentityIdentifier;
108
+ export interface AssigneeIdentityIdentifier {
109
+ identity: {
110
+ authHost: string,
111
+ authName: string
112
+ }
113
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Copyright (c) 2021 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 { PrebuiltWorkspaceState } from "./protocol";
8
+ import { v4 as uuidv4 } from 'uuid';
9
+ import { DeepPartial } from "./util/deep-partial";
10
+
11
+ export interface ProjectConfig {
12
+ '.gitpod.yml': string;
13
+ }
14
+
15
+ export interface ProjectSettings {
16
+ useIncrementalPrebuilds?: boolean;
17
+ }
18
+
19
+ export interface Project {
20
+ id: string;
21
+ name: string;
22
+ slug?: string;
23
+ cloneUrl: string;
24
+ teamId?: string;
25
+ userId?: string;
26
+ appInstallationId: string;
27
+ config?: ProjectConfig;
28
+ settings?: ProjectSettings;
29
+ creationTime: string;
30
+ /** This is a flag that triggers the HARD DELETION of this entity */
31
+ deleted?: boolean;
32
+ markedDeleted?: boolean;
33
+ }
34
+
35
+ export namespace Project {
36
+ export const create = (project: Omit<Project, 'id' | 'creationTime'>): Project => {
37
+ return {
38
+ ...project,
39
+ id: uuidv4(),
40
+ creationTime: new Date().toISOString()
41
+ };
42
+ }
43
+
44
+ export interface Overview {
45
+ branches: BranchDetails[];
46
+ }
47
+
48
+ export namespace Overview {
49
+ export function is(data?: any): data is Project.Overview {
50
+ return Array.isArray(data?.branches);
51
+ }
52
+ }
53
+
54
+ export interface BranchDetails {
55
+ name: string;
56
+ url: string;
57
+ isDefault: boolean;
58
+
59
+ // Latest commit
60
+ changeTitle: string;
61
+ changeDate?: string;
62
+ changeAuthor?: string;
63
+ changeAuthorAvatar?: string;
64
+ changePR?: string;
65
+ changeUrl?: string;
66
+ changeHash: string;
67
+ }
68
+ }
69
+
70
+ export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
71
+
72
+ export interface PrebuildWithStatus {
73
+ info: PrebuildInfo;
74
+ status: PrebuiltWorkspaceState;
75
+ error?: string;
76
+ }
77
+
78
+ export interface PrebuildInfo {
79
+ id: string;
80
+ buildWorkspaceId: string;
81
+ basedOnPrebuildId?: string;
82
+
83
+ teamId?: string;
84
+ userId?: string;
85
+
86
+ projectId: string;
87
+ projectName: string;
88
+
89
+ cloneUrl: string;
90
+ branch: string;
91
+
92
+ startedAt: string;
93
+ startedBy: string;
94
+ startedByAvatar?: string;
95
+
96
+ changeTitle: string;
97
+ changeDate: string;
98
+ changeAuthor: string;
99
+ changeAuthorAvatar?: string;
100
+ changePR?: string;
101
+ changeUrl?: string;
102
+ changeHash: string;
103
+ }
104
+ export namespace PrebuildInfo {
105
+ export function is(data?: any): data is PrebuildInfo {
106
+ return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every(p => p in data);
107
+ }
108
+ }
109
+
110
+ export interface StartPrebuildResult {
111
+ prebuildId: string;
112
+ wsid: string;
113
+ done: boolean;
114
+ }
115
+
116
+ export interface Team {
117
+ id: string;
118
+ name: string;
119
+ slug: string;
120
+ creationTime: string;
121
+ markedDeleted?: boolean;
122
+ /** This is a flag that triggers the HARD DELETION of this entity */
123
+ deleted?: boolean;
124
+ }
125
+
126
+ export type TeamMemberRole = "owner" | "member";
127
+
128
+ export interface TeamMemberInfo {
129
+ userId: string;
130
+ fullName?: string;
131
+ primaryEmail?: string;
132
+ avatarUrl?: string;
133
+ role: TeamMemberRole;
134
+ memberSince: string;
135
+ }
136
+
137
+ export interface TeamMembershipInvite {
138
+ id: string;
139
+ teamId: string;
140
+ role: TeamMemberRole;
141
+ creationTime: string;
142
+ invalidationTime: string;
143
+ invitedEmail?: string;
144
+
145
+ /** This is a flag that triggers the HARD DELETION of this entity */
146
+ deleted?: boolean;
147
+ }
@@ -1,5 +1,5 @@
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
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) 2020 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
+ interface Window {
8
+ gitpod: {
9
+ service: import('../gitpod-service').GitpodService
10
+ ideService?: import('../ide-frontend-service').IDEFrontendService
11
+ }
12
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Copyright (c) 2021 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 Analytics = require("analytics-node");
8
+ import { IAnalyticsWriter, IdentifyMessage, TrackMessage, PageMessage } from "../analytics";
9
+ import { log } from './logging';
10
+
11
+
12
+ export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
13
+ switch (process.env.GITPOD_ANALYTICS_WRITER) {
14
+ case "segment":
15
+ return new SegmentAnalyticsWriter(process.env.GITPOD_ANALYTICS_SEGMENT_KEY || "");
16
+ case "log":
17
+ return new LogAnalyticsWriter();
18
+ default:
19
+ return new NoAnalyticsWriter();
20
+ }
21
+ }
22
+
23
+ class SegmentAnalyticsWriter implements IAnalyticsWriter {
24
+
25
+ protected readonly analytics: Analytics;
26
+
27
+ constructor(writeKey: string) {
28
+ this.analytics = new Analytics(writeKey);
29
+ }
30
+
31
+ identify(msg: IdentifyMessage) {
32
+ try {
33
+ this.analytics.identify(msg, (err: Error) => {
34
+ if (err) {
35
+ log.warn("analytics.identify failed", err);
36
+ }
37
+ });
38
+ } catch (err) {
39
+ log.warn("analytics.identify failed", err);
40
+ }
41
+ }
42
+
43
+ track(msg: TrackMessage) {
44
+ try {
45
+ this.analytics.track(msg, (err: Error) => {
46
+ if (err) {
47
+ log.warn("analytics.track failed", err);
48
+ }
49
+ });
50
+ } catch (err) {
51
+ log.warn("analytics.track failed", err);
52
+ }
53
+ }
54
+
55
+ page(msg: PageMessage) {
56
+ try{
57
+ this.analytics.page(msg, (err: Error) => {
58
+ if (err) {
59
+ log.warn("analytics.page failed", err);
60
+ }
61
+ });
62
+ } catch (err) {
63
+ log.warn("analytics.page failed", err);
64
+ }
65
+ }
66
+
67
+ }
68
+
69
+ class LogAnalyticsWriter implements IAnalyticsWriter {
70
+
71
+ identify(msg: IdentifyMessage): void {
72
+ log.debug("analytics identify", msg);
73
+ }
74
+ track(msg: TrackMessage): void {
75
+ log.debug("analytics track", msg);
76
+ }
77
+ page(msg: PageMessage): void {
78
+ log.debug("analytics page", msg);
79
+ }
80
+
81
+ }
82
+
83
+ class NoAnalyticsWriter implements IAnalyticsWriter {
84
+ identify(msg: IdentifyMessage): void {}
85
+ track(msg: TrackMessage): void {}
86
+ page(msg: PageMessage): void {}
87
+ }
@@ -1,5 +1,5 @@
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
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,5 +1,5 @@
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
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,5 +1,5 @@
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
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,5 +1,5 @@
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
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -1,5 +1,5 @@
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
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
@@ -19,7 +19,7 @@ export class Deferred<T> {
19
19
  promise = new Promise<T>((resolve, reject) => {
20
20
  this.resolve = (o) => {
21
21
  this.isResolved = true;
22
- resolve(o)
22
+ resolve(o as any)
23
23
  clearTimeout(this.timer)
24
24
  };
25
25
  this.reject = (e) => {
@@ -1,9 +1,11 @@
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
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
+ import { repeat } from "./repeat";
8
+
7
9
 
8
10
  interface CacheEntry<T> {
9
11
  key: string;
@@ -13,13 +15,13 @@ interface CacheEntry<T> {
13
15
 
14
16
  export class GarbageCollectedCache<T> {
15
17
  protected readonly store = new Map<string, CacheEntry<T>>();
16
-
18
+
17
19
  constructor(
18
20
  protected readonly defaultMaxAgeSeconds: number,
19
21
  protected readonly gcIntervalSeconds: number) {
20
22
  this.regularlyCollectGarbage();
21
23
  }
22
-
24
+
23
25
  public set(key: string, value: T) {
24
26
  const oldValue = this.store.get(key);
25
27
  if (oldValue) {
@@ -41,8 +43,12 @@ export class GarbageCollectedCache<T> {
41
43
  return entry.value;
42
44
  }
43
45
 
46
+ public delete(key: string) {
47
+ this.store.delete(key);
48
+ }
49
+
44
50
  protected regularlyCollectGarbage() {
45
- setInterval(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
51
+ repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
46
52
  }
47
53
 
48
54
  protected collectGarbage() {
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright (c) 2020 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 { suite, test } from "mocha-typescript"
8
+ import * as chai from "chai"
9
+ import { generateWorkspaceID, colors, animals } from "./generate-workspace-id";
10
+ import { GitpodHostUrl } from "./gitpod-host-url";
11
+
12
+ const expect = chai.expect
13
+
14
+ @suite class TestGenerateWorkspaceId {
15
+
16
+ @test public async testGenerateWorkspaceId() {
17
+ for (let i = 0; i < 100; i++) {
18
+ const id = await generateWorkspaceID();
19
+ expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
20
+ }
21
+ }
22
+
23
+ @test public testLongestName() {
24
+ const longestColor = colors.sort((a, b) => b.length - a.length)[0];
25
+ const longestAnimal = animals.sort((a, b) => b.length - a.length)[0];
26
+ const longestName = `${longestColor}-${longestAnimal}-12345678`;
27
+ expect(longestName.length <= 36, `"${longestName}" is longer than 36 chars (${longestName.length})`).to.be.true;
28
+ }
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
+ ['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
36
+ ['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
37
+ ['UPPER', "CaSe", "upper-case-"]
38
+ ]
39
+ for (const d of data) {
40
+ const id = await generateWorkspaceID(d[0], d[1]);
41
+ expect(id).match(new RegExp("^"+d[2]));
42
+ expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
43
+ expect(id.length <= 36, `"${id}" is longer than 36 chars (${id.length})`).to.be.true;
44
+ }
45
+ }
46
+
47
+ }
48
+ module.exports = new TestGenerateWorkspaceId()