Skip to content
Files SDK
Esc
navigateopen⌘Jpreview
On this page

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.

PropType
namestring

Identifies the plugin in collision errors and diagnostics.

Typestring
wrap?<O extends FilesOperation>( op: O, next: PluginNext ) => Promise<OperationResult<O>>

Tier A/B: wrap any operation. Call `next` to continue inward.

Type<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.

Type(files: Files) => Ext

FilesOperation

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.

PropType
kind"upload"
Type"upload"
options?UploadOptions
TypeUploadOptions

handlers

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.

Was this page helpful?