@gitpod/gitpod-protocol 0.1.5-me-version.1 → 0.1.5-me-ingress.14

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 (272) hide show
  1. package/data/gitpod-schema.json +11 -4
  2. package/lib/accounting-protocol.d.ts +3 -6
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +10 -16
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +9 -4
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +45 -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/context-url.d.ts +18 -0
  15. package/lib/context-url.d.ts.map +1 -0
  16. package/lib/context-url.js +49 -0
  17. package/lib/context-url.js.map +1 -0
  18. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +2 -0
  19. package/lib/context-url.spec.d.ts.map +1 -0
  20. package/lib/context-url.spec.js +73 -0
  21. package/lib/context-url.spec.js.map +1 -0
  22. package/lib/email-protocol.d.ts +1 -2
  23. package/lib/email-protocol.d.ts.map +1 -1
  24. package/lib/email-protocol.js +4 -4
  25. package/lib/email-protocol.js.map +1 -1
  26. package/lib/encryption/container-module.js +4 -4
  27. package/lib/encryption/container-module.js.map +1 -1
  28. package/lib/encryption/encryption-engine.js +19 -20
  29. package/lib/encryption/encryption-engine.js.map +1 -1
  30. package/lib/encryption/encryption-engine.spec.js +29 -36
  31. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  32. package/lib/encryption/encryption-service.js +29 -43
  33. package/lib/encryption/encryption-service.js.map +1 -1
  34. package/lib/encryption/key-provider.js +25 -30
  35. package/lib/encryption/key-provider.js.map +1 -1
  36. package/lib/env.d.ts +1 -2
  37. package/lib/env.d.ts.map +1 -1
  38. package/lib/env.js +20 -21
  39. package/lib/env.js.map +1 -1
  40. package/lib/gitpod-file-parser.js +25 -41
  41. package/lib/gitpod-file-parser.js.map +1 -1
  42. package/lib/gitpod-file-parser.spec.js +116 -116
  43. package/lib/gitpod-file-parser.spec.js.map +1 -1
  44. package/lib/gitpod-service.d.ts +86 -9
  45. package/lib/gitpod-service.d.ts.map +1 -1
  46. package/lib/gitpod-service.js +150 -295
  47. package/lib/gitpod-service.js.map +1 -1
  48. package/lib/headless-workspace-log.d.ts +8 -11
  49. package/lib/headless-workspace-log.d.ts.map +1 -1
  50. package/lib/headless-workspace-log.js +4 -7
  51. package/lib/headless-workspace-log.js.map +1 -1
  52. package/lib/ide-protocol.d.ts +81 -0
  53. package/lib/ide-protocol.d.ts.map +1 -0
  54. package/lib/ide-protocol.js +8 -0
  55. package/lib/ide-protocol.js.map +1 -0
  56. package/lib/index.d.ts +4 -0
  57. package/lib/index.d.ts.map +1 -1
  58. package/lib/index.js +4 -0
  59. package/lib/index.js.map +1 -1
  60. package/lib/messaging/browser/connection.d.ts +3 -3
  61. package/lib/messaging/browser/connection.d.ts.map +1 -1
  62. package/lib/messaging/browser/connection.js +172 -35
  63. package/lib/messaging/browser/connection.js.map +1 -1
  64. package/lib/messaging/browser/window-connection.js +35 -55
  65. package/lib/messaging/browser/window-connection.js.map +1 -1
  66. package/lib/messaging/client-call-metrics.d.ts +35 -0
  67. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  68. package/lib/messaging/client-call-metrics.js +83 -0
  69. package/lib/messaging/client-call-metrics.js.map +1 -0
  70. package/lib/messaging/connection-error-handler.js +11 -23
  71. package/lib/messaging/connection-error-handler.js.map +1 -1
  72. package/lib/messaging/error.d.ts +2 -1
  73. package/lib/messaging/error.d.ts.map +1 -1
  74. package/lib/messaging/error.js +4 -2
  75. package/lib/messaging/error.js.map +1 -1
  76. package/lib/messaging/handler.d.ts +10 -0
  77. package/lib/messaging/handler.d.ts.map +1 -1
  78. package/lib/messaging/node/connection.d.ts +0 -10
  79. package/lib/messaging/node/connection.d.ts.map +1 -1
  80. package/lib/messaging/node/connection.js +12 -50
  81. package/lib/messaging/node/connection.js.map +1 -1
  82. package/lib/messaging/proxy-factory.d.ts +2 -0
  83. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  84. package/lib/messaging/proxy-factory.js +74 -159
  85. package/lib/messaging/proxy-factory.js.map +1 -1
  86. package/lib/oss-allowlist.d.ts +14 -0
  87. package/lib/oss-allowlist.d.ts.map +1 -0
  88. package/lib/oss-allowlist.js +8 -0
  89. package/lib/oss-allowlist.js.map +1 -0
  90. package/lib/permission.d.ts +1 -2
  91. package/lib/permission.d.ts.map +1 -1
  92. package/lib/permission.js +12 -13
  93. package/lib/permission.js.map +1 -1
  94. package/lib/plans.d.ts +1 -1
  95. package/lib/plans.d.ts.map +1 -1
  96. package/lib/plans.js +38 -57
  97. package/lib/plans.js.map +1 -1
  98. package/lib/protocol.d.ts +50 -48
  99. package/lib/protocol.d.ts.map +1 -1
  100. package/lib/protocol.js +57 -114
  101. package/lib/protocol.js.map +1 -1
  102. package/lib/snapshot-url.d.ts +14 -0
  103. package/lib/snapshot-url.d.ts.map +1 -0
  104. package/lib/snapshot-url.js +26 -0
  105. package/lib/snapshot-url.js.map +1 -0
  106. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  107. package/lib/snapshot-url.spec.d.ts.map +1 -0
  108. package/lib/snapshot-url.spec.js +41 -0
  109. package/lib/snapshot-url.spec.js.map +1 -0
  110. package/lib/team-subscription-protocol.d.ts +3 -3
  111. package/lib/team-subscription-protocol.d.ts.map +1 -1
  112. package/lib/team-subscription-protocol.js +15 -12
  113. package/lib/team-subscription-protocol.js.map +1 -1
  114. package/lib/teams-projects-protocol.d.ts +110 -0
  115. package/lib/teams-projects-protocol.d.ts.map +1 -0
  116. package/lib/teams-projects-protocol.js +23 -0
  117. package/lib/teams-projects-protocol.js.map +1 -0
  118. package/lib/util/analytics.d.ts +1 -26
  119. package/lib/util/analytics.d.ts.map +1 -1
  120. package/lib/util/analytics.js +36 -28
  121. package/lib/util/analytics.js.map +1 -1
  122. package/lib/util/async-iterator.js +55 -133
  123. package/lib/util/async-iterator.js.map +1 -1
  124. package/lib/util/cancelable.js +17 -59
  125. package/lib/util/cancelable.js.map +1 -1
  126. package/lib/util/date-time.js +8 -8
  127. package/lib/util/date-time.js.map +1 -1
  128. package/lib/util/deferred.js +10 -12
  129. package/lib/util/deferred.js.map +1 -1
  130. package/lib/util/disposable.js +26 -39
  131. package/lib/util/disposable.js.map +1 -1
  132. package/lib/util/event.js +58 -74
  133. package/lib/util/event.js.map +1 -1
  134. package/lib/util/garbage-collected-cache.d.ts +1 -0
  135. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  136. package/lib/util/garbage-collected-cache.js +26 -46
  137. package/lib/util/garbage-collected-cache.js.map +1 -1
  138. package/lib/util/generate-workspace-id.d.ts +1 -1
  139. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  140. package/lib/util/generate-workspace-id.js +29 -68
  141. package/lib/util/generate-workspace-id.js.map +1 -1
  142. package/lib/util/generate-workspace-id.spec.js +56 -78
  143. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  144. package/lib/util/gitpod-cookie.d.ts +20 -0
  145. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  146. package/lib/util/gitpod-cookie.js +44 -0
  147. package/lib/util/gitpod-cookie.js.map +1 -0
  148. package/lib/util/gitpod-host-url.d.ts +1 -0
  149. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  150. package/lib/util/gitpod-host-url.js +96 -103
  151. package/lib/util/gitpod-host-url.js.map +1 -1
  152. package/lib/util/gitpod-host-url.spec.js +87 -135
  153. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  154. package/lib/util/grpc.d.ts +15 -0
  155. package/lib/util/grpc.d.ts.map +1 -0
  156. package/lib/util/grpc.js +18 -0
  157. package/lib/util/grpc.js.map +1 -0
  158. package/lib/util/jaeger-client-types.d.ts +68 -0
  159. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  160. package/lib/util/{without.js → jaeger-client-types.js} +1 -1
  161. package/lib/util/jaeger-client-types.js.map +1 -0
  162. package/lib/util/logging.d.ts +49 -33
  163. package/lib/util/logging.d.ts.map +1 -1
  164. package/lib/util/logging.js +107 -110
  165. package/lib/util/logging.js.map +1 -1
  166. package/lib/util/make-link.js +2 -2
  167. package/lib/util/make-link.js.map +1 -1
  168. package/lib/util/parse-workspace-id.d.ts +10 -0
  169. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  170. package/lib/util/parse-workspace-id.js +31 -7
  171. package/lib/util/parse-workspace-id.js.map +1 -1
  172. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  173. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  174. package/lib/util/parse-workspace-id.spec.js +123 -84
  175. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  176. package/lib/util/queue.js +16 -55
  177. package/lib/util/queue.js.map +1 -1
  178. package/lib/util/queue.spec.js +144 -288
  179. package/lib/util/queue.spec.js.map +1 -1
  180. package/lib/util/repeat.d.ts +15 -0
  181. package/lib/util/repeat.d.ts.map +1 -0
  182. package/lib/util/repeat.js +55 -0
  183. package/lib/util/repeat.js.map +1 -0
  184. package/lib/util/safe-promise.js +9 -12
  185. package/lib/util/safe-promise.js.map +1 -1
  186. package/lib/util/semaphore.js +15 -46
  187. package/lib/util/semaphore.js.map +1 -1
  188. package/lib/util/skip-if.js +6 -6
  189. package/lib/util/skip-if.js.map +1 -1
  190. package/lib/util/timeutil.js +16 -16
  191. package/lib/util/timeutil.js.map +1 -1
  192. package/lib/util/timeutil.spec.js +21 -24
  193. package/lib/util/timeutil.spec.js.map +1 -1
  194. package/lib/util/tracing.d.ts +50 -5
  195. package/lib/util/tracing.d.ts.map +1 -1
  196. package/lib/util/tracing.js +175 -63
  197. package/lib/util/tracing.js.map +1 -1
  198. package/lib/util/tracing.spec.d.ts +7 -0
  199. package/lib/util/tracing.spec.d.ts.map +1 -0
  200. package/lib/util/tracing.spec.js +121 -0
  201. package/lib/util/tracing.spec.js.map +1 -0
  202. package/lib/util/workspace-port-authentication.js +2 -2
  203. package/lib/util/workspace-port-authentication.js.map +1 -1
  204. package/lib/workspace-cluster.d.ts +12 -3
  205. package/lib/workspace-cluster.d.ts.map +1 -1
  206. package/lib/workspace-cluster.js +3 -3
  207. package/lib/workspace-cluster.js.map +1 -1
  208. package/lib/workspace-instance.d.ts +5 -2
  209. package/lib/workspace-instance.d.ts.map +1 -1
  210. package/lib/wsready.js +1 -1
  211. package/package.json +24 -13
  212. package/pkg-yarn.lock +14 -7
  213. package/provenance-bundle.jsonl +2 -0
  214. package/src/accounting-protocol.ts +4 -10
  215. package/src/admin-protocol.ts +10 -5
  216. package/src/analytics.ts +54 -0
  217. package/src/context-url.spec.ts +39 -0
  218. package/src/context-url.ts +51 -0
  219. package/src/email-protocol.ts +2 -3
  220. package/src/env.ts +10 -10
  221. package/src/gitpod-service.ts +101 -17
  222. package/src/headless-workspace-log.ts +7 -11
  223. package/src/ide-protocol.ts +92 -0
  224. package/src/index.ts +4 -0
  225. package/src/messaging/browser/connection.ts +176 -10
  226. package/src/messaging/client-call-metrics.ts +97 -0
  227. package/src/messaging/error.ts +5 -2
  228. package/src/messaging/handler.ts +12 -0
  229. package/src/messaging/node/connection.ts +3 -47
  230. package/src/messaging/proxy-factory.ts +13 -5
  231. package/src/oss-allowlist.ts +15 -0
  232. package/src/permission.ts +0 -1
  233. package/src/protocol.ts +68 -56
  234. package/src/snapshot-url.spec.ts +25 -0
  235. package/src/snapshot-url.ts +27 -0
  236. package/src/team-subscription-protocol.ts +6 -4
  237. package/src/teams-projects-protocol.ts +141 -0
  238. package/src/util/analytics.ts +17 -30
  239. package/src/util/garbage-collected-cache.ts +7 -1
  240. package/src/util/generate-workspace-id.spec.ts +16 -0
  241. package/src/util/generate-workspace-id.ts +20 -2
  242. package/src/util/gitpod-cookie.ts +39 -0
  243. package/src/util/gitpod-host-url.ts +12 -8
  244. package/src/util/grpc.ts +15 -0
  245. package/src/util/jaeger-client-types.ts +102 -0
  246. package/src/util/logging.ts +102 -38
  247. package/src/util/parse-workspace-id.spec.ts +21 -1
  248. package/src/util/parse-workspace-id.ts +32 -6
  249. package/src/util/repeat.ts +45 -0
  250. package/src/util/tracing.spec.ts +83 -0
  251. package/src/util/tracing.ts +162 -18
  252. package/src/workspace-cluster.ts +9 -3
  253. package/src/workspace-instance.ts +18 -6
  254. package/src/wsready.ts +1 -1
  255. package/lib/util/context-url.d.ts +0 -13
  256. package/lib/util/context-url.d.ts.map +0 -1
  257. package/lib/util/context-url.js +0 -26
  258. package/lib/util/context-url.js.map +0 -1
  259. package/lib/util/context-url.spec.d.ts.map +0 -1
  260. package/lib/util/context-url.spec.js +0 -52
  261. package/lib/util/context-url.spec.js.map +0 -1
  262. package/lib/util/repeater.d.ts +0 -22
  263. package/lib/util/repeater.d.ts.map +0 -1
  264. package/lib/util/repeater.js +0 -118
  265. package/lib/util/repeater.js.map +0 -1
  266. package/lib/util/without.d.ts +0 -7
  267. package/lib/util/without.d.ts.map +0 -1
  268. package/lib/util/without.js.map +0 -1
  269. package/src/util/context-url.spec.ts +0 -25
  270. package/src/util/context-url.ts +0 -23
  271. package/src/util/jaeger-client.d.ts +0 -105
  272. package/src/util/repeater.ts +0 -49
