feat(nbstore): init (#7639)

TODO

- [x] basic
- [x] storages
- [x] producer/consumer
- [x] operation pattern
- [x] events
- [x] worker
- [x] readme
- [x] peer dependencies
This commit is contained in:
forehalo
2024-11-22 03:13:04 +00:00
parent 76eabf644c
commit 4125038ff8
18 changed files with 882 additions and 3 deletions
@@ -0,0 +1,29 @@
import { Storage, type StorageOptions } from './storage';
export interface BlobStorageOptions extends StorageOptions {}
export interface BlobRecord {
key: string;
data: Uint8Array;
mime: string;
createdAt: Date;
}
export interface ListedBlobRecord {
key: string;
mime: string;
size: number;
createdAt: Date;
}
export abstract class BlobStorage<
Options extends BlobStorageOptions = BlobStorageOptions,
> extends Storage<Options> {
override readonly storageType = 'blob';
abstract get(key: string): Promise<BlobRecord | null>;
abstract set(blob: BlobRecord): Promise<void>;
abstract delete(key: string, permanently: boolean): Promise<void>;
abstract release(): Promise<void>;
abstract list(): Promise<ListedBlobRecord[]>;
}