@gitpod/gitpod-protocol 0.1.5-to-code-reading.1 → 0.1.5-to-monitor-delete.18

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 (361) hide show
  1. package/data/gitpod-schema.json +124 -5
  2. package/lib/accounting-protocol.d.ts +18 -10
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +34 -32
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +19 -0
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js.map +1 -1
  9. package/lib/analytics.d.ts +4 -5
  10. package/lib/analytics.d.ts.map +1 -1
  11. package/lib/analytics.js.map +1 -1
  12. package/lib/attribution.d.ts +24 -0
  13. package/lib/attribution.d.ts.map +1 -0
  14. package/lib/attribution.js +54 -0
  15. package/lib/attribution.js.map +1 -0
  16. package/lib/auth.d.ts.map +1 -1
  17. package/lib/billing-mode.d.ts +45 -0
  18. package/lib/billing-mode.d.ts.map +1 -0
  19. package/lib/billing-mode.js +44 -0
  20. package/lib/billing-mode.js.map +1 -0
  21. package/lib/blocked-repositories-protocol.d.ts +13 -0
  22. package/lib/blocked-repositories-protocol.d.ts.map +1 -0
  23. package/lib/blocked-repositories-protocol.js +8 -0
  24. package/lib/blocked-repositories-protocol.js.map +1 -0
  25. package/lib/context-url.d.ts +18 -5
  26. package/lib/context-url.d.ts.map +1 -1
  27. package/lib/context-url.js +59 -6
  28. package/lib/context-url.js.map +1 -1
  29. package/lib/context-url.spec.d.ts +2 -0
  30. package/lib/context-url.spec.d.ts.map +1 -1
  31. package/lib/context-url.spec.js +40 -4
  32. package/lib/context-url.spec.js.map +1 -1
  33. package/lib/encryption/container-module.d.ts.map +1 -1
  34. package/lib/encryption/container-module.js +1 -1
  35. package/lib/encryption/container-module.js.map +1 -1
  36. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  37. package/lib/encryption/encryption-engine.js +9 -9
  38. package/lib/encryption/encryption-engine.js.map +1 -1
  39. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  40. package/lib/encryption/encryption-engine.spec.js +2 -3
  41. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  42. package/lib/encryption/encryption-service.d.ts.map +1 -1
  43. package/lib/encryption/encryption-service.js +1 -1
  44. package/lib/encryption/encryption-service.js.map +1 -1
  45. package/lib/encryption/key-provider.d.ts.map +1 -1
  46. package/lib/encryption/key-provider.js +7 -9
  47. package/lib/encryption/key-provider.js.map +1 -1
  48. package/lib/env.d.ts +0 -5
  49. package/lib/env.d.ts.map +1 -1
  50. package/lib/env.js +1 -20
  51. package/lib/env.js.map +1 -1
  52. package/lib/experiments/always-default.d.ts +8 -0
  53. package/lib/experiments/always-default.d.ts.map +1 -0
  54. package/lib/experiments/always-default.js +20 -0
  55. package/lib/experiments/always-default.js.map +1 -0
  56. package/lib/experiments/configcat-server.d.ts +10 -0
  57. package/lib/experiments/configcat-server.d.ts.map +1 -0
  58. package/lib/experiments/configcat-server.js +36 -0
  59. package/lib/experiments/configcat-server.js.map +1 -0
  60. package/lib/experiments/configcat.d.ts +21 -0
  61. package/lib/experiments/configcat.d.ts.map +1 -0
  62. package/lib/experiments/configcat.js +51 -0
  63. package/lib/experiments/configcat.js.map +1 -0
  64. package/lib/experiments/types.d.ts +22 -0
  65. package/lib/experiments/types.d.ts.map +1 -0
  66. package/lib/experiments/types.js +10 -0
  67. package/lib/experiments/types.js.map +1 -0
  68. package/lib/gitpod-file-parser.d.ts.map +1 -1
  69. package/lib/gitpod-file-parser.js +6 -6
  70. package/lib/gitpod-file-parser.js.map +1 -1
  71. package/lib/gitpod-file-parser.spec.js +42 -39
  72. package/lib/gitpod-file-parser.spec.js.map +1 -1
  73. package/lib/gitpod-service.d.ts +83 -45
  74. package/lib/gitpod-service.d.ts.map +1 -1
  75. package/lib/gitpod-service.js +52 -33
  76. package/lib/gitpod-service.js.map +1 -1
  77. package/lib/headless-workspace-log.d.ts +1 -0
  78. package/lib/headless-workspace-log.d.ts.map +1 -1
  79. package/lib/headless-workspace-log.js +2 -1
  80. package/lib/headless-workspace-log.js.map +1 -1
  81. package/lib/ide-frontend-service.d.ts +1 -1
  82. package/lib/ide-protocol.d.ts +38 -6
  83. package/lib/ide-protocol.d.ts.map +1 -1
  84. package/lib/index.d.ts +16 -15
  85. package/lib/index.d.ts.map +1 -1
  86. package/lib/index.js +2 -1
  87. package/lib/index.js.map +1 -1
  88. package/lib/installation-admin-protocol.d.ts +30 -0
  89. package/lib/installation-admin-protocol.d.ts.map +1 -0
  90. package/lib/installation-admin-protocol.js +31 -0
  91. package/lib/installation-admin-protocol.js.map +1 -0
  92. package/lib/license-protocol.d.ts +7 -0
  93. package/lib/license-protocol.d.ts.map +1 -1
  94. package/lib/license-protocol.js.map +1 -1
  95. package/lib/messaging/browser/connection.d.ts +1 -1
  96. package/lib/messaging/browser/connection.d.ts.map +1 -1
  97. package/lib/messaging/browser/connection.js +19 -19
  98. package/lib/messaging/browser/connection.js.map +1 -1
  99. package/lib/messaging/browser/window-connection.d.ts +4 -4
  100. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  101. package/lib/messaging/browser/window-connection.js +9 -6
  102. package/lib/messaging/browser/window-connection.js.map +1 -1
  103. package/lib/messaging/client-call-metrics.d.ts +2 -18
  104. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  105. package/lib/messaging/client-call-metrics.js +21 -22
  106. package/lib/messaging/client-call-metrics.js.map +1 -1
  107. package/lib/messaging/error.d.ts +8 -1
  108. package/lib/messaging/error.d.ts.map +1 -1
  109. package/lib/messaging/error.js +17 -3
  110. package/lib/messaging/error.js.map +1 -1
  111. package/lib/messaging/handler.d.ts.map +1 -1
  112. package/lib/messaging/handler.js +1 -1
  113. package/lib/messaging/node/connection.js +8 -8
  114. package/lib/messaging/node/connection.js.map +1 -1
  115. package/lib/messaging/proxy-factory.d.ts +1 -1
  116. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  117. package/lib/messaging/proxy-factory.js +7 -9
  118. package/lib/messaging/proxy-factory.js.map +1 -1
  119. package/lib/payment-protocol.d.ts.map +1 -1
  120. package/lib/payment-protocol.js +1 -1
  121. package/lib/payment-protocol.js.map +1 -1
  122. package/lib/permission.d.ts +9 -3
  123. package/lib/permission.d.ts.map +1 -1
  124. package/lib/permission.js +34 -25
  125. package/lib/permission.js.map +1 -1
  126. package/lib/plans.d.ts +4 -3
  127. package/lib/plans.d.ts.map +1 -1
  128. package/lib/plans.js +210 -171
  129. package/lib/plans.js.map +1 -1
  130. package/lib/protocol.d.ts +192 -59
  131. package/lib/protocol.d.ts.map +1 -1
  132. package/lib/protocol.js +292 -104
  133. package/lib/protocol.js.map +1 -1
  134. package/{src/theia-plugins.ts → lib/protocol.spec.d.ts} +2 -6
  135. package/lib/protocol.spec.d.ts.map +1 -0
  136. package/lib/protocol.spec.js +127 -0
  137. package/lib/protocol.spec.js.map +1 -0
  138. package/lib/snapshot-url.spec.js.map +1 -1
  139. package/lib/team-subscription-protocol.d.ts +22 -3
  140. package/lib/team-subscription-protocol.d.ts.map +1 -1
  141. package/lib/team-subscription-protocol.js +20 -5
  142. package/lib/team-subscription-protocol.js.map +1 -1
  143. package/lib/teams-projects-protocol.d.ts +29 -5
  144. package/lib/teams-projects-protocol.d.ts.map +1 -1
  145. package/lib/teams-projects-protocol.js +8 -1
  146. package/lib/teams-projects-protocol.js.map +1 -1
  147. package/lib/typings/globals.d.ts +2 -2
  148. package/lib/typings/globals.d.ts.map +1 -1
  149. package/lib/usage.d.ts +61 -0
  150. package/lib/usage.d.ts.map +1 -0
  151. package/lib/usage.js +14 -0
  152. package/lib/usage.js.map +1 -0
  153. package/lib/util/analytics.d.ts.map +1 -1
  154. package/lib/util/analytics.js +12 -3
  155. package/lib/util/analytics.js.map +1 -1
  156. package/lib/util/async-iterator.d.ts.map +1 -1
  157. package/lib/util/async-iterator.js +3 -3
  158. package/lib/util/async-iterator.js.map +1 -1
  159. package/lib/util/cancelable.js.map +1 -1
  160. package/lib/util/date-time.js +6 -6
  161. package/lib/util/date-time.js.map +1 -1
  162. package/lib/util/debug-app.d.ts +25 -0
  163. package/lib/util/debug-app.d.ts.map +1 -0
  164. package/lib/util/debug-app.js +100 -0
  165. package/lib/util/debug-app.js.map +1 -0
  166. package/lib/util/deferred.js.map +1 -1
  167. package/lib/util/disposable.d.ts.map +1 -1
  168. package/lib/util/disposable.js +2 -2
  169. package/lib/util/disposable.js.map +1 -1
  170. package/lib/util/event.d.ts.map +1 -1
  171. package/lib/util/event.js +5 -3
  172. package/lib/util/event.js.map +1 -1
  173. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  174. package/lib/util/garbage-collected-cache.js +6 -1
  175. package/lib/util/garbage-collected-cache.js.map +1 -1
  176. package/lib/util/generate-workspace-id.d.ts +5 -0
  177. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  178. package/lib/util/generate-workspace-id.js +446 -442
  179. package/lib/util/generate-workspace-id.js.map +1 -1
  180. package/lib/util/generate-workspace-id.spec.js +18 -7
  181. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  182. package/lib/util/gitpod-cookie.d.ts +1 -1
  183. package/lib/util/gitpod-cookie.d.ts.map +1 -1
  184. package/lib/util/gitpod-cookie.js +0 -3
  185. package/lib/util/gitpod-cookie.js.map +1 -1
  186. package/lib/util/gitpod-host-url.d.ts +3 -0
  187. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  188. package/lib/util/gitpod-host-url.js +49 -29
  189. package/lib/util/gitpod-host-url.js.map +1 -1
  190. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  191. package/lib/util/gitpod-host-url.spec.js +15 -5
  192. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  193. package/lib/util/grpc.d.ts +19 -0
  194. package/lib/util/grpc.d.ts.map +1 -1
  195. package/lib/util/grpc.js +73 -1
  196. package/lib/util/grpc.js.map +1 -1
  197. package/lib/util/jaeger-client-types.d.ts.map +1 -1
  198. package/lib/util/logging.d.ts +1 -1
  199. package/lib/util/logging.d.ts.map +1 -1
  200. package/lib/util/logging.js +31 -25
  201. package/lib/util/logging.js.map +1 -1
  202. package/lib/util/logging.spec.d.ts +7 -0
  203. package/lib/util/logging.spec.d.ts.map +1 -0
  204. package/lib/util/logging.spec.js +52 -0
  205. package/lib/util/logging.spec.js.map +1 -0
  206. package/lib/util/make-link.js +5 -5
  207. package/lib/util/make-link.js.map +1 -1
  208. package/lib/util/nice-grpc.d.ts +9 -0
  209. package/lib/util/nice-grpc.d.ts.map +1 -0
  210. package/lib/util/nice-grpc.js +119 -0
  211. package/lib/util/nice-grpc.js.map +1 -0
  212. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  213. package/lib/util/parse-workspace-id.js +1 -2
  214. package/lib/util/parse-workspace-id.js.map +1 -1
  215. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  216. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  217. package/lib/util/queue.spec.js +9 -6
  218. package/lib/util/queue.spec.js.map +1 -1
  219. package/lib/util/semaphore.d.ts.map +1 -1
  220. package/lib/util/semaphore.js.map +1 -1
  221. package/lib/util/skip-if.d.ts.map +1 -1
  222. package/lib/util/skip-if.js.map +1 -1
  223. package/lib/util/timeutil.d.ts +2 -0
  224. package/lib/util/timeutil.d.ts.map +1 -1
  225. package/lib/util/timeutil.js +15 -3
  226. package/lib/util/timeutil.js.map +1 -1
  227. package/lib/util/timeutil.spec.d.ts +2 -0
  228. package/lib/util/timeutil.spec.d.ts.map +1 -1
  229. package/lib/util/timeutil.spec.js +34 -0
  230. package/lib/util/timeutil.spec.js.map +1 -1
  231. package/lib/util/tracing.d.ts +8 -8
  232. package/lib/util/tracing.d.ts.map +1 -1
  233. package/lib/util/tracing.js +19 -20
  234. package/lib/util/tracing.js.map +1 -1
  235. package/lib/util/tracing.spec.js +3 -3
  236. package/lib/util/tracing.spec.js.map +1 -1
  237. package/lib/util/workspace-port-authentication.d.ts +7 -7
  238. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  239. package/lib/util/workspace-port-authentication.js +8 -11
  240. package/lib/util/workspace-port-authentication.js.map +1 -1
  241. package/lib/webhook-event.d.ts +44 -0
  242. package/lib/webhook-event.d.ts.map +1 -0
  243. package/lib/{theia-plugins.js → webhook-event.js} +2 -2
  244. package/lib/webhook-event.js.map +1 -0
  245. package/lib/workspace-class.d.ts +14 -0
  246. package/lib/workspace-class.d.ts.map +1 -0
  247. package/lib/workspace-class.js +8 -0
  248. package/lib/workspace-class.js.map +1 -0
  249. package/lib/workspace-cluster.d.ts +18 -17
  250. package/lib/workspace-cluster.d.ts.map +1 -1
  251. package/lib/workspace-cluster.js +16 -1
  252. package/lib/workspace-cluster.js.map +1 -1
  253. package/lib/workspace-instance.d.ts +39 -3
  254. package/lib/workspace-instance.d.ts.map +1 -1
  255. package/lib/wsready.d.ts +1 -1
  256. package/lib/wsready.d.ts.map +1 -1
  257. package/lib/wsready.js +2 -2
  258. package/package.json +15 -7
  259. package/pkg-yarn.lock +11 -6
  260. package/provenance-bundle.jsonl +3 -1
  261. package/src/accounting-protocol.ts +66 -51
  262. package/src/admin-protocol.ts +45 -18
  263. package/src/analytics.ts +26 -28
  264. package/src/attribution.ts +63 -0
  265. package/src/auth.ts +2 -2
  266. package/src/billing-mode.ts +84 -0
  267. package/src/blocked-repositories-protocol.ts +13 -0
  268. package/src/context-url.spec.ts +37 -9
  269. package/src/context-url.ts +94 -36
  270. package/src/encryption/container-module.ts +2 -3
  271. package/src/encryption/encryption-engine.spec.ts +9 -8
  272. package/src/encryption/encryption-engine.ts +20 -16
  273. package/src/encryption/encryption-service.ts +4 -5
  274. package/src/encryption/key-provider.ts +16 -19
  275. package/src/env.ts +0 -22
  276. package/src/experiments/always-default.ts +24 -0
  277. package/src/experiments/configcat-server.ts +41 -0
  278. package/src/experiments/configcat.ts +56 -0
  279. package/src/experiments/types.ts +34 -0
  280. package/src/gitpod-file-parser.spec.ts +55 -61
  281. package/src/gitpod-file-parser.ts +16 -17
  282. package/src/gitpod-service.ts +228 -129
  283. package/src/headless-workspace-log.ts +6 -4
  284. package/src/ide-frontend-service.ts +2 -2
  285. package/src/ide-protocol.ts +43 -6
  286. package/src/index.ts +16 -15
  287. package/src/installation-admin-protocol.ts +45 -0
  288. package/src/license-protocol.ts +12 -6
  289. package/src/messaging/browser/connection.ts +45 -47
  290. package/src/messaging/browser/window-connection.ts +39 -29
  291. package/src/messaging/client-call-metrics.ts +62 -82
  292. package/src/messaging/error.ts +26 -7
  293. package/src/messaging/handler.ts +6 -6
  294. package/src/messaging/node/connection.ts +8 -8
  295. package/src/messaging/proxy-factory.ts +23 -30
  296. package/src/oss-allowlist.ts +3 -3
  297. package/src/payment-protocol.ts +2 -2
  298. package/src/permission.ts +40 -32
  299. package/src/plans.ts +240 -189
  300. package/src/protocol.spec.ts +97 -0
  301. package/src/protocol.ts +556 -258
  302. package/src/snapshot-url.spec.ts +9 -7
  303. package/src/team-subscription-protocol.ts +59 -22
  304. package/src/teams-projects-protocol.ts +43 -12
  305. package/src/typings/globals.ts +4 -4
  306. package/src/usage.ts +71 -0
  307. package/src/util/analytics.ts +46 -24
  308. package/src/util/async-iterator.ts +4 -5
  309. package/src/util/cancelable.ts +3 -3
  310. package/src/util/date-time.ts +8 -8
  311. package/src/util/debug-app.ts +81 -0
  312. package/src/util/deferred.ts +6 -6
  313. package/src/util/disposable.ts +3 -6
  314. package/src/util/event.ts +9 -11
  315. package/src/util/garbage-collected-cache.ts +8 -6
  316. package/src/util/generate-workspace-id.spec.ts +26 -16
  317. package/src/util/generate-workspace-id.ts +460 -454
  318. package/src/util/gitpod-cookie.ts +8 -9
  319. package/src/util/gitpod-host-url.spec.ts +40 -13
  320. package/src/util/gitpod-host-url.ts +57 -33
  321. package/src/util/grpc.ts +90 -1
  322. package/src/util/jaeger-client-types.ts +2 -2
  323. package/src/util/logging.spec.ts +23 -0
  324. package/src/util/logging.ts +60 -42
  325. package/src/util/make-link.ts +6 -7
  326. package/src/util/nice-grpc.ts +93 -0
  327. package/src/util/parse-workspace-id.spec.ts +17 -8
  328. package/src/util/parse-workspace-id.ts +5 -6
  329. package/src/util/queue.spec.ts +27 -25
  330. package/src/util/repeat.ts +1 -1
  331. package/src/util/semaphore.ts +4 -6
  332. package/src/util/skip-if.ts +9 -6
  333. package/src/util/timeutil.spec.ts +40 -14
  334. package/src/util/timeutil.ts +27 -11
  335. package/src/util/tracing.spec.ts +28 -23
  336. package/src/util/tracing.ts +58 -54
  337. package/src/util/workspace-port-authentication.ts +10 -13
  338. package/src/webhook-event.ts +55 -0
  339. package/src/workspace-class.ts +14 -0
  340. package/src/workspace-cluster.ts +34 -20
  341. package/src/workspace-instance.ts +76 -20
  342. package/src/wsready.ts +3 -3
  343. package/data/builtin-theia-plugins.json +0 -372
  344. package/lib/email-protocol.d.ts +0 -49
  345. package/lib/email-protocol.d.ts.map +0 -1
  346. package/lib/email-protocol.js +0 -28
  347. package/lib/email-protocol.js.map +0 -1
  348. package/lib/messaging/connection-error-handler.d.ts +0 -27
  349. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  350. package/lib/messaging/connection-error-handler.js +0 -34
  351. package/lib/messaging/connection-error-handler.js.map +0 -1
  352. package/lib/theia-plugins.d.ts +0 -11
  353. package/lib/theia-plugins.d.ts.map +0 -1
  354. package/lib/theia-plugins.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 -31
  358. package/lib/util/safe-promise.js.map +0 -1
  359. package/src/email-protocol.ts +0 -66
  360. package/src/messaging/connection-error-handler.ts +0 -62
  361. package/src/util/safe-promise.ts +0 -26
