@gitpod/gitpod-protocol 0.1.5-v0.6.0-beta4 → 0.1.5-vn-6525.75

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 (344) hide show
  1. package/data/gitpod-schema.json +68 -26
  2. package/lib/accounting-protocol.d.ts +155 -0
  3. package/lib/accounting-protocol.d.ts.map +1 -0
  4. package/lib/accounting-protocol.js +100 -0
  5. package/lib/accounting-protocol.js.map +1 -0
  6. package/lib/admin-protocol.d.ts +33 -4
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +15 -0
  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 +25 -0
  15. package/lib/auth.d.ts.map +1 -0
  16. package/lib/auth.js +16 -0
  17. package/lib/auth.js.map +1 -0
  18. package/lib/context-url.d.ts +31 -0
  19. package/lib/context-url.d.ts.map +1 -0
  20. package/lib/context-url.js +102 -0
  21. package/lib/context-url.js.map +1 -0
  22. package/lib/context-url.spec.d.ts +14 -0
  23. package/lib/context-url.spec.d.ts.map +1 -0
  24. package/lib/context-url.spec.js +109 -0
  25. package/lib/context-url.spec.js.map +1 -0
  26. package/lib/email-protocol.d.ts +1 -2
  27. package/lib/email-protocol.d.ts.map +1 -1
  28. package/lib/email-protocol.js +4 -4
  29. package/lib/email-protocol.js.map +1 -1
  30. package/lib/encryption/container-module.d.ts.map +1 -1
  31. package/lib/encryption/container-module.js +5 -4
  32. package/lib/encryption/container-module.js.map +1 -1
  33. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  34. package/lib/encryption/encryption-engine.js +25 -26
  35. package/lib/encryption/encryption-engine.js.map +1 -1
  36. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  37. package/lib/encryption/encryption-engine.spec.js +29 -37
  38. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  39. package/lib/encryption/encryption-service.d.ts.map +1 -1
  40. package/lib/encryption/encryption-service.js +30 -44
  41. package/lib/encryption/encryption-service.js.map +1 -1
  42. package/lib/encryption/key-provider.d.ts.map +1 -1
  43. package/lib/encryption/key-provider.js +31 -38
  44. package/lib/encryption/key-provider.js.map +1 -1
  45. package/lib/env.d.ts +2 -3
  46. package/lib/env.d.ts.map +1 -1
  47. package/lib/env.js +24 -25
  48. package/lib/env.js.map +1 -1
  49. package/lib/gitpod-file-parser.d.ts.map +1 -1
  50. package/lib/gitpod-file-parser.js +26 -42
  51. package/lib/gitpod-file-parser.js.map +1 -1
  52. package/lib/gitpod-file-parser.spec.js +145 -142
  53. package/lib/gitpod-file-parser.spec.js.map +1 -1
  54. package/lib/gitpod-service.d.ts +172 -33
  55. package/lib/gitpod-service.d.ts.map +1 -1
  56. package/lib/gitpod-service.js +187 -267
  57. package/lib/gitpod-service.js.map +1 -1
  58. package/lib/headless-workspace-log.d.ts +9 -11
  59. package/lib/headless-workspace-log.d.ts.map +1 -1
  60. package/lib/headless-workspace-log.js +6 -8
  61. package/lib/headless-workspace-log.js.map +1 -1
  62. package/lib/ide-frontend-service.d.ts +5 -1
  63. package/lib/ide-frontend-service.d.ts.map +1 -1
  64. package/lib/ide-protocol.d.ts +105 -0
  65. package/lib/ide-protocol.d.ts.map +1 -0
  66. package/lib/{util/without.js → ide-protocol.js} +2 -2
  67. package/lib/ide-protocol.js.map +1 -0
  68. package/lib/index.d.ts +16 -10
  69. package/lib/index.d.ts.map +1 -1
  70. package/lib/index.js +7 -1
  71. package/lib/index.js.map +1 -1
  72. package/lib/installation-admin-protocol.d.ts +27 -0
  73. package/lib/installation-admin-protocol.d.ts.map +1 -0
  74. package/lib/installation-admin-protocol.js +30 -0
  75. package/lib/installation-admin-protocol.js.map +1 -0
  76. package/lib/license-protocol.d.ts.map +1 -1
  77. package/lib/license-protocol.js.map +1 -1
  78. package/lib/messaging/browser/connection.d.ts +5 -3
  79. package/lib/messaging/browser/connection.d.ts.map +1 -1
  80. package/lib/messaging/browser/connection.js +184 -34
  81. package/lib/messaging/browser/connection.js.map +1 -1
  82. package/lib/messaging/browser/window-connection.d.ts +4 -4
  83. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  84. package/lib/messaging/browser/window-connection.js +42 -59
  85. package/lib/messaging/browser/window-connection.js.map +1 -1
  86. package/lib/messaging/client-call-metrics.d.ts +35 -0
  87. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  88. package/lib/messaging/client-call-metrics.js +83 -0
  89. package/lib/messaging/client-call-metrics.js.map +1 -0
  90. package/lib/messaging/error.d.ts +5 -1
  91. package/lib/messaging/error.d.ts.map +1 -1
  92. package/lib/messaging/error.js +10 -2
  93. package/lib/messaging/error.js.map +1 -1
  94. package/lib/messaging/handler.d.ts +10 -0
  95. package/lib/messaging/handler.d.ts.map +1 -1
  96. package/lib/messaging/handler.js +1 -1
  97. package/lib/messaging/node/connection.d.ts +1 -17
  98. package/lib/messaging/node/connection.d.ts.map +1 -1
  99. package/lib/messaging/node/connection.js +24 -60
  100. package/lib/messaging/node/connection.js.map +1 -1
  101. package/lib/messaging/proxy-factory.d.ts +3 -1
  102. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  103. package/lib/messaging/proxy-factory.js +75 -162
  104. package/lib/messaging/proxy-factory.js.map +1 -1
  105. package/lib/oss-allowlist.d.ts +14 -0
  106. package/lib/oss-allowlist.d.ts.map +1 -0
  107. package/lib/oss-allowlist.js +8 -0
  108. package/lib/oss-allowlist.js.map +1 -0
  109. package/lib/payment-protocol.d.ts +18 -0
  110. package/lib/payment-protocol.d.ts.map +1 -0
  111. package/lib/payment-protocol.js +13 -0
  112. package/lib/payment-protocol.js.map +1 -0
  113. package/lib/permission.d.ts +10 -5
  114. package/lib/permission.d.ts.map +1 -1
  115. package/lib/permission.js +41 -35
  116. package/lib/permission.js.map +1 -1
  117. package/lib/plans.d.ts +210 -0
  118. package/lib/plans.d.ts.map +1 -0
  119. package/lib/plans.js +605 -0
  120. package/lib/plans.js.map +1 -0
  121. package/lib/protocol.d.ts +164 -88
  122. package/lib/protocol.d.ts.map +1 -1
  123. package/lib/protocol.js +184 -199
  124. package/lib/protocol.js.map +1 -1
  125. package/lib/snapshot-url.d.ts +14 -0
  126. package/lib/snapshot-url.d.ts.map +1 -0
  127. package/lib/snapshot-url.js +26 -0
  128. package/lib/snapshot-url.js.map +1 -0
  129. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  130. package/lib/snapshot-url.spec.d.ts.map +1 -0
  131. package/lib/snapshot-url.spec.js +41 -0
  132. package/lib/snapshot-url.spec.js.map +1 -0
  133. package/lib/team-subscription-protocol.d.ts +75 -0
  134. package/lib/team-subscription-protocol.d.ts.map +1 -0
  135. package/lib/team-subscription-protocol.js +63 -0
  136. package/lib/team-subscription-protocol.js.map +1 -0
  137. package/lib/teams-projects-protocol.d.ts +113 -0
  138. package/lib/teams-projects-protocol.d.ts.map +1 -0
  139. package/lib/teams-projects-protocol.js +30 -0
  140. package/lib/teams-projects-protocol.js.map +1 -0
  141. package/lib/typings/globals.d.ts +2 -2
  142. package/lib/typings/globals.d.ts.map +1 -1
  143. package/lib/util/analytics.d.ts +8 -0
  144. package/lib/util/analytics.d.ts.map +1 -0
  145. package/lib/util/analytics.js +88 -0
  146. package/lib/util/analytics.js.map +1 -0
  147. package/lib/util/async-iterator.d.ts.map +1 -1
  148. package/lib/util/async-iterator.js +57 -135
  149. package/lib/util/async-iterator.js.map +1 -1
  150. package/lib/util/cancelable.js +17 -59
  151. package/lib/util/cancelable.js.map +1 -1
  152. package/lib/util/date-time.js +11 -11
  153. package/lib/util/date-time.js.map +1 -1
  154. package/lib/util/deferred.js +10 -12
  155. package/lib/util/deferred.js.map +1 -1
  156. package/lib/util/disposable.d.ts.map +1 -1
  157. package/lib/util/disposable.js +27 -40
  158. package/lib/util/disposable.js.map +1 -1
  159. package/lib/util/event.d.ts.map +1 -1
  160. package/lib/util/event.js +63 -77
  161. package/lib/util/event.js.map +1 -1
  162. package/lib/util/garbage-collected-cache.d.ts +1 -0
  163. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  164. package/lib/util/garbage-collected-cache.js +27 -47
  165. package/lib/util/garbage-collected-cache.js.map +1 -1
  166. package/lib/util/generate-workspace-id.d.ts +4 -0
  167. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  168. package/lib/util/generate-workspace-id.js +487 -0
  169. package/lib/util/generate-workspace-id.js.map +1 -0
  170. package/{src/theia-plugins.ts → lib/util/generate-workspace-id.spec.d.ts} +2 -6
  171. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  172. package/lib/util/generate-workspace-id.spec.js +91 -0
  173. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  174. package/lib/util/gitpod-cookie.d.ts +20 -0
  175. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  176. package/lib/util/gitpod-cookie.js +41 -0
  177. package/lib/util/gitpod-cookie.js.map +1 -0
  178. package/lib/util/gitpod-host-url.d.ts +2 -2
  179. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  180. package/lib/util/gitpod-host-url.js +109 -106
  181. package/lib/util/gitpod-host-url.js.map +1 -1
  182. package/lib/util/gitpod-host-url.spec.d.ts +8 -1
  183. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  184. package/lib/util/gitpod-host-url.spec.js +114 -22
  185. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  186. package/lib/util/grpc.d.ts +15 -0
  187. package/lib/util/grpc.d.ts.map +1 -0
  188. package/lib/util/grpc.js +18 -0
  189. package/lib/util/grpc.js.map +1 -0
  190. package/lib/util/jaeger-client-types.d.ts +68 -0
  191. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  192. package/lib/{theia-plugins.js → util/jaeger-client-types.js} +1 -1
  193. package/lib/util/jaeger-client-types.js.map +1 -0
  194. package/lib/util/logging.d.ts +49 -33
  195. package/lib/util/logging.d.ts.map +1 -1
  196. package/lib/util/logging.js +125 -129
  197. package/lib/util/logging.js.map +1 -1
  198. package/lib/util/make-link.js +5 -5
  199. package/lib/util/make-link.js.map +1 -1
  200. package/lib/util/parse-workspace-id.d.ts +13 -3
  201. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  202. package/lib/util/parse-workspace-id.js +37 -8
  203. package/lib/util/parse-workspace-id.js.map +1 -1
  204. package/lib/util/parse-workspace-id.spec.d.ts +8 -0
  205. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  206. package/lib/util/parse-workspace-id.spec.js +127 -47
  207. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  208. package/lib/util/queue.js +16 -55
  209. package/lib/util/queue.js.map +1 -1
  210. package/lib/util/queue.spec.js +147 -288
  211. package/lib/util/queue.spec.js.map +1 -1
  212. package/lib/util/repeat.d.ts +15 -0
  213. package/lib/util/repeat.d.ts.map +1 -0
  214. package/lib/util/repeat.js +55 -0
  215. package/lib/util/repeat.js.map +1 -0
  216. package/lib/util/semaphore.d.ts.map +1 -1
  217. package/lib/util/semaphore.js +15 -46
  218. package/lib/util/semaphore.js.map +1 -1
  219. package/lib/util/skip-if.d.ts.map +1 -1
  220. package/lib/util/skip-if.js +6 -6
  221. package/lib/util/skip-if.js.map +1 -1
  222. package/lib/util/timeutil.d.ts.map +1 -1
  223. package/lib/util/timeutil.js +28 -16
  224. package/lib/util/timeutil.js.map +1 -1
  225. package/lib/util/timeutil.spec.d.ts.map +1 -1
  226. package/lib/util/timeutil.spec.js +21 -24
  227. package/lib/util/timeutil.spec.js.map +1 -1
  228. package/lib/util/tracing.d.ts +52 -6
  229. package/lib/util/tracing.d.ts.map +1 -1
  230. package/lib/util/tracing.js +199 -64
  231. package/lib/util/tracing.js.map +1 -1
  232. package/lib/util/tracing.spec.d.ts +7 -0
  233. package/lib/util/tracing.spec.d.ts.map +1 -0
  234. package/lib/util/tracing.spec.js +121 -0
  235. package/lib/util/tracing.spec.js.map +1 -0
  236. package/lib/util/workspace-port-authentication.d.ts +7 -7
  237. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  238. package/lib/util/workspace-port-authentication.js +10 -12
  239. package/lib/util/workspace-port-authentication.js.map +1 -1
  240. package/lib/workspace-cluster.d.ts +76 -0
  241. package/lib/workspace-cluster.d.ts.map +1 -0
  242. package/lib/workspace-cluster.js +31 -0
  243. package/lib/workspace-cluster.js.map +1 -0
  244. package/lib/workspace-instance.d.ts +28 -4
  245. package/lib/workspace-instance.d.ts.map +1 -1
  246. package/lib/wsready.d.ts +1 -1
  247. package/lib/wsready.d.ts.map +1 -1
  248. package/lib/wsready.js +2 -2
  249. package/package.json +33 -17
  250. package/pkg-yarn.lock +18 -9
  251. package/provenance-bundle.jsonl +2 -0
  252. package/src/accounting-protocol.ts +231 -0
  253. package/src/admin-protocol.ts +71 -19
  254. package/src/analytics.ts +52 -0
  255. package/src/auth.ts +27 -0
  256. package/src/context-url.spec.ts +67 -0
  257. package/src/context-url.ts +109 -0
  258. package/src/email-protocol.ts +5 -7
  259. package/src/encryption/container-module.ts +2 -3
  260. package/src/encryption/encryption-engine.spec.ts +9 -8
  261. package/src/encryption/encryption-engine.ts +14 -14
  262. package/src/encryption/encryption-service.ts +4 -5
  263. package/src/encryption/key-provider.ts +16 -19
  264. package/src/env.ts +18 -18
  265. package/src/gitpod-file-parser.spec.ts +55 -61
  266. package/src/gitpod-file-parser.ts +16 -17
  267. package/src/gitpod-service.ts +327 -102
  268. package/src/headless-workspace-log.ts +12 -14
  269. package/src/ide-frontend-service.ts +6 -2
  270. package/src/ide-protocol.ts +119 -0
  271. package/src/index.ts +16 -10
  272. package/src/installation-admin-protocol.ts +42 -0
  273. package/src/license-protocol.ts +5 -6
  274. package/src/messaging/browser/connection.ts +197 -18
  275. package/src/messaging/browser/window-connection.ts +39 -29
  276. package/src/messaging/client-call-metrics.ts +96 -0
  277. package/src/messaging/error.ts +15 -5
  278. package/src/messaging/handler.ts +13 -1
  279. package/src/messaging/node/connection.ts +23 -70
  280. package/src/messaging/proxy-factory.ts +35 -34
  281. package/src/oss-allowlist.ts +15 -0
  282. package/src/payment-protocol.ts +20 -0
  283. package/src/permission.ts +42 -38
  284. package/src/plans.ts +679 -0
  285. package/src/protocol.ts +384 -279
  286. package/src/snapshot-url.spec.ts +27 -0
  287. package/src/snapshot-url.ts +27 -0
  288. package/src/team-subscription-protocol.ts +123 -0
  289. package/src/teams-projects-protocol.ts +147 -0
  290. package/src/typings/globals.ts +4 -4
  291. package/src/util/analytics.ts +109 -0
  292. package/src/util/async-iterator.ts +4 -5
  293. package/src/util/cancelable.ts +3 -3
  294. package/src/util/date-time.ts +8 -8
  295. package/src/util/deferred.ts +6 -6
  296. package/src/util/disposable.ts +3 -6
  297. package/src/util/event.ts +9 -11
  298. package/src/util/garbage-collected-cache.ts +11 -8
  299. package/src/util/generate-workspace-id.spec.ts +51 -0
  300. package/src/util/generate-workspace-id.ts +475 -0
  301. package/src/util/gitpod-cookie.ts +38 -0
  302. package/src/util/gitpod-host-url.spec.ts +63 -7
  303. package/src/util/gitpod-host-url.ts +55 -38
  304. package/src/util/grpc.ts +15 -0
  305. package/src/util/jaeger-client-types.ts +102 -0
  306. package/src/util/logging.ts +145 -71
  307. package/src/util/make-link.ts +6 -7
  308. package/src/util/parse-workspace-id.spec.ts +60 -10
  309. package/src/util/parse-workspace-id.ts +38 -8
  310. package/src/util/queue.spec.ts +28 -26
  311. package/src/util/repeat.ts +45 -0
  312. package/src/util/semaphore.ts +6 -8
  313. package/src/util/skip-if.ts +10 -7
  314. package/src/util/timeutil.spec.ts +14 -15
  315. package/src/util/timeutil.ts +19 -15
  316. package/src/util/tracing.spec.ts +88 -0
  317. package/src/util/tracing.ts +202 -31
  318. package/src/util/workspace-port-authentication.ts +10 -13
  319. package/src/workspace-cluster.ts +107 -0
  320. package/src/workspace-instance.ts +72 -30
  321. package/src/wsready.ts +3 -3
  322. package/data/builtin-theia-plugins.json +0 -372
  323. package/lib/messaging/connection-error-handler.d.ts +0 -27
  324. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  325. package/lib/messaging/connection-error-handler.js +0 -46
  326. package/lib/messaging/connection-error-handler.js.map +0 -1
  327. package/lib/theia-plugins.d.ts +0 -11
  328. package/lib/theia-plugins.d.ts.map +0 -1
  329. package/lib/theia-plugins.js.map +0 -1
  330. package/lib/util/repeater.d.ts +0 -22
  331. package/lib/util/repeater.d.ts.map +0 -1
  332. package/lib/util/repeater.js +0 -118
  333. package/lib/util/repeater.js.map +0 -1
  334. package/lib/util/safe-promise.d.ts +0 -11
  335. package/lib/util/safe-promise.d.ts.map +0 -1
  336. package/lib/util/safe-promise.js +0 -34
  337. package/lib/util/safe-promise.js.map +0 -1
  338. package/lib/util/without.d.ts +0 -7
  339. package/lib/util/without.d.ts.map +0 -1
  340. package/lib/util/without.js.map +0 -1
  341. package/src/messaging/connection-error-handler.ts +0 -62
  342. package/src/util/jaeger-client.d.ts +0 -105
  343. package/src/util/repeater.ts +0 -49
  344. package/src/util/safe-promise.ts +0 -26
