compile.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { ClsiCachePromptVariant } from '@/features/pdf-preview/util/types'
  2. export type Chunk = {
  3. start: number
  4. end: number
  5. }
  6. export type PrefetchedChunk<ChunkType extends Chunk> = ChunkType & {
  7. buffer: Uint8Array
  8. }
  9. export type PDFRange<ObjectIdType = Uint8Array | string> = Chunk & {
  10. objectId: ObjectIdType
  11. hash: string
  12. size: number
  13. totalUsage: number
  14. }
  15. type OutputFileBase = {
  16. path: string
  17. url: string
  18. type: string
  19. build: string
  20. downloadURL: string
  21. // assigned by buildFileList in frontend
  22. main?: boolean
  23. }
  24. type PDFFileBase = OutputFileBase & {
  25. clsiCacheShard: string
  26. contentId: string
  27. editorId: string
  28. pdfDownloadUrl: string
  29. pdfUrl: string
  30. size: number
  31. startXRefTable?: number
  32. }
  33. export type PDFFile = PDFFileBase & {
  34. createdAt?: string
  35. ranges: PDFRange<string>[]
  36. prefetched?: PrefetchedChunk<PDFRange<Uint8Array>>[]
  37. }
  38. export type ProcessedPDFFile = PDFFileBase & {
  39. preprocessed: true
  40. createdAt: Date
  41. prefetched: PrefetchedChunk<PDFRange<Uint8Array>>[]
  42. ranges: PDFRange<Uint8Array>[]
  43. }
  44. // This type is a little bit of a hack to work around the fact that we mutate
  45. // the PDFFile object directly when processed into a ProcessedPDFFile
  46. export type PartiallyProcessedPDFFile = PDFFileBase & {
  47. preprocessed?: boolean
  48. createdAt?: Date | string
  49. prefetched?: PrefetchedChunk<PDFRange<Uint8Array>>[]
  50. ranges: PDFRange<Uint8Array>[] | PDFRange<string>[]
  51. }
  52. export type CompileOutputFile = OutputFileBase | PDFFile
  53. export type CompileResponseData = {
  54. fromCache?: boolean
  55. status: string
  56. outputFiles: CompileOutputFile[]
  57. compileGroup?: string
  58. clsiServerId?: string
  59. clsiCacheShard?: string
  60. pdfDownloadDomain?: string
  61. pdfCachingMinChunkSize: number
  62. validationProblems: any
  63. stats?: Record<string, number>
  64. timings?: Record<string, number>
  65. outputFilesArchive?: CompileOutputFile
  66. clsiCachePromptVariant?: ClsiCachePromptVariant
  67. // assigned on response body by DocumentCompiler in frontend
  68. rootDocId?: string | null
  69. options: CompileOptions
  70. }
  71. export type CompileOptions = {
  72. draft?: boolean
  73. stopOnFirstError?: boolean
  74. isAutoCompileOnLoad?: boolean
  75. isAutoCompileOnChange?: boolean
  76. rootResourcePath?: string
  77. imageName?: string
  78. compiler?: string
  79. }