@gitpod/gitpod-protocol 0.1.5-se-external-config.13 → 0.1.5-se-workspace-for-teams.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 (137) hide show
  1. package/data/gitpod-schema.json +4 -22
  2. package/lib/accounting-protocol.d.ts +3 -5
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +0 -5
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +1 -2
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js.map +1 -1
  9. package/lib/analytics.d.ts +33 -0
  10. package/lib/analytics.d.ts.map +1 -0
  11. package/lib/{util/without.js → analytics.js} +4 -2
  12. package/lib/analytics.js.map +1 -0
  13. package/lib/context-url.d.ts +18 -0
  14. package/lib/context-url.d.ts.map +1 -0
  15. package/lib/context-url.js +49 -0
  16. package/lib/context-url.js.map +1 -0
  17. package/lib/{util/context-url.spec.d.ts → context-url.spec.d.ts} +2 -0
  18. package/lib/context-url.spec.d.ts.map +1 -0
  19. package/lib/{util/context-url.spec.js → context-url.spec.js} +26 -2
  20. package/lib/context-url.spec.js.map +1 -0
  21. package/lib/email-protocol.d.ts +1 -2
  22. package/lib/email-protocol.d.ts.map +1 -1
  23. package/lib/email-protocol.js.map +1 -1
  24. package/lib/env.d.ts +1 -1
  25. package/lib/env.d.ts.map +1 -1
  26. package/lib/env.js +10 -9
  27. package/lib/env.js.map +1 -1
  28. package/lib/gitpod-service.d.ts +65 -5
  29. package/lib/gitpod-service.d.ts.map +1 -1
  30. package/lib/gitpod-service.js +7 -6
  31. package/lib/gitpod-service.js.map +1 -1
  32. package/lib/headless-workspace-log.d.ts +8 -11
  33. package/lib/headless-workspace-log.d.ts.map +1 -1
  34. package/lib/headless-workspace-log.js +4 -7
  35. package/lib/headless-workspace-log.js.map +1 -1
  36. package/lib/index.d.ts +2 -0
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/index.js +2 -0
  39. package/lib/index.js.map +1 -1
  40. package/lib/messaging/client-call-metrics.d.ts +35 -0
  41. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  42. package/lib/messaging/client-call-metrics.js +84 -0
  43. package/lib/messaging/client-call-metrics.js.map +1 -0
  44. package/lib/messaging/error.d.ts +1 -0
  45. package/lib/messaging/error.d.ts.map +1 -1
  46. package/lib/messaging/error.js +2 -0
  47. package/lib/messaging/error.js.map +1 -1
  48. package/lib/messaging/node/connection.js +2 -2
  49. package/lib/messaging/node/connection.js.map +1 -1
  50. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  51. package/lib/messaging/proxy-factory.js +3 -1
  52. package/lib/messaging/proxy-factory.js.map +1 -1
  53. package/lib/permission.d.ts +2 -1
  54. package/lib/permission.d.ts.map +1 -1
  55. package/lib/permission.js +1 -0
  56. package/lib/permission.js.map +1 -1
  57. package/lib/protocol.d.ts +41 -24
  58. package/lib/protocol.d.ts.map +1 -1
  59. package/lib/protocol.js +18 -1
  60. package/lib/protocol.js.map +1 -1
  61. package/lib/team-subscription-protocol.d.ts +3 -3
  62. package/lib/team-subscription-protocol.d.ts.map +1 -1
  63. package/lib/team-subscription-protocol.js +3 -0
  64. package/lib/team-subscription-protocol.js.map +1 -1
  65. package/lib/teams-projects-protocol.d.ts +100 -0
  66. package/lib/teams-projects-protocol.d.ts.map +1 -0
  67. package/lib/teams-projects-protocol.js +34 -0
  68. package/lib/teams-projects-protocol.js.map +1 -0
  69. package/lib/util/analytics.d.ts +1 -26
  70. package/lib/util/analytics.d.ts.map +1 -1
  71. package/lib/util/analytics.js +1 -2
  72. package/lib/util/analytics.js.map +1 -1
  73. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  74. package/lib/util/generate-workspace-id.js +1 -0
  75. package/lib/util/generate-workspace-id.js.map +1 -1
  76. package/lib/util/gitpod-host-url.js +1 -1
  77. package/lib/util/gitpod-host-url.js.map +1 -1
  78. package/lib/util/gitpod-host-url.spec.d.ts +5 -0
  79. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  80. package/lib/util/gitpod-host-url.spec.js +70 -0
  81. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  82. package/lib/util/grpc.d.ts +15 -0
  83. package/lib/util/grpc.d.ts.map +1 -0
  84. package/lib/util/grpc.js +18 -0
  85. package/lib/util/grpc.js.map +1 -0
  86. package/lib/util/logging.d.ts +17 -1
  87. package/lib/util/logging.d.ts.map +1 -1
  88. package/lib/util/logging.js +66 -28
  89. package/lib/util/logging.js.map +1 -1
  90. package/lib/workspace-cluster.d.ts +1 -2
  91. package/lib/workspace-cluster.d.ts.map +1 -1
  92. package/lib/workspace-cluster.js.map +1 -1
  93. package/lib/workspace-instance.d.ts +1 -0
  94. package/lib/workspace-instance.d.ts.map +1 -1
  95. package/lib/wsready.js +1 -1
  96. package/lib/wsready.js.map +1 -1
  97. package/package.json +9 -6
  98. package/pkg-yarn.lock +6 -4
  99. package/src/accounting-protocol.ts +3 -7
  100. package/src/admin-protocol.ts +1 -2
  101. package/src/analytics.ts +39 -0
  102. package/src/context-url.spec.ts +39 -0
  103. package/src/context-url.ts +51 -0
  104. package/src/email-protocol.ts +1 -2
  105. package/src/env.ts +10 -9
  106. package/src/gitpod-service.ts +80 -12
  107. package/src/headless-workspace-log.ts +7 -11
  108. package/src/index.ts +2 -0
  109. package/src/messaging/client-call-metrics.ts +97 -0
  110. package/src/messaging/error.ts +3 -0
  111. package/src/messaging/node/connection.ts +2 -2
  112. package/src/messaging/proxy-factory.ts +3 -1
  113. package/src/permission.ts +1 -0
  114. package/src/protocol.ts +58 -29
  115. package/src/team-subscription-protocol.ts +5 -3
  116. package/src/teams-projects-protocol.ts +129 -0
  117. package/src/util/analytics.ts +1 -30
  118. package/src/util/generate-workspace-id.ts +1 -0
  119. package/src/util/gitpod-host-url.spec.ts +20 -0
  120. package/src/util/gitpod-host-url.ts +1 -1
  121. package/src/util/grpc.ts +15 -0
  122. package/src/util/logging.ts +64 -13
  123. package/src/workspace-cluster.ts +1 -2
  124. package/src/workspace-instance.ts +13 -7
  125. package/src/wsready.ts +1 -1
  126. package/lib/util/context-url.d.ts +0 -13
  127. package/lib/util/context-url.d.ts.map +0 -1
  128. package/lib/util/context-url.js +0 -26
  129. package/lib/util/context-url.js.map +0 -1
  130. package/lib/util/context-url.spec.d.ts.map +0 -1
  131. package/lib/util/context-url.spec.js.map +0 -1
  132. package/lib/util/without.d.ts +0 -7
  133. package/lib/util/without.d.ts.map +0 -1
  134. package/lib/util/without.js.map +0 -1
  135. package/src/util/context-url.spec.ts +0 -25
  136. package/src/util/context-url.ts +0 -23
  137. package/src/util/without.ts +0 -8
