@gitpod/gitpod-protocol 0.1.5-mp-stripe-finalize-invoice.13 → 0.1.5-mp-server-ws-probe-remove.0

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 (60) hide show
  1. package/data/gitpod-schema.json +19 -0
  2. package/lib/admin-protocol.d.ts +3 -0
  3. package/lib/admin-protocol.d.ts.map +1 -1
  4. package/lib/admin-protocol.js.map +1 -1
  5. package/lib/billing-mode.d.ts +2 -1
  6. package/lib/billing-mode.d.ts.map +1 -1
  7. package/lib/billing-mode.js +8 -0
  8. package/lib/billing-mode.js.map +1 -1
  9. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  10. package/lib/encryption/encryption-engine.js +3 -3
  11. package/lib/encryption/encryption-engine.js.map +1 -1
  12. package/lib/encryption/encryption-engine.spec.js +1 -1
  13. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  14. package/lib/encryption/key-provider.js +1 -1
  15. package/lib/encryption/key-provider.js.map +1 -1
  16. package/lib/experiments/configcat.d.ts +1 -0
  17. package/lib/experiments/configcat.d.ts.map +1 -1
  18. package/lib/experiments/configcat.js +5 -1
  19. package/lib/experiments/configcat.js.map +1 -1
  20. package/lib/experiments/types.d.ts +2 -1
  21. package/lib/experiments/types.d.ts.map +1 -1
  22. package/lib/gitpod-service.d.ts +11 -17
  23. package/lib/gitpod-service.d.ts.map +1 -1
  24. package/lib/gitpod-service.js +12 -0
  25. package/lib/gitpod-service.js.map +1 -1
  26. package/lib/messaging/error.d.ts +1 -0
  27. package/lib/messaging/error.d.ts.map +1 -1
  28. package/lib/messaging/error.js +2 -0
  29. package/lib/messaging/error.js.map +1 -1
  30. package/lib/protocol.d.ts +28 -10
  31. package/lib/protocol.d.ts.map +1 -1
  32. package/lib/protocol.js +13 -8
  33. package/lib/protocol.js.map +1 -1
  34. package/lib/teams-projects-protocol.d.ts +0 -1
  35. package/lib/teams-projects-protocol.d.ts.map +1 -1
  36. package/lib/teams-projects-protocol.js.map +1 -1
  37. package/lib/usage.d.ts +46 -28
  38. package/lib/usage.d.ts.map +1 -1
  39. package/lib/usage.js +6 -0
  40. package/lib/usage.js.map +1 -1
  41. package/lib/util/timeutil.spec.d.ts +1 -0
  42. package/lib/util/timeutil.spec.d.ts.map +1 -1
  43. package/lib/util/timeutil.spec.js +24 -0
  44. package/lib/util/timeutil.spec.js.map +1 -1
  45. package/package.json +1 -1
  46. package/pkg-yarn.lock +1 -1
  47. package/provenance-bundle.jsonl +1 -1
  48. package/src/admin-protocol.ts +3 -0
  49. package/src/billing-mode.ts +11 -1
  50. package/src/encryption/encryption-engine.spec.ts +1 -1
  51. package/src/encryption/encryption-engine.ts +7 -3
  52. package/src/encryption/key-provider.ts +1 -1
  53. package/src/experiments/configcat.ts +4 -0
  54. package/src/experiments/types.ts +4 -1
  55. package/src/gitpod-service.ts +23 -17
  56. package/src/messaging/error.ts +3 -0
  57. package/src/protocol.ts +30 -14
  58. package/src/teams-projects-protocol.ts +0 -1
  59. package/src/usage.ts +51 -43
  60. package/src/util/timeutil.spec.ts +21 -0
package/src/protocol.ts CHANGED
@@ -8,6 +8,7 @@ import { WorkspaceInstance, PortVisibility } from "./workspace-instance";
8
8
  import { RoleOrPermission } from "./permission";
9
9
  import { Project } from "./teams-projects-protocol";
10
10
  import { createHash } from "crypto";
11
+ import { AttributionId } from "./attribution";
11
12
 
