@gitpod/gitpod-protocol 0.1.5-patch-2-fork.0 → 0.1.5-pd-del-private-repo-check-fork.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/data/gitpod-schema.json +8 -22
  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 +15 -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 +45 -0
  11. package/lib/analytics.d.ts.map +1 -0
  12. package/lib/{util/without.js → analytics.js} +4 -2
  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} +3 -1
  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 +5 -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 +95 -20
  45. package/lib/gitpod-service.d.ts.map +1 -1
  46. package/lib/gitpod-service.js +167 -278
  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/index.d.ts +4 -0
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/index.js +5 -1
  55. package/lib/index.js.map +1 -1
  56. package/lib/messaging/browser/connection.d.ts +5 -3
  57. package/lib/messaging/browser/connection.d.ts.map +1 -1
  58. package/lib/messaging/browser/connection.js +183 -33
  59. package/lib/messaging/browser/connection.js.map +1 -1
  60. package/lib/messaging/browser/window-connection.js +35 -55
  61. package/lib/messaging/browser/window-connection.js.map +1 -1
  62. package/lib/messaging/client-call-metrics.d.ts +35 -0
  63. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  64. package/lib/messaging/client-call-metrics.js +83 -0
  65. package/lib/messaging/client-call-metrics.js.map +1 -0
  66. package/lib/messaging/connection-error-handler.js +11 -23
  67. package/lib/messaging/connection-error-handler.js.map +1 -1
  68. package/lib/messaging/error.d.ts +2 -1
  69. package/lib/messaging/error.d.ts.map +1 -1
  70. package/lib/messaging/error.js +4 -2
  71. package/lib/messaging/error.js.map +1 -1
  72. package/lib/messaging/handler.d.ts +10 -0
  73. package/lib/messaging/handler.d.ts.map +1 -1
  74. package/lib/messaging/node/connection.js +22 -22
  75. package/lib/messaging/node/connection.js.map +1 -1
  76. package/lib/messaging/proxy-factory.d.ts +2 -0
  77. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  78. package/lib/messaging/proxy-factory.js +74 -159
  79. package/lib/messaging/proxy-factory.js.map +1 -1
  80. package/lib/permission.d.ts +2 -1
  81. package/lib/permission.d.ts.map +1 -1
  82. package/lib/permission.js +14 -13
  83. package/lib/permission.js.map +1 -1
  84. package/lib/plans.d.ts +210 -0
  85. package/lib/plans.d.ts.map +1 -0
  86. package/lib/plans.js +570 -0
  87. package/lib/plans.js.map +1 -0
  88. package/lib/protocol.d.ts +93 -15
  89. package/lib/protocol.d.ts.map +1 -1
  90. package/lib/protocol.js +104 -130
  91. package/lib/protocol.js.map +1 -1
  92. package/lib/snapshot-url.d.ts +14 -0
  93. package/lib/snapshot-url.d.ts.map +1 -0
  94. package/lib/snapshot-url.js +26 -0
  95. package/lib/snapshot-url.js.map +1 -0
  96. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  97. package/lib/snapshot-url.spec.d.ts.map +1 -0
  98. package/lib/snapshot-url.spec.js +41 -0
  99. package/lib/snapshot-url.spec.js.map +1 -0
  100. package/lib/team-subscription-protocol.d.ts +4 -4
  101. package/lib/team-subscription-protocol.d.ts.map +1 -1
  102. package/lib/team-subscription-protocol.js +15 -12
  103. package/lib/team-subscription-protocol.js.map +1 -1
  104. package/lib/teams-projects-protocol.d.ts +103 -0
  105. package/lib/teams-projects-protocol.d.ts.map +1 -0
  106. package/lib/teams-projects-protocol.js +23 -0
  107. package/lib/teams-projects-protocol.js.map +1 -0
  108. package/lib/util/analytics.d.ts +8 -0
  109. package/lib/util/analytics.d.ts.map +1 -0
  110. package/lib/util/analytics.js +79 -0
  111. package/lib/util/analytics.js.map +1 -0
  112. package/lib/util/async-iterator.js +55 -133
  113. package/lib/util/async-iterator.js.map +1 -1
  114. package/lib/util/cancelable.js +17 -59
  115. package/lib/util/cancelable.js.map +1 -1
  116. package/lib/util/date-time.js +8 -8
  117. package/lib/util/date-time.js.map +1 -1
  118. package/lib/util/deferred.js +10 -12
  119. package/lib/util/deferred.js.map +1 -1
  120. package/lib/util/disposable.js +26 -39
  121. package/lib/util/disposable.js.map +1 -1
  122. package/lib/util/event.js +58 -74
  123. package/lib/util/event.js.map +1 -1
  124. package/lib/util/garbage-collected-cache.js +22 -46
  125. package/lib/util/garbage-collected-cache.js.map +1 -1
  126. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  127. package/lib/util/generate-workspace-id.js +13 -67
  128. package/lib/util/generate-workspace-id.js.map +1 -1
  129. package/lib/util/generate-workspace-id.spec.js +34 -79
  130. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  131. package/lib/util/gitpod-cookie.d.ts +20 -0
  132. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  133. package/lib/util/gitpod-cookie.js +44 -0
  134. package/lib/util/gitpod-cookie.js.map +1 -0
  135. package/lib/util/gitpod-host-url.d.ts +0 -1
  136. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  137. package/lib/util/gitpod-host-url.js +95 -98
  138. package/lib/util/gitpod-host-url.js.map +1 -1
  139. package/lib/util/gitpod-host-url.spec.d.ts +7 -1
  140. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  141. package/lib/util/gitpod-host-url.spec.js +103 -31
  142. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  143. package/lib/util/grpc.d.ts +15 -0
  144. package/lib/util/grpc.d.ts.map +1 -0
  145. package/lib/util/grpc.js +18 -0
  146. package/lib/util/grpc.js.map +1 -0
  147. package/lib/util/logging.d.ts +49 -33
  148. package/lib/util/logging.d.ts.map +1 -1
  149. package/lib/util/logging.js +107 -110
  150. package/lib/util/logging.js.map +1 -1
  151. package/lib/util/make-link.js +2 -2
  152. package/lib/util/make-link.js.map +1 -1
  153. package/lib/util/parse-workspace-id.d.ts +10 -0
  154. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  155. package/lib/util/parse-workspace-id.js +32 -7
  156. package/lib/util/parse-workspace-id.js.map +1 -1
  157. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  158. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  159. package/lib/util/parse-workspace-id.spec.js +123 -84
  160. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  161. package/lib/util/queue.js +16 -55
  162. package/lib/util/queue.js.map +1 -1
  163. package/lib/util/queue.spec.js +144 -288
  164. package/lib/util/queue.spec.js.map +1 -1
  165. package/lib/util/repeater.js +35 -88
  166. package/lib/util/repeater.js.map +1 -1
  167. package/lib/util/safe-promise.js +9 -12
  168. package/lib/util/safe-promise.js.map +1 -1
  169. package/lib/util/semaphore.js +15 -46
  170. package/lib/util/semaphore.js.map +1 -1
  171. package/lib/util/skip-if.js +6 -6
  172. package/lib/util/skip-if.js.map +1 -1
  173. package/lib/util/timeutil.js +28 -16
  174. package/lib/util/timeutil.js.map +1 -1
  175. package/lib/util/timeutil.spec.js +21 -24
  176. package/lib/util/timeutil.spec.js.map +1 -1
  177. package/lib/util/tracing.js +43 -47
  178. package/lib/util/tracing.js.map +1 -1
  179. package/lib/util/workspace-port-authentication.js +3 -2
  180. package/lib/util/workspace-port-authentication.js.map +1 -1
  181. package/lib/workspace-cluster.d.ts +74 -0
  182. package/lib/workspace-cluster.d.ts.map +1 -0
  183. package/lib/workspace-cluster.js +16 -0
  184. package/lib/workspace-cluster.js.map +1 -0
  185. package/lib/workspace-instance.d.ts +4 -2
  186. package/lib/workspace-instance.d.ts.map +1 -1
  187. package/lib/wsready.d.ts +1 -1
  188. package/lib/wsready.js +2 -2
  189. package/package.json +28 -16
  190. package/pkg-yarn.lock +17 -9
  191. package/src/accounting-protocol.ts +4 -10
  192. package/src/admin-protocol.ts +33 -5
  193. package/src/analytics.ts +54 -0
  194. package/src/context-url.spec.ts +39 -0
  195. package/src/context-url.ts +51 -0
  196. package/src/email-protocol.ts +2 -3
  197. package/src/env.ts +10 -10
  198. package/src/gitpod-service.ts +145 -39
  199. package/src/headless-workspace-log.ts +7 -11
  200. package/src/index.ts +5 -1
  201. package/src/messaging/browser/connection.ts +195 -14
  202. package/src/messaging/client-call-metrics.ts +97 -0
  203. package/src/messaging/error.ts +5 -2
  204. package/src/messaging/handler.ts +12 -0
  205. package/src/messaging/node/connection.ts +2 -2
  206. package/src/messaging/proxy-factory.ts +14 -6
  207. package/src/permission.ts +2 -1
  208. package/src/plans.ts +632 -0
  209. package/src/protocol.ts +152 -43
  210. package/src/snapshot-url.spec.ts +25 -0
  211. package/src/snapshot-url.ts +27 -0
  212. package/src/team-subscription-protocol.ts +7 -5
  213. package/src/teams-projects-protocol.ts +132 -0
  214. package/src/util/analytics.ts +87 -0
  215. package/src/util/deferred.ts +1 -1
  216. package/src/util/garbage-collected-cache.ts +2 -2
  217. package/src/util/generate-workspace-id.spec.ts +3 -3
  218. package/src/util/generate-workspace-id.ts +2 -0
  219. package/src/util/gitpod-cookie.ts +39 -0
  220. package/src/util/gitpod-host-url.spec.ts +25 -1
  221. package/src/util/gitpod-host-url.ts +19 -10
  222. package/src/util/grpc.ts +15 -0
  223. package/src/util/logging.ts +102 -38
  224. package/src/util/parse-workspace-id.spec.ts +21 -1
  225. package/src/util/parse-workspace-id.ts +32 -6
  226. package/src/util/queue.spec.ts +1 -1
  227. package/src/util/semaphore.ts +2 -2
  228. package/src/util/skip-if.ts +1 -1
  229. package/src/util/timeutil.ts +4 -4
  230. package/src/workspace-cluster.ts +96 -0
  231. package/src/workspace-instance.ts +22 -13
  232. package/src/wsready.ts +2 -2
  233. package/lib/util/context-url.d.ts +0 -13
  234. package/lib/util/context-url.d.ts.map +0 -1
  235. package/lib/util/context-url.js +0 -26
  236. package/lib/util/context-url.js.map +0 -1
  237. package/lib/util/context-url.spec.d.ts.map +0 -1
  238. package/lib/util/context-url.spec.js +0 -52
  239. package/lib/util/context-url.spec.js.map +0 -1
  240. package/lib/util/without.d.ts +0 -7
  241. package/lib/util/without.d.ts.map +0 -1
  242. package/lib/util/without.js.map +0 -1
  243. package/src/util/context-url.spec.ts +0 -25
  244. package/src/util/context-url.ts +0 -23
