longcelot-sheet-db
Version:
Google Sheets-backed staging database adapter for Node.js with schema-first design
33 lines • 1.89 kB
TypeScript
import { StorageAdapter, UploadOptions, UploadActorContext } from '../schema/types';
import { SheetClient } from './sheetClient';
import { type DriveTenancyInjection } from './driveTenancy';
export interface DriveStorageAdapterOptions {
/** Default upload folder path (relative to the resolved base folder — see UploadOptions.folder). */
folder?: string;
}
export declare class DriveStorageAdapter implements StorageAdapter {
private _client?;
/** Tenancy config injected by SheetAdapter — undefined when constructed/used standalone. */
private _tenancy?;
private readonly defaultFolder;
/** Cached Drive folder IDs, keyed by a scope-namespaced path so an actor-owned client's folders
* never collide with the shared admin client's folders of the same name. */
private readonly _folderCache;
/** Cached actor-owned SheetClients, keyed by userId — avoids rebuilding one per upload. */
private readonly _actorClientCache;
constructor(options?: DriveStorageAdapterOptions);
/** Called by SheetAdapter at construction time — injects the shared SheetClient + tenancy config. */
_setClient(client: SheetClient, tenancy?: DriveTenancyInjection): void;
private get client();
upload(file: Buffer, options: UploadOptions): Promise<string>;
delete(url: string, actorContext?: UploadActorContext): Promise<void>;
/**
* Resolves which client (and folder-cache scope) an upload/delete should use for `actorContext`:
* an actor on the actor-owned sheet model (resolved via `tokenStore`, same as `createUserSheet()`)
* gets their own Drive; everyone else (no context, `actor: 'admin'`, or no tenancy config at all)
* shares the single admin/default client — the pre-Phase-23 behavior.
*/
private resolveClient;
private resolveFolder;
}
//# sourceMappingURL=driveStorageAdapter.d.ts.map