Skip to content

Commit 1c86fd3

Browse files
committed
Fix
1 parent 150559c commit 1c86fd3

File tree

165 files changed

+1953
-1953
lines changed

Some content is hidden

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

165 files changed

+1953
-1953
lines changed

components/gitpod-db/src/accounting-db.spec.db.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
* See License.enterprise.txt in the project root folder.
55
*/
66

7-
import { Subscription } from '@gitpod/gitpod-protocol/lib/accounting-protocol';
8-
import * as chai from 'chai';
9-
import { suite, test, timeout } from 'mocha-typescript';
10-
import { QueryRunner } from 'typeorm';
11-
import { AccountingDB } from './accounting-db';
12-
import { oneMonthLater, rightAfter, rightBefore } from '@gitpod/gitpod-protocol/lib/util/timeutil';
13-
import { DBAccountEntry } from './typeorm/entity/db-account-entry';
14-
import { TransactionalAccountingDBImpl } from './typeorm/accounting-db-impl';
15-
import { DBWorkspace } from './typeorm/entity/db-workspace';
16-
import { DBWorkspaceInstance } from './typeorm/entity/db-workspace-instance';
17-
import { DBSubscription } from './typeorm/entity/db-subscription';
18-
import { testContainer } from './test-container';
19-
import { TypeORM } from './typeorm/typeorm';
7+
import { Subscription } from "@gitpod/gitpod-protocol/lib/accounting-protocol";
8+
import * as chai from "chai";
9+
import { suite, test, timeout } from "mocha-typescript";
10+
import { QueryRunner } from "typeorm";
11+
import { AccountingDB } from "./accounting-db";
12+
import { oneMonthLater, rightAfter, rightBefore } from "@gitpod/gitpod-protocol/lib/util/timeutil";
13+
import { DBAccountEntry } from "./typeorm/entity/db-account-entry";
14+
import { TransactionalAccountingDBImpl } from "./typeorm/accounting-db-impl";
15+
import { DBWorkspace } from "./typeorm/entity/db-workspace";
16+
import { DBWorkspaceInstance } from "./typeorm/entity/db-workspace-instance";
17+
import { DBSubscription } from "./typeorm/entity/db-subscription";
18+
import { testContainer } from "./test-container";
19+
import { TypeORM } from "./typeorm/typeorm";
2020
const expect = chai.expect;
2121