@@ -5,14 +5,19 @@
5
5
  */
6
6
 
7
7
  import {
8
- User, WorkspaceInfo, WorkspaceCreationResult, UserMessage, WorkspaceInstanceUser,
8
+ User, WorkspaceInfo, WorkspaceCreationResult, WorkspaceInstanceUser,
9
9
  WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode,
10
10
  Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
- ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType, GitpodToken, AuthProviderEntry
11
+ ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
+ GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes
12
13
  } from './protocol';
14
+ import {
15
+ Team, TeamMemberInfo,
16
+ TeamMembershipInvite, Project, TeamMemberRole, PrebuildWithStatus, StartPrebuildResult
17
+ } from './teams-projects-protocol';
13
18
  import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
14
19
  import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
15
- import { HeadlessLogEvent } from './headless-workspace-log';
20
+ import { HeadlessLogUrls } from './headless-workspace-log';
16
21
  import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
17
22
  import { AdminServer } from './admin-protocol';
18
23
  import { GitpodHostUrl } from './util/gitpod-host-url';
@@ -23,11 +28,13 @@ import { Emitter } from './util/event';
23
28
  import { AccountStatement, CreditAlert } from './accounting-protocol';
24
29
  import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
25
30
  import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
31
+ import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from './analytics';
26
32
 
