@gitpod/gitpod-protocol 0.1.5-mp-usage-api-order-impl.3 → 0.1.5-mp-papi-stripe-secret-subpath.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 (83) hide show
  1. package/data/gitpod-schema.json +44 -129
  2. package/lib/accounting-protocol.d.ts +1 -0
  3. package/lib/accounting-protocol.d.ts.map +1 -1
  4. package/lib/accounting-protocol.js +4 -0
  5. package/lib/accounting-protocol.js.map +1 -1
  6. package/lib/billing-mode.d.ts +40 -0
  7. package/lib/billing-mode.d.ts.map +1 -0
  8. package/lib/billing-mode.js +36 -0
  9. package/lib/billing-mode.js.map +1 -0
  10. package/lib/experiments/configcat-server.d.ts +2 -0
  11. package/lib/experiments/configcat-server.d.ts.map +1 -1
  12. package/lib/experiments/configcat-server.js +2 -1
  13. package/lib/experiments/configcat-server.js.map +1 -1
  14. package/lib/gitpod-service.d.ts +9 -2
  15. package/lib/gitpod-service.d.ts.map +1 -1
  16. package/lib/gitpod-service.js.map +1 -1
  17. package/lib/ide-protocol.d.ts +8 -0
  18. package/lib/ide-protocol.d.ts.map +1 -1
  19. package/lib/messaging/error.d.ts +4 -1
  20. package/lib/messaging/error.d.ts.map +1 -1
  21. package/lib/messaging/error.js +9 -3
  22. package/lib/messaging/error.js.map +1 -1
  23. package/lib/plans.d.ts +1 -0
  24. package/lib/plans.d.ts.map +1 -1
  25. package/lib/plans.js +4 -0
  26. package/lib/plans.js.map +1 -1
  27. package/lib/protocol.d.ts +6 -1
  28. package/lib/protocol.d.ts.map +1 -1
  29. package/lib/protocol.js +15 -2
  30. package/lib/protocol.js.map +1 -1
  31. package/lib/team-subscription-protocol.d.ts +1 -0
  32. package/lib/team-subscription-protocol.d.ts.map +1 -1
  33. package/lib/team-subscription-protocol.js +4 -0
  34. package/lib/team-subscription-protocol.js.map +1 -1
  35. package/lib/usage.d.ts +15 -1
  36. package/lib/usage.d.ts.map +1 -1
  37. package/lib/usage.js +6 -0
  38. package/lib/usage.js.map +1 -1
  39. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  40. package/lib/util/garbage-collected-cache.js +5 -0
  41. package/lib/util/garbage-collected-cache.js.map +1 -1
  42. package/lib/util/gitpod-host-url.d.ts +2 -0
  43. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  44. package/lib/util/gitpod-host-url.js +15 -0
  45. package/lib/util/gitpod-host-url.js.map +1 -1
  46. package/lib/util/logging.spec.d.ts +7 -0
  47. package/lib/util/logging.spec.d.ts.map +1 -0
  48. package/lib/util/logging.spec.js +52 -0
  49. package/lib/util/logging.spec.js.map +1 -0
  50. package/lib/util/timeutil.d.ts +1 -0
  51. package/lib/util/timeutil.d.ts.map +1 -1
  52. package/lib/util/timeutil.js +7 -1
  53. package/lib/util/timeutil.js.map +1 -1
  54. package/lib/util/timeutil.spec.d.ts +1 -0
  55. package/lib/util/timeutil.spec.d.ts.map +1 -1
  56. package/lib/util/timeutil.spec.js +10 -0
  57. package/lib/util/timeutil.spec.js.map +1 -1
  58. package/lib/workspace-class.d.ts +14 -0
  59. package/lib/workspace-class.d.ts.map +1 -0
  60. package/lib/workspace-class.js +8 -0
  61. package/lib/workspace-class.js.map +1 -0
  62. package/lib/workspace-instance.d.ts +1 -0
  63. package/lib/workspace-instance.d.ts.map +1 -1
  64. package/package.json +3 -1
  65. package/pkg-yarn.lock +2 -1
  66. package/provenance-bundle.jsonl +1 -1
  67. package/src/accounting-protocol.ts +3 -0
  68. package/src/billing-mode.ts +67 -0
  69. package/src/experiments/configcat-server.ts +3 -0
  70. package/src/gitpod-service.ts +12 -2
  71. package/src/ide-protocol.ts +10 -0
  72. package/src/messaging/error.ts +13 -4
  73. package/src/plans.ts +4 -0
  74. package/src/protocol.ts +22 -2
  75. package/src/team-subscription-protocol.ts +3 -0
  76. package/src/usage.ts +18 -1
  77. package/src/util/garbage-collected-cache.ts +5 -0
  78. package/src/util/gitpod-host-url.ts +17 -0
  79. package/src/util/logging.spec.ts +23 -0
  80. package/src/util/timeutil.spec.ts +7 -1
  81. package/src/util/timeutil.ts +6 -0
  82. package/src/workspace-class.ts +14 -0
  83. package/src/workspace-instance.ts +3 -0
