feat!: client storage is read-only, storage.save and storage.delete removed
This commit is contained in:
@@ -15,7 +15,6 @@ export interface RecordedRequest {
|
||||
export interface FakeGatewayState {
|
||||
storage: Map<string, StorageItem>;
|
||||
currencies: CatalogCurrency[];
|
||||
/** Response per `module/fn`; falls back to `{ result: {} }`. */
|
||||
moduleCalls: Map<string, CallModuleFunctionClientResponse>;
|
||||
}
|
||||
|
||||
@@ -32,7 +31,6 @@ function json(body: unknown, status = 200): Response {
|
||||
});
|
||||
}
|
||||
|
||||
const noContent = (): Response => new Response(null, { status: 204 });
|
||||
|
||||
export function createFakeGateway(seed?: Partial<FakeGatewayState>): FakeGateway {
|
||||
const state: FakeGatewayState = {
|
||||
@@ -79,19 +77,6 @@ export function createFakeGateway(seed?: Partial<FakeGatewayState>): FakeGateway
|
||||
);
|
||||
return json({ items, nextCursor: '' });
|
||||
}
|
||||
if (method === 'PUT') {
|
||||
const items = (body as { items?: StorageItem[] }).items ?? [];
|
||||
for (const item of items) {
|
||||
if (item.type) state.storage.set(item.type, { id: `id-${item.type}`, ...item });
|
||||
}
|
||||
return noContent();
|
||||
}
|
||||
if (method === 'DELETE') {
|
||||
const type = query.get('type');
|
||||
if (type) state.storage.delete(type);
|
||||
else state.storage.clear();
|
||||
return noContent();
|
||||
}
|
||||
}
|
||||
|
||||
return json({ error: `unhandled route: ${method} ${path}` }, 500);
|
||||
|
||||
Reference in New Issue
Block a user