27
33
  export interface GitpodClient {
28
34
  onInstanceUpdate(instance: WorkspaceInstance): void;
29
35
  onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
30
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void;
36
+
37
+ onPrebuildUpdate(update: PrebuildWithStatus): void;
31
38
 
32
39
  onCreditAlert(creditAlert: CreditAlert): void;
33
40
 
@@ -45,11 +52,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
45
52
  updateLoggedInUser(user: Partial<User>): Promise<User>;
46
53
  getAuthProviders(): Promise<AuthProviderInfo[]>;
47
54
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
48
- updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<void>;
55
+ updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
49
56
  deleteOwnAuthProvider(params: GitpodServer.DeleteOwnAuthProviderParams): Promise<void>;
50
57
  getBranding(): Promise<Branding>;
51
58
  getConfiguration(): Promise<Configuration>;
52
59
  getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
60
+ getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
53
61
  /**
54
62
  * @deprecated
55
63
  */
@@ -81,8 +89,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
81
89
  updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
82
90
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
83
91
  watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
84
- watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
85
92
  isPrebuildDone(pwsid: string): Promise<boolean>;
93
+ getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
86
94
 
87
95
  // Workspace timeout
88
96
  setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
@@ -96,19 +104,41 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
96
104
  openPort(workspaceId: string, port: WorkspaceInstancePort): Promise<WorkspaceInstancePort | undefined>;
97
105
  closePort(workspaceId: string, port: number): Promise<void>;
98
106
 
99
- // User messages
100
- getUserMessages(options: GitpodServer.GetUserMessagesOptions): Promise<UserMessage[]>;
101
- updateUserMessages(options: GitpodServer.UpdateUserMessagesOptions): Promise<void>;
102
-
103
107
  // User storage
104
108
  getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
105
109
  updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
106
110
 
107
- // user env vars
111
+ // User env vars
108
112
  getEnvVars(): Promise<UserEnvVarValue[]>;
113
+ getAllEnvVars(): Promise<UserEnvVarValue[]>;
109
114
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
110
115
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
111
116
 
117
+ // Teams
118
+ getTeams(): Promise<Team[]>;
119
+ getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
120
+ createTeam(name: string): Promise<Team>;
121
+ joinTeam(inviteId: string): Promise<Team>;
122
+ setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
123
+ removeTeamMember(teamId: string, userId: string): Promise<void>;
124
+ getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
125
+ resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
126
+ deleteTeam(teamId: string, userId: string): Promise<void>;
127
+
128
+ // Projects
129
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
130
+ createProject(params: CreateProjectParams): Promise<Project>;
131
+ deleteProject(projectId: string): Promise<void>;
132
+ getTeamProjects(teamId: string): Promise<Project[]>;
133
+ getUserProjects(): Promise<Project[]>;
134
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
135
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
136
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
137
+ cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
138
+ setProjectConfiguration(projectId: string, configString: string): Promise<void>;
139
+ fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
140
+ guessProjectConfiguration(projectId: string): Promise<string | undefined>;
141
+
112
142
  // content service
113
143
  getContentBlobUploadUrl(name: string): Promise<string>
114
144
  getContentBlobDownloadUrl(name: string): Promise<string>
@@ -123,10 +153,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
123
153
  registerGithubApp(installationId: string): Promise<void>;
124
154
 
125
155
  /**
126
- * Stores a new snapshot for the given workspace and bucketId
156
+ * Stores a new snapshot for the given workspace and bucketId. Returns _before_ the actual snapshot is done. To wait for that, use `waitForSnapshot`.
127
157
  * @return the snapshot id
128
158
  */
129
159
  takeSnapshot(options: GitpodServer.TakeSnapshotOptions): Promise<string>;
160
+ /**
161
+ *
162
+ * @param snapshotId
163
+ */
164
+ waitForSnapshot(snapshotId: string): Promise<void>;
130
165
 
131
166
  /**
132
167
  * Returns the list of snapshots that exist for a workspace.
@@ -152,20 +187,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
152
187
  installUserPlugins(params: InstallPluginsParams): Promise<boolean>;
153
188
  uninstallUserPlugin(params: UninstallPluginParams): Promise<boolean>;
154
189
 
190
+ guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
191
+
155
192
  /**
156
193
  * gitpod.io concerns
157
194
  */
158
195
  isStudent(): Promise<boolean>;
159
- getPrivateRepoTrialEndDate(): Promise<string | undefined>;
160
-
161
196
  /**
162
- *
197
+ *
163
198
  */
164
199
  getAccountStatement(options: GitpodServer.GetAccountStatementOptions): Promise<AccountStatement | undefined>;
165
200
  getRemainingUsageHours(): Promise<number>;
166
201
 
167
202
  /**
168
- *
203
+ *
169
204
  */
170
205
  getChargebeeSiteId(): Promise<string>;
171
206
  createPortalSession(): Promise<{}>;
@@ -175,7 +210,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
175
210
 
176
211
  getShowPaymentUI(): Promise<boolean>;
177
212
  isChargebeeCustomer(): Promise<boolean>;
178
- mayAccessPrivateRepo(): Promise<boolean>;
179
213
 
180
214
  subscriptionUpgradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
181
215
  subscriptionDowngradeTo(subscriptionId: string, chargebeePlanId: string): Promise<void>;
@@ -186,13 +220,61 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
186
220
  tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
187
221
  tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>
188
222
  tsAddSlots(teamSubscriptionId: string, quantity: number): Promise<void>;
189
- tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string|undefined): Promise<void>
223
+ tsAssignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, identityStr: string | undefined): Promise<void>
190
224
  tsReassignSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string, newIdentityStr: string): Promise<void>;