@@ -5,31 +5,63 @@
5
5
  */
6
6
 
7
7
  import {
8
- User, WorkspaceInfo, WorkspaceCreationResult, WorkspaceInstanceUser,
9
- WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, CreateWorkspaceMode,
10
- Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
- ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
- GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes, ProjectEnvVar
13
- } from './protocol';
8
+ User,
9
+ WorkspaceInfo,
10
+ WorkspaceCreationResult,
11
+ WorkspaceInstanceUser,
12
+ WhitelistedRepository,
13
+ WorkspaceImageBuild,
14
+ AuthProviderInfo,
15
+ Token,
16
+ UserEnvVarValue,
17
+ Terms,
18
+ Configuration,
19
+ UserInfo,
20
+ GitpodTokenType,
21
+ GitpodToken,
22
+ AuthProviderEntry,
23
+ GuessGitTokenScopesParams,
24
+ GuessedGitTokenScopes,
25
+ ProjectEnvVar,
26
+ PrebuiltWorkspace,
27
+ UserSSHPublicKeyValue,
28
+ SSHPublicKeyValue,
29
+ } from "./protocol";
14
30
  import {
15
- Team, TeamMemberInfo,
16
- TeamMembershipInvite, Project, TeamMemberRole, PrebuildWithStatus, StartPrebuildResult, PartialProject
17
- } from './teams-projects-protocol';
18
- import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
19
- import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
20
- import { HeadlessLogUrls } from './headless-workspace-log';
21
- import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
22
- import { AdminServer } from './admin-protocol';
23
- import { GitpodHostUrl } from './util/gitpod-host-url';
24
- import { WebSocketConnectionProvider } from './messaging/browser/connection';
25
- import { PermissionName } from './permission';
26
- import { LicenseService } from './license-protocol';
27
- import { Emitter } from './util/event';
28
- import { AccountStatement, CreditAlert } from './accounting-protocol';
29
- import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
30
- import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
31
- import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from './analytics';
32
- import { IDEServer } from './ide-protocol';
31
+ Team,
32
+ TeamMemberInfo,
33
+ TeamMembershipInvite,
34
+ Project,
35
+ TeamMemberRole,
36
+ PrebuildWithStatus,
37
+ StartPrebuildResult,
38
+ PartialProject,
39
+ PrebuildEvent,
40
+ } from "./teams-projects-protocol";
41
+ import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
42
+ import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
43
+ import { HeadlessLogUrls } from "./headless-workspace-log";
44
+ import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from "./workspace-instance";
45
+ import { AdminServer } from "./admin-protocol";
46
+ import { GitpodHostUrl } from "./util/gitpod-host-url";
47
+ import { WebSocketConnectionProvider } from "./messaging/browser/connection";
48
+ import { PermissionName } from "./permission";
49
+ import { LicenseService } from "./license-protocol";
50
+ import { Emitter } from "./util/event";
51
+ import { AccountStatement, CreditAlert } from "./accounting-protocol";
52
+ import { GithubUpgradeURL, PlanCoupon } from "./payment-protocol";
53
+ import {
54
+ TeamSubscription,
55
+ TeamSubscription2,
56
+ TeamSubscriptionSlot,
57
+ TeamSubscriptionSlotResolved,
58
+ } from "./team-subscription-protocol";
59
+ import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
60
+ import { IDEServer } from "./ide-protocol";
61
+ import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
62
+ import { ListUsageRequest, ListUsageResponse } from "./usage";
63
+ import { SupportedWorkspaceClass } from "./workspace-class";
64
+ import { BillingMode } from "./billing-mode";
33
65
 
