@gitpod/gitpod-protocol 0.1.5-prs-test-dazzle-rewrite.90 → 0.1.5-prs-dazzlev2-test.3

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 (46) hide show
  1. package/lib/admin-protocol.d.ts +3 -0
  2. package/lib/admin-protocol.d.ts.map +1 -1
  3. package/lib/admin-protocol.js.map +1 -1
  4. package/lib/context-url.d.ts +1 -0
  5. package/lib/context-url.d.ts.map +1 -1
  6. package/lib/context-url.js +3 -1
  7. package/lib/context-url.js.map +1 -1
  8. package/lib/gitpod-service.d.ts +13 -1
  9. package/lib/gitpod-service.d.ts.map +1 -1
  10. package/lib/gitpod-service.js +4 -2
  11. package/lib/gitpod-service.js.map +1 -1
  12. package/lib/ide-protocol.d.ts +20 -0
  13. package/lib/ide-protocol.d.ts.map +1 -1
  14. package/lib/index.d.ts +1 -0
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +1 -0
  17. package/lib/index.js.map +1 -1
  18. package/lib/installation-admin-protocol.d.ts +21 -0
  19. package/lib/installation-admin-protocol.d.ts.map +1 -0
  20. package/lib/installation-admin-protocol.js +30 -0
  21. package/lib/installation-admin-protocol.js.map +1 -0
  22. package/lib/messaging/node/connection.d.ts +1 -7
  23. package/lib/messaging/node/connection.d.ts.map +1 -1
  24. package/lib/messaging/node/connection.js +20 -18
  25. package/lib/messaging/node/connection.js.map +1 -1
  26. package/lib/protocol.d.ts +19 -4
  27. package/lib/protocol.d.ts.map +1 -1
  28. package/lib/protocol.js +13 -1
  29. package/lib/protocol.js.map +1 -1
  30. package/lib/util/tracing.d.ts.map +1 -1
  31. package/lib/util/tracing.js +5 -2
  32. package/lib/util/tracing.js.map +1 -1
  33. package/package.json +1 -1
  34. package/pkg-yarn.lock +1 -1
  35. package/provenance-bundle.jsonl +1 -1
  36. package/src/admin-protocol.ts +7 -3
  37. package/src/context-url.ts +3 -1
  38. package/src/gitpod-service.ts +20 -4
  39. package/src/ide-frontend-service.ts +1 -1
  40. package/src/ide-protocol.ts +22 -0
  41. package/src/index.ts +1 -0
  42. package/src/installation-admin-protocol.ts +35 -0
  43. package/src/messaging/node/connection.ts +20 -23
  44. package/src/protocol.ts +31 -4
  45. package/src/util/gitpod-host-url.ts +1 -1
  46. package/src/util/tracing.ts +5 -2
@@ -0,0 +1,35 @@
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 { v4 as uuidv4 } from 'uuid';
8
+
9
+ const InstallationAdminSettingsPrototype = {
10
+ sendTelemetry: true
11
+ }
12
+
13
+ export type InstallationAdminSettings = typeof InstallationAdminSettingsPrototype;
14
+
15
+ export namespace InstallationAdminSettings {
16
+ export function fields(): (keyof InstallationAdminSettings)[] {
17
+ return Object.keys(InstallationAdminSettingsPrototype) as (keyof InstallationAdminSettings)[];
18
+ }
19
+ }
20
+
21
+ export interface InstallationAdmin {
22
+ id: string;
23
+ settings: InstallationAdminSettings;
24
+ }
25
+
26
+ export namespace InstallationAdmin {
27
+ export function createDefault(): InstallationAdmin {
28
+ return {
29
+ id: uuidv4(),
30
+ settings: {
31
+ ...InstallationAdminSettingsPrototype,
32
+ }
33
+ };
34
+ }
35
+ }
@@ -6,37 +6,34 @@
6
6
  */
7
7
 
8
8
  import * as ws from "ws";
9
- import * as http from "http";
10
- import * as net from "net";
11
9
  import { IWebSocket } from "vscode-ws-jsonrpc";
12
- import { log } from '../../util/logging';
13
10
 