package/src/usage.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { WorkspaceType } from "./protocol";
7
+ import { User, WorkspaceType } from "./protocol";
8
8
 
9
9
  export interface BillableSession {
10
10
  // The id of the one paying the bill
@@ -35,4 +35,21 @@ export interface BillableSession {
35
35
  projectId?: string;
36
36
  }
37
37
 
38
+ export interface ExtendedBillableSession extends BillableSession {
39
+ contextURL?: string;
40
+ user?: Pick<User.Profile, "name" | "avatarURL">;
41
+ }
42
+
43
+ export interface BillableSessionRequest {
44
+ attributionId: string;
45
+ startedTimeOrder: SortOrder;
46
+ from?: number;
47
+ to?: number;
48
+ }
49
+
38
50
  export type BillableWorkspaceType = WorkspaceType;
51
+
52
+ export enum SortOrder {
53
+ Descending = 0,
54
+ Ascending = 1,
55
+ }
@@ -37,6 +37,11 @@ export class GarbageCollectedCache<T> {
37
37
  if (!entry) {
38
38
  return undefined;
39
39
  }
40
+ // Still valid?
41
+ if (entry.expiryDate < Date.now()) {
42
+ this.store.delete(entry.key);
43
+ return undefined;
44
+ }
40
45
  return entry.value;
41
46
  }
42
47
 
@@ -175,4 +175,21 @@ export class GitpodHostUrl {
175
175
  asApiLogout(): GitpodHostUrl {
176
176
  return this.withApi((url) => ({ pathname: "/logout/" }));
177
177
  }
178
+
179
+ asIDEProxy(): GitpodHostUrl {
180
+ const hostSegments = this.url.host.split(".");
181
+ if (hostSegments[0] === "ide") {
182
+ return this;
183
+ }
184
+ return this.with((url) => ({ host: "ide." + url.host }));
185
+ }
186
+
187
+ asIDEMetrics(): GitpodHostUrl {
188
+ let newUrl: GitpodHostUrl = this;
189
+ const hostSegments = this.url.host.split(".");
190
+ if (hostSegments[0] !== "ide") {
191
+ newUrl = newUrl.asIDEProxy();
192
+ }
193
+ return newUrl.with((url) => ({ pathname: "/metrics-api" }));
194
+ }
178
195
  }
@@ -0,0 +1,23 @@
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 { suite, test } from "mocha-typescript";
8
+ import { log } from "./logging";
9
+
10
+ @suite
11
+ class TestLogging {
12
+ @test public async testLogInfo_output() {
13
+ const testObj = {
14
+ null: null,
15
+ undefined: undefined,
16
+ empty: "",
17
+ foo: "bar",
18
+ number: 0,
19
+ };
20
+ log.info("info logging test", testObj);
21
+ }
22
+ }
23
+ module.exports = new TestLogging();
@@ -7,10 +7,16 @@
7
7
  import * as chai from "chai";
8
8
  const expect = chai.expect;
9
9
  import { suite, test } from "mocha-typescript";
10
- import { oneMonthLater } from "./timeutil";
10
+ import { daysBefore, hoursBefore, oneMonthLater } from "./timeutil";
11
11
 
12
12
  @suite()
13
13
  export class TimeutilSpec {
14
+ @test
15
+ testDaysBefore() {
16
+ const now = new Date().toISOString();
17
+ expect(daysBefore(now, 2)).to.be.eq(hoursBefore(now, 48));
18
+ }
19
+
14
20
  @test
15
21
  testTimeutil() {
16
22
  // targeting a 1st, 1th of Jan => 1st of Feb
@@ -47,6 +47,12 @@ export const orderAsc = (d1: string, d2: string): number => liftDate(d1, d2, (d1
47
47
  export const liftDate1 = <T>(d1: string, f: (d1: Date) => T): T => f(new Date(d1));
48
48
  export const liftDate = <T>(d1: string, d2: string, f: (d1: Date, d2: Date) => T): T => f(new Date(d1), new Date(d2));
49
49
 
50
+ export function daysBefore(date: string, days: number): string {
51
+ const result = new Date(date);
52
+ result.setDate(result.getDate() - days);
53
+ return result.toISOString();
54
+ }
55
+
50
56
  export function hoursBefore(date: string, hours: number): string {
51
57
  const result = new Date(date);
52
58
  result.setHours(result.getHours() - hours);
@@ -0,0 +1,14 @@
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
+ export interface SupportedWorkspaceClass {
8
+ id: string;
9
+ category: string;
10
+ displayName: string;
11
+ description: string;
12
+ powerups: number;
13
+ isSelected: boolean;
14
+ }
@@ -246,6 +246,9 @@ export interface WorkspaceInstanceConfiguration {
246
246
  // desktopIdeImage is the ref of the desktop IDE image this instance uses.
247
247
  desktopIdeImage?: string;
248
248
 
249
+ // desktopIdePluginImage is the ref of the desktop IDE plugin image this instance uses.
250
+ desktopIdePluginImage?: string;
251
+
249
252
  // supervisorImage is the ref of the supervisor image this instance uses.
250
253
  supervisorImage?: string;
251
254