34
66
  export interface GitpodClient {
35
67
  onInstanceUpdate(instance: WorkspaceInstance): void;
@@ -37,6 +69,8 @@ export interface GitpodClient {
37
69
 
38
70
  onPrebuildUpdate(update: PrebuildWithStatus): void;
39
71
 
72
+ onNotificationUpdated(): void;
73
+
40
74
  onCreditAlert(creditAlert: CreditAlert): void;
41
75
 
42
76
  //#region propagating reconnection to iframe
@@ -45,12 +79,14 @@ export interface GitpodClient {
45
79
  //#endregion
46
80
  }
47
81
 
48
- export const GitpodServer = Symbol('GitpodServer');
82
+ export const GitpodServer = Symbol("GitpodServer");
49
83
  export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
50
84
  // User related API
51
85
  getLoggedInUser(): Promise<User>;
52
86
  getTerms(): Promise<Terms>;
53
87
  updateLoggedInUser(user: Partial<User>): Promise<User>;
88
+ sendPhoneNumberVerificationToken(phoneNumber: string): Promise<void>;
89
+ verifyPhoneNumberVerificationToken(phoneNumber: string, token: string): Promise<boolean>;
54
90
  getAuthProviders(): Promise<AuthProviderInfo[]>;
55
91
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
56
92
  updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
@@ -71,8 +107,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
71
107
  getWorkspaceOwner(workspaceId: string): Promise<UserInfo | undefined>;
72
108
  getWorkspaceUsers(workspaceId: string): Promise<WorkspaceInstanceUser[]>;
73
109
  getFeaturedRepositories(): Promise<WhitelistedRepository[]>;
110
+ getSuggestedContextURLs(): Promise<string[]>;
111
+ /**
112
+ * **Security:**
113
+ * Sensitive information like an owner token is erased, since it allows access for all team members.
114
+ * If you need to access an owner token use `getOwnerToken` instead.
115
+ */
74
116
  getWorkspace(id: string): Promise<WorkspaceInfo>;
75
117
  isWorkspaceOwner(workspaceId: string): Promise<boolean>;
118
+ getOwnerToken(workspaceId: string): Promise<string>;
76
119
 
77
120
  /**
78
121
  * Creates and starts a workspace for the given context URL.
@@ -114,7 +157,14 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
114
157
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
115
158
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
116
159
 
160
+ // User SSH Keys
161
+ hasSSHPublicKey(): Promise<boolean>;
162
+ getSSHPublicKeys(): Promise<UserSSHPublicKeyValue[]>;
163
+ addSSHPublicKey(value: SSHPublicKeyValue): Promise<UserSSHPublicKeyValue>;
164
+ deleteSSHPublicKey(id: string): Promise<void>;
165
+
117
166
  // Teams
167
+ getTeam(teamId: string): Promise<Team>;
118
168
  getTeams(): Promise<Team[]>;
119
169
  getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
120
170
  createTeam(name: string): Promise<Team>;
@@ -123,7 +173,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
123
173
  removeTeamMember(teamId: string, userId: string): Promise<void>;
124
174
  getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
125
175
  resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
126
- deleteTeam(teamId: string, userId: string): Promise<void>;
176
+ deleteTeam(teamId: string): Promise<void>;
177
+
178
+ // Admin Settings
179
+ adminGetSettings(): Promise<InstallationAdminSettings>;
180
+ adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
181
+ adminGetTelemetryData(): Promise<TelemetryData>;
127
182
 
128
183
  // Projects
129
184
  getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
@@ -132,22 +187,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
132
187
  getTeamProjects(teamId: string): Promise<Project[]>;
133
188
  getUserProjects(): Promise<Project[]>;
134
189
  getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
190
+ getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
135
191
  findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
192
+ findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
193
+ getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
136
194
  triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
137
195
  cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
138
- fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
139
- guessProjectConfiguration(projectId: string): Promise<string | undefined>;
140
- fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
141
- guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
142
- setProjectConfiguration(projectId: string, configString: string): Promise<void>;
143
196
  updateProjectPartial(partialProject: PartialProject): Promise<void>;
144
197
  setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
145
198
  getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
146
199
  deleteProjectEnvironmentVariable(variableId: string): Promise<void>;
147
200
 
148
201
  // content service
149
- getContentBlobUploadUrl(name: string): Promise<string>
150
- getContentBlobDownloadUrl(name: string): Promise<string>
202
+ getContentBlobUploadUrl(name: string): Promise<string>;
203
+ getContentBlobDownloadUrl(name: string): Promise<string>;
151
204
 
152
205
  // Gitpod token
153
206
  getGitpodTokens(): Promise<GitpodToken[]>;
@@ -155,7 +208,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
155
208
  deleteGitpodToken(tokenHash: string): Promise<void>;
156
209
 
157
210
  // misc
158
- sendFeedback(feedback: string): Promise<string | undefined>;
211
+ isGitHubAppEnabled(): Promise<boolean>;
159
212
  registerGithubApp(installationId: string): Promise<void>;
160
213
 
161
214
  /**
@@ -174,25 +227,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
174
227
  */
175
228
  getSnapshots(workspaceID: string): Promise<string[]>;
176
229
 
177
- /**
178
- * stores/updates layout information for the given workspace
179
- */
180
- storeLayout(workspaceId: string, layoutData: string): Promise<void>;
181
-
182
- /**
183
- * retrieves layout information for the given workspace
184
- */
185
- getLayout(workspaceId: string): Promise<string | undefined>;
186
-
187
- /**
188
- * @param params
189
- * @returns promise resolves to an URL to be used for the upload
190
- */
191
- preparePluginUpload(params: PreparePluginUploadParams): Promise<string>
192
- resolvePlugins(workspaceId: string, params: ResolvePluginsParams): Promise<ResolvedPlugins>;
193
- installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
194
- uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
195
-
196
230
  guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
197
231
 
198
232
  /**
@@ -210,7 +244,9 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
210
244
  */
211
245
  getChargebeeSiteId(): Promise<string>;
212
246
  createPortalSession(): Promise<{}>;
247
+ createTeamPortalSession(teamId: string): Promise<{}>;
213
248
  checkout(planId: string, planQuantity?: number): Promise<{}>;
249
+ teamCheckout(teamId: string, planId: string): Promise<{}>;
214
250
  getAvailableCoupons(): Promise<PlanCoupon[]>;
215
251
  getAppliedCoupons(): Promise<PlanCoupon[]>;
216
252
 
@@ -222,30 +258,67 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
222
258
  subscriptionCancel(subscriptionId: string): Promise<void>;
223
259
  subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
224
260
 
261
+ getTeamSubscription(teamId: string): Promise<TeamSubscription2 | undefined>;
225
262
  tsGet(): Promise<TeamSubscription[]>;
226
263
  tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
227
- tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
264
+ tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
228
265
  tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
229
- tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string | undefined): Promise<void>
266
+ tsAssignSlot(
267
+ teamSubscriptionId: string,
268
+ teamSubscriptionSlotId: string,
269
+ identityStr: string | undefined,
270
+ ): Promise<void>;
230
271
  tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
231
272
  tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
232
273
  tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
233
274
 
234
275
  getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
235
276
 
277
+ getStripePublishableKey(): Promise<string>;
278
+ getStripeSetupIntentClientSecret(): Promise<string>;
279
+ findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
280
+ createStripeCustomerIfNeeded(attributionId: string, currency: string): Promise<void>;
281
+ subscribeToStripe(attributionId: string, setupIntentId: string, usageLimit: number): Promise<number | undefined>;
282
+ getStripePortalUrl(attributionId: string): Promise<string>;
283
+ getUsageLimit(attributionId: string): Promise<number | undefined>;
284
+ setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
285
+
286
+ listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
287
+
288
+ setUsageAttribution(usageAttribution: string): Promise<void>;
289
+ listAvailableUsageAttributionIds(): Promise<string[]>;
290
+
291
+ getBillingModeForUser(): Promise<BillingMode>;
292
+ getBillingModeForTeam(teamId: string): Promise<BillingMode>;
293
+
236
294
  /**
237
295
  * Analytics
238
296
  */
239
297
  trackEvent(event: RemoteTrackMessage): Promise<void>;
240
298
  trackLocation(event: RemotePageMessage): Promise<void>;
241
299
  identifyUser(event: RemoteIdentifyMessage): Promise<void>;
300
+
301
+ /**
302
+ * Frontend notifications
303
+ */
304
+ getNotifications(): Promise<string[]>;
305
+
306
+ getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
307
+ }
308
+
309
+ export interface RateLimiterError {
310
+ method?: string;
311
+
312
+ /**
313
+ * Retry after this many seconds, earliest.
314
+ * cmp.: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
315
+ */
316
+ retryAfter: number;
242
317
  }
