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

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 (124) hide show
  1. package/data/gitpod-schema.json +63 -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/billing-mode.d.ts +41 -0
  10. package/lib/billing-mode.d.ts.map +1 -0
  11. package/lib/billing-mode.js +44 -0
  12. package/lib/billing-mode.js.map +1 -0
  13. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  14. package/lib/encryption/encryption-engine.js +3 -3
  15. package/lib/encryption/encryption-engine.js.map +1 -1
  16. package/lib/encryption/encryption-engine.spec.js +1 -1
  17. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  18. package/lib/encryption/key-provider.js +1 -1
  19. package/lib/encryption/key-provider.js.map +1 -1
  20. package/lib/experiments/configcat-server.d.ts +2 -0
  21. package/lib/experiments/configcat-server.d.ts.map +1 -1
  22. package/lib/experiments/configcat-server.js +2 -1
  23. package/lib/experiments/configcat-server.js.map +1 -1
  24. package/lib/experiments/configcat.d.ts +1 -0
  25. package/lib/experiments/configcat.d.ts.map +1 -1
  26. package/lib/experiments/configcat.js +5 -1
  27. package/lib/experiments/configcat.js.map +1 -1
  28. package/lib/experiments/types.d.ts +2 -1
  29. package/lib/experiments/types.d.ts.map +1 -1
  30. package/lib/gitpod-service.d.ts +25 -16
  31. package/lib/gitpod-service.d.ts.map +1 -1
  32. package/lib/gitpod-service.js +13 -1
  33. package/lib/gitpod-service.js.map +1 -1
  34. package/lib/ide-protocol.d.ts +8 -0
  35. package/lib/ide-protocol.d.ts.map +1 -1
  36. package/lib/messaging/client-call-metrics.d.ts +1 -17
  37. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  38. package/lib/messaging/client-call-metrics.js +1 -2
  39. package/lib/messaging/client-call-metrics.js.map +1 -1
  40. package/lib/messaging/error.d.ts +5 -1
  41. package/lib/messaging/error.d.ts.map +1 -1
  42. package/lib/messaging/error.js +11 -3
  43. package/lib/messaging/error.js.map +1 -1
  44. package/lib/plans.d.ts +1 -0
  45. package/lib/plans.d.ts.map +1 -1
  46. package/lib/plans.js +4 -0
  47. package/lib/plans.js.map +1 -1
  48. package/lib/protocol.d.ts +41 -4
  49. package/lib/protocol.d.ts.map +1 -1
  50. package/lib/protocol.js +27 -2
  51. package/lib/protocol.js.map +1 -1
  52. package/lib/team-subscription-protocol.d.ts +1 -0
  53. package/lib/team-subscription-protocol.d.ts.map +1 -1
  54. package/lib/team-subscription-protocol.js +4 -0
  55. package/lib/team-subscription-protocol.js.map +1 -1
  56. package/lib/teams-projects-protocol.d.ts +12 -1
  57. package/lib/teams-projects-protocol.d.ts.map +1 -1
  58. package/lib/usage.d.ts +49 -10
  59. package/lib/usage.d.ts.map +1 -1
  60. package/lib/usage.js +6 -107
  61. package/lib/usage.js.map +1 -1
  62. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  63. package/lib/util/garbage-collected-cache.js +5 -0
  64. package/lib/util/garbage-collected-cache.js.map +1 -1
  65. package/lib/util/gitpod-host-url.d.ts +3 -0
  66. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  67. package/lib/util/gitpod-host-url.js +18 -0
  68. package/lib/util/gitpod-host-url.js.map +1 -1
  69. package/lib/util/grpc.d.ts +19 -0
  70. package/lib/util/grpc.d.ts.map +1 -1
  71. package/lib/util/grpc.js +73 -1
  72. package/lib/util/grpc.js.map +1 -1
  73. package/lib/util/logging.spec.d.ts +7 -0
  74. package/lib/util/logging.spec.d.ts.map +1 -0
  75. package/lib/util/logging.spec.js +52 -0
  76. package/lib/util/logging.spec.js.map +1 -0
  77. package/lib/util/timeutil.d.ts +1 -0
  78. package/lib/util/timeutil.d.ts.map +1 -1
  79. package/lib/util/timeutil.js +7 -1
  80. package/lib/util/timeutil.js.map +1 -1
  81. package/lib/util/timeutil.spec.d.ts +2 -0
  82. package/lib/util/timeutil.spec.d.ts.map +1 -1
  83. package/lib/util/timeutil.spec.js +34 -0
  84. package/lib/util/timeutil.spec.js.map +1 -1
  85. package/lib/workspace-class.d.ts +14 -0
  86. package/lib/workspace-class.d.ts.map +1 -0
  87. package/lib/workspace-class.js +8 -0
  88. package/lib/workspace-class.js.map +1 -0
  89. package/lib/workspace-instance.d.ts +1 -0
  90. package/lib/workspace-instance.d.ts.map +1 -1
  91. package/lib/wsready.d.ts +3 -3
  92. package/lib/wsready.d.ts.map +1 -1
  93. package/lib/wsready.js +0 -2
  94. package/lib/wsready.js.map +1 -1
  95. package/package.json +5 -2
  96. package/pkg-yarn.lock +3 -2
  97. package/provenance-bundle.jsonl +1 -1
  98. package/src/accounting-protocol.ts +3 -0
  99. package/src/admin-protocol.ts +4 -1
  100. package/src/billing-mode.ts +77 -0
  101. package/src/encryption/encryption-engine.spec.ts +1 -1
  102. package/src/encryption/encryption-engine.ts +7 -3
  103. package/src/encryption/key-provider.ts +1 -1
  104. package/src/experiments/configcat-server.ts +3 -0
  105. package/src/experiments/configcat.ts +4 -0
  106. package/src/experiments/types.ts +4 -1
  107. package/src/gitpod-service.ts +42 -16
  108. package/src/ide-protocol.ts +10 -0
  109. package/src/messaging/client-call-metrics.ts +1 -20
  110. package/src/messaging/error.ts +16 -4
  111. package/src/plans.ts +4 -0
  112. package/src/protocol.ts +62 -6
  113. package/src/team-subscription-protocol.ts +3 -0
  114. package/src/teams-projects-protocol.ts +13 -1
  115. package/src/usage.ts +53 -128
  116. package/src/util/garbage-collected-cache.ts +5 -0
  117. package/src/util/gitpod-host-url.ts +21 -0
  118. package/src/util/grpc.ts +89 -0
  119. package/src/util/logging.spec.ts +23 -0
  120. package/src/util/timeutil.spec.ts +28 -1
  121. package/src/util/timeutil.ts +6 -0
  122. package/src/workspace-class.ts +14 -0
  123. package/src/workspace-instance.ts +3 -0
  124. package/src/wsready.ts +5 -4
