mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-14 21:35:25 +00:00
refactor
This commit is contained in:
parent
bddbb76a6a
commit
ceee66ed46
22 changed files with 39 additions and 24 deletions
|
|
@ -6,7 +6,7 @@ import { memo, useEffect, useMemo, useState } from 'react'
|
|||
import { useCodeMirrorHighlighter } from '@/hooks/useCodeMirrorHighlighter'
|
||||
import tailwind from '@/tailwind'
|
||||
import { measure } from '@/lib/utils'
|
||||
import { SourceRange } from '@/features/search/types'
|
||||
import { SourceRange } from '@/features/search'
|
||||
|
||||
// Define a plain text language
|
||||
const plainTextLanguage = StreamLanguage.define({
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { Suggestion, SuggestionMode } from "./searchSuggestionsBox";
|
|||
import { getRepos, search } from "@/app/api/(client)/client";
|
||||
import { getSearchContexts } from "@/actions";
|
||||
import { useMemo } from "react";
|
||||
import { SearchSymbol } from "@/features/search/types";
|
||||
import { SearchSymbol } from "@/features/search";
|
||||
import { languageMetadataMap } from "@/lib/languageMetadata";
|
||||
import {
|
||||
VscSymbolClass,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { EditorContextMenu } from "@/app/[domain]/components/editorContextMenu";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { SearchResultChunk } from "@/features/search/types";
|
||||
import { SearchResultChunk } from "@/features/search";
|
||||
import { useCodeMirrorTheme } from "@/hooks/useCodeMirrorTheme";
|
||||
import { useKeymapExtension } from "@/hooks/useKeymapExtension";
|
||||
import { useCodeMirrorLanguageExtension } from "@/hooks/useCodeMirrorLanguageExtension";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { CodePreview } from "./codePreview";
|
||||
import { SearchResultFile } from "@/features/search/types";
|
||||
import { SearchResultFile } from "@/features/search";
|
||||
import { SymbolIcon } from "@radix-ui/react-icons";
|
||||
import { SetStateAction, Dispatch, useMemo } from "react";
|
||||
import { unwrapServiceError } from "@/lib/utils";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use client';
|
||||
|
||||
import { FileIcon } from "@/components/ui/fileIcon";
|
||||
import { RepositoryInfo, SearchResultFile } from "@/features/search/types";
|
||||
import { RepositoryInfo, SearchResultFile } from "@/features/search";
|
||||
import { cn, getCodeHostInfoForRepo } from "@/lib/utils";
|
||||
import { LaptopIcon } from "@radix-ui/react-icons";
|
||||
import Image from "next/image";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { SearchResultFile } from "@/features/search/types";
|
||||
import { SearchResultFile } from "@/features/search";
|
||||
import { useMemo } from "react";
|
||||
import { useGetSelectedFromQuery } from "./useGetSelectedFromQuery";
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from "@/components/ui/resizable";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { RepositoryInfo, SearchResultFile, SearchStats } from "@/features/search/types";
|
||||
import { RepositoryInfo, SearchResultFile, SearchStats } from "@/features/search";
|
||||
import useCaptureEvent from "@/hooks/useCaptureEvent";
|
||||
import { useDomain } from "@/hooks/useDomain";
|
||||
import { useNonEmptyQueryParam } from "@/hooks/useNonEmptyQueryParam";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { SearchResultFile, SearchResultChunk } from "@/features/search/types";
|
||||
import { SearchResultFile, SearchResultChunk } from "@/features/search";
|
||||
import { LightweightCodeHighlighter } from "@/app/[domain]/components/lightweightCodeHighlighter";
|
||||
import Link from "next/link";
|
||||
import { getBrowsePath } from "@/app/[domain]/browse/hooks/utils";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { Separator } from "@/components/ui/separator";
|
|||
import { DoubleArrowDownIcon, DoubleArrowUpIcon } from "@radix-ui/react-icons";
|
||||
import { useMemo } from "react";
|
||||
import { FileMatch } from "./fileMatch";
|
||||
import { RepositoryInfo, SearchResultFile } from "@/features/search/types";
|
||||
import { RepositoryInfo, SearchResultFile } from "@/features/search";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
export const MAX_MATCHES_TO_PREVIEW = 3;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { RepositoryInfo, SearchResultFile } from "@/features/search/types";
|
||||
import { RepositoryInfo, SearchResultFile } from "@/features/search";
|
||||
import { useVirtualizer, VirtualItem } from "@tanstack/react-virtual";
|
||||
import { useDebounce } from "@uidotdev/usehooks";
|
||||
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from "react";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
|
||||
import { RepositoryInfo, SearchRequest, SearchResultFile, SearchStats, StreamedSearchResponse } from '@/features/search/types';
|
||||
import { RepositoryInfo, SearchRequest, SearchResultFile, SearchStats, StreamedSearchResponse } from '@/features/search';
|
||||
import { useState, useCallback, useRef, useEffect } from 'react';
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
|
||||
|
|
|
|||
|
|
@ -4,10 +4,12 @@ import { ServiceError } from "@/lib/serviceError";
|
|||
import { GetVersionResponse, GetReposResponse } from "@/lib/types";
|
||||
import { isServiceError } from "@/lib/utils";
|
||||
import {
|
||||
FileSourceResponse,
|
||||
FileSourceRequest,
|
||||
SearchRequest,
|
||||
SearchResponse,
|
||||
} from "@/features/search";
|
||||
import {
|
||||
FileSourceRequest,
|
||||
FileSourceResponse,
|
||||
} from "@/features/search/types";
|
||||
import {
|
||||
FindRelatedSymbolsRequest,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
'use server';
|
||||
|
||||
import { search } from "@/features/search/searchApi";
|
||||
import { search, searchRequestSchema } from "@/features/search";
|
||||
import { isServiceError } from "@/lib/utils";
|
||||
import { NextRequest } from "next/server";
|
||||
import { schemaValidationError, serviceErrorResponse } from "@/lib/serviceError";
|
||||
import { searchRequestSchema } from "@/features/search/types";
|
||||
|
||||
export const POST = async (request: NextRequest) => {
|
||||
const body = await request.json();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
'use server';
|
||||
|
||||
import { streamSearch } from '@/features/search/searchApi';
|
||||
import { searchRequestSchema } from '@/features/search/types';
|
||||
import { streamSearch, searchRequestSchema } from '@/features/search';
|
||||
import { schemaValidationError, serviceErrorResponse } from '@/lib/serviceError';
|
||||
import { isServiceError } from '@/lib/utils';
|
||||
import { NextRequest } from 'next/server';
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { getBrowsePath } from "@/app/[domain]/browse/hooks/utils";
|
|||
import { PathHeader } from "@/app/[domain]/components/pathHeader";
|
||||
import { LightweightCodeHighlighter } from "@/app/[domain]/components/lightweightCodeHighlighter";
|
||||
import { FindRelatedSymbolsResponse } from "@/features/codeNav/types";
|
||||
import { RepositoryInfo, SourceRange } from "@/features/search/types";
|
||||
import { RepositoryInfo, SourceRange } from "@/features/search";
|
||||
import { useMemo, useRef } from "react";
|
||||
import useCaptureEvent from "@/hooks/useCaptureEvent";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Badge } from "@/components/ui/badge";
|
|||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { LightweightCodeHighlighter } from "@/app/[domain]/components/lightweightCodeHighlighter";
|
||||
import { useMemo } from "react";
|
||||
import { SourceRange } from "@/features/search/types";
|
||||
import { SourceRange } from "@/features/search";
|
||||
|
||||
interface SymbolDefinitionPreviewProps {
|
||||
symbolDefinition: {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { findSearchBasedSymbolDefinitions } from "@/app/api/(client)/client";
|
||||
import { SourceRange } from "@/features/search/types";
|
||||
import { SourceRange } from "@/features/search";
|
||||
import { useDomain } from "@/hooks/useDomain";
|
||||
import { unwrapServiceError } from "@/lib/utils";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from "zod"
|
||||
import { search } from "@/features/search/searchApi"
|
||||
import { search } from "@/features/search"
|
||||
import { InferToolInput, InferToolOutput, InferUITool, tool, ToolUIPart } from "ai";
|
||||
import { isServiceError } from "@/lib/utils";
|
||||
import { getFileSource } from "../search/fileSourceApi";
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'server-only';
|
||||
|
||||
import { sew } from "@/actions";
|
||||
import { search } from "@/features/search/searchApi";
|
||||
import { search } from "@/features/search";
|
||||
import { ServiceError } from "@/lib/serviceError";
|
||||
import { isServiceError } from "@/lib/utils";
|
||||
import { withOptionalAuthV2 } from "@/withAuthV2";
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import { withOptionalAuthV2 } from "@/withAuthV2";
|
|||
import { QueryIR } from './ir';
|
||||
// @todo (bkellam) #574 : We should really be using `git show <hash>:<path>` to fetch file contents here.
|
||||
// This will allow us to support permalinks to files at a specific revision that may not be indexed
|
||||
// by zoekt.
|
||||
// by zoekt. We should also refactor this out of the /search folder.
|
||||
|
||||
export const getFileSource = async ({ fileName, repository, branch }: FileSourceRequest): Promise<FileSourceResponse | ServiceError> => sew(() =>
|
||||
withOptionalAuthV2(async () => {
|
||||
|
|
|
|||
15
packages/web/src/features/search/index.ts
Normal file
15
packages/web/src/features/search/index.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
export { search, streamSearch } from './searchApi';
|
||||
export {
|
||||
searchRequestSchema,
|
||||
} from './types';
|
||||
export type {
|
||||
SourceRange,
|
||||
SearchSymbol,
|
||||
RepositoryInfo,
|
||||
SearchRequest,
|
||||
SearchResultFile,
|
||||
SearchStats,
|
||||
StreamedSearchResponse,
|
||||
SearchResultChunk,
|
||||
SearchResponse,
|
||||
} from './types';
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { EditorSelection, Extension, StateEffect, StateField, Text, Transaction } from "@codemirror/state";
|
||||
import { Decoration, DecorationSet, EditorView } from "@codemirror/view";
|
||||
import { SourceRange } from "@/features/search/types";
|
||||
import { SourceRange } from "@/features/search";
|
||||
|
||||
const setMatchState = StateEffect.define<{
|
||||
selectedMatchIndex: number,
|
||||
|
|
|
|||
Loading…
Reference in a new issue