243
318
 
244
319
  export interface CreateProjectParams {
245
320
  name: string;
246
- slug?: string;
247
- account: string;
248
- provider: string;
321
+ slug: string;
249
322
  cloneUrl: string;
250
323
  teamId?: string;
251
324
  userId?: string;
@@ -269,7 +342,7 @@ export interface ProviderRepository {
269
342
  account: string;
270
343
  accountAvatarUrl: string;
271
344
  cloneUrl: string;
272
- updatedAt: string;
345
+ updatedAt?: string;
273
346
  installationId?: number;
274
347
  installationUpdatedAt?: string;
275
348
 
@@ -283,42 +356,56 @@ export interface ClientHeaderFields {
283
356
  clientRegion?: string;
284
357
  }
285
358
 
286
- export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
287
-
288
- export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): GitpodServiceImpl<C, S> {
359
+ export const WORKSPACE_TIMEOUT_DEFAULT_SHORT = "short";
360
+ export const WORKSPACE_TIMEOUT_DEFAULT_LONG = "long";
361
+ export const WORKSPACE_TIMEOUT_EXTENDED = "extended";
362
+ export const WORKSPACE_TIMEOUT_EXTENDED_ALT = "180m"; // for backwards compatibility since the IDE uses this
363
+ export const WorkspaceTimeoutValues = [
364
+ WORKSPACE_TIMEOUT_DEFAULT_SHORT,
365
+ WORKSPACE_TIMEOUT_DEFAULT_LONG,
366
+ WORKSPACE_TIMEOUT_EXTENDED,
367
+ WORKSPACE_TIMEOUT_EXTENDED_ALT,
368
+ ] as const;
369
+
370
+ export const createServiceMock = function <C extends GitpodClient, S extends GitpodServer>(
371
+ methods: Partial<JsonRpcProxy<S>>,
372
+ ): GitpodServiceImpl<C, S> {
289
373
  return new GitpodServiceImpl<C, S>(createServerMock(methods));
290
- }
374
+ };
291
375
 
292
- export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(methods: Partial<JsonRpcProxy<S>>): JsonRpcProxy<S> {
293
- methods.setClient = methods.setClient || (() => { });
294
- methods.dispose = methods.dispose || (() => { });
376
+ export const createServerMock = function <C extends GitpodClient, S extends GitpodServer>(
377
+ methods: Partial<JsonRpcProxy<S>>,
378
+ ): JsonRpcProxy<S> {
379
+ methods.setClient = methods.setClient || (() => {});
380
+ methods.dispose = methods.dispose || (() => {});
295
381
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
296
382
  // @ts-ignore
297
383
  get: (target: S, property: keyof S) => {
298
384
  const result = target[property];
299
385
  if (!result) {
300
- throw new Error(`Method ${property} not implemented`);
386
+ throw new Error(`Method ${String(property)} not implemented`);
301
387
  }
302
388
  return result;
303
- }
389
+ },
304
390
  });
