* Resolves the bytes + content type to serve for a stored file via the shared * resolveServableDocBytes (generated docs → compiled artifact). `raw=1` * bypasses resolution and serves the stored source as-is.
( buffer: Buffer, filename: string, workspaceId: string | undefined, raw: boolean, ownerKey: string | undefined, signal: AbortSignal | undefined )
| 31 | * bypasses resolution and serves the stored source as-is. |
| 32 | */ |
| 33 | async function compileDocumentIfNeeded( |
| 34 | buffer: Buffer, |
| 35 | filename: string, |
| 36 | workspaceId: string | undefined, |
| 37 | raw: boolean, |
| 38 | ownerKey: string | undefined, |
| 39 | signal: AbortSignal | undefined |
| 40 | ): Promise<{ buffer: Buffer; contentType: string }> { |
| 41 | if (raw) return { buffer, contentType: getContentType(filename) } |
| 42 | return resolveServableDocBytes({ |
| 43 | rawBuffer: buffer, |
| 44 | fileName: filename, |
| 45 | workspaceId, |
| 46 | ownerKey, |
| 47 | signal, |
| 48 | }) |
| 49 | } |
| 50 | |
| 51 | const STORAGE_KEY_PREFIX_RE = /^\d{13}-[a-z0-9]{7}-/ |
| 52 |
no test coverage detected