Skip to content
Snippets Groups Projects
apiPath.ts 2.77 KiB
Newer Older
import { PROJECT_ID } from '@/constants';
import { PerfectSearchParams } from '@/types/search';
import { Point } from '@/types/map';

export const apiPath = {
  getBioEntityContentsStringWithQuery: ({
    searchQuery,
    isPerfectMatch,
  }: PerfectSearchParams): string =>
    `projects/${PROJECT_ID}/models/*/bioEntities/:search?query=${searchQuery}&size=1000&perfectMatch=${isPerfectMatch}`,
  getSingleBioEntityContentsStringWithCoordinates: (
    { x, y }: Point,
    currentModelId: number,
  ): string => {
    const coordinates = [x, y].join();
    return `projects/${PROJECT_ID}/models/${currentModelId}/bioEntities:search/?coordinates=${coordinates}&count=1`;
  },
  getReactionsWithIds: (ids: number[]): string =>
    `projects/${PROJECT_ID}/models/*/bioEntities/reactions/?id=${ids.join(',')}&size=1000`,
  getDrugsStringWithQuery: (searchQuery: string): string =>
    `projects/${PROJECT_ID}/drugs:search?query=${searchQuery}`,
  getModelsString: (): string => `projects/${PROJECT_ID}/models/`,
  getChemicalsStringWithQuery: (searchQuery: string): string =>
    `projects/${PROJECT_ID}/chemicals:search?query=${searchQuery}`,
  getAllOverlaysByProjectIdQuery: (
    projectId: string,
    { publicOverlay }: { publicOverlay: boolean },
  ): string => `projects/${projectId}/overlays/?publicOverlay=${String(publicOverlay)}`,
  getAllBackgroundsByProjectIdQuery: (projectId: string): string =>
    `projects/${projectId}/backgrounds/`,
  getProjectById: (projectId: string): string => `projects/${projectId}`,
  getSessionValid: (): string => `users/isSessionValid`,
  postLogin: (): string => `doLogin`,
  getConfigurationOptions: (): string => 'configuration/options/',
  getConfiguration: (): string => 'configuration/',
  getOverlayBioEntity: ({ overlayId, modelId }: { overlayId: number; modelId: number }): string =>
    `projects/${PROJECT_ID}/overlays/${overlayId}/models/${modelId}/bioEntities/`,
  createOverlay: (projectId: string): string => `projects/${projectId}/overlays/`,
  createOverlayFile: (): string => `files/`,
  uploadOverlayFileContent: (fileId: number): string => `files/${fileId}:uploadContent`,
  getStatisticsById: (projectId: string): string => `projects/${projectId}/statistics/`,
  getCompartmentPathwaysIds: (objectId: number): string =>
    `projects/${PROJECT_ID}/models/${objectId}/bioEntities/elements/?columns=id&type=Compartment,Pathway`,
  getCompartmentPathwayDetails: (ids: number[]): string =>
    `projects/${PROJECT_ID}/models/*/bioEntities/elements/?id=${ids.join(',')}`,
  sendCompartmentPathwaysIds: (): string => `projects/${PROJECT_ID}/models/*/bioEntities/elements/`,
  getSourceFile: (): string => `/projects/${PROJECT_ID}:downloadSource`,
  getMesh: (meshId: string): string => `mesh/${meshId}`,
  getTaxonomy: (taxonomyId: string): string => `taxonomy/${taxonomyId}`,