File
Blob: src/worker/objects/file-dav/types.ts
| 1 | import type { ParsedIfHeader } from "@/worker/dav/if-header"; |
| 2 | import type { NormalizedDavPath } from "@/worker/dav/paths"; |
| 3 | import type { FileBlobRow, FileDeadPropRow, FileLockRow, FileNodeRow } from "@/worker/db/file-dav-do/schema"; |
| 4 | import type { LockDepth, LockScope } from "@/worker/db/types"; |
| 5 | |
| 6 | export type FileDavErrorCode = |
| 7 | | "bad_request" |
| 8 | | "conflict" |
| 9 | | "forbidden" |
| 10 | | "locked" |
| 11 | | "method_not_allowed" |
| 12 | | "not_found" |
| 13 | | "payload_too_large" |
| 14 | | "precondition_failed"; |
| 15 | |
| 16 | export interface FileDavError { |
| 17 | ok: false; |
| 18 | status: number; |
| 19 | code: FileDavErrorCode; |
| 20 | message: string; |
| 21 | } |
| 22 | |
| 23 | export interface SubjectInput { |
| 24 | subjectId: string; |
| 25 | storageId: string; |
| 26 | } |
| 27 | |
| 28 | export interface FileDavNodeView { |
| 29 | node: FileNodeRow; |
| 30 | href: string; |
| 31 | depth: number; |
| 32 | deadProps: FileDeadPropRow[]; |
| 33 | locks: FileLockRow[]; |
| 34 | } |
| 35 | |
| 36 | export interface BlobGcCandidate { |
| 37 | blobId: string; |
| 38 | blobKey: string; |
| 39 | } |
| 40 | |
| 41 | export interface EnsureInitializedInput extends SubjectInput { |
| 42 | nowMs: number; |
| 43 | } |
| 44 | |
| 45 | export interface PropfindInput extends SubjectInput { |
| 46 | path: NormalizedDavPath; |
| 47 | depth: "0" | "1" | "infinity"; |
| 48 | maxNodes: number; |
| 49 | nowMs: number; |
| 50 | } |
| 51 | |
| 52 | export interface MkcolInput extends SubjectInput { |
| 53 | path: NormalizedDavPath; |
| 54 | ifHeader: ParsedIfHeader; |
| 55 | lockTokens: string[]; |
| 56 | nowMs: number; |
| 57 | } |
| 58 | |
| 59 | export interface ProppatchInput extends SubjectInput { |
| 60 | path: NormalizedDavPath; |
| 61 | instructions: ( |
| 62 | | { kind: "set"; nsUri: string; localName: string; xmlValue: string } |
| 63 | | { kind: "remove"; nsUri: string; localName: string } |
| 64 | )[]; |
| 65 | ifMatch: string | null; |
| 66 | ifNoneMatch: string | null; |
| 67 | ifHeader: ParsedIfHeader; |
| 68 | lockTokens: string[]; |
| 69 | nowMs: number; |
| 70 | } |
| 71 | |
| 72 | export interface BeginWriteInput extends SubjectInput { |
| 73 | path: NormalizedDavPath; |
| 74 | contentLength: number | null; |
| 75 | contentType: string | null; |
| 76 | contentLanguage: string | null; |
| 77 | ifMatch: string | null; |
| 78 | ifNoneMatch: string | null; |
| 79 | ifHeader: ParsedIfHeader; |
| 80 | lockTokens: string[]; |
| 81 | nowMs: number; |
| 82 | maxFileBytes: number; |
| 83 | } |
| 84 | |
| 85 | export interface CommitWriteInput extends SubjectInput { |
| 86 | uploadId: string; |
| 87 | size: number; |
| 88 | r2Etag: string | null; |
| 89 | contentType: string | null; |
| 90 | contentLanguage: string | null; |
| 91 | sha256?: string | null; |
| 92 | nowMs: number; |
| 93 | } |
| 94 | |
| 95 | export interface ResolveFileInput extends SubjectInput { |
| 96 | path: NormalizedDavPath; |
| 97 | ifMatch: string | null; |
| 98 | ifNoneMatch: string | null; |
| 99 | nowMs: number; |
| 100 | } |
| 101 | |
| 102 | export interface DeleteInput extends SubjectInput { |
| 103 | path: NormalizedDavPath; |
| 104 | ifMatch: string | null; |
| 105 | ifNoneMatch: string | null; |
| 106 | ifHeader: ParsedIfHeader; |
| 107 | lockTokens: string[]; |
| 108 | nowMs: number; |
| 109 | maxNodes: number; |
| 110 | } |
| 111 | |
| 112 | export interface CopyInput extends SubjectInput { |
| 113 | from: NormalizedDavPath; |
| 114 | to: NormalizedDavPath; |
| 115 | depth: "0" | "infinity"; |
| 116 | overwrite: boolean; |
| 117 | ifMatch: string | null; |
| 118 | ifNoneMatch: string | null; |
| 119 | ifHeader: ParsedIfHeader; |
| 120 | lockTokens: string[]; |
| 121 | nowMs: number; |
| 122 | maxNodes: number; |
| 123 | } |
| 124 | |
| 125 | export interface MoveInput extends SubjectInput { |
| 126 | from: NormalizedDavPath; |
| 127 | to: NormalizedDavPath; |
| 128 | overwrite: boolean; |
| 129 | ifMatch: string | null; |
| 130 | ifNoneMatch: string | null; |
| 131 | ifHeader: ParsedIfHeader; |
| 132 | lockTokens: string[]; |
| 133 | nowMs: number; |
| 134 | maxNodes: number; |
| 135 | } |
| 136 | |
| 137 | export interface LockInput extends SubjectInput { |
| 138 | path: NormalizedDavPath; |
| 139 | ownerXml: string | null; |
| 140 | scope: LockScope; |
| 141 | depth: LockDepth; |
| 142 | timeoutSeconds: number; |
| 143 | ifHeader: ParsedIfHeader; |
| 144 | lockTokens: string[]; |
| 145 | nowMs: number; |
| 146 | refresh: boolean; |
| 147 | } |
| 148 | |
| 149 | export interface UnlockInput extends SubjectInput { |
| 150 | path: NormalizedDavPath; |
| 151 | lockToken: string; |
| 152 | nowMs: number; |
| 153 | } |
| 154 | |
| 155 | export interface AbortWriteInput { |
| 156 | uploadId: string; |
| 157 | } |
| 158 | |
| 159 | export interface CleanupExpiredPendingUploadsInput extends SubjectInput { |
| 160 | nowMs: number; |
| 161 | limit: number; |
| 162 | } |
| 163 | |
| 164 | export interface CleanupExpiredLocksInput extends SubjectInput { |
| 165 | nowMs: number; |
| 166 | limit: number; |
| 167 | } |
| 168 | |
| 169 | export interface FileDavRepairInput extends SubjectInput { |
| 170 | nowMs: number; |
| 171 | limit: number; |
| 172 | } |
| 173 | |
| 174 | export interface VerifyBlobUnreferencedInput { |
| 175 | subjectId: string; |
| 176 | blobId: string; |
| 177 | blobKey: string; |
| 178 | nowMs: number; |
| 179 | } |
| 180 | |
| 181 | export interface BeginWriteResult { |
| 182 | ok: true; |
| 183 | uploadId: string; |
| 184 | blobId: string; |
| 185 | blobKey: string; |
| 186 | } |
| 187 | |
| 188 | export interface CommitWriteResult { |
| 189 | ok: true; |
| 190 | created: boolean; |
| 191 | node: FileNodeRow; |
| 192 | blobGc: BlobGcCandidate[]; |
| 193 | } |
| 194 | |
| 195 | export interface ResolveFileResult { |
| 196 | ok: true; |
| 197 | node: FileNodeRow; |
| 198 | blob: FileBlobRow | null; |
| 199 | href: string; |
| 200 | } |