191
225
  tsDeactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
192
226
  tsReactivateSlot(teamSubscriptionId: string, teamSubscriptionSlotId: string): Promise<void>;
193
227
 
194
228
  getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
195
229
 
230
+ /**
231
+ * Analytics
232
+ */
233
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
234
+ trackLocation(event: RemotePageMessage): Promise<void>;
235
+ identifyUser(event: RemoteIdentifyMessage): Promise<void>;
236
+ }
237
+
238
+ export interface CreateProjectParams {
239
+ name: string;
240
+ slug?: string;
241
+ account: string;
242
+ provider: string;
243
+ cloneUrl: string;
244
+ teamId?: string;
245
+ userId?: string;
246
+ appInstallationId: string;
247
+ }
248
+ export interface FindPrebuildsParams {
249
+ projectId: string;
250
+ branch?: string;
251
+ latest?: boolean;
252
+ prebuildId?: string;
253
+ // default: 30
254
+ limit?: number;
255
+ }
256
+ export interface GetProviderRepositoriesParams {
257
+ provider: string;
258
+ hints?: { installationId: string } | object;
259
+ }
260
+ export interface ProviderRepository {
261
+ name: string;
262
+ path?: string;
263
+ account: string;
264
+ accountAvatarUrl: string;
265
+ cloneUrl: string;
266
+ updatedAt: string;
267
+ installationId?: number;
268
+ installationUpdatedAt?: string;
269
+
270
+ inUse?: boolean;
271
+ }
272
+
273
+ export interface ClientHeaderFields{
274
+ ip?: string;
275
+ userAgent?: string;
276
+ dnt?: string;
277
+ clientRegion?: string;
196
278
  }
