| 782 | |
| 783 | // Mock DurableObjectStorage - simple Map-based implementation |
| 784 | class MockDurableObjectStorage { |
| 785 | private data = new Map<string, any>(); |
| 786 | |
| 787 | async get<T>(key: string): Promise<T | undefined>; |
| 788 | async get<T>(keys: string[]): Promise<Map<string, T>>; |
| 789 | async get<T>( |
| 790 | keyOrKeys: string | string[], |
| 791 | ): Promise<T | undefined | Map<string, T>> { |
| 792 | if (Array.isArray(keyOrKeys)) { |
| 793 | const result = new Map<string, T>(); |
| 794 | for (const key of keyOrKeys) { |
| 795 | const value = this.data.get(key); |
| 796 | if (value !== undefined) result.set(key, value); |
| 797 | } |
| 798 | return result; |
| 799 | } |
| 800 | return this.data.get(keyOrKeys); |
| 801 | } |
| 802 | |
| 803 | async put(entries: Record<string, any>): Promise<void> { |
| 804 | for (const [key, value] of Object.entries(entries)) { |
| 805 | this.data.set(key, value); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | async list<T>(options?: {prefix?: string}): Promise<Map<string, T>> { |
| 810 | const result = new Map<string, T>(); |
| 811 | const prefix = options?.prefix ?? ''; |
| 812 | for (const [key, value] of this.data.entries()) { |
| 813 | if (key.startsWith(prefix)) { |
| 814 | result.set(key, value); |
| 815 | } |
| 816 | } |
| 817 | return result; |
| 818 | } |
| 819 | |
| 820 | async delete(key: string): Promise<boolean> { |
| 821 | return this.data.delete(key); |
| 822 | } |
| 823 | |
| 824 | clear(): void { |
| 825 | this.data.clear(); |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | const STORAGE_PREFIX = 'tinybase_'; |
| 830 | const T = 't'; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…