@gitpod/gitpod-protocol 0.1.5-vn-update-gitpod-json-schema.0 → 0.1.5-vn-jetbrains-backend-plugin-223.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.
Files changed (183) hide show
  1. package/data/gitpod-schema.json +63 -113
  2. package/lib/accounting-protocol.d.ts +8 -0
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +12 -1
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +7 -0
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js.map +1 -1
  9. package/lib/attribution.d.ts +20 -0
  10. package/lib/attribution.d.ts.map +1 -0
  11. package/lib/attribution.js +40 -0
  12. package/lib/attribution.js.map +1 -0
  13. package/lib/billing-mode.d.ts +41 -0
  14. package/lib/billing-mode.d.ts.map +1 -0
  15. package/lib/billing-mode.js +44 -0
  16. package/lib/billing-mode.js.map +1 -0
  17. package/lib/blocked-repositories-protocol.d.ts +13 -0
  18. package/lib/blocked-repositories-protocol.d.ts.map +1 -0
  19. package/lib/blocked-repositories-protocol.js +8 -0
  20. package/lib/blocked-repositories-protocol.js.map +1 -0
  21. package/lib/context-url.js +1 -1
  22. package/lib/context-url.js.map +1 -1
  23. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  24. package/lib/encryption/encryption-engine.js +3 -3
  25. package/lib/encryption/encryption-engine.js.map +1 -1
  26. package/lib/encryption/encryption-engine.spec.js +1 -1
  27. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  28. package/lib/encryption/key-provider.js +1 -1
  29. package/lib/encryption/key-provider.js.map +1 -1
  30. package/lib/experiments/always-default.d.ts +8 -0
  31. package/lib/experiments/always-default.d.ts.map +1 -0
  32. package/lib/experiments/always-default.js +20 -0
  33. package/lib/experiments/always-default.js.map +1 -0
  34. package/lib/experiments/configcat-server.d.ts +10 -0
  35. package/lib/experiments/configcat-server.d.ts.map +1 -0
  36. package/lib/experiments/configcat-server.js +36 -0
  37. package/lib/experiments/configcat-server.js.map +1 -0
  38. package/lib/experiments/configcat.d.ts +23 -0
  39. package/lib/experiments/configcat.d.ts.map +1 -0
  40. package/lib/experiments/configcat.js +57 -0
  41. package/lib/experiments/configcat.js.map +1 -0
  42. package/lib/experiments/types.d.ts +24 -0
  43. package/lib/experiments/types.d.ts.map +1 -0
  44. package/lib/experiments/types.js +10 -0
  45. package/lib/experiments/types.js.map +1 -0
  46. package/lib/gitpod-service.d.ts +39 -12
  47. package/lib/gitpod-service.d.ts.map +1 -1
  48. package/lib/gitpod-service.js +13 -1
  49. package/lib/gitpod-service.js.map +1 -1
  50. package/lib/ide-protocol.d.ts +8 -0
  51. package/lib/ide-protocol.d.ts.map +1 -1
  52. package/lib/index.d.ts +1 -1
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/index.js +1 -1
  55. package/lib/index.js.map +1 -1
  56. package/lib/installation-admin-protocol.d.ts +3 -0
  57. package/lib/installation-admin-protocol.d.ts.map +1 -1
  58. package/lib/installation-admin-protocol.js +1 -0
  59. package/lib/installation-admin-protocol.js.map +1 -1
  60. package/lib/messaging/client-call-metrics.d.ts +1 -17
  61. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  62. package/lib/messaging/client-call-metrics.js +1 -2
  63. package/lib/messaging/client-call-metrics.js.map +1 -1
  64. package/lib/messaging/error.d.ts +6 -1
  65. package/lib/messaging/error.d.ts.map +1 -1
  66. package/lib/messaging/error.js +13 -3
  67. package/lib/messaging/error.js.map +1 -1
  68. package/lib/plans.d.ts +1 -0
  69. package/lib/plans.d.ts.map +1 -1
  70. package/lib/plans.js +4 -0
  71. package/lib/plans.js.map +1 -1
  72. package/lib/protocol.d.ts +94 -12
  73. package/lib/protocol.d.ts.map +1 -1
  74. package/lib/protocol.js +119 -13
  75. package/lib/protocol.js.map +1 -1
  76. package/lib/protocol.spec.d.ts +7 -0
  77. package/lib/protocol.spec.d.ts.map +1 -0
  78. package/lib/protocol.spec.js +127 -0
  79. package/lib/protocol.spec.js.map +1 -0
  80. package/lib/team-subscription-protocol.d.ts +17 -0
  81. package/lib/team-subscription-protocol.d.ts.map +1 -1
  82. package/lib/team-subscription-protocol.js +16 -1
  83. package/lib/team-subscription-protocol.js.map +1 -1
  84. package/lib/teams-projects-protocol.d.ts +14 -1
  85. package/lib/teams-projects-protocol.d.ts.map +1 -1
  86. package/lib/teams-projects-protocol.js.map +1 -1
  87. package/lib/usage.d.ts +61 -0
  88. package/lib/usage.d.ts.map +1 -0
  89. package/lib/usage.js +14 -0
  90. package/lib/usage.js.map +1 -0
  91. package/lib/util/debug-app.d.ts +25 -0
  92. package/lib/util/debug-app.d.ts.map +1 -0
  93. package/lib/util/debug-app.js +100 -0
  94. package/lib/util/debug-app.js.map +1 -0
  95. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  96. package/lib/util/garbage-collected-cache.js +5 -0
  97. package/lib/util/garbage-collected-cache.js.map +1 -1
  98. package/lib/util/gitpod-host-url.d.ts +3 -0
  99. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  100. package/lib/util/gitpod-host-url.js +18 -0
  101. package/lib/util/gitpod-host-url.js.map +1 -1
  102. package/lib/util/grpc.d.ts +19 -0
  103. package/lib/util/grpc.d.ts.map +1 -1
  104. package/lib/util/grpc.js +73 -1
  105. package/lib/util/grpc.js.map +1 -1
  106. package/lib/util/logging.d.ts.map +1 -1
  107. package/lib/util/logging.js +8 -1
  108. package/lib/util/logging.js.map +1 -1
  109. package/lib/util/logging.spec.d.ts +7 -0
  110. package/lib/util/logging.spec.d.ts.map +1 -0
  111. package/lib/util/logging.spec.js +52 -0
  112. package/lib/util/logging.spec.js.map +1 -0
  113. package/lib/util/timeutil.d.ts +2 -0
  114. package/lib/util/timeutil.d.ts.map +1 -1
  115. package/lib/util/timeutil.js +13 -1
  116. package/lib/util/timeutil.js.map +1 -1
  117. package/lib/util/timeutil.spec.d.ts +2 -0
  118. package/lib/util/timeutil.spec.d.ts.map +1 -1
  119. package/lib/util/timeutil.spec.js +34 -0
  120. package/lib/util/timeutil.spec.js.map +1 -1
  121. package/lib/webhook-event.d.ts +44 -0
  122. package/lib/webhook-event.d.ts.map +1 -0
  123. package/lib/webhook-event.js +8 -0
  124. package/lib/webhook-event.js.map +1 -0
  125. package/lib/workspace-class.d.ts +14 -0
  126. package/lib/workspace-class.d.ts.map +1 -0
  127. package/lib/workspace-class.js +8 -0
  128. package/lib/workspace-class.js.map +1 -0
  129. package/lib/workspace-cluster.d.ts +5 -7
  130. package/lib/workspace-cluster.d.ts.map +1 -1
  131. package/lib/workspace-cluster.js.map +1 -1
  132. package/lib/workspace-instance.d.ts +12 -0
  133. package/lib/workspace-instance.d.ts.map +1 -1
  134. package/lib/wsready.d.ts +3 -3
  135. package/lib/wsready.d.ts.map +1 -1
  136. package/lib/wsready.js +0 -2
  137. package/lib/wsready.js.map +1 -1
  138. package/package.json +12 -6
  139. package/pkg-yarn.lock +8 -5
  140. package/provenance-bundle.jsonl +1 -1
  141. package/src/accounting-protocol.ts +13 -0
  142. package/src/admin-protocol.ts +10 -0
  143. package/src/attribution.ts +48 -0
  144. package/src/billing-mode.ts +77 -0
  145. package/src/blocked-repositories-protocol.ts +13 -0
  146. package/src/context-url.ts +1 -1
  147. package/src/encryption/encryption-engine.spec.ts +1 -1
  148. package/src/encryption/encryption-engine.ts +7 -3
  149. package/src/encryption/key-provider.ts +1 -1
  150. package/src/experiments/always-default.ts +24 -0
  151. package/src/experiments/configcat-server.ts +41 -0
  152. package/src/experiments/configcat.ts +62 -0
  153. package/src/experiments/types.ts +38 -0
  154. package/src/gitpod-service.ts +67 -11
  155. package/src/ide-protocol.ts +10 -0
  156. package/src/index.ts +1 -1
  157. package/src/installation-admin-protocol.ts +3 -0
  158. package/src/messaging/client-call-metrics.ts +1 -20
  159. package/src/messaging/error.ts +19 -4
  160. package/src/plans.ts +4 -0
  161. package/src/protocol.spec.ts +97 -0
  162. package/src/protocol.ts +205 -20
  163. package/src/team-subscription-protocol.ts +27 -0
  164. package/src/teams-projects-protocol.ts +15 -1
  165. package/src/usage.ts +71 -0
  166. package/src/util/debug-app.ts +81 -0
  167. package/src/util/garbage-collected-cache.ts +5 -0
  168. package/src/util/gitpod-host-url.ts +21 -0
  169. package/src/util/grpc.ts +89 -0
  170. package/src/util/logging.spec.ts +23 -0
  171. package/src/util/logging.ts +11 -2
  172. package/src/util/timeutil.spec.ts +28 -1
  173. package/src/util/timeutil.ts +12 -0
  174. package/src/webhook-event.ts +55 -0
  175. package/src/workspace-class.ts +14 -0
  176. package/src/workspace-cluster.ts +2 -4
  177. package/src/workspace-instance.ts +20 -0
  178. package/src/wsready.ts +5 -4
  179. package/lib/email-protocol.d.ts +0 -49
  180. package/lib/email-protocol.d.ts.map +0 -1
  181. package/lib/email-protocol.js +0 -28
  182. package/lib/email-protocol.js.map +0 -1
  183. package/src/email-protocol.ts +0 -65