197
279
 
198
280
  export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
@@ -205,6 +287,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
205
287
  methods.setClient = methods.setClient || (() => { });
206
288
  methods.dispose = methods.dispose || (() => { });
207
289
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
290
+ // @ts-ignore
208
291
  get: (target: S, property: keyof S) => {
209
292
  const result = target[property];
210
293
  if (!result) {
@@ -237,6 +320,8 @@ export namespace GitpodServer {
237
320
  limit?: number;
238
321
  searchString?: string;
239
322
  pinnedOnly?: boolean;
323
+ projectId?: string | string[];
324
+ includeWithoutProject?: boolean;
240
325
  }
241
326
  export interface GetAccountStatementOptions {
242
327
  date?: string;
@@ -244,6 +329,7 @@ export namespace GitpodServer {
244
329
  export interface CreateWorkspaceOptions {
245
330
  contextUrl: string;
246
331
  mode?: CreateWorkspaceMode;
332
+ forceDefaultConfig?: boolean;
247
333
  }
248
334
  export interface StartWorkspaceOptions {
249
335
  forceDefaultImage: boolean;
@@ -251,13 +337,8 @@ export namespace GitpodServer {
251
337
  export interface TakeSnapshotOptions {
252
338
  workspaceId: string;
253
339
  layoutData?: string;
254
- }
255
- export interface GetUserMessagesOptions {
256
- readonly releaseNotes?: boolean;
257
- readonly workspaceInstanceId: string;
258
- }
259
- export interface UpdateUserMessagesOptions {
260
- readonly messageIds: string[];
340
+ /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
341
+ dontWait?: boolean;
261
342
  }
262
343
  export interface GetUserStorageResourceOptions {
263
344
  readonly uri: string;
@@ -319,11 +400,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
319
400
  }
320
401
  }
321
402
 
322
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
403
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
323
404
  for (const client of this.clients) {
324
- if (client.onWorkspaceImageBuildLogs) {
405
+ if (client.onPrebuildUpdate) {
325
406
  try {
326
- client.onWorkspaceImageBuildLogs(info, content);
407
+ client.onPrebuildUpdate(update);
327
408
  } catch (error) {
328
409
  console.error(error)
329
410
  }
@@ -331,11 +412,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
331
412
  }
332
413
  }
333
414
 
334
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
415
+ onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
335
416
  for (const client of this.clients) {
336
- if (client.onHeadlessWorkspaceLogs) {
417
+ if (client.onWorkspaceImageBuildLogs) {
337
418
  try {
338
- client.onHeadlessWorkspaceLogs(evt);
419
+ client.onWorkspaceImageBuildLogs(info, content);
339
420
  } catch (error) {
340
421
  console.error(error)
341
422
  }
@@ -399,7 +480,7 @@ export class WorkspaceInstanceUpdateListener {
399
480
  private readonly onDidChangeEmitter = new Emitter<void>();
400
481
  readonly onDidChange = this.onDidChangeEmitter.event;
401
482
 
402
- private source: 'sync' | 'update' = 'sync';
483
+ private source: 'sync' | 'update' = 'sync';
403
484
 
404
485
  get info(): WorkspaceInfo {
405
486
  return this._info;
@@ -491,11 +572,15 @@ export class WorkspaceInstanceUpdateListener {
491
572
 
492
573
  }
493
574
 
575
+ export interface GitpodServiceOptions {
576
+ onReconnect?: () => (void | Promise<void>)
577
+ }
578
+
494
579
  export class GitpodServiceImpl<Client extends GitpodClient, Server extends GitpodServer> {
495
580
 
496
581
  private readonly compositeClient = new GitpodCompositeClient<Client>();
497
582
 
498
- constructor(public readonly server: JsonRpcProxy<Server>) {
583
+ constructor(public readonly server: JsonRpcProxy<Server>, private options?: GitpodServiceOptions) {
499
584
  server.setClient(this.compositeClient);
500
585
  server.onDidOpenConnection(() => this.compositeClient.notifyDidOpenConnection());
501
586
  server.onDidCloseConnection(() => this.compositeClient.notifyDidCloseConnection());
@@ -515,13 +600,34 @@ export class GitpodServiceImpl<Client extends GitpodClient, Server extends Gitpo
515
600
  this.instanceListeners.set(workspaceId, listener);
516
601
  return listener;
517
602
  }
603
+
604
+ async reconnect(): Promise<void> {
605
+ if (this.options?.onReconnect) {
606
+ await this.options.onReconnect();
607
+ }
608
+ }
518
609
  }
519
610
 
520
- export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string) {
521
- const url = new GitpodHostUrl(serverUrl)
522
- .asWebsocket()
523
- .withApi({ pathname: GitpodServerPath });
611
+ export function createGitpodService<C extends GitpodClient, S extends GitpodServer>(serverUrl: string | Promise<string>) {
612
+ const toWsUrl = (serverUrl: string) => {
613
+ return new GitpodHostUrl(serverUrl)
614
+ .asWebsocket()
615
+ .withApi({ pathname: GitpodServerPath })
616
+ .toString();
617
+ };
618
+ let url: string | Promise<string>;
619
+ if (typeof serverUrl === "string") {
620
+ url = toWsUrl(serverUrl);
621
+ } else {
622
+ url = serverUrl.then(url => toWsUrl(url));
623
+ }
624
+
524
625
  const connectionProvider = new WebSocketConnectionProvider();
525
- const gitpodServer = connectionProvider.createProxy<S>(url.toString());
526
- return new GitpodServiceImpl<C, S>(gitpodServer);
626
+ let onReconnect = () => { };
627
+ const gitpodServer = connectionProvider.createProxy<S>(url, undefined, {
628
+ onListening: socket => {
629
+ onReconnect = () => socket.reconnect();
630
+ }
631
+ });
632
+ return new GitpodServiceImpl<C, S>(gitpodServer, { onReconnect });
527
633
  }
@@ -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})/;
package/src/index.ts CHANGED
@@ -13,4 +13,8 @@ export * from './license-protocol';
13
13
  export * from './workspace-instance';
14
14
  export * from './permission';
15
15
  export * from './admin-protocol';
16
- export * from './email-protocol';
16
+ export * from './email-protocol';
17
+ export * from './headless-workspace-log';
18
+ export * from './context-url';
19
+ export * from './teams-projects-protocol';
20
+ export * from './snapshot-url';
@@ -5,13 +5,17 @@
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;
18
+ onListening?: (socket: ReconnectingWebSocket) => void;
15
19
  }
16
20
 
17
21
  export class WebSocketConnectionProvider {
@@ -23,19 +27,35 @@ export class WebSocketConnectionProvider {
23
27
  * An optional target can be provided to handle
24
28
  * notifications and requests from a remote side.
25
29
  */
26
- createProxy<T extends object>(path: string, target?: object, options?: WebSocketOptions): JsonRpcProxy<T> {
30
+ createProxy<T extends object>(path: string | Promise<string>, target?: object, options?: WebSocketOptions): JsonRpcProxy<T> {
27
31
  const factory = new JsonRpcProxyFactory<T>(target);
28
- this.listen({
29
- path,
30
- onConnection: c => factory.listen(c)
31
- }, options);
32
+ const startListening = (path: string) => {
33
+ const socket = this.listen({
34
+ path,
35
+ onConnection: c => factory.listen(c),
36
+ }, {
37
+ onTransportDidClose: () => factory.fireConnectionClosed(),
38
+ onTransportDidOpen: () => factory.fireConnectionOpened(),
39
+ },
40
+ options
41
+ );
42
+ if (options?.onListening) {
43
+ options.onListening(socket as any as ReconnectingWebSocket)
44
+ }
45
+ };
46
+
47
+ if (typeof path === "string") {
48
+ startListening(path);
49
+ } else {
50
+ path.then(path => startListening(path));
51
+ }
32
52
  return factory.createProxy();
33
53
  }
34
54
 
35
55
  /**
36
56
  * Install a connection handler for the given path.
37
57
  */
38
- listen(handler: ConnectionHandler, options?: WebSocketOptions): void {
58
+ listen(handler: ConnectionHandler, eventHandler: ConnectionEventHandler, options?: WebSocketOptions): WebSocket {
39
59
  const url = handler.path;
40
60
  const webSocket = this.createWebSocket(url);
41
61
 
@@ -50,11 +70,13 @@ export class WebSocketConnectionProvider {
50
70
  logger.error(JSON.stringify(error));
51
71
  });
52
72
  }
53
- doListen({
54
- webSocket,
55
- onConnection: connection => handler.onConnection(connection),
56
- logger
57
- });
73
+ doListen(
74
+ webSocket as any as ReconnectingWebSocket,
75
+ handler,
76
+ eventHandler,
77
+ logger,
78
+ );
79
+ return webSocket;
58
80
  }
59
81
 
60
82
  protected createLogger(): Logger {
@@ -76,3 +98,162 @@ export class WebSocketConnectionProvider {
76
98
  }
77
99
 
78
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
+ }