@fonderie/cli 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fonderie.mjs +22 -0
- package/bin/fonderie.test.mjs +11 -0
- package/package.json +1 -1
package/bin/fonderie.mjs
CHANGED
|
@@ -329,6 +329,9 @@ const ADMIN_PAGES = {
|
|
|
329
329
|
tokens: { path: '/access/tokens', about: 'the admin token verdict + legacy per-brick tokens' },
|
|
330
330
|
log: { path: '/activity/admin-log', about: 'who did what through the surface (--limit, --before)' },
|
|
331
331
|
user: { path: '/users', about: 'look up a user: admin user <email|id> [sessions|history|revoke-sessions|suspend|unsuspend]' },
|
|
332
|
+
catalog: { path: '/catalog', about: 'plans as configured and as stored' },
|
|
333
|
+
subscriber:{ path: '/subscriptions', about: 'admin subscriber <user|workspace> <id> [subscription|wallet|ledger]' },
|
|
334
|
+
audit: { path: '/audit', about: 'events across every workspace (--workspace, --type, --actor, --from, --to, --limit, --cursor)' },
|
|
332
335
|
};
|
|
333
336
|
async function adminCmd() {
|
|
334
337
|
const pageName = argv[1];
|
|
@@ -353,11 +356,28 @@ async function adminCmd() {
|
|
|
353
356
|
const qs = q.toString();
|
|
354
357
|
return adminFetch(sub[0], base + sub[1] + (qs ? `?${qs}` : ''));
|
|
355
358
|
}
|
|
359
|
+
if (pageName === 'subscriber') {
|
|
360
|
+
const type = argv[2]; const id = argv[3]; const verb = argv[4] ?? 'subscription';
|
|
361
|
+
if ((type !== 'user' && type !== 'workspace') || !id) { console.error('fonderie admin subscriber <user|workspace> <id> [subscription|wallet|ledger] [--currency <c>] [--limit <n>]'); process.exit(2); }
|
|
362
|
+
const sub = `/${type}/${encodeURIComponent(id)}`;
|
|
363
|
+
const q = new URLSearchParams(); const cur = arg('--currency', undefined); const lim = arg('--limit', undefined);
|
|
364
|
+
if (cur) q.set('currency', cur); if (lim && verb === 'ledger') q.set('limit', lim);
|
|
365
|
+
const qs = q.toString(); const tail = qs ? `?${qs}` : '';
|
|
366
|
+
if (verb === 'subscription') return adminFetch('GET', `${prefix}/subscriptions${sub}`);
|
|
367
|
+
if (verb === 'wallet') return adminFetch('GET', `${prefix}/wallet${sub}${tail}`);
|
|
368
|
+
if (verb === 'ledger') return adminFetch('GET', `${prefix}/wallet${sub}/ledger${tail}`);
|
|
369
|
+
console.error(`unknown verb "${verb}"`); process.exit(2);
|
|
370
|
+
}
|
|
356
371
|
const q = new URLSearchParams();
|
|
357
372
|
const limit = arg('--limit', undefined);
|
|
358
373
|
const before = arg('--before', undefined);
|
|
359
374
|
if (pageName === 'log' && limit) q.set('limit', limit);
|
|
360
375
|
if (pageName === 'log' && before) q.set('before', before);
|
|
376
|
+
if (pageName === 'audit') {
|
|
377
|
+
for (const [flag, param] of [['--workspace', 'workspaceId'], ['--type', 'type'], ['--actor', 'actorId'], ['--from', 'from'], ['--to', 'to'], ['--limit', 'limit'], ['--cursor', 'cursor']]) {
|
|
378
|
+
const v = arg(flag, undefined); if (v) q.set(param, v);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
361
381
|
const qs = q.toString();
|
|
362
382
|
return adminFetch('GET', prefix + page.path + (qs ? `?${qs}` : ''));
|
|
363
383
|
}
|
|
@@ -459,6 +479,8 @@ else {
|
|
|
459
479
|
manage a live deployment over its admin API — set FONDERIE_ADMIN_URL + FONDERIE_ADMIN_TOKEN
|
|
460
480
|
fonderie admin <attention|manifest|doctor|config|routes|tokens|log> [--limit <n>] [--before <cursor>]
|
|
461
481
|
fonderie admin user <email|id> [sessions|history|revoke-sessions|suspend|unsuspend]
|
|
482
|
+
fonderie admin catalog · admin subscriber <user|workspace> <id> [subscription|wallet|ledger] [--currency <c>]
|
|
483
|
+
fonderie admin audit [--workspace <id>] [--type <t>] [--actor <id>] [--from <iso>] [--to <iso>] [--limit <n>]
|
|
462
484
|
read a deployment's operator surface (@fonderie/admin) — same env; FONDERIE_ADMIN_PREFIX if moved
|
|
463
485
|
|
|
464
486
|
Zero deps. No MCP server. A binary + markdown that runs in any agent harness.`);
|
package/bin/fonderie.test.mjs
CHANGED
|
@@ -147,6 +147,17 @@ await (async () => {
|
|
|
147
147
|
if (!find('GET', '/_admin/users?email=ada%40example.com')) fail('admin user <email>: wrong lookup path');
|
|
148
148
|
if (!find('GET', '/_admin/users/u1/login-history?limit=3')) fail('admin user history: flags not forwarded');
|
|
149
149
|
if (!find('POST', '/_admin/users/u1/suspend')) fail('admin user suspend: wrong request');
|
|
150
|
+
await cli(['admin', 'catalog']);
|
|
151
|
+
await cli(['admin', 'subscriber', 'workspace', 'w1']);
|
|
152
|
+
await cli(['admin', 'subscriber', 'user', 'u1', 'ledger', '--currency', 'eur', '--limit', '7']);
|
|
153
|
+
if (!find('GET', '/_admin/catalog')) fail('admin catalog: wrong path');
|
|
154
|
+
if (!find('GET', '/_admin/subscriptions/workspace/w1')) fail('admin subscriber: wrong path');
|
|
155
|
+
if (!find('GET', '/_admin/wallet/user/u1/ledger?currency=eur&limit=7')) fail('admin subscriber ledger: flags not forwarded');
|
|
156
|
+
await cli(['admin', 'audit', '--workspace', 'w1', '--type', 'user.login', '--limit', '9']);
|
|
157
|
+
if (!find('GET', '/_admin/audit?workspaceId=w1&type=user.login&limit=9')) fail('admin audit: flags not forwarded');
|
|
158
|
+
let badType = 0;
|
|
159
|
+
try { await cli(['admin', 'subscriber', 'team', 'x']); } catch (e) { badType = e.code; }
|
|
160
|
+
if (badType !== 2) fail(`admin subscriber <bad type> should exit 2, got ${badType}`);
|
|
150
161
|
let needsId = 0;
|
|
151
162
|
try { await cli(['admin', 'user', 'ada@example.com', 'suspend']); } catch (e) { needsId = e.code; }
|
|
152
163
|
if (needsId !== 2) fail(`admin user <email> suspend should exit 2, got ${needsId}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonderie/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The Fonderie CLI — teaches any coding agent the SDK without loading it eagerly. `fonderie skill` writes a lazy skill (a small router + per-package bodies read on demand); `fonderie query` answers what to install for a capability. Zero deps, runs anywhere.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fonderiejs",
|