Implementa o MVP do Adaptador de Planilhas no Elo Pro.
O módulo usa a identidade Supabase, isola cada workspace e registra storage, TTL, runner e biblioteca XLSX como decisões ainda abertas. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
6e23f1533b
144 files changed
+19060
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { AdapterError } from "@/domain/spreadsheet-adapter/errors";
|
||||
import { assertStorageKey } from "@/domain/spreadsheet-adapter/filenames";
|
||||
|
||||
export interface ObjectStorage {
|
||||
put(key: string, body: Buffer): Promise<void>;
|
||||
get(key: string): Promise<Buffer>;
|
||||
delete(key: string): Promise<void>;
|
||||
list(prefix: string): Promise<string[]>;
|
||||
}
|
||||
|
||||
export class MemoryStorage implements ObjectStorage {
|
||||
private readonly objects = new Map<string, Buffer>();
|
||||
|
||||
async put(key: string, body: Buffer): Promise<void> {
|
||||
assertStorageKey(key);
|
||||
this.objects.set(key, Buffer.from(body));
|
||||
}
|
||||
|
||||
async get(key: string): Promise<Buffer> {
|
||||
assertStorageKey(key);
|
||||
const value = this.objects.get(key);
|
||||
if (!value) throw new AdapterError("NOT_FOUND", "Arquivo não encontrado.", 404);
|
||||
return Buffer.from(value);
|
||||
}
|
||||
|
||||
async delete(key: string): Promise<void> {
|
||||
assertStorageKey(key);
|
||||
this.objects.delete(key);
|
||||
}
|
||||
|
||||
async list(prefix: string): Promise<string[]> {
|
||||
return [...this.objects.keys()].filter((key) => key.startsWith(prefix));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user