Skip to content

Commit

Permalink
Revert "Update imports"
Browse files Browse the repository at this point in the history
This reverts commit 7b21157.
  • Loading branch information
antoinejaussoin committed Oct 17, 2024
1 parent 8037011 commit dc978e0
Show file tree
Hide file tree
Showing 62 changed files with 330 additions and 330 deletions.
22 changes: 11 additions & 11 deletions backend/src/admin/router.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import express from 'express';
import type { NextFunction, Request, Response } from 'express';
import type { NextFunction, Response, Request } from 'express';
import type { Server } from 'socket.io';
import type {
AdminChangePasswordPayload,
AdminStats,
BackendCapabilities,
MergeUsersPayload,
} from '../common/index.js';
import config from '../config.js';
import { mergeUsers } from '../db/actions/merge.js';
import {
getAllNonDeletedUsers,
getPasswordIdentityByUserId,
updateIdentity,
} from '../db/actions/users.js';
import { canSendEmails } from '../email/utils.js';
import { hashPassword } from '../encryption.js';
import config from '../config.js';
import { isLicenced } from '../security/is-licenced.js';
import type {
AdminChangePasswordPayload,
AdminStats,
BackendCapabilities,
MergeUsersPayload,
} from '../common/index.js';
import { getIdentityFromRequest } from '../utils.js';
import { hashPassword } from '../encryption.js';
import { canSendEmails } from '../email/utils.js';
import { mergeUsers } from '../db/actions/merge.js';

