@gitpod/gitpod-protocol 0.1.5-server-vscode-ouath2.17 → 0.1.5-server-vscode-oauth2.14
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.
- package/data/gitpod-schema.json +49 -4
- package/lib/accounting-protocol.d.ts +10 -11
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +31 -41
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +20 -2
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js +2 -13
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +12 -1
- package/lib/analytics.d.ts.map +1 -1
- package/lib/analytics.js.map +1 -1
- package/lib/auth.d.ts.map +1 -1
- package/lib/context-url.d.ts +18 -5
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +63 -10
- package/lib/context-url.js.map +1 -1
- package/lib/context-url.spec.d.ts +2 -0
- package/lib/context-url.spec.d.ts.map +1 -1
- package/lib/context-url.spec.js +81 -48
- package/lib/context-url.spec.js.map +1 -1
- package/lib/email-protocol.d.ts +1 -1
- package/lib/email-protocol.d.ts.map +1 -1
- package/lib/email-protocol.js +4 -4
- package/lib/email-protocol.js.map +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +4 -4
- package/lib/encryption/container-module.js.map +1 -1
- package/lib/encryption/encryption-engine.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.js +25 -26
- package/lib/encryption/encryption-engine.js.map +1 -1
- package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
- package/lib/encryption/encryption-engine.spec.js +29 -37
- package/lib/encryption/encryption-engine.spec.js.map +1 -1
- package/lib/encryption/encryption-service.d.ts.map +1 -1
- package/lib/encryption/encryption-service.js +30 -44
- package/lib/encryption/encryption-service.js.map +1 -1
- package/lib/encryption/key-provider.d.ts.map +1 -1
- package/lib/encryption/key-provider.js +31 -38
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +17 -19
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +26 -42
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +145 -142
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +67 -31
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +162 -309
- package/lib/gitpod-service.js.map +1 -1
- package/lib/headless-workspace-log.d.ts +1 -0
- package/lib/headless-workspace-log.d.ts.map +1 -1
- package/lib/headless-workspace-log.js +2 -1
- package/lib/headless-workspace-log.js.map +1 -1
- package/lib/ide-frontend-service.d.ts +1 -1
- package/lib/ide-protocol.d.ts +105 -0
- package/lib/ide-protocol.d.ts.map +1 -0
- package/lib/ide-protocol.js +8 -0
- package/lib/ide-protocol.js.map +1 -0
- package/lib/index.d.ts +16 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +27 -0
- package/lib/installation-admin-protocol.d.ts.map +1 -0
- package/lib/installation-admin-protocol.js +30 -0
- package/lib/installation-admin-protocol.js.map +1 -0
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +3 -3
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +173 -36
- package/lib/messaging/browser/connection.js.map +1 -1
- package/lib/messaging/browser/window-connection.d.ts +4 -4
- package/lib/messaging/browser/window-connection.d.ts.map +1 -1
- package/lib/messaging/browser/window-connection.js +42 -59
- package/lib/messaging/browser/window-connection.js.map +1 -1
- package/lib/messaging/client-call-metrics.d.ts +2 -2
- package/lib/messaging/client-call-metrics.d.ts.map +1 -1
- package/lib/messaging/client-call-metrics.js +37 -38
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts +2 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js +4 -2
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts +10 -0
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -1
- package/lib/messaging/node/connection.d.ts +1 -17
- package/lib/messaging/node/connection.d.ts.map +1 -1
- package/lib/messaging/node/connection.js +24 -60
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +3 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +74 -163
- package/lib/messaging/proxy-factory.js.map +1 -1
- package/lib/oss-allowlist.d.ts +14 -0
- package/lib/oss-allowlist.d.ts.map +1 -0
- package/lib/oss-allowlist.js +8 -0
- package/lib/oss-allowlist.js.map +1 -0
- package/lib/payment-protocol.d.ts.map +1 -1
- package/lib/payment-protocol.js +1 -1
- package/lib/payment-protocol.js.map +1 -1
- package/lib/permission.d.ts +9 -4
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +39 -31
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +4 -4
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +225 -209
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +83 -78
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +131 -190
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.d.ts +14 -0
- package/lib/snapshot-url.d.ts.map +1 -0
- package/lib/snapshot-url.js +26 -0
- package/lib/snapshot-url.js.map +1 -0
- package/{src/theia-plugins.ts → lib/snapshot-url.spec.d.ts} +2 -6
- package/lib/snapshot-url.spec.d.ts.map +1 -0
- package/lib/snapshot-url.spec.js +41 -0
- package/lib/snapshot-url.spec.js.map +1 -0
- package/lib/team-subscription-protocol.d.ts +5 -3
- package/lib/team-subscription-protocol.d.ts.map +1 -1
- package/lib/team-subscription-protocol.js +17 -17
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +16 -3
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +11 -15
- package/lib/teams-projects-protocol.js.map +1 -1
- package/lib/typings/globals.d.ts +2 -2
- package/lib/typings/globals.d.ts.map +1 -1
- package/lib/util/analytics.d.ts.map +1 -1
- package/lib/util/analytics.js +44 -26
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +57 -135
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js +17 -59
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +11 -11
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js +10 -12
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +27 -40
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +63 -77
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts +1 -0
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +27 -47
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +460 -499
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +61 -78
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +20 -0
- package/lib/util/gitpod-cookie.d.ts.map +1 -0
- package/lib/util/gitpod-cookie.js +41 -0
- package/lib/util/gitpod-cookie.js.map +1 -0
- package/lib/util/gitpod-host-url.d.ts +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +106 -114
- package/lib/util/gitpod-host-url.js.map +1 -1
- package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.spec.js +97 -135
- package/lib/util/gitpod-host-url.spec.js.map +1 -1
- package/lib/util/grpc.d.ts.map +1 -1
- package/lib/util/grpc.js +3 -3
- package/lib/util/grpc.js.map +1 -1
- package/lib/util/jaeger-client-types.d.ts +68 -0
- package/lib/util/jaeger-client-types.d.ts.map +1 -0
- package/lib/{theia-plugins.js → util/jaeger-client-types.js} +1 -1
- package/lib/util/jaeger-client-types.js.map +1 -0
- package/lib/util/logging.d.ts +33 -33
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +87 -129
- package/lib/util/logging.js.map +1 -1
- package/lib/util/make-link.js +5 -5
- package/lib/util/make-link.js.map +1 -1
- package/lib/util/parse-workspace-id.d.ts +10 -0
- package/lib/util/parse-workspace-id.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.js +30 -7
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts +4 -0
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js +123 -84
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.js +16 -55
- package/lib/util/queue.js.map +1 -1
- package/lib/util/queue.spec.js +147 -288
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/repeat.d.ts +15 -0
- package/lib/util/repeat.d.ts.map +1 -0
- package/lib/util/repeat.js +55 -0
- package/lib/util/repeat.js.map +1 -0
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js +15 -46
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js +6 -6
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +16 -16
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js +21 -24
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +52 -6
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +199 -64
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.d.ts +7 -0
- package/lib/util/tracing.spec.d.ts.map +1 -0
- package/lib/util/tracing.spec.js +121 -0
- package/lib/util/tracing.spec.js.map +1 -0
- package/lib/util/workspace-port-authentication.d.ts +7 -7
- package/lib/util/workspace-port-authentication.d.ts.map +1 -1
- package/lib/util/workspace-port-authentication.js +9 -12
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +15 -3
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +19 -4
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +25 -4
- package/lib/workspace-instance.d.ts.map +1 -1
- package/lib/wsready.d.ts +1 -1
- package/lib/wsready.d.ts.map +1 -1
- package/lib/wsready.js +2 -2
- package/package.json +22 -13
- package/pkg-yarn.lock +12 -7
- package/provenance-bundle.jsonl +2 -0
- package/src/accounting-protocol.ts +53 -53
- package/src/admin-protocol.ts +43 -20
- package/src/analytics.ts +28 -15
- package/src/auth.ts +2 -2
- package/src/context-url.spec.ts +37 -9
- package/src/context-url.ts +94 -36
- package/src/email-protocol.ts +5 -6
- package/src/encryption/container-module.ts +2 -3
- package/src/encryption/encryption-engine.spec.ts +9 -8
- package/src/encryption/encryption-engine.ts +14 -14
- package/src/encryption/encryption-service.ts +4 -5
- package/src/encryption/key-provider.ts +16 -19
- package/src/env.ts +9 -10
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +174 -109
- package/src/headless-workspace-log.ts +6 -4
- package/src/ide-frontend-service.ts +2 -2
- package/src/ide-protocol.ts +119 -0
- package/src/index.ts +16 -13
- package/src/installation-admin-protocol.ts +42 -0
- package/src/license-protocol.ts +5 -6
- package/src/messaging/browser/connection.ts +185 -21
- package/src/messaging/browser/window-connection.ts +39 -29
- package/src/messaging/client-call-metrics.ts +70 -71
- package/src/messaging/error.ts +6 -5
- package/src/messaging/handler.ts +13 -1
- package/src/messaging/node/connection.ts +23 -70
- package/src/messaging/proxy-factory.ts +32 -33
- package/src/oss-allowlist.ts +15 -0
- package/src/payment-protocol.ts +2 -2
- package/src/permission.ts +40 -33
- package/src/plans.ts +236 -189
- package/src/protocol.ts +280 -277
- package/src/snapshot-url.spec.ts +27 -0
- package/src/snapshot-url.ts +27 -0
- package/src/team-subscription-protocol.ts +33 -23
- package/src/teams-projects-protocol.ts +27 -9
- package/src/typings/globals.ts +4 -4
- package/src/util/analytics.ts +56 -18
- package/src/util/async-iterator.ts +4 -5
- package/src/util/cancelable.ts +3 -3
- package/src/util/date-time.ts +8 -8
- package/src/util/deferred.ts +6 -6
- package/src/util/disposable.ts +3 -6
- package/src/util/event.ts +9 -11
- package/src/util/garbage-collected-cache.ts +9 -6
- package/src/util/generate-workspace-id.spec.ts +26 -6
- package/src/util/generate-workspace-id.ts +458 -440
- package/src/util/gitpod-cookie.ts +38 -0
- package/src/util/gitpod-host-url.spec.ts +40 -13
- package/src/util/gitpod-host-url.ts +41 -38
- package/src/util/grpc.ts +4 -4
- package/src/util/jaeger-client-types.ts +102 -0
- package/src/util/logging.ts +109 -86
- package/src/util/make-link.ts +6 -7
- package/src/util/parse-workspace-id.spec.ts +37 -8
- package/src/util/parse-workspace-id.ts +32 -7
- package/src/util/queue.spec.ts +27 -25
- package/src/util/repeat.ts +45 -0
- package/src/util/semaphore.ts +4 -6
- package/src/util/skip-if.ts +9 -6
- package/src/util/timeutil.spec.ts +14 -15
- package/src/util/timeutil.ts +15 -11
- package/src/util/tracing.spec.ts +88 -0
- package/src/util/tracing.ts +202 -31
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/workspace-cluster.ts +26 -8
- package/src/workspace-instance.ts +53 -23
- package/src/wsready.ts +3 -3
- package/data/builtin-theia-plugins.json +0 -372
- package/lib/messaging/connection-error-handler.d.ts +0 -27
- package/lib/messaging/connection-error-handler.d.ts.map +0 -1
- package/lib/messaging/connection-error-handler.js +0 -46
- package/lib/messaging/connection-error-handler.js.map +0 -1
- package/lib/theia-plugins.d.ts +0 -11
- package/lib/theia-plugins.d.ts.map +0 -1
- package/lib/theia-plugins.js.map +0 -1
- package/lib/util/repeater.d.ts +0 -22
- package/lib/util/repeater.d.ts.map +0 -1
- package/lib/util/repeater.js +0 -118
- package/lib/util/repeater.js.map +0 -1
- package/lib/util/safe-promise.d.ts +0 -11
- package/lib/util/safe-promise.d.ts.map +0 -1
- package/lib/util/safe-promise.js +0 -34
- package/lib/util/safe-promise.js.map +0 -1
- package/src/messaging/connection-error-handler.ts +0 -62
- package/src/util/jaeger-client.d.ts +0 -105
- package/src/util/repeater.ts +0 -49
- package/src/util/safe-promise.ts +0 -26
package/src/util/logging.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
const inspect: (object: any) => string = require(
|
|
7
|
+
const inspect: (object: any) => string = require("util").inspect; // undefined in frontend
|
|
8
8
|
|
|
9
9
|
let jsonLogging: boolean = false;
|
|
10
10
|
let component: string | undefined;
|
|
@@ -15,81 +15,81 @@ export interface LogContext {
|
|
|
15
15
|
sessionId?: string;
|
|
16
16
|
userId?: string;
|
|
17
17
|
workspaceId?: string;
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
export namespace LogContext {
|
|
20
|
-
export function from(params
|
|
20
|
+
export function from(params: { userId?: string; user?: any; request?: any }) {
|
|
21
21
|
return <LogContext>{
|
|
22
22
|
sessionId: params.request?.requestID,
|
|
23
|
-
userId: params.userId || params.user?.id
|
|
24
|
-
}
|
|
23
|
+
userId: params.userId || params.user?.id,
|
|
24
|
+
};
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface LogPayload {
|
|
29
29
|
// placeholder to indicate that only dictionary-style objects should be passed as payload
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
export namespace log {
|
|
33
|
-
export function error(context: LogContext, message: string, error:
|
|
34
|
-
export function error(context: LogContext, message: string, error:
|
|
33
|
+
export function error(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
34
|
+
export function error(context: LogContext, message: string, error: any): void;
|
|
35
35
|
export function error(context: LogContext, message: string, payload: LogPayload): void;
|
|
36
36
|
export function error(context: LogContext, message: string): void;
|
|
37
|
-
export function error(context: LogContext, error:
|
|
38
|
-
export function error(context: LogContext, error:
|
|
39
|
-
export function error(message: string, error:
|
|
40
|
-
export function error(message: string, error:
|
|
37
|
+
export function error(context: LogContext, error: any, payload: LogPayload): void;
|
|
38
|
+
export function error(context: LogContext, error: any): void;
|
|
39
|
+
export function error(message: string, error: any, payload: LogPayload): void;
|
|
40
|
+
export function error(message: string, error: any): void;
|
|
41
41
|
export function error(message: string, payload: LogPayload): void;
|
|
42
42
|
export function error(message: string): void;
|
|
43
|
-
export function error(error:
|
|
44
|
-
export function error(error:
|
|
43
|
+
export function error(error: any, payload: LogPayload): void;
|
|
44
|
+
export function error(error: any): void;
|
|
45
45
|
export function error(...args: any[]): void {
|
|
46
46
|
errorLog(false, args);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function warn(context: LogContext, message: string, error:
|
|
50
|
-
export function warn(context: LogContext, message: string, error:
|
|
49
|
+
export function warn(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
50
|
+
export function warn(context: LogContext, message: string, error: any): void;
|
|
51
51
|
export function warn(context: LogContext, message: string, payload: LogPayload): void;
|
|
52
52
|
export function warn(context: LogContext, message: string): void;
|
|
53
|
-
export function warn(context: LogContext, error:
|
|
54
|
-
export function warn(context: LogContext, error:
|
|
55
|
-
export function warn(message: string, error:
|
|
56
|
-
export function warn(message: string, error:
|
|
53
|
+
export function warn(context: LogContext, error: any, payload: LogPayload): void;
|
|
54
|
+
export function warn(context: LogContext, error: any): void;
|
|
55
|
+
export function warn(message: string, error: any, payload: LogPayload): void;
|
|
56
|
+
export function warn(message: string, error: any): void;
|
|
57
57
|
export function warn(message: string, payload: LogPayload): void;
|
|
58
58
|
export function warn(message: string): void;
|
|
59
|
-
export function warn(error:
|
|
60
|
-
export function warn(error:
|
|
59
|
+
export function warn(error: any, payload: LogPayload): void;
|
|
60
|
+
export function warn(error: any): void;
|
|
61
61
|
export function warn(...args: any[]): void {
|
|
62
62
|
warnLog(false, args);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export function info(context: LogContext, message: string, error:
|
|
66
|
-
export function info(context: LogContext, message: string, error:
|
|
65
|
+
export function info(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
66
|
+
export function info(context: LogContext, message: string, error: any): void;
|
|
67
67
|
export function info(context: LogContext, message: string, payload: LogPayload): void;
|
|
68
68
|
export function info(context: LogContext, message: string): void;
|
|
69
|
-
export function info(context: LogContext, error:
|
|
70
|
-
export function info(context: LogContext, error:
|
|
71
|
-
export function info(message: string, error:
|
|
72
|
-
export function info(message: string, error:
|
|
69
|
+
export function info(context: LogContext, error: any, payload: LogPayload): void;
|
|
70
|
+
export function info(context: LogContext, error: any): void;
|
|
71
|
+
export function info(message: string, error: any, payload: LogPayload): void;
|
|
72
|
+
export function info(message: string, error: any): void;
|
|
73
73
|
export function info(message: string, payload: LogPayload): void;
|
|
74
74
|
export function info(message: string): void;
|
|
75
|
-
export function info(error:
|
|
76
|
-
export function info(error:
|
|
75
|
+
export function info(error: any, payload: LogPayload): void;
|
|
76
|
+
export function info(error: any): void;
|
|
77
77
|
export function info(...args: any[]): void {
|
|
78
78
|
infoLog(false, args);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
export function debug(context: LogContext, message: string, error:
|
|
82
|
-
export function debug(context: LogContext, message: string, error:
|
|
81
|
+
export function debug(context: LogContext, message: string, error: any, payload: LogPayload): void;
|
|
82
|
+
export function debug(context: LogContext, message: string, error: any): void;
|
|
83
83
|
export function debug(context: LogContext, message: string, payload: LogPayload): void;
|
|
84
84
|
export function debug(context: LogContext, message: string): void;
|
|
85
|
-
export function debug(context: LogContext, error:
|
|
86
|
-
export function debug(context: LogContext, error:
|
|
87
|
-
export function debug(message: string, error:
|
|
88
|
-
export function debug(message: string, error:
|
|
85
|
+
export function debug(context: LogContext, error: any, payload: LogPayload): void;
|
|
86
|
+
export function debug(context: LogContext, error: any): void;
|
|
87
|
+
export function debug(message: string, error: any, payload: LogPayload): void;
|
|
88
|
+
export function debug(message: string, error: any): void;
|
|
89
89
|
export function debug(message: string, payload: LogPayload): void;
|
|
90
90
|
export function debug(message: string): void;
|
|
91
|
-
export function debug(error:
|
|
92
|
-
export function debug(error:
|
|
91
|
+
export function debug(error: any, payload: LogPayload): void;
|
|
92
|
+
export function debug(error: any): void;
|
|
93
93
|
export function debug(...args: any[]): void {
|
|
94
94
|
debugLog(false, args);
|
|
95
95
|
}
|
|
@@ -97,7 +97,11 @@ export namespace log {
|
|
|
97
97
|
/**
|
|
98
98
|
* Do not use in frontend.
|
|
99
99
|
*/
|
|
100
|
-
export function enableJSONLogging(
|
|
100
|
+
export function enableJSONLogging(
|
|
101
|
+
componentArg: string,
|
|
102
|
+
versionArg: string | undefined,
|
|
103
|
+
logLevel?: LogrusLogLevel,
|
|
104
|
+
): void {
|
|
101
105
|
component = componentArg;
|
|
102
106
|
version = versionArg;
|
|
103
107
|
|
|
@@ -107,24 +111,32 @@ export namespace log {
|
|
|
107
111
|
export function setLogLevel(logLevel: LogrusLogLevel | undefined) {
|
|
108
112
|
jsonLogging = true;
|
|
109
113
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
console.error = function (...args: any[]): void {
|
|
115
|
+
errorLog(true, args);
|
|
116
|
+
};
|
|
117
|
+
console.warn = function (...args: any[]): void {
|
|
118
|
+
warnLog(true, args);
|
|
119
|
+
};
|
|
120
|
+
console.info = function (...args: any[]): void {
|
|
121
|
+
infoLog(true, args);
|
|
122
|
+
};
|
|
123
|
+
console.debug = function (...args: any[]): void {
|
|
124
|
+
debugLog(true, args);
|
|
119
125
|
};
|
|
120
|
-
|
|
121
|
-
console.error = setLog(errorLog, "error");
|
|
122
|
-
console.warn = setLog(warnLog, "warning");
|
|
123
|
-
console.info = setLog(infoLog, "info");
|
|
124
|
-
console.debug = setLog(debugLog, "debug");
|
|
125
126
|
|
|
126
127
|
console.log = console.info;
|
|
127
128
|
// FIXME wrap also other console methods (e.g. trace())
|
|
129
|
+
|
|
130
|
+
// set/unset log functions based on loglevel so we only have to evaluate once, not every call
|
|
131
|
+
const noop = () => {};
|
|
132
|
+
const setLog = (logFunc: DoLogFunction, funcLevel: LogrusLogLevel): DoLogFunction => {
|
|
133
|
+
return LogrusLogLevel.isGreatherOrEqual(funcLevel, logLevel) ? logFunc : noop;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
errorLog = setLog(doErrorLog, "error");
|
|
137
|
+
warnLog = setLog(doWarnLog, "warning");
|
|
138
|
+
infoLog = setLog(doInfoLog, "info");
|
|
139
|
+
debugLog = setLog(doDebugLog, "debug");
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
export function resetToDefaultLogging(): void {
|
|
@@ -142,24 +154,30 @@ export namespace log {
|
|
|
142
154
|
}
|
|
143
155
|
}
|
|
144
156
|
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
type DoLogFunction = (calledViaConsole: boolean, args: any[]) => void;
|
|
158
|
+
|
|
159
|
+
let errorLog = doErrorLog;
|
|
160
|
+
function doErrorLog(calledViaConsole: boolean, args: any[]): void {
|
|
161
|
+
doLog(calledViaConsole, errorConsoleLog, "ERROR", args);
|
|
147
162
|
}
|
|
148
163
|
|
|
149
|
-
|
|
150
|
-
|
|
164
|
+
let warnLog = doWarnLog;
|
|
165
|
+
function doWarnLog(calledViaConsole: boolean, args: any[]): void {
|
|
166
|
+
doLog(calledViaConsole, warnConsoleLog, "WARNING", args);
|
|
151
167
|
}
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
169
|
+
let infoLog = doInfoLog;
|
|
170
|
+
function doInfoLog(calledViaConsole: boolean, args: any[]): void {
|
|
171
|
+
doLog(calledViaConsole, infoConsoleLog, "INFO", args);
|
|
155
172
|
}
|
|
156
173
|
|
|
157
|
-
|
|
158
|
-
|
|
174
|
+
let debugLog = doDebugLog;
|
|
175
|
+
function doDebugLog(calledViaConsole: boolean, args: any[]): void {
|
|
176
|
+
doLog(calledViaConsole, debugConsoleLog, "DEBUG", args);
|
|
159
177
|
}
|
|
160
178
|
|
|
161
179
|
// Ref: https://github.com/sirupsen/logrus#level-logging
|
|
162
|
-
export type LogrusLogLevel = keyof
|
|
180
|
+
export type LogrusLogLevel = keyof typeof LogrusLogLevels;
|
|
163
181
|
export const LogrusLogLevels = {
|
|
164
182
|
trace: true,
|
|
165
183
|
debug: true,
|
|
@@ -168,7 +186,7 @@ export const LogrusLogLevels = {
|
|
|
168
186
|
error: true,
|
|
169
187
|
fatal: true,
|
|
170
188
|
panic: true,
|
|
171
|
-
}
|
|
189
|
+
};
|
|
172
190
|
export namespace LogrusLogLevel {
|
|
173
191
|
export function isGreatherOrEqual(lvl: LogrusLogLevel | undefined, ref: LogrusLogLevel | undefined): boolean {
|
|
174
192
|
if (lvl === undefined) {
|
|
@@ -180,8 +198,7 @@ export namespace LogrusLogLevel {
|
|
|
180
198
|
return getLevelArity(lvl) >= getLevelArity(ref);
|
|
181
199
|
}
|
|
182
200
|
function getLevelArity(lvl: LogrusLogLevel): number {
|
|
183
|
-
return Object.keys(LogrusLogLevels)
|
|
184
|
-
.findIndex((l) => l === lvl);
|
|
201
|
+
return Object.keys(LogrusLogLevels).findIndex((l) => l === lvl);
|
|
185
202
|
}
|
|
186
203
|
export function getFromEnv(): LogrusLogLevel | undefined {
|
|
187
204
|
const lvlStr = process.env.LOG_LEVEL;
|
|
@@ -189,7 +206,7 @@ export namespace LogrusLogLevel {
|
|
|
189
206
|
return undefined;
|
|
190
207
|
}
|
|
191
208
|
const lvl = lvlStr as LogrusLogLevel;
|
|
192
|
-
const exists = LogrusLogLevels[lvl]
|
|
209
|
+
const exists = LogrusLogLevels[lvl];
|
|
193
210
|
if (!exists) {
|
|
194
211
|
return undefined;
|
|
195
212
|
}
|
|
@@ -198,12 +215,12 @@ export namespace LogrusLogLevel {
|
|
|
198
215
|
}
|
|
199
216
|
|
|
200
217
|
// Source: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogSeverity
|
|
201
|
-
type GoogleLogSeverity =
|
|
218
|
+
type GoogleLogSeverity = "EMERGENCY" | "ALERT" | "CRITICAL" | "ERROR" | "WARNING" | "INFO" | "DEBUG";
|
|
202
219
|
namespace GoogleLogSeverity {
|
|
203
220
|
export const isGreaterOrEqualThanWarning = (severity: GoogleLogSeverity) => {
|
|
204
221
|
switch (severity) {
|
|
205
|
-
case
|
|
206
|
-
case
|
|
222
|
+
case "INFO":
|
|
223
|
+
case "DEBUG":
|
|
207
224
|
return false;
|
|
208
225
|
default:
|
|
209
226
|
return true;
|
|
@@ -231,7 +248,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
231
248
|
// console.xyz(Error, ...any) / log.xyz(Error) / log.xyz(Error, LogPayload)
|
|
232
249
|
error = args[0];
|
|
233
250
|
payloadArgs = args.slice(1);
|
|
234
|
-
} else if (typeof args[0] ===
|
|
251
|
+
} else if (typeof args[0] === "string") {
|
|
235
252
|
message = args[0];
|
|
236
253
|
if (args.length < 2 || !(args[1] instanceof Error)) {
|
|
237
254
|
// console.xyz(string) / console.xyz(string, !Error, ...any) / log.xyz(string) / log.xyz(string, LogPayload)
|
|
@@ -251,7 +268,7 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
251
268
|
// log.xyz(LogContext, Error) / log.xyz(LogContext, Error, LogPayload)
|
|
252
269
|
error = args[1];
|
|
253
270
|
payloadArgs = args.slice(2);
|
|
254
|
-
} else if (typeof args[1] ===
|
|
271
|
+
} else if (typeof args[1] === "string") {
|
|
255
272
|
message = args[1];
|
|
256
273
|
if (args.length < 3 || !(args[2] instanceof Error)) {
|
|
257
274
|
// log.xyz(LogContext, string) / log.xyz(LogContext, string, LogPayload)
|
|
@@ -274,9 +291,14 @@ function doLog(calledViaConsole: boolean, consoleLog: ConsoleLog, severity: Goog
|
|
|
274
291
|
}
|
|
275
292
|
}
|
|
276
293
|
|
|
277
|
-
function makeLogItem(
|
|
278
|
-
|
|
279
|
-
|
|
294
|
+
function makeLogItem(
|
|
295
|
+
severity: GoogleLogSeverity,
|
|
296
|
+
context: LogContext | undefined,
|
|
297
|
+
message: string | undefined,
|
|
298
|
+
error: Error | undefined,
|
|
299
|
+
payloadArgs: any[],
|
|
300
|
+
calledViaConsole: boolean,
|
|
301
|
+
): string | undefined {
|
|
280
302
|
if (context !== undefined && Object.keys(context).length == 0) {
|
|
281
303
|
context = undefined;
|
|
282
304
|
}
|
|
@@ -294,12 +316,11 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
|
|
|
294
316
|
severity,
|
|
295
317
|
time: new Date().toISOString(),
|
|
296
318
|
environment: process.env.KUBE_STAGE,
|
|
297
|
-
region: process.env.GITPOD_REGION,
|
|
298
319
|
context,
|
|
299
320
|
message,
|
|
300
321
|
error,
|
|
301
322
|
payload,
|
|
302
|
-
loggedViaConsole: calledViaConsole ? true : undefined
|
|
323
|
+
loggedViaConsole: calledViaConsole ? true : undefined,
|
|
303
324
|
};
|
|
304
325
|
let result: string = stringifyLogItem(logItem);
|
|
305
326
|
|
|
@@ -310,11 +331,11 @@ function makeLogItem(severity: GoogleLogSeverity, context: LogContext | undefine
|
|
|
310
331
|
result = stringifyLogItem(logItem);
|
|
311
332
|
|
|
312
333
|
if (result.length <= maxAllowedLogItemLength) {
|
|
313
|
-
log.warn(
|
|
334
|
+
log.warn("Log item too large, stripping payload", { logItemStub: makeLogItemStub(logItem) });
|
|
314
335
|
}
|
|
315
336
|
}
|
|
316
337
|
if (result.length > maxAllowedLogItemLength) {
|
|
317
|
-
log.error(
|
|
338
|
+
log.error("Log item too large w/o payload, discarding", { logItemStub: makeLogItemStub(logItem) });
|
|
318
339
|
return undefined;
|
|
319
340
|
}
|
|
320
341
|
|
|
@@ -328,10 +349,10 @@ function makeReportedErrorEvent(error: Error | undefined) {
|
|
|
328
349
|
// Serves as marker only
|
|
329
350
|
"@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
|
|
330
351
|
// This is useful for filtering in the UI
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}
|
|
352
|
+
serviceContext: {
|
|
353
|
+
service: component || "<ts-not-set>",
|
|
354
|
+
version: version || "<ts-not-set>",
|
|
355
|
+
},
|
|
335
356
|
};
|
|
336
357
|
|
|
337
358
|
if (error) {
|
|
@@ -351,9 +372,9 @@ function makeLogItemStub(logItem: any): any {
|
|
|
351
372
|
severity: logItem.severity,
|
|
352
373
|
time: logItem.time,
|
|
353
374
|
environment: logItem.environment,
|
|
354
|
-
region: logItem.region
|
|
375
|
+
region: logItem.region,
|
|
355
376
|
};
|
|
356
|
-
if (typeof
|
|
377
|
+
if (typeof logItem.message === "string") {
|
|
357
378
|
if (logItem.message.length <= maxMessageStubLength) {
|
|
358
379
|
result.message = logItem.message;
|
|
359
380
|
} else {
|
|
@@ -387,10 +408,12 @@ function stringifyLogItem(logItem: any): string {
|
|
|
387
408
|
* Jsonifies Errors properly, not as {} only.
|
|
388
409
|
*/
|
|
389
410
|
function jsonStringifyWithErrors(value: any): string {
|
|
390
|
-
return JSON.stringify(value, (key: string, value: any): any => {
|
|
411
|
+
return JSON.stringify(value, (key: string, value: any): any => {
|
|
412
|
+
return value instanceof Error ? value.stack : value;
|
|
413
|
+
});
|
|
391
414
|
}
|
|
392
415
|
|
|
393
|
-
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void;
|
|
416
|
+
type ConsoleLog = (message?: any, ...optionalArgs: any[]) => void; // signature of console.xyz
|
|
394
417
|
const logConsoleLog: ConsoleLog = console.log;
|
|
395
418
|
const errorConsoleLog: ConsoleLog = console.error;
|
|
396
419
|
const warnConsoleLog: ConsoleLog = console.warn;
|
package/src/util/make-link.ts
CHANGED
|
@@ -5,18 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
function isOpenNewTab(event: MouseEvent): boolean {
|
|
8
|
-
return event.metaKey ||
|
|
8
|
+
return event.metaKey || event.ctrlKey;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function makeLink(node: HTMLElement, url: string, hover: string): void {
|
|
12
|
-
node.onclick = event => {
|
|
13
|
-
let target =
|
|
12
|
+
node.onclick = (event) => {
|
|
13
|
+
let target = "_self";
|
|
14
14
|
if (isOpenNewTab(event)) {
|
|
15
|
-
target =
|
|
15
|
+
target = "_blank";
|
|
16
16
|
}
|
|
17
17
|
window.open(url, target);
|
|
18
|
-
}
|
|
19
|
-
node.style.cursor =
|
|
18
|
+
};
|
|
19
|
+
node.style.cursor = "pointer";
|
|
20
20
|
node.title = hover;
|
|
21
21
|
}
|
|
22
|
-
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import * as chai from
|
|
8
|
-
import { suite, test } from
|
|
9
|
-
import {
|
|
7
|
+
import * as chai from "chai";
|
|
8
|
+
import { suite, test } from "mocha-typescript";
|
|
9
|
+
import {
|
|
10
|
+
matchesInstanceIdOrLegacyWorkspaceIdExactly,
|
|
11
|
+
matchesNewWorkspaceIdExactly,
|
|
12
|
+
parseWorkspaceIdFromHostname,
|
|
13
|
+
} from "./parse-workspace-id";
|
|
10
14
|
const expect = chai.expect;
|
|
11
15
|
|
|
12
16
|
@suite
|
|
13
17
|
export class ParseWorkspaceIdTest {
|
|
14
|
-
|
|
15
18
|
@test public parseWorkspaceIdFromHostname_fromWorkspaceLocation() {
|
|
16
19
|
const actual = parseWorkspaceIdFromHostname("moccasin-ferret-155799b3.ws-eu01.gitpod.io");
|
|
17
20
|
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
@@ -28,7 +31,9 @@ export class ParseWorkspaceIdTest {
|
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
@test public parseWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
|
|
31
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
34
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
35
|
+
"webview-3000-moccasin-ferret-155799b3.ws-eu01.some.subdomain.somehost.com",
|
|
36
|
+
);
|
|
32
37
|
expect(actual).to.equal("moccasin-ferret-155799b3");
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -44,13 +49,37 @@ export class ParseWorkspaceIdTest {
|
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefix() {
|
|
47
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
52
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
53
|
+
"webview-3000-b7e0eaf8-ec73-44ec-81ea-04859263b656.ws-eu01.gitpod.io",
|
|
54
|
+
);
|
|
48
55
|
expect(actual).to.equal("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
@test public parseLegacyWorkspaceIdFromHostname_fromWorkspacePortLocationWithWebviewPrefixCustomHost() {
|
|
52
|
-
const actual = parseWorkspaceIdFromHostname(
|
|
59
|
+
const actual = parseWorkspaceIdFromHostname(
|
|
60
|
+
"webview-3000-ca81a50f-09d7-465c-acd9-264a747d5351.ws-eu01.some.subdomain.somehost.com",
|
|
61
|
+
);
|
|
53
62
|
expect(actual).to.equal("ca81a50f-09d7-465c-acd9-264a747d5351");
|
|
54
63
|
}
|
|
64
|
+
|
|
65
|
+
// match - instance ID
|
|
66
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_positive() {
|
|
67
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81ea-04859263b656");
|
|
68
|
+
expect(actual).to.be.true;
|
|
69
|
+
}
|
|
70
|
+
@test public matchesInstanceIdOrLegacyWorkspaceIdExactly_negative() {
|
|
71
|
+
const actual = matchesInstanceIdOrLegacyWorkspaceIdExactly("b7e0eaf8-ec73-44ec-81a-04859263b656");
|
|
72
|
+
expect(actual).to.be.false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// match - new workspace ID
|
|
76
|
+
@test public matchesWorkspaceIdExactly_new_positive() {
|
|
77
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-155799b3");
|
|
78
|
+
expect(actual).to.be.true;
|
|
79
|
+
}
|
|
80
|
+
@test public matchesWorkspaceIdExactly_new_negative() {
|
|
81
|
+
const actual = matchesNewWorkspaceIdExactly("moccasin-ferret-15599b3");
|
|
82
|
+
expect(actual).to.be.false;
|
|
83
|
+
}
|
|
55
84
|
}
|
|
56
|
-
module.exports = new ParseWorkspaceIdTest()
|
|
85
|
+
module.exports = new ParseWorkspaceIdTest();
|
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const REGEX_WORKSPACE_ID = /[0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8,11}/;
|
|
8
|
+
const REGEX_WORKSPACE_ID_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID.source}$`);
|
|
9
|
+
// We need to parse the workspace id precisely here to get the case '<some-str>-<port>-<wsid>.ws.' right
|
|
10
|
+
const REGEX_WORKSPACE_ID_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID.source})\.ws`);
|
|
11
|
+
|
|
12
|
+
const REGEX_WORKSPACE_ID_LEGACY = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
13
|
+
const REGEX_WORKSPACE_ID_LEGACY_EXACT = new RegExp(`^${REGEX_WORKSPACE_ID_LEGACY.source}$`);
|
|
14
|
+
const REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME = new RegExp(`(${REGEX_WORKSPACE_ID_LEGACY.source})\.ws`);
|
|
7
15
|
|
|
8
16
|
/**
|
|
9
17
|
* Hostname may be of the form:
|
|
@@ -12,18 +20,35 @@
|
|
|
12
20
|
* - webview-1234-moccasin-ferret-155799b3.ws-eu01.gitpod.io (or any other string replacing webview)
|
|
13
21
|
* @param hostname The hostname the request is headed to
|
|
14
22
|
*/
|
|
15
|
-
export const parseWorkspaceIdFromHostname = function(hostname: string) {
|
|
16
|
-
|
|
17
|
-
const wsIdExpression = /([0-9a-z]{2,16}-[0-9a-z]{2,16}-[0-9a-z]{8})\.ws/g;
|
|
18
|
-
const match = wsIdExpression.exec(hostname);
|
|
23
|
+
export const parseWorkspaceIdFromHostname = function (hostname: string) {
|
|
24
|
+
const match = REGEX_WORKSPACE_ID_FROM_HOSTNAME.exec(hostname);
|
|
19
25
|
if (match && match.length >= 2) {
|
|
20
26
|
return match[1];
|
|
21
27
|
} else {
|
|
22
|
-
const
|
|
23
|
-
const legacyMatch = legacyUrlFormat.exec(hostname);
|
|
28
|
+
const legacyMatch = REGEX_WORKSPACE_ID_LEGACY_FROM_HOSTNAME.exec(hostname);
|
|
24
29
|
if (legacyMatch && legacyMatch.length >= 2) {
|
|
25
30
|
return legacyMatch[1];
|
|
26
31
|
}
|
|
27
32
|
return undefined;
|
|
28
33
|
}
|
|
29
|
-
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Equalls UUIDv4 (and REGEX_WORKSPACE_ID_LEGACY!) */
|
|
37
|
+
const REGEX_INSTANCE_ID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/;
|
|
38
|
+
const REGEX_INSTANCE_ID_EXACT = new RegExp(`^${REGEX_INSTANCE_ID.source}$`);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @param maybeId
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
export const matchesInstanceIdOrLegacyWorkspaceIdExactly = function (maybeId: string): boolean {
|
|
45
|
+
return REGEX_INSTANCE_ID_EXACT.test(maybeId) || REGEX_WORKSPACE_ID_LEGACY_EXACT.test(maybeId);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param maybeWorkspaceId
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
export const matchesNewWorkspaceIdExactly = function (maybeWorkspaceId: string): boolean {
|
|
53
|
+
return REGEX_WORKSPACE_ID_EXACT.test(maybeWorkspaceId);
|
|
54
|
+
};
|
package/src/util/queue.spec.ts
CHANGED
|
@@ -4,19 +4,19 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { suite, test, slow, timeout } from
|
|
8
|
-
import * as chai from
|
|
9
|
-
const chaiSubset = require(
|
|
7
|
+
import { suite, test, slow, timeout } from "mocha-typescript";
|
|
8
|
+
import * as chai from "chai";
|
|
9
|
+
const chaiSubset = require("chai-subset");
|
|
10
10
|
chai.use(chaiSubset);
|
|
11
11
|
|
|
12
|
-
import { Queue } from
|
|
13
|
-
import { fail } from
|
|
14
|
-
import { Deferred } from
|
|
12
|
+
import { Queue } from "..";
|
|
13
|
+
import { fail } from "assert";
|
|
14
|
+
import { Deferred } from "./deferred";
|
|
15
15
|
|
|
16
|
-
const expect = chai.expect
|
|
17
|
-
|
|
18
|
-
@suite class QueueSpec {
|
|
16
|
+
const expect = chai.expect;
|
|
19
17
|
|
|
18
|
+
@suite
|
|
19
|
+
class QueueSpec {
|
|
20
20
|
queue: Queue;
|
|
21
21
|
seq: number[];
|
|
22
22
|
|
|
@@ -35,8 +35,7 @@ const expect = chai.expect
|
|
|
35
35
|
resolve(undefined);
|
|
36
36
|
}, sleep);
|
|
37
37
|
});
|
|
38
|
-
else
|
|
39
|
-
this.seq.push(seqNr);
|
|
38
|
+
else this.seq.push(seqNr);
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
if (nextTick)
|
|
@@ -45,20 +44,22 @@ const expect = chai.expect
|
|
|
45
44
|
push().then(resolve);
|
|
46
45
|
});
|
|
47
46
|
});
|
|
48
|
-
else
|
|
49
|
-
await push();
|
|
47
|
+
else await push();
|
|
50
48
|
});
|
|
51
49
|
}
|
|
52
50
|
execError(seqNr: number): Deferred<boolean> {
|
|
53
51
|
const deferred = new Deferred<boolean>();
|
|
54
|
-
this.queue
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
this.queue
|
|
53
|
+
.enqueue(async () => {
|
|
54
|
+
this.seq.push(seqNr);
|
|
55
|
+
throw new Error("test error");
|
|
56
|
+
})
|
|
57
|
+
.then(() => {
|
|
58
|
+
deferred.reject(false);
|
|
59
|
+
})
|
|
60
|
+
.catch(() => {
|
|
61
|
+
deferred.resolve(true);
|
|
62
|
+
});
|
|
62
63
|
|
|
63
64
|
return deferred;
|
|
64
65
|
}
|
|
@@ -67,7 +68,9 @@ const expect = chai.expect
|
|
|
67
68
|
expect(actual).to.have.lengthOf(expected.length);
|
|
68
69
|
const expIt = expected.entries();
|
|
69
70
|
for (const act of actual) {
|
|
70
|
-
const {
|
|
71
|
+
const {
|
|
72
|
+
value: [, exp],
|
|
73
|
+
} = expIt.next();
|
|
71
74
|
expect(act).to.deep.equal(exp);
|
|
72
75
|
}
|
|
73
76
|
}
|
|
@@ -93,7 +96,6 @@ const expect = chai.expect
|
|
|
93
96
|
this.expectArray(this.seq, [1, 2]);
|
|
94
97
|
}
|
|
95
98
|
|
|
96
|
-
|
|
97
99
|
@test public async continueDespiteError() {
|
|
98
100
|
this.exec(1);
|
|
99
101
|
const receivedError = this.execError(2);
|
|
@@ -107,7 +109,7 @@ const expect = chai.expect
|
|
|
107
109
|
@test public async mustCatchError() {
|
|
108
110
|
const f = async () => {
|
|
109
111
|
throw new Error();
|
|
110
|
-
}
|
|
112
|
+
};
|
|
111
113
|
try {
|
|
112
114
|
const p = this.queue.enqueue(async () => {
|
|
113
115
|
return f();
|
|
@@ -124,7 +126,7 @@ const expect = chai.expect
|
|
|
124
126
|
@test public async expectUncaughtError() {
|
|
125
127
|
const f = async () => {
|
|
126
128
|
throw new Error();
|
|
127
|
-
}
|
|
129
|
+
};
|
|
128
130
|
const p = this.queue.enqueue(async () => {
|
|
129
131
|
return f();
|
|
130
132
|
});
|