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

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 (83) hide show
  1. package/data/gitpod-schema.json +16 -0
  2. package/lib/attribution.d.ts +4 -0
  3. package/lib/attribution.d.ts.map +1 -1
  4. package/lib/attribution.js +14 -0
  5. package/lib/attribution.js.map +1 -1
  6. package/lib/billing-mode.d.ts +4 -0
  7. package/lib/billing-mode.d.ts.map +1 -1
  8. package/lib/experiments/configcat.d.ts +0 -2
  9. package/lib/experiments/configcat.d.ts.map +1 -1
  10. package/lib/experiments/configcat.js +1 -7
  11. package/lib/experiments/configcat.js.map +1 -1
  12. package/lib/experiments/types.d.ts +0 -2
  13. package/lib/experiments/types.d.ts.map +1 -1
  14. package/lib/experiments/types.js.map +1 -1
  15. package/lib/frontend-dashboard-service.d.ts +90 -0
  16. package/lib/frontend-dashboard-service.d.ts.map +1 -0
  17. package/lib/frontend-dashboard-service.js +49 -0
  18. package/lib/frontend-dashboard-service.js.map +1 -0
  19. package/lib/gitpod-service.d.ts +10 -15
  20. package/lib/gitpod-service.d.ts.map +1 -1
  21. package/lib/gitpod-service.js.map +1 -1
  22. package/lib/index.d.ts +0 -1
  23. package/lib/index.d.ts.map +1 -1
  24. package/lib/index.js +0 -1
  25. package/lib/index.js.map +1 -1
  26. package/lib/messaging/error.d.ts +1 -0
  27. package/lib/messaging/error.d.ts.map +1 -1
  28. package/lib/messaging/error.js +2 -0
  29. package/lib/messaging/error.js.map +1 -1
  30. package/lib/plans.js +2 -2
  31. package/lib/plans.js.map +1 -1
  32. package/lib/protocol.d.ts +24 -39
  33. package/lib/protocol.d.ts.map +1 -1
  34. package/lib/protocol.js +9 -20
  35. package/lib/protocol.js.map +1 -1
  36. package/lib/teams-projects-protocol.d.ts +5 -1
  37. package/lib/teams-projects-protocol.d.ts.map +1 -1
  38. package/lib/teams-projects-protocol.js.map +1 -1
  39. package/lib/typings/globals.d.ts +2 -1
  40. package/lib/typings/globals.d.ts.map +1 -1
  41. package/lib/usage.d.ts +12 -0
  42. package/lib/usage.d.ts.map +1 -1
  43. package/lib/usage.js +7 -1
  44. package/lib/usage.js.map +1 -1
  45. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  46. package/lib/util/gitpod-host-url.js +4 -0
  47. package/lib/util/gitpod-host-url.js.map +1 -1
  48. package/lib/util/nice-grpc.d.ts +9 -0
  49. package/lib/util/nice-grpc.d.ts.map +1 -0
  50. package/lib/util/nice-grpc.js +119 -0
  51. package/lib/util/nice-grpc.js.map +1 -0
  52. package/lib/workspace-cluster.d.ts +6 -5
  53. package/lib/workspace-cluster.d.ts.map +1 -1
  54. package/lib/workspace-cluster.js.map +1 -1
  55. package/lib/wsready.d.ts +3 -3
  56. package/lib/wsready.d.ts.map +1 -1
  57. package/lib/wsready.js +2 -0
  58. package/lib/wsready.js.map +1 -1
  59. package/package.json +3 -1
  60. package/pkg-yarn.lock +3 -1
  61. package/provenance-bundle.jsonl +1 -1
  62. package/src/attribution.ts +15 -0
  63. package/src/billing-mode.ts +7 -0
  64. package/src/experiments/configcat.ts +0 -6
  65. package/src/experiments/types.ts +0 -4
  66. package/src/frontend-dashboard-service.ts +125 -0
  67. package/src/gitpod-service.ts +10 -17
  68. package/src/index.ts +0 -1
  69. package/src/messaging/error.ts +3 -0
  70. package/src/plans.ts +2 -2
  71. package/src/protocol.ts +30 -48
  72. package/src/teams-projects-protocol.ts +8 -2
  73. package/src/typings/globals.ts +4 -1
  74. package/src/usage.ts +14 -0
  75. package/src/util/gitpod-host-url.ts +5 -0
  76. package/src/util/nice-grpc.ts +93 -0
  77. package/src/workspace-cluster.ts +11 -6
  78. package/src/wsready.ts +4 -5
  79. package/lib/email-protocol.d.ts +0 -49
  80. package/lib/email-protocol.d.ts.map +0 -1
  81. package/lib/email-protocol.js +0 -28
  82. package/lib/email-protocol.js.map +0 -1
  83. package/src/email-protocol.ts +0 -65