export default function getRouter(io: Server) {
const router = express.Router();
Expand Down
6 changes: 3 additions & 3 deletions backend/src/ai/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { last } from 'lodash-es';
import { Configuration, OpenAIApi } from 'openai';
import type { CoachMessage } from '../common/types.js';
import config from '../config.js';
import { Configuration, OpenAIApi } from 'openai';
import { getAiChatSession, recordAiChatMessage } from '../db/actions/ai.js';
import type UserView from '../db/entities/UserView.js';
import type { CoachMessage } from '../common/types.js';
import { last } from 'lodash-es';

const systemMessage: CoachMessage = {
role: 'system',
Expand Down
4 changes: 2 additions & 2 deletions backend/src/ai/router.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import express, { type Router } from 'express';
import { dialog } from './index.js';
import { getUserViewFromRequest } from '../utils.js';
import type { AiChatPayload } from '../common/payloads.js';
import { getAllowance } from '../db/actions/ai.js';
import { getUserViewFromRequest } from '../utils.js';
import { dialog } from './index.js';

export default function aiRouter(): Router {
const router = express.Router();
Expand Down
4 changes: 2 additions & 2 deletions backend/src/auth/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { StrategyOptionsWithRequest as GitHubStrategy } from 'passport-github2';
import type { IStrategyOptionWithRequest } from 'passport-twitter';
import type { StrategyOptionsWithRequest as GoogleStrategyOptions } from 'passport-google-oauth20';
import type { StrategyOptionsWithRequest as GitHubStrategy } from 'passport-github2';
import type { MicrosoftStrategyOptionsWithRequest } from 'passport-microsoft';
import type { OktaStrategyOptions } from 'passport-okta-oauth20';
import type { IStrategyOptionWithRequest } from 'passport-twitter';
import config from '../config.js';

type MicrosoftStrategyOptionsWithTenant =
Expand Down
2 changes: 1 addition & 1 deletion backend/src/auth/logins/anonymous-user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { registerAnonymousUser } from '../../db/actions/users.js';
import type { UserIdentityEntity } from '../../db/entities/index.js';
import { registerAnonymousUser } from '../../db/actions/users.js';

export default async function loginAnonymous(
username: string,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/auth/logins/password-user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getIdentityByUsername } from '../../db/actions/users.js';
import type { UserIdentityEntity } from '../../db/entities/index.js';
import { getIdentityByUsername } from '../../db/actions/users.js';
import { comparePassword } from '../../encryption.js';

export default async function loginUser(
Expand Down
36 changes: 18 additions & 18 deletions backend/src/auth/passport.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import passport from 'passport';
import { Strategy as GithubStrategy } from 'passport-github2';
import { Strategy as LocalStrategy, type IVerifyOptions } from 'passport-local';
import { Strategy as TwitterStrategy } from 'passport-twitter';
import { Strategy as GoogleStrategy } from 'passport-google-oauth20';
import { type IVerifyOptions, Strategy as LocalStrategy } from 'passport-local';
import { Strategy as GithubStrategy } from 'passport-github2';
import { Strategy as SlackStrategy } from 'passport-slack-oauth2';
import { Strategy as MicrosoftStrategy } from 'passport-microsoft';
import passportOkta from 'passport-okta-oauth20';
import { Strategy as SlackStrategy } from 'passport-slack-oauth2';
import { Strategy as TwitterStrategy } from 'passport-twitter';

const { Strategy: OktaStrategy } = passportOkta;

import chalk from 'chalk-template';
import type { Request } from 'express';
import type { AccountType } from '../common/index.js';
import config from '../config.js';
import { mergeAnonymous } from '../db/actions/merge.js';
import { type UserRegistration, registerUser } from '../db/actions/users.js';
import { type UserIds, deserialiseIds, serialiseIds } from '../utils.js';
import {
GITHUB_CONFIG,
TWITTER_CONFIG,
GOOGLE_CONFIG,
GITHUB_CONFIG,
MICROSOFT_CONFIG,
OKTA_CONFIG,
SLACK_CONFIG,
TWITTER_CONFIG,
OKTA_CONFIG,
} from './config.js';
import loginAnonymous from './logins/anonymous-user.js';
import type { AccountType } from '../common/index.js';
import chalk from 'chalk-template';
import loginUser from './logins/password-user.js';
import loginAnonymous from './logins/anonymous-user.js';
import type {
BaseProfile,
GitHubProfile,
TwitterProfile,
GoogleProfile,
GitHubProfile,
MicrosoftProfile,
OktaProfile,
SlackProfile,
TwitterProfile,
OktaProfile,
} from './types.js';
import { registerUser, type UserRegistration } from '../db/actions/users.js';
import { serialiseIds, type UserIds, deserialiseIds } from '../utils.js';
import config from '../config.js';
import type { Request } from 'express';
import { mergeAnonymous } from '../db/actions/merge.js';

export default () => {
passport.serializeUser<string>((user, cb) => {
Expand Down
6 changes: 3 additions & 3 deletions backend/src/auth/register/register-user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { v4 } from 'uuid';
import type { RegisterPayload } from '../../common/index.js';
import { getIdentityByUsername, registerUser } from '../../db/actions/users.js';
import { v4 } from 'uuid';
import { hashPassword } from '../../encryption.js';
import type { UserIdentityEntity } from '../../db/entities/index.js';
import { getIdentityByUsername, registerUser } from '../../db/actions/users.js';
import { canSendEmails } from '../../email/utils.js';
import { hashPassword } from '../../encryption.js';

export default async function registerPasswordUser(
details: RegisterPayload,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/auth/router.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { mergeAnonymous } from '../db/actions/merge.js';
import express, {
type NextFunction,
type Request,
type Response,
} from 'express';
import passport from 'passport';
import { mergeAnonymous } from '../db/actions/merge.js';
import type { UserIds } from '../utils.js';

const router = express.Router();
Expand Down
2 changes: 1 addition & 1 deletion backend/src/common/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Session, SessionOptions } from './types.js';
import type { SessionOptions, Session } from './types.js';

export const defaultOptions: SessionOptions = {
allowActions: true,
Expand Down
6 changes: 3 additions & 3 deletions backend/src/common/payloads.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type {
Plan,
Currency,
StripeLocales,
AccessErrorType,
CoachMessage,
Currency,
Plan,
Session,
StripeLocales,
} from './types.js';

export interface RegisterPayload {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/common/random-username.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
uniqueNamesGenerator,
adjectives,
animals,
uniqueNamesGenerator,
} from 'unique-names-generator';
import { v4 } from 'uuid';

Expand Down
2 changes: 1 addition & 1 deletion backend/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'node:fs';
import path from 'node:path';
import type { BackendConfig } from './types.js';
import dotenv from 'dotenv';
import { getDirname } from './path-utils.js';
import type { BackendConfig } from './types.js';

function findDotEnvPath(): string | null {
let current = getDirname(import.meta.url);
Expand Down
18 changes: 9 additions & 9 deletions backend/src/db/actions/ai.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { CoachMessage, CoachRole } from 'common/types.js';
import { addDays } from 'date-fns';
import { MoreThanOrEqual } from 'typeorm';
import { v4 } from 'uuid';
import config from '../../config.js';
import AiChatEntity from '../entities/AiChat.js';
import AiChatMessageEntity from '../entities/AiChatMessage.js';
import type UserView from '../entities/UserView.js';
import AiChatMessageRepository from '../repositories/AiChatMessageRepository.js';
import AiChatRepository from '../repositories/AiChatRepository.js';
import AiChatEntity from '../entities/AiChat.js';
import { transaction } from './transaction.js';
import AiChatRepository from '../repositories/AiChatRepository.js';
import { getUser } from './users.js';
import type { CoachMessage, CoachRole } from 'common/types.js';
import AiChatMessageRepository from '../repositories/AiChatMessageRepository.js';
import AiChatMessageEntity from '../entities/AiChatMessage.js';
import { v4 } from 'uuid';
import { MoreThanOrEqual } from 'typeorm';
import { addDays } from 'date-fns';
import config from '../../config.js';

export async function getAiChatSession(
id: string,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/db/actions/delete.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DeleteAccountPayload } from '../../common/index.js';
import type { EntityManager } from 'typeorm';
import { v4 } from 'uuid';
import type { DeleteAccountPayload } from '../../common/index.js';
import type { UserIdentityEntity, UserView } from '../entities/index.js';
import {
PostGroupRepository,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/db/actions/demo.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { DeepPartial } from 'typeorm';
import { v4 } from 'uuid';
import type { Post, Session } from '../../common/types.js';
import type { UserEntity } from '../../db/entities/UserIdentity.js';
import { getMiddle, getNext } from '../../lexorank.js';
import { savePost, saveVote } from './posts.js';
import { createSession, getSession, saveSession } from './sessions.js';
import { getNext, getMiddle } from '../../lexorank.js';
import { registerAnonymousUser } from './users.js';
import type { DeepPartial } from 'typeorm';

export async function createDemoSession(author: UserEntity): Promise<Session> {
const session = await createSession(author);
Expand Down
6 changes: 3 additions & 3 deletions backend/src/db/actions/licences.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { transaction } from './transaction.js';
import LicenceEntity from '../entities/Licence.js';
import { v4 } from 'uuid';
import { sendSelfHostWelcome } from '../../email/emailSender.js';
import LicenceEntity from '../entities/Licence.js';
import { saveAndReload } from '../repositories/BaseRepository.js';
import { LicenceRepository } from '../repositories/index.js';
import type { LicenceMetadata } from './../../types.js';
import { transaction } from './transaction.js';
import { saveAndReload } from '../repositories/BaseRepository.js';

export async function registerLicence(
email: string | null,
Expand Down
10 changes: 5 additions & 5 deletions backend/src/db/actions/merge.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { Request } from 'express';
import { getUserViewFromRequest } from '../../utils.js';
import type { UserView } from '../entities/index.js';
import AiChatRepository from '../repositories/AiChatRepository.js';
import { getUserView } from './users.js';
import { transaction } from './transaction.js';
import {
PostGroupRepository,
PostRepository,
SessionRepository,
VoteRepository,
} from '../repositories/index.js';
import { deleteAccount } from './delete.js';
import { transaction } from './transaction.js';
import { getUserView } from './users.js';
import { getUserViewFromRequest } from '../../utils.js';
import type { Request } from 'express';
import AiChatRepository from '../repositories/AiChatRepository.js';

export async function mergeAnonymous(req: Request, newUserIdentityId: string) {
const anonymousUser = await getUserViewFromRequest(req);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/db/actions/posts.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { DeepPartial } from 'typeorm';
import type { Post, PostGroup, Vote } from '../../common/index.js';
import {
PostGroupRepository,
PostRepository,
SessionRepository,
PostGroupRepository,
VoteRepository,
SessionRepository,
} from '../repositories/index.js';
import { transaction } from './transaction.js';

Expand Down
42 changes: 21 additions & 21 deletions backend/src/db/actions/sessions.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { uniq } from 'lodash-es';
import shortId from 'shortid';
import { type EntityManager, In } from 'typeorm';
import { v4 } from 'uuid';
import {
type AccessErrorType,
type ColumnDefinition,
type FullUser,
type Session,
type SessionMetadata,
type SessionOptions,
defaultSession,
} from '../../common/index.js';
import type MessageEntity from '../entities/Message.js';
import {
type ColumnDefinitionEntity,
type UserEntity,
type PostEntity,
type PostGroupEntity,
type ColumnDefinitionEntity,
type SessionEntity,
type SessionTemplateEntity,
SessionView,
type UserEntity,
} from '../entities/index.js';
import MessageRepository from '../repositories/MessageRepository.js';
import {
ColumnRepository,
PostGroupRepository,
PostRepository,
type Session,
defaultSession,
type ColumnDefinition,
type SessionOptions,
type SessionMetadata,
type AccessErrorType,
type FullUser,
} from '../../common/index.js';
import shortId from 'shortid';
import { v4 } from 'uuid';
import {
UserRepository,
SessionRepository,
SessionTemplateRepository,
UserRepository,
PostRepository,
PostGroupRepository,
ColumnRepository,
} from '../repositories/index.js';
import { transaction } from './transaction.js';
import { type EntityManager, In } from 'typeorm';
import { getUserViewInner, isUserPro } from './users.js';
import { uniq } from 'lodash-es';
import MessageRepository from '../repositories/MessageRepository.js';
import type MessageEntity from '../entities/Message.js';

export async function createSessionFromSlack(
slackUserId: string,
Expand Down
12 changes: 6 additions & 6 deletions backend/src/db/actions/subscriptions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { In } from 'typeorm';
import type { Currency, Plan } from '../../common/index.js';
import {
SubscriptionRepository,
UserRepository,
} from '../repositories/index.js';
import type { Plan, Currency } from '../../common/index.js';
import {
type SubscriptionEntity,
type UserEntity,
UserView,
} from '../entities/index.js';
import {
SubscriptionRepository,
UserRepository,
} from '../repositories/index.js';
import { transaction } from './transaction.js';
import { In } from 'typeorm';

export async function activateSubscription(
userId: string,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/db/actions/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EntityManager } from 'typeorm';
import { dataSource } from '../index.js';
import type { EntityManager } from 'typeorm';

type Inner<T> = (manager: EntityManager) => Promise<T>;

Expand Down
Loading

0 comments on commit dc978e0

Please sign in to comment.