Skip to content

Commit 2f0b946

Browse files
easyCZroboquat
authored andcommitted
Format components/gitpod-protocol with prettier
1 parent 05f91c1 commit 2f0b946

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2061
-1960
lines changed

components/gitpod-protocol/src/accounting-protocol.ts

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7-
import { v4 as uuidv4 } from 'uuid';
8-
import { User } from './protocol';
9-
import { oneMonthLater } from './util/timeutil';
7+
import { v4 as uuidv4 } from "uuid";
8+
import { User } from "./protocol";
9+
import { oneMonthLater } from "./util/timeutil";
1010

1111
/*
1212
* Subscription and acocunting data
@@ -33,7 +33,7 @@ export interface AccountEntry {
3333
/**
3434
* credit: end of validity
3535
*/
36-
expiryDate?: string; // exclusive
36+
expiryDate?: string; // exclusive
3737

3838
kind: AccountEntryKind;
3939

@@ -46,26 +46,26 @@ export interface AccountEntry {
4646
description?: object;
4747
}
4848
export namespace AccountEntry {
49-
export function create<T extends AccountEntry>(entry: Omit<T, 'uid'>): T {
49+
export function create<T extends AccountEntry>(entry: Omit<T, "uid">): T {
5050
const result = entry as T;
5151
result.uid = uuidv4();
5252
return result;
53-
};
53+
}
5454
}
5555

56-
export type DebitAccountEntryKind = 'session' | 'expiry' | 'loss';
57-
export type AccountEntryKind = 'credit' | DebitAccountEntryKind | 'carry' | 'open';
56+
export type DebitAccountEntryKind = "session" | "expiry" | "loss";
57+
export type AccountEntryKind = "credit" | DebitAccountEntryKind | "carry" | "open";
5858

5959
export interface Credit extends AccountEntry {
60-
kind: 'credit';
60+
kind: "credit";
6161
expiryDate: string;
6262
}
6363
export type Debit = LossDebit | ExpiryDebit | SessionDebit;
6464
export interface LossDebit extends AccountEntry {
65-
kind: 'loss';
65+
kind: "loss";
6666
}
6767
export interface ExpiryDebit extends AccountEntry {
68-
kind: 'expiry';
68+
kind: "expiry";
6969
creditId: undefined;
7070
}
7171
export interface SessionDebit extends AccountEntry {
@@ -80,9 +80,7 @@ export interface CreditDescription {
8080
}
8181
export namespace CreditDescription {
8282
export function is(obj: any): obj is CreditDescription {
83-
return !!obj
84-
&& obj.hasOwnProperty('subscriptionId')
85-
&& obj.hasOwnProperty('planId');
83+
return !!obj && obj.hasOwnProperty("subscriptionId") && obj.hasOwnProperty("planId");
8684
}
8785
}
8886
export interface SessionDescription {
@@ -93,11 +91,13 @@ export interface SessionDescription {
9391
}
9492
export namespace SessionDescription {
9593
export function is(obj: any): obj is SessionDescription {
96-
return !!obj
97-
&& obj.hasOwnProperty('contextTitle')
98-
&& obj.hasOwnProperty('contextUrl')
99-
&& obj.hasOwnProperty('workspaceId')
100-
&& obj.hasOwnProperty('workspaceInstanceId')
94+
return (
95+
!!obj &&
96+
obj.hasOwnProperty("contextTitle") &&
97+
obj.hasOwnProperty("contextUrl") &&
98+
obj.hasOwnProperty("workspaceId") &&
99+
obj.hasOwnProperty("workspaceInstanceId")
100+
);
101101
}
102102
}
103103

@@ -111,11 +111,11 @@ export namespace SessionDescription {
111111
export interface Subscription {
112112
uid: string;
113113
userId: string;
114-
startDate: string; // inclusive
114+
startDate: string; // inclusive
115115
/** When the subscription will end (must be >= cancellationDate!) */
116-
endDate?: string; // exclusive
116+
endDate?: string; // exclusive
117117
/** When the subscription was cancelled */
118-
cancellationDate?: string; // exclusive
118+
cancellationDate?: string; // exclusive
119119
/** Number of granted hours */
120120
amount: number;
121121
/** Number of granted hours for the first month: If this is set, use this value for the first month */
@@ -145,8 +145,7 @@ export interface UserPaidSubscription extends Subscription {
145145
}
146146
export namespace UserPaidSubscription {
147147
export function is(data: any): data is UserPaidSubscription {
148-
return !!data
149-
&& data.hasOwnProperty('paymentReference');
148+
return !!data && data.hasOwnProperty("paymentReference");
150149
}
151150
}
152151

@@ -155,61 +154,64 @@ export interface AssignedTeamSubscription extends Subscription {
155154
}
156155
export namespace AssignedTeamSubscription {
157156
export function is(data: any): data is AssignedTeamSubscription {
158-
return !!data
159-
&& data.hasOwnProperty('teamSubscriptionSlotId');
157+
return !!data && data.hasOwnProperty("teamSubscriptionSlotId");
160158
}
161159
}
162160

163161
export namespace Subscription {
164-
export function create(newSubscription: Omit<Subscription, 'uid'>) {
162+
export function create(newSubscription: Omit<Subscription, "uid">) {
165163
const subscription = newSubscription as Subscription;
166164
subscription.uid = uuidv4();
167165
return subscription;
168-
};
166+
}
169167
export function cancelSubscription(s: Subscription, cancellationDate: string, endDate?: string) {
170168
s.endDate = endDate || cancellationDate;
171169
s.cancellationDate = cancellationDate;
172-
};
170+
}
173171
export function isSame(s1: Subscription | undefined, s2: Subscription | undefined): boolean {
174-
return !!s1 && !!s2
175-
&& s1.userId === s2.userId
176-
&& s1.planId === s2.planId
177-
&& s1.startDate === s2.startDate
178-
&& s1.endDate === s2.endDate
179-
&& s1.amount === s2.amount
180-
&& s1.cancellationDate === s2.cancellationDate
181-
&& s1.deleted === s2.deleted
182-
&& ((s1.paymentData === undefined && s2.paymentData === undefined)
183-
|| (!!s1.paymentData && !!s2.paymentData
184-
&& s1.paymentData.downgradeDate === s2.paymentData.downgradeDate
185-
&& s1.paymentData.newPlan === s2.paymentData.newPlan));
186-
};
172+
return (
173+
!!s1 &&
174+
!!s2 &&
175+
s1.userId === s2.userId &&
176+
s1.planId === s2.planId &&
177+
s1.startDate === s2.startDate &&
178+
s1.endDate === s2.endDate &&
179+
s1.amount === s2.amount &&
180+
s1.cancellationDate === s2.cancellationDate &&
181+
s1.deleted === s2.deleted &&
182+
((s1.paymentData === undefined && s2.paymentData === undefined) ||
183+
(!!s1.paymentData &&
184+
!!s2.paymentData &&
185+
s1.paymentData.downgradeDate === s2.paymentData.downgradeDate &&
186+
s1.paymentData.newPlan === s2.paymentData.newPlan))
187+
);
188+
}
187189
export function isActive(s: Subscription, date: string): boolean {
188190
return s.startDate <= date && (s.endDate === undefined || date < s.endDate);
189-
};
191+
}
190192
export function isDowngraded(s: Subscription) {
191193
return s.paymentData && s.paymentData.downgradeDate;
192-
};
194+
}
193195
export function calculateCurrentPeriod(startDate: string, now: Date) {
194196
let nextStartDate = startDate;
195197
do {
196198
startDate = nextStartDate;
197199
nextStartDate = oneMonthLater(startDate, new Date(startDate).getDate());
198200
} while (nextStartDate < now.toISOString());
199201
return { startDate, endDate: nextStartDate };
200-
};
202+
}
201203
}
202204

