@gitpod/gitpod-protocol 0.1.5-pd-update-to-node-14-fork.2 → 0.1.5-pd-add-latest-jb.0

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 (229) hide show
  1. package/data/gitpod-schema.json +21 -2
  2. package/lib/accounting-protocol.d.ts +0 -1
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +10 -11
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +8 -2
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +2 -13
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +1 -0
  11. package/lib/analytics.d.ts.map +1 -1
  12. package/lib/context-url.d.ts +1 -0
  13. package/lib/context-url.d.ts.map +1 -1
  14. package/lib/context-url.js +7 -5
  15. package/lib/context-url.js.map +1 -1
  16. package/lib/context-url.spec.js +45 -48
  17. package/lib/context-url.spec.js.map +1 -1
  18. package/lib/email-protocol.js +4 -4
  19. package/lib/email-protocol.js.map +1 -1
  20. package/lib/encryption/container-module.js +4 -4
  21. package/lib/encryption/container-module.js.map +1 -1
  22. package/lib/encryption/encryption-engine.js +19 -20
  23. package/lib/encryption/encryption-engine.js.map +1 -1
  24. package/lib/encryption/encryption-engine.spec.js +29 -36
  25. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  26. package/lib/encryption/encryption-service.js +29 -43
  27. package/lib/encryption/encryption-service.js.map +1 -1
  28. package/lib/encryption/key-provider.js +25 -30
  29. package/lib/encryption/key-provider.js.map +1 -1
  30. package/lib/env.js +12 -13
  31. package/lib/env.js.map +1 -1
  32. package/lib/gitpod-file-parser.js +25 -41
  33. package/lib/gitpod-file-parser.js.map +1 -1
  34. package/lib/gitpod-file-parser.spec.js +116 -116
  35. package/lib/gitpod-file-parser.spec.js.map +1 -1
  36. package/lib/gitpod-service.d.ts +33 -11
  37. package/lib/gitpod-service.d.ts.map +1 -1
  38. package/lib/gitpod-service.js +151 -295
  39. package/lib/gitpod-service.js.map +1 -1
  40. package/lib/ide-protocol.d.ts +105 -0
  41. package/lib/ide-protocol.d.ts.map +1 -0
  42. package/lib/ide-protocol.js +8 -0
  43. package/lib/ide-protocol.js.map +1 -0
  44. package/lib/index.d.ts +3 -0
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/index.js +3 -0
  47. package/lib/index.js.map +1 -1
  48. package/lib/installation-admin-protocol.d.ts +13 -0
  49. package/lib/installation-admin-protocol.d.ts.map +1 -0
  50. package/lib/installation-admin-protocol.js +8 -0
  51. package/lib/installation-admin-protocol.js.map +1 -0
  52. package/lib/messaging/browser/connection.js +91 -156
  53. package/lib/messaging/browser/connection.js.map +1 -1
  54. package/lib/messaging/browser/window-connection.js +35 -55
  55. package/lib/messaging/browser/window-connection.js.map +1 -1
  56. package/lib/messaging/client-call-metrics.js +17 -18
  57. package/lib/messaging/client-call-metrics.js.map +1 -1
  58. package/lib/messaging/connection-error-handler.js +11 -23
  59. package/lib/messaging/connection-error-handler.js.map +1 -1
  60. package/lib/messaging/error.d.ts +1 -1
  61. package/lib/messaging/error.d.ts.map +1 -1
  62. package/lib/messaging/error.js +2 -2
  63. package/lib/messaging/error.js.map +1 -1
  64. package/lib/messaging/node/connection.d.ts +1 -17
  65. package/lib/messaging/node/connection.d.ts.map +1 -1
  66. package/lib/messaging/node/connection.js +23 -59
  67. package/lib/messaging/node/connection.js.map +1 -1
  68. package/lib/messaging/proxy-factory.js +71 -162
  69. package/lib/messaging/proxy-factory.js.map +1 -1
  70. package/lib/oss-allowlist.d.ts +14 -0
  71. package/lib/oss-allowlist.d.ts.map +1 -0
  72. package/lib/oss-allowlist.js +8 -0
  73. package/lib/oss-allowlist.js.map +1 -0
  74. package/lib/permission.js +12 -12
  75. package/lib/permission.js.map +1 -1
  76. package/lib/plans.d.ts +1 -1
  77. package/lib/plans.d.ts.map +1 -1
  78. package/lib/plans.js +38 -57
  79. package/lib/plans.js.map +1 -1
  80. package/lib/protocol.d.ts +33 -44
  81. package/lib/protocol.d.ts.map +1 -1
  82. package/lib/protocol.js +57 -115
  83. package/lib/protocol.js.map +1 -1
  84. package/lib/snapshot-url.d.ts +14 -0
  85. package/lib/snapshot-url.d.ts.map +1 -0
  86. package/lib/snapshot-url.js +26 -0
  87. package/lib/snapshot-url.js.map +1 -0
  88. package/lib/snapshot-url.spec.d.ts +7 -0
  89. package/lib/snapshot-url.spec.d.ts.map +1 -0
  90. package/lib/snapshot-url.spec.js +41 -0
  91. package/lib/snapshot-url.spec.js.map +1 -0
  92. package/lib/team-subscription-protocol.js +13 -13
  93. package/lib/team-subscription-protocol.js.map +1 -1
  94. package/lib/teams-projects-protocol.d.ts +9 -0
  95. package/lib/teams-projects-protocol.d.ts.map +1 -1
  96. package/lib/teams-projects-protocol.js +4 -15
  97. package/lib/teams-projects-protocol.js.map +1 -1
  98. package/lib/util/analytics.js +25 -32
  99. package/lib/util/analytics.js.map +1 -1
  100. package/lib/util/async-iterator.js +55 -133
  101. package/lib/util/async-iterator.js.map +1 -1
  102. package/lib/util/cancelable.js +17 -59
  103. package/lib/util/cancelable.js.map +1 -1
  104. package/lib/util/date-time.js +8 -8
  105. package/lib/util/date-time.js.map +1 -1
  106. package/lib/util/deferred.js +10 -12
  107. package/lib/util/deferred.js.map +1 -1
  108. package/lib/util/disposable.js +26 -39
  109. package/lib/util/disposable.js.map +1 -1
  110. package/lib/util/event.js +58 -74
  111. package/lib/util/event.js.map +1 -1
  112. package/lib/util/garbage-collected-cache.d.ts +1 -0
  113. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  114. package/lib/util/garbage-collected-cache.js +26 -46
  115. package/lib/util/garbage-collected-cache.js.map +1 -1
  116. package/lib/util/generate-workspace-id.d.ts +1 -1
  117. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  118. package/lib/util/generate-workspace-id.js +29 -68
  119. package/lib/util/generate-workspace-id.js.map +1 -1
  120. package/lib/util/generate-workspace-id.spec.js +57 -78
  121. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  122. package/lib/util/gitpod-cookie.d.ts +20 -0
  123. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  124. package/lib/util/gitpod-cookie.js +44 -0
  125. package/lib/util/gitpod-cookie.js.map +1 -0
  126. package/lib/util/gitpod-host-url.d.ts +1 -1
  127. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  128. package/lib/util/gitpod-host-url.js +93 -103
  129. package/lib/util/gitpod-host-url.js.map +1 -1
  130. package/lib/util/gitpod-host-url.spec.js +87 -135
  131. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  132. package/lib/util/grpc.js +3 -3
  133. package/lib/util/grpc.js.map +1 -1
  134. package/lib/util/jaeger-client-types.d.ts +68 -0
  135. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  136. package/lib/util/jaeger-client-types.js +8 -0
  137. package/lib/util/jaeger-client-types.js.map +1 -0
  138. package/lib/util/logging.d.ts +32 -32
  139. package/lib/util/logging.d.ts.map +1 -1
  140. package/lib/util/logging.js +50 -113
  141. package/lib/util/logging.js.map +1 -1
  142. package/lib/util/make-link.js +2 -2
  143. package/lib/util/make-link.js.map +1 -1
  144. package/lib/util/parse-workspace-id.d.ts +10 -0
  145. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  146. package/lib/util/parse-workspace-id.js +31 -7
  147. package/lib/util/parse-workspace-id.js.map +1 -1
  148. package/lib/util/parse-workspace-id.spec.d.ts +4 -0
  149. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  150. package/lib/util/parse-workspace-id.spec.js +123 -84
  151. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  152. package/lib/util/queue.js +16 -55
  153. package/lib/util/queue.js.map +1 -1
  154. package/lib/util/queue.spec.js +144 -288
  155. package/lib/util/queue.spec.js.map +1 -1
  156. package/lib/util/repeat.d.ts +15 -0
  157. package/lib/util/repeat.d.ts.map +1 -0
  158. package/lib/util/repeat.js +55 -0
  159. package/lib/util/repeat.js.map +1 -0
  160. package/lib/util/safe-promise.js +9 -12
  161. package/lib/util/safe-promise.js.map +1 -1
  162. package/lib/util/semaphore.js +15 -46
  163. package/lib/util/semaphore.js.map +1 -1
  164. package/lib/util/skip-if.js +6 -6
  165. package/lib/util/skip-if.js.map +1 -1
  166. package/lib/util/timeutil.js +16 -16
  167. package/lib/util/timeutil.js.map +1 -1
  168. package/lib/util/timeutil.spec.js +21 -24
  169. package/lib/util/timeutil.spec.js.map +1 -1
  170. package/lib/util/tracing.d.ts +51 -5
  171. package/lib/util/tracing.d.ts.map +1 -1
  172. package/lib/util/tracing.js +196 -62
  173. package/lib/util/tracing.js.map +1 -1
  174. package/lib/util/tracing.spec.d.ts +7 -0
  175. package/lib/util/tracing.spec.d.ts.map +1 -0
  176. package/lib/util/tracing.spec.js +121 -0
  177. package/lib/util/tracing.spec.js.map +1 -0
  178. package/lib/util/workspace-port-authentication.js +2 -2
  179. package/lib/util/workspace-port-authentication.js.map +1 -1
  180. package/lib/workspace-cluster.d.ts +11 -1
  181. package/lib/workspace-cluster.d.ts.map +1 -1
  182. package/lib/workspace-cluster.js +3 -3
  183. package/lib/workspace-cluster.js.map +1 -1
  184. package/lib/workspace-instance.d.ts +3 -2
  185. package/lib/workspace-instance.d.ts.map +1 -1
  186. package/lib/wsready.js +1 -1
  187. package/package.json +22 -13
  188. package/pkg-yarn.lock +12 -7
  189. package/provenance-bundle.jsonl +2 -0
  190. package/src/accounting-protocol.ts +1 -3
  191. package/src/admin-protocol.ts +9 -3
  192. package/src/analytics.ts +2 -0
  193. package/src/context-url.ts +3 -1
  194. package/src/email-protocol.ts +1 -1
  195. package/src/gitpod-service.ts +42 -20
  196. package/src/ide-frontend-service.ts +1 -1
  197. package/src/ide-protocol.ts +119 -0
  198. package/src/index.ts +3 -0
  199. package/src/installation-admin-protocol.ts +14 -0
  200. package/src/messaging/error.ts +2 -2
  201. package/src/messaging/node/connection.ts +21 -68
  202. package/src/oss-allowlist.ts +15 -0
  203. package/src/protocol.ts +49 -46
  204. package/src/snapshot-url.spec.ts +25 -0
  205. package/src/snapshot-url.ts +27 -0
  206. package/src/team-subscription-protocol.ts +1 -1
  207. package/src/teams-projects-protocol.ts +12 -1
  208. package/src/util/garbage-collected-cache.ts +7 -1
  209. package/src/util/generate-workspace-id.spec.ts +17 -0
  210. package/src/util/generate-workspace-id.ts +20 -2
  211. package/src/util/gitpod-cookie.ts +39 -0
  212. package/src/util/gitpod-host-url.ts +11 -11
  213. package/src/util/grpc.ts +3 -3
  214. package/src/util/jaeger-client-types.ts +102 -0
  215. package/src/util/logging.ts +32 -32
  216. package/src/util/parse-workspace-id.spec.ts +21 -1
  217. package/src/util/parse-workspace-id.ts +32 -6
  218. package/src/util/repeat.ts +45 -0
  219. package/src/util/tracing.spec.ts +83 -0
  220. package/src/util/tracing.ts +183 -18
  221. package/src/workspace-cluster.ts +8 -1
  222. package/src/workspace-instance.ts +9 -6
  223. package/src/wsready.ts +1 -1
  224. package/lib/util/repeater.d.ts +0 -22
  225. package/lib/util/repeater.d.ts.map +0 -1
  226. package/lib/util/repeater.js +0 -118
  227. package/lib/util/repeater.js.map +0 -1
  228. package/src/util/jaeger-client.d.ts +0 -105
  229. package/src/util/repeater.ts +0 -49
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ /**
8
+ * `IDEServer` provides a list of available IDEs.
9
+ */
10
+ export interface IDEServer {
11
+ /**
12
+ * Returns the IDE preferences.
13
+ */
14
+ getIDEOptions(): Promise<IDEOptions>;
15
+ }
16
+
17
+ export interface IDEOptions {
18
+ /**
19
+ * A list of available IDEs.
20
+ */
21
+ options: { [key: string]: IDEOption };
22
+
23
+ /**
24
+ * The default (browser) IDE when the user has not specified one.
25
+ */
26
+ defaultIde: string;
27
+
28
+ /**
29
+ * The default desktop IDE when the user has not specified one.
30
+ */
31
+ defaultDesktopIde: string;
32
+
33
+ /**
34
+ * Client specific IDE options.
35
+ */
36
+ clients?: { [id: string]: IDEClient };
37
+ }
38
+
39
+ export interface IDEClient {
40
+ /**
41
+ * The default desktop IDE when the user has not specified one.
42
+ */
43
+ defaultDesktopIDE?: string;
44
+
45
+ /**
46
+ * Desktop IDEs supported by the client.
47
+ */
48
+ desktopIDEs?: string[]
49
+
50
+ /**
51
+ * Steps to install the client on user machine.
52
+ */
53
+ installationSteps?: string[]
54
+ }
55
+
56
+ export interface IDEOption {
57
+ /**
58
+ * To ensure a stable order one can set an `orderKey`.
59
+ */
60
+ orderKey?: string;
61
+
62
+ /**
63
+ * Human readable title text of the IDE (plain text only).
64
+ */
65
+ title: string;
66
+
67
+ /**
68
+ * The type of the IDE, currently 'browser' or 'desktop'.
69
+ */
70
+ type: 'browser' | 'desktop';
71
+
72
+ /**
73
+ * The logo for the IDE. That could be a key in (see
74
+ * components/dashboard/src/images/ideLogos.ts) or a URL.
75
+ */
76
+ logo: string;
77
+
78
+ /**
79
+ * Text of an optional tooltip (plain text only).
80
+ */
81
+ tooltip?: string;
82
+
83
+ /**
84
+ * Text of an optional label next to the IDE option like “Insiders” (plain
85
+ * text only).
86
+ */
87
+ label?: string;
88
+
89
+ /**
90
+ * Notes to the IDE option that are renderd in the preferences when a user
91
+ * chooses this IDE.
92
+ */
93
+ notes?: string[];
94
+
95
+ /**
96
+ * If `true` this IDE option is not visible in the IDE preferences.
97
+ */
98
+ hidden?: boolean;
99
+
100
+ /**
101
+ * The image ref to the IDE image.
102
+ */
103
+ image: string;
104
+
105
+ /**
106
+ * The latest image ref to the IDE image, this image ref always resolve to digest.
107
+ */
108
+ latestImage?: string;
109
+
110
+ /**
111
+ * When this is `true`, the tag of this image is resolved to the latest
112
+ * image digest regularly.
113
+ *
114
+ * This is useful if this image points to a tag like `nightly` that will be
115
+ * updated regularly. When `resolveImageDigest` is `true`, we make sure that
116
+ * we resolve the tag regularly to the most recent image version.
117
+ */
118
+ resolveImageDigest?: boolean;
119
+ }
package/src/index.ts CHANGED
@@ -17,3 +17,6 @@ export * from './email-protocol';
17
17
  export * from './headless-workspace-log';