@@ -4,29 +4,36 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- const URL = require('url').URL || window.URL;
8
- import { log } from './logging';
7
+ const URL = require("url").URL || window.URL;
8
+ import { log } from "./logging";
9
9
 
10
10
  export interface UrlChange {
11
- (old: URL): Partial<URL>
11
+ (old: URL): Partial<URL>;
12
12
  }
13
13
  export type UrlUpdate = UrlChange | Partial<URL>;
14
14
 
15
- export const workspaceIDRegex = /([a-z0-9]{4,8}-)+([a-z0-9]{12})/;
15
+ const baseWorkspaceIDRegex =
16
+ "(([a-f][0-9a-f]{7}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})|([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}))";
17
+
18
+ // this pattern matches v4 UUIDs as well as the new generated workspace ids (e.g. pink-panda-ns35kd21)
19
+ const workspaceIDRegex = RegExp(`^${baseWorkspaceIDRegex}$`);
20
+
21
+ // this pattern matches URL prefixes of workspaces
22
+ const workspaceUrlPrefixRegex = RegExp(`^([0-9]{4,6}-)?${baseWorkspaceIDRegex}\\.`);
16
23
 
17
24
  export class GitpodHostUrl {
18
25
  readonly url: URL;
19
26
 
20
27
  constructor(urlParam?: string | URL) {
21
- if (urlParam === undefined || typeof urlParam === 'string') {
22
- this.url = new URL(urlParam || 'https://gitpod.io');
23
- this.url.search = '';
24
- this.url.hash = '';
25
- this.url.pathname = '';
28
+ if (urlParam === undefined || typeof urlParam === "string") {
29
+ this.url = new URL(urlParam || "https://gitpod.io");
30
+ this.url.search = "";
31
+ this.url.hash = "";
32
+ this.url.pathname = "";
26
33
  } else if (urlParam instanceof URL) {
27
34
  this.url = urlParam;
28
35
  } else {
29
- log.error('Unexpected urlParam', { urlParam });
36
+ log.error("Unexpected urlParam", { urlParam });
30
37
  }
31
38
  }
32
39
 
@@ -39,11 +46,11 @@ export class GitpodHostUrl {
39
46
  }
40
47
 
41
48
  withDomainPrefix(prefix: string): GitpodHostUrl {
42
- return this.with(url => ({ host: prefix + url.host }));;
49
+ return this.with((url) => ({ host: prefix + url.host }));
43
50
  }
44
51
 
45
52
  withoutWorkspacePrefix(): GitpodHostUrl {
46
- if (!this.url.host.match(workspaceIDRegex)) {
53
+ if (!this.url.host.match(workspaceUrlPrefixRegex)) {
47
54
  // URL has no workspace prefix
48
55
  return this;
49
56
  }
@@ -52,14 +59,14 @@ export class GitpodHostUrl {
52
59
  }
53
60
 
54
61
  withoutDomainPrefix(removeSegmentsCount: number): GitpodHostUrl {
55
- return this.with(url => ({ host: url.host.split('.').splice(removeSegmentsCount).join('.') }));
62
+ return this.with((url) => ({ host: url.host.split(".").splice(removeSegmentsCount).join(".") }));
56
63
  }
57
64
 
58
65
  with(urlUpdate: UrlUpdate) {
59
- const update = typeof urlUpdate === 'function' ? urlUpdate(this.url) : urlUpdate;
60
- const addSlashToPath = update.pathname && update.pathname.length > 0 && !update.pathname.startsWith('/');
66
+ const update = typeof urlUpdate === "function" ? urlUpdate(this.url) : urlUpdate;
67
+ const addSlashToPath = update.pathname && update.pathname.length > 0 && !update.pathname.startsWith("/");
61
68
  if (addSlashToPath) {
62
- update.pathname = '/' + update.pathname;
69
+ update.pathname = "/" + update.pathname;
63
70
  }
64
71
  const result = Object.assign(new URL(this.toString()), update);
65
72
  return new GitpodHostUrl(result);
@@ -67,50 +74,53 @@ export class GitpodHostUrl {
67
74
 
68
75
  withApi(urlUpdate?: UrlUpdate) {
69
76
  const updated = urlUpdate ? this.with(urlUpdate) : this;
70
- return updated.with(url => ({ pathname: `/api${url.pathname}` }));
77
+ return updated.with((url) => ({ pathname: `/api${url.pathname}` }));
71
78
  }
72
79
 
73
80
  withContext(contextUrl: string) {
74
- return this.with(url => ({ hash: contextUrl }));
81
+ return this.with((url) => ({ hash: contextUrl }));
75
82
  }
76
83
 
77
84
  asWebsocket(): GitpodHostUrl {
78
- return this.with(url => ({ protocol: url.protocol === 'https:' ? 'wss:' : 'ws:' }));
85
+ return this.with((url) => ({ protocol: url.protocol === "https:" ? "wss:" : "ws:" }));
79
86
  }
80
87
 
81
88
  asDashboard(): GitpodHostUrl {
82
- return this.with(url => ({ pathname: '/workspaces/' }));
89
+ return this.with((url) => ({ pathname: "/" }));
83
90
  }
84
91
 
85
92
  asLogin(): GitpodHostUrl {
86
- return this.with(url => ({ pathname: '/login/' }));
93
+ return this.with((url) => ({ pathname: "/login" }));
87
94
  }
88
95
 
89
96
  asUpgradeSubscription(): GitpodHostUrl {
90
- return this.with(url => ({ pathname: '/upgrade-subscription/' }));
97
+ return this.with((url) => ({ pathname: "/plans" }));
91
98
  }
92
99
 
93
100
  asAccessControl(): GitpodHostUrl {
94
- return this.with(url => ({ pathname: '/access-control/' }));
101
+ return this.with((url) => ({ pathname: "/integrations" }));
95
102
  }
96
103
 
97
104
  asSettings(): GitpodHostUrl {
98
- return this.with(url => ({ pathname: '/settings/' }));
105
+ return this.with((url) => ({ pathname: "/settings" }));
99
106
  }
100
107
 
101
- asGraphQLApi(): GitpodHostUrl {
102
- return this.with(url => ({ pathname: '/graphql/' }));
108
+ asPreferences(): GitpodHostUrl {
109
+ return this.with((url) => ({ pathname: "/preferences" }));
103
110
  }
104
111
 
105
112
  asStart(workspaceId = this.workspaceId): GitpodHostUrl {
106
113
  return this.withoutWorkspacePrefix().with({
107
- pathname: '/start/',
108
- hash: '#' + workspaceId
114
+ pathname: "/start/",
115
+ hash: "#" + workspaceId,
109
116
  });
110
117
  }
111
118
 
112
119
  asWorkspaceAuth(instanceID: string, redirect?: boolean): GitpodHostUrl {
113
- return this.with(url => ({ pathname: `/api/auth/workspace-cookie/${instanceID}`, search: redirect ? "redirect" : "" }));
120
+ return this.with((url) => ({
121
+ pathname: `/api/auth/workspace-cookie/${instanceID}`,
122
+ search: redirect ? "redirect" : "",
123
+ }));
114
124
  }
115
125
 
116
126
  toString() {
@@ -119,7 +129,7 @@ export class GitpodHostUrl {
119
129
 
120
130
  toStringWoRootSlash() {
121
131
  let result = this.toString();
122
- if (result.endsWith('/')) {
132
+ if (result.endsWith("/")) {
123
133
  result = result.slice(0, result.length - 1);
124
134
  }
125
135
  return result;
@@ -127,12 +137,16 @@ export class GitpodHostUrl {
127
137
 
128
138
  get workspaceId(): string | undefined {
129
139
  const hostSegs = this.url.host.split(".");
130
- if (hostSegs.length > 1 && hostSegs[0].match(workspaceIDRegex)) {
131
- // URL has a workspace prefix
132
- return hostSegs[0];
140
+ if (hostSegs.length > 1) {
141
+ const matchResults = hostSegs[0].match(workspaceIDRegex);
142
+ if (matchResults) {
143
+ // URL has a workspace prefix
144
+ // port prefixes are excluded
145
+ return matchResults[0];
146
+ }
133
147
  }
134
148
 
135
- const pathSegs = this.url.pathname.split("/")
149
+ const pathSegs = this.url.pathname.split("/");
136
150
  if (pathSegs.length > 3 && pathSegs[1] === "workspace") {
137
151
  return pathSegs[2];
138
152
  }
@@ -140,18 +154,21 @@ export class GitpodHostUrl {
140
154
  return undefined;
141
155
  }
142
156
 
143
- get blobServe(): boolean {
157
+ get blobServe(): boolean {
144
158
  const hostSegments = this.url.host.split(".");
145
- if (hostSegments[0] === 'blobserve') {
159
+ if (hostSegments[0] === "blobserve") {
146
160
  return true;
147
161
  }
148
162
 
149
- const pathSegments = this.url.pathname.split("/")
163
+ const pathSegments = this.url.pathname.split("/");
150
164
  return pathSegments[0] === "blobserve";
151
165
  }
152
166
 
153
167
  asSorry(message: string) {
154
- return this.with({ pathname: '/sorry', hash: message });
168
+ return this.with({ pathname: "/sorry", hash: message });
155
169
  }
156
170
 
171
+ asApiLogout(): GitpodHostUrl {
172
+ return this.withApi((url) => ({ pathname: "/logout/" }));
173
+ }
157
174
  }
@@ -0,0 +1,15 @@
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
+ export const defaultGRPCOptions = {
8
+ "grpc.keepalive_timeout_ms": 10000,
9
+ "grpc.keepalive_time_ms": 60000,
10
+ "grpc.http2.min_time_between_pings_ms": 10000,
11
+ "grpc.keepalive_permit_without_calls": 1,
12
+ "grpc-node.max_session_memory": 50,
13
+ "grpc.max_reconnect_backoff_ms": 5000,
14
+ "grpc.max_receive_message_length": 1024 * 1024 * 16,
15
+ };
@@ -0,0 +1,102 @@
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 { opentracing } from "jaeger-client";
8
+
9
+ // Type definitions for jaeger-client which are not exported by @types/jaeger-client
10
+ // Project: https://github.com/uber/jaeger-client-node
11
+ // Definitions by: Julian Steger <https://github.com/julianste>
12
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
13
+
14
+ export interface TracingConfig {
15
+ serviceName?: string;
16
+ disable?: boolean;
17
+ sampler?: SamplerConfig;
18
+ reporter?: ReporterConfig;
19
+ }
20
+
21
+ export interface TracingOptions {
22
+ reporter?: Reporter;
23
+ metrics?: MetricsFactory;
24
+ logger?: Logger;
25
+ tags?: any;
26
+ }
27
+
28
+ export interface ReporterConfig {
29
+ logSpans?: boolean;
30
+ agentHost?: string;
31
+ agentPort?: number;
32
+ flushIntervalMs?: number;
33
+ }
34
+
35
+ export interface SamplerConfig {
36
+ type: string;
37
+ param: number;
38
+ host?: string;
39
+ port?: number;
40
+ refreshIntervalMs?: number;
41
+ }
42
+
43
+ export interface Logger {
44
+ info(msg: string): void;
45
+ error(msg: string): void;
46
+ }
47
+
48
+ export interface Reporter {
49
+ report(span: opentracing.Span): void;
50
+ close(callback?: () => void): void;
51
+ setProcess(serviceName: string, tags: any): void;
52
+ }
53
+
54
+ export interface MetricsFactory {
55
+ createCounter(name: string, tags: any): Counter;
56
+ createTimer(name: string, tags: any): Timer;
57
+ createGauge(name: string, tags: any): Gauge;
58
+ }
59
+
60
+ // Counter tracks the number of times an event has occurred
61
+ export interface Counter {
62
+ // Adds the given value to the counter.
63
+ increment(delta: number): void;
64
+ }
65
+
66
+ // Timer tracks how long an operation took and also computes percentiles.
67
+ export interface Timer {
68
+ // Records the time passed in.
69
+ record(value: number): void;
70
+ }
71
+
72
+ // Gauge returns instantaneous measurements of something as an int64 value
73
+ export interface Gauge {
74
+ // Update the gauge to the value passed in.
75
+ update(value: number): void;
76
+ }
77
+
78
+ // export function initTracer(
79
+ // tracingConfig: TracingConfig,
80
+ // tracingOptions: TracingOptions,
81
+ // ): opentracing.Tracer;
82
+
83
+ // export function initTracerFromEnv(
84
+ // tracingConfig: TracingConfig,
85
+ // tracingOptions: TracingOptions,
86
+ // ): opentracing.Tracer;
87
+
88
+ export interface SamplingDecision {
89
+ sample: boolean;
90
+ retryable: boolean;
91
+ tags: any;
92
+ }
93
+
94
+ // added by TypeFox
95
+ export interface Sampler {
96
+ name(): string;
97
+ isSampled(operation: string, tags: any): boolean;
98
+ onCreateSpan(span: opentracing.Span): SamplingDecision;
99
+ onSetOperationName(span: opentracing.Span, operationName: string): SamplingDecision;
100
+ onSetTag(span: opentracing.Span, key: string, value: any): SamplingDecision;
101
+ close(callback: () => void): void;
102
+ }