@gitpod/gitpod-protocol 0.1.5-v0.6.0-beta2 → 0.1.5-vn-integrate-gitpod-yml-tasks-into-jetbrainsa.5

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 (299) hide show
  1. package/data/builtin-theia-plugins.json +9 -9
  2. package/data/gitpod-schema.json +25 -24
  3. package/lib/accounting-protocol.d.ts +155 -0
  4. package/lib/accounting-protocol.d.ts.map +1 -0
  5. package/lib/accounting-protocol.js +109 -0
  6. package/lib/accounting-protocol.js.map +1 -0
  7. package/lib/admin-protocol.d.ts +31 -4
  8. package/lib/admin-protocol.d.ts.map +1 -1
  9. package/lib/admin-protocol.js +15 -0
  10. package/lib/admin-protocol.js.map +1 -1
  11. package/lib/analytics.d.ts +45 -0
  12. package/lib/analytics.d.ts.map +1 -0
  13. package/lib/analytics.js +10 -0
  14. package/lib/analytics.js.map +1 -0
  15. package/lib/auth.d.ts +25 -0
  16. package/lib/auth.d.ts.map +1 -0
  17. package/lib/auth.js +16 -0
  18. package/lib/auth.js.map +1 -0
  19. package/lib/context-url.d.ts +31 -0
  20. package/lib/context-url.d.ts.map +1 -0
  21. package/lib/context-url.js +102 -0
  22. package/lib/context-url.js.map +1 -0
  23. package/lib/context-url.spec.d.ts +14 -0
  24. package/lib/context-url.spec.d.ts.map +1 -0
  25. package/lib/context-url.spec.js +94 -0
  26. package/lib/context-url.spec.js.map +1 -0
  27. package/lib/email-protocol.d.ts +1 -2
  28. package/lib/email-protocol.d.ts.map +1 -1
  29. package/lib/email-protocol.js +4 -4
  30. package/lib/email-protocol.js.map +1 -1
  31. package/lib/encryption/container-module.js +5 -4
  32. package/lib/encryption/container-module.js.map +1 -1
  33. package/lib/encryption/encryption-engine.js +19 -20
  34. package/lib/encryption/encryption-engine.js.map +1 -1
  35. package/lib/encryption/encryption-engine.spec.js +29 -36
  36. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  37. package/lib/encryption/encryption-service.js +29 -43
  38. package/lib/encryption/encryption-service.js.map +1 -1
  39. package/lib/encryption/key-provider.js +25 -30
  40. package/lib/encryption/key-provider.js.map +1 -1
  41. package/lib/env.d.ts +1 -2
  42. package/lib/env.d.ts.map +1 -1
  43. package/lib/env.js +20 -21
  44. package/lib/env.js.map +1 -1
  45. package/lib/gitpod-file-parser.js +25 -41
  46. package/lib/gitpod-file-parser.js.map +1 -1
  47. package/lib/gitpod-file-parser.spec.js +116 -116
  48. package/lib/gitpod-file-parser.spec.js.map +1 -1
  49. package/lib/gitpod-service.d.ts +162 -20
  50. package/lib/gitpod-service.d.ts.map +1 -1
  51. package/lib/gitpod-service.js +170 -256
  52. package/lib/gitpod-service.js.map +1 -1
  53. package/lib/headless-workspace-log.d.ts +8 -11
  54. package/lib/headless-workspace-log.d.ts.map +1 -1
  55. package/lib/headless-workspace-log.js +4 -7
  56. package/lib/headless-workspace-log.js.map +1 -1
  57. package/lib/ide-frontend-service.d.ts +4 -0
  58. package/lib/ide-frontend-service.d.ts.map +1 -1
  59. package/lib/ide-protocol.d.ts +105 -0
  60. package/lib/ide-protocol.d.ts.map +1 -0
  61. package/lib/ide-protocol.js +8 -0
  62. package/lib/ide-protocol.js.map +1 -0
  63. package/lib/index.d.ts +6 -0
  64. package/lib/index.d.ts.map +1 -1
  65. package/lib/index.js +7 -1
  66. package/lib/index.js.map +1 -1
  67. package/lib/installation-admin-protocol.d.ts +27 -0
  68. package/lib/installation-admin-protocol.d.ts.map +1 -0
  69. package/lib/installation-admin-protocol.js +30 -0
  70. package/lib/installation-admin-protocol.js.map +1 -0
  71. package/lib/messaging/browser/connection.d.ts +5 -3
  72. package/lib/messaging/browser/connection.d.ts.map +1 -1
  73. package/lib/messaging/browser/connection.js +183 -33
  74. package/lib/messaging/browser/connection.js.map +1 -1
  75. package/lib/messaging/browser/window-connection.js +35 -55
  76. package/lib/messaging/browser/window-connection.js.map +1 -1
  77. package/lib/messaging/client-call-metrics.d.ts +35 -0
  78. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  79. package/lib/messaging/client-call-metrics.js +83 -0
  80. package/lib/messaging/client-call-metrics.js.map +1 -0
  81. package/lib/messaging/error.d.ts +5 -1
  82. package/lib/messaging/error.d.ts.map +1 -1
  83. package/lib/messaging/error.js +10 -2
  84. package/lib/messaging/error.js.map +1 -1
  85. package/lib/messaging/handler.d.ts +10 -0
  86. package/lib/messaging/handler.d.ts.map +1 -1
  87. package/lib/messaging/node/connection.d.ts +1 -17
  88. package/lib/messaging/node/connection.d.ts.map +1 -1
  89. package/lib/messaging/node/connection.js +23 -59
  90. package/lib/messaging/node/connection.js.map +1 -1
  91. package/lib/messaging/proxy-factory.d.ts +2 -0
  92. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  93. package/lib/messaging/proxy-factory.js +74 -159
  94. package/lib/messaging/proxy-factory.js.map +1 -1
  95. package/lib/oss-allowlist.d.ts +14 -0
  96. package/lib/oss-allowlist.d.ts.map +1 -0
  97. package/lib/oss-allowlist.js +8 -0
  98. package/lib/oss-allowlist.js.map +1 -0
  99. package/lib/payment-protocol.d.ts +18 -0
  100. package/lib/payment-protocol.d.ts.map +1 -0
  101. package/lib/payment-protocol.js +13 -0
  102. package/lib/payment-protocol.js.map +1 -0
  103. package/lib/permission.d.ts +8 -3
  104. package/lib/permission.d.ts.map +1 -1
  105. package/lib/permission.js +36 -19
  106. package/lib/permission.js.map +1 -1
  107. package/lib/plans.d.ts +210 -0
  108. package/lib/plans.d.ts.map +1 -0
  109. package/lib/plans.js +570 -0
  110. package/lib/plans.js.map +1 -0
  111. package/lib/protocol.d.ts +118 -58
  112. package/lib/protocol.d.ts.map +1 -1
  113. package/lib/protocol.js +116 -130
  114. package/lib/protocol.js.map +1 -1
  115. package/lib/snapshot-url.d.ts +14 -0
  116. package/lib/snapshot-url.d.ts.map +1 -0
  117. package/lib/snapshot-url.js +26 -0
  118. package/lib/snapshot-url.js.map +1 -0
  119. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  120. package/lib/snapshot-url.spec.d.ts.map +1 -0
  121. package/lib/snapshot-url.spec.js +41 -0
  122. package/lib/snapshot-url.spec.js.map +1 -0
  123. package/lib/team-subscription-protocol.d.ts +73 -0
  124. package/lib/team-subscription-protocol.d.ts.map +1 -0
  125. package/lib/team-subscription-protocol.js +63 -0
  126. package/lib/team-subscription-protocol.js.map +1 -0
  127. package/lib/teams-projects-protocol.d.ts +113 -0
  128. package/lib/teams-projects-protocol.d.ts.map +1 -0
  129. package/lib/teams-projects-protocol.js +30 -0
  130. package/lib/teams-projects-protocol.js.map +1 -0
  131. package/lib/util/analytics.d.ts +8 -0
  132. package/lib/util/analytics.d.ts.map +1 -0
  133. package/lib/util/analytics.js +79 -0
  134. package/lib/util/analytics.js.map +1 -0
  135. package/lib/util/async-iterator.js +55 -133
  136. package/lib/util/async-iterator.js.map +1 -1
  137. package/lib/util/cancelable.js +17 -59
  138. package/lib/util/cancelable.js.map +1 -1
  139. package/lib/util/date-time.js +8 -8
  140. package/lib/util/date-time.js.map +1 -1
  141. package/lib/util/deferred.js +10 -12
  142. package/lib/util/deferred.js.map +1 -1
  143. package/lib/util/disposable.js +26 -39
  144. package/lib/util/disposable.js.map +1 -1
  145. package/lib/util/event.js +58 -74
  146. package/lib/util/event.js.map +1 -1
  147. package/lib/util/garbage-collected-cache.d.ts +1 -0
  148. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  149. package/lib/util/garbage-collected-cache.js +26 -46
  150. package/lib/util/garbage-collected-cache.js.map +1 -1
  151. package/lib/util/generate-workspace-id.d.ts +4 -0
  152. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  153. package/lib/util/generate-workspace-id.js +487 -0
  154. package/lib/util/generate-workspace-id.js.map +1 -0
  155. package/lib/util/{without.d.ts → generate-workspace-id.spec.d.ts} +2 -2
  156. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  157. package/lib/util/generate-workspace-id.spec.js +87 -0
  158. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  159. package/lib/util/gitpod-cookie.d.ts +20 -0
  160. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  161. package/lib/util/gitpod-cookie.js +44 -0
  162. package/lib/util/gitpod-cookie.js.map +1 -0
  163. package/lib/util/gitpod-host-url.d.ts +2 -2
  164. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  165. package/lib/util/gitpod-host-url.js +96 -95
  166. package/lib/util/gitpod-host-url.js.map +1 -1
  167. package/lib/util/gitpod-host-url.spec.d.ts +8 -1
  168. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  169. package/lib/util/gitpod-host-url.spec.js +104 -22
  170. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  171. package/lib/util/grpc.d.ts +15 -0
  172. package/lib/util/grpc.d.ts.map +1 -0
  173. package/lib/util/grpc.js +18 -0
  174. package/lib/util/grpc.js.map +1 -0
  175. package/lib/util/jaeger-client-types.d.ts +68 -0
  176. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  177. package/lib/util/{without.js → jaeger-client-types.js} +1 -1
  178. package/lib/util/jaeger-client-types.js.map +1 -0
  179. package/lib/util/logging.d.ts +49 -33
  180. package/lib/util/logging.d.ts.map +1 -1
  181. package/lib/util/logging.js +107 -110
  182. package/lib/util/logging.js.map +1 -1
  183. package/lib/util/make-link.js +2 -2
  184. package/lib/util/make-link.js.map +1 -1
  185. package/lib/util/parse-workspace-id.d.ts +13 -3
  186. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  187. package/lib/util/parse-workspace-id.js +38 -8
  188. package/lib/util/parse-workspace-id.js.map +1 -1
  189. package/lib/util/parse-workspace-id.spec.d.ts +8 -0
  190. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  191. package/lib/util/parse-workspace-id.spec.js +127 -47
  192. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  193. package/lib/util/queue.js +16 -55
  194. package/lib/util/queue.js.map +1 -1
  195. package/lib/util/queue.spec.js +144 -288
  196. package/lib/util/queue.spec.js.map +1 -1
  197. package/lib/util/repeat.d.ts +15 -0
  198. package/lib/util/repeat.d.ts.map +1 -0
  199. package/lib/util/repeat.js +55 -0
  200. package/lib/util/repeat.js.map +1 -0
  201. package/lib/util/semaphore.js +15 -46
  202. package/lib/util/semaphore.js.map +1 -1
  203. package/lib/util/skip-if.js +6 -6
  204. package/lib/util/skip-if.js.map +1 -1
  205. package/lib/util/timeutil.js +28 -16
  206. package/lib/util/timeutil.js.map +1 -1
  207. package/lib/util/timeutil.spec.js +21 -24
  208. package/lib/util/timeutil.spec.js.map +1 -1
  209. package/lib/util/tracing.d.ts +51 -5
  210. package/lib/util/tracing.d.ts.map +1 -1
  211. package/lib/util/tracing.js +197 -62
  212. package/lib/util/tracing.js.map +1 -1
  213. package/lib/util/tracing.spec.d.ts +7 -0
  214. package/lib/util/tracing.spec.d.ts.map +1 -0
  215. package/lib/util/tracing.spec.js +121 -0
  216. package/lib/util/tracing.spec.js.map +1 -0
  217. package/lib/util/workspace-port-authentication.js +3 -2
  218. package/lib/util/workspace-port-authentication.js.map +1 -1
  219. package/lib/workspace-cluster.d.ts +76 -0
  220. package/lib/workspace-cluster.d.ts.map +1 -0
  221. package/lib/workspace-cluster.js +33 -0
  222. package/lib/workspace-cluster.js.map +1 -0
  223. package/lib/workspace-instance.d.ts +26 -2
  224. package/lib/workspace-instance.d.ts.map +1 -1
  225. package/lib/wsready.d.ts +1 -1
  226. package/lib/wsready.js +2 -2
  227. package/package.json +33 -17
  228. package/pkg-yarn.lock +18 -9
  229. package/provenance-bundle.jsonl +2 -0
  230. package/src/accounting-protocol.ts +229 -0
  231. package/src/admin-protocol.ts +53 -5
  232. package/src/analytics.ts +54 -0
  233. package/src/auth.ts +27 -0
  234. package/src/context-url.spec.ts +53 -0
  235. package/src/context-url.ts +107 -0
  236. package/src/email-protocol.ts +2 -3
  237. package/src/env.ts +10 -10
  238. package/src/gitpod-service.ts +237 -38
  239. package/src/headless-workspace-log.ts +7 -11
  240. package/src/ide-frontend-service.ts +5 -1
  241. package/src/ide-protocol.ts +119 -0
  242. package/src/index.ts +7 -1
  243. package/src/installation-admin-protocol.ts +42 -0
  244. package/src/messaging/browser/connection.ts +195 -14
  245. package/src/messaging/client-call-metrics.ts +97 -0
  246. package/src/messaging/error.ts +14 -2
  247. package/src/messaging/handler.ts +12 -0
  248. package/src/messaging/node/connection.ts +21 -68
  249. package/src/messaging/proxy-factory.ts +14 -6
  250. package/src/oss-allowlist.ts +15 -0
  251. package/src/payment-protocol.ts +20 -0
  252. package/src/permission.ts +24 -9
  253. package/src/plans.ts +632 -0
  254. package/src/protocol.ts +192 -87
  255. package/src/snapshot-url.spec.ts +25 -0
  256. package/src/snapshot-url.ts +27 -0
  257. package/src/team-subscription-protocol.ts +113 -0
  258. package/src/teams-projects-protocol.ts +147 -0
  259. package/src/util/analytics.ts +87 -0
  260. package/src/util/deferred.ts +1 -1
  261. package/src/util/garbage-collected-cache.ts +9 -3
  262. package/src/util/generate-workspace-id.spec.ts +48 -0
  263. package/src/util/generate-workspace-id.ts +475 -0
  264. package/src/util/gitpod-cookie.ts +39 -0
  265. package/src/util/gitpod-host-url.spec.ts +30 -1
  266. package/src/util/gitpod-host-url.ts +27 -13
  267. package/src/util/grpc.ts +15 -0
  268. package/src/util/jaeger-client-types.ts +102 -0
  269. package/src/util/logging.ts +102 -38
  270. package/src/util/parse-workspace-id.spec.ts +45 -4
  271. package/src/util/parse-workspace-id.ts +38 -7
  272. package/src/util/queue.spec.ts +1 -1
  273. package/src/util/repeat.ts +45 -0
  274. package/src/util/semaphore.ts +2 -2
  275. package/src/util/skip-if.ts +1 -1
  276. package/src/util/timeutil.ts +4 -4
  277. package/src/util/tracing.spec.ts +83 -0
  278. package/src/util/tracing.ts +183 -17
  279. package/src/workspace-cluster.ts +104 -0
  280. package/src/workspace-instance.ts +51 -13
  281. package/src/wsready.ts +2 -2
  282. package/lib/messaging/connection-error-handler.d.ts +0 -27
  283. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  284. package/lib/messaging/connection-error-handler.js +0 -46
  285. package/lib/messaging/connection-error-handler.js.map +0 -1
  286. package/lib/util/repeater.d.ts +0 -22
  287. package/lib/util/repeater.d.ts.map +0 -1
  288. package/lib/util/repeater.js +0 -118
  289. package/lib/util/repeater.js.map +0 -1
  290. package/lib/util/safe-promise.d.ts +0 -11
  291. package/lib/util/safe-promise.d.ts.map +0 -1
  292. package/lib/util/safe-promise.js +0 -34
  293. package/lib/util/safe-promise.js.map +0 -1
  294. package/lib/util/without.d.ts.map +0 -1
  295. package/lib/util/without.js.map +0 -1
  296. package/src/messaging/connection-error-handler.ts +0 -62
  297. package/src/util/jaeger-client.d.ts +0 -105
  298. package/src/util/repeater.ts +0 -49
  299. package/src/util/safe-promise.ts +0 -26
