@faces-sh/cli 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +158 -2
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/base.d.ts +26 -0
- package/dist/base.js +181 -0
- package/dist/benchmark.d.ts +21 -0
- package/dist/benchmark.js +95 -0
- package/dist/billing.d.ts +17 -0
- package/dist/billing.js +101 -0
- package/dist/catalog.d.ts +35 -0
- package/dist/catalog.js +242 -0
- package/dist/client.d.ts +98 -0
- package/dist/client.js +590 -0
- package/dist/commands/account/preferences.d.ts +20 -0
- package/dist/commands/account/preferences.js +190 -0
- package/dist/commands/account/state.d.ts +11 -0
- package/dist/commands/account/state.js +24 -0
- package/dist/commands/auth/connect.d.ts +17 -0
- package/dist/commands/auth/connect.js +190 -0
- package/dist/commands/auth/connections.d.ts +12 -0
- package/dist/commands/auth/connections.js +40 -0
- package/dist/commands/auth/disconnect.d.ts +15 -0
- package/dist/commands/auth/disconnect.js +49 -0
- package/dist/commands/auth/login.d.ts +13 -0
- package/dist/commands/auth/login.js +42 -0
- package/dist/commands/auth/logout.d.ts +11 -0
- package/dist/commands/auth/logout.js +14 -0
- package/dist/commands/auth/refresh.d.ts +11 -0
- package/dist/commands/auth/refresh.js +30 -0
- package/dist/commands/auth/register.d.ts +15 -0
- package/dist/commands/auth/register.js +98 -0
- package/dist/commands/auth/whoami.d.ts +11 -0
- package/dist/commands/auth/whoami.js +108 -0
- package/dist/commands/benchmark/get.d.ts +16 -0
- package/dist/commands/benchmark/get.js +42 -0
- package/dist/commands/benchmark/list.d.ts +13 -0
- package/dist/commands/benchmark/list.js +47 -0
- package/dist/commands/benchmark/start.d.ts +22 -0
- package/dist/commands/benchmark/start.js +80 -0
- package/dist/commands/billing/balance.d.ts +11 -0
- package/dist/commands/billing/balance.js +27 -0
- package/dist/commands/billing/card/default.d.ts +15 -0
- package/dist/commands/billing/card/default.js +33 -0
- package/dist/commands/billing/card/remove.d.ts +16 -0
- package/dist/commands/billing/card/remove.js +41 -0
- package/dist/commands/billing/card-setup.d.ts +13 -0
- package/dist/commands/billing/card-setup.js +41 -0
- package/dist/commands/billing/cards.d.ts +11 -0
- package/dist/commands/billing/cards.js +34 -0
- package/dist/commands/billing/llm-costs.d.ts +14 -0
- package/dist/commands/billing/llm-costs.js +95 -0
- package/dist/commands/billing/subscription/activate.d.ts +14 -0
- package/dist/commands/billing/subscription/activate.js +91 -0
- package/dist/commands/billing/subscription/cancel.d.ts +12 -0
- package/dist/commands/billing/subscription/cancel.js +54 -0
- package/dist/commands/billing/subscription/index.d.ts +11 -0
- package/dist/commands/billing/subscription/index.js +46 -0
- package/dist/commands/billing/subscription/plan.d.ts +16 -0
- package/dist/commands/billing/subscription/plan.js +86 -0
- package/dist/commands/billing/topup.d.ts +16 -0
- package/dist/commands/billing/topup.js +60 -0
- package/dist/commands/billing/usage.d.ts +15 -0
- package/dist/commands/billing/usage.js +68 -0
- package/dist/commands/catalog/backup.d.ts +11 -0
- package/dist/commands/catalog/backup.js +169 -0
- package/dist/commands/catalog/doctor.d.ts +14 -0
- package/dist/commands/catalog/doctor.js +303 -0
- package/dist/commands/catalog/list.d.ts +11 -0
- package/dist/commands/catalog/list.js +39 -0
- package/dist/commands/catalog/restore.d.ts +17 -0
- package/dist/commands/catalog/restore.js +259 -0
- package/dist/commands/causes.d.ts +27 -0
- package/dist/commands/causes.js +135 -0
- package/dist/commands/chat/chat.d.ts +42 -0
- package/dist/commands/chat/chat.js +363 -0
- package/dist/commands/chat/messages.d.ts +26 -0
- package/dist/commands/chat/messages.js +139 -0
- package/dist/commands/chat/responses.d.ts +27 -0
- package/dist/commands/chat/responses.js +150 -0
- package/dist/commands/chat/thread.d.ts +43 -0
- package/dist/commands/chat/thread.js +458 -0
- package/dist/commands/compile/all.d.ts +14 -0
- package/dist/commands/compile/all.js +186 -0
- package/dist/commands/compile/doc/create.d.ts +19 -0
- package/dist/commands/compile/doc/create.js +58 -0
- package/dist/commands/compile/doc/delete.d.ts +15 -0
- package/dist/commands/compile/doc/delete.js +33 -0
- package/dist/commands/compile/doc/edit.d.ts +19 -0
- package/dist/commands/compile/doc/edit.js +59 -0
- package/dist/commands/compile/doc/get.d.ts +15 -0
- package/dist/commands/compile/doc/get.js +43 -0
- package/dist/commands/compile/doc/index.d.ts +24 -0
- package/dist/commands/compile/doc/index.js +211 -0
- package/dist/commands/compile/doc/list.d.ts +15 -0
- package/dist/commands/compile/doc/list.js +46 -0
- package/dist/commands/compile/doc/make.d.ts +17 -0
- package/dist/commands/compile/doc/make.js +95 -0
- package/dist/commands/compile/doc/pause.d.ts +17 -0
- package/dist/commands/compile/doc/pause.js +74 -0
- package/dist/commands/compile/doc/reset.d.ts +15 -0
- package/dist/commands/compile/doc/reset.js +33 -0
- package/dist/commands/compile/import.d.ts +20 -0
- package/dist/commands/compile/import.js +138 -0
- package/dist/commands/compile/stats.d.ts +11 -0
- package/dist/commands/compile/stats.js +75 -0
- package/dist/commands/compile/status.d.ts +17 -0
- package/dist/commands/compile/status.js +110 -0
- package/dist/commands/compile/thread/create.d.ts +16 -0
- package/dist/commands/compile/thread/create.js +42 -0
- package/dist/commands/compile/thread/delete.d.ts +15 -0
- package/dist/commands/compile/thread/delete.js +33 -0
- package/dist/commands/compile/thread/edit.d.ts +19 -0
- package/dist/commands/compile/thread/edit.js +120 -0
- package/dist/commands/compile/thread/get.d.ts +15 -0
- package/dist/commands/compile/thread/get.js +48 -0
- package/dist/commands/compile/thread/list.d.ts +14 -0
- package/dist/commands/compile/thread/list.js +38 -0
- package/dist/commands/compile/thread/make.d.ts +17 -0
- package/dist/commands/compile/thread/make.js +87 -0
- package/dist/commands/compile/thread/message.d.ts +16 -0
- package/dist/commands/compile/thread/message.js +43 -0
- package/dist/commands/compile/thread/pause.d.ts +17 -0
- package/dist/commands/compile/thread/pause.js +75 -0
- package/dist/commands/compile/thread/replace.d.ts +27 -0
- package/dist/commands/compile/thread/replace.js +114 -0
- package/dist/commands/compile/thread/reset.d.ts +15 -0
- package/dist/commands/compile/thread/reset.js +33 -0
- package/dist/commands/compile/upload.d.ts +21 -0
- package/dist/commands/compile/upload.js +162 -0
- package/dist/commands/config/clear.d.ts +12 -0
- package/dist/commands/config/clear.js +17 -0
- package/dist/commands/config/set.d.ts +15 -0
- package/dist/commands/config/set.js +43 -0
- package/dist/commands/config/show.d.ts +11 -0
- package/dist/commands/config/show.js +19 -0
- package/dist/commands/decide.d.ts +35 -0
- package/dist/commands/decide.js +242 -0
- package/dist/commands/face/attributes.d.ts +11 -0
- package/dist/commands/face/attributes.js +44 -0
- package/dist/commands/face/avatar/delete.d.ts +15 -0
- package/dist/commands/face/avatar/delete.js +38 -0
- package/dist/commands/face/avatar/get.d.ts +20 -0
- package/dist/commands/face/avatar/get.js +100 -0
- package/dist/commands/face/avatar/list.d.ts +14 -0
- package/dist/commands/face/avatar/list.js +56 -0
- package/dist/commands/face/avatar/make.d.ts +16 -0
- package/dist/commands/face/avatar/make.js +64 -0
- package/dist/commands/face/avatar/upload.d.ts +15 -0
- package/dist/commands/face/avatar/upload.js +67 -0
- package/dist/commands/face/create.d.ts +23 -0
- package/dist/commands/face/create.js +122 -0
- package/dist/commands/face/delete.d.ts +15 -0
- package/dist/commands/face/delete.js +39 -0
- package/dist/commands/face/diff.d.ts +12 -0
- package/dist/commands/face/diff.js +50 -0
- package/dist/commands/face/edit.d.ts +25 -0
- package/dist/commands/face/edit.js +155 -0
- package/dist/commands/face/get.d.ts +16 -0
- package/dist/commands/face/get.js +145 -0
- package/dist/commands/face/groups.d.ts +15 -0
- package/dist/commands/face/groups.js +34 -0
- package/dist/commands/face/list.d.ts +23 -0
- package/dist/commands/face/list.js +168 -0
- package/dist/commands/face/lock.d.ts +15 -0
- package/dist/commands/face/lock.js +35 -0
- package/dist/commands/face/neighbors.d.ts +16 -0
- package/dist/commands/face/neighbors.js +63 -0
- package/dist/commands/face/publish.d.ts +16 -0
- package/dist/commands/face/publish.js +42 -0
- package/dist/commands/face/share.d.ts +22 -0
- package/dist/commands/face/share.js +103 -0
- package/dist/commands/face/sources.d.ts +21 -0
- package/dist/commands/face/sources.js +169 -0
- package/dist/commands/face/stats.d.ts +12 -0
- package/dist/commands/face/stats.js +46 -0
- package/dist/commands/face/tag/add.d.ts +15 -0
- package/dist/commands/face/tag/add.js +40 -0
- package/dist/commands/face/tag/all.d.ts +11 -0
- package/dist/commands/face/tag/all.js +31 -0
- package/dist/commands/face/tag/list.d.ts +14 -0
- package/dist/commands/face/tag/list.js +36 -0
- package/dist/commands/face/tag/remove.d.ts +16 -0
- package/dist/commands/face/tag/remove.js +44 -0
- package/dist/commands/face/tag/set.d.ts +15 -0
- package/dist/commands/face/tag/set.js +40 -0
- package/dist/commands/face/unlock.d.ts +15 -0
- package/dist/commands/face/unlock.js +35 -0
- package/dist/commands/face/unpublish.d.ts +14 -0
- package/dist/commands/face/unpublish.js +31 -0
- package/dist/commands/face/unshare.d.ts +18 -0
- package/dist/commands/face/unshare.js +66 -0
- package/dist/commands/fidelity/get.d.ts +15 -0
- package/dist/commands/fidelity/get.js +42 -0
- package/dist/commands/fidelity/pick.d.ts +19 -0
- package/dist/commands/fidelity/pick.js +70 -0
- package/dist/commands/fidelity/run.d.ts +20 -0
- package/dist/commands/fidelity/run.js +99 -0
- package/dist/commands/fidelity/save-thread.d.ts +15 -0
- package/dist/commands/fidelity/save-thread.js +35 -0
- package/dist/commands/fidelity/start.d.ts +17 -0
- package/dist/commands/fidelity/start.js +56 -0
- package/dist/commands/fidelity/turn.d.ts +17 -0
- package/dist/commands/fidelity/turn.js +48 -0
- package/dist/commands/group/add.d.ts +16 -0
- package/dist/commands/group/add.js +83 -0
- package/dist/commands/group/create.d.ts +16 -0
- package/dist/commands/group/create.js +68 -0
- package/dist/commands/group/delete.d.ts +15 -0
- package/dist/commands/group/delete.js +39 -0
- package/dist/commands/group/edit.d.ts +18 -0
- package/dist/commands/group/edit.js +75 -0
- package/dist/commands/group/get.d.ts +14 -0
- package/dist/commands/group/get.js +29 -0
- package/dist/commands/group/list.d.ts +11 -0
- package/dist/commands/group/list.js +39 -0
- package/dist/commands/group/members.d.ts +15 -0
- package/dist/commands/group/members.js +68 -0
- package/dist/commands/group/remove.d.ts +15 -0
- package/dist/commands/group/remove.js +55 -0
- package/dist/commands/group/tag/add.d.ts +15 -0
- package/dist/commands/group/tag/add.js +30 -0
- package/dist/commands/group/tag/list.d.ts +14 -0
- package/dist/commands/group/tag/list.js +36 -0
- package/dist/commands/group/tag/remove.d.ts +15 -0
- package/dist/commands/group/tag/remove.js +30 -0
- package/dist/commands/group/tag/set.d.ts +15 -0
- package/dist/commands/group/tag/set.js +30 -0
- package/dist/commands/keys/create.d.ts +17 -0
- package/dist/commands/keys/create.js +72 -0
- package/dist/commands/keys/list.d.ts +11 -0
- package/dist/commands/keys/list.js +24 -0
- package/dist/commands/keys/revoke.d.ts +15 -0
- package/dist/commands/keys/revoke.js +49 -0
- package/dist/commands/keys/update.d.ts +17 -0
- package/dist/commands/keys/update.js +41 -0
- package/dist/commands/models/list.d.ts +15 -0
- package/dist/commands/models/list.js +98 -0
- package/dist/commands/session/close.d.ts +16 -0
- package/dist/commands/session/close.js +36 -0
- package/dist/commands/session/compact.d.ts +15 -0
- package/dist/commands/session/compact.js +58 -0
- package/dist/commands/session/create.d.ts +15 -0
- package/dist/commands/session/create.js +45 -0
- package/dist/commands/session/get.d.ts +15 -0
- package/dist/commands/session/get.js +34 -0
- package/dist/commands/style/delete.d.ts +19 -0
- package/dist/commands/style/delete.js +92 -0
- package/dist/commands/style/make.d.ts +28 -0
- package/dist/commands/style/make.js +298 -0
- package/dist/commands/style/revert.d.ts +17 -0
- package/dist/commands/style/revert.js +66 -0
- package/dist/commands/style/status.d.ts +20 -0
- package/dist/commands/style/status.js +109 -0
- package/dist/commands/style/upload.d.ts +19 -0
- package/dist/commands/style/upload.js +100 -0
- package/dist/commands/style/versions.d.ts +15 -0
- package/dist/commands/style/versions.js +104 -0
- package/dist/commands/user/follow.d.ts +14 -0
- package/dist/commands/user/follow.js +38 -0
- package/dist/commands/user/followers.d.ts +14 -0
- package/dist/commands/user/followers.js +50 -0
- package/dist/commands/user/following.d.ts +14 -0
- package/dist/commands/user/following.js +50 -0
- package/dist/commands/user/get.d.ts +14 -0
- package/dist/commands/user/get.js +49 -0
- package/dist/commands/user/unfollow.d.ts +14 -0
- package/dist/commands/user/unfollow.js +38 -0
- package/dist/config.d.ts +32 -0
- package/dist/config.js +139 -0
- package/dist/decisions.d.ts +42 -0
- package/dist/decisions.js +262 -0
- package/dist/fidelity.d.ts +50 -0
- package/dist/fidelity.js +92 -0
- package/dist/group-catalog.d.ts +22 -0
- package/dist/group-catalog.js +133 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.js +8 -0
- package/dist/poll.d.ts +26 -0
- package/dist/poll.js +75 -0
- package/dist/routing.d.ts +15 -0
- package/dist/routing.js +135 -0
- package/dist/session.d.ts +14 -0
- package/dist/session.js +18 -0
- package/dist/style.d.ts +46 -0
- package/dist/style.js +285 -0
- package/dist/utils.d.ts +149 -0
- package/dist/utils.js +865 -0
- package/oclif.manifest.json +11070 -0
- package/package.json +127 -4
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { seg } from '../../utils.js';
|
|
5
|
+
const REASONS = {
|
|
6
|
+
unpublished_or_unshared: 'access was revoked by its owner',
|
|
7
|
+
deleted: 'the face was deleted',
|
|
8
|
+
};
|
|
9
|
+
export default class GroupMembers extends BaseCommand {
|
|
10
|
+
static description = 'List members of a group. A member you do not own can stop being reachable if its owner revokes ' +
|
|
11
|
+
'access or deletes it; those are listed with the reason rather than dropped.';
|
|
12
|
+
static examples = ['<%= config.bin %> <%= command.id %> GROUP_ID', '<%= config.bin %> <%= command.id %> GROUP_ID --json'];
|
|
13
|
+
static flags = {
|
|
14
|
+
...BaseCommand.baseFlags,
|
|
15
|
+
};
|
|
16
|
+
static args = {
|
|
17
|
+
group_id: Args.string({ description: 'Group ID', required: true }),
|
|
18
|
+
};
|
|
19
|
+
async run() {
|
|
20
|
+
const { args, flags } = await this.parse(GroupMembers);
|
|
21
|
+
const client = this.makeClient(flags);
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = await client.get(`/v1/groups/${seg(args.group_id)}/members`);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
if (err instanceof FacesAPIError) {
|
|
28
|
+
if (err.statusCode === 404)
|
|
29
|
+
this.error(`No group '${args.group_id}'. It does not exist, or is not yours.`);
|
|
30
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
31
|
+
}
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
if (this.jsonEnabled())
|
|
35
|
+
return data;
|
|
36
|
+
const members = (data.data ?? data) ?? [];
|
|
37
|
+
if (members.length === 0) {
|
|
38
|
+
this.log('This group has no members.');
|
|
39
|
+
this.log(`Add one with: faces group:add ${args.group_id} --face <alias>`);
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
const rows = members.map((m) => ({
|
|
43
|
+
alias: m.alias?.trim() || '(unknown)',
|
|
44
|
+
status: m.reachable === false
|
|
45
|
+
? `unreachable - ${REASONS[m.unreachable_reason ?? ''] ?? m.unreachable_reason ?? 'reason not given'}`
|
|
46
|
+
: 'ok',
|
|
47
|
+
id: m.iam_id ?? '-',
|
|
48
|
+
}));
|
|
49
|
+
const cols = [
|
|
50
|
+
['FACE', (r) => r.alias],
|
|
51
|
+
['STATUS', (r) => r.status],
|
|
52
|
+
['ID', (r) => r.id],
|
|
53
|
+
];
|
|
54
|
+
const w = cols.map(([h, g]) => Math.max(h.length, ...rows.map((r) => g(r).length)));
|
|
55
|
+
const line = (c) => c.map((x, i) => x.padEnd(w[i])).join(' ').trimEnd();
|
|
56
|
+
this.log(line(cols.map(([h]) => h)));
|
|
57
|
+
for (const r of rows)
|
|
58
|
+
this.log(line(cols.map(([, g]) => g(r))));
|
|
59
|
+
const lost = members.filter((m) => m.reachable === false);
|
|
60
|
+
this.log('');
|
|
61
|
+
this.log(`${rows.length} member(s).`);
|
|
62
|
+
if (lost.length > 0) {
|
|
63
|
+
this.log(`${lost.length} can no longer be reached and will not answer. They are still listed because the ` +
|
|
64
|
+
'group has not changed; remove them with faces group:remove.');
|
|
65
|
+
}
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class GroupRemove extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
+
alias: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { GroupCatalogService } from '../../group-catalog.js';
|
|
5
|
+
import { seg } from '../../utils.js';
|
|
6
|
+
export default class GroupRemove extends BaseCommand {
|
|
7
|
+
static description = 'Remove a face from a group';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
};
|
|
11
|
+
static args = {
|
|
12
|
+
group_id: Args.string({ description: 'Group ID', required: true }),
|
|
13
|
+
alias: Args.string({ description: 'Face alias to remove', required: true }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(GroupRemove);
|
|
17
|
+
const client = this.makeClient(flags);
|
|
18
|
+
let iamId;
|
|
19
|
+
try {
|
|
20
|
+
const face = await client.get(`/v1/faces/${seg(args.alias)}`);
|
|
21
|
+
iamId = (face.uid ?? face.id ?? face.iam_id);
|
|
22
|
+
if (!iamId)
|
|
23
|
+
this.error(`Could not find the owner of face '${args.alias}'.`);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
if (err instanceof FacesAPIError)
|
|
27
|
+
this.error(`Could not resolve '${args.alias}' (HTTP ${err.statusCode}): ${err.message}`);
|
|
28
|
+
throw err;
|
|
29
|
+
}
|
|
30
|
+
let data;
|
|
31
|
+
try {
|
|
32
|
+
data = await client.delete(`/v1/groups/${seg(args.group_id)}/members/${seg(iamId)}`);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
if (err instanceof FacesAPIError)
|
|
36
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const groupCatalog = new GroupCatalogService();
|
|
41
|
+
for (const name of groupCatalog.listGroups()) {
|
|
42
|
+
const group = groupCatalog.readGroup(name);
|
|
43
|
+
if (group?.frontmatter.id === args.group_id) {
|
|
44
|
+
group.frontmatter.members = (group.frontmatter.members ?? []).filter(m => m !== args.alias);
|
|
45
|
+
groupCatalog.writeGroup(name, group.frontmatter, group.body || undefined);
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch { }
|
|
51
|
+
if (!this.jsonEnabled())
|
|
52
|
+
this.log(`Removed ${args.alias} from group.`);
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class GroupTagAdd extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
static args: {
|
|
12
|
+
group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../../client.js';
|
|
4
|
+
import { seg } from '../../../utils.js';
|
|
5
|
+
export default class GroupTagAdd extends BaseCommand {
|
|
6
|
+
static description = 'Add tags to a group (appends, idempotent)';
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
tag: Flags.string({ description: 'Tag to add (repeatable)', multiple: true, required: true }),
|
|
10
|
+
};
|
|
11
|
+
static args = {
|
|
12
|
+
group_id: Args.string({ description: 'Group ID', required: true }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(GroupTagAdd);
|
|
16
|
+
const client = this.makeClient(flags);
|
|
17
|
+
let data;
|
|
18
|
+
try {
|
|
19
|
+
data = await client.post(`/v1/groups/${seg(args.group_id)}/tags`, { body: { tags: flags.tag } });
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (err instanceof FacesAPIError)
|
|
23
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
if (!this.jsonEnabled())
|
|
27
|
+
this.printHuman(data);
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class GroupTagList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<unknown>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../../client.js';
|
|
4
|
+
import { seg } from '../../../utils.js';
|
|
5
|
+
export default class GroupTagList extends BaseCommand {
|
|
6
|
+
static description = 'List tags on a group';
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
};
|
|
10
|
+
static args = {
|
|
11
|
+
group_id: Args.string({ description: 'Group ID', required: true }),
|
|
12
|
+
};
|
|
13
|
+
async run() {
|
|
14
|
+
const { args, flags } = await this.parse(GroupTagList);
|
|
15
|
+
const client = this.makeClient(flags);
|
|
16
|
+
let data;
|
|
17
|
+
try {
|
|
18
|
+
data = await client.get(`/v1/groups/${seg(args.group_id)}/tags`);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (err instanceof FacesAPIError)
|
|
22
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
if (!this.jsonEnabled()) {
|
|
26
|
+
const tags = data.tags ?? [];
|
|
27
|
+
if (tags.length === 0) {
|
|
28
|
+
this.log('(no tags)');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
this.log(tags.join(', '));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class GroupTagRemove extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
static args: {
|
|
11
|
+
group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
+
tag: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../../client.js';
|
|
4
|
+
import { seg } from '../../../utils.js';
|
|
5
|
+
export default class GroupTagRemove extends BaseCommand {
|
|
6
|
+
static description = 'Remove a tag from a group';
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
};
|
|
10
|
+
static args = {
|
|
11
|
+
group_id: Args.string({ description: 'Group ID', required: true }),
|
|
12
|
+
tag: Args.string({ description: 'Tag to remove', required: true }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(GroupTagRemove);
|
|
16
|
+
const client = this.makeClient(flags);
|
|
17
|
+
let data;
|
|
18
|
+
try {
|
|
19
|
+
data = await client.delete(`/v1/groups/${seg(args.group_id)}/tags/${seg(args.tag)}`);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (err instanceof FacesAPIError)
|
|
23
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
if (!this.jsonEnabled())
|
|
27
|
+
this.log(`Removed tag '${args.tag}' from group.`);
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base.js';
|
|
2
|
+
export default class GroupTagSet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
tag: import("@oclif/core/interfaces").OptionFlag<string[], import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
static args: {
|
|
12
|
+
group_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../../client.js';
|
|
4
|
+
import { seg } from '../../../utils.js';
|
|
5
|
+
export default class GroupTagSet extends BaseCommand {
|
|
6
|
+
static description = 'Replace all tags on a group';
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
tag: Flags.string({ description: 'Tag to set (repeatable, replaces all)', multiple: true, required: true }),
|
|
10
|
+
};
|
|
11
|
+
static args = {
|
|
12
|
+
group_id: Args.string({ description: 'Group ID', required: true }),
|
|
13
|
+
};
|
|
14
|
+
async run() {
|
|
15
|
+
const { args, flags } = await this.parse(GroupTagSet);
|
|
16
|
+
const client = this.makeClient(flags);
|
|
17
|
+
let data;
|
|
18
|
+
try {
|
|
19
|
+
data = await client.put(`/v1/groups/${seg(args.group_id)}/tags`, { body: { tags: flags.tag } });
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
if (err instanceof FacesAPIError)
|
|
23
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
if (!this.jsonEnabled())
|
|
27
|
+
this.printHuman(data);
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class KeysCreate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'expires-days': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
budget: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
face: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
model: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
save: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<unknown>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { resolveBaseUrl, saveCredentials } from '../../config.js';
|
|
5
|
+
import { parseBudget } from '../../utils.js';
|
|
6
|
+
export default class KeysCreate extends BaseCommand {
|
|
7
|
+
static description = 'Create a new API key (JWT required). The new key is saved to ~/.faces/config.json as api_key by default; pass --no-save to skip.';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
name: Flags.string({ description: 'Key name/label', required: true }),
|
|
11
|
+
'expires-days': Flags.integer({ description: 'Expiry in days, 1 to 36500 (omit for no expiry)', min: 1, max: 36500 }),
|
|
12
|
+
budget: Flags.string({ description: 'Lifetime spend cap in USD, e.g. 5 or 0.50 (omit for no cap)' }),
|
|
13
|
+
face: Flags.string({
|
|
14
|
+
description: 'Only chat with this face alias (repeatable). Other faces are refused for chat; their details can still be read.',
|
|
15
|
+
multiple: true,
|
|
16
|
+
}),
|
|
17
|
+
model: Flags.string({ description: 'Only use this model (repeatable)', multiple: true }),
|
|
18
|
+
save: Flags.boolean({
|
|
19
|
+
description: 'Save the new key to ~/.faces/config.json as api_key (default: true; use --no-save to skip)',
|
|
20
|
+
default: true,
|
|
21
|
+
allowNo: true,
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
const { flags } = await this.parse(KeysCreate);
|
|
26
|
+
const client = this.makeClient(flags);
|
|
27
|
+
const payload = { name: flags.name };
|
|
28
|
+
if (flags['expires-days'] !== undefined)
|
|
29
|
+
payload.expires_in_days = flags['expires-days'];
|
|
30
|
+
if (flags.budget !== undefined)
|
|
31
|
+
payload.budget_usd = parseBudget(flags.budget, (m) => this.error(m));
|
|
32
|
+
if (flags.face && flags.face.length > 0)
|
|
33
|
+
payload.allowed_face_ids = flags.face;
|
|
34
|
+
if (flags.model && flags.model.length > 0)
|
|
35
|
+
payload.allowed_llm_models = flags.model;
|
|
36
|
+
let data;
|
|
37
|
+
try {
|
|
38
|
+
data = (await client.post('/v1/auth/api-keys', {
|
|
39
|
+
requireJwt: true,
|
|
40
|
+
body: payload,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
if (err instanceof FacesAPIError)
|
|
45
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
const apiKey = (data.key ?? data.api_key ?? data.secret);
|
|
49
|
+
let saved = false;
|
|
50
|
+
if (flags.save && apiKey) {
|
|
51
|
+
saveCredentials({ api_key: apiKey }, resolveBaseUrl(flags['base-url']));
|
|
52
|
+
saved = true;
|
|
53
|
+
}
|
|
54
|
+
if (this.jsonEnabled()) {
|
|
55
|
+
data._saved_to_config = saved;
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
this.printHuman(data);
|
|
59
|
+
this.log('');
|
|
60
|
+
this.log('⚠ The full key is shown only once. `faces keys:list` returns it truncated by design.');
|
|
61
|
+
if (saved) {
|
|
62
|
+
this.log('✓ Saved to ~/.faces/config.json as api_key. Faces commands will use it automatically.');
|
|
63
|
+
}
|
|
64
|
+
else if (!flags.save) {
|
|
65
|
+
this.log(' Not saved (--no-save). Copy the key above now.');
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.warn('Could not find the key in the response. Nothing was saved. Copy it manually.');
|
|
69
|
+
}
|
|
70
|
+
return data;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class KeysList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
import { FacesAPIError } from '../../client.js';
|
|
3
|
+
export default class KeysList extends BaseCommand {
|
|
4
|
+
static description = 'List all API keys (JWT required)';
|
|
5
|
+
static flags = {
|
|
6
|
+
...BaseCommand.baseFlags,
|
|
7
|
+
};
|
|
8
|
+
async run() {
|
|
9
|
+
const { flags } = await this.parse(KeysList);
|
|
10
|
+
const client = this.makeClient(flags);
|
|
11
|
+
let data;
|
|
12
|
+
try {
|
|
13
|
+
data = await client.get('/v1/auth/api-keys', { requireJwt: true });
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
if (err instanceof FacesAPIError)
|
|
17
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
20
|
+
if (!this.jsonEnabled())
|
|
21
|
+
this.printHuman(data);
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class KeysRevoke extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
static args: {
|
|
12
|
+
key_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { loadConfig, saveConfig } from '../../config.js';
|
|
5
|
+
import { seg } from '../../utils.js';
|
|
6
|
+
export default class KeysRevoke extends BaseCommand {
|
|
7
|
+
static description = 'Revoke an API key (JWT required)';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
yes: Flags.boolean({ description: 'Skip confirmation', default: false }),
|
|
11
|
+
};
|
|
12
|
+
static args = {
|
|
13
|
+
key_id: Args.string({ description: 'Key ID', required: true }),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(KeysRevoke);
|
|
17
|
+
const client = this.makeClient(flags);
|
|
18
|
+
await this.confirmOrRefuse(`Revoke key '${args.key_id}'?`, flags.yes);
|
|
19
|
+
const saved = loadConfig().api_key;
|
|
20
|
+
let prefix;
|
|
21
|
+
if (saved) {
|
|
22
|
+
try {
|
|
23
|
+
const listed = (await client.get('/v1/auth/api-keys', { requireJwt: true }));
|
|
24
|
+
const keys = (Array.isArray(listed) ? listed : (listed?.data ?? []));
|
|
25
|
+
prefix = keys.find((k) => k.id === args.key_id)?.key_prefix;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
let data;
|
|
31
|
+
try {
|
|
32
|
+
data = await client.delete(`/v1/auth/api-keys/${seg(args.key_id)}`, { requireJwt: true });
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
if (err instanceof FacesAPIError)
|
|
36
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
const clearedSaved = Boolean(saved && prefix && saved.startsWith(prefix));
|
|
40
|
+
if (clearedSaved)
|
|
41
|
+
saveConfig({ api_key: undefined });
|
|
42
|
+
if (!this.jsonEnabled()) {
|
|
43
|
+
this.printHuman(data);
|
|
44
|
+
if (clearedSaved)
|
|
45
|
+
this.log('This was the API key saved in your config, so it was removed from there too.');
|
|
46
|
+
}
|
|
47
|
+
return clearedSaved ? { ...data, _removed_from_config: true } : data;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class KeysUpdate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
budget: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
'reset-spent': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
static args: {
|
|
14
|
+
key_id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
15
|
+
};
|
|
16
|
+
run(): Promise<unknown>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base.js';
|
|
3
|
+
import { FacesAPIError } from '../../client.js';
|
|
4
|
+
import { seg, parseBudget } from '../../utils.js';
|
|
5
|
+
export default class KeysUpdate extends BaseCommand {
|
|
6
|
+
static description = 'Update API key metadata (JWT required)';
|
|
7
|
+
static flags = {
|
|
8
|
+
...BaseCommand.baseFlags,
|
|
9
|
+
name: Flags.string({ description: 'New key name' }),
|
|
10
|
+
budget: Flags.string({ description: 'New lifetime spend cap in USD, e.g. 5 or 0.50' }),
|
|
11
|
+
'reset-spent': Flags.boolean({ description: 'Reset spent amount to zero', default: false }),
|
|
12
|
+
};
|
|
13
|
+
static args = {
|
|
14
|
+
key_id: Args.string({ description: 'Key ID', required: true }),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const { args, flags } = await this.parse(KeysUpdate);
|
|
18
|
+
const client = this.makeClient(flags);
|
|
19
|
+
const payload = {};
|
|
20
|
+
if (flags.name)
|
|
21
|
+
payload.name = flags.name;
|
|
22
|
+
if (flags.budget !== undefined)
|
|
23
|
+
payload.budget_usd = parseBudget(flags.budget, (m) => this.error(m));
|
|
24
|
+
if (flags['reset-spent'])
|
|
25
|
+
payload.reset_spent = true;
|
|
26
|
+
if (Object.keys(payload).length === 0)
|
|
27
|
+
this.error('Provide at least one field to update.');
|
|
28
|
+
let data;
|
|
29
|
+
try {
|
|
30
|
+
data = await client.patch(`/v1/auth/api-keys/${seg(args.key_id)}`, { requireJwt: true, body: payload });
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
if (err instanceof FacesAPIError)
|
|
34
|
+
this.error(`HTTP ${err.statusCode}: ${err.message}`);
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
if (!this.jsonEnabled())
|
|
38
|
+
this.printHuman(data);
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base.js';
|
|
2
|
+
export default class ModelsList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
kind: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
provider: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
chatgpt: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'base-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
token: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
toon: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<unknown>;
|
|
15
|
+
}
|