@@ -0,0 +1,24 @@
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
+ import { Attributes, Client } from "./types";
7
+
8
+ // AlwaysReturningDefaultValueClient is an implemention of an experiments.Client which performs no lookup/network operation
9
+ // and always returns the default value for a given experimentName.
10
+ // This client is used for non-SaaS version of Gitpod, in particular for self-hosted installations where external
11
+ // network connections are not desirable or even possible.
12
+ class AlwaysReturningDefaultValueClient implements Client {
13
+ getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T> {
14
+ return Promise.resolve(defaultValue);
15
+ }
16
+
17
+ dispose(): void {
18
+ // there is nothing to dispose, no-op.
19
+ }
20
+ }
21
+
22
+ export function newAlwaysReturningDefaultValueClient(): Client {
23
+ return new AlwaysReturningDefaultValueClient();
24
+ }
@@ -0,0 +1,41 @@
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
+ import { Client } from "./types";
8
+ import * as configcat from "configcat-node";
9
+ import { LogLevel } from "configcat-common";
10
+ import { ConfigCatClient } from "./configcat";
11
+ import { newAlwaysReturningDefaultValueClient } from "./always-default";
12
+
13
+ let client: Client | undefined;
14
+
15
+ export type ConfigCatClientFactory = () => Client;
16
+ export const ConfigCatClientFactory = Symbol("ConfigCatClientFactory");
17
+
18
+ export function getExperimentsClientForBackend(): Client {
19
+ // We have already instantiated a client, we can just re-use it.
20
+ if (client !== undefined) {
21
+ return client;
22
+ }
23
+
24
+ // Retrieve SDK key from ENV Variable
25
+ const sdkKey = process.env.CONFIGCAT_SDK_KEY;
26
+
27
+ // Self-hosted installations do not set the ConfigCat SDK key, so always use a client which returns the default value.
28
+ if (sdkKey === undefined || sdkKey === "") {
29
+ client = newAlwaysReturningDefaultValueClient();
30
+ return client;
31
+ }
32
+
33
+ const configCatClient = configcat.createClient(sdkKey, {
34
+ pollIntervalSeconds: 3 * 60, // 3 minutes
35
+ logger: configcat.createConsoleLogger(LogLevel.Error),
36
+ maxInitWaitTimeSeconds: 0,
37
+ });
38
+
39
+ client = new ConfigCatClient(configCatClient);
40
+ return client;
41
+ }
@@ -0,0 +1,62 @@
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
+ import { Attributes, Client } from "./types";
8
+ import { User as ConfigCatUser } from "configcat-common/lib/RolloutEvaluator";
9
+ import { IConfigCatClient } from "configcat-common/lib/ConfigCatClient";
10
+ import { User } from "../protocol";
11
+
12
+ export const USER_ID_ATTRIBUTE = "user_id";
13
+ export const PROJECT_ID_ATTRIBUTE = "project_id";
14
+ export const TEAM_ID_ATTRIBUTE = "team_id";
15
+ export const TEAM_IDS_ATTRIBUTE = "team_ids";
16
+ export const TEAM_NAME_ATTRIBUTE = "team_name";
17
+ export const TEAM_NAMES_ATTRIBUTE = "team_names";
18
+ export const BILLING_TIER_ATTRIBUTE = "billing_tier";
19
+
20
+ export class ConfigCatClient implements Client {
21
+ private client: IConfigCatClient;
22
+
23
+ constructor(cc: IConfigCatClient) {
24
+ this.client = cc;
25
+ }
26
+
27
+ getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T> {
28
+ return this.client.getValueAsync(experimentName, defaultValue, attributesToUser(attributes));
29
+ }
30
+
31
+ dispose(): void {
32
+ return this.client.dispose();
33
+ }
34
+ }
35
+
36
+ export function attributesToUser(attributes: Attributes): ConfigCatUser {
37
+ const userId = attributes.user?.id || "";
38
+ const email = User.is(attributes.user) ? User.getPrimaryEmail(attributes.user) : attributes.user?.email || "";
39
+
40
+ const custom: { [key: string]: string } = {};
41
+ if (userId) {
42
+ custom[USER_ID_ATTRIBUTE] = userId;
43
+ }
44
+ if (attributes.projectId) {
45
+ custom[PROJECT_ID_ATTRIBUTE] = attributes.projectId;
46
+ }
47
+ if (attributes.teamId) {
48
+ custom[TEAM_ID_ATTRIBUTE] = attributes.teamId;
49
+ }
50
+ if (attributes.teamName) {
51
+ custom[TEAM_NAME_ATTRIBUTE] = attributes.teamName;
52
+ }
53
+ if (attributes.teams) {
54
+ custom[TEAM_NAMES_ATTRIBUTE] = attributes.teams.map((t) => t.name).join(",");
55
+ custom[TEAM_IDS_ATTRIBUTE] = attributes.teams.map((t) => t.id).join(",");
56
+ }
57
+ if (attributes.billingTier) {
58
+ custom[BILLING_TIER_ATTRIBUTE] = attributes.billingTier;
59
+ }
60
+
61
+ return new ConfigCatUser(userId, email, "", custom);
62
+ }
@@ -0,0 +1,38 @@
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
+ import { BillingTier, User } from "../protocol";
8
+ import { Team } from "../teams-projects-protocol";
9
+
10
+ export const Client = Symbol("Client");
11
+
12
+ // Attributes define attributes which can be used to segment audiences.
13
+ // Set the attributes which you want to use to group audiences into.
14
+ export interface Attributes {
15
+ // user.id is mapped to ConfigCat's "identifier" + "custom.user_id"
16
+ user?: User | { id: string; email?: string };
17
+
18
+ // The BillingTier of this particular user
19
+ billingTier?: BillingTier;
20
+
21
+ // Currently selected Gitpod Project ID (mapped to "custom.project_id")
22
+ projectId?: string;
23
+
24
+ // Currently selected Gitpod Team ID (mapped to "custom.team_id")
25
+ teamId?: string;
26
+ // Currently selected Gitpod Team Name (mapped to "custom.team_name")
27
+ teamName?: string;
28
+
29
+ // All the Gitpod Teams that the user is a member (or owner) of (mapped to "custom.team_names" and "custom.team_ids")
30
+ teams?: Team[];
31
+ }
32
+
33
+ export interface Client {
34
+ getValueAsync<T>(experimentName: string, defaultValue: T, attributes: Attributes): Promise<T>;
35
+
36
+ // dispose will dispose of the client, no longer retrieving flags
37
+ dispose(): void;
38
+ }
@@ -24,6 +24,9 @@ import {
24
24
  GuessGitTokenScopesParams,
25
25
  GuessedGitTokenScopes,
26
26
  ProjectEnvVar,
27
+ PrebuiltWorkspace,
28
+ UserSSHPublicKeyValue,
29
+ SSHPublicKeyValue,
27
30
  } from "./protocol";