@@ -9,11 +9,15 @@ import {
9
9
  WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode,
10
10
  Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
11
  ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
- GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes, Team, TeamMemberInfo, TeamMembershipInvite
12
+ GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes
13
13
  } from './protocol';
14
+ import {
15
+ Team, TeamMemberInfo,
16
+ TeamMembershipInvite, Project, TeamMemberRole, PrebuildWithStatus, StartPrebuildResult, PartialProject
17
+ } from './teams-projects-protocol';
14
18
  import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
15
19
  import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
16
- import { HeadlessLogEvent } from './headless-workspace-log';
20
+ import { HeadlessLogUrls } from './headless-workspace-log';
17
21
  import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
18
22
  import { AdminServer } from './admin-protocol';
19
23
  import { GitpodHostUrl } from './util/gitpod-host-url';
@@ -24,11 +28,14 @@ import { Emitter } from './util/event';
24
28
  import { AccountStatement, CreditAlert } from './accounting-protocol';
25
29
  import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
26
30
  import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
31
+ import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from './analytics';
32
+ import { IDEServer } from './ide-protocol';
27
33
 
28
34
  export interface GitpodClient {
29
35
  onInstanceUpdate(instance: WorkspaceInstance): void;
30
36
  onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
31
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void;
37
+
38
+ onPrebuildUpdate(update: PrebuildWithStatus): void;
32
39
 
33
40
  onCreditAlert(creditAlert: CreditAlert): void;
34
41
 
@@ -39,7 +46,7 @@ export interface GitpodClient {
39
46
  }
40
47
 
41
48
  export const GitpodServer = Symbol('GitpodServer');
42
- export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService {
49
+ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer, LicenseService, IDEServer {
43
50
  // User related API
44
51
  getLoggedInUser(): Promise<User>;
45
52
  getTerms(): Promise<Terms>;
@@ -51,6 +58,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
51
58
  getBranding(): Promise<Branding>;
52
59
  getConfiguration(): Promise<Configuration>;
53
60
  getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
61
+ getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
54
62
  /**
55
63
  * @deprecated
56
64
  */
@@ -82,8 +90,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
82
90
  updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
83
91
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
84
92
  watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
85
- watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
86
93
  isPrebuildDone(pwsid: string): Promise<boolean>;
94
+ getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
87
95
 
88
96
  // Workspace timeout
89
97
  setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
@@ -101,19 +109,39 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
101
109
  getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
102
110
  updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
103
111
 
104
- // user env vars
112
+ // User env vars
105
113
  getEnvVars(): Promise<UserEnvVarValue[]>;
106
114
  getAllEnvVars(): Promise<UserEnvVarValue[]>;
107
115
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
108
116
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
109
117
 
110
- // teams and projects
118
+ // Teams
111
119
  getTeams(): Promise<Team[]>;
112
120
  getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
113
121
  createTeam(name: string): Promise<Team>;
114
122
  joinTeam(inviteId: string): Promise<Team>;
123
+ setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
124
+ removeTeamMember(teamId: string, userId: string): Promise<void>;
115
125
  getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
116
126
  resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
127
+ deleteTeam(teamId: string, userId: string): Promise<void>;
128
+
129
+ // Projects
130
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
131
+ createProject(params: CreateProjectParams): Promise<Project>;
132
+ deleteProject(projectId: string): Promise<void>;
133
+ getTeamProjects(teamId: string): Promise<Project[]>;
134
+ getUserProjects(): Promise<Project[]>;
135
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
136
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
137
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
138
+ cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
139
+ fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
140
+ guessProjectConfiguration(projectId: string): Promise<string | undefined>;
141
+ fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
142
+ guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
143
+ setProjectConfiguration(projectId: string, configString: string): Promise<void>;
144
+ updateProjectPartial(partialProject: PartialProject): Promise<void>;
117
145
 
118
146
  // content service
119
147
  getContentBlobUploadUrl(name: string): Promise<string>
@@ -129,10 +157,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
129
157
  registerGithubApp(installationId: string): Promise<void>;
130
158
 
131
159
  /**
132
- * Stores a new snapshot for the given workspace and bucketId
160
+ * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
133
161
  * @return the snapshot id
134
162
  */
135
163
  takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
164
+ /**
165
+ *
166
+ * @param snapshotId
167
+ */
168
+ waitForSnapshot(snapshotId: string): Promise<void>;
136
169
 
137
170
  /**
138
171
  * Returns the list of snapshots that exist for a workspace.
@@ -164,8 +197,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
164
197
  * gitpod.io concerns
165
198
  */
166
199
  isStudent(): Promise<boolean>;
167
- getPrivateRepoTrialEndDate(): Promise<string | undefined>;
168
-
169
200
  /**
170
201
  *
171
202
  */
@@ -183,7 +214,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
183
214
 
184
215
  getShowPaymentUI(): Promise<boolean>;
185
216
  isChargebeeCustomer(): Promise<boolean>;
186
- mayAccessPrivateRepo(): Promise<boolean>;
187
217
 
188
218
  subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
189
219
  subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
@@ -201,6 +231,54 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
201
231
 
202
232
  getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
203
233
 
234
+ /**
235
+ * Analytics
236
+ */
237
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
238
+ trackLocation(event: RemotePageMessage): Promise<void>;
239
+ identifyUser(event: RemoteIdentifyMessage): Promise<void>;
240
+ }
241
+
242
+ export interface CreateProjectParams {
243
+ name: string;
244
+ slug?: string;
245
+ account: string;
246
+ provider: string;
247
+ cloneUrl: string;
248
+ teamId?: string;
249
+ userId?: string;
250
+ appInstallationId: string;
251
+ }
252
+ export interface FindPrebuildsParams {
253
+ projectId: string;
254
+ branch?: string;
255
+ latest?: boolean;
256
+ prebuildId?: string;
257
+ // default: 30
258
+ limit?: number;
259
+ }
260
+ export interface GetProviderRepositoriesParams {
261
+ provider: string;
262
+ hints?: { installationId: string } | object;
263
+ }
264
+ export interface ProviderRepository {
265
+ name: string;
266
+ path?: string;
267
+ account: string;
268
+ accountAvatarUrl: string;
269
+ cloneUrl: string;
270
+ updatedAt: string;
271
+ installationId?: number;
272
+ installationUpdatedAt?: string;
273
+
274
+ inUse?: { userName: string };
275
+ }
276
+
277
+ export interface ClientHeaderFields {
278
+ ip?: string;
279
+ userAgent?: string;
280
+ dnt?: string;
281
+ clientRegion?: string;
204
282
  }
205
283
 
206
284
  export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
@@ -213,6 +291,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
213
291
  methods.setClient = methods.setClient || (() => { });
214
292
  methods.dispose = methods.dispose || (() => { });
215
293
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
294
+ // @ts-ignore
216
295
  get: (target: S, property: keyof S) => {
217
296
  const result = target[property];
218
297
  if (!result) {
@@ -245,6 +324,8 @@ export namespace GitpodServer {
245
324
  limit?: number;
246
325
  searchString?: string;
247
326
  pinnedOnly?: boolean;
327
+ projectId?: string | string[];
328
+ includeWithoutProject?: boolean;
248
329
  }
249
330
  export interface GetAccountStatementOptions {
250
331
  date?: string;
@@ -252,6 +333,7 @@ export namespace GitpodServer {
252
333
  export interface CreateWorkspaceOptions {
253
334
  contextUrl: string;
254
335
  mode?: CreateWorkspaceMode;
336
+ forceDefaultConfig?: boolean;
255
337
  }
256
338
  export interface StartWorkspaceOptions {
257
339
  forceDefaultImage: boolean;
@@ -259,6 +341,8 @@ export namespace GitpodServer {
259
341
  export interface TakeSnapshotOptions {
260
342
  workspaceId: string;
261
343
  layoutData?: string;
344
+ /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
345
+ dontWait?: boolean;
262
346
  }
263
347
  export interface GetUserStorageResourceOptions {
264
348
  readonly uri: string;
@@ -320,11 +404,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
320
404
  }
321
405
  }
322
406
 
323
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
407
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
324
408
  for (const client of this.clients) {
325
- if (client.onWorkspaceImageBuildLogs) {
409
+ if (client.onPrebuildUpdate) {
326
410
  try {
327
- client.onWorkspaceImageBuildLogs(info, content);
411
+ client.onPrebuildUpdate(update);
328
412
  } catch (error) {
329
413
  console.error(error)
330
414
  }
@@ -332,11 +416,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
332
416
  }
333
417
  }
334
418
 
335
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
419
+ onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
336
420
  for (const client of this.clients) {
337
- if (client.onHeadlessWorkspaceLogs) {
421
+ if (client.onWorkspaceImageBuildLogs) {
338
422
  try {
339
- client.onHeadlessWorkspaceLogs(evt);
423
+ client.onWorkspaceImageBuildLogs(info, content);
340
424
  } catch (error) {
341
425
  console.error(error)
342
426
  }
@@ -22,21 +22,17 @@ export namespace HeadlessWorkspaceEventType {
22
22
  }
23
23
  }
24
24
 
25
- export interface HeadlessLogEvent {
25
+ export interface HeadlessWorkspaceEvent {
26
26
  workspaceID: string;
27
27
  text: string;
28
28
  type: HeadlessWorkspaceEventType;
29
29
  }
30
30
 
31
- export enum TheiaHeadlessLogType {
32
- TaskLogLabel = "workspaceTaskOutput",
33
- TaskFailedLabel = "workspaceTaskFailed",
34
- TaskSuccessfulLabel = "workspaceTaskDone"
31
+ export interface HeadlessLogUrls {
32
+ // A map of id to URL
33
+ streams: { [streamID: string]: string };
35
34
  }
36
35
 
37
- export interface TheiaHeadlessLogMessage {
38
- type: TheiaHeadlessLogType;
39
- data?: string;
40
- error?: string;
41
- snapshotURL?: string;
42
- }
36
+ /** cmp. @const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX */
37
+ export const HEADLESS_LOG_STREAM_STATUS_CODE = "X-LogStream-StatusCode";
38
+ export const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX = /X-LogStream-StatusCode: ([0-9]{3})/;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ /**
8
+ * `IDEServer` provides a list of available IDEs.
9
+ */
10
+ export interface IDEServer {
11
+ /**
12
+ * Returns the IDE preferences.
13
+ */
14
+ getIDEOptions(): Promise<IDEOptions>;
15
+ }
16
+
17
+ export interface IDEOptions {
18
+ /**
19
+ * A list of available IDEs.
20
+ */
21
+ options: { [key: string]: IDEOption };
22
+
23
+ /**
24
+ * The default (browser) IDE when the user has not specified one.
25
+ */
26
+ defaultIde: string;
27
+
28
+ /**
29
+ * The default desktop IDE when the user has not specified one.
30
+ */
31
+ defaultDesktopIde: string;
32
+ }
33
+
34
+ export interface IDEOption {
35
+ /**
36
+ * To ensure a stable order one can set an `orderKey`.
37
+ */
38
+ orderKey?: string;
39
+
40
+ /**
41
+ * Human readable title text of the IDE (plain text only).
42
+ */
43
+ title: string;
44
+
45
+ /**
46
+ * The type of the IDE, currently 'browser' or 'desktop'.
47
+ */
48
+ type: 'browser' | 'desktop';
49
+
50
+ /**
51
+ * The logo for the IDE. That could be a key in (see
52
+ * components/dashboard/src/images/ideLogos.ts) or a URL.
53
+ */
54
+ logo: string;
55
+
56
+ /**
57
+ * Text of an optional tooltip (plain text only).
58
+ */
59
+ tooltip?: string;
60
+
61
+ /**
62
+ * Text of an optional label next to the IDE option like “Insiders” (plain
63
+ * text only).
64
+ */
65
+ label?: string;
66
+
67
+ /**
68
+ * Notes to the IDE option that are renderd in the preferences when a user
69
+ * chooses this IDE.
70
+ */
71
+ notes?: string[];
72
+
73
+ /**
74
+ * If `true` this IDE option is not visible in the IDE preferences.
75
+ */
76
+ hidden?: boolean;
77
+
78
+ /**
79
+ * The image ref to the IDE image.
80
+ */
81
+ image: string;
82
+
83
+ /**
84
+ * When this is `true`, the tag of this image is resolved to the latest
85
+ * image digest regularly.
86
+ *
87
+ * This is useful if this image points to a tag like `nightly` that will be
88
+ * updated regularly. When `resolveImageDigest` is `true`, we make sure that
89
+ * we resolve the tag regularly to the most recent image version.
90
+ */
91
+ resolveImageDigest?: boolean;
92
+ }
package/src/index.ts CHANGED
@@ -15,3 +15,7 @@ export * from './permission';
15
15
  export * from './admin-protocol';
16
16
  export * from './email-protocol';
17
17
  export * from './headless-workspace-log';
18
+ export * from './context-url';
19
+ export * from './teams-projects-protocol';
20
+ export * from './snapshot-url';
21
+ export * from './oss-allowlist';
@@ -5,10 +5,13 @@
5
5
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
6
  */
7
7
 
8
- import { listen as doListen, Logger, ConsoleLogger } from "vscode-ws-jsonrpc";
8
+ import { Logger, ConsoleLogger, toSocket, IWebSocket } from "vscode-ws-jsonrpc";
9
+ import { createMessageConnection } from "vscode-jsonrpc";
10
+ import { AbstractMessageWriter } from "vscode-jsonrpc/lib/messageWriter";
11
+ import { AbstractMessageReader } from "vscode-jsonrpc/lib/messageReader";
9
12
  import { JsonRpcProxyFactory, JsonRpcProxy } from "../proxy-factory";
10
- import { ConnectionHandler } from "../handler";
11
- import ReconnectingWebSocket from 'reconnecting-websocket';
13
+ import { ConnectionEventHandler, ConnectionHandler } from "../handler";
14
+ import ReconnectingWebSocket, { Event } from 'reconnecting-websocket';
12
15
 
13
16
  export interface WebSocketOptions {
14
17
  onerror?: (event: Event) => void;
@@ -29,7 +32,10 @@ export class WebSocketConnectionProvider {
29
32
  const startListening = (path: string) => {
30
33
  const socket = this.listen({
31
34
  path,
32
- onConnection: c => factory.listen(c)
35
+ onConnection: c => factory.listen(c),
36
+ }, {
37
+ onTransportDidClose: () => factory.fireConnectionClosed(),
38
+ onTransportDidOpen: () => factory.fireConnectionOpened(),
33
39
  },
34
40
  options
35
41
  );
@@ -49,7 +55,7 @@ export class WebSocketConnectionProvider {
49
55
  /**
50
56
  * Install a connection handler for the given path.
51
57
  */
52
- listen(handler: ConnectionHandler, options?: WebSocketOptions): WebSocket {
58
+ listen(handler: ConnectionHandler, eventHandler: ConnectionEventHandler, options?: WebSocketOptions): WebSocket {
53
59
  const url = handler.path;
54
60
  const webSocket = this.createWebSocket(url);
55
61
 
@@ -64,11 +70,12 @@ export class WebSocketConnectionProvider {
64
70
  logger.error(JSON.stringify(error));
65
71
  });
66
72
  }
67
- doListen({
68
- webSocket,
69
- onConnection: connection => handler.onConnection(connection),
70
- logger
71
- });
73
+ doListen(
74
+ webSocket as any as ReconnectingWebSocket,
75
+ handler,
76
+ eventHandler,
77
+ logger,
78
+ );
72
79
  return webSocket;
73
80
  }
74
81
 
@@ -91,3 +98,162 @@ export class WebSocketConnectionProvider {
91
98
  }
92
99
 
93
100
  }
101
+
102
+ // The following was extracted from vscode-ws-jsonrpc to make these changes:
103
+ // - switch from WebSocket to ReconnectingWebSocket
104
+ // - webSocket.onopen: making sure it's only ever called once so we're re-using MessageConnection
105
+ // - WebSocketMessageWriter: buffer and re-try messages instead of throwing an error immidiately
106
+ // - WebSocketMessageReader: don't close MessageConnection on 'socket.onclose'
107
+ function doListen(resocket: ReconnectingWebSocket, handler: ConnectionHandler, eventHandler: ConnectionEventHandler, logger: Logger) {
108
+ resocket.addEventListener("close", () => eventHandler.onTransportDidClose());
109
+
110
+ let alreadyOpened = false;
111
+ resocket.onopen = () => {
112
+ // trigerr "open" every time we re-open the underlying websocket
113
+ eventHandler.onTransportDidOpen();
114
+
115
+ // make sure we're only ever creating one MessageConnection, irregardless of how many times we have to re-open the underlying (reconnecting) websocket
116
+ if (alreadyOpened) {
117
+ return;
118
+ }
119
+ alreadyOpened = true;
120
+
121
+ const connection = createWebSocketConnection(resocket, logger);
122
+ handler.onConnection(connection);
123
+ };
124
+ }
125
+
126
+ function createWebSocketConnection(resocket: ReconnectingWebSocket, logger: Logger) {
127
+ const socket = toSocket(resocket as any);
128
+ const messageReader = new NonClosingWebSocketMessageReader(socket);
129
+ const messageWriter = new BufferingWebSocketMessageWriter(resocket, logger);
130
+ const connection = createMessageConnection(messageReader, messageWriter, logger);
131
+ connection.onClose(() => connection.dispose());
132
+ return connection;
133
+ }
134
+
135
+ /**
136
+ * This takes vscode-ws-jsonrpc/lib/socket/writer/WebSocketMessageWriter and adds a buffer
137
+ */
138
+ class BufferingWebSocketMessageWriter extends AbstractMessageWriter {
139
+ protected readonly socket: ReconnectingWebSocket;
140
+ protected readonly logger: Logger;
141
+ protected errorCount: number = 0;
142
+
143
+ protected buffer: any[] = [];
144
+
145
+ constructor(socket: ReconnectingWebSocket, logger: Logger) {
146
+ super();
147
+ this.socket = socket;
148
+ this.logger = logger;
149
+
150
+ socket.addEventListener("open", (event: Event) => this.flushBuffer());
151
+ }
152
+
153
+ write(msg: any) {
154
+ if (this.socket.readyState !== ReconnectingWebSocket.OPEN) {
155
+ this.bufferMsg(msg);
156
+ return;
157
+ }
158
+
159
+ try {
160
+ const content = JSON.stringify(msg);
161
+ this.socket.send(content);
162
+ } catch (e) {
163
+ this.errorCount++;
164
+ this.fireError(e, msg, this.errorCount);
165
+
166
+ this.bufferMsg(msg);
167
+ }
168
+ }
169
+
170
+ protected flushBuffer() {
171
+ if (this.buffer.length === 0) {
172
+ return
173
+ }
174
+
175
+ const buffer = [...this.buffer];
176
+ this.buffer = [];
177
+ for (const msg of buffer) {
178
+ this.write(msg);
179
+ }
180
+ //this.logger.info(`flushed buffer (${this.buffer.length})`)
181
+ }
182
+
183
+ protected bufferMsg(msg: any) {
184
+ this.buffer.push(msg);
185
+ //this.logger.info(`buffered message (${this.buffer.length})`);
186
+ }
187
+ }
188
+
189
+
190
+ /**
191
+ * This takes vscode-ws-jsonrpc/lib/socket/reader/WebSocketMessageReader and removes the "onClose -> fireClose" connection
192
+ */
193
+ class NonClosingWebSocketMessageReader extends AbstractMessageReader {
194
+ protected readonly socket: IWebSocket;
195
+ protected readonly events: any[] = [];
196
+ protected state: 'initial' | 'listening' | 'closed' = 'initial';
197
+ protected callback: (message: any) => void = () => {};
198
+
199
+ constructor(socket: IWebSocket) {
200
+ super();
201
+ this.socket = socket;
202
+ this.socket.onMessage(message => this.readMessage(message));
203
+ this.socket.onError(error => this.fireError(error));
204
+ this.socket.onClose((code, reason) => {
205
+ if (code !== 1000) {
206
+ const error = {
207
+ name: '' + code,
208
+ message: `Error during socket reconnect: code = ${code}, reason = ${reason}`
209
+ };
210
+ this.fireError(error);
211
+ }
212
+ // this.fireClose(); // <-- reason for this class to be copied over
213
+ });
214
+ }
215
+ listen(callback: (message: any) => void) {
216
+ if (this.state === 'initial') {
217
+ this.state = 'listening';
218
+ this.callback = callback;
219
+ while (this.events.length !== 0) {
220
+ const event = this.events.pop();
221
+ if (event.message) {
222
+ this.readMessage(event.message);
223
+ }
224
+ else if (event.error) {
225
+ this.fireError(event.error);
226
+ }
227
+ else {
228
+ this.fireClose();
229
+ }
230
+ }
231
+ }
232
+ }
233
+ readMessage(message: any) {
234
+ if (this.state === 'initial') {
235
+ this.events.splice(0, 0, { message });
236
+ }
237
+ else if (this.state === 'listening') {
238
+ const data = JSON.parse(message);
239
+ this.callback(data);
240
+ }
241
+ }
242
+ fireError(error: any) {
243
+ if (this.state === 'initial') {
244
+ this.events.splice(0, 0, { error });
245
+ }
246
+ else if (this.state === 'listening') {
247
+ super.fireError(error);
248
+ }
249
+ }
250
+ fireClose() {
251
+ if (this.state === 'initial') {
252
+ this.events.splice(0, 0, {});
253
+ }
254
+ else if (this.state === 'listening') {
255
+ super.fireClose();
256
+ }
257
+ this.state = 'closed';
258
+ }
259
+ }