search.ts 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { IPageInfoAll, IPageWithMeta } from './page';
  2. export enum CheckboxType {
  3. NONE_CHECKED = 'noneChecked',
  4. INDETERMINATE = 'indeterminate',
  5. ALL_CHECKED = 'allChecked',
  6. }
  7. export type IPageSearchMeta = {
  8. bookmarkCount?: number,
  9. elasticSearchResult?: {
  10. snippet: string;
  11. highlightedPath: string;
  12. isHtmlInPath: boolean;
  13. };
  14. }
  15. export const isIPageSearchMeta = (meta: IPageInfoAll | (IPageInfoAll & IPageSearchMeta) | undefined): meta is IPageInfoAll & IPageSearchMeta => {
  16. return meta != null && 'elasticSearchResult' in meta;
  17. };
  18. export type IFormattedSearchResult = {
  19. data: IPageWithMeta<IPageSearchMeta>[]
  20. totalCount: number
  21. meta: {
  22. total: number
  23. took?: number
  24. count?: number
  25. }
  26. }
  27. export const SORT_AXIS = {
  28. RELATION_SCORE: 'relationScore',
  29. CREATED_AT: 'createdAt',
  30. UPDATED_AT: 'updatedAt',
  31. } as const;
  32. export type SORT_AXIS = typeof SORT_AXIS[keyof typeof SORT_AXIS];
  33. export const SORT_ORDER = {
  34. DESC: 'desc',
  35. ASC: 'asc',
  36. } as const;
  37. export type SORT_ORDER = typeof SORT_ORDER[keyof typeof SORT_ORDER];