@gitpod/gitpod-protocol 0.1.5-tar-telemetry-settings-data.2 → 0.1.5-tar-sh-active-users.8

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 (344) hide show
  1. package/data/gitpod-schema.json +97 -5
  2. package/lib/accounting-protocol.d.ts +18 -10
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +34 -32
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/admin-protocol.d.ts +9 -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/attribution.d.ts +20 -0
  13. package/lib/attribution.d.ts.map +1 -0
  14. package/lib/attribution.js +40 -0
  15. package/lib/attribution.js.map +1 -0
  16. package/lib/auth.d.ts.map +1 -1
  17. package/lib/billing-mode.d.ts +40 -0
  18. package/lib/billing-mode.d.ts.map +1 -0
  19. package/lib/billing-mode.js +36 -0
  20. package/lib/billing-mode.js.map +1 -0
  21. package/lib/blocked-repositories-protocol.d.ts +13 -0
  22. package/lib/blocked-repositories-protocol.d.ts.map +1 -0
  23. package/lib/blocked-repositories-protocol.js +8 -0
  24. package/lib/blocked-repositories-protocol.js.map +1 -0
  25. package/lib/context-url.d.ts.map +1 -1
  26. package/lib/context-url.js +4 -4
  27. package/lib/context-url.js.map +1 -1
  28. package/lib/context-url.spec.d.ts.map +1 -1
  29. package/lib/context-url.spec.js +20 -5
  30. package/lib/context-url.spec.js.map +1 -1
  31. package/lib/email-protocol.d.ts +1 -1
  32. package/lib/email-protocol.d.ts.map +1 -1
  33. package/lib/email-protocol.js.map +1 -1
  34. package/lib/encryption/container-module.d.ts.map +1 -1
  35. package/lib/encryption/container-module.js +1 -1
  36. package/lib/encryption/container-module.js.map +1 -1
  37. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  38. package/lib/encryption/encryption-engine.js +7 -7
  39. package/lib/encryption/encryption-engine.js.map +1 -1
  40. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  41. package/lib/encryption/encryption-engine.spec.js +2 -3
  42. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  43. package/lib/encryption/encryption-service.d.ts.map +1 -1
  44. package/lib/encryption/encryption-service.js +1 -1
  45. package/lib/encryption/encryption-service.js.map +1 -1
  46. package/lib/encryption/key-provider.d.ts.map +1 -1
  47. package/lib/encryption/key-provider.js +7 -9
  48. package/lib/encryption/key-provider.js.map +1 -1
  49. package/lib/env.d.ts +0 -5
  50. package/lib/env.d.ts.map +1 -1
  51. package/lib/env.js +1 -20
  52. package/lib/env.js.map +1 -1
  53. package/lib/experiments/always-default.d.ts +8 -0
  54. package/lib/experiments/always-default.d.ts.map +1 -0
  55. package/lib/experiments/always-default.js +20 -0
  56. package/lib/experiments/always-default.js.map +1 -0
  57. package/lib/experiments/configcat-server.d.ts +10 -0
  58. package/lib/experiments/configcat-server.d.ts.map +1 -0
  59. package/lib/experiments/configcat-server.js +36 -0
  60. package/lib/experiments/configcat-server.js.map +1 -0
  61. package/lib/experiments/configcat.d.ts +22 -0
  62. package/lib/experiments/configcat.d.ts.map +1 -0
  63. package/lib/experiments/configcat.js +53 -0
  64. package/lib/experiments/configcat.js.map +1 -0
  65. package/lib/experiments/types.d.ts +23 -0
  66. package/lib/experiments/types.d.ts.map +1 -0
  67. package/lib/experiments/types.js +10 -0
  68. package/lib/experiments/types.js.map +1 -0
  69. package/lib/gitpod-file-parser.d.ts.map +1 -1
  70. package/lib/gitpod-file-parser.js +6 -6
  71. package/lib/gitpod-file-parser.js.map +1 -1
  72. package/lib/gitpod-file-parser.spec.js +42 -39
  73. package/lib/gitpod-file-parser.spec.js.map +1 -1
  74. package/lib/gitpod-service.d.ts +56 -26
  75. package/lib/gitpod-service.d.ts.map +1 -1
  76. package/lib/gitpod-service.js +40 -33
  77. package/lib/gitpod-service.js.map +1 -1
  78. package/lib/headless-workspace-log.d.ts +1 -0
  79. package/lib/headless-workspace-log.d.ts.map +1 -1
  80. package/lib/headless-workspace-log.js +2 -1
  81. package/lib/headless-workspace-log.js.map +1 -1
  82. package/lib/ide-frontend-service.d.ts +1 -1
  83. package/lib/ide-protocol.d.ts +14 -6
  84. package/lib/ide-protocol.d.ts.map +1 -1
  85. package/lib/index.d.ts +17 -16
  86. package/lib/index.d.ts.map +1 -1
  87. package/lib/index.js +1 -0
  88. package/lib/index.js.map +1 -1
  89. package/lib/installation-admin-protocol.d.ts +4 -0
  90. package/lib/installation-admin-protocol.d.ts.map +1 -1
  91. package/lib/installation-admin-protocol.js +3 -2
  92. package/lib/installation-admin-protocol.js.map +1 -1
  93. package/lib/license-protocol.d.ts +7 -0
  94. package/lib/license-protocol.d.ts.map +1 -1
  95. package/lib/license-protocol.js.map +1 -1
  96. package/lib/messaging/browser/connection.d.ts +1 -1
  97. package/lib/messaging/browser/connection.d.ts.map +1 -1
  98. package/lib/messaging/browser/connection.js +19 -19
  99. package/lib/messaging/browser/connection.js.map +1 -1
  100. package/lib/messaging/browser/window-connection.d.ts +4 -4
  101. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  102. package/lib/messaging/browser/window-connection.js +9 -6
  103. package/lib/messaging/browser/window-connection.js.map +1 -1
  104. package/lib/messaging/client-call-metrics.d.ts +2 -18
  105. package/lib/messaging/client-call-metrics.d.ts.map +1 -1
  106. package/lib/messaging/client-call-metrics.js +21 -22
  107. package/lib/messaging/client-call-metrics.js.map +1 -1
  108. package/lib/messaging/error.d.ts +6 -1
  109. package/lib/messaging/error.d.ts.map +1 -1
  110. package/lib/messaging/error.js +13 -3
  111. package/lib/messaging/error.js.map +1 -1
  112. package/lib/messaging/handler.d.ts.map +1 -1
  113. package/lib/messaging/handler.js +1 -1
  114. package/lib/messaging/node/connection.js +8 -8
  115. package/lib/messaging/node/connection.js.map +1 -1
  116. package/lib/messaging/proxy-factory.d.ts +1 -1
  117. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  118. package/lib/messaging/proxy-factory.js +7 -9
  119. package/lib/messaging/proxy-factory.js.map +1 -1
  120. package/lib/payment-protocol.d.ts.map +1 -1
  121. package/lib/payment-protocol.js +1 -1
  122. package/lib/payment-protocol.js.map +1 -1
  123. package/lib/permission.d.ts +2 -2
  124. package/lib/permission.d.ts.map +1 -1
  125. package/lib/permission.js +12 -23
  126. package/lib/permission.js.map +1 -1
  127. package/lib/plans.d.ts +4 -3
  128. package/lib/plans.d.ts.map +1 -1
  129. package/lib/plans.js +210 -171
  130. package/lib/plans.js.map +1 -1
  131. package/lib/protocol.d.ts +146 -39
  132. package/lib/protocol.d.ts.map +1 -1
  133. package/lib/protocol.js +267 -88
  134. package/lib/protocol.js.map +1 -1
  135. package/{src/theia-plugins.ts → lib/protocol.spec.d.ts} +2 -6
  136. package/lib/protocol.spec.d.ts.map +1 -0
  137. package/lib/protocol.spec.js +127 -0
  138. package/lib/protocol.spec.js.map +1 -0
  139. package/lib/snapshot-url.spec.js.map +1 -1
  140. package/lib/team-subscription-protocol.d.ts +22 -3
  141. package/lib/team-subscription-protocol.d.ts.map +1 -1
  142. package/lib/team-subscription-protocol.js +20 -5
  143. package/lib/team-subscription-protocol.js.map +1 -1
  144. package/lib/teams-projects-protocol.d.ts +21 -3
  145. package/lib/teams-projects-protocol.d.ts.map +1 -1
  146. package/lib/teams-projects-protocol.js +1 -1
  147. package/lib/teams-projects-protocol.js.map +1 -1
  148. package/lib/typings/globals.d.ts +2 -2
  149. package/lib/typings/globals.d.ts.map +1 -1
  150. package/lib/usage.d.ts +43 -0
  151. package/lib/usage.d.ts.map +1 -0
  152. package/lib/{theia-plugins.js → usage.js} +2 -2
  153. package/lib/usage.js.map +1 -0
  154. package/lib/util/analytics.d.ts.map +1 -1
  155. package/lib/util/analytics.js +12 -3
  156. package/lib/util/analytics.js.map +1 -1
  157. package/lib/util/async-iterator.d.ts.map +1 -1
  158. package/lib/util/async-iterator.js +3 -3
  159. package/lib/util/async-iterator.js.map +1 -1
  160. package/lib/util/cancelable.js.map +1 -1
  161. package/lib/util/date-time.js +6 -6
  162. package/lib/util/date-time.js.map +1 -1
  163. package/lib/util/debug-app.d.ts +25 -0
  164. package/lib/util/debug-app.d.ts.map +1 -0
  165. package/lib/util/debug-app.js +100 -0
  166. package/lib/util/debug-app.js.map +1 -0
  167. package/lib/util/deferred.js.map +1 -1
  168. package/lib/util/disposable.d.ts.map +1 -1
  169. package/lib/util/disposable.js +2 -2
  170. package/lib/util/disposable.js.map +1 -1
  171. package/lib/util/event.d.ts.map +1 -1
  172. package/lib/util/event.js +5 -3
  173. package/lib/util/event.js.map +1 -1
  174. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  175. package/lib/util/garbage-collected-cache.js +6 -1
  176. package/lib/util/garbage-collected-cache.js.map +1 -1
  177. package/lib/util/generate-workspace-id.d.ts +5 -0
  178. package/lib/util/generate-workspace-id.d.ts.map +1 -1
  179. package/lib/util/generate-workspace-id.js +446 -442
  180. package/lib/util/generate-workspace-id.js.map +1 -1
  181. package/lib/util/generate-workspace-id.spec.js +18 -7
  182. package/lib/util/generate-workspace-id.spec.js.map +1 -1
  183. package/lib/util/gitpod-cookie.d.ts +1 -1
  184. package/lib/util/gitpod-cookie.d.ts.map +1 -1
  185. package/lib/util/gitpod-cookie.js +0 -3
  186. package/lib/util/gitpod-cookie.js.map +1 -1
  187. package/lib/util/gitpod-host-url.d.ts +3 -0
  188. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  189. package/lib/util/gitpod-host-url.js +49 -29
  190. package/lib/util/gitpod-host-url.js.map +1 -1
  191. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -1
  192. package/lib/util/gitpod-host-url.spec.js +15 -5
  193. package/lib/util/gitpod-host-url.spec.js.map +1 -1
  194. package/lib/util/grpc.d.ts +19 -0
  195. package/lib/util/grpc.d.ts.map +1 -1
  196. package/lib/util/grpc.js +73 -1
  197. package/lib/util/grpc.js.map +1 -1
  198. package/lib/util/jaeger-client-types.d.ts.map +1 -1
  199. package/lib/util/logging.d.ts +1 -1
  200. package/lib/util/logging.d.ts.map +1 -1
  201. package/lib/util/logging.js +31 -25
  202. package/lib/util/logging.js.map +1 -1
  203. package/lib/util/logging.spec.d.ts +7 -0
  204. package/lib/util/logging.spec.d.ts.map +1 -0
  205. package/lib/util/logging.spec.js +52 -0
  206. package/lib/util/logging.spec.js.map +1 -0
  207. package/lib/util/make-link.js +5 -5
  208. package/lib/util/make-link.js.map +1 -1
  209. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  210. package/lib/util/parse-workspace-id.js +1 -2
  211. package/lib/util/parse-workspace-id.js.map +1 -1
  212. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  213. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  214. package/lib/util/queue.spec.js +9 -6
  215. package/lib/util/queue.spec.js.map +1 -1
  216. package/lib/util/semaphore.d.ts.map +1 -1
  217. package/lib/util/semaphore.js.map +1 -1
  218. package/lib/util/skip-if.d.ts.map +1 -1
  219. package/lib/util/skip-if.js.map +1 -1
  220. package/lib/util/timeutil.d.ts +2 -0
  221. package/lib/util/timeutil.d.ts.map +1 -1
  222. package/lib/util/timeutil.js +15 -3
  223. package/lib/util/timeutil.js.map +1 -1
  224. package/lib/util/timeutil.spec.d.ts +1 -0
  225. package/lib/util/timeutil.spec.d.ts.map +1 -1
  226. package/lib/util/timeutil.spec.js +10 -0
  227. package/lib/util/timeutil.spec.js.map +1 -1
  228. package/lib/util/tracing.d.ts +6 -6
  229. package/lib/util/tracing.d.ts.map +1 -1
  230. package/lib/util/tracing.js +14 -16
  231. package/lib/util/tracing.js.map +1 -1
  232. package/lib/util/tracing.spec.js +3 -3
  233. package/lib/util/tracing.spec.js.map +1 -1
  234. package/lib/util/workspace-port-authentication.d.ts +7 -7
  235. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  236. package/lib/util/workspace-port-authentication.js +8 -11
  237. package/lib/util/workspace-port-authentication.js.map +1 -1
  238. package/lib/webhook-event.d.ts +44 -0
  239. package/lib/webhook-event.d.ts.map +1 -0
  240. package/lib/webhook-event.js +8 -0
  241. package/lib/webhook-event.js.map +1 -0
  242. package/lib/workspace-class.d.ts +14 -0
  243. package/lib/workspace-class.d.ts.map +1 -0
  244. package/lib/workspace-class.js +8 -0
  245. package/lib/workspace-class.js.map +1 -0
  246. package/lib/workspace-cluster.d.ts +6 -8
  247. package/lib/workspace-cluster.d.ts.map +1 -1
  248. package/lib/workspace-cluster.js +2 -4
  249. package/lib/workspace-cluster.js.map +1 -1
  250. package/lib/workspace-instance.d.ts +20 -3
  251. package/lib/workspace-instance.d.ts.map +1 -1
  252. package/lib/wsready.d.ts +4 -4
  253. package/lib/wsready.d.ts.map +1 -1
  254. package/lib/wsready.js +1 -3
  255. package/lib/wsready.js.map +1 -1
  256. package/package.json +13 -7
  257. package/pkg-yarn.lock +9 -6
  258. package/provenance-bundle.jsonl +1 -1
  259. package/src/accounting-protocol.ts +66 -51
  260. package/src/admin-protocol.ts +33 -21
  261. package/src/analytics.ts +26 -28
  262. package/src/attribution.ts +48 -0
  263. package/src/auth.ts +2 -2
  264. package/src/billing-mode.ts +67 -0
  265. package/src/blocked-repositories-protocol.ts +13 -0
  266. package/src/context-url.spec.ts +25 -11
  267. package/src/context-url.ts +80 -78
  268. package/src/email-protocol.ts +5 -6
  269. package/src/encryption/container-module.ts +2 -3
  270. package/src/encryption/encryption-engine.spec.ts +9 -8
  271. package/src/encryption/encryption-engine.ts +14 -14
  272. package/src/encryption/encryption-service.ts +4 -5
  273. package/src/encryption/key-provider.ts +16 -19
  274. package/src/env.ts +0 -22
  275. package/src/experiments/always-default.ts +24 -0
  276. package/src/experiments/configcat-server.ts +41 -0
  277. package/src/experiments/configcat.ts +58 -0
  278. package/src/experiments/types.ts +35 -0
  279. package/src/gitpod-file-parser.spec.ts +55 -61
  280. package/src/gitpod-file-parser.ts +16 -17
  281. package/src/gitpod-service.ts +188 -111
  282. package/src/headless-workspace-log.ts +6 -4
  283. package/src/ide-frontend-service.ts +2 -2
  284. package/src/ide-protocol.ts +18 -8
  285. package/src/index.ts +17 -16
  286. package/src/installation-admin-protocol.ts +12 -8
  287. package/src/license-protocol.ts +12 -6
  288. package/src/messaging/browser/connection.ts +45 -47
  289. package/src/messaging/browser/window-connection.ts +39 -29
  290. package/src/messaging/client-call-metrics.ts +62 -82
  291. package/src/messaging/error.ts +20 -7
  292. package/src/messaging/handler.ts +6 -6
  293. package/src/messaging/node/connection.ts +8 -8
  294. package/src/messaging/proxy-factory.ts +23 -30
  295. package/src/oss-allowlist.ts +3 -3
  296. package/src/payment-protocol.ts +2 -2
  297. package/src/permission.ts +20 -31
  298. package/src/plans.ts +240 -189
  299. package/src/protocol.spec.ts +97 -0
  300. package/src/protocol.ts +509 -242
  301. package/src/snapshot-url.spec.ts +9 -7
  302. package/src/team-subscription-protocol.ts +59 -22
  303. package/src/teams-projects-protocol.ts +28 -8
  304. package/src/typings/globals.ts +4 -4
  305. package/src/usage.ts +63 -0
  306. package/src/util/analytics.ts +46 -24
  307. package/src/util/async-iterator.ts +4 -5
  308. package/src/util/cancelable.ts +3 -3
  309. package/src/util/date-time.ts +8 -8
  310. package/src/util/debug-app.ts +81 -0
  311. package/src/util/deferred.ts +6 -6
  312. package/src/util/disposable.ts +3 -6
  313. package/src/util/event.ts +9 -11
  314. package/src/util/garbage-collected-cache.ts +8 -6
  315. package/src/util/generate-workspace-id.spec.ts +26 -16
  316. package/src/util/generate-workspace-id.ts +460 -454
  317. package/src/util/gitpod-cookie.ts +8 -9
  318. package/src/util/gitpod-host-url.spec.ts +40 -13
  319. package/src/util/gitpod-host-url.ts +57 -33
  320. package/src/util/grpc.ts +90 -1
  321. package/src/util/jaeger-client-types.ts +2 -2
  322. package/src/util/logging.spec.ts +23 -0
  323. package/src/util/logging.ts +60 -42
  324. package/src/util/make-link.ts +6 -7
  325. package/src/util/parse-workspace-id.spec.ts +17 -8
  326. package/src/util/parse-workspace-id.ts +5 -6
  327. package/src/util/queue.spec.ts +27 -25
  328. package/src/util/repeat.ts +1 -1
  329. package/src/util/semaphore.ts +4 -6
  330. package/src/util/skip-if.ts +9 -6
  331. package/src/util/timeutil.spec.ts +19 -14
  332. package/src/util/timeutil.ts +27 -11
  333. package/src/util/tracing.spec.ts +28 -23
  334. package/src/util/tracing.ts +54 -51
  335. package/src/util/workspace-port-authentication.ts +10 -13
  336. package/src/webhook-event.ts +55 -0
  337. package/src/workspace-class.ts +14 -0
  338. package/src/workspace-cluster.ts +14 -13
  339. package/src/workspace-instance.ts +60 -24
  340. package/src/wsready.ts +6 -5
  341. package/data/builtin-theia-plugins.json +0 -372
  342. package/lib/theia-plugins.d.ts +0 -11
  343. package/lib/theia-plugins.d.ts.map +0 -1
  344. package/lib/theia-plugins.js.map +0 -1
