@gitpod/gitpod-protocol 0.1.5-mixpanel-migration-prep.0 → 0.1.5-mp-fmt-gitpod-db.6
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.
- package/data/gitpod-schema.json +28 -2
- package/lib/accounting-protocol.d.ts +10 -10
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +22 -31
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +4 -2
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts.map +1 -1
- package/lib/analytics.js.map +1 -1
- package/lib/auth.d.ts.map +1 -1
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +3 -3
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +20 -5
- package/lib/context-url.spec.js.map +1 -1
- package/lib/email-protocol.d.ts +1 -1
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +1 -1
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +7 -7
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +2 -3
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +1 -1
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +7 -9
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -1
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -5
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +6 -6
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +42 -39
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +16 -24
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +21 -24
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +1 -0
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +2 -1
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +1 -1
- package/lib/ide-protocol.d.ts +6 -6
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/index.d.ts +16 -16
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +2 -2
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +1 -1
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +19 -19
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +4 -4
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +9 -6
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +2 -2
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +20 -20
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -1
- package/lib/messaging/node/connection.js +8 -8
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +1 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +7 -9
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/payment-protocol.d.ts.map +1 -1
- package/lib/payment-protocol.js +1 -1
- package/lib/payment-protocol.js.map +1 -1
- package/lib/permission.d.ts +2 -2
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +12 -23
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +3 -3
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +206 -171
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +46 -35
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +73 -85
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.spec.js.map +1 -1
- package/lib/team-subscription-protocol.d.ts +5 -3
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +4 -4
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +3 -3
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +1 -1
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +2 -2
- package/lib/typings/globals.d.ts.map +1 -1
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +6 -6
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +3 -3
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +6 -6
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +2 -2
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +5 -3
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +1 -1
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +435 -435
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +10 -6
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +1 -1
- package/lib/util/gitpod-cookie.d.ts.map +1 -1
- package/lib/util/gitpod-cookie.js +0 -3
- package/lib/util/gitpod-cookie.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +31 -29
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +15 -5
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts.map +1 -1
- package/lib/util/logging.d.ts +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +22 -23
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +5 -5
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +1 -2
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.spec.js +9 -6
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +2 -2
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +6 -6
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +6 -6
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.js +3 -3
- package/lib/util/tracing.spec.js.map +1 -1
- package/lib/util/workspace-port-authentication.d.ts +7 -7
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +8 -11
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +1 -1
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +2 -4
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +2 -2
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +2 -2
- package/pkg-yarn.lock +2 -2
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +53 -51
- package/src/admin-protocol.ts +25 -21
- package/src/analytics.ts +21 -21
- package/src/auth.ts +2 -2
- package/src/context-url.spec.ts +25 -11
- package/src/context-url.ts +80 -78
- package/src/email-protocol.ts +5 -6
- package/src/encryption/container-module.ts +2 -3
- package/src/encryption/encryption-engine.spec.ts +9 -8
- package/src/encryption/encryption-engine.ts +14 -14
- package/src/encryption/encryption-service.ts +4 -5
- package/src/encryption/key-provider.ts +16 -19
- package/src/env.ts +9 -9
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +117 -101
- package/src/headless-workspace-log.ts +6 -4
- package/src/ide-frontend-service.ts +2 -2
- package/src/ide-protocol.ts +8 -8
- package/src/index.ts +16 -16
- package/src/installation-admin-protocol.ts +8 -8
- package/src/license-protocol.ts +5 -6
- package/src/messaging/browser/connection.ts +45 -47
- package/src/messaging/browser/window-connection.ts +39 -29
- package/src/messaging/client-call-metrics.ts +70 -71
- package/src/messaging/error.ts +1 -3
- package/src/messaging/handler.ts +6 -6
- package/src/messaging/node/connection.ts +8 -8
- package/src/messaging/proxy-factory.ts +23 -30
- package/src/oss-allowlist.ts +3 -3
- package/src/payment-protocol.ts +2 -2
- package/src/permission.ts +20 -31
- package/src/plans.ts +236 -189
- package/src/protocol.ts +226 -238
- package/src/snapshot-url.spec.ts +9 -7
- package/src/team-subscription-protocol.ts +33 -23
- package/src/teams-projects-protocol.ts +8 -8
- package/src/typings/globals.ts +4 -4
- package/src/util/analytics.ts +46 -42
- package/src/util/async-iterator.ts +4 -5
- package/src/util/cancelable.ts +3 -3
- package/src/util/date-time.ts +8 -8
- package/src/util/deferred.ts +6 -6
- package/src/util/disposable.ts +3 -6
- package/src/util/event.ts +9 -11
- package/src/util/garbage-collected-cache.ts +3 -6
- package/src/util/generate-workspace-id.spec.ts +18 -15
- package/src/util/generate-workspace-id.ts +453 -453
- package/src/util/gitpod-cookie.ts +8 -9
- package/src/util/gitpod-host-url.spec.ts +40 -13
- package/src/util/gitpod-host-url.ts +37 -34
- package/src/util/grpc.ts +1 -1
- package/src/util/jaeger-client-types.ts +2 -2
- package/src/util/logging.ts +49 -39
- package/src/util/make-link.ts +6 -7
- package/src/util/parse-workspace-id.spec.ts +17 -8
- package/src/util/parse-workspace-id.ts +5 -6
- package/src/util/queue.spec.ts +27 -25
- package/src/util/repeat.ts +1 -1
- package/src/util/semaphore.ts +4 -6
- package/src/util/skip-if.ts +9 -6
- package/src/util/timeutil.spec.ts +14 -15
- package/src/util/timeutil.ts +15 -11
- package/src/util/tracing.spec.ts +28 -23
- package/src/util/tracing.ts +46 -41
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/workspace-cluster.ts +15 -12
- package/src/workspace-instance.ts +27 -23
- package/src/wsready.ts +3 -3
- package/data/builtin-theia-plugins.json +0 -372
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js +0 -8
- package/lib/theia-plugins.js.map +0 -1
- package/src/theia-plugins.ts +0 -11
package/src/protocol.ts
CHANGED
|
@@ -7,26 +7,27 @@
|
|
|
7
7
|
import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
|
|
8
8
|
import { RoleOrPermission } from "./permission";
|
|
9
9
|
import { Project } from "./teams-projects-protocol";
|
|
10
|
+
import { createHash } from "crypto";
|
|
10
11
|
|
|
11
12
|
export interface UserInfo {
|
|
12
|
-
name?: string
|
|
13
|
+
name?: string;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export interface User {
|
|
16
17
|
/** The user id */
|
|
17
|
-
id: string
|
|
18
|
+
id: string;
|
|
18
19
|
|
|
19
20
|
/** The timestamp when the user entry was created */
|
|
20
|
-
creationDate: string
|
|
21
|
+
creationDate: string;
|
|
21
22
|
|
|
22
|
-
avatarUrl?: string
|
|
23
|
+
avatarUrl?: string;
|
|
23
24
|
|
|
24
|
-
name?: string
|
|
25
|
+
name?: string;
|
|
25
26
|
|
|
26
27
|
/** Optional for backwards compatibility */
|
|
27
|
-
fullName?: string
|
|
28
|
+
fullName?: string;
|
|
28
29
|
|
|
29
|
-
identities: Identity[]
|
|
30
|
+
identities: Identity[];
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Whether the user has been blocked to use our service, because of TOS violation for example.
|
|
@@ -48,29 +49,27 @@ export interface User {
|
|
|
48
49
|
|
|
49
50
|
export namespace User {
|
|
50
51
|
export function is(data: any): data is User {
|
|
51
|
-
return data
|
|
52
|
-
&& data.hasOwnProperty('id')
|
|
53
|
-
&& data.hasOwnProperty('identities')
|
|
52
|
+
return data && data.hasOwnProperty("id") && data.hasOwnProperty("identities");
|
|
54
53
|
}
|
|
55
54
|
export function getIdentity(user: User, authProviderId: string): Identity | undefined {
|
|
56
|
-
return user.identities.find(id => id.authProviderId === authProviderId);
|
|
55
|
+
return user.identities.find((id) => id.authProviderId === authProviderId);
|
|
57
56
|
}
|
|
58
57
|
export function censor(user: User): User {
|
|
59
58
|
const res = { ...user };
|
|
60
|
-
delete
|
|
61
|
-
res.identities = res.identities.map(i => {
|
|
62
|
-
delete
|
|
59
|
+
delete res.additionalData;
|
|
60
|
+
res.identities = res.identities.map((i) => {
|
|
61
|
+
delete i.tokens;
|
|
63
62
|
|
|
64
63
|
// The user field is not in the Identity shape, but actually exists on DBIdentity.
|
|
65
64
|
// Trying to push this object out via JSON RPC will fail because of the cyclic nature
|
|
66
65
|
// of this field.
|
|
67
|
-
delete (
|
|
66
|
+
delete (i as any).user;
|
|
68
67
|
return i;
|
|
69
68
|
});
|
|
70
69
|
return res;
|
|
71
70
|
}
|
|
72
71
|
export function getPrimaryEmail(user: User): string {
|
|
73
|
-
const identities = user.identities.filter(i => !!i.primaryEmail);
|
|
72
|
+
const identities = user.identities.filter((i) => !!i.primaryEmail);
|
|
74
73
|
if (identities.length <= 0) {
|
|
75
74
|
throw new Error(`No identity with primary email for user: ${user.id}!`);
|
|
76
75
|
}
|
|
@@ -98,10 +97,10 @@ export interface AdditionalUserData {
|
|
|
98
97
|
featurePreview?: boolean;
|
|
99
98
|
ideSettings?: IDESettings;
|
|
100
99
|
// key is the name of the news, string the iso date when it was seen
|
|
101
|
-
whatsNewSeen?: { [key: string]: string }
|
|
100
|
+
whatsNewSeen?: { [key: string]: string };
|
|
102
101
|
// key is the name of the OAuth client i.e. local app, string the iso date when it was approved
|
|
103
102
|
// TODO(rl): provide a management UX to allow rescinding of approval
|
|
104
|
-
oauthClientsApproved?: { [key: string]: string }
|
|
103
|
+
oauthClientsApproved?: { [key: string]: string };
|
|
105
104
|
// to remember GH Orgs the user installed/updated the GH App for
|
|
106
105
|
knownGitHubOrgs?: string[];
|
|
107
106
|
|
|
@@ -116,11 +115,11 @@ export interface EmailNotificationSettings {
|
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
export type IDESettings = {
|
|
119
|
-
defaultIde?: string
|
|
120
|
-
useDesktopIde?: boolean
|
|
121
|
-
defaultDesktopIde?: string
|
|
122
|
-
useLatestVersion?: boolean
|
|
123
|
-
}
|
|
118
|
+
defaultIde?: string;
|
|
119
|
+
useDesktopIde?: boolean;
|
|
120
|
+
defaultDesktopIde?: string;
|
|
121
|
+
useLatestVersion?: boolean;
|
|
122
|
+
};
|
|
124
123
|
|
|
125
124
|
export interface UserPlatform {
|
|
126
125
|
uid: string;
|
|
@@ -152,8 +151,8 @@ export interface UserFeatureSettings {
|
|
|
152
151
|
* The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
|
|
153
152
|
* If they don't we'll break things during workspace startup.
|
|
154
153
|
*/
|
|
155
|
-
export const WorkspaceFeatureFlags = {
|
|
156
|
-
export type NamedWorkspaceFeatureFlag = keyof
|
|
154
|
+
export const WorkspaceFeatureFlags = { full_workspace_backup: undefined, fixed_resources: undefined };
|
|
155
|
+
export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
|
|
157
156
|
|
|
158
157
|
export interface EnvVarWithValue {
|
|
159
158
|
name: string;
|
|
@@ -166,7 +165,7 @@ export interface ProjectEnvVarWithValue extends EnvVarWithValue {
|
|
|
166
165
|
censored: boolean;
|
|
167
166
|
}
|
|
168
167
|
|
|
169
|
-
export type ProjectEnvVar = Omit<ProjectEnvVarWithValue,
|
|
168
|
+
export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, "value">;
|
|
170
169
|
|
|
171
170
|
export interface UserEnvVarValue extends EnvVarWithValue {
|
|
172
171
|
id?: string;
|
|
@@ -179,7 +178,6 @@ export interface UserEnvVar extends UserEnvVarValue {
|
|
|
179
178
|
}
|
|
180
179
|
|
|
181
180
|
export namespace UserEnvVar {
|
|
182
|
-
|
|
183
181
|
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
184
182
|
export function normalizeRepoPattern(pattern: string) {
|
|
185
183
|
return pattern.toLocaleLowerCase();
|
|
@@ -199,7 +197,7 @@ export namespace UserEnvVar {
|
|
|
199
197
|
if (repoPattern == "*") {
|
|
200
198
|
score += 1;
|
|
201
199
|
}
|
|
202
|
-
if (ownerPattern ==
|
|
200
|
+
if (ownerPattern == "*") {
|
|
203
201
|
score += 2;
|
|
204
202
|
}
|
|
205
203
|
if (ownerPattern == "#" || repoPattern == "#") {
|
|
@@ -210,20 +208,20 @@ export namespace UserEnvVar {
|
|
|
210
208
|
|
|
211
209
|
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
212
210
|
export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
|
|
213
|
-
let result = vars.filter(e => {
|
|
211
|
+
let result = vars.filter((e) => {
|
|
214
212
|
const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
|
|
215
|
-
if (ownerPattern !==
|
|
213
|
+
if (ownerPattern !== "*" && ownerPattern !== "#" && !!owner && ownerPattern !== owner.toLocaleLowerCase()) {
|
|
216
214
|
return false;
|
|
217
215
|
}
|
|
218
|
-
if (repoPattern !==
|
|
216
|
+
if (repoPattern !== "*" && repoPattern !== "#" && !!repo && repoPattern !== repo.toLocaleLowerCase()) {
|
|
219
217
|
return false;
|
|
220
218
|
}
|
|
221
219
|
return true;
|
|
222
220
|
});
|
|
223
221
|
|
|
224
222
|
const resmap = new Map<string, T[]>();
|
|
225
|
-
result.forEach(e => {
|
|
226
|
-
const l =
|
|
223
|
+
result.forEach((e) => {
|
|
224
|
+
const l = resmap.get(e.name) || [];
|
|
227
225
|
l.push(e);
|
|
228
226
|
resmap.set(e.name, l);
|
|
229
227
|
});
|
|
@@ -258,46 +256,45 @@ export namespace UserEnvVar {
|
|
|
258
256
|
|
|
259
257
|
// DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
|
|
260
258
|
export function splitRepositoryPattern(repositoryPattern: string): string[] {
|
|
261
|
-
const patterns = repositoryPattern.split(
|
|
262
|
-
const repoPattern = patterns.slice(1).join(
|
|
259
|
+
const patterns = repositoryPattern.split("/");
|
|
260
|
+
const repoPattern = patterns.slice(1).join("/");
|
|
263
261
|
const ownerPattern = patterns[0];
|
|
264
262
|
return [ownerPattern, repoPattern];
|
|
265
263
|
}
|
|
266
264
|
}
|
|
267
265
|
|
|
268
266
|
export interface GitpodToken {
|
|
269
|
-
|
|
270
267
|
/** Hash value (SHA256) of the token (primary key). */
|
|
271
|
-
tokenHash: string
|
|
268
|
+
tokenHash: string;
|
|
272
269
|
|
|
273
270
|
/** Human readable name of the token */
|
|
274
|
-
name?: string
|
|
271
|
+
name?: string;
|
|
275
272
|
|
|
276
273
|
/** Token kind */
|
|
277
|
-
type: GitpodTokenType
|
|
274
|
+
type: GitpodTokenType;
|
|
278
275
|
|
|
279
276
|
/** The user the token belongs to. */
|
|
280
|
-
user: User
|
|
277
|
+
user: User;
|
|
281
278
|
|
|
282
279
|
/** Scopes (e.g. limition to read-only) */
|
|
283
|
-
scopes: string[]
|
|
280
|
+
scopes: string[];
|
|
284
281
|
|
|
285
282
|
/** Created timestamp */
|
|
286
|
-
created: string
|
|
283
|
+
created: string;
|
|
287
284
|
|
|
288
285
|
// token is deleted on the database and about to be collected by db-sync
|
|
289
|
-
deleted?: boolean
|
|
286
|
+
deleted?: boolean;
|
|
290
287
|
}
|
|
291
288
|
|
|
292
289
|
export enum GitpodTokenType {
|
|
293
290
|
API_AUTH_TOKEN = 0,
|
|
294
|
-
MACHINE_AUTH_TOKEN = 1
|
|
291
|
+
MACHINE_AUTH_TOKEN = 1,
|
|
295
292
|
}
|
|
296
293
|
|
|
297
294
|
export interface OneTimeSecret {
|
|
298
|
-
id: string
|
|
295
|
+
id: string;
|
|
299
296
|
|
|
300
|
-
value: string
|
|
297
|
+
value: string;
|
|
301
298
|
|
|
302
299
|
expirationTime: string;
|
|
303
300
|
|
|
@@ -329,13 +326,12 @@ export type IdentityLookup = Pick<Identity, "authProviderId" | "authId">;
|
|
|
329
326
|
|
|
330
327
|
export namespace Identity {
|
|
331
328
|
export function is(data: any): data is Identity {
|
|
332
|
-
return
|
|
333
|
-
&& data.hasOwnProperty(
|
|
334
|
-
|
|
329
|
+
return (
|
|
330
|
+
data.hasOwnProperty("authProviderId") && data.hasOwnProperty("authId") && data.hasOwnProperty("authName")
|
|
331
|
+
);
|
|
335
332
|
}
|
|
336
333
|
export function equals(id1: IdentityLookup, id2: IdentityLookup) {
|
|
337
|
-
return id1.authProviderId === id2.authProviderId
|
|
338
|
-
&& id1.authId === id2.authId
|
|
334
|
+
return id1.authProviderId === id2.authProviderId && id1.authId === id2.authId;
|
|
339
335
|
}
|
|
340
336
|
}
|
|
341
337
|
|
|
@@ -399,7 +395,7 @@ export interface Snapshot {
|
|
|
399
395
|
message?: string;
|
|
400
396
|
}
|
|
401
397
|
|
|
402
|
-
export type SnapshotState =
|
|
398
|
+
export type SnapshotState = "pending" | "available" | "error";
|
|
403
399
|
|
|
404
400
|
export interface LayoutData {
|
|
405
401
|
workspaceId: string;
|
|
@@ -428,13 +424,13 @@ export interface Workspace {
|
|
|
428
424
|
* The resolved, fix name of the workspace image. We only use this
|
|
429
425
|
* to access the logs during an image build.
|
|
430
426
|
*/
|
|
431
|
-
imageNameResolved?: string
|
|
427
|
+
imageNameResolved?: string;
|
|
432
428
|
|
|
433
429
|
/**
|
|
434
430
|
* The resolved/built fixed named of the base image. This field is only set if the workspace
|
|
435
431
|
* already has its base image built.
|
|
436
432
|
*/
|
|
437
|
-
baseImageNameResolved?: string
|
|
433
|
+
baseImageNameResolved?: string;
|
|
438
434
|
|
|
439
435
|
shareable?: boolean;
|
|
440
436
|
pinned?: boolean;
|
|
@@ -471,17 +467,16 @@ export type WorkspaceSoftDeletion = "user" | "gc";
|
|
|
471
467
|
export type WorkspaceType = "regular" | "prebuild" | "probe";
|
|
472
468
|
|
|
473
469
|
export namespace Workspace {
|
|
474
|
-
|
|
475
470
|
export function getFullRepositoryName(ws: Workspace): string | undefined {
|
|
476
471
|
if (CommitContext.is(ws.context)) {
|
|
477
|
-
return ws.context.repository.owner +
|
|
472
|
+
return ws.context.repository.owner + "/" + ws.context.repository.name;
|
|
478
473
|
}
|
|
479
474
|
return undefined;
|
|
480
475
|
}
|
|
481
476
|
|
|
482
477
|
export function getFullRepositoryUrl(ws: Workspace): string | undefined {
|
|
483
478
|
if (CommitContext.is(ws.context)) {
|
|
484
|
-
return `https://${ws.context.repository.host}/${getFullRepositoryName(ws)}
|
|
479
|
+
return `https://${ws.context.repository.host}/${getFullRepositoryName(ws)}`;
|
|
485
480
|
}
|
|
486
481
|
return undefined;
|
|
487
482
|
}
|
|
@@ -515,59 +510,36 @@ export namespace Workspace {
|
|
|
515
510
|
}
|
|
516
511
|
}
|
|
517
512
|
|
|
518
|
-
export interface PreparePluginUploadParams {
|
|
519
|
-
fullPluginName: string;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
export interface ResolvePluginsParams {
|
|
523
|
-
config?: WorkspaceConfig
|
|
524
|
-
builtins?: ResolvedPlugins
|
|
525
|
-
vsxRegistryUrl?: string
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
export interface InstallPluginsParams {
|
|
529
|
-
pluginIds: string[]
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
export interface UninstallPluginParams {
|
|
533
|
-
pluginId: string;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
513
|
export interface GuessGitTokenScopesParams {
|
|
537
|
-
host: string
|
|
538
|
-
repoUrl: string
|
|
539
|
-
|
|
540
|
-
currentToken: GitToken
|
|
514
|
+
host: string;
|
|
515
|
+
repoUrl: string;
|
|
516
|
+
gitCommand: string;
|
|
517
|
+
currentToken: GitToken;
|
|
541
518
|
}
|
|
542
519
|
|
|
543
520
|
export interface GitToken {
|
|
544
|
-
token: string
|
|
545
|
-
user: string
|
|
546
|
-
scopes: string[]
|
|
521
|
+
token: string;
|
|
522
|
+
user: string;
|
|
523
|
+
scopes: string[];
|
|
547
524
|
}
|
|
548
525
|
|
|
549
526
|
export interface GuessedGitTokenScopes {
|
|
550
|
-
message?: string
|
|
551
|
-
scopes?: string[]
|
|
527
|
+
message?: string;
|
|
528
|
+
scopes?: string[];
|
|
552
529
|
}
|
|
553
530
|
|
|
554
|
-
export
|
|
555
|
-
|
|
556
|
-
export interface ResolvedPlugins {
|
|
557
|
-
[pluginId: string]: ResolvedPlugin | undefined
|
|
531
|
+
export interface VSCodeConfig {
|
|
532
|
+
extensions?: string[];
|
|
558
533
|
}
|
|
559
534
|
|
|
560
|
-
export interface
|
|
561
|
-
fullPluginName: string;
|
|
535
|
+
export interface RepositoryCloneInformation {
|
|
562
536
|
url: string;
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
export interface VSCodeConfig {
|
|
567
|
-
extensions?: string[];
|
|
537
|
+
checkoutLocation?: string;
|
|
568
538
|
}
|
|
569
539
|
|
|
570
540
|
export interface WorkspaceConfig {
|
|
541
|
+
mainConfiguration?: string;
|
|
542
|
+
additionalRepositories?: RepositoryCloneInformation[];
|
|
571
543
|
image?: ImageConfig;
|
|
572
544
|
ports?: PortConfig[];
|
|
573
545
|
tasks?: TaskConfig[];
|
|
@@ -590,7 +562,7 @@ export interface WorkspaceConfig {
|
|
|
590
562
|
* additional-content - config comes from additional content, usually provided through the project's configuration
|
|
591
563
|
* default - our static catch-all default config
|
|
592
564
|
*/
|
|
593
|
-
_origin?:
|
|
565
|
+
_origin?: "repo" | "project-db" | "definitely-gp" | "derived" | "additional-content" | "default";
|
|
594
566
|
|
|
595
567
|
/**
|
|
596
568
|
* Set of automatically infered feature flags. That's not something the user can set, but
|
|
@@ -600,34 +572,33 @@ export interface WorkspaceConfig {
|
|
|
600
572
|
}
|
|
601
573
|
|
|
602
574
|
export interface GithubAppConfig {
|
|
603
|
-
prebuilds?: GithubAppPrebuildConfig
|
|
575
|
+
prebuilds?: GithubAppPrebuildConfig;
|
|
604
576
|
}
|
|
605
577
|
export interface GithubAppPrebuildConfig {
|
|
606
|
-
master?: boolean
|
|
607
|
-
branches?: boolean
|
|
608
|
-
pullRequests?: boolean
|
|
609
|
-
pullRequestsFromForks?: boolean
|
|
610
|
-
addCheck?: boolean |
|
|
611
|
-
addBadge?: boolean
|
|
612
|
-
addLabel?: boolean | string
|
|
613
|
-
addComment?: boolean
|
|
578
|
+
master?: boolean;
|
|
579
|
+
branches?: boolean;
|
|
580
|
+
pullRequests?: boolean;
|
|
581
|
+
pullRequestsFromForks?: boolean;
|
|
582
|
+
addCheck?: boolean | "prevent-merge-on-error";
|
|
583
|
+
addBadge?: boolean;
|
|
584
|
+
addLabel?: boolean | string;
|
|
585
|
+
addComment?: boolean;
|
|
614
586
|
}
|
|
615
587
|
export namespace GithubAppPrebuildConfig {
|
|
616
588
|
export function is(obj: boolean | GithubAppPrebuildConfig): obj is GithubAppPrebuildConfig {
|
|
617
|
-
return !(typeof obj ===
|
|
589
|
+
return !(typeof obj === "boolean");
|
|
618
590
|
}
|
|
619
591
|
}
|
|
620
592
|
|
|
621
593
|
export type WorkspaceImageSource = WorkspaceImageSourceDocker | WorkspaceImageSourceReference;
|
|
622
594
|
export interface WorkspaceImageSourceDocker {
|
|
623
|
-
dockerFilePath: string
|
|
624
|
-
dockerFileHash: string
|
|
625
|
-
dockerFileSource?: Commit
|
|
595
|
+
dockerFilePath: string;
|
|
596
|
+
dockerFileHash: string;
|
|
597
|
+
dockerFileSource?: Commit;
|
|
626
598
|
}
|
|
627
599
|
export namespace WorkspaceImageSourceDocker {
|
|
628
600
|
export function is(obj: object): obj is WorkspaceImageSourceDocker {
|
|
629
|
-
return
|
|
630
|
-
&& 'dockerFilePath' in obj;
|
|
601
|
+
return "dockerFileHash" in obj && "dockerFilePath" in obj;
|
|
631
602
|
}
|
|
632
603
|
}
|
|
633
604
|
export interface WorkspaceImageSourceReference {
|
|
@@ -636,21 +607,23 @@ export interface WorkspaceImageSourceReference {
|
|
|
636
607
|
}
|
|
637
608
|
export namespace WorkspaceImageSourceReference {
|
|
638
609
|
export function is(obj: object): obj is WorkspaceImageSourceReference {
|
|
639
|
-
return
|
|
610
|
+
return "baseImageResolved" in obj;
|
|
640
611
|
}
|
|
641
612
|
}
|
|
642
613
|
|
|
643
|
-
export type PrebuiltWorkspaceState
|
|
614
|
+
export type PrebuiltWorkspaceState =
|
|
644
615
|
// the prebuild is queued and may start at anytime
|
|
645
|
-
|
|
616
|
+
| "queued"
|
|
646
617
|
// the workspace prebuild is currently running (i.e. there's a workspace pod deployed)
|
|
647
618
|
| "building"
|
|
648
|
-
// the prebuild
|
|
619
|
+
// the prebuild was aborted
|
|
649
620
|
| "aborted"
|
|
650
621
|
// the prebuild timed out
|
|
651
622
|
| "timeout"
|
|
652
|
-
// the prebuild has finished and a snapshot is available
|
|
653
|
-
| "available"
|
|
623
|
+
// the prebuild has finished (even if a headless task failed) and a snapshot is available
|
|
624
|
+
| "available"
|
|
625
|
+
// the prebuild (headless workspace) failed due to some system error
|
|
626
|
+
| "failed";
|
|
654
627
|
|
|
655
628
|
export interface PrebuiltWorkspace {
|
|
656
629
|
id: string;
|
|
@@ -667,7 +640,7 @@ export interface PrebuiltWorkspace {
|
|
|
667
640
|
|
|
668
641
|
export namespace PrebuiltWorkspace {
|
|
669
642
|
export function isDone(pws: PrebuiltWorkspace) {
|
|
670
|
-
return pws.state === "available" || pws.state === "timeout" || pws.state ===
|
|
643
|
+
return pws.state === "available" || pws.state === "timeout" || pws.state === "aborted";
|
|
671
644
|
}
|
|
672
645
|
|
|
673
646
|
export function isAvailable(pws: PrebuiltWorkspace) {
|
|
@@ -686,18 +659,22 @@ export interface PrebuiltWorkspaceUpdatable {
|
|
|
686
659
|
repo: string;
|
|
687
660
|
isResolved: boolean;
|
|
688
661
|
installationId: string;
|
|
662
|
+
/**
|
|
663
|
+
* the commitSHA of the commit that triggered the prebuild
|
|
664
|
+
*/
|
|
665
|
+
commitSHA?: string;
|
|
689
666
|
issue?: string;
|
|
690
667
|
contextUrl?: string;
|
|
691
668
|
}
|
|
692
669
|
|
|
693
670
|
export interface WhitelistedRepository {
|
|
694
|
-
url: string
|
|
695
|
-
name: string
|
|
696
|
-
description?: string
|
|
697
|
-
avatar?: string
|
|
671
|
+
url: string;
|
|
672
|
+
name: string;
|
|
673
|
+
description?: string;
|
|
674
|
+
avatar?: string;
|
|
698
675
|
}
|
|
699
676
|
|
|
700
|
-
export type PortOnOpen =
|
|
677
|
+
export type PortOnOpen = "open-browser" | "open-preview" | "notify" | "ignore";
|
|
701
678
|
|
|
702
679
|
export interface PortConfig {
|
|
703
680
|
port: number;
|
|
@@ -708,7 +685,7 @@ export interface PortConfig {
|
|
|
708
685
|
}
|
|
709
686
|
export namespace PortConfig {
|
|
710
687
|
export function is(config: any): config is PortConfig {
|
|
711
|
-
return config &&
|
|
688
|
+
return config && "port" in config && typeof config.port === "number";
|
|
712
689
|
}
|
|
713
690
|
}
|
|
714
691
|
|
|
@@ -718,7 +695,7 @@ export interface PortRangeConfig {
|
|
|
718
695
|
}
|
|
719
696
|
export namespace PortRangeConfig {
|
|
720
697
|
export function is(config: any): config is PortRangeConfig {
|
|
721
|
-
return config &&
|
|
698
|
+
return config && "port" in config && (typeof config.port === "string" || config.port instanceof String);
|
|
722
699
|
}
|
|
723
700
|
}
|
|
724
701
|
|
|
@@ -729,32 +706,31 @@ export interface TaskConfig {
|
|
|
729
706
|
prebuild?: string;
|
|
730
707
|
command?: string;
|
|
731
708
|
env?: { [env: string]: any };
|
|
732
|
-
openIn?:
|
|
733
|
-
openMode?:
|
|
709
|
+
openIn?: "bottom" | "main" | "left" | "right";
|
|
710
|
+
openMode?: "split-top" | "split-left" | "split-right" | "split-bottom" | "tab-before" | "tab-after";
|
|
734
711
|
}
|
|
735
712
|
|
|
736
713
|
export namespace TaskConfig {
|
|
737
714
|
export function is(config: any): config is TaskConfig {
|
|
738
|
-
return config
|
|
739
|
-
&& ('command' in config || 'init' in config || 'before' in config);
|
|
715
|
+
return config && ("command" in config || "init" in config || "before" in config);
|
|
740
716
|
}
|
|
741
717
|
}
|
|
742
718
|
|
|
743
719
|
export namespace WorkspaceImageBuild {
|
|
744
|
-
export type Phase =
|
|
720
|
+
export type Phase = "BaseImage" | "GitpodLayer" | "Error" | "Done";
|
|
745
721
|
export interface StateInfo {
|
|
746
|
-
phase: Phase
|
|
747
|
-
currentStep?: number
|
|
748
|
-
maxSteps?: number
|
|
722
|
+
phase: Phase;
|
|
723
|
+
currentStep?: number;
|
|
724
|
+
maxSteps?: number;
|
|
749
725
|
}
|
|
750
726
|
export interface LogContent {
|
|
751
|
-
text: string
|
|
752
|
-
upToLine?: number
|
|
753
|
-
isDiff?: boolean
|
|
727
|
+
text: string;
|
|
728
|
+
upToLine?: number;
|
|
729
|
+
isDiff?: boolean;
|
|
754
730
|
}
|
|
755
731
|
export type LogCallback = (info: StateInfo, content: LogContent | undefined) => void;
|
|
756
732
|
export namespace LogLine {
|
|
757
|
-
export const DELIMITER =
|
|
733
|
+
export const DELIMITER = "\r\n";
|
|
758
734
|
export const DELIMITER_REGEX = /\r?\n/;
|
|
759
735
|
}
|
|
760
736
|
}
|
|
@@ -763,20 +739,18 @@ export type ImageConfig = ImageConfigString | ImageConfigFile;
|
|
|
763
739
|
export type ImageConfigString = string;
|
|
764
740
|
export namespace ImageConfigString {
|
|
765
741
|
export function is(config: ImageConfig | undefined): config is ImageConfigString {
|
|
766
|
-
return typeof config ===
|
|
742
|
+
return typeof config === "string";
|
|
767
743
|
}
|
|
768
|
-
|
|
769
744
|
}
|
|
770
745
|
export interface ImageConfigFile {
|
|
771
746
|
// Path to the Dockerfile relative to repository root
|
|
772
|
-
file: string
|
|
747
|
+
file: string;
|
|
773
748
|
// Path to the docker build context relative to repository root
|
|
774
|
-
context?: string
|
|
749
|
+
context?: string;
|
|
775
750
|
}
|
|
776
751
|
export namespace ImageConfigFile {
|
|
777
752
|
export function is(config: ImageConfig | undefined): config is ImageConfigFile {
|
|
778
|
-
return typeof config ===
|
|
779
|
-
&& 'file' in config;
|
|
753
|
+
return typeof config === "object" && "file" in config;
|
|
780
754
|
}
|
|
781
755
|
}
|
|
782
756
|
export interface ExternalImageConfigFile extends ImageConfigFile {
|
|
@@ -784,9 +758,7 @@ export interface ExternalImageConfigFile extends ImageConfigFile {
|
|
|
784
758
|
}
|
|
785
759
|
export namespace ExternalImageConfigFile {
|
|
786
760
|
export function is(config: any | undefined): config is ExternalImageConfigFile {
|
|
787
|
-
return typeof config ===
|
|
788
|
-
&& 'file' in config
|
|
789
|
-
&& 'externalSource' in config;
|
|
761
|
+
return typeof config === "object" && "file" in config && "externalSource" in config;
|
|
790
762
|
}
|
|
791
763
|
}
|
|
792
764
|
|
|
@@ -800,8 +772,7 @@ export interface WorkspaceContext {
|
|
|
800
772
|
|
|
801
773
|
export namespace WorkspaceContext {
|
|
802
774
|
export function is(context: any): context is WorkspaceContext {
|
|
803
|
-
return context
|
|
804
|
-
&& 'title' in context;
|
|
775
|
+
return context && "title" in context;
|
|
805
776
|
}
|
|
806
777
|
}
|
|
807
778
|
|
|
@@ -810,8 +781,7 @@ export interface WithSnapshot {
|
|
|
810
781
|
}
|
|
811
782
|
export namespace WithSnapshot {
|
|
812
783
|
export function is(context: any): context is WithSnapshot {
|
|
813
|
-
return context
|
|
814
|
-
&& 'snapshotBucketId' in context;
|
|
784
|
+
return context && "snapshotBucketId" in context;
|
|
815
785
|
}
|
|
816
786
|
}
|
|
817
787
|
|
|
@@ -821,10 +791,7 @@ export interface WithPrebuild extends WithSnapshot {
|
|
|
821
791
|
}
|
|
822
792
|
export namespace WithPrebuild {
|
|
823
793
|
export function is(context: any): context is WithPrebuild {
|
|
824
|
-
return context
|
|
825
|
-
&& WithSnapshot.is(context)
|
|
826
|
-
&& 'prebuildWorkspaceId' in context
|
|
827
|
-
&& 'wasPrebuilt' in context;
|
|
794
|
+
return context && WithSnapshot.is(context) && "prebuildWorkspaceId" in context && "wasPrebuilt" in context;
|
|
828
795
|
}
|
|
829
796
|
}
|
|
830
797
|
|
|
@@ -838,16 +805,14 @@ export interface WithDefaultConfig {
|
|
|
838
805
|
|
|
839
806
|
export namespace WithDefaultConfig {
|
|
840
807
|
export function is(context: any): context is WithDefaultConfig {
|
|
841
|
-
return context
|
|
842
|
-
&& 'withDefaultConfig' in context
|
|
843
|
-
&& context.withDefaultConfig;
|
|
808
|
+
return context && "withDefaultConfig" in context && context.withDefaultConfig;
|
|
844
809
|
}
|
|
845
810
|
|
|
846
811
|
export function mark(ctx: WorkspaceContext): WorkspaceContext & WithDefaultConfig {
|
|
847
812
|
return {
|
|
848
813
|
...ctx,
|
|
849
|
-
withDefaultConfig: true
|
|
850
|
-
}
|
|
814
|
+
withDefaultConfig: true,
|
|
815
|
+
};
|
|
851
816
|
}
|
|
852
817
|
}
|
|
853
818
|
|
|
@@ -857,23 +822,24 @@ export interface SnapshotContext extends WorkspaceContext, WithSnapshot {
|
|
|
857
822
|
|
|
858
823
|
export namespace SnapshotContext {
|
|
859
824
|
export function is(context: any): context is SnapshotContext {
|
|
860
|
-
return context
|
|
861
|
-
&& WithSnapshot.is(context)
|
|
862
|
-
&& 'snapshotId' in context;
|
|
825
|
+
return context && WithSnapshot.is(context) && "snapshotId" in context;
|
|
863
826
|
}
|
|
864
827
|
}
|
|
865
828
|
|
|
866
829
|
export interface StartPrebuildContext extends WorkspaceContext {
|
|
867
830
|
actual: WorkspaceContext;
|
|
868
831
|
commitHistory?: string[];
|
|
832
|
+
additionalRepositoryCommitHistories?: {
|
|
833
|
+
cloneUrl: string;
|
|
834
|
+
commitHistory: string[];
|
|
835
|
+
}[];
|
|
869
836
|
project?: Project;
|
|
870
837
|
branch?: string;
|
|
871
838
|
}
|
|
872
839
|
|
|
873
840
|
export namespace StartPrebuildContext {
|
|
874
841
|
export function is(context: any): context is StartPrebuildContext {
|
|
875
|
-
return context
|
|
876
|
-
&& 'actual' in context;
|
|
842
|
+
return context && "actual" in context;
|
|
877
843
|
}
|
|
878
844
|
}
|
|
879
845
|
|
|
@@ -885,21 +851,18 @@ export interface PrebuiltWorkspaceContext extends WorkspaceContext {
|
|
|
885
851
|
|
|
886
852
|
export namespace PrebuiltWorkspaceContext {
|
|
887
853
|
export function is(context: any): context is PrebuiltWorkspaceContext {
|
|
888
|
-
return context
|
|
889
|
-
&& 'originalContext' in context
|
|
890
|
-
&& 'prebuiltWorkspace' in context;
|
|
854
|
+
return context && "originalContext" in context && "prebuiltWorkspace" in context;
|
|
891
855
|
}
|
|
892
856
|
}
|
|
893
857
|
|
|
894
858
|
export interface WithReferrerContext extends WorkspaceContext {
|
|
895
|
-
referrer: string
|
|
896
|
-
referrerIde?: string
|
|
859
|
+
referrer: string;
|
|
860
|
+
referrerIde?: string;
|
|
897
861
|
}
|
|
898
862
|
|
|
899
863
|
export namespace WithReferrerContext {
|
|
900
864
|
export function is(context: any): context is WithReferrerContext {
|
|
901
|
-
return context
|
|
902
|
-
&& 'referrer' in context;
|
|
865
|
+
return context && "referrer" in context;
|
|
903
866
|
}
|
|
904
867
|
}
|
|
905
868
|
|
|
@@ -909,21 +872,18 @@ export interface WithEnvvarsContext extends WorkspaceContext {
|
|
|
909
872
|
|
|
910
873
|
export namespace WithEnvvarsContext {
|
|
911
874
|
export function is(context: any): context is WithEnvvarsContext {
|
|
912
|
-
return context
|
|
913
|
-
&& 'envvars' in context
|
|
875
|
+
return context && "envvars" in context;
|
|
914
876
|
}
|
|
915
877
|
}
|
|
916
878
|
|
|
917
879
|
export interface WorkspaceProbeContext extends WorkspaceContext {
|
|
918
|
-
responseURL: string
|
|
919
|
-
responseToken: string
|
|
880
|
+
responseURL: string;
|
|
881
|
+
responseToken: string;
|
|
920
882
|
}
|
|
921
883
|
|
|
922
884
|
export namespace WorkspaceProbeContext {
|
|
923
885
|
export function is(context: any): context is WorkspaceProbeContext {
|
|
924
|
-
return context
|
|
925
|
-
&& 'responseURL' in context
|
|
926
|
-
&& 'responseToken' in context;
|
|
886
|
+
return context && "responseURL" in context && "responseToken" in context;
|
|
927
887
|
}
|
|
928
888
|
}
|
|
929
889
|
|
|
@@ -935,32 +895,30 @@ export namespace RefType {
|
|
|
935
895
|
}
|
|
936
896
|
// This fallback is meant to handle the cases where (for historic reasons) ref is present but refType is missing
|
|
937
897
|
return commit.refType || "branch";
|
|
938
|
-
}
|
|
898
|
+
};
|
|
939
899
|
}
|
|
940
900
|
|
|
941
901
|
export interface Commit {
|
|
942
|
-
repository: Repository
|
|
943
|
-
revision: string
|
|
902
|
+
repository: Repository;
|
|
903
|
+
revision: string;
|
|
944
904
|
|
|
945
905
|
// Might contain either a branch or a tag (determined by refType)
|
|
946
|
-
ref?: string
|
|
906
|
+
ref?: string;
|
|
947
907
|
|
|
948
908
|
// refType is only set if ref is present (and not for old workspaces, before this feature was added)
|
|
949
|
-
refType?: RefType
|
|
909
|
+
refType?: RefType;
|
|
950
910
|
}
|
|
951
911
|
|
|
952
912
|
export interface AdditionalContentContext extends WorkspaceContext {
|
|
953
|
-
|
|
954
913
|
/**
|
|
955
914
|
* utf-8 encoded contents that will be copied on top of the workspace's filesystem
|
|
956
915
|
*/
|
|
957
|
-
additionalFiles: {[filePath: string]: string};
|
|
958
|
-
|
|
916
|
+
additionalFiles: { [filePath: string]: string };
|
|
959
917
|
}
|
|
960
918
|
|
|
961
919
|
export namespace AdditionalContentContext {
|
|
962
920
|
export function is(ctx: any): ctx is AdditionalContentContext {
|
|
963
|
-
return
|
|
921
|
+
return "additionalFiles" in ctx;
|
|
964
922
|
}
|
|
965
923
|
|
|
966
924
|
export function hasDockerConfig(ctx: any, config: WorkspaceConfig): boolean {
|
|
@@ -968,16 +926,49 @@ export namespace AdditionalContentContext {
|
|
|
968
926
|
}
|
|
969
927
|
}
|
|
970
928
|
|
|
971
|
-
export interface CommitContext extends WorkspaceContext,
|
|
929
|
+
export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
|
|
972
930
|
/** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
|
|
973
|
-
cloneUrl?: string
|
|
931
|
+
cloneUrl?: string;
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* The clone and checkout information for additional repositories in case of multi-repo projects.
|
|
935
|
+
*/
|
|
936
|
+
additionalRepositoryCheckoutInfo?: GitCheckoutInfo[];
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
export namespace CommitContext {
|
|
940
|
+
/**
|
|
941
|
+
* Creates a hash for all the commits of the CommitContext and all sub-repo commit infos.
|
|
942
|
+
* The hash is max 255 chars long.
|
|
943
|
+
* @param commitContext
|
|
944
|
+
* @returns hash for commitcontext
|
|
945
|
+
*/
|
|
946
|
+
export function computeHash(commitContext: CommitContext): string {
|
|
947
|
+
// for single commits we use the revision to be backward compatible.
|
|
948
|
+
if (
|
|
949
|
+
!commitContext.additionalRepositoryCheckoutInfo ||
|
|
950
|
+
commitContext.additionalRepositoryCheckoutInfo.length === 0
|
|
951
|
+
) {
|
|
952
|
+
return commitContext.revision;
|
|
953
|
+
}
|
|
954
|
+
const hasher = createHash("sha256");
|
|
955
|
+
hasher.update(commitContext.revision);
|
|
956
|
+
for (const info of commitContext.additionalRepositoryCheckoutInfo) {
|
|
957
|
+
hasher.update(info.revision);
|
|
958
|
+
}
|
|
959
|
+
return hasher.digest("hex");
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
export interface GitCheckoutInfo extends Commit {
|
|
964
|
+
checkoutLocation?: string;
|
|
965
|
+
upstreamRemoteURI?: string;
|
|
966
|
+
localBranch?: string;
|
|
974
967
|
}
|
|
975
968
|
|
|
976
969
|
export namespace CommitContext {
|
|
977
970
|
export function is(commit: any): commit is CommitContext {
|
|
978
|
-
return WorkspaceContext.is(commit)
|
|
979
|
-
&& 'repository' in commit
|
|
980
|
-
&& 'revision' in commit
|
|
971
|
+
return WorkspaceContext.is(commit) && "repository" in commit && "revision" in commit;
|
|
981
972
|
}
|
|
982
973
|
}
|
|
983
974
|
|
|
@@ -985,17 +976,14 @@ export interface PullRequestContext extends CommitContext {
|
|
|
985
976
|
nr: number;
|
|
986
977
|
ref: string;
|
|
987
978
|
base: {
|
|
988
|
-
repository: Repository
|
|
989
|
-
ref: string
|
|
990
|
-
}
|
|
979
|
+
repository: Repository;
|
|
980
|
+
ref: string;
|
|
981
|
+
};
|
|
991
982
|
}
|
|
992
983
|
|
|
993
984
|
export namespace PullRequestContext {
|
|
994
985
|
export function is(ctx: any): ctx is PullRequestContext {
|
|
995
|
-
return CommitContext.is(ctx)
|
|
996
|
-
&& 'nr' in ctx
|
|
997
|
-
&& 'ref' in ctx
|
|
998
|
-
&& 'base' in ctx
|
|
986
|
+
return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "base" in ctx;
|
|
999
987
|
}
|
|
1000
988
|
}
|
|
1001
989
|
|
|
@@ -1007,10 +995,7 @@ export interface IssueContext extends CommitContext {
|
|
|
1007
995
|
|
|
1008
996
|
export namespace IssueContext {
|
|
1009
997
|
export function is(ctx: any): ctx is IssueContext {
|
|
1010
|
-
return CommitContext.is(ctx)
|
|
1011
|
-
&& 'nr' in ctx
|
|
1012
|
-
&& 'ref' in ctx
|
|
1013
|
-
&& 'localBranch' in ctx
|
|
998
|
+
return CommitContext.is(ctx) && "nr" in ctx && "ref" in ctx && "localBranch" in ctx;
|
|
1014
999
|
}
|
|
1015
1000
|
}
|
|
1016
1001
|
|
|
@@ -1021,9 +1006,7 @@ export interface NavigatorContext extends CommitContext {
|
|
|
1021
1006
|
|
|
1022
1007
|
export namespace NavigatorContext {
|
|
1023
1008
|
export function is(ctx: any): ctx is NavigatorContext {
|
|
1024
|
-
return CommitContext.is(ctx)
|
|
1025
|
-
&& 'path' in ctx
|
|
1026
|
-
&& 'isFile' in ctx
|
|
1009
|
+
return CommitContext.is(ctx) && "path" in ctx && "isFile" in ctx;
|
|
1027
1010
|
}
|
|
1028
1011
|
}
|
|
1029
1012
|
|
|
@@ -1040,8 +1023,8 @@ export interface Repository {
|
|
|
1040
1023
|
private?: boolean;
|
|
1041
1024
|
fork?: {
|
|
1042
1025
|
// The direct parent of this fork
|
|
1043
|
-
parent: Repository
|
|
1044
|
-
}
|
|
1026
|
+
parent: Repository;
|
|
1027
|
+
};
|
|
1045
1028
|
}
|
|
1046
1029
|
export interface Branch {
|
|
1047
1030
|
name: string;
|
|
@@ -1066,21 +1049,19 @@ export namespace Repository {
|
|
|
1066
1049
|
export interface WorkspaceInstancePortsChangedEvent {
|
|
1067
1050
|
type: "PortsChanged";
|
|
1068
1051
|
instanceID: string;
|
|
1069
|
-
portsOpened: number[]
|
|
1070
|
-
portsClosed: number[]
|
|
1052
|
+
portsOpened: number[];
|
|
1053
|
+
portsClosed: number[];
|
|
1071
1054
|
}
|
|
1072
1055
|
|
|
1073
1056
|
export namespace WorkspaceInstancePortsChangedEvent {
|
|
1074
|
-
|
|
1075
1057
|
export function is(data: any): data is WorkspaceInstancePortsChangedEvent {
|
|
1076
1058
|
return data && data.type == "PortsChanged";
|
|
1077
1059
|
}
|
|
1078
|
-
|
|
1079
1060
|
}
|
|
1080
1061
|
|
|
1081
1062
|
export interface WorkspaceInfo {
|
|
1082
|
-
workspace: Workspace
|
|
1083
|
-
latestInstance?: WorkspaceInstance
|
|
1063
|
+
workspace: Workspace;
|
|
1064
|
+
latestInstance?: WorkspaceInstance;
|
|
1084
1065
|
}
|
|
1085
1066
|
|
|
1086
1067
|
export namespace WorkspaceInfo {
|
|
@@ -1096,35 +1077,36 @@ export interface WorkspaceCreationResult {
|
|
|
1096
1077
|
workspaceURL?: string;
|
|
1097
1078
|
existingWorkspaces?: WorkspaceInfo[];
|
|
1098
1079
|
runningWorkspacePrebuild?: {
|
|
1099
|
-
prebuildID: string
|
|
1100
|
-
workspaceID: string
|
|
1101
|
-
instanceID: string
|
|
1102
|
-
starting: RunningWorkspacePrebuildStarting
|
|
1103
|
-
sameCluster: boolean
|
|
1104
|
-
}
|
|
1080
|
+
prebuildID: string;
|
|
1081
|
+
workspaceID: string;
|
|
1082
|
+
instanceID: string;
|
|
1083
|
+
starting: RunningWorkspacePrebuildStarting;
|
|
1084
|
+
sameCluster: boolean;
|
|
1085
|
+
};
|
|
1105
1086
|
runningPrebuildWorkspaceID?: string;
|
|
1106
1087
|
}
|
|
1107
|
-
export type RunningWorkspacePrebuildStarting =
|
|
1088
|
+
export type RunningWorkspacePrebuildStarting = "queued" | "starting" | "running";
|
|
1108
1089
|
|
|
1109
1090
|
export enum CreateWorkspaceMode {
|
|
1110
1091
|
// Default returns a running prebuild if there is any, otherwise creates a new workspace (using a prebuild if one is available)
|
|
1111
|
-
Default =
|
|
1092
|
+
Default = "default",
|
|
1112
1093
|
// ForceNew creates a new workspace irrespective of any running prebuilds. This mode is guaranteed to actually create a workspace - but may degrade user experience as currently runnig prebuilds are ignored.
|
|
1113
|
-
ForceNew =
|
|
1094
|
+
ForceNew = "force-new",
|
|
1114
1095
|
// UsePrebuild polls the database waiting for a currently running prebuild to become available. This mode exists to handle the db-sync delay.
|
|
1115
|
-
UsePrebuild =
|
|
1096
|
+
UsePrebuild = "use-prebuild",
|
|
1116
1097
|
// SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
|
|
1117
|
-
SelectIfRunning =
|
|
1098
|
+
SelectIfRunning = "select-if-running",
|
|
1118
1099
|
}
|
|
1119
1100
|
|
|
1120
1101
|
export namespace WorkspaceCreationResult {
|
|
1121
1102
|
export function is(data: any): data is WorkspaceCreationResult {
|
|
1122
|
-
return
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1103
|
+
return (
|
|
1104
|
+
data &&
|
|
1105
|
+
("createdWorkspaceId" in data ||
|
|
1106
|
+
"existingWorkspaces" in data ||
|
|
1107
|
+
"runningWorkspacePrebuild" in data ||
|
|
1108
|
+
"runningPrebuildWorkspaceID" in data)
|
|
1109
|
+
);
|
|
1128
1110
|
}
|
|
1129
1111
|
}
|
|
1130
1112
|
|
|
@@ -1158,7 +1140,7 @@ export interface AuthProviderInfo {
|
|
|
1158
1140
|
readonly default: string[];
|
|
1159
1141
|
readonly publicRepo: string[];
|
|
1160
1142
|
readonly privateRepo: string[];
|
|
1161
|
-
}
|
|
1143
|
+
};
|
|
1162
1144
|
}
|
|
1163
1145
|
|
|
1164
1146
|
export interface AuthProviderEntry {
|
|
@@ -1170,6 +1152,8 @@ export interface AuthProviderEntry {
|
|
|
1170
1152
|
readonly status: AuthProviderEntry.Status;
|
|
1171
1153
|
|
|
1172
1154
|
readonly oauth: OAuth2Config;
|
|
1155
|
+
/** A random string that is to change whenever oauth changes (enforced on DB level) */
|
|
1156
|
+
readonly oauthRevision?: string;
|
|
1173
1157
|
}
|
|
1174
1158
|
|
|
1175
1159
|
export interface OAuth2Config {
|
|
@@ -1182,23 +1166,27 @@ export interface OAuth2Config {
|
|
|
1182
1166
|
readonly scopeSeparator?: string;
|
|
1183
1167
|
|
|
1184
1168
|
readonly settingsUrl?: string;
|
|
1185
|
-
readonly authorizationParams?: { [key: string]: string }
|
|
1169
|
+
readonly authorizationParams?: { [key: string]: string };
|
|
1186
1170
|
readonly configURL?: string;
|
|
1187
1171
|
}
|
|
1188
1172
|
|
|
1189
1173
|
export namespace AuthProviderEntry {
|
|
1190
1174
|
export type Type = "GitHub" | "GitLab" | string;
|
|
1191
1175
|
export type Status = "pending" | "verified";
|
|
1192
|
-
export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & {
|
|
1193
|
-
|
|
1176
|
+
export type NewEntry = Pick<AuthProviderEntry, "ownerId" | "host" | "type"> & {
|
|
1177
|
+
clientId?: string;
|
|
1178
|
+
clientSecret?: string;
|
|
1179
|
+
};
|
|
1180
|
+
export type UpdateEntry = Pick<AuthProviderEntry, "id" | "ownerId"> &
|
|
1181
|
+
Pick<OAuth2Config, "clientId" | "clientSecret">;
|
|
1194
1182
|
export function redact(entry: AuthProviderEntry): AuthProviderEntry {
|
|
1195
1183
|
return {
|
|
1196
1184
|
...entry,
|
|
1197
1185
|
oauth: {
|
|
1198
1186
|
...entry.oauth,
|
|
1199
|
-
clientSecret: "redacted"
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1187
|
+
clientSecret: "redacted",
|
|
1188
|
+
},
|
|
1189
|
+
};
|
|
1202
1190
|
}
|
|
1203
1191
|
}
|
|
1204
1192
|
|