305
- }
391
+ };
306
392
 
307
393
  type WorkspaceTimeoutDurationTuple = typeof WorkspaceTimeoutValues;
308
394
  export type WorkspaceTimeoutDuration = WorkspaceTimeoutDurationTuple[number];
309
395
 
310
396
  export interface SetWorkspaceTimeoutResult {
311
- resetTimeoutOnWorkspaces: string[]
397
+ resetTimeoutOnWorkspaces: string[];
312
398
  }
313
399
 
314
400
  export interface GetWorkspaceTimeoutResult {
315
- duration: WorkspaceTimeoutDuration
316
- canChange: boolean
401
+ duration: WorkspaceTimeoutDuration;
402
+ durationRaw: string;
403
+ canChange: boolean;
317
404
  }
318
405
 
319
406
  export interface StartWorkspaceResult {
320
- instanceID: string
321
- workspaceURL?: string
407
+ instanceID: string;
408
+ workspaceURL?: string;
322
409
  }
323
410
 
324
411
  export namespace GitpodServer {
@@ -334,7 +421,10 @@ export namespace GitpodServer {
334
421
  }
335
422
  export interface CreateWorkspaceOptions {
336
423
  contextUrl: string;
337
- mode?: CreateWorkspaceMode;
424
+ // whether running workspaces on the same context should be ignored. If false (default) users will be asked.
425
+ ignoreRunningWorkspaceOnSameCommit?: boolean;
426
+ ignoreRunningPrebuild?: boolean;
427
+ allowUsingPreviousPrebuilds?: boolean;
338
428
  forceDefaultConfig?: boolean;
339
429
  }
340
430
  export interface StartWorkspaceOptions {
@@ -342,7 +432,6 @@ export namespace GitpodServer {
342
432
  }
343
433
  export interface TakeSnapshotOptions {
344
434
  workspaceId: string;
345
- layoutData?: string;
346
435
  /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
347
436
  dontWait?: boolean;
348
437
  }
@@ -362,23 +451,23 @@ export namespace GitpodServer {
362
451
  readonly roundTripTime?: number;
363
452
  }
364
453
  export interface UpdateOwnAuthProviderParams {
365
- readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry
454
+ readonly entry: AuthProviderEntry.UpdateEntry | AuthProviderEntry.NewEntry;
366
455
  }
367
456
  export interface DeleteOwnAuthProviderParams {
368
- readonly id: string
457
+ readonly id: string;
369
458
  }
370
459
  export type AdmissionLevel = "owner" | "everyone";
371
460
  export type PinAction = "pin" | "unpin" | "toggle";
372
461
  export interface GenerateNewGitpodTokenOptions {
373
- name?: string
374
- type: GitpodTokenType
375
- scopes?: string[]
462
+ name?: string;
463
+ type: GitpodTokenType;
464
+ scopes?: string[];
376
465
  }
377
466
  }
378
467
 
379
- export const GitpodServerPath = '/gitpod';
468
+ export const GitpodServerPath = "/gitpod";
380
469
 
381
- export const GitpodServerProxy = Symbol('GitpodServerProxy');
470
+ export const GitpodServerProxy = Symbol("GitpodServerProxy");
382
471
  export type GitpodServerProxy<S extends GitpodServer> = JsonRpcProxy<S>;
383
472
 
384
473
  export class GitpodCompositeClient<Client extends GitpodClient> implements GitpodClient {
@@ -392,8 +481,8 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
392
481
  if (index > -1) {
393
482
  this.clients.splice(index, 1);
394
483
  }
395
- }
396
- }
484
+ },
485
+ };
397
486
  }
