@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,7 +4,7 @@
4
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
9
  let jsonLogging: boolean = false;
10
10
  let component: string | undefined;
@@ -15,81 +15,81 @@ export interface LogContext {
15
15
  sessionId?: string;
16
16
  userId?: string;
17
17
  workspaceId?: string;
18
- };
18
+ }
19
19
  export namespace LogContext {
20
- export function from(params : { userId?: string, user?: any, request?: any } ) {
20
+ export function from(params: { userId?: string; user?: any; request?: any }) {
21
21
  return <LogContext>{
22
22
  sessionId: params.request?.requestID,
23
- userId: params.userId || params.user?.id
24
- }
23
+ userId: params.userId || params.user?.id,
24
+ };
25
25
  }
26
26
  }
27
27
 
28
28
  export interface LogPayload {
29
29
  // placeholder to indicate that only dictionary-style objects should be passed as payload
30
- };
30
+ }
31
31
 
32
32
  export namespace log {
33
- export function error(context: LogContext, message: string, error: Error, payload: LogPayload): void;
34
- export function error(context: LogContext, message: string, error: Error): void;
33
+ export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
34
+ export function error(context: LogContext, message: string, error: any): void;
35
35
  export function error(context: LogContext, message: string, payload: LogPayload): void;
36
36
  export function error(context: LogContext, message: string): void;
37
- export function error(context: LogContext, error: Error, payload: LogPayload): void;
38
- export function error(context: LogContext, error: Error): void;
39
- export function error(message: string, error: Error, payload: LogPayload): void;
40
- export function error(message: string, error: Error): void;
37
+ export function error(context: LogContext, error: any, payload: LogPayload): void;
38
+ export function error(context: LogContext, error: any): void;
39
+ export function error(message: string, error: any, payload: LogPayload): void;
40
+ export function error(message: string, error: any): void;
41
41
  export function error(message: string, payload: LogPayload): void;
42
42
  export function error(message: string): void;
43
- export function error(error: Error, payload: LogPayload): void;
44
- export function error(error: Error): void;
43
+ export function error(error: any, payload: LogPayload): void;
44
+ export function error(error: any): void;
45
45
  export function error(...args: any[]): void {
46
46
  errorLog(false, args);
47
47
  }
48
48
 
49
- export function warn(context: LogContext, message: string, error: Error, payload: LogPayload): void;
50
- export function warn(context: LogContext, message: string, error: Error): void;
49
+ export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
50
+ export function warn(context: LogContext, message: string, error: any): void;
51
51
  export function warn(context: LogContext, message: string, payload: LogPayload): void;
52
52
  export function warn(context: LogContext, message: string): void;
53
- export function warn(context: LogContext, error: Error, payload: LogPayload): void;
54
- export function warn(context: LogContext, error: Error): void;
55
- export function warn(message: string, error: Error, payload: LogPayload): void;
56
- export function warn(message: string, error: Error): void;
53
+ export function warn(context: LogContext, error: any, payload: LogPayload): void;
54
+ export function warn(context: LogContext, error: any): void;
55
+ export function warn(message: string, error: any, payload: LogPayload): void;
56
+ export function warn(message: string, error: any): void;
57
57
  export function warn(message: string, payload: LogPayload): void;
58
58
  export function warn(message: string): void;
59
- export function warn(error: Error, payload: LogPayload): void;
60
- export function warn(error: Error): void;
59
+ export function warn(error: any, payload: LogPayload): void;
60
+ export function warn(error: any): void;
61
61
  export function warn(...args: any[]): void {
62
62
  warnLog(false, args);
63
63
  }
64
64
 
65
- export function info(context: LogContext, message: string, error: Error, payload: LogPayload): void;
66
- export function info(context: LogContext, message: string, error: Error): void;
65
+ export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
66
+ export function info(context: LogContext, message: string, error: any): void;
67
67
  export function info(context: LogContext, message: string, payload: LogPayload): void;
68
68
  export function info(context: LogContext, message: string): void;
69
- export function info(context: LogContext, error: Error, payload: LogPayload): void;
70
- export function info(context: LogContext, error: Error): void;
71
- export function info(message: string, error: Error, payload: LogPayload): void;
72
- export function info(message: string, error: Error): void;
69
+ export function info(context: LogContext, error: any, payload: LogPayload): void;
70
+ export function info(context: LogContext, error: any): void;
71
+ export function info(message: string, error: any, payload: LogPayload): void;
72
+ export function info(message: string, error: any): void;
73
73
  export function info(message: string, payload: LogPayload): void;
74
74
  export function info(message: string): void;
75
- export function info(error: Error, payload: LogPayload): void;
76
- export function info(error: Error): void;
75
+ export function info(error: any, payload: LogPayload): void;
76
+ export function info(error: any): void;
77
77
  export function info(...args: any[]): void {
78
78
  infoLog(false, args);
79
79
  }
80
80
 
81
- export function debug(context: LogContext, message: string, error: Error, payload: LogPayload): void;
82
- export function debug(context: LogContext, message: string, error: Error): void;
81
+ export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
82
+ export function debug(context: LogContext, message: string, error: any): void;
83
83
  export function debug(context: LogContext, message: string, payload: LogPayload): void;
84
84
  export function debug(context: LogContext, message: string): void;
85
- export function debug(context: LogContext, error: Error, payload: LogPayload): void;
86
- export function debug(context: LogContext, error: Error): void;
87
- export function debug(message: string, error: Error, payload: LogPayload): void;
88
- export function debug(message: string, error: Error): void;
85
+ export function debug(context: LogContext, error: any, payload: LogPayload): void;
86
+ export function debug(context: LogContext, error: any): void;
87
+ export function debug(message: string, error: any, payload: LogPayload): void;
88
+ export function debug(message: string, error: any): void;
89
89
  export function debug(message: string, payload: LogPayload): void;
90
90
  export function debug(message: string): void;
91
- export function debug(error: Error, payload: LogPayload): void;
92
- export function debug(error: Error): void;
91
+ export function debug(error: any, payload: LogPayload): void;
92
+ export function debug(error: any): void;
93
93
  export function debug(...args: any[]): void {
94
94
  debugLog(false, args);
95
95
  }
@@ -97,26 +97,46 @@ export namespace log {
97
97
  /**
98
98
  * Do not use in frontend.
99
99
  */
100
- export function enableJSONLogging(componentArg: string, versionArg: string | undefined): void {
100
+ export function enableJSONLogging(
101
+ componentArg: string,
102
+ versionArg: string | undefined,
103
+ logLevel?: LogrusLogLevel,
104
+ ): void {
101
105
  component = componentArg;
102
106
  version = versionArg;
103
107
 
108
+ setLogLevel(logLevel);
109
+ }
110
+
111
+ export function setLogLevel(logLevel: LogrusLogLevel | undefined) {
104
112
  jsonLogging = true;
105
113
 
106
114
  console.error = function (...args: any[]): void {
107
115
  errorLog(true, args);
108
- }
116
+ };
109
117
  console.warn = function (...args: any[]): void {
110
118
  warnLog(true, args);
111
- }
119
+ };
112
120
  console.info = function (...args: any[]): void {
113
121
  infoLog(true, args);
114
- }
122
+ };
115
123
  console.debug = function (...args: any[]): void {
116
124
  debugLog(true, args);
117
- }
125
+ };
126
+
118
127
  console.log = console.info;
