@gitpod/gitpod-protocol 0.1.5-release-2022.6.1.1 → 0.1.5-release-2022.11.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/data/gitpod-schema.json +79 -129
  2. package/lib/accounting-protocol.d.ts +1 -0
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +4 -0
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +4 -1
  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 +4 -0
  10. package/lib/attribution.d.ts.map +1 -1
  11. package/lib/attribution.js +14 -0
  12. package/lib/attribution.js.map +1 -1
  13. package/lib/billing-mode.d.ts +45 -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/encryption/encryption-engine.d.ts.map +1 -1
  18. package/lib/encryption/encryption-engine.js +3 -3
  19. package/lib/encryption/encryption-engine.js.map +1 -1
  20. package/lib/encryption/encryption-engine.spec.js +1 -1
  21. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  22. package/lib/encryption/key-provider.js +1 -1
  23. package/lib/encryption/key-provider.js.map +1 -1
  24. package/lib/experiments/configcat-server.d.ts +2 -0
  25. package/lib/experiments/configcat-server.d.ts.map +1 -1
  26. package/lib/experiments/configcat-server.js +2 -1
  27. package/lib/experiments/configcat-server.js.map +1 -1
  28. package/lib/experiments/configcat.d.ts +1 -2
  29. package/lib/experiments/configcat.d.ts.map +1 -1
  30. package/lib/experiments/configcat.js +4 -6
  31. package/lib/experiments/configcat.js.map +1 -1
  32. package/lib/experiments/types.d.ts +2 -3
  33. package/lib/experiments/types.d.ts.map +1 -1
  34. package/lib/experiments/types.js.map +1 -1
  35. package/lib/gitpod-service.d.ts +32 -28
  36. package/lib/gitpod-service.d.ts.map +1 -1
  37. package/lib/gitpod-service.js +13 -1
  38. package/lib/gitpod-service.js.map +1 -1
  39. package/lib/ide-protocol.d.ts +8 -0
  40. package/lib/ide-protocol.d.ts.map +1 -1
  41. package/lib/index.d.ts +0 -1
  42. package/lib/index.d.ts.map +1 -1
  43. package/lib/index.js +0 -1
  44. package/lib/index.js.map +1 -1
  45. package/lib/messaging/client-call-metrics.d.ts +1 -17
  46. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  47. package/lib/messaging/client-call-metrics.js +1 -2
  48. package/lib/messaging/client-call-metrics.js.map +1 -1
  49. package/lib/messaging/error.d.ts +6 -1
  50. package/lib/messaging/error.d.ts.map +1 -1
  51. package/lib/messaging/error.js +13 -3
  52. package/lib/messaging/error.js.map +1 -1
  53. package/lib/plans.d.ts +1 -0
  54. package/lib/plans.d.ts.map +1 -1
  55. package/lib/plans.js +6 -2
  56. package/lib/plans.js.map +1 -1
  57. package/lib/protocol.d.ts +50 -28
  58. package/lib/protocol.d.ts.map +1 -1
  59. package/lib/protocol.js +35 -21
  60. package/lib/protocol.js.map +1 -1
  61. package/lib/team-subscription-protocol.d.ts +1 -0
  62. package/lib/team-subscription-protocol.d.ts.map +1 -1
  63. package/lib/team-subscription-protocol.js +4 -0
  64. package/lib/team-subscription-protocol.js.map +1 -1
  65. package/lib/teams-projects-protocol.d.ts +17 -2
  66. package/lib/teams-projects-protocol.d.ts.map +1 -1
  67. package/lib/teams-projects-protocol.js.map +1 -1
  68. package/lib/usage.d.ts +61 -10
  69. package/lib/usage.d.ts.map +1 -1
  70. package/lib/usage.js +12 -107
  71. package/lib/usage.js.map +1 -1
  72. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  73. package/lib/util/garbage-collected-cache.js +5 -0
  74. package/lib/util/garbage-collected-cache.js.map +1 -1
  75. package/lib/util/gitpod-host-url.d.ts +3 -0
  76. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  77. package/lib/util/gitpod-host-url.js +18 -0
  78. package/lib/util/gitpod-host-url.js.map +1 -1
  79. package/lib/util/grpc.d.ts +19 -0
  80. package/lib/util/grpc.d.ts.map +1 -1
  81. package/lib/util/grpc.js +73 -1
  82. package/lib/util/grpc.js.map +1 -1
  83. package/lib/util/logging.spec.d.ts +7 -0
  84. package/lib/util/logging.spec.d.ts.map +1 -0
  85. package/lib/util/logging.spec.js +52 -0
  86. package/lib/util/logging.spec.js.map +1 -0
  87. package/lib/util/nice-grpc.d.ts +9 -0
  88. package/lib/util/nice-grpc.d.ts.map +1 -0
  89. package/lib/util/nice-grpc.js +119 -0
  90. package/lib/util/nice-grpc.js.map +1 -0
  91. package/lib/util/timeutil.d.ts +1 -0
  92. package/lib/util/timeutil.d.ts.map +1 -1
  93. package/lib/util/timeutil.js +7 -1
  94. package/lib/util/timeutil.js.map +1 -1
  95. package/lib/util/timeutil.spec.d.ts +2 -0
  96. package/lib/util/timeutil.spec.d.ts.map +1 -1
  97. package/lib/util/timeutil.spec.js +34 -0
  98. package/lib/util/timeutil.spec.js.map +1 -1
  99. package/lib/workspace-class.d.ts +14 -0
  100. package/lib/workspace-class.d.ts.map +1 -0
  101. package/lib/workspace-class.js +8 -0
  102. package/lib/workspace-class.js.map +1 -0
  103. package/lib/workspace-cluster.d.ts +6 -5
  104. package/lib/workspace-cluster.d.ts.map +1 -1
  105. package/lib/workspace-cluster.js.map +1 -1
  106. package/lib/workspace-instance.d.ts +1 -0
  107. package/lib/workspace-instance.d.ts.map +1 -1
  108. package/lib/wsready.js +1 -1
  109. package/package.json +7 -2
  110. package/pkg-yarn.lock +5 -2
  111. package/provenance-bundle.jsonl +1 -1
  112. package/src/accounting-protocol.ts +3 -0
  113. package/src/admin-protocol.ts +4 -1
  114. package/src/attribution.ts +15 -0
  115. package/src/billing-mode.ts +84 -0
  116. package/src/encryption/encryption-engine.spec.ts +1 -1
  117. package/src/encryption/encryption-engine.ts +7 -3
  118. package/src/encryption/key-provider.ts +1 -1
  119. package/src/experiments/configcat-server.ts +3 -0
  120. package/src/experiments/configcat.ts +3 -5
  121. package/src/experiments/types.ts +4 -5
  122. package/src/gitpod-service.ts +49 -30
  123. package/src/ide-protocol.ts +10 -0
  124. package/src/index.ts +0 -1
  125. package/src/messaging/client-call-metrics.ts +1 -20
  126. package/src/messaging/error.ts +19 -4
  127. package/src/plans.ts +6 -2
  128. package/src/protocol.ts +78 -40
  129. package/src/team-subscription-protocol.ts +3 -0
  130. package/src/teams-projects-protocol.ts +21 -3
  131. package/src/usage.ts +65 -126
  132. package/src/util/garbage-collected-cache.ts +5 -0
  133. package/src/util/gitpod-host-url.ts +21 -0
  134. package/src/util/grpc.ts +89 -0
  135. package/src/util/logging.spec.ts +23 -0
  136. package/src/util/nice-grpc.ts +93 -0
  137. package/src/util/timeutil.spec.ts +28 -1
  138. package/src/util/timeutil.ts +6 -0
  139. package/src/workspace-class.ts +14 -0
  140. package/src/workspace-cluster.ts +11 -6
  141. package/src/workspace-instance.ts +3 -0
  142. package/src/wsready.ts +1 -1
  143. package/lib/email-protocol.d.ts +0 -49
  144. package/lib/email-protocol.d.ts.map +0 -1
  145. package/lib/email-protocol.js +0 -28
  146. package/lib/email-protocol.js.map +0 -1
  147. package/src/email-protocol.ts +0 -65
