websocket.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. export const SocketEventName = {
  2. // Update descendantCount
  3. UpdateDescCount: 'UpdateDescCount',
  4. // Public migration
  5. PMStarted: 'PublicMigrationStarted',
  6. PMMigrating: 'PublicMigrationMigrating',
  7. PMErrorCount: 'PublicMigrationErrorCount',
  8. PMEnded: 'PublicMigrationEnded',
  9. // Page migration
  10. PageMigrationSuccess: 'PageMigrationSuccess',
  11. PageMigrationError: 'PageMigrationError',
  12. // Elasticsearch
  13. AddPageProgress: 'addPageProgress',
  14. FinishAddPage: 'finishAddPage',
  15. RebuildingFailed: 'rebuildingFailed',
  16. } as const;
  17. export type SocketEventName = typeof SocketEventName[keyof typeof SocketEventName];
  18. type PageId = string;
  19. type DescendantCount = number;
  20. /**
  21. * Data of updateDescCount when used through socket.io. Convert to UpdateDescCountData type when use with swr cache.
  22. */
  23. export type UpdateDescCountRawData = Record<PageId, DescendantCount>;
  24. export type UpdateDescCountData = Map<PageId, DescendantCount>;
  25. export type PMStartedData = { total: number };
  26. export type PMMigratingData = { count: number };
  27. export type PMErrorCountData = { skip: number };
  28. export type PMEndedData = { isSucceeded: boolean };
  29. export type PageMigrationErrorData = { paths: string[] }