203205
export type MaybeSubscription = Subscription | undefined;
204206

205207
export interface Period {
206-
startDate: string; // inclusive
207-
endDate: string; // exclusive
208+
startDate: string; // inclusive
209+
endDate: string; // exclusive
208210
}
209211

210212
export type MaybePeriod = Period | undefined;
211213

212-
export type AccountEntryFixedPeriod = Omit<AccountEntry, 'uid'> & { expiryDate: string };
214+
export type AccountEntryFixedPeriod = Omit<AccountEntry, "uid"> & { expiryDate: string };
213215
export interface AccountStatement extends Period {
214216
userId: string;
215217
/**
@@ -221,9 +223,9 @@ export interface AccountStatement extends Period {
221223
/** Remaining valid hours (accumulated from credits) */
222224
remainingHours: RemainingHours;
223225
}
224-
export type RemainingHours = number | 'unlimited';
226+
export type RemainingHours = number | "unlimited";
225227

226228
export interface CreditAlert {
227-
userId: string,
228-
remainingUsageHours: number
229+
userId: string;
230+
remainingUsageHours: number;
229231
}

components/gitpod-protocol/src/admin-protocol.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { User, Workspace, NamedWorkspaceFeatureFlag } from "./protocol";
88
import { FindPrebuildsParams } from "./gitpod-service";
9-
import { Project, Team, PrebuildWithStatus, TeamMemberInfo, TeamMemberRole } from "./teams-projects-protocol"
9+
import { Project, Team, PrebuildWithStatus, TeamMemberInfo, TeamMemberRole } from "./teams-projects-protocol";
1010
import { WorkspaceInstance, WorkspaceInstancePhase } from "./workspace-instance";
1111
import { RoleOrPermission } from "./permission";
1212
import { AccountStatement } from "./accounting-protocol";
@@ -42,45 +42,47 @@ export interface AdminServer {
4242
adminAddStudentEmailDomain(userId: string, domain: string): Promise<void>;
4343
adminGrantExtraHours(userId: string, extraHours: number): Promise<void>;
4444

45-
adminGetSettings(): Promise<InstallationAdminSettings>
46-
adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>
45+
adminGetSettings(): Promise<InstallationAdminSettings>;
46+
adminUpdateSettings(settings: InstallationAdminSettings): Promise<void>;
4747
}
4848

