@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.
Files changed (281) hide show
  1. package/data/gitpod-schema.json +28 -2
  2. package/lib/accounting-protocol.d.ts +10 -10
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +22 -31
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +4 -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 +4 -5
  10. package/lib/analytics.d.ts.map +1 -1
  11. package/lib/analytics.js.map +1 -1
  12. package/lib/auth.d.ts.map +1 -1
  13. package/lib/connections.d.ts +14 -0
  14. package/lib/connections.d.ts.map +1 -0
  15. package/lib/{theia-plugins.js → connections.js} +2 -2
  16. package/lib/connections.js.map +1 -0
  17. package/lib/context-url.d.ts +17 -5
  18. package/lib/context-url.d.ts.map +1 -1
  19. package/lib/context-url.js +57 -6
  20. package/lib/context-url.js.map +1 -1
  21. package/lib/context-url.spec.d.ts +2 -0
  22. package/lib/context-url.spec.d.ts.map +1 -1
  23. package/lib/context-url.spec.js +40 -4
  24. package/lib/context-url.spec.js.map +1 -1
  25. package/lib/email-protocol.d.ts +1 -1
  26. package/lib/email-protocol.d.ts.map +1 -1
  27. package/lib/email-protocol.js.map +1 -1
  28. package/lib/encryption/container-module.d.ts.map +1 -1
  29. package/lib/encryption/container-module.js +1 -1
  30. package/lib/encryption/container-module.js.map +1 -1
  31. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  32. package/lib/encryption/encryption-engine.js +7 -7
  33. package/lib/encryption/encryption-engine.js.map +1 -1
  34. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  35. package/lib/encryption/encryption-engine.spec.js +2 -3
  36. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  37. package/lib/encryption/encryption-service.d.ts.map +1 -1
  38. package/lib/encryption/encryption-service.js +1 -1
  39. package/lib/encryption/encryption-service.js.map +1 -1
  40. package/lib/encryption/key-provider.d.ts.map +1 -1
  41. package/lib/encryption/key-provider.js +7 -9
  42. package/lib/encryption/key-provider.js.map +1 -1
  43. package/lib/env.d.ts +1 -1
  44. package/lib/env.d.ts.map +1 -1
  45. package/lib/env.js +5 -5
  46. package/lib/env.js.map +1 -1
  47. package/lib/gitpod-file-parser.d.ts.map +1 -1
  48. package/lib/gitpod-file-parser.js +6 -6
  49. package/lib/gitpod-file-parser.js.map +1 -1
  50. package/lib/gitpod-file-parser.spec.js +42 -39
  51. package/lib/gitpod-file-parser.spec.js.map +1 -1
  52. package/lib/gitpod-service.d.ts +28 -24
  53. package/lib/gitpod-service.d.ts.map +1 -1
  54. package/lib/gitpod-service.js +21 -24
  55. package/lib/gitpod-service.js.map +1 -1
  56. package/lib/headless-workspace-log.d.ts +1 -0
  57. package/lib/headless-workspace-log.d.ts.map +1 -1
  58. package/lib/headless-workspace-log.js +2 -1
  59. package/lib/headless-workspace-log.js.map +1 -1
  60. package/lib/ide-frontend-service.d.ts +1 -1
  61. package/lib/ide-protocol.d.ts +10 -6
  62. package/lib/ide-protocol.d.ts.map +1 -1
  63. package/lib/index.d.ts +17 -16
  64. package/lib/index.d.ts.map +1 -1
  65. package/lib/index.js +1 -0
  66. package/lib/index.js.map +1 -1
  67. package/lib/installation-admin-protocol.d.ts +1 -1
  68. package/lib/installation-admin-protocol.d.ts.map +1 -1
  69. package/lib/installation-admin-protocol.js +2 -2
  70. package/lib/installation-admin-protocol.js.map +1 -1
  71. package/lib/license-protocol.d.ts.map +1 -1
  72. package/lib/license-protocol.js.map +1 -1
  73. package/lib/messaging/browser/connection.d.ts +1 -1
  74. package/lib/messaging/browser/connection.d.ts.map +1 -1
  75. package/lib/messaging/browser/connection.js +19 -19
  76. package/lib/messaging/browser/connection.js.map +1 -1
  77. package/lib/messaging/browser/window-connection.d.ts +4 -4
  78. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  79. package/lib/messaging/browser/window-connection.js +9 -6
  80. package/lib/messaging/browser/window-connection.js.map +1 -1
  81. package/lib/messaging/client-call-metrics.d.ts +2 -2
  82. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  83. package/lib/messaging/client-call-metrics.js +20 -20
  84. package/lib/messaging/client-call-metrics.js.map +1 -1
  85. package/lib/messaging/error.d.ts.map +1 -1
  86. package/lib/messaging/error.js.map +1 -1
  87. package/lib/messaging/handler.d.ts.map +1 -1
  88. package/lib/messaging/handler.js +1 -1
  89. package/lib/messaging/node/connection.js +8 -8
  90. package/lib/messaging/node/connection.js.map +1 -1
  91. package/lib/messaging/proxy-factory.d.ts +1 -1
  92. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  93. package/lib/messaging/proxy-factory.js +7 -9
  94. package/lib/messaging/proxy-factory.js.map +1 -1
  95. package/lib/payment-protocol.d.ts.map +1 -1
  96. package/lib/payment-protocol.js +1 -1
  97. package/lib/payment-protocol.js.map +1 -1
  98. package/lib/permission.d.ts +5 -2
  99. package/lib/permission.d.ts.map +1 -1
  100. package/lib/permission.js +30 -25
  101. package/lib/permission.js.map +1 -1
  102. package/lib/plans.d.ts +3 -3
  103. package/lib/plans.d.ts.map +1 -1
  104. package/lib/plans.js +206 -171
  105. package/lib/plans.js.map +1 -1
  106. package/lib/protocol.d.ts +51 -37
  107. package/lib/protocol.d.ts.map +1 -1
  108. package/lib/protocol.js +81 -86
  109. package/lib/protocol.js.map +1 -1
  110. package/lib/snapshot-url.spec.js.map +1 -1
  111. package/lib/team-subscription-protocol.d.ts +5 -3
  112. package/lib/team-subscription-protocol.d.ts.map +1 -1
  113. package/lib/team-subscription-protocol.js +4 -4
  114. package/lib/team-subscription-protocol.js.map +1 -1
  115. package/lib/teams-projects-protocol.d.ts +3 -3
  116. package/lib/teams-projects-protocol.d.ts.map +1 -1
  117. package/lib/teams-projects-protocol.js +1 -1
  118. package/lib/teams-projects-protocol.js.map +1 -1
  119. package/lib/typings/globals.d.ts +2 -2
  120. package/lib/typings/globals.d.ts.map +1 -1
  121. package/lib/util/analytics.d.ts.map +1 -1
  122. package/lib/util/analytics.js +12 -3
  123. package/lib/util/analytics.js.map +1 -1
  124. package/lib/util/async-iterator.d.ts.map +1 -1
  125. package/lib/util/async-iterator.js +3 -3
  126. package/lib/util/async-iterator.js.map +1 -1
  127. package/lib/util/cancelable.js.map +1 -1
  128. package/lib/util/date-time.js +6 -6
  129. package/lib/util/date-time.js.map +1 -1
  130. package/lib/util/deferred.js.map +1 -1
  131. package/lib/util/disposable.d.ts.map +1 -1
  132. package/lib/util/disposable.js +2 -2
  133. package/lib/util/disposable.js.map +1 -1
  134. package/lib/util/event.d.ts.map +1 -1
  135. package/lib/util/event.js +5 -3
  136. package/lib/util/event.js.map +1 -1
  137. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  138. package/lib/util/garbage-collected-cache.js +1 -1
  139. package/lib/util/garbage-collected-cache.js.map +1 -1
  140. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  141. package/lib/util/generate-workspace-id.js +435 -435
  142. package/lib/util/generate-workspace-id.js.map +1 -1
  143. package/lib/util/generate-workspace-id.spec.js +10 -6
  144. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  145. package/lib/util/gitpod-cookie.d.ts +1 -1
  146. package/lib/util/gitpod-cookie.d.ts.map +1 -1
  147. package/lib/util/gitpod-cookie.js +0 -3
  148. package/lib/util/gitpod-cookie.js.map +1 -1
  149. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  150. package/lib/util/gitpod-host-url.js +31 -29
  151. package/lib/util/gitpod-host-url.js.map +1 -1
  152. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  153. package/lib/util/gitpod-host-url.spec.js +15 -5
  154. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  155. package/lib/util/grpc.d.ts.map +1 -1
  156. package/lib/util/grpc.js.map +1 -1
  157. package/lib/util/jaeger-client-types.d.ts.map +1 -1
  158. package/lib/util/logging.d.ts +1 -1
  159. package/lib/util/logging.d.ts.map +1 -1
  160. package/lib/util/logging.js +22 -23
  161. package/lib/util/logging.js.map +1 -1
  162. package/lib/util/make-link.js +5 -5
  163. package/lib/util/make-link.js.map +1 -1
  164. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  165. package/lib/util/parse-workspace-id.js +1 -2
  166. package/lib/util/parse-workspace-id.js.map +1 -1
  167. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  168. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  169. package/lib/util/queue.spec.js +9 -6
  170. package/lib/util/queue.spec.js.map +1 -1
  171. package/lib/util/semaphore.d.ts.map +1 -1
  172. package/lib/util/semaphore.js.map +1 -1
  173. package/lib/util/skip-if.d.ts.map +1 -1
  174. package/lib/util/skip-if.js.map +1 -1
  175. package/lib/util/timeutil.d.ts.map +1 -1
  176. package/lib/util/timeutil.js +2 -2
  177. package/lib/util/timeutil.js.map +1 -1
  178. package/lib/util/timeutil.spec.d.ts.map +1 -1
  179. package/lib/util/timeutil.spec.js.map +1 -1
  180. package/lib/util/tracing.d.ts +8 -8
  181. package/lib/util/tracing.d.ts.map +1 -1
  182. package/lib/util/tracing.js +19 -18
  183. package/lib/util/tracing.js.map +1 -1
  184. package/lib/util/tracing.spec.js +3 -3
  185. package/lib/util/tracing.spec.js.map +1 -1
  186. package/lib/util/workspace-port-authentication.d.ts +7 -7
  187. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  188. package/lib/util/workspace-port-authentication.js +8 -11
  189. package/lib/util/workspace-port-authentication.js.map +1 -1
  190. package/lib/workspace-cluster.d.ts +8 -3
  191. package/lib/workspace-cluster.d.ts.map +1 -1
  192. package/lib/workspace-cluster.js +16 -1
  193. package/lib/workspace-cluster.js.map +1 -1
  194. package/lib/workspace-instance.d.ts +2 -2
  195. package/lib/workspace-instance.d.ts.map +1 -1
  196. package/lib/wsready.d.ts +1 -1
  197. package/lib/wsready.d.ts.map +1 -1
  198. package/lib/wsready.js +2 -2
  199. package/package.json +2 -2
  200. package/pkg-yarn.lock +2 -2
  201. package/provenance-bundle.jsonl +1 -1
  202. package/src/accounting-protocol.ts +53 -51
  203. package/src/admin-protocol.ts +25 -21
  204. package/src/analytics.ts +26 -28
  205. package/src/auth.ts +2 -2
  206. package/src/connections.ts +16 -0
  207. package/src/context-url.spec.ts +37 -9
  208. package/src/context-url.ts +96 -40
  209. package/src/email-protocol.ts +5 -6
  210. package/src/encryption/container-module.ts +2 -3
  211. package/src/encryption/encryption-engine.spec.ts +9 -8
  212. package/src/encryption/encryption-engine.ts +14 -14
  213. package/src/encryption/encryption-service.ts +4 -5
  214. package/src/encryption/key-provider.ts +16 -19
  215. package/src/env.ts +9 -9
  216. package/src/gitpod-file-parser.spec.ts +55 -61
  217. package/src/gitpod-file-parser.ts +16 -17
  218. package/src/gitpod-service.ts +129 -99
  219. package/src/headless-workspace-log.ts +6 -4
  220. package/src/ide-frontend-service.ts +2 -2
  221. package/src/ide-protocol.ts +13 -8
  222. package/src/index.ts +17 -16
  223. package/src/installation-admin-protocol.ts +9 -9
  224. package/src/license-protocol.ts +5 -6
  225. package/src/messaging/browser/connection.ts +45 -47
  226. package/src/messaging/browser/window-connection.ts +39 -29
  227. package/src/messaging/client-call-metrics.ts +70 -71
  228. package/src/messaging/error.ts +1 -3
  229. package/src/messaging/handler.ts +6 -6
  230. package/src/messaging/node/connection.ts +8 -8
  231. package/src/messaging/proxy-factory.ts +23 -30
  232. package/src/oss-allowlist.ts +3 -3
  233. package/src/payment-protocol.ts +2 -2
  234. package/src/permission.ts +35 -32
  235. package/src/plans.ts +236 -189
  236. package/src/protocol.ts +232 -238
  237. package/src/snapshot-url.spec.ts +9 -7
  238. package/src/team-subscription-protocol.ts +33 -23
  239. package/src/teams-projects-protocol.ts +8 -8
  240. package/src/typings/globals.ts +4 -4
  241. package/src/util/analytics.ts +46 -24
  242. package/src/util/async-iterator.ts +4 -5
  243. package/src/util/cancelable.ts +3 -3
  244. package/src/util/date-time.ts +8 -8
  245. package/src/util/deferred.ts +6 -6
  246. package/src/util/disposable.ts +3 -6
  247. package/src/util/event.ts +9 -11
  248. package/src/util/garbage-collected-cache.ts +3 -6
  249. package/src/util/generate-workspace-id.spec.ts +18 -15
  250. package/src/util/generate-workspace-id.ts +453 -453
  251. package/src/util/gitpod-cookie.ts +8 -9
  252. package/src/util/gitpod-host-url.spec.ts +40 -13
  253. package/src/util/gitpod-host-url.ts +37 -34
  254. package/src/util/grpc.ts +1 -1
  255. package/src/util/jaeger-client-types.ts +2 -2
  256. package/src/util/logging.ts +49 -39
  257. package/src/util/make-link.ts +6 -7
  258. package/src/util/parse-workspace-id.spec.ts +17 -8
  259. package/src/util/parse-workspace-id.ts +5 -6
  260. package/src/util/queue.spec.ts +27 -25
  261. package/src/util/repeat.ts +1 -1
  262. package/src/util/semaphore.ts +4 -6
  263. package/src/util/skip-if.ts +9 -6
  264. package/src/util/timeutil.spec.ts +14 -15
  265. package/src/util/timeutil.ts +15 -11
  266. package/src/util/tracing.spec.ts +28 -23
  267. package/src/util/tracing.ts +58 -52
  268. package/src/util/workspace-port-authentication.ts +10 -13
  269. package/src/workspace-cluster.ts +24 -8
  270. package/src/workspace-instance.ts +27 -23
  271. package/src/wsready.ts +3 -3
  272. package/data/builtin-theia-plugins.json +0 -372
  273. package/lib/messaging/connection-error-handler.d.ts +0 -27
  274. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  275. package/lib/messaging/connection-error-handler.js +0 -34
  276. package/lib/messaging/connection-error-handler.js.map +0 -1
  277. package/lib/theia-plugins.d.ts +0 -11
  278. package/lib/theia-plugins.d.ts.map +0 -1
  279. package/lib/theia-plugins.js.map +0 -1
  280. package/src/messaging/connection-error-handler.ts +0 -62
  281. 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 './handler';