28
31
  import {
29
32
  Team,
@@ -34,6 +37,7 @@ import {
34
37
  PrebuildWithStatus,
35
38
  StartPrebuildResult,
36
39
  PartialProject,
40
+ PrebuildEvent,
37
41
  } from "./teams-projects-protocol";
38
42
  import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
39
43
  import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
@@ -47,10 +51,18 @@ import { LicenseService } from "./license-protocol";
47
51
  import { Emitter } from "./util/event";
48
52
  import { AccountStatement, CreditAlert } from "./accounting-protocol";
49
53
  import { GithubUpgradeURL, PlanCoupon } from "./payment-protocol";
50
- import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from "./team-subscription-protocol";
54
+ import {
55
+ TeamSubscription,
56
+ TeamSubscription2,
57
+ TeamSubscriptionSlot,
58
+ TeamSubscriptionSlotResolved,
59
+ } from "./team-subscription-protocol";
51
60
  import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
52
61
  import { IDEServer } from "./ide-protocol";
53
62
  import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
63
+ import { ListUsageRequest, ListUsageResponse } from "./usage";
64
+ import { SupportedWorkspaceClass } from "./workspace-class";
65
+ import { BillingMode } from "./billing-mode";
54
66
 
55
67
  export interface GitpodClient {
56
68
  onInstanceUpdate(instance: WorkspaceInstance): void;
@@ -58,6 +70,8 @@ export interface GitpodClient {
58
70
 
59
71
  onPrebuildUpdate(update: PrebuildWithStatus): void;
60
72
 
73
+ onNotificationUpdated(): void;
74
+
61
75
  onCreditAlert(creditAlert: CreditAlert): void;
62
76
 
63
77
  //#region propagating reconnection to iframe
@@ -72,6 +86,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
72
86
  getLoggedInUser(): Promise<User>;
73
87
  getTerms(): Promise<Terms>;
74
88
  updateLoggedInUser(user: Partial<User>): Promise<User>;
89
+ sendPhoneNumberVerificationToken(phoneNumber: string): Promise<void>;
90
+ verifyPhoneNumberVerificationToken(phoneNumber: string, token: string): Promise<boolean>;
75
91
  getAuthProviders(): Promise<AuthProviderInfo[]>;
76
92
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
77
93
  updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
@@ -142,6 +158,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
142
158
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
143
159
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
144
160
 
161
+ // User SSH Keys
162
+ hasSSHPublicKey(): Promise<boolean>;
163
+ getSSHPublicKeys(): Promise<UserSSHPublicKeyValue[]>;
164
+ addSSHPublicKey(value: SSHPublicKeyValue): Promise<UserSSHPublicKeyValue>;
165
+ deleteSSHPublicKey(id: string): Promise<void>;
166
+
145
167
  // Teams
146
168
  getTeams(): Promise<Team[]>;
147
169
  getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
@@ -165,14 +187,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
165
187
  getTeamProjects(teamId: string): Promise<Project[]>;
166
188
  getUserProjects(): Promise<Project[]>;
167
189
  getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
190
+ getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
168
191
  findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
192
+ findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
193
+ getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
169
194
  triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
170
195
  cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
171
- fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
172
- guessProjectConfiguration(projectId: string): Promise<string | undefined>;
173
- fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
174
- guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
175
- setProjectConfiguration(projectId: string, configString: string): Promise<void>;
176
196
  updateProjectPartial(partialProject: PartialProject): Promise<void>;
177
197
  setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
178
198
  getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
@@ -188,7 +208,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
188
208
  deleteGitpodToken(tokenHash: string): Promise<void>;
189
209
 
190
210
  // misc
191
- sendFeedback(feedback: string): Promise<string | undefined>;
192
211
  isGitHubAppEnabled(): Promise<boolean>;
193
212
  registerGithubApp(installationId: string): Promise<void>;
194
213
 
@@ -235,7 +254,9 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
235
254
  */
236
255
  getChargebeeSiteId(): Promise<string>;
237
256
  createPortalSession(): Promise<{}>;
257
+ createTeamPortalSession(teamId: string): Promise<{}>;
238
258
  checkout(planId: string, planQuantity?: number): Promise<{}>;
259
+ teamCheckout(teamId: string, planId: string): Promise<{}>;
239
260
  getAvailableCoupons(): Promise<PlanCoupon[]>;
240
261
  getAppliedCoupons(): Promise<PlanCoupon[]>;
241
262
 
@@ -247,6 +268,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
247
268
  subscriptionCancel(subscriptionId: string): Promise<void>;
248
269
  subscriptionCancelDowngrade(subscriptionId: string): Promise<void>;
249
270
 
271
+ getTeamSubscription(teamId: string): Promise<TeamSubscription2 | undefined>;
250
272
  tsGet(): Promise<TeamSubscription[]>;
251
273
  tsGetSlots(): Promise<TeamSubscriptionSlotResolved[]>;
252
274
  tsGetUnassignedSlot(teamSubscriptionId: string): Promise<TeamSubscriptionSlot | undefined>;
@@ -262,12 +284,35 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
262
284
 
263
285
  getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
264
286
 
287
+ getStripePublishableKey(): Promise<string>;
288
+ getStripeSetupIntentClientSecret(): Promise<string>;
289
+ findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
290
+ createStripeCustomerIfNeeded(attributionId: string, currency: string): Promise<void>;
291
+ subscribeToStripe(attributionId: string, setupIntentId: string): Promise<void>;
292
+ getStripePortalUrl(attributionId: string): Promise<string>;
293
+ getUsageLimit(attributionId: string): Promise<number | undefined>;
294
+ setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
295
+
296
+ listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
297
+
298
+ setUsageAttribution(usageAttribution: string): Promise<void>;
299
+
300
+ getBillingModeForUser(): Promise<BillingMode>;
301
+ getBillingModeForTeam(teamId: string): Promise<BillingMode>;
302
+
265
303
  /**
266
304
  * Analytics
267
305
  */
268
306
  trackEvent(event: RemoteTrackMessage): Promise<void>;
269
307
  trackLocation(event: RemotePageMessage): Promise<void>;
270
308
  identifyUser(event: RemoteIdentifyMessage): Promise<void>;
309
+
310
+ /**
311
+ * Frontend notifications
312
+ */
313
+ getNotifications(): Promise<string[]>;
314
+
315
+ getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
271
316
  }
272
317
 
273
318
  export interface RateLimiterError {
@@ -282,9 +327,7 @@ export interface RateLimiterError {
282
327
 
283
328
  export interface CreateProjectParams {
284
329
  name: string;
285
- slug?: string;
286
- account: string;
287
- provider: string;
330
+ slug: string;
288
331
  cloneUrl: string;
289
332
  teamId?: string;
290
333
  userId?: string;
@@ -349,7 +392,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
349
392
  get: (target: S, property: keyof S) => {
350
393
  const result = target[property];
351
394
  if (!result) {
352
- throw new Error(`Method ${property} not implemented`);
395
+ throw new Error(`Method ${String(property)} not implemented`);
353
396
  }
354
397
  return result;
355
398
  },
@@ -365,6 +408,7 @@ export interface SetWorkspaceTimeoutResult {
365
408
 
366
409
  export interface GetWorkspaceTimeoutResult {
367
410
  duration: WorkspaceTimeoutDuration;
411
+ durationRaw: string;
368
412
  canChange: boolean;
369
413
  }
370
414
 
@@ -522,6 +566,18 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
522
566
  }
523
567
  }
524
568
  }
569
+
570
+ onNotificationUpdated(): void {
571
+ for (const client of this.clients) {
572
+ if (client.onNotificationUpdated) {
573
+ try {
574
+ client.onNotificationUpdated();
575
+ } catch (error) {
576
+ console.error(error);
577
+ }
578
+ }
579
+ }
580
+ }
525
581
  }
526
582
 
527
583
  export type GitpodService = GitpodServiceImpl<GitpodClient, GitpodServer>;
@@ -116,4 +116,14 @@ export interface IDEOption {
116
116
  * we resolve the tag regularly to the most recent image version.
117
117
  */
118
118
  resolveImageDigest?: boolean;
119
+
120
+ /**
121
+ * The plugin image ref for the IDE image, this image ref always resolve to digest.
122
+ */
123
+ pluginImage?: string;
124
+
125
+ /**
126
+ * The latest plugin image ref for the latest IDE image, this image ref always resolve to digest.
127
+ */
128
+ pluginLatestImage?: string;
119
129
  }
package/src/index.ts CHANGED
@@ -13,10 +13,10 @@ export * from "./license-protocol";
13
13
  export * from "./workspace-instance";
14
14
  export * from "./permission";
15
15
  export * from "./admin-protocol";
16
- export * from "./email-protocol";
17
16
  export * from "./headless-workspace-log";
18
17
  export * from "./context-url";
19
18
  export * from "./teams-projects-protocol";
20
19
  export * from "./snapshot-url";
21
20
  export * from "./oss-allowlist";
22
21
  export * from "./installation-admin-protocol";
22
+ export * from "./webhook-event";
@@ -8,6 +8,7 @@ import { v4 as uuidv4 } from "uuid";
8
8
 
9
9
  const InstallationAdminSettingsPrototype = {
10
10
  sendTelemetry: true,
11
+ sendCustomerID: true,
11
12
  };
12
13
 
13
14
  export type InstallationAdminSettings = typeof InstallationAdminSettingsPrototype;
@@ -28,6 +29,8 @@ export interface TelemetryData {
28
29
  totalUsers: number;
29
30
  totalWorkspaces: number;
30
31
  totalInstances: number;
32
+ licenseType: string;
33
+ customerID?: string;
31
34
  }
32
35
 
33
36
  export namespace InstallationAdmin {
@@ -6,26 +6,7 @@
6
6
 
7
7
  import { injectable } from "inversify";
8
8
  import * as prometheusClient from "prom-client";
9
-
10
- type GrpcMethodType = "unary" | "client_stream" | "server_stream" | "bidi_stream";
11
- export interface IGrpcCallMetricsLabels {
12
- service: string;
13
- method: string;
14
- type: GrpcMethodType;
15
- }
16
-
17
- export interface IGrpcCallMetricsLabelsWithCode extends IGrpcCallMetricsLabels {
18
- code: string;
19
- }
20
-
21
- export const IClientCallMetrics = Symbol("IClientCallMetrics");
22
-
23
- export interface IClientCallMetrics {
24
- started(labels: IGrpcCallMetricsLabels): void;
25
- sent(labels: IGrpcCallMetricsLabels): void;
26
- received(labels: IGrpcCallMetricsLabels): void;
27
- handled(labels: IGrpcCallMetricsLabelsWithCode): void;
28
- }
9
+ import { IClientCallMetrics, IGrpcCallMetricsLabels, IGrpcCallMetricsLabelsWithCode } from "../util/grpc";
29
10
 
30
11
  @injectable()
31
12
  export class PrometheusClientCallMetrics implements IClientCallMetrics {
@@ -26,21 +26,30 @@ export namespace ErrorCodes {
26
26
  // 410 No User
27
27
  export const SETUP_REQUIRED = 410;
28
28
 
29
+ // 411 No User
30
+ export const NEEDS_VERIFICATION = 411;
31
+
29
32
  // 429 Too Many Requests
30
33
  export const TOO_MANY_REQUESTS = 429;
31
34
 
32
35
  // 430 Repository not whitelisted (custom status code)
33
36
  export const REPOSITORY_NOT_WHITELISTED = 430;
34
37
 
38
+ // 450 Payment error
39
+ export const PAYMENT_ERROR = 450;
40
+
41
+ // 451 Out of credits
42
+ export const PAYMENT_SPENDING_LIMIT_REACHED = 451;
43
+
44
+ // 455 Invalid cost center (custom status code)
45
+ export const INVALID_COST_CENTER = 455;
46
+
35
47
  // 460 Context Parse Error (custom status code)
36
48
  export const CONTEXT_PARSE_ERROR = 460;
37
49
 
38
- // 461 Invalid gitpod yml
50
+ // 461 Invalid gitpod yml (custom status code)
39
51
  export const INVALID_GITPOD_YML = 461;
40
52
 
41
- // 450 Payment error
42
- export const PAYMENT_ERROR = 450;
43
-
44
53
  // 470 User Blocked (custom status code)
45
54
  export const USER_BLOCKED = 470;
46
55
 
@@ -62,6 +71,9 @@ export namespace ErrorCodes {
62
71
  // 490 Too Many Running Workspace
63
72
  export const TOO_MANY_RUNNING_WORKSPACES = 490;
64
73
 
74
+ // 500 Internal Server Error
75
+ export const INTERNAL_SERVER_ERROR = 500;
76
+
65
77
  // 501 EE Feature
66
78
  export const EE_FEATURE = 501;
67
79
 
@@ -82,4 +94,7 @@ export namespace ErrorCodes {
82
94
 
83
95
  // 640 Headless logs are not available (yet)
84
96
  export const HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
97
+
98
+ // 650 Invalid Value
99
+ export const INVALID_VALUE = 650;
85
100
  }
package/src/plans.ts CHANGED
@@ -482,6 +482,10 @@ export namespace Plans {
482
482
  );
483
483
  }
484
484
 
485
+ export function isFreeTier(chargebeeId: string | undefined): boolean {
486
+ return chargebeeId === Plans.FREE.chargebeeId || chargebeeId === Plans.FREE_50.chargebeeId;
487
+ }
488
+
485
489
  export function isFreeNonTransientPlan(chargebeeId: string | undefined): boolean {
486
490
  return chargebeeId === Plans.FREE_OPEN_SOURCE.chargebeeId;
487
491
  }
@@ -0,0 +1,97 @@
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 { SSHPublicKeyValue } from ".";
10
+
11
+ const expect = chai.expect;
12
+
13
+ @suite
14
+ class TestSSHPublicKeyValue {
15
+ private key =
16
+ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDCnrN9UdK1bNGPmZfenTWXLuYYDjlYvZE8S+WOfP08WpR1GETzX5ZvgYOEZGwEE8KUPHC9cge4Hvo/ydIS9aqbZ5MiVGJ8cAIq1Ic89SjlDWU6fl8TwIqOPCi2imAASlEDP4q8vMLK1N6UOW1EVbxyL3uybGd10ysC1t1FxFPveIGNsYE/MOQeuEWS16AplpXYXIfVRSlgAskeBft2w8Ud3B4gNe8ECLA/FXu96UpvZkdtOarA3JZ9Z27GveNJg9Mtmmw0+US0KXiO9x9NyH7G8+mqVDwDY+nNvaFA5gtQxkkl/uY2oz9k/B4Rjlj3jOiUXe5uQs3XUm5m8g9a9fh62DabLpA2fEvtfg+a/VqNe52dNa5YjupwvBd6Inb5uMW/TYjNl6bNHPlXFKw/nwLOVzukpkjxMZUKS6+4BGkpoasj6y2rTU/wkpbdD8J7yjI1p6J9aKkC6KksIWgN7xGmHkv2PCGDqMHTNbnQyowtNKMgA/667vAYJ0qW7HAHBFXJRs6uRi/DI3+c1QV2s4wPCpEHDIYApovQ0fbON4WDPoGMyHd7kPh9xB/bX7Dj0uMXImu1pdTd62fQ/1XXX64+vjAAXS/P9RSCD0RCRt/K3LPKl2m7GPI3y1niaE52XhxZw+ms9ays6NasNVMw/ZC+f02Ti+L5FBEVf8230RVVRQ== notfound@gitpod.io";
17
+
18
+ @test public testValidate() {
19
+ const key = this.key;
20
+ const [t, k, e] = key.split(" ");
21
+ expect(
22
+ SSHPublicKeyValue.getData({
23
+ key,
24
+ name: "NiceName",
25
+ }),
26
+ ).to.deep.equal({ type: t, key: k, email: e });
27
+ }
28
+
29
+ @test public testValidateWithDiffType() {
30
+ const key = this.key;
31
+ const [_, k, e] = key.split(" ");
32
+ expect(
33
+ SSHPublicKeyValue.getData({
34
+ key: key.replace("ssh-rsa", "sk-ecdsa-sha2-nistp256@openssh.com"),
35
+ name: "NiceName",
36
+ }),
37
+ ).to.deep.equal({ type: "sk-ecdsa-sha2-nistp256@openssh.com", key: k, email: e });
38
+ }
39
+
40
+ @test public testValidateWithoutEmail() {
41
+ const key = this.key;
42
+ const [t, k, _] = key.split(" ");
43
+ expect(
44
+ SSHPublicKeyValue.getData({
45
+ key: key.replace(" notfound@gitpod.io", ""),
46
+ name: "NiceName",
47
+ }),
48
+ ).to.deep.equal({ type: t, key: k, email: undefined });
49
+ }
50
+
51
+ @test public testValidateWithoutEmailButEndsWithSpaces() {
52
+ const key = this.key;
53
+ const [t, k, _] = key.split(" ");
54
+ expect(
55
+ SSHPublicKeyValue.getData({
56
+ key: key.replace("notfound@gitpod.io", " "),
57
+ name: "NiceName",
58
+ }),
59
+ ).to.deep.equal({ type: t, key: k, email: undefined });
60
+ }
61
+
62
+ @test public testValidateWithError() {
63
+ expect(() =>
64
+ SSHPublicKeyValue.getData({
65
+ key: "Hello World",
66
+ name: "NiceName",
67
+ }),
68
+ ).throw("Key is invalid");
69
+
70
+ expect(() =>
71
+ SSHPublicKeyValue.getData({
72
+ key: "",
73
+ name: "NiceName",
74
+ }),
75
+ ).throw("Key is invalid");
76
+ }
77
+
78
+ @test public testGetFingerprint() {
79
+ const key = this.key;
80
+ expect(
81
+ SSHPublicKeyValue.getFingerprint({
82
+ key,
83
+ name: "NiceName",
84
+ }),
85
+ ).to.equal("ykjP/b5aqoa3envmXzWpPMCGgEFMu3QvubfSTNrJCMA=");
86
+ }
87
+
88
+ @test public testGetFingerprintWithIncorrectPublicKey() {
89
+ expect(() =>
90
+ SSHPublicKeyValue.getFingerprint({
91
+ key: "Hello World",
92
+ name: "NiceName",
93
+ }),
94
+ ).to.throw("Key is invalid");
95
+ }
96
+ }
97
+ module.exports = new TestSSHPublicKeyValue(); // Only to circumvent no usage warning :-/