faces-cli 1.5.12 → 1.5.14

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/dist/client.js CHANGED
@@ -43,7 +43,12 @@ export class FacesClient {
43
43
  try {
44
44
  const body = await resp.json();
45
45
  const raw = body.detail ?? body.error ?? body.message ?? msg;
46
- msg = typeof raw === 'object' ? JSON.stringify(raw) : String(raw);
46
+ if (typeof raw === 'object' && raw !== null && 'message' in raw) {
47
+ msg = String(raw.message);
48
+ }
49
+ else {
50
+ msg = typeof raw === 'object' ? JSON.stringify(raw) : String(raw);
51
+ }
47
52
  }
48
53
  catch {
49
54
  // use statusText
@@ -11,7 +11,7 @@ export default class AuthRefresh extends BaseCommand {
11
11
  const client = this.makeClient(flags);
12
12
  let data;
13
13
  try {
14
- data = (await client.post('/v1/auth/refresh', { requireJwt: true }));
14
+ data = (await client.post('/auth/refresh', { requireJwt: true }));
15
15
  }
16
16
  catch (err) {
17
17
  if (err instanceof FacesAPIError)
@@ -15,9 +15,15 @@ export default class BillingUsage extends BaseCommand {
15
15
  async run() {
16
16
  const { flags } = await this.parse(BillingUsage);
17
17
  const client = this.makeClient(flags);
18
+ const groupByMap = {
19
+ api_key: 'api_key_id',
20
+ model: 'llm_model',
21
+ llm: 'llm_model',
22
+ date: 'date',
23
+ };
18
24
  const params = {};
19
25
  if (flags['group-by'])
20
- params.group_by = flags['group-by'];
26
+ params.group_by = groupByMap[flags['group-by']] ?? flags['group-by'];
21
27
  if (flags.from)
22
28
  params.from = flags.from;
23
29
  if (flags.to)
@@ -0,0 +1,10 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ export default class FaceAttributes 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
+ };
9
+ run(): Promise<unknown>;
10
+ }
@@ -0,0 +1,30 @@
1
+ import { BaseCommand } from '../../base.js';
2
+ import { FacesAPIError } from '../../client.js';
3
+ export default class FaceAttributes extends BaseCommand {
4
+ static description = 'List all supported attribute keys';
5
+ static flags = {
6
+ ...BaseCommand.baseFlags,
7
+ };
8
+ async run() {
9
+ const { flags } = await this.parse(FaceAttributes);
10
+ const client = this.makeClient(flags);
11
+ let data;
12
+ try {
13
+ data = await client.get('/v1/faces/attributes');
14
+ }
15
+ catch (err) {
16
+ if (err instanceof FacesAPIError)
17
+ this.error(`Error (${err.statusCode}): ${err.message}`);
18
+ throw err;
19
+ }
20
+ if (!this.jsonEnabled()) {
21
+ const response = data;
22
+ for (const category of response.data) {
23
+ this.log(`\n${category.name}`);
24
+ this.log(` ${category.facts.join(', ')}`);
25
+ }
26
+ this.log('');
27
+ }
28
+ return data;
29
+ }
30
+ }
@@ -25,6 +25,8 @@ export default class FaceCreate extends BaseCommand {
25
25
  const payload = { name: flags.name, alias: flags.alias };
26
26
  if (flags.formula) {
27
27
  payload.formula = flags.formula;
28
+ if (flags['default-model'])
29
+ payload.default_model = flags['default-model'];
28
30
  }
29
31
  else {
30
32
  const parsedAttrs = {};
@@ -51,6 +53,10 @@ export default class FaceCreate extends BaseCommand {
51
53
  throw err;
52
54
  }
53
55
  const face = data;
56
+ if (Array.isArray(face.warnings) && face.warnings.length > 0) {
57
+ for (const w of face.warnings)
58
+ this.warn(w);
59
+ }
54
60
  if (face.basic_facts && typeof face.basic_facts === 'object') {
55
61
  face.basic_facts = flattenBasicFacts(face.basic_facts);
56
62
  }
@@ -66,6 +66,10 @@ export default class FaceUpdate extends BaseCommand {
66
66
  }
67
67
  }
68
68
  const face = data;
69
+ if (Array.isArray(face.warnings) && face.warnings.length > 0) {
70
+ for (const w of face.warnings)
71
+ this.warn(w);
72
+ }
69
73
  if (face.basic_facts && typeof face.basic_facts === 'object') {
70
74
  face.basic_facts = flattenBasicFacts(face.basic_facts);
71
75
  }
@@ -25,7 +25,7 @@ export default class KeysCreate extends BaseCommand {
25
25
  payload.allowed_models = flags.model;
26
26
  let data;
27
27
  try {
28
- data = await client.post('/v1/api-keys', { requireJwt: true, body: payload });
28
+ data = await client.post('/v1/auth/api-keys', { requireJwt: true, body: payload });
29
29
  }
30
30
  catch (err) {
31
31
  if (err instanceof FacesAPIError)
@@ -10,7 +10,7 @@ export default class KeysList extends BaseCommand {
10
10
  const client = this.makeClient(flags);
11
11
  let data;
12
12
  try {
13
- data = await client.get('/v1/api-keys', { requireJwt: true });
13
+ data = await client.get('/v1/auth/api-keys', { requireJwt: true });
14
14
  }
15
15
  catch (err) {
16
16
  if (err instanceof FacesAPIError)
@@ -21,7 +21,7 @@ export default class KeysRevoke extends BaseCommand {
21
21
  }
22
22
  let data;
23
23
  try {
24
- data = await client.delete(`/v1/api-keys/${args.key_id}`, { requireJwt: true });
24
+ data = await client.delete(`/v1/auth/api-keys/${args.key_id}`, { requireJwt: true });
25
25
  }
26
26
  catch (err) {
27
27
  if (err instanceof FacesAPIError)
@@ -26,7 +26,7 @@ export default class KeysUpdate extends BaseCommand {
26
26
  this.error('Provide at least one field to update.');
27
27
  let data;
28
28
  try {
29
- data = await client.patch(`/v1/api-keys/${args.key_id}`, { requireJwt: true, body: payload });
29
+ data = await client.patch(`/v1/auth/api-keys/${args.key_id}`, { requireJwt: true, body: payload });
30
30
  }
31
31
  catch (err) {
32
32
  if (err instanceof FacesAPIError)