import type { FetchMediaOptions, FetchMediaResult, SecretInputRef } from "./types.js";
/** Platform adapter that core/ modules use for framework-specific operations. */
export interface PlatformAdapter { /** Validate that a remote URL is safe to fetch (SSRF protection). */
validateRemoteUrl(url: string, options?: { allowPrivate?: boolean }): Promise<void>;
/** Resolve a secret value (SecretInput or plain string) to a plain string. */
resolveSecret(value: string | SecretInputRef | undefined): Promise<string | undefined>;
/** Download a remote file to a local directory. Returns the local file path. */
downloadFile(url: string, destDir: string, filename?: string): Promise<string>;
let _adapter: PlatformAdapter | null = null;
let _adapterFactory: (() => PlatformAdapter) | null = null;
/** Register the platform adapter. Called once during startup. */
export function registerPlatformAdapter(adapter: PlatformAdapter): void {
_adapter = adapter;
}
/** *Gettheregisteredplatformadapter. * *Ifnoadapterhasbeenexplicitlyregisteredyetbutafactorywasprovided *via`registerPlatformAdapterFactory()`,thefactoryisinvokedtocreate *andregistertheadapterautomatically.
*/
export function getPlatformAdapter(): PlatformAdapter { if (!_adapter && _adapterFactory) {
_adapter = _adapterFactory();
} if (!_adapter) { thrownew Error( "PlatformAdapter not registered. Call registerPlatformAdapter() during bootstrap.",
);
} return _adapter;
}
/** Check whether a platform adapter has been registered (or can be created from a factory). */
export function hasPlatformAdapter(): boolean { return _adapter !== null || _adapterFactory !== null;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.