119
128
  // FIXME wrap also other console methods (e.g. trace())
129
+
130
+ // set/unset log functions based on loglevel so we only have to evaluate once, not every call
131
+ const noop = () => {};
132
+ const setLog = (logFunc: DoLogFunction, funcLevel: LogrusLogLevel): DoLogFunction => {
133
+ return LogrusLogLevel.isGreatherOrEqual(funcLevel, logLevel) ? logFunc : noop;
134
+ };
135
+
136
+ errorLog = setLog(doErrorLog, "error");
137
+ warnLog = setLog(doWarnLog, "warning");
138
+ infoLog = setLog(doInfoLog, "info");
139
+ debugLog = setLog(doDebugLog, "debug");
120
140
  }
121
141
 
122
142
  export function resetToDefaultLogging(): void {
@@ -128,31 +148,79 @@ export namespace log {
128
148
  console.info = infoConsoleLog;
129
149
  console.debug = debugConsoleLog;
130
150
  }
151
+
152
+ export function setVersion(versionArg: string) {
153
+ version = versionArg;
154
+ }
131
155
  }
132
156
 
133
- function errorLog(calledViaConsole: boolean, args: any[]): void {
134
- doLog(calledViaConsole, errorConsoleLog, 'ERROR', args);
157
+ type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
158
+
159
+ let errorLog = doErrorLog;
160
+ function doErrorLog(calledViaConsole: boolean, args: any[]): void {
161
+ doLog(calledViaConsole, errorConsoleLog, "ERROR", args);
135
162
  }
136
163
 
137
- function warnLog(calledViaConsole: boolean, args: any[]): void {
138
- doLog(calledViaConsole, warnConsoleLog, 'WARNING', args);
164
+ let warnLog = doWarnLog;
165
+ function doWarnLog(calledViaConsole: boolean, args: any[]): void {
166
+ doLog(calledViaConsole, warnConsoleLog, "WARNING", args);
139
167
  }
140
168
 
141
- function infoLog(calledViaConsole: boolean, args: any[]): void {
142
- doLog(calledViaConsole, infoConsoleLog, 'INFO', args);
169
+ let infoLog = doInfoLog;
170
+ function doInfoLog(calledViaConsole: boolean, args: any[]): void {
171
+ doLog(calledViaConsole, infoConsoleLog, "INFO", args);
143
172
  }
144
173
 
145
- function debugLog(calledViaConsole: boolean, args: any[]): void {
146
- doLog(calledViaConsole, debugConsoleLog, 'DEBUG', args);
174
+ let debugLog = doDebugLog;
175
+ function doDebugLog(calledViaConsole: boolean, args: any[]): void {
176
+ doLog(calledViaConsole, debugConsoleLog, "DEBUG", args);
177
+ }
178
+
179
+ // Ref: https://github.com/sirupsen/logrus#level-logging
180
+ export type LogrusLogLevel = keyof typeof LogrusLogLevels;
181
+ export const LogrusLogLevels = {
182
+ trace: true,
183
+ debug: true,
184
+ info: true,
185
+ warning: true,
186
+ error: true,
187
+ fatal: true,
188
+ panic: true,
189
+ };
190
+ export namespace LogrusLogLevel {
191
+ export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
192
+ if (lvl === undefined) {
193
+ return false;
194
+ }
195
+ if (ref === undefined) {
196
+ return true;
197
+ }
198
+ return getLevelArity(lvl) >= getLevelArity(ref);
199
+ }
200
+ function getLevelArity(lvl: LogrusLogLevel): number {
201
+ return Object.keys(LogrusLogLevels).findIndex((l) => l === lvl);
202
+ }
203
+ export function getFromEnv(): LogrusLogLevel | undefined {
204
+ const lvlStr = process.env.LOG_LEVEL;
205
+ if (!lvlStr) {
206
+ return undefined;
207
+ }
208
+ const lvl = lvlStr as LogrusLogLevel;
209
+ const exists = LogrusLogLevels[lvl];
210
+ if (!exists) {
211
+ return undefined;
212
+ }
213
+ return lvl;
214
+ }
147
215
  }
148
216
 
149
217
  // Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
150
- type GoogleLogSeverity = 'EMERGENCY' | 'ALERT' | 'CRITICAL' | 'ERROR' | 'WARNING' | 'INFO' | 'DEBUG';
218
+ type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
151
219
  namespace GoogleLogSeverity {
152
220
  export const isGreaterOrEqualThanWarning = (severity: GoogleLogSeverity) => {
153
221
  switch (severity) {
154
- case 'INFO':
155
- case 'DEBUG':
222
+ case "INFO":
223
+ case "DEBUG":
156
224
  return false;
157
225
  default:
158
226
  return true;
@@ -180,7 +248,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
180
248
  // console.xyz(Error, ...any) / log.xyz(Error) / log.xyz(Error, LogPayload)
181
249
  error = args[0];
182
250
  payloadArgs = args.slice(1);
183
- } else if (typeof args[0] === 'string') {
251
+ } else if (typeof args[0] === "string") {
184
252
  message = args[0];
185
253
  if (args.length < 2 || !(args[1] instanceof Error)) {
186
254
  // console.xyz(string) / console.xyz(string, !Error, ...any) / log.xyz(string) / log.xyz(string, LogPayload)
@@ -200,7 +268,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
200
268
  // log.xyz(LogContext, Error) / log.xyz(LogContext, Error, LogPayload)
201
269
  error = args[1];
202
270
  payloadArgs = args.slice(2);
203
- } else if (typeof args[1] === 'string') {
271
+ } else if (typeof args[1] === "string") {
204
272
  message = args[1];
205
273
  if (args.length < 3 || !(args[2] instanceof Error)) {
206
274
  // log.xyz(LogContext, string) / log.xyz(LogContext, string, LogPayload)
@@ -223,9 +291,14 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
223
291
  }
224
292
  }
225
293
 
226
- function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefined, message: string | undefined,
227
- error: Error | undefined, payloadArgs: any[], calledViaConsole: boolean): string | undefined {
228
-
294
+ function makeLogItem(
295
+ severity: GoogleLogSeverity,
296
+ context: LogContext | undefined,
297
+ message: string | undefined,
298
+ error: Error | undefined,
299
+ payloadArgs: any[],
300
+ calledViaConsole: boolean,
301
+ ): string | undefined {
229
302
  if (context !== undefined && Object.keys(context).length == 0) {
230
303
  context = undefined;
231
304
  }
@@ -243,12 +316,11 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
243
316
  severity,
244
317
  time: new Date().toISOString(),
245
318
  environment: process.env.KUBE_STAGE,
246
- region: process.env.GITPOD_REGION,
247
319
  context,
248
320
  message,
249
321
  error,
250
322
  payload,
251
- loggedViaConsole: calledViaConsole ? true : undefined
323
+ loggedViaConsole: calledViaConsole ? true : undefined,
252
324
  };
253
325
  let result: string = stringifyLogItem(logItem);
254
326
 
@@ -259,11 +331,11 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
259
331
  result = stringifyLogItem(logItem);
260
332
 
261
333
  if (result.length <= maxAllowedLogItemLength) {
262
- log.warn('Log item too large, stripping payload', { logItemStub: makeLogItemStub(logItem) });
334
+ log.warn("Log item too large, stripping payload", { logItemStub: makeLogItemStub(logItem) });
263
335
  }
264
336
  }
265
337
  if (result.length > maxAllowedLogItemLength) {
266
- log.error('Log item too large w/o payload, discarding', { logItemStub: makeLogItemStub(logItem) });
338
+ log.error("Log item too large w/o payload, discarding", { logItemStub: makeLogItemStub(logItem) });
267
339
  return undefined;
268
340
  }
269
341
 
@@ -277,10 +349,10 @@ function makeReportedErrorEvent(error: Error | undefined) {
277
349
  // Serves as marker only
278
350
  "@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
279
351
  // This is useful for filtering in the UI
280
- "serviceContext": {
281
- "service": component || "<ts-not-set>",
282
- "version": version || "<ts-not-set>",
283
- }
352
+ serviceContext: {
353
+ service: component || "<ts-not-set>",
354
+ version: version || "<ts-not-set>",
355
+ },
284
356
  };
285
357
 
286
358
  if (error) {
@@ -300,9 +372,9 @@ function makeLogItemStub(logItem: any): any {
300
372
  severity: logItem.severity,
301
373
  time: logItem.time,
302
374
  environment: logItem.environment,
303
- region: logItem.region
375
+ region: logItem.region,
304
376
  };
305
- if (typeof (logItem.message) === 'string') {
377
+ if (typeof logItem.message === "string") {
306
378
  if (logItem.message.length <= maxMessageStubLength) {
307
379
  result.message = logItem.message;
308
380
  } else {
@@ -336,10 +408,12 @@ function stringifyLogItem(logItem: any): string {
336
408
  * Jsonifies Errors properly, not as {} only.
337
409
  */
338
410
  function jsonStringifyWithErrors(value: any): string {
339
- return JSON.stringify(value, (key: string, value: any): any => { return value instanceof Error ? value.stack : value });
411
+ return JSON.stringify(value, (key: string, value: any): any => {
412
+ return value instanceof Error ? value.stack : value;
413
+ });
340
414
  }
341
415
 
342
- type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
416
+ type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
343
417
  const logConsoleLog: ConsoleLog = console.log;
344
418
  const errorConsoleLog: ConsoleLog = console.error;
345
419
  const warnConsoleLog: ConsoleLog = console.warn;
@@ -5,18 +5,17 @@
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
-
@@ -4,32 +4,82 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import * as chai from 'chai';
8
- import { suite, test } from 'mocha-typescript';
9
- import { parseWorkspaceIdFromHostname } from './parse-workspace-id';
7
+ import * as chai from "chai";
8
+ import { suite, test } from "mocha-typescript";
9
+ import {
10
+ matchesInstanceIdOrLegacyWorkspaceIdExactly,
11
+ matchesNewWorkspaceIdExactly,
12
+ parseWorkspaceIdFromHostname,
13
+ } from "./parse-workspace-id";
10
14
  const expect = chai.expect;
11
15
 
12
16
  @suite
13
17
  export class ParseWorkspaceIdTest {
14
-
15
18
  @test public parseWorkspaceIdFromHostname_fromWorkspaceLocation() {
19
+ const actual = parseWorkspaceIdFromHostname("moccasin-ferret-155799b3.ws-eu01.gitpod.io");
20
+ expect(actual).to.equal("moccasin-ferret-155799b3");
21
+ }
22
+
23
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocation() {
24
+ const actual = parseWorkspaceIdFromHostname("3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
25
+ expect(actual).to.equal("moccasin-ferret-155799b3");
26
+ }
27
+
28
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
29
+ const actual = parseWorkspaceIdFromHostname("webview-3000-moccasin-ferret-155799b3.ws-eu01.gitpod.io");
30
+ expect(actual).to.equal("moccasin-ferret-155799b3");
31
+ }
32
+
33
+ @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
34
+ const actual = parseWorkspaceIdFromHostname(
35
+ "webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com",
36
+ );
37
+ expect(actual).to.equal("moccasin-ferret-155799b3");
38
+ }
39
+
40
+ // legacy mode
41
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspaceLocation() {
16
42
  const actual = parseWorkspaceIdFromHostname("b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
17
43
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
18
44
  }
19
45
 
20
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocation() {
46
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocation() {
21
47
  const actual = parseWorkspaceIdFromHostname("3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
22
48
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
23
49
  }
24
50
 
25
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
26
- const actual = parseWorkspaceIdFromHostname("webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io");
51
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
52
+ const actual = parseWorkspaceIdFromHostname(
53
+ "webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io",
54
+ );
27
55
  expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
28
56
  }
29
57
 
30
- @test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
31
- const actual = parseWorkspaceIdFromHostname("webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com");
58
+ @test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
59
+ const actual = parseWorkspaceIdFromHostname(
60
+ "webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com",
61
+ );
32
62
  expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
33
63
  }
64
+
65
+ // match - instance ID
66
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
67
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
68
+ expect(actual).to.be.true;
69
+ }
70
+ @test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
71
+ const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
72
+ expect(actual).to.be.false;
73
+ }
74
+
75
+ // match - new workspace ID
76
+ @test public matchesWorkspaceIdExactly_new_positive() {
77
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
78
+ expect(actual).to.be.true;
79
+ }
80
+ @test public matchesWorkspaceIdExactly_new_negative() {
81
+ const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
82
+ expect(actual).to.be.false;
83
+ }
34
84
  }
35
- module.exports = new ParseWorkspaceIdTest()
85
+ module.exports = new ParseWorkspaceIdTest();
@@ -4,21 +4,51 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
+ const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
8
+ const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
9
+ // We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
10
+ const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
11
+
12
+ const REGEX_WORKSPACE_ID_LEGACY = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
13
+ const REGEX_WORKSPACE_ID_LEGACY_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID_LEGACY.source}$`);
14
+ const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID_LEGACY.source})\.ws`);
7
15
 
8
16
  /**
9
17
  * Hostname may be of the form:
10
- * - b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io
11
- * - 1234-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io
12
- * - webview-1234-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io (or any other string replacing webview)
18
+ * - moccasin-ferret-155799b3.ws-eu01.gitpod.io
19
+ * - 1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io
20
+ * - webview-1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io (or any other string replacing webview)
13
21
  * @param hostname The hostname the request is headed to
14
22
  */
15
- export const parseWorkspaceIdFromHostname = function(hostname: string) {
16
- // We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
17
- const wsIdExpression = /([a-z][0-9a-z]+\-([0-9a-z]+\-){3}[0-9a-z]+)\.ws/g;
18
- const match = wsIdExpression.exec(hostname);
23
+ export const parseWorkspaceIdFromHostname = function (hostname: string) {
24
+ const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
19
25
  if (match && match.length >= 2) {
20
26
  return match[1];
21
27
  } else {
28
+ const legacyMatch = REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME.exec(hostname);
29
+ if (legacyMatch && legacyMatch.length >= 2) {
30
+ return legacyMatch[1];
31
+ }
22
32
  return undefined;
23
33
  }
24
- }
34
+ };
35
+
36
+ /** Equalls UUIDv4 (and REGEX_WORKSPACE_ID_LEGACY!) */
37
+ const REGEX_INSTANCE_ID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
38
+ const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
39
+
40
+ /**
41
+ * @param maybeId
42
+ * @returns
43
+ */
44
+ export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function (maybeId: string): boolean {
45
+ return REGEX_INSTANCE_ID_EXACT.test(maybeId) || REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
46
+ };
47
+
48
+ /**
49
+ * @param maybeWorkspaceId
50
+ * @returns
51
+ */
52
+ export const matchesNewWorkspaceIdExactly = function (maybeWorkspaceId: string): boolean {
53
+ return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
54
+ };
@@ -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, 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
 
@@ -32,11 +32,10 @@ const expect = chai.expect
32
32
  return new Promise((resolve) => {
33
33
  setTimeout(() => {
34
34
  this.seq.push(seqNr);
35
- resolve();
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
  });