package/lib/wsready.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.WorkspaceInitSource = void 0;
9
- // generated using github.com/32leaves/bel on 2021-06-09 13:14:02.32194335 +0000 UTC m=+0.009503424
9
+ // generated using github.com/32leaves/bel on 2021-08-03 10:42:32.582603295 +0000 UTC m=+0.005734479
10
10
  // DO NOT MODIFY
11
11
  var WorkspaceInitSource;
12
12
  (function (WorkspaceInitSource) {
@@ -1 +1 @@
1
- {"version":3,"file":"wsready.js","sourceRoot":"","sources":["../src/wsready.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mGAAmG;AACnG,gBAAgB;AAEhB,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC3B,8DAAuC,CAAA;IACvC,kEAA2C,CAAA;IAC3C,4DAAqC,CAAA;AACzC,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B"}
1
+ {"version":3,"file":"wsready.js","sourceRoot":"","sources":["../src/wsready.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,oGAAoG;AACpG,gBAAgB;AAEhB,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC3B,8DAAuC,CAAA;IACvC,kEAA2C,CAAA;IAC3C,4DAAqC,CAAA;AACzC,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B"}
package/package.json CHANGED
@@ -6,19 +6,22 @@
6
6
  "jaeger-client": "3.17.2",
7
7
  "js-yaml": "^3.10.0",
8
8
  "opentracing": "^0.14.4",
9
- "prom-client": "^10.2.0",
9
+ "prom-client": "^13.2.0",
10
10
  "random-number-csprng": "^1.0.2",
11
- "reconnecting-websocket": "^4.2.0",
11
+ "reconnecting-websocket": "^4.4.0",
12
12
  "reflect-metadata": "^0.1.10",
13
13
  "uuid": "^3.3.3",
14
+ "vscode-jsonrpc": "^5.0.1",
15
+ "vscode-languageserver-protocol": "3.15.3",
14
16
  "vscode-uri": "^1.0.1",
15
17
  "vscode-ws-jsonrpc": "^0.2.0",
16
- "ws": "^5.2.2"
18
+ "ws": "^7.4.6"
17
19
  },
18
20
  "devDependencies": {
19
21
  "@types/analytics-node": "^3.1.4",
20
22
  "@types/chai-subset": "^1.3.1",
21
23
  "@types/js-yaml": "^3.10.1",
24
+ "@types/mocha": "^5.2.7",
22
25
  "@types/random-number-csprng": "^1.0.0",
23
26
  "@types/uuid": "^3.4.5",
24
27
  "@types/ws": "^5.1.2",
@@ -29,7 +32,7 @@
29
32
  "rimraf": "^2.6.2",
30
33
  "ts-node": "^9.0.0",
31
34
  "typescript": "~4.1.2",
32
- "typescript-json-schema": "^0.43.0",
35
+ "typescript-json-schema": "^0.50.1",
33
36
  "typescript-parser": "^2.6.1"
34
37
  },
35
38
  "files": [
@@ -45,9 +48,9 @@
45
48
  "build": "tsc",
46
49
  "clean": "rimraf lib",
47
50
  "prepare": "yarn run clean && yarn run build",
48
- "test": "mocha --opts mocha.opts '**/*.spec.ts'",
51
+ "test": "mocha --opts mocha.opts './**/*.spec.ts' --exclude './node_modules/**'",
49
52
  "watch": "leeway exec --package .:lib --transitive-dependencies --filter-type yarn --components --parallel -- tsc -w --preserveWatchOutput"
50
53
  },
51
54
  "types": "./lib/index.d.ts",
52
- "version": "0.1.5-se-external-config.13"
55
+ "version": "0.1.5-se-workspace-for-teams.5"
53
56
  }
package/pkg-yarn.lock CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  "@gitpod/gitpod-protocol@0.1.5":
6
6
  version "0.1.5"
7
- resolved "file:///tmp/cache/dc30594bc8e7acf833a60875a372fc93952f3ab6.tar.gz"
7
+ resolved "file:///tmp/cache/546be1ec8ab4c413a119c49a2a3ebe96936f599e.tar.gz"
8
8
  dependencies:
9
9
  ajv "^6.5.4"
10
10
  analytics-node "^4.0.1"
@@ -12,12 +12,14 @@
12
12
  jaeger-client "3.17.2"
13
13
  js-yaml "^3.10.0"
14
14
  opentracing "^0.14.4"
15
- prom-client "^10.2.0"
15
+ prom-client "^13.2.0"
16
16
  random-number-csprng "^1.0.2"
17
- reconnecting-websocket "^4.2.0"
17
+ reconnecting-websocket "^4.4.0"
18
18
  reflect-metadata "^0.1.10"
19
19
  uuid "^3.3.3"
20
+ vscode-jsonrpc "^5.0.1"
21
+ vscode-languageserver-protocol "3.15.3"
20
22
  vscode-uri "^1.0.1"
21
23
  vscode-ws-jsonrpc "^0.2.0"
22
- ws "^5.2.2"
24
+ ws "^7.4.6"
23
25
 
@@ -5,7 +5,6 @@
5
5
  */
6
6
 
7
7
  import * as uuidv4 from 'uuid/v4';
8
- import { Without } from "./util/without";
9
8
  import { User } from './protocol';
10
9
  import { oneMonthLater } from './util/timeutil';
11
10
 
@@ -47,7 +46,7 @@ export interface AccountEntry {
47
46
  description?: object;
48
47
  }
49
48
  export namespace AccountEntry {
50
- export function create<T extends AccountEntry>(entry: Without<T, 'uid'>): T {
49
+ export function create<T extends AccountEntry>(entry: Omit<T, 'uid'>): T {
51
50
  const result = entry as T;
52
51
  result.uid = uuidv4();
53
52
  return result;
@@ -164,7 +163,7 @@ export namespace AssignedTeamSubscription {
164
163
  }
165
164
 
166
165
  export namespace Subscription {
167
- export function create(newSubscription: Without<Subscription, 'uid'>) {
166
+ export function create(newSubscription: Omit<Subscription, 'uid'>) {
168
167
  const subscription = newSubscription as Subscription;
169
168
  subscription.uid = uuidv4();
170
169
  return subscription;
@@ -193,9 +192,6 @@ export namespace Subscription {
193
192
  export function isDowngraded(s: Subscription) {
194
193
  return s.paymentData && s.paymentData.downgradeDate;
195
194
  };
196
- export function isCancelled(s: Subscription) {
197
- return !!s.cancellationDate;
198
- };
199
195
  export function calculateCurrentPeriod(startDate: string, now: Date) {
200
196
  let nextStartDate = startDate;
201
197
  do {
@@ -215,7 +211,7 @@ export interface Period {
215
211
 
216
212
  export type MaybePeriod = Period | undefined;
217
213
 
218
- export type AccountEntryFixedPeriod = Without<AccountEntry, 'uid'> & { expiryDate: string };
214
+ export type AccountEntryFixedPeriod = Omit<AccountEntry, 'uid'> & { expiryDate: string };
219
215
  export interface AccountStatement extends Period {
220
216
  userId: string;
221
217
  /**
@@ -5,7 +5,6 @@
5
5
  */
6
6
 
7
7
  import { User, Workspace, NamedWorkspaceFeatureFlag } from "./protocol";
8
- import { Without } from "./util/without";
9
8
  import { WorkspaceInstance, WorkspaceInstancePhase } from "./workspace-instance";
10
9
  import { RoleOrPermission } from "./permission";
11
10
  import { AccountStatement } from "./accounting-protocol";
@@ -66,7 +65,7 @@ export interface AdminModifyPermanentWorkspaceFeatureFlagRequest {
66
65
  }[]
67
66
  }
68
67
 
69
- export interface WorkspaceAndInstance extends Without<Workspace, "id"|"creationTime">, Without<WorkspaceInstance, "id"|"creationTime"> {
68
+ export interface WorkspaceAndInstance extends Omit<Workspace, "id"|"creationTime">, Omit<WorkspaceInstance, "id"|"creationTime"> {
70
69
  workspaceId: string;
71
70
  workspaceCreationTime: string;
72
71
  instanceId: string;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) 2021 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
+
8
+ export const IAnalyticsWriter = Symbol("IAnalyticsWriter");
9
+
10
+ type Identity =
11
+ | { userId: string | number }
12
+ | { userId?: string | number; anonymousId: string | number };
13
+
14
+ interface Message {
15
+ messageId?: string;
16
+ }
17
+
18
+ export type IdentifyMessage = Message & Identity & {
19
+ traits?: any;
20
+ timestamp?: Date;
21
+ context?: any;
22
+ };
23
+
24
+ export type TrackMessage = Message & Identity & {
25
+ event: string;
26
+ properties?: any;
27
+ timestamp?: Date;
28
+ context?: any;
29
+ };
30
+
31
+ export type RemoteTrackMessage = Omit<TrackMessage, "timestamp" | "userId" | "anonymousId">;
32
+
33
+ export interface IAnalyticsWriter {
34
+
35
+ identify(msg: IdentifyMessage): void;
36
+
37
+ track(msg: TrackMessage): void;
38
+
39
+ }
@@ -0,0 +1,39 @@
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 * as chai from 'chai';
8
+ import { suite, test } from 'mocha-typescript';
9
+ import { ContextURL } from './context-url';
10
+ const expect = chai.expect;
11
+
12
+ @suite
13
+ export class ContextUrlTest {
14
+
15
+ @test public parseContextUrl_withEnvVar() {
16
+ const actual = ContextURL.parseToURL("passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo");
17
+ expect(actual?.host).to.equal("github.com");
18
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
19
+ }
20
+
21
+ @test public parseContextUrl_withEnvVar_withoutSchema() {
22
+ const actual = ContextURL.parseToURL("passedin=test%20value/github.com/gitpod-io/gitpod-test-repo");
23
+ expect(actual?.host).to.equal("github.com");
24
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
25
+ }
26
+
27
+ @test public parseContextUrl_withPrebuild() {
28
+ const actual = ContextURL.parseToURL("prebuild/https://github.com/gitpod-io/gitpod-test-repo");
29
+ expect(actual?.host).to.equal("github.com");
30
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
31
+ }
32
+
33
+ @test public parseContextUrl_withPrebuild_withoutSchema() {
34
+ const actual = ContextURL.parseToURL("prebuild/github.com/gitpod-io/gitpod-test-repo");
35
+ expect(actual?.host).to.equal("github.com");
36
+ expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
37
+ }
38
+ }
39
+ module.exports = new ContextUrlTest()
@@ -0,0 +1,51 @@
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
+ export namespace ContextURL {
8
+ export const INCREMENTAL_PREBUILD_PREFIX = "incremental-prebuild";
9
+ export const PREBUILD_PREFIX = "prebuild";
10
+ export const IMAGEBUILD_PREFIX = "imagebuild";
11
+
12
+ /**
13
+ * The field "contextUrl" might contain prefixes like:
14
+ * - envvar1=value1/...
15
+ * - prebuild/...
16
+ * This is the analogon to the (Prefix)ContextParser structure in "server".
17
+ */
18
+ export function parseToURL(contextUrl: string | undefined): URL | undefined {
19
+ if (contextUrl === undefined) {
20
+ return undefined;
21
+ }
22
+
23
+ const segments = contextUrl.split("/");
24
+ if (segments.length === 1) {
25
+ return new URL(segments[0]); // this might be something, we just try
26
+ }
27
+
28
+ const segmentsToURL = (offset: number): URL => {
29
+ let rest = segments.slice(offset).join("/");
30
+ if (!rest.startsWith("http")) {
31
+ rest = 'https://' + rest;
32
+ }
33
+ return new URL(rest);
34
+ };
35
+
36
+
37
+ const firstSegment = segments[0];
38
+ if (firstSegment === PREBUILD_PREFIX ||
39
+ firstSegment === INCREMENTAL_PREBUILD_PREFIX ||
40
+ firstSegment === IMAGEBUILD_PREFIX) {
41
+ return segmentsToURL(1);
42
+ }
43
+
44
+ // check for env vars
45
+ if (firstSegment.indexOf("=") !== -1) {
46
+ return segmentsToURL(1);
47
+ }
48
+
49
+ return segmentsToURL(0);
50
+ }
51
+ }
@@ -4,7 +4,6 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { Without } from "./util/without";
8
7
  import uuidv4 = require("uuid/v4");
9
8
 
10
9
  export type EMailState = "scheduledInternal"
@@ -59,7 +58,7 @@ export type EMail = {
59
58
  } & EMailStatus;
60
59
 
61
60
  export namespace EMail {
62
- export const create = (ts: Without<EMail, 'uid'>): EMail => {
61
+ export const create = (ts: Omit<EMail, 'uid'>): EMail => {
63
62
  const withId = ts as EMail;
64
63
  withId.uid = uuidv4();
65
64
  return withId;
package/src/env.ts CHANGED
@@ -13,18 +13,19 @@ const legacyStagenameTranslation: { [key: string]: KubeStage } = {
13
13
  "dev": "dev"
14
14
  }
15
15
 
16
+ export function translateLegacyStagename(kubeStage: string): KubeStage {
17
+ const stage = legacyStagenameTranslation[kubeStage];
18
+ if (!stage) {
19
+ throw new Error(`Invalid KUBE_STAGE: ${kubeStage}`);
20
+ }
21
+
22
+ return stage;
23
+ }
24
+
16
25
  @injectable()
17
26
  export abstract class AbstractComponentEnv {
18
- readonly kubeStage: KubeStage = getEnvVarParsed('KUBE_STAGE', (kubeStage) => {
19
- const stage = legacyStagenameTranslation[kubeStage];
20
- if (!stage) {
21
- throw new Error(`Environment variable invalid: KUBE_STAGE=${kubeStage}`);
22
- }
23
-
24
- return stage;
25
- });
27
+ readonly kubeStage: KubeStage = getEnvVarParsed('KUBE_STAGE', translateLegacyStagename);
26
28
  readonly kubeNamespace: string = getEnvVar('KUBE_NAMESPACE');
27
- readonly version: string = getEnvVar('VERSION');
28
29
 
29
30
  readonly installationLongname: string = getEnvVar("GITPOD_INSTALLATION_LONGNAME")
30
31
  readonly installationShortname: string = getEnvVar("GITPOD_INSTALLATION_SHORTNAME")
@@ -9,11 +9,15 @@ import {
9
9
  WhitelistedRepository, WorkspaceImageBuild, AuthProviderInfo, Branding, CreateWorkspaceMode,
10
10
  Token, UserEnvVarValue, ResolvePluginsParams, PreparePluginUploadParams, Terms,
11
11
  ResolvedPlugins, Configuration, InstallPluginsParams, UninstallPluginParams, UserInfo, GitpodTokenType,
12
- GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes, Team
12
+ GitpodToken, AuthProviderEntry, GuessGitTokenScopesParams, GuessedGitTokenScopes
13
13
  } from './protocol';
14
+ import {
15
+ Team, TeamMemberInfo,
16
+ TeamMembershipInvite, Project, TeamMemberRole, PrebuildWithStatus, StartPrebuildResult
17
+ } from './teams-projects-protocol';
14
18
  import { JsonRpcProxy, JsonRpcServer } from './messaging/proxy-factory';
15
19
  import { Disposable, CancellationTokenSource } from 'vscode-jsonrpc';
16
- import { HeadlessLogEvent } from './headless-workspace-log';
20
+ import { HeadlessLogUrls } from './headless-workspace-log';
17
21
  import { WorkspaceInstance, WorkspaceInstancePort, WorkspaceInstancePhase } from './workspace-instance';
18
22
  import { AdminServer } from './admin-protocol';
19
23
  import { GitpodHostUrl } from './util/gitpod-host-url';
@@ -24,11 +28,13 @@ import { Emitter } from './util/event';
24
28
  import { AccountStatement, CreditAlert } from './accounting-protocol';
25
29
  import { GithubUpgradeURL, PlanCoupon } from './payment-protocol';
26
30
  import { TeamSubscription, TeamSubscriptionSlot, TeamSubscriptionSlotResolved } from './team-subscription-protocol';
31
+ import { RemoteTrackMessage } from './analytics';
27
32
 
28
33
  export interface GitpodClient {
29
34
  onInstanceUpdate(instance: WorkspaceInstance): void;
30
35
  onWorkspaceImageBuildLogs: WorkspaceImageBuild.LogCallback;
31
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void;
36
+
37
+ onPrebuildUpdate(update: PrebuildWithStatus): void;
32
38
 
33
39
  onCreditAlert(creditAlert: CreditAlert): void;
34
40
 
@@ -51,6 +57,7 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
51
57
  getBranding(): Promise<Branding>;
52
58
  getConfiguration(): Promise<Configuration>;
53
59
  getToken(query: GitpodServer.GetTokenSearchOptions): Promise<Token | undefined>;
60
+ getGitpodTokenScopes(tokenHash: string): Promise<string[]>;
54
61
  /**
55
62
  * @deprecated
56
63
  */
@@ -82,8 +89,8 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
82
89
  updateWorkspaceUserPin(id: string, action: GitpodServer.PinAction): Promise<void>;
83
90
  sendHeartBeat(options: GitpodServer.SendHeartBeatOptions): Promise<void>;
84
91
  watchWorkspaceImageBuildLogs(workspaceId: string): Promise<void>;
85
- watchHeadlessWorkspaceLogs(workspaceId: string): Promise<void>;
86
92
  isPrebuildDone(pwsid: string): Promise<boolean>;
93
+ getHeadlessLog(instanceId: string): Promise<HeadlessLogUrls>;
87
94
 
88
95
  // Workspace timeout
89
96
  setWorkspaceTimeout(workspaceId: string, duration: WorkspaceTimeoutDuration): Promise<SetWorkspaceTimeoutResult>;
@@ -101,14 +108,34 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
101
108
  getUserStorageResource(options: GitpodServer.GetUserStorageResourceOptions): Promise<string>;
102
109
  updateUserStorageResource(options: GitpodServer.UpdateUserStorageResourceOptions): Promise<void>;
103
110
 
104
- // user env vars
111
+ // User env vars
105
112
  getEnvVars(): Promise<UserEnvVarValue[]>;
106
113
  getAllEnvVars(): Promise<UserEnvVarValue[]>;
107
114
  setEnvVar(variable: UserEnvVarValue): Promise<void>;
108
115
  deleteEnvVar(variable: UserEnvVarValue): Promise<void>;
109
116
 
110
- // teams and projects
117
+ // Teams
111
118
  getTeams(): Promise<Team[]>;
119
+ getTeamMembers(teamId: string): Promise<TeamMemberInfo[]>;
120
+ createTeam(name: string): Promise<Team>;
121
+ joinTeam(inviteId: string): Promise<Team>;
122
+ setTeamMemberRole(teamId: string, userId: string, role: TeamMemberRole): Promise<void>;
123
+ removeTeamMember(teamId: string, userId: string): Promise<void>;
124
+ getGenericInvite(teamId: string): Promise<TeamMembershipInvite>;
125
+ resetGenericInvite(inviteId: string): Promise<TeamMembershipInvite>;
126
+
127
+ // Projects
128
+ getProviderRepositoriesForUser(params: GetProviderRepositoriesParams): Promise<ProviderRepository[]>;
129
+ createProject(params: CreateProjectParams): Promise<Project>;
130
+ deleteProject(projectId: string): Promise<void>;
131
+ getTeamProjects(teamId: string): Promise<Project[]>;
132
+ getUserProjects(): Promise<Project[]>;
133
+ getProjectOverview(projectId: string): Promise<Project.Overview | undefined>;
134
+ findPrebuilds(params: FindPrebuildsParams): Promise<PrebuildWithStatus[]>;
135
+ triggerPrebuild(projectId: string, branchName: string | null): Promise<StartPrebuildResult>;
136
+ setProjectConfiguration(projectId: string, configString: string): Promise<void>;
137
+ fetchProjectRepositoryConfiguration(projectId: string): Promise<string | undefined>;
138
+ guessProjectConfiguration(projectId: string): Promise<string | undefined>;
112
139
 
113
140
  // content service
114
141
  getContentBlobUploadUrl(name: string): Promise<string>
@@ -196,6 +223,43 @@ export interface GitpodServer extends JsonRpcServer<GitpodClient>, AdminServer,
196
223
 
197
224
  getGithubUpgradeUrls(): Promise<GithubUpgradeURL[]>;
198
225
 
226
+ /**
227
+ * Analytics
228
+ */
229
+ trackEvent(event: RemoteTrackMessage): Promise<void>;
230
+ }
231
+
232
+ export interface CreateProjectParams {
233
+ name: string;
234
+ account: string;
235
+ provider: string;
236
+ cloneUrl: string;
237
+ teamId?: string;
238
+ userId?: string;
239
+ appInstallationId: string;
240
+ }
241
+ export interface FindPrebuildsParams {
242
+ projectId: string;
243
+ branch?: string;
244
+ latest?: boolean;
245
+ prebuildId?: string;
246
+ // default: 30
247
+ limit?: number;
248
+ }
249
+ export interface GetProviderRepositoriesParams {
250
+ provider: string;
251
+ hints?: { installationId: string } | object;
252
+ }
253
+ export interface ProviderRepository {
254
+ name: string;
255
+ account: string;
256
+ accountAvatarUrl: string;
257
+ cloneUrl: string;
258
+ updatedAt: string;
259
+ installationId?: number;
260
+ installationUpdatedAt?: string;
261
+
262
+ inUse?: boolean;
199
263
  }
200
264
 
201
265
  export const WorkspaceTimeoutValues = ["30m", "60m", "180m"] as const;
@@ -208,6 +272,7 @@ export const createServerMock = function <C extends GitpodClient, S extends Gitp
208
272
  methods.setClient = methods.setClient || (() => { });
209
273
  methods.dispose = methods.dispose || (() => { });
210
274
  return new Proxy<JsonRpcProxy<S>>(methods as any as JsonRpcProxy<S>, {
275
+ // @ts-ignore
211
276
  get: (target: S, property: keyof S) => {
212
277
  const result = target[property];
213
278
  if (!result) {
@@ -240,6 +305,8 @@ export namespace GitpodServer {
240
305
  limit?: number;
241
306
  searchString?: string;
242
307
  pinnedOnly?: boolean;
308
+ projectId?: string | string[];
309
+ includeWithoutProject?: boolean;
243
310
  }
244
311
  export interface GetAccountStatementOptions {
245
312
  date?: string;
@@ -247,6 +314,7 @@ export namespace GitpodServer {
247
314
  export interface CreateWorkspaceOptions {
248
315
  contextUrl: string;
249
316
  mode?: CreateWorkspaceMode;
317
+ forceDefaultConfig?: boolean;
250
318
  }
251
319
  export interface StartWorkspaceOptions {
252
320
  forceDefaultImage: boolean;
@@ -315,11 +383,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
315
383
  }
316
384
  }
317
385
 
318
- onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
386
+ onPrebuildUpdate(update: PrebuildWithStatus): void {
319
387
  for (const client of this.clients) {
320
- if (client.onWorkspaceImageBuildLogs) {
388
+ if (client.onPrebuildUpdate) {
321
389
  try {
322
- client.onWorkspaceImageBuildLogs(info, content);
390
+ client.onPrebuildUpdate(update);
323
391
  } catch (error) {
324
392
  console.error(error)
325
393
  }
@@ -327,11 +395,11 @@ export class GitpodCompositeClient<Client extends GitpodClient> implements Gitpo
327
395
  }
328
396
  }
329
397
 
330
- onHeadlessWorkspaceLogs(evt: HeadlessLogEvent): void {
398
+ onWorkspaceImageBuildLogs(info: WorkspaceImageBuild.StateInfo, content: WorkspaceImageBuild.LogContent | undefined): void {
331
399
  for (const client of this.clients) {
332
- if (client.onHeadlessWorkspaceLogs) {
400
+ if (client.onWorkspaceImageBuildLogs) {
333
401
  try {
334
- client.onHeadlessWorkspaceLogs(evt);
402
+ client.onWorkspaceImageBuildLogs(info, content);
335
403
  } catch (error) {
336
404
  console.error(error)
337
405
  }
@@ -22,21 +22,17 @@ export namespace HeadlessWorkspaceEventType {
22
22
  }
23
23
  }
24
24
 
25
- export interface HeadlessLogEvent {
25
+ export interface HeadlessWorkspaceEvent {
26
26
  workspaceID: string;
27
27
  text: string;
28
28
  type: HeadlessWorkspaceEventType;
29
29
  }
30
30
 
31
- export enum TheiaHeadlessLogType {
32
- TaskLogLabel = "workspaceTaskOutput",
33
- TaskFailedLabel = "workspaceTaskFailed",
34
- TaskSuccessfulLabel = "workspaceTaskDone"
31
+ export interface HeadlessLogUrls {
32
+ // A map of id to URL
33
+ streams: { [streamID: string]: string };
35
34
  }
36
35
 
37
- export interface TheiaHeadlessLogMessage {
38
- type: TheiaHeadlessLogType;
39
- data?: string;
40
- error?: string;
41
- snapshotURL?: string;
42
- }
36
+ /** cmp. @const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX */
37
+ export const HEADLESS_LOG_STREAM_STATUS_CODE = "X-LogStream-StatusCode";
38
+ export const HEADLESS_LOG_STREAM_STATUS_CODE_REGEX = /X-LogStream-StatusCode: ([0-9]{3})/;
package/src/index.ts CHANGED
@@ -15,3 +15,5 @@ export * from './permission';
15
15
  export * from './admin-protocol';
16
16
  export * from './email-protocol';
17
17
  export * from './headless-workspace-log';
18
+ export * from './context-url';
19
+ export * from './teams-projects-protocol';
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Copyright (c) 2021 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 { injectable } from 'inversify';
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
+ }
29
+
30
+ @injectable()
31
+ export class PrometheusClientCallMetrics implements IClientCallMetrics {
32
+
33
+ readonly startedCounter: prometheusClient.Counter<string>;
34
+ readonly sentCounter: prometheusClient.Counter<string>;
35
+ readonly receivedCounter: prometheusClient.Counter<string>;
36
+ readonly handledCounter: prometheusClient.Counter<string>;
37
+
38
+ constructor() {
39
+ this.startedCounter = new prometheusClient.Counter({
40
+ name: 'grpc_client_started_total',
41
+ help: 'Total number of RPCs started on the client.',
42
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
43
+ registers: [prometheusClient.register]
44
+ });
45
+ this.sentCounter = new prometheusClient.Counter({
46
+ name: 'grpc_client_msg_sent_total',
47
+ help: ' Total number of gRPC stream messages sent by the client.',
48
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
49
+ registers: [prometheusClient.register]
50
+ });
51
+ this.receivedCounter = new prometheusClient.Counter({
52
+ name: 'grpc_client_msg_received_total',
53
+ help: 'Total number of RPC stream messages received by the client.',
54
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type'],
55
+ registers: [prometheusClient.register]
56
+ });
57
+ this.handledCounter = new prometheusClient.Counter({
58
+ name: 'grpc_client_handled_total',
59
+ help: 'Total number of RPCs completed by the client, regardless of success or failure.',
60
+ labelNames: ['grpc_service', 'grpc_method', 'grpc_type', 'grpc_code'],
61
+ registers: [prometheusClient.register]
62
+ });
63
+ }
64
+
65
+ started(labels: IGrpcCallMetricsLabels): void {
66
+ this.startedCounter.inc({
67
+ grpc_service: labels.service,
68
+ grpc_method: labels.method,
69
+ grpc_type: labels.type
70
+ });
71
+ }
72
+
73
+ sent(labels: IGrpcCallMetricsLabels): void {
74
+ this.sentCounter.inc({
75
+ grpc_service: labels.service,
76
+ grpc_method: labels.method,
77
+ grpc_type: labels.type
78
+ });
79
+ }
80
+
81
+ received(labels: IGrpcCallMetricsLabels): void {
82
+ this.receivedCounter.inc({
83
+ grpc_service: labels.service,
84
+ grpc_method: labels.method,
85
+ grpc_type: labels.type
86
+ });
87
+ }
88
+
89
+ handled(labels: IGrpcCallMetricsLabelsWithCode): void {
90
+ this.handledCounter.inc({
91
+ grpc_service: labels.service,
92
+ grpc_method: labels.method,
93
+ grpc_type: labels.type,
94
+ grpc_code: labels.code
95
+ });
96
+ }
97
+ }
@@ -34,6 +34,9 @@ export namespace ErrorCodes {
34
34
  // 460 Context Parse Error (custom status code)
35
35
  export const CONTEXT_PARSE_ERROR = 460;
36
36
 
37
+ // 461 Invalid gitpod yml
38
+ export const INVALID_GITPOD_YML = 461;
39
+
37
40
  // 450 Payment error
38
41
  export const PAYMENT_ERROR = 450;
39
42