4949
export interface AdminGetListRequest<T> {
50-
offset: number
51-
limit: number
52-
orderBy: keyof T
53-
orderDir: "asc" | "desc"
50+
offset: number;
51+
limit: number;
52+
orderBy: keyof T;
53+
orderDir: "asc" | "desc";
5454
searchTerm?: string;
5555
}
5656

5757
export interface AdminGetListResult<T> {
58-
total: number
59-
rows: T[]
58+
total: number;
59+
rows: T[];
6060
}
6161

6262
export interface AdminBlockUserRequest {
63-
id: string
64-
blocked: boolean
63+
id: string;
64+
blocked: boolean;
6565
}
6666

6767
export interface AdminModifyRoleOrPermissionRequest {
6868
id: string;
6969
rpp: {
70-
r: RoleOrPermission
71-
add: boolean
72-
}[]
70+
r: RoleOrPermission;
71+
add: boolean;
72+
}[];
7373
}
7474

7575
export interface AdminModifyPermanentWorkspaceFeatureFlagRequest {
7676
id: string;
7777
changes: {
78-
featureFlag: NamedWorkspaceFeatureFlag
79-
add: boolean
80-
}[]
78+
featureFlag: NamedWorkspaceFeatureFlag;
79+
add: boolean;
80+
}[];
8181
}
8282

83-
export interface WorkspaceAndInstance extends Omit<Workspace, "id" | "creationTime">, Omit<WorkspaceInstance, "id" | "creationTime"> {
83+
export interface WorkspaceAndInstance
84+
extends Omit<Workspace, "id" | "creationTime">,
85+
Omit<WorkspaceInstance, "id" | "creationTime"> {
8486
workspaceId: string;
8587
workspaceCreationTime: string;
8688
instanceId: string;
@@ -93,7 +95,7 @@ export namespace WorkspaceAndInstance {
9395
return {
9496
id: wai.workspaceId,
9597
creationTime: wai.workspaceCreationTime,
96-
...wai
98+
...wai,
9799
};
98100
}
99101

@@ -104,7 +106,7 @@ export namespace WorkspaceAndInstance {
104106
return {
105107
id: wai.instanceId,
106108
creationTime: wai.instanceCreationTime,
107-
...wai
109+
...wai,
108110
};
109111
}
110112
}

components/gitpod-protocol/src/analytics.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* See License-AGPL.txt in the project root for license information.
55
*/
66

7-
87
export const IAnalyticsWriter = Symbol("IAnalyticsWriter");
98

109
type Identity =
@@ -15,24 +14,27 @@ interface Message {
1514
messageId?: string;
1615
}
1716

18-
export type IdentifyMessage = Message & Identity & {
19-
traits?: any;
20-
timestamp?: Date;
21-
context?: any;
22-
};
23-
24-
export type TrackMessage = Message & Identity & {
25-
event: string;
26-
properties?: any;
27-
timestamp?: Date;
28-
context?: any;
29-
};
30-
31-
export type PageMessage = Message & Identity & {
32-
properties?: any;
33-
timestamp?: Date;
34-
context?: any;
35-
};
17+
export type IdentifyMessage = Message &
18+
Identity & {
19+
traits?: any;
20+
timestamp?: Date;
21+
context?: any;
22+
};
23+
24+
export type TrackMessage = Message &
25+
Identity & {
26+
event: string;
27+
properties?: any;
28+
timestamp?: Date;
29+
context?: any;
30+
};
31+
32+
export type PageMessage = Message &
33+
Identity & {
34+
properties?: any;
35+
timestamp?: Date;
36+
context?: any;
37+
};
3638

3739
export type RemoteTrackMessage = Omit<TrackMessage, "timestamp" | "userId">;
3840
export type RemotePageMessage = Omit<PageMessage, "timestamp" | "userId"> & {
@@ -42,11 +44,9 @@ export type RemotePageMessage = Omit<PageMessage, "timestamp" | "userId"> & {
4244
export type RemoteIdentifyMessage = Omit<IdentifyMessage, "timestamp" | "userId">;
4345

4446
export interface IAnalyticsWriter {
45-
4647
identify(msg: IdentifyMessage): void;
4748

4849
track(msg: TrackMessage): void;
4950

5051
page(msg: PageMessage): void;
51-
5252
}

components/gitpod-protocol/src/auth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export interface SelectAccountPayload {
1111
authHost: string;
1212
authName: string;
1313
authProviderType: string;
14-
},
14+
};
1515
otherUser: {
1616
name: string;
1717
avatarUrl: string;
1818
authHost: string;
1919
authName: string;
2020
authProviderType: string;
21-
}
21+
};
2222
}
2323
export namespace SelectAccountPayload {
2424
export function is(data: any): data is SelectAccountPayload {

0 commit comments

Comments
 (0)