@@ -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,
@@ -60,7 +59,7 @@ import {
60
59
  import { RemotePageMessage, RemoteTrackMessage, RemoteIdentifyMessage } from "./analytics";
61
60
  import { IDEServer } from "./ide-protocol";
62
61
  import { InstallationAdminSettings, TelemetryData } from "./installation-admin-protocol";
63
- import { ListUsageRequest, ListUsageResponse } from "./usage";
62
+ import { ListUsageRequest, ListUsageResponse, CostCenterJSON } from "./usage";
64
63
  import { SupportedWorkspaceClass } from "./workspace-class";
65
64
  import { BillingMode } from "./billing-mode";
66
65
 
@@ -165,6 +164,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
165
164
  deleteSSHPublicKey(id: string): Promise<void>;
166
165
 
167
166
  // Teams
167
+ getTeam(teamId: string): Promise<Team>;
168
168
  getTeams(): Promise<Team[]>;
169
169
  getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
170
170
  createTeam(name: string): Promise<Team>;
@@ -173,7 +173,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
173
173
  removeTeamMember(teamId: string, userId: string): Promise<void>;
174
174
  getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
175
175
  resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
176
- deleteTeam(teamId: string, userId: string): Promise<void>;
176
+ deleteTeam(teamId: string): Promise<void>;
177
177
 
178
178
  // Admin Settings
179
179
  adminGetSettings(): Promise<InstallationAdminSettings>;
@@ -227,16 +227,6 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
227
227
  */
228
228
  getSnapshots(workspaceID: string): Promise<string[]>;
229
229
 
230
- /**
231
- * stores/updates layout information for the given workspace
232
- */
233
- storeLayout(workspaceId: string, layoutData: string): Promise<void>;
234
-
235
- /**
236
- * retrieves layout information for the given workspace
237
- */
238
- getLayout(workspaceId: string): Promise<string | undefined>;
239
-
240
230
  guessGitTokenScopes(params: GuessGitTokenScopesParams): Promise<GuessedGitTokenScopes>;
241
231
 
242
232
  /**
@@ -288,14 +278,15 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
288
278
  getStripeSetupIntentClientSecret(): Promise<string>;
289
279
  findStripeSubscriptionId(attributionId: string): Promise<string | undefined>;
290
280
  createStripeCustomerIfNeeded(attributionId: string, currency: string): Promise<void>;
291
- subscribeToStripe(attributionId: string, setupIntentId: string): Promise<void>;
281
+ subscribeToStripe(attributionId: string, setupIntentId: string, usageLimit: number): Promise<number | undefined>;
292
282
  getStripePortalUrl(attributionId: string): Promise<string>;
293
- getUsageLimit(attributionId: string): Promise<number | undefined>;
283
+ getCostCenter(attributionId: string): Promise<CostCenterJSON | undefined>;
294
284
  setUsageLimit(attributionId: string, usageLimit: number): Promise<void>;
295
285
 
296
286
  listUsage(req: ListUsageRequest): Promise<ListUsageResponse>;
297
287
 
298
288
  setUsageAttribution(usageAttribution: string): Promise<void>;
289
+ listAvailableUsageAttributionIds(): Promise<string[]>;
299
290
 
300
291
  getBillingModeForUser(): Promise<BillingMode>;
301
292
  getBillingModeForTeam(teamId: string): Promise<BillingMode>;
@@ -430,7 +421,10 @@ export namespace GitpodServer {
430
421
  }
431
422
  export interface CreateWorkspaceOptions {
432
423
  contextUrl: string;
433
- 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;
434
428
  forceDefaultConfig?: boolean;
435
429
  }
436
430
  export interface StartWorkspaceOptions {
@@ -438,7 +432,6 @@ export namespace GitpodServer {
438
432
  }
439
433
  export interface TakeSnapshotOptions {
440
434
  workspaceId: string;
441
- layoutData?: string;
442
435
  /* this is here to enable backwards-compatibility and untangling rollout between workspace, IDE and meta */
443
436
  dontWait?: boolean;
444
437
  }
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";
@@ -41,6 +41,9 @@ export namespace ErrorCodes {
41
41
  // 451 Out of credits
42
42
  export const PAYMENT_SPENDING_LIMIT_REACHED = 451;
43
43
 
44
+ // 451 Error creating a subscription
45
+ export const SUBSCRIPTION_ERROR = 452;
46
+
44
47
  // 455 Invalid cost center (custom status code)
45
48
  export const INVALID_COST_CENTER = 455;
46
49
 
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,
package/src/protocol.ts CHANGED
@@ -8,7 +8,6 @@ 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";
12
11
 
13
12
  export interface UserInfo {
14
13
  name?: string;
@@ -295,9 +294,9 @@ export type BillingTier = "paid" | "free";
295
294
  export const WorkspaceFeatureFlags = {
296
295
  full_workspace_backup: undefined,
297
296
  persistent_volume_claim: undefined,
298
- protected_secrets: undefined,
299
297
  workspace_class_limiting: undefined,
300
298
  workspace_connection_limiting: undefined,
299
+ workspace_psi: undefined,
301
300
  };
302
301
  export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
303
302
  export namespace NamedWorkspaceFeatureFlag {
@@ -471,7 +470,7 @@ export interface UserSSHPublicKey extends SSHPublicKeyValue {
471
470
  lastUsedTime?: string;
472
471
  }
473
472
 
474
- export type UserSSHPublicKeyValue = Omit<UserSSHPublicKey, "key" | "userId">;
473
+ export type UserSSHPublicKeyValue = Omit<UserSSHPublicKey, "userId">;
475
474
 
476
475
  export namespace SSHPublicKeyValue {
477
476
  export function validate(value: SSHPublicKeyValue): string | undefined {
@@ -639,6 +638,7 @@ export interface PendingGithubEvent {
639
638
  creationDate: Date;
640
639
  type: string;
641
640
  event: string;
641
+ deleted: boolean;
642
642
  }
643
643
 
644
644
  export interface Snapshot {
@@ -647,7 +647,6 @@ export interface Snapshot {
647
647
  availableTime?: string;
648
648
  originalWorkspaceId: string;
649
649
  bucketId: string;
650
- layoutData?: string;
651
650
  state: SnapshotState;
652
651
  message?: string;
653
652
  }
@@ -659,14 +658,13 @@ export interface VolumeSnapshot {
659
658
  volumeHandle: string;
660
659
  }
661
660
 
662
- export type SnapshotState = "pending" | "available" | "error";
663
-
664
- export interface LayoutData {
665
- workspaceId: string;
666
- lastUpdatedTime: string;
667
- layoutData: string;
661
+ export interface VolumeSnapshotWithWSType {
662
+ vs: VolumeSnapshot;
663
+ wsType: WorkspaceType;
668
664
  }
669
665
 
666
+ export type SnapshotState = "pending" | "available" | "error";
667
+
670
668
  export interface Workspace {
671
669
  id: string;
672
670
  creationTime: string;
@@ -728,7 +726,7 @@ export interface Workspace {
728
726
 
729
727
  export type WorkspaceSoftDeletion = "user" | "gc";
730
728
 
731
- export type WorkspaceType = "regular" | "prebuild" | "probe"; // TODO(gpl) Removed prove here
729
+ export type WorkspaceType = "regular" | "prebuild";
732
730
 
733
731
  export namespace Workspace {
734
732
  export function getFullRepositoryName(ws: Workspace): string | undefined {
@@ -801,6 +799,10 @@ export interface JetBrainsConfig {
801
799
  goland?: JetBrainsProductConfig;
802
800
  pycharm?: JetBrainsProductConfig;
803
801
  phpstorm?: JetBrainsProductConfig;
802
+ rubymine?: JetBrainsProductConfig;
803
+ webstorm?: JetBrainsProductConfig;
804
+ rider?: JetBrainsProductConfig;
805
+ clion?: JetBrainsProductConfig;
804
806
  }
805
807
  export interface JetBrainsProductConfig {
806
808
  prebuilds?: JetBrainsPrebuilds;
@@ -1115,13 +1117,16 @@ export namespace SnapshotContext {
1115
1117
  }
1116
1118
  }
1117
1119
 
1118
- export interface StartPrebuildContext extends WorkspaceContext {
1119
- actual: WorkspaceContext;
1120
+ export interface WithCommitHistory {
1120
1121
  commitHistory?: string[];
1121
1122
  additionalRepositoryCommitHistories?: {
1122
1123
  cloneUrl: string;
1123
1124
  commitHistory: string[];
1124
1125
  }[];
1126
+ }
1127
+
1128
+ export interface StartPrebuildContext extends WorkspaceContext, WithCommitHistory {
1129
+ actual: WorkspaceContext;
1125
1130
  project?: Project;
1126
1131
  branch?: string;
1127
1132
  }
@@ -1165,17 +1170,6 @@ export namespace WithEnvvarsContext {
1165
1170
  }
1166
1171
  }
1167
1172
 
1168
- export interface WorkspaceProbeContext extends WorkspaceContext {
1169
- responseURL: string;
1170
- responseToken: string;
1171
- }
1172
-
1173
- export namespace WorkspaceProbeContext {
1174
- export function is(context: any): context is WorkspaceProbeContext {
1175
- return context && "responseURL" in context && "responseToken" in context;
1176
- }
1177
- }
1178
-
1179
1173
  export type RefType = "branch" | "tag" | "revision";
1180
1174
  export namespace RefType {
1181
1175
  export const getRefType = (commit: Commit): RefType => {
@@ -1215,6 +1209,16 @@ export namespace AdditionalContentContext {
1215
1209
  }
1216
1210
  }
1217
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
+
1218
1222
  export interface CommitContext extends WorkspaceContext, GitCheckoutInfo {
1219
1223
  /** @deprecated Moved to .repository.cloneUrl, left here for backwards-compatibility for old workspace contextes in the DB */
1220
1224
  cloneUrl?: string;
@@ -1378,17 +1382,6 @@ export interface WorkspaceCreationResult {
1378
1382
  }
1379
1383
  export type RunningWorkspacePrebuildStarting = "queued" | "starting" | "running";
1380
1384
 
1381
- export enum CreateWorkspaceMode {
1382
- // Default returns a running prebuild if there is any, otherwise creates a new workspace (using a prebuild if one is available)
1383
- Default = "default",
1384
- // 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.
1385
- ForceNew = "force-new",
1386
- // UsePrebuild polls the database waiting for a currently running prebuild to become available. This mode exists to handle the db-sync delay.
1387
- UsePrebuild = "use-prebuild",
1388
- // SelectIfRunning returns a list of currently running workspaces for the context URL if there are any, otherwise falls back to Default mode
1389
- SelectIfRunning = "select-if-running",
1390
- }
1391
-
1392
1385
  export namespace WorkspaceCreationResult {
1393
1386
  export function is(data: any): data is WorkspaceCreationResult {
1394
1387
  return (
@@ -1523,17 +1516,6 @@ export interface Terms {
1523
1516
  }
1524
1517
 
1525
1518
  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;
1519
+ individualUsagePriceIds: { [currency: string]: string };
1520
+ teamUsagePriceIds: { [currency: string]: string };
1539
1521
  }
@@ -4,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { PrebuiltWorkspaceState } from "./protocol";
7
+ import { PrebuiltWorkspaceState, WorkspaceClasses } from "./protocol";
8
8
  import { v4 as uuidv4 } from "uuid";
9
9
  import { DeepPartial } from "./util/deep-partial";
10
10
  import { WebhookEvent } from "./webhook-event";
@@ -17,6 +17,12 @@ export interface ProjectSettings {
17
17
  useIncrementalPrebuilds?: boolean;
18
18
  usePersistentVolumeClaim?: boolean;
19
19
  keepOutdatedPrebuildsRunning?: boolean;
20
+ // whether new workspaces can start on older prebuilds and incrementally update
21
+ allowUsingPreviousPrebuilds?: boolean;
22
+ // how many commits in the commit history a prebuild is good (undefined and 0 means every commit is prebuilt)
23
+ prebuildEveryNthCommit?: number;
24
+ // preferred workspace classes
25
+ workspaceClasses?: WorkspaceClasses;
20
26
  }
21
27
 
22
28
  export interface Project {
@@ -45,6 +51,7 @@ export namespace Project {
45
51
 
46
52
  export interface Overview {
47
53
  branches: BranchDetails[];
54
+ isConsideredInactive?: boolean;
48
55
  }
49
56
 
50
57
  export namespace Overview {
@@ -119,7 +126,6 @@ export interface StartPrebuildResult {
119
126
  wsid: string;
120
127
  done: boolean;
121
128
  }
122
-
123
129
  export interface Team {
124
130
  id: string;
125
131
  name: string;
@@ -5,8 +5,11 @@
5
5
  */
6
6
 
7
7
  interface Window {
8
+ // gitpod is used by supervisor/frontend and vscode browser https://github.com/gitpod-io/openvscode-server/blob/dadd40deda5959c0efdaa0c7d02ab64b6f8b5ad0/src/vs/gitpod/browser/workbench/workbench.ts#L7
8
9
  gitpod: {
9
- service: import("../gitpod-service").GitpodService;
10
10
  ideService?: import("../ide-frontend-service").IDEFrontendService;
11
+ loggedUserID?: string;
12
+
13
+ openDesktopIDE(url: string): void;
11
14
  };
12
15
  }
package/src/usage.ts CHANGED
@@ -69,3 +69,17 @@ export interface InvoiceUsageData {
69
69
  startDate: string;
70
70
  endDate: string;
71
71
  }
72
+
73
+ export interface CostCenterJSON {
74
+ attributionId: string;
75
+ spendingLimit: number;
76
+ billingStrategy: CostCenter_BillingStrategy;
77
+ nextBillingTime?: string;
78
+ billingCycleStart?: string;
79
+ }
80
+
81
+ export enum CostCenter_BillingStrategy {
82
+ BILLING_STRATEGY_STRIPE = "BILLING_STRATEGY_STRIPE",
83
+ BILLING_STRATEGY_OTHER = "BILLING_STRATEGY_OTHER",
84
+ UNRECOGNIZED = "UNRECOGNIZED",
85
+ }
@@ -155,6 +155,11 @@ export class GitpodHostUrl {
155
155
  return pathSegs[2];
156
156
  }
157
157
 
158
+ const cleanHash = this.url.hash.replace(/^#/, "");
159
+ if (this.url.pathname == "/start/" && cleanHash.match(workspaceIDRegex)) {
160
+ return cleanHash;
161
+ }
162
+
158
163
  return undefined;
159
164
  }
160
165
 
@@ -0,0 +1,93 @@
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 { isAbortError } from "abort-controller-x";
8
+ import {
9
+ CallOptions,
10
+ ClientError,
11
+ ClientMiddleware,
12
+ ClientMiddlewareCall,
13
+ Status,
14
+ MethodDescriptor,
15
+ } from "nice-grpc-common";
16
+ import { GrpcMethodType, IClientCallMetrics } from "./grpc";
17
+
18
+ function getLabels(method: MethodDescriptor) {
19
+ const callType = method.requestStream
20
+ ? method.responseStream
21
+ ? "bidi_stream"
22
+ : "client_stream"
23
+ : method.responseStream
24
+ ? "server_stream"
25
+ : "unary";
26
+ const { path } = method;
27
+ const [serviceName, methodName] = path.split("/").slice(1);
28
+
29
+ return {
30
+ type: callType as GrpcMethodType,
31
+ service: serviceName,
32
+ method: methodName,
33
+ };
34
+ }
35
+
36
+ async function* incrementStreamMessagesCounter<T>(iterable: AsyncIterable<T>, callback: () => void): AsyncIterable<T> {
37
+ for await (const item of iterable) {
38
+ callback();
39
+ yield item;
40
+ }
41
+ }
42
+
43
+ export function prometheusClientMiddleware(metrics: IClientCallMetrics): ClientMiddleware {
44
+ return async function* prometheusClientMiddlewareGenerator<Request, Response>(
45
+ call: ClientMiddlewareCall<Request, Response>,
46
+ options: CallOptions,
47
+ ): AsyncGenerator<Response, Response | void, undefined> {
48
+ const labels = getLabels(call.method);
49
+
50
+ metrics.started(labels);
51
+
52
+ let settled = false;
53
+ let status: Status = Status.OK;
54
+
55
+ try {
56
+ let request;
57
+
58
+ if (!call.requestStream) {
59
+ request = call.request;
60
+ } else {
61
+ request = incrementStreamMessagesCounter(call.request, metrics.sent.bind(metrics, labels));
62
+ }
63
+
64
+ if (!call.responseStream) {
65
+ const response = yield* call.next(request, options);
66
+ settled = true;
67
+ return response;
68
+ } else {
69
+ yield* incrementStreamMessagesCounter(
70
+ call.next(request, options),
71
+ metrics.received.bind(metrics, labels),
72
+ );
73
+ settled = true;
74
+ return;
75
+ }
76
+ } catch (err) {
77
+ settled = true;
78
+ if (err instanceof ClientError) {
79
+ status = err.code;
80
+ } else if (isAbortError(err)) {
81
+ status = Status.CANCELLED;
82
+ } else {
83
+ status = Status.UNKNOWN;
84
+ }
85
+ throw err;
86
+ } finally {
87
+ if (!settled) {
88
+ status = Status.CANCELLED;
89
+ }
90
+ metrics.handled({ ...labels, code: Status[status] });
91
+ }
92
+ };
93
+ }
@@ -15,6 +15,10 @@ export interface WorkspaceCluster {
15
15
  // Must be identical to the installationShortname of the cluster it represents!
16
16
  name: string;
17
17
 
18
+ // The name of the application cluster to which this cluster should be registered.
19
+ // The name can be at most 60 characters.
20
+ applicationCluster: string;
21
+
18
22
  // URL of the cluster's ws-manager API
19
23
  url: string;
20
24
 
@@ -86,20 +90,21 @@ export interface WorkspaceClusterDB {
86
90
  * Deletes the cluster identified by this name, if any.
87
91
  * @param name
88
92
  */
89
- deleteByName(name: string): Promise<void>;
93
+ deleteByName(name: string, applicationCluster: string): Promise<void>;
90
94
 
91
95
  /**
92
96
  * Finds a WorkspaceCluster with the given name. If there is none, `undefined` is returned.
93
97
  * @param name
94
98
  */
95
- findByName(name: string): Promise<WorkspaceCluster | undefined>;
99
+ findByName(name: string, applicationCluster: string): Promise<WorkspaceCluster | undefined>;
96
100
 
97
101
  /**
98
102
  * Lists all WorkspaceClusterWoTls for which the given predicate is true (does not return TLS for size/speed concerns)
99
103
  * @param predicate
100
104
  */
101
- findFiltered(predicate: DeepPartial<WorkspaceClusterFilter>): Promise<WorkspaceClusterWoTLS[]>;
102
- }
103
- export interface WorkspaceClusterFilter extends Pick<WorkspaceCluster, "state" | "govern" | "url"> {
104
- minScore: number;
105
+ findFiltered(predicate: WorkspaceClusterFilter): Promise<WorkspaceClusterWoTLS[]>;
105
106
  }
107
+
108
+ export type WorkspaceClusterFilter = Pick<WorkspaceCluster, "applicationCluster"> &
109
+ DeepPartial<Pick<WorkspaceCluster, "name" | "state" | "govern" | "url">> &
110
+ Partial<{ minScore: number }>;
package/src/wsready.ts CHANGED
@@ -4,15 +4,14 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- // generated using github.com/32leaves/bel on 2022-07-21 07:41:48.081573085 +0000 UTC m=+0.009109470
7
+ // generated using github.com/32leaves/bel on 2022-10-10 21:41:56.018177383 +0000 UTC m=+0.010324839
8
8
  // DO NOT MODIFY
9
9
 
10
- export interface WorkspaceReadyMessage {
11
- source: WorkspaceInitSource;
12
- }
13
-
14
10
  export enum WorkspaceInitSource {
15
11
  WorkspaceInitFromBackup = "from-backup",
16
12
  WorkspaceInitFromPrebuild = "from-prebuild",
17
13
  WorkspaceInitFromOther = "from-other",
18
14
  }
15
+ export interface WorkspaceReadyMessage {
16
+ source: WorkspaceInitSource;
17
+ }
@@ -1,49 +0,0 @@
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
- export declare type EMailState = "scheduledInternal" | "scheduledSendgrid";
7
- export interface EMailStatus {
8
- /** The time the email entry was inserted into the DB */
9
- scheduledInternalTime: string;
10
- /** The time the email state transitioned to "scheduledSendgrid" */
11
- scheduledSendgridTime?: string;
12
- /** In case of any errors during sending with Sendgrid it gets noted here */
13
- error?: string;
14
- }
15
- export declare namespace EMailStatus {
16
- function getState(status: EMailStatus): EMailState;
17
- }
18
- export interface EmailAddress {
19
- name?: string;
20
- email: string;
21
- }
22
- export interface EMailParameters {
23
- /** undefined means default from template */
24
- subject?: string;
25
- /** The sender address */
26
- senderAddress: string | EmailAddress;
27
- /** The replyTo address */
28
- replyToAddress?: string | EmailAddress;
29
- /** The SendGrid template id */
30
- templateId: string;
31
- /** The parameters for the SendGrid template */
32
- templateParams: {};
33
- }
34
- export declare type EMail = {
35
- /** The unique id of this email (uuid/v4 for now) */
36
- uid: string;
37
- /** The id of the user this email was sent to */
38
- userId: string;
39
- /** The address this email was sent to */
40
- recipientAddress: string;
41
- /** Which campaign scheduled this email */
42
- campaignId: string;
43
- /** The parameters this email was sent with (template id, template params, etc) */
44
- params: EMailParameters;
45
- } & EMailStatus;
46
- export declare namespace EMail {
47
- const create: (ts: Omit<EMail, "uid">) => EMail;
48
- }
49
- //# sourceMappingURL=email-protocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"email-protocol.d.ts","sourceRoot":"","sources":["../src/email-protocol.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,oBAAY,UAAU,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAEnE,MAAM,WAAW,WAAW;IACxB,wDAAwD;IACxD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mEAAmE;IACnE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,yBAAiB,WAAW,CAAC;IACzB,SAAgB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAKxD;CACJ;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC5B,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yBAAyB;IACzB,aAAa,EAAE,MAAM,GAAG,YAAY,CAAC;IACrC,0BAA0B;IAC1B,cAAc,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IACvC,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,+CAA+C;IAC/C,cAAc,EAAE,EAAE,CAAC;CACtB;AAED,oBAAY,KAAK,GAAG;IAChB,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,MAAM,EAAE,eAAe,CAAC;CAC3B,GAAG,WAAW,CAAC;AAEhB,yBAAiB,KAAK,CAAC;IACZ,MAAM,MAAM,OAAQ,KAAK,KAAK,EAAE,KAAK,CAAC,KAAG,KAI/C,CAAC;CACL"}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
4
- * Licensed under the GNU Affero General Public License (AGPL).
5
- * See License-AGPL.txt in the project root for license information.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.EMail = exports.EMailStatus = void 0;
9
- const uuid_1 = require("uuid");
10
- var EMailStatus;
11
- (function (EMailStatus) {
12
- function getState(status) {
13
- if (status.scheduledSendgridTime) {
14
- return "scheduledSendgrid";
15
- }
16
- return "scheduledInternal";
17
- }
18
- EMailStatus.getState = getState;
19
- })(EMailStatus = exports.EMailStatus || (exports.EMailStatus = {}));
20
- var EMail;
21
- (function (EMail) {
22
- EMail.create = (ts) => {
23
- const withId = ts;
24
- withId.uid = (0, uuid_1.v4)();
25
- return withId;
26
- };
27
- })(EMail = exports.EMail || (exports.EMail = {}));
28
- //# sourceMappingURL=email-protocol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"email-protocol.js","sourceRoot":"","sources":["../src/email-protocol.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,+BAAoC;AAYpC,IAAiB,WAAW,CAO3B;AAPD,WAAiB,WAAW;IACxB,SAAgB,QAAQ,CAAC,MAAmB;QACxC,IAAI,MAAM,CAAC,qBAAqB,EAAE;YAC9B,OAAO,mBAAmB,CAAC;SAC9B;QACD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IALe,oBAAQ,WAKvB,CAAA;AACL,CAAC,EAPgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAO3B;AAiCD,IAAiB,KAAK,CAMrB;AAND,WAAiB,KAAK;IACL,YAAM,GAAG,CAAC,EAAsB,EAAS,EAAE;QACpD,MAAM,MAAM,GAAG,EAAW,CAAC;QAC3B,MAAM,CAAC,GAAG,GAAG,IAAA,SAAM,GAAE,CAAC;QACtB,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;AACN,CAAC,EANgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAMrB"}