~app/types.ts
.ts
TypeScript
(application/typescript)
// generated via script[generate:prisma]
import type {
  Prisma,
  GlobalRole,
  Repository,
  Organization,
} from "@prisma/client";

export type AppThemeScheme = "light" | "dark";
export type WithThemeSchemeProp = {
  themeScheme: AppThemeScheme;
};

export interface AppSessionData extends Prisma.JsonObject {
  sessionId: null | string;
  authenticated: boolean;
  flash_message: null | string;
  flash_message_shown_once: boolean;
  curr_user_avatar_uri: null | string;
  curr_user_uid: null | string;
  curr_user_username: null | string;
  curr_user_role: null | GlobalRole;
  two_factor_lock: boolean;
  two_factor_complete: boolean;
}

export interface CommonViewProps {
  appVersion: string;
  authenticated: boolean;
  currentUserAvatarUri: string | null;
  currentUserId: string | null;
  currentUserRole: GlobalRole | null;
  currentUserUsername: string | null;
  gitStamp: string;
  flashMessage: string | null;
  themeScheme: AppThemeScheme;
  title?: string;
}

export type CommonProps = { commonProps: CommonViewProps };

export interface LanguageDetectFn {
  (path: string, callback: (err: Error, language: string | null) => void): void;
  sync: (path: string | null) => string | null;
  contents: (path: string, content: string) => string | null;
  filename: (path: string) => string | null;
  shebang: (content: string) => string | null;
  classify: (content: string) => string | null;
}

export interface LanguagesMap {
  [languageName: string]: {
    aceMode: string;
    aliases?: string[];
    color?: string;
    codemirrorMode?: string;
    codemirrorMimeType?: string;
    extensions?: string[];
    filenames?: string[];
    group?: string;
    interpreters?: string[];
    languageId: number;
    tmScope: string;
    type: string;
    wrap?: boolean;
  };
}

export interface LinguistFileInfos {
  color: string;
  extensions: string[];
  filenames?: string[];
  group?: string;
  language: string;
  languageDisplayName: string;
  languageId: number;
  mimeType: string;
  type: string;
}

export interface RepositoryHead {
  treeId: string;
  parentId: null | string;
  author: {
    name: string;
    email: string;
    timestamp: number;
    timezone: string;
  };
  committer: {
    name: string;
    email: string;
    timestamp: number;
    timezone: string;
  };
  commitMessage: string;
}

export interface RepositoryFile {
  id: string;
  name: string;
  permissions: string;
  type: "blob" | "tree";
  lastCommit: RepositoryLog | null;
}

export interface RepositoryFileContent {
  content: string;
  mimeType: string;
}

export interface RepositoryFileDiffChunkChange {
  type: string;
  del: boolean;
  oldLine?: number;
  newLine?: number;
  position: number;
  content: string;
}

export interface RepositoryFileDiffChunk {
  content: string;
  changes: RepositoryFileDiffChunkChange[];
  oldStart: number;
  oldLines: number;
  newStart: number;
  newLines: number;
}

export interface RepositoryFileDiff {
  additions: number;
  deletions: number;
  index: string[];
  from: string;
  to: string;
  chunks: RepositoryFileDiffChunk[];
}

export interface RepositoryLog {
  commit: string;
  abbreviated_commit: string;
  tree: string;
  abbreviated_tree: string;
  parent: string;
  abbreviated_parent: string;
  refs: string;
  encoding: string;
  subject: string;
  sanitized_subject_line: string;
  body: string;
  commit_notes: string;
  verification_flag: string;
  signer: string;
  signer_key: string;
  author: {
    name: string;
    email: string;
    date: string;
  };
  commiter: {
    name: string;
    email: string;
    date: string;
  };
}

export type RepositoryObject = RepositoryLog;

export interface RepositoryForkedFromRepoMeta {
  displayName: string | null;
  id: string;
  slug: string;
  organization: {
    displayName: string | null;
    id: string;
    slug: string;
  };
}

export type RepositoryWithForkedFromRepo = Repository & {
  forkedFromRepo: RepositoryForkedFromRepoMeta | null;
  forks: {
    _count: Prisma.RepositoryCountOutputType;
  }[];
};

export type RepositoryWithParentAndForkedFromRepos =
  RepositoryWithForkedFromRepo & {
    organization: Organization;
  };