2222
@suite
@@ -50,11 +50,11 @@ export class AccountingDBSpec {
5050
const inBetween = new Date(0.5 * (new Date(now).getTime() + new Date(later).getTime())).toISOString();
5151

5252
const subscription = <Subscription>{
53-
userId: 'Now open',
53+
userId: "Now open",
5454
startDate: now,
5555
endDate: later,
5656
amount: 1.01,
57-
planId: 'test',
57+
planId: "test",
5858
};
5959
await this.db.newSubscription(subscription);
6060

@@ -76,11 +76,11 @@ export class AccountingDBSpec {
7676
const inBetween = new Date(0.5 * (new Date(now).getTime() + new Date(later).getTime())).toISOString();
7777

7878
const subscription = <Subscription>{
79-
userId: 'Open ended',
79+
userId: "Open ended",
8080
startDate: now,
8181
endDate: undefined, // open ended
8282
amount: 1.01,
83-
planId: 'test',
83+
planId: "test",
8484
};
8585
await this.db.newSubscription(subscription);
8686

@@ -100,11 +100,11 @@ export class AccountingDBSpec {
100100
const now = new Date().toISOString();
101101
const later = oneMonthLater(now, 31);
102102
const subscription = <Subscription>{
103-
userId: 'Open ended',
103+
userId: "Open ended",
104104
startDate: now,
105105
endDate: undefined, // open ended
106106
amount: 1.01,
107-
planId: 'test',
107+
planId: "test",
108108
};
109109
const dbSubscription = await this.db.newSubscription(subscription);
110110
expectExactlyOne(await this.db.findActiveSubscriptions(now, rightAfter(later)), subscription);
@@ -120,15 +120,15 @@ export class AccountingDBSpec {
120120
const now = new Date().toISOString();
121121
const later = oneMonthLater(now, 31);
122122
const subscription = <Subscription>{
123-
userId: 'Open ended',
123+
userId: "Open ended",
124124
startDate: now,
125125
endDate: undefined, // open ended
126126
amount: 1.01,
127-
planId: 'test',
127+
planId: "test",
128128
};
129129
let dbSubscription = await this.db.newSubscription(subscription);
130130
expectExactlyOne(await this.db.findActiveSubscriptionsForUser(subscription.userId, now), subscription);
131-
expect(await this.db.findActiveSubscriptionsForUser(subscription.userId, rightBefore(now))).to.be.an('array')
131+
expect(await this.db.findActiveSubscriptionsForUser(subscription.userId, rightBefore(now))).to.be.an("array")
132132
.and.empty;
133133
expectExactlyOne(await this.db.findActiveSubscriptionsForUser(subscription.userId, later), subscription);
134134
Subscription.cancelSubscription(dbSubscription, later);
@@ -138,7 +138,7 @@ export class AccountingDBSpec {
138138
await this.db.findActiveSubscriptionsForUser(subscription.userId, rightBefore(later)),
139139
dbSubscription,
140140
);
141-
expect(await this.db.findActiveSubscriptionsForUser(subscription.userId, later)).to.be.an('array').and.empty;
141+
expect(await this.db.findActiveSubscriptionsForUser(subscription.userId, later)).to.be.an("array").and.empty;
142142
}
143143
}
144144

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ import {
99
Subscription,
1010
SubscriptionAndUser,
1111
Credit,
12-
} from '@gitpod/gitpod-protocol/lib/accounting-protocol';
13-
import { DBSubscriptionAdditionalData } from './typeorm/entity/db-subscription';
14-
import { EntityManager } from 'typeorm';
12+
} from "@gitpod/gitpod-protocol/lib/accounting-protocol";
13+
import { DBSubscriptionAdditionalData } from "./typeorm/entity/db-subscription";
14+
import { EntityManager } from "typeorm";
1515

16-
export const TransactionalAccountingDBFactory = Symbol('TransactionalAccountingDBFactory');
16+
export const TransactionalAccountingDBFactory = Symbol("TransactionalAccountingDBFactory");
1717
export interface TransactionalAccountingDBFactory {
1818
(manager: EntityManager): AccountingDB;
1919
}
2020

21-
export const AccountingDB = Symbol('AccountingDB');
21+
export const AccountingDB = Symbol("AccountingDB");
2222

2323
export interface AccountingDB {
24-
newAccountEntry(entry: Omit<AccountEntry, 'uid'>): Promise<AccountEntry>;
24+
newAccountEntry(entry: Omit<AccountEntry, "uid">): Promise<AccountEntry>;
2525
storeAccountEntry(AccountEntry: AccountEntry): void;
2626
findAccountEntriesFor(userId: string, fromDate: string, toDate: string): Promise<AccountEntry[]>;
2727
findOpenCredits(userId: string, date: string): Promise<Credit[]>;
2828

29-
newSubscription(subscription: Omit<Subscription, 'uid'>): Promise<Subscription>;
29+
newSubscription(subscription: Omit<Subscription, "uid">): Promise<Subscription>;
3030
storeSubscription(subscription: Subscription): Promise<Subscription>;
3131
findSubscriptionById(id: string): Promise<Subscription | undefined>;
3232
deleteSubscription(subscription: Subscription): Promise<void>;

components/gitpod-db/src/app-installation-db.ts

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

7-
import { AppInstallation, AppInstallationPlatform } from '@gitpod/gitpod-protocol';
7+
import { AppInstallation, AppInstallationPlatform } from "@gitpod/gitpod-protocol";
88

9-
export const AppInstallationDB = Symbol('AppInstallationDB');
9+
export const AppInstallationDB = Symbol("AppInstallationDB");
1010

1111
export interface AppInstallationDB {
1212
recordNewInstallation(
1313
platform: AppInstallationPlatform,
14-
source: 'user' | 'platform',
14+
source: "user" | "platform",
1515
installationID: string,
1616
ownerUserID?: string,
1717
platformUserID?: string,
1818
): Promise<void>;
1919
recordUninstallation(
2020
platform: AppInstallationPlatform,
21-
source: 'user' | 'platform',
21+
source: "user" | "platform",
2222
installationID: string,
2323
): Promise<void>;
2424

components/gitpod-db/src/auth-provider-entry-db.ts

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

7-
import { AuthProviderEntry as AuthProviderEntry } from '@gitpod/gitpod-protocol';
8-
import { createHash } from 'crypto';
7+
import { AuthProviderEntry as AuthProviderEntry } from "@gitpod/gitpod-protocol";
8+
import { createHash } from "crypto";
99

10-
export const AuthProviderEntryDB = Symbol('AuthProviderEntryDB');
10+
export const AuthProviderEntryDB = Symbol("AuthProviderEntryDB");
1111

1212
export interface AuthProviderEntryDB {
1313
storeAuthProvider(ap: AuthProviderEntry, updateOAuthRevision: boolean): Promise<AuthProviderEntry>;
@@ -20,6 +20,6 @@ export interface AuthProviderEntryDB {
2020
findByUserId(userId: string): Promise<AuthProviderEntry[]>;
2121
}
2222

23-
export function hashOAuth(oauth: AuthProviderEntry['oauth']): string {
24-
return createHash('sha256').update(JSON.stringify(oauth)).digest('hex');
23+
export function hashOAuth(oauth: AuthProviderEntry["oauth"]): string {
24+
return createHash("sha256").update(JSON.stringify(oauth)).digest("hex");
2525
}

components/gitpod-db/src/auth-provider-entry.spec.db.ts

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
* See License.enterprise.txt in the project root folder.
55
*/
66

7-
import * as chai from 'chai';
8-
import { suite, test, timeout } from 'mocha-typescript';
9-
import { testContainer } from './test-container';
10-
import { TypeORM } from './typeorm/typeorm';
11-
import { AuthProviderEntryDB } from '.';
12-
import { DBAuthProviderEntry } from './typeorm/entity/db-auth-provider-entry';
13-
import { DeepPartial } from '@gitpod/gitpod-protocol/lib/util/deep-partial';
7+
import * as chai from "chai";
8+
import { suite, test, timeout } from "mocha-typescript";
9+
import { testContainer } from "./test-container";
10+
import { TypeORM } from "./typeorm/typeorm";
11+
import { AuthProviderEntryDB } from ".";
12+
import { DBAuthProviderEntry } from "./typeorm/entity/db-auth-provider-entry";
13+
import { DeepPartial } from "@gitpod/gitpod-protocol/lib/util/deep-partial";
1414
const expect = chai.expect;
1515

1616
@suite
@@ -34,27 +34,27 @@ export class AuthProviderEntryDBSpec {
3434
}
3535

3636
protected authProvider(ap: DeepPartial<DBAuthProviderEntry> = {}): DBAuthProviderEntry {
37-
const ownerId = '1234';
38-
const host = 'github.com';
37+
const ownerId = "1234";
38+
const host = "github.com";
3939
return {
40-
id: '0049b9d2-005f-43c2-a0ae-76377805d8b8',
40+
id: "0049b9d2-005f-43c2-a0ae-76377805d8b8",
4141
host,
4242
ownerId,
43-
status: 'verified',
44-
type: 'GitHub',
43+
status: "verified",
44+
type: "GitHub",
4545
oauthRevision: undefined,
4646
deleted: false,
4747
...ap,
4848
oauth: {
49-
callBackUrl: 'example.org/some/callback',
50-
authorizationUrl: 'example.org/some/auth',
51-
settingsUrl: 'example.org/settings',
52-
configURL: 'example.org/config',
53-
clientId: 'clientId',
54-
clientSecret: 'clientSecret',
55-
tokenUrl: 'example.org/get/token',
56-
scope: 'scope',
57-
scopeSeparator: ',',
49+
callBackUrl: "example.org/some/callback",
50+
authorizationUrl: "example.org/some/auth",
51+
settingsUrl: "example.org/settings",
52+
configURL: "example.org/config",
53+
clientId: "clientId",
54+
clientSecret: "clientSecret",
55+
tokenUrl: "example.org/get/token",
56+
scope: "scope",
57+
scopeSeparator: ",",
5858
...ap.oauth,
5959
authorizationParams: {},
6060
},
@@ -66,29 +66,29 @@ export class AuthProviderEntryDBSpec {
6666
await this.db.storeAuthProvider(ap, false);
6767

6868
const aap = await this.db.findByHost(ap.host);
69-
expect(aap, 'AuthProvider').to.deep.equal(ap);
69+
expect(aap, "AuthProvider").to.deep.equal(ap);
7070
}
7171

7272
@test public async findAll() {
73-
const ap1 = this.authProvider({ id: '1', oauthRevision: 'rev1' });
74-
const ap2 = this.authProvider({ id: '2', oauthRevision: 'rev2' });
73+
const ap1 = this.authProvider({ id: "1", oauthRevision: "rev1" });
74+
const ap2 = this.authProvider({ id: "2", oauthRevision: "rev2" });
7575
await this.db.storeAuthProvider(ap1, false);
7676
await this.db.storeAuthProvider(ap2, false);
7777

7878
const all = await this.db.findAll();
79-
expect(all, 'findAll([])').to.deep.equal([ap1, ap2]);
80-
expect(await this.db.findAll([ap1.oauthRevision!, ap2.oauthRevision!]), 'findAll([ap1, ap2])').to.be.empty;
81-
expect(await this.db.findAll([ap1.oauthRevision!]), 'findAll([ap1])').to.deep.equal([ap2]);
79+
expect(all, "findAll([])").to.deep.equal([ap1, ap2]);
80+
expect(await this.db.findAll([ap1.oauthRevision!, ap2.oauthRevision!]), "findAll([ap1, ap2])").to.be.empty;
81+
expect(await this.db.findAll([ap1.oauthRevision!]), "findAll([ap1])").to.deep.equal([ap2]);
8282
}
8383

8484
@test public async oauthRevision() {
85-
const ap = this.authProvider({ id: '1' });
85+
const ap = this.authProvider({ id: "1" });
8686
await this.db.storeAuthProvider(ap, true);
8787

8888
const loadedAp = await this.db.findByHost(ap.host);
89-
expect(loadedAp, 'findByHost()').to.deep.equal(ap);
90-
expect(loadedAp?.oauthRevision, 'findByHost()').to.equal(
91-
'e05ea6fab8efcaba4b3246c2b2d3931af897c3bc2c1cf075c31614f0954f9840',
89+
expect(loadedAp, "findByHost()").to.deep.equal(ap);
90+
expect(loadedAp?.oauthRevision, "findByHost()").to.equal(
91+
"e05ea6fab8efcaba4b3246c2b2d3931af897c3bc2c1cf075c31614f0954f9840",
9292
);
9393
}
9494
}

components/gitpod-db/src/config.ts

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

7-
import { injectable } from 'inversify';
8-
import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
9-
import { getEnvVarParsed, getEnvVar } from '@gitpod/gitpod-protocol/lib/env';
10-
import { ConnectionConfig } from 'mysql';
7+
import { injectable } from "inversify";
8+
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
9+
import { getEnvVarParsed, getEnvVar } from "@gitpod/gitpod-protocol/lib/env";
10+
import { ConnectionConfig } from "mysql";
1111

1212
@injectable()
1313
export class Config {
1414
get dbConfig(): DatabaseConfig {
1515
// defaults to be used only in tests
1616
const dbSetup = {
17-
host: process.env.DB_HOST || 'localhost',
18-
port: getEnvVarParsed('DB_PORT', Number.parseInt, '3306'),
19-
username: process.env.DB_USERNAME || 'gitpod',
20-
password: process.env.DB_PASSWORD || 'test',
21-
database: process.env.DB_NAME || 'gitpod',
17+
host: process.env.DB_HOST || "localhost",
18+
port: getEnvVarParsed("DB_PORT", Number.parseInt, "3306"),
19+
username: process.env.DB_USERNAME || "gitpod",
20+
password: process.env.DB_PASSWORD || "test",
21+
database: process.env.DB_NAME || "gitpod",
2222
};
2323

2424
log.info(`Using DB: ${dbSetup.host}:${dbSetup.port}/${dbSetup.database}`);
@@ -38,12 +38,12 @@ export class Config {
3838
}
3939

4040
get dbEncryptionKeys(): string {
41-
return getEnvVar('DB_ENCRYPTION_KEYS');
41+
return getEnvVar("DB_ENCRYPTION_KEYS");
4242
}
4343

4444
get deletedEntryGCConfig(): DeletedEntryGCConfig {
45-
const enabled = getEnvVar('DB_DELETED_ENTRIES_GC_ENABLED', 'true') === 'true';
46-
const intervalMS = parseInt(getEnvVar('DB_DELETED_ENTRIES_GC_INTERVAL', (10 * 60 * 1000).toString()));
45+
const enabled = getEnvVar("DB_DELETED_ENTRIES_GC_ENABLED", "true") === "true";
46+
const intervalMS = parseInt(getEnvVar("DB_DELETED_ENTRIES_GC_INTERVAL", (10 * 60 * 1000).toString()));
4747
return { enabled, intervalMS };
4848
}
4949
}

0 commit comments

Comments
 (0)