@@ -4,16 +4,18 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { suite, test } from "mocha-typescript"
8
- import * as chai from "chai"
7
+ import { suite, test } from "mocha-typescript";
8
+ import * as chai from "chai";
9
9
  import { SnapshotUrl } from ".";
10
10
 
11
- const expect = chai.expect
12
-
13
- @suite class TestSnapshotUrlParser {
11
+ const expect = chai.expect;
14
12
 
13
+ @suite
14
+ class TestSnapshotUrlParser {
15
15
  @test public testPositive() {
16
- const actual = SnapshotUrl.parse("workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd");
16
+ const actual = SnapshotUrl.parse(
17
+ "workspaces/c362d434-6faa-4ce0-9ad4-91b4a87c4abe/3f0556f7-4afa-11e9-98d5-52f8983b9279.tar@gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
18
+ );
17
19
 
18
20
  expect(actual).to.deep.equal(<SnapshotUrl>{
19
21
  bucketId: "gitpod-prodcopy-user-e1e28f18-0354-4a5d-b6b4-8879a2ff73fd",
@@ -22,4 +24,4 @@ const expect = chai.expect
22
24
  });
23
25
  }
24
26
  }
25
- module.exports = new TestSnapshotUrlParser() // Only to circumvent no usage warning :-/
27
+ module.exports = new TestSnapshotUrlParser(); // Only to circumvent no usage warning :-/
@@ -4,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { v4 as uuidv4 } from 'uuid';
7
+ import { v4 as uuidv4 } from "uuid";
8
8
  import { Subscription } from "./accounting-protocol";
9
9
 
10
10
  export interface TeamSubscription {
@@ -18,16 +18,45 @@ export interface TeamSubscription {
18
18
  paymentReference: string;
19
19
  cancellationDate?: string;
20
20
  deleted?: boolean;
21
+ /** If this flag is set slots are not eligibile for clusters with "more-resources" - even if their plan might be */
22
+ excludeFromMoreResources: boolean;
21
23
  }
22
24
 
23
25
  export namespace TeamSubscription {
24
- export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
26
+ export const create = (ts: Omit<TeamSubscription, "id">): TeamSubscription => {
25
27
  const withId = ts as TeamSubscription;
26
28
  withId.id = uuidv4();
27
29
  return withId;
28
- }
30
+ };
29
31
  export const isActive = (ts: TeamSubscription, date: string): boolean => {
30
32
  return ts.startDate <= date && (ts.endDate === undefined || date < ts.endDate);
33
+ };
34
+ }
35
+
36
+ export interface TeamSubscription2 {
37
+ id: string;
38
+ teamId: string;
39
+ planId: string;
40
+ startDate: string;
41
+ endDate?: string;
42
+ quantity: number;
43
+ /** The Chargebee subscription id */
44
+ paymentReference: string;
45
+ cancellationDate?: string;
46
+ excludeFromMoreResources: boolean;
47
+ }
48
+
49
+ export namespace TeamSubscription2 {
50
+ export const create = (ts2: Omit<TeamSubscription2, "id">): TeamSubscription2 => {
51
+ const withId = ts2 as TeamSubscription2;
52
+ withId.id = uuidv4();
53
+ return withId;
54
+ };
55
+ export const isActive = (ts2: TeamSubscription2, date: string): boolean => {
56
+ return ts2.startDate <= date && (ts2.endDate === undefined || date < ts2.endDate);
57
+ };
58
+ export function isCancelled(s: TeamSubscription2, date: string): boolean {
59
+ return (!!s.cancellationDate && s.cancellationDate < date) || (!!s.endDate && s.endDate < date); // This edge case is meant to handle bad data: If for whatever reason cancellationDate has not been set: treat endDate as such
31
60
  }
32
61
  }
33
62
 
@@ -42,49 +71,57 @@ export interface TeamSubscriptionSlot {
42
71
  subscriptionId?: string;
43
72
  cancellationDate?: string;
44
73
  }
45
- export type TeamSubscriptionSlotDeactivated = TeamSubscriptionSlot & { assigneeId: string, assigneeIdentifier: AssigneeIdentifier };
46
- export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscriptionSlotDeactivated & { subscriptionId: string };
74
+ export type TeamSubscriptionSlotDeactivated = TeamSubscriptionSlot & {
75
+ assigneeId: string;
76
+ assigneeIdentifier: AssigneeIdentifier;
77
+ };
78
+ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot &
79
+ TeamSubscriptionSlotDeactivated & { subscriptionId: string };
47
80
 
48
- export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';
81
+ export type TeamSubscriptionSlotState = "unassigned" | "assigned" | "deactivated" | "cancelled";
49
82
 
50
83
  export namespace TeamSubscriptionSlot {
51
- export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
84
+ export const create = (ts: Omit<TeamSubscriptionSlot, "id">): TeamSubscriptionSlot => {
52
85
  const withId = ts as TeamSubscriptionSlot;
53
86
  withId.id = uuidv4();
54
87
  return withId;
55
- }
56
- export const assign = (slot: TeamSubscriptionSlot, assigneeId: string, subscriptionId: string, assigneeIdentifier: AssigneeIdentifier) => {
88
+ };
89
+ export const assign = (
90
+ slot: TeamSubscriptionSlot,
91
+ assigneeId: string,
92
+ subscriptionId: string,
93
+ assigneeIdentifier: AssigneeIdentifier,
94
+ ) => {
57
95
  slot.assigneeId = assigneeId;
58
96
  slot.subscriptionId = subscriptionId;
59
97
  slot.assigneeIdentifier = assigneeIdentifier;
60
- }
98
+ };
61
99
  export const deactivate = (slot: TeamSubscriptionSlot, cancellationDate: string) => {
62
100
  slot.subscriptionId = undefined;
63
101
  slot.cancellationDate = cancellationDate;
64
- }
102
+ };
65
103
  export const reactivate = (slot: TeamSubscriptionSlot, subscriptionId?: string) => {
66
104
  slot.subscriptionId = subscriptionId;
67
105
  slot.cancellationDate = undefined;
68
- }
106
+ };
69
107
  export const status = (slot: TeamSubscriptionSlot, now: string): TeamSubscriptionSlotState => {
70
108
  if (slot.cancellationDate) {
71
109
  if (slot.cancellationDate < now) {
72
- return 'cancelled';
110
+ return "cancelled";
73
111
  } else {
74
- return 'deactivated';
112
+ return "deactivated";
75
113
  }
76
114
  } else {
77
115
  if (slot.subscriptionId) {
78
- return 'assigned';
116
+ return "assigned";
79
117
  } else {
80
- return 'unassigned';
118
+ return "unassigned";
81
119
  }
82
120
  }
83
-
84
- }
121
+ };
85
122
  export const isActive = (slot: TeamSubscriptionSlot): boolean => {
86
123
  return !slot.cancellationDate;
87
- }
124
+ };
88
125
  }