@@ -40,7 +40,7 @@ export class EncryptionEngineImpl {
40
40
  encrypt(data: string, key: Buffer): EncryptedData {
41
41
  const iv = crypto.randomBytes(16);
42
42
  const cipher = crypto.createCipheriv(this.algorithm, key, iv);
43
- const encrypted = cipher.update(new Buffer(data, "utf8"));
43
+ const encrypted = cipher.update(Buffer.from(data, "utf8"));
44
44
  const finalEncrypted = Buffer.concat([encrypted, cipher.final()]);
45
45
  return {
46
46
  data: finalEncrypted.toString(this.enc),
@@ -51,8 +51,12 @@ export class EncryptionEngineImpl {
51
51
  }
52
52
 
53
53
  decrypt(encryptedData: EncryptedData, key: Buffer): string {
54
- const decipher = crypto.createDecipheriv(this.algorithm, key, new Buffer(encryptedData.keyParams.iv, this.enc));
55
- let decrypted = decipher.update(new Buffer(encryptedData.data, this.enc));
54
+ const decipher = crypto.createDecipheriv(
55
+ this.algorithm,
56
+ key,
57
+ Buffer.from(encryptedData.keyParams.iv, this.enc),
58
+ );
59
+ let decrypted = decipher.update(Buffer.from(encryptedData.data, this.enc));
56
60
  const finalDecrypted = Buffer.concat([decrypted, decipher.final()]);
57
61
  return finalDecrypted.toString("utf8");
58
62
  }
@@ -71,7 +71,7 @@ export class KeyProviderImpl implements KeyProvider {
71
71
  name: config.name,
72
72
  version: config.version,
73
73
  },
74
- material: new Buffer(config.material, "base64"),
74
+ material: Buffer.from(config.material, "base64"),
75
75
  };
76
76
  }
77
77
  }
@@ -12,6 +12,9 @@ import { newAlwaysReturningDefaultValueClient } from "./always-default";
12
12
 
13
13
  let client: Client | undefined;
14
14
 
