websocket.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // External user group sync
  17. GroupSyncProgress: 'groupSyncProgress',
  18. FinishGroupSync: 'finishGroupSync',
  19. // Page Operation
  20. PageCreated: 'page:create',
  21. PageUpdated: 'page:update',
  22. PageDeleted: 'page:delete',
  23. // Hackmd
  24. EditingWithHackmd: 'page:editingWithHackmd',
  25. } as const;
  26. export type SocketEventName = typeof SocketEventName[keyof typeof SocketEventName];
  27. type PageId = string;
  28. type DescendantCount = number;
  29. /**
  30. * Data of updateDescCount when used through socket.io. Convert to UpdateDescCountData type when use with swr cache.
  31. */
  32. export type UpdateDescCountRawData = Record<PageId, DescendantCount>;
  33. export type UpdateDescCountData = Map<PageId, DescendantCount>;
  34. export type PMStartedData = { total: number };
  35. export type PMMigratingData = { count: number };
  36. export type PMErrorCountData = { skip: number };
  37. export type PMEndedData = { isSucceeded: boolean };
  38. export type PageMigrationErrorData = { paths: string[] }