websocket.ts 1.3 KB

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