Restore approved state (tree of 4effcc7 "Added LICENSE")
Roll the working tree back to the last approved shape, before the post-LICENSE span that false-greened the AFI parity matrix with symbol-presence probes and smuggled an unauthorized SQLAlchemy dependency into FastAPI's Shapes binding.
Forward commit, not a history rewrite — the six commits since 4effcc7 stay in the log as the record of what happened.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -386,18 +386,6 @@ async function resolveHeaders(): Promise<Record<string, string>> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Browser-safe `File` check — `File` is undefined under Node/SSR. */
|
||||
function isFile(value: unknown): boolean {
|
||||
return typeof File !== 'undefined' && value instanceof File
|
||||
}
|
||||
|
||||
/** True when any arg is a file (or an array containing a file). */
|
||||
function hasFileArg(args: Record<string, any>): boolean {
|
||||
return Object.values(args).some(
|
||||
(v) => isFile(v) || (Array.isArray(v) && v.some(isFile)),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Mizan transport — POST `${baseUrl}/call/` and GET
|
||||
* `${baseUrl}/ctx/${name}/`. Compatible with `mizan-fastapi`,
|
||||
@@ -409,38 +397,13 @@ export function httpTransport(): MizanTransport {
|
||||
return {
|
||||
async call(functionName, args) {
|
||||
const headers = await resolveHeaders()
|
||||
|
||||
// File-typed args switch the call to multipart/form-data: `fn` and a
|
||||
// JSON `args` part for the non-file fields, plus one part per file
|
||||
// (an array field repeats its part). Otherwise JSON as usual. The
|
||||
// server reconstructs the args dict by merging the file parts back in.
|
||||
let body: BodyInit
|
||||
if (hasFileArg(args)) {
|
||||
const form = new FormData()
|
||||
form.append('fn', functionName)
|
||||
const jsonArgs: Record<string, any> = {}
|
||||
for (const [key, value] of Object.entries(args)) {
|
||||
if (isFile(value)) {
|
||||
form.append(key, value)
|
||||
} else if (Array.isArray(value) && value.some(isFile)) {
|
||||
for (const item of value) form.append(key, item as Blob)
|
||||
} else {
|
||||
jsonArgs[key] = value
|
||||
}
|
||||
}
|
||||
form.append('args', JSON.stringify(jsonArgs))
|
||||
body = form
|
||||
// Content-Type is set by the browser (with the multipart boundary).
|
||||
} else {
|
||||
headers['Content-Type'] = 'application/json'
|
||||
body = JSON.stringify({ fn: functionName, args })
|
||||
}
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
const res = await fetch(`${config.baseUrl}/call/`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
credentials: 'same-origin',
|
||||
body,
|
||||
body: JSON.stringify({ fn: functionName, args }),
|
||||
})
|
||||
if (!res.ok) throw new MizanError(res.status, await res.text())
|
||||
return res.json()
|
||||
|
||||
Reference in New Issue
Block a user