398
487
 
399
488
  onInstanceUpdate(instance: WorkspaceInstance): void {
@@ -402,7 +491,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
402
491
  try {
403
492
  client.onInstanceUpdate(instance);
404
493
  } catch (error) {
405
- console.error(error)
494
+ console.error(error);
406
495
  }
407
496
  }
408
497
  }
@@ -414,19 +503,22 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
414
503
  try {
415
504
  client.onPrebuildUpdate(update);
416
505
  } catch (error) {
417
- console.error(error)
506
+ console.error(error);
418
507
  }
419
508
  }
420
509
  }
421
510
  }
422
511
 
423
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
512
+ onWorkspaceImageBuildLogs(
513
+ info: WorkspaceImageBuild.StateInfo,
514
+ content: WorkspaceImageBuild.LogContent | undefined,
515
+ ): void {
424
516
  for (const client of this.clients) {
425
517
  if (client.onWorkspaceImageBuildLogs) {
426
518
  try {
427
519
  client.onWorkspaceImageBuildLogs(info, content);
428
520
  } catch (error) {
429
- console.error(error)
521
+ console.error(error);
430
522
  }
431
523
  }
432
524
  }
@@ -438,7 +530,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
438
530
  try {
439
531
  client.notifyDidOpenConnection();
440
532
  } catch (error) {
441
- console.error(error)
533
+ console.error(error);
442
534
  }
443
535
  }
