MCPcopy
hub / github.com/simstudioai/sim / compileDocumentIfNeeded

Function compileDocumentIfNeeded

apps/sim/app/api/files/serve/[...path]/route.ts:33–49  ·  view source on GitHub ↗

* 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
)

Source from the content-addressed store, hash-verified

31 * bypasses resolution and serves the stored source as-is.
32 */
33async 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
51const STORAGE_KEY_PREFIX_RE = /^\d{13}-[a-z0-9]{7}-/
52

Callers 2

handleLocalFileFunction · 0.85
handleCloudProxyFunction · 0.85

Calls 2

getContentTypeFunction · 0.90
resolveServableDocBytesFunction · 0.90

Tested by

no test coverage detected