feat(admin): add image quota management UI on memind_adm 5174
Add image-quota admin pages and API wiring for plan defaults, ledger, and per-user grants, plus local verify scripts and AGENTS.md note that this repo is the sole admin UI surface. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,6 +12,8 @@ import type {
|
||||
CapabilityDefinition,
|
||||
CapabilityMap,
|
||||
InsufficientBalanceDetails,
|
||||
ImageQuotaLedgerEntry,
|
||||
ImageQuotaView,
|
||||
LedgerEntry,
|
||||
LlmConnectionTestResult,
|
||||
LlmExecutorBinding,
|
||||
@@ -1351,3 +1353,51 @@ export async function getUserSubscription(userId: string): Promise<AdminSubscrip
|
||||
);
|
||||
return result.subscription;
|
||||
}
|
||||
|
||||
export async function fetchImageQuotaConfig() {
|
||||
return portalFetch<{ plans: PlanDefinition[] }>('/admin-api/image-quota/config');
|
||||
}
|
||||
|
||||
export async function patchImageQuotaPlan(planType: string, periodImages: number) {
|
||||
return portalFetch<{ ok: boolean; plan: PlanDefinition }>(`/admin-api/image-quota/config/${planType}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ periodImages }),
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchUserImageQuota(userId: string) {
|
||||
return portalFetch<{
|
||||
subscription: AdminSubscription;
|
||||
quota: ImageQuotaView;
|
||||
ledger: ImageQuotaLedgerEntry[];
|
||||
}>(`/admin-api/users/${userId}/image-quota`);
|
||||
}
|
||||
|
||||
export async function grantUserImageQuota(userId: string, delta: number, note = '') {
|
||||
return portalFetch<{
|
||||
ok: boolean;
|
||||
subscription: AdminSubscription;
|
||||
quota: ImageQuotaView;
|
||||
}>(`/admin-api/users/${userId}/image-quota/grant`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ delta, note }),
|
||||
});
|
||||
}
|
||||
|
||||
export async function fetchImageQuotaLedger(params: {
|
||||
userId?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
} = {}) {
|
||||
const q = new URLSearchParams();
|
||||
if (params.userId) q.set('userId', params.userId);
|
||||
if (params.page) q.set('page', String(params.page));
|
||||
if (params.pageSize) q.set('pageSize', String(params.pageSize));
|
||||
return portalFetch<{
|
||||
entries: ImageQuotaLedgerEntry[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
totalPages: number;
|
||||
}>(`/admin-api/image-quota/ledger${q.toString() ? `?${q}` : ''}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user