API
The plugin contract types and helpers - FilesPlugin, FilesOperation, handlers, and createFiles. See the overview for how they compose.
The types and helpers that make up the plugin system. See the overview for how wrap, extend, and the pipeline fit together.
FilesPlugin
The plugin object you pass to plugins. A name plus up to two optional capabilities - wrap and extend.
namestring
Identifies the plugin in collision errors and diagnostics.
stringwrap?<O extends FilesOperation>(
op: O,
next: PluginNext
) => Promise<OperationResult<O>>
Tier A/B: wrap any operation. Call `next` to continue inward.
<O extends FilesOperation>(
op: O,
next: PluginNext
) => Promise<OperationResult<O>>extend?(files: Files) => Ext
Tier C: contribute namespaced surface. The only part that changes the type.
(files: Files) => ExtFilesOperation
The discriminated union handed to wrap - one variant per public verb, carrying the caller-facing inputs. The array forms of upload / download / head / exists / delete set bulk: true on each fanned-out item.
kind"upload"
"upload"options?UploadOptions
UploadOptionshandlers
function handlers(map: PluginHandlers): FilesPlugin["wrap"];
Builds a wrap from a per-verb map. Each handler is typed to its own operation and a same-kind next; verbs absent from the map pass through untouched.
createFiles
function createFiles(
opts: FilesOptions & { plugins?: FilesPlugin[] }
): Files & ExtensionsOf<plugins>;
Constructs a Files instance whose type includes every plugin’s extend surface. Runtime-identical to new Files(opts) - it exists only to surface the added methods on the type.