444
536
  }
@@ -450,7 +542,7 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
450
542
  try {
451
543
  client.notifyDidCloseConnection();
452
544
  } catch (error) {
453
- console.error(error)
545
+ console.error(error);
454
546
  }
455
547
  }
456
548
  }
@@ -462,64 +554,73 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
462
554
  try {
463
555
  client.onCreditAlert(creditAlert);
464
556
  } catch (error) {
465
- console.error(error)
557
+ console.error(error);
466
558
  }
467
559
  }
468
560
  }
469
561
  }
470
562
 
563
+ onNotificationUpdated(): void {
564
+ for (const client of this.clients) {
565
+ if (client.onNotificationUpdated) {
566
+ try {
567
+ client.onNotificationUpdated();
568
+ } catch (error) {
569
+ console.error(error);
570
+ }
571
+ }
572
+ }
573
+ }
471
574
  }
472
575
 
473
576
  export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
474
577
 
475
- const hasWindow = (typeof window !== 'undefined');
578
+ const hasWindow = typeof window !== "undefined";
476
579
  const phasesOrder: Record<WorkspaceInstancePhase, number> = {
477
580
  unknown: 0,
478
581
  preparing: 1,
479
- pending: 2,
480
- creating: 3,
481
- initializing: 4,
482
- running: 5,
483
- interrupted: 6,
484
- stopping: 7,
485
- stopped: 8
582
+ building: 2,
583
+ pending: 3,
584
+ creating: 4,
585
+ initializing: 5,
586
+ running: 6,
587
+ interrupted: 7,
588
+ stopping: 8,
589
+ stopped: 9,
486
590
  };