18
18
  export * from './context-url';
19
19
  export * from './teams-projects-protocol';
20
+ export * from './snapshot-url';
21
+ export * from './oss-allowlist';
22
+ export * from './installation-admin-protocol';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2022 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 InstallationAdminSettings {
8
+ sendTelemetry: boolean;
9
+ }
10
+
11
+ export interface InstallationAdmin {
12
+ id: string;
13
+ settings: InstallationAdminSettings;
14
+ }
@@ -76,6 +76,6 @@ export namespace ErrorCodes {
76
76
  // 620 Team Subscription Assignment Failed
77
77
  export const TEAM_SUBSCRIPTION_ASSIGNMENT_FAILED = 620;
78
78
 
79
- // 666 Not Implemented TODO IO-SPLIT remove
80
- export const NOT_IMPLEMENTED = 666;
79
+ // 630 Snapshot Error
80
+ export const SNAPSHOT_ERROR = 630;
81
81
  }
@@ -6,81 +6,34 @@
6
6
  */
7
7
 
8
8
  import * as ws from "ws";
9
- import * as http from "http";
10
- import * as https from "https";
11
- import * as url from "url";
12
- import * as net from "net";
13
- import { MessageConnection } from "vscode-jsonrpc";
14
- import { createWebSocketConnection, IWebSocket } from "vscode-ws-jsonrpc";
15
- import { log } from '../../util/logging';
9
+ import { IWebSocket } from "vscode-ws-jsonrpc";
16
10
 
