Skip to main content

createStoredLimitResolver

@forge/monorepo


@forge/monorepo / backend/src / createStoredLimitResolver

Function: createStoredLimitResolver()

createStoredLimitResolver(deps): (context, about) => Promise<readonly QuotaLimits[]>

Defined in: backend/src/usage/quota.ts:661

resolveLimits backed by the admin-configured store — #175.

The guard already took resolveLimits as a function so limits could change without a redeploy. What was missing was anything to resolve them from: every deployment had to hardcode them, which is not a configuration.

Per-person first, tenant default second, unbounded last. The store decides which row applies; this decides what to do when a person has no override — and it deliberately does not fall back to checking the tenant default against the person's own usage. That would compare a tenant-sized allowance to one person's spend, so nobody would ever hit it and the limit would silently do nothing.

So the resolved limit carries the grain it was configured at, and the guard reads the matching rollup. A limit and the usage it is compared against have to be the same shape, and this is the one place that can guarantee it.

Parameters

deps

limits

UsageLimitStore

Returns

(context, about) => Promise<readonly QuotaLimits[]>