package/src/protocol.ts CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
8
8
  import { RoleOrPermission } from "./permission";
9
+ import { Project } from "./teams-projects-protocol";
9
10
 
10
11
  export interface UserInfo {
11
12
  name?: string
@@ -27,19 +28,12 @@ export interface User {
27
28
 
28
29
  identities: Identity[]
29
30
 
30
- allowsMarketingCommunication: boolean;
31
-
32
31
  /**
33
32
  * Whether the user has been blocked to use our service, because of TOS violation for example.
34
33
  * Optional for backwards compatibility.
35
34
  */
36
35
  blocked?: boolean;
37
36
 
38
- /**
39
- * whether this user can run workspaces in privileged mode
40
- */
41
- privileged?: boolean;
42
-
43
37
  /** A map of random settings that alter the behaviour of Gitpod on a per-user basis */
44
38
  featureFlags?: UserFeatureSettings;
45
39
 
@@ -103,14 +97,29 @@ export interface AdditionalUserData {
103
97
  emailNotificationSettings?: EmailNotificationSettings;
104
98
  featurePreview?: boolean;
105
99
  ideSettings?: IDESettings;
100
+ // key is the name of the news, string the iso date when it was seen
101
+ whatsNewSeen?: { [key: string]: string }
102
+ // key is the name of the OAuth client i.e. local app, string the iso date when it was approved
103
+ // TODO(rl): provide a management UX to allow rescinding of approval
104
+ oauthClientsApproved?: { [key: string]: string }
105
+ // to remember GH Orgs the user installed/updated the GH App for
106
+ knownGitHubOrgs?: string[];
107
+
108
+ // Git clone URL pointing to the user's dotfile repo
109
+ dotfileRepo?: string;
106
110
  }
107
111
 
108
112
  export interface EmailNotificationSettings {
109
- disallowTransactionalEmails?: boolean;
113
+ allowsChangelogMail?: boolean;
114
+ allowsDevXMail?: boolean;
115
+ allowsOnboardingMail?: boolean;
110
116
  }
111
117
 
112
118
  export type IDESettings = {
113
119
  defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
122
+ useLatestVersion?: boolean
114
123
  }
115
124
 
116
125
  export interface UserPlatform {
@@ -132,14 +141,6 @@ export interface UserPlatform {
132
141
  }
133
142
 
134
143
  export interface UserFeatureSettings {
135
- /**
136
- * This field is used as marker to grant users a free trial for using private repositories,
137
- * independent of any subscription or Chargebee.
138
- * - it is set when the user uses their first private repo
139
- * - whether the trial is expired or not is juged by the UserService
140
- */
141
- privateRepoTrialStartDate?: string;
142
-
143
144
  /**
144
145
  * Permanent feature flags are added to each and every workspace instance
145
146
  * this user starts.
@@ -151,15 +152,26 @@ export interface UserFeatureSettings {
151
152
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
152
153
  * If they don't we'll break things during workspace startup.
153
154
  */
154
- export const WorkspaceFeatureFlags = { "privileged": undefined, "registry_facade": undefined, "full_workspace_backup": undefined, "fixed_resources": undefined, "user_namespace": undefined };
155
+ export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
155
156
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
156
157
 
157
- export interface UserEnvVarValue {
158
- id?: string;
158
+ export interface EnvVarWithValue {
159
159
  name: string;
160
- repositoryPattern: string;
161
160
  value: string;
162
161
  }
162
+
163
+ export interface ProjectEnvVarWithValue extends EnvVarWithValue {
164
+ id: string;
165
+ projectId: string;
166
+ censored: boolean;
167
+ }
168
+
169
+ export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
170
+
171
+ export interface UserEnvVarValue extends EnvVarWithValue {
172
+ id?: string;
173
+ repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
174
+ }
163
175
  export interface UserEnvVar extends UserEnvVarValue {
164
176
  id: string;
165
177
  userId: string;
@@ -168,10 +180,35 @@ export interface UserEnvVar extends UserEnvVarValue {
168
180
 
169
181
  export namespace UserEnvVar {
170
182
 
183
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
171
184
  export function normalizeRepoPattern(pattern: string) {
172
185
  return pattern.toLocaleLowerCase();
173
186
  }
174
187
 
188
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
189
+ export function score(value: UserEnvVarValue): number {
190
+ // We use a score to enforce precedence:
191
+ // value/value = 0
192
+ // value/* = 1
193
+ // */value = 2
194
+ // */* = 3
195
+ // #/# = 4 (used for env vars passed through the URL)
196
+ // the lower the score, the higher the precedence.
197
+ const [ownerPattern, repoPattern] = splitRepositoryPattern(value.repositoryPattern);
198
+ let score = 0;
199
+ if (repoPattern == "*") {
200
+ score += 1;
201
+ }
202
+ if (ownerPattern == '*') {
203
+ score += 2;
204
+ }
205
+ if (ownerPattern == "#" || repoPattern == "#") {
206
+ score = 4;
207
+ }
208
+ return score;
209
+ }
210
+
211
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
175
212
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
176
213
  let result = vars.filter(e => {
177
214
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -207,25 +244,7 @@ export namespace UserEnvVar {
207
244
  let minscore = 10;
208
245
  let bestCandidate: T | undefined;
209
246
  for (const e of candidates) {
210
- // We use a score to enforce precedence:
211
- // value/value = 0
212
- // value/* = 1
213
- // */value = 2
214
- // */* = 3
215
- // #/# = 4 (used for env vars passed through the URL)
216
- // the lower the score, the higher the precedence.
217
- const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
218
- let score = 0;
219
- if (repoPattern == "*") {
220
- score += 1;
221
- }
222
- if (ownerPattern == '*') {
223
- score += 2;
224
- }
225
- if (ownerPattern == "#" || repoPattern == "#") {
226
- score = 4;
227
- }
228
-
247
+ const score = UserEnvVar.score(e);
229
248
  if (!bestCandidate || score < minscore) {
230
249
  minscore = score;
231
250
  bestCandidate = e;
@@ -237,10 +256,11 @@ export namespace UserEnvVar {
237
256
  return result;
238
257
  }
239
258
 
240
- function splitRepositoryPattern(repositoryPattern: string): string[] {
259
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
260
+ export function splitRepositoryPattern(repositoryPattern: string): string[] {
241
261
  const patterns = repositoryPattern.split('/');
242
- const repoPattern = patterns.pop() || "";
243
- const ownerPattern = patterns.join('/');
262
+ const repoPattern = patterns.slice(1).join('/')
263
+ const ownerPattern = patterns[0];
244
264
  return [ownerPattern, repoPattern];
245
265
  }
246
266
  }
@@ -371,11 +391,16 @@ export interface PendingGithubEvent {
371
391
  export interface Snapshot {
372
392
  id: string;
373
393
  creationTime: string;
394
+ availableTime?: string;
374
395
  originalWorkspaceId: string;
375
396
  bucketId: string;
376
397
  layoutData?: string;
398
+ state: SnapshotState;
399
+ message?: string;
377
400
  }
378
401
 
402
+ export type SnapshotState = 'pending' | 'available' | 'error';
403
+
379
404
  export interface LayoutData {
380
405
  workspaceId: string;
381
406
  lastUpdatedTime: string;
@@ -388,6 +413,7 @@ export interface Workspace {
388
413
  contextURL: string;
389
414
  description: string;
390
415
  ownerId: string;
416
+ projectId?: string;
391
417
  context: WorkspaceContext;
392
418
  config: WorkspaceConfig;
393
419
 
@@ -507,6 +533,24 @@ export interface UninstallPluginParams {
507
533
  pluginId: string;
508
534
  }
509
535
 
536
+ export interface GuessGitTokenScopesParams {
537
+ host: string
538
+ repoUrl: string
539
+ gitCommand: string
540
+ currentToken: GitToken
541
+ }
542
+
543
+ export interface GitToken {
544
+ token: string
545
+ user: string
546
+ scopes: string[]
547
+ }
548
+
549
+ export interface GuessedGitTokenScopes {
550
+ message?: string
551
+ scopes?: string[]
552
+ }
553
+
510
554
  export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
511
555
 
512
556
  export interface ResolvedPlugins {
@@ -532,16 +576,21 @@ export interface WorkspaceConfig {
532
576
  gitConfig?: { [config: string]: string };
533
577
  github?: GithubAppConfig;
534
578
  vscode?: VSCodeConfig;
535
-
579
+
580
+ /** deprecated. Enabled by default **/
581
+ experimentalNetwork?: boolean;
582
+
536
583
  /**
537
584
  * Where the config object originates from.
538
- *
585
+ *
539
586
  * repo - from the repository
587
+ * project-db - from the "Project" stored in the database
540
588
  * definitly-gp - from github.com/gitpod-io/definitely-gp
541
589
  * derived - computed based on analyzing the repository
590
+ * additional-content - config comes from additional content, usually provided through the project's configuration
542
591
  * default - our static catch-all default config
543
592
  */
544
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
593
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
545
594
 
546
595
  /**
547
596
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -558,7 +607,7 @@ export interface GithubAppPrebuildConfig {
558
607
  branches?: boolean
559
608
  pullRequests?: boolean
560
609
  pullRequestsFromForks?: boolean
561
- addCheck?: boolean
610
+ addCheck?: boolean | 'prevent-merge-on-error'
562
611
  addBadge?: boolean
563
612
  addLabel?: boolean | string
564
613
  addComment?: boolean
@@ -571,16 +620,13 @@ export namespace GithubAppPrebuildConfig {
571
620
 
572
621
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
573
622
  export interface WorkspaceImageSourceDocker {
574
- // TODO: clean this up. We should have the commit and an ImageSource in here, not duplicate the whole thing again.
575
- // We have a ton of those objects in the database, thus cleaning this up means lengthy DB migrations. Yuck.
576
- dockerFileHash: string
577
- dockerFileSource: Commit
578
623
  dockerFilePath: string
624
+ dockerFileHash: string
625
+ dockerFileSource?: Commit
579
626
  }
580
627
  export namespace WorkspaceImageSourceDocker {
581
628
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
582
629
  return 'dockerFileHash' in obj
583
- && 'dockerFileSource' in obj
584
630
  && 'dockerFilePath' in obj;
585
631
  }
586
632
  }
@@ -609,6 +655,8 @@ export type PrebuiltWorkspaceState
609
655
  export interface PrebuiltWorkspace {
610
656
  id: string;
611
657
  cloneURL: string;
658
+ branch?: string;
659
+ projectId?: string;
612
660
  commit: string;
613
661
  buildWorkspaceId: string;
614
662
  creationTime: string;
@@ -619,7 +667,7 @@ export interface PrebuiltWorkspace {
619
667
 
620
668
  export namespace PrebuiltWorkspace {
621
669
  export function isDone(pws: PrebuiltWorkspace) {
622
- return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
670
+ return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
623
671
  }
624
672
 
625
673
  export function isAvailable(pws: PrebuiltWorkspace) {
@@ -655,6 +703,8 @@ export interface PortConfig {
655
703
  port: number;
656
704
  onOpen?: PortOnOpen;
657
705
  visibility?: PortVisibility;
706
+ description?: string;
707
+ name?: string;
658
708
  }
659
709
  export namespace PortConfig {
660
710
  export function is(config: any): config is PortConfig {
@@ -678,7 +728,7 @@ export interface TaskConfig {
678
728
  init?: string;
679
729
  prebuild?: string;
680
730
  command?: string;
681
- env?: { [env: string]: string };
731
+ env?: { [env: string]: any };
682
732
  openIn?: 'bottom' | 'main' | 'left' | 'right';
683
733
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
684
734
  }
@@ -742,8 +792,10 @@ export namespace ExternalImageConfigFile {
742
792
 
743
793
  export interface WorkspaceContext {
744
794
  title: string;
795
+ /** This contains the URL portion of the contextURL (which might contain other modifiers as well). It's optional because it's not set for older workspaces. */
745
796
  normalizedContextURL?: string;
746
797
  forceCreateNewWorkspace?: boolean;
798
+ forceImageBuild?: boolean;
747
799
  }
748
800
 
749
801
  export namespace WorkspaceContext {
@@ -777,6 +829,29 @@ export namespace WithPrebuild {
777
829
  }
778
830
  }
779
831
 
832
+ /**
833
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
834
+ * and fall back to the built-in configuration.
835
+ */
836
+ export interface WithDefaultConfig {
837
+ withDefaultConfig: true;
838
+ }
839
+
840
+ export namespace WithDefaultConfig {
841
+ export function is(context: any): context is WithDefaultConfig {
842
+ return context
843
+ && 'withDefaultConfig' in context
844
+ && context.withDefaultConfig;
845
+ }
846
+
847
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
848
+ return {
849
+ ...ctx,
850
+ withDefaultConfig: true
851
+ }
852
+ }
853
+ }
854
+
780
855
  export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
781
856
  snapshotId: string;
782
857
  }
@@ -791,6 +866,9 @@ export namespace SnapshotContext {
791
866
 
792
867
  export interface StartPrebuildContext extends WorkspaceContext {
793
868
  actual: WorkspaceContext;
869
+ commitHistory?: string[];
870
+ project?: Project;
871
+ branch?: string;
794
872
  }
795
873
 
796
874
  export namespace StartPrebuildContext {
@@ -814,8 +892,20 @@ export namespace PrebuiltWorkspaceContext {
814
892
  }
815
893
  }
816
894
 
895
+ export interface WithReferrerContext extends WorkspaceContext {
896
+ referrer: string
897
+ referrerIde?: string
898
+ }
899
+
900
+ export namespace WithReferrerContext {
901
+ export function is(context: any): context is WithReferrerContext {
902
+ return context
903
+ && 'referrer' in context;
904
+ }
905
+ }
906
+
817
907
  export interface WithEnvvarsContext extends WorkspaceContext {
818
- envvars: UserEnvVarValue[];
908
+ envvars: EnvVarWithValue[];
819
909
  }
820
910
 
821
911
  export namespace WithEnvvarsContext {
@@ -860,6 +950,25 @@ export interface Commit {
860
950
  refType?: RefType
861
951
  }
862
952
 
953
+ export interface AdditionalContentContext extends WorkspaceContext {
954
+
955
+ /**
956
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
957
+ */
958
+ additionalFiles: {[filePath: string]: string};
959
+
960
+ }
961
+
962
+ export namespace AdditionalContentContext {
963
+ export function is(ctx: any): ctx is AdditionalContentContext {
964
+ return 'additionalFiles' in ctx;
965
+ }
966
+
967
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
968
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
969
+ }
970
+ }
971
+
863
972
  export interface CommitContext extends WorkspaceContext, Commit {
864
973
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
865
974
  cloneUrl?: string
@@ -935,6 +1044,19 @@ export interface Repository {
935
1044
  parent: Repository
936
1045
  }
937
1046
  }
1047
+ export interface Branch {
1048
+ name: string;
1049
+ commit: CommitInfo;
1050
+ htmlUrl: string;
1051
+ }
1052
+
1053
+ export interface CommitInfo {
1054
+ author: string;
1055
+ sha: string;
1056
+ commitMessage: string;
1057
+ authorAvatarUrl?: string;
1058
+ authorDate?: string;
1059
+ }
938
1060
 
939
1061
  export namespace Repository {
940
1062
  export function fullRepoName(repo: Repository): string {
@@ -962,6 +1084,12 @@ export interface WorkspaceInfo {
962
1084
  latestInstance?: WorkspaceInstance
963
1085
  }
964
1086
 
1087
+ export namespace WorkspaceInfo {
1088
+ export function lastActiveISODate(info: WorkspaceInfo): string {
1089
+ return info.latestInstance?.creationTime || info.workspace.creationTime;
1090
+ }
1091
+ }
1092
+
965
1093
  export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
966
1094
 
967
1095
  export interface WorkspaceCreationResult {
@@ -971,6 +1099,7 @@ export interface WorkspaceCreationResult {
971
1099
  runningWorkspacePrebuild?: {
972
1100
  prebuildID: string
973
1101
  workspaceID: string
1102
+ instanceID: string
974
1103
  starting: RunningWorkspacePrebuildStarting
975
1104
  sameCluster: boolean
976
1105
  }
@@ -1061,40 +1190,16 @@ export interface OAuth2Config {
1061
1190
  export namespace AuthProviderEntry {
1062
1191
  export type Type = "GitHub" | "GitLab" | string;
1063
1192
  export type Status = "pending" | "verified";
1064
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type">;
1193
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1065
1194
  export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
1066
- }
1067
-
1068
- export interface Branding {
1069
- readonly name: string;
1070
- readonly favicon?: string;
1071
- /** Either including domain OR absolute path (interpreted relative to host URL) */
1072
- readonly logo: string;
1073
- readonly startupLogo: string;
1074
- readonly showProductivityTips: boolean;
1075
- readonly redirectUrlIfNotAuthenticated?: string;
1076
- readonly redirectUrlAfterLogout?: string;
1077
- readonly homepage: string;
1078
- readonly ide?: {
1079
- readonly logo: string;
1080
- readonly showReleaseNotes: boolean;
1081
- readonly helpMenu: Branding.Link[];
1082
- }
1083
- readonly links: {
1084
- readonly header: Branding.Link[];
1085
- readonly footer: Branding.Link[];
1086
- readonly social: Branding.SocialLink[];
1087
- readonly legal: Branding.Link[];
1088
- }
1089
- }
1090
- export namespace Branding {
1091
- export interface Link {
1092
- readonly name: string;
1093
- readonly url: string;
1094
- }
1095
- export interface SocialLink {
1096
- readonly type: string;
1097
- readonly url: string;
1195
+ export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1196
+ return {
1197
+ ...entry,
1198
+ oauth: {
1199
+ ...entry.oauth,
1200
+ clientSecret: "redacted"
1201
+ }
1202
+ }
1098
1203
  }
1099
1204
  }
1100
1205
 
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { suite, test } from "mocha-typescript"
8
+ import * as chai from "chai"
9
+ import { SnapshotUrl } from ".";
10
+
11
+ const expect = chai.expect
12
+
13
+ @suite class TestSnapshotUrlParser {
14
+
15
+ @test public testPositive() {
16
+ const actual = SnapshotUrl.parse("workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd");
17
+
18
+ expect(actual).to.deep.equal(<SnapshotUrl>{
19
+ bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
20
+ filename: "3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
21
+ fullPath: "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar",
22
+ });
23
+ }
24
+ }
25
+ module.exports = new TestSnapshotUrlParser() // Only to circumvent no usage warning :-/
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ export interface SnapshotUrl {
8
+ bucketId: string;
9
+ fullPath: string;
10
+ filename: string;
11
+ }
12
+ export namespace SnapshotUrl {
13
+ export function parse(url: string): SnapshotUrl {
14
+ const parts = url.split("@");
15
+ if (parts.length !== 2) {
16
+ throw new Error(`cannot parse snapshot URL: ${url}`);
17
+ }
18
+ const [fullPath, bucketId] = parts;
19
+
20
+ const pathParts = fullPath.split("/");
21
+ if (pathParts.length < 1) {
22
+ throw new Error(`cannot parse snapshot URL: ${url}`);
23
+ }
24
+ const filename = pathParts[pathParts.length - 1];
25
+ return { bucketId, fullPath, filename };
26
+ }
27
+ }
@@ -0,0 +1,113 @@
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
+ import { v4 as uuidv4 } from 'uuid';
8
+ import { Subscription } from "./accounting-protocol";
9
+
10
+ export interface TeamSubscription {
11
+ id: string;
12
+ userId: string;
13
+ planId: string;
14
+ startDate: string;
15
+ endDate?: string;
16
+ quantity: number;
17
+ /** The Chargebee subscription id */
18
+ paymentReference: string;
19
+ cancellationDate?: string;
20
+ deleted?: boolean;
21
+ }
22
+
23
+ export namespace TeamSubscription {
24
+ export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
25
+ const withId = ts as TeamSubscription;
26
+ withId.id = uuidv4();
27
+ return withId;
28
+ }
29
+ export const isActive = (ts: TeamSubscription, date: string): boolean => {
30
+ return ts.startDate <= date && (ts.endDate === undefined || date < ts.endDate);
31
+ }
32
+ }
33
+
34
+ /**
35
+ * A slot represents one unit of a TeamSubscription that gets assigned to one user at a time
36
+ */
37
+ export interface TeamSubscriptionSlot {
38
+ id: string;
39
+ teamSubscriptionId: string;
40
+ assigneeId?: string;
41
+ assigneeIdentifier?: AssigneeIdentifier;
42
+ subscriptionId?: string;
43
+ cancellationDate?: string;
44
+ }
45
+ export type TeamSubscriptionSlotDeactivated = TeamSubscriptionSlot & { assigneeId: string, assigneeIdentifier: AssigneeIdentifier };
46
+ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscriptionSlotDeactivated & { subscriptionId: string };
47
+
48
+ export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
49
+
50
+ export namespace TeamSubscriptionSlot {
51
+ export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
52
+ const withId = ts as TeamSubscriptionSlot;
53
+ withId.id = uuidv4();
54
+ return withId;
55
+ }
56
+ export const assign = (slot: TeamSubscriptionSlot, assigneeId: string, subscriptionId: string, assigneeIdentifier: AssigneeIdentifier) => {
57
+ slot.assigneeId = assigneeId;
58
+ slot.subscriptionId = subscriptionId;
59
+ slot.assigneeIdentifier = assigneeIdentifier;
60
+ }
61
+ export const deactivate = (slot: TeamSubscriptionSlot, cancellationDate: string) => {
62
+ slot.subscriptionId = undefined;
63
+ slot.cancellationDate = cancellationDate;
64
+ }
65
+ export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
66
+ slot.subscriptionId = subscriptionId;
67
+ slot.cancellationDate = undefined;
68
+ }
69
+ export const status = (slot: TeamSubscriptionSlot, now: string): TeamSubscriptionSlotState => {
70
+ if (slot.cancellationDate) {
71
+ if (slot.cancellationDate < now) {
72
+ return 'cancelled';
73
+ } else {
74
+ return 'deactivated';
75
+ }
76
+ } else {
77
+ if (slot.subscriptionId) {
78
+ return 'assigned';
79
+ } else {
80
+ return 'unassigned';
81
+ }
82
+ }
83
+
84
+ }
85
+ export const isActive = (slot: TeamSubscriptionSlot): boolean => {
86
+ return !slot.cancellationDate;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * The mapping between a TeamSubscription and a resulting Subscription, resolved
92
+ */
93
+ export interface TeamSubscriptionSlotResolved {
94
+ id: string;
95
+ teamSubscription: TeamSubscription;
96
+ state: TeamSubscriptionSlotState;
97
+ assigneeId?: string;
98
+ assigneeIdentifier?: AssigneeIdentifier;
99
+ subscription?: Subscription;
100
+ cancellationDate?: string;
101
+ hoursLeft?: number;
102
+ }
103
+
104
+ /**
105
+ * Contains the data structure that the assigner used to identify the assignee.
106
+ */
107
+ export type AssigneeIdentifier = AssigneeIdentityIdentifier;
108
+ export interface AssigneeIdentityIdentifier {
109
+ identity: {
110
+ authHost: string,
111
+ authName: string
112
+ }
113
+ }