~app/types.ts
.ts
TypeScript
(application/typescript)
import type { Prisma, GlobalRole } 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;
}

// @deprecated use #Section instead
export interface IDocSectionEntrypoint {
  slug: string;
  firstPageSlug: string;
  coverImageUrl: string;
  title: string;
  summary: string;
}

export interface Section {
  slug: string;
  title: string;
  summary: string;
  pagesBySlug: {
    [pageSlug: string]: Page;
  };
}

export interface PageSummary {
  title: string;
  subtitle?: string;
  href: string;
}

export interface Page {
  slug: string;
  content: string;
  tableOfContent: Array<{
    title: string;
    targetAnchor: string;
    depth: number;
  }>;
  metas: {
    [x: string]: any;
    title?: string;
    summary?: string;
    showExamples?: string;
    examplesFile?: string;
    prevPage?: null | PageSummary;
    nextPage?: null | PageSummary;
  };
}

export type SectionsPagesIndex = {
  [sectionSlug: string]: string[];
};

export type SectionsWithPages = {
  [sectionSlug: string]: Section;
};

export interface CommonViewProps {
  authenticated: boolean;
  currentSectionSlug: string | undefined;
  currentPageSlug: string | undefined;
  menuDefinition: SectionsWithPages;
  themeScheme: AppThemeScheme;
  title?: string;
}

export type CommonProps = { commonProps: CommonViewProps };

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";
}