17
- export interface IServerOptions {
18
- readonly server: http.Server | https.Server;
19
- readonly path?: string;
20
- matches?(request: http.IncomingMessage): boolean;
21
- }
22
-
23
- export function createServerWebSocketConnection(options: IServerOptions, onConnect: (connection: MessageConnection) => void): void {
24
- openJsonRpcSocket(options, socket => {
25
- onConnect(createWebSocketConnection(socket, console));
26
- });
27
- }
28
-
29
- export function openJsonRpcSocket(options: IServerOptions, onOpen: (socket: IWebSocket) => void): void {
30
- openSocket(options, socket => {
31
- const webSocket = toIWebSocket(socket);
32
- onOpen(webSocket);
33
- });
34
- }
35
-
36
- export interface OnOpen {
37
- (webSocket: ws, request: http.IncomingMessage, socket: net.Socket, head: Buffer): void;
38
- }
39
-
40
- export function openSocket(options: IServerOptions, onOpen: OnOpen): void {
41
- const wss = new ws.Server({
42
- noServer: true,
43
- perMessageDeflate: {
44
- // don't compress if a message is less than 256kb
45
- threshold: 256 * 1024
46
- }
47
- });
48
- options.server.on('upgrade', (request: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
49
- const pathname = request.url ? url.parse(request.url).pathname : undefined;
50
- if (options.path && pathname === options.path || options.matches && options.matches(request)) {
51
- wss.handleUpgrade(request, socket, head, webSocket => {
52
- if (webSocket.readyState === webSocket.OPEN) {
53
- onOpen(webSocket, request, socket, head);
54
- } else {
55
- webSocket.on('open', () => onOpen(webSocket, request, socket, head));
56
- }
57
- });
58
- }
59
- });
60
- }
61
-
62
- export function toIWebSocket(webSocket: ws) {
63
- let sendsAfterOpen = 0;
11
+ export function toIWebSocket(ws: ws) {
64
12
  return <IWebSocket>{
65
13
  send: content => {
66
- if (webSocket.readyState !== ws.OPEN) {
67
- if (sendsAfterOpen++ > 3) {
68
- //log.debug(`Repeated try to send on closed web socket (readyState was ${webSocket.readyState})`, { ws });
69
- }
14
+ if (ws.readyState >= ws.CLOSING) {
15
+ // ws is already CLOSING/CLOSED, send() would just return an error.
70
16
  return;
71
17
  }
72
- webSocket.send(content, err => {
73
- if (err) {
74
- log.error('error in ws.send()', err, { ws });
75
- }
76
- })
18
+
19
+ // in general send-errors should trigger an 'error' event already, we just make sure it actually happens.
20
+ try {
21
+ ws.send(content, err => {
22
+ if (!err) {
23
+ return;
24
+ }
25
+ ws.emit('error', err);
26
+ });
27
+ } catch (err) {
28
+ ws.emit('error', err);
29
+ }
77
30
  },
78
- onMessage: cb => webSocket.on('message', cb),
79
- onError: cb => webSocket.on('error', cb),
80
- onClose: cb => webSocket.on('close', cb),
31
+ onMessage: cb => ws.on('message', cb),
32
+ onError: cb => ws.on('error', cb),
33
+ onClose: cb => ws.on('close', cb),
81
34
  dispose: () => {
82
- if (webSocket.readyState < ws.CLOSING) {
83
- webSocket.close();
35
+ if (ws.readyState < ws.CLOSING) {
36
+ ws.close();
84
37
  }
85
38
  }
86
39
  };
@@ -0,0 +1,15 @@
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 OssAllowList {
8
+ /**
9
+ * A string that identifies a GitHub/GitLab/Bitbucket identity of the form "<host>/<profilename>"
10
+ * E.g., "github.com/geropl"
11
+ */
12
+ identity: string,
13
+
14
+ deleted?: boolean,
15
+ }
package/src/protocol.ts CHANGED
@@ -104,6 +104,9 @@ export interface AdditionalUserData {
104
104
  oauthClientsApproved?: { [key: string]: string }
105
105
  // to remember GH Orgs the user installed/updated the GH App for
106
106
  knownGitHubOrgs?: string[];
107
+
108
+ // Git clone URL pointing to the user's dotfile repo
109
+ dotfileRepo?: string;
107
110
  }
108
111
 
109
112
  export interface EmailNotificationSettings {
@@ -114,6 +117,9 @@ export interface EmailNotificationSettings {
114
117
 
115
118
  export type IDESettings = {
116
119
  defaultIde?: string
120
+ useDesktopIde?: boolean
121
+ defaultDesktopIde?: string
122
+ useLatestVersion?: boolean
117
123
  }
118
124
 
119
125
  export interface UserPlatform {
@@ -135,14 +141,6 @@ export interface UserPlatform {
135
141
  }
136
142
 
137
143
  export interface UserFeatureSettings {
138
- /**
139
- * This field is used as marker to grant users a free trial for using private repositories,
140
- * independent of any subscription or Chargebee.
141
- * - it is set when the user uses their first private repo
142
- * - whether the trial is expired or not is juged by the UserService
143
- */
144
- privateRepoTrialStartDate?: string;
145
-
146
144
  /**
147
145
  * Permanent feature flags are added to each and every workspace instance
148
146
  * this user starts.
@@ -157,12 +155,23 @@ export interface UserFeatureSettings {
157
155
  export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
158
156
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
159
157
 
160
- export interface UserEnvVarValue {
161
- id?: string;
158
+ export interface EnvVarWithValue {
162
159
  name: string;
163
- repositoryPattern: string;
164
160
  value: string;
165
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
+ }
166
175
  export interface UserEnvVar extends UserEnvVarValue {
167
176
  id: string;
168
177
  userId: string;
@@ -171,10 +180,12 @@ export interface UserEnvVar extends UserEnvVarValue {
171
180
 
172
181
  export namespace UserEnvVar {
173
182
 
183
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
174
184
  export function normalizeRepoPattern(pattern: string) {
175
185
  return pattern.toLocaleLowerCase();
176
186
  }
177
187
 
188
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
178
189
  export function score(value: UserEnvVarValue): number {
179
190
  // We use a score to enforce precedence:
180
191
  // value/value = 0
@@ -197,6 +208,7 @@ export namespace UserEnvVar {
197
208
  return score;
198
209
  }
199
210
 
211
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
200
212
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
201
213
  let result = vars.filter(e => {
202
214
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -244,6 +256,7 @@ export namespace UserEnvVar {
244
256
  return result;
245
257
  }
246
258
 
259
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
247
260
  export function splitRepositoryPattern(repositoryPattern: string): string[] {
248
261
  const patterns = repositoryPattern.split('/');
249
262
  const repoPattern = patterns.pop() || "";
@@ -378,11 +391,16 @@ export interface PendingGithubEvent {
378
391
  export interface Snapshot {
379
392
  id: string;
380
393
  creationTime: string;
394
+ availableTime?: string;
381
395
  originalWorkspaceId: string;
382
396
  bucketId: string;
383
397
  layoutData?: string;
398
+ state: SnapshotState;
399
+ message?: string;
384
400
  }
385
401
 
402
+ export type SnapshotState = 'pending' | 'available' | 'error';
403
+
386
404
  export interface LayoutData {
387
405
  workspaceId: string;
388
406
  lastUpdatedTime: string;
@@ -559,6 +577,9 @@ export interface WorkspaceConfig {
559
577
  github?: GithubAppConfig;
560
578
  vscode?: VSCodeConfig;
561
579
 
580
+ /** deprecated. Enabled by default **/
581
+ experimentalNetwork?: boolean;
582
+
562
583
  /**
563
584
  * Where the config object originates from.
564
585
  *
@@ -586,7 +607,7 @@ export interface GithubAppPrebuildConfig {
586
607
  branches?: boolean
587
608
  pullRequests?: boolean
588
609
  pullRequestsFromForks?: boolean
589
- addCheck?: boolean
610
+ addCheck?: boolean | 'prevent-merge-on-error'
590
611
  addBadge?: boolean
591
612
  addLabel?: boolean | string
592
613
  addComment?: boolean
@@ -682,6 +703,8 @@ export interface PortConfig {
682
703
  port: number;
683
704
  onOpen?: PortOnOpen;
684
705
  visibility?: PortVisibility;
706
+ description?: string;
707
+ name?: string;
685
708
  }
686
709
  export namespace PortConfig {
687
710
  export function is(config: any): config is PortConfig {
@@ -769,6 +792,7 @@ export namespace ExternalImageConfigFile {
769
792
 
770
793
  export interface WorkspaceContext {
771
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. */
772
796
  normalizedContextURL?: string;
773
797
  forceCreateNewWorkspace?: boolean;
774
798
  forceImageBuild?: boolean;
@@ -868,8 +892,20 @@ export namespace PrebuiltWorkspaceContext {
868
892
  }
869
893
  }
870
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
+
871
907
  export interface WithEnvvarsContext extends WorkspaceContext {
872
- envvars: UserEnvVarValue[];
908
+ envvars: EnvVarWithValue[];
873
909
  }
874
910
 
875
911
  export namespace WithEnvvarsContext {
@@ -1167,39 +1203,6 @@ export namespace AuthProviderEntry {
1167
1203
  }
1168
1204
  }
1169
1205
 
1170
- export interface Branding {
1171
- readonly name: string;
1172
- readonly favicon?: string;
1173
- /** Either including domain OR absolute path (interpreted relative to host URL) */
1174
- readonly logo: string;
1175
- readonly startupLogo: string;
1176
- readonly showProductivityTips: boolean;
1177
- readonly redirectUrlIfNotAuthenticated?: string;
1178
- readonly redirectUrlAfterLogout?: string;
1179
- readonly homepage: string;
1180
- readonly ide?: {
1181
- readonly logo: string;
1182
- readonly showReleaseNotes: boolean;
1183
- readonly helpMenu: Branding.Link[];
1184
- }
1185
- readonly links: {
1186
- readonly header: Branding.Link[];
1187
- readonly footer: Branding.Link[];
1188
- readonly social: Branding.SocialLink[];
1189
- readonly legal: Branding.Link[];
1190
- }
1191
- }
1192
- export namespace Branding {
1193
- export interface Link {
1194
- readonly name: string;
1195
- readonly url: string;
1196
- }
1197
- export interface SocialLink {
1198
- readonly type: string;
1199
- readonly url: string;
1200
- }
1201
- }
1202
-
1203
1206
  export interface Configuration {
1204
1207
  readonly daysBeforeGarbageCollection: number;
1205
1208
  readonly garbageCollectionStartDate: number;
@@ -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,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import uuidv4 = require("uuid/v4");
7
+ import { v4 as uuidv4 } from 'uuid';
8
8
  import { Subscription } from "./accounting-protocol";
9
9
 
10
10
  export interface TeamSubscription {
@@ -5,20 +5,27 @@
5
5
  */
6
6
 
7
7
  import { PrebuiltWorkspaceState } from "./protocol";
8
- import uuidv4 = require("uuid/v4");
8
+ import { v4 as uuidv4 } from 'uuid';
9
+ import { DeepPartial } from "./util/deep-partial";
9
10
 
10
11
  export interface ProjectConfig {
11
12
  '.gitpod.yml': string;
12
13
  }
13
14
 
15
+ export interface ProjectSettings {
16
+ useIncrementalPrebuilds?: boolean;
17
+ }
18
+
14
19
  export interface Project {
15
20
  id: string;
16
21
  name: string;
22
+ slug?: string;
17
23
  cloneUrl: string;
18
24
  teamId?: string;
19
25
  userId?: string;
20
26
  appInstallationId: string;
21
27
  config?: ProjectConfig;
28
+ settings?: ProjectSettings;
22
29
  creationTime: string;
23
30
  /** This is a flag that triggers the HARD DELETION of this entity */
24
31
  deleted?: boolean;
@@ -54,6 +61,8 @@ export namespace Project {
54
61
  }
55
62
  }
56
63
 
64
+ export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
65
+
57
66
  export interface PrebuildWithStatus {
58
67
  info: PrebuildInfo;
59
68
  status: PrebuiltWorkspaceState;
@@ -63,6 +72,7 @@ export interface PrebuildWithStatus {
63
72
  export interface PrebuildInfo {
64
73
  id: string;
65
74
  buildWorkspaceId: string;
75
+ basedOnPrebuildId?: string;
66
76
 
67
77
  teamId?: string;
68
78
  userId?: string;
@@ -92,6 +102,7 @@ export namespace PrebuildInfo {
92
102
  }
93
103
 
94
104
  export interface StartPrebuildResult {
105
+ prebuildId: string;
95
106
  wsid: string;
96
107
  done: boolean;
97
108
  }
@@ -4,6 +4,8 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
+ import { repeat } from "./repeat";
8
+
7
9
 
8
10
  interface CacheEntry<T> {
9
11
  key: string;
@@ -41,8 +43,12 @@ export class GarbageCollectedCache<T> {
41
43
  return entry.value;
42
44
  }
43
45
 
46
+ public delete(key: string) {
47
+ this.store.delete(key);
48
+ }
49
+
44
50
  protected regularlyCollectGarbage() {
45
- setInterval(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
51
+ repeat(() => this.collectGarbage(), this.gcIntervalSeconds * 1000);
46
52
  }
47
53
 
48
54
  protected collectGarbage() {
@@ -27,5 +27,22 @@ const expect = chai.expect
27
27
  expect(longestName.length <= 36, `"${longestName}" is longer than 36 chars (${longestName.length})`).to.be.true;
28
28
  }
29
29
 
30
+ @test public async testCustomName() {
31
+ const data = [
32
+ ['foo','bar','foo-bar-'],
33
+ ['f','bar','.{2,16}-bar-'],
34
+ ['gitpod-io','gitpod','gitpodio-gitpod-'],
35
+ ['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
36
+ ['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
37
+ ['UPPER', "CaSe", "upper-case-"]
38
+ ]
39
+ for (const d of data) {
40
+ const id = await generateWorkspaceID(d[0], d[1]);
41
+ expect(id).match(new RegExp("^"+d[2]));
42
+ expect(new GitpodHostUrl().withWorkspacePrefix(id, "eu").workspaceId).to.equal(id);
43
+ expect(id.length <= 36, `"${id}" is longer than 36 chars (${id.length})`).to.be.true;
44
+ }
45
+ }
46
+
30
47
  }
31
48
  module.exports = new TestGenerateWorkspaceId()
@@ -5,8 +5,26 @@
5
5
  */
6
6
  import randomNumber = require("random-number-csprng");
7
7
 
8
- export async function generateWorkspaceID(): Promise<string> {
9
- return (await random(colors))+'-'+(await random(animals))+'-'+(await random(characters, 8));
8
+ export async function generateWorkspaceID(firstSegment?: string, secondSegment?: string): Promise<string> {
9
+ const firstSeg = clean(firstSegment) || await random(colors);
10
+ const secSeg = clean(secondSegment, Math.min(15, 23 - firstSeg.length)) || await random(animals);
11
+ return firstSeg+'-'+secSeg+'-'+(await random(characters, 11));
12
+ }
13
+
14
+ function clean(segment: string | undefined, maxChars: number = 15) {
15
+ if (!segment) {
16
+ return undefined;
17
+ }
18
+ segment = segment.toLowerCase();
19
+ let result = '';
20
+ for (let i =0; i < segment.length; i++) {
21
+ if (characters.indexOf(segment[i]) !== -1) {
22
+ result += segment[i];
23
+ }
24
+ }
25
+ if (result.length >= 2) {
26
+ return result.substring(0, maxChars);
27
+ }
10
28
  }
11
29
 
12
30
  async function random(array: string[], length: number = 1): Promise<string> {