89
126
 
90
127
  /**
@@ -107,7 +144,7 @@ export interface TeamSubscriptionSlotResolved {
107
144
  export type AssigneeIdentifier = AssigneeIdentityIdentifier;
108
145
  export interface AssigneeIdentityIdentifier {
109
146
  identity: {
110
- authHost: string,
111
- authName: string
112
- }
147
+ authHost: string;
148
+ authName: string;
149
+ };
113
150
  }
@@ -5,15 +5,18 @@
5
5
  */
6
6
 
7
7
  import { PrebuiltWorkspaceState } from "./protocol";
8
- import { v4 as uuidv4 } from 'uuid';
8
+ import { v4 as uuidv4 } from "uuid";
9
9
  import { DeepPartial } from "./util/deep-partial";
10
+ import { WebhookEvent } from "./webhook-event";
10
11
 
11
12
  export interface ProjectConfig {
12
- '.gitpod.yml': string;
13
+ ".gitpod.yml": string;
13
14
  }
14
15
 
15
16
  export interface ProjectSettings {
16
17
  useIncrementalPrebuilds?: boolean;
18
+ usePersistentVolumeClaim?: boolean;
19
+ keepOutdatedPrebuildsRunning?: boolean;
17
20
  }
18
21
 
19
22
  export interface Project {
@@ -33,13 +36,13 @@ export interface Project {
33
36
  }
34
37
 
35
38
  export namespace Project {
36
- export const create = (project: Omit<Project, 'id' | 'creationTime'>): Project => {
39
+ export const create = (project: Omit<Project, "id" | "creationTime">): Project => {
37
40
  return {
38
41
  ...project,
39
42
  id: uuidv4(),
40
- creationTime: new Date().toISOString()
43
+ creationTime: new Date().toISOString(),
41
44
  };
42
- }
45
+ };
43
46
 
44
47
  export interface Overview {
45
48
  branches: BranchDetails[];
@@ -67,7 +70,12 @@ export namespace Project {
67
70
  }
68
71
  }
69
72
 
70
- export type PartialProject = DeepPartial<Project> & Pick<Project, 'id'>;
73
+ export type PartialProject = DeepPartial<Project> & Pick<Project, "id">;
74
+
75
+ export interface ProjectUsage {
76
+ lastWebhookReceived: string;
77
+ lastWorkspaceStart: string;
78
+ }
71
79
 
72
80
  export interface PrebuildWithStatus {
73
81
  info: PrebuildInfo;
@@ -103,7 +111,7 @@ export interface PrebuildInfo {
103
111
  }
104
112
  export namespace PrebuildInfo {
105
113
  export function is(data?: any): data is PrebuildInfo {
106
- return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every(p => p in data);
114
+ return typeof data === "object" && ["id", "buildWorkspaceId", "projectId", "branch"].every((p) => p in data);
107
115
  }
108
116
  }
109
117
 
@@ -144,4 +152,16 @@ export interface TeamMembershipInvite {
144
152
 
145
153
  /** This is a flag that triggers the HARD DELETION of this entity */
146
154
  deleted?: boolean;
147
- }
155
+ }
156
+
157
+ export interface PrebuildEvent {
158
+ id: string;
159
+ creationTime: string;
160
+ status: WebhookEvent.Status | WebhookEvent.PrebuildStatus;
161
+ message?: string;
162
+ prebuildId?: string;
163
+ projectId?: string;
164
+ cloneUrl?: string;
165
+ branch?: string;
166
+ commit?: string;
167
+ }
@@ -6,7 +6,7 @@
6
6
 
7
7
  interface Window {
8
8
  gitpod: {
9
- service: import('../gitpod-service').GitpodService
10
- ideService?: import('../ide-frontend-service').IDEFrontendService
11
- }
12
- }
9
+ service: import("../gitpod-service").GitpodService;
10
+ ideService?: import("../ide-frontend-service").IDEFrontendService;
11
+ };
12
+ }
package/src/usage.ts ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import { User, WorkspaceType } from "./protocol";
8
+
9
+ export interface BillableSession {
10
+ // The id of the one paying the bill
11
+ attributionId: string;
12
+
13
+ // Relevant for workspace type. When prebuild, shows "prebuild"
14
+ userId?: string;
15
+ teamId?: string;
16
+
17
+ instanceId: string;
18
+
19
+ workspaceId: string;
20
+
21
+ workspaceType: BillableWorkspaceType;
22
+
23
+ workspaceClass: string;
24
+
25
+ // When the workspace started
26
+ startTime: string;
27
+
28
+ // When the workspace ended. Not set when the workspace is still running.
29
+ endTime?: string;
30
+
31
+ // The credits used for this session
32
+ credits: number;
33
+
34
+ // TODO - maybe
35
+ projectId?: string;
36
+ }
37
+
38
+ export interface ExtendedBillableSession extends BillableSession {
39
+ contextURL?: string;
40
+ user?: Pick<User.Profile, "name" | "avatarURL">;
41
+ }
42
+
43
+ /**
44
+ * This is a paginated request
45
+ */
46
+ export interface ListBilledUsageRequest {
47
+ attributionId: string;
48
+ fromDate?: number;
49
+ toDate?: number;
50
+ perPage: number;
51
+ page: number;
52
+ }
53
+
54
+ export interface ListBilledUsageResponse {
55
+ sessions: ExtendedBillableSession[];
56
+ totalCreditsUsed: number;
57
+ totalPages: number;
58
+ totalSessions: number;
59
+ perPage: number;
60
+ page: number;
61
+ }
62
+
63
+ export type BillableWorkspaceType = WorkspaceType;
@@ -6,8 +6,7 @@
6
6
 