@@ -12,9 +12,8 @@ import { User } from "../protocol";
12
12
  export const USER_ID_ATTRIBUTE = "user_id";
13
13
  export const PROJECT_ID_ATTRIBUTE = "project_id";
14
14
  export const TEAM_ID_ATTRIBUTE = "team_id";
15
- export const TEAM_IDS_ATTRIBUTE = "team_ids";
16
15
  export const TEAM_NAME_ATTRIBUTE = "team_name";
17
- export const TEAM_NAMES_ATTRIBUTE = "team_names";
16
+ export const BILLING_TIER_ATTRIBUTE = "billing_tier";
18
17
 
19
18
  export class ConfigCatClient implements Client {
20
19
  private client: IConfigCatClient;
@@ -49,9 +48,8 @@ export function attributesToUser(attributes: Attributes): ConfigCatUser {
49
48
  if (attributes.teamName) {
50
49
  custom[TEAM_NAME_ATTRIBUTE] = attributes.teamName;
51
50
  }
52
- if (attributes.teams) {
53
- custom[TEAM_NAMES_ATTRIBUTE] = attributes.teams.map((t) => t.name).join(",");
54
- custom[TEAM_IDS_ATTRIBUTE] = attributes.teams.map((t) => t.id).join(",");
51
+ if (attributes.billingTier) {
52
+ custom[BILLING_TIER_ATTRIBUTE] = attributes.billingTier;
55
53
  }
56
54
 
57
55
  return new ConfigCatUser(userId, email, "", custom);
@@ -4,8 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { User } from "../protocol";
8
- import { Team } from "../teams-projects-protocol";
7
+ import { BillingTier, User } from "../protocol";
9
8
 
10
9
  export const Client = Symbol("Client");
11
10
 
@@ -15,6 +14,9 @@ export interface Attributes {
15
14
  // user.id is mapped to ConfigCat's "identifier" + "custom.user_id"
16
15
  user?: User | { id: string; email?: string };
17
16
 
17
+ // The BillingTier of this particular user
18
+ billingTier?: BillingTier;
19
+
18
20
  // Currently selected Gitpod Project ID (mapped to "custom.project_id")
19
21
  projectId?: string;
20
22
 
@@ -22,9 +24,6 @@ export interface Attributes {
22
24
  teamId?: string;
23
25
  // Currently selected Gitpod Team Name (mapped to "custom.team_name")
24
26
  teamName?: string;
25
-
26
- // All the Gitpod Teams that the user is a member (or owner) of (mapped to "custom.team_names" and "custom.team_ids")
27
- teams?: Team[];
28
27
  }
29
28
 
30
29
  export interface Client {
@@ -12,7 +12,6 @@ import {
12
12
  WhitelistedRepository,
13
13
  WorkspaceImageBuild,
14
14
  AuthProviderInfo,
15
- CreateWorkspaceMode,
16
15
  Token,
17
16
  UserEnvVarValue,
18
17
  Terms,
@@ -37,6 +36,7 @@ import {
37
36
  PrebuildWithStatus,
38
37
  StartPrebuildResult,
39
38
  PartialProject,
39
+ PrebuildEvent,
40
40
  } from "./teams-projects-protocol";
41
41
  import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
42
42
  import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
@@ -59,8 +59,9 @@ import {
59
59
  import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
60
60
  import { IDEServer } from "./ide-protocol";
61
61
  import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
62
- import { Currency } from "./plans";
63
- import { BillableSession } from "./usage";
62
+ import { ListUsageRequest, ListUsageResponse, CostCenterJSON } from "./usage";
63
+ import { SupportedWorkspaceClass } from "./workspace-class";
64
+ import { BillingMode } from "./billing-mode";
64
65
 
65
66
  export interface GitpodClient {
66
67
  onInstanceUpdate(instance: WorkspaceInstance): void;
@@ -68,6 +69,8 @@ export interface GitpodClient {
68
69
 
69
70
  onPrebuildUpdate(update: PrebuildWithStatus): void;
70
71
 
72
+ onNotificationUpdated(): void;
73
+
71
74
  onCreditAlert(creditAlert: CreditAlert): void;
72
75
 
73
76
  //#region propagating reconnection to iframe
@@ -82,6 +85,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
82
85
  getLoggedInUser(): Promise<User>;
83
86
  getTerms(): Promise<Terms>;
84
87
  updateLoggedInUser(user: Partial<User>): Promise<User>;
88
+ sendPhoneNumberVerificationToken(phoneNumber: string): Promise<void>;
89
+ verifyPhoneNumberVerificationToken(phoneNumber: string, token: string): Promise<boolean>;
85
90
  getAuthProviders(): Promise<AuthProviderInfo[]>;
86
91
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
87
92
  updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
@@ -159,6 +164,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
159
164
  deleteSSHPublicKey(id: string): Promise<void>;
160
165
 
161
166
  // Teams
167
+ getTeam(teamId: string): Promise<Team>;
162
168
  getTeams(): Promise<Team[]>;
163
169
  getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
164
170
  createTeam(name: string): Promise<Team>;
@@ -167,7 +173,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
167
173
  removeTeamMember(teamId: string, userId: string): Promise<void>;
168
174
  getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
169
175
  resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
170
- deleteTeam(teamId: string, userId: string): Promise<void>;
176
+ deleteTeam(teamId: string): Promise<void>;
171
177
 
172
178
  // Admin Settings
173
179
  adminGetSettings(): Promise<InstallationAdminSettings>;
@@ -181,16 +187,12 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
181
187
  getTeamProjects(teamId: string): Promise<Project[]>;
182
188
  getUserProjects(): Promise<Project[]>;
183
189
  getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
190
+ getPrebuildEvents(projectId: string): Promise<PrebuildEvent[]>;
184
191
  findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
185
192
  findPrebuildByWorkspaceID(workspaceId: string): Promise<PrebuiltWorkspace | undefined>;
186
193
  getPrebuild(prebuildId: string): Promise<PrebuildWithStatus | undefined>;
187
194
  triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
188
195
  cancelPrebuild(projectId: string, prebuildId: string): Promise<void>;
189
- fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
190
- guessProjectConfiguration(projectId: string): Promise<string | undefined>;
191
- fetchRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
192
- guessRepositoryConfiguration(cloneUrl: string): Promise<string | undefined>;
193
- setProjectConfiguration(projectId: string, configString: string): Promise<void>;
194
196
  updateProjectPartial(partialProject: PartialProject): Promise<void>;
195
197
  setProjectEnvironmentVariable(projectId: string, name: string, value: string, censored: boolean): Promise<void>;
196
198
  getProjectEnvironmentVariables(projectId: string): Promise<ProjectEnvVar[]>;
@@ -206,7 +208,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
206
208
  deleteGitpodToken(tokenHash: string): Promise<void>;
207
209
 
208
210
  // misc
209
- sendFeedback(feedback: string): Promise<string | undefined>;
210
211
  isGitHubAppEnabled(): Promise<boolean>;
211
212
  registerGithubApp(installationId: string): Promise<void>;
212
213
 
@@ -226,16 +227,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
226
227
  */
227
228
  getSnapshots(workspaceID: string): Promise<string[]>;
228
229
 
229
- /**
230
- * stores/updates layout information for the given workspace
231
- */
232
- storeLayout(workspaceId: string, layoutData: string): Promise<void>;
233
-
234
- /**
235
- * retrieves layout information for the given workspace
236
- */
237
- getLayout(workspaceId: string): Promise<string | undefined>;
238
-
239
230
  guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
240
231
 
241
232
  /**
@@ -285,11 +276,20 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
285
276
 
286
277
  getStripePublishableKey(): Promise<string>;
287
278
  getStripeSetupIntentClientSecret(): Promise<string>;
288
- findStripeSubscriptionIdForTeam(teamId: string): Promise<string | undefined>;
289
- subscribeTeamToStripe(teamId: string, setupIntentId: string, currency: Currency): Promise<void>;
290
- getStripePortalUrlForTeam(teamId: string): Promise<string>;
279
+ findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
280
+ createStripeCustomerIfNeeded(attributionId: string, currency: string): Promise<void>;
281
+ subscribeToStripe(attributionId: string, setupIntentId: string, usageLimit: number): Promise<number | undefined>;
282
+ getStripePortalUrl(attributionId: string): Promise<string>;
283
+ getCostCenter(attributionId: string): Promise<CostCenterJSON | undefined>;
284
+ setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
285
+
286
+ listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
287
+
288
+ setUsageAttribution(usageAttribution: string): Promise<void>;
289
+ listAvailableUsageAttributionIds(): Promise<string[]>;
291
290
 
292
- getBilledUsage(attributionId: string): Promise<BillableSession[]>;
291
+ getBillingModeForUser(): Promise<BillingMode>;
292
+ getBillingModeForTeam(teamId: string): Promise<BillingMode>;
293
293
 
294
294
  /**
295
295
  * Analytics
@@ -297,6 +297,13 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
297
297
  trackEvent(event: RemoteTrackMessage): Promise<void>;
298
298
  trackLocation(event: RemotePageMessage): Promise<void>;
299
299
  identifyUser(event: RemoteIdentifyMessage): Promise<void>;
300
+
301
+ /**
302
+ * Frontend notifications
303
+ */
304
+ getNotifications(): Promise<string[]>;
305
+
306
+ getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
300
307
  }
301
308
 
302
309
  export interface RateLimiterError {
@@ -311,9 +318,7 @@ export interface RateLimiterError {
311
318
 
312
319
  export interface CreateProjectParams {
313
320
  name: string;
314
- slug?: string;
315
- account: string;
316
- provider: string;
321
+ slug: string;
317
322
  cloneUrl: string;
318
323
  teamId?: string;
319
324
  userId?: string;
@@ -378,7 +383,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
378
383
  get: (target: S, property: keyof S) => {
379
384
  const result = target[property];
380
385
  if (!result) {
381
- throw new Error(`Method ${property} not implemented`);
386
+ throw new Error(`Method ${String(property)} not implemented`);
382
387
  }
383
388
  return result;
384
389
  },
@@ -416,7 +421,10 @@ export namespace GitpodServer {
416
421
  }
417
422
  export interface CreateWorkspaceOptions {
418
423
  contextUrl: string;
419
- mode?: CreateWorkspaceMode;
424
+ // whether running workspaces on the same context should be ignored. If false (default) users will be asked.
425
+ ignoreRunningWorkspaceOnSameCommit?: boolean;
426
+ ignoreRunningPrebuild?: boolean;
427
+ allowUsingPreviousPrebuilds?: boolean;
420
428
  forceDefaultConfig?: boolean;
421
429
  }
422
430
  export interface StartWorkspaceOptions {
@@ -424,7 +432,6 @@ export namespace GitpodServer {
424
432
  }
425
433
  export interface TakeSnapshotOptions {
426
434
  workspaceId: string;
427
- layoutData?: string;
428
435
  /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
429
436
  dontWait?: boolean;
430
437
  }
@@ -552,6 +559,18 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
552
559
  }
553
560
  }
554
561
  }
562
+
563
+ onNotificationUpdated(): void {
564
+ for (const client of this.clients) {
565
+ if (client.onNotificationUpdated) {
566
+ try {
567
+ client.onNotificationUpdated();
568
+ } catch (error) {
569
+ console.error(error);
570
+ }
571
+ }
572
+ }
573
+ }
555
574
  }
556
575
 
557
576
  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,7 +13,6 @@ 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";
@@ -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,33 @@ 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
+ // 451 Error creating a subscription
45
+ export const SUBSCRIPTION_ERROR = 452;
46
+
47
+ // 455 Invalid cost center (custom status code)
48
+ export const INVALID_COST_CENTER = 455;
49
+
35
50
  // 460 Context Parse Error (custom status code)
36
51
  export const CONTEXT_PARSE_ERROR = 460;
37
52
 
38
- // 461 Invalid gitpod yml
53
+ // 461 Invalid gitpod yml (custom status code)
39
54
  export const INVALID_GITPOD_YML = 461;
40
55
 
41
- // 450 Payment error
42
- export const PAYMENT_ERROR = 450;
43
-
44
56
  // 470 User Blocked (custom status code)
45
57
  export const USER_BLOCKED = 470;
46
58
 
@@ -85,4 +97,7 @@ export namespace ErrorCodes {
85
97
 
86
98
  // 640 Headless logs are not available (yet)
87
99
  export const HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
100
+
101
+ // 650 Invalid Value
102
+ export const INVALID_VALUE = 650;
88
103
  }
package/src/plans.ts CHANGED
@@ -131,7 +131,7 @@ export namespace Plans {
131
131
  githubPlanNumber: 1,
132
132
 
133
133
  type: "free",
134
- name: "Open Source",
134
+ name: "Free",
135
135
  currency: "USD",
136
136
  pricePerMonth: 0,
137
137
  hoursPerMonth: 100,
@@ -146,7 +146,7 @@ export namespace Plans {
146
146
  githubPlanNumber: 5,
147
147
 
148
148
  type: "free-50",
149
- name: "Open Source",
149
+ name: "Free",
150
150
  currency: "USD",
151
151
  pricePerMonth: 0,
152
152
  hoursPerMonth: 50,
@@ -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
  }
package/src/protocol.ts CHANGED
@@ -45,6 +45,15 @@ export interface User {
45
45
  markedDeleted?: boolean;
46
46
 
47
47
  additionalData?: AdditionalUserData;
48
+
49
+ // Identifies an explicit team or user ID to which all the user's workspace usage should be attributed to (e.g. for billing purposes)
50
+ usageAttributionId?: string;
51
+
52
+ // The last time this user got verified somehow. The user is not verified if this is empty.
53
+ lastVerificationTime?: string;
54
+
55
+ // The phone number used for the last phone verification.
56
+ verificationPhoneNumber?: string;
48
57
  }
49
58
 
50
59
  export namespace User {
@@ -199,14 +208,26 @@ export interface AdditionalUserData {
199
208
  knownGitHubOrgs?: string[];
200
209
  // Git clone URL pointing to the user's dotfile repo
201
210
  dotfileRepo?: string;
202
- // Identifies an explicit team or user ID to which all the user's workspace usage should be attributed to (e.g. for billing purposes)
203
- usageAttributionId?: string;
204
211
  // preferred workspace classes
205
212
  workspaceClasses?: WorkspaceClasses;
206
213
  // additional user profile data
207
214
  profile?: ProfileDetails;
208
215
  }
209
-
216
+ export namespace AdditionalUserData {
217
+ export function set(user: User, partialData: Partial<AdditionalUserData>): User {
218
+ if (!user.additionalData) {
219
+ user.additionalData = {
220
+ ...partialData,
221
+ };
222
+ } else {
223
+ user.additionalData = {
224
+ ...user.additionalData,
225
+ ...partialData,
226
+ };
227
+ }
228
+ return user;
229
+ }
230
+ }
210
231
  // The format in which we store User Profiles in
211
232
  export interface ProfileDetails {
212
233
  // when was the last time the user updated their profile information or has been nudged to do so.
@@ -264,17 +285,29 @@ export interface UserFeatureSettings {
264
285
  permanentWSFeatureFlags?: NamedWorkspaceFeatureFlag[];
265
286
  }
266
287
 
288
+ export type BillingTier = "paid" | "free";
289
+
267
290
  /**
268
291
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
269
292
  * If they don't we'll break things during workspace startup.
270
293
  */
271
294
  export const WorkspaceFeatureFlags = {
272
295
  full_workspace_backup: undefined,
273
- fixed_resources: undefined,
274
296
  persistent_volume_claim: undefined,
275
- protected_secrets: undefined,
297
+ workspace_class_limiting: undefined,
298
+ workspace_connection_limiting: undefined,
299
+ workspace_psi: undefined,
276
300
  };
277
301
  export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
302
+ export namespace NamedWorkspaceFeatureFlag {
303
+ export const WORKSPACE_PERSISTED_FEATTURE_FLAGS: NamedWorkspaceFeatureFlag[] = [
304
+ "full_workspace_backup",
305
+ "persistent_volume_claim",
306
+ ];
307
+ export function isWorkspacePersisted(ff: NamedWorkspaceFeatureFlag): boolean {
308
+ return WORKSPACE_PERSISTED_FEATTURE_FLAGS.includes(ff);
309
+ }
310
+ }
278
311
 
279
312
  export interface EnvVarWithValue {
280
313
  name: string;
@@ -437,7 +470,7 @@ export interface UserSSHPublicKey extends SSHPublicKeyValue {
437
470
  lastUsedTime?: string;
438
471
  }
439
472
 
440
- export type UserSSHPublicKeyValue = Omit<UserSSHPublicKey, "key" | "userId">;
473
+ export type UserSSHPublicKeyValue = Omit<UserSSHPublicKey, "userId">;
441
474
 
442
475
  export namespace SSHPublicKeyValue {
443
476
  export function validate(value: SSHPublicKeyValue): string | undefined {
@@ -605,6 +638,7 @@ export interface PendingGithubEvent {
605
638
  creationDate: Date;
606
639
  type: string;
607
640
  event: string;
641
+ deleted: boolean;
608
642
  }
609
643
 
610
644
  export interface Snapshot {
@@ -613,7 +647,6 @@ export interface Snapshot {
613
647
  availableTime?: string;
614
648
  originalWorkspaceId: string;
615
649
  bucketId: string;
616
- layoutData?: string;
617
650
  state: SnapshotState;
618
651
  message?: string;
619
652
  }
@@ -625,14 +658,13 @@ export interface VolumeSnapshot {
625
658
  volumeHandle: string;
626
659
  }
627
660
 
628
- export type SnapshotState = "pending" | "available" | "error";
629
-
630
- export interface LayoutData {
631
- workspaceId: string;
632
- lastUpdatedTime: string;
633
- layoutData: string;
661
+ export interface VolumeSnapshotWithWSType {
662
+ vs: VolumeSnapshot;
663
+ wsType: WorkspaceType;
634
664
  }
635
665
 
666
+ export type SnapshotState = "pending" | "available" | "error";
667
+
636
668
  export interface Workspace {
637
669
  id: string;
638
670
  creationTime: string;
@@ -694,7 +726,7 @@ export interface Workspace {
694
726
 
695
727
  export type WorkspaceSoftDeletion = "user" | "gc";
696
728
 
697
- export type WorkspaceType = "regular" | "prebuild" | "probe"; // TODO(gpl) Removed prove here
729
+ export type WorkspaceType = "regular" | "prebuild";
698
730
 
699
731
  export namespace Workspace {
700
732
  export function getFullRepositoryName(ws: Workspace): string | undefined {
@@ -767,6 +799,10 @@ export interface JetBrainsConfig {
767
799
  goland?: JetBrainsProductConfig;
768
800
  pycharm?: JetBrainsProductConfig;
769
801
  phpstorm?: JetBrainsProductConfig;
802
+ rubymine?: JetBrainsProductConfig;
803
+ webstorm?: JetBrainsProductConfig;
804
+ rider?: JetBrainsProductConfig;
805
+ clion?: JetBrainsProductConfig;
770
806
  }
771
807
  export interface JetBrainsProductConfig {
772
808
  prebuilds?: JetBrainsPrebuilds;
@@ -781,6 +817,12 @@ export interface RepositoryCloneInformation {
781
817
  checkoutLocation?: string;
782
818
  }
783
819
 
820
+ export interface CoreDumpConfig {
821
+ enabled?: boolean;
822
+ softLimit?: number;
823
+ hardLimit?: number;
824
+ }
825
+
784
826
  export interface WorkspaceConfig {
785
827
  mainConfiguration?: string;
786
828
  additionalRepositories?: RepositoryCloneInformation[];
@@ -793,6 +835,7 @@ export interface WorkspaceConfig {
793
835
  github?: GithubAppConfig;
794
836
  vscode?: VSCodeConfig;
795
837
  jetbrains?: JetBrainsConfig;
838
+ coreDump?: CoreDumpConfig;
796
839
 
797
840
  /** deprecated. Enabled by default **/
798
841
  experimentalNetwork?: boolean;
@@ -801,13 +844,12 @@ export interface WorkspaceConfig {
801
844
  * Where the config object originates from.
802
845
  *
803
846
  * repo - from the repository
804
- * project-db - from the "Project" stored in the database
805
847
  * definitly-gp - from github.com/gitpod-io/definitely-gp
806
848
  * derived - computed based on analyzing the repository
807
849
  * additional-content - config comes from additional content, usually provided through the project's configuration
808
850
  * default - our static catch-all default config
809
851
  */
810
- _origin?: "repo" | "project-db" | "definitely-gp" | "derived" | "additional-content" | "default";
852
+ _origin?: "repo" | "definitely-gp" | "derived" | "additional-content" | "default";
811
853
 
812
854
  /**
813
855
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -1075,13 +1117,16 @@ export namespace SnapshotContext {
1075
1117
  }
1076
1118
  }
1077
1119
 
1078
- export interface StartPrebuildContext extends WorkspaceContext {
1079
- actual: WorkspaceContext;
1120
+ export interface WithCommitHistory {
1080
1121
  commitHistory?: string[];
1081
1122
  additionalRepositoryCommitHistories?: {
1082
1123
  cloneUrl: string;
1083
1124
  commitHistory: string[];
1084
1125
  }[];
1126
+ }
1127
+
1128
+ export interface StartPrebuildContext extends WorkspaceContext, WithCommitHistory {
1129
+ actual: WorkspaceContext;
1085
1130
  project?: Project;
1086
1131
  branch?: string;
1087
1132
  }
@@ -1125,17 +1170,6 @@ export namespace WithEnvvarsContext {
1125
1170
  }
1126
1171
  }
1127
1172
 
1128
- export interface WorkspaceProbeContext extends WorkspaceContext {
1129
- responseURL: string;
1130
- responseToken: string;
1131
- }
1132
-
1133
- export namespace WorkspaceProbeContext {
1134
- export function is(context: any): context is WorkspaceProbeContext {
1135
- return context && "responseURL" in context && "responseToken" in context;
1136
- }
1137
- }
1138
-
1139
1173
  export type RefType = "branch" | "tag" | "revision";
1140
1174
  export namespace RefType {
1141
1175
  export const getRefType = (commit: Commit): RefType => {
@@ -1175,6 +1209,16 @@ export namespace AdditionalContentContext {
1175
1209
  }
1176
1210
  }
1177
1211
 
1212
+ export interface OpenPrebuildContext extends WorkspaceContext {
1213
+ openPrebuildID: string;
1214
+ }
1215
+
1216
+ export namespace OpenPrebuildContext {
1217
+ export function is(ctx: any): ctx is OpenPrebuildContext {
1218
+ return "openPrebuildID" in ctx;
1219
+ }
1220
+ }
1221
+
1178
1222
  export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
1179
1223
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
1180
1224
  cloneUrl?: string;
@@ -1338,17 +1382,6 @@ export interface WorkspaceCreationResult {
1338
1382
  }
1339
1383
  export type RunningWorkspacePrebuildStarting = "queued" | "starting" | "running";
1340
1384
 
1341
- export enum CreateWorkspaceMode {
1342
- // Default returns a running prebuild if there is any, otherwise creates a new workspace (using a prebuild if one is available)
1343
- Default = "default",
1344
- // 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.
1345
- ForceNew = "force-new",
1346
- // UsePrebuild polls the database waiting for a currently running prebuild to become available. This mode exists to handle the db-sync delay.
1347
- UsePrebuild = "use-prebuild",
1348
- // SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
1349
- SelectIfRunning = "select-if-running",
1350
- }
1351
-
1352
1385
  export namespace WorkspaceCreationResult {
1353
1386
  export function is(data: any): data is WorkspaceCreationResult {
1354
1387
  return (
@@ -1481,3 +1514,8 @@ export interface Terms {
1481
1514
  readonly content: string;
1482
1515
  readonly formElements?: object;
1483
1516
  }
1517
+
1518
+ export interface StripeConfig {
1519
+ individualUsagePriceIds: { [currency: string]: string };
1520
+ teamUsagePriceIds: { [currency: string]: string };
1521
+ }
@@ -55,6 +55,9 @@ export namespace TeamSubscription2 {
55
55
  export const isActive = (ts2: TeamSubscription2, date: string): boolean => {
56
56
  return ts2.startDate <= date && (ts2.endDate === undefined || date < ts2.endDate);
57
57
  };
58
+ export function isCancelled(s: TeamSubscription2, date: string): boolean {
59
+ return (!!s.cancellationDate && s.cancellationDate < date) || (!!s.endDate && s.endDate < date); // This edge case is meant to handle bad data: If for whatever reason cancellationDate has not been set: treat endDate as such
60
+ }
58
61
  }
59
62
 
60
63
  /**