@jsvfs/adapter-azure-blob
Version:
An adapter for Azure Storage Blobs.
51 lines (50 loc) • 2.89 kB
TypeScript
/// <reference types="node" />
import { Journal, Matcher } from '@jsvfs/extras';
import { BlobServiceClient, ContainerClient } from '@azure/storage-blob';
import type { Adapter, ItemType, LinkType, SnapshotEntry } from '@jsvfs/types';
import type { AzureBlobAdapterOpts, AzBlobJournalEntry } from './types';
/** An adapter for Azure Storage Blobs. */
export declare class AzureBlobAdapter implements Adapter {
/** Creates an instance of Azure blob adapter. */
constructor(opts: AzureBlobAdapterOpts);
/** The backing instance of blob service client. */
readonly blobService: BlobServiceClient;
/** A cache of encountered container clients to optimize performance. */
readonly containerCache: Map<string, ContainerClient>;
/** The real root of this file system which will be committed to. */
readonly root: string;
/** The file globs to apply to `snapshot` and `flush` operations. */
readonly include: Matcher;
/** Whether to create a container if it does not yet exist. */
createIfNotExist: boolean;
/** Enable or disable flushing the file system. */
flushEnabled: boolean;
/** Log useful messages to the journal about file operations. */
journal: Journal<AzBlobJournalEntry>;
/** The handle for this adapter, basically an id. Should be something simple but descriptive, like 'node-fs' or 'blob'. */
handle: 'azure-blob';
/** Returns true if root is the storage account. */
get isGlobal(): boolean;
/** Snapshot of the underlying file system; an asynchronous iterable which returns an entry of path and data.
* @returns {AsyncGenerator<[string, SnapshotEntry]>} The asynchronous iterable to get the snapshot.
*/
snapshot(): AsyncGenerator<[string, SnapshotEntry]>;
/** Read a file from persistent storage. */
read(path: string): Promise<Buffer>;
/** Create a file or write the contents of a file to persistent storage. */
write(path: string, contents?: Buffer): Promise<void>;
/** Make a directory or directory tree in persistent storage. Technically unsupported by Microsoft, as 'directories' are virtual. */
mkdir(path: string): Promise<void>;
/** Create a link in persistent storage. Definitely unsupported by Microsoft, so we copy the file contents from an existing blob. */
link(linkPath: string, linkTarget: string, type: LinkType): Promise<void>;
/** Remove items from persistent storage. */
remove(path: string, type: ItemType): Promise<void>;
/** Flush the underlying file system to prepare for a commit. */
flush(): Promise<void>;
/** Reads a blob from blob storage. */
private readBlob;
/** Get or initialize the given container by name. */
private getContainer;
/** List the containers for this instance and optionally cache them. */
private listContainers;
}