7
7
  import Analytics = require("analytics-node");
8
8
  import { IAnalyticsWriter, IdentifyMessage, TrackMessage, PageMessage } from "../analytics";
9
- import { log } from './logging';
10
-
9
+ import { log } from "./logging";
11
10
 
12
11
  export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
13
12
  switch (process.env.GITPOD_ANALYTICS_WRITER) {
@@ -21,20 +20,28 @@ export function newAnalyticsWriterFromEnv(): IAnalyticsWriter {
21
20
  }
22
21
 
23
22
  class SegmentAnalyticsWriter implements IAnalyticsWriter {
24
-
25
23
  protected readonly analytics: Analytics;
26
24
 
27
25
  constructor(writeKey: string) {
28
26
  this.analytics = new Analytics(writeKey);
29
27
  }
30
28
 
31
- identify(msg: IdentifyMessage) {
29
+ identify(msg: IdentifyMessage) {
32
30
  try {
33
- this.analytics.identify(msg, (err: Error) => {
34
- if (err) {
35
- log.warn("analytics.identify failed", err);
36
- }
37
- });
31
+ this.analytics.identify(
32
+ {
33
+ ...msg,
34
+ integrations: {
35
+ All: true,
36
+ Mixpanel: !!msg.userId,
37
+ },
38
+ },
39
+ (err: Error) => {
40
+ if (err) {
41
+ log.warn("analytics.identify failed", err);
42
+ }
43
+ },
44
+ );
38
45
  } catch (err) {
39
46
  log.warn("analytics.identify failed", err);
40
47
  }
@@ -42,32 +49,48 @@ class SegmentAnalyticsWriter implements IAnalyticsWriter {
42
49
 
43
50
  track(msg: TrackMessage) {
44
51
  try {
45
- this.analytics.track(msg, (err: Error) => {
46
- if (err) {
47
- log.warn("analytics.track failed", err);
48
- }
49
- });
52
+ this.analytics.track(
53
+ {
54
+ ...msg,
55
+ integrations: {
56
+ All: true,
57
+ Mixpanel: !!msg.userId,
58
+ },
59
+ },
60
+ (err: Error) => {
61
+ if (err) {
62
+ log.warn("analytics.track failed", err);
63
+ }
64
+ },
65
+ );
50
66
  } catch (err) {
51
67
  log.warn("analytics.track failed", err);
52
68
  }
53
69
  }
54
70
 
55
71
  page(msg: PageMessage) {
56
- try{
57
- this.analytics.page(msg, (err: Error) => {
58
- if (err) {
59
- log.warn("analytics.page failed", err);
60
- }
61
- });
72
+ try {
73
+ this.analytics.page(
74
+ {
75
+ ...msg,
76
+ integrations: {
77
+ All: true,
78
+ Mixpanel: !!msg.userId,
79
+ },
80
+ },
81
+ (err: Error) => {
82
+ if (err) {
83
+ log.warn("analytics.page failed", err);
84
+ }
85
+ },
86
+ );
62
87
  } catch (err) {
63
88
  log.warn("analytics.page failed", err);
64
89
  }
65
90
  }
66
-
67
91
  }
68
92
 
69
93
  class LogAnalyticsWriter implements IAnalyticsWriter {
70
-
71
94
  identify(msg: IdentifyMessage): void {
72
95
  log.debug("analytics identify", msg);
73
96
  }
@@ -77,11 +100,10 @@ class LogAnalyticsWriter implements IAnalyticsWriter {
77
100
  page(msg: PageMessage): void {
78
101
  log.debug("analytics page", msg);
79
102
  }
80
-
81
103
  }
82
104
 
83
105
  class NoAnalyticsWriter implements IAnalyticsWriter {
84
106
  identify(msg: IdentifyMessage): void {}
85
107
  track(msg: TrackMessage): void {}
86
108
  page(msg: PageMessage): void {}
87
- }
109
+ }
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
  // Use asyncIterators with es2015
8
- if (typeof (Symbol as any).asyncIterator === 'undefined') {
9
- (Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol('asyncIterator');
8
+ if (typeof (Symbol as any).asyncIterator === "undefined") {
9
+ (Symbol as any).asyncIterator = Symbol.asyncIterator || Symbol("asyncIterator");
10
10
  }
11
11
 
12
12
  export async function find<T>(it: AsyncIterableIterator<T>, predicate: (value: T) => boolean): Promise<T | undefined> {
@@ -31,12 +31,11 @@ export interface AsyncCachingIterator<T> extends AsyncIterableIterator<T> {
31
31
  resetCursor(): void;
32
32
  }
33
33
  export class AsyncCachingIteratorImpl<T> implements AsyncIterableIterator<T>, AsyncCachingIterator<T> {
34
-
35
34
  protected cache: T[] = [];
36
35
  protected cursor = 0;
37
36
  protected cacheRead = false;
38
37
 
39
- constructor(protected readonly iterable: AsyncIterableIterator<T>) { }
38
+ constructor(protected readonly iterable: AsyncIterableIterator<T>) {}
40
39
 
41
40
  public resetCursor() {
42
41
  this.cursor = 0;
@@ -47,7 +46,7 @@ export class AsyncCachingIteratorImpl<T> implements AsyncIterableIterator<T>, As
47
46
  if (!this.cacheRead && this.cursor < this.cache.length) {
48
47
  return {
49
48
  done: false,
50
- value: this.cache[this.cursor++]
49
+ value: this.cache[this.cursor++],
51
50
  };
52
51
  }
53
52
  this.cacheRead = true;
@@ -9,10 +9,10 @@ import { Disposable } from "./disposable";
9
9
  export class Cancelable<T> implements Disposable {
10
10
  protected canceled: boolean;
11
11
 
12
- constructor(protected readonly activity: (cancel: boolean) => Promise<T> | undefined) { }
12
+ constructor(protected readonly activity: (cancel: boolean) => Promise<T> | undefined) {}
13
13
 
14
14
  public async run(): Promise<T | undefined> {
15
- for(let r = await this.activity(this.canceled); ; r = await this.activity(this.canceled)) {
15
+ for (let r = await this.activity(this.canceled); ; r = await this.activity(this.canceled)) {
16
16
  if (this.canceled) {
17
17
  return;
18
18
  } else if (r !== undefined) {
@@ -28,4 +28,4 @@ export class Cancelable<T> implements Disposable {
28
28
  dispose(): void {
29
29
  this.cancel();
30
30
  }
31
- }
31
+ }
@@ -5,26 +5,26 @@
5
5
  */
6
6
 
7
7
  export function formatDate(date?: string) {
8
- return date ? new Date(date).toLocaleString() : '';
8
+ return date ? new Date(date).toLocaleString() : "";
9
9
  }
10
10
 
11
11
  export function formatHours(hours?: number) {
12
12
  if (hours === undefined) {
13
- return '';
13
+ return "";
14
14
  }
15
15
  const h = Math.floor(Math.abs(hours));
16
- const rm = (Math.abs(hours) - h) * 60.;
16
+ const rm = (Math.abs(hours) - h) * 60;
17
17
  const m = Math.floor(rm);
18
- const rs = (rm - m) * 60.;
18
+ const rs = (rm - m) * 60;
19
19
  const s = Math.floor(rs);
20
- const result = h + ':' + pad2(m) + ':' + pad2(s);
20
+ const result = h + ":" + pad2(m) + ":" + pad2(s);
21
21
  if (hours < 0) {
22
- return `-${result}`
22
+ return `-${result}`;
23
23
  } else {
24
- return `${result}`
24
+ return `${result}`;
25
25
  }
26
26
  }
27
27
 
28
28
  function pad2(n: number) {
29
- return n < 10 ? '0' + n : '' + n;
29
+ return n < 10 ? "0" + n : "" + n;
30
30
  }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Copyright (c) 2021 Gitpod GmbH. All rights reserved.
3
+ * Licensed under the GNU Affero General Public License (AGPL).
4
+ * See License-AGPL.txt in the project root for license information.
5
+ */
6
+
7
+ import * as http from "http";
8
+ import * as express from "express";
9
+ import { injectable, postConstruct } from "inversify";
10
+ import { log, LogrusLogLevel } from "./logging";
11
+
12
+ export interface SetLogLevelRequest {
13
+ level: LogrusLogLevel;
14
+ }
15
+ export namespace SetLogLevelRequest {
16
+ export function is(o: any): o is SetLogLevelRequest {
17
+ return typeof o === "object" && "level" in o;
18
+ }
19
+ }
20
+
21
+ @injectable()
22
+ export class DebugApp {
23
+ protected _app: express.Application;
24
+ protected httpServer: http.Server | undefined = undefined;
25
+
26
+ @postConstruct()
27
+ public ctor() {
28
+ this._app = this.create();
29
+ }
30
+
31
+ create(): express.Application {
32
+ const app = express();
33
+
34
+ app.use(express.json());
35
+ app.use(express.urlencoded({ extended: true }));
36
+
37
+ app.post("/debug/logging", (req, res) => {
38
+ try {
39
+ const levelRequest = req.body;
40
+ if (!SetLogLevelRequest.is(levelRequest)) {
41
+ res.status(400).end("not a SetLogLevelRequest");
42
+ return;
43
+ }
44
+
45
+ const newLogLevel = levelRequest.level;
46
+ log.setLogLevel(newLogLevel);
47
+ log.info("set log level", { newLogLevel });
48
+ res.status(200).end(JSON.stringify(levelRequest));
49
+ } catch (err) {
50
+ res.status(500).end(err);
51
+ }
52
+ });
53
+ return app;
54
+ }
55
+
56
+ public start(port: number = 6060) {
57
+ this.httpServer = this._app.listen(port, "localhost", () => {
58
+ log.info(`debug server listening on port: ${port}`);
59
+ });
60
+ }
61
+
62
+ public async stop() {
63
+ const server = this.httpServer;
64
+ if (!server) {
65
+ return;
66
+ }
67
+ return new Promise<void>((resolve) =>
68
+ server.close((err: any) => {
69
+ if (err) {
70
+ log.warn(`error while closing http server`, { err });
71
+ }
72
+ this.httpServer = undefined;
73
+ resolve();
74
+ }),
75
+ );
76
+ }
77
+
78
+ public get app(): express.Application {
79
+ return this._app;
80
+ }
81
+ }
@@ -19,12 +19,12 @@ export class Deferred<T> {
19
19
  promise = new Promise<T>((resolve, reject) => {
20
20
  this.resolve = (o) => {
21
21
  this.isResolved = true;
22
- resolve(o as any)
23
- clearTimeout(this.timer)
22
+ resolve(o as any);
23
+ clearTimeout(this.timer);
24
24
  };
25
25
  this.reject = (e) => {
26
- reject(e)
27
- clearTimeout(this.timer)
28
- }
26
+ reject(e);
27
+ clearTimeout(this.timer);
28
+ };
29
29
  });
30
- }
30
+ }
@@ -16,10 +16,10 @@ export interface Disposable {
16
16
  export namespace Disposable {
17
17
  export function create(func: () => void): Disposable {
18
18
  return {
19
- dispose: func
19
+ dispose: func,
20
20
  };
21
21
  }
22
- export const NULL = create(() => { });
22
+ export const NULL = create(() => {});
23
23
  }
24
24
 
25
25
  export class DisposableCollection implements Disposable {
@@ -69,9 +69,6 @@ export class DisposableCollection implements Disposable {
69
69
  }
70
70
 
71
71
  pushAll(disposables: Disposable[]): Disposable[] {
72
- return disposables.map(disposable =>
73
- this.push(disposable)
74
- );
72
+ return disposables.map((disposable) => this.push(disposable));
75
73
  }
76
-
77
74
  }