page-bulk-export.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import type {
  2. HasObjectId,
  3. IAttachment, IPage, IRevision, IUser, Ref,
  4. } from '@growi/core';
  5. export const PageBulkExportFormat = {
  6. md: 'md',
  7. pdf: 'pdf',
  8. } as const;
  9. export type PageBulkExportFormat = typeof PageBulkExportFormat[keyof typeof PageBulkExportFormat]
  10. export const PageBulkExportJobInProgressStatus = {
  11. initializing: 'initializing', // preparing for export
  12. exporting: 'exporting', // exporting to fs
  13. uploading: 'uploading', // uploading to cloud storage
  14. } as const;
  15. export const PageBulkExportJobStatus = {
  16. ...PageBulkExportJobInProgressStatus,
  17. completed: 'completed',
  18. failed: 'failed',
  19. } as const;
  20. export type PageBulkExportJobStatus = typeof PageBulkExportJobStatus[keyof typeof PageBulkExportJobStatus]
  21. export interface IPageBulkExportJob {
  22. user: Ref<IUser>, // user that started export job
  23. page: Ref<IPage>, // the root page of page tree to export
  24. lastExportedPagePath?: string, // the path of page that was exported to the fs last
  25. format: PageBulkExportFormat,
  26. completedAt?: Date, // the date at which job was completed
  27. attachment?: Ref<IAttachment>,
  28. status: PageBulkExportJobStatus,
  29. statusOnPreviousCronExec?: PageBulkExportJobStatus, // status on previous cron execution
  30. revisionListHash?: string, // Hash created from the list of revision IDs. Used to detect existing duplicate uploads.
  31. restartFlag: boolean, // flag to restart the job
  32. createdAt?: Date,
  33. updatedAt?: Date
  34. }
  35. export interface IPageBulkExportJobHasId extends IPageBulkExportJob, HasObjectId {}
  36. // snapshot of page info to upload
  37. export interface IPageBulkExportPageSnapshot {
  38. pageBulkExportJob: Ref<IPageBulkExportJob>,
  39. path: string, // page path when export was stared
  40. revision: Ref<IRevision>, // page revision when export was stared
  41. }