15
+ export type ConfigCatClientFactory = () => Client;
16
+ export const ConfigCatClientFactory = Symbol("ConfigCatClientFactory");
17
+
15
18
  export function getExperimentsClientForBackend(): Client {
16
19
  // We have already instantiated a client, we can just re-use it.
17
20
  if (client !== undefined) {
@@ -15,6 +15,7 @@ export const TEAM_ID_ATTRIBUTE = "team_id";
15
15
  export const TEAM_IDS_ATTRIBUTE = "team_ids";
16
16
  export const TEAM_NAME_ATTRIBUTE = "team_name";
17
17
  export const TEAM_NAMES_ATTRIBUTE = "team_names";
18
+ export const BILLING_TIER_ATTRIBUTE = "billing_tier";
18
19
 
19
20
  export class ConfigCatClient implements Client {
20
21
  private client: IConfigCatClient;
@@ -53,6 +54,9 @@ export function attributesToUser(attributes: Attributes): ConfigCatUser {
53
54
  custom[TEAM_NAMES_ATTRIBUTE] = attributes.teams.map((t) => t.name).join(",");
54
55
  custom[TEAM_IDS_ATTRIBUTE] = attributes.teams.map((t) => t.id).join(",");
55
56
  }
57
+ if (attributes.billingTier) {
58
+ custom[BILLING_TIER_ATTRIBUTE] = attributes.billingTier;
59
+ }
56
60
 
57
61
  return new ConfigCatUser(userId, email, "", custom);
58
62
  }
@@ -4,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { User } from "../protocol";
7
+ import { BillingTier, User } from "../protocol";
8
8
  import { Team } from "../teams-projects-protocol";
9
9
 
10
10
  export const Client = Symbol("Client");
@@ -15,6 +15,9 @@ export interface Attributes {
15
15
  // user.id is mapped to ConfigCat's "identifier" + "custom.user_id"
16
16
  user?: User | { id: string; email?: string };
17
17
 
18
+ // The BillingTier of this particular user
19
+ billingTier?: BillingTier;
20
+
18
21
  // Currently selected Gitpod Project ID (mapped to "custom.project_id")
19
22
  projectId?: string;
20
23
 
@@ -37,6 +37,7 @@ import {
37
37
  PrebuildWithStatus,
38
38
  StartPrebuildResult,
39
39
  PartialProject,
40
+ PrebuildEvent,
40
41
  } from "./teams-projects-protocol";
41
42
  import { JsonRpcProxy, JsonRpcServer } from "./messaging/proxy-factory";
42
43
  import { Disposable, CancellationTokenSource } from "vscode-jsonrpc";
@@ -59,8 +60,9 @@ import {
59
60
  import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
60
61
  import { IDEServer } from "./ide-protocol";
61
62
  import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
62
- import { Currency } from "./plans";
63
- import { BillableSession } from "./usage";
63
+ import { ListUsageRequest, ListUsageResponse } from "./usage";
64
+ import { SupportedWorkspaceClass } from "./workspace-class";
65
+ import { BillingMode } from "./billing-mode";
64
66
 
65
67
  export interface GitpodClient {
66
68
  onInstanceUpdate(instance: WorkspaceInstance): void;
@@ -68,6 +70,8 @@ export interface GitpodClient {
68
70
 
69
71
  onPrebuildUpdate(update: PrebuildWithStatus): void;
70
72
 
73
+ onNotificationUpdated(): void;
74
+
71
75
  onCreditAlert(creditAlert: CreditAlert): void;
72
76
 
73
77
  //#region propagating reconnection to iframe
@@ -82,6 +86,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
82
86
  getLoggedInUser(): Promise<User>;
83
87
  getTerms(): Promise<Terms>;
84
88
  updateLoggedInUser(user: Partial<User>): Promise<User>;
89
+ sendPhoneNumberVerificationToken(phoneNumber: string): Promise<void>;
90
+ verifyPhoneNumberVerificationToken(phoneNumber: string, token: string): Promise<boolean>;
85
91
  getAuthProviders(): Promise<AuthProviderInfo[]>;
86
92
  getOwnAuthProviders(): Promise<AuthProviderEntry[]>;
87
93
  updateOwnAuthProvider(params: GitpodServer.UpdateOwnAuthProviderParams): Promise<AuthProviderEntry>;
@@ -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
 
@@ -285,11 +286,19 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
285
286
 
286
287
  getStripePublishableKey(): Promise<string>;
287
288
  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>;
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>;
291
299
 
292
- getBilledUsage(attributionId: string): Promise<BillableSession[]>;
300
+ getBillingModeForUser(): Promise<BillingMode>;
301
+ getBillingModeForTeam(teamId: string): Promise<BillingMode>;
293
302
 
294
303
  /**
295
304
  * Analytics
@@ -297,6 +306,13 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
297
306
  trackEvent(event: RemoteTrackMessage): Promise<void>;
298
307
  trackLocation(event: RemotePageMessage): Promise<void>;
299
308
  identifyUser(event: RemoteIdentifyMessage): Promise<void>;
309
+
310
+ /**
311
+ * Frontend notifications
312
+ */
313
+ getNotifications(): Promise<string[]>;
314
+
315
+ getSupportedWorkspaceClasses(): Promise<SupportedWorkspaceClass[]>;
300
316
  }
301
317
 
302
318
  export interface RateLimiterError {
@@ -311,9 +327,7 @@ export interface RateLimiterError {
311
327
 
312
328
  export interface CreateProjectParams {
313
329
  name: string;
314
- slug?: string;
315
- account: string;
316
- provider: string;
330
+ slug: string;
317
331
  cloneUrl: string;
318
332
  teamId?: string;
319
333
  userId?: string;
@@ -378,7 +392,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
378
392
  get: (target: S, property: keyof S) => {
379
393
  const result = target[property];
380
394
  if (!result) {
381
- throw new Error(`Method ${property} not implemented`);
395
+ throw new Error(`Method ${String(property)} not implemented`);
382
396
  }
383
397
  return result;
384
398
  },
@@ -552,6 +566,18 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
552
566
  }
553
567
  }
554
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
+ }
555
581
  }
556
582
 
557
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
  }
@@ -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
 
@@ -85,4 +94,7 @@ export namespace ErrorCodes {
85
94
 
86
95
  // 640 Headless logs are not available (yet)
87
96
  export const HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
97
+
98
+ // 650 Invalid Value
99
+ export const INVALID_VALUE = 650;
88
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
  }
package/src/protocol.ts CHANGED
@@ -8,6 +8,7 @@ import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
8
8
  import { RoleOrPermission } from "./permission";
9
9
  import { Project } from "./teams-projects-protocol";
10
10
  import { createHash } from "crypto";
11
+ import { AttributionId } from "./attribution";
11
12
 
12
13
  export interface UserInfo {
13
14
  name?: string;
@@ -45,6 +46,15 @@ export interface User {
45
46
  markedDeleted?: boolean;
46
47
 
47
48
  additionalData?: AdditionalUserData;
49
+
50
+ // Identifies an explicit team or user ID to which all the user's workspace usage should be attributed to (e.g. for billing purposes)
51
+ usageAttributionId?: string;
52
+
53
+ // The last time this user got verified somehow. The user is not verified if this is empty.
54
+ lastVerificationTime?: string;
55
+
56
+ // The phone number used for the last phone verification.
57
+ verificationPhoneNumber?: string;
48
58
  }
49
59
 
50
60
  export namespace User {
@@ -199,14 +209,26 @@ export interface AdditionalUserData {
199
209
  knownGitHubOrgs?: string[];
200
210
  // Git clone URL pointing to the user's dotfile repo
201
211
  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
212
  // preferred workspace classes
205
213
  workspaceClasses?: WorkspaceClasses;
206
214
  // additional user profile data
207
215
  profile?: ProfileDetails;
208
216
  }
209
-
217
+ export namespace AdditionalUserData {
218
+ export function set(user: User, partialData: Partial<AdditionalUserData>): User {
219
+ if (!user.additionalData) {
220
+ user.additionalData = {
221
+ ...partialData,
222
+ };
223
+ } else {
224
+ user.additionalData = {
225
+ ...user.additionalData,
226
+ ...partialData,
227
+ };
228
+ }
229
+ return user;
230
+ }
231
+ }
210
232
  // The format in which we store User Profiles in
211
233
  export interface ProfileDetails {
212
234
  // when was the last time the user updated their profile information or has been nudged to do so.
@@ -264,17 +286,29 @@ export interface UserFeatureSettings {
264
286
  permanentWSFeatureFlags?: NamedWorkspaceFeatureFlag[];
265
287
  }
266
288
 
289
+ export type BillingTier = "paid" | "free";
290
+
267
291
  /**
268
292
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
269
293
  * If they don't we'll break things during workspace startup.
270
294
  */
271
295
  export const WorkspaceFeatureFlags = {
272
296
  full_workspace_backup: undefined,
273
- fixed_resources: undefined,
274
297
  persistent_volume_claim: undefined,
275
298
  protected_secrets: undefined,
299
+ workspace_class_limiting: undefined,
300
+ workspace_connection_limiting: undefined,
276
301
  };
277
302
  export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
303
+ export namespace NamedWorkspaceFeatureFlag {
304
+ export const WORKSPACE_PERSISTED_FEATTURE_FLAGS: NamedWorkspaceFeatureFlag[] = [
305
+ "full_workspace_backup",
306
+ "persistent_volume_claim",
307
+ ];
308
+ export function isWorkspacePersisted(ff: NamedWorkspaceFeatureFlag): boolean {
309
+ return WORKSPACE_PERSISTED_FEATTURE_FLAGS.includes(ff);
310
+ }
311
+ }
278
312
 
279
313
  export interface EnvVarWithValue {
280
314
  name: string;
@@ -781,6 +815,12 @@ export interface RepositoryCloneInformation {
781
815
  checkoutLocation?: string;
782
816
  }
783
817
 
818
+ export interface CoreDumpConfig {
819
+ enabled?: boolean;
820
+ softLimit?: number;
821
+ hardLimit?: number;
822
+ }
823
+
784
824
  export interface WorkspaceConfig {
785
825
  mainConfiguration?: string;
786
826
  additionalRepositories?: RepositoryCloneInformation[];
@@ -793,6 +833,7 @@ export interface WorkspaceConfig {
793
833
  github?: GithubAppConfig;
794
834
  vscode?: VSCodeConfig;
795
835
  jetbrains?: JetBrainsConfig;
836
+ coreDump?: CoreDumpConfig;
796
837
 
797
838
  /** deprecated. Enabled by default **/
798
839
  experimentalNetwork?: boolean;
@@ -801,13 +842,12 @@ export interface WorkspaceConfig {
801
842
  * Where the config object originates from.
802
843
  *
803
844
  * repo - from the repository
804
- * project-db - from the "Project" stored in the database
805
845
  * definitly-gp - from github.com/gitpod-io/definitely-gp
806
846
  * derived - computed based on analyzing the repository
807
847
  * additional-content - config comes from additional content, usually provided through the project's configuration
808
848
  * default - our static catch-all default config
809
849
  */
810
- _origin?: "repo" | "project-db" | "definitely-gp" | "derived" | "additional-content" | "default";
850
+ _origin?: "repo" | "definitely-gp" | "derived" | "additional-content" | "default";
811
851
 
812
852
  /**
813
853
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -1481,3 +1521,19 @@ export interface Terms {
1481
1521
  readonly content: string;
1482
1522
  readonly formElements?: object;
1483
1523
  }
1524
+
1525
+ export interface StripeConfig {
1526
+ usageProductPriceIds: { [currency: string]: string };
1527
+ individualUsagePriceIds?: { [currency: string]: string };
1528
+ teamUsagePriceIds?: { [currency: string]: string };
1529
+ }
1530
+
1531
+ export type BillingStrategy = "other" | "stripe";
1532
+ export interface CostCenter {
1533
+ readonly id: AttributionId;
1534
+ /**
1535
+ * Unit: credits
1536
+ */
1537
+ spendingLimit: number;
1538
+ billingStrategy: BillingStrategy;
1539
+ }
@@ -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
  /**
@@ -7,6 +7,7 @@
7
7
  import { PrebuiltWorkspaceState } from "./protocol";
8
8
  import { v4 as uuidv4 } from "uuid";
9
9
  import { DeepPartial } from "./util/deep-partial";
10
+ import { WebhookEvent } from "./webhook-event";
10
11
 
11
12
  export interface ProjectConfig {
12
13
  ".gitpod.yml": string;
@@ -26,7 +27,6 @@ export interface Project {
26
27
  teamId?: string;
27
28
  userId?: string;
28
29
  appInstallationId: string;
29
- config?: ProjectConfig;
30
30
  settings?: ProjectSettings;
31
31
  creationTime: string;
32
32
  /** This is a flag that triggers the HARD DELETION of this entity */
@@ -152,3 +152,15 @@ export interface TeamMembershipInvite {
152
152
  /** This is a flag that triggers the HARD DELETION of this entity */
153
153
  deleted?: boolean;
154
154
  }
155
+
156
+ export interface PrebuildEvent {
157
+ id: string;
158
+ creationTime: string;
159
+ status: WebhookEvent.Status | WebhookEvent.PrebuildStatus;
160
+ message?: string;
161
+ prebuildId?: string;
162
+ projectId?: string;
163
+ cloneUrl?: string;
164
+ branch?: string;
165
+ commit?: string;
166
+ }