MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchStorageInfo

Function fetchStorageInfo

apps/sim/hooks/queries/workspace-files.ts:248–268  ·  view source on GitHub ↗

* Fetch storage info from API

(signal?: AbortSignal)

Source from the content-addressed store, hash-verified

246 * Fetch storage info from API
247 */
248async function fetchStorageInfo(signal?: AbortSignal): Promise<StorageInfo | null> {
249 try {
250 const data = await requestJson(getUsageLimitsContract, { signal })
251
252 if (data.success && data.storage) {
253 return {
254 usedBytes: data.storage.usedBytes,
255 limitBytes: data.storage.limitBytes,
256 percentUsed: data.storage.percentUsed,
257 plan: data.usage?.plan || 'free',
258 }
259 }
260
261 return null
262 } catch (error) {
263 if (isApiClientError(error) && error.status === 404) {
264 return null
265 }
266 throw error
267 }
268}
269
270/**
271 * Hook to fetch storage info

Callers 1

useStorageInfoFunction · 0.85

Calls 2

requestJsonFunction · 0.90
isApiClientErrorFunction · 0.90

Tested by

no test coverage detected