487
591
  export class WorkspaceInstanceUpdateListener {
488
592
  private readonly onDidChangeEmitter = new Emitter<void>();
489
593
  readonly onDidChange = this.onDidChangeEmitter.event;
490
594
 
491
- private source: 'sync' | 'update' = 'sync';
595
+ private source: "sync" | "update" = "sync";
492
596
 
493
597
  get info(): WorkspaceInfo {
494
598
  return this._info;
495
599
  }
496
600
 
497
- constructor(
498
- private readonly service: GitpodService,
499
- private _info: WorkspaceInfo
500
- ) {
601
+ constructor(private readonly service: GitpodService, private _info: WorkspaceInfo) {
501
602
  service.registerClient({
502
- onInstanceUpdate: instance => {
603
+ onInstanceUpdate: (instance) => {
503
604
  if (this.isOutOfOrder(instance)) {
504
605
  return;
505
606
  }
506
607
  this.cancelSync();
507
608
  this._info.latestInstance = instance;
508
- this.source = 'update';
609
+ this.source = "update";
509
610
  this.onDidChangeEmitter.fire(undefined);
510
611
  },
511
612
  notifyDidOpenConnection: () => {
512
613
  this.sync();
513
- }
614
+ },
514
615
  });
515
616
  if (hasWindow) {
516
617
  // learn about page lifecycle here: https://developers.google.com/web/updates/2018/07/page-lifecycle-api
517
- window.document.addEventListener('visibilitychange', async () => {
518
- if (window.document.visibilityState === 'visible') {
618
+ window.document.addEventListener("visibilitychange", async () => {
619
+ if (window.document.visibilityState === "visible") {
519
620
  this.sync();
520
621
  }
521
622
  });
522
- window.addEventListener('pageshow', e => {
623
+ window.addEventListener("pageshow", (e) => {
523
624
  if (e.persisted) {
524
625
  this.sync();
525
626
  }
@@ -547,12 +648,12 @@ export class WorkspaceInstanceUpdateListener {
547
648
  return;
548
649
  }
549
650
  this._info = info;
550
- this.source = 'sync';
651
+ this.source = "sync";
551
652
  this.onDidChangeEmitter.fire(undefined);
552
653
  } catch (e) {
553
- console.error('failed to sync workspace instance:', e)
654
+ console.error("failed to sync workspace instance:", e);
554
655
  }
555
- })
656
+ });
556
657
  }
557
658
  private cancelSync(): void {
558
659
  if (this.syncTokenSource) {
@@ -569,7 +670,7 @@ export class WorkspaceInstanceUpdateListener {
569
670
  if (instance.workspaceId !== this._info.workspace.id) {
570
671
  return true;
571
672
  }
572
- if (this.source === 'update') {
673
+ if (this.source === "update") {
573
674
  return false;
574
675
  }
575
676
  if (instance.id !== this.info.latestInstance?.id) {
@@ -577,15 +678,13 @@ export class WorkspaceInstanceUpdateListener {
577
678
  }
578
679
  return phasesOrder[instance.status.phase] < phasesOrder[this.info.latestInstance.status.phase];
579
680
  }
580
-
581
681
  }
582
682
 
583
683
  export interface GitpodServiceOptions {
584
- onReconnect?: () => (void | Promise<void>)
684
+ onReconnect?: () => void | Promise<void>;
585
685
  }
586
686
 
587
687
  export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
588
-
589
688
  private readonly compositeClient = new GitpodCompositeClient<Client>();
590
689
 
591
690
  constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
@@ -600,7 +699,8 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
600
699
 
601
700
  private readonly instanceListeners = new Map<string, Promise<WorkspaceInstanceUpdateListener>>();
602
701
  listenToInstance(workspaceId: string): Promise<WorkspaceInstanceUpdateListener> {
603
- const listener = this.instanceListeners.get(workspaceId) ||
702
+ const listener =
703
+ this.instanceListeners.get(workspaceId) ||
604
704
  (async () => {
605
705
  const info = await this.server.getWorkspace(workspaceId);
606
706
  return new WorkspaceInstanceUpdateListener(this, info);
@@ -616,26 +716,25 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
616
716
  }
617
717
  }
618
718
 
619
- export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
719
+ export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(
720
+ serverUrl: string | Promise<string>,
721
+ ) {
620
722
  const toWsUrl = (serverUrl: string) => {
621
- return new GitpodHostUrl(serverUrl)
622
- .asWebsocket()
623
- .withApi({ pathname: GitpodServerPath })
624
- .toString();
723
+ return new GitpodHostUrl(serverUrl).asWebsocket().withApi({ pathname: GitpodServerPath }).toString();
625
724
  };
626
725
  let url: string | Promise<string>;
627
726
  if (typeof serverUrl === "string") {
628
727
  url = toWsUrl(serverUrl);
629
728
  } else {
630
- url = serverUrl.then(url => toWsUrl(url));
729
+ url = serverUrl.then((url) => toWsUrl(url));
631
730
  }
632
731
 
633
732
  const connectionProvider = new WebSocketConnectionProvider();
634
- let onReconnect = () => { };
733
+ let onReconnect = () => {};
635
734
  const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
636
- onListening: socket => {
735
+ onListening: (socket) => {
637
736
  onReconnect = () => socket.reconnect();
638
- }
737
+ },
639
738
  });
640
739
  return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
641
- }
740
+ }