14
- export interface OnOpen {
15
- (webSocket: ws, request: http.IncomingMessage, socket: net.Socket, head: Buffer): void;
16
- }
17
-
18
- export function toIWebSocket(webSocket: ws) {
19
- let sendsAfterOpen = 0;
11
+ export function toIWebSocket(ws: ws) {
20
12
  return <IWebSocket>{
21
13
  send: content => {
22
- if (webSocket.readyState !== ws.OPEN) {
23
- if (sendsAfterOpen++ > 3) {
24
- //log.debug(`Repeated try to send on closed web socket (readyState was ${webSocket.readyState})`, { ws });
25
- }
14
+ if (ws.readyState >= ws.CLOSING) {
15
+ // ws is already CLOSING/CLOSED, send() would just return an error.
26
16
  return;
27
17
  }
28
- webSocket.send(content, err => {
29
- if (err) {
30
- log.error('error in ws.send()', err, { ws });
31
- }
32
- })
18
+
19
+ // in general send-errors should trigger an 'error' event already, we just make sure it actually happens.
20
+ try {
21
+ ws.send(content, err => {
22
+ if (!err) {
23
+ return;
24
+ }
25
+ ws.emit('error', err);
26
+ });
27
+ } catch (err) {
28
+ ws.emit('error', err);
29
+ }
33
30
  },
34
- onMessage: cb => webSocket.on('message', cb),
35
- onError: cb => webSocket.on('error', cb),
36
- onClose: cb => webSocket.on('close', cb),
31
+ onMessage: cb => ws.on('message', cb),
32
+ onError: cb => ws.on('error', cb),
33
+ onClose: cb => ws.on('close', cb),
37
34
  dispose: () => {
38
- if (webSocket.readyState < ws.CLOSING) {
39
- webSocket.close();
35
+ if (ws.readyState < ws.CLOSING) {
36
+ ws.close();
40
37
  }
41
38
  }
42
39
  };
package/src/protocol.ts CHANGED
@@ -154,12 +154,23 @@ export interface UserFeatureSettings {
154
154
  export const WorkspaceFeatureFlags = { "full_workspace_backup": undefined, "fixed_resources": undefined };
155
155
  export type NamedWorkspaceFeatureFlag = keyof (typeof WorkspaceFeatureFlags);
156
156
 
157
- export interface UserEnvVarValue {
158
- id?: string;
157
+ export interface EnvVarWithValue {
159
158
  name: string;
160
- repositoryPattern: string;
161
159
  value: string;
162
160
  }
161
+
162
+ export interface ProjectEnvVarWithValue extends EnvVarWithValue {
163
+ id: string;
164
+ projectId: string;
165
+ censored: boolean;
166
+ }
167
+
168
+ export type ProjectEnvVar = Omit<ProjectEnvVarWithValue, 'value'>;
169
+
170
+ export interface UserEnvVarValue extends EnvVarWithValue {
171
+ id?: string;
172
+ repositoryPattern: string; // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
173
+ }
163
174
  export interface UserEnvVar extends UserEnvVarValue {
164
175
  id: string;
165
176
  userId: string;
@@ -168,10 +179,12 @@ export interface UserEnvVar extends UserEnvVarValue {
168
179
 
169
180
  export namespace UserEnvVar {
170
181
 
182
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
171
183
  export function normalizeRepoPattern(pattern: string) {
172
184
  return pattern.toLocaleLowerCase();
173
185
  }
174
186
 
187
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
175
188
  export function score(value: UserEnvVarValue): number {
176
189
  // We use a score to enforce precedence:
177
190
  // value/value = 0
@@ -194,6 +207,7 @@ export namespace UserEnvVar {
194
207
  return score;
195
208
  }
196
209
 
210
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
197
211
  export function filter<T extends UserEnvVarValue>(vars: T[], owner: string, repo: string): T[] {
198
212
  let result = vars.filter(e => {
199
213
  const [ownerPattern, repoPattern] = splitRepositoryPattern(e.repositoryPattern);
@@ -241,6 +255,7 @@ export namespace UserEnvVar {
241
255
  return result;
242
256
  }
243
257
 
258
+ // DEPRECATED: Use ProjectEnvVar instead of repositoryPattern - https://github.com/gitpod-com/gitpod/issues/5322
244
259
  export function splitRepositoryPattern(repositoryPattern: string): string[] {
245
260
  const patterns = repositoryPattern.split('/');
246
261
  const repoPattern = patterns.pop() || "";
@@ -876,8 +891,20 @@ export namespace PrebuiltWorkspaceContext {
876
891
  }
877
892
  }
878
893
 
894
+ export interface WithReferrerContext extends WorkspaceContext {
895
+ referrer: string
896
+ referrerIde?: string
897
+ }
898
+
899
+ export namespace WithReferrerContext {
900
+ export function is(context: any): context is WithReferrerContext {
901
+ return context
902
+ && 'referrer' in context;
903
+ }
904
+ }
905
+
879
906
  export interface WithEnvvarsContext extends WorkspaceContext {
880
- envvars: UserEnvVarValue[];
907
+ envvars: EnvVarWithValue[];
881
908
  }
882
909
 
883
910
  export namespace WithEnvvarsContext {
@@ -150,7 +150,7 @@ export class GitpodHostUrl {
150
150
  return undefined;
151
151
  }
152
152
 
153
- get blobServe(): boolean {
153
+ get blobServe(): boolean {
154
154
  const hostSegments = this.url.host.split(".");
155
155
  if (hostSegments[0] === 'blobserve') {
156
156
  return true;
@@ -24,12 +24,15 @@ export type TraceContextWithSpan = TraceContext & {
24
24
  export namespace TraceContext {
25
25
  export function startSpan(operation: string, parentCtx?: TraceContext, ...referencedSpans: (opentracing.Span | undefined)[]): opentracing.Span {
26
26
  const options: opentracing.SpanOptions = {};
27
- if (parentCtx) {
27
+ if (parentCtx && parentCtx.span && !!parentCtx.span.context().toSpanId()) {
28
28
  options.childOf = parentCtx.span;
29
29
  }
30
30
  if (referencedSpans) {
31
31
  // note: allthough followsForm's type says it takes 'opentracing.Span | opentracing.SpanContext', it only works with SpanContext (typing mismatch)
32
- options.references = referencedSpans.filter(s => s !== undefined).map(s => followsFrom(s!.context()));
32
+ // note2: we need to filter out debug spans (spanId === "")
33
+ options.references = referencedSpans.filter(s => s !== undefined)
34
+ .filter(s => !!s!.context().toSpanId())
35
+ .map(s => followsFrom(s!.context()));
33
36
  }
34
37
 
35
38
  return opentracing.globalTracer().startSpan(operation, options);