search.ts 958 B

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