@gitpod/gitpod-protocol 0.1.5-wth-update-mysql-dependencies-2.31 → 0.1.5-wth-test.80

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 (295) hide show
  1. package/data/gitpod-schema.json +25 -24
  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 +26 -4
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +15 -0
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +44 -0
  11. package/lib/analytics.d.ts.map +1 -0
  12. package/lib/analytics.js +10 -0
  13. package/lib/analytics.js.map +1 -0
  14. package/lib/context-url.d.ts +31 -0
  15. package/lib/context-url.d.ts.map +1 -0
  16. package/lib/context-url.js +102 -0
  17. package/lib/context-url.js.map +1 -0
  18. package/lib/context-url.spec.d.ts +14 -0
  19. package/lib/context-url.spec.d.ts.map +1 -0
  20. package/lib/context-url.spec.js +94 -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 +124 -22
  45. package/lib/gitpod-service.d.ts.map +1 -1
  46. package/lib/gitpod-service.js +169 -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/ide-protocol.d.ts +105 -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 +6 -0
  57. package/lib/index.d.ts.map +1 -1
  58. package/lib/index.js +7 -1
  59. package/lib/index.js.map +1 -1
  60. package/lib/installation-admin-protocol.d.ts +27 -0
  61. package/lib/installation-admin-protocol.d.ts.map +1 -0
  62. package/lib/installation-admin-protocol.js +30 -0
  63. package/lib/installation-admin-protocol.js.map +1 -0
  64. package/lib/messaging/browser/connection.d.ts +5 -3
  65. package/lib/messaging/browser/connection.d.ts.map +1 -1
  66. package/lib/messaging/browser/connection.js +183 -33
  67. package/lib/messaging/browser/connection.js.map +1 -1
  68. package/lib/messaging/browser/window-connection.js +35 -55
  69. package/lib/messaging/browser/window-connection.js.map +1 -1
  70. package/lib/messaging/client-call-metrics.d.ts +35 -0
  71. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  72. package/lib/messaging/client-call-metrics.js +83 -0
  73. package/lib/messaging/client-call-metrics.js.map +1 -0
  74. package/lib/messaging/error.d.ts +3 -1
  75. package/lib/messaging/error.d.ts.map +1 -1
  76. package/lib/messaging/error.js +6 -2
  77. package/lib/messaging/error.js.map +1 -1
  78. package/lib/messaging/handler.d.ts +10 -0
  79. package/lib/messaging/handler.d.ts.map +1 -1
  80. package/lib/messaging/node/connection.d.ts +1 -17
  81. package/lib/messaging/node/connection.d.ts.map +1 -1
  82. package/lib/messaging/node/connection.js +23 -59
  83. package/lib/messaging/node/connection.js.map +1 -1
  84. package/lib/messaging/proxy-factory.d.ts +2 -0
  85. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  86. package/lib/messaging/proxy-factory.js +74 -159
  87. package/lib/messaging/proxy-factory.js.map +1 -1
  88. package/lib/oss-allowlist.d.ts +14 -0
  89. package/lib/oss-allowlist.d.ts.map +1 -0
  90. package/lib/oss-allowlist.js +8 -0
  91. package/lib/oss-allowlist.js.map +1 -0
  92. package/lib/permission.d.ts +8 -1
  93. package/lib/permission.d.ts.map +1 -1
  94. package/lib/permission.js +36 -15
  95. package/lib/permission.js.map +1 -1
  96. package/lib/plans.d.ts +210 -0
  97. package/lib/plans.d.ts.map +1 -0
  98. package/lib/plans.js +570 -0
  99. package/lib/plans.js.map +1 -0
  100. package/lib/protocol.d.ts +121 -54
  101. package/lib/protocol.d.ts.map +1 -1
  102. package/lib/protocol.js +117 -131
  103. package/lib/protocol.js.map +1 -1
  104. package/lib/snapshot-url.d.ts +14 -0
  105. package/lib/snapshot-url.d.ts.map +1 -0
  106. package/lib/snapshot-url.js +26 -0
  107. package/lib/snapshot-url.js.map +1 -0
  108. package/{src/util/without.ts → lib/snapshot-url.spec.d.ts} +2 -3
  109. package/lib/snapshot-url.spec.d.ts.map +1 -0
  110. package/lib/snapshot-url.spec.js +41 -0
  111. package/lib/snapshot-url.spec.js.map +1 -0
  112. package/lib/team-subscription-protocol.d.ts +4 -4
  113. package/lib/team-subscription-protocol.d.ts.map +1 -1
  114. package/lib/team-subscription-protocol.js +15 -12
  115. package/lib/team-subscription-protocol.js.map +1 -1
  116. package/lib/teams-projects-protocol.d.ts +113 -0
  117. package/lib/teams-projects-protocol.d.ts.map +1 -0
  118. package/lib/teams-projects-protocol.js +30 -0
  119. package/lib/teams-projects-protocol.js.map +1 -0
  120. package/lib/util/analytics.d.ts +8 -0
  121. package/lib/util/analytics.d.ts.map +1 -0
  122. package/lib/util/analytics.js +88 -0
  123. package/lib/util/analytics.js.map +1 -0
  124. package/lib/util/async-iterator.js +55 -133
  125. package/lib/util/async-iterator.js.map +1 -1
  126. package/lib/util/cancelable.js +17 -59
  127. package/lib/util/cancelable.js.map +1 -1
  128. package/lib/util/date-time.js +8 -8
  129. package/lib/util/date-time.js.map +1 -1
  130. package/lib/util/deferred.js +10 -12
  131. package/lib/util/deferred.js.map +1 -1
  132. package/lib/util/disposable.js +26 -39
  133. package/lib/util/disposable.js.map +1 -1
  134. package/lib/util/event.js +58 -74
  135. package/lib/util/event.js.map +1 -1
  136. package/lib/util/garbage-collected-cache.d.ts +1 -0
  137. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  138. package/lib/util/garbage-collected-cache.js +26 -46
  139. package/lib/util/garbage-collected-cache.js.map +1 -1
  140. package/lib/util/generate-workspace-id.d.ts +1 -1
  141. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  142. package/lib/util/generate-workspace-id.js +31 -68
  143. package/lib/util/generate-workspace-id.js.map +1 -1
  144. package/lib/util/generate-workspace-id.spec.js +57 -78
  145. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  146. package/lib/util/gitpod-cookie.d.ts +20 -0
  147. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  148. package/lib/util/gitpod-cookie.js +44 -0
  149. package/lib/util/gitpod-cookie.js.map +1 -0
  150. package/lib/util/gitpod-host-url.d.ts +1 -2
  151. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  152. package/lib/util/gitpod-host-url.js +95 -98
  153. package/lib/util/gitpod-host-url.js.map +1 -1
  154. package/lib/util/gitpod-host-url.spec.d.ts +7 -1
  155. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  156. package/lib/util/gitpod-host-url.spec.js +103 -31
  157. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  158. package/lib/util/grpc.d.ts +15 -0
  159. package/lib/util/grpc.d.ts.map +1 -0
  160. package/lib/util/grpc.js +18 -0
  161. package/lib/util/grpc.js.map +1 -0
  162. package/lib/util/jaeger-client-types.d.ts +68 -0
  163. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  164. package/lib/util/{without.js → jaeger-client-types.js} +1 -1
  165. package/lib/util/jaeger-client-types.js.map +1 -0
  166. package/lib/util/logging.d.ts +49 -33
  167. package/lib/util/logging.d.ts.map +1 -1
  168. package/lib/util/logging.js +107 -110
  169. package/lib/util/logging.js.map +1 -1
  170. package/lib/util/make-link.js +2 -2
  171. package/lib/util/make-link.js.map +1 -1
  172. package/lib/util/parse-workspace-id.d.ts +10 -0
  173. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  174. package/lib/util/parse-workspace-id.js +32 -7
  175. package/lib/util/parse-workspace-id.js.map +1 -1
  176. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  177. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  178. package/lib/util/parse-workspace-id.spec.js +123 -84
  179. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  180. package/lib/util/queue.js +16 -55
  181. package/lib/util/queue.js.map +1 -1
  182. package/lib/util/queue.spec.js +144 -288
  183. package/lib/util/queue.spec.js.map +1 -1
  184. package/lib/util/repeat.d.ts +15 -0
  185. package/lib/util/repeat.d.ts.map +1 -0
  186. package/lib/util/repeat.js +55 -0
  187. package/lib/util/repeat.js.map +1 -0
  188. package/lib/util/semaphore.js +15 -46
  189. package/lib/util/semaphore.js.map +1 -1
  190. package/lib/util/skip-if.js +6 -6
  191. package/lib/util/skip-if.js.map +1 -1
  192. package/lib/util/timeutil.js +28 -16
  193. package/lib/util/timeutil.js.map +1 -1
  194. package/lib/util/timeutil.spec.js +21 -24
  195. package/lib/util/timeutil.spec.js.map +1 -1
  196. package/lib/util/tracing.d.ts +51 -5
  197. package/lib/util/tracing.d.ts.map +1 -1
  198. package/lib/util/tracing.js +197 -62
  199. package/lib/util/tracing.js.map +1 -1
  200. package/lib/util/tracing.spec.d.ts +7 -0
  201. package/lib/util/tracing.spec.d.ts.map +1 -0
  202. package/lib/util/tracing.spec.js +121 -0
  203. package/lib/util/tracing.spec.js.map +1 -0
  204. package/lib/util/workspace-port-authentication.js +3 -2
  205. package/lib/util/workspace-port-authentication.js.map +1 -1
  206. package/lib/workspace-cluster.d.ts +76 -0
  207. package/lib/workspace-cluster.d.ts.map +1 -0
  208. package/lib/workspace-cluster.js +33 -0
  209. package/lib/workspace-cluster.js.map +1 -0
  210. package/lib/workspace-instance.d.ts +24 -2
  211. package/lib/workspace-instance.d.ts.map +1 -1
  212. package/lib/wsready.d.ts +1 -1
  213. package/lib/wsready.js +2 -2
  214. package/package.json +31 -17
  215. package/pkg-yarn.lock +17 -9
  216. package/provenance-bundle.jsonl +2 -0
  217. package/src/accounting-protocol.ts +4 -10
  218. package/src/admin-protocol.ts +47 -5
  219. package/src/analytics.ts +52 -0
  220. package/src/context-url.spec.ts +53 -0
  221. package/src/context-url.ts +107 -0
  222. package/src/email-protocol.ts +2 -3
  223. package/src/env.ts +10 -10
  224. package/src/gitpod-service.ts +181 -44
  225. package/src/headless-workspace-log.ts +7 -11
  226. package/src/ide-frontend-service.ts +1 -1
  227. package/src/ide-protocol.ts +119 -0
  228. package/src/index.ts +7 -1
  229. package/src/installation-admin-protocol.ts +42 -0
  230. package/src/messaging/browser/connection.ts +195 -14
  231. package/src/messaging/client-call-metrics.ts +97 -0
  232. package/src/messaging/error.ts +8 -2
  233. package/src/messaging/handler.ts +12 -0
  234. package/src/messaging/node/connection.ts +21 -68
  235. package/src/messaging/proxy-factory.ts +14 -6
  236. package/src/oss-allowlist.ts +15 -0
  237. package/src/permission.ts +24 -4
  238. package/src/plans.ts +632 -0
  239. package/src/protocol.ts +196 -85
  240. package/src/snapshot-url.spec.ts +25 -0
  241. package/src/snapshot-url.ts +27 -0
  242. package/src/team-subscription-protocol.ts +7 -5
  243. package/src/teams-projects-protocol.ts +147 -0
  244. package/src/util/analytics.ts +105 -0
  245. package/src/util/deferred.ts +1 -1
  246. package/src/util/garbage-collected-cache.ts +9 -3
  247. package/src/util/generate-workspace-id.spec.ts +20 -3
  248. package/src/util/generate-workspace-id.ts +22 -2
  249. package/src/util/gitpod-cookie.ts +39 -0
  250. package/src/util/gitpod-host-url.spec.ts +25 -1
  251. package/src/util/gitpod-host-url.ts +22 -13
  252. package/src/util/grpc.ts +15 -0
  253. package/src/util/jaeger-client-types.ts +102 -0
  254. package/src/util/logging.ts +102 -38
  255. package/src/util/parse-workspace-id.spec.ts +21 -1
  256. package/src/util/parse-workspace-id.ts +32 -6
  257. package/src/util/queue.spec.ts +1 -1
  258. package/src/util/repeat.ts +45 -0
  259. package/src/util/semaphore.ts +2 -2
  260. package/src/util/skip-if.ts +1 -1
  261. package/src/util/timeutil.ts +4 -4
  262. package/src/util/tracing.spec.ts +83 -0
  263. package/src/util/tracing.ts +183 -17
  264. package/src/workspace-cluster.ts +104 -0
  265. package/src/workspace-instance.ts +45 -13
  266. package/src/wsready.ts +2 -2
  267. package/lib/messaging/connection-error-handler.d.ts +0 -27
  268. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  269. package/lib/messaging/connection-error-handler.js +0 -46
  270. package/lib/messaging/connection-error-handler.js.map +0 -1
  271. package/lib/util/context-url.d.ts +0 -13
  272. package/lib/util/context-url.d.ts.map +0 -1
  273. package/lib/util/context-url.js +0 -26
  274. package/lib/util/context-url.js.map +0 -1
  275. package/lib/util/context-url.spec.d.ts +0 -10
  276. package/lib/util/context-url.spec.d.ts.map +0 -1
  277. package/lib/util/context-url.spec.js +0 -52
  278. package/lib/util/context-url.spec.js.map +0 -1
  279. package/lib/util/repeater.d.ts +0 -22
  280. package/lib/util/repeater.d.ts.map +0 -1
  281. package/lib/util/repeater.js +0 -118
  282. package/lib/util/repeater.js.map +0 -1
  283. package/lib/util/safe-promise.d.ts +0 -11
  284. package/lib/util/safe-promise.d.ts.map +0 -1
  285. package/lib/util/safe-promise.js +0 -34
  286. package/lib/util/safe-promise.js.map +0 -1
  287. package/lib/util/without.d.ts +0 -7
  288. package/lib/util/without.d.ts.map +0 -1
  289. package/lib/util/without.js.map +0 -1
  290. package/src/messaging/connection-error-handler.ts +0 -62
  291. package/src/util/context-url.spec.ts +0 -25
  292. package/src/util/context-url.ts +0 -23
  293. package/src/util/jaeger-client.d.ts +0 -105
  294. package/src/util/repeater.ts +0 -49
  295. 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,8 +28,6 @@ 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.