12
- import { log } from '../util/logging';
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
- this.connectionPromiseResolve = resolve
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 === 'setClient') {
201
+ if (p === "setClient") {
208
202
  return (client: any) => {
209
203
  this.target = client;
210
204
  };
211
205
  }
212
- if (p === 'onDidOpenConnection') {
206
+ if (p === "onDidOpenConnection") {
213
207
  return this.onDidOpenConnectionEmitter.event;
214
208
  }
215
- if (p === 'onDidCloseConnection') {
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(connection =>
221
- new Promise((resolve, reject) => {
222
- try {
223
- if (isNotify) {
224
- connection.sendNotification(p.toString(), ...args);
225
- resolve(undefined);
226
- } else {
227
- const resultPromise = connection.sendRequest(p.toString(), ...args) as Promise<any>;
228
- resultPromise
229
- .catch((err: any) => reject(err))
230
- .then((result: any) => resolve(result));
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
- } catch (err) {
233
- reject(err);
234
- }
235
- })
228
+ }),
236
229
  );
237
230
  }
238
231
 
@@ -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
+ }
@@ -4,8 +4,8 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- export namespace PaymentProtocol {
8
- export const UPDATE_GITPOD_SUBSCRIPTION_PATH = '/payment/chargebee'
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
- "monitor": undefined,
11
- "enforcement": undefined,
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 (typeof Permissions);
22
- export const Roles = {"devops": undefined, "viewer": undefined, "admin": undefined };
23
- export type RoleName = keyof (typeof Roles);
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(o) === 'string'
29
- && Role.all().some(r => r.name === o);
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(o) === 'string'
65
- && Permission.all().some(p => p === o);
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(Permission)
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(k) === 'object');
120
+ .map((k) => (Role as any)[k])
121
+ .filter((k) => typeof k === "object");
119
122
  };
120
123
  }