12
13
  export interface UserInfo {
13
14
  name?: string;
@@ -285,6 +286,8 @@ export interface UserFeatureSettings {
285
286
  permanentWSFeatureFlags?: NamedWorkspaceFeatureFlag[];
286
287
  }
287
288
 
289
+ export type BillingTier = "paid" | "free";
290
+
288
291
  /**
289
292
  * The values of this type MUST MATCH enum values in WorkspaceFeatureFlag from ws-manager/client/core_pb.d.ts
290
293
  * If they don't we'll break things during workspace startup.
@@ -294,8 +297,18 @@ export const WorkspaceFeatureFlags = {
294
297
  persistent_volume_claim: undefined,
295
298
  protected_secrets: undefined,
296
299
  workspace_class_limiting: undefined,
300
+ workspace_connection_limiting: undefined,
297
301
  };
298
302
  export type NamedWorkspaceFeatureFlag = keyof typeof WorkspaceFeatureFlags;
303
+ export namespace NamedWorkspaceFeatureFlag {
304
+ export const WORKSPACE_PERSISTED_FEATTURE_FLAGS: NamedWorkspaceFeatureFlag[] = [
305
+ "full_workspace_backup",
306
+ "persistent_volume_claim",
307
+ ];
308
+ export function isWorkspacePersisted(ff: NamedWorkspaceFeatureFlag): boolean {
309
+ return WORKSPACE_PERSISTED_FEATTURE_FLAGS.includes(ff);
310
+ }
311
+ }
299
312
 
300
313
  export interface EnvVarWithValue {
301
314
  name: string;
@@ -802,6 +815,12 @@ export interface RepositoryCloneInformation {
802
815
  checkoutLocation?: string;
803
816
  }
804
817
 
818
+ export interface CoreDumpConfig {
819
+ enabled?: boolean;
820
+ softLimit?: number;
821
+ hardLimit?: number;
822
+ }
823
+
805
824
  export interface WorkspaceConfig {
806
825
  mainConfiguration?: string;
807
826
  additionalRepositories?: RepositoryCloneInformation[];
@@ -814,6 +833,7 @@ export interface WorkspaceConfig {
814
833
  github?: GithubAppConfig;
815
834
  vscode?: VSCodeConfig;
816
835
  jetbrains?: JetBrainsConfig;
836
+ coreDump?: CoreDumpConfig;
817
837
 
818
838
  /** deprecated. Enabled by default **/
819
839
  experimentalNetwork?: boolean;
@@ -822,13 +842,12 @@ export interface WorkspaceConfig {
822
842
  * Where the config object originates from.
823
843
  *
824
844
  * repo - from the repository
825
- * project-db - from the "Project" stored in the database
826
845
  * definitly-gp - from github.com/gitpod-io/definitely-gp
827
846
  * derived - computed based on analyzing the repository
828
847
  * additional-content - config comes from additional content, usually provided through the project's configuration
829
848
  * default - our static catch-all default config
830
849
  */
831
- _origin?: "repo" | "project-db" | "definitely-gp" | "derived" | "additional-content" | "default";
850
+ _origin?: "repo" | "definitely-gp" | "derived" | "additional-content" | "default";
832
851
 
833
852
  /**
834
853
  * Set of automatically infered feature flags. That's not something the user can set, but
@@ -1146,17 +1165,6 @@ export namespace WithEnvvarsContext {
1146
1165
  }
1147
1166
  }
1148
1167
 
1149
- export interface WorkspaceProbeContext extends WorkspaceContext {
1150
- responseURL: string;
1151
- responseToken: string;
1152
- }
1153
-
1154
- export namespace WorkspaceProbeContext {
1155
- export function is(context: any): context is WorkspaceProbeContext {
1156
- return context && "responseURL" in context && "responseToken" in context;
1157
- }
1158
- }
1159
-
1160
1168
  export type RefType = "branch" | "tag" | "revision";
1161
1169
  export namespace RefType {
1162
1170
  export const getRefType = (commit: Commit): RefType => {
@@ -1503,10 +1511,18 @@ export interface Terms {
1503
1511
  readonly formElements?: object;
1504
1512
  }
1505
1513
 
1514
+ export interface StripeConfig {
1515
+ usageProductPriceIds: { [currency: string]: string };
1516
+ individualUsagePriceIds?: { [currency: string]: string };
1517
+ teamUsagePriceIds?: { [currency: string]: string };
1518
+ }
1519
+
1520
+ export type BillingStrategy = "other" | "stripe";
1506
1521
  export interface CostCenter {
1507
- readonly id: string;
1522
+ readonly id: AttributionId;
1508
1523
  /**
1509
1524
  * Unit: credits
1510
1525
  */
1511
1526
  spendingLimit: number;
1527
+ billingStrategy: BillingStrategy;
1512
1528
  }
@@ -27,7 +27,6 @@ export interface Project {
27
27
  teamId?: string;
28
28
  userId?: string;
29
29
  appInstallationId: string;
30
- config?: ProjectConfig;
31
30
  settings?: ProjectSettings;
32
31
  creationTime: string;
33
32
  /** This is a flag that triggers the HARD DELETION of this entity */
package/src/usage.ts CHANGED
@@ -4,60 +4,68 @@
4
4
  * See License-AGPL.txt in the project root for license information.
5
5
  */
6
6
 
7
- import { User, WorkspaceType } from "./protocol";
7
+ import { WorkspaceType } from "./protocol";
8
8
 
9
- export interface BillableSession {
10
- // The id of the one paying the bill
9
+ // types below are copied over from components/usage-api/typescript/src/usage/v1/usage_pb.d.ts
10
+ export interface ListUsageRequest {
11
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;
12
+ from?: number;
13
+ to?: number;
14
+ order: Ordering;
15
+ pagination?: PaginationRequest;
36
16
  }
37
17
 
38
- export interface ExtendedBillableSession extends BillableSession {
39
- contextURL?: string;
40
- user?: Pick<User.Profile, "name" | "avatarURL">;
18
+ export enum Ordering {
19
+ ORDERING_DESCENDING = 0,
20
+ ORDERING_ASCENDING = 1,
41
21
  }
42
22
 
43
- /**
44
- * This is a paginated request
45
- */
46
- export interface ListBilledUsageRequest {
47
- attributionId: string;
48
- fromDate?: number;
49
- toDate?: number;
23
+ export interface PaginationRequest {
50
24
  perPage: number;
51
25
  page: number;
52
26
  }
53
27
 
54
- export interface ListBilledUsageResponse {
55
- sessions: ExtendedBillableSession[];
56
- totalCreditsUsed: number;
57
- totalPages: number;
58
- totalSessions: number;
28
+ export interface ListUsageResponse {
29
+ usageEntriesList: Usage[];
30
+ pagination?: PaginationResponse;
31
+ creditsUsed: number;
32
+ }
33
+
34
+ export interface PaginationResponse {
59
35
  perPage: number;
36
+ totalPages: number;
37
+ total: number;
60
38
  page: number;
61
39
  }
62
40
 
63
- export type BillableWorkspaceType = WorkspaceType;
41
+ export type UsageKind = "workspaceinstance" | "invoice";
42
+ export interface Usage {
43
+ id: string;
44
+ attributionId: string;
45
+ description: string;
46
+ credits: number;
47
+ effectiveTime?: number;
48
+ kind: UsageKind;
49
+ workspaceInstanceId: string;
50
+ draft: boolean;
51
+ metadata: WorkspaceInstanceUsageData | InvoiceUsageData;
52
+ }
53
+
54
+ // the equivalent golang shape is maintained in `/workspace/gitpod/`components/usage/pkg/db/usage.go`
55
+ export interface WorkspaceInstanceUsageData {
56
+ workspaceId: string;
57
+ workspaceType: WorkspaceType;
58
+ workspaceClass: string;
59
+ contextURL: string;
60
+ startTime: string;
61
+ endTime?: string;
62
+ userId: string;
63
+ userName: string;
64
+ userAvatarURL: string;
65
+ }
66
+
67
+ export interface InvoiceUsageData {
68
+ invoiceId: string;
69
+ startDate: string;
70
+ endDate: string;
71
+ }
@@ -45,4 +45,25 @@ export class TimeutilSpec {
45
45
  const later = oneMonthLater(from.toISOString(), day);
46
46
  expect(later, `expected ${later} to be equal ${expectation}`).to.be.equal(expectation.toISOString());
47
47
  }
48
+
49
+ @test
50
+ testDaysBefore2() {
51
+ const tests: { date: Date; daysEarlier: number; expectation: string }[] = [
52
+ {
53
+ date: new Date("2021-07-13T00:00:00.000Z"),
54
+ daysEarlier: 365,
55
+ expectation: "2020-07-13T00:00:00.000Z",
56
+ },
57
+ {
58
+ date: new Date("2019-02-01T00:00:00.000Z"),
59
+ daysEarlier: 365,
60
+ expectation: "2018-02-01T00:00:00.000Z",
61
+ },
62
+ ];
63
+
64
+ for (const t of tests) {
65
+ const actual = daysBefore(t.date.toISOString(), t.daysEarlier);
66
+ expect(actual).to.equal(t.expectation, `expected ${actual} to be equal ${t.expectation}`);
67
+ }
68
+ }
48
69
  }