@gitpod/gitpod-protocol 0.1.5-tarun-telemetry-users.9 → 0.1.5-team-conns.1
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 +28 -2
- package/lib/accounting-protocol.d.ts +10 -10
- package/lib/accounting-protocol.d.ts.map +1 -1
- package/lib/accounting-protocol.js +22 -31
- package/lib/accounting-protocol.js.map +1 -1
- package/lib/admin-protocol.d.ts +4 -2
- package/lib/admin-protocol.d.ts.map +1 -1
- package/lib/admin-protocol.js.map +1 -1
- package/lib/analytics.d.ts +4 -5
- 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/connections.d.ts +14 -0
- package/lib/connections.d.ts.map +1 -0
- package/lib/{theia-plugins.js → connections.js} +2 -2
- package/lib/connections.js.map +1 -0
- package/lib/context-url.d.ts +17 -5
- package/lib/context-url.d.ts.map +1 -1
- package/lib/context-url.js +57 -6
- 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 +40 -4
- 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.map +1 -1
- package/lib/encryption/container-module.d.ts.map +1 -1
- package/lib/encryption/container-module.js +1 -1
- 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 +7 -7
- 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 +2 -3
- 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 +1 -1
- 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 +7 -9
- package/lib/encryption/key-provider.js.map +1 -1
- package/lib/env.d.ts +1 -1
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -5
- package/lib/env.js.map +1 -1
- package/lib/gitpod-file-parser.d.ts.map +1 -1
- package/lib/gitpod-file-parser.js +6 -6
- package/lib/gitpod-file-parser.js.map +1 -1
- package/lib/gitpod-file-parser.spec.js +42 -39
- package/lib/gitpod-file-parser.spec.js.map +1 -1
- package/lib/gitpod-service.d.ts +28 -24
- package/lib/gitpod-service.d.ts.map +1 -1
- package/lib/gitpod-service.js +21 -24
- 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 +10 -6
- package/lib/ide-protocol.d.ts.map +1 -1
- package/lib/index.d.ts +17 -16
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/installation-admin-protocol.d.ts +1 -1
- package/lib/installation-admin-protocol.d.ts.map +1 -1
- package/lib/installation-admin-protocol.js +2 -2
- package/lib/installation-admin-protocol.js.map +1 -1
- package/lib/license-protocol.d.ts.map +1 -1
- package/lib/license-protocol.js.map +1 -1
- package/lib/messaging/browser/connection.d.ts +1 -1
- package/lib/messaging/browser/connection.d.ts.map +1 -1
- package/lib/messaging/browser/connection.js +19 -19
- 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 +9 -6
- 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 +20 -20
- package/lib/messaging/client-call-metrics.js.map +1 -1
- package/lib/messaging/error.d.ts.map +1 -1
- package/lib/messaging/error.js.map +1 -1
- package/lib/messaging/handler.d.ts.map +1 -1
- package/lib/messaging/handler.js +1 -1
- package/lib/messaging/node/connection.js +8 -8
- package/lib/messaging/node/connection.js.map +1 -1
- package/lib/messaging/proxy-factory.d.ts +1 -1
- package/lib/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/messaging/proxy-factory.js +7 -9
- package/lib/messaging/proxy-factory.js.map +1 -1
- 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 +5 -2
- package/lib/permission.d.ts.map +1 -1
- package/lib/permission.js +30 -25
- package/lib/permission.js.map +1 -1
- package/lib/plans.d.ts +3 -3
- package/lib/plans.d.ts.map +1 -1
- package/lib/plans.js +206 -171
- package/lib/plans.js.map +1 -1
- package/lib/protocol.d.ts +51 -37
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +81 -86
- package/lib/protocol.js.map +1 -1
- package/lib/snapshot-url.spec.js.map +1 -1
- 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 +4 -4
- package/lib/team-subscription-protocol.js.map +1 -1
- package/lib/teams-projects-protocol.d.ts +3 -3
- package/lib/teams-projects-protocol.d.ts.map +1 -1
- package/lib/teams-projects-protocol.js +1 -1
- 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 +12 -3
- package/lib/util/analytics.js.map +1 -1
- package/lib/util/async-iterator.d.ts.map +1 -1
- package/lib/util/async-iterator.js +3 -3
- package/lib/util/async-iterator.js.map +1 -1
- package/lib/util/cancelable.js.map +1 -1
- package/lib/util/date-time.js +6 -6
- package/lib/util/date-time.js.map +1 -1
- package/lib/util/deferred.js.map +1 -1
- package/lib/util/disposable.d.ts.map +1 -1
- package/lib/util/disposable.js +2 -2
- package/lib/util/disposable.js.map +1 -1
- package/lib/util/event.d.ts.map +1 -1
- package/lib/util/event.js +5 -3
- package/lib/util/event.js.map +1 -1
- package/lib/util/garbage-collected-cache.d.ts.map +1 -1
- package/lib/util/garbage-collected-cache.js +1 -1
- package/lib/util/garbage-collected-cache.js.map +1 -1
- package/lib/util/generate-workspace-id.d.ts.map +1 -1
- package/lib/util/generate-workspace-id.js +435 -435
- package/lib/util/generate-workspace-id.js.map +1 -1
- package/lib/util/generate-workspace-id.spec.js +10 -6
- package/lib/util/generate-workspace-id.spec.js.map +1 -1
- package/lib/util/gitpod-cookie.d.ts +1 -1
- package/lib/util/gitpod-cookie.d.ts.map +1 -1
- package/lib/util/gitpod-cookie.js +0 -3
- package/lib/util/gitpod-cookie.js.map +1 -1
- package/lib/util/gitpod-host-url.d.ts.map +1 -1
- package/lib/util/gitpod-host-url.js +31 -29
- 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 +15 -5
- 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.map +1 -1
- package/lib/util/jaeger-client-types.d.ts.map +1 -1
- package/lib/util/logging.d.ts +1 -1
- package/lib/util/logging.d.ts.map +1 -1
- package/lib/util/logging.js +22 -23
- 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.map +1 -1
- package/lib/util/parse-workspace-id.js +1 -2
- package/lib/util/parse-workspace-id.js.map +1 -1
- package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
- package/lib/util/parse-workspace-id.spec.js.map +1 -1
- package/lib/util/queue.spec.js +9 -6
- package/lib/util/queue.spec.js.map +1 -1
- package/lib/util/semaphore.d.ts.map +1 -1
- package/lib/util/semaphore.js.map +1 -1
- package/lib/util/skip-if.d.ts.map +1 -1
- package/lib/util/skip-if.js.map +1 -1
- package/lib/util/timeutil.d.ts.map +1 -1
- package/lib/util/timeutil.js +2 -2
- package/lib/util/timeutil.js.map +1 -1
- package/lib/util/timeutil.spec.d.ts.map +1 -1
- package/lib/util/timeutil.spec.js.map +1 -1
- package/lib/util/tracing.d.ts +8 -8
- package/lib/util/tracing.d.ts.map +1 -1
- package/lib/util/tracing.js +19 -18
- package/lib/util/tracing.js.map +1 -1
- package/lib/util/tracing.spec.js +3 -3
- package/lib/util/tracing.spec.js.map +1 -1
- 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 +8 -11
- package/lib/util/workspace-port-authentication.js.map +1 -1
- package/lib/workspace-cluster.d.ts +8 -3
- package/lib/workspace-cluster.d.ts.map +1 -1
- package/lib/workspace-cluster.js +16 -1
- package/lib/workspace-cluster.js.map +1 -1
- package/lib/workspace-instance.d.ts +2 -2
- 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 +2 -2
- package/pkg-yarn.lock +2 -2
- package/provenance-bundle.jsonl +1 -1
- package/src/accounting-protocol.ts +53 -51
- package/src/admin-protocol.ts +25 -21
- package/src/analytics.ts +26 -28
- package/src/auth.ts +2 -2
- package/src/connections.ts +16 -0
- package/src/context-url.spec.ts +37 -9
- package/src/context-url.ts +96 -40
- 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 -9
- package/src/gitpod-file-parser.spec.ts +55 -61
- package/src/gitpod-file-parser.ts +16 -17
- package/src/gitpod-service.ts +129 -99
- package/src/headless-workspace-log.ts +6 -4
- package/src/ide-frontend-service.ts +2 -2
- package/src/ide-protocol.ts +13 -8
- package/src/index.ts +17 -16
- package/src/installation-admin-protocol.ts +9 -9
- package/src/license-protocol.ts +5 -6
- package/src/messaging/browser/connection.ts +45 -47
- package/src/messaging/browser/window-connection.ts +39 -29
- package/src/messaging/client-call-metrics.ts +70 -71
- package/src/messaging/error.ts +1 -3
- package/src/messaging/handler.ts +6 -6
- package/src/messaging/node/connection.ts +8 -8
- package/src/messaging/proxy-factory.ts +23 -30
- package/src/oss-allowlist.ts +3 -3
- package/src/payment-protocol.ts +2 -2
- package/src/permission.ts +35 -32
- package/src/plans.ts +236 -189
- package/src/protocol.ts +232 -238
- package/src/snapshot-url.spec.ts +9 -7
- package/src/team-subscription-protocol.ts +33 -23
- package/src/teams-projects-protocol.ts +8 -8
- package/src/typings/globals.ts +4 -4
- package/src/util/analytics.ts +46 -24
- 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 +3 -6
- package/src/util/generate-workspace-id.spec.ts +18 -15
- package/src/util/generate-workspace-id.ts +453 -453
- package/src/util/gitpod-cookie.ts +8 -9
- package/src/util/gitpod-host-url.spec.ts +40 -13
- package/src/util/gitpod-host-url.ts +37 -34
- package/src/util/grpc.ts +1 -1
- package/src/util/jaeger-client-types.ts +2 -2
- package/src/util/logging.ts +49 -39
- package/src/util/make-link.ts +6 -7
- package/src/util/parse-workspace-id.spec.ts +17 -8
- package/src/util/parse-workspace-id.ts +5 -6
- package/src/util/queue.spec.ts +27 -25
- package/src/util/repeat.ts +1 -1
- 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 +28 -23
- package/src/util/tracing.ts +58 -52
- package/src/util/workspace-port-authentication.ts +10 -13
- package/src/workspace-cluster.ts +24 -8
- package/src/workspace-instance.ts +27 -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 -34
- 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/src/messaging/connection-error-handler.ts +0 -62
- package/src/theia-plugins.ts +0 -11
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
import { MessageConnection, ResponseError } from "vscode-jsonrpc";
|
|
9
9
|
import { Event, Emitter } from "../util/event";
|
|
10
10
|
import { Disposable } from "../util/disposable";
|
|
11
|
-
import { ConnectionHandler } from
|
|
12
|
-
import { log } from
|
|
11
|
+
import { ConnectionHandler } from "./handler";
|
|
12
|
+
import { log } from "../util/logging";
|
|
13
13
|
|
|
14
14
|
export type JsonRpcServer<Client> = Disposable & {
|
|
15
15
|
/**
|
|
@@ -27,10 +27,7 @@ export interface JsonRpcConnectionEventEmitter {
|
|
|
27
27
|
export type JsonRpcProxy<T> = T & JsonRpcConnectionEventEmitter;
|
|
28
28
|
|
|
29
29
|
export class JsonRpcConnectionHandler<T extends object> implements ConnectionHandler {
|
|
30
|
-
constructor(
|
|
31
|
-
readonly path: string,
|
|
32
|
-
readonly targetFactory: (proxy: JsonRpcProxy<T>, request?: object) => any
|
|
33
|
-
) { }
|
|
30
|
+
constructor(readonly path: string, readonly targetFactory: (proxy: JsonRpcProxy<T>, request?: object) => any) {}
|
|
34
31
|
|
|
35
32
|
onConnection(connection: MessageConnection, request?: object): void {
|
|
36
33
|
const factory = new JsonRpcProxyFactory<T>();
|
|
@@ -83,7 +80,6 @@ export class JsonRpcConnectionHandler<T extends object> implements ConnectionHan
|
|
|
83
80
|
* @param <T> - The type of the object to expose to JSON-RPC.
|
|
84
81
|
*/
|
|
85
82
|
export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
|
|
86
|
-
|
|
87
83
|
protected readonly onDidOpenConnectionEmitter = new Emitter<void>();
|
|
88
84
|
protected readonly onDidCloseConnectionEmitter = new Emitter<void>();
|
|
89
85
|
|
|
@@ -101,17 +97,15 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
|
|
|
101
97
|
}
|
|
102
98
|
|
|
103
99
|
protected waitForConnection(): void {
|
|
104
|
-
this.connectionPromise = new Promise(resolve =>
|
|
105
|
-
|
|
106
|
-
);
|
|
107
|
-
this.connectionPromise.then(connection => {
|
|
100
|
+
this.connectionPromise = new Promise((resolve) => (this.connectionPromiseResolve = resolve));
|
|
101
|
+
this.connectionPromise.then((connection) => {
|
|
108
102
|
connection.onClose(() => this.fireConnectionClosed());
|
|
109
103
|
this.fireConnectionOpened();
|
|
110
104
|
});
|
|
111
105
|
}
|
|
112
106
|
|
|
113
107
|
fireConnectionClosed() {
|
|
114
|
-
this.onDidCloseConnectionEmitter.fire(undefined)
|
|
108
|
+
this.onDidCloseConnectionEmitter.fire(undefined);
|
|
115
109
|
}
|
|
116
110
|
|
|
117
111
|
fireConnectionOpened() {
|
|
@@ -204,35 +198,34 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
|
|
|
204
198
|
* @returns A callable that executes the JSON-RPC call.
|
|
205
199
|
*/
|
|
206
200
|
get(target: T, p: PropertyKey, receiver: any): any {
|
|
207
|
-
if (p ===
|
|
201
|
+
if (p === "setClient") {
|
|
208
202
|
return (client: any) => {
|
|
209
203
|
this.target = client;
|
|
210
204
|
};
|
|
211
205
|
}
|
|
212
|
-
if (p ===
|
|
206
|
+
if (p === "onDidOpenConnection") {
|
|
213
207
|
return this.onDidOpenConnectionEmitter.event;
|
|
214
208
|
}
|
|
215
|
-
if (p ===
|
|
209
|
+
if (p === "onDidCloseConnection") {
|
|
216
210
|
return this.onDidCloseConnectionEmitter.event;
|
|
217
211
|
}
|
|
218
212
|
const isNotify = this.isNotification(p);
|
|
219
213
|
return (...args: any[]) =>
|
|
220
|
-
this.connectionPromise.then(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
.catch((err: any) => reject(err))
|
|
230
|
-
|
|
214
|
+
this.connectionPromise.then(
|
|
215
|
+
(connection) =>
|
|
216
|
+
new Promise((resolve, reject) => {
|
|
217
|
+
try {
|
|
218
|
+
if (isNotify) {
|
|
219
|
+
connection.sendNotification(p.toString(), ...args);
|
|
220
|
+
resolve(undefined);
|
|
221
|
+
} else {
|
|
222
|
+
const resultPromise = connection.sendRequest(p.toString(), ...args) as Promise<any>;
|
|
223
|
+
resultPromise.catch((err: any) => reject(err)).then((result: any) => resolve(result));
|
|
224
|
+
}
|
|
225
|
+
} catch (err) {
|
|
226
|
+
reject(err);
|
|
231
227
|
}
|
|
232
|
-
}
|
|
233
|
-
reject(err);
|
|
234
|
-
}
|
|
235
|
-
})
|
|
228
|
+
}),
|
|
236
229
|
);
|
|
237
230
|
}
|
|
238
231
|
|
package/src/oss-allowlist.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface OssAllowList {
|
|
|
9
9
|
* A string that identifies a GitHub/GitLab/Bitbucket identity of the form "<host>/<profilename>"
|
|
10
10
|
* E.g., "github.com/geropl"
|
|
11
11
|
*/
|
|
12
|
-
identity: string
|
|
12
|
+
identity: string;
|
|
13
13
|
|
|
14
|
-
deleted?: boolean
|
|
15
|
-
}
|
|
14
|
+
deleted?: boolean;
|
|
15
|
+
}
|
package/src/payment-protocol.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
export const UPDATE_GITPOD_SUBSCRIPTION_PATH =
|
|
7
|
+
export namespace PaymentProtocol {
|
|
8
|
+
export const UPDATE_GITPOD_SUBSCRIPTION_PATH = "/payment/chargebee";
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface PlanCoupon {
|
package/src/permission.ts
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
* See License-AGPL.txt in the project root for license information.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
// see below for explanation
|
|
9
8
|
export const Permissions = {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
monitor: undefined,
|
|
10
|
+
enforcement: undefined,
|
|
12
11
|
"privileged-ws": undefined,
|
|
13
12
|
"registry-access": undefined,
|
|
14
13
|
"admin-users": undefined,
|
|
@@ -18,21 +17,36 @@ export const Permissions = {
|
|
|
18
17
|
"ide-settings": undefined,
|
|
19
18
|
"new-workspace-cluster": undefined,
|
|
20
19
|
};
|
|
21
|
-
export type PermissionName = keyof
|
|
22
|
-
export const Roles = {
|
|
23
|
-
export type RoleName = keyof
|
|
20
|
+
export type PermissionName = keyof typeof Permissions;
|
|
21
|
+
export const Roles = { devops: undefined, viewer: undefined, admin: undefined };
|
|
22
|
+
export type RoleName = keyof typeof Roles;
|
|
24
23
|
export type RoleOrPermission = RoleName | PermissionName;
|
|
25
24
|
|
|
26
25
|
export namespace RoleName {
|
|
27
26
|
export const is = (o: any): o is RoleName => {
|
|
28
|
-
return typeof(
|
|
29
|
-
|
|
30
|
-
}
|
|
27
|
+
return typeof o === "string" && Role.all().some((r) => r.name === o);
|
|
28
|
+
};
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
export interface Role {
|
|
34
|
-
name: RoleName
|
|
35
|
-
permissions: PermissionName[]
|
|
32
|
+
name: RoleName;
|
|
33
|
+
permissions: PermissionName[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export namespace RolesOrPermissions {
|
|
37
|
+
export function toPermissionSet(rolesOrPermissions: RoleOrPermission[] | undefined): Set<PermissionName> {
|
|
38
|
+
rolesOrPermissions = rolesOrPermissions || [];
|
|
39
|
+
|
|
40
|
+
const permissions = new Set<PermissionName>();
|
|
41
|
+
for (const rop of rolesOrPermissions) {
|
|
42
|
+
if (Permission.is(rop)) {
|
|
43
|
+
permissions.add(rop);
|
|
44
|
+
} else if (RoleName.is(rop)) {
|
|
45
|
+
Role.getByName(rop).permissions.forEach((p) => permissions.add(p));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return permissions;
|
|
49
|
+
}
|
|
36
50
|
}
|
|
37
51
|
|
|
38
52
|
export namespace Permission {
|
|
@@ -61,14 +75,11 @@ export namespace Permission {
|
|
|
61
75
|
export const IDE_SETTINGS: PermissionName = "ide-settings";
|
|
62
76
|
|
|
63
77
|
export const is = (o: any): o is PermissionName => {
|
|
64
|
-
return typeof(
|
|
65
|
-
|
|
66
|
-
}
|
|
78
|
+
return typeof o === "string" && Permission.all().some((p) => p === o);
|
|
79
|
+
};
|
|
67
80
|
|
|
68
81
|
export const all = (): PermissionName[] => {
|
|
69
|
-
return Object.keys(
|
|
70
|
-
.map(k => (Permission as any)[k])
|
|
71
|
-
.filter(k => typeof(k) === 'string');
|
|
82
|
+
return Object.keys(Permissions) as PermissionName[];
|
|
72
83
|
};
|
|
73
84
|
}
|
|
74
85
|
|
|
@@ -76,21 +87,13 @@ export namespace Role {
|
|
|
76
87
|
/** The default role for all Gitpod developers */
|
|
77
88
|
export const DEVOPS: Role = {
|
|
78
89
|
name: "devops",
|
|
79
|
-
permissions: [
|
|
80
|
-
Permission.MONITOR,
|
|
81
|
-
Permission.ENFORCEMENT,
|
|
82
|
-
Permission.REGISTRY_ACCESS,
|
|
83
|
-
Permission.IDE_SETTINGS
|
|
84
|
-
]
|
|
90
|
+
permissions: [Permission.MONITOR, Permission.ENFORCEMENT, Permission.REGISTRY_ACCESS, Permission.IDE_SETTINGS],
|
|
85
91
|
};
|
|
86
92
|
|
|
87
93
|
/** A role for people that are allowed to view Gitpod internals */
|
|
88
94
|
export const VIEWER: Role = {
|
|
89
95
|
name: "viewer",
|
|
90
|
-
permissions: [
|
|
91
|
-
Permission.MONITOR,
|
|
92
|
-
Permission.REGISTRY_ACCESS,
|
|
93
|
-
]
|
|
96
|
+
permissions: [Permission.MONITOR, Permission.REGISTRY_ACCESS],
|
|
94
97
|
};
|
|
95
98
|
|
|
96
99
|
export const ADMIN: Role = {
|
|
@@ -101,11 +104,11 @@ export namespace Role {
|
|
|
101
104
|
Permission.ADMIN_PROJECTS,
|
|
102
105
|
Permission.ADMIN_API,
|
|
103
106
|
Permission.ENFORCEMENT,
|
|
104
|
-
]
|
|
105
|
-
}
|
|
107
|
+
],
|
|
108
|
+
};
|
|
106
109
|
|
|
107
110
|
export const getByName = (name: RoleName): Role => {
|
|
108
|
-
const result = Role.all().find(r => r.name === name)
|
|
111
|
+
const result = Role.all().find((r) => r.name === name);
|
|
109
112
|
if (!result) {
|
|
110
113
|
throw Error("Unknown RoleName: " + name);
|
|
111
114
|
}
|
|
@@ -114,7 +117,7 @@ export namespace Role {
|
|
|
114
117
|
|
|
115
118
|
export const all = (): Role[] => {
|
|
116
119
|
return Object.keys(Role)
|
|
117
|
-
.map(k => (Role as any)[k])
|
|
118
|
-
.filter(k => typeof
|
|
120
|
+
.map((k) => (Role as any)[k])
|
|
121
|
+
.filter((k) => typeof k === "object");
|
|
119
122
|
};
|
|
120
123
|
}
|