@gitpod/gitpod-protocol 0.1.5-sje-server-installation-admin.8 → 0.1.5-sje-server-installation-admin.15

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 (42) hide show
  1. package/lib/gitpod-service.d.ts +4 -1
  2. package/lib/gitpod-service.d.ts.map +1 -1
  3. package/lib/gitpod-service.js +4 -2
  4. package/lib/gitpod-service.js.map +1 -1
  5. package/lib/index.d.ts +1 -0
  6. package/lib/index.d.ts.map +1 -1
  7. package/lib/index.js +1 -0
  8. package/lib/index.js.map +1 -1
  9. package/lib/installation-admin-protocol.d.ts +10 -0
  10. package/lib/installation-admin-protocol.d.ts.map +1 -0
  11. package/lib/installation-admin-protocol.js +8 -0
  12. package/lib/installation-admin-protocol.js.map +1 -0
  13. package/lib/messaging/node/connection.d.ts +1 -7
  14. package/lib/messaging/node/connection.d.ts.map +1 -1
  15. package/lib/messaging/node/connection.js +20 -18
  16. package/lib/messaging/node/connection.js.map +1 -1
  17. package/lib/protocol.d.ts +12 -4
  18. package/lib/protocol.d.ts.map +1 -1
  19. package/lib/protocol.js +4 -0
  20. package/lib/protocol.js.map +1 -1
  21. package/lib/teams-projects-protocol.d.ts +0 -6
  22. package/lib/teams-projects-protocol.d.ts.map +1 -1
  23. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  24. package/lib/util/generate-workspace-id.js +1 -0
  25. package/lib/util/generate-workspace-id.js.map +1 -1
  26. package/lib/util/generate-workspace-id.spec.js +1 -0
  27. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  28. package/lib/util/tracing.d.ts.map +1 -1
  29. package/lib/util/tracing.js +5 -2
  30. package/lib/util/tracing.js.map +1 -1
  31. package/package.json +1 -1
  32. package/pkg-yarn.lock +1 -1
  33. package/provenance-bundle.jsonl +1 -1
  34. package/src/gitpod-service.ts +9 -4
  35. package/src/index.ts +1 -0
  36. package/src/installation-admin-protocol.ts +10 -0
  37. package/src/messaging/node/connection.ts +20 -23
  38. package/src/protocol.ts +19 -4
  39. package/src/teams-projects-protocol.ts +0 -7
  40. package/src/util/generate-workspace-id.spec.ts +1 -0
  41. package/src/util/generate-workspace-id.ts +1 -0
  42. package/src/util/tracing.ts +5 -2
@@ -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() || "";
@@ -877,7 +892,7 @@ export namespace PrebuiltWorkspaceContext {
877
892
  }
878
893
 
879
894
  export interface WithEnvvarsContext extends WorkspaceContext {
880
- envvars: UserEnvVarValue[];
895
+ envvars: EnvVarWithValue[];
881
896
  }
882
897
 
883
898
  export namespace WithEnvvarsContext {
@@ -117,13 +117,6 @@ export interface Team {
117
117
  deleted?: boolean;
118
118
  }
119
119
 
120
- export interface InstallationAdmin {
121
- id: string;
122
- sendTelemetry: boolean;
123
- createdAt: Date;
124
- updatedAt: Date;
125
- }
126
-
127
120
  export type TeamMemberRole = "owner" | "member";
128
121
 
129
122
  export interface TeamMemberInfo {
@@ -34,6 +34,7 @@ const expect = chai.expect
34
34
  ['gitpod-io','gitpod','gitpodio-gitpod-'],
35
35
  ['this is rather long and has some "§$"% special chars','also here pretty long and needs abbreviation','thisisratherlon-alsohere-'],
36
36
  ['breatheco-de', 'python-flask-api-tutorial', 'breathecode-pythonflaska-'],
37
+ ['UPPER', "CaSe", "upper-case-"]
37
38
  ]
38
39
  for (const d of data) {
39
40
  const id = await generateWorkspaceID(d[0], d[1]);
@@ -15,6 +15,7 @@ function clean(segment: string | undefined, maxChars: number = 15) {
15
15
  if (!segment) {
16
16
  return undefined;
17
17
  }
18
+ segment = segment.toLowerCase();
18
19
  let result = '';
19
20
  for (let i =0; i < segment.length; i++) {
20
21
  if (characters.indexOf(segment[i]) !== -1) {
@@ -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);