Skip to content

Commit

Permalink
remove custom Without type
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTugarev committed Jul 20, 2021

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 845cc1f commit 25213a2
Showing 13 changed files with 20 additions and 40 deletions.
5 changes: 2 additions & 3 deletions components/dashboard/src/chargebee/chargebee-client.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@

import * as chargebee from 'chargebee';

import { Without } from '@gitpod/gitpod-protocol/lib/util/without';
import { GitpodServer } from '@gitpod/gitpod-protocol';
import { getGitpodService } from '../service/service';

@@ -57,7 +56,7 @@ export class ChargebeeClient {
return chargebeeClient;
}

checkout(hostedPage: (paymentServer: GitpodServer) => Promise<{}>, params: Without<chargebee.CheckoutCallbacks, 'hostedPage'> = { success: noOp }) {
checkout(hostedPage: (paymentServer: GitpodServer) => Promise<{}>, params: Omit<chargebee.CheckoutCallbacks, 'hostedPage'> = { success: noOp }) {
const paymentServer = getGitpodService().server;
this.client.openCheckout({
...params,
@@ -67,7 +66,7 @@ export class ChargebeeClient {
});
}

checkoutExisting(hostedPage: (paymentServer: GitpodServer) => Promise<{}>, params: Without<chargebee.CheckoutCallbacks, 'hostedPage'> = { success: noOp }) {
checkoutExisting(hostedPage: (paymentServer: GitpodServer) => Promise<{}>, params: Omit<chargebee.CheckoutCallbacks, 'hostedPage'> = { success: noOp }) {
const paymentServer = getGitpodService().server;
this.client.openCheckout({
...params,
5 changes: 2 additions & 3 deletions components/ee/db-sync/src/database.ts
Original file line number Diff line number Diff line change
@@ -6,13 +6,12 @@

import { createConnection, Connection, QueryOptions } from "mysql";
import { NamedConnectionConfig } from "./config";
import { Without } from '@gitpod/gitpod-protocol/lib/util/without';

export type NamedConnection = Connection & { name: string };

export async function connect(db: NamedConnectionConfig): Promise<NamedConnection> {
const conn = createConnection({
...db as Without<NamedConnectionConfig, 'name'>,
...db as Omit<NamedConnectionConfig, 'name'>,
multipleStatements: true,
charset: 'utf8mb4',

@@ -35,7 +34,7 @@ export async function connect(db: NamedConnectionConfig): Promise<NamedConnectio
});
}

export async function query(conn: Connection, sql: string, args?: Without<QueryOptions, "sql">) {
export async function query(conn: Connection, sql: string, args?: Omit<QueryOptions, "sql">) {
return new Promise((resolve, reject) => {
conn.query({ sql, ...args }, (err, rows) => {
if (err) {
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ import { Accounting } from "./accounting";
import { orderByExpiryDateDesc, SortedArray, orderCreditFirst, within } from "./accounting-util";
import { AccountService } from "./account-service";
import { SubscriptionService } from "./subscription-service";
import { Without } from "@gitpod/gitpod-protocol/lib/util/without";
import { Plans } from "@gitpod/gitpod-protocol/lib/plans";

/**
@@ -477,7 +476,7 @@ export class AccountServiceImpl implements AccountService {
delete (ourDebit as any).endDate; // Introduced by spread

const debitEntry = AccountEntry.create<Debit>({
...(ourDebit as Without<OpenDebit, "endDate">),
...(ourDebit as Omit<OpenDebit, "endDate">),
amount: millisecondsToHours(amount),
// TODO This looks really strange: Judging by amount, endDate is inclusive; here it looks like it's not!
// Maybe some irregularity aroun endDate and debits? Add tests and clarify!
@@ -568,7 +567,7 @@ interface CreditChange {
amount: number
}

type OpenDebit = Without<AccountEntry, 'uid'> & {
type OpenDebit = Omit<AccountEntry, 'uid'> & {
endDate: string;
kind: DebitAccountEntryKind;
}
5 changes: 2 additions & 3 deletions components/gitpod-db/src/accounting-db.ts
Original file line number Diff line number Diff line change
@@ -5,19 +5,18 @@
*/

import { AccountEntry, Subscription, SubscriptionAndUser, Credit } from "@gitpod/gitpod-protocol/lib/accounting-protocol";
import { Without } from "@gitpod/gitpod-protocol/lib/util/without";
import { DBSubscriptionAdditionalData, DBPaymentSourceInfo } from "./typeorm/entity/db-subscription";
import { DeepPartial } from "typeorm";

export const AccountingDB = Symbol('AccountingDB');

export interface AccountingDB {
newAccountEntry(entry: Without<AccountEntry, 'uid'>): Promise<AccountEntry>;
newAccountEntry(entry: Omit<AccountEntry, 'uid'>): Promise<AccountEntry>;
storeAccountEntry(AccountEntry: AccountEntry): void;
findAccountEntriesFor(userId: string, fromDate: string, toDate: string): Promise<AccountEntry[]>;
findOpenCredits(userId: string, date: string): Promise<Credit[]>;

newSubscription(subscription: Without<Subscription, 'uid'>): Promise<Subscription>;
newSubscription(subscription: Omit<Subscription, 'uid'>): Promise<Subscription>;
storeSubscription(subscription: Subscription): Promise<Subscription>;
findSubscriptionById(id: string): Promise<Subscription | undefined>;
deleteSubscription(subscription: Subscription): Promise<void>
5 changes: 2 additions & 3 deletions components/gitpod-db/src/typeorm/accounting-db-impl.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import { EntityManager, Repository } from "typeorm";
import { DBSubscription, DBSubscriptionAdditionalData, DBPaymentSourceInfo } from "./entity/db-subscription";
import { injectable, inject } from "inversify";
import * as uuidv4 from 'uuid/v4';
import { Without } from "@gitpod/gitpod-protocol/lib/util/without";
import { DBUser } from "../typeorm/entity/db-user";
import { TypeORM } from "./typeorm";

@@ -36,7 +35,7 @@ export class TypeORMAccountingDBImpl implements AccountingDB {
return (await this.getEntityManager()).getRepository(DBAccountEntry);
}

async newAccountEntry(accountEntry: Without<AccountEntry, 'uid'>): Promise<AccountEntry> {
async newAccountEntry(accountEntry: Omit<AccountEntry, 'uid'>): Promise<AccountEntry> {
const newEntry = new DBAccountEntry();
AccountEntry.create(newEntry);
Object.assign(newEntry, accountEntry)
@@ -99,7 +98,7 @@ export class TypeORMAccountingDBImpl implements AccountingDB {
return (await this.getEntityManager()).getRepository(DBPaymentSourceInfo);
}

async newSubscription(subscription: Without<Subscription, 'uid'>): Promise<Subscription> {
async newSubscription(subscription: Omit<Subscription, 'uid'>): Promise<Subscription> {
const newSubscription = new DBSubscription();
Subscription.create(newSubscription);
Object.assign(newSubscription, subscription)
3 changes: 1 addition & 2 deletions components/gitpod-db/src/user-db.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
*/

import { GitpodToken, GitpodTokenType, Identity, IdentityLookup, Token, TokenEntry, User, UserEnvVar } from "@gitpod/gitpod-protocol";
import { Without } from "@gitpod/gitpod-protocol/lib/util/without";
import { OAuthTokenRepository, OAuthUserRepository } from "@jmondi/oauth2-server";
import { Repository } from "typeorm";
import { DBUser } from "./typeorm/entity/db-user";
@@ -117,7 +116,7 @@ export interface UserDB extends OAuthUserRepository, OAuthTokenRepository {
deleteGitpodToken(tokenHash: string): Promise<void>;
deleteGitpodTokensNamedLike(userId: string, namePattern: string): Promise<void>;
}
export type PartialUserUpdate = Partial<Without<User, "identities">> & Pick<User, "id">
export type PartialUserUpdate = Partial<Omit<User, "identities">> & Pick<User, "id">

export const BUILTIN_WORKSPACE_PROBE_USER_NAME = "builtin-workspace-prober";

7 changes: 3 additions & 4 deletions components/gitpod-protocol/src/accounting-protocol.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
*/

import * as uuidv4 from 'uuid/v4';
import { Without } from "./util/without";
import { User } from './protocol';
import { oneMonthLater } from './util/timeutil';

@@ -47,7 +46,7 @@ export interface AccountEntry {
description?: object;
}
export namespace AccountEntry {
export function create<T extends AccountEntry>(entry: Without<T, 'uid'>): T {
export function create<T extends AccountEntry>(entry: Omit<T, 'uid'>): T {
const result = entry as T;
result.uid = uuidv4();
return result;
@@ -164,7 +163,7 @@ export namespace AssignedTeamSubscription {
}

export namespace Subscription {
export function create(newSubscription: Without<Subscription, 'uid'>) {
export function create(newSubscription: Omit<Subscription, 'uid'>) {
const subscription = newSubscription as Subscription;
subscription.uid = uuidv4();
return subscription;
@@ -212,7 +211,7 @@ export interface Period {

export type MaybePeriod = Period | undefined;

export type AccountEntryFixedPeriod = Without<AccountEntry, 'uid'> & { expiryDate: string };
export type AccountEntryFixedPeriod = Omit<AccountEntry, 'uid'> & { expiryDate: string };
export interface AccountStatement extends Period {
userId: string;
/**
3 changes: 1 addition & 2 deletions components/gitpod-protocol/src/admin-protocol.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
*/

import { User, Workspace, NamedWorkspaceFeatureFlag } from "./protocol";
import { Without } from "./util/without";
import { WorkspaceInstance, WorkspaceInstancePhase } from "./workspace-instance";
import { RoleOrPermission } from "./permission";
import { AccountStatement } from "./accounting-protocol";
@@ -66,7 +65,7 @@ export interface AdminModifyPermanentWorkspaceFeatureFlagRequest {
}[]
}

export interface WorkspaceAndInstance extends Without<Workspace, "id"|"creationTime">, Without<WorkspaceInstance, "id"|"creationTime"> {
export interface WorkspaceAndInstance extends Omit<Workspace, "id"|"creationTime">, Omit<WorkspaceInstance, "id"|"creationTime"> {
workspaceId: string;
workspaceCreationTime: string;
instanceId: string;
3 changes: 1 addition & 2 deletions components/gitpod-protocol/src/analytics.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
* See License-AGPL.txt in the project root for license information.
*/

import { Without } from "./util/without";

export const IAnalyticsWriter = Symbol("IAnalyticsWriter");

@@ -29,7 +28,7 @@ export type TrackMessage = Message & Identity & {
context?: any;
};

export type RemoteTrackMessage = Without<TrackMessage, "timestamp" | "userId" | "anonymousId">;
export type RemoteTrackMessage = Omit<TrackMessage, "timestamp" | "userId" | "anonymousId">;

export interface IAnalyticsWriter {

3 changes: 1 addition & 2 deletions components/gitpod-protocol/src/email-protocol.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
* See License-AGPL.txt in the project root for license information.
*/

import { Without } from "./util/without";
import uuidv4 = require("uuid/v4");

export type EMailState = "scheduledInternal"
@@ -59,7 +58,7 @@ export type EMail = {
} & EMailStatus;

export namespace EMail {
export const create = (ts: Without<EMail, 'uid'>): EMail => {
export const create = (ts: Omit<EMail, 'uid'>): EMail => {
const withId = ts as EMail;
withId.uid = uuidv4();
return withId;
5 changes: 2 additions & 3 deletions components/gitpod-protocol/src/team-subscription-protocol.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
* See License-AGPL.txt in the project root for license information.
*/

import { Without } from "./util/without";
import uuidv4 = require("uuid/v4");
import { Subscription } from "./accounting-protocol";

@@ -22,7 +21,7 @@ export interface TeamSubscription {
}

export namespace TeamSubscription {
export const create = (ts: Without<TeamSubscription, 'id'>): TeamSubscription => {
export const create = (ts: Omit<TeamSubscription, 'id'>): TeamSubscription => {
const withId = ts as TeamSubscription;
withId.id = uuidv4();
return withId;
@@ -49,7 +48,7 @@ export type TeamSubscriptionSlotAssigned = TeamSubscriptionSlot & TeamSubscripti
export type TeamSubscriptionSlotState = 'unassigned' | 'assigned' | 'deactivated' | 'cancelled';

export namespace TeamSubscriptionSlot {
export const create = (ts: Without<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
export const create = (ts: Omit<TeamSubscriptionSlot, 'id'>): TeamSubscriptionSlot => {
const withId = ts as TeamSubscriptionSlot;
withId.id = uuidv4();
return withId;
8 changes: 0 additions & 8 deletions components/gitpod-protocol/src/util/without.ts

This file was deleted.

3 changes: 1 addition & 2 deletions components/gitpod-protocol/src/workspace-cluster.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@
import * as fs from 'fs';
import { filePathTelepresenceAware } from './env';
import { DeepPartial } from "./util/deep-partial";
import { Without } from './util/without';
import { PermissionName } from './permission';

export interface WorkspaceCluster {
@@ -50,7 +49,7 @@ export interface TLSConfig {
export namespace TLSConfig {
export const loadFromBase64File = (path: string): string => fs.readFileSync(filePathTelepresenceAware(path)).toString("base64");
}
export type WorkspaceClusterWoTLS = Without<WorkspaceCluster, "tls">;
export type WorkspaceClusterWoTLS = Omit<WorkspaceCluster, "tls">;
export type WorkspaceManagerConnectionInfo = Pick<WorkspaceCluster, "name" | "url" | "tls">;

export type AdmissionConstraint = AdmissionConstraintFeaturePreview | AdmissionConstraintHasRole;

0 comments on commit 25213a2

Please sign in to comment.