@@ -98,14 +97,29 @@ export interface AdditionalUserData {
98
97
  emailNotificationSettings?: EmailNotificationSettings;
99
98
  featurePreview?: boolean;
100
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;
101
110
  }
102
111
 
103
112
  export interface EmailNotificationSettings {
104
- disallowTransactionalEmails?: boolean;
113
+ allowsChangelogMail?: boolean;
114
+ allowsDevXMail?: boolean;
115
+ allowsOnboardingMail?: boolean;
105
116
  }
106
117
 
107
118
  export type IDESettings = {
108
119
  defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
122
+ useLatestVersion?: boolean
109
123
  }
110
124
 
111
125
  export interface UserPlatform {
@@ -127,14 +141,6 @@ export interface UserPlatform {
127
141
  }
128
142
 
129
143
  export interface UserFeatureSettings {
130
- /**
131
- * This field is used as marker to grant users a free trial for using private repositories,
132
- * independent of any subscription or Chargebee.
133
- * - it is set when the user uses their first private repo
134
- * - whether the trial is expired or not is juged by the UserService
135
- */
136
- privateRepoTrialStartDate?: string;
137
-
138
144
  /**
139
145
  * Permanent feature flags are added to each and every workspace instance
140
146
  * this user starts.
@@ -146,15 +152,26 @@ export interface UserFeatureSettings {
146
152
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
147
153
  * If they don't we'll break things during workspace startup.
148
154
  */
149
- export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined, "user_namespace": undefined };
155
+ export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
150
156
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
151
157
 
152
- export interface UserEnvVarValue {
153
- id?: string;
158
+ export interface EnvVarWithValue {
154
159
  name: string;
155
- repositoryPattern: string;
156
160
  value: string;
157
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
+ }
158
175
  export interface UserEnvVar extends UserEnvVarValue {
159
176
  id: string;
160
177
  userId: string;
@@ -163,10 +180,35 @@ export interface UserEnvVar extends UserEnvVarValue {
163
180
 
164
181
  export namespace UserEnvVar {
165
182
 
183
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
166
184
  export function normalizeRepoPattern(pattern: string) {
167
185
  return pattern.toLocaleLowerCase();
168
186
  }
169
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
170
212
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
171
213
  let result = vars.filter(e => {
172
214
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -202,25 +244,7 @@ export namespace UserEnvVar {
202
244
  let minscore = 10;
203
245
  let bestCandidate: T | undefined;
204
246
  for (const e of candidates) {
205
- // We use a score to enforce precedence:
206
- // value/value = 0
207
- // value/* = 1
208
- // */value = 2
209
- // */* = 3
210
- // #/# = 4 (used for env vars passed through the URL)
211
- // the lower the score, the higher the precedence.
212
- const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
213
- let score = 0;
214
- if (repoPattern == "*") {
215
- score += 1;
216
- }
217
- if (ownerPattern == '*') {
218
- score += 2;
219
- }
220
- if (ownerPattern == "#" || repoPattern == "#") {
221
- score = 4;
222
- }
223
-
247
+ const score = UserEnvVar.score(e);
224
248
  if (!bestCandidate || score < minscore) {
225
249
  minscore = score;
226
250
  bestCandidate = e;
@@ -232,10 +256,11 @@ export namespace UserEnvVar {
232
256
  return result;
233
257
  }
234
258
 
235
- 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[] {
236
261
  const patterns = repositoryPattern.split('/');
237
- const repoPattern = patterns.pop() || "";
238
- const ownerPattern = patterns.join('/');
262
+ const repoPattern = patterns.slice(1).join('/')
263
+ const ownerPattern = patterns[0];
239
264
  return [ownerPattern, repoPattern];
240
265
  }
241
266
  }
@@ -366,11 +391,16 @@ export interface PendingGithubEvent {
366
391
  export interface Snapshot {
367
392
  id: string;
368
393
  creationTime: string;
394
+ availableTime?: string;
369
395
  originalWorkspaceId: string;
370
396
  bucketId: string;
371
397
  layoutData?: string;
398
+ state: SnapshotState;
399
+ message?: string;
372
400
  }
373
401
 
402
+ export type SnapshotState = 'pending' | 'available' | 'error';
403
+
374
404
  export interface LayoutData {
375
405
  workspaceId: string;
376
406
  lastUpdatedTime: string;
@@ -383,6 +413,7 @@ export interface Workspace {
383
413
  contextURL: string;
384
414
  description: string;
385
415
  ownerId: string;
416
+ projectId?: string;
386
417
  context: WorkspaceContext;
387
418
  config: WorkspaceConfig;
388
419
 
@@ -502,6 +533,24 @@ export interface UninstallPluginParams {
502
533
  pluginId: string;
503
534
  }
504
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
+
505
554
  export type ResolvedPluginKind = 'user' | 'workspace' | 'builtin';
506
555
 
507
556
  export interface ResolvedPlugins {
@@ -527,16 +576,21 @@ export interface WorkspaceConfig {
527
576
  gitConfig?: { [config: string]: string };
528
577
  github?: GithubAppConfig;
529
578
  vscode?: VSCodeConfig;
530
-
579
+
580
+ /** deprecated. Enabled by default **/
581
+ experimentalNetwork?: boolean;
582
+
531
583
  /**
532
584
  * Where the config object originates from.
533
- *
585
+ *
534
586
  * repo - from the repository
587
+ * project-db - from the "Project" stored in the database
535
588
  * definitly-gp - from github.com/gitpod-io/definitely-gp
536
589
  * derived - computed based on analyzing the repository
590
+ * additional-content - config comes from additional content, usually provided through the project's configuration
537
591
  * default - our static catch-all default config
538
592
  */
539
- _origin?: 'repo' | 'definitely-gp' | 'derived' | 'default';
593
+ _origin?: 'repo' | 'project-db' | 'definitely-gp' | 'derived' | 'additional-content' | 'default';
540
594
 
541
595
  /**
542
596
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -553,7 +607,7 @@ export interface GithubAppPrebuildConfig {
553
607
  branches?: boolean
554
608
  pullRequests?: boolean
555
609
  pullRequestsFromForks?: boolean
556
- addCheck?: boolean
610
+ addCheck?: boolean | 'prevent-merge-on-error'
557
611
  addBadge?: boolean
558
612
  addLabel?: boolean | string
559
613
  addComment?: boolean
@@ -566,16 +620,13 @@ export namespace GithubAppPrebuildConfig {
566
620
 
567
621
  export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
568
622
  export interface WorkspaceImageSourceDocker {
569
- // TODO: clean this up. We should have the commit and an ImageSource in here, not duplicate the whole thing again.
570
- // We have a ton of those objects in the database, thus cleaning this up means lengthy DB migrations. Yuck.
571
- dockerFileHash: string
572
- dockerFileSource: Commit
573
623
  dockerFilePath: string
624
+ dockerFileHash: string
625
+ dockerFileSource?: Commit
574
626
  }
575
627
  export namespace WorkspaceImageSourceDocker {
576
628
  export function is(obj: object): obj is WorkspaceImageSourceDocker {
577
629
  return 'dockerFileHash' in obj
578
- && 'dockerFileSource' in obj
579
630
  && 'dockerFilePath' in obj;
580
631
  }
581
632
  }
@@ -604,6 +655,8 @@ export type PrebuiltWorkspaceState
604
655
  export interface PrebuiltWorkspace {
605
656
  id: string;
606
657
  cloneURL: string;
658
+ branch?: string;
659
+ projectId?: string;
607
660
  commit: string;
608
661
  buildWorkspaceId: string;
609
662
  creationTime: string;
@@ -614,7 +667,7 @@ export interface PrebuiltWorkspace {
614
667
 
615
668
  export namespace PrebuiltWorkspace {
616
669
  export function isDone(pws: PrebuiltWorkspace) {
617
- return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
670
+ return pws.state === "available" || pws.state === "timeout" || pws.state === 'aborted';
618
671
  }
619
672
 
620
673
  export function isAvailable(pws: PrebuiltWorkspace) {
@@ -650,6 +703,8 @@ export interface PortConfig {
650
703
  port: number;
651
704
  onOpen?: PortOnOpen;
652
705
  visibility?: PortVisibility;
706
+ description?: string;
707
+ name?: string;
653
708
  }
654
709
  export namespace PortConfig {
655
710
  export function is(config: any): config is PortConfig {
@@ -673,7 +728,7 @@ export interface TaskConfig {
673
728
  init?: string;
674
729
  prebuild?: string;
675
730
  command?: string;
676
- env?: { [env: string]: string };
731
+ env?: { [env: string]: any };
677
732
  openIn?: 'bottom' | 'main' | 'left' | 'right';
678
733
  openMode?: 'split-top' | 'split-left' | 'split-right' | 'split-bottom' | 'tab-before' | 'tab-after';
679
734
  }
@@ -737,8 +792,10 @@ export namespace ExternalImageConfigFile {
737
792
 
738
793
  export interface WorkspaceContext {
739
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. */
740
796
  normalizedContextURL?: string;
741
797
  forceCreateNewWorkspace?: boolean;
798
+ forceImageBuild?: boolean;
742
799
  }
743
800
 
744
801
  export namespace WorkspaceContext {
@@ -758,20 +815,42 @@ export namespace WithSnapshot {
758
815
  }
759
816
  }
760
817
 
761
- export interface WithPrebuild {
762
- snapshotBucketId: string;
818
+ export interface WithPrebuild extends WithSnapshot {
763
819
  prebuildWorkspaceId: string;
764
820
  wasPrebuilt: true;
765
821
  }
766
822
  export namespace WithPrebuild {
767
823
  export function is(context: any): context is WithPrebuild {
768
824
  return context
769
- && 'snapshotBucketId' in context
825
+ && WithSnapshot.is(context)
770
826
  && 'prebuildWorkspaceId' in context
771
827
  && 'wasPrebuilt' in context;
772
828
  }
773
829
  }
774
830
 
831
+ /**
832
+ * WithDefaultConfig contexts disable the download of the gitpod.yml from the repository
833
+ * and fall back to the built-in configuration.
834
+ */
835
+ export interface WithDefaultConfig {
836
+ withDefaultConfig: true;
837
+ }
838
+
839
+ export namespace WithDefaultConfig {
840
+ export function is(context: any): context is WithDefaultConfig {
841
+ return context
842
+ && 'withDefaultConfig' in context
843
+ && context.withDefaultConfig;
844
+ }
845
+
846
+ export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
847
+ return {
848
+ ...ctx,
849
+ withDefaultConfig: true
850
+ }
851
+ }
852
+ }
853
+
775
854
  export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
776
855
  snapshotId: string;
777
856
  }
@@ -786,6 +865,9 @@ export namespace SnapshotContext {
786
865
 
787
866
  export interface StartPrebuildContext extends WorkspaceContext {
788
867
  actual: WorkspaceContext;
868
+ commitHistory?: string[];
869
+ project?: Project;
870
+ branch?: string;
789
871
  }
790
872
 
791
873
  export namespace StartPrebuildContext {
@@ -809,8 +891,20 @@ export namespace PrebuiltWorkspaceContext {
809
891
  }
810
892
  }
811
893
 
894
+ export interface WithReferrerContext extends WorkspaceContext {
895
+ referrer: string
896
+ referrerIde?: string
897
+ }
898
+
899
+ export namespace WithReferrerContext {
900
+ export function is(context: any): context is WithReferrerContext {
901
+ return context
902
+ && 'referrer' in context;
903
+ }
904
+ }
905
+
812
906
  export interface WithEnvvarsContext extends WorkspaceContext {
813
- envvars: UserEnvVarValue[];
907
+ envvars: EnvVarWithValue[];
814
908
  }
815
909
 
816
910
  export namespace WithEnvvarsContext {
@@ -855,6 +949,25 @@ export interface Commit {
855
949
  refType?: RefType
856
950
  }
857
951
 
952
+ export interface AdditionalContentContext extends WorkspaceContext {
953
+
954
+ /**
955
+ * utf-8 encoded contents that will be copied on top of the workspace's filesystem
956
+ */
957
+ additionalFiles: {[filePath: string]: string};
958
+
959
+ }
960
+
961
+ export namespace AdditionalContentContext {
962
+ export function is(ctx: any): ctx is AdditionalContentContext {
963
+ return 'additionalFiles' in ctx;
964
+ }
965
+
966
+ export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
967
+ return is(ctx) && ImageConfigFile.is(config.image) && !!ctx.additionalFiles[config.image.file];
968
+ }
969
+ }
970
+
858
971
  export interface CommitContext extends WorkspaceContext, Commit {
859
972
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
860
973
  cloneUrl?: string
@@ -930,6 +1043,19 @@ export interface Repository {
930
1043
  parent: Repository
931
1044
  }
932
1045
  }
1046
+ export interface Branch {
1047
+ name: string;
1048
+ commit: CommitInfo;
1049
+ htmlUrl: string;
1050
+ }
1051
+
1052
+ export interface CommitInfo {
1053
+ author: string;
1054
+ sha: string;
1055
+ commitMessage: string;
1056
+ authorAvatarUrl?: string;
1057
+ authorDate?: string;
1058
+ }
933
1059
 
934
1060
  export namespace Repository {
935
1061
  export function fullRepoName(repo: Repository): string {
@@ -957,6 +1083,12 @@ export interface WorkspaceInfo {
957
1083
  latestInstance?: WorkspaceInstance
958
1084
  }
959
1085
 
1086
+ export namespace WorkspaceInfo {
1087
+ export function lastActiveISODate(info: WorkspaceInfo): string {
1088
+ return info.latestInstance?.creationTime || info.workspace.creationTime;
1089
+ }
1090
+ }
1091
+
960
1092
  export type RunningWorkspaceInfo = WorkspaceInfo & { latestInstance: WorkspaceInstance };
961
1093
 
962
1094
  export interface WorkspaceCreationResult {
@@ -966,6 +1098,7 @@ export interface WorkspaceCreationResult {
966
1098
  runningWorkspacePrebuild?: {
967
1099
  prebuildID: string
968
1100
  workspaceID: string
1101
+ instanceID: string
969
1102
  starting: RunningWorkspacePrebuildStarting
970
1103
  sameCluster: boolean
971
1104
  }
@@ -1037,6 +1170,8 @@ export interface AuthProviderEntry {
1037
1170
  readonly status: AuthProviderEntry.Status;
1038
1171
 
1039
1172
  readonly oauth: OAuth2Config;
1173
+ /** A random string that is to change whenever oauth changes (enforced on DB level) */
1174
+ readonly oauthRevision?: string;
1040
1175
  }
1041
1176
 
1042
1177
  export interface OAuth2Config {
@@ -1056,40 +1191,16 @@ export interface OAuth2Config {
1056
1191
  export namespace AuthProviderEntry {
1057
1192
  export type Type = "GitHub" | "GitLab" | string;
1058
1193
  export type Status = "pending" | "verified";
1059
- export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type">;
1194
+ export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & { clientId?: string, clientSecret?: string };
1060
1195
  export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> & Pick<OAuth2Config, "clientId" | "clientSecret">;
1061
- }
1062
-
1063
- export interface Branding {
1064
- readonly name: string;
1065
- readonly favicon?: string;
1066
- /** Either including domain OR absolute path (interpreted relative to host URL) */
1067
- readonly logo: string;
1068
- readonly startupLogo: string;
1069
- readonly showProductivityTips: boolean;
1070
- readonly redirectUrlIfNotAuthenticated?: string;
1071
- readonly redirectUrlAfterLogout?: string;
1072
- readonly homepage: string;
1073
- readonly ide?: {
1074
- readonly logo: string;
1075
- readonly showReleaseNotes: boolean;
1076
- readonly helpMenu: Branding.Link[];
1077
- }
1078
- readonly links: {
1079
- readonly header: Branding.Link[];
1080
- readonly footer: Branding.Link[];
1081
- readonly social: Branding.SocialLink[];
1082
- readonly legal: Branding.Link[];
1083
- }
1084
- }
1085
- export namespace Branding {
1086
- export interface Link {
1087
- readonly name: string;
1088
- readonly url: string;
1089
- }
1090
- export interface SocialLink {
1091
- readonly type: string;
1092
- readonly url: string;
1196
+ export function redact(entry: AuthProviderEntry): AuthProviderEntry {
1197
+ return {
1198
+ ...entry,
1199
+ oauth: {
1200
+ ...entry.oauth,
1201
+ clientSecret: "redacted"
1202
+ }
1203
+ }
1093
1204
  }
1094
1205
  }
1095
1206
 
@@ -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
+ }
@@ -4,8 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { Without } from "./util/without";
8
- import uuidv4 = require("uuid/v4");
7
+ import { v4 as uuidv4 } from 'uuid';
9
8
  import { Subscription } from "./accounting-protocol";
10
9
 
11
10
  export interface TeamSubscription {
@@ -22,7 +21,7 @@ export interface TeamSubscription {
22
21
  }
23
22
 
24
23
  export namespace TeamSubscription {
25
- export const create = (ts: Without<TeamSubscription, 'id'>): TeamSubscription => {
24
+ export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
26
25
  const withId = ts as TeamSubscription;
27
26
  withId.id = uuidv4();
28
27
  return withId;
@@ -49,7 +48,7 @@ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscripti
49
48
  export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
50
49
 
51
50
  export namespace TeamSubscriptionSlot {
52
- export const create = (ts: Without<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
51
+ export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
53
52
  const withId = ts as TeamSubscriptionSlot;
54
53
  withId.id = uuidv4();
55
54
  return withId;
@@ -63,7 +62,7 @@ export namespace TeamSubscriptionSlot {
63
62
  slot.subscriptionId = undefined;
64
63
  slot.cancellationDate = cancellationDate;
65
64
  }
66
- export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId: string) => {
65
+ export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
67
66
  slot.subscriptionId = subscriptionId;
68
67
  slot.cancellationDate = undefined;
69
68
  }
@@ -83,6 +82,9 @@ export namespace TeamSubscriptionSlot {
83
82
  }
84
83
 
85
84
  }
85
+ export const isActive = (slot: TeamSubscriptionSlot): boolean => {
86
+ return !slot.cancellationDate;
87
+ }
86
88
  }
87
89
 
88
90
  /**